Difference between revisions of "Manual:DIL Manual/SFB PRE"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
 
 
Line 1: Line 1:
 +
= SFB_PRE =
 +
Command preprocessing
  
 +
When this flag is set, the program is activated by a few special events
 +
which can then be blocked or changed. Currently, this event is triggered
 +
just prior to a spell being cast, and just prior to any sort of damage
 +
being given to a target.
  
<span id="sfbpre"></span>
+
Examples:
 +
  wait(SFB_PRE, command(CMD_AUTO_DAMAGE));
 +
  wait(SFB_PRE, command("cast"));
  
SFB_PRE            Command preprocessing
+
Assume a a spell is cast from player A on player B with a scroll C.
 
 
  When this flag is set, the program is activated by a few special events
 
  which can then be blocked or changed. Currently, this event is triggered
 
  just prior to a spell being cast, and just prior to any sort of damage
 
  being given to a target.
 
 
 
  PRE "command(CMD_CAST)"
 
 
 
  Assume a a spell is cast from player A on player B with a scroll C.
 
  
 
       'activator'... is a unitptr to A.
 
       'activator'... is a unitptr to A.
Line 18: Line 17:
 
       'target'  ... is a unitptr to B.
 
       'target'  ... is a unitptr to B.
  
       command(CMD_CAST) will evaluate to TRUE.
+
       command("cast") will evaluate to TRUE.
  
 
       'argument'.... will contain a number followed by any
 
       'argument'.... will contain a number followed by any
Line 29: Line 28:
  
 
  Example:
 
  Example:
     wait(SFB_PRE, command(CMD_CAST));
+
     wait(SFB_PRE, command("cast"));
  
 
     s := getword(argument);
 
     s := getword(argument);
Line 39: Line 38:
  
  
   PRE "command(CMD_AUTO_DAMAGE)"
+
   SFB_PRE "command(CMD_AUTO_DAMAGE)"
  
 
   Assume that damage is given from player A to player B with a sword C.
 
   Assume that damage is given from player A to player B with a sword C.

Latest revision as of 18:41, 17 August 2022

SFB_PRE

Command preprocessing

When this flag is set, the program is activated by a few special events which can then be blocked or changed. Currently, this event is triggered just prior to a spell being cast, and just prior to any sort of damage being given to a target.

Examples:

  wait(SFB_PRE, command(CMD_AUTO_DAMAGE));
  wait(SFB_PRE, command("cast"));

Assume a a spell is cast from player A on player B with a scroll C.

     'activator'... is a unitptr to A.
     'medium'   ... is a unitptr to C.
     'target'   ... is a unitptr to B.
     command("cast") will evaluate to TRUE.
     'argument'.... will contain a number followed by any
                    argument to the spell itself. You should
                    parse this number, it equals the spell number SPL_XXX.
     'power' ....   is set to 'HM', i.e. how powerful the spell cast
                    is going to be. YOu can change this number at will.
                    If you decide to block the spell, you ought to set it
                    to -1.
Example:
   wait(SFB_PRE, command("cast"));
   s := getword(argument);
   splno := atoi(s);
   if (splno == SPL_FIREBALL_3)
     power := 0; /* No damage */
   ...


  SFB_PRE "command(CMD_AUTO_DAMAGE)"
  Assume that damage is given from player A to player B with a sword C.
     'activator'... is a unitptr to A.
     'medium'   ... is a unitptr to C.
     'target'   ... is a unitptr to B.
     command(CMD_AUTO_DAMAGE) will evaluate to TRUE.
     'power' ....   is set to how much damage will be given. You can change
                    this number at will, but you should not set it to less
                    than zero.
     'argument'.... will contain three numbers that you must parse to
                    determine what kind of damage we're talking about.
                    First number is the attack group, this can be one of
                    MSG_TYPE_XXX from values.h and/or vme.h.
                    Second number is dependant on the attack group and
                    identifies what damage compared to the group. For
                    example WPN_XXX for weapon group.
                    Third number is the body hit location, one of WEAR_XXX,
                    (but not all of them, just hands, feet, legs, body, head,
                     arms, i.e. the armour positions, not positions like finger
                     or ear).


Example:
   wait(SFB_PRE, command(CMD_AUTO_DAMAGE));
   s1 := getword(argument);
   grpno := atoi(s1);
   s2 := getword(argument);
   atkno := atoi(s2);
   s3 := getword(argument);
   hitloc := atoi(s3);
   if (grpno == MSG_TYPE_SPELL)
   {
      if ((s2 == SPL_FINGER_DEATH))
      {
          act("Your scarabaeus lights up as it protects your life force.");
          power := -1;
          block;
      }
   }
   ...


---~---~---~---~---~---~---~---~---
A note upon activating a DIL program
This is what you can't do:
  If a DIL program is already active, e.g. it is sending a message or
  perhaps using "exec" to perform an action, then it can not be activated.
  Thus, any active DIL program is unable to catch further messages.
  Imagine this setting:
  You have five program P1..P5. P1 sends a message, which is intercepted
  by P2. P2 now sends a message, but since P1 is busy it can not process
  the message. P3..P5 are however possible candidates.
  Assume P3 sends a message, and P4 acts upon it. P4 now sends a message
  and the ONLY program which can catch it is P5, since all the other programs
  are "busy". If P5 sends a message no-one can act upon it. When P5
  returns, so does P4, P3, P2 and finally P1.