Intermediate Tutorial: Using Event Trigger - Execute GPDL function

Trap Detection

General:

GPDL scripts offer great flexibility in determining whether an event should fire. Many parameters can be tested in a single script, which may eliminate the need for multiple chained events. It can also improve the game flow by performing tasks without player input.

For example, here is a trap detection script for use with a Chain event.

$VAR index;
$VAR name;
$VAR rnd;
index = 0;
$WHILE (index <# $PARTYSIZE())
 {
  name = $GET_CHAR_NAME(index);
//Find Traps spell active
  $IF ($IS_AFFECTED_BY_SPELL($Name(name),"Find Traps"))
     {
      $SET_PARTY_ACTIVECHAR(index);
      $RETURN 1;
     };
//Thief - Find Traps
  $IF ($GET_CHAR_FINDTRAPS(index) ># 0)
   {
    rnd = $RANDOM(100) +# 1;
    $IF (rnd <=# $GET_CHAR_FINDTRAPS(index))
     {
      $SET_PARTY_ACTIVECHAR(index);
      $RETURN 1;
     };
   };

//Dwarf - Detect traps in stonework
  $IF ($GET_CHAR_RACE(index) == "Dwarf")
   {
    rnd = $RANDOM(100) +# 1;
    $IF (rnd <= 50)
     {
      $SET_PARTY_ACTIVECHAR(index);
      $RETURN 1;
     };
   };

//Gnome - Detect unsafe walls, ceilings, or floors
  $IF ($GET_CHAR_RACE(index) == "Gnome")
   {
    rnd = $RANDOM(100) +# 1;
    $IF (rnd <=# 70)
     {
      $SET_PARTY_ACTIVECHAR(index);
      $RETURN 1;
     };
   };

  index = index +# 1;
 };

Script notes:


Back to Design Tutorials

Back to Designer's Guide Index