public bool LevelUp() { if (!ExpMetadataStorage.LevelExist((short)(Level + 1))) { return(false); } Level++; Player.Stats.AddBaseStats(Player); Player.FieldPlayer.RecoverHp(FieldPlayer.Stats[StatId.Hp].Bonus); Session.FieldManager.BroadcastPacket(RevivalConfirmPacket.Send(FieldPlayer.ObjectId, 0)); Session.FieldManager.BroadcastPacket(LevelUpPacket.LevelUp(FieldPlayer.ObjectId, Level)); Session.FieldManager.BroadcastPacket(FieldObjectPacket.UpdateCharacterLevel(Player)); Session.FieldManager.BroadcastPacket(JobPacket.SendJob(FieldPlayer)); Session.Send(StatPacket.SetStats(FieldPlayer)); Session.FieldManager.BroadcastPacket(StatPacket.UpdateFieldStats(FieldPlayer), Session); Session.Send(KeyTablePacket.SendFullOptions(Player.GameOptions)); TrophyManager.OnLevelUp(Player); QuestHelper.GetNewQuests(Player); return(true); }
public void GainExp(long amount) { if (amount <= 0 || !ExpMetadataStorage.LevelExist((short)(Level + 1))) { return; } long newExp = Exp + amount + RestExp; if (RestExp > 0) { RestExp -= amount; } else { RestExp = 0; } bool hasLeveledUp = false; while (newExp >= ExpMetadataStorage.GetExpToLevel(Level)) { newExp -= ExpMetadataStorage.GetExpToLevel(Level); if (LevelUp()) { hasLeveledUp = true; continue; } newExp = 0; break; } Exp = newExp; Session.Send(ExperiencePacket.ExpUp(amount, newExp, RestExp)); if (!hasLeveledUp) { return; } Session.FieldManager.BroadcastPacket(RevivalConfirmPacket.Send(FieldPlayer.ObjectId, 0)); Session.FieldManager.BroadcastPacket(LevelUpPacket.LevelUp(FieldPlayer.ObjectId, Level)); Session.FieldManager.BroadcastPacket(FieldObjectPacket.UpdateCharacterLevel(Player)); // Find all new skills for current level HashSet <int> newSkillIds = SkillMetadataStorage.GetJobSkills(Player.Job) .Where(x => x.SkillLevels.First().SkillUpgrade.LevelRequired == Level) .Select(x => x.SkillId).ToHashSet(); Session.FieldManager.BroadcastPacket(JobPacket.UpdateSkillTab(FieldPlayer, newSkillIds)); Session.Send(StatPacket.SetStats(FieldPlayer)); Session.FieldManager.BroadcastPacket(StatPacket.SetStats(FieldPlayer), Session); Session.Send(KeyTablePacket.SendFullOptions(Player.GameOptions)); DatabaseManager.Characters.Update(Player); }