|
|
[Package Index | Mudlib Index | Effect Index]
Inherits
This class inherits the following classes /std/living/corpse.c and /std/weapon_logic.cIncludes
This class includes the following files /include/player.h, /include/tasks.h, /include/playtesters.h, /include/weapon.h, /include/living.h, /include/skills.h, /include/attack_messages.h, /include/command.h, /include/combat.h and /include/group_handler.hMethod index
- accepted_surrender(object)
This method is called if surrender was accepted for the particular
person.
- add_defender(object)
This method will add a defender to the current list of defenders
for this living object.
- add_protector(object)
This method will add a protector to the current list of protectors
for this living object.
- adjust_action_defecit(int)
- adjust_actions(class attack)
Adjust the time left, combat actions and gp used by this attack.
- after_attack(class attack)
This function is called after it's all over and done (just before the
costs are charged).
- attack_by(object)
This method is called when the living object is attacked by some opponent.
- attack_ob(object)
This method is called to make us attack someone else.
- calc_armour_protection(class attack)
Calculate how much of the damage is saved by the armour.
- calc_attack_modifier(class attack)
This method calculates the modifier to the attack.
- calc_damage(class attack)
After a successful attack (or possibly a parried one) calculate the
amount of damage done to the opponent.
- calc_defense_modifier(class attack)
This method calculates the modifier to the defense.
- call_special(int, class attack)
Go through the list of the attacker & opponents specials and
call any that have registered for this stage.
- choose_attack(class attack)
Determine which attack they'll use.
- choose_defender(class attack)
This method is used to choose who will defend this attack.
- choose_defense(class attack)
Will the defender defend or not?
- choose_opponent(class attack)
Choose an opponent and attack them.
- damage_weapon(class attack)
Do damage to the attacking & defending weapons.
- do_attack()
This performs the actual attack itself.
- do_surrender(object)
This method will be called when we surrender.
- dont_attack_me()
- end_combat()
This method is called when combat ends.
- event_surrender(object, object *)
This method tells us what the npc shouuld do in the case that it
might possibly surrender.
- fight_in_progress(object)
This method is called when there is a fight in progress.
- is_fighting(object, int)
This method determines whether or not the object is fighting another
object.
- monitor_points()
Display the hitpoint monitor.
- offered_surrender(object)
This method is called when someone offers to surrender to the living
object.
- opponent_died(object, object)
This is called by /std/living/corpse to notify us that the opponent
died.
- perform_movement(class attack)
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.
- prepare_messages(class attack)
Prepare the result messages.
- query_action_defecit()
- query_arcane_shields()
- query_attackable()
Is this object attackable or not?
- query_attacker_list()
This method returns the current list of people in the attacker list
on the object.
- query_can_attack()
Decide if we will attack this round or not.
- query_can_defend()
Decide if we are able to defend ourselves this time or not.
- query_combat()
- query_combat_attack()
- query_combat_attitude()
- query_combat_distance()
- query_combat_focus()
- query_combat_mercy()
- query_combat_parry()
- query_combat_response()
- query_concentrating()
- query_defend()
Is this object prepared to try to defend someone else at this time?
- query_defenders()
This method returns the current array of defenders on the living
object.
- query_distance(object)
Query the distance from this object to the given opponent.
- query_fighting()
Is the player currently fighting anyone.
- query_last_action()
This method returns the last (combat) action performed.
- query_last_opponent()
This method returns the last known opponent we attacked or defended
against.
- query_last_result()
This method returns the result of the last combat round.
- query_last_weapon()
This method returns the last weapon we used for an attack or defense.
- query_monitor_string()
Returns the raw monitor string.
- query_protect()
Is this object prepared to try to protect someone else at this time?
- query_protectors()
This method returns the current array of protectors on the living
object.
- query_specials()
List the specials currently registered for this npc/player.
- query_surrender()
- query_surrenderers()
This method returns the current list of people surrendering to us.
- query_tactics()
This method returns the current tactics set using the tactics class.
- query_unarmed_parry()
- recalc_hunting_list()
- refused_surrender(object)
This method is called if surrender was refused for the particular
person.
- register_special(int, int, mixed, mixed)
Register a combat special.
- remove_attacker_list(object)
This method removes someone from an attacker/hunting list.
- remove_defender(object)
This method will remove a defender to the current list of defenders
for this living object.
- remove_noncont_specials()
This method removes all non-continuous specials.
- remove_protector(object)
This method will remove a protector to the current list of protectors
for this living object.
- remove_special(int)
Remove a combat special.
- remove_surrenderer(object)
This method removes a person surrendering from our current list.
- reset_defenders()
This method resets the defender array back to being nothing.
- reset_protectors()
This method resets the protector array back to being nothing.
- set_combat_attack(string)
- set_combat_attitude(string)
- set_combat_distance(string)
- set_combat_focus(string)
- set_combat_mercy(string)
- set_combat_parry(string)
- set_combat_response(string)
- set_concentrating(object)
- set_distance(object, int)
Set the distance from this object to the given opponent.
- set_monitor_string(string)
Sets the monitor string.
- set_special_data(int, mixed)
Update the user data for a specific special.
- set_specials(class combat_special *)
Directly set the special list.
- set_tactics(class tactics)
This sets the current attitude to use in combat.
- set_unarmed_parry(int)
- start_combat(object)
This method is called when combat starts.
- stop_all_fight()
- stop_fight(object)
- stop_hunting(object)
- stopped_fighting(object)
This method is called when the fight has stopped.
- write_messages(class attack)
Write out the attack/defense messages.
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_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(object opponent)
This method is called to make us attack someone else.
- Parameters:
opponent - the person to attack
- Returns:
0 if we cannot attack them, 1 if we can
- See also:
query_attacker_list() and attack_by()
-
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
-
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 defender 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
-
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
-
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
-
is_fighting
varargs int is_fighting(object ob,
int actively)
This method determines whether or not the object is fighting another
object.
- 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.
-
monitor_points
void monitor_points()
Display the hitpoint monitor.
-
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.
-
query_action_defecit
int query_action_defecit()
-
query_arcane_shields
string * query_arcane_shields()
-
query_attackable
int query_attackable()
Is this object attackable or not?
- Returns:
1 or 0 for true or false.
-
query_attacker_list
object * query_attacker_list()
This method returns the current list of people in the attacker list
on the object.
- 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_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()
-
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.
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_CONTINUE - continue 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.
- 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(this_object()), "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_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_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_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_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
|