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