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.112 by root, Sun Mar 28 16:41:45 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));
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 { 947 {
951 /* Potential for cursed potions, in which case we just can use 948 /* Potential for cursed potions, in which case we just can use
952 * a straight MAX, as potion_resist is initialised to zero. 949 * a straight MAX, as potion_resist is initialised to zero.
950 // TODO: this is askign for a magic marker optimisation
953 */ 951 */
954 if (tmp->type == POTION_EFFECT)
955 {
956 if (potion_resist[i]) 952 if (potion_resist[i])
957 potion_resist[i] = max (potion_resist[i], tmp->resist[i]); 953 max_it (potion_resist[i], tmp->resist[i]);
958 else 954 else
959 potion_resist[i] = tmp->resist[i]; 955 potion_resist[i] = tmp->resist[i];
960 } 956 }
957 else if (tmp->type != POTION)
958 for (int i = 0; i < NROFATTACKS; i++)
961 else if (tmp->resist[i] > 0) 959 if (tmp->resist[i] > 0)
962 prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; 960 prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100;
963 else if (tmp->resist[i] < 0) 961 else if (tmp->resist[i] < 0)
964 vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; 962 vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100;
965 }
966 }
967 963
968 /* There may be other things that should not adjust the attacktype */ 964 /* There may be other things that should not adjust the attacktype */
969 if (tmp->type != SYMPTOM) 965 if (tmp->type != SYMPTOM)
970 { 966 {
971 attacktype |= tmp->attacktype; 967 attacktype |= tmp->attacktype;
998 added_speed += tmp->stats.exp; 994 added_speed += tmp->stats.exp;
999 } 995 }
1000 996
1001 switch (tmp->type) 997 switch (tmp->type)
1002 { 998 {
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. */ 999 /* skills modifying the character -b.t. */
1013 /* for all skills and skill granting objects */ 1000 /* for all skills and skill granting objects */
1014 case SKILL: 1001 case SKILL:
1015 { 1002 {
1016 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || skill_flags [tmp->subtype] & SF_APPLY) 1003 if (!QUERY_FLAG (tmp, FLAG_APPLIED) || skill_flags [tmp->subtype] & SF_APPLY)
1051 1038
1052 if (tmp->stats.ac) 1039 if (tmp->stats.ac)
1053 ac -= tmp->stats.ac + tmp->magic; 1040 ac -= tmp->stats.ac + tmp->magic;
1054 1041
1055 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1042 if (settings.spell_encumbrance == TRUE && type == PLAYER)
1056 contr->encumbrance += (int) 3 *tmp->weight / 1000; 1043 contr->encumbrance += 3 * tmp->weight / 1000;
1057 } 1044 }
1058 1045
1059 break; 1046 break;
1060 1047
1061 case SHIELD: 1048 case SHIELD:
1062 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1049 if (settings.spell_encumbrance == TRUE && type == PLAYER)
1063 contr->encumbrance += (int) tmp->weight / 2000; 1050 contr->encumbrance += tmp->weight / 2000;
1051 //FALLTHROUGH
1064 case RING: 1052 case RING:
1065 case AMULET: 1053 case AMULET:
1066 case GIRDLE: 1054 case GIRDLE:
1067 case HELMET: 1055 case HELMET:
1068 case BOOTS: 1056 case BOOTS:
1077 if (tmp->stats.ac) 1065 if (tmp->stats.ac)
1078 ac -= tmp->stats.ac + tmp->magic; 1066 ac -= tmp->stats.ac + tmp->magic;
1079 1067
1080 break; 1068 break;
1081 1069
1070 case WAND:
1071 case ROD:
1072 case HORN:
1073 case SKILL_TOOL:
1074 if (type != PLAYER)
1075 chosen_skill = find_skill_by_name (this, tmp->skill);
1076 break;
1077
1082 case BOW: 1078 case BOW:
1083 case WEAPON: 1079 case WEAPON:
1084 if (type != PLAYER || current_weapon == tmp) 1080 if (type != PLAYER || current_weapon == tmp)
1085 { 1081 {
1082 chosen_skill = find_skill_by_name (this, tmp->skill);
1083
1086 wc -= tmp->stats.wc + tmp->magic; 1084 wc -= tmp->stats.wc + tmp->magic;
1087 1085
1088 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) 1086 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0)
1089 ac -= tmp->stats.ac + tmp->magic; 1087 ac -= tmp->stats.ac + tmp->magic;
1090 1088
1148 1146
1149 break; 1147 break;
1150 } /* switch tmp->type */ 1148 } /* switch tmp->type */
1151 } /* item is equipped */ 1149 } /* item is equipped */
1152 } /* for loop of items */ 1150 } /* for loop of items */
1151
1152 if (type != PLAYER)
1153 this->chosen_skill = chosen_skill;
1153 1154
1154 glow_radius = min (glow_radius, MAX_LIGHT_RADIUS); 1155 glow_radius = min (glow_radius, MAX_LIGHT_RADIUS);
1155 1156
1156 /* We've gone through all the objects the player has equipped. For many things, we 1157 /* 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. 1158 * have generated intermediate values which we now need to assign.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines