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.144 by root, Thu May 3 10:39:46 2007 UTC vs.
Revision 1.147 by root, Sat May 12 16:06:42 2007 UTC

29#include <stdio.h> 29#include <stdio.h>
30#include <sys/types.h> 30#include <sys/types.h>
31#include <sys/uio.h> 31#include <sys/uio.h>
32#include <object.h> 32#include <object.h>
33#include <funcpoint.h> 33#include <funcpoint.h>
34#include <sproto.h>
34#include <loader.h> 35#include <loader.h>
35 36
36#include <bitset> 37#include <bitset>
37 38
38int nrofallocobjects = 0; 39int nrofallocobjects = 0;
449 owner = owner->owner; 450 owner = owner->owner;
450 451
451 this->owner = owner; 452 this->owner = owner;
452} 453}
453 454
454void 455bool
455object::set_weapon (object *ob) 456object::change_weapon (object *ob)
456{ 457{
457 if (current_weapon == ob) 458 if (current_weapon == ob)
458 return; 459 return true;
460
461 if (chosen_skill)
462 chosen_skill->flag [FLAG_APPLIED] = false;
459 463
460 current_weapon = ob; 464 current_weapon = ob;
461 new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name); 465 chosen_skill = !ob || ob->type == SKILL ? ob : find_skill_by_name (this, ob->skill);
466
467 if (chosen_skill)
468 chosen_skill->flag [FLAG_APPLIED] = true;
469
462 update_stats (); 470 update_stats ();
471
472 if (ob)
473 {
474 // now check wether any body locations became invalid, in which case
475 // we cannot apply the weapon at the moment.
476 for (int i = 0; i < NUM_BODY_LOCATIONS; ++i)
477 if (slot[i].used < 0)
478 {
479 current_weapon = chosen_skill = 0;
480 update_stats ();
481
482 new_draw_info_format (NDI_UNIQUE, 0, this,
483 "You try to balance your applied items all at once, but the %s is too much. "
484 "You need to unapply some items first.", &ob->name);
485 return false;
486 }
487
488 new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name);
489 }
490 else
491 new_draw_info_format (NDI_UNIQUE, 0, this, "You unwield your weapons.");
492
493 return true;
463} 494}
464 495
465/* Zero the key_values on op, decrementing the shared-string 496/* Zero the key_values on op, decrementing the shared-string
466 * refcounts and freeing the links. 497 * refcounts and freeing the links.
467 */ 498 */
549 * need for monsters, but doesn't hurt to do it for everything. 580 * need for monsters, but doesn't hurt to do it for everything.
550 * by doing so, when a monster is created, it has good starting 581 * by doing so, when a monster is created, it has good starting
551 * values for the body_used info, so when items are created 582 * values for the body_used info, so when items are created
552 * for it, they can be properly equipped. 583 * for it, they can be properly equipped.
553 */ 584 */
554 memcpy (body_used, body_info, sizeof (body_used)); 585 for (int i = NUM_BODY_LOCATIONS; i--; )
586 slot[i].used = slot[i].info;
555 587
556 attachable::instantiate (); 588 attachable::instantiate ();
557} 589}
558 590
559object * 591object *

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines