Five Gods Exiled — 185 of 191

Carolyn VanEseltine

Release 1

Part 4 - Monster Movement

Definition: a direction (called thataway) is monster-viable if the room thataway from the location of the current monster is a room.

To carry out monster movement:

repeat with temporary monster running through active monsters in Blight rooms:

now the current monster is the temporary monster;

if the temporary monster is not in the location:

if a carving (called the temporary carving) is in the location of the current monster:

DM "(Updating [a temporary carving] to represent [the current monster].)";

now the carving-shape of the temporary carving is the monster name of the current monster;

if the current monster is aware of the player:

let the right direction be the best route from the location of the current monster to the location of the player;

if the right direction is a compass direction:

[ say "[The current monster] is going to move [right direction] (moving towards the player).";]

try the current monster going the right direction;

otherwise:

let the right direction be a random monster-viable compass direction;

[ say "[The current monster] is going to move [right direction] (moving randomly).";]

try the current monster going the right direction.

To decide whether the current monster is aware of the player:

let K be the number of moves from the location of the current monster to the location of the player;

DM "(Checking awareness of [a current monster]. Comparing monster awareness of [eawareness of the current monster] to player stealth of [estealth of the player] with [K] moves between them and a presence count of [presence count of the current monster]. ";

if the eawareness of the current monster is greater than K:

if (the eawareness of the current monster - the estealth of the player + presence count of the current monster) is greater than K:

DM "[The current monster] is aware of the player.)";

decide yes;

otherwise:

DM "[The current monster] is unaware of the player.)";

decide no;

otherwise:

now the presence count of the current monster is 0;

DM "[The current monster] is unaware of the player.)";

decide no.

To decide whether the player is aware of the current monster:

if (the location of the current monster is the location of the player) or (the location of the current monster is adjacent to the location of the player):

let K be the number of moves from the location of the current monster to the location of the player;

if the estealth of the current monster - (the eawareness of the player + presence count of the current monster) > K:

decide no;

otherwise:

decide yes.

Report a monster (called the temporary monster) going a direction (called thataway):

now the current monster is the temporary monster;

if the player is aware of the current monster:

if the location of the temporary monster is the location of the player:

if the current monster is aware of the player:

say the aware arrival text of the current monster instead;

otherwise:

say the unaware arrival text of the current monster instead;

otherwise:

if the current monster is aware of the player:

say the fleeing departure text of the current monster instead;

otherwise:

say the unaware departure text of the current monster instead;

otherwise:

DM "([The current monster] just moved [thataway], but the player is unaware.)"