… | |
… | |
242 | change_attr_value (living *stats, int attr, sint8 value) |
242 | change_attr_value (living *stats, int attr, sint8 value) |
243 | { |
243 | { |
244 | stats->stat (attr) += value; |
244 | stats->stat (attr) += value; |
245 | } |
245 | } |
246 | |
246 | |
247 | sint8 & |
|
|
248 | living::stat (int index) |
|
|
249 | { |
|
|
250 | switch (index) |
|
|
251 | { |
|
|
252 | case STR: return Str; |
|
|
253 | case DEX: return Dex; |
|
|
254 | case CON: return Con; |
|
|
255 | case INT: return Int; |
|
|
256 | case WIS: return Wis; |
|
|
257 | case POW: return Pow; |
|
|
258 | case CHA: return Cha; |
|
|
259 | } |
|
|
260 | |
|
|
261 | LOG (llevError | logBacktrace, "living.stat() called with out-of-range stat index"); |
|
|
262 | static sint8 dummy; |
|
|
263 | return dummy; |
|
|
264 | } |
|
|
265 | |
|
|
266 | sint8 |
|
|
267 | living::stat (int index) const |
|
|
268 | { |
|
|
269 | switch (index) |
|
|
270 | { |
|
|
271 | case STR: return Str; |
|
|
272 | case DEX: return Dex; |
|
|
273 | case CON: return Con; |
|
|
274 | case INT: return Int; |
|
|
275 | case WIS: return Wis; |
|
|
276 | case POW: return Pow; |
|
|
277 | case CHA: return Cha; |
|
|
278 | } |
|
|
279 | |
|
|
280 | LOG (llevError | logBacktrace, "living.stat() called with out-of-range stat index"); |
|
|
281 | static sint8 dummy; |
|
|
282 | return dummy; |
|
|
283 | } |
|
|
284 | |
|
|
285 | /* |
247 | /* |
286 | * Ensures that all stats (str/dex/con/wis/cha/int) are within the |
248 | * Ensures that all stats (str/dex/con/wis/cha/int) are within the |
287 | * 1-30 stat limit. |
249 | * 1-30 stat limit. |
288 | */ |
250 | */ |
289 | void |
251 | void |
… | |
… | |
319 | * that gives them that ability. |
281 | * that gives them that ability. |
320 | */ |
282 | */ |
321 | int |
283 | int |
322 | change_abil (object *op, object *tmp) |
284 | change_abil (object *op, object *tmp) |
323 | { |
285 | { |
324 | int flag = QUERY_FLAG (tmp, FLAG_APPLIED) ? 1 : -1, i, j, success = 0; |
286 | int flag = QUERY_FLAG (tmp, FLAG_APPLIED) ? 1 : -1, success = 0; |
325 | char message[MAX_BUF]; |
287 | char message[MAX_BUF]; |
326 | int potion_max = 0; |
288 | int potion_max = 0; |
327 | |
289 | |
328 | /* remember what object was like before it was changed. note that |
290 | /* remember what object was like before it was changed. note that |
329 | * refop is a local copy of op only to be used for detecting changes |
291 | * refop is a local copy of op only to be used for detecting changes |
… | |
… | |
334 | if (op->type == PLAYER) |
296 | if (op->type == PLAYER) |
335 | { |
297 | { |
336 | if (tmp->type == POTION) |
298 | if (tmp->type == POTION) |
337 | { |
299 | { |
338 | potion_max = 1; |
300 | potion_max = 1; |
339 | for (j = 0; j < NUM_STATS; j++) |
301 | for (int j = 0; j < NUM_STATS; j++) |
340 | { |
302 | { |
341 | int nstat, ostat; |
|
|
342 | |
|
|
343 | ostat = op->contr->orig_stats.stat (j); |
303 | int ostat = op->contr->orig_stats.stat (j); |
344 | i = tmp->stats.stat (j); |
304 | int i = tmp->stats.stat (j); |
345 | |
305 | |
346 | /* nstat is what the stat will be after use of the potion */ |
306 | /* nstat is what the stat will be after use of the potion */ |
347 | nstat = flag * i + ostat; |
307 | int nstat = flag * i + ostat; |
348 | |
308 | |
349 | /* Do some bounds checking. While I don't think any |
309 | /* Do some bounds checking. While I don't think any |
350 | * potions do so right now, there is the potential for potions |
310 | * potions do so right now, there is the potential for potions |
351 | * that adjust that stat by more than one point, so we need |
311 | * that adjust that stat by more than one point, so we need |
352 | * to allow for that. |
312 | * to allow for that. |
… | |
… | |
370 | |
330 | |
371 | /* This section of code ups the characters normal stats also. I am not |
331 | /* This section of code ups the characters normal stats also. I am not |
372 | * sure if this is strictly necessary, being that fix_player probably |
332 | * sure if this is strictly necessary, being that fix_player probably |
373 | * recalculates this anyway. |
333 | * recalculates this anyway. |
374 | */ |
334 | */ |
375 | for (j = 0; j < NUM_STATS; j++) |
335 | for (int j = 0; j < NUM_STATS; j++) |
376 | change_attr_value (&op->stats, j, flag * tmp->stats.stat (j)); |
336 | change_attr_value (&op->stats, j, flag * tmp->stats.stat (j)); |
377 | |
337 | |
378 | check_stat_bounds (&op->stats); |
338 | check_stat_bounds (&op->stats); |
379 | } /* end of potion handling code */ |
339 | } /* end of potion handling code */ |
380 | } |
340 | } |
381 | |
341 | |
382 | /* reset attributes that fix_player doesn't reset since it doesn't search |
342 | /* reset attributes that update_stats doesn't reset since it doesn't search |
383 | * everything to set |
343 | * everything to set |
384 | */ |
344 | */ |
385 | if (flag == -1) |
345 | if (flag == -1) |
386 | { |
346 | { |
387 | op->attacktype &= ~tmp->attacktype; |
347 | op->attacktype &= ~tmp->attacktype; |
… | |
… | |
393 | */ |
353 | */ |
394 | op->move_type &= ~tmp->move_type; |
354 | op->move_type &= ~tmp->move_type; |
395 | } |
355 | } |
396 | |
356 | |
397 | /* call fix_player since op object could have whatever attribute due |
357 | /* call fix_player since op object could have whatever attribute due |
398 | * to multiple items. if fix_player always has to be called after |
358 | * to multiple items. if update_stats always has to be called after |
399 | * change_ability then might as well call it from here |
359 | * change_ability then might as well call it from here |
400 | */ |
360 | */ |
401 | op->update_stats (); |
361 | op->update_stats (); |
402 | |
362 | |
403 | /* Fix player won't add the bows ability to the player, so don't |
363 | /* update_stats won't add the bows ability to the player, so don't |
404 | * print out message if this is a bow. |
364 | * print out message if this is a bow. |
405 | */ |
365 | */ |
406 | if (tmp->attacktype & AT_CONFUSION && tmp->type != BOW) |
366 | if (tmp->attacktype & AT_CONFUSION && tmp->type != BOW) |
407 | { |
367 | { |
408 | success = 1; |
368 | success = 1; |
… | |
… | |
448 | if (tmp->move_type & MOVE_FLY_HIGH) |
408 | if (tmp->move_type & MOVE_FLY_HIGH) |
449 | { |
409 | { |
450 | /* double conditional - second case covers if you have move_fly_low - |
410 | /* double conditional - second case covers if you have move_fly_low - |
451 | * in that case, you don't actually land |
411 | * in that case, you don't actually land |
452 | */ |
412 | */ |
453 | DIFF_MSG (flag, "You soar into the air air!.", |
413 | DIFF_MSG (flag, "You soar into the air!", |
454 | (op->move_type & MOVE_FLY_LOW ? "You fly lower in the air" : "You float down to the ground.")); |
414 | (op->move_type & MOVE_FLY_LOW ? "You fly lower in the air" : "You float down to the ground.")); |
455 | } |
415 | } |
456 | |
416 | |
457 | if (tmp->move_type & MOVE_SWIM) |
417 | if (tmp->move_type & MOVE_SWIM) |
458 | DIFF_MSG (flag, "You feel ready for a swim", "You no longer feel like swimming"); |
418 | DIFF_MSG (flag, "You feel ready for a swim", "You no longer feel like swimming"); |
… | |
… | |
589 | success = 1; |
549 | success = 1; |
590 | DIFF_MSG (flag * tmp->stats.food, "You feel your digestion slowing down.", "You feel your digestion speeding up."); |
550 | DIFF_MSG (flag * tmp->stats.food, "You feel your digestion slowing down.", "You feel your digestion speeding up."); |
591 | } |
551 | } |
592 | |
552 | |
593 | /* Messages for changed resistance */ |
553 | /* Messages for changed resistance */ |
594 | for (i = 0; i < NROFATTACKS; i++) |
554 | for (int i = 0; i < NROFATTACKS; i++) |
595 | { |
555 | { |
596 | if (i == ATNR_PHYSICAL) |
556 | if (i == ATNR_PHYSICAL) |
597 | continue; /* Don't display about armour */ |
557 | continue; /* Don't display about armour */ |
598 | |
558 | |
599 | if (op->resist[i] != refop.resist[i]) |
559 | if (op->resist[i] != refop.resist[i]) |
… | |
… | |
608 | } |
568 | } |
609 | } |
569 | } |
610 | |
570 | |
611 | if (!potion_max) |
571 | if (!potion_max) |
612 | { |
572 | { |
613 | for (j = 0; j < NUM_STATS; j++) |
573 | for (int j = 0; j < NUM_STATS; j++) |
614 | { |
574 | { |
615 | if ((i = tmp->stats.stat (j))) |
575 | if (int i = tmp->stats.stat (j)) |
616 | { |
576 | { |
617 | success = 1; |
577 | success = 1; |
618 | DIFF_MSG (i * flag, gain_msg[j], lose_msg[j]); |
578 | DIFF_MSG (i * flag, gain_msg[j], lose_msg[j]); |
619 | } |
579 | } |
620 | } |
580 | } |
… | |
… | |
723 | * Subtracts stat-bonuses given by the class which the player has chosen. |
683 | * Subtracts stat-bonuses given by the class which the player has chosen. |
724 | */ |
684 | */ |
725 | void |
685 | void |
726 | object::remove_statbonus () |
686 | object::remove_statbonus () |
727 | { |
687 | { |
728 | stats.Str -= arch->clone.stats.Str; |
688 | for (int i = 0; i < NUM_STATS; ++i) |
729 | stats.Dex -= arch->clone.stats.Dex; |
689 | { |
730 | stats.Con -= arch->clone.stats.Con; |
690 | sint8 v = arch->clone.stats.stat (i); |
731 | stats.Wis -= arch->clone.stats.Wis; |
691 | stats.stat (i) -= v; |
732 | stats.Pow -= arch->clone.stats.Pow; |
692 | contr->orig_stats.stat (i) -= v; |
733 | stats.Cha -= arch->clone.stats.Cha; |
693 | } |
734 | stats.Int -= arch->clone.stats.Int; |
|
|
735 | |
|
|
736 | contr->orig_stats.Str -= arch->clone.stats.Str; |
|
|
737 | contr->orig_stats.Dex -= arch->clone.stats.Dex; |
|
|
738 | contr->orig_stats.Con -= arch->clone.stats.Con; |
|
|
739 | contr->orig_stats.Wis -= arch->clone.stats.Wis; |
|
|
740 | contr->orig_stats.Pow -= arch->clone.stats.Pow; |
|
|
741 | contr->orig_stats.Cha -= arch->clone.stats.Cha; |
|
|
742 | contr->orig_stats.Int -= arch->clone.stats.Int; |
|
|
743 | } |
694 | } |
744 | |
695 | |
745 | /* |
696 | /* |
746 | * Adds stat-bonuses given by the class which the player has chosen. |
697 | * Adds stat-bonuses given by the class which the player has chosen. |
747 | */ |
698 | */ |
748 | void |
699 | void |
749 | object::add_statbonus () |
700 | object::add_statbonus () |
750 | { |
701 | { |
751 | stats.Str += arch->clone.stats.Str; |
702 | for (int i = 0; i < NUM_STATS; ++i) |
752 | stats.Dex += arch->clone.stats.Dex; |
703 | { |
753 | stats.Con += arch->clone.stats.Con; |
704 | sint8 v = arch->clone.stats.stat (i); |
754 | stats.Wis += arch->clone.stats.Wis; |
705 | stats.stat (i) += v; |
755 | stats.Pow += arch->clone.stats.Pow; |
706 | contr->orig_stats.stat (i) += v; |
756 | stats.Cha += arch->clone.stats.Cha; |
707 | } |
757 | stats.Int += arch->clone.stats.Int; |
|
|
758 | |
|
|
759 | contr->orig_stats.Str += arch->clone.stats.Str; |
|
|
760 | contr->orig_stats.Dex += arch->clone.stats.Dex; |
|
|
761 | contr->orig_stats.Con += arch->clone.stats.Con; |
|
|
762 | contr->orig_stats.Wis += arch->clone.stats.Wis; |
|
|
763 | contr->orig_stats.Pow += arch->clone.stats.Pow; |
|
|
764 | contr->orig_stats.Cha += arch->clone.stats.Cha; |
|
|
765 | contr->orig_stats.Int += arch->clone.stats.Int; |
|
|
766 | } |
708 | } |
767 | |
709 | |
768 | /* |
710 | /* |
769 | * Updates all abilities given by applied objects in the inventory |
711 | * Updates all abilities given by applied objects in the inventory |
770 | * of the given object. Note: This function works for both monsters |
712 | * of the given object. Note: This function works for both monsters |
… | |
… | |
781 | int i, j; |
723 | int i, j; |
782 | float f, max = 9, added_speed = 0, bonus_speed = 0, sp_tmp, speed_reduce_from_disease = 1; |
724 | float f, max = 9, added_speed = 0, bonus_speed = 0, sp_tmp, speed_reduce_from_disease = 1; |
783 | int weapon_weight = 0, weapon_speed = 0; |
725 | int weapon_weight = 0, weapon_speed = 0; |
784 | int best_wc = 0, best_ac = 0, wc = 0, ac = 0; |
726 | int best_wc = 0, best_ac = 0, wc = 0, ac = 0; |
785 | int prot[NROFATTACKS], vuln[NROFATTACKS], potion_resist[NROFATTACKS]; |
727 | int prot[NROFATTACKS], vuln[NROFATTACKS], potion_resist[NROFATTACKS]; |
786 | object *grace_obj = NULL, *mana_obj = NULL, *wc_obj = NULL, *tmp; |
728 | object *grace_obj = NULL, *mana_obj = NULL, *tmp; |
787 | float old_speed = speed; |
729 | float old_speed = speed; |
788 | |
730 | |
789 | /* First task is to clear all the values back to their original values */ |
731 | /* First task is to clear all the values back to their original values */ |
790 | if (type == PLAYER) |
732 | if (type == PLAYER) |
791 | { |
733 | { |
… | |
… | |
997 | vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; |
939 | vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; |
998 | } |
940 | } |
999 | } |
941 | } |
1000 | |
942 | |
1001 | /* There may be other things that should not adjust the attacktype */ |
943 | /* There may be other things that should not adjust the attacktype */ |
1002 | if ((tmp->type != WEAPON && tmp->type != BOW && tmp->type != SYMPTOM) |
944 | if (tmp->type != SYMPTOM) |
1003 | || current_weapon == tmp) |
|
|
1004 | { |
945 | { |
1005 | attacktype |= tmp->attacktype; |
946 | attacktype |= tmp->attacktype; |
1006 | path_attuned |= tmp->path_attuned; |
947 | path_attuned |= tmp->path_attuned; |
1007 | path_repelled |= tmp->path_repelled; |
948 | path_repelled |= tmp->path_repelled; |
1008 | path_denied |= tmp->path_denied; |
949 | path_denied |= tmp->path_denied; |
… | |
… | |
1053 | /* for all skills and skill granting objects */ |
994 | /* for all skills and skill granting objects */ |
1054 | case SKILL: |
995 | case SKILL: |
1055 | if (!QUERY_FLAG (tmp, FLAG_APPLIED)) |
996 | if (!QUERY_FLAG (tmp, FLAG_APPLIED)) |
1056 | break; |
997 | break; |
1057 | |
998 | |
1058 | if (IS_COMBAT_SKILL (tmp->subtype)) |
|
|
1059 | wc_obj = tmp; |
|
|
1060 | |
|
|
1061 | if (chosen_skill) |
999 | if (chosen_skill) |
1062 | LOG (llevDebug, "fix_player, op %s has multiple skills applied\n", &name); |
1000 | LOG (llevDebug, "fix_player, op %s has multiple skills applied\n", &name); |
1063 | |
1001 | |
1064 | chosen_skill = tmp; |
1002 | chosen_skill = tmp; |
1065 | |
1003 | |
… | |
… | |
1070 | |
1008 | |
1071 | if (weapon_speed < 0) |
1009 | if (weapon_speed < 0) |
1072 | weapon_speed = 0; |
1010 | weapon_speed = 0; |
1073 | |
1011 | |
1074 | weapon_weight = tmp->weight; |
1012 | weapon_weight = tmp->weight; |
1075 | stats.dam += tmp->stats.dam * (1 + (chosen_skill->level / 9)); |
1013 | stats.dam += 1 + (chosen_skill->level * tmp->stats.dam / 9); |
1076 | |
1014 | |
1077 | if (tmp->magic) |
1015 | if (tmp->magic) |
1078 | stats.dam += tmp->magic; |
1016 | stats.dam += tmp->magic; |
1079 | } |
1017 | } |
1080 | |
1018 | |
… | |
… | |
1284 | stats.maxsp = (sint16)sp_tmp; |
1222 | stats.maxsp = (sint16)sp_tmp; |
1285 | |
1223 | |
1286 | for (i = 11; i <= mana_obj->level; i++) |
1224 | for (i = 11; i <= mana_obj->level; i++) |
1287 | stats.maxsp += 2; |
1225 | stats.maxsp += 2; |
1288 | } |
1226 | } |
|
|
1227 | |
1289 | /* Characters can get their sp supercharged via rune of transferrance */ |
1228 | /* Characters can get their sp supercharged via rune of transferrance */ |
1290 | if (stats.sp > stats.maxsp * 2) |
1229 | if (stats.sp > stats.maxsp * 2) |
1291 | stats.sp = stats.maxsp * 2; |
1230 | stats.sp = stats.maxsp * 2; |
1292 | |
1231 | |
1293 | /* set maxgrace, notice 3-4 lines below it depends on both Wis and Pow */ |
1232 | /* set maxgrace, notice 3-4 lines below it depends on both Wis and Pow */ |
… | |
… | |
1324 | |
1263 | |
1325 | /* two grace points per level after 11 */ |
1264 | /* two grace points per level after 11 */ |
1326 | for (i = 11; i <= grace_obj->level; i++) |
1265 | for (i = 11; i <= grace_obj->level; i++) |
1327 | stats.maxgrace += 2; |
1266 | stats.maxgrace += 2; |
1328 | } |
1267 | } |
|
|
1268 | |
1329 | /* No limit on grace vs maxgrace */ |
1269 | /* No limit on grace vs maxgrace */ |
1330 | |
1270 | |
1331 | if (contr->braced) |
1271 | if (contr->braced) |
1332 | { |
1272 | { |
1333 | ac += 2; |
1273 | ac += 2; |
… | |
… | |
1345 | * improvement every level, now its fighterlevel/5. So |
1285 | * improvement every level, now its fighterlevel/5. So |
1346 | * we give the player a bonus here in wc and dam |
1286 | * we give the player a bonus here in wc and dam |
1347 | * to make up for the change. Note that I left the |
1287 | * to make up for the change. Note that I left the |
1348 | * monster bonus the same as before. -b.t. |
1288 | * monster bonus the same as before. -b.t. |
1349 | */ |
1289 | */ |
|
|
1290 | object *wc_obj = chosen_skill; |
1350 | |
1291 | |
1351 | if (type == PLAYER && wc_obj && wc_obj->level > 1) |
1292 | if (contr && wc_obj && wc_obj->level > 1) |
1352 | { |
1293 | { |
1353 | wc -= wc_obj->level + thaco_bonus[stats.Str]; |
1294 | wc -= wc_obj->level + thaco_bonus[stats.Str]; |
1354 | |
1295 | |
1355 | for (i = 1; i < wc_obj->level; i++) |
1296 | for (i = 1; i < wc_obj->level; i++) |
1356 | { |
1297 | { |
1357 | /* addtional wc every 6 levels */ |
1298 | /* additional wc every 6 levels */ |
1358 | if (!(i % 6)) |
1299 | if (!(i % 6)) |
1359 | wc--; |
1300 | wc--; |
1360 | |
1301 | |
1361 | /* addtional dam every 4 levels. */ |
1302 | /* additional dam every 4 levels. */ |
1362 | if (!(i % 4) && dam_bonus[stats.Str] >= 0) |
1303 | if (!(i % 4) && dam_bonus[stats.Str] >= 0) |
1363 | stats.dam += 1 + dam_bonus[stats.Str] / 5; |
1304 | stats.dam += 1 + dam_bonus[stats.Str] / 5; |
1364 | } |
1305 | } |
1365 | } |
1306 | } |
1366 | else |
1307 | else |
… | |
… | |
1376 | if (settings.search_items && contr->search_str[0]) |
1317 | if (settings.search_items && contr->search_str[0]) |
1377 | speed -= 1; |
1318 | speed -= 1; |
1378 | |
1319 | |
1379 | if (attacktype == 0) |
1320 | if (attacktype == 0) |
1380 | attacktype = arch->clone.attacktype; |
1321 | attacktype = arch->clone.attacktype; |
1381 | |
|
|
1382 | } /* End if player */ |
1322 | } /* End if player */ |
1383 | |
1323 | |
1384 | if (added_speed >= 0) |
1324 | if (added_speed >= 0) |
1385 | speed += added_speed / 10.f; |
1325 | speed += added_speed / 10.f; |
1386 | else /* Something wrong here...: */ |
1326 | else /* Something wrong here...: */ |
… | |
… | |
1644 | if (!skill_obj) |
1584 | if (!skill_obj) |
1645 | { |
1585 | { |
1646 | LOG (llevError, "add_player_exp: couldn't find skill %s\n", skill_name); |
1586 | LOG (llevError, "add_player_exp: couldn't find skill %s\n", skill_name); |
1647 | return NULL; |
1587 | return NULL; |
1648 | } |
1588 | } |
|
|
1589 | |
1649 | /* clear the flag - exp goes into this bucket, but player |
1590 | /* clear the flag - exp goes into this bucket, but player |
1650 | * still doesn't know it. |
1591 | * still doesn't know it. |
1651 | */ |
1592 | */ |
1652 | CLEAR_FLAG (skill_obj, FLAG_CAN_USE_SKILL); |
1593 | CLEAR_FLAG (skill_obj, FLAG_CAN_USE_SKILL); |
1653 | skill_obj->stats.exp = 0; |
1594 | skill_obj->stats.exp = 0; |
… | |
… | |
1662 | } |
1603 | } |
1663 | |
1604 | |
1664 | return skill_obj; |
1605 | return skill_obj; |
1665 | } |
1606 | } |
1666 | |
1607 | |
1667 | |
|
|
1668 | /* player_lvl_adj() - for the new exp system. we are concerned with |
1608 | /* player_lvl_adj() - for the new exp system. we are concerned with |
1669 | * whether the player gets more hp, sp and new levels. |
1609 | * whether the player gets more hp, sp and new levels. |
1670 | * Note this this function should only be called for players. Monstes |
1610 | * Note this this function should only be called for players. Monstes |
1671 | * don't really gain levels |
1611 | * don't really gain levels |
1672 | * who is the player, op is what we are checking to gain the level |
1612 | * who is the player, op is what we are checking to gain the level |
… | |
… | |
1682 | |
1622 | |
1683 | if (op->level < settings.max_level && op->stats.exp >= level_exp (op->level + 1, who->expmul)) |
1623 | if (op->level < settings.max_level && op->stats.exp >= level_exp (op->level + 1, who->expmul)) |
1684 | { |
1624 | { |
1685 | op->level++; |
1625 | op->level++; |
1686 | |
1626 | |
1687 | if (op != NULL && op == who && op->stats.exp > 1 && is_dragon_pl (who)) |
1627 | if (op && op == who && op->stats.exp > 1 && is_dragon_pl (who)) |
1688 | dragon_level_gain (who); |
1628 | dragon_level_gain (who); |
1689 | |
1629 | |
1690 | /* Only roll these if it is the player (who) that gained the level */ |
1630 | /* Only roll these if it is the player (who) that gained the level */ |
1691 | if (op == who && (who->level < 11) && who->type == PLAYER) |
1631 | if (op == who && (who->level < 11) && who->type == PLAYER) |
1692 | { |
1632 | { |
… | |
… | |
1700 | { |
1640 | { |
1701 | if (op->type != PLAYER) |
1641 | if (op->type != PLAYER) |
1702 | sprintf (buf, "You are now level %d in the %s skill.", op->level, &op->name); |
1642 | sprintf (buf, "You are now level %d in the %s skill.", op->level, &op->name); |
1703 | else |
1643 | else |
1704 | sprintf (buf, "You are now level %d.", op->level); |
1644 | sprintf (buf, "You are now level %d.", op->level); |
|
|
1645 | |
1705 | if (who) |
1646 | if (who) |
1706 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf); |
1647 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf); |
1707 | } |
1648 | } |
|
|
1649 | |
1708 | player_lvl_adj (who, op); /* To increase more levels */ |
1650 | player_lvl_adj (who, op); /* To increase more levels */ |
1709 | } |
1651 | } |
1710 | else if (op->level > 1 && op->stats.exp < level_exp (op->level, who->expmul)) |
1652 | else if (op->level > 1 && op->stats.exp < level_exp (op->level, who->expmul)) |
1711 | { |
1653 | { |
1712 | op->level--; |
1654 | op->level--; |
1713 | who->update_stats (); |
1655 | who->update_stats (); |
|
|
1656 | |
1714 | if (op->type != PLAYER) |
1657 | if (op->type != PLAYER) |
1715 | { |
1658 | { |
1716 | sprintf (buf, "You are now level %d in the %s skill.", op->level, &op->name); |
1659 | sprintf (buf, "You are now level %d in the %s skill.", op->level, &op->name); |
1717 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf); |
1660 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf); |
1718 | } |
1661 | } |
|
|
1662 | |
1719 | player_lvl_adj (who, op); /* To decrease more levels */ |
1663 | player_lvl_adj (who, op); /* To decrease more levels */ |
1720 | } |
1664 | } |
1721 | |
1665 | |
1722 | /* check if the spell data has changed */ |
1666 | /* check if the spell data has changed */ |
1723 | esrv_update_stats (who->contr); |
1667 | esrv_update_stats (who->contr); |
… | |
… | |
2034 | player_lvl_adj (op, tmp); |
1978 | player_lvl_adj (op, tmp); |
2035 | } |
1979 | } |
2036 | |
1980 | |
2037 | percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100; |
1981 | percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100; |
2038 | level_loss = op->stats.exp - levels[MAX (0, op->level - settings.death_penalty_level)]; |
1982 | level_loss = op->stats.exp - levels[MAX (0, op->level - settings.death_penalty_level)]; |
|
|
1983 | |
2039 | if (level_loss < 0) |
1984 | if (level_loss < 0) |
2040 | level_loss = 0; |
1985 | level_loss = 0; |
2041 | loss = check_exp_loss (op, MIN (level_loss, percentage_loss)); |
1986 | loss = check_exp_loss (op, MIN (level_loss, percentage_loss)); |
2042 | |
1987 | |
2043 | op->stats.exp -= loss; |
1988 | op->stats.exp -= loss; |