ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/c_object.C
(Generate patch)

Comparing deliantra/server/server/c_object.C (file contents):
Revision 1.5 by elmex, Sun Aug 20 21:26:03 2006 UTC vs.
Revision 1.12 by root, Sun Sep 3 00:18:42 2006 UTC

1/* 1/*
2 * static char *rcsid_c_object_c = 2 * static char *rcsid_c_object_c =
3 * "$Id: c_object.C,v 1.5 2006/08/20 21:26:03 elmex Exp $"; 3 * "$Id: c_object.C,v 1.12 2006/09/03 00:18:42 root Exp $";
4 */ 4 */
5/* 5/*
6 CrossFire, A Multiplayer game for X-windows 6 CrossFire, A Multiplayer game for X-windows
7 7
8 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 8 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
41 41
42#define OBLINKMALLOC(p) if(!((p)=(objectlink *)malloc(sizeof(objectlink))))\ 42#define OBLINKMALLOC(p) if(!((p)=(objectlink *)malloc(sizeof(objectlink))))\
43 fatal(OUT_OF_MEMORY); 43 fatal(OUT_OF_MEMORY);
44 44
45#define ADD_ITEM(NEW,COUNT)\ 45#define ADD_ITEM(NEW,COUNT)\
46 if(!first) {\ 46 if(!first) {\
47 OBLINKMALLOC(first);\ 47 OBLINKMALLOC(first);\
48 last=first;\ 48 last=first;\
49 } else {\ 49 } else {\
50 OBLINKMALLOC(last->next);\ 50 OBLINKMALLOC(last->next);\
51 last=last->next;\ 51 last=last->next;\
52 }\ 52 }\
53 last->next=NULL;\ 53 last->next=NULL;\
54 last->ob=(NEW);\ 54 last->ob=(NEW);\
55 last->id=(COUNT); 55 last->id=(COUNT);
56 56
57/** 57/**
58 * Search the inventory of 'pl' for what matches best with params. 58 * Search the inventory of 'pl' for what matches best with params.
59 * we use item_matched_string above - this gives us consistent behaviour 59 * we use item_matched_string above - this gives us consistent behaviour
84object *find_best_object_match(object *pl, const char *params) 84object *find_best_object_match(object *pl, const char *params)
85{ 85{
86 return find_best_apply_object_match(pl, params, AP_NULL); 86 return find_best_apply_object_match(pl, params, AP_NULL);
87} 87}
88 88
89/*
90 * Notes about item creation:
91 * 1) It is similar in syntax to the dm create command.
92 * 2) It requires a player to have a buildfacility below him, a tool in his
93 * possesion, and materials to build with.
94 * 3) The random roll is done in a loop, so if the player tries to make 100,
95 * he makes 100 checks.
96 * 4) Exp is given only on succ. creations, but materials are used regardless.
97 * 5) The properties of the tool are stored in tooltype and weapontype.
98 * 6) The properties of the buildfacilities are stored in tooltype.
99 * 7) For now, all ingredients must be type 73 INORGANIC.
100 * 8) The player can attempt to create any arch, but item_power and value
101 * will prevent most artifacts from being built.
102 * 9) The code allows magic bonuses up to +5. It is not trivial to make a +5
103 * item.
104 *10) If you ever extend it beyond +5, add more gemtypes. Currently the code
105 * looks for gemcost gems per item, per plus. So a +5 item requires
106 * gemcost pearls,rubies,emeralds,sapphires and diamonds. Not cheap.
107 *11) There are a zillion if statements in this code. Alot of checking takes
108 * place here. All of them are needed.
109 */
110
111int command_build (object *pl, char *params) {
112 return 0;
113#if 0
114 object *marked, *facility, *tool, *newobj, *tmp;
115 archetype *at;
116 int skillnr, obpow, number, bonus, mneed, nrof, magic, i, nummade, found;
117 int gemcost;
118 char *bp;
119 materialtype_t *mt;
120
121 /* NOTE THIS FUNCTION IS CURRENTLY DISABLED */
122
123/* Given this is currently disabled, I'm not going to bother updating
124 * it with the new skill system. IT really needs to get the skill object
125 * pointer in a better fashion than it is currently doing.
126 */
127 if (!params) {
128 new_draw_info(NDI_UNIQUE, 0, pl, "Usage:build [nr] [+magic] <object>");
129 return 0;
130 }
131 marked = find_marked_object(pl);
132 if (marked == NULL || !marked->material || marked->materialname == NULL ||
133 marked->type != INORGANIC) {
134 new_draw_info(NDI_UNIQUE, 0, pl, "You must mark some ingredients.");
135 return 0;
136 }
137 while (*params==' ')
138 params++;
139 bp = params;
140 nrof = 1;
141 magic = 0;
142
143 if (sscanf(bp, "%d ", &nrof)) {
144 if ((bp = strchr(params, ' ')) == NULL) {
145 new_draw_info(NDI_UNIQUE, 0, pl,
146 "Usage: build [nr] [+magic] <object>");
147 return 0;
148 }
149 bp++;
150 }
151 if (sscanf(bp, "+%d ", &magic)) {
152 if ((bp = strchr(bp, ' ')) == NULL) {
153 new_draw_info(NDI_UNIQUE, 0, pl,
154 "Usage: build [nr] [+magic] <object>");
155 return 0;
156 }
157 bp++;
158 }
159 while (*bp==' ')
160 bp++;
161 at=find_archetype_by_object_name(bp);
162 if (at == NULL) {
163 new_draw_info_format(NDI_UNIQUE, 0, pl,
164 "You don't know how to make a %s.", bp);
165 return 0;
166 }
167 newobj = get_object();
168 copy_object(&at->clone, newobj);
169
170 skillnr = -1;
171
172 if ((IS_ARMOR(newobj) && newobj->material != M_LEATHER) ||
173 newobj->type == WEAPON)
174 skillnr = SK_SMITH;
175
176 if (IS_ARMOR(newobj) && newobj->material == M_LEATHER)
177 skillnr = SK_WOODSMAN;
178
179 if (newobj->type == BOW || newobj->type == ARROW)
180 skillnr = SK_BOWYER;
181
182 if (skillnr == -1) {
183 new_draw_info(NDI_UNIQUE, 0, pl, "You don't know how to create that.");
184 return 0;
185 }
186
187 if (!change_skill(pl, skillnr, 0)) {
188 new_draw_info(NDI_UNIQUE, 0, pl,
189 "You lack the needed skill to make that item.");
190 return 0;
191 }
192 facility = NULL;
193 for (tmp=GET_MAP_OB(pl->map, pl->x, pl->y); tmp; tmp=tmp->above)
194 if (tmp->type == BUILDFAC && tmp->tooltype == newobj->type)
195 facility=tmp;
196 if (facility == NULL) {
197 new_draw_info(NDI_UNIQUE, 0, pl, "You lack a suitable workspace.");
198 return 0;
199 }
200 if (magic && !(IS_ARMOR(newobj) || IS_WEAPON(newobj))) {
201 new_draw_info(NDI_UNIQUE, 0, pl, "A magical bonus is only valid with "
202 "armour and weapons.");
203 return 0;
204 }
205
206 /* use newobj->weapontype == tool->weapontype for building weapons */
207 /* use newobj->material == tool->weapontype for building armour */
208 /* newobj->type == tool->tooltype */
209 tool = NULL;
210 for (tmp=pl->inv; tmp; tmp=tmp->below) {
211 if (tmp->type != TOOL)
212 continue;
213 if (IS_ARMOR(newobj) && (newobj->material & tmp->weapontype) &&
214 newobj->type == tmp->tooltype) {
215 if (tool == NULL ||
216 (tool->level + tool->magic) < (tmp->level + tmp->magic))
217 tool = tmp;
218 } else if (IS_WEAPON(newobj) && (newobj->weapontype&tmp->weapontype) &&
219 newobj->type == tmp->tooltype) {
220 if (tool == NULL ||
221 (tool->level + tool->magic) < (tmp->level + tmp->magic))
222 tool = tmp;
223 }
224 /* should split off bows arrows and probably bolts around here */
225 }
226 if (tool == NULL) {
227 new_draw_info(NDI_UNIQUE, 0, pl, "You lack the required tools.");
228 return 0;
229 }
230
231 mt = name_to_material(marked->materialname);
232 if (mt == NULL) {
233 new_draw_info(NDI_UNIQUE, 0, pl, "Your raw materials are garbage.");
234 return 0;
235 }
236 if (magic < 0) {
237 new_draw_info(NDI_UNIQUE, 0, pl, "You cannot create cursed objects.");
238 return 0;
239 }
240 if (magic > 0 && SK_level(pl)/20 < magic) {
241 new_draw_info(NDI_UNIQUE, 0, pl, "You are not powerful enough to "
242 "create such a magical item.");
243 return 0;
244 }
245
246 gemcost = 100;
247 if (newobj->type == ARROW)
248 gemcost = 1;
249 if (magic > 0) {
250 found = 0;
251 for (tmp=GET_MAP_OB(pl->map, pl->x, pl->y); tmp; tmp=tmp->above)
252 if (tmp->type == GEM && !strcmp(tmp->arch->name, "pearl") &&
253 tmp->nrof >= gemcost*nrof*mt->value/100)
254 found++;
255 if (magic > 1)
256 for (tmp=GET_MAP_OB(pl->map, pl->x, pl->y); tmp; tmp=tmp->above)
257 if (tmp->type == GEM && !strcmp(tmp->arch->name, "emerald") &&
258 tmp->nrof >= gemcost*nrof*mt->value/100)
259 found++;
260 if (magic > 2)
261 for (tmp=GET_MAP_OB(pl->map, pl->x, pl->y); tmp; tmp=tmp->above)
262 if (tmp->type == GEM && !strcmp(tmp->arch->name, "sapphire") &&
263 tmp->nrof >= gemcost*nrof*mt->value/100)
264 found++;
265 if (magic > 3)
266 for (tmp=GET_MAP_OB(pl->map, pl->x, pl->y); tmp; tmp=tmp->above)
267 if (tmp->type == GEM && !strcmp(tmp->arch->name, "ruby") &&
268 tmp->nrof >= gemcost*nrof*mt->value/100)
269 found++;
270 if (magic > 4)
271 for (tmp=GET_MAP_OB(pl->map, pl->x, pl->y); tmp; tmp=tmp->above)
272 if (tmp->type == GEM && !strcmp(tmp->arch->name, "diamond") &&
273 tmp->nrof >= gemcost*nrof*mt->value/100)
274 found++;
275 if (found < magic) {
276 new_draw_info(NDI_UNIQUE, 0, pl, "You did not provide a suitable "
277 "sacrifice of gems on the ground to add this much magic.");
278 return 0;
279 }
280 if (25*pow(3, magic)*mt->value/100 > pl->stats.sp) {
281 new_draw_info(NDI_UNIQUE, 0, pl, "You do not have enough mana "
282 "to create this object.");
283 return 0;
284 }
285 }
286
287 /* good lord. Now we have a tool, facilites, materials (marked) and an
288 object we want to create. Thats alot of if's */
289
290 obpow = (newobj->item_power + newobj->value/1000 + 1)*mt->value/100;
291 mneed = nrof*((newobj->weight * mt->weight)/80);
292 /* cost can be balanced out by cost to disassemble items for materials */
293 if ((marked->weight * MAX(1, marked->nrof)) < mneed) {
294 new_draw_info_format(NDI_UNIQUE, 0, pl, "You do not have enough %s.",
295 marked->name);
296 return 0;
297 }
298 if (obpow > (tool->level+tool->magic)) {
299 new_draw_info_format(NDI_UNIQUE, 0, pl, "Your %s is not capable of "
300 "crafting such a complex item.", tool->name);
301 return 0;
302 }
303 set_abs_magic(newobj, magic);
304 set_materialname(newobj, 1, mt);
305 for (i=0, nummade=0; i< nrof; i++) {
306 bonus = tool->level+tool->magic - obpow;
307 number = rndm(1, 3*obpow*magic);
308 LOG(llevDebug, "command_build: skill:%d obpow:%d rndm:%d tool:%s "
309 "newobj:%s marked:%s magic:%d\n", SK_level(pl)+bonus, obpow,
310 number, tool->name, newobj->name, marked->name, magic);
311 if (SK_level(pl)+bonus > number) {
312 /* wow, we actually created something */
313 newobj->x = pl->x;
314 newobj->y = pl->y;
315 newobj->map = pl->map;
316 SET_FLAG(newobj, FLAG_IDENTIFIED);
317 if (i == 0)
318 newobj = insert_ob_in_ob(newobj, pl);
319 else
320 newobj->nrof++;
321 esrv_send_item(pl, newobj);
322 nummade++;
323 } else {
324 free_object(newobj);
325 if (bonus < rndm(1, number-SK_level(pl)+bonus)) {
326 new_draw_info_format(NDI_UNIQUE, 0, pl,
327 "You broke your %s!\n", tool->name);
328 esrv_del_item(pl->contr, tool->count);
329 remove_ob(tool);
330 free_object(tool);
331 break;
332 }
333 }
334 /* take away materials too */
335 tmp = get_split_ob(marked, MAX(1, mneed/marked->weight));
336 if (tmp)
337 free_object(tmp);
338 if (marked->nrof < 1)
339 esrv_del_item(pl->contr, marked->count);
340 else
341 esrv_send_item(pl, marked);
342 }
343 if (magic)
344 for (tmp=GET_MAP_OB(pl->map, pl->x, pl->y); tmp; tmp=tmp->above)
345 if (tmp->type == GEM && !strcmp(tmp->arch->name, "pearl") &&
346 tmp->nrof >= gemcost*nrof*mt->value/100)
347 tmp->nrof -= gemcost*nrof*mt->value/100;
348 if (magic > 1)
349 for (tmp=GET_MAP_OB(pl->map, pl->x, pl->y); tmp; tmp=tmp->above)
350 if (tmp->type == GEM && !strcmp(tmp->arch->name, "emerald") &&
351 tmp->nrof >= gemcost*nrof*mt->value/100)
352 tmp->nrof -= gemcost*nrof*mt->value/100;
353 if (magic > 2)
354 for (tmp=GET_MAP_OB(pl->map, pl->x, pl->y); tmp; tmp=tmp->above)
355 if (tmp->type == GEM && !strcmp(tmp->arch->name, "sapphire") &&
356 tmp->nrof >= gemcost*nrof*mt->value/100)
357 tmp->nrof -= gemcost*nrof*mt->value/100;
358 if (magic > 3)
359 for (tmp=GET_MAP_OB(pl->map, pl->x, pl->y); tmp; tmp=tmp->above)
360 if (tmp->type == GEM && !strcmp(tmp->arch->name, "ruby") &&
361 tmp->nrof >= gemcost*nrof*mt->value/100)
362 tmp->nrof -= gemcost*nrof*mt->value/100;
363 if (magic > 4)
364 for (tmp=GET_MAP_OB(pl->map, pl->x, pl->y); tmp; tmp=tmp->above)
365 if (tmp->type == GEM && !strcmp(tmp->arch->name, "diamond") &&
366 tmp->nrof >= gemcost*nrof*mt->value/100)
367 tmp->nrof -= gemcost*nrof*mt->value/100;
368 if (magic)
369 for (tmp=GET_MAP_OB(pl->map, pl->x, pl->y); tmp; tmp=tmp->above)
370 if (tmp->type == GEM &&
371 (!strcmp(tmp->arch->name, "diamond") ||
372 !strcmp(tmp->arch->name, "ruby") ||
373 !strcmp(tmp->arch->name, "sapphire") ||
374 !strcmp(tmp->arch->name, "emerald") ||
375 !strcmp(tmp->arch->name, "pearl"))) {
376 if (tmp->nrof == 0) {
377 remove_ob(tmp);
378 free_object(tmp);
379 }
380 if (pl->contr)
381 pl->contr->socket.update_look=1;
382 }
383 pl->stats.sp -= 25*pow(3, magic)*mt->value/100;
384 fix_player(pl);
385 if (nummade > 1) {
386 new_draw_info_format(NDI_UNIQUE, 0, pl, "You have created %d %s.",
387 nummade, query_base_name(newobj, 1));
388 } else if (nummade == 1) {
389 new_draw_info_format(NDI_UNIQUE, 0, pl, "You have created a %s.",
390 query_base_name(newobj, 0));
391 } else {
392 new_draw_info_format(NDI_UNIQUE, 0, pl,
393 "You have failed to craft a %s.", query_base_name(newobj, 0));
394 return 0;
395 }
396 if (skills[skillnr].category != EXP_NONE)
397 add_exp(pl, obpow*nummade);
398 return 1;
399#endif
400}
401
402
403
404int command_uskill ( object *pl, char *params) { 89int command_uskill ( object *pl, char *params) {
405 if (!params) { 90 if (!params) {
406 new_draw_info(NDI_UNIQUE, 0, pl, "Usage: use_skill <skill name>"); 91 new_draw_info(NDI_UNIQUE, 0, pl, "Usage: use_skill <skill name>");
407 return 0; 92 return 0;
408 } 93 }
411 96
412int command_rskill ( object *pl, char *params) { 97int command_rskill ( object *pl, char *params) {
413 object *skill; 98 object *skill;
414 99
415 if (!params) { 100 if (!params) {
416 new_draw_info(NDI_UNIQUE, 0, pl, "Usage: ready_skill <skill name>"); 101 new_draw_info(NDI_UNIQUE, 0, pl, "Usage: ready_skill <skill name>");
417 return 0; 102 return 0;
418 } 103 }
419 skill = find_skill_by_name(pl, params); 104 skill = find_skill_by_name(pl, params);
420 105
421 if (!skill) { 106 if (!skill) {
422 new_draw_info_format(NDI_UNIQUE, 0, pl, "You have no knowledge of the skill %s", params); 107 new_draw_info_format(NDI_UNIQUE, 0, pl, "You have no knowledge of the skill %s", params);
423 return 0; 108 return 0;
424 } 109 }
425 return change_skill(pl,skill, 0); 110 return change_skill(pl,skill, 0);
426} 111}
427 112
428 113
447 object *skop; 132 object *skop;
448 133
449 skop = find_skill_by_name(op, skill_names[SK_THROWING]); 134 skop = find_skill_by_name(op, skill_names[SK_THROWING]);
450 if (skop) return do_skill(op, op, skop, op->facing,params); 135 if (skop) return do_skill(op, op, skop, op->facing,params);
451 else { 136 else {
452 new_draw_info(NDI_UNIQUE, 0, op, "You have no knowledge of the skill throwing."); 137 new_draw_info(NDI_UNIQUE, 0, op, "You have no knowledge of the skill throwing.");
453 } 138 }
454 return 0; 139 return 0;
455} 140}
456 141
457 142
465 apply_flag aflag = (apply_flag) 0; 150 apply_flag aflag = (apply_flag) 0;
466 object *inv; 151 object *inv;
467 152
468 while (*params==' ') params++; 153 while (*params==' ') params++;
469 if (!strncmp(params,"-a ",3)) { 154 if (!strncmp(params,"-a ",3)) {
470 aflag=AP_APPLY; 155 aflag=AP_APPLY;
471 params+=3; 156 params+=3;
472 } 157 }
473 if (!strncmp(params,"-u ",3)) { 158 if (!strncmp(params,"-u ",3)) {
474 aflag=AP_UNAPPLY; 159 aflag=AP_UNAPPLY;
475 params+=3; 160 params+=3;
476 } 161 }
477 while (*params==' ') params++; 162 while (*params==' ') params++;
478 163
479 inv=find_best_apply_object_match(op, params, aflag); 164 inv=find_best_apply_object_match(op, params, aflag);
480 if (inv) { 165 if (inv) {
481 player_apply(op,inv,aflag,0); 166 player_apply(op,inv,aflag,0);
482 } else 167 } else
483 new_draw_info_format(NDI_UNIQUE, 0, op, 168 new_draw_info_format(NDI_UNIQUE, 0, op,
484 "Could not find any match to the %s.",params); 169 "Could not find any match to the %s.",params);
485 } 170 }
486 return 0; 171 return 0;
487} 172}
488 173
489/* 174/*
496 * not need to use split_ob and stuff. 181 * not need to use split_ob and stuff.
497 */ 182 */
498int sack_can_hold (object *pl, object *sack, object *op, uint32 nrof) { 183int sack_can_hold (object *pl, object *sack, object *op, uint32 nrof) {
499 184
500 if (! QUERY_FLAG (sack, FLAG_APPLIED)) { 185 if (! QUERY_FLAG (sack, FLAG_APPLIED)) {
501 new_draw_info_format(NDI_UNIQUE, 0, pl, 186 new_draw_info_format(NDI_UNIQUE, 0, pl,
502 "The %s is not active.", query_name(sack)); 187 "The %s is not active.", query_name(sack));
503 return 0; 188 return 0;
504 } 189 }
505 if (sack == op) { 190 if (sack == op) {
506 new_draw_info_format(NDI_UNIQUE, 0, pl, 191 new_draw_info_format(NDI_UNIQUE, 0, pl,
507 "You can't put the %s into itself.", query_name(sack)); 192 "You can't put the %s into itself.", query_name(sack));
508 return 0; 193 return 0;
509 } 194 }
510 if (sack->race && (sack->race != op->race || op->type == CONTAINER 195 if (sack->race && (sack->race != op->race || op->type == CONTAINER
511 || (sack->stats.food && sack->stats.food != op->type))) { 196 || (sack->stats.food && sack->stats.food != op->type))) {
512 new_draw_info_format(NDI_UNIQUE, 0, pl, 197 new_draw_info_format(NDI_UNIQUE, 0, pl,
513 "You can put only %s into the %s.", sack->race, query_name(sack)); 198 "You can put only %s into the %s.", &sack->race, query_name(sack));
514 return 0; 199 return 0;
515 } 200 }
516 if (op->type == SPECIAL_KEY && sack->slaying && op->slaying) { 201 if (op->type == SPECIAL_KEY && sack->slaying && op->slaying) {
517 new_draw_info_format(NDI_UNIQUE, 0, pl, 202 new_draw_info_format(NDI_UNIQUE, 0, pl,
518 "You can't put the key into %s.", query_name(sack)); 203 "You can't put the key into %s.", query_name(sack));
519 return 0; 204 return 0;
520 } 205 }
521 if (sack->weight_limit && sack->carrying + (nrof ? nrof : 1) * 206 if (sack->weight_limit && sack->carrying + (nrof ? nrof : 1) *
522 (op->weight + (op->type==CONTAINER?(op->carrying*op->stats.Str):0)) 207 (op->weight + (op->type==CONTAINER?(op->carrying*op->stats.Str):0))
523 * (100 - sack->stats.Str) / 100 > sack->weight_limit) { 208 * (100 - sack->stats.Str) / 100 > sack->weight_limit) {
524 new_draw_info_format(NDI_UNIQUE, 0, pl, 209 new_draw_info_format(NDI_UNIQUE, 0, pl,
525 "That won't fit in the %s!", query_name(sack)); 210 "That won't fit in the %s!", query_name(sack));
526 return 0; 211 return 0;
527 } 212 }
528 /* All other checks pass, must be OK */ 213 /* All other checks pass, must be OK */
529 return 1; 214 return 1;
530} 215}
550 * (sack, luggage, etc), tmp->env->env then points to the player (nested 235 * (sack, luggage, etc), tmp->env->env then points to the player (nested
551 * containers not allowed as of now) 236 * containers not allowed as of now)
552 */ 237 */
553 if((pl->move_type & MOVE_FLYING) && !QUERY_FLAG(pl, FLAG_WIZ) && 238 if((pl->move_type & MOVE_FLYING) && !QUERY_FLAG(pl, FLAG_WIZ) &&
554 is_player_inv(tmp)!=pl) { 239 is_player_inv(tmp)!=pl) {
555 new_draw_info(NDI_UNIQUE, 0,pl, "You are levitating, you can't reach the ground!"); 240 new_draw_info(NDI_UNIQUE, 0,pl, "You are levitating, you can't reach the ground!");
556 return; 241 return;
557 } 242 }
558 if (QUERY_FLAG (tmp, FLAG_NO_DROP)) 243 if (QUERY_FLAG (tmp, FLAG_NO_DROP))
559 return; 244 return;
560 if(QUERY_FLAG(tmp,FLAG_WAS_WIZ) && !QUERY_FLAG(pl, FLAG_WAS_WIZ)) { 245 if(QUERY_FLAG(tmp,FLAG_WAS_WIZ) && !QUERY_FLAG(pl, FLAG_WAS_WIZ)) {
561 new_draw_info(NDI_UNIQUE, 0,pl, "The object disappears in a puff of smoke!"); 246 new_draw_info(NDI_UNIQUE, 0,pl, "The object disappears in a puff of smoke!");
562 new_draw_info(NDI_UNIQUE, 0,pl, "It must have been an illusion."); 247 new_draw_info(NDI_UNIQUE, 0,pl, "It must have been an illusion.");
563 if (pl->type==PLAYER) esrv_del_item (pl->contr, tmp->count); 248 if (pl->type==PLAYER) esrv_del_item (pl->contr, tmp->count);
564 if ( ! QUERY_FLAG (tmp, FLAG_REMOVED)) 249 if ( ! QUERY_FLAG (tmp, FLAG_REMOVED))
565 remove_ob (tmp); 250 remove_ob (tmp);
566 free_object(tmp); 251 free_object(tmp);
567 return; 252 return;
568 } 253 }
569 254
570 if (nrof > tmp_nrof || nrof == 0) 255 if (nrof > tmp_nrof || nrof == 0)
571 nrof = tmp_nrof; 256 nrof = tmp_nrof;
572 /* Figure out how much weight this object will add to the player */ 257 /* Figure out how much weight this object will add to the player */
573 weight = tmp->weight * nrof; 258 weight = tmp->weight * nrof;
574 if (tmp->inv) weight += tmp->carrying * (100 - tmp->stats.Str) / 100; 259 if (tmp->inv) weight += tmp->carrying * (100 - tmp->stats.Str) / 100;
575 if (pl->stats.Str <= MAX_STAT) 260 if (pl->stats.Str <= MAX_STAT)
576 effective_weight_limit = weight_limit[pl->stats.Str]; 261 effective_weight_limit = weight_limit[pl->stats.Str];
577 else 262 else
578 effective_weight_limit = weight_limit[MAX_STAT]; 263 effective_weight_limit = weight_limit[MAX_STAT];
579 if ((pl->weight + pl->carrying + weight) > effective_weight_limit) { 264 if ((pl->weight + pl->carrying + weight) > effective_weight_limit) {
580 new_draw_info(0, 0,pl,"That item is too heavy for you to pick up."); 265 new_draw_info(0, 0,pl,"That item is too heavy for you to pick up.");
581 return; 266 return;
582 } 267 }
583 if (settings.real_wiz == FALSE && QUERY_FLAG(pl, FLAG_WAS_WIZ)) 268 if (settings.real_wiz == FALSE && QUERY_FLAG(pl, FLAG_WAS_WIZ))
584 SET_FLAG(tmp, FLAG_WAS_WIZ); 269 SET_FLAG(tmp, FLAG_WAS_WIZ);
585 if (nrof != tmp_nrof) { 270 if (nrof != tmp_nrof) {
586 object *tmp2 = tmp; 271 object *tmp2 = tmp;
587 tag_t tmp2_tag = tmp2->count; 272 tag_t tmp2_tag = tmp2->count;
588 tmp = get_split_ob (tmp, nrof); 273 tmp = get_split_ob (tmp, nrof);
589 if(!tmp) { 274 if(!tmp) {
590 new_draw_info(NDI_UNIQUE, 0,pl, errmsg); 275 new_draw_info(NDI_UNIQUE, 0,pl, errmsg);
591 return; 276 return;
592 } 277 }
593 /* Tell a client what happened rest of objects */ 278 /* Tell a client what happened rest of objects */
594 if (pl->type == PLAYER) { 279 if (pl->type == PLAYER) {
595 if (was_destroyed (tmp2, tmp2_tag)) 280 if (was_destroyed (tmp2, tmp2_tag))
596 esrv_del_item (pl->contr, tmp2_tag); 281 esrv_del_item (pl->contr, tmp2_tag);
597 else 282 else
598 esrv_send_item (pl, tmp2); 283 esrv_send_item (pl, tmp2);
599 } 284 }
600 } else { 285 } else {
601 /* If the object is in a container, send a delete to the client. 286 /* If the object is in a container, send a delete to the client.
602 * - we are moving all the items from the container to elsewhere, 287 * - we are moving all the items from the container to elsewhere,
603 * so it needs to be deleted. 288 * so it needs to be deleted.
604 */ 289 */
605 if ( ! QUERY_FLAG (tmp, FLAG_REMOVED)) { 290 if ( ! QUERY_FLAG (tmp, FLAG_REMOVED)) {
606 if (tmp->env && pl->type==PLAYER) 291 if (tmp->env && pl->type==PLAYER)
607 esrv_del_item (pl->contr, tmp->count); 292 esrv_del_item (pl->contr, tmp->count);
608 remove_ob(tmp); /* Unlink it */ 293 remove_ob(tmp); /* Unlink it */
609 } 294 }
610 } 295 }
611 if(QUERY_FLAG(tmp, FLAG_UNPAID)) 296 if(QUERY_FLAG(tmp, FLAG_UNPAID))
612 (void) sprintf(buf,"%s will cost you %s.", query_name(tmp), 297 (void) sprintf(buf,"%s will cost you %s.", query_name(tmp),
613 query_cost_string(tmp,pl,F_BUY | F_SHOP)); 298 query_cost_string(tmp,pl,F_BUY | F_SHOP));
614 else 299 else
615 (void) sprintf(buf,"You pick up the %s.", query_name(tmp)); 300 (void) sprintf(buf,"You pick up the %s.", query_name(tmp));
616 new_draw_info(NDI_UNIQUE, 0,pl,buf); 301 new_draw_info(NDI_UNIQUE, 0,pl,buf);
617 302
618 tmp = insert_ob_in_ob(tmp, op); 303 tmp = insert_ob_in_ob(tmp, op);
619 304
620 /* All the stuff below deals with client/server code, and is only 305 /* All the stuff below deals with client/server code, and is only
625 esrv_send_item (pl, tmp); 310 esrv_send_item (pl, tmp);
626 /* These are needed to update the weight for the container we 311 /* These are needed to update the weight for the container we
627 * are putting the object in. 312 * are putting the object in.
628 */ 313 */
629 if (op!=pl) { 314 if (op!=pl) {
630 esrv_update_item (UPD_WEIGHT, pl, op); 315 esrv_update_item (UPD_WEIGHT, pl, op);
631 esrv_send_item (pl, pl); 316 esrv_send_item (pl, pl);
632 } 317 }
633 318
634 /* Update the container the object was in */ 319 /* Update the container the object was in */
635 if (env && env!=pl && env!=op) esrv_update_item (UPD_WEIGHT, pl, env); 320 if (env && env!=pl && env!=op) esrv_update_item (UPD_WEIGHT, pl, env);
636} 321}
647 332
648 /* Decide which object to pick. */ 333 /* Decide which object to pick. */
649 if (alt) 334 if (alt)
650 { 335 {
651 if ( ! can_pick (op, alt)) { 336 if ( ! can_pick (op, alt)) {
652 new_draw_info_format (NDI_UNIQUE, 0, op, "You can't pick up the %s.", 337 new_draw_info_format (NDI_UNIQUE, 0, op, "You can't pick up the %s.", &alt->name);
653 alt->name);
654 goto leave; 338 goto leave;
655 } 339 }
656 tmp = alt; 340 tmp = alt;
657 } 341 }
658 else 342 else
659 { 343 {
673 need_fix_tmp = 1; 357 need_fix_tmp = 1;
674 if ( ! can_pick (op, tmp)) 358 if ( ! can_pick (op, tmp))
675 goto leave; 359 goto leave;
676 360
677 if (op->type==PLAYER) { 361 if (op->type==PLAYER) {
678 count=op->contr->count; 362 count=op->contr->count;
679 if (count==0) count = tmp->nrof; 363 if (count==0) count = tmp->nrof;
680 } 364 }
681 else 365 else
682 count=tmp->nrof; 366 count=tmp->nrof;
683 367
684 /* container is open, so use it */ 368 /* container is open, so use it */
685 if (op->container) { 369 if (op->container) {
686 alt = op->container; 370 alt = op->container;
687 if (alt != tmp->env && !sack_can_hold (op, alt, tmp,count)) 371 if (alt != tmp->env && !sack_can_hold (op, alt, tmp,count))
688 goto leave; 372 goto leave;
689 } else { /* non container pickup */ 373 } else { /* non container pickup */
690 for (alt=op->inv; alt; alt=alt->below)
691 if (alt->type==CONTAINER && QUERY_FLAG(alt, FLAG_APPLIED) &&
692 alt->race && alt->race==tmp->race &&
693 sack_can_hold (NULL, alt, tmp,count))
694 break; /* perfect match */
695
696 if (!alt)
697 for (alt=op->inv; alt; alt=alt->below) 374 for (alt=op->inv; alt; alt=alt->below)
698 if (alt->type==CONTAINER && QUERY_FLAG(alt, FLAG_APPLIED) && 375 if (alt->type==CONTAINER && QUERY_FLAG(alt, FLAG_APPLIED) &&
376 alt->race && alt->race==tmp->race &&
699 sack_can_hold (NULL, alt, tmp,count)) 377 sack_can_hold (NULL, alt, tmp,count))
378 break; /* perfect match */
379
380 if (!alt)
381 for (alt=op->inv; alt; alt=alt->below)
382 if (alt->type==CONTAINER && QUERY_FLAG(alt, FLAG_APPLIED) &&
383 sack_can_hold (NULL, alt, tmp,count))
700 break; /* General container comes next */ 384 break; /* General container comes next */
701 if (!alt) 385 if (!alt)
702 alt = op; /* No free containers */ 386 alt = op; /* No free containers */
703 } 387 }
704 if(tmp->env == alt) { 388 if(tmp->env == alt) {
705 /* here it could be possible to check rent, 389 /* here it could be possible to check rent,
706 * if someone wants to implement it 390 * if someone wants to implement it
707 */ 391 */
708 alt = op; 392 alt = op;
709 } 393 }
710#ifdef PICKUP_DEBUG 394#ifdef PICKUP_DEBUG
711 LOG(llevDebug, "Pick_up(): %s picks %s (%d) and inserts it %s.\n", op->name, tmp->name, op->contr->count, alt->name); 395 LOG(llevDebug, "Pick_up(): %s picks %s (%d) and inserts it %s.\n", op->name, tmp->name, op->contr->count, alt->name);
712#endif 396#endif
713 397
714 /* startequip items are not allowed to be put into containers: */ 398 /* startequip items are not allowed to be put into containers: */
715 if (op->type == PLAYER && alt->type == CONTAINER 399 if (op->type == PLAYER && alt->type == CONTAINER
716 && QUERY_FLAG (tmp, FLAG_STARTEQUIP)) 400 && QUERY_FLAG (tmp, FLAG_STARTEQUIP))
717 { 401 {
718 new_draw_info (NDI_UNIQUE, 0, op, 402 new_draw_info (NDI_UNIQUE, 0, op,
719 "This object cannot be put into containers!"); 403 "This object cannot be put into containers!");
720 goto leave; 404 goto leave;
721 } 405 }
742int command_take (object *op, char *params) 426int command_take (object *op, char *params)
743{ 427{
744 object *tmp, *next; 428 object *tmp, *next;
745 429
746 if (op->container) 430 if (op->container)
747 tmp=op->container->inv; 431 tmp=op->container->inv;
748 else { 432 else {
749 tmp=op->above; 433 tmp=op->above;
750 if (tmp) while (tmp->above) { 434 if (tmp) while (tmp->above) {
751 tmp=tmp->above; 435 tmp=tmp->above;
752 } 436 }
753 if (!tmp) 437 if (!tmp)
754 tmp=op->below; 438 tmp=op->below;
755 } 439 }
756 440
757 if (tmp==NULL) { 441 if (tmp==NULL) {
758 new_draw_info(NDI_UNIQUE, 0,op,"Nothing to take!"); 442 new_draw_info(NDI_UNIQUE, 0,op,"Nothing to take!");
759 return 0; 443 return 0;
760 } 444 }
761 445
762 /* Makes processing easier */ 446 /* Makes processing easier */
763 if (params && *params=='\0') params=NULL; 447 if (params && *params=='\0') params=NULL;
764 448
765 while (tmp) { 449 while (tmp) {
766 next=tmp->below; 450 next=tmp->below;
767 451
768 if (tmp->invisible) { 452 if (tmp->invisible) {
769 tmp=next; 453 tmp=next;
770 continue; 454 continue;
771 } 455 }
772 /* This following two if and else if could be merged into line 456 /* This following two if and else if could be merged into line
773 * but that probably will make it more difficult to read, and 457 * but that probably will make it more difficult to read, and
774 * not make it any more efficient 458 * not make it any more efficient
775 */ 459 */
776 if (params && item_matched_string(op, tmp, params)) { 460 if (params && item_matched_string(op, tmp, params)) {
777 pick_up(op, tmp); 461 pick_up(op, tmp);
778 } 462 }
779 else if (can_pick(op, tmp) && !params) { 463 else if (can_pick(op, tmp) && !params) {
780 pick_up(op,tmp); 464 pick_up(op,tmp);
781 break; 465 break;
782 } 466 }
783 tmp=next; 467 tmp=next;
784 /* Might as well just skip over the player immediately - 468 /* Might as well just skip over the player immediately -
785 * we know it can't be picked up 469 * we know it can't be picked up
786 */ 470 */
787 if (tmp == op) tmp=tmp->below; 471 if (tmp == op) tmp=tmp->below;
788 } 472 }
789 if (!params && !tmp) { 473 if (!params && !tmp) {
790 for (tmp=op->below; tmp!=NULL; tmp=tmp->next) 474 for (tmp=op->below; tmp!=NULL; tmp=tmp->next)
791 if (!tmp->invisible) { 475 if (!tmp->invisible) {
792 char buf[MAX_BUF]; 476 char buf[MAX_BUF];
793 sprintf(buf,"You can't pick up a %s.", 477 sprintf(buf,"You can't pick up a %s.", &tmp->name);
794 tmp->name? tmp->name:"null");
795 new_draw_info(NDI_UNIQUE, 0,op, buf); 478 new_draw_info(NDI_UNIQUE, 0, op, buf);
796 break; 479 break;
797 } 480 }
798 if (!tmp) new_draw_info(NDI_UNIQUE, 0,op, "There is nothing to pick up."); 481 if (!tmp) new_draw_info(NDI_UNIQUE, 0,op, "There is nothing to pick up.");
799 } 482 }
800 return 0; 483 return 0;
801} 484}
802 485
803 486
813 tag_t tmp_tag, tmp2_tag; 496 tag_t tmp_tag, tmp2_tag;
814 object *tmp2, *sack2; 497 object *tmp2, *sack2;
815 char buf[MAX_BUF]; 498 char buf[MAX_BUF];
816 499
817 if (sack==tmp) return; /* Can't put an object in itself */ 500 if (sack==tmp) return; /* Can't put an object in itself */
818 if (sack->type != CONTAINER && sack->type != TRANSPORT) {
819 new_draw_info_format(NDI_UNIQUE, 0,op,
820 "The %s is not a container.", query_name(sack));
821 return;
822 }
823 if (QUERY_FLAG(tmp,FLAG_STARTEQUIP)) { 501 if (QUERY_FLAG(tmp,FLAG_STARTEQUIP)) {
824 new_draw_info_format(NDI_UNIQUE, 0,op, 502 new_draw_info_format(NDI_UNIQUE, 0,op,
825 "You cannot put the %s in the %s.", query_name(tmp), 503 "You cannot put the %s in the %s.", query_name(tmp),
826 query_name(sack)); 504 query_name(sack));
827 return; 505 return;
828 } 506 }
829 if (tmp->type == CONTAINER && tmp->inv) { 507 if (tmp->type == CONTAINER && tmp->inv) {
830 508
831 /* Eneq(@csd.uu.se): If the object to be dropped is a container 509 /* Eneq(@csd.uu.se): If the object to be dropped is a container
832 * we instead move the contents of that container into the active 510 * we instead move the contents of that container into the active
833 * container, this is only done if the object has something in it. 511 * container, this is only done if the object has something in it.
834 */ 512 */
835 sack2 = tmp; 513 sack2 = tmp;
836 new_draw_info_format(NDI_UNIQUE, 0,op, "You move the items from %s into %s.", 514 new_draw_info_format(NDI_UNIQUE, 0,op, "You move the items from %s into %s.",
837 query_name(tmp), query_name(sack)); 515 query_name(tmp), query_name(sack));
838 for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) { 516 for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) {
839 tmp = tmp2->below; 517 tmp = tmp2->below;
840 if ((sack->type == CONTAINER && sack_can_hold(op, op->container, tmp2,tmp2->nrof)) || 518 if ((sack->type == CONTAINER && sack_can_hold(op, op->container, tmp2,tmp2->nrof))) {
841 (sack->type == TRANSPORT && transport_can_hold(sack, tmp2, tmp2->nrof))) {
842 put_object_in_sack (op, sack, tmp2, 0); 519 put_object_in_sack (op, sack, tmp2, 0);
843 } else { 520 } else {
844 sprintf(buf,"Your %s fills up.", query_name(sack)); 521 sprintf(buf,"Your %s fills up.", query_name(sack));
845 new_draw_info(NDI_UNIQUE, 0,op, buf); 522 new_draw_info(NDI_UNIQUE, 0,op, buf);
846 break; 523 break;
847 } 524 }
848 } 525 }
849 esrv_update_item (UPD_WEIGHT, op, sack2); 526 esrv_update_item (UPD_WEIGHT, op, sack2);
850 return; 527 return;
851 } 528 }
852 529
853 /* Don't worry about this for containers - our caller should have 530 /* Don't worry about this for containers - our caller should have
854 * already checked this. 531 * already checked this.
855 */ 532 */
856 if ((sack->type == CONTAINER) && !sack_can_hold (op, sack, tmp,(nrof?nrof:tmp->nrof))) 533 if ((sack->type == CONTAINER) && !sack_can_hold (op, sack, tmp,(nrof?nrof:tmp->nrof)))
857 return; 534 return;
858 535
859 if(QUERY_FLAG(tmp, FLAG_APPLIED)) { 536 if(QUERY_FLAG(tmp, FLAG_APPLIED)) {
860 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) 537 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE))
861 return; 538 return;
862 } 539 }
863 540
864 /* we want to put some portion of the item into the container */ 541 /* we want to put some portion of the item into the container */
865 if (nrof && tmp->nrof != nrof) { 542 if (nrof && tmp->nrof != nrof) {
866 object *tmp2 = tmp; 543 object *tmp2 = tmp;
867 tmp2_tag = tmp2->count; 544 tmp2_tag = tmp2->count;
868 tmp = get_split_ob (tmp, nrof); 545 tmp = get_split_ob (tmp, nrof);
869 546
870 if(!tmp) { 547 if(!tmp) {
871 new_draw_info(NDI_UNIQUE, 0,op, errmsg); 548 new_draw_info(NDI_UNIQUE, 0,op, errmsg);
872 return; 549 return;
873 } 550 }
874 /* Tell a client what happened other objects */ 551 /* Tell a client what happened other objects */
875 if (was_destroyed (tmp2, tmp2_tag)) 552 if (was_destroyed (tmp2, tmp2_tag))
876 esrv_del_item (op->contr, tmp2_tag); 553 esrv_del_item (op->contr, tmp2_tag);
877 else /* this can proably be replaced with an update */ 554 else /* this can proably be replaced with an update */
878 esrv_send_item (op, tmp2); 555 esrv_send_item (op, tmp2);
879 } else 556 } else
880 remove_ob(tmp); 557 remove_ob(tmp);
881 558
882 new_draw_info_format(NDI_UNIQUE, 0,op, "You put the %s in %s.", 559 new_draw_info_format(NDI_UNIQUE, 0,op, "You put the %s in %s.",
883 query_name(tmp), query_name(sack)); 560 query_name(tmp), query_name(sack));
884 tmp_tag = tmp->count; 561 tmp_tag = tmp->count;
885 tmp2 = insert_ob_in_ob(tmp, sack); 562 tmp2 = insert_ob_in_ob(tmp, sack);
886 fix_player(op); /* This is overkill, fix_player() is called somewhere */ 563 fix_player(op); /* This is overkill, fix_player() is called somewhere */
887 /* in object.c */ 564 /* in object.c */
888 565
889 /* If an object merged (and thus, different object), we need to 566 /* If an object merged (and thus, different object), we need to
890 * delete the original. 567 * delete the original.
891 */ 568 */
892 if (tmp2 != tmp) 569 if (tmp2 != tmp)
893 esrv_del_item (op->contr, tmp_tag); 570 esrv_del_item (op->contr, tmp_tag);
894 571
895 esrv_send_item (op, tmp2); 572 esrv_send_item (op, tmp2);
896 573
897 /* If a transport, need to update all the players in the transport
898 * the view of what is in it.
899 */
900 if (sack->type == TRANSPORT) {
901 for (tmp=sack->inv; tmp; tmp=tmp->below) {
902 if (tmp->type == PLAYER) tmp->contr->socket.update_look=1;
903 }
904 } else {
905 /* update the sacks weight */ 574 /* update the sacks weight */
906 esrv_update_item (UPD_WEIGHT, op, sack); 575 esrv_update_item (UPD_WEIGHT, op, sack);
907 }
908} 576}
909 577
910/* 578/*
911 * This function was part of drop, now is own function. 579 * This function was part of drop, now is own function.
912 * Player 'op' tries to drop object 'tmp', if tmp is non zero, then 580 * Player 'op' tries to drop object 'tmp', if tmp is non zero, then
951 } 619 }
952 } 620 }
953 else 621 else
954 remove_ob (tmp); 622 remove_ob (tmp);
955 623
956 /* Lauwenmark: Handle for plugin drop event */ 624 if (INVOKE_OBJECT (DROP, tmp, ARG_OBJECT (op)))
957 if (execute_event (tmp, EVENT_DROP, op, NULL, NULL, SCRIPT_FIX_ALL) != 0)
958 return; 625 return;
959 626
960 if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) 627 if (QUERY_FLAG (tmp, FLAG_STARTEQUIP))
961 { 628 {
962 sprintf (buf, "You drop the %s.", query_name (tmp)); 629 sprintf (buf, "You drop the %s.", query_name (tmp));
1002 /* Need to update the weight for the player */ 669 /* Need to update the weight for the player */
1003 esrv_send_item (op, op); 670 esrv_send_item (op, op);
1004 } 671 }
1005 672
1006 for (floor = get_map_ob (op->map, op->x, op->y); floor; floor = floor->above) 673 for (floor = get_map_ob (op->map, op->x, op->y); floor; floor = floor->above)
1007 if (execute_event (floor, EVENT_DROP_ON, op, tmp, NULL, SCRIPT_FIX_ALL)) 674 if (INVOKE_OBJECT (DROP_ON, floor, ARG_OBJECT (tmp), ARG_OBJECT (op)))
1008 return; 675 return;
1009 676
1010 if (floor 677 if (is_in_shop (op)
1011 && floor->type == SHOP_FLOOR
1012 && !QUERY_FLAG (tmp, FLAG_UNPAID) 678 && !QUERY_FLAG (tmp, FLAG_UNPAID)
1013 && tmp->type != MONEY) 679 && tmp->type != MONEY)
1014 sell_item (tmp, op); 680 sell_item (tmp, op);
1015 681
1016 tmp->x = op->x; 682 tmp->x = op->x;
1025 * somehow, players get an invisible object in the container, and the 691 * somehow, players get an invisible object in the container, and the
1026 * old logic would skip over invisible objects - works fine for the 692 * old logic would skip over invisible objects - works fine for the
1027 * playes inventory, but drop inventory wants to use the next value. 693 * playes inventory, but drop inventory wants to use the next value.
1028 */ 694 */
1029 if (tmp->invisible) { 695 if (tmp->invisible) {
1030 /* if the following is the case, it must be in an container. */ 696 /* if the following is the case, it must be in an container. */
1031 if (tmp->env && tmp->env->type != PLAYER) { 697 if (tmp->env && tmp->env->type != PLAYER) {
1032 /* Just toss the object - probably shouldn't be hanging 698 /* Just toss the object - probably shouldn't be hanging
1033 * around anyways 699 * around anyways
1034 */ 700 */
1035 remove_ob(tmp); 701 remove_ob(tmp);
1036 free_object(tmp); 702 free_object(tmp);
1037 return; 703 return;
1038 } else { 704 } else {
1039 while(tmp!=NULL && tmp->invisible) 705 while(tmp!=NULL && tmp->invisible)
1040 tmp=tmp->below; 706 tmp=tmp->below;
1041 } 707 }
1042 } 708 }
1043 709
1044 if (tmp==NULL) { 710 if (tmp==NULL) {
1045 new_draw_info(NDI_UNIQUE, 0,op,"You don't have anything to drop."); 711 new_draw_info(NDI_UNIQUE, 0,op,"You don't have anything to drop.");
1046 return; 712 return;
1060 if (op->type == PLAYER) 726 if (op->type == PLAYER)
1061 { 727 {
1062 if (op->contr->last_used==tmp && op->contr->last_used_id == tmp->count) { 728 if (op->contr->last_used==tmp && op->contr->last_used_id == tmp->count) {
1063 object *n=NULL; 729 object *n=NULL;
1064 if(tmp->below != NULL) 730 if(tmp->below != NULL)
1065 n = tmp->below; 731 n = tmp->below;
1066 else if(tmp->above != NULL) 732 else if(tmp->above != NULL)
1067 n = tmp->above; 733 n = tmp->above;
1068 op->contr->last_used = n; 734 op->contr->last_used = n;
1069 if (n != NULL) 735 if (n != NULL)
1070 op->contr->last_used_id = n->count; 736 op->contr->last_used_id = n->count;
1071 else 737 else
1072 op->contr->last_used_id = 0; 738 op->contr->last_used_id = 0;
1073 } 739 }
1074 }; 740 };
1075 741
1076 if (op->container) { 742 if (op->container) {
1077 if (op->type == PLAYER) 743 if (op->type == PLAYER)
1118 784
1119 if(params==NULL) { 785 if(params==NULL) {
1120 while(curinv != NULL) { 786 while(curinv != NULL) {
1121 nextinv = curinv->below; 787 nextinv = curinv->below;
1122 while (nextinv && nextinv->type==MONEY) 788 while (nextinv && nextinv->type==MONEY)
1123 nextinv = nextinv->below; 789 nextinv = nextinv->below;
1124 if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && curinv->type != MONEY && 790 if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && curinv->type != MONEY &&
1125 curinv->type != FOOD && curinv->type != KEY && 791 curinv->type != FOOD && curinv->type != KEY &&
1126 curinv->type != SPECIAL_KEY && curinv->type != GEM && 792 curinv->type != SPECIAL_KEY && curinv->type != GEM &&
1127 !curinv->invisible && 793 !curinv->invisible &&
1128 (curinv->type!=CONTAINER || op->container!=curinv)) 794 (curinv->type!=CONTAINER || op->container!=curinv))
1129 { 795 {
1130 drop(op,curinv); 796 drop(op,curinv);
1131 } 797 }
1132 curinv = nextinv; 798 curinv = nextinv;
1133 } 799 }
1134 } 800 }
1135 801
1136 else if(strcmp(params, "weapons") == 0) { 802 else if(strcmp(params, "weapons") == 0) {
1137 while(curinv != NULL) { 803 while(curinv != NULL) {
1138 nextinv = curinv->below; 804 nextinv = curinv->below;
1139 while (nextinv && nextinv->type==MONEY) 805 while (nextinv && nextinv->type==MONEY)
1140 nextinv = nextinv->below; 806 nextinv = nextinv->below;
1141 if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ((curinv->type == WEAPON) || 807 if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ((curinv->type == WEAPON) ||
1142 (curinv->type == BOW) || (curinv->type == ARROW))) 808 (curinv->type == BOW) || (curinv->type == ARROW)))
1143 { 809 {
1144 drop(op,curinv); 810 drop(op,curinv);
1145 } 811 }
1146 curinv = nextinv; 812 curinv = nextinv;
1147 } 813 }
1148 } 814 }
1149 815
1150 else if(strcmp(params, "armor") == 0 || strcmp(params, "armour") == 0) { 816 else if(strcmp(params, "armor") == 0 || strcmp(params, "armour") == 0) {
1151 while(curinv != NULL) { 817 while(curinv != NULL) {
1152 nextinv = curinv->below; 818 nextinv = curinv->below;
1153 while (nextinv && nextinv->type==MONEY) 819 while (nextinv && nextinv->type==MONEY)
1154 nextinv = nextinv->below; 820 nextinv = nextinv->below;
1155 if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ((curinv->type == ARMOUR) || 821 if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ((curinv->type == ARMOUR) ||
1156 curinv->type == SHIELD || curinv->type==HELMET)) 822 curinv->type == SHIELD || curinv->type==HELMET))
1157 { 823 {
1158 drop(op,curinv); 824 drop(op,curinv);
1159 } 825 }
1160 curinv = nextinv; 826 curinv = nextinv;
1161 } 827 }
1162 } 828 }
1163 829
1164 else if(strcmp(params, "misc") == 0) { 830 else if(strcmp(params, "misc") == 0) {
1165 while(curinv != NULL) { 831 while(curinv != NULL) {
1166 nextinv = curinv->below; 832 nextinv = curinv->below;
1167 while (nextinv && nextinv->type==MONEY) 833 while (nextinv && nextinv->type==MONEY)
1168 nextinv = nextinv->below; 834 nextinv = nextinv->below;
1169 if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ! QUERY_FLAG(curinv,FLAG_APPLIED)) { 835 if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ! QUERY_FLAG(curinv,FLAG_APPLIED)) {
1170 switch(curinv->type) { 836 switch(curinv->type) {
1171 case HORN: 837 case HORN:
1172 case BOOK: 838 case BOOK:
1173 case SPELLBOOK: 839 case SPELLBOOK:
1174 case GIRDLE: 840 case GIRDLE:
1175 case AMULET: 841 case AMULET:
1176 case RING: 842 case RING:
1177 case CLOAK: 843 case CLOAK:
1178 case BOOTS: 844 case BOOTS:
1179 case GLOVES: 845 case GLOVES:
1180 case BRACERS: 846 case BRACERS:
1181 case SCROLL: 847 case SCROLL:
1182 case ARMOUR_IMPROVER: 848 case ARMOUR_IMPROVER:
1183 case WEAPON_IMPROVER: 849 case WEAPON_IMPROVER:
1184 case WAND: 850 case WAND:
1185 case ROD: 851 case ROD:
1186 case POTION: 852 case POTION:
1187 drop(op,curinv); 853 drop(op,curinv);
1188 curinv = nextinv; 854 curinv = nextinv;
1189 break; 855 break;
1190 default: 856 default:
1191 curinv = nextinv; 857 curinv = nextinv;
1192 break; 858 break;
1193 } 859 }
1194 } 860 }
1195 curinv = nextinv; 861 curinv = nextinv;
1196 } 862 }
1197 } 863 }
1198 op->contr->socket.update_look=1; 864 op->contr->socket.update_look=1;
1208{ 874{
1209 object *tmp, *next; 875 object *tmp, *next;
1210 int did_one=0; 876 int did_one=0;
1211 877
1212 if (!params) { 878 if (!params) {
1213 new_draw_info(NDI_UNIQUE,0, op, "Drop what?"); 879 new_draw_info(NDI_UNIQUE,0, op, "Drop what?");
1214 return 0; 880 return 0;
1215 } else { 881 } else {
1216 for (tmp=op->inv; tmp; tmp=next) { 882 for (tmp=op->inv; tmp; tmp=next) {
1217 next=tmp->below; 883 next=tmp->below;
1218 if (QUERY_FLAG(tmp,FLAG_NO_DROP) || 884 if (QUERY_FLAG(tmp,FLAG_NO_DROP) ||
1219 tmp->invisible) continue; 885 tmp->invisible) continue;
1220 if (item_matched_string(op,tmp,params)) { 886 if (item_matched_string(op,tmp,params)) {
1221 drop(op, tmp); 887 drop(op, tmp);
1222 did_one=1; 888 did_one=1;
1223 } 889 }
1224 } 890 }
1225 if (!did_one) new_draw_info(NDI_UNIQUE, 0,op,"Nothing to drop."); 891 if (!did_one) new_draw_info(NDI_UNIQUE, 0,op,"Nothing to drop.");
1226 } 892 }
1227 if (op->type==PLAYER) 893 if (op->type==PLAYER)
1228 { 894 {
1229 op->contr->count=0; 895 op->contr->count=0;
1230 op->contr->socket.update_look=1; 896 op->contr->socket.update_look=1;
1243 else { 909 else {
1244 object *tmp=find_best_object_match(op,params); 910 object *tmp=find_best_object_match(op,params);
1245 if (tmp) 911 if (tmp)
1246 examine(op,tmp); 912 examine(op,tmp);
1247 else 913 else
1248 new_draw_info_format(NDI_UNIQUE,0,op,"Could not find an object that matches %s",params); 914 new_draw_info_format(NDI_UNIQUE,0,op,"Could not find an object that matches %s",params);
1249 } 915 }
1250 return 0; 916 return 0;
1251} 917}
1252 918
1253/* op should be a player. 919/* op should be a player.
1261 object *tmp; 927 object *tmp;
1262 928
1263 if (!op || !op->contr) return NULL; 929 if (!op || !op->contr) return NULL;
1264 if (!op->contr->mark) { 930 if (!op->contr->mark) {
1265/* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ 931/* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/
1266 return NULL; 932 return NULL;
1267 } 933 }
1268 /* This may seem like overkill, but we need to make sure that they 934 /* This may seem like overkill, but we need to make sure that they
1269 * player hasn't dropped the item. We use count on the off chance that 935 * player hasn't dropped the item. We use count on the off chance that
1270 * an item got reincarnated at some point. 936 * an item got reincarnated at some point.
1271 */ 937 */
1272 for (tmp=op->inv; tmp; tmp=tmp->below) { 938 for (tmp=op->inv; tmp; tmp=tmp->below) {
1273 if (tmp->invisible) continue; 939 if (tmp->invisible) continue;
1274 if (tmp == op->contr->mark) { 940 if (tmp == op->contr->mark) {
1275 if (tmp->count == op->contr->mark_count) 941 if (tmp->count == op->contr->mark_count)
1276 return tmp; 942 return tmp;
1277 else { 943 else {
1278 op->contr->mark=NULL; 944 op->contr->mark=NULL;
1279 op->contr->mark_count=0; 945 op->contr->mark_count=0;
1280/* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ 946/* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/
1281 return NULL; 947 return NULL;
1282 } 948 }
1283 } 949 }
1284 } 950 }
1285 return NULL; 951 return NULL;
1286} 952}
1287 953
1288 954
1292 */ 958 */
1293int command_mark(object *op, char *params) 959int command_mark(object *op, char *params)
1294{ 960{
1295 if (!op->contr) return 1; 961 if (!op->contr) return 1;
1296 if (!params) { 962 if (!params) {
1297 object *mark=find_marked_object(op); 963 object *mark=find_marked_object(op);
1298 if (!mark) new_draw_info(NDI_UNIQUE,0,op,"You have no marked object."); 964 if (!mark) new_draw_info(NDI_UNIQUE,0,op,"You have no marked object.");
1299 else new_draw_info_format(NDI_UNIQUE,0,op,"%s is marked.", query_name(mark)); 965 else new_draw_info_format(NDI_UNIQUE,0,op,"%s is marked.", query_name(mark));
1300 } 966 }
1301 else { 967 else {
1302 object *mark1=find_best_object_match(op, params); 968 object *mark1=find_best_object_match(op, params);
1303 if (!mark1) { 969 if (!mark1) {
1304 new_draw_info_format(NDI_UNIQUE,0,op,"Could not find an object that matches %s",params); 970 new_draw_info_format(NDI_UNIQUE,0,op,"Could not find an object that matches %s",params);
1305 return 1; 971 return 1;
1306 } 972 }
1307 else { 973 else {
1308 op->contr->mark=mark1; 974 op->contr->mark=mark1;
1309 op->contr->mark_count=mark1->count; 975 op->contr->mark_count=mark1->count;
1310 new_draw_info_format(NDI_UNIQUE,0,op,"Marked item %s", query_name(mark1)); 976 new_draw_info_format(NDI_UNIQUE,0,op,"Marked item %s", query_name(mark1));
1311 return 0; 977 return 0;
1312 } 978 }
1313 } 979 }
1314 return 0; /*shouldnt get here */ 980 return 0; /*shouldnt get here */
1315} 981}
1316 982
1317 983
1320 */ 986 */
1321void examine_monster(object *op,object *tmp) { 987void examine_monster(object *op,object *tmp) {
1322 object *mon=tmp->head?tmp->head:tmp; 988 object *mon=tmp->head?tmp->head:tmp;
1323 989
1324 if(QUERY_FLAG(mon,FLAG_UNDEAD)) 990 if(QUERY_FLAG(mon,FLAG_UNDEAD))
1325 new_draw_info(NDI_UNIQUE, 0,op,"It is an undead force."); 991 new_draw_info(NDI_UNIQUE, 0,op,"It is an undead force.");
1326 if(mon->level>op->level) 992 if(mon->level>op->level)
1327 new_draw_info(NDI_UNIQUE, 0,op,"It is likely more powerful than you."); 993 new_draw_info(NDI_UNIQUE, 0,op,"It is likely more powerful than you.");
1328 else if(mon->level<op->level) 994 else if(mon->level<op->level)
1329 new_draw_info(NDI_UNIQUE, 0,op,"It is likely less powerful than you."); 995 new_draw_info(NDI_UNIQUE, 0,op,"It is likely less powerful than you.");
1330 else 996 else
1331 new_draw_info(NDI_UNIQUE, 0,op,"It is probably as powerful as you."); 997 new_draw_info(NDI_UNIQUE, 0,op,"It is probably as powerful as you.");
1332 if(mon->attacktype&AT_ACID) 998 if(mon->attacktype&AT_ACID)
1333 new_draw_info(NDI_UNIQUE, 0,op,"You seem to smell an acrid odor."); 999 new_draw_info(NDI_UNIQUE, 0,op,"You seem to smell an acrid odor.");
1334 1000
1335 /* Anyone know why this used to use the clone value instead of the 1001 /* Anyone know why this used to use the clone value instead of the
1336 * maxhp field? This seems that it should give more accurate results. 1002 * maxhp field? This seems that it should give more accurate results.
1337 */ 1003 */
1338 switch((mon->stats.hp+1)*4/(mon->stats.maxhp+1)) { /* From 1-4 */ 1004 switch((mon->stats.hp+1)*4/(mon->stats.maxhp+1)) { /* From 1-4 */
1339 case 1: 1005 case 1:
1340 new_draw_info(NDI_UNIQUE, 0,op,"It is in a bad shape."); 1006 new_draw_info(NDI_UNIQUE, 0,op,"It is in a bad shape.");
1341 break; 1007 break;
1342 case 2: 1008 case 2:
1343 new_draw_info(NDI_UNIQUE, 0,op,"It is hurt."); 1009 new_draw_info(NDI_UNIQUE, 0,op,"It is hurt.");
1344 break; 1010 break;
1345 case 3: 1011 case 3:
1346 new_draw_info(NDI_UNIQUE, 0,op,"It is somewhat hurt."); 1012 new_draw_info(NDI_UNIQUE, 0,op,"It is somewhat hurt.");
1347 break; 1013 break;
1348 case 4: 1014 case 4:
1349 new_draw_info(NDI_UNIQUE, 0,op,"It is in excellent shape."); 1015 new_draw_info(NDI_UNIQUE, 0,op,"It is in excellent shape.");
1350 break; 1016 break;
1351 } 1017 }
1352 if(present_in_ob(POISONING,mon)!=NULL) 1018 if(present_in_ob(POISONING,mon)!=NULL)
1353 new_draw_info(NDI_UNIQUE, 0,op,"It looks very ill."); 1019 new_draw_info(NDI_UNIQUE, 0,op,"It looks very ill.");
1354} 1020}
1355 1021
1356 1022
1357/* tmp is the object being described, pl is who is examing it. */ 1023/* tmp is the object being described, pl is who is examing it. */
1358char *long_desc(object *tmp, object *pl) { 1024char *long_desc(object *tmp, object *pl) {
1359 static char buf[VERY_BIG_BUF]; 1025 static char buf[VERY_BIG_BUF];
1360 char *cp; 1026 char *cp;
1361 1027
1362 if(tmp==NULL) 1028 if(tmp==NULL)
1363 return ""; 1029 return "";
1364 1030
1365 buf[0]='\0'; 1031 buf[0]='\0';
1366 switch(tmp->type) { 1032 switch(tmp->type) {
1367 case RING: 1033 case RING:
1368 case SKILL: 1034 case SKILL:
1369 case WEAPON: 1035 case WEAPON:
1370 case ARMOUR: 1036 case ARMOUR:
1371 case BRACERS: 1037 case BRACERS:
1372 case HELMET: 1038 case HELMET:
1373 case SHIELD: 1039 case SHIELD:
1374 case BOOTS: 1040 case BOOTS:
1375 case GLOVES: 1041 case GLOVES:
1376 case AMULET: 1042 case AMULET:
1377 case GIRDLE: 1043 case GIRDLE:
1378 case BOW: 1044 case BOW:
1379 case ARROW: 1045 case ARROW:
1380 case CLOAK: 1046 case CLOAK:
1381 case FOOD: 1047 case FOOD:
1382 case DRINK: 1048 case DRINK:
1383 case FLESH: 1049 case FLESH:
1384 case SKILL_TOOL: 1050 case SKILL_TOOL:
1385 case POWER_CRYSTAL: 1051 case POWER_CRYSTAL:
1386 if(*(cp=describe_item(tmp, pl))!='\0') { 1052 if(*(cp=describe_item(tmp, pl))!='\0') {
1387 int len; 1053 int len;
1388 1054
1389 strncpy(buf,query_name(tmp), VERY_BIG_BUF-1); 1055 strncpy(buf,query_name(tmp), VERY_BIG_BUF-1);
1390 buf[VERY_BIG_BUF-1]=0; 1056 buf[VERY_BIG_BUF-1]=0;
1391 len=strlen(buf); 1057 len=strlen(buf);
1392 if (len<VERY_BIG_BUF-5) { 1058 if (len<VERY_BIG_BUF-5) {
1393 /* Since we know the length, we save a few cpu cycles by using 1059 /* Since we know the length, we save a few cpu cycles by using
1394 * it instead of calling strcat */ 1060 * it instead of calling strcat */
1395 strcpy(buf+len," "); 1061 strcpy(buf+len," ");
1396 len++; 1062 len++;
1397 strncpy(buf+len, cp, VERY_BIG_BUF-len-1); 1063 strncpy(buf+len, cp, VERY_BIG_BUF-len-1);
1398 buf[VERY_BIG_BUF-1]=0; 1064 buf[VERY_BIG_BUF-1]=0;
1399 } 1065 }
1400 } 1066 }
1401 } 1067 }
1402 if(buf[0]=='\0') { 1068 if(buf[0]=='\0') {
1403 strncpy(buf,query_name(tmp), VERY_BIG_BUF-1); 1069 strncpy(buf,query_name(tmp), VERY_BIG_BUF-1);
1404 buf[VERY_BIG_BUF-1]=0; 1070 buf[VERY_BIG_BUF-1]=0;
1405 } 1071 }
1406 1072
1407 return buf; 1073 return buf;
1408} 1074}
1409 1075
1410void examine(object *op, object *tmp) { 1076void examine(object *op, object *tmp) {
1411 char buf[VERY_BIG_BUF]; 1077 char buf[VERY_BIG_BUF];
1412 int i; 1078 int i;
1413 1079
1414 if (tmp == NULL || tmp->type == CLOSE_CON) 1080 if (tmp == NULL || tmp->type == CLOSE_CON)
1415 return; 1081 return;
1416 1082
1417 strcpy(buf,"That is "); 1083 strcpy(buf,"That is ");
1418 strncat(buf, long_desc(tmp, op), VERY_BIG_BUF-strlen(buf)-1); 1084 strncat(buf, long_desc(tmp, op), VERY_BIG_BUF-strlen(buf)-1);
1419 buf[VERY_BIG_BUF-1]=0; 1085 buf[VERY_BIG_BUF-1]=0;
1420 1086
1428 new_draw_info(NDI_UNIQUE, 0,op,buf); 1094 new_draw_info(NDI_UNIQUE, 0,op,buf);
1429 buf[0]='\0'; 1095 buf[0]='\0';
1430 } 1096 }
1431 1097
1432 switch(tmp->type) { 1098 switch(tmp->type) {
1433 case SPELLBOOK: 1099 case SPELLBOOK:
1434 if(QUERY_FLAG(tmp, FLAG_IDENTIFIED) && tmp->inv ) { 1100 if(QUERY_FLAG(tmp, FLAG_IDENTIFIED) && tmp->inv ) {
1435 sprintf(buf,"%s is a %s level %s spell", 1101 sprintf(buf,"%s is a %s level %s spell",
1436 tmp->inv->name, get_levelnumber(tmp->inv->level), 1102 &tmp->inv->name, get_levelnumber(tmp->inv->level),
1437 tmp->inv->skill); 1103 &tmp->inv->skill);
1438 } 1104 }
1439 break; 1105 break;
1440 1106
1441 case BOOK: 1107 case BOOK:
1442 if(tmp->msg!=NULL) 1108 if(tmp->msg!=NULL)
1443 strcpy(buf,"Something is written in it."); 1109 strcpy(buf,"Something is written in it.");
1444 break; 1110 break;
1445 1111
1446 case CONTAINER: 1112 case CONTAINER:
1447 if(tmp->race!=NULL) { 1113 if(tmp->race!=NULL) {
1448 if(tmp->weight_limit && tmp->stats.Str<100) 1114 if(tmp->weight_limit && tmp->stats.Str<100)
1449 sprintf (buf,"It can hold only %s and its weight limit is %.1f kg.", 1115 sprintf (buf,"It can hold only %s and its weight limit is %.1f kg.",
1450 tmp->race, tmp->weight_limit/(10.0 * (100 - tmp->stats.Str))); 1116 &tmp->race, tmp->weight_limit/(10.0 * (100 - tmp->stats.Str)));
1451 else 1117 else
1452 sprintf (buf,"It can hold only %s.", tmp->race); 1118 sprintf (buf,"It can hold only %s.", &tmp->race);
1453 } else 1119 } else
1454 if(tmp->weight_limit && tmp->stats.Str<100) 1120 if(tmp->weight_limit && tmp->stats.Str<100)
1455 sprintf (buf,"Its weight limit is %.1f kg.", 1121 sprintf (buf,"Its weight limit is %.1f kg.",
1456 tmp->weight_limit/(10.0 * (100 - tmp->stats.Str))); 1122 tmp->weight_limit/(10.0 * (100 - tmp->stats.Str)));
1457 break; 1123 break;
1458 1124
1459 case WAND: 1125 case WAND:
1460 if(QUERY_FLAG(tmp, FLAG_IDENTIFIED)) 1126 if(QUERY_FLAG(tmp, FLAG_IDENTIFIED))
1461 sprintf(buf,"It has %d charges left.",tmp->stats.food); 1127 sprintf(buf,"It has %d charges left.",tmp->stats.food);
1462 break; 1128 break;
1463 } 1129 }
1464 1130
1465 if(buf[0]!='\0') 1131 if(buf[0]!='\0')
1466 new_draw_info(NDI_UNIQUE, 0,op,buf); 1132 new_draw_info(NDI_UNIQUE, 0,op,buf);
1467 1133
1468 if(tmp->materialname != NULL && !tmp->msg) { 1134 if(tmp->materialname != NULL && !tmp->msg) {
1469 sprintf(buf, "It is made of: %s.", tmp->materialname); 1135 sprintf(buf, "It is made of: %s.", &tmp->materialname);
1470 new_draw_info(NDI_UNIQUE, 0, op, buf); 1136 new_draw_info(NDI_UNIQUE, 0, op, buf);
1471 } 1137 }
1472 /* Where to wear this item */ 1138 /* Where to wear this item */
1473 for (i=0; i < NUM_BODY_LOCATIONS; i++) { 1139 for (i=0; i < NUM_BODY_LOCATIONS; i++) {
1474 if (tmp->body_info[i]<-1) { 1140 if (tmp->body_info[i]<-1) {
1475 if (op->body_info[i]) 1141 if (op->body_info[i])
1476 new_draw_info_format(NDI_UNIQUE, 0,op, 1142 new_draw_info_format(NDI_UNIQUE, 0,op,
1477 "It goes %s (%d)", body_locations[i].use_name, -tmp->body_info[i]); 1143 "It goes %s (%d)", body_locations[i].use_name, -tmp->body_info[i]);
1478 else 1144 else
1479 new_draw_info_format(NDI_UNIQUE, 0,op, 1145 new_draw_info_format(NDI_UNIQUE, 0,op,
1480 "It goes %s", body_locations[i].nonuse_name); 1146 "It goes %s", body_locations[i].nonuse_name);
1481 } else if (tmp->body_info[i]) { 1147 } else if (tmp->body_info[i]) {
1482 if (op->body_info[i]) 1148 if (op->body_info[i])
1483 new_draw_info_format(NDI_UNIQUE, 0,op, 1149 new_draw_info_format(NDI_UNIQUE, 0,op,
1484 "It goes %s", body_locations[i].use_name); 1150 "It goes %s", body_locations[i].use_name);
1485 else 1151 else
1486 new_draw_info_format(NDI_UNIQUE, 0,op, 1152 new_draw_info_format(NDI_UNIQUE, 0,op,
1487 "It goes %s", body_locations[i].nonuse_name); 1153 "It goes %s", body_locations[i].nonuse_name);
1488 } 1154 }
1489 } 1155 }
1490 1156
1491 if(tmp->weight) { 1157 if(tmp->weight) {
1492 sprintf(buf,tmp->nrof>1?"They weigh %3.3f kg.":"It weighs %3.3f kg.", 1158 sprintf(buf,tmp->nrof>1?"They weigh %3.3f kg.":"It weighs %3.3f kg.",
1493 tmp->weight*(tmp->nrof?tmp->nrof:1)/1000.0); 1159 tmp->weight*(tmp->nrof?tmp->nrof:1)/1000.0);
1494 new_draw_info(NDI_UNIQUE, 0,op,buf); 1160 new_draw_info(NDI_UNIQUE, 0,op,buf);
1495 } 1161 }
1496 1162
1497 if (tmp->value && !QUERY_FLAG(tmp, FLAG_STARTEQUIP) && !QUERY_FLAG(tmp, FLAG_NO_PICK)) { 1163 if (tmp->value && !QUERY_FLAG(tmp, FLAG_STARTEQUIP) && !QUERY_FLAG(tmp, FLAG_NO_PICK)) {
1498 object *floor;
1499 sprintf(buf,"You reckon %s worth %s.", 1164 sprintf(buf,"You reckon %s worth %s.",
1500 tmp->nrof>1?"they are":"it is",query_cost_string(tmp,op, F_TRUE | F_APPROX)); 1165 tmp->nrof>1?"they are":"it is",query_cost_string(tmp,op, F_TRUE | F_APPROX));
1501 new_draw_info(NDI_UNIQUE, 0,op,buf);
1502 floor = get_map_ob (op->map, op->x, op->y);
1503 if (floor && floor->type == SHOP_FLOOR) {
1504 if(QUERY_FLAG(tmp, FLAG_UNPAID))
1505 sprintf(buf,"%s would cost you %s.",
1506 tmp->nrof>1?"They":"It",query_cost_string(tmp,op,F_BUY | F_SHOP));
1507 else
1508 sprintf(buf,"You are offered %s for %s.",
1509 query_cost_string(tmp,op,F_SELL+F_SHOP), tmp->nrof>1?"them":"it");
1510 new_draw_info(NDI_UNIQUE, 0,op,buf); 1166 new_draw_info(NDI_UNIQUE, 0,op,buf);
1511 } 1167 if (is_in_shop (op)) {
1168 if(QUERY_FLAG(tmp, FLAG_UNPAID))
1169 sprintf(buf,"%s would cost you %s.",
1170 tmp->nrof>1?"They":"It",query_cost_string(tmp,op,F_BUY | F_SHOP));
1171 else
1172 sprintf(buf,"You are offered %s for %s.",
1173 query_cost_string(tmp,op,F_SELL+F_SHOP), tmp->nrof>1?"them":"it");
1174 new_draw_info(NDI_UNIQUE, 0,op,buf);
1175 }
1512 } 1176 }
1513 1177
1514 if(QUERY_FLAG(tmp, FLAG_MONSTER)) 1178 if(QUERY_FLAG(tmp, FLAG_MONSTER))
1515 examine_monster(op,tmp); 1179 examine_monster(op,tmp);
1516 1180
1517 /* Is this item buildable? */ 1181 /* Is this item buildable? */
1518 if ( QUERY_FLAG( tmp, FLAG_IS_BUILDABLE ) ) 1182 if ( QUERY_FLAG( tmp, FLAG_IS_BUILDABLE ) )
1519 new_draw_info( NDI_UNIQUE, 0, op, "This is a buildable item." ); 1183 new_draw_info( NDI_UNIQUE, 0, op, "This is a buildable item." );
1520 1184
1523 */ 1187 */
1524 if(tmp->msg && tmp->type != EXIT && tmp->type != BOOK && 1188 if(tmp->msg && tmp->type != EXIT && tmp->type != BOOK &&
1525 tmp->type != CORPSE && !tmp->move_on && 1189 tmp->type != CORPSE && !tmp->move_on &&
1526 strncasecmp(tmp->msg, "@match",7)) { 1190 strncasecmp(tmp->msg, "@match",7)) {
1527 1191
1528 /* This is just a hack so when identifying the items, we print 1192 /* This is just a hack so when identifying the items, we print
1529 * out the extra message 1193 * out the extra message
1530 */ 1194 */
1531 if (need_identify(tmp) && QUERY_FLAG(tmp, FLAG_IDENTIFIED)) 1195 if (need_identify(tmp) && QUERY_FLAG(tmp, FLAG_IDENTIFIED))
1532 new_draw_info(NDI_UNIQUE, 0,op, "The object has a story:"); 1196 new_draw_info(NDI_UNIQUE, 0,op, "The object has a story:");
1533 1197
1534 new_draw_info(NDI_UNIQUE, 0,op,tmp->msg); 1198 new_draw_info(NDI_UNIQUE, 0,op,tmp->msg);
1535 } 1199 }
1536 new_draw_info(NDI_UNIQUE, 0,op," "); /* Blank line */ 1200 new_draw_info(NDI_UNIQUE, 0,op," "); /* Blank line */
1537} 1201}
1538 1202
1539/* 1203/*
1582 if((!op||!QUERY_FLAG(op, FLAG_WIZ)) && (tmp->invisible || 1246 if((!op||!QUERY_FLAG(op, FLAG_WIZ)) && (tmp->invisible ||
1583 (inv && inv->type != CONTAINER && !QUERY_FLAG(tmp, FLAG_APPLIED)))) 1247 (inv && inv->type != CONTAINER && !QUERY_FLAG(tmp, FLAG_APPLIED))))
1584 continue; 1248 continue;
1585 if((!op || QUERY_FLAG(op, FLAG_WIZ))) 1249 if((!op || QUERY_FLAG(op, FLAG_WIZ)))
1586 new_draw_info_format(NDI_UNIQUE, 0,op ,"%s- %-*.*s (%5d) %-8s", in, length, length, 1250 new_draw_info_format(NDI_UNIQUE, 0,op ,"%s- %-*.*s (%5d) %-8s", in, length, length,
1587 query_name(tmp), tmp->count,query_weight(tmp)); 1251 query_name(tmp), tmp->count,query_weight(tmp));
1588 else 1252 else
1589 new_draw_info_format(NDI_UNIQUE,0, op, "%s- %-*.*s %-8s", in, length+8, 1253 new_draw_info_format(NDI_UNIQUE,0, op, "%s- %-*.*s %-8s", in, length+8,
1590 length+8, query_name(tmp), 1254 length+8, query_name(tmp),
1591 query_weight(tmp)); 1255 query_weight(tmp));
1592 } 1256 }
1593 if(!inv && op) { 1257 if(!inv && op) {
1594 new_draw_info_format(NDI_UNIQUE,0, op ,"%-*s %-8s", 1258 new_draw_info_format(NDI_UNIQUE,0, op ,"%-*s %-8s",
1595 41,"Total weight :",query_weight(op)); 1259 41,"Total weight :",query_weight(op));
1734int command_search_items (object *op, char *params) 1398int command_search_items (object *op, char *params)
1735{ 1399{
1736 char buf[MAX_BUF]; 1400 char buf[MAX_BUF];
1737 1401
1738 if (settings.search_items == FALSE) 1402 if (settings.search_items == FALSE)
1739 return 1; 1403 return 1;
1740 1404
1741 if(params == NULL) { 1405 if(params == NULL) {
1742 if(op->contr->search_str[0]=='\0') { 1406 if(op->contr->search_str[0]=='\0') {
1743 new_draw_info(NDI_UNIQUE, 0,op,"Example: search magic+1"); 1407 new_draw_info(NDI_UNIQUE, 0,op,"Example: search magic+1");
1744 new_draw_info(NDI_UNIQUE, 0,op,"Would automatically pick up all"); 1408 new_draw_info(NDI_UNIQUE, 0,op,"Would automatically pick up all");
1745 new_draw_info(NDI_UNIQUE, 0,op,"items containing the word 'magic+1'."); 1409 new_draw_info(NDI_UNIQUE, 0,op,"items containing the word 'magic+1'.");
1746 return 1; 1410 return 1;
1747 } 1411 }
1748 op->contr->search_str[0]='\0'; 1412 op->contr->search_str[0]='\0';
1749 new_draw_info(NDI_UNIQUE, 0,op,"Search mode turned off."); 1413 new_draw_info(NDI_UNIQUE, 0,op,"Search mode turned off.");
1750 fix_player(op); 1414 fix_player(op);
1751 return 1; 1415 return 1;
1752 } 1416 }
1753 if((int)strlen(params) >= MAX_BUF) { 1417 if((int)strlen(params) >= MAX_BUF) {
1754 new_draw_info(NDI_UNIQUE, 0,op,"Search string too long."); 1418 new_draw_info(NDI_UNIQUE, 0,op,"Search string too long.");
1755 return 1; 1419 return 1;
1756 } 1420 }
1757 strcpy(op->contr->search_str, params); 1421 strcpy(op->contr->search_str, params);
1758 sprintf(buf,"Searching for '%s'.",op->contr->search_str); 1422 sprintf(buf,"Searching for '%s'.",op->contr->search_str);
1759 new_draw_info(NDI_UNIQUE, 0,op,buf); 1423 new_draw_info(NDI_UNIQUE, 0,op,buf);
1760 fix_player(op); 1424 fix_player(op);
1783 /* Let's skip white spaces */ 1447 /* Let's skip white spaces */
1784 while(' '==*params) params++; 1448 while(' '==*params) params++;
1785 1449
1786 /* Checking the first part */ 1450 /* Checking the first part */
1787 if ((itemnumber = atoi(params))!=0) { 1451 if ((itemnumber = atoi(params))!=0) {
1788 for (item=op->inv; item && ((item->count != itemnumber) || item->invisible); item=item->below); 1452 for (item=op->inv; item && ((item->count != itemnumber) || item->invisible); item=item->below);
1789 if (!item) { 1453 if (!item) {
1790 new_draw_info(NDI_UNIQUE,0,op,"Tried to rename an invalid item."); 1454 new_draw_info(NDI_UNIQUE,0,op,"Tried to rename an invalid item.");
1791 return 1; 1455 return 1;
1792 } 1456 }
1793 while(isdigit(*params) || ' '==*params) params++; 1457 while(isdigit(*params) || ' '==*params) params++;
1794 } 1458 }
1795 else if ('<'==*params) { 1459 else if ('<'==*params) {
1796 /* Got old name, let's get it & find appropriate matching item */ 1460 /* Got old name, let's get it & find appropriate matching item */
1797 closebrace=strchr(params,'>'); 1461 closebrace=strchr(params,'>');
1798 if(!closebrace) { 1462 if(!closebrace) {
1893 1557
1894 /* Coming here, everything is fine... */ 1558 /* Coming here, everything is fine... */
1895 if(!strlen(buf)) { 1559 if(!strlen(buf)) {
1896 /* Clear custom name */ 1560 /* Clear custom name */
1897 if(item->custom_name) { 1561 if(item->custom_name) {
1898 FREE_AND_CLEAR_STR(item->custom_name); 1562 item->custom_name = 0;
1899 1563
1900 new_draw_info_format(NDI_UNIQUE, 0, op,"You stop calling your %s with weird names.",query_base_name(item,item->nrof>1?1:0)); 1564 new_draw_info_format(NDI_UNIQUE, 0, op,"You stop calling your %s with weird names.",query_base_name(item,item->nrof>1?1:0));
1901 esrv_update_item(UPD_NAME,op,item); 1565 esrv_update_item(UPD_NAME,op,item);
1902 } else { 1566 } else {
1903 new_draw_info(NDI_UNIQUE,0,op,"This item has no custom name."); 1567 new_draw_info(NDI_UNIQUE,0,op,"This item has no custom name.");
1904 } 1568 }
1905 } else { 1569 } else {
1906 /* Set custom name */ 1570 /* Set custom name */
1907 FREE_AND_COPY(item->custom_name,buf); 1571 item->custom_name = buf;
1908 1572
1909 new_draw_info_format(NDI_UNIQUE, 0, op,"Your %s will now be called %s.",query_base_name(item,item->nrof>1?1:0),buf); 1573 new_draw_info_format(NDI_UNIQUE, 0, op,"Your %s will now be called %s.",query_base_name(item,item->nrof>1?1:0),buf);
1910 esrv_update_item(UPD_NAME,op,item); 1574 esrv_update_item(UPD_NAME,op,item);
1911 } 1575 }
1912 1576

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines