50 #define OBLINKMALLOC(p) if (!((p) = (objectlink *)malloc(sizeof(objectlink)))) \
71 object *tmp, *best = NULL;
72 int match_val = 0, tmpmatch;
74 for (tmp = start; tmp; tmp = tmp->
below) {
116 "Usage: use_skill <skill name>", NULL);
137 "Usage: ready_skill <skill name>", NULL);
144 "You have no knowledge of the skill %s",
145 "You have no knowledge of the skill %s",
206 "You have no knowledge of the skill throwing.", NULL);
227 object *inv = op->
inv;
229 while (*params ==
' ')
231 if (!strncmp(params,
"-a ", 3)) {
235 if (!strncmp(params,
"-u ", 3)) {
239 if (!strncmp(params,
"-b ", 3)) {
249 while (*params ==
' ')
257 "Could not find any match to the %s.",
258 "Could not find any match to the %s.",
288 "The %s is not active.",
289 "The %s is not active.",
295 "You can't put the %s into itself.",
296 "You can't put the %s into itself.",
303 "You can put only %s into the %s.",
304 "You can put only %s into the %s.",
310 "You can't want put the key into %s.",
311 "You can't want put the key into %s.",
319 "That won't fit in the %s!",
320 "That won't fit in the %s!",
345 object *env = tmp->
env;
346 uint32 weight, effective_weight_limit;
347 int tmp_nrof = tmp->
nrof ? tmp->
nrof : 1;
358 "You are levitating, you can't reach the ground!", NULL);
366 "The object disappears in a puff of smoke! It must have been an illusion.",
374 if (nrof > tmp_nrof || nrof == 0)
378 weight = tmp->
weight*nrof;
389 "That item is too heavy for you to pick up.", NULL);
396 if (nrof != tmp_nrof) {
399 tmp =
get_split_ob(tmp, nrof, failure,
sizeof(failure));
418 snprintf(buf,
sizeof(buf),
"%s will cost you %s.", name, value);
421 snprintf(buf,
sizeof(buf),
"You pick up the %s.", name);
450 if (env && env != pl && env != op)
464 object *tmp = NULL, *tmp1;
473 "You can't pick up the %s.",
474 "You can't pick up the %s.",
482 "There is nothing to pick up here.", NULL);
512 if (tmp == NULL)
return;
532 object *container=NULL;
540 for (alt = op->
inv; alt; alt = alt->
below) {
547 else if (!container) {
553 if (!alt) alt=container;
561 if (tmp->
env == alt) {
582 "This object cannot be put into containers!", NULL);
621 "Nothing to take!", NULL);
626 if (params && *params ==
'\0')
641 if ((ival <= 2) && (!
can_pick(op, tmp))) {
646 }
else if (
can_pick(op, tmp) && !params) {
657 if (!params && !tmp) {
658 for (tmp = op->
below; tmp != NULL; tmp = tmp->
next)
661 "You can't pick up a %s.",
662 "You can't pick up a %s.",
669 "There is nothing to pick up.", NULL);
673 "You were unable to take one of the items.", NULL);
676 "You were unable to take %d of the items.",
677 "You were unable to take %d of the items.",
701 tag_t tmp_tag, tmp2_tag;
702 object *tmp2, *sack2, *orig = sack;
710 "The %s is not a container.",
711 "The %s is not a container.",
718 "You cannot put the %s in the %s.",
719 "You cannot put the %s in the %s.",
720 name_tmp, name_sack);
736 "You move the items from %s into %s.",
737 "You move the items from %s into %s.",
738 name_tmp, name_sack);
740 for (tmp2 = tmp->
inv; tmp2; tmp2 = tmp) {
759 "You can not put a %s into a %s",
760 "You can not put a %s into a %s",
780 if (nrof && tmp->
nrof != nrof) {
784 tmp2_tag = tmp2->
count;
785 tmp =
get_split_ob(tmp, nrof, failure,
sizeof(failure));
795 if (sack->
nrof > 1) {
809 "You put the %s in %s.",
810 "You put the %s in %s.",
811 name_tmp, name_sack);
812 tmp_tag = tmp->
count;
822 for (tmp = sack->
inv; tmp; tmp = tmp->
below) {
866 if (nrof && tmp->
nrof != nrof) {
869 tmp =
get_split_ob(tmp, nrof, failure,
sizeof(failure));
883 "You drop the %s. The gods who lent it to you retrieves it.",
884 "You drop the %s. The gods who lent it to you retrieves it.",
905 && (op->
contr->last_save_time+SAVE_INTERVAL) <= time(NULL)) {
907 op->
contr->last_save_time = time(NULL);
915 tmp_tag = tmp->
count;
943 void drop(
object *op,
object *tmp) {
966 "You don't have anything to drop.", NULL);
971 "This item is locked", NULL);
982 if (tmp->
below != NULL)
984 else if (tmp->
above != NULL)
1022 object *curinv, *nextinv;
1025 if (op->
inv == NULL) {
1028 "Nothing to drop!", NULL);
1049 if (params == NULL) {
1050 while (curinv != NULL) {
1051 nextinv = curinv->
below;
1052 while (nextinv && nextinv->
type ==
MONEY)
1053 nextinv = nextinv->
below;
1068 }
else if (strcmp(params,
"weapons") == 0) {
1069 while (curinv != NULL) {
1070 nextinv = curinv->
below;
1071 while (nextinv && nextinv->
type ==
MONEY)
1072 nextinv = nextinv->
below;
1081 }
else if (strcmp(params,
"armor") == 0 || strcmp(params,
"armour") == 0) {
1082 while (curinv != NULL) {
1083 nextinv = curinv->
below;
1084 while (nextinv && nextinv->
type ==
MONEY)
1085 nextinv = nextinv->
below;
1094 }
else if (strcmp(params,
"food") == 0) {
1095 while (curinv != NULL) {
1096 nextinv = curinv->
below;
1104 }
else if (strcmp(params,
"flesh") == 0) {
1105 while (curinv != NULL) {
1106 nextinv = curinv->
below;
1114 }
else if (strcmp(params,
"misc") == 0) {
1115 while (curinv != NULL) {
1116 nextinv = curinv->
below;
1117 while (nextinv && nextinv->
type ==
MONEY)
1118 nextinv = nextinv->
below;
1121 switch (curinv->
type) {
1181 "Drop what?", NULL);
1184 for (tmp = op->
inv; tmp; tmp = next) {
1198 "Nothing to drop.", NULL);
1201 "One item couldn't be dropped because it was locked.", NULL);
1202 else if (missed > 1)
1204 "%d items couldn't be dropped because they were locked.",
1205 "%d items couldn't be dropped because they were locked.",
1229 if (!container->
inv)
1232 for (inv = container->
inv; inv; inv = next) {
1240 if (inv->
below == next)
1269 "Empty what?", NULL);
1273 if (strcmp(params,
"all") == 0) {
1274 for (inv = op->
inv; inv; inv = inv->
below)
1283 "No such item.", NULL);
1288 "This is not a container!", NULL);
1308 object *tmp = op->
below;
1321 "Could not find an object that matches %s",
1322 "Could not find an object that matches %s",
1349 for (tmp = op->
inv; tmp; tmp = tmp->
below) {
1385 "You have no marked object.", NULL);
1398 "Could not find an object that matches %s",
1399 "Could not find an object that matches %s",
1429 "It is an undead force.", NULL);
1432 "It is likely more powerful than you.", NULL);
1435 "It is likely less powerful than you.", NULL);
1438 "It is probably as powerful as you.", NULL);
1442 "You smell an acrid odor.", NULL);
1450 "It is in a bad shape.", NULL);
1455 "It is hurt.", NULL);
1460 "It is somewhat hurt.", NULL);
1465 "It is in excellent shape.", NULL);
1470 "It looks very ill.", NULL);
1516 switch (tmp->
type) {
1527 if (tmp->
msg != NULL)
1528 snprintf(buf,
sizeof(buf),
"Something is written in it.");
1532 if (tmp->
race != NULL) {
1536 snprintf(buf,
sizeof(buf),
"It can hold only %s.", tmp->
race);
1554 "It is made of: %s.",
1555 "It is made of: %s.",
1586 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));
1595 snprintf(buf,
sizeof(buf),
"You reckon %s worth %s.", tmp->
nrof > 1 ?
"they are" :
"it is", value);
1602 snprintf(buf,
sizeof(buf),
"%s would cost you %s.", tmp->
nrof > 1 ?
"They" :
"It", value);
1606 snprintf(buf,
sizeof(buf),
"You are offered %s for %s.", value, tmp->
nrof > 1 ?
"them" :
"it");
1620 "This is a buildable item.", NULL);
1636 "The object has a story:", NULL);
1656 int items = 0, length;
1659 if (inv == NULL && op == NULL) {
1661 "Inventory of what object?", NULL);
1664 tmp = inv ? inv->
inv : op->
inv;
1675 "You carry nothing.", NULL);
1681 "Inventory:", NULL);
1691 for (tmp = inv ? inv->
inv : op->
inv; tmp; tmp = tmp->
below) {
1699 "[fixed]%s- %-*.*s (%5d) %-8s",
1700 "%s- %-*.*s (%5d) %-8s",
1701 in, length, length, name, tmp->
count, weight);
1704 "[fixed]%s- %-*.*s %-8s",
1706 in, length+8, length+8, name, weight);
1713 41,
"Total weight :", weight);
1732 i&PU_NEWMODE ? 1 : 0);
1747 "%d <= x pickup weight/value RATIO (0==off)",
1748 "%d <= x pickup weight/value RATIO (0==off)",
1869 static const char *names[] = {
1870 "debug",
"inhibit",
"stop",
"food",
"drink",
1871 "valuables",
"bow",
"arrow",
"helmet",
"shield",
1872 "armour",
"boots",
"gloves",
"cloak",
"key",
1873 "missile",
"allweapon",
"magical",
"potion",
"spellbook",
1874 "skillscroll",
"readables",
"magicdevice",
"notcursed",
"jewels",
1877 static const uint32 modes[] = {
1896 while (*params ==
' ')
1899 if (*params ==
'+' || *params ==
'-') {
1902 for (mode = 0; names[mode]; mode++) {
1903 if (!strcmp(names[mode], params+1)) {
1917 "Pickup: invalid item %s\n",
1918 "Pickup: invalid item %s\n",
1923 if (sscanf(params,
"%u", &i) != 1) {
1927 "Usage: pickup <0-7> or <value_density> .", NULL);
1948 "Mode: Don't pick up.", NULL);
1953 "Mode: Pick up one item.", NULL);
1958 "Mode: Pick up one item and stop.", NULL);
1963 "Mode: Stop before picking up.", NULL);
1968 "Mode: Pick up all items.", NULL);
1973 "Mode: Pick up all items and stop.", NULL);
1978 "Mode: Pick up all magic items.", NULL);
1983 "Mode: Pick up all coins and gems", NULL);
2002 if (params == NULL) {
2005 "Example: search magic+1 "
2006 "Would automatically pick up all "
2007 "items containing the word 'magic+1'.",
2013 "Search mode turned off.", NULL);
2017 if ((
int)strlen(params) >=
MAX_BUF) {
2019 "Search string too long.", NULL);
2024 "Searching for '%s'.",
2025 "Searching for '%s'.",
2050 object *item = NULL;
2058 while (
' ' == *params)
2062 if ((itemnumber = atoi(params)) != 0) {
2067 "Tried to rename an invalid item.", NULL);
2070 while (isdigit(*params) ||
' ' == *params)
2072 }
else if (
'<' == *params) {
2074 closebrace = strchr(params,
'>');
2077 "Syntax error!", NULL);
2081 if ((closebrace-params) > 127) {
2083 "Old name too long (up to 127 characters allowed)!", NULL);
2087 snprintf(buf,
sizeof(buf),
"%.*s", (
int)(closebrace-(params+1)), params+1);
2093 "Could not find a matching item to rename.", NULL);
2098 params = closebrace+1;
2099 while (
' ' == *params)
2106 "No marked item to rename.", NULL);
2112 if (!strncmp(params,
"to ", 3)) {
2114 while (
' ' == *params)
2116 if (
'<' != *params) {
2118 "Syntax error, expecting < at start of new name!", NULL);
2121 closebrace = strchr(params+1,
'>');
2124 "Syntax error, expecting > at end of new name!", NULL);
2129 if ((closebrace-params) > 127) {
2131 "New name too long (up to 127 characters allowed)!", NULL);
2136 snprintf(buf,
sizeof(buf),
"%.*s", (
int)(closebrace-(params+1)), params+1);
2139 for (counter = 0; counter < strlen(buf); counter++) {
2140 if (isalnum(buf[counter]))
2142 if (
' ' == buf[counter])
2144 if (
'\'' == buf[counter])
2146 if (
'+' == buf[counter])
2148 if (
'_' == buf[counter])
2150 if (
'-' == buf[counter])
2157 "Invalid new name!", NULL);
2162 if (strlen(params)) {
2164 "Syntax error, expected 'to <' after old name!", NULL);
2175 "No marked item to rename.", NULL);
2186 "This item has no custom name.", NULL);
2193 "You stop calling your %s with weird names.",
2194 "You stop calling your %s with weird names.",
2200 "You keep calling your %s %s.",
2201 "You keep calling your %s %s.",
2211 "Your %s will now be called %s.",
2212 "Your %s will now be called %s.",
2240 if (!params || strlen(params) == 0) {
2242 "Lock what item?",
"Lock what item?");
2249 "Can't find any matching item.",
"Can't find any matching item.");
2256 "Unlocked %s.",
"Unlocked %s.", name);
2260 "Locked %s.",
"Locked %s.", name);
2284 object *first, *second, *add;
2292 snprintf(copy,
sizeof(copy),
"%s", params);
2293 with = strstr(copy,
" with ");
2300 with = with+strlen(
" with ");
2319 snprintf(copy,
sizeof(copy),
"on_use_with_%d", first->
type);
2328 while (data != NULL) {
2329 if (strncmp(data,
"add ", 4) == 0) {
2331 if (isdigit(*data)) {
2333 data = strchr(data,
' ')+1;
2336 with = strchr(data,
' ');
2338 strncpy(copy, data,
sizeof(copy));
2342 strncpy(copy, data,
sizeof(copy));
2343 data += strlen(copy)+1;
2353 }
else if (strncmp(data,
"remove $", 8) == 0) {
2359 }
else if (*data ==
'2') {
#define MSG_TYPE_SKILL_MISSING
int sack_can_hold(const object *pl, const object *sack, const object *op, uint32 nrof)
static object * find_best_object_match(object *pl, const char *params)
#define NUM_BODY_LOCATIONS
int apply_special(object *who, object *op, int aflags)
archetype * find_archetype(const char *name)
int is_in_shop(object *ob)
int change_skill(object *who, object *new_skill, int flag)
const char * get_ob_key_value(const object *op, const char *const key)
void pick_up(object *op, object *alt)
int command_apply(object *op, char *params)
object * present_in_ob(uint8 type, const object *op)
void get_levelnumber(int i, char *buf, size_t size)
object * insert_ob_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
#define FLAG_NO_FIX_PLAYER
int save_player(object *op, int flag)
void inventory(object *op, object *inv)
int command_pickup(object *op, char *params)
void esrv_update_item(int flags, object *pl, object *op)
#define MSG_TYPE_COMMAND_SUCCESS
int item_matched_string(object *pl, object *op, const char *name)
void query_base_name(const object *op, int plural, char *buf, size_t size)
void query_weight(const object *op, char *buf, size_t size)
object * merge_ob(object *op, object *top)
void draw_ext_info(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *message, const char *oldmessage)
int command_examine(object *op, char *params)
const char * skill_names[NUM_SKILLS]
void examine_monster(object *op, object *tmp)
body_locations_struct body_locations[NUM_BODY_LOCATIONS]
object * stop_item(object *op)
static void pick_up_object(object *pl, object *op, object *tmp, int nrof)
void draw_ext_info_format(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *new_format, const char *old_format,...)
int command_take(object *op, char *params)
#define MSG_TYPE_COMMAND_FAILURE
int command_disarm(object *op, char *params)
int command_lock_item(object *op, char *params)
void remove_ob(object *op)
int command_uskill(object *pl, char *params)
void examine(object *op, object *tmp)
object * get_player_container(object *op)
const char * materialname
StringBuffer * query_cost_string(const object *tmp, object *who, int flag, StringBuffer *buf)
static void display_new_pickup(const object *op)
int do_skill(object *op, object *part, object *skill, int dir, const char *string)
int can_pick(const object *who, const object *item)
static void empty_container(object *container, object *pl)
int command_rename_item(object *op, char *params)
int command_search_items(object *op, char *params)
#define FREE_AND_CLEAR_STR(xyz)
int command_dropall(object *op, char *params)
void player_apply_below(object *pl)
static void set_pickup_mode(const object *op, int i)
int command_drop(object *op, char *params)
#define QUERY_FLAG(xyz, p)
#define CLEAR_FLAG(xyz, p)
object * insert_ob_in_ob(object *op, object *where)
char * ob_describe(const object *op, const object *observer, char *buf, size_t size)
object * object_create_arch(archetype *at)
int command_rskill(object *pl, char *params)
int strncasecmp(const char *s1, const char *s2, int n)
object * insert_ob_in_map(object *op, mapstruct *m, object *originator, int flag)
int command_use(object *op, char *params)
object * drop_object(object *op, object *tmp, uint32 nrof)
int need_identify(const object *op)
sint8 body_info[NUM_BODY_LOCATIONS]
int snprintf(char *dest, int max, const char *format,...)
int set_object_face_main(object *op)
int command_mark(object *op, char *params)
void sell_item(object *op, object *pl)
#define FREE_AND_COPY(sv, nv)
#define MSG_TYPE_COMMAND_INFO
#define FLAG_IS_BUILDABLE
int transport_can_hold(const object *transport, const object *op, int nrof)
void query_short_name(const object *op, char *buf, size_t size)
int execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix)
const uint32 weight_limit[MAX_STAT+1]
int command_empty(object *op, char *params)
static object * find_best_apply_object_match(object *start, object *pl, const char *params, int aflag)
void LOG(LogLevel logLevel, const char *format,...)
object * get_split_ob(object *orig_ob, uint32 nr, char *err, size_t size)
int player_apply(object *pl, object *op, int aflag, int quiet)
#define was_destroyed(op, old_tag)
object * find_marked_object(object *op)
void query_name(const object *op, char *buf, size_t size)
#define MSG_TYPE_COMMAND_EXAMINE
void free_object(object *ob)
int use_skill(object *op, const char *string)
void fix_object(object *op)
#define MSG_TYPE_COMMAND_ERROR
object * find_skill_by_name(object *who, const char *name)
void put_object_in_sack(object *op, object *sack, object *tmp, uint32 nrof)
#define MSG_TYPE_COMMAND_INVENTORY
char * stringbuffer_finish(StringBuffer *sb)
int command_throw(object *op, char *params)
int command_search(object *op, char *params)
void drop(object *op, object *tmp)