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.11 2006/08/29 10:51:43 elmex 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; |
1009 | |
678 | |
1010 | if (floor |
679 | if (is_in_shop (op) |
1011 | && floor->type == SHOP_FLOOR |
|
|
1012 | && !QUERY_FLAG (tmp, FLAG_UNPAID) |
680 | && !QUERY_FLAG (tmp, FLAG_UNPAID) |
1013 | && tmp->type != MONEY) |
681 | && tmp->type != MONEY) |
1014 | sell_item (tmp, op); |
682 | sell_item (tmp, op); |
1015 | |
683 | |
1016 | tmp->x = op->x; |
684 | tmp->x = op->x; |
… | |
… | |
1025 | * somehow, players get an invisible object in the container, and the |
693 | * somehow, players get an invisible object in the container, and the |
1026 | * old logic would skip over invisible objects - works fine for the |
694 | * old logic would skip over invisible objects - works fine for the |
1027 | * playes inventory, but drop inventory wants to use the next value. |
695 | * playes inventory, but drop inventory wants to use the next value. |
1028 | */ |
696 | */ |
1029 | if (tmp->invisible) { |
697 | if (tmp->invisible) { |
1030 | /* if the following is the case, it must be in an container. */ |
698 | /* if the following is the case, it must be in an container. */ |
1031 | if (tmp->env && tmp->env->type != PLAYER) { |
699 | if (tmp->env && tmp->env->type != PLAYER) { |
1032 | /* Just toss the object - probably shouldn't be hanging |
700 | /* Just toss the object - probably shouldn't be hanging |
1033 | * around anyways |
701 | * around anyways |
1034 | */ |
702 | */ |
1035 | remove_ob(tmp); |
703 | remove_ob(tmp); |
1036 | free_object(tmp); |
704 | free_object(tmp); |
1037 | return; |
705 | return; |
1038 | } else { |
706 | } else { |
1039 | while(tmp!=NULL && tmp->invisible) |
707 | while(tmp!=NULL && tmp->invisible) |
1040 | tmp=tmp->below; |
708 | tmp=tmp->below; |
1041 | } |
709 | } |
1042 | } |
710 | } |
1043 | |
711 | |
1044 | if (tmp==NULL) { |
712 | if (tmp==NULL) { |
1045 | new_draw_info(NDI_UNIQUE, 0,op,"You don't have anything to drop."); |
713 | new_draw_info(NDI_UNIQUE, 0,op,"You don't have anything to drop."); |
1046 | return; |
714 | return; |
… | |
… | |
1060 | if (op->type == PLAYER) |
728 | if (op->type == PLAYER) |
1061 | { |
729 | { |
1062 | if (op->contr->last_used==tmp && op->contr->last_used_id == tmp->count) { |
730 | if (op->contr->last_used==tmp && op->contr->last_used_id == tmp->count) { |
1063 | object *n=NULL; |
731 | object *n=NULL; |
1064 | if(tmp->below != NULL) |
732 | if(tmp->below != NULL) |
1065 | n = tmp->below; |
733 | n = tmp->below; |
1066 | else if(tmp->above != NULL) |
734 | else if(tmp->above != NULL) |
1067 | n = tmp->above; |
735 | n = tmp->above; |
1068 | op->contr->last_used = n; |
736 | op->contr->last_used = n; |
1069 | if (n != NULL) |
737 | if (n != NULL) |
1070 | op->contr->last_used_id = n->count; |
738 | op->contr->last_used_id = n->count; |
1071 | else |
739 | else |
1072 | op->contr->last_used_id = 0; |
740 | op->contr->last_used_id = 0; |
1073 | } |
741 | } |
1074 | }; |
742 | }; |
1075 | |
743 | |
1076 | if (op->container) { |
744 | if (op->container) { |
1077 | if (op->type == PLAYER) |
745 | if (op->type == PLAYER) |
… | |
… | |
1118 | |
786 | |
1119 | if(params==NULL) { |
787 | if(params==NULL) { |
1120 | while(curinv != NULL) { |
788 | while(curinv != NULL) { |
1121 | nextinv = curinv->below; |
789 | nextinv = curinv->below; |
1122 | while (nextinv && nextinv->type==MONEY) |
790 | while (nextinv && nextinv->type==MONEY) |
1123 | nextinv = nextinv->below; |
791 | nextinv = nextinv->below; |
1124 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && curinv->type != MONEY && |
792 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && curinv->type != MONEY && |
1125 | curinv->type != FOOD && curinv->type != KEY && |
793 | curinv->type != FOOD && curinv->type != KEY && |
1126 | curinv->type != SPECIAL_KEY && curinv->type != GEM && |
794 | curinv->type != SPECIAL_KEY && curinv->type != GEM && |
1127 | !curinv->invisible && |
795 | !curinv->invisible && |
1128 | (curinv->type!=CONTAINER || op->container!=curinv)) |
796 | (curinv->type!=CONTAINER || op->container!=curinv)) |
1129 | { |
797 | { |
1130 | drop(op,curinv); |
798 | drop(op,curinv); |
1131 | } |
799 | } |
1132 | curinv = nextinv; |
800 | curinv = nextinv; |
1133 | } |
801 | } |
1134 | } |
802 | } |
1135 | |
803 | |
1136 | else if(strcmp(params, "weapons") == 0) { |
804 | else if(strcmp(params, "weapons") == 0) { |
1137 | while(curinv != NULL) { |
805 | while(curinv != NULL) { |
1138 | nextinv = curinv->below; |
806 | nextinv = curinv->below; |
1139 | while (nextinv && nextinv->type==MONEY) |
807 | while (nextinv && nextinv->type==MONEY) |
1140 | nextinv = nextinv->below; |
808 | nextinv = nextinv->below; |
1141 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ((curinv->type == WEAPON) || |
809 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ((curinv->type == WEAPON) || |
1142 | (curinv->type == BOW) || (curinv->type == ARROW))) |
810 | (curinv->type == BOW) || (curinv->type == ARROW))) |
1143 | { |
811 | { |
1144 | drop(op,curinv); |
812 | drop(op,curinv); |
1145 | } |
813 | } |
1146 | curinv = nextinv; |
814 | curinv = nextinv; |
1147 | } |
815 | } |
1148 | } |
816 | } |
1149 | |
817 | |
1150 | else if(strcmp(params, "armor") == 0 || strcmp(params, "armour") == 0) { |
818 | else if(strcmp(params, "armor") == 0 || strcmp(params, "armour") == 0) { |
1151 | while(curinv != NULL) { |
819 | while(curinv != NULL) { |
1152 | nextinv = curinv->below; |
820 | nextinv = curinv->below; |
1153 | while (nextinv && nextinv->type==MONEY) |
821 | while (nextinv && nextinv->type==MONEY) |
1154 | nextinv = nextinv->below; |
822 | nextinv = nextinv->below; |
1155 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ((curinv->type == ARMOUR) || |
823 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ((curinv->type == ARMOUR) || |
1156 | curinv->type == SHIELD || curinv->type==HELMET)) |
824 | curinv->type == SHIELD || curinv->type==HELMET)) |
1157 | { |
825 | { |
1158 | drop(op,curinv); |
826 | drop(op,curinv); |
1159 | } |
827 | } |
1160 | curinv = nextinv; |
828 | curinv = nextinv; |
1161 | } |
829 | } |
1162 | } |
830 | } |
1163 | |
831 | |
1164 | else if(strcmp(params, "misc") == 0) { |
832 | else if(strcmp(params, "misc") == 0) { |
1165 | while(curinv != NULL) { |
833 | while(curinv != NULL) { |
1166 | nextinv = curinv->below; |
834 | nextinv = curinv->below; |
1167 | while (nextinv && nextinv->type==MONEY) |
835 | while (nextinv && nextinv->type==MONEY) |
1168 | nextinv = nextinv->below; |
836 | nextinv = nextinv->below; |
1169 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ! QUERY_FLAG(curinv,FLAG_APPLIED)) { |
837 | if(! QUERY_FLAG(curinv,FLAG_INV_LOCKED) && ! QUERY_FLAG(curinv,FLAG_APPLIED)) { |
1170 | switch(curinv->type) { |
838 | switch(curinv->type) { |
1171 | case HORN: |
839 | case HORN: |
1172 | case BOOK: |
840 | case BOOK: |
1173 | case SPELLBOOK: |
841 | case SPELLBOOK: |
1174 | case GIRDLE: |
842 | case GIRDLE: |
1175 | case AMULET: |
843 | case AMULET: |
1176 | case RING: |
844 | case RING: |
1177 | case CLOAK: |
845 | case CLOAK: |
1178 | case BOOTS: |
846 | case BOOTS: |
1179 | case GLOVES: |
847 | case GLOVES: |
1180 | case BRACERS: |
848 | case BRACERS: |
1181 | case SCROLL: |
849 | case SCROLL: |
1182 | case ARMOUR_IMPROVER: |
850 | case ARMOUR_IMPROVER: |
1183 | case WEAPON_IMPROVER: |
851 | case WEAPON_IMPROVER: |
1184 | case WAND: |
852 | case WAND: |
1185 | case ROD: |
853 | case ROD: |
1186 | case POTION: |
854 | case POTION: |
1187 | drop(op,curinv); |
855 | drop(op,curinv); |
1188 | curinv = nextinv; |
856 | curinv = nextinv; |
1189 | break; |
857 | break; |
1190 | default: |
858 | default: |
1191 | curinv = nextinv; |
859 | curinv = nextinv; |
1192 | break; |
860 | break; |
1193 | } |
861 | } |
1194 | } |
862 | } |
1195 | curinv = nextinv; |
863 | curinv = nextinv; |
1196 | } |
864 | } |
1197 | } |
865 | } |
1198 | op->contr->socket.update_look=1; |
866 | op->contr->socket.update_look=1; |
… | |
… | |
1208 | { |
876 | { |
1209 | object *tmp, *next; |
877 | object *tmp, *next; |
1210 | int did_one=0; |
878 | int did_one=0; |
1211 | |
879 | |
1212 | if (!params) { |
880 | if (!params) { |
1213 | new_draw_info(NDI_UNIQUE,0, op, "Drop what?"); |
881 | new_draw_info(NDI_UNIQUE,0, op, "Drop what?"); |
1214 | return 0; |
882 | return 0; |
1215 | } else { |
883 | } else { |
1216 | for (tmp=op->inv; tmp; tmp=next) { |
884 | for (tmp=op->inv; tmp; tmp=next) { |
1217 | next=tmp->below; |
885 | next=tmp->below; |
1218 | if (QUERY_FLAG(tmp,FLAG_NO_DROP) || |
886 | if (QUERY_FLAG(tmp,FLAG_NO_DROP) || |
1219 | tmp->invisible) continue; |
887 | tmp->invisible) continue; |
1220 | if (item_matched_string(op,tmp,params)) { |
888 | if (item_matched_string(op,tmp,params)) { |
1221 | drop(op, tmp); |
889 | drop(op, tmp); |
1222 | did_one=1; |
890 | did_one=1; |
1223 | } |
891 | } |
1224 | } |
892 | } |
1225 | if (!did_one) new_draw_info(NDI_UNIQUE, 0,op,"Nothing to drop."); |
893 | if (!did_one) new_draw_info(NDI_UNIQUE, 0,op,"Nothing to drop."); |
1226 | } |
894 | } |
1227 | if (op->type==PLAYER) |
895 | if (op->type==PLAYER) |
1228 | { |
896 | { |
1229 | op->contr->count=0; |
897 | op->contr->count=0; |
1230 | op->contr->socket.update_look=1; |
898 | op->contr->socket.update_look=1; |
… | |
… | |
1243 | else { |
911 | else { |
1244 | object *tmp=find_best_object_match(op,params); |
912 | object *tmp=find_best_object_match(op,params); |
1245 | if (tmp) |
913 | if (tmp) |
1246 | examine(op,tmp); |
914 | examine(op,tmp); |
1247 | else |
915 | else |
1248 | new_draw_info_format(NDI_UNIQUE,0,op,"Could not find an object that matches %s",params); |
916 | new_draw_info_format(NDI_UNIQUE,0,op,"Could not find an object that matches %s",params); |
1249 | } |
917 | } |
1250 | return 0; |
918 | return 0; |
1251 | } |
919 | } |
1252 | |
920 | |
1253 | /* op should be a player. |
921 | /* op should be a player. |
… | |
… | |
1261 | object *tmp; |
929 | object *tmp; |
1262 | |
930 | |
1263 | if (!op || !op->contr) return NULL; |
931 | if (!op || !op->contr) return NULL; |
1264 | if (!op->contr->mark) { |
932 | if (!op->contr->mark) { |
1265 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
933 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
1266 | return NULL; |
934 | return NULL; |
1267 | } |
935 | } |
1268 | /* This may seem like overkill, but we need to make sure that they |
936 | /* 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 |
937 | * player hasn't dropped the item. We use count on the off chance that |
1270 | * an item got reincarnated at some point. |
938 | * an item got reincarnated at some point. |
1271 | */ |
939 | */ |
1272 | for (tmp=op->inv; tmp; tmp=tmp->below) { |
940 | for (tmp=op->inv; tmp; tmp=tmp->below) { |
1273 | if (tmp->invisible) continue; |
941 | if (tmp->invisible) continue; |
1274 | if (tmp == op->contr->mark) { |
942 | if (tmp == op->contr->mark) { |
1275 | if (tmp->count == op->contr->mark_count) |
943 | if (tmp->count == op->contr->mark_count) |
1276 | return tmp; |
944 | return tmp; |
1277 | else { |
945 | else { |
1278 | op->contr->mark=NULL; |
946 | op->contr->mark=NULL; |
1279 | op->contr->mark_count=0; |
947 | op->contr->mark_count=0; |
1280 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
948 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
1281 | return NULL; |
949 | return NULL; |
1282 | } |
950 | } |
1283 | } |
951 | } |
1284 | } |
952 | } |
1285 | return NULL; |
953 | return NULL; |
1286 | } |
954 | } |
1287 | |
955 | |
1288 | |
956 | |
… | |
… | |
1292 | */ |
960 | */ |
1293 | int command_mark(object *op, char *params) |
961 | int command_mark(object *op, char *params) |
1294 | { |
962 | { |
1295 | if (!op->contr) return 1; |
963 | if (!op->contr) return 1; |
1296 | if (!params) { |
964 | if (!params) { |
1297 | object *mark=find_marked_object(op); |
965 | object *mark=find_marked_object(op); |
1298 | if (!mark) new_draw_info(NDI_UNIQUE,0,op,"You have no marked object."); |
966 | 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)); |
967 | else new_draw_info_format(NDI_UNIQUE,0,op,"%s is marked.", query_name(mark)); |
1300 | } |
968 | } |
1301 | else { |
969 | else { |
1302 | object *mark1=find_best_object_match(op, params); |
970 | object *mark1=find_best_object_match(op, params); |
1303 | if (!mark1) { |
971 | if (!mark1) { |
1304 | new_draw_info_format(NDI_UNIQUE,0,op,"Could not find an object that matches %s",params); |
972 | new_draw_info_format(NDI_UNIQUE,0,op,"Could not find an object that matches %s",params); |
1305 | return 1; |
973 | return 1; |
1306 | } |
974 | } |
1307 | else { |
975 | else { |
1308 | op->contr->mark=mark1; |
976 | op->contr->mark=mark1; |
1309 | op->contr->mark_count=mark1->count; |
977 | op->contr->mark_count=mark1->count; |
1310 | new_draw_info_format(NDI_UNIQUE,0,op,"Marked item %s", query_name(mark1)); |
978 | new_draw_info_format(NDI_UNIQUE,0,op,"Marked item %s", query_name(mark1)); |
1311 | return 0; |
979 | return 0; |
1312 | } |
980 | } |
1313 | } |
981 | } |
1314 | return 0; /*shouldnt get here */ |
982 | return 0; /*shouldnt get here */ |
1315 | } |
983 | } |
1316 | |
984 | |
1317 | |
985 | |
… | |
… | |
1320 | */ |
988 | */ |
1321 | void examine_monster(object *op,object *tmp) { |
989 | void examine_monster(object *op,object *tmp) { |
1322 | object *mon=tmp->head?tmp->head:tmp; |
990 | object *mon=tmp->head?tmp->head:tmp; |
1323 | |
991 | |
1324 | if(QUERY_FLAG(mon,FLAG_UNDEAD)) |
992 | if(QUERY_FLAG(mon,FLAG_UNDEAD)) |
1325 | new_draw_info(NDI_UNIQUE, 0,op,"It is an undead force."); |
993 | new_draw_info(NDI_UNIQUE, 0,op,"It is an undead force."); |
1326 | if(mon->level>op->level) |
994 | if(mon->level>op->level) |
1327 | new_draw_info(NDI_UNIQUE, 0,op,"It is likely more powerful than you."); |
995 | new_draw_info(NDI_UNIQUE, 0,op,"It is likely more powerful than you."); |
1328 | else if(mon->level<op->level) |
996 | else if(mon->level<op->level) |
1329 | new_draw_info(NDI_UNIQUE, 0,op,"It is likely less powerful than you."); |
997 | new_draw_info(NDI_UNIQUE, 0,op,"It is likely less powerful than you."); |
1330 | else |
998 | else |
1331 | new_draw_info(NDI_UNIQUE, 0,op,"It is probably as powerful as you."); |
999 | new_draw_info(NDI_UNIQUE, 0,op,"It is probably as powerful as you."); |
1332 | if(mon->attacktype&AT_ACID) |
1000 | if(mon->attacktype&AT_ACID) |
1333 | new_draw_info(NDI_UNIQUE, 0,op,"You seem to smell an acrid odor."); |
1001 | new_draw_info(NDI_UNIQUE, 0,op,"You seem to smell an acrid odor."); |
1334 | |
1002 | |
1335 | /* Anyone know why this used to use the clone value instead of the |
1003 | /* 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. |
1004 | * maxhp field? This seems that it should give more accurate results. |
1337 | */ |
1005 | */ |
1338 | switch((mon->stats.hp+1)*4/(mon->stats.maxhp+1)) { /* From 1-4 */ |
1006 | switch((mon->stats.hp+1)*4/(mon->stats.maxhp+1)) { /* From 1-4 */ |
1339 | case 1: |
1007 | case 1: |
1340 | new_draw_info(NDI_UNIQUE, 0,op,"It is in a bad shape."); |
1008 | new_draw_info(NDI_UNIQUE, 0,op,"It is in a bad shape."); |
1341 | break; |
1009 | break; |
1342 | case 2: |
1010 | case 2: |
1343 | new_draw_info(NDI_UNIQUE, 0,op,"It is hurt."); |
1011 | new_draw_info(NDI_UNIQUE, 0,op,"It is hurt."); |
1344 | break; |
1012 | break; |
1345 | case 3: |
1013 | case 3: |
1346 | new_draw_info(NDI_UNIQUE, 0,op,"It is somewhat hurt."); |
1014 | new_draw_info(NDI_UNIQUE, 0,op,"It is somewhat hurt."); |
1347 | break; |
1015 | break; |
1348 | case 4: |
1016 | case 4: |
1349 | new_draw_info(NDI_UNIQUE, 0,op,"It is in excellent shape."); |
1017 | new_draw_info(NDI_UNIQUE, 0,op,"It is in excellent shape."); |
1350 | break; |
1018 | break; |
1351 | } |
1019 | } |
1352 | if(present_in_ob(POISONING,mon)!=NULL) |
1020 | if(present_in_ob(POISONING,mon)!=NULL) |
1353 | new_draw_info(NDI_UNIQUE, 0,op,"It looks very ill."); |
1021 | new_draw_info(NDI_UNIQUE, 0,op,"It looks very ill."); |
1354 | } |
1022 | } |
1355 | |
1023 | |
1356 | |
1024 | |
1357 | /* tmp is the object being described, pl is who is examing it. */ |
1025 | /* tmp is the object being described, pl is who is examing it. */ |
1358 | char *long_desc(object *tmp, object *pl) { |
1026 | char *long_desc(object *tmp, object *pl) { |
1359 | static char buf[VERY_BIG_BUF]; |
1027 | static char buf[VERY_BIG_BUF]; |
1360 | char *cp; |
1028 | char *cp; |
1361 | |
1029 | |
1362 | if(tmp==NULL) |
1030 | if(tmp==NULL) |
1363 | return ""; |
1031 | return ""; |
1364 | |
1032 | |
1365 | buf[0]='\0'; |
1033 | buf[0]='\0'; |
1366 | switch(tmp->type) { |
1034 | switch(tmp->type) { |
1367 | case RING: |
1035 | case RING: |
1368 | case SKILL: |
1036 | case SKILL: |
1369 | case WEAPON: |
1037 | case WEAPON: |
1370 | case ARMOUR: |
1038 | case ARMOUR: |
1371 | case BRACERS: |
1039 | case BRACERS: |
1372 | case HELMET: |
1040 | case HELMET: |
1373 | case SHIELD: |
1041 | case SHIELD: |
1374 | case BOOTS: |
1042 | case BOOTS: |
1375 | case GLOVES: |
1043 | case GLOVES: |
1376 | case AMULET: |
1044 | case AMULET: |
1377 | case GIRDLE: |
1045 | case GIRDLE: |
1378 | case BOW: |
1046 | case BOW: |
1379 | case ARROW: |
1047 | case ARROW: |
1380 | case CLOAK: |
1048 | case CLOAK: |
1381 | case FOOD: |
1049 | case FOOD: |
1382 | case DRINK: |
1050 | case DRINK: |
1383 | case FLESH: |
1051 | case FLESH: |
1384 | case SKILL_TOOL: |
1052 | case SKILL_TOOL: |
1385 | case POWER_CRYSTAL: |
1053 | case POWER_CRYSTAL: |
1386 | if(*(cp=describe_item(tmp, pl))!='\0') { |
1054 | if(*(cp=describe_item(tmp, pl))!='\0') { |
1387 | int len; |
1055 | int len; |
1388 | |
1056 | |
1389 | strncpy(buf,query_name(tmp), VERY_BIG_BUF-1); |
1057 | strncpy(buf,query_name(tmp), VERY_BIG_BUF-1); |
1390 | buf[VERY_BIG_BUF-1]=0; |
1058 | buf[VERY_BIG_BUF-1]=0; |
1391 | len=strlen(buf); |
1059 | len=strlen(buf); |
1392 | if (len<VERY_BIG_BUF-5) { |
1060 | if (len<VERY_BIG_BUF-5) { |
1393 | /* Since we know the length, we save a few cpu cycles by using |
1061 | /* Since we know the length, we save a few cpu cycles by using |
1394 | * it instead of calling strcat */ |
1062 | * it instead of calling strcat */ |
1395 | strcpy(buf+len," "); |
1063 | strcpy(buf+len," "); |
1396 | len++; |
1064 | len++; |
1397 | strncpy(buf+len, cp, VERY_BIG_BUF-len-1); |
1065 | strncpy(buf+len, cp, VERY_BIG_BUF-len-1); |
1398 | buf[VERY_BIG_BUF-1]=0; |
1066 | buf[VERY_BIG_BUF-1]=0; |
1399 | } |
1067 | } |
1400 | } |
1068 | } |
1401 | } |
1069 | } |
1402 | if(buf[0]=='\0') { |
1070 | if(buf[0]=='\0') { |
1403 | strncpy(buf,query_name(tmp), VERY_BIG_BUF-1); |
1071 | strncpy(buf,query_name(tmp), VERY_BIG_BUF-1); |
1404 | buf[VERY_BIG_BUF-1]=0; |
1072 | buf[VERY_BIG_BUF-1]=0; |
1405 | } |
1073 | } |
1406 | |
1074 | |
1407 | return buf; |
1075 | return buf; |
1408 | } |
1076 | } |
1409 | |
1077 | |
1410 | void examine(object *op, object *tmp) { |
1078 | void examine(object *op, object *tmp) { |
1411 | char buf[VERY_BIG_BUF]; |
1079 | char buf[VERY_BIG_BUF]; |
1412 | int i; |
1080 | int i; |
1413 | |
1081 | |
1414 | if (tmp == NULL || tmp->type == CLOSE_CON) |
1082 | if (tmp == NULL || tmp->type == CLOSE_CON) |
1415 | return; |
1083 | return; |
1416 | |
1084 | |
1417 | strcpy(buf,"That is "); |
1085 | strcpy(buf,"That is "); |
1418 | strncat(buf, long_desc(tmp, op), VERY_BIG_BUF-strlen(buf)-1); |
1086 | strncat(buf, long_desc(tmp, op), VERY_BIG_BUF-strlen(buf)-1); |
1419 | buf[VERY_BIG_BUF-1]=0; |
1087 | buf[VERY_BIG_BUF-1]=0; |
1420 | |
1088 | |
… | |
… | |
1428 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1096 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1429 | buf[0]='\0'; |
1097 | buf[0]='\0'; |
1430 | } |
1098 | } |
1431 | |
1099 | |
1432 | switch(tmp->type) { |
1100 | switch(tmp->type) { |
1433 | case SPELLBOOK: |
1101 | case SPELLBOOK: |
1434 | if(QUERY_FLAG(tmp, FLAG_IDENTIFIED) && tmp->inv ) { |
1102 | if(QUERY_FLAG(tmp, FLAG_IDENTIFIED) && tmp->inv ) { |
1435 | sprintf(buf,"%s is a %s level %s spell", |
1103 | sprintf(buf,"%s is a %s level %s spell", |
1436 | tmp->inv->name, get_levelnumber(tmp->inv->level), |
1104 | tmp->inv->name, get_levelnumber(tmp->inv->level), |
1437 | tmp->inv->skill); |
1105 | tmp->inv->skill); |
1438 | } |
1106 | } |
1439 | break; |
1107 | break; |
1440 | |
1108 | |
1441 | case BOOK: |
1109 | case BOOK: |
1442 | if(tmp->msg!=NULL) |
1110 | if(tmp->msg!=NULL) |
1443 | strcpy(buf,"Something is written in it."); |
1111 | strcpy(buf,"Something is written in it."); |
1444 | break; |
1112 | break; |
1445 | |
1113 | |
1446 | case CONTAINER: |
1114 | case CONTAINER: |
1447 | if(tmp->race!=NULL) { |
1115 | if(tmp->race!=NULL) { |
1448 | if(tmp->weight_limit && tmp->stats.Str<100) |
1116 | if(tmp->weight_limit && tmp->stats.Str<100) |
1449 | sprintf (buf,"It can hold only %s and its weight limit is %.1f kg.", |
1117 | 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))); |
1118 | tmp->race, tmp->weight_limit/(10.0 * (100 - tmp->stats.Str))); |
1451 | else |
1119 | else |
1452 | sprintf (buf,"It can hold only %s.", tmp->race); |
1120 | sprintf (buf,"It can hold only %s.", tmp->race); |
1453 | } else |
1121 | } else |
1454 | if(tmp->weight_limit && tmp->stats.Str<100) |
1122 | if(tmp->weight_limit && tmp->stats.Str<100) |
1455 | sprintf (buf,"Its weight limit is %.1f kg.", |
1123 | sprintf (buf,"Its weight limit is %.1f kg.", |
1456 | tmp->weight_limit/(10.0 * (100 - tmp->stats.Str))); |
1124 | tmp->weight_limit/(10.0 * (100 - tmp->stats.Str))); |
1457 | break; |
1125 | break; |
1458 | |
1126 | |
1459 | case WAND: |
1127 | case WAND: |
1460 | if(QUERY_FLAG(tmp, FLAG_IDENTIFIED)) |
1128 | if(QUERY_FLAG(tmp, FLAG_IDENTIFIED)) |
1461 | sprintf(buf,"It has %d charges left.",tmp->stats.food); |
1129 | sprintf(buf,"It has %d charges left.",tmp->stats.food); |
1462 | break; |
1130 | break; |
1463 | } |
1131 | } |
1464 | |
1132 | |
1465 | if(buf[0]!='\0') |
1133 | if(buf[0]!='\0') |
1466 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1134 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1467 | |
1135 | |
1468 | if(tmp->materialname != NULL && !tmp->msg) { |
1136 | if(tmp->materialname != NULL && !tmp->msg) { |
1469 | sprintf(buf, "It is made of: %s.", tmp->materialname); |
1137 | sprintf(buf, "It is made of: %s.", tmp->materialname); |
1470 | new_draw_info(NDI_UNIQUE, 0, op, buf); |
1138 | new_draw_info(NDI_UNIQUE, 0, op, buf); |
1471 | } |
1139 | } |
1472 | /* Where to wear this item */ |
1140 | /* Where to wear this item */ |
1473 | for (i=0; i < NUM_BODY_LOCATIONS; i++) { |
1141 | for (i=0; i < NUM_BODY_LOCATIONS; i++) { |
1474 | if (tmp->body_info[i]<-1) { |
1142 | if (tmp->body_info[i]<-1) { |
1475 | if (op->body_info[i]) |
1143 | if (op->body_info[i]) |
1476 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1144 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1477 | "It goes %s (%d)", body_locations[i].use_name, -tmp->body_info[i]); |
1145 | "It goes %s (%d)", body_locations[i].use_name, -tmp->body_info[i]); |
1478 | else |
1146 | else |
1479 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1147 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1480 | "It goes %s", body_locations[i].nonuse_name); |
1148 | "It goes %s", body_locations[i].nonuse_name); |
1481 | } else if (tmp->body_info[i]) { |
1149 | } else if (tmp->body_info[i]) { |
1482 | if (op->body_info[i]) |
1150 | if (op->body_info[i]) |
1483 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1151 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1484 | "It goes %s", body_locations[i].use_name); |
1152 | "It goes %s", body_locations[i].use_name); |
1485 | else |
1153 | else |
1486 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1154 | new_draw_info_format(NDI_UNIQUE, 0,op, |
1487 | "It goes %s", body_locations[i].nonuse_name); |
1155 | "It goes %s", body_locations[i].nonuse_name); |
1488 | } |
1156 | } |
1489 | } |
1157 | } |
1490 | |
1158 | |
1491 | if(tmp->weight) { |
1159 | if(tmp->weight) { |
1492 | sprintf(buf,tmp->nrof>1?"They weigh %3.3f kg.":"It weighs %3.3f kg.", |
1160 | 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); |
1161 | tmp->weight*(tmp->nrof?tmp->nrof:1)/1000.0); |
1494 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1162 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1495 | } |
1163 | } |
1496 | |
1164 | |
1497 | if (tmp->value && !QUERY_FLAG(tmp, FLAG_STARTEQUIP) && !QUERY_FLAG(tmp, FLAG_NO_PICK)) { |
1165 | 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.", |
1166 | sprintf(buf,"You reckon %s worth %s.", |
1500 | tmp->nrof>1?"they are":"it is",query_cost_string(tmp,op, F_TRUE | F_APPROX)); |
1167 | 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); |
1168 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1511 | } |
1169 | if (is_in_shop (op)) { |
|
|
1170 | if(QUERY_FLAG(tmp, FLAG_UNPAID)) |
|
|
1171 | sprintf(buf,"%s would cost you %s.", |
|
|
1172 | tmp->nrof>1?"They":"It",query_cost_string(tmp,op,F_BUY | F_SHOP)); |
|
|
1173 | else |
|
|
1174 | sprintf(buf,"You are offered %s for %s.", |
|
|
1175 | query_cost_string(tmp,op,F_SELL+F_SHOP), tmp->nrof>1?"them":"it"); |
|
|
1176 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
|
|
1177 | } |
1512 | } |
1178 | } |
1513 | |
1179 | |
1514 | if(QUERY_FLAG(tmp, FLAG_MONSTER)) |
1180 | if(QUERY_FLAG(tmp, FLAG_MONSTER)) |
1515 | examine_monster(op,tmp); |
1181 | examine_monster(op,tmp); |
1516 | |
1182 | |
1517 | /* Is this item buildable? */ |
1183 | /* Is this item buildable? */ |
1518 | if ( QUERY_FLAG( tmp, FLAG_IS_BUILDABLE ) ) |
1184 | if ( QUERY_FLAG( tmp, FLAG_IS_BUILDABLE ) ) |
1519 | new_draw_info( NDI_UNIQUE, 0, op, "This is a buildable item." ); |
1185 | new_draw_info( NDI_UNIQUE, 0, op, "This is a buildable item." ); |
1520 | |
1186 | |
… | |
… | |
1523 | */ |
1189 | */ |
1524 | if(tmp->msg && tmp->type != EXIT && tmp->type != BOOK && |
1190 | if(tmp->msg && tmp->type != EXIT && tmp->type != BOOK && |
1525 | tmp->type != CORPSE && !tmp->move_on && |
1191 | tmp->type != CORPSE && !tmp->move_on && |
1526 | strncasecmp(tmp->msg, "@match",7)) { |
1192 | strncasecmp(tmp->msg, "@match",7)) { |
1527 | |
1193 | |
1528 | /* This is just a hack so when identifying the items, we print |
1194 | /* This is just a hack so when identifying the items, we print |
1529 | * out the extra message |
1195 | * out the extra message |
1530 | */ |
1196 | */ |
1531 | if (need_identify(tmp) && QUERY_FLAG(tmp, FLAG_IDENTIFIED)) |
1197 | if (need_identify(tmp) && QUERY_FLAG(tmp, FLAG_IDENTIFIED)) |
1532 | new_draw_info(NDI_UNIQUE, 0,op, "The object has a story:"); |
1198 | new_draw_info(NDI_UNIQUE, 0,op, "The object has a story:"); |
1533 | |
1199 | |
1534 | new_draw_info(NDI_UNIQUE, 0,op,tmp->msg); |
1200 | new_draw_info(NDI_UNIQUE, 0,op,tmp->msg); |
1535 | } |
1201 | } |
1536 | new_draw_info(NDI_UNIQUE, 0,op," "); /* Blank line */ |
1202 | new_draw_info(NDI_UNIQUE, 0,op," "); /* Blank line */ |
1537 | } |
1203 | } |
1538 | |
1204 | |
1539 | /* |
1205 | /* |
… | |
… | |
1582 | if((!op||!QUERY_FLAG(op, FLAG_WIZ)) && (tmp->invisible || |
1248 | if((!op||!QUERY_FLAG(op, FLAG_WIZ)) && (tmp->invisible || |
1583 | (inv && inv->type != CONTAINER && !QUERY_FLAG(tmp, FLAG_APPLIED)))) |
1249 | (inv && inv->type != CONTAINER && !QUERY_FLAG(tmp, FLAG_APPLIED)))) |
1584 | continue; |
1250 | continue; |
1585 | if((!op || QUERY_FLAG(op, FLAG_WIZ))) |
1251 | if((!op || QUERY_FLAG(op, FLAG_WIZ))) |
1586 | new_draw_info_format(NDI_UNIQUE, 0,op ,"%s- %-*.*s (%5d) %-8s", in, length, length, |
1252 | new_draw_info_format(NDI_UNIQUE, 0,op ,"%s- %-*.*s (%5d) %-8s", in, length, length, |
1587 | query_name(tmp), tmp->count,query_weight(tmp)); |
1253 | query_name(tmp), tmp->count,query_weight(tmp)); |
1588 | else |
1254 | else |
1589 | new_draw_info_format(NDI_UNIQUE,0, op, "%s- %-*.*s %-8s", in, length+8, |
1255 | new_draw_info_format(NDI_UNIQUE,0, op, "%s- %-*.*s %-8s", in, length+8, |
1590 | length+8, query_name(tmp), |
1256 | length+8, query_name(tmp), |
1591 | query_weight(tmp)); |
1257 | query_weight(tmp)); |
1592 | } |
1258 | } |
1593 | if(!inv && op) { |
1259 | if(!inv && op) { |
1594 | new_draw_info_format(NDI_UNIQUE,0, op ,"%-*s %-8s", |
1260 | new_draw_info_format(NDI_UNIQUE,0, op ,"%-*s %-8s", |
1595 | 41,"Total weight :",query_weight(op)); |
1261 | 41,"Total weight :",query_weight(op)); |
… | |
… | |
1734 | int command_search_items (object *op, char *params) |
1400 | int command_search_items (object *op, char *params) |
1735 | { |
1401 | { |
1736 | char buf[MAX_BUF]; |
1402 | char buf[MAX_BUF]; |
1737 | |
1403 | |
1738 | if (settings.search_items == FALSE) |
1404 | if (settings.search_items == FALSE) |
1739 | return 1; |
1405 | return 1; |
1740 | |
1406 | |
1741 | if(params == NULL) { |
1407 | if(params == NULL) { |
1742 | if(op->contr->search_str[0]=='\0') { |
1408 | if(op->contr->search_str[0]=='\0') { |
1743 | new_draw_info(NDI_UNIQUE, 0,op,"Example: search magic+1"); |
1409 | new_draw_info(NDI_UNIQUE, 0,op,"Example: search magic+1"); |
1744 | new_draw_info(NDI_UNIQUE, 0,op,"Would automatically pick up all"); |
1410 | 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'."); |
1411 | new_draw_info(NDI_UNIQUE, 0,op,"items containing the word 'magic+1'."); |
1746 | return 1; |
1412 | return 1; |
1747 | } |
1413 | } |
1748 | op->contr->search_str[0]='\0'; |
1414 | op->contr->search_str[0]='\0'; |
1749 | new_draw_info(NDI_UNIQUE, 0,op,"Search mode turned off."); |
1415 | new_draw_info(NDI_UNIQUE, 0,op,"Search mode turned off."); |
1750 | fix_player(op); |
1416 | fix_player(op); |
1751 | return 1; |
1417 | return 1; |
1752 | } |
1418 | } |
1753 | if((int)strlen(params) >= MAX_BUF) { |
1419 | if((int)strlen(params) >= MAX_BUF) { |
1754 | new_draw_info(NDI_UNIQUE, 0,op,"Search string too long."); |
1420 | new_draw_info(NDI_UNIQUE, 0,op,"Search string too long."); |
1755 | return 1; |
1421 | return 1; |
1756 | } |
1422 | } |
1757 | strcpy(op->contr->search_str, params); |
1423 | strcpy(op->contr->search_str, params); |
1758 | sprintf(buf,"Searching for '%s'.",op->contr->search_str); |
1424 | sprintf(buf,"Searching for '%s'.",op->contr->search_str); |
1759 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1425 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1760 | fix_player(op); |
1426 | fix_player(op); |
… | |
… | |
1783 | /* Let's skip white spaces */ |
1449 | /* Let's skip white spaces */ |
1784 | while(' '==*params) params++; |
1450 | while(' '==*params) params++; |
1785 | |
1451 | |
1786 | /* Checking the first part */ |
1452 | /* Checking the first part */ |
1787 | if ((itemnumber = atoi(params))!=0) { |
1453 | if ((itemnumber = atoi(params))!=0) { |
1788 | for (item=op->inv; item && ((item->count != itemnumber) || item->invisible); item=item->below); |
1454 | for (item=op->inv; item && ((item->count != itemnumber) || item->invisible); item=item->below); |
1789 | if (!item) { |
1455 | if (!item) { |
1790 | new_draw_info(NDI_UNIQUE,0,op,"Tried to rename an invalid item."); |
1456 | new_draw_info(NDI_UNIQUE,0,op,"Tried to rename an invalid item."); |
1791 | return 1; |
1457 | return 1; |
1792 | } |
1458 | } |
1793 | while(isdigit(*params) || ' '==*params) params++; |
1459 | while(isdigit(*params) || ' '==*params) params++; |
1794 | } |
1460 | } |
1795 | else if ('<'==*params) { |
1461 | else if ('<'==*params) { |
1796 | /* Got old name, let's get it & find appropriate matching item */ |
1462 | /* Got old name, let's get it & find appropriate matching item */ |
1797 | closebrace=strchr(params,'>'); |
1463 | closebrace=strchr(params,'>'); |
1798 | if(!closebrace) { |
1464 | if(!closebrace) { |