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.107 by root, Fri Mar 26 00:05:45 2010 UTC vs.
Revision 1.114 by root, Sun Mar 28 18:44:21 2010 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
810 path_repelled = arch->path_repelled; 810 path_repelled = arch->path_repelled;
811 path_denied = arch->path_denied; 811 path_denied = arch->path_denied;
812 glow_radius = arch->glow_radius; 812 glow_radius = arch->glow_radius;
813 move_type = arch->move_type; 813 move_type = arch->move_type;
814 814
815 chosen_skill = 0; 815 object *chosen_skill = 0;
816 816
817 /* initializing resistances from the values in player/monster's 817 /* initializing resistances from the values in player/monster's
818 * archetype clone 818 * archetype clone
819 */ 819 */
820 memcpy (&resist, &arch->resist, sizeof (resist)); 820 memcpy (&resist, &arch->resist, sizeof (resist));
821 821
822 for (int i = 0; i < NROFATTACKS; i++) 822 for (int i = 0; i < NROFATTACKS; i++)
823 { 823 {
824 if (resist[i] > 0) 824 if (resist[i] > 0)
825 prot[i] = resist[i], vuln[i] = 0; 825 prot[i] = resist[i], vuln[i] = 0;
826 else 826 else
827 vuln[i] = -(resist[i]), prot[i] = 0; 827 vuln[i] = -resist[i], prot[i] = 0;
828 828
829 potion_resist[i] = 0; 829 potion_resist[i] = -1000;
830 } 830 }
831 831
832 wc = arch->stats.wc; 832 wc = arch->stats.wc;
833 stats.dam = arch->stats.dam; 833 stats.dam = arch->stats.dam;
834 834
895 * up, etc. 895 * up, etc.
896 */ 896 */
897 if ((tmp->flag [FLAG_APPLIED] 897 if ((tmp->flag [FLAG_APPLIED]
898 && tmp->type != CONTAINER 898 && tmp->type != CONTAINER
899 && tmp->type != CLOSE_CON) 899 && tmp->type != CLOSE_CON)
900 || (tmp->type == SKILL
901 && tmp->subtype == SK_PRAYING)) 900 || (tmp->type == SKILL && tmp->subtype == SK_PRAYING))
902 { 901 {
903 if (type == PLAYER) 902 if (type == PLAYER)
904 { 903 {
905 contr->item_power += tmp->item_power; 904 contr->item_power += tmp->item_power;
906 905
929 if (tmp->type == WEAPON) 928 if (tmp->type == WEAPON)
930 current_weapon = tmp; 929 current_weapon = tmp;
931 } 930 }
932 931
933 /* Update slots used for items */ 932 /* Update slots used for items */
934 if (QUERY_FLAG (tmp, FLAG_APPLIED)) 933 if (tmp->flag [FLAG_APPLIED])
935 for (int i = 0; i < NUM_BODY_LOCATIONS; i++) 934 for (int i = 0; i < NUM_BODY_LOCATIONS; i++)
936 slot[i].used += tmp->slot[i].info; 935 slot[i].used += tmp->slot[i].info;
937 936
938 if (tmp->type == SYMPTOM) 937 if (tmp->type == SYMPTOM)
939 speed_reduce_from_disease =
940 min (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f); 938 min_it (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f);
941 939
942 /* Pos. and neg. protections are counted separate (-> pro/vuln). 940 /* Pos. and neg. protections are counted separate (-> pro/vuln).
943 * (Negative protections are calculated exactly like positive.) 941 * (Negative protections are calculated exactly like positive.)
944 * Resistance from potions are treated special as well. If there's 942 * Resistance from potions are treated special as well. If there's
945 * more than one potion-effect, the bigger prot.-value is taken. 943 * more than one potion-effect, the bigger prot.-value is taken.
946 */ 944 */
947 if (tmp->type != POTION) 945 if (tmp->type == POTION_EFFECT)
948 {
949 for (int i = 0; i < NROFATTACKS; i++) 946 for (int i = 0; i < NROFATTACKS; i++)
950 {
951 /* Potential for cursed potions, in which case we just can use
952 * a straight MAX, as potion_resist is initialised to zero.
953 */
954 if (tmp->type == POTION_EFFECT)
955 {
956 if (potion_resist[i])
957 potion_resist[i] = max (potion_resist[i], tmp->resist[i]);
958 else
959 potion_resist[i] = tmp->resist[i]; 947 max_it (potion_resist[i], tmp->resist[i]);
960 } 948 else if (tmp->type != POTION)
949 for (int i = 0; i < NROFATTACKS; i++)
961 else if (tmp->resist[i] > 0) 950 if (tmp->resist[i] > 0)
962 prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; 951 prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100;
963 else if (tmp->resist[i] < 0) 952 else if (tmp->resist[i] < 0)
964 vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; 953 vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100;
965 }
966 }
967 954
968 /* There may be other things that should not adjust the attacktype */ 955 /* There may be other things that should not adjust the attacktype */
969 if (tmp->type != SYMPTOM) 956 if (tmp->type != SYMPTOM)
970 { 957 {
971 attacktype |= tmp->attacktype; 958 attacktype |= tmp->attacktype;
998 added_speed += tmp->stats.exp; 985 added_speed += tmp->stats.exp;
999 } 986 }
1000 987
1001 switch (tmp->type) 988 switch (tmp->type)
1002 { 989 {
1003#if 0
1004 case WAND:
1005 case ROD:
1006 case HORN:
1007 if (type != PLAYER || current_weapon == tmp)
1008 chosen_skill = tmp;
1009 break;
1010#endif
1011
1012 /* skills modifying the character -b.t. */ 990 /* skills modifying the character -b.t. */
1013 /* for all skills and skill granting objects */ 991 /* for all skills and skill granting objects */
1014 case SKILL: 992 case SKILL:
1015 { 993 {
1016 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || skill_flags [tmp->subtype] & SF_APPLY) 994 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || skill_flags [tmp->subtype] & SF_APPLY)
1051 1029
1052 if (tmp->stats.ac) 1030 if (tmp->stats.ac)
1053 ac -= tmp->stats.ac + tmp->magic; 1031 ac -= tmp->stats.ac + tmp->magic;
1054 1032
1055 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1033 if (settings.spell_encumbrance == TRUE && type == PLAYER)
1056 contr->encumbrance += (int) 3 *tmp->weight / 1000; 1034 contr->encumbrance += 3 * tmp->weight / 1000;
1057 } 1035 }
1058 1036
1059 break; 1037 break;
1060 1038
1061 case SHIELD: 1039 case SHIELD:
1062 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1040 if (settings.spell_encumbrance == TRUE && type == PLAYER)
1063 contr->encumbrance += (int) tmp->weight / 2000; 1041 contr->encumbrance += tmp->weight / 2000;
1042 //FALLTHROUGH
1064 case RING: 1043 case RING:
1065 case AMULET: 1044 case AMULET:
1066 case GIRDLE: 1045 case GIRDLE:
1067 case HELMET: 1046 case HELMET:
1068 case BOOTS: 1047 case BOOTS:
1077 if (tmp->stats.ac) 1056 if (tmp->stats.ac)
1078 ac -= tmp->stats.ac + tmp->magic; 1057 ac -= tmp->stats.ac + tmp->magic;
1079 1058
1080 break; 1059 break;
1081 1060
1061 case WAND:
1062 case ROD:
1063 case HORN:
1064 case SKILL_TOOL:
1065 if (type != PLAYER)
1066 chosen_skill = find_skill_by_name (this, tmp->skill);
1067 break;
1068
1082 case BOW: 1069 case BOW:
1083 case WEAPON: 1070 case WEAPON:
1084 if (type != PLAYER || current_weapon == tmp) 1071 if (type != PLAYER || current_weapon == tmp)
1085 { 1072 {
1073 chosen_skill = find_skill_by_name (this, tmp->skill);
1074
1086 wc -= tmp->stats.wc + tmp->magic; 1075 wc -= tmp->stats.wc + tmp->magic;
1087 1076
1088 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) 1077 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0)
1089 ac -= tmp->stats.ac + tmp->magic; 1078 ac -= tmp->stats.ac + tmp->magic;
1090 1079
1149 break; 1138 break;
1150 } /* switch tmp->type */ 1139 } /* switch tmp->type */
1151 } /* item is equipped */ 1140 } /* item is equipped */
1152 } /* for loop of items */ 1141 } /* for loop of items */
1153 1142
1143 if (type != PLAYER)
1144 this->chosen_skill = chosen_skill;
1145
1154 glow_radius = min (glow_radius, MAX_LIGHT_RADIUS); 1146 min_it (glow_radius, MAX_LIGHT_RADIUS);
1155 1147
1156 /* We've gone through all the objects the player has equipped. For many things, we 1148 /* We've gone through all the objects the player has equipped. For many things, we
1157 * have generated intermediate values which we now need to assign. 1149 * have generated intermediate values which we now need to assign.
1158 */ 1150 */
1159 1151
1165 */ 1157 */
1166 for (int i = 0; i < NROFATTACKS; i++) 1158 for (int i = 0; i < NROFATTACKS; i++)
1167 { 1159 {
1168 resist[i] = prot[i] - vuln[i]; 1160 resist[i] = prot[i] - vuln[i];
1169 1161
1170 if (potion_resist[i] && ((potion_resist[i] > resist[i]) || (potion_resist[i] < 0))) 1162 if (potion_resist[i] != -1000
1163 && (potion_resist[i] < 0 || potion_resist[i] > resist[i]))
1171 resist[i] = potion_resist[i]; 1164 resist[i] = potion_resist[i];
1172 } 1165 }
1173 1166
1174 if (type == PLAYER) 1167 if (type == PLAYER)
1175 { 1168 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines