Go to the documentation of this file.
34 "debug",
"inhibit",
"stop",
"food",
"drink",
35 "valuables",
"bow",
"arrow",
"helmet",
"shield",
36 "armour",
"boots",
"gloves",
"cloak",
"key",
37 "missile",
"melee",
"magical",
"potion",
"spellbook",
38 "skillscroll",
"readables",
"magicdevice",
"notcursed",
"jewels",
39 "flesh",
"container",
"cursed", NULL
60 size_t len = strlen(
name);
75 return best != -2 ? best : -1;
102 object *
tmp, *best = NULL;
103 int match_val = 0, tmpmatch;
114 if (tmpmatch > match_val) {
115 match_val = tmpmatch;
147 "Usage: use_skill <skill name>");
166 "Usage: ready_skill <skill name>");
173 "You have no knowledge of the skill %s",
189 const char *missing_message) {
253 object *
inv =
op->inv;
263 if (!strncmp(
params,
"-a ", 3)) {
267 if (!strncmp(
params,
"-u ", 3)) {
271 if (!strncmp(
params,
"-o ", 3)) {
275 if (!strncmp(
params,
"-b ", 3)) {
278 inv =
op->container->inv;
295 "Could not find any match to the %s.",
323 "The %s is not active.",
329 "You can't put the %s into itself.",
336 "You can put only %s into the %s.",
342 "You can't put the key into %s.",
349 new_weight = sack->
carrying+(nrof ? nrof : 1)
358 "That won't fit in the %s!",
385 uint32_t weight, effective_weight_limit;
386 const int tmp_nrof =
NROF(
tmp);
400 "You are levitating, you can't reach the ground!");
408 "The object disappears in a puff of smoke! It must have been an illusion.");
415 if (nrof > tmp_nrof || nrof == 0)
419 weight =
tmp->weight*nrof;
421 weight +=
tmp->carrying*(100-
tmp->stats.Str)/100;
425 if (
pl->weight+
pl->carrying+weight > effective_weight_limit) {
427 "That item is too heavy for you to pick up.");
434 if (nrof != tmp_nrof) {
459 snprintf(
buf,
sizeof(
buf),
"%s will cost you %s. You place it in your %s.",
name,
value,
op->name);
464 snprintf(
buf,
sizeof(
buf),
"You pick up the %s.",
name);
466 snprintf(
buf,
sizeof(
buf),
"You pick up the %s and put it in your %s.",
name,
op->name);
521 object *
tmp = NULL, *tmp1;
529 "You can't pick up the %s.",
537 "There is nothing to pick up here.");
590 object *container = NULL;
605 }
else if (!container) {
620 if (
tmp->env == alt) {
631 LOG(
llevDebug,
"Pick_up(): %s picks %s (%d) and inserts it %s.\n",
op->name,
tmp->name,
op->contr->count, alt->
name);
641 "This object cannot be put into containers!");
647 op->contr->count = 0;
807 memset(mp, 0,
sizeof(*mp));
850 tmp =
op->container->inv;
876 if (
tmp->invisible) {
879 if ((*matcher)(
op, &mp,
tmp)) {
886 if (
params[0] ==
'\0' && !did_one) {
889 if (!
tmp->invisible) {
891 "You can't pick up a %s.",
892 tmp->name ?
tmp->name :
"null");
899 "There is nothing to pick up.");
904 "You were unable to take one of the items.");
907 "You were unable to take %d of the items.",
914 op->contr->count = 0;
938 object *sack2, *orig = sack;
946 "The %s is not a container.",
953 "You cannot put the %s in the %s.",
954 name_tmp, name_sack);
970 "You move the items from %s into %s.",
971 name_tmp, name_sack);
990 "You can not put a %s into a %s",
1009 if (nrof &&
tmp->nrof != nrof) {
1022 if (sack->
nrof > 1) {
1036 "You put the %s in %s.",
1037 name_tmp, name_sack);
1050 tmp->contr->socket->update_look = 1;
1095 if (nrof &&
tmp->nrof != nrof) {
1112 "You drop the %s. The gods who lent it to you retrieve it.",
1125 #ifdef SAVE_INTERVAL
1132 && (
tmp->nrof ?
tmp->value*
tmp->nrof :
tmp->value > 2000)
1133 &&
op->contr->last_save_time+SAVE_INTERVAL <= time(NULL)) {
1135 op->contr->last_save_time = time(NULL);
1140 tmp_tag =
tmp->count;
1174 if (
tmp->invisible) {
1185 if (!
tmp->invisible)
1193 "You don't have anything to drop.");
1198 "This item is locked");
1205 if (
op->container) {
1219 op->contr->count = 0;
1233 if (
op->inv == NULL) {
1236 "Nothing to drop!");
1258 && curinv->type !=
MONEY
1259 && curinv->type !=
FOOD
1260 && curinv->type !=
KEY
1262 && curinv->type !=
GEM
1263 && !curinv->invisible
1264 && (curinv->type !=
CONTAINER ||
op->container != curinv)) {
1270 }
else if (strcmp(
params,
"weapons") == 0) {
1273 && (curinv->type ==
WEAPON || curinv->type ==
BOW || curinv->type ==
ARROW)) {
1279 }
else if (strcmp(
params,
"armor") == 0 || strcmp(
params,
"armour") == 0) {
1288 }
else if (strcmp(
params,
"food") == 0) {
1291 && (curinv->type ==
FOOD || curinv->type ==
DRINK)) {
1297 }
else if (strcmp(
params,
"flesh") == 0) {
1300 && (curinv->type ==
FLESH)) {
1306 }
else if (strcmp(
params,
"misc") == 0) {
1310 switch (curinv->type) {
1337 op->contr->socket->update_look = 1;
1375 if ((*matcher)(
op, &mp,
tmp)) {
1386 "Nothing to drop.");
1389 "One item couldn't be dropped because it was locked.");
1390 else if (missed > 1)
1392 "%d items couldn't be dropped because they were locked.",
1399 op->contr->count = 0;
1416 if (!container->
inv)
1459 if (strcmp(
params,
"all") == 0) {
1475 "This is not a container!");
1504 "Could not find an object that matches %s",
1521 if (!
op || !
op->contr || !
op->contr->mark)
1550 if (
op->contr->mark->env ==
op &&
op->contr->mark->count ==
op->contr->mark_count)
1551 return op->contr->mark;
1553 op->contr->mark = NULL;
1554 op->contr->mark_count = 0;
1576 "You have no marked object.");
1588 "Could not find an object that matches %s",
1592 op->contr->mark = mark1;
1593 op->contr->mark_count = mark1->
count;
1619 "It is an undead force.");
1622 "It is likely more powerful than you.");
1625 "It is likely less powerful than you.");
1628 "It is probably as powerful as you.");
1632 "You smell an acrid odor.");
1641 "It is critically wounded.");
1646 "It is in a bad shape.");
1656 "It is somewhat hurt.");
1661 "It is in excellent shape.");
1666 "It looks very ill.");
1679 if (
probe == NULL) {
1719 "You discover mystic forces on %s",
tmp->nrof <= 1?
"that item":
"those items" );
1730 "You have a bad feeling about %s",
tmp->nrof <= 1?
"that item":
"those items" );
1736 LOG(
llevError,
"Attempted to examine item %d with type %d, which is invalid\n",
tmp->count,
tmp->type);
1740 bool have_skill =
false;
1787 bool pl =
tmp->nrof > 1;
1788 float weight = (
tmp->nrof ?
tmp->nrof : 1) * ((
float)
tmp->weight/1000.0);
1790 if (
tmp->materialname && weight) {
1792 "%s made of %s and %s %3.3f kg.",
1793 pl ?
"They are" :
"It is",
tmp->materialname,
1794 pl ?
"weigh" :
"weighs", weight);
1795 }
else if (
tmp->materialname) {
1797 "%s made of %s.",
pl ?
"They are" :
"It is",
tmp->materialname);
1798 }
else if (weight) {
1800 "%s %3.3f kg.",
pl ?
"They weigh" :
"it weighs", weight);
1827 if (
tmp->msg && strncasecmp(
tmp->msg,
"@match", 6)) {
1829 "%s has a story:",
tmp->nrof > 1 ?
"These objects" :
"This object");
1838 switch (
tmp->type) {
1846 if (!
tmp->skill)
break;
1851 "Unfortunately, it is damaged beyond %s.",
1857 "%s lets you %s a skill:",
1858 tmp->nrof > 1 ?
"These objects" :
"This object",
1881 if (
tmp->inv &&
tmp->inv->msg) {
1883 "%s holds%s a spell:",
1884 tmp->nrof > 1 ?
"These objects" :
"This object",
1920 snprintf(
prefix,
MAX_BUF,
"You lack the skill to understand %s:",
1921 tmp->nrof<=1 ?
"that fully; it is" :
"those fully; they are");
1925 tmp->nrof<=1 ?
"that fully; it is" :
"those fully; they are");
1947 switch (
tmp->type) {
1950 snprintf(
buf,
sizeof(
buf),
"It has %d charges left.",
tmp->stats.food);
1955 if (
tmp->msg != NULL)
1956 snprintf(
buf,
sizeof(
buf),
"Something is written in it.");
1960 if (
tmp->race != NULL) {
1961 if (
tmp->weight_limit &&
tmp->stats.Str < 100)
1962 snprintf(
buf,
sizeof(
buf),
"It can hold only %s and its weight limit is %.1f kg.",
tmp->race,
tmp->weight_limit/(10.0*(100-
tmp->stats.Str)));
1964 snprintf(
buf,
sizeof(
buf),
"It can hold only %s.",
tmp->race);
1966 if (
tmp->weight_limit &&
tmp->stats.Str < 100)
1967 snprintf(
buf,
sizeof(
buf),
"Its weight limit is %.1f kg.",
tmp->weight_limit/(10.0*(100-
tmp->stats.Str)));
1979 if (
tmp->body_info[i]) {
1980 if (
op->body_info[i]) {
1981 if (
tmp->body_info[i] < -1) {
1983 "%s %s (%d).",
tmp->nrof > 1 ?
"They go" :
"It goes",
1987 "%s %s.",
tmp->nrof > 1 ?
"They go" :
"It goes",
1992 "%s %s.",
tmp->nrof > 1 ?
"They go" :
"It goes",
2002 snprintf(
buf,
sizeof(
buf),
"You reckon %s worth %s.",
tmp->nrof > 1 ?
"they are" :
"it is",
value);
2009 snprintf(
buf,
sizeof(
buf),
"%s would cost you %s.",
tmp->nrof > 1 ?
"They" :
"It",
value);
2013 snprintf(
buf,
sizeof(
buf),
"You are offered %s for %s.",
value,
tmp->nrof > 1 ?
"them" :
"it");
2027 bool has_link =
false;
2030 if (tmp_inv->type ==
FORCE && tmp_inv->slaying != NULL
2031 && strcmp(tmp_inv->slaying,
op->map->path) == 0
2032 && tmp_inv->msg != NULL
2033 && tmp_inv->path_attuned == (uint32_t) conn) {
2038 "This is a buildable item, connected with: %s",
2046 "This is a buildable item.");
2070 int items = 0, length;
2073 if (
inv == NULL &&
op == NULL) {
2075 "Inventory of what object?");
2086 "You carry nothing.");
2110 "[fixed]%s- %-*.*s (%5d) %-8s",
2111 in, length, length,
name,
tmp->count, weight);
2114 "[fixed]%s- %-*.*s %-8s",
2115 in, length+8, length+8,
name, weight);
2121 41,
"Total weight :", weight);
2134 int i =
op->contr->mode;
2141 "Pickup is now %s.", (old &
PU_INHIBIT) ?
"active" :
"inhibited");
2160 "%d <= x pickup weight/value RATIO (0==off)",
2284 int old =
op->contr->mode;
2285 i =
op->contr->mode;
2298 op->contr->mode = i;
2303 "Pickup: invalid item %s\n",
2308 if (sscanf(
params,
"%u", &i) != 1) {
2312 "Usage: pickup <0-7> or <value_density> .");
2328 op->contr->mode = i;
2329 switch (
op->contr->mode) {
2332 "Mode: Don't pick up.");
2337 "Mode: Pick up one item.");
2342 "Mode: Pick up one item and stop.");
2347 "Mode: Stop before picking up.");
2352 "Mode: Pick up all items.");
2357 "Mode: Pick up all items and stop.");
2362 "Mode: Pick up all magic items.");
2367 "Mode: Pick up all coins and gems");
2385 if (
op->contr->search_str[0] ==
'\0') {
2387 "Example: search magic+1 "
2388 "Would automatically pick up all "
2389 "items containing the word 'magic+1'.");
2392 op->contr->search_str[0] =
'\0';
2394 "Search mode turned off.");
2400 "Search string too long.");
2403 strcpy(
op->contr->search_str,
params);
2405 "Searching for '%s'.",
2406 op->contr->search_str);
2428 object *
item = NULL;
2430 const char *closebrace;
2439 itemnumber = atoi(
params);
2440 if (itemnumber != 0) {
2442 if (
inv->count == itemnumber && !
inv->invisible) {
2449 "Tried to rename an invalid item.");
2454 }
else if (
'<' == *
params) {
2456 closebrace = strchr(
params,
'>');
2463 if (closebrace-
params > 127) {
2465 "Old name too long (up to 127 characters allowed)!");
2475 "Could not find a matching item to rename.");
2488 "No marked item to rename.");
2494 if (!strncmp(
params,
"to ", 3)) {
2500 "Syntax error, expecting < at start of new name!");
2503 closebrace = strchr(
params+1,
'>');
2506 "Syntax error, expecting > at end of new name!");
2511 if (closebrace-
params > 127) {
2513 "New name too long (up to 127 characters allowed)!");
2521 for (counter = 0; counter < strlen(
buf); counter++) {
2522 if (isalnum(
buf[counter]))
2524 if (
' ' ==
buf[counter])
2526 if (
'\'' ==
buf[counter])
2528 if (
'+' ==
buf[counter])
2530 if (
'_' ==
buf[counter])
2532 if (
'-' ==
buf[counter])
2539 "Invalid new name!");
2546 "Syntax error, expected 'to <' after old name!");
2557 "No marked item to rename.");
2568 "This item has no custom name.");
2575 "You stop calling your %s with weird names.",
2579 if (custom_name != NULL && strcmp(custom_name,
buf) == 0) {
2582 "You keep calling your %s %s.",
2592 "Your %s will now be called %s.",
2625 "Can't find any matching item.");
2632 "Unlocked %s.",
name);
2636 "Locked %s.",
name);
2656 object *first, *second;
2666 with = strstr(copy,
" with ");
2673 with = with+strlen(
" with ");
2686 transformation = NULL;
2696 if (transformation->
yield)
2697 generated->
nrof = transformation->
yield;
#define object_was_destroyed(op, old_tag)
void drop(object *op, object *tmp)
recipe * find_recipe_for_tool(const char *tool, recipe *from)
int do_skill(object *op, object *part, object *skill, int dir, const char *string)
static int matcher_pickup_type(object *who, matcher_params *params, object *item)
#define NUM_BODY_LOCATIONS
#define MSG_TYPE_COMMAND_SUCCESS
void command_search(object *op, const char *params)
object * find_skill_by_number(object *who, int skillno)
void LOG(LogLevel logLevel, const char *format,...)
#define QUERY_FLAG(xyz, p)
void command_rename_item(object *op, const char *params)
object * object_merge(object *op, object *top)
void examine_monster(object *op, object *tmp, int level)
StringBuffer * stringbuffer_new(void)
void examine(object *op, object *tmp)
#define FOR_BELOW_PREPARE(op_, it_)
int detect_curse_on_item(object *pl, object *tmp, object *skill)
void command_rskill(object *pl, const char *params)
uint64_t shop_price_buy(const object *obj, object *who)
void command_use(object *op, const char *params)
void esrv_send_pickup(player *pl)
void command_uskill(object *pl, const char *params)
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
static int matcher_name(object *who, matcher_params *params, object *item)
int change_skill(object *who, object *new_skill, int flag)
#define MSG_TYPE_COMMAND_EXAMINE
void fix_object(object *op)
void command_mark(object *op, const char *params)
void command_pickup(object *op, const char *params)
#define MSG_TYPE_COMMAND_ERROR
#define MSG_TYPE_SPELL_INFO
const char * object_get_value(const object *op, const char *const key)
void apply_by_living_below(object *pl)
int events_execute_object_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix)
object * object_insert_in_ob(object *op, object *where)
static void set_pickup_mode(const object *op, int i)
void command_drop(object *op, const char *params)
#define FOR_BELOW_FINISH()
void command_empty(object *op, const char *params)
int object_matches_pickup_mode(const object *item, int mode)
char * stringbuffer_finish(StringBuffer *sb)
void object_free_drop_inventory(object *ob)
void put_object_in_sack(object *op, object *sack, object *tmp, uint32_t nrof)
static uint32_t NROF(const object *const ob)
int use_skill(object *op, const char *string)
static int matcher_all(object *who, matcher_params *params, object *item)
#define object_decrease_nrof_by_one(xyz)
void command_throw(object *op, const char *params)
const typedata * get_typedata(int itemtype)
void query_name(const object *op, char *buf, size_t size)
void examine_fluff(object *op, object *tmp)
#define FLAG_KNOWN_CURSED
void examine_weight_and_material(object *op, object *tmp)
static int matcher_number(object *who, matcher_params *params, object *item)
int set_object_face_main(object *op)
#define MSG_TYPE_COMMAND_INFO
sstring add_string(const char *str)
void knowledge_add_probe_monster(object *op, object *mon)
#define FOR_OB_AND_BELOW_FINISH()
bool player_can_find(object *op, object *ob)
static void pick_up_object(object *pl, object *op, object *tmp, int nrof)
int transport_can_hold(const object *transport, const object *op, int nrof)
object * object_find_by_type_and_name(const object *who, int type, const char *name)
void query_short_name(const object *op, char *buf, size_t size)
int is_identified(const object *op)
char * ob_describe(const object *op, const object *observer, int use_media_tags, char *buf, size_t size)
static void empty_container(object *container, object *pl)
void command_dropall(object *op, const char *params)
int identify_object_with_skill(object *tmp, object *pl, object *skill, int print_on_success)
#define INS_BELOW_ORIGINATOR
#define MSG_TYPE_SKILL_MISSING
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
void knowledge_item_can_be_used_alchemy(object *op, const object *item)
body_locations_struct body_locations[NUM_BODY_LOCATIONS]
int object_matches_string(object *pl, object *op, const char *name)
static item_matcher make_matcher(object *who, const char *params, matcher_params *mp)
void stringbuffer_append_string(StringBuffer *sb, const char *str)
#define FOR_OB_AND_BELOW_PREPARE(op_)
static object * find_best_apply_object_match(object *start, object *pl, const char *params, int aflag)
int detect_magic_on_item(object *pl, object *tmp, object *skill)
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
void command_search_items(object *op, const char *params)
void inventory(object *op, object *inv)
object * find_skill_by_name(object *who, const char *name)
static std::shared_ptr< inja::Environment > env
void pick_up(object *op, object *alt)
static void do_skill_by_number(object *op, int skill_subtype, const char *params, const char *missing_message)
size_t strlcpy(char *dst, const char *src, size_t size)
object * object_insert_in_map(object *op, mapstruct *m, object *originator, int flag)
int sack_can_hold(const object *pl, const object *sack, const object *op, uint32_t nrof)
object * create_archetype(const char *name)
object * object_present_in_ob(uint8_t type, const object *op)
uint32_t get_weight_limit(int stat)
void free_string(sstring str)
void command_disarm(object *op, const char *params)
static bool IS_PLAYER(object *op)
int item_must_be_pickable
int probe(object *op, object *caster, object *spell_ob, int dir, int level)
#define MSG_TYPE_COMMAND_FAILURE
#define FLAG_KNOWN_MAGICAL
static const uint32_t pickup_modes[]
static object * find_best_object_match(object *pl, const char *params)
static int get_pickup_mode_index(const char *name)
#define MSG_TYPE_COMMAND_INVENTORY
int(* item_matcher)(object *who, matcher_params *params, object *item)
void query_weight(const object *op, char *buf, size_t size)
char * cost_approx_str(const object *obj, object *who)
int object_can_pick(const object *who, const object *item)
void stringbuffer_trim_whitespace(StringBuffer *sb)
char * cost_str(uint64_t cost)
#define FLAG_IS_BUILDABLE
int is_identifiable_type(const object *op)
const typedef char * sstring
void command_apply(object *op, const char *params)
object * object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
void command_examine(object *op, const char *params)
int apply_by_living(object *pl, object *op, int aflag, int quiet)
void esrv_update_item(int flags, object *pl, object *op)
#define FLAG_NO_FIX_PLAYER
object * find_marked_object(object *op)
#define CLEAR_FLAG(xyz, p)
#define SK_SUBTRACT_SKILL_EXP
int apply_special(object *who, object *op, int aflags)
static void display_new_pickup(const object *op, int old)
int save_player(object *op, int flag)
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
object * stop_item(object *op)
void object_remove(object *op)
object * drop_object(object *op, object *tmp, uint32_t nrof)
void sell_item(object *op, object *pl)
void command_lock_item(object *op, const char *params)
void query_base_name(const object *op, int plural, char *buf, size_t size)
int object_set_value(object *op, const char *key, const char *value, int add_key)
void command_take(object *op, const char *params)
bool shop_contains(object *ob)
static const char * pickup_names[]
#define FLAG_NO_SKILL_IDENT
object * object_get_player_container(object *op)
#define CUSTOM_NAME_FIELD
uint64_t shop_price_sell(const object *obj, object *who)
#define FOR_INV_PREPARE(op_, it_)
ex_autoid_result examine_autoidentify(object *op, object *tmp)
archetype * get_archetype_by_skill_name(const char *skill, int type)