Crossfire Server, Branch 1.12  R12190
Functions
pets.c File Reference

Those functions deal with pets. More...

#include <global.h>
#include <sproto.h>
Include dependency graph for pets.c:

Go to the source code of this file.

Functions

static object * choose_cult_monster (object *pl, const object *god, int summon_level)
 Returns a monster (chosen at random) that this particular player (and his god) find acceptable.
void control_golem (object *op, int dir)
 Makes the golem go in specified direction.
static object * fix_summon_pet (archetype *at, object *op, int dir, int is_golem)
 This makes multisquare/single square monsters proper for map insertion.
void follow_owner (object *ob, object *owner)
 A pet is trying to follow its owner.
object * get_pet_enemy (object *pet, rv_vector *rv)
 Given that 'pet' is a friendly object, this function returns a monster the pet should attack, NULL if nothing appropriate is found.
static object * get_real_owner (object *ob)
 Recursively look through the owner property of objects until the real owner is found.
static void mark_inventory_as_no_drop (object *ob)
 Mark all inventory items as FLAG_NO_DROP.
void move_golem (object *op)
 Handles a golem's movement.
void pet_move (object *ob)
 Handles a pet's movement.
void remove_all_pets (void)
 This function checks all pets so they try to follow their master around the world.
int should_arena_attack (object *pet, object *owner, object *target)
 Determines if checks so pets don't attack players or other pets should be overruled by the arena petmode.
int summon_golem (object *op, object *caster, int dir, object *spob)
 Summons a monster.
int summon_object (object *op, object *caster, object *spell_ob, int dir, const char *stringarg)
 General purpose summoning function.
void terminate_all_pets (object *owner)
 Removes all pets someone owns.

Detailed Description

Those functions deal with pets.

Definition in file pets.c.


Function Documentation

static object* choose_cult_monster ( object *  pl,
const object *  god,
int  summon_level 
) [static]

Returns a monster (chosen at random) that this particular player (and his god) find acceptable.

This checks level, races allowed by god, etc to determine what is acceptable.

Parameters:
plplayer summoning.
godgod the player worships.
summon_levelsummoning level.
Returns:
suitable monster, or NULL if no match found.

Definition at line 837 of file pets.c.

References draw_ext_info_format(), find_racelink(), FLAG_MONSTER, llevDebug, LOG(), MAX_BUF, ralnk::member, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, NDI_UNIQUE, QUERY_FLAG, and rndm().

Referenced by summon_object().

Here is the call graph for this function:

Here is the caller graph for this function:

void control_golem ( object *  op,
int  dir 
)

Makes the golem go in specified direction.

This is a really stupid function when you get down and look at it. Keep it here for the time being - makes life easier if we ever decide to do more interesting thing with controlled golems.

Parameters:
opgolem.
dirdesired direction.
Todo:
trash.

Definition at line 648 of file pets.c.

Referenced by animate_weapon(), and fire().

Here is the caller graph for this function:

static object* fix_summon_pet ( archetype *  at,
object *  op,
int  dir,
int  is_golem 
) [static]

This makes multisquare/single square monsters proper for map insertion.

Parameters:
atarchetype to prepare.
opcaster of the spell
dirdirection the monster should be placed in.
is_golemif set then this is a golem spell.
Returns:
suitable golem.

Definition at line 464 of file pets.c.

References add_friendly_object(), arch_to_object(), AT_DRAIN, AT_GHOSTHIT, AT_PHYSICAL, CLEAR_FLAG, create_treasure(), FLAG_CHANGING, FLAG_FRIENDLY, FLAG_GENERATOR, FLAG_MONSTER, FLAG_SPLITTING, FLAG_STAND_STILL, freearr_x, freearr_y, get_owner(), GOLEM, GT_APPLY, GT_STARTEQUIP, mark_inventory_as_no_drop(), PETMOVE, PLAYER, QUERY_FLAG, SET_FLAG, and set_owner().

Referenced by summon_golem().

Here is the call graph for this function:

Here is the caller graph for this function:

void follow_owner ( object *  ob,
object *  owner 
)

A pet is trying to follow its owner.

Parameters:
obpet trying to follow. Will be remove_ob()'d if can't follow.
ownerowner of ob.

Definition at line 306 of file pets.c.

References draw_ext_info(), find_free_spot(), FLAG_REMOVED, freearr_x, freearr_y, get_map_from_coord(), insert_ob_in_map(), llevError, llevMonster, LOG(), MAP_IN_MEMORY, MSG_TYPE_SPELL, MSG_TYPE_SPELL_PET, NDI_UNIQUE, OUT_OF_REAL_MAP, PLAYER, QUERY_FLAG, remove_ob(), and SIZEOFFREE.

Referenced by move_monster(), pet_move(), and remove_all_pets().

Here is the call graph for this function:

Here is the caller graph for this function:

object* get_pet_enemy ( object *  pet,
rv_vector rv 
)

Given that 'pet' is a friendly object, this function returns a monster the pet should attack, NULL if nothing appropriate is found.

it basically looks for nasty things around the owner of the pet to attack. This is now tilemap aware.

Parameters:
petwho is seeking an enemy.
[out]rvwill contain the path to the enemy.
Returns:
enemy, or NULL if nothing suitable.

Definition at line 67 of file pets.c.

References can_detect_enemy(), can_see_enemy(), check_enemy(), CLEAR_FLAG, find_nearest_living_creature(), FLAG_ALIVE, FLAG_CONFUSED, FLAG_FRIENDLY, FLAG_UNAGGRESSIVE, freearr_x, freearr_y, get_map_flags(), GET_MAP_OB, get_owner(), get_rangevector(), get_search_arr(), on_same_map(), P_IS_ALIVE, P_OUT_OF_MAP, pet_defend, pet_normal, pet_sad, PETMOVE, PLAYER, QUERY_FLAG, remove_friendly_object(), should_arena_attack(), and SIZEOFFREE.

Referenced by find_enemy().

Here is the call graph for this function:

Here is the caller graph for this function:

static object* get_real_owner ( object *  ob) [static]

Recursively look through the owner property of objects until the real owner is found.

Parameters:
obitem we're searching the owner of.
Returns:
owner, NULL if nothing found.

Definition at line 1119 of file pets.c.

References get_owner().

Referenced by should_arena_attack().

Here is the call graph for this function:

Here is the caller graph for this function:

static void mark_inventory_as_no_drop ( object *  ob) [static]

Mark all inventory items as FLAG_NO_DROP.

Parameters:
obthe object to modify.

Definition at line 45 of file pets.c.

References FLAG_NO_DROP, and SET_FLAG.

Referenced by fix_summon_pet(), and summon_object().

Here is the caller graph for this function:

void move_golem ( object *  op)

Handles a golem's movement.

Updated this to allow more than the golem 'head' to attack.

Parameters:
opgolem to be moved.

Definition at line 541 of file pets.c.

References attack_ob(), draw_ext_info(), draw_ext_info_format(), FLAG_ALIVE, FLAG_MONSTER, free_object(), freearr_x, freearr_y, get_map_flags(), GET_MAP_OB, get_owner(), llevDebug, LOG(), move_ob(), MSG_TYPE_SPELL, MSG_TYPE_SPELL_PET, NDI_UNIQUE, P_OUT_OF_MAP, QUERY_FLAG, range_golem, remove_friendly_object(), remove_ob(), and update_object().

Referenced by legacy_ob_process().

Here is the call graph for this function:

Here is the caller graph for this function:

void pet_move ( object *  ob)
void remove_all_pets ( void  )

This function checks all pets so they try to follow their master around the world.

Unfortunately, sometimes, the owner of a pet is in the process of entering a new map when this is called. Thus the map isn't loaded yet, and we have to remove the pet...

Definition at line 273 of file pets.c.

References FABS, first_friendly_object, FLAG_FRIENDLY, FLAG_REMOVED, follow_owner(), free_object(), get_owner(), llevMonster, LOG(), MIN_ACTIVE_SPEED, on_same_map(), PLAYER, QUERY_FLAG, and remove_friendly_object().

Referenced by enter_map(), and swap_map().

Here is the call graph for this function:

Here is the caller graph for this function:

int should_arena_attack ( object *  pet,
object *  owner,
object *  target 
)

Determines if checks so pets don't attack players or other pets should be overruled by the arena petmode.

Parameters:
petpet considered.
ownerpet's owner.
targetpotential pet target.
Return values:
0pet shouldn't attack target.
1target is a suitable victim for the pet.

Definition at line 1146 of file pets.c.

References get_real_owner(), llevError, LOG(), op_on_battleground(), pet_arena, and PLAYER.

Referenced by check_enemy(), and get_pet_enemy().

Here is the call graph for this function:

Here is the caller graph for this function:

int summon_golem ( object *  op,
object *  caster,
int  dir,
object *  spob 
)

Summons a monster.

Parameters:
opwho is summoning.
casterobject casting the spell.
dirdirection to place the monster.
spobspell object casting. At this stage, all spob is really used for is to adjust some values in the monster.
Return values:
0failed to summon something.
1summoned correctly something.

Definition at line 669 of file pets.c.

References add_friendly_object(), add_string(), AT_PHYSICAL, caster_level(), determine_god(), determine_holy_arch(), draw_ext_info(), draw_ext_info_format(), FABS, find_free_spot(), find_god(), fix_summon_pet(), FLAG_FRIENDLY, FLAG_MONSTER, FREE_AND_CLEAR_STR, free_object(), free_string(), freearr_x, freearr_y, get_owner(), GOLEM, insert_ob_in_map(), llevError, LOG(), MAX, MAX_BUF, MIN, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, MSG_TYPE_SPELL_PET, NDI_UNIQUE, ob_blocked(), PETMOVE, PLAYER, QUERY_FLAG, range_golem, remove_ob(), SET_FLAG, set_owner(), set_spell_skill(), SIZEOFFREE1, snprintf(), SP_level_dam_adjust(), SP_level_duration_adjust(), and SP_level_range_adjust().

Referenced by cast_spell().

Here is the call graph for this function:

Here is the caller graph for this function:

int summon_object ( object *  op,
object *  caster,
object *  spell_ob,
int  dir,
const char *  stringarg 
)

General purpose summoning function.

Parameters:
opwho is summoning.
casterwhat object did cast the summoning spell.
spell_obactual spell object for summoning.
dirdirection to summon in.
stringargadditional parameters.
Return values:
0nothing was summoned.
1something was summoned.

Definition at line 929 of file pets.c.

References absdir(), add_friendly_object(), arch_to_object(), caster_level(), choose_cult_monster(), CLEAR_FLAG, create_treasure(), determine_god(), die_roll(), draw_ext_info(), draw_ext_info_format(), find_free_spot(), find_god(), FLAG_FRIENDLY, FLAG_MONSTER, FLAG_SLEEP, freearr_x, freearr_y, freedir, get_map_from_coord(), get_owner(), GT_APPLY, GT_STARTEQUIP, insert_ob_in_map(), treasurestruct::item, llevError, LOG(), mark_inventory_as_no_drop(), MIN_ACTIVE_SPEED, mon, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, NDI_UNIQUE, treasurestruct::next, treasurestruct::nrof, ob_blocked(), PLAYER, PREFER_HIGH, QUERY_FLAG, random_roll(), SET_FLAG, set_owner(), set_spell_skill(), SIZEOFFREE, and SP_level_dam_adjust().

Referenced by cast_spell().

Here is the call graph for this function:

Here is the caller graph for this function:

void terminate_all_pets ( object *  owner)

Removes all pets someone owns.

Parameters:
ownerplayer we wish to remove all pets of.

Definition at line 250 of file pets.c.

References first_friendly_object, FLAG_REMOVED, free_object(), get_owner(), QUERY_FLAG, remove_friendly_object(), and remove_ob().

Referenced by apply_savebed(), check_login(), command_kill_pets(), do_server(), key_confirm_quit(), and save_player().

Here is the call graph for this function:

Here is the caller graph for this function: