Crossfire Server, Branches 1.12
R18729
|
#include <global.h>
#include <living.h>
#include <spells.h>
#include <skills.h>
#include <tod.h>
#include <sproto.h>
#include <sounds.h>
#include <math.h>
Go to the source code of this file.
Handles objects being applied, and their effect.
Definition in file apply.c.
Applies (race) changes to a player.
pl | object to change. |
change | what kind of changes to apply. Should be of type CLASS. |
Definition at line 1776 of file apply.c.
References obj::anim_speed, obj::anim_suffix, animate_object(), obj::animation_id, animations, obj::arch, obj::below, CHA, change_attr_value(), CLASS, CLEAR_FLAG, archt::clone, obj::contr, obj::face, obj::facing, FLAG_ANIMATE, FLAG_USE_WEAPON, GET_ANIM_ID, get_attr_value(), give_initial_items(), obj::inv, MAX_BUF, animations_struct::name, obj::name, NUM_STATS, pl::orig_stats, QUERY_FLAG, obj::randomitems, rndm(), set_attr_value(), SET_FLAG, snprintf(), obj::stats, try_find_animation(), and obj::type.
Referenced by player_changer_type_process().
Handle apply on containers. This is for containers that are applied by a player, whether in inventory or on the ground: eg, sacks, luggages, 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. |
Definition at line 230 of file apply.c.
References CLEAR_FLAG, obj::container, CONTAINER, draw_ext_info_format(), obj::env, esrv_send_inventory(), esrv_send_item(), esrv_update_item(), EVENT_CLOSE, execute_event(), find_key(), FLAG_APPLIED, get_split_ob(), INS_NO_MERGE, insert_ob_in_map_at(), insert_ob_in_ob(), 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, PLAYER, QUERY_FLAG, query_name(), SCRIPT_FIX_ALL, SET_FLAG, set_object_face_main(), set_object_face_other(), obj::slaying, obj::type, UPD_FACE, UPD_FLAGS, obj::x, and obj::y.
Referenced by legacy_apply_container(), and loot_object().
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 1139 of file apply.c.
References AMULET, AP_APPLY, AP_BASIC_FLAGS, AP_IGNORE_CURSE, AP_NOPRINT, AP_PRINT, AP_UNAPPLY, ARMOUR, BOOTS, BOW, BRACERS, BUILDER, CAN_APPLY_NEVER, can_apply_object(), CAN_APPLY_RESTRICTION, CAN_APPLY_UNAPPLY_CHOICE, change_abil(), change_skill(), check_weapon_power(), obj::chosen_skill, CLOAK, obj::contr, draw_ext_info(), draw_ext_info_format(), obj::env, esrv_update_item(), liv::exp, 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, get_ob_key_value(), get_split_ob(), GIRDLE, GLOVES, HELMET, HORN, liv::hp, insert_ob_in_ob(), obj::invisible, pl::item_power, obj::item_power, Settings::item_power_factor, obj::last_eat, obj::level, llevError, LOG(), MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BADBODY, MSG_TYPE_APPLY_CURSED, MSG_TYPE_APPLY_ERROR, MSG_TYPE_APPLY_PROHIBITION, MSG_TYPE_APPLY_SUCCESS, MSG_TYPE_APPLY_UNAPPLY, MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_WAS_HIT, obj::name, NDI_UNIQUE, obj::nrof, Settings::personalized_blessings, PLAYER, QUERY_FLAG, query_name(), obj::race, random_roll(), range_bow, range_builder, range_misc, range_skill, pl::ranges, RING, ROD, SET_FLAG, settings, SHIELD, pl::shoottype, SKILL, obj::skill, SKILL_TOOL, obj::stats, obj::type, pl::unapply, unapply_always, unapply_for_ob(), unapply_never, unapply_nochoice, 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().
int auto_apply | ( | object * | op | ) |
Map was just loaded, handle op's initialisation.
Generates shop floor's item, and treasures.
op | object to initialize. |
Definition at line 1526 of file apply.c.
References obj::below, CLEAR_FLAG, create_treasure(), mapdef::difficulty, obj::env, liv::exp, FLAG_AUTO_APPLY, FLAG_CURSED, FLAG_DAMNED, FLAG_IS_A_TEMPLATE, FLAG_UNPAID, free_object(), generate_treasure(), GT_ENVIRONMENT, HAS_RANDOM_ITEMS, liv::hp, identify(), insert_ob_in_map(), insert_ob_in_ob(), obj::inv, obj::map, MAX, QUERY_FLAG, obj::randomitems, remove_ob(), SET_FLAG, SHOP_FLOOR, obj::stats, TREASURE, obj::type, obj::x, and obj::y.
Referenced by fix_auto_apply().
Checks to see if 'who' can apply object 'op'.
who | living thing trying to apply op. |
op | object applied. |
Definition at line 955 of file apply.c.
References obj::below, 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_APPLIED, FLAG_USE_ARMOUR, FLAG_USE_BOW, FLAG_USE_RANGE, FLAG_USE_RING, FLAG_USE_SHIELD, FLAG_USE_WEAPON, get_item_from_body_location(), HORN, obj::inv, IS_ARMOR, IS_SHIELD, IS_WEAPON, NUM_BODY_LOCATIONS, PLAYER, QUERY_FLAG, RING, ROD, SHIELD, obj::type, WAND, and WEAPON.
Referenced by apply_special(), and monster_check_apply().
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 472 of file apply.c.
References draw_ext_info_format(), FLAG_WIZ, get_ob_key_value(), MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_PROHIBITION, NDI_UNIQUE, PLAYER, QUERY_FLAG, query_name(), obj::race, snprintf(), and obj::type.
Referenced by manual_apply().
int check_weapon_power | ( | const object * | who, |
int | improvs | ||
) |
This checks to see of the player (who) is sufficient level to use a weapon with improvs 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 usuable. we return 1 (true) if the player can use the weapon. See ../types/weapon_improver/weapon_improver.c
who | living to check |
improvs | improvement level. |
Definition at line 1076 of file apply.c.
References obj::below, obj::inv, IS_COMBAT_SKILL, obj::level, llevError, LOG(), obj::name, PLAYER, SKILL, obj::subtype, and obj::type.
Referenced by apply_special(), and improve_weapon().
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 440 of file apply.c.
References check_spell_known(), obj::contr, draw_ext_info_format(), esrv_remove_spell(), free_object(), llevError, LOG(), MSG_TYPE_APPLY, MSG_TYPE_APPLY_CURSED, NDI_NAVY, NDI_UNIQUE, PLAYER, player_unready_range_ob(), remove_ob(), and obj::type.
Referenced by cfapi_object_forget_spell(), check_special_prayers(), 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 398 of file apply.c.
References check_spell_known(), obj::contr, copy_object(), draw_ext_info_format(), esrv_add_spells(), FLAG_STARTEQUIP, get_object(), insert_ob_in_ob(), llevError, LOG(), MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, obj::name, NDI_UNIQUE, 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().
void fix_auto_apply | ( | 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 auto_apply() if appropriate.
m | map to fix. |
Definition at line 1590 of file apply.c.
References obj::above, ALTAR, obj::arch, auto_apply(), obj::below, check_trigger(), CLASS, CONTAINER, create_treasure(), mapdef::difficulty, FIREWALL, FLAG_AUTO_APPLY, FLAG_IS_LINKED, GET_MAP_OB, GT_APPLY, HAS_RANDOM_ITEMS, obj::head, HORN, liv::hp, obj::inv, MAP_HEIGHT, MAP_WIDTH, PLAYER, PLAYER_CHANGER, POTION, QUERY_FLAG, obj::randomitems, ROD, SCROLL, obj::speed, SPELL, SPELLBOOK, obj::stats, TIMED_GATE, TREASURE, TRIGGER_BUTTON, TRIGGER_PEDESTAL, obj::type, update_ob_speed(), and WAND.
Returns the object that is using body location 'loc'. Note that 'start' is the first object to start examing - 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 814 of file apply.c.
References obj::below, obj::body_info, FLAG_APPLIED, obj::invisible, QUERY_FLAG, SKILL, and obj::type.
Referenced by can_apply_object(), and unapply_for_ob().
void handle_apply_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 131 of file apply.c.
References create_archetype(), drop(), obj::env, get_ob_key_value(), INS_BELOW_ORIGINATOR, insert_ob_in_map(), insert_ob_in_ob(), obj::map, obj::x, and obj::y.
Referenced by food_type_apply(), poison_type_apply(), and potion_type_apply().
Definition at line 1872 of file apply.c.
References apply_container().
Referenced by container_type_move_on(), and legacy_ob_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 512 of file apply.c.
References check_race_restrictions(), obj::contr, draw_ext_info(), EVENT_APPLY, execute_event(), FLAG_APPLIED, FLAG_UNPAID, obj::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 cfapi_object_apply(), give_initial_items(), monster_apply_below(), monster_check_apply(), player_apply(), polymorph_living(), transmute_item_to_flower(), and write_scroll().
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 player_apply_below(). There can still be "but you are floating high above the ground" messages. |
Definition at line 557 of file apply.c.
References obj::anim_suffix, apply_anim_suffix(), obj::contr, obj::count, draw_ext_info(), draw_ext_info_format(), obj::env, FLAG_WAS_WIZ, FLAG_WIZ, free_object(), pl::last_used, pl::last_used_id, manual_apply(), MAX_BUF, METHOD_ERROR, METHOD_OK, METHOD_SILENT_ERROR, METHOD_UNHANDLED, MOVE_FLYING, obj::move_type, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, NDI_UNIQUE, play_sound_map(), PLAYER, QUERY_FLAG, query_name(), remove_ob(), SOUND_TYPE_ITEM, and obj::type.
Referenced by apply_cmd(), command_apply(), and player_apply_below().
void player_apply_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 619 of file apply.c.
References obj::below, obj::container, obj::contr, FLAG_IS_FLOOR, obj::inv, obj::invisible, METHOD_OK, obj::move_on, obj::move_type, ob_apply(), player_apply(), QUERY_FLAG, TRANSPORT, pl::transport, and obj::type.
Referenced by cfapi_object_apply_below(), and command_apply().
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 1708 of file apply.c.
References blind_living(), cast_magic_storm(), cast_wonder(), confuse_living(), create_archetype(), draw_ext_info(), free_object(), LOOSE_MANA, MSG_TYPE_APPLY, MSG_TYPE_APPLY_FAILURE, NDI_UNIQUE, 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().
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 160 of file apply.c.
References obj::arch, archt::clone, obj::face, FALSE, find_face(), get_ob_key_value(), new_faces, new_face_struct::number, and TRUE.
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 185 of file apply.c.
References obj::arch, archt::clone, obj::face, FALSE, find_face(), get_ob_key_value(), new_face_struct::name, new_faces, new_face_struct::number, obj::other_arch, set_ob_key_value(), and TRUE.
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 81 of file apply.c.
References obj::arch, obj::name, archt::name, obj::race, obj::slaying, and obj::subtype.
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 64 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().
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 waht to unapply instead of doing it. This is a lot less code than having another function that does just that.
Definition at line 850 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, get_item_from_body_location(), obj::inv, MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_UNAPPLY, NDI_UNIQUE, NUM_BODY_LOCATIONS, QUERY_FLAG, query_name(), SHIELD, obj::type, unapply_special(), and WEAPON.
Referenced by apply_special().
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 managable size.
Definition at line 675 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, HORN, obj::invisible, LAMP, llevError, LOG(), MAX_BUF, merge_ob(), MSG_TYPE_APPLY, MSG_TYPE_APPLY_UNAPPLY, NDI_UNIQUE, PLAYER, QUERY_FLAG, 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().