[Package Index | Mudlib Index | Effect Index]

Inherits

This class inherits the following classes /std/weapon_logic.c, /std/living/corpse.c and /std/living/feats.c

Includes

This class includes the following files /include/feats.h, /include/units.h, /include/combat.h, /include/minmax.h, /include/group_handler.h, /include/command.h, /include/attack_messages.h, /include/weapon.h, /include/tasks.h, /include/player.h, /include/skills.h, /include/living.h and /include/playtesters.h

Method index

Public Functions

These are functions that everyone can access.

accepted_surrender
void accepted_surrender(object attacker)

This method is called if surrender was accepted for the particular person.

Parameters:
attacker - the person who is surrendering

See also:
refused_surrender()


add_defender
int add_defender(object thing)

This method will add a defender to the current list of defenders for this living object.

Parameters:
thing - the defender to add

See also:
remove_defender() and query_defenders()


add_protection_message
void add_protection_message(string * att_mess,
class attack att)

Updates the given attack messages to include a message that someone is jumping in front of the attack.
add_protector
int add_protector(object thing)

This method will add a protector to the current list of protectors for this living object.

Parameters:
thing - the protector to add

See also:
remove_protector() and query_protectors()


adjust_action_defecit
void adjust_action_defecit(int amount)
after_attack
class attack after_attack(class attack att)

This function is called after it's all over and done (just before the costs are charged). It can be used to do any special outcomes that we may decide on. Note that if you override this function in a special be absolutely certain you know what you're doing if you return R_ABORT or R_DONE. Use of either of these two could cause really nasty side-effects.

Parameters:
class - attack

Returns:
class attack


attack_by
int attack_by(object opponent)

This method is called when the living object is attacked by some opponent.

Parameters:
opponent - the opponent we are attacked by

Returns:
0 if we cannot attack them, 1 if we can

See also:
query_attacker_list() and attack_ob()


attack_ob
int attack_ob(mixed opponents)

This method is called to make us attack someone else.

Parameters:
opponents - the opponent(s) to attack

Returns:
0 if we cannot attack any of them, 1 if we can

See also:
query_attacker_list() and attack_by()


available_attack_weapons
object * available_attack_weapons(class attack att)

Returns the weapons the attacker in att can use with his current settings.
calc_armour_protection
class attack calc_armour_protection(class attack att)

Calculate how much of the damage is saved by the armour. PRE: all information has been filled in except the amount of damage stopped by armour, and which piece of armour did the stopping.
POST: The damage stopped and which armour did it is filled in.

Parameters:
class - attack

Returns:
class attack


calc_attack_modifier
class attack calc_attack_modifier(class attack att)

This method calculates the modifier to the attack. It will take into account all the basic stuff that makes the attack harder or easier. PRE: All attack and response data has been filled in.
POST: The offensive modifier must be set.

Parameters:
class - attack

Returns:
class attack


calc_damage
class attack calc_damage(class attack att)

After a successful attack (or possibly a parried one) calculate the amount of damage done to the opponent. This method must fill in the amount of damage to be done and may adjust the time taken too. PRE: the outcome of an attack must have been determined.
POST: damage must be filled in.
calc_defense_modifier
class attack calc_defense_modifier(class attack att)

This method calculates the modifier to the defense. It will take into account all the basic stuff that makes the defense harder or easier. PRE: All attack and response data has been filled in.
POST: The defensive modifier must be set.

Parameters:
class - attack

Returns:
class attack


can_defend
int can_defend(object person,
object attacker)

Checks whether the given person can defend someone.
can_protect
int can_protect(object person,
object attacker)

Checks whether the given person can defend / protect.
caster_defense_penalty
int caster_defense_penalty(object defender,
int base)

Modifies "base" if the defender is casting a spell or performing a ritual, based on their feats.
choose_attack
class attack choose_attack(class attack att)

Determine which attack they'll use. This picks a weapon, gets the attack data and the weapon skill and determines how much the attack will cost. PRE: attacker info, opponent and defender info have been set.
POST: attack weapon, attack skill, attack data, and attack_cost must be set.

Parameters:
class - attack

Returns:
class attack


choose_defender
class attack choose_defender(class attack att)

This method is used to choose who will defend this attack. Typically this will be the person who was attacked, however it could be someone else in some circumstances. PRE: attacker, attack and opponent information has been set.
POST: defender and person_hit must be set.

Parameters:
class - attack

Returns:
class attack


choose_defense
class attack choose_defense(class attack att)

Will the defender defend or not? If so, with what skill and weapon and at what action cost? PRE: all attack data and opponent and defender data have been set.
POST: defense type, skill and weapon must be set. If defense_action is "none" the defender will have a big negative modifier.

Parameters:
class - attack

Returns:
class attack


combat_feedback
void combat_feedback(object player,
string * messages,
int level,
object wpn)
defend_cost
int defend_cost(object defender)
do_attack
void do_attack()

This performs the actual attack itself. All attack data, everything we know about the attacker and the defender is stored in the attack class which is passed into and back by every function at every step of the attack.
do_surrender
object do_surrender(object thing)

This method will be called when we surrender. This does mean that the opponent must have accepted our surrender plea.

Parameters:
thing - the thing which made us surrender

Returns:
always returns 0


dodge_modifier
int * dodge_modifier(object defender,
object attacker,
object attack_weapon,
int dodge_defense_bonus,
string attack_type,
int give_feedback)

This method calculates the modifier to the defense if the defense is parrying, and gives combat feedback if required.
dont_attack_me
int dont_attack_me()
end_combat
void end_combat()

This method is called when combat ends. You can overload this function to make your NPC do things at the end of combat. You do not need to call ::end_combat() since this is just a stub function.
event_surrender
void event_surrender(object victim,
object * attackers)

This method tells us what the npc shouuld do in the case that it might possibly surrender.

Parameters:
victim - the person surrendering
attacker - the person beating up the surrenderer


fight_in_progress
void fight_in_progress(object thing)

This method is called when there is a fight in progress. It will propogate the event onto all the objects in the room.

Parameters:
thing - the person fighting


give_zone_failure_message
void give_zone_failure_message(class attack att)
height_related_zone
string height_related_zone(object target,
object protector,
string zone)

Comparing heights between the target and the protector, and assuming the target is hit in the zone, return what zone position in the protector that roughly corresponds to (not very precise, but if zones are ordered top-down, this should give roughly the right idea). This returns 0 if the zone is likely to be above the protector.
is_fighting
varargs int is_fighting(object ob,
int actively)

This method determines whether or not the object is fighting another object. Cannot fight invisible people.

Parameters:
ob - the object being tested
actively - is the opponent being actively fought at this time?

Returns:
1 if it is in combat, 0 if it is not.


item_in_hand
varargs object item_in_hand(string hand,
object person)

Returns the object held in the given hand, or 0 if they are not holding anything in it (or there is no hand).
items_in_hand
varargs object * items_in_hand(string hand,
object person)

Returns an array containing either the object held in the given hand, if the hand is valid, all items if the given hand is "both", or the empty array if nothing is held or the hand is invalid.
monitor_points
void monitor_points()
mounted_zone
string mounted_zone(object target,
object attacker,
string original_zone)

If the target is mounted on a horse, attacks from non-mounted opponents will land on lower zones. Conversely, if the attacker is mounted on a horse, attacks on non-mounted opponents will land on higher zones. This returns the zone that an attack will land in instead.
nearby_zone
string nearby_zone(object person,
string zone,
int dist)

Returns a zone "near" the given zone, with a higher chance given to closer zones.
offered_surrender
void offered_surrender(object victim)

This method is called when someone offers to surrender to the living object. It will check the current tactics for surrender and then handle the response appropriately.

Parameters:
victim - the person surrendering


opponent_died
void opponent_died(object opponent,
object corpse)

This is called by /std/living/corpse to notify us that the opponent died.
parry_modifier
int * parry_modifier(object defender,
object attacker,
object defense_weapon,
object attack_weapon,
int parry_defense_bonus,
int distance,
int give_feedback)

This method calculates the modifier to the defense if the defense is parrying or blocking, and gives combat feedback if required.
protect_cost
int protect_cost(object defender)
protect_defend_cost
int protect_defend_cost(object defender)
protector_zone
string protector_zone(object target,
object protector,
string original_zone)

If the target is being hit in original_zone, but protector jumps in front of it, return an alternative zone in which protector is hit instead.
query_action_defecit
int query_action_defecit()
query_arcane_shields
string * query_arcane_shields()
query_attackable
varargs int query_attackable(string cmd)

Is this object attackable or not? The cmd is 0 if it is from inside the combat system itself and the name of the command otherwise.

Returns:
1 or 0 for true or false.


query_attacker_list
varargs object * query_attacker_list(int dont_remove_nulls)

This method returns the current list of people in the attacker list on the object.

Parameters:
dont_remove_nulls - If true, null objects won't be removed from the list. This is a bit quicker, but requires care when used

Returns:
the current attacker array


query_can_attack
int query_can_attack()

Decide if we will attack this round or not. This function can be overloaded if necessary. It also checks for the property "cannot attack" on this object. If the property is set the object cannot attack.

Returns:
1 if we want to, 0 if we don't.


query_can_defend
int query_can_defend()

Decide if we are able to defend ourselves this time or not. This function can be overloaded if necessary. It also checks for the property "cannot defend" on this object. If the property is set the object cannot defend.

Returns:
1 if we want to, 0 if we don't.


query_combat
class combat_information query_combat()
query_combat_attack
string query_combat_attack()
query_combat_attitude
string query_combat_attitude()
query_combat_distance
string query_combat_distance()
query_combat_focus
string query_combat_focus()
query_combat_mercy
string query_combat_mercy()
query_combat_parry
string query_combat_parry()
query_combat_response
string query_combat_response()
query_combat_testing
int query_combat_testing()
query_concentrating
object query_concentrating()
query_defend
int query_defend()

Is this object prepared to try to defend someone else at this time?

Returns:
1 or 0 for true or false.


query_defenders
object * query_defenders()

This method returns the current array of defenders on the living object. This is the people who are protecting us, so if we are hit make them attack the hitter.

Returns:
the current defenders array

See also:
add_protector() and remove_protector()


query_distance
int query_distance(object opponent)

Query the distance from this object to the given opponent.

Parameters:
opponent - the object to check


query_fighting
int query_fighting()

Is the player currently fighting anyone.

Returns:
1 for yes, 0 for no.


query_last_action
string query_last_action()

This method returns the last (combat) action performed.

Returns:
string the action.


query_last_opponent
object query_last_opponent()

This method returns the last known opponent we attacked or defended against. It is kept as up to date as the system can manage and so will include anyone who is currently attacking us or who we are currently attacking.

Returns:
object the opponent.


query_last_result
int query_last_result()

This method returns the result of the last combat round.

Returns:
int the result.


query_last_weapon
object query_last_weapon()

This method returns the last weapon we used for an attack or defense.

Returns:
object the weapon.


query_monitor_string
string query_monitor_string()

Returns the raw monitor string.

Returns:
The monitor string, 0 for the default monitor


query_protect
int query_protect()

Is this object prepared to try to protect someone else at this time?

Returns:
1 or 0 for true or false.


query_protectors
object * query_protectors()

This method returns the current array of protectors on the living object. This is the people who are protecting us, so if we are hit make them attack the hitter.

Returns:
the current protectors array

See also:
add_protector() and remove_protector()


query_specials
class combat_special * query_specials()

List the specials currently registered for this npc/player.

Returns:
an array of combat_special classes.


query_surrender
class surrender_information query_surrender()
query_surrenderers
object * query_surrenderers()

This method returns the current list of people surrendering to us.

Returns:
the list of people surrendering

See also:
remove_surrenderer()


query_tactics
class tactics query_tactics()

This method returns the current tactics set using the tactics class.

See also:
set_tactics()


query_unarmed_parry
int query_unarmed_parry()
query_used_combat_response
varargs string query_used_combat_response(string default_response)

Selects one of parry, dodge or block based on the player's preferences. This handles the random selection when a player is set to neutral response, and the selection of block for a player set to parrying but using shields. Note that in cases where the player's preferences do not allow for a defence --- i.e. when parrying but having unarmed parry disabled and not holding weapons, or when blocking while not holding a shield --- the string parameter default_response is returned. If this default is not given, then 0 is returned.
recalc_hunting_list
void recalc_hunting_list()
refused_surrender
void refused_surrender(object attacker)

This method is called if surrender was refused for the particular person.

Parameters:
attacker - the person who is surrendering

See also:
accepted_surrender()


register_special
int register_special(int type,
int events,
mixed callback,
mixed data)

Register a combat special. The combat system maintains a list of combat specials. These specials can be used to override or alter any facet of a combat attack (or defense).

A special must register what type of special it is:
T_OFFENSIVE - an offensive special
T_DEFENSIVE - a defensive special
T_CONTINUOUS - can be used with one of the above to indicate that the special is continuous and not a one-time event.
T_PRIORITY - Must be used in conjunction with one of the previous types. If it is set, then the special is added to the beginning of the list, rather than the end.

It also indicates which stages of combat it wants to be notified of:
E_OPPONENT_SELECTION - selection of an opponent
E_DEFENDER_SELECTION - selection of the defender
E_ATTACK_SELECTION - selecting which attack the attacker will perform
E_DEFENSE_SELECTION - selection of the method of defense
E_ATTACK_MODIFIER - calculating the modifier for attack (how easy/hard it is)
E_DEFENSE_MODIFIER - doing the same for the defense
E_DAMAGE_CALCULATION - calculating how much damage the attack can do
E_ARMOUR_CALCULATION - calculating how much damage the armour will stop
E_WEAPON_DAMAGE - performing damage to the weapons involved
E_WRITE_MESSAGES - writing out the success/failure messages
E_AFTER_ATTACK - any post-attack cleanup.

The special provides the combat system with a callback function to be called and any additional data the special wants tracked by the combat system.

Then, when combat reaches one of the stages requested it calls the callback function. This function is passed the stage we're at, all the data for this attack and also the extra data the special requested.

The callback can then modify any aspect of the attack data (it could change the attack skill, the defensive weapon, the defense modifier, anything at all) and then return back into combat.

The return tells the combat system what to do next. The options are:
R_PASSTHRU - indicates that the special hasn't done anything; if more than one special for this attacker / defender is registered, the combat system will simply try the next special instead, otherwise we fall through to the combat system's standard behaviour. R_CONTINUE - indicates that the special HAS done something, or is planning to, but we should continue with the combat system's standard behaviour, as though the special hadn't done anything.
R_DONE - treat this step as completed.
R_ABORT - abort the attack
R_REMOVE_ME - do one of the above and then remove the special.
R_IGNORE_ROUND - do one of the above, and note that in the current combat action sequence, this special will not do anything anymore, and should not get called.

Note that it is possible for multiple specials to be registered for the same attacker / defender. In this case, in each phase the specials will be called in the order they were added (except that priority specials are added to the front of the list, not the back). The first special to return R_CONTINUE or R_DONE in any stage is set as the current special for that person; during this attack, only this special will be called for any stage, until either the special is removed, or the attack ends.

Also note that it is possible that the stages E_DEFENDER_SELECTION .. E_POST_DEFENSE_MODIFIER are called twice: if the opponent is being defended, and the defender fails the skillcheck, then if the special has not yet removed itself, these stages will be called again to allow the opponent to defend himself. The data for the current attacker and defender special will be reset to the values they had after E_OPPONENT_SELECTION if this happens.

Parameters:
type - Is this an offensive or defensive special.
events - A bitmap of the events this special is interested in.
callback - the function to be called. A mixed array containing an object and a function string.
data - A mixed variable containing any data you want stored and passed in (often used to record info about the special)

Returns:
the id of the special.

Example:
This example registers a special that causes the player to be unable to
defend themselves for three rounds.

id = player->register_special(T_DEFENSIVE | T_CONTINUOUS,
                              E_DEFENSE_SELECTION | E_DAMAGE_CALCULATION,
                              ({ base_name(), "callback" }),
                              ({ player, 0}));

mixed *callback(int stage, class attack att, mixed data) {
  // If it's not our player defending we won't do anything.
  if(att->defender != data[1])
    return ({ R_CONTINUE, att, data });

   switch(stage) {
   case E_DEFENSE_SELECTION: // We won't let them defend themselves!
     att->defense_action = "none";
     return ({ R_DONE, att, data });
   case E_DAMAGE_CALCULATION:
     // If they managed to defend themself, turn it into a failure.
     if(att->result == DEFWIN || att->result == DEFAWARD)
       att->result = OFFWIN;

     // By using R_CONTINUE they take 500 hits _plus_ the normal damage.
     att->damage = 500;

     // The R_REMOVE_ME causes our special to disappear once we've hurt
     // them three times.
     if(data[1] > 3)
       return ({ R_CONTINUE | R_REMOVE_ME, att, data });

     data[1]++;
     return ({ R_CONTINUE, att, data });
   }
}

remove_attacker_list
void remove_attacker_list(object ob)

This method removes someone from an attacker/hunting list.

Parameters:
ob - the object to be removed.


remove_defender
int remove_defender(object defender)

This method will remove a defender to the current list of defenders for this living object.

Parameters:
thing - the defender to remove

Returns:
1 for success, 0 for failure.

See also:
add_defender() and query_defenders()


remove_noncont_specials
void remove_noncont_specials()

This method removes all non-continuous specials. It is called by the "stop" command.

Returns:
1 for success, 0 for failure


remove_protector
int remove_protector(object protector)

This method will remove a protector to the current list of protectors for this living object.

Parameters:
thing - the protector to remove

Returns:
1 for success, 0 for failure.

