Person Functions for Mocha


Determining basic characteristics

boolean pc.awake;
Indicates that the person pc is awake.

boolean pc.is_mobile;
Indicates that the person pc is a mobile.

boolean pc.is_player;
Indicates that the person pc is a player.

boolean pc.is_immortal;
Indicates that the person pc is an immortal player.

boolean pc.is_mortal;
Indicates that the person pc is a mortal player.

boolean pc.is_good;
Indicates that the person pc is of good alignment.

boolean pc.is_neutral;
Indicates that the person pc is of neutral alignment.

boolean pc.is_evil;
Indicates that the person pc is of evil alignment.

boolean pc.wimpy_mode;
Indicates that the person pc uses wimpy mode. Also see wimpy_level for players.


Determining basic player characteristics

boolean pc.is_criminal;
void set_person_criminal (person pc, boolean flag);
Determine or set whether or not the person pc is a criminal.

boolean pc.is_weenie;
void set_person_weenie (person pc, boolean flag);
Determine or set whether or not the person pc is a weenie.

boolean pc.is_perm_death;
void set_person_perm_death (person pc, boolean flag);
Determine or set whether or not the person pc is a worshipper of Thurvun (the penalty for Thurvun worship is deletion upon death).

boolean pc.display_ansi;
Indicates that the person pc uses ANSI in his display.

boolean pc.brief_mode;
Indicates that the person pc uses brief mode.


Determining basic mobile characteristics

boolean pc.is_use_weapons;
void set_person_use_weapons (person pc, boolean flag)
Indicates that the person pc uses weapons.

boolean pc.is_aggressive;
void set_person_aggressive (person pc, boolean flag)
Indicates that the person pc is aggressive.

boolean pc.is_hunter;
void set_person_hunter (person pc, boolean flag)
Indicates that the person pc hunts players.

boolean pc.is_nice_thief;
void set_person_nice_thief (person pc, boolean flag)
Indicates that the person pc tolerates attempted theft.

boolean pc.is_undead;
void set_person_undead (person pc, boolean flag)
Indicates that the person pc is undead.

boolean pc.is_wanderer;
void set_person_wanderer (person pc, boolean flag)
Indicates that the person pc does not wander.


Finding general attributes

object pc.weapon;
Returns the weapon used by the person pc, or none if no weapon is being used.

person pc.opponent;
Returns the opponent of the person pc, or none if pc is not fighting anyone.

person pc.hunting;
Returns the hunting target of the person pc, or none if pc is not hunting.

person pc.leader;
Returns the person pc's leader, or none if pc is not following anyone.

person pc.follower;
Returns the person pc's first follower, or none if pc is not being followed.

person pc.next_follower;
Returns the next follower in a tree of followers. If the person pc has a follower, that person is returned. If not, the function returns the next follower of the pc's leader, if one exists. If the pc has no followers and is either not following anyone or is the last follower in his leader's chain, the function returns the value none.

integer pc.sex;
void set_person_sex (person pc, integer val);
Determine or set the sex of the person pc. The value must be one of the following constants:

integer pc.race;
Returns the race of the person pc as one of the following constants:

integer pc.class;
Returns the class of the person pc as one of the following constants:

integer pc.level;
Returns the level of the person pc.

integer pc.remort;
Returns number of times the person pc has remorted.

integer pc.hunger;
void set_person_hunger (person pc, integer val);
Determine or set the hours remaining until the person pc becomes hungry (returns a value of nothing for immortals).

integer pc.thirst;
void set_person_thirst (person pc, integer val);
Determine or set the hours remaining until the person pc becomes thirsty (returns a value of nothing for immortals).

integer pc.intoxication;
void set_person_intoxication (person pc, integer val);
Determine or set the hours remaining until the person pc becomes unintoxicated (returns a value of nothing for immortals).

integer pc.weight;
Returns the weight of the person pc in pounds.

integer pc.height;
Returns the height of the person pc in inches.

integer pc.alignment;
special change_alignment (person pc, integer delta);
Determine or alter the alignment of the person pc. Alignment always falls in the range -1500 to 1500, so one need never adjust it by more than 3000 to push it to the extreme. Changing the pc's alignment may kill the pc if the pc is currently wearing or using aligned objects. change_alignment returns ignored if the change is not allowed, handled if the change was made and the pc is still alive, and fatal if the pc was killed by the change.

