Crossfire Server, Trunk  R20513
Functions
pets.c File Reference

Those functions deal with pets. More...

#include "global.h"
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "sproto.h"
Include dependency graph for pets.c:

Go to the source code of this file.

Functions

static objectchoose_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. More...
 
static objectfix_summon_pet (archetype *at, object *op, int dir)
 This makes multisquare/single square monsters proper for map insertion. More...
 
static objectget_real_owner (object *ob)
 Recursively look through the owner property of objects until the real owner is found. More...
 
static void mark_inventory_as_no_drop (object *ob)
 Mark all inventory items as FLAG_NO_DROP. More...
 
void pets_control_golem (object *op, int dir)
 Makes the golem go in specified direction. More...
 
void pets_follow_owner (object *ob, object *owner)
 A pet is trying to follow its owner. More...
 
objectpets_get_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. More...
 
void pets_move (object *ob)
 Handles a pet's movement. More...
 
void pets_move_golem (object *op)
 Handles a golem's movement. More...
 
void pets_remove_all (void)
 This function checks all pets so they try to follow their master around the world. More...
 
int pets_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. More...
 
int pets_summon_golem (object *op, object *caster, int dir, object *spob)
 Summons a monster. More...
 
int pets_summon_object (object *op, object *caster, object *spell_ob, int dir, const char *stringarg)
 General purpose summoning function. More...
 
void pets_terminate_all (object *owner)
 Removes all pets someone owns. More...
 

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 840 of file pets.c.

References draw_ext_info_format(), find_racelink(), FLAG_MONSTER, obj::level, llevDebug, LOG(), MAX_BUF, ralnk::member, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, obj::name, NDI_UNIQUE, oblnk::next, oblnk::ob, QUERY_FLAG, obj::race, rndm(), and safe_strncpy.

Referenced by pets_summon_object().

Here is the call graph for this function:

Here is the caller graph for this function:

static object* fix_summon_pet ( archetype at,
object op,
int  dir 
)
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.
Returns
suitable golem.

Definition at line 446 of file pets.c.

References add_friendly_object(), obj::arch, arch_to_object(), AT_DRAIN, AT_GHOSTHIT, AT_PHYSICAL, obj::attack_movement, CLEAR_FLAG, archt::clone, create_treasure(), obj::direction, obj::enemy, liv::exp, FLAG_CHANGING, FLAG_FRIENDLY, FLAG_GENERATOR, FLAG_MONSTER, FLAG_SPLITTING, FLAG_STAND_STILL, freearr_x, freearr_y, GOLEM, GT_STARTEQUIP, obj::head, obj::invisible, llevError, LOG(), obj::map, mark_inventory_as_no_drop(), monster_check_apply_all(), obj::more, archt::more, obj::move_type, MOVE_WALK, obj::name, archt::name, object_get_owner(), object_set_enemy(), object_set_owner(), PETMOVE, PLAYER, QUERY_FLAG, SET_FLAG, obj::speed_left, obj::stats, obj::type, obj::x, and obj::y.

Referenced by pets_summon_golem().

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 1122 of file pets.c.

References object_get_owner().

Referenced by pets_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 34 of file pets.c.

References FLAG_NO_DROP, FOR_INV_FINISH, FOR_INV_PREPARE, and SET_FLAG.

Referenced by fix_summon_pet(), and pets_summon_object().

Here is the caller graph for this function:

void pets_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.
Note
control_golem() has been renamed to pets_control_golem()

Definition at line 648 of file pets.c.

References obj::direction.

Referenced by animate_weapon(), and fire().

Here is the caller graph for this function:

void pets_follow_owner ( object ob,
object owner 
)

A pet is trying to follow its owner.

Parameters
obpet trying to follow. Will be object_remove()'d if can't follow.
ownerowner of ob.
Note
follow_owner() has been renamed to pets_follow_owner()

Definition at line 293 of file pets.c.

References draw_ext_info(), FLAG_REMOVED, freearr_x, freearr_y, mapdef::in_memory, llevError, llevMonster, LOG(), obj::map, MAP_IN_MEMORY, MSG_TYPE_SPELL, MSG_TYPE_SPELL_PET, obj::name, NDI_UNIQUE, object_find_free_spot(), object_insert_in_map_at(), object_remove(), PLAYER, QUERY_FLAG, SIZEOFFREE, obj::type, obj::x, and obj::y.

Referenced by monster_move(), pets_move(), and pets_remove_all().

Here is the call graph for this function:

Here is the caller graph for this function:

object* pets_get_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.
Note
pet_get_enemy() has been renamed to pets_get_enemy()

Definition at line 57 of file pets.c.

References obj::attack_movement, obj::attacked_by, obj::attacked_by_count, CLEAR_FLAG, obj::contr, obj::count, FLAG_ALIVE, FLAG_CONFUSED, FLAG_FRIENDLY, FLAG_UNAGGRESSIVE, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, get_map_flags(), get_rangevector(), get_search_arr(), HEAD, obj::map, monster_can_detect_enemy(), monster_can_see_enemy(), monster_check_enemy(), monster_find_nearest_living_creature(), object_get_owner(), object_set_enemy(), on_same_map(), P_IS_ALIVE, P_OUT_OF_MAP, pet_defend, pet_sad, pl::petmode, PETMOVE, pets_should_arena_attack(), PLAYER, QUERY_FLAG, remove_friendly_object(), SIZEOFFREE, obj::type, obj::x, and obj::y.

Referenced by monster_find_enemy().

Here is the call graph for this function:

Here is the caller graph for this function:

void pets_move ( object ob)
void pets_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.
Note
move_golem() has been renamed to pets_move_golem()

Definition at line 534 of file pets.c.

References attack_ob(), obj::contr, obj::count, obj::direction, DIRX, DIRY, draw_ext_info(), draw_ext_info_format(), FLAG_ALIVE, FLAG_MONSTER, FOR_MAP_FINISH, FOR_MAP_PREPARE, get_map_flags(), pl::golem_count, obj::head, liv::hp, llevDebug, LOG(), obj::map, obj::more, move_ob(), obj::msg, MSG_TYPE_SPELL, MSG_TYPE_SPELL_PET, obj::name, NDI_UNIQUE, object_free_drop_inventory(), object_get_owner(), object_remove(), object_update(), object_was_destroyed, P_OUT_OF_MAP, QUERY_FLAG, obj::race, range_golem, pl::ranges, remove_friendly_object(), obj::stats, UP_OBJ_FACE, obj::x, and obj::y.

Referenced by legacy_ob_process().

Here is the call graph for this function:

Here is the caller graph for this function:

void pets_remove_all ( 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...

Note
remove_all_pets() has been renamed to pets_remove_all()

Definition at line 257 of file pets.c.

References FABS, first_friendly_object, FLAG_FRIENDLY, FLAG_REMOVED, llevMonster, LOG(), MIN_ACTIVE_SPEED, oblnk::next, oblnk::ob, object_free_drop_inventory(), object_get_owner(), on_same_map(), pets_follow_owner(), PLAYER, QUERY_FLAG, remove_friendly_object(), obj::speed, and obj::type.

Referenced by enter_map(), and swap_map().

Here is the call graph for this function:

Here is the caller graph for this function:

int pets_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.
Note
should_arena_attack() has been renamed to pets_should_arena_attack()

Definition at line 1152 of file pets.c.

References obj::contr, get_real_owner(), llevError, LOG(), op_on_battleground(), pl::party, pet_arena, pl::petmode, PLAYER, and obj::type.

Referenced by monster_check_enemy(), and pets_get_enemy().

Here is the call graph for this function:

Here is the caller graph for this function:

int pets_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.
Note
summon_golem() has been renamed to pets_summon_golem()

Definition at line 672 of file pets.c.

References add_friendly_object(), add_string(), AT_PHYSICAL, obj::attack_movement, obj::attacktype, caster_level(), archt::clone, obj::contr, obj::count, liv::dam, determine_god(), determine_holy_arch(), obj::direction, draw_ext_info(), draw_ext_info_format(), obj::duration, liv::exp, FABS, find_god(), fix_summon_pet(), FLAG_FRIENDLY, FLAG_MONSTER, FREE_AND_CLEAR_STR, free_string(), freearr_x, freearr_y, GOLEM, pl::golem_count, liv::hp, llevError, LOG(), obj::map, MAX, MAX_BUF, liv::maxgrace, liv::maxhp, MIN, obj::more, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, MSG_TYPE_SPELL_PET, obj::name, NDI_UNIQUE, ob_blocked(), object_find_free_spot(), object_free_drop_inventory(), object_get_owner(), object_insert_in_map_at(), object_remove(), object_set_owner(), obj::other_arch, PETMOVE, PLAYER, QUERY_FLAG, obj::race, range_golem, pl::ranges, obj::resist, SET_FLAG, set_spell_skill(), pl::shoottype, SIZEOFFREE1, obj::slaying, snprintf, liv::sp, SP_level_dam_adjust(), SP_level_duration_adjust(), SP_level_range_adjust(), SP_level_wc_adjust(), obj::speed, obj::speed_left, obj::stats, obj::type, liv::wc, obj::x, and obj::y.

Referenced by cast_spell().

Here is the call graph for this function:

Here is the caller graph for this function:

int pets_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.
Note
summon_object() has been renamed to pets_summon_object()

Definition at line 935 of file pets.c.

References absdir(), add_friendly_object(), obj::arch, arch_to_object(), obj::attack_movement, caster_level(), choose_cult_monster(), CLEAR_FLAG, archt::clone, create_treasure(), liv::dam, determine_god(), die_roll(), obj::direction, draw_ext_info(), draw_ext_info_format(), obj::enemy, find_god(), FLAG_FRIENDLY, FLAG_MONSTER, FLAG_SLEEP, freearr_x, freearr_y, freedir, GT_STARTEQUIP, treasurestruct::item, treasureliststruct::items, obj::level, llevError, LOG(), obj::map, mark_inventory_as_no_drop(), MIN_ACTIVE_SPEED, mon, monster_check_apply_all(), obj::more, archt::more, MSG_TYPE_SPELL, MSG_TYPE_SPELL_FAILURE, treasureliststruct::name, obj::name, archt::name, NDI_UNIQUE, treasurestruct::next, treasurestruct::nrof, ob_blocked(), object_find_free_spot(), object_get_owner(), object_insert_in_map_at(), object_set_enemy(), object_set_owner(), obj::other_arch, PLAYER, PREFER_HIGH, QUERY_FLAG, obj::race, RANDOM, random_roll(), obj::randomitems, SET_FLAG, set_spell_skill(), SIZEOFFREE, SP_level_dam_adjust(), obj::stats, obj::type, obj::x, and obj::y.

Referenced by cast_spell().

Here is the call graph for this function:

Here is the caller graph for this function:

void pets_terminate_all ( object owner)

Removes all pets someone owns.

Parameters
ownerplayer we wish to remove all pets of.
Note
terminate_all_pets() has been renamed to pets_terminate_all()

Definition at line 231 of file pets.c.

References first_friendly_object, FLAG_REMOVED, oblnk::next, oblnk::ob, object_free_drop_inventory(), object_get_owner(), object_remove(), QUERY_FLAG, and remove_friendly_object().

Referenced by apply_savebed(), command_kill_pets(), key_confirm_quit(), leave(), and save_player().

Here is the call graph for this function:

Here is the caller graph for this function: