home *** CD-ROM | disk | FTP | other *** search
-
-
- { Animate Module }
- {This module contains all creature-specific activity,}
- {such as attacking the player, moving, or taking any }
- {other type of action. It is executed just after the }
- {Execute [user command] procedure. }
-
- PROCEDURE Animate;
- VAR
- i : Integer;
- w : words;
- PROCEDURE CreatureAttacks(i : Integer);
- BEGIN
- WITH M[i]^ DO
- BEGIN
- w := name; Normalize(w);
- WriteLn(IO, ' ');
- WriteLn(IO, 'The ', w, ' seems to calm down for a moment,');
- WriteLn(IO, 'but suddenly attacks.');
- IF gender = Thing THEN {default creature}
- BEGIN
- WriteLn(IO, 'Its mouth opens to reveal');
- WriteLn(IO, 'teeth grotesquely out of proportion to the rest');
- WriteLn(IO, 'of its body, a fact you notice as those same');
- WriteLn(IO, 'teeth tear your flesh into tiny pieces.');
- END
- ELSE BEGIN {Man or Woman}
- WriteLn(IO, 'Hands suddenly grasp our throat and begin to');
- WriteLn(IO, 'squeeze and squeeze and squeeze!!');
- WriteLn(IO, 'You fight for breath, but the struggle is in vain.');
- END;
- IF counter >= threshhold THEN
- counter := 0 {reset counter for this creature}
- ELSE
- timecounter := 0; {reset timecounter for this creature}
- END;
- player_dead := True;
- END;
-
- BEGIN { Animate }
- {Update any active counters}
- FOR i := 0 TO MaxCounter DO
- IF counter[i] > 0 THEN counter[i] := counter[i]+1;
- FOR i := First_creature TO MaxCreature DO
- BEGIN
- {act hostile if appropriate}
- {attack player if appropriate}
- WITH M[i]^ DO
- IF ((location = Current_room) AND
- (counter >= threshhold) AND (hostile) AND LightIsHere)
- THEN {attack threshhold exceeded!}
- CreatureAttacks(i)
- ELSE {check time threshhold}
- IF ((location = Current_room) AND (hostile)
- AND (timethresh > 0) AND LightIsHere)
- THEN
- BEGIN
- timecounter := timecounter+1;
- IF (timecounter = timethresh)
- THEN
- CreatureAttacks(i)
- ELSE
- BEGIN
- IF (timecounter > timethresh-3)
- THEN
- BEGIN
- w := name; Normalize(w);
- WriteLn(IO, ' The ', w, ' seems to be getting angrier!');
- END;
- END
- END
- ELSE timecounter := 0;
- END; {for i in creatures}
- END; {animate}
-
-
- { Check_If_Here (NOUN,OBJECT) }
- {Check if NOUN and OBJECT are here and give error message if not here}
-
- PROCEDURE Check_If_Here(noun, object_word : words);
- VAR
- m_num : Integer;
- BEGIN
- {first check if Noun is here or otherwise implied as here}
- DoNormalCMD := False; {error condition}
- m_num := Noun_Number(noun);
- Normalize(noun);
- IF (m_num = 0) OR
- (noun = 'door') OR
- (noun = 'doors') THEN
- DoNormalCMD := True {Implied noun -- so no error condition}
- ELSE {check if noun is here}
- IF NOT Is_Visible(m_num) THEN
- WriteLn(IO, 'What ', noun, '? There ', Is_Or_Are(m_num), ' no ',
- noun, ' here.')
- ELSE
- DoNormalCMD := True; {It's here -- so no error condition}
- IF DoNormalCMD THEN
- BEGIN {now check if Object is here or otherwise implied as here}
- DoNormalCMD := False; {error condition}
- m_num := Noun_Number(object_word);
- Normalize(object_word);
- IF (m_num = 0) OR
- (object_word = 'door') OR
- (object_word = 'doors') THEN
- DoNormalCMD := True {Implied object -- so no error condition}
- ELSE {check if object is here}
- IF NOT Is_Visible(m_num) THEN
- WriteLn(IO, 'What ', object_word, '? There ', Is_Or_Are(m_num), ' no ',
- object_word, ' here.')
- ELSE
- DoNormalCMD := True; {It's here -- so no error condition}
- END;
- END; {Check_If_Here}