Guest User

Untitled

a guest
Oct 21st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. //
  2. // P_MaxExpForLevel
  3. //
  4. // haleyjd 20110701: [PIG] New function
  5. // Calculate the max experience for a level.
  6. // Note the displayed level is +1 from the internal level (starts @ 0)
  7. //
  8. int P_MaxExpForLevel(int level)
  9. {
  10. int accExp = 875; // EXP needed for lv 2 (kill 5 Ettins)
  11. int maxExp = accExp;
  12. float expFactor;
  13. int i;
  14.  
  15. for(i = 0; i < level; i++)
  16. {
  17. expFactor = 1.25f - ((float)i/2.0f * 0.0125f); // declining exponent
  18. if(expFactor < 1.0f) // curve stops growing exponentially at lv 40
  19. expFactor = 1.0f;
  20. accExp = (int)(accExp * expFactor);
  21. maxExp += accExp;
  22. }
  23.  
  24. return maxExp;
  25. }
  26.  
  27. //
  28. // P_GiveExperience
  29. //
  30. // haleyjd 20110701: [PIG] New function
  31. //
  32. void P_GiveExperience(player_t *player, mobj_t *victim)
  33. {
  34. boolean leveledUp = false;
  35.  
  36. // No experience for self-kills :P
  37. if(player == victim->player)
  38. return;
  39.  
  40. // Experience scale is based on spawnhealth for simplicity
  41. if(victim->flags & MF_COUNTKILL)
  42. player->experience += victim->info->spawnhealth;
  43. else
  44. player->experience += 10; // Anything non-COUNTKILL gives 10 EXP
  45.  
  46. if(victim->player && victim->player->class != PCLASS_PIG)
  47. player->experience += 1000; // non-pig player kill bonus
  48.  
  49. while(player->experience >= P_MaxExpForLevel(player->level))
  50. {
  51. player->level++;
  52. leveledUp = true;
  53. }
  54.  
  55. if(leveledUp)
  56. {
  57. static char msg[128];
  58.  
  59. snprintf(msg, sizeof(msg), "PIG IS NOW LEVEL %d!", player->level+1);
  60. P_SetMessage(player, msg, true);
  61. S_StartSound(player->mo, SFX_PUZZLE_SUCCESS); // FLONG!
  62. }
  63. }
Add Comment
Please, Sign In to add comment