[Package Index | Mudlib Index | Effect Index]

File /obj/monster/smart_fighter.c

The Good Fighter inherit. The main docs are stored in the effect header file, not here... Mostly for standardisation reasons.

See also:
/std/effects/npc/good_fighter .c

Written by Sin

Change history

Includes

This class includes the following files /include/magic.h, /include/guilds.h, /include/ritual_system.h, /include/assassin.h, /include/player.h, /include/tasks.h, /include/inhume.h, /include/playtesters.h, /include/combat.h, /include/smart_fighter.h and /include/assert.h

Method index

Public Functions

These are functions that everyone can access.

check_for_contracts
void check_for_contracts()
do_smart_fighter_move
int do_smart_fighter_move(object npc,
                          string dir,
                          int running_away)

If the smart_fighter wants to do something special with the attempt runaway/move. If the run_away sequence has finished, so this it the last move or this a wander move, then we the running_away flags is not set.

Parameters:
running_away - is 1 if this is part of the run away sequence

Returns:
1 if we handled it, 0 if not.


event_enter_check
void event_enter_check(object dest,
                       string mess,
                       object from)

We check for ambush and backstab attempts in here.
event_fight_in_progress
void event_fight_in_progress(object attacker,
                             object opponent)

This function is called once per attack made during combat. It controls on whom the NPC is concentrating, chooses an appropriate attack, and chooses an appropriate weapon for the attack.

Most of the intelligence is in the specific choice of attack, and there isn't a whole lot in that. It restricts itself to simply going through the attacks stored in the specials[] array (calculated in the call to good_fighter_setup()), finding which attacks are valid (based on whether the opponent is holding a weapon and which weapons are wielded by the NPC). Once it has a list of valid commands, it choses from them randomly.

Regardless, there is always the possibility that this function will drop through and allow the combat handler to attack normally. That chance is inversely proportional to the NPC's level.

Parameters:
attacker - The person doing the attacking which triggered this call.
opponent - who attacker is attacking.


event_npc_cast_spell
void event_npc_cast_spell(object spell,
                          object caster,
                          object * targets,
                          class spell_argument args,
                          int stage)

Called when a player starts to cast a spell. We will do specific things in certain cases, depending on the spell being cast. In combination with level and ability of the npc.
event_npc_consider
void event_npc_consider(object player)

Make them get prepared when considered.
event_ritual
void event_ritual(object spell,
                  class ritual ritual)
inhume_command
string inhume_command(string spec,
                      object weapon,
                      object dest)
query_fighter_options
int query_fighter_options()
query_inhume_handler
string query_inhume_handler()

Figures out the handler to use for querying contracts to fulfill.

Returns:
the inhume handler


query_is_smart_fighter
int query_is_smart_fighter()
query_managed_specials
string query_managed_specials(int type)
set_inhume_handler
void set_inhume_handler(string handler)

Sets the handler to use for querying contracts to fulfill.
set_smart_fighter
varargs void set_smart_fighter(int weapon_type,
                               int defence_type,
                               int spell_options)
setup_spell_options
void setup_spell_options(int options)

This sets up the NPCs reaction to spells. Wigthout this setup the npc will not react at all to spells.

Parameters:
options - the optoins in how the npc responds


Protected Functions

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

check_add_command
void check_add_command(string command,
                       string skill,
                       int level,
                       int type)

This helper function is used by good_fighter_setup() to add a known command to the NPC's repertoire _only_ if the relevant skill is above a certain level. If the command is added, then it is also stored in the specials[] array for later use by fight_in_progress()

Parameters:
command - The command to be added
skill - The skill that controls the NPC's effectiveness with this command.
level - The minimum level before the command can be added.


check_skill
void check_skill(string skill,
                 int level)

This is a helper function used by the good_fighter_setup() function to ensure that the specified skill is at least at a particular level.

Parameters:
skill - The skill to check
level - The minimum acceptable level for this skill


check_weapon
int check_weapon(object weapon,
                 string command)

This helper function is used by fight_in_progress() to see if one of the NPC's weapons are appropriate for use with the command.

Parameters:
weapon - The object to check.

Returns:
1 if the object is appropriate, 0 otherwise


smart_fighter_setup
void smart_fighter_setup(int type)

This function is called from a callout() registered when set_good_fighter is called. It is responsible for ensuring that all of the NPC's skills are at a reasonable level, that the NPC has the commands appropriate for its priorities and level, and that the tactics are set appropriately.