See also:
add_protector() and query_protectors()


remove_special
int remove_special(int id)

Remove a combat special.

Parameters:
id - The id of the special

Returns:
1 for success, 0 for failure


remove_surrenderer
void remove_surrenderer(object victim)

This method removes a person surrendering from our current list.

Parameters:
victim - the person to remove

See also:
query_surrenderers()


reset_attack_limb
void reset_attack_limb()

The limb you attacked with last is remembered, and you receive a penalty for reusing it. If a new attack should _not_ penalise reusing a limb (and not prioritise using another limb!), call this function to reset the limb before choosing an attack.
reset_defenders
void reset_defenders()

This method resets the defender array back to being nothing.
reset_protectors
void reset_protectors()

This method resets the protector array back to being nothing.
set_combat_attack
void set_combat_attack(string attack)
set_combat_attitude
void set_combat_attitude(string attitude)
set_combat_distance
void set_combat_distance(string distance)
set_combat_focus
void set_combat_focus(string focus)
set_combat_mercy
void set_combat_mercy(string mercy)
set_combat_parry
void set_combat_parry(string parry)
set_combat_response
void set_combat_response(string response)
set_combat_testing
void set_combat_testing(int value)
set_concentrating
int set_concentrating(object thing)
set_distance
int set_distance(object opponent,
int distance)

Set the distance from this object to the given opponent.

Parameters:
opponent - the object to set the distance to.
distance - the new distance.


set_monitor_string
void set_monitor_string(string str)

Sets the monitor string.

Parameters:
str - The string to set the monitor string to


set_special_data
int set_special_data(int id,
mixed data)

Update the user data for a specific special.

Parameters:
id - The id of the special
data - The data to be set

Returns:
True or false for success or failure


set_specials
void set_specials(class combat_special * specials)

Directly set the special list. Use with care!

Parameters:
class - combat_special *


set_tactics
void set_tactics(class tactics new_tactics)

This sets the current attitude to use in combat.

Parameters:
attitude - the new combat attitude

See also:
query_tactics()


set_unarmed_parry
void set_unarmed_parry(int parry)
start_combat
void start_combat(object opponent)

This method is called when combat starts. You can overload this function to make your NPC do things at the start of combat. You do not need to call ::start_combat() since this is just a stub function.

Parameters:
opponent - The first opponent to be attacked.


stop_all_fight
void stop_all_fight()
stop_fight
void stop_fight(object opponent)
stop_hunting
void stop_hunting(object opponent)
stopped_fighting
void stopped_fighting(object thing)

This method is called when the fight has stopped. It propogates the stopped fighting event onto all the objects in the room.

Parameters:
thing - the thing which stopped fighting?


Protected Functions

These are functions that only objects inheriting the class can access.

adjust_actions
void adjust_actions(class attack att)

Adjust the time left, combat actions and gp used by this attack. This calls adjust_action_defecit in both the attacker and defender as appropriate.

Parameters:
class - attack


call_special
mixed * call_special(int stage,
class attack att)

Go through the list of the attacker & opponents specials and call any that have registered for this stage.
choose_opponent
class attack choose_opponent(class attack att)

Choose an opponent and attack them. This method must fill in the opponent variable. If no opponent is chosen the attack will be aborted. PRE: Attacker information has been filled in.
POST: opponent must be chosen or the attack will be aborted.

Parameters:
class - attack

Returns:
class attack


damage_weapon
class attack damage_weapon(class attack att)

Do damage to the attacking & defending weapons. PRE: all information has been filled in
POST: the weapons involved have taken appropriate damage.

Parameters:
class - attack

Returns:
class attack


perform_movement
class attack perform_movement(class attack att)

This function is called as part of the post attack processing and performs the checks to see if someone can move closer or further away from their opponent.

Parameters:
class - attack

Returns:
class attack

See also:
after_attack()


prepare_messages
class attack prepare_messages(class attack att)

Prepare the result messages. This method prepares the attack and defense messages setting up the 5 element arrays of att_mess & def_mess. The elements are as follows: 0 - the attacker, 1 - the opponent, 2 - everyone else, 3 - the defender 4 - the person hit PRE: The attack has been done and the amount of damage done and stopped has been calculated.
POST: The 5 element att_mess & def_mess arrays are populated.

Parameters:
class - attack


write_messages
class attack write_messages(class attack att)

Write out the attack/defense messages. PRE: all information has been filled in
POST: the appropriate messages have been written out.

Parameters:
class - attack

Returns:
class attack


write_monitor_string
void write_monitor_string(string str)