integer pc.xp;
Returns the current XP of the person pc.

integer pc.xp_to_level;
Returns the XP required to advance for the person pc.

integer skill (person pc, integer num);
Returns a person's percentage chance for success in a specified skill. The skill must be taken from the list of available skills. Mobiles are assigned default skills based on their level. Non-zero skill values include any modifiers due to the person's stats (see skill_adjust below).

integer skill_adjust (person pc, integer num);
Returns the modifier to a person's skill due to the person's stats. The skill must be taken from the list of available skills.

integer pc.invis_level;
Returns the invisibility level of the person pc.

integer pc.num_carried;
Returns the number of things carried by the person pc.

integer pc.max_num_carried;
Returns the maximum number of things that the person pc can carry.

integer pc.position;
void set_person_position (person pc, integer val);
integer pc.default_position;
Determine or set the position or default position of the person pc. The position must come from the following list of constants:

integer pc.num_npc_followers;
Returns the number of NPC's following the person pc.

dice pc.base_attack_damage;
Returns the base (weaponless) attack damage for the person pc.

dice pc.attack_damage;
Returns the attack damage for the person pc.

integer pc.armor;
Returns the combat armor modifier for the person pc. This is a the number added to the skill of an attack against the pc and is related to the armor class.

integer pc.attack;
Returns the combat attack skill for the person pc. This is the base skill used in attacking an opponent (not including affects of armor, opponent agility, visibility, etc.).

integer pc.heal_hit_bonus;
integer pc.heal_spell_bonus;
integer pc.heal_favor_bonus;
integer pc.heal_move_bonus;
Returns the typed healing bonus for the person pc.

integer pc.age_bonus;
Returns the age bonus for the person pc.

integer save_chance (person pc, integer type);
Returns the percentage chance for a person to save against a particular type of danger. The type must be one of the following constants:

integer save_bonus (person pc, integer type);
Returns the save bonus of the specified type for a person. The type must be one of those listed above, and the value returned affects the save chance by 4% per point.

integer pc.carried_weight;
Returns the weight of things carried by the person pc.

integer pc.max_carried_weight;
Returns the maximum weight that the person pc can carry.


Checking on points

integer pc.hit_points;
void set_person_hit_points (person pc, integer val);
integer pc.max_hit_points;
integer pc.perm_hit_points;
integer pc.add_hit_points;
Determine the person pc's current, maximum, permanent, or bonus hit points.

integer pc.move_points;
void set_person_move_points (person pc, integer val);
integer pc.max_move_points;
integer pc.perm_move_points;
integer pc.add_move_points;
Determine the person pc's current, maximum, permanent, or bonus movement points.

integer pc.spell_points;
void set_person_spell_points (person pc, integer val);
integer pc.max_spell_points;
integer pc.perm_spell_points;
integer pc.add_spell_points;
Determine the person pc's current, maximum, permanent, or bonus spell points.


Learning stats

integer pc.strength;
integer pc.perm_strength;
integer pc.add_strength;
Determine the person pc's current, permanent, or bonus strength.

integer pc.perception;
integer pc.perm_perception;
integer pc.add_perception;
Determine the person pc's current, permanent, or bonus perception.

integer pc.focus;
integer pc.perm_focus;
integer pc.add_focus;
Determine the person pc's current, permanent, or bonus focus.

integer pc.agility;
integer pc.perm_agility;
integer pc.add_agility;
Determine the person pc's current, permanent, or bonus agility.

integer pc.endurance;
integer pc.perm_endurance;
integer pc.add_endurance;
Determine the person pc's current, permanent, or bonus endurance.

integer pc.willpower;
integer pc.perm_willpower;
integer pc.add_willpower;
Determine the person pc's current, permanent, or bonus willpower.

integer pc.speed;
integer pc.perm_speed;
integer pc.add_speed;
Determine the person pc's current, permanent, or bonus speed.


Dealing with affects

boolean is_affected (entity ent, integer type);
Returns true if an entity is marked with a timed effect of the specified type. The type must be a damage type constant.

void add_modifier (entity ent, integer type, integer duration, integer effect, integer amount, boolean avg_time, boolean avg_mod);
Merge an affect or modifier into the those already on the entity ent. The type must be a damage type constant. duration is the number of mud hours the affect will last. The effect must be a constant modifier type, and the amount modifies the appropriate type. If avg_time is true, the duration will be averaged with that of any existing effect. If avg_mod is true, the amount will be averaged with that of any existing effect.
void add_affect (person pc, integer type, integer duration, integer flag);
Merge an affect or modifier into the those already on the entity ent. The type must be a damage type constant. duration is the number of mud hours the affect will last. The flag is one of the following affect flags:
affect_blind -- causes blindness
affect_charm -- charms the person (the master is the person's leader)
affect_confusion -- causes confusion
affect_cripple -- causes crippling
affect_curse -- curses the person
affect_detect_align -- allows detection of alignment
affect_detect_invis -- allows detection of invisibility
affect_detect_life -- allows detection of life
affect_detect_magic -- allows detection of magic
affect_endure_cold -- protects against cold
affect_endure_heat -- protects against heat
affect_feather_fall -- protects against falling damage
affect_hide -- hides the person
affect_immune_charm -- gives immunity to charm spells
affect_immune_summon -- gives immunity to summon spells
affect_infravision -- gives infravision
affect_invisible -- makes the person invisible
affect_paralysis -- paralyzes the person
affect_poison -- reduces healing
affect_protection -- grants protection against some aggression
affect_sanctuary -- provides sanctuary
affect_silence -- silences the person
affect_sleep -- forces the person to stay asleep once asleep
affect_sneak -- allows silent movement
affect_water_breath -- allows breathing underwater
affect_water_walk -- allows walking on water without a boat

The following functions allow a handler to check whether a person pc is affected by any of the listed effects.
boolean pc.afraid;
boolean pc.blind;
boolean pc.charmed;
boolean pc.confused;
boolean pc.crippled;
boolean pc.cursed;
boolean pc.detects_align;
boolean pc.detects_invis;
boolean pc.detects_life;
boolean pc.detects_magic;
boolean pc.endures_cold;
boolean pc.endures_heat;
boolean pc.has_feather_fall;
boolean pc.has_infravision;
boolean pc.has_protection;
boolean pc.has_water_breath;
boolean pc.has_water_walk;
boolean pc.hidden;
boolean pc.immune_to_charm;
boolean pc.immune_to_spells;
boolean pc.immune_to_summon;
boolean pc.in_group;
boolean pc.invisible;
boolean pc.paralyzed;
boolean pc.parrying;
boolean pc.poisoned;
boolean pc.sanctified;
boolean pc.silenced;
boolean pc.slept;
boolean pc.sneaking;
boolean pc.stunned;
boolean pc.tame;

Checking on completed quests

boolean pc.done_spear_quest;
void set_person_done_spear_quest (person pc, boolean flag);
Determine or set whether or not the player pc has completed the Spear Quest.

boolean pc.done_astoraths;
void set_person_done_astoraths (person pc, boolean flag);
Determine or set whether or not the player pc has solved the riddle of Astorath's Maze.

boolean pc.done_isvaelin;
void set_person_done_isvaelin (person pc, boolean flag);
Determine or set whether or not the player pc has participated in the binding of Isvaelin.

boolean done_udc (person pc);
void set_person_done_udc (person pc, boolean flag);
Determine or set whether or not the player pc has solved every puzzle in the Ultimate Death Challenge.

boolean done_sorrow (person pc);
void set_person_done_sorrow (person pc, boolean flag);
Determine or set whether or not the player pc has defeated the Liches of the Sorrow.

boolean done_belly (person pc);
void set_person_done_belly (person pc, boolean flag);
Determine or set whether or not the player pc has participated in the destruction of the Ego.

boolean done_xymar (person pc);
void set_person_done_xymar (person pc, boolean flag);
Determine or set whether or not the player pc has completed the Xymaran assassination.


Checking on abilities

boolean pc.can_see;
Returns true if the person pc can see, false otherwise.

boolean pc.can_see_room;
Returns true if the person pc can see in his current location, false otherwise.

boolean pc.can_see_room_light;
Returns true if the person pc could see in his current location were it lit, false otherwise.

boolean pc.can_hear;
Returns true if the person pc can hear, false otherwise.

boolean pc.can_speak;
Returns true if the person pc can speak, false otherwise.

boolean pc.can_be_heard_remotely;
Returns true if the person pc can be heard outside of his location, false otherwise.

boolean can_see_pers (person pc, person target);
Returns true if pc can see target, false otherwise.

boolean can_see_obj (person pc, object obj);
Returns true if pc can see obj, false otherwise.

boolean same_alignment (person pc, person compare);
Returns true if pc and compare have the same alignment (e.g., both are good), false otherwise.

boolean same_group (person pc, person compare, booleam charmees);
Returns true if pc and compare have the same leader, and are grouped. charmees lets you select if you consider charmed followers to be part of the group.
boolean can_carry_obj (person pc, object obj);
Returns true if pc can carry obj, false otherwise.

boolean can_hear_pers (person pc, person target);
Returns true if pc can hear target, false otherwise.

boolean can_wear (person pc, object obj, integer style);
boolean size_can_wear (person pc, object obj, integer style);
boolean align_can_wear (person pc, object obj, integer style);
boolean class_can_wear (person pc, object obj, integer style);
Returns true if pc can wear obj, false otherwise. If only size (or alignment, or class) should be checked, call the appropriate function. style must be one of the following constants:


Making a person act

Note that immortals cannot be forced to act.

special attack (person pc, person vict, boolean forced, integer delay);
special normal_attack (person pc, person vict, boolean forced, integer delay);
Causes pc to attack vict, potentially through a class-specific attack (when using the attack form with a mobile), and regardless of pc's ability to see vict when forced. For mobiles, the attack can be delayed by some number of pulses through the delay parameter. Returns ignored if the attack is not legal, fatal if the victim is slain (immediate attacks only), and handled otherwise.

void pc.stop_fighting;
Ends combat for the person pc.

void do_damage (person pc, person vict, integer type, integer amt);
Causes pc to do amt damage of type type to vict. Returns ignored if the damage is not legal, fatal if the victim is slain (immediate attacks only), and handled otherwise.

void interpret (person pc, string cmd, integer delay);
Issue an arbitrary command for a person pc. For mobiles, the command can be delayed by some number of pulses through the delay parameter.

void interpret_one_entity (person pc, entity ent, string cmd, integer delay);
Issue an arbitrary command for a person pc, attaching the name of the entity ent to the end of the command string (e.g., "nod" might become "nod dwarf"). For mobiles, the command can be delayed by some number of pulses through the delay parameter.

void interpret_two_entities (person pc, entity ent1, entity ent2, string cmd, integer delay);
Issue an arbitrary command for a person pc, attaching the names of two entities to the end of the command string (e.g., "get" might become "get sword chest"). For mobiles, the command can be delayed by some number of pulses through the delay parameter.

void tell (person pc, person target, string text);
Tell the person target something, provided that the other person can hear the pc.
boolean save_against (person pc, integer type);
Attempt to save against a particular type of danger. Returns true on success, false on failure. The types of danger are listed along with save_chance.

void follow (person pc, person leader);
Causes pc to begin following leader, or to stop following if leader is the pc.

void use_exit (person pc, exit ex, integer delay);
void use_exit_restricted (person pc, exit ex, integer delay);
Causes a person pc to use the exit ex, possibly after a delay in pulses (for mobiles only). The pc must be in the same room as the exit and must be capable of moving through the exit using normal movement commands. If the restricted form of the function is used, mobiles will only use the exit if normal wandering motion would permit it. For hunting in Mocha, combine this function with path_exit

void pc.wake;
Causes the person pc to attempt to wake, or has no affect if the person is already awake.

void stand (person pc);
Causes the person pc to attempt to stand, or has no affect if the person is already standing.


Checking player-specific attributes

boolean pc.is_playing;
Returns true if the person pc has a link in the playing state, false otherwise.

boolean pc.is_linkdead;
Returns true if the person pc is a linkdead player (no link, but not switched), false otherwise.

boolean mob.is_occupied;
Returns true if the person pc is a mobile occupied by a switched player, false otherwise.

boolean pc.is_switched;
Returns true if the person pc is a switched player, false otherwise.

boolean pc.is_hearing;
Returns true if the person pc has a link in a state which hears mud banter (e.g., gossip), false otherwise. This should be checked before sending text to a player found with a "for each connection" statement.

integer pc.karma;
void set_person_karma (person pc, integer val);
Determine of set the player's karma.

integer pc.bank_account;
void set_person_bank_account (person pc, integer val);
Determine or set the number of default coins in the player pc's bank account.

room pc.load_room;
integer pc.load_room_vnum;
void set_person_load_room (person pc, room rm);
void set_person_load_room_vnum (person pc, integer vnum);
Determine or set the room or virtual number of the room to which the player pc returns on recall or entry into the game.

integer pc.num_practices;
void set_person_num_practices (person pc, integer val);
Determine or set the number of guild practices for the player pc.

integer pc.wimpy_level;
void set_person_wimpy_level (person pc, integer val);
Determine or set the wimpy level for the player pc.

integer pc.age;
Returns the player pc's age in years.

boolean killed_recently (person pc, integer vnum, integer period);
Returns true if the player pc has killed a mobile with virtual number vnum in the last period pulses, or false otherwise.

void set_person_skill (person pc, integer num, integer val);
Set the player pc's skill to the specified value. The skill number num must be taken from the list of available skills.

void restore (person pc, boolean completely);
Restore the player pc to full health, spell points, and movement and removes all negative spell affects. Completely restoring a player removes absolutely all spell affects.

Gaining experience points

void gain_xp (person pc, integer amt);
Give amt XP to the person pc. amt can be negative. This experience is not shared with group members.

void gain_group_xp (person pc, integer amt, boolean room_only);
Give amt XP to the person pc's group, to be shared amongst the members in the standard way. amt can be negative. If room_only is true, group members must be in the room to gain a share of the XP. Otherwise, they may be anywhere (but must still be awake and linked to the mud).

void gain_kill_xp (person pc, person vict);
Give the usual amount of XP to the pc's group for killing vict. This must be done before vict actually dies, of course.

void gain_quest_xp (person pc, integer amt);
Give a fixed amount of XP unaffected by rent bonus or xp caps. Still affected by Remort, however.

Switching and snooping

boolean start_switch (person pc, person mob);
Switches a player into a mobile's body. Returns true on success, false on failure.

void pc.end_switch;
Switches the player pc out of a mobile's body or switches a player out of the pc's body (either the mobile or the pc may be given). Returns true on success, false on failure.

person pc.in_body;
Given a switched player, pc, returns the mobile to which the player has switched. Otherwise, returns none.

person pc.from_body;
Given a mobile pc occupied by a player, returns the player who has switched into the mobile. Otherwise, returns none.

boolean start_snoop (person pc, person vict, integer bits);
Begins to route snooping text from vict to pc. Returns true on success, false on failure. Bits are required to decide what info the snooper receives.
snoop_output -- Snooper sees output sent to the target.
snoop_input -- Snooper sees what input the target types in.
snoop_paged -- Pauses output with [More] if snooper receives too much in one instant.
void pc.end_snoop;
Stops a player pc from receiving further snoop output.

void pc.end_snoopers;
Stops all snoopers associated with the target.

Checking a mobile's memory

Mocha has a limited interface to mobile memory. The following reasons can be checked and added to a mobile memory with Mocha. Please remember not to add memories unless the mobile can see the pc.
void remember (person mob, person pc, integer reason, integer period);
Forces a mobile to remember the pc for the given reason for period pulses.

boolean remembers (person mob, person pc, integer reason);
Returns true if the mobile remembers the pc for the given reason, false otherwise.

void forget (person mob, person pc, integer reason);
Forces a mobile to forget about the pc for the given reason.

void forget_all (person mob, integer reason);
Forces a mobile to forget anyone it remembers for the given reason.


Selecting a victim

person pc.pick_other;
Selects a person besides the person pc in the same location as the pc. Ignores nohassle'd persons, and returns none if no such person exists.


Return to Mocha's Main Page