Crossfire Server, Trunk  R20513
Functions
apply.c File Reference

Handles objects being applied, and their effect. More...

#include "global.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "living.h"
#include "skills.h"
#include "sounds.h"
#include "spells.h"
#include "sproto.h"
#include "tod.h"
Include dependency graph for apply.c:

Go to the source code of this file.

Functions

int apply_auto (object *op)
 Map was just loaded, handle op's initialization. More...
 
void apply_auto_fix (mapstruct *m)
 Go through the entire map (only the first time when an original map is loaded) and performs special actions for certain objects (most initialization of chests and creation of treasures and stuff). More...
 
int apply_by_living (object *pl, object *op, int aflag, int quiet)
 Living thing is applying an object. More...
 
void apply_by_living_below (object *pl)
 Attempt to apply the object 'below' the player. More...
 
int apply_can_apply_object (const object *who, const object *op)
 Checks to see if 'who' can apply object 'op'. More...
 
void apply_changes_to_player (object *pl, object *change, int limit_stats)
 Applies (race) changes to a player. More...
 
static int apply_check_apply_restrictions (object *who, object *op, int aflags)
 Checks for general apply restrictions (no body, prohibited by god, conflicts with other items, etc.) More...
 
static int apply_check_item_power (const object *who, const object *op, int aflags)
 Checks for item power restrictions when applying an item. More...
 
static int apply_check_owner (const object *who, const object *op, int aflags)
 Checks that the item's owner matches the applier. More...
 
static int apply_check_personalized_blessings (object *who, const object *op)
 If personalized blessings are activated, the weapon can bite the wielder if he/she is not the one who initially blessed it. More...
 
static int apply_check_race_restrictions (object *who, object *item)
 Checks if an item is restricted to a race. More...
 
int apply_check_weapon_power (const object *who, int improves)
 This checks to see of the player (who) is sufficient level to use a weapon with improves improvements (typically last_eat). More...
 
int apply_container (object *op, object *sack)
 Handle apply on containers. More...
 
void apply_handle_yield (object *tmp)
 This checks whether the object has a "on_use_yield" field, and if so generated and drops matching item. More...
 
int apply_manual (object *op, object *tmp, int aflag)
 Main apply handler. More...
 
int apply_special (object *who, object *op, int aflags)
 Apply an object. More...
 
static void apply_update_ranged_skill (const object *who, object *op, int aflags)
 Updates ranged skill information. More...
 
void do_forget_spell (object *op, const char *spell)
 Erases spell from player's inventory. More...
 
void do_learn_spell (object *op, object *spell, int special_prayer)
 Actually makes op learn spell. More...
 
static objectget_item_from_body_location (object *start, int loc)
 Returns the object that is using body location 'loc'. More...
 
void legacy_apply_container (object *op, object *sack)
 
void scroll_failure (object *op, int failure, int power)
 op made some mistake with a scroll, this takes care of punishment. More...
 
int set_object_face_main (object *op)
 Makes an object's face the main face, which is supposed to be the "closed" one. More...
 
static int set_object_face_other (object *op)
 Makes an object's face the other_arch face, supposed to be the "opened" one. More...
 
int should_director_abort (const object *op, const object *victim)
 Check if op should abort moving victim because of it's race or slaying. More...
 
int transport_can_hold (const object *transport, const object *op, int nrof)
 Can transport hold object op? This is a pretty trivial function, but in the future, possible transport may have more restrictions or weight reduction like containers. More...
 
static int unapply_for_ob (object *who, object *op, int aflags)
 Remove equipment so an object can be applied. More...
 
static int unapply_special (object *who, object *op, int aflags)
 Unapplies specified item. More...
 

Detailed Description

Handles objects being applied, and their effect.

Definition in file apply.c.

Function Documentation

int apply_auto ( object op)

Map was just loaded, handle op's initialization.

Generates shop floor's item, and treasures.

Parameters
opobject to initialize.
Returns
1 if object was initialized, 0 else.
Note
auto_apply() has been renamed to apply_auto()

Definition at line 1329 of file apply.c.

References CLEAR_FLAG, create_treasure(), mapdef::difficulty, obj::env, liv::exp, FLAG_AUTO_APPLY, FLAG_BLESSED, FLAG_CURSED, FLAG_DAMNED, FLAG_IS_A_TEMPLATE, FLAG_UNPAID, FOR_INV_FINISH, FOR_INV_PREPARE, FREE_OBJ_NO_DESTROY_CALLBACK, generate_treasure(), GT_ENVIRONMENT, GT_ONLY_GOOD, HAS_RANDOM_ITEMS, liv::hp, identify(), obj::map, MAX, object_free2(), object_free_drop_inventory(), object_insert_in_map_at(), object_insert_in_ob(), object_remove(), QUERY_FLAG, obj::randomitems, SET_FLAG, SHOP_FLOOR, obj::stats, TREASURE, obj::type, obj::x, and obj::y.

Referenced by apply_auto_fix().

Here is the call graph for this function:

Here is the caller graph for this function:

void apply_auto_fix ( mapstruct m)

Go through the entire map (only the first time when an original map is loaded) and performs special actions for certain objects (most initialization of chests and creation of treasures and stuff).

Calls apply_auto() if appropriate.

Parameters
mmap to fix.
Note
fix_auto_apply() has been renamed to apply_auto_fix()

Definition at line 1395 of file apply.c.

References ALTAR, apply_auto(), check_trigger(), CLASS, CONTAINER, create_treasure(), mapdef::difficulty, FIREWALL, FLAG_AUTO_APPLY, FLAG_IS_LINKED, FLAG_MONSTER, FOR_INV_FINISH, FOR_INV_PREPARE, FOR_MAP_FINISH, FOR_MAP_PREPARE, HAS_RANDOM_ITEMS, HEAD, MAP_HEIGHT, MAP_WIDTH, monster_check_apply_all(), object_update_speed(), PLAYER, PLAYER_CHANGER, POTION, QUERY_FLAG, ROD, SCROLL, SPELL, SPELLBOOK, TIMED_GATE, TREASURE, TRIGGER_BUTTON, TRIGGER_PEDESTAL, and WAND.

Here is the call graph for this function:

int apply_by_living ( object pl,
object op,
int  aflag,
int  quiet 
)

Living thing is applying an object.

Parameters
plobject causing op to be applied.
opobject being applied.
aflagspecial (always apply/unapply) flags. Nothing is done with them in this function - they are passed to apply_special().
quietif 1, suppresses the "don't know how to apply" and "you must get it first" messages as needed by apply_by_living_below(). There can still be "but you are floating high above the ground" messages.
Returns
  • 0: player or monster can't apply objects of that type
  • 1: has been applied, or there was an error applying the object
  • 2: objects of that type can't be applied if not in inventory
Note
player_apply() has been renamed to apply_by_living()

Definition at line 557 of file apply.c.

References obj::anim_suffix, apply_anim_suffix(), apply_manual(), draw_ext_info(), draw_ext_info_format(), obj::env, FLAG_WAS_WIZ, FLAG_WIZ, MAX_BUF, METHOD_ERROR, METHOD_OK, METHOD_SILENT_ERROR, METHOD_UNHANDLED, MOVE_FLYING, obj::move_type, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, account_struct::name, NDI_UNIQUE, object_free2(), object_remove(), play_sound_map(), PLAYER, QUERY_FLAG, query_name(), SOUND_TYPE_ITEM, and obj::type.

Referenced by apply_by_living_below(), apply_cmd(), and command_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

void apply_by_living_below ( object pl)

Attempt to apply the object 'below' the player.

If the player has an open container, we use that for below, otherwise we use the ground.

Parameters
plplayer.
Note
player_apply_below() has been renamed to apply_by_living_below()

Definition at line 618 of file apply.c.

References apply_by_living(), obj::below, obj::container, obj::contr, FLAG_IS_FLOOR, FOR_OB_AND_BELOW_FINISH, FOR_OB_AND_BELOW_PREPARE, obj::inv, obj::invisible, METHOD_OK, obj::move_on, obj::move_type, ob_apply(), QUERY_FLAG, TRANSPORT, pl::transport, and obj::type.

Referenced by cfapi_object_apply_below(), command_apply(), and knowledge_alchemy_attempt().

Here is the call graph for this function:

Here is the caller graph for this function:

int apply_can_apply_object ( const object who,
const object op 
)

Checks to see if 'who' can apply object 'op'.

Parameters
wholiving thing trying to apply op.
opobject applied.
Returns
0 if apply can be done without anything special. Otherwise returns a bitmask of CAN_APPLY_xxx - potentially several of these may be set, but largely depends on circumstance - in the future, processing may be pruned once we know some status (eg, once CAN_APPLY_NEVER is set, do we really are what the other flags may be?) See include/define.h for detailed description of the meaning of these return values.
Note
can_apply_object() has been renamed to apply_can_apply_object()

Definition at line 942 of file apply.c.

References obj::body_info, obj::body_used, BOW, CAN_APPLY_NEVER, CAN_APPLY_RESTRICTION, CAN_APPLY_UNAPPLY, CAN_APPLY_UNAPPLY_CHOICE, CAN_APPLY_UNAPPLY_MULT, FABS, FLAG_USE_ARMOUR, FLAG_USE_BOW, FLAG_USE_RANGE, FLAG_USE_RING, FLAG_USE_SHIELD, FLAG_USE_WEAPON, get_item_from_body_location(), obj::inv, IS_ARMOR, IS_SHIELD, IS_WEAPON, NUM_BODY_LOCATIONS, object_find_by_type_applied(), PLAYER, QUERY_FLAG, RING, ROD, SHIELD, obj::type, WAND, and WEAPON.

Referenced by apply_check_apply_restrictions(), and monster_check_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

void apply_changes_to_player ( object pl,
object change,
int  limit_stats 
)

Applies (race) changes to a player.

Parameters
plobject to change.
changewhat kind of changes to apply. Should be of type CLASS.
limit_statsuses the AC_PLAYER_STAT defines from define.h: AC_PLAYER_STAT_LIMIT: Limit stats to racial maximum AC_PLAYER_STAT_NO_CHANGE: Do not make any stat adjustments

Definition at line 1581 of file apply.c.

References AC_PLAYER_STAT_LIMIT, AC_PLAYER_STAT_NO_CHANGE, obj::anim_speed, obj::anim_suffix, animate_object(), obj::animation_id, animations, obj::arch, change_attr_value(), CHARISMA, CLASS, CLEAR_FLAG, archt::clone, obj::contr, obj::face, obj::facing, FLAG_ANIMATE, FLAG_USE_WEAPON, FORCE, GET_ANIM_ID, get_attr_value(), give_initial_items(), MAX_BUF, animations_struct::name, NUM_STATS, object_find_by_name(), object_present_in_ob_by_name(), pl::orig_stats, QUERY_FLAG, obj::randomitems, rndm(), set_attr_value(), SET_FLAG, snprintf, obj::stats, try_find_animation(), and obj::type.

Referenced by apply_race_and_class(), and player_changer_type_process().

Here is the call graph for this function:

Here is the caller graph for this function:

static int apply_check_apply_restrictions ( object who,
object op,
int  aflags 
)
static

Checks for general apply restrictions (no body, prohibited by god, conflicts with other items, etc.)

Parameters
whothe object applying the item
opthe item being applied
aflagscombinaison of AP_xxx flags
Returns
whether applying is possible

Definition at line 1706 of file apply.c.

References AP_NOPRINT, AP_PRINT, apply_can_apply_object(), CAN_APPLY_NEVER, CAN_APPLY_RESTRICTION, CAN_APPLY_UNAPPLY_CHOICE, obj::contr, draw_ext_info(), draw_ext_info_format(), MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BADBODY, MSG_TYPE_APPLY_PROHIBITION, MSG_TYPE_APPLY_UNAPPLY, NDI_UNIQUE, PLAYER, query_name(), obj::type, pl::unapply, unapply_always, unapply_for_ob(), unapply_never, and unapply_nochoice.

Referenced by apply_special().

Here is the call graph for this function:

Here is the caller graph for this function:

static int apply_check_item_power ( const object who,
const object op,
int  aflags 
)
static

Checks for item power restrictions when applying an item.

Parameters
whothe object applying the item
opthe item being applied
aflagscombinaison of AP_xxx flags
Returns
whether applying is possible

Definition at line 1773 of file apply.c.

References AP_NOPRINT, obj::contr, draw_ext_info(), pl::item_power, obj::item_power, Settings::item_power_factor, obj::level, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, NDI_UNIQUE, PLAYER, settings, and obj::type.

Referenced by apply_special().

Here is the call graph for this function:

Here is the caller graph for this function:

static int apply_check_owner ( const object who,
const object op,
int  aflags 
)
static

Checks that the item's owner matches the applier.

If the weapon does not have the name as the character, can't use it. (Ragnarok's sword attempted to be used by Foo: won't work).

Parameters
whothe object applying the item
opthe item being applied
aflagscombination of AP_xxx flags
Returns
whether applying is possible

Definition at line 1877 of file apply.c.

References AP_NOPRINT, draw_ext_info(), obj::level, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, obj::name, and NDI_UNIQUE.

Referenced by apply_special().

Here is the call graph for this function:

Here is the caller graph for this function:

static int apply_check_personalized_blessings ( object who,
const object op 
)
static

If personalized blessings are activated, the weapon can bite the wielder if he/she is not the one who initially blessed it.

Chances of being hurt depend on the experience amount ("willpower") the object has, compared to the experience amount of the wielder.

Parameters
whothe object applying the item
opthe item being applied
Returns
whether applying is possible

Definition at line 1801 of file apply.c.

References draw_ext_info_format(), liv::exp, liv::hp, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, MSG_TYPE_APPLY_SUCCESS, MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_WAS_HIT, obj::name, NDI_UNIQUE, object_get_value(), Settings::personalized_blessings, random_roll(), settings, and obj::stats.

Referenced by apply_special().

Here is the call graph for this function:

Here is the caller graph for this function:

static int apply_check_race_restrictions ( object who,
object item 
)
static

Checks if an item is restricted to a race.

Non players and DMs can always apply.

Parameters
wholiving thing trying to apply an item.
itemitem being applied.
Returns
0 if item can't be applied, 1 else.
Note
check_race_restrictions() has been renamed to apply_check_race_restrictions()

Definition at line 467 of file apply.c.

References draw_ext_info_format(), FLAG_WIZ, MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_PROHIBITION, NDI_UNIQUE, object_get_value(), PLAYER, QUERY_FLAG, query_name(), obj::race, snprintf, and obj::type.

Referenced by apply_manual().

Here is the call graph for this function:

Here is the caller graph for this function:

int apply_check_weapon_power ( const object who,
int  improves 
)

This checks to see of the player (who) is sufficient level to use a weapon with improves improvements (typically last_eat).

We take an int here instead of the object so that the improvement code can pass along the increased value to see if the object is usable. we return 1 (true) if the player can use the weapon. See ../types/weapon_improver/weapon_improver.c

Parameters
wholiving to check
improvesimprovement level.
Returns
1 if who can use the item, 0 else.

Definition at line 1057 of file apply.c.

References obj::level.

Referenced by apply_special(), and improve_weapon().

Here is the caller graph for this function:

int apply_container ( object op,
object sack 
)

Handle apply on containers.

This is for containers that are applied by a player, whether in inventory or on the ground: eg, sacks, luggage, etc.

Moved to own function and added many features [Tero.Haatanen(at)lut.fi] This version is for client/server mode.

Reminder - there are three states for any container - closed (non applied), applied (not open, but objects that match get tossed into it), and open (applied flag set, and op->container points to the open container)

Parameters
opplayer.
sackcontainer the player is opening or closing.
Returns
1 if an object is applied somehow or another, 0 if error/no apply
Author
Eneq(at)(csd.uu.se)

Definition at line 216 of file apply.c.

References CLEAR_FLAG, CONTAINER, obj::container, socket_struct::container_position, obj::contr, obj::count, draw_ext_info_format(), obj::env, esrv_send_inventory(), esrv_send_item(), esrv_update_item(), EVENT_CLOSE, execute_event(), find_key(), FLAG_APPLIED, INS_NO_MERGE, llevError, LOG(), obj::map, MAX_BUF, MOVE_ALL, obj::move_off, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, MSG_TYPE_APPLY_SUCCESS, MSG_TYPE_APPLY_UNAPPLY, obj::name, NDI_UNIQUE, obj::nrof, object_insert_in_map_at(), object_insert_in_ob(), object_split(), object_was_destroyed, PLAYER, QUERY_FLAG, query_name(), SCRIPT_FIX_ALL, SET_FLAG, set_object_face_main(), set_object_face_other(), obj::slaying, pl::socket, obj::type, UPD_FACE, UPD_FLAGS, obj::x, and obj::y.

Referenced by legacy_apply_container(), and loot_object().

Here is the call graph for this function:

Here is the caller graph for this function:

void apply_handle_yield ( object tmp)

This checks whether the object has a "on_use_yield" field, and if so generated and drops matching item.

Parameters
tmpitem that was applied.
Note
handle_apply_yield() has been renamed to apply_handle_yield()

Definition at line 125 of file apply.c.

References create_archetype(), drop(), obj::env, INS_BELOW_ORIGINATOR, obj::map, object_get_value(), object_insert_in_map_at(), object_insert_in_ob(), obj::x, and obj::y.

Referenced by food_type_apply(), poison_type_apply(), and potion_type_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

int apply_manual ( object op,
object tmp,
int  aflag 
)

Main apply handler.

Checks for unpaid items before applying.

Parameters
opobject causing tmp to be applied.
tmpobject being applied.
aflagspecial (always apply/unapply) flags. Nothing is done with them in this function - they are passed to apply_special().
Returns
  • 0: player or monster can't apply objects of that type
  • 1: has been applied, or there was an error applying the object
  • 2: objects of that type can't be applied if not in inventory
Note
manual_apply() has been renamed to apply_manual()

Definition at line 510 of file apply.c.

References apply_check_race_restrictions(), obj::contr, draw_ext_info(), EVENT_APPLY, execute_event(), FLAG_APPLIED, FLAG_UNPAID, HEAD, METHOD_OK, METHOD_SILENT_ERROR, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, NDI_UNIQUE, ob_apply(), play_sound_player_only(), PLAYER, QUERY_FLAG, SCRIPT_FIX_ALL, SOUND_TYPE_ITEM, and obj::type.

Referenced by apply_by_living(), cfapi_object_apply(), give_initial_items(), monster_apply_below(), monster_check_apply(), polymorph_living(), transmute_item_to_flower(), and write_scroll().

Here is the call graph for this function:

Here is the caller graph for this function:

int apply_special ( object who,
object op,
int  aflags 
)

Apply an object.

This function doesn't check for unpaid items, but check other restrictions.

Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE)

Parameters
whoobject using op. It can be a monster.
opobject being used. Should be an equipment type item, eg, one which you put on and keep on for a while, and not something like a potion or scroll.
aflagscombination of AP_xxx flags.
Returns
1 if the action could not be completed, 0 on success. However, success is a matter of meaning - if the user passes the 'apply' flag to an object already applied, nothing is done, and 0 is returned.

Definition at line 1082 of file apply.c.

References AMULET, AP_APPLY, AP_BASIC_FLAGS, AP_IGNORE_CURSE, AP_NOPRINT, AP_UNAPPLY, apply_check_apply_restrictions(), apply_check_item_power(), apply_check_owner(), apply_check_personalized_blessings(), apply_check_weapon_power(), apply_update_ranged_skill(), ARMOUR, BOOTS, BOW, BRACERS, BUILDER, change_abil(), change_skill(), obj::chosen_skill, CLOAK, obj::contr, draw_ext_info(), draw_ext_info_format(), obj::env, esrv_update_item(), find_skill_by_name(), fix_object(), FLAG_APPLIED, FLAG_BEEN_APPLIED, FLAG_CURSED, FLAG_DAMNED, FLAG_KNOWN_CURSED, FLAG_READY_BOW, FLAG_READY_RANGE, FLAG_READY_SKILL, FLAG_READY_WEAPON, GIRDLE, GLOVES, HELMET, obj::last_eat, llevError, LOG(), MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_CURSED, MSG_TYPE_APPLY_ERROR, MSG_TYPE_APPLY_SUCCESS, MSG_TYPE_APPLY_UNAPPLY, NDI_UNIQUE, obj::nrof, object_insert_in_ob(), object_split(), PLAYER, QUERY_FLAG, query_name(), obj::race, range_bow, range_builder, range_misc, pl::ranges, RING, ROD, SET_FLAG, SHIELD, pl::shoottype, SKILL, obj::skill, SKILL_TOOL, obj::type, unapply_special(), UPD_FLAGS, UPD_NROF, UPD_WEIGHT, WAND, and WEAPON.

Referenced by adjust_skill_tool(), attack_hth(), change_skill(), drop_object(), find_throw_ob(), improve_armour(), improve_weapon(), legacy_ob_apply(), put_object_in_sack(), and stop_using_item().

Here is the call graph for this function:

Here is the caller graph for this function:

static void apply_update_ranged_skill ( const object who,
object op,
int  aflags 
)
static

Updates ranged skill information.

Parameters
whothe object applying the item
opthe item being applied
aflagscombination of AP_xxx flags

Definition at line 1903 of file apply.c.

References AP_NOPRINT, obj::contr, draw_ext_info_format(), obj::invisible, MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, obj::name, NDI_UNIQUE, PLAYER, query_name(), range_skill, pl::ranges, pl::shoottype, obj::skill, and obj::type.

Referenced by apply_special().

Here is the call graph for this function:

Here is the caller graph for this function:

void do_forget_spell ( object op,
const char *  spell 
)

Erases spell from player's inventory.

Will inform player of loss.

Parameters
opplayer.
spellspell name to forget.

Definition at line 432 of file apply.c.

References check_spell_known(), obj::contr, draw_ext_info_format(), esrv_remove_spell(), llevError, LOG(), MSG_TYPE_APPLY, MSG_TYPE_APPLY_CURSED, NDI_NAVY, NDI_UNIQUE, object_free2(), object_remove(), PLAYER, player_unready_range_ob(), and obj::type.

Referenced by cfapi_object_forget_spell(), command_forget_spell(), and spellbook_type_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

void do_learn_spell ( object op,
object spell,
int  special_prayer 
)

Actually makes op learn spell.

Informs player of new spell and binding.

Parameters
opplayer who'll learn the spell.
spellspell to learn.
special_prayer1 for god-given prayer, 0 else.

Definition at line 391 of file apply.c.

References check_spell_known(), obj::contr, draw_ext_info_format(), esrv_add_spells(), FLAG_STARTEQUIP, llevError, LOG(), MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, obj::name, NDI_UNIQUE, object_copy(), object_insert_in_ob(), object_new(), play_sound_player_only(), PLAYER, QUERY_FLAG, SET_FLAG, SOUND_TYPE_SPELL, and obj::type.

Referenced by cfapi_object_learn_spell(), command_learn_spell_or_prayer(), dragon_ability_gain(), god_intervention(), and spellbook_type_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

static object* get_item_from_body_location ( object start,
int  loc 
)
static

Returns the object that is using body location 'loc'.

Note that 'start' is the first object to start examine - we then go through the below of this. In this way, you can do something like: tmp = get_item_from_body_location(who->inv, 1); if (tmp) tmp1 = get_item_from_body_location(tmp->below, 1); to find the second object that may use this location, etc.

Don't return invisible objects unless they are skill objects. Invisible other objects that use up body locations can be used as restrictions.

Parameters
startobject to start from.
locbody position to search. Must be between 0 and NUM_BODY_LOCATIONS-1.
Returns
object at position, NULL if none.

Definition at line 801 of file apply.c.

References obj::body_info, FLAG_APPLIED, FOR_OB_AND_BELOW_FINISH, FOR_OB_AND_BELOW_PREPARE, obj::invisible, QUERY_FLAG, SKILL, and obj::type.

Referenced by apply_can_apply_object(), and unapply_for_ob().

Here is the caller graph for this function:

void legacy_apply_container ( object op,
object sack 
)

Definition at line 1689 of file apply.c.

References apply_container().

Referenced by container_type_move_on(), and legacy_ob_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

void scroll_failure ( object op,
int  failure,
int  power 
)

op made some mistake with a scroll, this takes care of punishment.

scroll_failure()- hacked directly from spell_failure

If settings.spell_failure_effects is FALSE, the only nasty things that can happen are weird spell cast, or mana drain.

Parameters
opwho failed.
failurewhat kind of nasty things happen.
powerthe higher the value, the worse the thing that happens.

Definition at line 1509 of file apply.c.

References blind_living(), cast_magic_storm(), cast_wonder(), confuse_living(), create_archetype(), draw_ext_info(), FREE_OBJ_NO_DESTROY_CALLBACK, LOOSE_MANA, MSG_TYPE_APPLY, MSG_TYPE_APPLY_FAILURE, NDI_UNIQUE, object_free2(), paralyze_living(), PREFER_LOW, random_roll(), settings, liv::sp, Settings::spell_failure_effects, SPELL_WONDER, obj::stats, and TRUE.

Referenced by scroll_type_apply(), and spellbook_type_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

int set_object_face_main ( object op)

Makes an object's face the main face, which is supposed to be the "closed" one.

Sets an object's face to the 'face' in the archetype. Meant for showing containers opening and closing.

Parameters
opObject to set face on
Returns
TRUE if face changed

Definition at line 149 of file apply.c.

References obj::arch, archt::clone, obj::face, FALSE, find_face(), new_faces, new_face_struct::number, object_get_value(), and TRUE.

Referenced by apply_container(), and put_object_in_sack().

Here is the call graph for this function:

Here is the caller graph for this function:

static int set_object_face_other ( object op)
static

Makes an object's face the other_arch face, supposed to be the "opened" one.

Sets an object's face to the other_arch 'face'. Meant for showing containers opening and closing.

Parameters
opObject to set face on
Returns
TRUE if face changed

Definition at line 173 of file apply.c.

References obj::arch, archt::clone, obj::face, FALSE, find_face(), new_face_struct::name, new_faces, new_face_struct::number, object_get_value(), object_set_value(), obj::other_arch, and TRUE.

Referenced by apply_container().

Here is the call graph for this function:

Here is the caller graph for this function:

int should_director_abort ( const object op,
const object victim 
)

Check if op should abort moving victim because of it's race or slaying.

Parameters
opdetector or equivalent we're testing. Note that its type is not checked.
victimobject trying to move on op.
Returns
1 if it should abort, 0 if it should continue.

Definition at line 68 of file apply.c.

References obj::arch, DOOR, obj::name, archt::name, obj::race, obj::slaying, obj::subtype, and obj::type.

Referenced by director_type_move_on(), move_player_mover(), and player_mover_type_move_on().

Here is the caller graph for this function:

int transport_can_hold ( const object transport,
const object op,
int  nrof 
)

Can transport hold object op? This is a pretty trivial function, but in the future, possible transport may have more restrictions or weight reduction like containers.

Parameters
transporttransport to check.
opobject we're trying to insert.
nrofnumber of op.
Returns
1 if can hold, 0 else.

Definition at line 54 of file apply.c.

References obj::carrying, obj::weight, and obj::weight_limit.

Referenced by esrv_move_object(), put_object_in_sack(), and transport_type_apply().

Here is the caller graph for this function:

static int unapply_for_ob ( object who,
object op,
int  aflags 
)
static

Remove equipment so an object can be applied.

This should only be called when it is known that there are objects to unapply. This makes pretty heavy use of get_item_from_body_location(). It makes no intelligent choice on objects - rather, the first that matched is used.

if aflags has AP_PRINT set, we instead print out what to unapply instead of doing it. This is a lot less code than having another function that does just that.

Parameters
wholiving trying to apply op.
opobject being applied.
aflagscombination of AP_xxx flags.
Returns
0 on success, 1 if there is some problem.

Definition at line 838 of file apply.c.

References AP_IGNORE_CURSE, AP_NOPRINT, AP_PRINT, obj::below, obj::body_info, obj::body_used, draw_ext_info(), draw_ext_info_format(), FLAG_APPLIED, FLAG_CURSED, FLAG_DAMNED, FOR_INV_FINISH, FOR_INV_PREPARE, get_item_from_body_location(), obj::inv, MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_UNAPPLY, account_struct::name, NDI_UNIQUE, NUM_BODY_LOCATIONS, QUERY_FLAG, query_name(), SHIELD, obj::type, unapply_special(), and WEAPON.

Referenced by apply_check_apply_restrictions().

Here is the call graph for this function:

Here is the caller graph for this function:

static int unapply_special ( object who,
object op,
int  aflags 
)
static

Unapplies specified item.

No check done on cursed/damned. Break this out of apply_special() - this is just done to keep the size of apply_special() to a more manageable size.

Parameters
wholiving that has op removed.
opobject.
aflagscombination of AP_xxx flags.
Returns
0.

Definition at line 674 of file apply.c.

References AMULET, AP_NO_MERGE, AP_NOPRINT, ARMOUR, BOOTS, BOW, BRACERS, BUILDER, change_abil(), obj::chosen_skill, CLEAR_FLAG, clear_skill(), CLOAK, obj::contr, obj::current_weapon, draw_ext_info_format(), esrv_update_item(), fix_object(), FLAG_APPLIED, FLAG_READY_BOW, FLAG_READY_RANGE, FLAG_READY_SKILL, FLAG_READY_WEAPON, GIRDLE, GLOVES, HELMET, obj::invisible, LAMP, llevError, LOG(), MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_UNAPPLY, account_struct::name, NDI_UNIQUE, object_merge(), PLAYER, query_name(), range_builder, range_none, range_skill, pl::ranges, RING, ROD, SHIELD, pl::shoottype, SKILL, obj::skill, SKILL_TOOL, obj::type, UPD_FLAGS, WAND, and WEAPON.

Referenced by apply_special(), and unapply_for_ob().

Here is the call graph for this function:

Here is the caller graph for this function: