private void cap_exp_gain(Game_Unit battler, Game_Unit target, ref int expGain) { if (expGain != 0) { expGain = (expGain > 0 ? Math.Min(expGain, battler.actor.exp_gain_possible()) : Math.Max(expGain, -battler.actor.exp_loss_possible())); // If unit is not playable, don't allow level ups if (!battler.is_player_team) { expGain = Math.Min(expGain, Global.ActorConfig.ExpToLvl - (battler.actor.exp + 1)); } // Caps total exp gain per individual unit if (expGain > 0 && exp_gain_cap(target)) { expGain = target.cap_exp_given(expGain); } } }