Crossfire Server, Trunk
|
#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"
Go to the source code of this file.
Functions | |
int | apply_auto (object *op) |
void | apply_auto_fix (mapstruct *m) |
int | apply_by_living (object *pl, object *op, int aflag, int quiet) |
void | apply_by_living_below (object *pl) |
int | apply_can_apply_object (const object *who, const object *op) |
void | apply_changes_to_player (object *pl, object *change, int limit_stats) |
static int | apply_check_apply_restrictions (object *who, object *op, int aflags) |
static int | apply_check_item_power (const object *who, const object *op, int aflags) |
static int | apply_check_owner (const object *who, const object *op, int aflags) |
static int | apply_check_personalized_blessings (object *who, const object *op) |
static int | apply_check_race_restrictions (object *who, object *item) |
int | apply_check_weapon_power (const object *who, int improves) |
int | apply_container (object *op, object *sack, int aflags) |
void | apply_handle_yield (object *tmp) |
int | apply_manual (object *op, object *tmp, int aflag) |
int | apply_special (object *who, object *op, int aflags) |
static void | apply_update_ranged_skill (const object *who, object *op, int aflags) |
static void | auto_apply_fix_inventory (mapstruct *m, object *tmp) |
void | do_forget_spell (object *op, const char *spell) |
void | do_learn_spell (object *op, object *spell, int special_prayer) |
static object * | get_item_from_body_location (object *start, int loc) |
void | scroll_failure (object *op, int failure, int power) |
int | set_object_face_main (object *op) |
static int | set_object_face_other (object *op) |
int | should_director_abort (const object *op, const object *victim) |
int | transport_can_hold (const object *transport, const object *op, int nrof) |
static int | unapply_for_ob (object *who, object *op, int aflags) |
static int | unapply_special (object *who, object *op, int aflags) |
Handles objects being applied, and their effect.
Definition in file apply.cpp.
int apply_auto | ( | object * | op | ) |
Map was just loaded, handle op's initialization.
Generates shop floor's item, and treasures.
op | object to initialize. |
Definition at line 1400 of file apply.cpp.
References CLEAR_FLAG, create_treasure(), FLAG_AUTO_APPLY, FLAG_BLESSED, FLAG_CURSED, FLAG_DAMNED, FLAG_IDENTIFIED, FLAG_IS_A_TEMPLATE, FLAG_KNOWN_MAGICAL, FLAG_UNPAID, FOR_INV_FINISH, FOR_INV_PREPARE, FREE_OBJ_NO_DESTROY_CALLBACK, generate_treasure(), GT_ENVIRONMENT, GT_ONLY_GOOD, HAS_RANDOM_ITEMS, identify(), is_magical(), MAX, object_free(), object_free_drop_inventory(), object_insert_in_map_at(), object_insert_in_ob(), object_remove(), give::op, QUERY_FLAG, SET_FLAG, SHOP_FLOOR, Ice::tmp, and TREASURE.
Referenced by apply_auto_fix(), and auto_apply_fix_inventory().
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.
m | map to fix. |
Definition at line 1527 of file apply.cpp.
References apply_auto(), auto_apply_fix_inventory(), check_trigger(), CLASS, CONTAINER, create_treasure(), FLAG_AUTO_APPLY, FLAG_IS_LINKED, FLAG_MONSTER, FOR_MAP_FINISH, FOR_MAP_PREPARE, HAS_RANDOM_ITEMS, HEAD, m, MAP_HEIGHT, MAP_WIDTH, monster_check_apply_all(), object_update_speed(), PLAYER, PLAYER_CHANGER, QUERY_FLAG, SPELL, TIMED_GATE, Ice::tmp, TREASURE, TRIGGER_BUTTON, TRIGGER_PEDESTAL, diamondslots::x, and diamondslots::y.
Living thing is applying an object.
pl | object causing op to be applied. |
op | object being applied. |
aflag | special (always apply/unapply) flags. Nothing is done with them in this function - they are passed to apply_special(). |
quiet | if 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. |
Definition at line 637 of file apply.cpp.
References apply_anim_suffix(), apply_manual(), draw_ext_info(), draw_ext_info_format(), FLAG_WAS_WIZ, FLAG_WIZ, MAX_BUF, METHOD_ERROR, METHOD_OK, METHOD_SILENT_ERROR, METHOD_UNHANDLED, MOVE_FLYING, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, give::name, NDI_UNIQUE, object_free(), object_remove(), give::op, altar_valkyrie::pl, play_sound_map(), PLAYER, QUERY_FLAG, query_name(), SOUND_TYPE_ITEM, and Ice::tmp.
Referenced by apply_by_living_below(), apply_cmd(), and command_apply().
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.
pl | player. |
Definition at line 695 of file apply.cpp.
References apply_by_living(), FLAG_IS_FLOOR, banquet::floors, FOR_OB_AND_BELOW_FINISH, FOR_OB_AND_BELOW_PREPARE, METHOD_OK, ob_apply(), altar_valkyrie::pl, QUERY_FLAG, Ice::tmp, and TRANSPORT.
Referenced by cfapi_object_apply_below(), command_apply(), and knowledge_alchemy_attempt().
Checks to see if 'who' can apply object 'op'.
who | living thing trying to apply op. |
op | object applied. |
Definition at line 1016 of file apply.cpp.
References object::body_info, 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(), IS_ARMOR, IS_SHIELD, IS_WEAPON, NUM_BODY_LOCATIONS, object_find_by_type_applied(), give::op, PLAYER, QUERY_FLAG, RING, ROD, SHIELD, Ice::tmp, WAND, WEAPON, and autojail::who.
Referenced by apply_check_apply_restrictions(), and monster_check_apply().
Applies (race) changes to a player.
pl | object to change. |
change | what kind of changes to apply. Should be of type CLASS. |
limit_stats | uses 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 1672 of file apply.cpp.
References AC_PLAYER_STAT_LIMIT, AC_PLAYER_STAT_NO_CHANGE, animate::anim, object::anim_suffix, animate_object(), buf, change_attr_value(), CHARISMA, CLASS, CLEAR_FLAG, object::face, FLAG_ANIMATE, FLAG_USE_WEAPON, FORCE, GET_ANIM, get_attr_value(), give_initial_items(), MAX_BUF, NUM_STATS, object_find_by_name(), object_present_in_ob_by_name(), altar_valkyrie::pl, QUERY_FLAG, object::randomitems, rndm(), set_attr_value(), SET_FLAG, object::stats, try_find_animation(), and object::type.
Referenced by apply_race_and_class(), and player_changer_type_process().
Checks for general apply restrictions (no body, prohibited by god, conflicts with other items, etc.)
who | the object applying the item |
op | the item being applied |
aflags | combinaison of AP_xxx flags |
Definition at line 1800 of file apply.cpp.
References AP_NOPRINT, AP_PRINT, apply_can_apply_object(), CAN_APPLY_NEVER, CAN_APPLY_RESTRICTION, CAN_APPLY_UNAPPLY_CHOICE, 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, give::op, PLAYER, query_name(), unapply_always, unapply_for_ob(), unapply_never, unapply_nochoice, and autojail::who.
Referenced by apply_special().
Checks for item power restrictions when applying an item.
who | the object applying the item |
op | the item being applied |
aflags | combinaison of AP_xxx flags |
Definition at line 1867 of file apply.cpp.
References AP_NOPRINT, draw_ext_info(), Settings::item_power_factor, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, NDI_UNIQUE, give::op, PLAYER, settings, and autojail::who.
Referenced by apply_special().
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).
who | the object applying the item |
op | the item being applied |
aflags | combination of AP_xxx flags |
Definition at line 1971 of file apply.cpp.
References AP_NOPRINT, draw_ext_info(), MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, NDI_UNIQUE, give::op, and autojail::who.
Referenced by apply_special().
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.
who | the object applying the item |
op | the item being applied |
Definition at line 1895 of file apply.cpp.
References draw_ext_info_format(), navar-midane_pickup::msg, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, MSG_TYPE_APPLY_SUCCESS, MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_WAS_HIT, NDI_UNIQUE, object_get_value(), give::op, Settings::personalized_blessings, random_roll(), settings, and autojail::who.
Referenced by apply_special().
Checks if an item is restricted to a race. Non players and DMs can always apply.
who | living thing trying to apply an item. |
item | item being applied. |
Definition at line 557 of file apply.cpp.
References buf, 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(), sstring, and autojail::who.
Referenced by apply_manual().
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
who | living to check |
improves | improvement level. |
Definition at line 1131 of file apply.cpp.
References autojail::who.
Referenced by apply_special(), and improve_weapon().
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)
op | player. |
sack | container the player is opening or closing. |
aflags | combination of Flags for apply_special(). flags. |
Definition at line 222 of file apply.cpp.
References AP_APPLY, AP_NULL, AP_OPEN, AP_UNAPPLY, CLEAR_FLAG, CONTAINER, draw_ext_info_format(), object::env, esrv_send_inventory(), esrv_send_item(), esrv_update_item(), EVENT_CLOSE, events_execute_object_event(), find_key(), FLAG_APPLIED, object::head, INS_NO_MERGE, llevError, LOG(), object::map, MAX_BUF, object::more, MOVE_ALL, object::move_off, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, MSG_TYPE_APPLY_SUCCESS, MSG_TYPE_APPLY_UNAPPLY, object::name, NDI_UNIQUE, object::nrof, object_insert_in_map_at(), object_insert_in_ob(), object_split(), object_was_destroyed, give::op, PLAYER, QUERY_FLAG, query_name(), SCRIPT_FIX_ALL, SET_FLAG, set_object_face_main(), set_object_face_other(), object::slaying, Ice::tmp, object::type, UPD_FACE, UPD_FLAGS, object::x, and object::y.
Referenced by container_type_move_on(), legacy_ob_apply(), and loot_object().
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.
tmp | item that was applied. |
Definition at line 122 of file apply.cpp.
References create_archetype(), drop(), INS_BELOW_ORIGINATOR, object_get_value(), object_insert_in_map_at(), object_insert_in_ob(), and Ice::tmp.
Referenced by food_type_apply(), poison_type_apply(), and potion_type_apply().
Main apply handler.
Checks for unpaid items before applying.
op | object causing tmp to be applied. |
tmp | object being applied. |
aflag | special (always apply/unapply) flags. Nothing is done with them in this function - they are passed to apply_special(). |
Definition at line 597 of file apply.cpp.
References apply_check_race_restrictions(), draw_ext_info(), FLAG_APPLIED, FLAG_UNPAID, HEAD, METHOD_SILENT_ERROR, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, NDI_UNIQUE, ob_apply(), give::op, play_sound_player_only(), PLAYER, QUERY_FLAG, SOUND_TYPE_ITEM, and Ice::tmp.
Referenced by apply_by_living(), cfapi_object_apply(), give_initial_items(), lightable_type_apply(), monster_apply_below(), monster_check_apply(), monster_use_scroll(), polymorph_living(), transmute_item_to_flower(), and write_scroll().
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)
who | object using op. It can be a monster. |
op | object 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. |
aflags | combination of AP_xxx flags. |
Definition at line 1156 of file apply.cpp.
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(), CLOAK, draw_ext_info(), draw_ext_info_format(), 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, 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, object_insert_in_ob(), object_split(), give::op, PLAYER, QUERY_FLAG, query_name(), range_bow, range_builder, range_misc, RING, ROD, SET_FLAG, SHIELD, SKILL, SKILL_TOOL, Ice::tmp, unapply_special(), UPD_FLAGS, UPD_NAME, UPD_NROF, UPD_WEIGHT, nlohmann::detail::void(), WAND, WEAPON, and autojail::who.
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().
Updates ranged skill information.
who | the object applying the item |
op | the item being applied |
aflags | combination of AP_xxx flags |
Definition at line 1997 of file apply.cpp.
References AP_NOPRINT, draw_ext_info_format(), MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, NDI_UNIQUE, give::op, PLAYER, query_name(), range_skill, and autojail::who.
Referenced by apply_special().
Go through one object on a map and process any special treasure creation or such for anything in it's inventory. Recurse through any inventory objects that have inventories of their own. This is only called by auto_apply_fix() below and by itself for recursion.
m | map to fix (only for the difficulty level for treasure creation) |
tmp | object with inventory to scan |
Definition at line 1469 of file apply.cpp.
References ALTAR, apply_auto(), CLASS, create_treasure(), FIREWALL, FLAG_AUTO_APPLY, FOR_INV_FINISH, FOR_INV_PREPARE, HAS_RANDOM_ITEMS, m, POTION, QUERY_FLAG, ROD, SCROLL, SPELL, SPELLBOOK, Ice::tmp, TREASURE, and WAND.
Referenced by apply_auto_fix().
void do_forget_spell | ( | object * | op, |
const char * | spell | ||
) |
Erases spell from player's inventory. Will inform player of loss.
op | player. |
spell | spell name to forget. |
Definition at line 525 of file apply.cpp.
References check_spell_known(), draw_ext_info_format(), esrv_remove_spell(), llevError, LOG(), MSG_TYPE_APPLY, MSG_TYPE_APPLY_CURSED, NDI_NAVY, NDI_UNIQUE, object_free(), object_remove(), give::op, PLAYER, and player_unready_range_ob().
Referenced by cfapi_object_forget_spell(), command_forget_spell(), and spellbook_type_apply().
Actually makes op learn spell. Informs player of new spell and binding.
op | player who'll learn the spell. |
spell | spell to learn. |
special_prayer | 1 for god-given prayer, 0 else. |
Definition at line 484 of file apply.cpp.
References check_spell_known(), draw_ext_info_format(), esrv_add_spells(), FLAG_STARTEQUIP, llevError, LOG(), MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, object::name, NDI_UNIQUE, object_copy(), object_insert_in_ob(), object_new(), give::op, play_sound_player_only(), PLAYER, QUERY_FLAG, SET_FLAG, SOUND_TYPE_SPELL, and Ice::tmp.
Referenced by cfapi_object_learn_spell(), command_learn_spell_or_prayer(), dragon_ability_gain(), god_intervention(), and spellbook_type_apply().
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.
start | object to start from. |
loc | body position to search. Must be between 0 and NUM_BODY_LOCATIONS-1. |
Definition at line 878 of file apply.cpp.
References FLAG_APPLIED, FOR_OB_AND_BELOW_FINISH, FOR_OB_AND_BELOW_PREPARE, QUERY_FLAG, SKILL, and Ice::tmp.
Referenced by apply_can_apply_object(), and unapply_for_ob().
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.
op | who failed. |
failure | what kind of nasty things happen. |
power | the higher the value, the worse the thing that happens. |
Definition at line 1601 of file apply.cpp.
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_free(), give::op, paralyze_living(), PREFER_LOW, random_roll(), settings, Settings::spell_failure_effects, SPELL_WONDER, Ice::tmp, and TRUE.
Referenced by scroll_type_apply(), and spellbook_type_apply().
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.
op | Object to set face on |
Definition at line 146 of file apply.cpp.
References FALSE, object_get_value(), give::op, sstring, TRUE, and try_find_face().
Referenced by apply_container(), and put_object_in_sack().
|
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.
op | Object to set face on |
Definition at line 173 of file apply.cpp.
References archetype::clone, object::face, FALSE, object_get_value(), object_set_value(), give::op, object::other_arch, sstring, TRUE, and try_find_face().
Referenced by apply_container().
Check if op should abort moving victim because of it's race or slaying.
op | detector or equivalent we're testing. Note that its type is not checked. |
victim | object trying to move on op. |
Definition at line 68 of file apply.cpp.
References DOOR, give::op, and sword_of_souls::victim.
Referenced by director_type_move_on(), move_player_mover(), and player_mover_type_move_on().
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
transport | transport to check. |
op | object we're trying to insert. |
nrof | number of op. |
Definition at line 54 of file apply.cpp.
References object::carrying, give::op, and object::weight_limit.
Referenced by esrv_move_object(), put_object_in_sack(), and transport_type_apply().
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.
Definition at line 915 of file apply.cpp.
References AP_IGNORE_CURSE, AP_NOPRINT, AP_PRINT, draw_ext_info(), draw_ext_info_format(), FLAG_APPLIED, FLAG_CURSED, FLAG_DAMNED, FOR_INV_FINISH, FOR_INV_PREPARE, get_item_from_body_location(), MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_UNAPPLY, give::name, NDI_UNIQUE, NUM_BODY_LOCATIONS, give::op, QUERY_FLAG, query_name(), SHIELD, Ice::tmp, unapply_special(), WEAPON, and autojail::who.
Referenced by apply_check_apply_restrictions().
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.
Definition at line 751 of file apply.cpp.
References AMULET, AP_NO_MERGE, AP_NOPRINT, ARMOUR, BOOTS, BOW, BRACERS, BUILDER, change_abil(), CLEAR_FLAG, clear_skill(), CLOAK, 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, LAMP, llevError, LOG(), MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_UNAPPLY, give::name, NDI_UNIQUE, object_merge(), give::op, PLAYER, query_name(), range_builder, range_none, range_skill, RING, ROD, SHIELD, SKILL, SKILL_TOOL, Ice::tmp, UPD_FLAGS, nlohmann::detail::void(), WAND, WEAPON, and autojail::who.
Referenced by apply_special(), and unapply_for_ob().