home *** CD-ROM | disk | FTP | other *** search
/ CD PowerPlay 6 / TheCompleteAdventureCollection1995 / CDPP6.ISO / utility / agtsrc / animate.pa4 < prev    next >
Encoding:
Text File  |  1989-12-20  |  4.4 KB  |  116 lines

  1.  
  2.  
  3.   { Animate Module }
  4.   {This module contains all creature-specific activity,}
  5.   {such as attacking the player, moving, or taking any }
  6.   {other type of action. It is executed just after the }
  7.   {Execute [user command] procedure. }
  8.  
  9.   PROCEDURE Animate;
  10.   VAR
  11.     i : Integer;
  12.     w : words;
  13.     PROCEDURE CreatureAttacks(i : Integer);
  14.     BEGIN
  15.       WITH M[i]^ DO
  16.         BEGIN
  17.           w := name; Normalize(w);
  18.           WriteLn(IO, ' ');
  19.           WriteLn(IO, 'The ', w, ' seems to calm down for a moment,');
  20.           WriteLn(IO, 'but suddenly attacks.');
  21.           IF gender = Thing THEN  {default creature}
  22.             BEGIN
  23.               WriteLn(IO, 'Its mouth opens to reveal');
  24.               WriteLn(IO, 'teeth grotesquely out of proportion to the rest');
  25.               WriteLn(IO, 'of its body, a fact you notice as those same');
  26.               WriteLn(IO, 'teeth tear your flesh into tiny pieces.');
  27.             END
  28.           ELSE BEGIN              {Man or Woman}
  29.             WriteLn(IO, 'Hands suddenly grasp our throat and begin to');
  30.             WriteLn(IO, 'squeeze and squeeze and squeeze!!');
  31.             WriteLn(IO, 'You fight for breath, but the struggle is in vain.');
  32.           END;
  33.           IF counter >= threshhold THEN
  34.             counter := 0          {reset counter for this creature}
  35.           ELSE
  36.             timecounter := 0;     {reset timecounter for this creature}
  37.         END;
  38.       player_dead := True;
  39.     END;
  40.  
  41.   BEGIN                           { Animate }
  42.     {Update any active counters}
  43.     FOR i := 0 TO MaxCounter DO
  44.       IF counter[i] > 0 THEN counter[i] := counter[i]+1;
  45.     FOR i := First_creature TO MaxCreature DO
  46.       BEGIN
  47.         {act hostile if appropriate}
  48.         {attack player if appropriate}
  49.         WITH M[i]^ DO
  50.           IF ((location = Current_room) AND
  51.               (counter >= threshhold) AND (hostile) AND LightIsHere)
  52.           THEN                    {attack threshhold exceeded!}
  53.             CreatureAttacks(i)
  54.           ELSE                    {check time threshhold}
  55.             IF ((location = Current_room) AND (hostile)
  56.                 AND (timethresh > 0) AND LightIsHere)
  57.             THEN
  58.               BEGIN
  59.                 timecounter := timecounter+1;
  60.                 IF (timecounter = timethresh)
  61.                 THEN
  62.                   CreatureAttacks(i)
  63.                 ELSE
  64.                   BEGIN
  65.                     IF (timecounter > timethresh-3)
  66.                     THEN
  67.                       BEGIN
  68.                         w := name; Normalize(w);
  69.                         WriteLn(IO, '  The ', w, ' seems to be getting angrier!');
  70.                       END;
  71.                   END
  72.               END
  73.             ELSE timecounter := 0;
  74.       END;                        {for i in creatures}
  75.   END;                            {animate}
  76.  
  77.  
  78.   { Check_If_Here (NOUN,OBJECT) }
  79.   {Check if NOUN and OBJECT are here and give error message if not here}
  80.  
  81.   PROCEDURE Check_If_Here(noun, object_word : words);
  82.   VAR
  83.     m_num : Integer;
  84.   BEGIN
  85.     {first check if Noun is here or otherwise implied as here}
  86.     DoNormalCMD := False;         {error condition}
  87.     m_num := Noun_Number(noun);
  88.     Normalize(noun);
  89.     IF (m_num = 0) OR 
  90.     (noun = 'door') OR   
  91.     (noun = 'doors') THEN 
  92.       DoNormalCMD := True         {Implied noun -- so no error condition}
  93.     ELSE                          {check if noun is here}
  94.       IF NOT Is_Visible(m_num) THEN
  95.         WriteLn(IO, 'What ', noun, '?  There ', Is_Or_Are(m_num), ' no ',
  96.                 noun, ' here.')
  97.       ELSE
  98.         DoNormalCMD := True;      {It's here -- so no error condition}
  99.     IF DoNormalCMD THEN
  100.       BEGIN                       {now check if Object is here or otherwise implied as here}
  101.         DoNormalCMD := False;     {error condition}
  102.         m_num := Noun_Number(object_word);
  103.         Normalize(object_word);
  104.         IF (m_num = 0) OR 
  105.         (object_word = 'door') OR
  106.         (object_word = 'doors') THEN
  107.           DoNormalCMD := True     {Implied object -- so no error condition}
  108.         ELSE                      {check if object is here}
  109.           IF NOT Is_Visible(m_num) THEN
  110.             WriteLn(IO, 'What ', object_word, '?  There ', Is_Or_Are(m_num), ' no ',
  111.                     object_word, ' here.')
  112.           ELSE
  113.             DoNormalCMD := True;  {It's here -- so no error condition}
  114.       END;
  115.   END;                            {Check_If_Here}
  116.