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.10 2006/08/29 08:01:37 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 |
… | |
… | |
84 | object *find_best_object_match(object *pl, const char *params) |
84 | object *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 | |
|
|
111 | int 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 | |
|
|
404 | int command_uskill ( object *pl, char *params) { |
89 | int 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 | |
412 | int command_rskill ( object *pl, char *params) { |
97 | int 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 | */ |
498 | int sack_can_hold (object *pl, object *sack, object *op, uint32 nrof) { |
183 | int 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 | } |
… | |
… | |
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.", |
653 | alt->name); |
338 | alt->name); |
654 | goto leave; |
339 | goto leave; |
655 | } |
340 | } |
656 | tmp = alt; |
341 | tmp = alt; |
657 | } |
342 | } |
658 | else |
343 | else |
659 | { |
344 | { |
… | |
… | |
673 | need_fix_tmp = 1; |
358 | need_fix_tmp = 1; |
674 | if ( ! can_pick (op, tmp)) |
359 | if ( ! can_pick (op, tmp)) |
675 | goto leave; |
360 | goto leave; |
676 | |
361 | |
677 | if (op->type==PLAYER) { |
362 | if (op->type==PLAYER) { |
678 | count=op->contr->count; |
363 | count=op->contr->count; |
679 | if (count==0) count = tmp->nrof; |
364 | if (count==0) count = tmp->nrof; |
680 | } |
365 | } |
681 | else |
366 | else |
682 | count=tmp->nrof; |
367 | count=tmp->nrof; |
683 | |
368 | |
684 | /* container is open, so use it */ |
369 | /* container is open, so use it */ |
685 | if (op->container) { |
370 | if (op->container) { |
686 | alt = op->container; |
371 | alt = op->container; |
687 | if (alt != tmp->env && !sack_can_hold (op, alt, tmp,count)) |
372 | if (alt != tmp->env && !sack_can_hold (op, alt, tmp,count)) |
688 | goto leave; |
373 | goto leave; |
689 | } else { /* non container pickup */ |
374 | } 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) |
375 | for (alt=op->inv; alt; alt=alt->below) |
698 | if (alt->type==CONTAINER && QUERY_FLAG(alt, FLAG_APPLIED) && |
376 | if (alt->type==CONTAINER && QUERY_FLAG(alt, FLAG_APPLIED) && |
|
|
377 | alt->race && alt->race==tmp->race && |
699 | sack_can_hold (NULL, alt, tmp,count)) |
378 | sack_can_hold (NULL, alt, tmp,count)) |
|
|
379 | break; /* perfect match */ |
|
|
380 | |
|
|
381 | if (!alt) |
|
|
382 | for (alt=op->inv; alt; alt=alt->below) |
|
|
383 | if (alt->type==CONTAINER && QUERY_FLAG(alt, FLAG_APPLIED) && |
|
|
384 | sack_can_hold (NULL, alt, tmp,count)) |
700 | break; /* General container comes next */ |
385 | break; /* General container comes next */ |
701 | if (!alt) |
386 | if (!alt) |
702 | alt = op; /* No free containers */ |
387 | alt = op; /* No free containers */ |
703 | } |
388 | } |
704 | if(tmp->env == alt) { |
389 | if(tmp->env == alt) { |
705 | /* here it could be possible to check rent, |
390 | /* here it could be possible to check rent, |
706 | * if someone wants to implement it |
391 | * if someone wants to implement it |
707 | */ |
392 | */ |
708 | alt = op; |
393 | alt = op; |
709 | } |
394 | } |
710 | #ifdef PICKUP_DEBUG |
395 | #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); |
396 | LOG(llevDebug, "Pick_up(): %s picks %s (%d) and inserts it %s.\n", op->name, tmp->name, op->contr->count, alt->name); |
712 | #endif |
397 | #endif |
713 | |
398 | |
714 | /* startequip items are not allowed to be put into containers: */ |
399 | /* startequip items are not allowed to be put into containers: */ |
715 | if (op->type == PLAYER && alt->type == CONTAINER |
400 | if (op->type == PLAYER && alt->type == CONTAINER |
716 | && QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
401 | && QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
717 | { |
402 | { |
718 | new_draw_info (NDI_UNIQUE, 0, op, |
403 | new_draw_info (NDI_UNIQUE, 0, op, |
719 | "This object cannot be put into containers!"); |
404 | "This object cannot be put into containers!"); |
720 | goto leave; |
405 | goto leave; |
721 | } |
406 | } |
… | |
… | |
742 | int command_take (object *op, char *params) |
427 | int command_take (object *op, char *params) |
743 | { |
428 | { |
744 | object *tmp, *next; |
429 | object *tmp, *next; |
745 | |
430 | |
746 | if (op->container) |
431 | if (op->container) |
747 | tmp=op->container->inv; |
432 | tmp=op->container->inv; |
748 | else { |
433 | else { |
749 | tmp=op->above; |
434 | tmp=op->above; |
750 | if (tmp) while (tmp->above) { |
435 | if (tmp) while (tmp->above) { |
751 | tmp=tmp->above; |
436 | tmp=tmp->above; |
752 | } |
437 | } |
753 | if (!tmp) |
438 | if (!tmp) |
754 | tmp=op->below; |
439 | tmp=op->below; |
755 | } |
440 | } |
756 | |
441 | |
757 | if (tmp==NULL) { |
442 | if (tmp==NULL) { |
758 | new_draw_info(NDI_UNIQUE, 0,op,"Nothing to take!"); |
443 | new_draw_info(NDI_UNIQUE, 0,op,"Nothing to take!"); |
759 | return 0; |
444 | return 0; |
760 | } |
445 | } |
761 | |
446 | |
762 | /* Makes processing easier */ |
447 | /* Makes processing easier */ |
763 | if (params && *params=='\0') params=NULL; |
448 | if (params && *params=='\0') params=NULL; |
764 | |
449 | |
765 | while (tmp) { |
450 | while (tmp) { |
766 | next=tmp->below; |
451 | next=tmp->below; |
767 | |
452 | |
768 | if (tmp->invisible) { |
453 | if (tmp->invisible) { |
769 | tmp=next; |
454 | tmp=next; |
770 | continue; |
455 | continue; |
771 | } |
456 | } |
772 | /* This following two if and else if could be merged into line |
457 | /* This following two if and else if could be merged into line |
773 | * but that probably will make it more difficult to read, and |
458 | * but that probably will make it more difficult to read, and |
774 | * not make it any more efficient |
459 | * not make it any more efficient |
775 | */ |
460 | */ |
776 | if (params && item_matched_string(op, tmp, params)) { |
461 | if (params && item_matched_string(op, tmp, params)) { |
777 | pick_up(op, tmp); |
462 | pick_up(op, tmp); |
778 | } |
463 | } |
779 | else if (can_pick(op, tmp) && !params) { |
464 | else if (can_pick(op, tmp) && !params) { |
780 | pick_up(op,tmp); |
465 | pick_up(op,tmp); |
781 | break; |
466 | break; |
782 | } |
467 | } |
783 | tmp=next; |
468 | tmp=next; |
784 | /* Might as well just skip over the player immediately - |
469 | /* Might as well just skip over the player immediately - |
785 | * we know it can't be picked up |
470 | * we know it can't be picked up |
786 | */ |
471 | */ |
787 | if (tmp == op) tmp=tmp->below; |
472 | if (tmp == op) tmp=tmp->below; |
788 | } |
473 | } |
789 | if (!params && !tmp) { |
474 | if (!params && !tmp) { |
790 | for (tmp=op->below; tmp!=NULL; tmp=tmp->next) |
475 | for (tmp=op->below; tmp!=NULL; tmp=tmp->next) |
791 | if (!tmp->invisible) { |
476 | if (!tmp->invisible) { |
792 | char buf[MAX_BUF]; |
477 | char buf[MAX_BUF]; |
793 | sprintf(buf,"You can't pick up a %s.", |
478 | sprintf(buf,"You can't pick up a %s.", |
794 | tmp->name? tmp->name:"null"); |
479 | tmp->name? tmp->name:"null"); |
795 | new_draw_info(NDI_UNIQUE, 0,op, buf); |
480 | new_draw_info(NDI_UNIQUE, 0,op, buf); |
796 | break; |
481 | break; |
797 | } |
482 | } |
798 | if (!tmp) new_draw_info(NDI_UNIQUE, 0,op, "There is nothing to pick up."); |
483 | if (!tmp) new_draw_info(NDI_UNIQUE, 0,op, "There is nothing to pick up."); |
799 | } |
484 | } |
800 | return 0; |
485 | return 0; |
801 | } |
486 | } |
802 | |
487 | |
803 | |
488 | |
… | |
… | |
813 | tag_t tmp_tag, tmp2_tag; |
498 | tag_t tmp_tag, tmp2_tag; |
814 | object *tmp2, *sack2; |
499 | object *tmp2, *sack2; |
815 | char buf[MAX_BUF]; |
500 | char buf[MAX_BUF]; |
816 | |
501 | |
817 | if (sack==tmp) return; /* Can't put an object in itself */ |
502 | 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)) { |
503 | if (QUERY_FLAG(tmp,FLAG_STARTEQUIP)) { |
824 | new_draw_info_format(NDI_UNIQUE, 0,op, |
504 | new_draw_info_format(NDI_UNIQUE, 0,op, |
825 | "You cannot put the %s in the %s.", query_name(tmp), |
505 | "You cannot put the %s in the %s.", query_name(tmp), |
826 | query_name(sack)); |
506 | query_name(sack)); |
827 | return; |
507 | return; |
828 | } |
508 | } |
829 | if (tmp->type == CONTAINER && tmp->inv) { |
509 | if (tmp->type == CONTAINER && tmp->inv) { |
830 | |
510 | |
831 | /* Eneq(@csd.uu.se): If the object to be dropped is a container |
511 | /* 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 |
512 | * we instead move the contents of that container into the active |
833 | * container, this is only done if the object has something in it. |
513 | * container, this is only done if the object has something in it. |
834 | */ |
514 | */ |
835 | sack2 = tmp; |
515 | sack2 = tmp; |
836 | new_draw_info_format(NDI_UNIQUE, 0,op, "You move the items from %s into %s.", |
516 | new_draw_info_format(NDI_UNIQUE, 0,op, "You move the items from %s into %s.", |
837 | query_name(tmp), query_name(sack)); |
517 | query_name(tmp), query_name(sack)); |
838 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) { |
518 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) { |
839 | tmp = tmp2->below; |
519 | tmp = tmp2->below; |
840 | if ((sack->type == CONTAINER && sack_can_hold(op, op->container, tmp2,tmp2->nrof)) || |
520 | 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); |
521 | put_object_in_sack (op, sack, tmp2, 0); |
843 | } else { |
522 | } else { |
844 | sprintf(buf,"Your %s fills up.", query_name(sack)); |
523 | sprintf(buf,"Your %s fills up.", query_name(sack)); |
845 | new_draw_info(NDI_UNIQUE, 0,op, buf); |
524 | new_draw_info(NDI_UNIQUE, 0,op, buf); |
846 | break; |
525 | break; |
847 | } |
526 | } |
848 | } |
527 | } |
849 | esrv_update_item (UPD_WEIGHT, op, sack2); |
528 | esrv_update_item (UPD_WEIGHT, op, sack2); |
850 | return; |
529 | return; |
851 | } |
530 | } |
852 | |
531 | |
853 | /* Don't worry about this for containers - our caller should have |
532 | /* Don't worry about this for containers - our caller should have |
854 | * already checked this. |
533 | * already checked this. |
855 | */ |
534 | */ |
856 | if ((sack->type == CONTAINER) && !sack_can_hold (op, sack, tmp,(nrof?nrof:tmp->nrof))) |
535 | if ((sack->type == CONTAINER) && !sack_can_hold (op, sack, tmp,(nrof?nrof:tmp->nrof))) |
857 | return; |
536 | return; |
858 | |
537 | |
859 | if(QUERY_FLAG(tmp, FLAG_APPLIED)) { |
538 | if(QUERY_FLAG(tmp, FLAG_APPLIED)) { |
860 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
539 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
861 | return; |
540 | return; |
862 | } |
541 | } |
863 | |
542 | |
864 | /* we want to put some portion of the item into the container */ |
543 | /* we want to put some portion of the item into the container */ |
865 | if (nrof && tmp->nrof != nrof) { |
544 | if (nrof && tmp->nrof != nrof) { |
866 | object *tmp2 = tmp; |
545 | object *tmp2 = tmp; |
867 | tmp2_tag = tmp2->count; |
546 | tmp2_tag = tmp2->count; |
868 | tmp = get_split_ob (tmp, nrof); |
547 | tmp = get_split_ob (tmp, nrof); |
869 | |
548 | |
870 | if(!tmp) { |
549 | if(!tmp) { |
871 | new_draw_info(NDI_UNIQUE, 0,op, errmsg); |
550 | new_draw_info(NDI_UNIQUE, 0,op, errmsg); |
872 | return; |
551 | return; |
873 | } |
552 | } |
874 | /* Tell a client what happened other objects */ |
553 | /* Tell a client what happened other objects */ |
875 | if (was_destroyed (tmp2, tmp2_tag)) |
554 | if (was_destroyed (tmp2, tmp2_tag)) |
876 | esrv_del_item (op->contr, tmp2_tag); |
555 | esrv_del_item (op->contr, tmp2_tag); |
877 | else /* this can proably be replaced with an update */ |
556 | else /* this can proably be replaced with an update */ |
878 | esrv_send_item (op, tmp2); |
557 | esrv_send_item (op, tmp2); |
879 | } else |
558 | } else |
880 | remove_ob(tmp); |
559 | remove_ob(tmp); |
881 | |
560 | |
882 | new_draw_info_format(NDI_UNIQUE, 0,op, "You put the %s in %s.", |
561 | new_draw_info_format(NDI_UNIQUE, 0,op, "You put the %s in %s.", |
883 | query_name(tmp), query_name(sack)); |
562 | query_name(tmp), query_name(sack)); |
884 | tmp_tag = tmp->count; |
563 | tmp_tag = tmp->count; |
885 | tmp2 = insert_ob_in_ob(tmp, sack); |
564 | tmp2 = insert_ob_in_ob(tmp, sack); |
886 | fix_player(op); /* This is overkill, fix_player() is called somewhere */ |
565 | fix_player(op); /* This is overkill, fix_player() is called somewhere */ |
887 | /* in object.c */ |
566 | /* in object.c */ |
888 | |
567 | |
889 | /* If an object merged (and thus, different object), we need to |
568 | /* If an object merged (and thus, different object), we need to |
890 | * delete the original. |
569 | * delete the original. |
891 | */ |
570 | */ |
892 | if (tmp2 != tmp) |
571 | if (tmp2 != tmp) |
893 | esrv_del_item (op->contr, tmp_tag); |
572 | esrv_del_item (op->contr, tmp_tag); |
894 | |
573 | |
895 | esrv_send_item (op, tmp2); |
574 | esrv_send_item (op, tmp2); |
896 | |
575 | |
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 */ |
576 | /* update the sacks weight */ |
906 | esrv_update_item (UPD_WEIGHT, op, sack); |
577 | esrv_update_item (UPD_WEIGHT, op, sack); |
907 | } |
|
|
908 | } |
578 | } |
909 | |
579 | |
910 | /* |
580 | /* |
911 | * This function was part of drop, now is own function. |
581 | * This function was part of drop, now is own function. |
912 | * Player 'op' tries to drop object 'tmp', if tmp is non zero, then |
582 | * Player 'op' tries to drop object 'tmp', if tmp is non zero, then |
… | |
… | |
951 | } |
621 | } |
952 | } |
622 | } |
953 | else |
623 | else |
954 | remove_ob (tmp); |
624 | remove_ob (tmp); |
955 | |
625 | |
956 | /* Lauwenmark: Handle for plugin drop event */ |
626 | if (INVOKE_OBJECT (DROP, tmp, ARG_OBJECT (op))) |
957 | if (execute_event (tmp, EVENT_DROP, op, NULL, NULL, SCRIPT_FIX_ALL) != 0) |
|
|
958 | return; |
627 | return; |
959 | |
628 | |
960 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
629 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
961 | { |
630 | { |
962 | sprintf (buf, "You drop the %s.", query_name (tmp)); |
631 | sprintf (buf, "You drop the %s.", query_name (tmp)); |
… | |
… | |
1002 | /* Need to update the weight for the player */ |
671 | /* Need to update the weight for the player */ |
1003 | esrv_send_item (op, op); |
672 | esrv_send_item (op, op); |
1004 | } |
673 | } |
1005 | |
674 | |
1006 | for (floor = get_map_ob (op->map, op->x, op->y); floor; floor = floor->above) |
675 | 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)) |
676 | if (INVOKE_OBJECT (DROP_ON, floor, ARG_OBJECT (tmp), ARG_OBJECT (op))) |
1008 | return; |
677 | return; |
|
|
678 | |
|
|
679 | floor = get_map_ob (op->map, op->x, op->y); |
1009 | |
680 | |
1010 | if (floor |
681 | if (floor |
1011 | && floor->type == SHOP_FLOOR |
682 | && floor->type == SHOP_FLOOR |
1012 | && !QUERY_FLAG (tmp, FLAG_UNPAID) |
683 | && !QUERY_FLAG (tmp, FLAG_UNPAID) |
1013 | && tmp->type != MONEY) |
684 | && tmp->type != MONEY) |
… | |
… | |
1025 | * somehow, players get an invisible object in the container, and the |
696 | * somehow, players get an invisible object in the container, and the |
1026 | * old logic would skip over invisible objects - works fine for the |
697 | * old logic would skip over invisible objects - works fine for the |
1027 | * playes inventory, but drop inventory wants to use the next value. |
698 | * playes inventory, but drop inventory wants to use the next value. |
1028 | */ |
699 | */ |
1029 | if (tmp->invisible) { |
700 | if (tmp->invisible) { |
1030 | /* if the following is the case, it must be in an container. */ |
701 | /* if the following is the case, it must be in an container. */ |
1031 | if (tmp->env && tmp->env->type != PLAYER) { |
702 | if (tmp->env && tmp->env->type != PLAYER) { |
1032 | /* Just toss the object - probably shouldn't be hanging |
703 | /* Just toss the object - probably shouldn't be hanging |
1033 | * around anyways |
704 | * around anyways |
1034 | */ |
705 | */ |
1035 | remove_ob(tmp); |
706 | remove_ob(tmp); |
1036 | free_object(tmp); |
707 | free_object(tmp); |
1037 | return; |
708 | return; |
1038 | } else { |
709 | } else { |
1039 | while(tmp!=NULL && tmp->invisible) |
710 | while(tmp!=NULL && tmp->invisible) |
1040 | tmp=tmp->below; |
711 | tmp=tmp->below; |
1041 | } |
712 | } |
1042 | } |
713 | } |
1043 | |
714 | |
1044 | if (tmp==NULL) { |
715 | if (tmp==NULL) { |
1045 | new_draw_info(NDI_UNIQUE, 0,op,"You don't have anything to drop."); |
716 | new_draw_info(NDI_UNIQUE, 0,op,"You don't have anything to drop."); |
1046 | return; |
717 | return; |
… | |
… | |
1060 | if (op->type == PLAYER) |
731 | if (op->type == PLAYER) |
1061 | { |
732 | { |
1062 | if (op->contr->last_used==tmp && op->contr->last_used_id == tmp->count) { |
733 | if (op->contr->last_used==tmp && op->contr->last_used_id == tmp->count) { |
1063 | object *n=NULL; |
734 | object *n=NULL; |
1064 | if(tmp->below != NULL) |
735 | if(tmp->below != NULL) |
1065 | n = tmp->below; |
736 | n = tmp->below; |
1066 | else if(tmp->above != NULL) |
737 | else if(tmp->above != NULL) |
1067 | n = tmp->above; |
738 | n = tmp->above; |
1068 | op->contr->last_used = n; |
739 | op->contr->last_used = n; |
1069 | if (n != NULL) |
740 | if (n != NULL) |
1070 | op->contr->last_used_id = n->count; |
741 | op->contr->last_used_id = n->count; |
1071 | else |
742 | else |
1072 | op->contr->last_used_id = 0; |
743 | op->contr->last_used_id = 0; |
1073 | } |
744 | } |
1074 | }; |
745 | }; |
1075 | |
746 | |
1076 | if (op->container) { |
747 | if (op->container) { |
1077 | if (op->type == PLAYER) |
748 | if (op->type == PLAYER) |
… | |
… | |
1118 | |
789 | |
1119 | if(params==NULL) { |
790 | if(params==NULL) { |
1120 | while(curinv != NULL) { |
791 | while(curinv != NULL) { |
1121 | nextinv = curinv->below; |
792 | nextinv = curinv->below; |
1122 | while (nextinv && nextinv->type==MONEY) |
793 | while (nextinv && nextinv->type==MONEY) |
1123 | nextinv = nextinv->below; |
794 | nextinv = nextinv->below; |
1124 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && curinv->type != MONEY && |
795 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && curinv->type != MONEY && |
1125 | curinv->type != FOOD && curinv->type != KEY && |
796 | curinv->type != FOOD && curinv->type != KEY && |
1126 | curinv->type != SPECIAL_KEY && curinv->type != GEM && |
797 | curinv->type != SPECIAL_KEY && curinv->type != GEM && |
1127 | !curinv->invisible && |
798 | !curinv->invisible && |
1128 | (curinv->type!=CONTAINER || op->container!=curinv)) |
799 | (curinv->type!=CONTAINER || op->container!=curinv)) |
1129 | { |
800 | { |
1130 | drop(op,curinv); |
801 | drop(op,curinv); |
1131 | } |
802 | } |
1132 | curinv = nextinv; |
803 | curinv = nextinv; |
1133 | } |
804 | } |
1134 | } |
805 | } |
1135 | |
806 | |
1136 | else if(strcmp(params, "weapons") == 0) { |
807 | else if(strcmp(params, "weapons") == 0) { |
1137 | while(curinv != NULL) { |
808 | while(curinv != NULL) { |
1138 | nextinv = curinv->below; |
809 | nextinv = curinv->below; |
1139 | while (nextinv && nextinv->type==MONEY) |
810 | while (nextinv && nextinv->type==MONEY) |
1140 | nextinv = nextinv->below; |
811 | nextinv = nextinv->below; |
1141 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ((curinv->type == WEAPON) || |
812 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ((curinv->type == WEAPON) || |
1142 | (curinv->type == BOW) || (curinv->type == ARROW))) |
813 | (curinv->type == BOW) || (curinv->type == ARROW))) |
1143 | { |
814 | { |
1144 | drop(op,curinv); |
815 | drop(op,curinv); |
1145 | } |
816 | } |
1146 | curinv = nextinv; |
817 | curinv = nextinv; |
1147 | } |
818 | } |
1148 | } |
819 | } |
1149 | |
820 | |
1150 | else if(strcmp(params, "armor") == 0 || strcmp(params, "armour") == 0) { |
821 | else if(strcmp(params, "armor") == 0 || strcmp(params, "armour") == 0) { |
1151 | while(curinv != NULL) { |
822 | while(curinv != NULL) { |
1152 | nextinv = curinv->below; |
823 | nextinv = curinv->below; |
1153 | while (nextinv && nextinv->type==MONEY) |
824 | while (nextinv && nextinv->type==MONEY) |
1154 | nextinv = nextinv->below; |
825 | nextinv = nextinv->below; |
1155 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ((curinv->type == ARMOUR) || |
826 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ((curinv->type == ARMOUR) || |
1156 | curinv->type == SHIELD || curinv->type==HELMET)) |
827 | curinv->type == SHIELD || curinv->type==HELMET)) |
1157 | { |
828 | { |
1158 | drop(op,curinv); |
829 | drop(op,curinv); |
1159 | } |
830 | } |
1160 | curinv = nextinv; |
831 | curinv = nextinv; |
1161 | } |
832 | } |
1162 | } |
833 | } |
1163 | |
834 | |
1164 | else if(strcmp(params, "misc") == 0) { |
835 | else if(strcmp(params, "misc") == 0) { |
1165 | while(curinv != NULL) { |
836 | while(curinv != NULL) { |
1166 | nextinv = curinv->below; |
837 | nextinv = curinv->below; |
1167 | while (nextinv && nextinv->type==MONEY) |
838 | while (nextinv && nextinv->type==MONEY) |
1168 | nextinv = nextinv->below; |
839 | nextinv = nextinv->below; |
1169 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ! QUERY_FLAG(curinv,FLAG_APPLIED)) { |
840 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ! QUERY_FLAG(curinv,FLAG_APPLIED)) { |
1170 | switch(curinv->type) { |
841 | switch(curinv->type) { |
1171 | case HORN: |
842 | case HORN: |
1172 | case BOOK: |
843 | case BOOK: |
1173 | case SPELLBOOK: |
844 | case SPELLBOOK: |
1174 | case GIRDLE: |
845 | case GIRDLE: |
1175 | case AMULET: |
846 | case AMULET: |
1176 | case RING: |
847 | case RING: |
1177 | case CLOAK: |
848 | case CLOAK: |
1178 | case BOOTS: |
849 | case BOOTS: |
1179 | case GLOVES: |
850 | case GLOVES: |
1180 | case BRACERS: |
851 | case BRACERS: |
1181 | case SCROLL: |
852 | case SCROLL: |
1182 | case ARMOUR_IMPROVER: |
853 | case ARMOUR_IMPROVER: |
1183 | case WEAPON_IMPROVER: |
854 | case WEAPON_IMPROVER: |
1184 | case WAND: |
855 | case WAND: |
1185 | case ROD: |
856 | case ROD: |
1186 | case POTION: |
857 | case POTION: |
1187 | drop(op,curinv); |
858 | drop(op,curinv); |
1188 | curinv = nextinv; |
859 | curinv = nextinv; |
1189 | break; |
860 | break; |
1190 | default: |
861 | default: |
1191 | curinv = nextinv; |
862 | curinv = nextinv; |
1192 | break; |
863 | break; |
1193 | } |
864 | } |
1194 | } |
865 | } |
1195 | curinv = nextinv; |
866 | curinv = nextinv; |
1196 | } |
867 | } |
1197 | } |
868 | } |
1198 | op->contr->socket.update_look=1; |
869 | op->contr->socket.update_look=1; |
… | |
… | |
1208 | { |
879 | { |
1209 | object *tmp, *next; |
880 | object *tmp, *next; |
1210 | int did_one=0; |
881 | int did_one=0; |
1211 | |
882 | |
1212 | if (!params) { |
883 | if (!params) { |
1213 | new_draw_info(NDI_UNIQUE,0, op, "Drop what?"); |
884 | new_draw_info(NDI_UNIQUE,0, op, "Drop what?"); |
1214 | return 0; |
885 | return 0; |
1215 | } else { |
886 | } else { |
1216 | for (tmp=op->inv; tmp; tmp=next) { |
887 | for (tmp=op->inv; tmp; tmp=next) { |
1217 | next=tmp->below; |
888 | next=tmp->below; |
1218 | if (QUERY_FLAG(tmp,FLAG_NO_DROP) || |
889 | if (QUERY_FLAG(tmp,FLAG_NO_DROP) || |
1219 | tmp->invisible) continue; |
890 | tmp->invisible) continue; |
1220 | if (item_matched_string(op,tmp,params)) { |
891 | if (item_matched_string(op,tmp,params)) { |
1221 | drop(op, tmp); |
892 | drop(op, tmp); |
1222 | did_one=1; |
893 | did_one=1; |
1223 | } |
894 | } |
1224 | } |
895 | } |
1225 | if (!did_one) new_draw_info(NDI_UNIQUE, 0,op,"Nothing to drop."); |
896 | if (!did_one) new_draw_info(NDI_UNIQUE, 0,op,"Nothing to drop."); |
1226 | } |
897 | } |
1227 | if (op->type==PLAYER) |
898 | if (op->type==PLAYER) |
1228 | { |
899 | { |
1229 | op->contr->count=0; |
900 | op->contr->count=0; |
1230 | op->contr->socket.update_look=1; |
901 | op->contr->socket.update_look=1; |
… | |
… | |
1243 | else { |
914 | else { |
1244 | object *tmp=find_best_object_match(op,params); |
915 | object *tmp=find_best_object_match(op,params); |
1245 | if (tmp) |
916 | if (tmp) |
1246 | examine(op,tmp); |
917 | examine(op,tmp); |
1247 | else |
918 | else |
1248 | new_draw_info_format(NDI_UNIQUE,0,op,"Could not find an object that matches %s",params); |
919 | new_draw_info_format(NDI_UNIQUE,0,op,"Could not find an object that matches %s",params); |
1249 | } |
920 | } |
1250 | return 0; |
921 | return 0; |
1251 | } |
922 | } |
1252 | |
923 | |
1253 | /* op should be a player. |
924 | /* op should be a player. |
… | |
… | |
1261 | object *tmp; |
932 | object *tmp; |
1262 | |
933 | |
1263 | if (!op || !op->contr) return NULL; |
934 | if (!op || !op->contr) return NULL; |
1264 | if (!op->contr->mark) { |
935 | if (!op->contr->mark) { |
1265 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
936 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
1266 | return NULL; |
937 | return NULL; |
1267 | } |
938 | } |
1268 | /* This may seem like overkill, but we need to make sure that they |
939 | /* 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 |
940 | * player hasn't dropped the item. We use count on the off chance that |
1270 | * an item got reincarnated at some point. |
941 | * an item got reincarnated at some point. |
1271 | */ |
942 | */ |
1272 | for (tmp=op->inv; tmp; tmp=tmp->below) { |
943 | for (tmp=op->inv; tmp; tmp=tmp->below) { |
1273 | if (tmp->invisible) continue; |
944 | if (tmp->invisible) continue; |
1274 | if (tmp == op->contr->mark) { |
945 | if (tmp == op->contr->mark) { |
1275 | if (tmp->count == op->contr->mark_count) |
946 | if (tmp->count == op->contr->mark_count) |
1276 | return tmp; |
947 | return tmp; |
1277 | else { |
948 | else { |
1278 | op->contr->mark=NULL; |
949 | op->contr->mark=NULL; |
1279 | op->contr->mark_count=0; |
950 | op->contr->mark_count=0; |
1280 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
951 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
1281 | return NULL; |
952 | return NULL; |
1282 | } |
953 | } |
1283 | } |
954 | } |
1284 | } |
955 | } |
1285 | return NULL; |
956 | return NULL; |
1286 | } |
957 | } |
1287 | |
958 | |
1288 | |
959 | |
… | |
… | |
1292 | */ |
963 | */ |
1293 | int command_mark(object *op, char *params) |
964 | int command_mark(object *op, char *params) |
1294 | { |
965 | { |
1295 | if (!op->contr) return 1; |
966 | if (!op->contr) return 1; |
1296 | if (!params) { |
967 | if (!params) { |
1297 | object *mark=find_marked_object(op); |
968 | object *mark=find_marked_object(op); |
1298 | if (!mark) new_draw_info(NDI_UNIQUE,0,op,"You have no marked object."); |
969 | 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)); |
970 | else new_draw_info_format(NDI_UNIQUE,0,op,"%s is marked.", query_name(mark)); |
1300 | } |
971 | } |
1301 | else { |
972 | else { |
1302 | object *mark1=find_best_object_match(op, params); |
973 | object *mark1=find_best_object_match(op, params); |
1303 | if (!mark1) { |
974 | if (!mark1) { |
1304 | new_draw_info_format(NDI_UNIQUE,0,op,"Could not find an object that matches %s",params); |
975 | new_draw_info_format(NDI_UNIQUE,0,op,"Could not find an object that matches %s",params); |
1305 | return 1; |
976 | return 1; |
1306 | } |
977 | } |
1307 | else { |
978 | else { |
1308 | op->contr->mark=mark1; |
979 | op->contr->mark=mark1; |
1309 | op->contr->mark_count=mark1->count; |
980 | op->contr->mark_count=mark1->count; |
1310 | new_draw_info_format(NDI_UNIQUE,0,op,"Marked item %s", query_name(mark1)); |
981 | new_draw_info_format(NDI_UNIQUE,0,op,"Marked item %s", query_name(mark1)); |
1311 | return 0; |
982 | return 0; |
1312 | } |
983 | } |
1313 | } |
984 | } |
1314 | return 0; /*shouldnt get here */ |
985 | return 0; /*shouldnt get here */ |
1315 | } |
986 | } |
1316 | |
987 | |
1317 | |
988 | |
… | |
… | |
1320 | */ |
991 | */ |
1321 | void examine_monster(object *op,object *tmp) { |
992 | void examine_monster(object *op,object *tmp) { |
1322 | object *mon=tmp->head?tmp->head:tmp; |
993 | object *mon=tmp->head?tmp->head:tmp; |
1323 | |
994 | |
1324 | if(QUERY_FLAG(mon,FLAG_UNDEAD)) |
995 | if(QUERY_FLAG(mon,FLAG_UNDEAD)) |
1325 | new_draw_info(NDI_UNIQUE, 0,op,"It is an undead force."); |
996 | new_draw_info(NDI_UNIQUE, 0,op,"It is an undead force."); |
1326 | if(mon->level>op->level) |
997 | if(mon->level>op->level) |
1327 | new_draw_info(NDI_UNIQUE, 0,op,"It is likely more powerful than you."); |
998 | new_draw_info(NDI_UNIQUE, 0,op,"It is likely more powerful than you."); |
1328 | else if(mon->level<op->level) |
999 | else if(mon->level<op->level) |
1329 | new_draw_info(NDI_UNIQUE, 0,op,"It is likely less powerful than you."); |
1000 | new_draw_info(NDI_UNIQUE, 0,op,"It is likely less powerful than you."); |
1330 | else |
1001 | else |
1331 | new_draw_info(NDI_UNIQUE, 0,op,"It is probably as powerful as you."); |
1002 | new_draw_info(NDI_UNIQUE, 0,op,"It is probably as powerful as you."); |
1332 | if(mon->attacktype&AT_ACID) |
1003 | if(mon->attacktype&AT_ACID) |
1333 | new_draw_info(NDI_UNIQUE, 0,op,"You seem to smell an acrid odor."); |
1004 | new_draw_info(NDI_UNIQUE, 0,op,"You seem to smell an acrid odor."); |
1334 | |
1005 | |
1335 | /* Anyone know why this used to use the clone value instead of the |
1006 | /* 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. |
1007 | * maxhp field? This seems that it should give more accurate results. |
1337 | */ |
1008 | */ |
1338 | switch((mon->stats.hp+1)*4/(mon->stats.maxhp+1)) { /* From 1-4 */ |
1009 | switch((mon->stats.hp+1)*4/(mon->stats.maxhp+1)) { /* From 1-4 */ |
1339 | case 1: |
1010 | case 1: |
1340 | new_draw_info(NDI_UNIQUE, 0,op,"It is in a bad shape."); |
1011 | new_draw_info(NDI_UNIQUE, 0,op,"It is in a bad shape."); |
1341 | break; |
1012 | break; |
1342 | case 2: |
1013 | case 2: |
1343 | new_draw_info(NDI_UNIQUE, 0,op,"It is hurt."); |
1014 | new_draw_info(NDI_UNIQUE, 0,op,"It is hurt."); |
1344 | break; |
1015 | break; |
1345 | case 3: |
1016 | case 3: |
1346 | new_draw_info(NDI_UNIQUE, 0,op,"It is somewhat hurt."); |
1017 | new_draw_info(NDI_UNIQUE, 0,op,"It is somewhat hurt."); |
1347 | break; |
1018 | break; |
1348 | case 4: |
1019 | case 4: |
1349 | new_draw_info(NDI_UNIQUE, 0,op,"It is in excellent shape."); |
1020 | new_draw_info(NDI_UNIQUE, 0,op,"It is in excellent shape."); |
1350 | break; |
1021 | break; |
1351 | } |
1022 | } |
1352 | if(present_in_ob(POISONING,mon)!=NULL) |
1023 | if(present_in_ob(POISONING,mon)!=NULL) |
1353 | new_draw_info(NDI_UNIQUE, 0,op,"It looks very ill."); |
1024 | new_draw_info(NDI_UNIQUE, 0,op,"It looks very ill."); |
1354 | } |
1025 | } |
1355 | |
1026 | |
1356 | |
1027 | |
1357 | /* tmp is the object being described, pl is who is examing it. */ |
1028 | /* tmp is the object being described, pl is who is examing it. */ |
1358 | char *long_desc(object *tmp, object *pl) { |
1029 | char *long_desc(object *tmp, object *pl) { |
1359 | static char buf[VERY_BIG_BUF]; |
1030 | static char buf[VERY_BIG_BUF]; |
1360 | char *cp; |
1031 | char *cp; |
1361 | |
1032 | |
1362 | if(tmp==NULL) |
1033 | if(tmp==NULL) |
1363 | return ""; |
1034 | return ""; |
1364 | |
1035 | |
1365 | buf[0]='\0'; |
1036 | buf[0]='\0'; |
1366 | switch(tmp->type) { |
1037 | switch(tmp->type) { |
1367 | case RING: |
1038 | case RING: |
1368 | case SKILL: |
1039 | case SKILL: |
1369 | case WEAPON: |
1040 | case WEAPON: |
1370 | case ARMOUR: |
1041 | case ARMOUR: |
1371 | case BRACERS: |
1042 | case BRACERS: |
1372 | case HELMET: |
1043 | case HELMET: |
1373 | case SHIELD: |
1044 | case SHIELD: |
1374 | case BOOTS: |
1045 | case BOOTS: |
1375 | case GLOVES: |
1046 | case GLOVES: |
1376 | case AMULET: |
1047 | case AMULET: |
1377 | case GIRDLE: |
1048 | case GIRDLE: |
1378 | case BOW: |
1049 | case BOW: |
1379 | case ARROW: |
1050 | case ARROW: |
1380 | case CLOAK: |
1051 | case CLOAK: |
1381 | case FOOD: |
1052 | case FOOD: |
1382 | case DRINK: |
1053 | case DRINK: |
1383 | case FLESH: |
1054 | case FLESH: |
1384 | case SKILL_TOOL: |
1055 | case SKILL_TOOL: |
1385 | case POWER_CRYSTAL: |
1056 | case POWER_CRYSTAL: |
1386 | if(*(cp=describe_item(tmp, pl))!='\0') { |
1057 | if(*(cp=describe_item(tmp, pl))!='\0') { |
1387 | int len; |
1058 | int len; |
1388 | |
1059 | |
1389 | strncpy(buf,query_name(tmp), VERY_BIG_BUF-1); |
1060 | strncpy(buf,query_name(tmp), VERY_BIG_BUF-1); |
1390 | buf[VERY_BIG_BUF-1]=0; |
1061 | buf[VERY_BIG_BUF-1]=0; |
1391 | len=strlen(buf); |
1062 | len=strlen(buf); |
1392 | if (len<VERY_BIG_BUF-5) { |
1063 | if (len<VERY_BIG_BUF-5) { |
1393 | /* Since we know the length, we save a few cpu cycles by using |
1064 | /* Since we know the length, we save a few cpu cycles by using |
1394 | * it instead of calling strcat */ |
1065 | * it instead of calling strcat */ |
1395 | strcpy(buf+len," "); |
1066 | strcpy(buf+len," "); |
1396 | len++; |
1067 | len++; |
1397 | strncpy(buf+len, cp, VERY_BIG_BUF-len-1); |
1068 | strncpy(buf+len, cp, VERY_BIG_BUF-len-1); |
1398 | buf[VERY_BIG_BUF-1]=0; |
1069 | buf[VERY_BIG_BUF-1]=0; |
1399 | } |
1070 | } |
1400 | } |
1071 | } |
1401 | } |
1072 | } |
1402 | if(buf[0]=='\0') { |
1073 | if(buf[0]=='\0') { |
1403 | strncpy(buf,query_name(tmp), VERY_BIG_BUF-1); |
1074 | strncpy(buf,query_name(tmp), VERY_BIG_BUF-1); |
1404 | buf[VERY_BIG_BUF-1]=0; |
1075 | buf[VERY_BIG_BUF-1]=0; |
1405 | } |
1076 | } |
1406 | |
1077 | |
1407 | return buf; |
1078 | return buf; |
1408 | } |
1079 | } |
1409 | |
1080 | |
1410 | void examine(object *op, object *tmp) { |
1081 | void examine(object *op, object *tmp) { |
1411 | char buf[VERY_BIG_BUF]; |
1082 | char buf[VERY_BIG_BUF]; |
1412 | int i; |
1083 | int i; |
1413 | |
1084 | |
1414 | if (tmp == NULL || tmp->type == CLOSE_CON) |
1085 | if (tmp == NULL || tmp->type == CLOSE_CON) |
1415 | return; |
1086 | return; |
1416 | |
1087 | |
1417 | strcpy(buf,"That is "); |
1088 | strcpy(buf,"That is "); |
1418 | strncat(buf, long_desc(tmp, op), VERY_BIG_BUF-strlen(buf)-1); |
1089 | strncat(buf, long_desc(tmp, op), VERY_BIG_BUF-strlen(buf)-1); |
1419 | buf[VERY_BIG_BUF-1]=0; |
1090 | buf[VERY_BIG_BUF-1]=0; |
1420 | |
1091 | |
… | |
… | |
1428 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1099 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1429 | buf[0]='\0'; |
1100 | buf[0]='\0'; |
1430 | } |
1101 | } |
1431 | |
1102 | |
1432 | switch(tmp->type) { |
1103 | switch(tmp->type) { |
1433 | case SPELLBOOK: |
1104 | case SPELLBOOK: |
1434 | if(QUERY_FLAG(tmp, FLAG_IDENTIFIED) && tmp->inv ) { |
1105 | if(QUERY_FLAG(tmp, FLAG_IDENTIFIED) && tmp->inv ) { |
1435 | sprintf(buf,"%s is a %s level %s spell", |
1106 | sprintf(buf,"%s is a %s level %s spell", |
1436 | tmp->inv->name, get_levelnumber(tmp->inv->level), |
1107 | tmp->inv->name, get_levelnumber(tmp->inv->level), |
1437 | tmp->inv->skill); |
1108 | tmp->inv->skill); |
1438 | } |
1109 | } |
1439 | break; |
1110 | break; |
1440 | |
1111 | |
1441 | case BOOK: |
1112 | case BOOK: |
1442 | if(tmp->msg!=NULL) |
1113 | if(tmp->msg!=NULL) |
1443 | strcpy(buf,"Something is written in it."); |
1114 | strcpy(buf,"Something is written in it."); |
1444 | break; |
1115 | break; |
1445 | |
1116 | |
1446 | case CONTAINER: |
1117 | case CONTAINER: |
1447 | if(tmp->race!=NULL) { |
1118 | if(tmp->race!=NULL) { |
1448 | if(tmp->weight_limit && tmp->stats.Str<100) |
1119 | if(tmp->weight_limit && tmp->stats.Str<100) |
1449 | sprintf (buf,"It can hold only %s and its weight limit is %.1f kg.", |
1120 | 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))); |
1121 | tmp->race, tmp->weight_limit/(10.0 * (100 - tmp->stats.Str))); |
1451 | else |
1122 | else |
1452 | sprintf (buf,"It can hold only %s.", tmp->race); |
1123 | sprintf (buf,"It can hold only %s.", tmp->race); |
1453 | } else |
1124 | } else |
1454 | if(tmp->weight_limit && tmp->stats.Str<100) |
1125 | if(tmp->weight_limit && tmp->stats.Str<100) |
1455 | sprintf (buf,"Its weight limit is %.1f kg.", |
1126 | sprintf (buf,"Its weight limit is %.1f kg.", |
1456 | tmp->weight_limit/(10.0 * (100 - tmp->stats.Str))); |
1127 | tmp->weight_limit/(10.0 * (100 - tmp->stats.Str))); |
1457 | break; |
1128 | break; |
1458 | |
1129 | |
1459 | case WAND: |
1130 | case WAND: |
1460 | if(QUERY_FLAG(tmp, FLAG_IDENTIFIED)) |
1131 | if(QUERY_FLAG(tmp, FLAG_IDENTIFIED)) |
1461 | sprintf(buf,"It has %d charges left.",tmp->stats.food); |
1132 | sprintf(buf,"It has %d charges left.",tmp->stats.food); |
1462 | break; |
1133 | break; |
1463 | } |
1134 | } |
1464 | |
1135 | |
1465 | if(buf[0]!='\0') |
1136 | if(buf[0]!='\0') |
1466 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1137 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1467 | |
1138 | |
1468 | if(tmp->materialname != NULL && !tmp->msg) { |
1139 | if(tmp->materialname != NULL && !tmp->msg) { |
1469 | sprintf(buf, "It is made of: %s.", tmp->materialname); |
1140 | sprintf(buf, "It is made of: %s.", tmp->materialname); |
1470 | new_draw_info(NDI_UNIQUE, 0, op, buf); |
1141 | new_draw_info(NDI_UNIQUE, 0, op, buf); |
1471 | } |
1142 | } |
1472 | /* Where to wear this item */ |
1143 | /* Where to wear this item */ |
1473 | for (i=0; i < NUM_BODY_LOCATIONS; i++) { |
1144 | for (i=0; i < NUM_BODY_LOCATIONS; i++) { |
1474 | if (tmp->body_info[i]<-1) { |
1145 | if (tmp->body_info[i]<-1) { |
1475 | if (op->body_info[i]) |
1146 | if (op->body_info[i]) |
1476 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1147 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1477 | "It goes %s (%d)", body_locations[i].use_name, -tmp->body_info[i]); |
1148 | "It goes %s (%d)", body_locations[i].use_name, -tmp->body_info[i]); |
1478 | else |
1149 | else |
1479 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1150 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1480 | "It goes %s", body_locations[i].nonuse_name); |
1151 | "It goes %s", body_locations[i].nonuse_name); |
1481 | } else if (tmp->body_info[i]) { |
1152 | } else if (tmp->body_info[i]) { |
1482 | if (op->body_info[i]) |
1153 | if (op->body_info[i]) |
1483 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1154 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1484 | "It goes %s", body_locations[i].use_name); |
1155 | "It goes %s", body_locations[i].use_name); |
1485 | else |
1156 | else |
1486 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1157 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1487 | "It goes %s", body_locations[i].nonuse_name); |
1158 | "It goes %s", body_locations[i].nonuse_name); |
1488 | } |
1159 | } |
1489 | } |
1160 | } |
1490 | |
1161 | |
1491 | if(tmp->weight) { |
1162 | if(tmp->weight) { |
1492 | sprintf(buf,tmp->nrof>1?"They weigh %3.3f kg.":"It weighs %3.3f kg.", |
1163 | 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); |
1164 | tmp->weight*(tmp->nrof?tmp->nrof:1)/1000.0); |
1494 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1165 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1495 | } |
1166 | } |
1496 | |
1167 | |
1497 | if (tmp->value && !QUERY_FLAG(tmp, FLAG_STARTEQUIP) && !QUERY_FLAG(tmp, FLAG_NO_PICK)) { |
1168 | if (tmp->value && !QUERY_FLAG(tmp, FLAG_STARTEQUIP) && !QUERY_FLAG(tmp, FLAG_NO_PICK)) { |
1498 | object *floor; |
1169 | object *floor; |
1499 | sprintf(buf,"You reckon %s worth %s.", |
1170 | sprintf(buf,"You reckon %s worth %s.", |
1500 | tmp->nrof>1?"they are":"it is",query_cost_string(tmp,op, F_TRUE | F_APPROX)); |
1171 | 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); |
1172 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1511 | } |
1173 | floor = get_map_ob (op->map, op->x, op->y); |
|
|
1174 | if (floor && floor->type == SHOP_FLOOR) { |
|
|
1175 | if(QUERY_FLAG(tmp, FLAG_UNPAID)) |
|
|
1176 | sprintf(buf,"%s would cost you %s.", |
|
|
1177 | tmp->nrof>1?"They":"It",query_cost_string(tmp,op,F_BUY | F_SHOP)); |
|
|
1178 | else |
|
|
1179 | sprintf(buf,"You are offered %s for %s.", |
|
|
1180 | query_cost_string(tmp,op,F_SELL+F_SHOP), tmp->nrof>1?"them":"it"); |
|
|
1181 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
|
|
1182 | } |
1512 | } |
1183 | } |
1513 | |
1184 | |
1514 | if(QUERY_FLAG(tmp, FLAG_MONSTER)) |
1185 | if(QUERY_FLAG(tmp, FLAG_MONSTER)) |
1515 | examine_monster(op,tmp); |
1186 | examine_monster(op,tmp); |
1516 | |
1187 | |
1517 | /* Is this item buildable? */ |
1188 | /* Is this item buildable? */ |
1518 | if ( QUERY_FLAG( tmp, FLAG_IS_BUILDABLE ) ) |
1189 | if ( QUERY_FLAG( tmp, FLAG_IS_BUILDABLE ) ) |
1519 | new_draw_info( NDI_UNIQUE, 0, op, "This is a buildable item." ); |
1190 | new_draw_info( NDI_UNIQUE, 0, op, "This is a buildable item." ); |
1520 | |
1191 | |
… | |
… | |
1523 | */ |
1194 | */ |
1524 | if(tmp->msg && tmp->type != EXIT && tmp->type != BOOK && |
1195 | if(tmp->msg && tmp->type != EXIT && tmp->type != BOOK && |
1525 | tmp->type != CORPSE && !tmp->move_on && |
1196 | tmp->type != CORPSE && !tmp->move_on && |
1526 | strncasecmp(tmp->msg, "@match",7)) { |
1197 | strncasecmp(tmp->msg, "@match",7)) { |
1527 | |
1198 | |
1528 | /* This is just a hack so when identifying the items, we print |
1199 | /* This is just a hack so when identifying the items, we print |
1529 | * out the extra message |
1200 | * out the extra message |
1530 | */ |
1201 | */ |
1531 | if (need_identify(tmp) && QUERY_FLAG(tmp, FLAG_IDENTIFIED)) |
1202 | if (need_identify(tmp) && QUERY_FLAG(tmp, FLAG_IDENTIFIED)) |
1532 | new_draw_info(NDI_UNIQUE, 0,op, "The object has a story:"); |
1203 | new_draw_info(NDI_UNIQUE, 0,op, "The object has a story:"); |
1533 | |
1204 | |
1534 | new_draw_info(NDI_UNIQUE, 0,op,tmp->msg); |
1205 | new_draw_info(NDI_UNIQUE, 0,op,tmp->msg); |
1535 | } |
1206 | } |
1536 | new_draw_info(NDI_UNIQUE, 0,op," "); /* Blank line */ |
1207 | new_draw_info(NDI_UNIQUE, 0,op," "); /* Blank line */ |
1537 | } |
1208 | } |
1538 | |
1209 | |
1539 | /* |
1210 | /* |
… | |
… | |
1582 | if((!op||!QUERY_FLAG(op, FLAG_WIZ)) && (tmp->invisible || |
1253 | if((!op||!QUERY_FLAG(op, FLAG_WIZ)) && (tmp->invisible || |
1583 | (inv && inv->type != CONTAINER && !QUERY_FLAG(tmp, FLAG_APPLIED)))) |
1254 | (inv && inv->type != CONTAINER && !QUERY_FLAG(tmp, FLAG_APPLIED)))) |
1584 | continue; |
1255 | continue; |
1585 | if((!op || QUERY_FLAG(op, FLAG_WIZ))) |
1256 | if((!op || QUERY_FLAG(op, FLAG_WIZ))) |
1586 | new_draw_info_format(NDI_UNIQUE, 0,op ,"%s- %-*.*s (%5d) %-8s", in, length, length, |
1257 | new_draw_info_format(NDI_UNIQUE, 0,op ,"%s- %-*.*s (%5d) %-8s", in, length, length, |
1587 | query_name(tmp), tmp->count,query_weight(tmp)); |
1258 | query_name(tmp), tmp->count,query_weight(tmp)); |
1588 | else |
1259 | else |
1589 | new_draw_info_format(NDI_UNIQUE,0, op, "%s- %-*.*s %-8s", in, length+8, |
1260 | new_draw_info_format(NDI_UNIQUE,0, op, "%s- %-*.*s %-8s", in, length+8, |
1590 | length+8, query_name(tmp), |
1261 | length+8, query_name(tmp), |
1591 | query_weight(tmp)); |
1262 | query_weight(tmp)); |
1592 | } |
1263 | } |
1593 | if(!inv && op) { |
1264 | if(!inv && op) { |
1594 | new_draw_info_format(NDI_UNIQUE,0, op ,"%-*s %-8s", |
1265 | new_draw_info_format(NDI_UNIQUE,0, op ,"%-*s %-8s", |
1595 | 41,"Total weight :",query_weight(op)); |
1266 | 41,"Total weight :",query_weight(op)); |
… | |
… | |
1734 | int command_search_items (object *op, char *params) |
1405 | int command_search_items (object *op, char *params) |
1735 | { |
1406 | { |
1736 | char buf[MAX_BUF]; |
1407 | char buf[MAX_BUF]; |
1737 | |
1408 | |
1738 | if (settings.search_items == FALSE) |
1409 | if (settings.search_items == FALSE) |
1739 | return 1; |
1410 | return 1; |
1740 | |
1411 | |
1741 | if(params == NULL) { |
1412 | if(params == NULL) { |
1742 | if(op->contr->search_str[0]=='\0') { |
1413 | if(op->contr->search_str[0]=='\0') { |
1743 | new_draw_info(NDI_UNIQUE, 0,op,"Example: search magic+1"); |
1414 | new_draw_info(NDI_UNIQUE, 0,op,"Example: search magic+1"); |
1744 | new_draw_info(NDI_UNIQUE, 0,op,"Would automatically pick up all"); |
1415 | 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'."); |
1416 | new_draw_info(NDI_UNIQUE, 0,op,"items containing the word 'magic+1'."); |
1746 | return 1; |
1417 | return 1; |
1747 | } |
1418 | } |
1748 | op->contr->search_str[0]='\0'; |
1419 | op->contr->search_str[0]='\0'; |
1749 | new_draw_info(NDI_UNIQUE, 0,op,"Search mode turned off."); |
1420 | new_draw_info(NDI_UNIQUE, 0,op,"Search mode turned off."); |
1750 | fix_player(op); |
1421 | fix_player(op); |
1751 | return 1; |
1422 | return 1; |
1752 | } |
1423 | } |
1753 | if((int)strlen(params) >= MAX_BUF) { |
1424 | if((int)strlen(params) >= MAX_BUF) { |
1754 | new_draw_info(NDI_UNIQUE, 0,op,"Search string too long."); |
1425 | new_draw_info(NDI_UNIQUE, 0,op,"Search string too long."); |
1755 | return 1; |
1426 | return 1; |
1756 | } |
1427 | } |
1757 | strcpy(op->contr->search_str, params); |
1428 | strcpy(op->contr->search_str, params); |
1758 | sprintf(buf,"Searching for '%s'.",op->contr->search_str); |
1429 | sprintf(buf,"Searching for '%s'.",op->contr->search_str); |
1759 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1430 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1760 | fix_player(op); |
1431 | fix_player(op); |
… | |
… | |
1783 | /* Let's skip white spaces */ |
1454 | /* Let's skip white spaces */ |
1784 | while(' '==*params) params++; |
1455 | while(' '==*params) params++; |
1785 | |
1456 | |
1786 | /* Checking the first part */ |
1457 | /* Checking the first part */ |
1787 | if ((itemnumber = atoi(params))!=0) { |
1458 | if ((itemnumber = atoi(params))!=0) { |
1788 | for (item=op->inv; item && ((item->count != itemnumber) || item->invisible); item=item->below); |
1459 | for (item=op->inv; item && ((item->count != itemnumber) || item->invisible); item=item->below); |
1789 | if (!item) { |
1460 | if (!item) { |
1790 | new_draw_info(NDI_UNIQUE,0,op,"Tried to rename an invalid item."); |
1461 | new_draw_info(NDI_UNIQUE,0,op,"Tried to rename an invalid item."); |
1791 | return 1; |
1462 | return 1; |
1792 | } |
1463 | } |
1793 | while(isdigit(*params) || ' '==*params) params++; |
1464 | while(isdigit(*params) || ' '==*params) params++; |
1794 | } |
1465 | } |
1795 | else if ('<'==*params) { |
1466 | else if ('<'==*params) { |
1796 | /* Got old name, let's get it & find appropriate matching item */ |
1467 | /* Got old name, let's get it & find appropriate matching item */ |
1797 | closebrace=strchr(params,'>'); |
1468 | closebrace=strchr(params,'>'); |
1798 | if(!closebrace) { |
1469 | if(!closebrace) { |