Skip to content
fluffymormegil edited this page Sep 13, 2010 · 5 revisions

struct Mon is the class used to represent instantiated monsters in the game.

Data members

mon_id is an index into the permons array, indicating what kind of monster this monster is.

self contains the monster’s lookup tag.

lev contains the lookup tag for the level the monster occupies; pos contains the monster’s position on that level.

ai_lastpos contains the monster’s last memory of the player’s position, and is only used if the player is not visible to the monster.

hpmax and hpcur are used to track the monster’s maximum and current hit points.

Member functions

Mon() is the default constructor, which makes sure that name is null. ~Mon() is the default destructor, which handles releasing any explicit allocations (as opposed to perseffs, whose allocations are implicit).

find_astar_path() and discard_path() are used to manage the monster’s A* path.

can_pass() and will_pass() are for deciding whether the monster is able and/or willing to enter a given square.

in_fov() checks whether the monster is in the player’s field of view. (This is not logically equivalent to being visible, though at the moment there are no exceptions.)

get_name() fills an STL std::string object with a string naming the individual monster.

curses() and incants() are informational fluff emitters used by the “black magic” code.

notice_you() wakes up a monster that has become aware of the player character’s presence.

suffer() applies the over-time effect of a persistent effect to the monster. apply_effect() attempts to attach a new persistent effect to the monster, possibly deleting others in the process.