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) {
1705 int i, exp = 0, conn;
1709 int id_attempted = 0;
1720 LOG(
llevError,
"Attempted to examine item %d with type %d, which is invalid\n",
tmp->count,
tmp->type);
1732 "You discover mystic forces on %s",
tmp->nrof <= 1?
"that item":
"those items" );
1742 "You have a bad feeling about %s",
tmp->nrof <= 1?
"that item":
"those items" );
1789 switch (id_attempted) {
1791 snprintf(
prefix,
MAX_BUF,
"You lack the skill to understand %s:",
tmp->nrof <= 1?
"that fully; it is":
"those fully, they are");
1794 snprintf(
prefix,
MAX_BUF,
"You fail to understand %s:",
tmp->nrof <= 1?
"that fully; it is":
"those fully, they are");
1799 }
else snprintf(
prefix,
MAX_BUF,
"%s:",
tmp->nrof <= 1?
"That is":
"Those are");
1814 switch (
tmp->type) {
1821 if (!
tmp->skill)
break;
1826 "Unfortunately the scroll is damaged and unreadable.");
1867 snprintf(
buf,
sizeof(
buf),
"It has %d charges left.",
tmp->stats.food);
1872 if (
tmp->msg != NULL)
1873 snprintf(
buf,
sizeof(
buf),
"Something is written in it.");
1877 if (
tmp->race != NULL) {
1878 if (
tmp->weight_limit &&
tmp->stats.Str < 100)
1879 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)));
1881 snprintf(
buf,
sizeof(
buf),
"It can hold only %s.",
tmp->race);
1883 if (
tmp->weight_limit &&
tmp->stats.Str < 100)
1884 snprintf(
buf,
sizeof(
buf),
"Its weight limit is %.1f kg.",
tmp->weight_limit/(10.0*(100-
tmp->stats.Str)));
1895 if (
tmp->materialname != NULL && !
tmp->msg) {
1897 "It is made of: %s.",
1902 if (
tmp->body_info[i]) {
1903 if (
op->body_info[i]) {
1904 if (
tmp->body_info[i] < -1) {
1906 "%s %s (%d)",
tmp->nrof > 1 ?
"They go" :
"It goes",
1910 "%s %s",
tmp->nrof > 1 ?
"They go" :
"It goes",
1915 "%s %s",
tmp->nrof > 1 ?
"They go" :
"It goes",
1922 snprintf(
buf,
sizeof(
buf),
tmp->nrof > 1 ?
"They weigh %3.3f kg." :
"It weighs %3.3f kg.",
tmp->weight*((
float)(
tmp->nrof ?
tmp->nrof : 1)/1000.0));
1931 snprintf(
buf,
sizeof(
buf),
"You reckon %s worth %s.",
tmp->nrof > 1 ?
"they are" :
"it is",
value);
1938 snprintf(
buf,
sizeof(
buf),
"%s would cost you %s.",
tmp->nrof > 1 ?
"They" :
"It",
value);
1942 snprintf(
buf,
sizeof(
buf),
"You are offered %s for %s.",
value,
tmp->nrof > 1 ?
"them" :
"it");
1956 "This is a buildable item.");
1961 if (tmp_inv->type ==
FORCE && tmp_inv->slaying != NULL
1962 && strcmp(tmp_inv->slaying,
op->map->path) == 0
1963 && tmp_inv->msg != NULL
1964 && tmp_inv->path_attuned == (uint32_t) conn) {
1985 && strncasecmp(
tmp->msg,
"@match", 6)) {
1997 "The object has a story:");
2021 int items = 0, length;
2024 if (
inv == NULL &&
op == NULL) {
2026 "Inventory of what object?");
2037 "You carry nothing.");
2061 "[fixed]%s- %-*.*s (%5d) %-8s",
2062 in, length, length,
name,
tmp->count, weight);
2065 "[fixed]%s- %-*.*s %-8s",
2066 in, length+8, length+8,
name, weight);
2072 41,
"Total weight :", weight);
2085 int i =
op->contr->mode;
2092 "Pickup is now %s.", (old &
PU_INHIBIT) ?
"active" :
"inhibited");
2111 "%d <= x pickup weight/value RATIO (0==off)",
2235 int old =
op->contr->mode;
2236 i =
op->contr->mode;
2249 op->contr->mode = i;
2254 "Pickup: invalid item %s\n",
2259 if (sscanf(
params,
"%u", &i) != 1) {
2263 "Usage: pickup <0-7> or <value_density> .");
2279 op->contr->mode = i;
2280 switch (
op->contr->mode) {
2283 "Mode: Don't pick up.");
2288 "Mode: Pick up one item.");
2293 "Mode: Pick up one item and stop.");
2298 "Mode: Stop before picking up.");
2303 "Mode: Pick up all items.");
2308 "Mode: Pick up all items and stop.");
2313 "Mode: Pick up all magic items.");
2318 "Mode: Pick up all coins and gems");
2336 if (
op->contr->search_str[0] ==
'\0') {
2338 "Example: search magic+1 "
2339 "Would automatically pick up all "
2340 "items containing the word 'magic+1'.");
2343 op->contr->search_str[0] =
'\0';
2345 "Search mode turned off.");
2351 "Search string too long.");
2354 strcpy(
op->contr->search_str,
params);
2356 "Searching for '%s'.",
2357 op->contr->search_str);
2379 object *
item = NULL;
2381 const char *closebrace;
2390 itemnumber = atoi(
params);
2391 if (itemnumber != 0) {
2393 if (
inv->count == itemnumber && !
inv->invisible) {
2400 "Tried to rename an invalid item.");
2405 }
else if (
'<' == *
params) {
2407 closebrace = strchr(
params,
'>');
2414 if (closebrace-
params > 127) {
2416 "Old name too long (up to 127 characters allowed)!");
2426 "Could not find a matching item to rename.");
2439 "No marked item to rename.");
2445 if (!strncmp(
params,
"to ", 3)) {
2451 "Syntax error, expecting < at start of new name!");
2454 closebrace = strchr(
params+1,
'>');
2457 "Syntax error, expecting > at end of new name!");
2462 if (closebrace-
params > 127) {
2464 "New name too long (up to 127 characters allowed)!");
2472 for (counter = 0; counter < strlen(
buf); counter++) {
2473 if (isalnum(
buf[counter]))
2475 if (
' ' ==
buf[counter])
2477 if (
'\'' ==
buf[counter])
2479 if (
'+' ==
buf[counter])
2481 if (
'_' ==
buf[counter])
2483 if (
'-' ==
buf[counter])
2490 "Invalid new name!");
2497 "Syntax error, expected 'to <' after old name!");
2508 "No marked item to rename.");
2519 "This item has no custom name.");
2526 "You stop calling your %s with weird names.",
2530 if (custom_name != NULL && strcmp(custom_name,
buf) == 0) {
2533 "You keep calling your %s %s.",
2543 "Your %s will now be called %s.",
2576 "Can't find any matching item.");
2583 "Unlocked %s.",
name);
2587 "Locked %s.",
name);
2607 object *first, *second;
2617 with = strstr(copy,
" with ");
2624 with = with+strlen(
" with ");
2637 transformation = NULL;
2647 if (transformation->
yield)
2648 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)
#define FLAG_KNOWN_CURSED
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)
const typedef char * sstring
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)
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_)
archetype * get_archetype_by_skill_name(const char *skill, int type)