public static uint XPGain(Player player, Unit u, bool isBattleGround = false) { Creature creature = u.ToCreature(); uint gain = 0; if (!creature || creature.CanGiveExperience()) { float xpMod = 1.0f; gain = BaseGain(player.getLevel(), u.getLevel()); if (gain != 0 && creature) { // Players get only 10% xp for killing creatures of lower expansion levels than himself if ((creature.GetCreatureTemplate().HealthScalingExpansion < (int)GetExpansionForLevel(player.getLevel()))) { gain = (uint)Math.Round(gain / 10.0f); } if (creature.isElite()) { // Elites in instances have a 2.75x XP bonus instead of the regular 2x world bonus. if (u.GetMap().IsDungeon()) { xpMod *= 2.75f; } else { xpMod *= 2.0f; } } xpMod *= creature.GetCreatureTemplate().ModExperience; } xpMod *= isBattleGround ? WorldConfig.GetFloatValue(WorldCfg.RateXpBgKill) : WorldConfig.GetFloatValue(WorldCfg.RateXpKill); if (creature && creature.m_PlayerDamageReq != 0) // if players dealt less than 50% of the damage and were credited anyway (due to CREATURE_FLAG_EXTRA_NO_PLAYER_DAMAGE_REQ), scale XP gained appropriately (linear scaling) { xpMod *= 1.0f - 2.0f * creature.m_PlayerDamageReq / creature.GetMaxHealth(); } gain = (uint)(gain * xpMod); } Global.ScriptMgr.OnGainCalculation(gain, player, u); return(gain); }