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.9 by root, Sun Sep 10 16:00:23 2006 UTC vs.
Revision 1.13 by pippijn, Mon Dec 4 17:48:35 2006 UTC

1
2/*
3 * static char *rcsid_living_c =
4 * "$Id: living.C,v 1.9 2006/09/10 16:00:23 root Exp $";
5 */
6
7/* 1/*
8 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
9 3
10 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen 5 Copyright (C) 1992 Frank Tore Johansen
22 16
23 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 20
27 The authors can be reached via e-mail at crossfire-devel@real-time.com 21 The authors can be reached via e-mail at <crossfire@schmorp.de>
28*/ 22*/
29 23
30#include <global.h> 24#include <global.h>
31#include <funcpoint.h> 25#include <funcpoint.h>
32 26
164 * -b.t. 158 * -b.t.
165 */ 159 */
166 160
167#define MAX_EXP_IN_OBJ levels[settings.max_level]/(MAX_EXP_CAT - 1) 161#define MAX_EXP_IN_OBJ levels[settings.max_level]/(MAX_EXP_CAT - 1)
168 162
169#ifndef WIN32
170extern uint64 *levels;
171#else
172extern sint64 *levels; 163extern sint64 *levels;
173#endif
174 164
175#define MAX_SAVE_LEVEL 110 165#define MAX_SAVE_LEVEL 110
176 166
177/* This no longer needs to be changed anytime the number of 167/* This no longer needs to be changed anytime the number of
178 * levels is increased - rather, did_make_save will do the 168 * levels is increased - rather, did_make_save will do the
251void 241void
252set_attr_value (living * stats, int attr, sint8 value) 242set_attr_value (living * stats, int attr, sint8 value)
253{ 243{
254 switch (attr) 244 switch (attr)
255 { 245 {
256 case STR: 246 case STR:
257 stats->Str = value; 247 stats->Str = value;
258 break; 248 break;
259 case DEX: 249 case DEX:
260 stats->Dex = value; 250 stats->Dex = value;
261 break; 251 break;
262 case CON: 252 case CON:
263 stats->Con = value; 253 stats->Con = value;
264 break; 254 break;
265 case WIS: 255 case WIS:
266 stats->Wis = value; 256 stats->Wis = value;
267 break; 257 break;
268 case POW: 258 case POW:
269 stats->Pow = value; 259 stats->Pow = value;
270 break; 260 break;
271 case CHA: 261 case CHA:
272 stats->Cha = value; 262 stats->Cha = value;
273 break; 263 break;
274 case INT: 264 case INT:
275 stats->Int = value; 265 stats->Int = value;
276 break; 266 break;
277 } 267 }
278} 268}
279 269
280/* 270/*
281 * Like set_attr_value(), but instead the value (which can be negative) 271 * Like set_attr_value(), but instead the value (which can be negative)
287{ 277{
288 if (value == 0) 278 if (value == 0)
289 return; 279 return;
290 switch (attr) 280 switch (attr)
291 { 281 {
292 case STR: 282 case STR:
293 stats->Str += value; 283 stats->Str += value;
294 break; 284 break;
295 case DEX: 285 case DEX:
296 stats->Dex += value; 286 stats->Dex += value;
297 break; 287 break;
298 case CON: 288 case CON:
299 stats->Con += value; 289 stats->Con += value;
300 break; 290 break;
301 case WIS: 291 case WIS:
302 stats->Wis += value; 292 stats->Wis += value;
303 break; 293 break;
304 case POW: 294 case POW:
305 stats->Pow += value; 295 stats->Pow += value;
306 break; 296 break;
307 case CHA: 297 case CHA:
308 stats->Cha += value; 298 stats->Cha += value;
309 break; 299 break;
310 case INT: 300 case INT:
311 stats->Int += value; 301 stats->Int += value;
312 break; 302 break;
313 default: 303 default:
314 LOG (llevError, "Invalid attribute in change_attr_value: %d\n", attr); 304 LOG (llevError, "Invalid attribute in change_attr_value: %d\n", attr);
315 } 305 }
316} 306}
317 307
318/* 308/*
319 * returns the specified stat. See also set_attr_value(). 309 * returns the specified stat. See also set_attr_value().
322sint8 312sint8
323get_attr_value (const living * stats, int attr) 313get_attr_value (const living * stats, int attr)
324{ 314{
325 switch (attr) 315 switch (attr)
326 { 316 {
327 case STR: 317 case STR:
328 return (stats->Str); 318 return (stats->Str);
329 case DEX: 319 case DEX:
330 return (stats->Dex); 320 return (stats->Dex);
331 case CON: 321 case CON:
332 return (stats->Con); 322 return (stats->Con);
333 case WIS: 323 case WIS:
334 return (stats->Wis); 324 return (stats->Wis);
335 case CHA: 325 case CHA:
336 return (stats->Cha); 326 return (stats->Cha);
337 case INT: 327 case INT:
338 return (stats->Int); 328 return (stats->Int);
339 case POW: 329 case POW:
340 return (stats->Pow); 330 return (stats->Pow);
341 } 331 }
342 return 0; 332 return 0;
343} 333}
344 334
345/* 335/*
692drain_specific_stat (object *op, int deplete_stats) 682drain_specific_stat (object *op, int deplete_stats)
693{ 683{
694 object *tmp; 684 object *tmp;
695 archetype *at; 685 archetype *at;
696 686
697 at = find_archetype (ARCH_DEPLETION); 687 at = archetype::find (ARCH_DEPLETION);
698 if (!at) 688 if (!at)
699 { 689 {
700 LOG (llevError, "Couldn't find archetype depletion.\n"); 690 LOG (llevError, "Couldn't find archetype depletion.\n");
701 return; 691 return;
702 } 692 }
726{ 716{
727 object *tmp; 717 object *tmp;
728 archetype *at; 718 archetype *at;
729 int new_luck; 719 int new_luck;
730 720
731 at = find_archetype ("luck"); 721 at = archetype::find ("luck");
732 if (!at) 722 if (!at)
733 LOG (llevError, "Couldn't find archetype luck.\n"); 723 LOG (llevError, "Couldn't find archetype luck.\n");
734 else 724 else
735 { 725 {
736 tmp = present_arch_in_ob (at, op); 726 tmp = present_arch_in_ob (at, op);
1103 added_speed += (float) tmp->stats.exp; 1093 added_speed += (float) tmp->stats.exp;
1104 } 1094 }
1105 1095
1106 switch (tmp->type) 1096 switch (tmp->type)
1107 { 1097 {
1108 /* skills modifying the character -b.t. */ 1098 /* skills modifying the character -b.t. */
1109 /* for all skills and skill granting objects */ 1099 /* for all skills and skill granting objects */
1110 case SKILL: 1100 case SKILL:
1111 if (!QUERY_FLAG (tmp, FLAG_APPLIED)) 1101 if (!QUERY_FLAG (tmp, FLAG_APPLIED))
1112 break;
1113
1114 if (IS_COMBAT_SKILL (tmp->subtype))
1115 wc_obj = tmp;
1116
1117 if (op->chosen_skill)
1118 {
1119 LOG (llevDebug, "fix_player, op %s has multiple skills applied\n", &op->name);
1120 }
1121 op->chosen_skill = tmp;
1122 if (tmp->stats.dam > 0)
1123 { /* skill is a 'weapon' */
1124 if (!QUERY_FLAG (op, FLAG_READY_WEAPON))
1125 weapon_speed = (int) WEAPON_SPEED (tmp);
1126 if (weapon_speed < 0)
1127 weapon_speed = 0;
1128 weapon_weight = tmp->weight;
1129 op->stats.dam += tmp->stats.dam * (1 + (op->chosen_skill->level / 9));
1130 if (tmp->magic)
1131 op->stats.dam += tmp->magic;
1132 }
1133 if (tmp->stats.wc)
1134 wc -= (tmp->stats.wc + tmp->magic);
1135
1136 if (tmp->slaying != NULL)
1137 op->slaying = tmp->slaying;
1138
1139 if (tmp->stats.ac)
1140 ac -= (tmp->stats.ac + tmp->magic);
1141 if (settings.spell_encumbrance == TRUE && op->type == PLAYER)
1142 op->contr->encumbrance += (int) 3 *tmp->weight / 1000;
1143
1144 if (op->type == PLAYER)
1145 op->contr->ranges[range_skill] = op;
1146 break; 1102 break;
1147 1103
1148 case SKILL_TOOL: 1104 if (IS_COMBAT_SKILL (tmp->subtype))
1105 wc_obj = tmp;
1106
1149 if (op->chosen_skill) 1107 if (op->chosen_skill)
1150 {
1151 LOG (llevDebug, "fix_player, op %s has multiple skills applied\n", &op->name); 1108 LOG (llevDebug, "fix_player, op %s has multiple skills applied\n", &op->name);
1152 } 1109
1153 op->chosen_skill = tmp; 1110 op->chosen_skill = tmp;
1154 if (op->type == PLAYER) 1111
1155 op->contr->ranges[range_skill] = op; 1112 if (tmp->stats.dam > 0)
1113 { /* skill is a 'weapon' */
1114 if (!QUERY_FLAG (op, FLAG_READY_WEAPON))
1115 weapon_speed = (int) WEAPON_SPEED (tmp);
1116 if (weapon_speed < 0)
1117 weapon_speed = 0;
1118 weapon_weight = tmp->weight;
1119 op->stats.dam += tmp->stats.dam * (1 + (op->chosen_skill->level / 9));
1120 if (tmp->magic)
1121 op->stats.dam += tmp->magic;
1156 break; 1122 }
1157 1123
1158 case SHIELD:
1159 if (settings.spell_encumbrance == TRUE && op->type == PLAYER)
1160 op->contr->encumbrance += (int) tmp->weight / 2000;
1161 case RING:
1162 case AMULET:
1163 case GIRDLE:
1164 case HELMET:
1165 case BOOTS:
1166 case GLOVES:
1167 case CLOAK:
1168 if (tmp->stats.wc) 1124 if (tmp->stats.wc)
1169 wc -= (tmp->stats.wc + tmp->magic);
1170 if (tmp->stats.dam)
1171 op->stats.dam += (tmp->stats.dam + tmp->magic);
1172 if (tmp->stats.ac)
1173 ac -= (tmp->stats.ac + tmp->magic);
1174 break;
1175
1176 case WEAPON:
1177 wc -= (tmp->stats.wc + tmp->magic); 1125 wc -= (tmp->stats.wc + tmp->magic);
1178 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) 1126
1127 if (tmp->slaying != NULL)
1128 op->slaying = tmp->slaying;
1129
1130 if (tmp->stats.ac)
1179 ac -= tmp->stats.ac + tmp->magic; 1131 ac -= (tmp->stats.ac + tmp->magic);
1132 if (settings.spell_encumbrance == TRUE && op->type == PLAYER)
1133 op->contr->encumbrance += (int) 3 *tmp->weight / 1000;
1134
1135 if (op->type == PLAYER)
1136 op->contr->ranges[range_skill] = op;
1137 break;
1138
1139 case SKILL_TOOL:
1140 if (op->chosen_skill)
1141 {
1142 LOG (llevDebug, "fix_player, op %s has multiple skills applied\n", &op->name);
1143 }
1144 op->chosen_skill = tmp;
1145 if (op->type == PLAYER)
1146 op->contr->ranges[range_skill] = op;
1147 break;
1148
1149 case SHIELD:
1150 if (settings.spell_encumbrance == TRUE && op->type == PLAYER)
1151 op->contr->encumbrance += (int) tmp->weight / 2000;
1152 case RING:
1153 case AMULET:
1154 case GIRDLE:
1155 case HELMET:
1156 case BOOTS:
1157 case GLOVES:
1158 case CLOAK:
1159 if (tmp->stats.wc)
1160 wc -= (tmp->stats.wc + tmp->magic);
1161 if (tmp->stats.dam)
1180 op->stats.dam += (tmp->stats.dam + tmp->magic); 1162 op->stats.dam += (tmp->stats.dam + tmp->magic);
1163 if (tmp->stats.ac)
1164 ac -= (tmp->stats.ac + tmp->magic);
1165 break;
1166
1167 case WEAPON:
1168 wc -= (tmp->stats.wc + tmp->magic);
1169 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0)
1170 ac -= tmp->stats.ac + tmp->magic;
1171 op->stats.dam += (tmp->stats.dam + tmp->magic);
1181 weapon_weight = tmp->weight; 1172 weapon_weight = tmp->weight;
1182 weapon_speed = ((int) WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; 1173 weapon_speed = ((int) WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2;
1183 if (weapon_speed < 0) 1174 if (weapon_speed < 0)
1184 weapon_speed = 0; 1175 weapon_speed = 0;
1185 op->slaying = tmp->slaying; 1176 op->slaying = tmp->slaying;
1186 /* If there is desire that two handed weapons should do 1177 /* If there is desire that two handed weapons should do
1187 * extra strength damage, this is where the code should 1178 * extra strength damage, this is where the code should
1188 * go. 1179 * go.
1189 */ 1180 */
1190 op->current_weapon = tmp; 1181 op->current_weapon = tmp;
1191 if (settings.spell_encumbrance == TRUE && op->type == PLAYER) 1182 if (settings.spell_encumbrance == TRUE && op->type == PLAYER)
1192 op->contr->encumbrance += (int) 3 *tmp->weight / 1000; 1183 op->contr->encumbrance += (int) 3 *tmp->weight / 1000;
1193 1184
1194 break; 1185 break;
1195 1186
1196 case ARMOUR: /* Only the best of these three are used: */ 1187 case ARMOUR: /* Only the best of these three are used: */
1197 if (settings.spell_encumbrance == TRUE && op->type == PLAYER) 1188 if (settings.spell_encumbrance == TRUE && op->type == PLAYER)
1198 op->contr->encumbrance += (int) tmp->weight / 1000; 1189 op->contr->encumbrance += (int) tmp->weight / 1000;
1199 1190
1200 case BRACERS: 1191 case BRACERS:
1201 case FORCE: 1192 case FORCE:
1202 if (tmp->stats.wc) 1193 if (tmp->stats.wc)
1203 { 1194 {
1204 if (best_wc < tmp->stats.wc + tmp->magic) 1195 if (best_wc < tmp->stats.wc + tmp->magic)
1205 { 1196 {
1206 wc += best_wc; 1197 wc += best_wc;
1207 best_wc = tmp->stats.wc + tmp->magic; 1198 best_wc = tmp->stats.wc + tmp->magic;
1208 } 1199 }
1209 else 1200 else
1210 wc += tmp->stats.wc + tmp->magic; 1201 wc += tmp->stats.wc + tmp->magic;
1211 } 1202 }
1212 if (tmp->stats.ac) 1203 if (tmp->stats.ac)
1213 { 1204 {
1214 if (best_ac < tmp->stats.ac + tmp->magic) 1205 if (best_ac < tmp->stats.ac + tmp->magic)
1215 { 1206 {
1216 ac += best_ac; /* Remove last bonus */ 1207 ac += best_ac; /* Remove last bonus */
1217 best_ac = tmp->stats.ac + tmp->magic; 1208 best_ac = tmp->stats.ac + tmp->magic;
1218 } 1209 }
1219 else /* To nullify the below effect */ 1210 else /* To nullify the below effect */
1220 ac += tmp->stats.ac + tmp->magic; 1211 ac += tmp->stats.ac + tmp->magic;
1221 } 1212 }
1222 if (tmp->stats.wc) 1213 if (tmp->stats.wc)
1223 wc -= (tmp->stats.wc + tmp->magic); 1214 wc -= (tmp->stats.wc + tmp->magic);
1224 if (tmp->stats.ac) 1215 if (tmp->stats.ac)
1225 ac -= (tmp->stats.ac + tmp->magic); 1216 ac -= (tmp->stats.ac + tmp->magic);
1226 if (ARMOUR_SPEED (tmp) && ARMOUR_SPEED (tmp) / 10.0 < max) 1217 if (ARMOUR_SPEED (tmp) && ARMOUR_SPEED (tmp) / 10.0 < max)
1227 max = ARMOUR_SPEED (tmp) / 10.0; 1218 max = ARMOUR_SPEED (tmp) / 10.0;
1228 break; 1219 break;
1229 } /* switch tmp->type */ 1220 } /* switch tmp->type */
1230 } /* item is equipped */ 1221 } /* item is equipped */
1231 } /* for loop of items */ 1222 } /* for loop of items */
1232 1223
1233 /* We've gone through all the objects the player has equipped. For many things, we 1224 /* We've gone through all the objects the player has equipped. For many things, we

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines