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.112 by root, Sun Mar 28 16:41:45 2010 UTC vs.
Revision 1.117 by root, Tue Apr 6 21:11:48 2010 UTC

521 { 521 {
522 success = 1; 522 success = 1;
523 DIFF_MSG (flag * tmp->stats.luck, "You feel more lucky.", "You feel less lucky."); 523 DIFF_MSG (flag * tmp->stats.luck, "You feel more lucky.", "You feel less lucky.");
524 } 524 }
525 525
526 if (digest_types [tmp->type])
527 {
526 if (tmp->stats.hp && op->type == PLAYER) 528 if (tmp->stats.hp && op->type == PLAYER)
527 { 529 {
528 success = 1; 530 success = 1;
529 DIFF_MSG (flag * tmp->stats.hp, "You feel much more healthy!", "You feel much less healthy!"); 531 DIFF_MSG (flag * tmp->stats.hp, "You feel much more healthy!", "You feel much less healthy!");
530 } 532 }
531 533
532 if (tmp->stats.sp && op->type == PLAYER && tmp->type != SKILL) 534 if (tmp->stats.sp && op->type == PLAYER
533 { 535 && tmp->type != SKILL && tmp->type != BOW)
536 {
534 success = 1; 537 success = 1;
535 DIFF_MSG (flag * tmp->stats.sp, "You feel one with the powers of magic!", "You suddenly feel very mundane."); 538 DIFF_MSG (flag * tmp->stats.sp, "You feel one with the powers of magic!", "You suddenly feel very mundane.");
536 } 539 }
537 540
538 /* for the future when artifacts set this -b.t. */ 541 /* for the future when artifacts set this -b.t. */
539 if (tmp->stats.grace && op->type == PLAYER) 542 if (tmp->stats.grace && op->type == PLAYER)
540 { 543 {
541 success = 1; 544 success = 1;
542 DIFF_MSG (flag * tmp->stats.grace, "You feel closer to your god!", "You suddenly feel less holy."); 545 DIFF_MSG (flag * tmp->stats.grace, "You feel closer to your god!", "You suddenly feel less holy.");
543 } 546 }
544 547
545 if (tmp->stats.food && op->type == PLAYER) 548 if (tmp->stats.food && op->type == PLAYER)
546 { 549 {
547 success = 1; 550 success = 1;
548 DIFF_MSG (flag * tmp->stats.food, "You feel your digestion slowing down.", "You feel your digestion speeding up."); 551 DIFF_MSG (flag * tmp->stats.food, "You feel your digestion slowing down.", "You feel your digestion speeding up.");
552 }
549 } 553 }
550 554
551 /* Messages for changed resistance */ 555 /* Messages for changed resistance */
552 for (int i = 0; i < NROFATTACKS; i++) 556 for (int i = 0; i < NROFATTACKS; i++)
553 { 557 {
699 sint8 v = arch->stats.stat (i); 703 sint8 v = arch->stats.stat (i);
700 stats.stat (i) += v; 704 stats.stat (i) += v;
701 contr->orig_stats.stat (i) += v; 705 contr->orig_stats.stat (i) += v;
702 } 706 }
703} 707}
704
705/* These are the items that currently can change digestion, regeneration,
706 * spell point recovery and mana point recovery. Seems sort of an arbitary
707 * list, but other items store other info into stats array.
708 */
709static struct digest_types : std::bitset<NUM_TYPES>
710{
711 digest_types ()
712 {
713 set (WEAPON);
714 set (BOW);
715 set (ARMOUR);
716 set (HELMET);
717 set (SHIELD);
718 set (RING);
719 set (BOOTS);
720 set (GLOVES);
721 set (AMULET);
722 set (GIRDLE);
723 set (BRACERS);
724 set (CLOAK);
725 set (DISEASE);
726 set (FORCE);
727 set (SKILL);
728 }
729} digest_types;
730 708
731static struct copy_flags : object::flags_t 709static struct copy_flags : object::flags_t
732{ 710{
733 copy_flags () 711 copy_flags ()
734 { 712 {
810 path_repelled = arch->path_repelled; 788 path_repelled = arch->path_repelled;
811 path_denied = arch->path_denied; 789 path_denied = arch->path_denied;
812 glow_radius = arch->glow_radius; 790 glow_radius = arch->glow_radius;
813 move_type = arch->move_type; 791 move_type = arch->move_type;
814 792
815 object *chosen_skill = 0;
816
817 /* initializing resistances from the values in player/monster's 793 /* initializing resistances from the values in player/monster's
818 * archetype clone 794 * archetype clone
819 */ 795 */
820 memcpy (&resist, &arch->resist, sizeof (resist)); 796 memcpy (&resist, &arch->resist, sizeof (resist));
821 797
822 for (int i = 0; i < NROFATTACKS; i++) 798 for (int i = 0; i < NROFATTACKS; i++)
823 { 799 {
824 if (resist[i] > 0) 800 if (resist[i] > 0)
825 prot[i] = resist[i], vuln[i] = 0; 801 prot[i] = resist[i], vuln[i] = 0;
826 else 802 else
827 vuln[i] = -(resist[i]), prot[i] = 0; 803 vuln[i] = -resist[i], prot[i] = 0;
828 804
829 potion_resist[i] = 0; 805 potion_resist[i] = -1000;
830 } 806 }
831 807
832 wc = arch->stats.wc; 808 wc = arch->stats.wc;
833 stats.dam = arch->stats.dam; 809 stats.dam = arch->stats.dam;
834 810
847 else 823 else
848 ac = arch->stats.ac; 824 ac = arch->stats.ac;
849 825
850 stats.luck = arch->stats.luck; 826 stats.luck = arch->stats.luck;
851 speed = arch->speed; 827 speed = arch->speed;
828
829 chosen_skill = 0;
852 830
853 /* OK - we've reset most all the objects attributes to sane values. 831 /* OK - we've reset most all the objects attributes to sane values.
854 * now go through and make adjustments for what the player has equipped. 832 * now go through and make adjustments for what the player has equipped.
855 */ 833 */
856 for (tmp = inv; tmp; tmp = tmp->below) 834 for (tmp = inv; tmp; tmp = tmp->below)
900 || (tmp->type == SKILL && tmp->subtype == SK_PRAYING)) 878 || (tmp->type == SKILL && tmp->subtype == SK_PRAYING))
901 { 879 {
902 if (type == PLAYER) 880 if (type == PLAYER)
903 { 881 {
904 contr->item_power += tmp->item_power; 882 contr->item_power += tmp->item_power;
905
906 if (tmp == contr->combat_ob || tmp == contr->ranged_ob)
907 if (tmp != current_weapon
908 && (tmp->type != SKILL || tmp->subtype != SK_PRAYING)
909 && !tmp->flag [FLAG_CURSED]
910 && !tmp->flag [FLAG_DAMNED])
911 continue;
912 883
913 for (int i = 0; i < NUM_STATS; i++) 884 for (int i = 0; i < NUM_STATS; i++)
914 stat_sum [i] += tmp->stats.stat (i); 885 stat_sum [i] += tmp->stats.stat (i);
915 886
916 if (digest_types [tmp->type]) 887 if (digest_types [tmp->type])
928 if (tmp->type == WEAPON) 899 if (tmp->type == WEAPON)
929 current_weapon = tmp; 900 current_weapon = tmp;
930 } 901 }
931 902
932 /* Update slots used for items */ 903 /* Update slots used for items */
933 if (tmp->flag [FLAG_APPLIED]) 904 if (tmp->flag [FLAG_APPLIED]) // exclude praying...
934 for (int i = 0; i < NUM_BODY_LOCATIONS; i++) 905 for (int i = 0; i < NUM_BODY_LOCATIONS; i++)
935 slot[i].used += tmp->slot[i].info; 906 slot[i].used += tmp->slot[i].info;
936 907
937 if (tmp->type == SYMPTOM) 908 if (tmp->type == SYMPTOM)
938 min_it (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f); 909 min_it (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f);
942 * Resistance from potions are treated special as well. If there's 913 * Resistance from potions are treated special as well. If there's
943 * more than one potion-effect, the bigger prot.-value is taken. 914 * more than one potion-effect, the bigger prot.-value is taken.
944 */ 915 */
945 if (tmp->type == POTION_EFFECT) 916 if (tmp->type == POTION_EFFECT)
946 for (int i = 0; i < NROFATTACKS; i++) 917 for (int i = 0; i < NROFATTACKS; i++)
947 {
948 /* Potential for cursed potions, in which case we just can use
949 * a straight MAX, as potion_resist is initialised to zero.
950 // TODO: this is askign for a magic marker optimisation
951 */
952 if (potion_resist[i])
953 max_it (potion_resist[i], tmp->resist[i]); 918 max_it (potion_resist[i], tmp->resist[i]);
954 else
955 potion_resist[i] = tmp->resist[i];
956 }
957 else if (tmp->type != POTION) 919 else if (tmp->type != POTION)
958 for (int i = 0; i < NROFATTACKS; i++) 920 for (int i = 0; i < NROFATTACKS; i++)
959 if (tmp->resist[i] > 0) 921 if (tmp->resist[i] > 0)
960 prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; 922 prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100;
961 else if (tmp->resist[i] < 0) 923 else if (tmp->resist[i] < 0)
975 flag |= tmp->flag & copy_flags; 937 flag |= tmp->flag & copy_flags;
976 938
977 if (QUERY_FLAG (tmp, FLAG_UNDEAD) && !QUERY_FLAG (arch, FLAG_UNDEAD)) 939 if (QUERY_FLAG (tmp, FLAG_UNDEAD) && !QUERY_FLAG (arch, FLAG_UNDEAD))
978 SET_FLAG (this, FLAG_UNDEAD); 940 SET_FLAG (this, FLAG_UNDEAD);
979 941
942 //TODO: copy_flags?
980 if (QUERY_FLAG (tmp, FLAG_MAKE_INVIS)) 943 if (QUERY_FLAG (tmp, FLAG_MAKE_INVIS))
981 { 944 {
982 SET_FLAG (this, FLAG_MAKE_INVIS); 945 SET_FLAG (this, FLAG_MAKE_INVIS);
983 invisible = 1; 946 invisible = 1;
984 } 947 }
994 added_speed += tmp->stats.exp; 957 added_speed += tmp->stats.exp;
995 } 958 }
996 959
997 switch (tmp->type) 960 switch (tmp->type)
998 { 961 {
999 /* skills modifying the character -b.t. */
1000 /* for all skills and skill granting objects */
1001 case SKILL: 962 case SKILL:
1002 { 963 {
964 // some skills will end up here without counting as "applied"
1003 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || skill_flags [tmp->subtype] & SF_APPLY) 965 if (!tmp->flag [FLAG_APPLIED] || skill_flags [tmp->subtype] & SF_AUTARK)
1004 break; 966 break;
1005 967
1006 if (chosen_skill) 968 if (chosen_skill)
1007 { 969 {
1008 LOG (llevDebug, "fix_player, op %s has multiple skills applied (%s and %s)\n", 970 LOG (llevDebug, "fix_player, op %s has multiple skills applied (%s and %s)\n",
1010 972
1011 tmp->flag [FLAG_APPLIED] = false; 973 tmp->flag [FLAG_APPLIED] = false;
1012 update_stats (); 974 update_stats ();
1013 return; 975 return;
1014 } 976 }
1015 else 977
1016 chosen_skill = tmp; 978 chosen_skill = tmp;
1017 979
1018 if (tmp->stats.dam > 0) 980 if (tmp->stats.dam > 0)
1019 { /* skill is a 'weapon' */ 981 { /* skill is a 'weapon' */
1020 if (!QUERY_FLAG (this, FLAG_READY_WEAPON)) 982 if (!QUERY_FLAG (this, FLAG_READY_WEAPON))
1021 weapon_speed = WEAPON_SPEED (tmp); 983 weapon_speed = max (0, WEAPON_SPEED (tmp));
1022
1023 if (weapon_speed < 0)
1024 weapon_speed = 0;
1025 984
1026 weapon_weight = tmp->weight; 985 weapon_weight = tmp->weight;
1027 stats.dam += 1 + chosen_skill->level * tmp->stats.dam / 9; 986 stats.dam += 1 + chosen_skill->level * tmp->stats.dam / 9;
1028 987
1029 if (tmp->magic) 988 if (tmp->magic)
1068 break; 1027 break;
1069 1028
1070 case WAND: 1029 case WAND:
1071 case ROD: 1030 case ROD:
1072 case HORN: 1031 case HORN:
1073 case SKILL_TOOL:
1074 if (type != PLAYER)
1075 chosen_skill = find_skill_by_name (this, tmp->skill);
1076 break; 1032 break;
1077 1033
1078 case BOW: 1034 case BOW:
1079 case WEAPON: 1035 case WEAPON:
1080 if (type != PLAYER || current_weapon == tmp)
1081 {
1082 chosen_skill = find_skill_by_name (this, tmp->skill);
1083
1084 wc -= tmp->stats.wc + tmp->magic; 1036 wc -= tmp->stats.wc + tmp->magic;
1085 1037
1086 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) 1038 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0)
1087 ac -= tmp->stats.ac + tmp->magic; 1039 ac -= tmp->stats.ac + tmp->magic;
1088 1040
1089 stats.dam += tmp->stats.dam + tmp->magic; 1041 stats.dam += tmp->stats.dam + tmp->magic;
1090 weapon_weight = tmp->weight; 1042 weapon_weight = tmp->weight;
1091 weapon_speed = (WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; 1043 weapon_speed = (WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2;
1092 1044
1093 if (weapon_speed < 0) 1045 if (weapon_speed < 0)
1094 weapon_speed = 0; 1046 weapon_speed = 0;
1095 1047
1096 slaying = tmp->slaying; 1048 slaying = tmp->slaying;
1097 1049
1098 /* If there is desire that two handed weapons should do 1050 /* If there is desire that two handed weapons should do
1099 * extra strength damage, this is where the code should 1051 * extra strength damage, this is where the code should
1100 * go. 1052 * go.
1101 */ 1053 */
1102 1054
1103 if (type == PLAYER) 1055 if (type == PLAYER)
1104 if (settings.spell_encumbrance) 1056 if (settings.spell_encumbrance)
1105 contr->encumbrance += tmp->weight * 3 / 1000; 1057 contr->encumbrance += tmp->weight * 3 / 1000;
1106 }
1107 1058
1108 break; 1059 break;
1109 1060
1110 case ARMOUR: /* Only the best of these three are used: */ 1061 case ARMOUR: /* Only the best of these three are used: */
1111 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1062 if (settings.spell_encumbrance == TRUE && type == PLAYER)
1147 break; 1098 break;
1148 } /* switch tmp->type */ 1099 } /* switch tmp->type */
1149 } /* item is equipped */ 1100 } /* item is equipped */
1150 } /* for loop of items */ 1101 } /* for loop of items */
1151 1102
1152 if (type != PLAYER)
1153 this->chosen_skill = chosen_skill;
1154
1155 glow_radius = min (glow_radius, MAX_LIGHT_RADIUS); 1103 min_it (glow_radius, MAX_LIGHT_RADIUS);
1156 1104
1157 /* We've gone through all the objects the player has equipped. For many things, we 1105 /* We've gone through all the objects the player has equipped. For many things, we
1158 * have generated intermediate values which we now need to assign. 1106 * have generated intermediate values which we now need to assign.
1159 */ 1107 */
1160 1108
1166 */ 1114 */
1167 for (int i = 0; i < NROFATTACKS; i++) 1115 for (int i = 0; i < NROFATTACKS; i++)
1168 { 1116 {
1169 resist[i] = prot[i] - vuln[i]; 1117 resist[i] = prot[i] - vuln[i];
1170 1118
1171 if (potion_resist[i] && ((potion_resist[i] > resist[i]) || (potion_resist[i] < 0))) 1119 if (potion_resist[i] != -1000
1120 && (potion_resist[i] < 0 || potion_resist[i] > resist[i]))
1172 resist[i] = potion_resist[i]; 1121 resist[i] = potion_resist[i];
1173 } 1122 }
1174 1123
1175 if (type == PLAYER) 1124 if (type == PLAYER)
1176 { 1125 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines