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.39 by root, Sun Apr 29 14:39:55 2007 UTC vs.
Revision 1.43 by root, Sun Apr 29 18:34:57 2007 UTC

935 */ 935 */
936 if (tmp->glow_radius > glow_radius) 936 if (tmp->glow_radius > glow_radius)
937 glow_radius = tmp->glow_radius; 937 glow_radius = tmp->glow_radius;
938 938
939 /* This happens because apply_potion calls change_abil with the potion 939 /* This happens because apply_potion calls change_abil with the potion
940 * applied so we can tell the player what chagned. But change_abil 940 * applied so we can tell the player what changed. But change_abil
941 * then calls this function. 941 * then calls this function.
942 */ 942 */
943 if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->type == POTION) 943 if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->type == POTION)
944 continue; 944 continue;
945 945
1017 for (i = 0; i < NUM_BODY_LOCATIONS; i++) 1017 for (i = 0; i < NUM_BODY_LOCATIONS; i++)
1018 body_used[i] += tmp->body_info[i]; 1018 body_used[i] += tmp->body_info[i];
1019 1019
1020 if (tmp->type == SYMPTOM) 1020 if (tmp->type == SYMPTOM)
1021 { 1021 {
1022 speed_reduce_from_disease = tmp->last_sp / 100.0; 1022 speed_reduce_from_disease = tmp->last_sp / 100.f;
1023 1023
1024 if (speed_reduce_from_disease == 0) 1024 if (speed_reduce_from_disease == 0)
1025 speed_reduce_from_disease = 1; 1025 speed_reduce_from_disease = 1;
1026 } 1026 }
1027 1027
1080 1080
1081 if (tmp->stats.exp && tmp->type != SKILL) 1081 if (tmp->stats.exp && tmp->type != SKILL)
1082 { 1082 {
1083 if (tmp->stats.exp > 0) 1083 if (tmp->stats.exp > 0)
1084 { 1084 {
1085 added_speed += (float) tmp->stats.exp / 3.0; 1085 added_speed += tmp->stats.exp / 3.f;
1086 bonus_speed += 1.0 + (float) tmp->stats.exp / 3.0; 1086 bonus_speed += 1.f + tmp->stats.exp / 3.f;
1087 } 1087 }
1088 else 1088 else
1089 added_speed += (float) tmp->stats.exp; 1089 added_speed += tmp->stats.exp;
1090 } 1090 }
1091 1091
1092 switch (tmp->type) 1092 switch (tmp->type)
1093 { 1093 {
1094 /* skills modifying the character -b.t. */ 1094 /* skills modifying the character -b.t. */
1106 chosen_skill = tmp; 1106 chosen_skill = tmp;
1107 1107
1108 if (tmp->stats.dam > 0) 1108 if (tmp->stats.dam > 0)
1109 { /* skill is a 'weapon' */ 1109 { /* skill is a 'weapon' */
1110 if (!QUERY_FLAG (this, FLAG_READY_WEAPON)) 1110 if (!QUERY_FLAG (this, FLAG_READY_WEAPON))
1111 weapon_speed = (int) WEAPON_SPEED (tmp); 1111 weapon_speed = WEAPON_SPEED (tmp);
1112 1112
1113 if (weapon_speed < 0) 1113 if (weapon_speed < 0)
1114 weapon_speed = 0; 1114 weapon_speed = 0;
1115 1115
1116 weapon_weight = tmp->weight; 1116 weapon_weight = tmp->weight;
1121 } 1121 }
1122 1122
1123 if (tmp->stats.wc) 1123 if (tmp->stats.wc)
1124 wc -= (tmp->stats.wc + tmp->magic); 1124 wc -= (tmp->stats.wc + tmp->magic);
1125 1125
1126 if (tmp->slaying != NULL) 1126 if (tmp->slaying)
1127 slaying = tmp->slaying; 1127 slaying = tmp->slaying;
1128 1128
1129 if (tmp->stats.ac) 1129 if (tmp->stats.ac)
1130 ac -= (tmp->stats.ac + tmp->magic); 1130 ac -= (tmp->stats.ac + tmp->magic);
1131 1131
1166 if (tmp->stats.ac) 1166 if (tmp->stats.ac)
1167 ac -= tmp->stats.ac + tmp->magic; 1167 ac -= tmp->stats.ac + tmp->magic;
1168 1168
1169 break; 1169 break;
1170 1170
1171 case BOW:
1172 case WEAPON: 1171 case WEAPON:
1173 wc -= tmp->stats.wc + tmp->magic; 1172 wc -= tmp->stats.wc + tmp->magic;
1174 1173
1175 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) 1174 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0)
1176 ac -= tmp->stats.ac + tmp->magic; 1175 ac -= tmp->stats.ac + tmp->magic;
1177 1176
1178 stats.dam += tmp->stats.dam + tmp->magic; 1177 stats.dam += tmp->stats.dam + tmp->magic;
1179 weapon_weight = tmp->weight; 1178 weapon_weight = tmp->weight;
1180 weapon_speed = ((int) WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; 1179 weapon_speed = (WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2;
1181 1180
1182 if (weapon_speed < 0) 1181 if (weapon_speed < 0)
1183 weapon_speed = 0; 1182 weapon_speed = 0;
1184 1183
1185 slaying = tmp->slaying; 1184 slaying = tmp->slaying;
1185
1186 /* If there is desire that two handed weapons should do 1186 /* If there is desire that two handed weapons should do
1187 * extra strength damage, this is where the code should 1187 * extra strength damage, this is where the code should
1188 * go. 1188 * go.
1189 */ 1189 */
1190
1190 current_weapon = tmp; 1191 current_weapon = tmp;
1191 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1192 if (type == PLAYER && settings.spell_encumbrance)
1192 contr->encumbrance += (int) 3 *tmp->weight / 1000; 1193 contr->encumbrance += tmp->weight * 3 / 1000;
1193 1194
1194 break; 1195 break;
1195 1196
1196 case ARMOUR: /* Only the best of these three are used: */ 1197 case ARMOUR: /* Only the best of these three are used: */
1197 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1198 if (settings.spell_encumbrance == TRUE && type == PLAYER)
1198 contr->encumbrance += (int) tmp->weight / 1000; 1199 contr->encumbrance += tmp->weight / 1000;
1199 1200
1200 case BRACERS: 1201 case BRACERS:
1201 case FORCE: 1202 case FORCE:
1202 if (tmp->stats.wc) 1203 if (tmp->stats.wc)
1203 { 1204 {
1225 wc -= (tmp->stats.wc + tmp->magic); 1226 wc -= (tmp->stats.wc + tmp->magic);
1226 1227
1227 if (tmp->stats.ac) 1228 if (tmp->stats.ac)
1228 ac -= (tmp->stats.ac + tmp->magic); 1229 ac -= (tmp->stats.ac + tmp->magic);
1229 1230
1230 if (ARMOUR_SPEED (tmp) && ARMOUR_SPEED (tmp) / 10.0 < max) 1231 if (ARMOUR_SPEED (tmp) && ARMOUR_SPEED (tmp) / 10.f < max)
1231 max = ARMOUR_SPEED (tmp) / 10.0; 1232 max = ARMOUR_SPEED (tmp) / 10.f;
1232 1233
1233 break; 1234 break;
1234 } /* switch tmp->type */ 1235 } /* switch tmp->type */
1235 } /* item is equipped */ 1236 } /* item is equipped */
1236 } /* for loop of items */ 1237 } /* for loop of items */
1304 1305
1305 if (mana_obj == this && type == PLAYER) 1306 if (mana_obj == this && type == PLAYER)
1306 stats.maxsp = 1; 1307 stats.maxsp = 1;
1307 else 1308 else
1308 { 1309 {
1309 sp_tmp = 0.0; 1310 sp_tmp = 0.f;
1310 1311
1311 for (i = 1; i <= mana_obj->level && i <= 10; i++) 1312 for (i = 1; i <= mana_obj->level && i <= 10; i++)
1312 { 1313 {
1313 float stmp; 1314 float stmp;
1314 1315
1315 /* Got some extra bonus at first level */ 1316 /* Got some extra bonus at first level */
1316 if (i < 2) 1317 if (i < 2)
1317 stmp = contr->levsp[i] + ((2.0 * (float) sp_bonus[stats.Pow] + (float) sp_bonus[stats.Int]) / 6.0); 1318 stmp = contr->levsp[i] + (2.f * sp_bonus[stats.Pow] + sp_bonus[stats.Int]) / 6.f;
1318 else 1319 else
1319 stmp = (float) contr->levsp[i] + (2.0 * (float) sp_bonus[stats.Pow] + (float) sp_bonus[stats.Int]) / 12.0; 1320 stmp = contr->levsp[i] + (2.f * sp_bonus[stats.Pow] + sp_bonus[stats.Int]) / 12.f;
1320 1321
1321 if (stmp < 1.0) 1322 if (stmp < 1.f)
1322 stmp = 1.0; 1323 stmp = 1.f;
1323 1324
1324 sp_tmp += stmp; 1325 sp_tmp += stmp;
1325 } 1326 }
1326 1327
1327 stats.maxsp = (int) sp_tmp; 1328 stats.maxsp = (sint16)sp_tmp;
1328 1329
1329 for (i = 11; i <= mana_obj->level; i++) 1330 for (i = 11; i <= mana_obj->level; i++)
1330 stats.maxsp += 2; 1331 stats.maxsp += 2;
1331 } 1332 }
1332 /* Characters can get their sp supercharged via rune of transferrance */ 1333 /* Characters can get their sp supercharged via rune of transferrance */
1344 /* store grace in a float - this way, the divisions below don't create 1345 /* store grace in a float - this way, the divisions below don't create
1345 * big jumps when you go from level to level - with int's, it then 1346 * big jumps when you go from level to level - with int's, it then
1346 * becomes big jumps when the sums of the bonuses jump to the next 1347 * becomes big jumps when the sums of the bonuses jump to the next
1347 * step of 8 - with floats, even fractional ones are useful. 1348 * step of 8 - with floats, even fractional ones are useful.
1348 */ 1349 */
1349 sp_tmp = 0.0; 1350 sp_tmp = 0.f;
1350 for (i = 1, stats.maxgrace = 0; i <= grace_obj->level && i <= 10; i++) 1351 for (i = 1, stats.maxgrace = 0; i <= grace_obj->level && i <= 10; i++)
1351 { 1352 {
1352 float grace_tmp = 0.0; 1353 float grace_tmp = 0.f;
1353 1354
1354 /* Got some extra bonus at first level */ 1355 /* Got some extra bonus at first level */
1355 if (i < 2) 1356 if (i < 2)
1356 grace_tmp = contr->levgrace[i] + (((float) grace_bonus[stats.Pow] + 1357 grace_tmp = contr->levgrace[i] + (grace_bonus[stats.Pow] + 2.f * grace_bonus[stats.Wis]) / 6.f;
1357 2.0 * (float) grace_bonus[stats.Wis]) / 6.0);
1358 else 1358 else
1359 grace_tmp = (float) contr->levgrace[i]
1360 + ((float) grace_bonus[stats.Pow] + 2.0 * (float) grace_bonus[stats.Wis]) / 12.0; 1359 grace_tmp = contr->levgrace[i] + (grace_bonus[stats.Pow] + 2.f * grace_bonus[stats.Wis]) / 12.f;
1361 1360
1362 if (grace_tmp < 1.0) 1361 if (grace_tmp < 1.f)
1363 grace_tmp = 1.0; 1362 grace_tmp = 1.f;
1364 1363
1365 sp_tmp += grace_tmp; 1364 sp_tmp += grace_tmp;
1366 } 1365 }
1367 1366
1368 stats.maxgrace = (int) sp_tmp; 1367 stats.maxgrace = (sint16)sp_tmp;
1369 1368
1370 /* two grace points per level after 11 */ 1369 /* two grace points per level after 11 */
1371 for (i = 11; i <= grace_obj->level; i++) 1370 for (i = 11; i <= grace_obj->level; i++)
1372 stats.maxgrace += 2; 1371 stats.maxgrace += 2;
1373 } 1372 }
1414 stats.dam += dam_bonus[stats.Str]; 1413 stats.dam += dam_bonus[stats.Str];
1415 1414
1416 if (stats.dam < 1) 1415 if (stats.dam < 1)
1417 stats.dam = 1; 1416 stats.dam = 1;
1418 1417
1419 speed = 1.0 + speed_bonus[stats.Dex]; 1418 speed = 1.f + speed_bonus[stats.Dex];
1420 1419
1421 if (settings.search_items && contr->search_str[0]) 1420 if (settings.search_items && contr->search_str[0])
1422 speed -= 1; 1421 speed -= 1;
1423 1422
1424 if (attacktype == 0) 1423 if (attacktype == 0)
1425 attacktype = arch->clone.attacktype; 1424 attacktype = arch->clone.attacktype;
1426 1425
1427 } /* End if player */ 1426 } /* End if player */
1428 1427
1429 if (added_speed >= 0) 1428 if (added_speed >= 0)
1430 speed += added_speed / 10.0; 1429 speed += added_speed / 10.f;
1431 else /* Something wrong here...: */ 1430 else /* Something wrong here...: */
1432 speed /= (float) (1.0 - added_speed); 1431 speed /= 1.f - added_speed;
1433 1432
1434 /* Max is determined by armour */ 1433 /* Max is determined by armour */
1435 if (speed > max) 1434 if (speed > max)
1436 speed = max; 1435 speed = max;
1437 1436
1442 * weight limit, then player suffers a speed reduction based on how 1441 * weight limit, then player suffers a speed reduction based on how
1443 * much above he is, and what is max carry is 1442 * much above he is, and what is max carry is
1444 */ 1443 */
1445 f = (carrying / 1000) - max_carry[stats.Str]; 1444 f = (carrying / 1000) - max_carry[stats.Str];
1446 if (f > 0) 1445 if (f > 0)
1447 speed = speed / (1.0 + f / max_carry[stats.Str]); 1446 speed = speed / (1.f + f / max_carry[stats.Str]);
1448 } 1447 }
1449 1448
1450 speed += bonus_speed / 10.0; /* Not affected by limits */ 1449 speed += bonus_speed / 10.f; /* Not affected by limits */
1451 1450
1452 /* Put a lower limit on speed. Note with this speed, you move once every 1451 /* Put a lower limit on speed. Note with this speed, you move once every
1453 * 100 ticks or so. This amounts to once every 12 seconds of realtime. 1452 * 100 ticks or so. This amounts to once every 12 seconds of realtime.
1454 */ 1453 */
1455 speed = speed * speed_reduce_from_disease; 1454 speed = speed * speed_reduce_from_disease;
1456 1455
1457 if (speed < 0.01 && type == PLAYER) 1456 if (speed < 0.01f && type == PLAYER)
1458 speed = 0.01; 1457 speed = 0.01f;
1459 1458
1460 if (type == PLAYER) 1459 if (type == PLAYER)
1461 { 1460 {
1462 float M, W, s, D, K, S, M2;
1463
1464 /* (This formula was made by vidarl@ifi.uio.no) 1461 /* (This formula was made by vidarl@ifi.uio.no)
1465 * Note that we never used these values again - basically 1462 * Note that we never used these values again - basically
1466 * all of these could be subbed into one big equation, but 1463 * all of these could be subbed into one big equation, but
1467 * that would just be a real pain to read. 1464 * that would just be a real pain to read.
1468 */ 1465 */
1469 M = (max_carry[stats.Str] - 121) / 121.0; 1466 float M = (max_carry[stats.Str] - 121) / 121.f;
1470 M2 = max_carry[stats.Str] / 100.0; 1467 float M2 = max_carry[stats.Str] / 100.f;
1471 W = weapon_weight / 20000.0; 1468 float W = weapon_weight / 20000.f;
1472 s = 2 - weapon_speed / 10.0; 1469 float s = 2 - weapon_speed / 10.f;
1473 D = (stats.Dex - 14) / 14.0; 1470 float D = (stats.Dex - 14) / 14.f;
1474 K = 1 + M / 3.0 - W / (3 * M2) + speed / 5.0 + D / 2.0; 1471 float K = 1 + M / 3.f - W / (3 * M2) + speed / 5.f + D / 2.f;
1472
1475 K *= (4 + level) / (float) (6 + level) * 1.2; 1473 K *= (4 + level) *1.2f / (6 + level);
1474
1476 if (K <= 0) 1475 if (K <= 0.f)
1477 K = 0.01; 1476 K = 0.01f;
1477
1478 S = speed / (K * s); 1478 float S = speed / (K * s);
1479
1479 contr->weapon_sp = S; 1480 contr->weapon_sp = S;
1480 } 1481 }
1481 1482
1482 /* I want to limit the power of small monsters with big weapons: */ 1483 /* I want to limit the power of small monsters with big weapons: */
1483 if (type != PLAYER && arch != NULL && stats.dam > arch->clone.stats.dam * 3) 1484 if (type != PLAYER && arch && stats.dam > arch->clone.stats.dam * 3)
1484 stats.dam = arch->clone.stats.dam * 3; 1485 stats.dam = arch->clone.stats.dam * 3;
1485 1486
1486 /* Prevent overflows of wc - best you can get is ABS(120) - this 1487 /* Prevent overflows of wc - best you can get is ABS(120) - this
1487 * should be more than enough - remember, AC is also in 8 bits, 1488 * should be more than enough - remember, AC is also in 8 bits,
1488 * so its value is the same. 1489 * so its value is the same.
1537 * false otherwise. 1538 * false otherwise.
1538 */ 1539 */
1539int 1540int
1540allowed_class (const object *op) 1541allowed_class (const object *op)
1541{ 1542{
1542 return op->stats.Dex > 0 && op->stats.Str > 0 && op->stats.Con > 0 && 1543 return op->stats.Dex > 0
1543 op->stats.Int > 0 && op->stats.Wis > 0 && op->stats.Pow > 0 && op->stats.Cha > 0; 1544 && op->stats.Str > 0
1545 && op->stats.Con > 0
1546 && op->stats.Int > 0
1547 && op->stats.Wis > 0
1548 && op->stats.Pow > 0
1549 && op->stats.Cha > 0;
1544} 1550}
1545 1551
1546/* 1552/*
1547 * set the new dragon name after gaining levels or 1553 * set the new dragon name after gaining levels or
1548 * changing ability focus (later this can be extended to 1554 * changing ability focus (later this can be extended to
1770sint64 1776sint64
1771level_exp (int level, double expmul) 1777level_exp (int level, double expmul)
1772{ 1778{
1773 if (level > settings.max_level) 1779 if (level > settings.max_level)
1774 return (sint64) (expmul * levels[settings.max_level]); 1780 return (sint64) (expmul * levels[settings.max_level]);
1781
1775 return (sint64) (expmul * levels[level]); 1782 return (sint64) (expmul * levels[level]);
1776} 1783}
1777 1784
1778/* 1785/*
1779 * Ensure that the permanent experience requirements in an exp object are met. 1786 * Ensure that the permanent experience requirements in an exp object are met.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines