Crossfire Server, Branches 1.12
R18729
|
#include <global.h>
#include <loader.h>
#include <skills.h>
#include <sproto.h>
#include <living.h>
#include <math.h>
Go to the source code of this file.
Macros | |
#define | OBLINKMALLOC(p) |
Functions | |
int | command_apply (object *op, char *params) |
int | command_disarm (object *op, char *params) |
int | command_drop (object *op, char *params) |
int | command_dropall (object *op, char *params) |
int | command_empty (object *op, char *params) |
int | command_examine (object *op, char *params) |
int | command_lock_item (object *op, char *params) |
int | command_mark (object *op, char *params) |
int | command_pickup (object *op, char *params) |
int | command_rename_item (object *op, char *params) |
int | command_rskill (object *pl, char *params) |
int | command_search (object *op, char *params) |
int | command_search_items (object *op, char *params) |
int | command_take (object *op, char *params) |
int | command_throw (object *op, char *params) |
int | command_use (object *op, char *params) |
int | command_uskill (object *pl, char *params) |
static void | display_new_pickup (const object *op) |
void | drop (object *op, object *tmp) |
object * | drop_object (object *op, object *tmp, uint32 nrof) |
static void | empty_container (object *container, object *pl) |
void | examine (object *op, object *tmp) |
void | examine_monster (object *op, object *tmp) |
static object * | find_best_apply_object_match (object *start, object *pl, const char *params, int aflag) |
static object * | find_best_object_match (object *pl, const char *params) |
object * | find_marked_object (object *op) |
void | inventory (object *op, object *inv) |
void | pick_up (object *op, object *alt) |
static void | pick_up_object (object *pl, object *op, object *tmp, int nrof) |
void | put_object_in_sack (object *op, object *sack, object *tmp, uint32 nrof) |
int | sack_can_hold (const object *pl, const object *sack, const object *op, uint32 nrof) |
static void | set_pickup_mode (const object *op, int i) |
Object commands, including picking/dropping, locking, etc.
Definition in file c_object.c.
#define OBLINKMALLOC | ( | p | ) |
Simple objectlink allocation, fail-safe.
Definition at line 50 of file c_object.c.
int command_apply | ( | object * | op, |
char * | params | ||
) |
'apply' command.
op | player. |
params | what to apply. |
Definition at line 221 of file c_object.c.
References obj::above, AP_APPLY, AP_UNAPPLY, obj::container, draw_ext_info_format(), find_best_apply_object_match(), obj::inv, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, player_apply(), and player_apply_below().
int command_disarm | ( | object * | op, |
char * | params | ||
) |
'disarm' command.
op | player. |
params | unused. |
Definition at line 181 of file c_object.c.
References SK_DISARM_TRAPS, skill_names, and use_skill().
int command_drop | ( | object * | op, |
char * | params | ||
) |
'drop' command.
op | player. |
params | what to drop. |
Definition at line 1173 of file c_object.c.
References obj::below, obj::contr, pl::count, draw_ext_info(), draw_ext_info_format(), drop(), FLAG_INV_LOCKED, FLAG_NO_DROP, obj::inv, obj::invisible, item_matched_string(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, PLAYER, QUERY_FLAG, pl::socket, obj::type, and socket_struct::update_look.
int command_dropall | ( | object * | op, |
char * | params | ||
) |
Command to drop all items that have not been locked.
op | player. |
params | optional specifier, like 'armour', 'weapon' and such. |
Definition at line 1021 of file c_object.c.
References AMULET, ARMOUR, ARMOUR_IMPROVER, ARROW, obj::below, BOOK, BOOTS, BOW, BRACERS, CLEAR_FLAG, CLOAK, obj::container, CONTAINER, obj::contr, pl::count, draw_ext_info(), DRINK, drop(), esrv_update_item(), fix_object(), FLAG_APPLIED, FLAG_INV_LOCKED, FLAG_NO_FIX_PLAYER, FLESH, FOOD, GEM, GIRDLE, GLOVES, HELMET, HORN, obj::inv, obj::invisible, KEY, MONEY, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, PLAYER, POTION, QUERY_FLAG, RING, ROD, SCROLL, SET_FLAG, SHIELD, pl::socket, SPECIAL_KEY, SPELLBOOK, obj::type, UPD_WEIGHT, socket_struct::update_look, WAND, WEAPON, and WEAPON_IMPROVER.
int command_empty | ( | object * | op, |
char * | params | ||
) |
'empty' command.
op | player. |
params | item specifier. |
Definition at line 1263 of file c_object.c.
References obj::below, CONTAINER, draw_ext_info(), empty_container(), find_best_object_match(), obj::inv, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, and obj::type.
int command_examine | ( | object * | op, |
char * | params | ||
) |
'examine' command.
op | player. |
params | optional item specifier. |
Definition at line 1306 of file c_object.c.
References obj::below, draw_ext_info_format(), examine(), find_best_object_match(), LOOK_OBJ, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, and NDI_UNIQUE.
int command_lock_item | ( | object * | op, |
char * | params | ||
) |
Alternate way to lock/unlock items (command line).
op | player |
params | sent command line. |
Definition at line 2234 of file c_object.c.
References CLEAR_FLAG, obj::count, draw_ext_info(), draw_ext_info_format(), esrv_update_item(), find_best_object_match(), FLAG_INV_LOCKED, HUGE_BUF, merge_ob(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_FAILURE, NDI_UNIQUE, QUERY_FLAG, query_short_name(), SET_FLAG, and UPD_FLAGS.
int command_mark | ( | object * | op, |
char * | params | ||
) |
'mark' command, to mark an item for some effects (enchant armor, ...).
op | player. |
params | If empty, we print out the currently marked object. Otherwise, try to find a matching object - try best match first. |
Definition at line 1376 of file c_object.c.
References obj::contr, obj::count, draw_ext_info(), draw_ext_info_format(), find_best_object_match(), find_marked_object(), pl::mark, pl::mark_count, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, and query_name().
int command_pickup | ( | object * | op, |
char * | params | ||
) |
'pickup' command.
op | player. |
params | pickup mode. Can be empty to display the current mode. |
Definition at line 1867 of file c_object.c.
References obj::contr, display_new_pickup(), draw_ext_info(), draw_ext_info_format(), llevDebug, LOG(), pl::mode, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, PU_ALLWEAPON, PU_ARMOUR, PU_ARROW, PU_BOOTS, PU_BOW, PU_CLOAK, PU_DEBUG, PU_DRINK, PU_FLESH, PU_FOOD, PU_GLOVES, PU_HELMET, PU_INHIBIT, PU_JEWELS, PU_KEY, PU_MAGIC_DEVICE, PU_MAGICAL, PU_MISSILEWEAPON, PU_NEWMODE, PU_NOT_CURSED, PU_POTION, PU_READABLES, PU_SHIELD, PU_SKILLSCROLL, PU_SPELLBOOK, PU_STOP, PU_VALUABLES, and set_pickup_mode().
int command_rename_item | ( | object * | op, |
char * | params | ||
) |
Changing the custom name of an item
Syntax is: rename <what object> to <new name>
Names are considered for all purpose having a length <=127 (max length sent to client by server).
op | player. |
params | how to rename. |
Definition at line 2047 of file c_object.c.
References obj::below, obj::count, obj::custom_name, draw_ext_info(), draw_ext_info_format(), esrv_update_item(), find_best_object_match(), find_marked_object(), FREE_AND_CLEAR_STR, FREE_AND_COPY, obj::inv, obj::invisible, MAX_BUF, merge_ob(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, obj::nrof, query_base_name(), snprintf(), UPD_NAME, and VERY_BIG_BUF.
int command_rskill | ( | object * | pl, |
char * | params | ||
) |
'ready_skill' command.
pl | player. |
params | skill name. |
Definition at line 132 of file c_object.c.
References change_skill(), draw_ext_info(), draw_ext_info_format(), find_skill_by_name(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_SKILL, MSG_TYPE_SKILL_MISSING, and NDI_UNIQUE.
int command_search | ( | object * | op, |
char * | params | ||
) |
'search' command.
op | player. |
params | unused. |
Definition at line 167 of file c_object.c.
References SK_FIND_TRAPS, skill_names, and use_skill().
int command_search_items | ( | object * | op, |
char * | params | ||
) |
'search-items' command.
op | player. |
params | options. |
Definition at line 1998 of file c_object.c.
References obj::contr, draw_ext_info(), draw_ext_info_format(), FALSE, fix_object(), MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, Settings::search_items, pl::search_str, and settings.
int command_take | ( | object * | op, |
char * | params | ||
) |
This takes (picks up) and item.
op | player who issued the command. |
params | string to match against the item name. |
Definition at line 602 of file c_object.c.
References obj::above, obj::below, can_pick(), obj::container, draw_ext_info(), draw_ext_info_format(), FLAG_IS_FLOOR, obj::inv, obj::invisible, item_matched_string(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_FAILURE, obj::name, NDI_UNIQUE, obj::next, pick_up(), and QUERY_FLAG.
int command_throw | ( | object * | op, |
char * | params | ||
) |
'throw' command.
A little special because we do want to pass the full params along as it includes the object to throw.
op | player. |
params | what to throw. |
Definition at line 198 of file c_object.c.
References do_skill(), draw_ext_info(), obj::facing, find_skill_by_name(), MSG_TYPE_SKILL, MSG_TYPE_SKILL_MISSING, NDI_UNIQUE, SK_THROWING, and skill_names.
int command_use | ( | object * | op, |
char * | params | ||
) |
Try to use an item on another. Items are checked for key/values matching.
op | player. |
params | sent string, with all parameters. |
Definition at line 2282 of file c_object.c.
References obj::arch, decrease_ob, draw_ext_info(), draw_ext_info_format(), find_archetype(), find_best_object_match(), get_ob_key_value(), insert_ob_in_ob(), llevError, LOG(), MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_FAILURE, obj::name, archt::name, NDI_UNIQUE, obj::nrof, object_create_arch(), PLAYER, snprintf(), obj::subtype, and obj::type.
int command_uskill | ( | object * | pl, |
char * | params | ||
) |
'use_skill' command.
pl | player. |
params | skill to use, and optional parameters. |
Definition at line 113 of file c_object.c.
References draw_ext_info(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, and use_skill().
|
static |
Utility function to display the pickup mode for a player.
op | must be a player. |
Definition at line 1723 of file c_object.c.
References obj::contr, draw_ext_info(), draw_ext_info_format(), pl::mode, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_INFO, NDI_UNIQUE, PU_ALLWEAPON, PU_ARMOUR, PU_ARROW, PU_BOOTS, PU_BOW, PU_CLOAK, PU_DEBUG, PU_DRINK, PU_FLESH, PU_FOOD, PU_GLOVES, PU_HELMET, PU_INHIBIT, PU_JEWELS, PU_KEY, PU_MAGIC_DEVICE, PU_MAGICAL, PU_MISSILEWEAPON, PU_NEWMODE, PU_NOT_CURSED, PU_POTION, PU_RATIO, PU_READABLES, PU_SHIELD, PU_SKILLSCROLL, PU_SPELLBOOK, PU_STOP, and PU_VALUABLES.
Referenced by command_pickup().
Drop an item, either on the floor or in a container.
op | who is dropping an item. |
tmp | what object to drop. |
Definition at line 943 of file c_object.c.
References obj::above, obj::below, obj::container, obj::contr, obj::count, pl::count, draw_ext_info(), drop_object(), obj::env, FLAG_INV_LOCKED, FLAG_NO_DROP, free_object(), obj::invisible, pl::last_used, pl::last_used_id, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, PLAYER, put_object_in_sack(), QUERY_FLAG, remove_ob(), and obj::type.
Referenced by cfapi_object_drop(), command_drop(), command_dropall(), empty_container(), and handle_apply_yield().
Try to drop an object on the floor.
This function was part of drop, now is own function.
op | who is dropping the item. |
tmp | item to drop. |
nrof | if is non zero, then nrof objects is tried to be dropped. |
Definition at line 847 of file c_object.c.
References AP_NO_MERGE, AP_UNAPPLY, apply_special(), obj::contr, obj::count, draw_ext_info(), draw_ext_info_format(), esrv_update_item(), EVENT_DROP, execute_event(), fix_object(), FLAG_APPLIED, FLAG_NO_DROP, FLAG_NO_FIX_PLAYER, FLAG_STARTEQUIP, FLAG_UNPAID, free_object(), get_split_ob(), insert_ob_in_map(), is_in_shop(), obj::map, MAX_BUF, MONEY, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, obj::nrof, PLAYER, QUERY_FLAG, query_name(), remove_ob(), save_player(), SCRIPT_FIX_ALL, sell_item(), obj::type, UPD_WEIGHT, obj::value, was_destroyed, obj::x, and obj::y.
Referenced by drop(), esrv_move_object(), and transport_type_apply().
Put all contents of the container on the ground below the player or in opened container, except locked items.
container | what to empty. |
pl | player to drop for. |
Definition at line 1223 of file c_object.c.
References obj::below, draw_ext_info_format(), drop(), esrv_update_item(), FLAG_INV_LOCKED, obj::inv, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, QUERY_FLAG, query_name(), and UPD_WEIGHT.
Referenced by command_empty().
Player examines some object.
op | player. |
tmp | object to examine. |
Definition at line 1481 of file c_object.c.
References obj::body_info, body_locations, BOOK, CLOSE_CON, CONTAINER, CORPSE, obj::custom_name, draw_ext_info(), draw_ext_info_format(), examine_monster(), EXIT, F_APPROX, F_BUY, F_SELL, F_SHOP, FLAG_IDENTIFIED, FLAG_IS_BUILDABLE, FLAG_MONSTER, FLAG_NO_PICK, FLAG_STARTEQUIP, FLAG_UNPAID, liv::food, get_levelnumber(), obj::inv, is_in_shop(), obj::level, obj::materialname, obj::move_on, obj::msg, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_EXAMINE, obj::name, NDI_UNIQUE, need_identify(), obj::nrof, NUM_BODY_LOCATIONS, ob_describe(), query_cost_string(), QUERY_FLAG, obj::race, obj::skill, snprintf(), SPELLBOOK, obj::stats, liv::Str, stringbuffer_finish(), strncasecmp(), obj::type, obj::value, VERY_BIG_BUF, WAND, obj::weight, and obj::weight_limit.
Referenced by command_examine(), and examine_cmd().
Player examine a monster.
op | player. |
tmp | monster being examined. |
Definition at line 1424 of file c_object.c.
References AT_ACID, obj::attacktype, draw_ext_info(), FLAG_UNDEAD, obj::head, liv::hp, obj::level, liv::maxhp, mon, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_EXAMINE, NDI_UNIQUE, POISONING, present_in_ob(), QUERY_FLAG, and obj::stats.
Referenced by examine(), and probe().
|
static |
Search from start and through below for what matches best with params. we use item_matched_string above - this gives us consistent behaviour between many commands. Return the best match, or NULL if no match.
start | first object to start searching at. |
pl | what object we're searching for. |
params | what to search for. |
aflag | Either 0 or AP_APPLY or AP_UNAPPLY. Used with apply -u, and apply -a to only unapply applied, or apply unapplied objects. |
Definition at line 70 of file c_object.c.
References AP_APPLY, AP_UNAPPLY, obj::below, FLAG_APPLIED, obj::invisible, item_matched_string(), and QUERY_FLAG.
Referenced by command_apply(), and find_best_object_match().
Shortcut to find_best_apply_object_match(pl->inv, pl, params, AF_NULL);
pl | who to search an item for. |
params | what to search for. |
Definition at line 99 of file c_object.c.
References AP_NULL, find_best_apply_object_match(), and obj::inv.
Referenced by command_empty(), command_examine(), command_lock_item(), command_mark(), command_rename_item(), and command_use().
Return the object the player has marked with the 'mark' command below. If no match is found (or object has changed), we return NULL. We leave it up to the calling function to print messages if nothing is found.
op | object. Should be a player. |
Definition at line 1339 of file c_object.c.
References obj::below, obj::contr, obj::count, obj::inv, obj::invisible, pl::mark, and pl::mark_count.
Referenced by animate_weapon(), apply_map_builder(), armour_improver_type_apply(), cast_item_curse_or_curse(), cfapi_object_get_property(), command_mark(), command_rename_item(), find_throw_ob(), identify_altar_type_move_on(), lighter_type_apply(), recharge(), weapon_improver_type_apply(), and write_on_item().
Prints object's inventory.
op | who to print for. |
inv | if NULL then print op's inventory, else print the inventory of inv. |
Definition at line 1653 of file c_object.c.
References obj::below, CONTAINER, obj::count, draw_ext_info(), draw_ext_info_format(), FLAG_APPLIED, FLAG_WIZ, obj::inv, obj::invisible, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_INVENTORY, NDI_UNIQUE, QUERY_FLAG, query_name(), query_weight(), and obj::type.
Referenced by command_inventory(), and look_at().
Try to pick up an item.
op | object trying to pick up. |
alt | optional object op is trying to pick. If NULL, try to pick first item under op. |
Definition at line 462 of file c_object.c.
References obj::below, can_pick(), obj::container, CONTAINER, obj::contr, obj::count, pl::count, draw_ext_info(), draw_ext_info_format(), obj::env, FLAG_APPLIED, FLAG_STARTEQUIP, INS_NO_MERGE, insert_ob_in_map(), obj::inv, llevDebug, LOG(), obj::map, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, obj::name, NDI_UNIQUE, obj::nrof, pick_up_object(), PLAYER, QUERY_FLAG, obj::race, sack_can_hold(), stop_item(), and obj::type.
Referenced by attempt_steal(), cast_create_missile(), cfapi_object_pickup(), check_pick(), command_take(), and esrv_move_object().
Try to pick up some item.
pl | object (player or monster) picking up. |
op | object to put tmp into. |
tmp | object to pick up. |
nrof | number of tmp to pick up (0 means all of them). |
Definition at line 340 of file c_object.c.
References obj::carrying, draw_ext_info(), obj::env, esrv_update_item(), EVENT_PICKUP, execute_event(), F_BUY, F_SHOP, FALSE, fix_object(), FLAG_NO_DROP, FLAG_REMOVED, FLAG_UNPAID, FLAG_WAS_WIZ, FLAG_WIZ, free_object(), get_player_container(), get_split_ob(), HUGE_BUF, insert_ob_in_ob(), obj::inv, MAX_BUF, MAX_STAT, MOVE_FLYING, obj::move_type, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_FAILURE, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, obj::nrof, PLAYER, query_cost_string(), QUERY_FLAG, query_name(), Settings::real_wiz, remove_ob(), SCRIPT_FIX_ALL, SET_FLAG, settings, snprintf(), obj::stats, liv::Str, stringbuffer_finish(), obj::type, UPD_WEIGHT, obj::weight, and weight_limit.
Referenced by pick_up().
Something tries to put an object into another.
This function was part of drop(), now is own function.
op | who is moving the item. |
sack | where to put the object. |
tmp | what to put into sack. |
nrof | if non zero, then nrof objects is tried to put into sack, else everything is put. |
Definition at line 700 of file c_object.c.
References AP_NO_MERGE, AP_UNAPPLY, apply_special(), obj::below, CLEAR_FLAG, obj::container, CONTAINER, obj::contr, obj::count, draw_ext_info(), draw_ext_info_format(), obj::env, esrv_update_item(), fix_object(), FLAG_APPLIED, FLAG_NO_FIX_PLAYER, FLAG_STARTEQUIP, get_split_ob(), insert_ob_in_map_at(), insert_ob_in_ob(), obj::inv, obj::map, MAX_BUF, obj::move_off, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_FAILURE, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, obj::nrof, PLAYER, QUERY_FLAG, query_name(), remove_ob(), sack_can_hold(), set_object_face_main(), obj::slaying, pl::socket, TRANSPORT, transport_can_hold(), obj::type, UPD_WEIGHT, socket_struct::update_look, obj::x, and obj::y.
Referenced by drop(), esrv_move_object(), and START_TEST().
Check if an item op can be put into a sack. If pl exists then tell a player the reason of failure.
pl | player. |
sack | container to try to put into. |
op | what to put in the sack. |
nrof | number of objects (op) we want to put in. We specify it separately instead of using op->nrof because often times, a player may have specified a certain number of objects to drop, so we can pass that number, and not need to use split_ob() and stuff. |
Definition at line 282 of file c_object.c.
References obj::carrying, CONTAINER, draw_ext_info_format(), FLAG_APPLIED, liv::food, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, QUERY_FLAG, query_name(), obj::race, obj::slaying, SPECIAL_KEY, obj::stats, liv::Str, obj::type, obj::weight, and obj::weight_limit.
Referenced by esrv_move_object(), pick_up(), and put_object_in_sack().
|
static |
Sets the 'old' pickup mode.
op | player. |
i | new pickup mode. |
Definition at line 1944 of file c_object.c.
References obj::contr, draw_ext_info(), pl::mode, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_SUCCESS, and NDI_UNIQUE.
Referenced by command_pickup().