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");
1807 if (
tmp->custom_name) {
1813 switch (
tmp->type) {
1819 if (!
tmp->skill)
break;
1824 "Unfortunately the scroll is damaged and unreadable.");
1864 snprintf(
buf,
sizeof(
buf),
"It has %d charges left.",
tmp->stats.food);
1869 if (
tmp->msg != NULL)
1870 snprintf(
buf,
sizeof(
buf),
"Something is written in it.");
1874 if (
tmp->race != NULL) {
1875 if (
tmp->weight_limit &&
tmp->stats.Str < 100)
1876 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)));
1878 snprintf(
buf,
sizeof(
buf),
"It can hold only %s.",
tmp->race);
1880 if (
tmp->weight_limit &&
tmp->stats.Str < 100)
1881 snprintf(
buf,
sizeof(
buf),
"Its weight limit is %.1f kg.",
tmp->weight_limit/(10.0*(100-
tmp->stats.Str)));
1892 if (
tmp->materialname != NULL && !
tmp->msg) {
1894 "It is made of: %s.",
1899 if (
tmp->body_info[i]) {
1900 if (
op->body_info[i]) {
1901 if (
tmp->body_info[i] < -1) {
1903 "%s %s (%d)",
tmp->nrof > 1 ?
"They go" :
"It goes",
1907 "%s %s",
tmp->nrof > 1 ?
"They go" :
"It goes",
1912 "%s %s",
tmp->nrof > 1 ?
"They go" :
"It goes",
1919 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));
1928 snprintf(
buf,
sizeof(
buf),
"You reckon %s worth %s.",
tmp->nrof > 1 ?
"they are" :
"it is",
value);
1935 snprintf(
buf,
sizeof(
buf),
"%s would cost you %s.",
tmp->nrof > 1 ?
"They" :
"It",
value);
1939 snprintf(
buf,
sizeof(
buf),
"You are offered %s for %s.",
value,
tmp->nrof > 1 ?
"them" :
"it");
1953 "This is a buildable item.");
1958 if (tmp_inv->type ==
FORCE && tmp_inv->slaying != NULL
1959 && strcmp(tmp_inv->slaying,
op->map->path) == 0
1960 && tmp_inv->msg != NULL
1961 && tmp_inv->path_attuned == (uint32_t) conn) {
1982 && strncasecmp(
tmp->msg,
"@match", 6)) {
1994 "The object has a story:");
2018 int items = 0, length;
2021 if (
inv == NULL &&
op == NULL) {
2023 "Inventory of what object?");
2034 "You carry nothing.");
2058 "[fixed]%s- %-*.*s (%5d) %-8s",
2059 in, length, length,
name,
tmp->count, weight);
2062 "[fixed]%s- %-*.*s %-8s",
2063 in, length+8, length+8,
name, weight);
2069 41,
"Total weight :", weight);
2082 int i =
op->contr->mode;
2089 "Pickup is now %s.", (old &
PU_INHIBIT) ?
"active" :
"inhibited");
2108 "%d <= x pickup weight/value RATIO (0==off)",
2232 int old =
op->contr->mode;
2233 i =
op->contr->mode;
2246 op->contr->mode = i;
2251 "Pickup: invalid item %s\n",
2256 if (sscanf(
params,
"%u", &i) != 1) {
2260 "Usage: pickup <0-7> or <value_density> .");
2276 op->contr->mode = i;
2277 switch (
op->contr->mode) {
2280 "Mode: Don't pick up.");
2285 "Mode: Pick up one item.");
2290 "Mode: Pick up one item and stop.");
2295 "Mode: Stop before picking up.");
2300 "Mode: Pick up all items.");
2305 "Mode: Pick up all items and stop.");
2310 "Mode: Pick up all magic items.");
2315 "Mode: Pick up all coins and gems");
2333 if (
op->contr->search_str[0] ==
'\0') {
2335 "Example: search magic+1 "
2336 "Would automatically pick up all "
2337 "items containing the word 'magic+1'.");
2340 op->contr->search_str[0] =
'\0';
2342 "Search mode turned off.");
2348 "Search string too long.");
2351 strcpy(
op->contr->search_str,
params);
2353 "Searching for '%s'.",
2354 op->contr->search_str);
2376 object *
item = NULL;
2387 itemnumber = atoi(
params);
2388 if (itemnumber != 0) {
2390 if (
inv->count == itemnumber && !
inv->invisible) {
2397 "Tried to rename an invalid item.");
2402 }
else if (
'<' == *
params) {
2404 closebrace = strchr(
params,
'>');
2411 if (closebrace-
params > 127) {
2413 "Old name too long (up to 127 characters allowed)!");
2423 "Could not find a matching item to rename.");
2436 "No marked item to rename.");
2442 if (!strncmp(
params,
"to ", 3)) {
2448 "Syntax error, expecting < at start of new name!");
2451 closebrace = strchr(
params+1,
'>');
2454 "Syntax error, expecting > at end of new name!");
2459 if (closebrace-
params > 127) {
2461 "New name too long (up to 127 characters allowed)!");
2469 for (counter = 0; counter < strlen(
buf); counter++) {
2470 if (isalnum(
buf[counter]))
2472 if (
' ' ==
buf[counter])
2474 if (
'\'' ==
buf[counter])
2476 if (
'+' ==
buf[counter])
2478 if (
'_' ==
buf[counter])
2480 if (
'-' ==
buf[counter])
2487 "Invalid new name!");
2494 "Syntax error, expected 'to <' after old name!");
2505 "No marked item to rename.");
2514 if (
item->custom_name == NULL) {
2516 "This item has no custom name.");
2523 "You stop calling your %s with weird names.",
2526 if (
item->custom_name != NULL && strcmp(
item->custom_name,
buf) == 0) {
2529 "You keep calling your %s %s.",
2539 "Your %s will now be called %s.",
2572 "Can't find any matching item.");
2579 "Unlocked %s.",
name);
2583 "Locked %s.",
name);
2603 object *first, *second;
2613 with = strstr(copy,
" with ");
2620 with = with+strlen(
" with ");
2633 transformation = NULL;
2643 if (transformation->
yield)
2644 generated->
nrof = transformation->
yield;
#define object_was_destroyed(op, old_tag)
int do_skill(object *op, object *part, object *skill, int dir, const char *string)
uint32_t get_weight_limit(int stat)
static int matcher_name(object *who, matcher_params *params, object *item)
sstring add_string(const char *str)
void object_remove(object *op)
StringBuffer * stringbuffer_new(void)
#define NUM_BODY_LOCATIONS
#define MSG_TYPE_COMMAND_SUCCESS
object * find_skill_by_number(object *who, int skillno)
void command_dropall(object *op, const char *params)
#define QUERY_FLAG(xyz, p)
static int matcher_all(object *who, matcher_params *params, object *item)
recipe * find_recipe_for_tool(const char *tool, recipe *from)
#define FOR_BELOW_PREPARE(op_, it_)
int detect_curse_on_item(object *pl, object *tmp, object *skill)
uint64_t shop_price_buy(const object *obj, object *who)
static const uint32_t pickup_modes[]
static int get_pickup_mode_index(const char *name)
int object_matches_string(object *pl, object *op, const char *name)
void esrv_send_pickup(player *pl)
void pick_up(object *op, object *alt)
static void set_pickup_mode(const object *op, int i)
void command_disarm(object *op, const char *params)
int change_skill(object *who, object *new_skill, int flag)
#define MSG_TYPE_COMMAND_EXAMINE
int object_matches_pickup_mode(const object *item, int mode)
void command_take(object *op, const char *params)
void command_drop(object *op, const char *params)
static void empty_container(object *container, object *pl)
#define MSG_TYPE_COMMAND_ERROR
void command_empty(object *op, const char *params)
#define MSG_TYPE_SPELL_INFO
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)
void put_object_in_sack(object *op, object *sack, object *tmp, uint32_t nrof)
int(* item_matcher)(object *who, matcher_params *params, object *item)
int sack_can_hold(const object *pl, const object *sack, const object *op, uint32_t nrof)
void inventory(object *op, object *inv)
void command_examine(object *op, const char *params)
#define FOR_BELOW_FINISH()
object * object_merge(object *op, object *top)
void free_string(sstring str)
void command_lock_item(object *op, const char *params)
static uint32_t NROF(const object *const ob)
int use_skill(object *op, const char *string)
void stringbuffer_trim_whitespace(StringBuffer *sb)
#define object_decrease_nrof_by_one(xyz)
static void display_new_pickup(const object *op, int old)
int is_identifiable_type(const object *op)
void command_mark(object *op, const char *params)
void query_name(const object *op, char *buf, size_t size)
#define FLAG_KNOWN_CURSED
static const char * pickup_names[]
int set_object_face_main(object *op)
#define MSG_TYPE_COMMAND_INFO
void knowledge_add_probe_monster(object *op, object *mon)
#define FOR_OB_AND_BELOW_FINISH()
bool player_can_find(object *op, object *ob)
void stringbuffer_append_string(StringBuffer *sb, const char *str)
int transport_can_hold(const object *transport, const object *op, int nrof)
int object_can_pick(const object *who, const object *item)
void query_short_name(const object *op, char *buf, size_t size)
object * object_present_in_ob(uint8_t type, const object *op)
#define FREE_AND_COPY(sv, nv)
void fix_object(object *op)
char * stringbuffer_finish(StringBuffer *sb)
int identify_object_with_skill(object *tmp, object *pl, object *skill, int print_on_success)
#define INS_BELOW_ORIGINATOR
#define MSG_TYPE_SKILL_MISSING
static void do_skill_by_number(object *op, int skill_subtype, const char *params, const char *missing_message)
void knowledge_item_can_be_used_alchemy(object *op, const object *item)
void command_pickup(object *op, const char *params)
#define FOR_OB_AND_BELOW_PREPARE(op_)
int detect_magic_on_item(object *pl, object *tmp, object *skill)
object * find_skill_by_name(object *who, const char *name)
size_t strlcpy(char *dst, const char *src, size_t size)
static std::shared_ptr< inja::Environment > env
static int matcher_pickup_type(object *who, matcher_params *params, object *item)
object * drop_object(object *op, object *tmp, uint32_t nrof)
object * create_archetype(const char *name)
void command_search(object *op, const char *params)
static bool IS_PLAYER(object *op)
int item_must_be_pickable
#define FREE_AND_CLEAR_STR(xyz)
int probe(object *op, object *caster, object *spell_ob, int dir, int level)
#define MSG_TYPE_COMMAND_FAILURE
#define FLAG_KNOWN_MAGICAL
char * ob_describe(const object *op, const object *observer, int use_media_tags, char *buf, size_t size)
static item_matcher make_matcher(object *who, const char *params, matcher_params *mp)
#define MSG_TYPE_COMMAND_INVENTORY
void drop(object *op, object *tmp)
char * cost_approx_str(const object *obj, object *who)
static void pick_up_object(object *pl, object *op, object *tmp, int nrof)
char * cost_str(uint64_t cost)
#define FLAG_IS_BUILDABLE
void LOG(LogLevel logLevel, const char *format,...)
void command_throw(object *op, const char *params)
void command_uskill(object *pl, const char *params)
void query_weight(const object *op, char *buf, size_t size)
object * object_insert_in_map(object *op, mapstruct *m, object *originator, int flag)
int apply_by_living(object *pl, object *op, int aflag, int quiet)
void esrv_update_item(int flags, object *pl, object *op)
void query_base_name(const object *op, int plural, char *buf, size_t size)
#define FLAG_NO_FIX_PLAYER
#define CLEAR_FLAG(xyz, p)
#define SK_SUBTRACT_SKILL_EXP
int apply_special(object *who, object *op, int aflags)
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
object * object_insert_in_ob(object *op, object *where)
const typedata * get_typedata(int itemtype)
void command_use(object *op, const char *params)
void command_rskill(object *pl, const char *params)
int save_player(object *op, int flag)
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
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_free_drop_inventory(object *ob)
void command_rename_item(object *op, const char *params)
object * find_marked_object(object *op)
static int matcher_number(object *who, matcher_params *params, object *item)
void sell_item(object *op, object *pl)
void examine_monster(object *op, object *tmp, int level)
object * object_find_by_type_and_name(const object *who, int type, const char *name)
void command_apply(object *op, const char *params)
static object * find_best_object_match(object *pl, const char *params)
static object * find_best_apply_object_match(object *start, object *pl, const char *params, int aflag)
bool shop_contains(object *ob)
void examine(object *op, object *tmp)
void command_search_items(object *op, const char *params)
object * object_get_player_container(object *op)
#define FLAG_NO_SKILL_IDENT
body_locations_struct body_locations[NUM_BODY_LOCATIONS]
object * object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
uint64_t shop_price_sell(const object *obj, object *who)
#define FOR_INV_PREPARE(op_, it_)
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
archetype * get_archetype_by_skill_name(const char *skill, int type)
int is_identified(const object *op)