… | |
… | |
450 | owner = owner->owner; |
450 | owner = owner->owner; |
451 | |
451 | |
452 | this->owner = owner; |
452 | this->owner = owner; |
453 | } |
453 | } |
454 | |
454 | |
455 | void |
455 | int |
|
|
456 | object::slottype () const |
|
|
457 | { |
|
|
458 | if (type == SKILL) |
|
|
459 | { |
|
|
460 | if (IS_COMBAT_SKILL (subtype)) return slot_combat; |
|
|
461 | if (IS_RANGED_SKILL (subtype)) return slot_ranged; |
|
|
462 | } |
|
|
463 | else |
|
|
464 | { |
|
|
465 | if (slot [body_combat].info) return slot_combat; |
|
|
466 | if (slot [body_range ].info) return slot_ranged; |
|
|
467 | } |
|
|
468 | |
|
|
469 | return slot_none; |
|
|
470 | } |
|
|
471 | |
|
|
472 | bool |
456 | object::set_weapon (object *ob) |
473 | object::change_weapon (object *ob) |
457 | { |
474 | { |
458 | if (current_weapon == ob) |
475 | if (current_weapon == ob) |
459 | return; |
476 | return true; |
460 | |
|
|
461 | new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name); |
|
|
462 | |
477 | |
463 | if (chosen_skill) |
478 | if (chosen_skill) |
464 | chosen_skill->flag [FLAG_APPLIED] = false; |
479 | chosen_skill->flag [FLAG_APPLIED] = false; |
465 | |
480 | |
466 | current_weapon = ob; |
481 | current_weapon = ob; |
467 | chosen_skill = ob->type == SKILL ? ob : find_skill_by_name (this, ob->skill); |
482 | chosen_skill = !ob || ob->type == SKILL ? ob : find_skill_by_name (this, ob->skill); |
468 | |
483 | |
469 | if (chosen_skill) |
484 | if (chosen_skill) |
470 | chosen_skill->flag [FLAG_APPLIED] = true; |
485 | chosen_skill->flag [FLAG_APPLIED] = true; |
471 | |
486 | |
472 | update_stats (); |
487 | update_stats (); |
|
|
488 | |
|
|
489 | if (ob) |
|
|
490 | { |
|
|
491 | // now check wether any body locations became invalid, in which case |
|
|
492 | // we cannot apply the weapon at the moment. |
|
|
493 | for (int i = 0; i < NUM_BODY_LOCATIONS; ++i) |
|
|
494 | if (slot[i].used < 0) |
|
|
495 | { |
|
|
496 | current_weapon = chosen_skill = 0; |
|
|
497 | update_stats (); |
|
|
498 | |
|
|
499 | new_draw_info_format (NDI_UNIQUE, 0, this, |
|
|
500 | "You try to balance your applied items all at once, but the %s is too much. " |
|
|
501 | "You need to unapply some items first.", &ob->name); |
|
|
502 | return false; |
|
|
503 | } |
|
|
504 | |
|
|
505 | //new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name); |
|
|
506 | } |
|
|
507 | else |
|
|
508 | ;//new_draw_info_format (NDI_UNIQUE, 0, this, "You unwield your weapons."); |
|
|
509 | |
|
|
510 | if (ob && !ob->flag [FLAG_APPLIED] && ob->type != SPELL) |
|
|
511 | { |
|
|
512 | LOG (llevError | logBacktrace, "%s changed to unapplied weapon %s", |
|
|
513 | &name, ob->debug_desc ()); |
|
|
514 | return false; |
|
|
515 | } |
|
|
516 | |
|
|
517 | return true; |
473 | } |
518 | } |
474 | |
519 | |
475 | /* Zero the key_values on op, decrementing the shared-string |
520 | /* Zero the key_values on op, decrementing the shared-string |
476 | * refcounts and freeing the links. |
521 | * refcounts and freeing the links. |
477 | */ |
522 | */ |
… | |
… | |
1622 | return op; |
1667 | return op; |
1623 | } |
1668 | } |
1624 | |
1669 | |
1625 | if (where->head) |
1670 | if (where->head) |
1626 | { |
1671 | { |
1627 | LOG (llevDebug, "Warning: Tried to insert object into wrong part of multipart object.\n"); |
1672 | LOG (llevError | logBacktrace, "Warning: Tried to insert object into wrong part of multipart object.\n"); |
1628 | where = where->head; |
1673 | where = where->head; |
1629 | } |
1674 | } |
1630 | |
1675 | |
1631 | return where->insert (op); |
1676 | return where->insert (op); |
1632 | } |
1677 | } |
… | |
… | |
1960 | for (object *tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2005 | for (object *tmp = op->inv; tmp != NULL; tmp = tmp->below) |
1961 | { |
2006 | { |
1962 | CLEAR_FLAG (tmp, flag); |
2007 | CLEAR_FLAG (tmp, flag); |
1963 | unflag_inv (tmp, flag); |
2008 | unflag_inv (tmp, flag); |
1964 | } |
2009 | } |
1965 | } |
|
|
1966 | |
|
|
1967 | /* |
|
|
1968 | * set_cheat(object) sets the cheat flag (WAS_WIZ) in the object and in |
|
|
1969 | * all it's inventory (recursively). |
|
|
1970 | * If checksums are used, a player will get set_cheat called for |
|
|
1971 | * him/her-self and all object carried by a call to this function. |
|
|
1972 | */ |
|
|
1973 | void |
|
|
1974 | set_cheat (object *op) |
|
|
1975 | { |
|
|
1976 | SET_FLAG (op, FLAG_WAS_WIZ); |
|
|
1977 | flag_inv (op, FLAG_WAS_WIZ); |
|
|
1978 | } |
2010 | } |
1979 | |
2011 | |
1980 | /* |
2012 | /* |
1981 | * find_free_spot(object, map, x, y, start, stop) will search for |
2013 | * find_free_spot(object, map, x, y, start, stop) will search for |
1982 | * a spot at the given map and coordinates which will be able to contain |
2014 | * a spot at the given map and coordinates which will be able to contain |