Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // P_MaxExpForLevel
- //
- // haleyjd 20110701: [PIG] New function
- // Calculate the max experience for a level.
- // Note the displayed level is +1 from the internal level (starts @ 0)
- //
- int P_MaxExpForLevel(int level)
- {
- int accExp = 875; // EXP needed for lv 2 (kill 5 Ettins)
- int maxExp = accExp;
- float expFactor;
- int i;
- for(i = 0; i < level; i++)
- {
- expFactor = 1.25f - ((float)i/2.0f * 0.0125f); // declining exponent
- if(expFactor < 1.0f) // curve stops growing exponentially at lv 40
- expFactor = 1.0f;
- accExp = (int)(accExp * expFactor);
- maxExp += accExp;
- }
- return maxExp;
- }
- //
- // P_GiveExperience
- //
- // haleyjd 20110701: [PIG] New function
- //
- void P_GiveExperience(player_t *player, mobj_t *victim)
- {
- boolean leveledUp = false;
- // No experience for self-kills :P
- if(player == victim->player)
- return;
- // Experience scale is based on spawnhealth for simplicity
- if(victim->flags & MF_COUNTKILL)
- player->experience += victim->info->spawnhealth;
- else
- player->experience += 10; // Anything non-COUNTKILL gives 10 EXP
- if(victim->player && victim->player->class != PCLASS_PIG)
- player->experience += 1000; // non-pig player kill bonus
- while(player->experience >= P_MaxExpForLevel(player->level))
- {
- player->level++;
- leveledUp = true;
- }
- if(leveledUp)
- {
- static char msg[128];
- snprintf(msg, sizeof(msg), "PIG IS NOW LEVEL %d!", player->level+1);
- P_SetMessage(player, msg, true);
- S_StartSound(player->mo, SFX_PUZZLE_SUCCESS); // FLONG!
- }
- }
Add Comment
Please, Sign In to add comment