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

Comparing deliantra/server/common/object.C (file contents):
Revision 1.146 by root, Fri May 11 21:07:13 2007 UTC vs.
Revision 1.151 by root, Wed May 16 11:10:01 2007 UTC

450 owner = owner->owner; 450 owner = owner->owner;
451 451
452 this->owner = owner; 452 this->owner = owner;
453} 453}
454 454
455void 455int
456object::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
472bool
456object::set_weapon (object *ob) 473object::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 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines