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);
1815 if (
tmp->stats.food <= 0) {
1816 desc =
"It is completely depleted.";
1817 }
else if (
tmp->stats.food <= 2) {
1818 desc =
"It is nearly depleted.";
1819 }
else if (
tmp->stats.food <= 4) {
1820 desc =
"It is very low on power.";
1821 }
else if (
tmp->stats.food <= 8) {
1822 desc =
"It is low on power.";
1823 }
else if (
tmp->stats.food <= 16) {
1824 desc =
"It is well charged.";
1825 }
else if (
tmp->stats.food <= 32) {
1826 desc =
"It is fully charged.";
1828 desc =
"It is overflowing with power.";
1850 if (castings <= 1) {
1851 desc =
"It is nearly depleted.";
1852 }
else if (castings <= 3) {
1853 desc =
"It hums with power.";
1855 desc =
"It crackles with power.";
1886 if (
tmp->msg && strncasecmp(
tmp->msg,
"@match", 6)) {
1887 if (!output)
return true;
1896 switch (
tmp->type) {
1904 if (!
tmp->skill)
break;
1910 "Unfortunately, it is damaged beyond %s.",
1915 if (!output)
return true;
1917 "%s lets you %s a skill:",
1918 tmp->nrof > 1 ?
"These objects" :
"This object",
1941 if (
tmp->inv &&
tmp->inv->msg) {
1942 if (!output)
return true;
1944 "%s holds%s a spell:",
1945 tmp->nrof > 1 ?
"These objects" :
"This object",
1959 if (!output)
return true;
1961 "%s a story:",
tmp->nrof > 1 ?
"These objects have" :
"This object has");
1992 if (
op->contr->last_examined ==
tmp->count) {
1993 op->contr->last_examined = 0;
1995 "You examine the %s more closely.",
tmp->nrof > 1 ?
tmp->name_pl :
tmp->name);
2010 snprintf(
prefix,
MAX_BUF,
"You lack the skill to understand %s:",
2011 tmp->nrof<=1 ?
"that fully; it is" :
"those fully; they are");
2015 tmp->nrof<=1 ?
"that fully; it is" :
"those fully; they are");
2037 switch (
tmp->type) {
2047 if (
tmp->msg != NULL)
2048 snprintf(
buf,
sizeof(
buf),
"Something is written in it.");
2052 if (
tmp->race != NULL) {
2053 if (
tmp->weight_limit &&
tmp->stats.Str < 100)
2054 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)));
2056 snprintf(
buf,
sizeof(
buf),
"It can hold only %s.",
tmp->race);
2058 if (
tmp->weight_limit &&
tmp->stats.Str < 100)
2059 snprintf(
buf,
sizeof(
buf),
"Its weight limit is %.1f kg.",
tmp->weight_limit/(10.0*(100-
tmp->stats.Str)));
2071 if (
tmp->body_info[i]) {
2072 if (
op->body_info[i]) {
2073 if (
tmp->body_info[i] < -1) {
2075 "%s %s (%d).",
tmp->nrof > 1 ?
"They go" :
"It goes",
2079 "%s %s.",
tmp->nrof > 1 ?
"They go" :
"It goes",
2084 "%s %s.",
tmp->nrof > 1 ?
"They go" :
"It goes",
2094 snprintf(
buf,
sizeof(
buf),
"You reckon %s worth %s.",
tmp->nrof > 1 ?
"they are" :
"it is",
value);
2101 snprintf(
buf,
sizeof(
buf),
"%s would cost you %s.",
tmp->nrof > 1 ?
"They" :
"It",
value);
2105 snprintf(
buf,
sizeof(
buf),
"You are offered %s for %s.",
value,
tmp->nrof > 1 ?
"them" :
"it");
2119 bool has_link =
false;
2122 if (tmp_inv->type ==
FORCE && tmp_inv->slaying != NULL
2123 && strcmp(tmp_inv->slaying,
op->map->path) == 0
2124 && tmp_inv->msg != NULL
2125 && tmp_inv->path_attuned == (uint32_t) conn) {
2130 "This is a buildable item, connected with: %s",
2138 "This is a buildable item.");
2144 op->contr->last_examined =
tmp->count;
2146 "Examine again for more details.");
2148 op->contr->last_examined = 0;
2169 int items = 0, length;
2172 if (
inv == NULL &&
op == NULL) {
2174 "Inventory of what object?");
2185 "You carry nothing.");
2209 "[fixed]%s- %-*.*s (%5d) %-8s",
2210 in, length, length,
name,
tmp->count, weight);
2213 "[fixed]%s- %-*.*s %-8s",
2214 in, length+8, length+8,
name, weight);
2220 41,
"Total weight :", weight);
2233 int i =
op->contr->mode;
2240 "Pickup is now %s.", (old &
PU_INHIBIT) ?
"active" :
"inhibited");
2259 "%d <= x pickup weight/value RATIO (0==off)",
2383 int old =
op->contr->mode;
2384 i =
op->contr->mode;
2397 op->contr->mode = i;
2402 "Pickup: invalid item %s\n",
2407 if (sscanf(
params,
"%u", &i) != 1) {
2411 "Usage: pickup <0-7> or <value_density> .");
2427 op->contr->mode = i;
2428 switch (
op->contr->mode) {
2431 "Mode: Don't pick up.");
2436 "Mode: Pick up one item.");
2441 "Mode: Pick up one item and stop.");
2446 "Mode: Stop before picking up.");
2451 "Mode: Pick up all items.");
2456 "Mode: Pick up all items and stop.");
2461 "Mode: Pick up all magic items.");
2466 "Mode: Pick up all coins and gems");
2484 if (
op->contr->search_str[0] ==
'\0') {
2486 "Example: search magic+1 "
2487 "Would automatically pick up all "
2488 "items containing the word 'magic+1'.");
2491 op->contr->search_str[0] =
'\0';
2493 "Search mode turned off.");
2499 "Search string too long.");
2502 strcpy(
op->contr->search_str,
params);
2504 "Searching for '%s'.",
2505 op->contr->search_str);
2527 object *
item = NULL;
2529 const char *closebrace;
2538 itemnumber = atoi(
params);
2539 if (itemnumber != 0) {
2541 if (
inv->count == itemnumber && !
inv->invisible) {
2548 "Tried to rename an invalid item.");
2553 }
else if (
'<' == *
params) {
2555 closebrace = strchr(
params,
'>');
2562 if (closebrace-
params > 127) {
2564 "Old name too long (up to 127 characters allowed)!");
2574 "Could not find a matching item to rename.");
2587 "No marked item to rename.");
2593 if (!strncmp(
params,
"to ", 3)) {
2599 "Syntax error, expecting < at start of new name!");
2602 closebrace = strchr(
params+1,
'>');
2605 "Syntax error, expecting > at end of new name!");
2610 if (closebrace-
params > 127) {
2612 "New name too long (up to 127 characters allowed)!");
2620 for (counter = 0; counter < strlen(
buf); counter++) {
2621 if (isalnum(
buf[counter]))
2623 if (
' ' ==
buf[counter])
2625 if (
'\'' ==
buf[counter])
2627 if (
'+' ==
buf[counter])
2629 if (
'_' ==
buf[counter])
2631 if (
'-' ==
buf[counter])
2638 "Invalid new name!");
2645 "Syntax error, expected 'to <' after old name!");
2656 "No marked item to rename.");
2667 "This item has no custom name.");
2674 "You stop calling your %s with weird names.",
2678 if (custom_name != NULL && strcmp(custom_name,
buf) == 0) {
2681 "You keep calling your %s %s.",
2691 "Your %s will now be called %s.",
2724 "Can't find any matching item.");
2731 "Unlocked %s.",
name);
2735 "Locked %s.",
name);
2755 object *first, *second;
2765 with = strstr(copy,
" with ");
2772 with = with+strlen(
" with ");
2785 transformation = NULL;
2795 if (transformation->
yield)
2796 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)
void examine_wand_charge_level(object *op, object *tmp)
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)
#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_)
int16_t SP_level_spellpoint_cost(object *caster, object *spell, int flags)
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)
bool examine_fluff(object *op, object *tmp, bool output)
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 examine_rod_charge_level(object *op, object *tmp)
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)