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

Comparing deliantra/server/common/living.C (file contents):
Revision 1.50 by root, Sat May 12 18:14:47 2007 UTC vs.
Revision 1.51 by root, Sat May 12 18:23:51 2007 UTC

319 * that gives them that ability. 319 * that gives them that ability.
320 */ 320 */
321int 321int
322change_abil (object *op, object *tmp) 322change_abil (object *op, object *tmp)
323{ 323{
324 int flag = QUERY_FLAG (tmp, FLAG_APPLIED) ? 1 : -1, i, j, success = 0; 324 int flag = QUERY_FLAG (tmp, FLAG_APPLIED) ? 1 : -1, success = 0;
325 char message[MAX_BUF]; 325 char message[MAX_BUF];
326 int potion_max = 0; 326 int potion_max = 0;
327 327
328 /* remember what object was like before it was changed. note that 328 /* remember what object was like before it was changed. note that
329 * refop is a local copy of op only to be used for detecting changes 329 * refop is a local copy of op only to be used for detecting changes
334 if (op->type == PLAYER) 334 if (op->type == PLAYER)
335 { 335 {
336 if (tmp->type == POTION) 336 if (tmp->type == POTION)
337 { 337 {
338 potion_max = 1; 338 potion_max = 1;
339 for (j = 0; j < NUM_STATS; j++) 339 for (int j = 0; j < NUM_STATS; j++)
340 { 340 {
341 int nstat, ostat;
342
343 ostat = op->contr->orig_stats.stat (j); 341 int ostat = op->contr->orig_stats.stat (j);
344 i = tmp->stats.stat (j); 342 int i = tmp->stats.stat (j);
345 343
346 /* nstat is what the stat will be after use of the potion */ 344 /* nstat is what the stat will be after use of the potion */
347 nstat = flag * i + ostat; 345 int nstat = flag * i + ostat;
348 346
349 /* Do some bounds checking. While I don't think any 347 /* Do some bounds checking. While I don't think any
350 * potions do so right now, there is the potential for potions 348 * potions do so right now, there is the potential for potions
351 * that adjust that stat by more than one point, so we need 349 * that adjust that stat by more than one point, so we need
352 * to allow for that. 350 * to allow for that.
370 368
371 /* This section of code ups the characters normal stats also. I am not 369 /* This section of code ups the characters normal stats also. I am not
372 * sure if this is strictly necessary, being that fix_player probably 370 * sure if this is strictly necessary, being that fix_player probably
373 * recalculates this anyway. 371 * recalculates this anyway.
374 */ 372 */
375 for (j = 0; j < NUM_STATS; j++) 373 for (int j = 0; j < NUM_STATS; j++)
376 change_attr_value (&op->stats, j, flag * tmp->stats.stat (j)); 374 change_attr_value (&op->stats, j, flag * tmp->stats.stat (j));
377 375
378 check_stat_bounds (&op->stats); 376 check_stat_bounds (&op->stats);
379 } /* end of potion handling code */ 377 } /* end of potion handling code */
380 } 378 }
381 379
382 /* reset attributes that fix_player doesn't reset since it doesn't search 380 /* reset attributes that update_stats doesn't reset since it doesn't search
383 * everything to set 381 * everything to set
384 */ 382 */
385 if (flag == -1) 383 if (flag == -1)
386 { 384 {
387 op->attacktype &= ~tmp->attacktype; 385 op->attacktype &= ~tmp->attacktype;
393 */ 391 */
394 op->move_type &= ~tmp->move_type; 392 op->move_type &= ~tmp->move_type;
395 } 393 }
396 394
397 /* call fix_player since op object could have whatever attribute due 395 /* call fix_player since op object could have whatever attribute due
398 * to multiple items. if fix_player always has to be called after 396 * to multiple items. if update_stats always has to be called after
399 * change_ability then might as well call it from here 397 * change_ability then might as well call it from here
400 */ 398 */
401 op->update_stats (); 399 op->update_stats ();
402 400
403 /* Fix player won't add the bows ability to the player, so don't 401 /* update_stats won't add the bows ability to the player, so don't
404 * print out message if this is a bow. 402 * print out message if this is a bow.
405 */ 403 */
406 if (tmp->attacktype & AT_CONFUSION && tmp->type != BOW) 404 if (tmp->attacktype & AT_CONFUSION && tmp->type != BOW)
407 { 405 {
408 success = 1; 406 success = 1;
448 if (tmp->move_type & MOVE_FLY_HIGH) 446 if (tmp->move_type & MOVE_FLY_HIGH)
449 { 447 {
450 /* double conditional - second case covers if you have move_fly_low - 448 /* double conditional - second case covers if you have move_fly_low -
451 * in that case, you don't actually land 449 * in that case, you don't actually land
452 */ 450 */
453 DIFF_MSG (flag, "You soar into the air air!.", 451 DIFF_MSG (flag, "You soar into the air!",
454 (op->move_type & MOVE_FLY_LOW ? "You fly lower in the air" : "You float down to the ground.")); 452 (op->move_type & MOVE_FLY_LOW ? "You fly lower in the air" : "You float down to the ground."));
455 } 453 }
456 454
457 if (tmp->move_type & MOVE_SWIM) 455 if (tmp->move_type & MOVE_SWIM)
458 DIFF_MSG (flag, "You feel ready for a swim", "You no longer feel like swimming"); 456 DIFF_MSG (flag, "You feel ready for a swim", "You no longer feel like swimming");
589 success = 1; 587 success = 1;
590 DIFF_MSG (flag * tmp->stats.food, "You feel your digestion slowing down.", "You feel your digestion speeding up."); 588 DIFF_MSG (flag * tmp->stats.food, "You feel your digestion slowing down.", "You feel your digestion speeding up.");
591 } 589 }
592 590
593 /* Messages for changed resistance */ 591 /* Messages for changed resistance */
594 for (i = 0; i < NROFATTACKS; i++) 592 for (int i = 0; i < NROFATTACKS; i++)
595 { 593 {
596 if (i == ATNR_PHYSICAL) 594 if (i == ATNR_PHYSICAL)
597 continue; /* Don't display about armour */ 595 continue; /* Don't display about armour */
598 596
599 if (op->resist[i] != refop.resist[i]) 597 if (op->resist[i] != refop.resist[i])
608 } 606 }
609 } 607 }
610 608
611 if (!potion_max) 609 if (!potion_max)
612 { 610 {
613 for (j = 0; j < NUM_STATS; j++) 611 for (int j = 0; j < NUM_STATS; j++)
614 { 612 {
615 if ((i = tmp->stats.stat (j))) 613 if (int i = tmp->stats.stat (j))
616 { 614 {
617 success = 1; 615 success = 1;
618 DIFF_MSG (i * flag, gain_msg[j], lose_msg[j]); 616 DIFF_MSG (i * flag, gain_msg[j], lose_msg[j]);
619 } 617 }
620 } 618 }
723 * Subtracts stat-bonuses given by the class which the player has chosen. 721 * Subtracts stat-bonuses given by the class which the player has chosen.
724 */ 722 */
725void 723void
726object::remove_statbonus () 724object::remove_statbonus ()
727{ 725{
728 stats.Str -= arch->clone.stats.Str; 726 for (int i = 0; i < NUM_STATS; ++i)
729 stats.Dex -= arch->clone.stats.Dex; 727 {
730 stats.Con -= arch->clone.stats.Con; 728 sint8 v = arch->clone.stats.stat (i);
731 stats.Wis -= arch->clone.stats.Wis; 729 stats.stat (i) -= v;
732 stats.Pow -= arch->clone.stats.Pow; 730 contr->orig_stats.stat (i) -= v;
733 stats.Cha -= arch->clone.stats.Cha; 731 }
734 stats.Int -= arch->clone.stats.Int;
735
736 contr->orig_stats.Str -= arch->clone.stats.Str;
737 contr->orig_stats.Dex -= arch->clone.stats.Dex;
738 contr->orig_stats.Con -= arch->clone.stats.Con;
739 contr->orig_stats.Wis -= arch->clone.stats.Wis;
740 contr->orig_stats.Pow -= arch->clone.stats.Pow;
741 contr->orig_stats.Cha -= arch->clone.stats.Cha;
742 contr->orig_stats.Int -= arch->clone.stats.Int;
743} 732}
744 733
745/* 734/*
746 * Adds stat-bonuses given by the class which the player has chosen. 735 * Adds stat-bonuses given by the class which the player has chosen.
747 */ 736 */
748void 737void
749object::add_statbonus () 738object::add_statbonus ()
750{ 739{
751 stats.Str += arch->clone.stats.Str; 740 for (int i = 0; i < NUM_STATS; ++i)
752 stats.Dex += arch->clone.stats.Dex; 741 {
753 stats.Con += arch->clone.stats.Con; 742 sint8 v = arch->clone.stats.stat (i);
754 stats.Wis += arch->clone.stats.Wis; 743 stats.stat (i) += v;
755 stats.Pow += arch->clone.stats.Pow; 744 contr->orig_stats.stat (i) += v;
756 stats.Cha += arch->clone.stats.Cha; 745 }
757 stats.Int += arch->clone.stats.Int;
758
759 contr->orig_stats.Str += arch->clone.stats.Str;
760 contr->orig_stats.Dex += arch->clone.stats.Dex;
761 contr->orig_stats.Con += arch->clone.stats.Con;
762 contr->orig_stats.Wis += arch->clone.stats.Wis;
763 contr->orig_stats.Pow += arch->clone.stats.Pow;
764 contr->orig_stats.Cha += arch->clone.stats.Cha;
765 contr->orig_stats.Int += arch->clone.stats.Int;
766} 746}
767 747
768/* 748/*
769 * Updates all abilities given by applied objects in the inventory 749 * Updates all abilities given by applied objects in the inventory
770 * of the given object. Note: This function works for both monsters 750 * of the given object. Note: This function works for both monsters

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines