… | |
… | |
313 | |
313 | |
314 | /* Everything passes, must be OK. */ |
314 | /* Everything passes, must be OK. */ |
315 | return 1; |
315 | return 1; |
316 | } |
316 | } |
317 | |
317 | |
318 | void |
|
|
319 | player::set_range (rangetype r) |
|
|
320 | { |
|
|
321 | shoottype = r; |
|
|
322 | } |
|
|
323 | |
|
|
324 | /* |
318 | /* |
325 | * sum_weight() is a recursive function which calculates the weight |
319 | * sum_weight() is a recursive function which calculates the weight |
326 | * an object is carrying. It goes through in figures out how much |
320 | * an object is carrying. It goes through in figures out how much |
327 | * containers are carrying, and sums it up. |
321 | * containers are carrying, and sums it up. |
328 | */ |
322 | */ |
… | |
… | |
330 | sum_weight (object *op) |
324 | sum_weight (object *op) |
331 | { |
325 | { |
332 | long sum; |
326 | long sum; |
333 | object *inv; |
327 | object *inv; |
334 | |
328 | |
335 | for (sum = 0, inv = op->inv; inv != NULL; inv = inv->below) |
329 | for (sum = 0, inv = op->inv; inv; inv = inv->below) |
336 | { |
330 | { |
337 | if (inv->inv) |
331 | if (inv->inv) |
338 | sum_weight (inv); |
332 | sum_weight (inv); |
|
|
333 | |
339 | sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1); |
334 | sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1); |
340 | } |
335 | } |
341 | |
336 | |
342 | if (op->type == CONTAINER && op->stats.Str) |
337 | if (op->type == CONTAINER && op->stats.Str) |
343 | sum = (sum * (100 - op->stats.Str)) / 100; |
338 | sum = (sum * (100 - op->stats.Str)) / 100; |
… | |
… | |
452 | */ |
447 | */ |
453 | while (owner->owner) |
448 | while (owner->owner) |
454 | owner = owner->owner; |
449 | owner = owner->owner; |
455 | |
450 | |
456 | this->owner = owner; |
451 | this->owner = owner; |
|
|
452 | } |
|
|
453 | |
|
|
454 | void |
|
|
455 | object::set_weapon (object *ob) |
|
|
456 | { |
|
|
457 | if (current_weapon == ob) |
|
|
458 | return; |
|
|
459 | |
|
|
460 | current_weapon = ob; |
|
|
461 | new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name); |
|
|
462 | update_stats (); |
457 | } |
463 | } |
458 | |
464 | |
459 | /* Zero the key_values on op, decrementing the shared-string |
465 | /* Zero the key_values on op, decrementing the shared-string |
460 | * refcounts and freeing the links. |
466 | * refcounts and freeing the links. |
461 | */ |
467 | */ |
… | |
… | |
543 | * need for monsters, but doesn't hurt to do it for everything. |
549 | * need for monsters, but doesn't hurt to do it for everything. |
544 | * by doing so, when a monster is created, it has good starting |
550 | * by doing so, when a monster is created, it has good starting |
545 | * values for the body_used info, so when items are created |
551 | * values for the body_used info, so when items are created |
546 | * for it, they can be properly equipped. |
552 | * for it, they can be properly equipped. |
547 | */ |
553 | */ |
548 | memcpy (body_used, body_info, sizeof (body_used)); |
554 | for (int i = NUM_BODY_LOCATIONS; i--; ) |
|
|
555 | slot[i].used = slot[i].info; |
549 | |
556 | |
550 | attachable::instantiate (); |
557 | attachable::instantiate (); |
551 | } |
558 | } |
552 | |
559 | |
553 | object * |
560 | object * |
… | |
… | |
2589 | } |
2596 | } |
2590 | |
2597 | |
2591 | const char * |
2598 | const char * |
2592 | object::debug_desc () const |
2599 | object::debug_desc () const |
2593 | { |
2600 | { |
2594 | static char info[256 * 4]; |
2601 | static char info[3][256 * 4]; |
|
|
2602 | static int info_idx; |
|
|
2603 | |
2595 | return debug_desc (info); |
2604 | return debug_desc (info [++info_idx % 3]); |
2596 | } |
|
|
2597 | |
|
|
2598 | const char * |
|
|
2599 | object::debug_desc2 () const |
|
|
2600 | { |
|
|
2601 | static char info[256 * 4]; |
|
|
2602 | return debug_desc (info); |
|
|
2603 | } |
2605 | } |
2604 | |
2606 | |
2605 | struct region * |
2607 | struct region * |
2606 | object::region () const |
2608 | object::region () const |
2607 | { |
2609 | { |