public static async Task AddJobExperience(this IPlayerEntity player, long amount) { player.JobLevelXp += amount; await player.TryJobLevelUp(); await player.ActualizeUiExpBar(); }
private static async Task SendCharacterInformationsPackets(IPlayerEntity player) { await player.SendPacketAsync(player.GenerateCInfoPacket()); await player.SendPacketAsync(player.GenerateCModePacket()); await player.SendPacketAsync(player.GenerateEqPacket()); await player.ActualizeUiWearPanel(); await player.ActualizeUiExpBar(); await player.SendPacketAsync(player.GenerateStatPacket()); }
public static async Task ChangeClass(this IPlayerEntity player, CharacterClassType type) { player.JobLevel = 1; player.JobLevelXp = 0; await player.SendPacketAsync(new NpInfoPacket { UnKnow = 0 }); await player.SendPacketAsync(new PClearPacket()); if (type == CharacterClassType.Adventurer) { player.Character.HairStyle = player.Character.HairStyle > HairStyleType.HairStyleB ? HairStyleType.HairStyleA : player.Character.HairStyle; } player.Character.Class = type; player.HpMax = Algorithm.GetHpMax(type, player.Level); player.MpMax = Algorithm.GetMpMax(type, player.Level); player.Hp = player.HpMax; player.Mp = player.MpMax; await player.SendPacketAsync(player.GenerateTitPacket()); await player.ActualizeUiHpBar(); await player.SendPacketAsync(player.GenerateEqPacket()); await player.SendPacketAsync(player.GenerateEffectPacket(8)); await player.SendPacketAsync(player.GenerateEffectPacket(196)); await player.SendPacketAsync(player.GenerateScrPacket()); await player.SendChatMessageFormat(PlayerMessages.CHARACTER_YOUR_CLASS_CHANGED_TO_X, SayColorType.Blue, type); player.Character.Faction = player.Family?.FamilyFaction ?? (FactionType)(1 + _randomGenerator.Next(0, 2)); await player.SendChatMessageFormat(PlayerMessages.CHARACTER_YOUR_FACTION_CHANGED_TO_X, SayColorType.Blue, player.Character.Faction); await player.ActualizeUiFaction(); await player.ActualizeUiStatChar(); await player.SendPacketAsync(player.GenerateEffectPacket(4799 + (byte)player.Character.Faction)); await player.ActualizePlayerCondition(); await player.ActualizeUiExpBar(); await player.BroadcastAsync(player.GenerateCModePacket()); await player.BroadcastAsync(player.GenerateInPacket()); await player.BroadcastAsync(player.GenerateGidxPacket()); await player.BroadcastAsync(player.GenerateEffectPacket(6)); await player.BroadcastAsync(player.GenerateEffectPacket(196)); SkillComponent component = player.SkillComponent; foreach (SkillDto skill in component.Skills.Values) { if (skill.Id >= 200) { component.Skills.Remove(skill.Id); } } // TODO : LATER ADD SKILL await player.ActualizeUiSkillList(); // Later too /* foreach (QuicklistEntryDTO quicklists in DAOFactory.QuicklistEntryDAO.LoadByCharacterId(CharacterId).Where(quicklists => QuicklistEntries.Any(qle => qle.Id == quicklists.Id))) * { * DAOFactory.QuicklistEntryDAO.Delete(quicklists.Id); * } * * QuicklistEntries = new List<QuicklistEntryDTO> * { * new QuicklistEntryDTO * { * CharacterId = CharacterId, * Q1 = 0, * Q2 = 9, * Type = 1, * Slot = 3, * Pos = 1 * } * }; * if (ServerManager.Instance.Groups.Any(s => s.IsMemberOfGroup(Session) && s.GroupType == GroupType.Group)) * { * Session.CurrentMapInstance?.Broadcast(Session, $"pidx 1 1.{CharacterId}", ReceiverType.AllExceptMe); * }*/ }
public static Task ChangeHeroLevel(this IPlayerEntity player, byte level) { player.Character.HeroLevel = level; player.Character.HeroXp = 0; return(player.ActualizeUiExpBar()); }
private static async Task HandleNpcSkillBuyRequest(IPlayerEntity player, ShopBuyEvent shopBuy, Shop shop) { ShopSkillDto skillShop = shop.Skills.FirstOrDefault(s => s.SkillId == shopBuy.Slot); if (skillShop == null) { return; } // check use sp if (player.HasSpWeared) { return; } // check skill cooldown if (player.SkillComponent.CooldownsBySkillId.Any(s => s.Item2 == shopBuy.Slot)) { return; } // check skill already exists in player skills if (player.SkillComponent.Skills.ContainsKey(shopBuy.Slot)) { return; } // check skill class if ((byte)player.Character.Class != skillShop.Skill.Class) { return; } // check skill price if (player.Character.Gold < skillShop.Skill.Price) { return; } // check skill cp if (player.GetCp() < skillShop.Skill.CpCost) { return; } // check skill minimum level byte minimumLevel = 1; switch (player.Character.Class) { case CharacterClassType.Adventurer: minimumLevel = skillShop.Skill.MinimumAdventurerLevel; break; case CharacterClassType.Swordman: minimumLevel = skillShop.Skill.MinimumSwordmanLevel; break; case CharacterClassType.Archer: minimumLevel = skillShop.Skill.MinimumArcherLevel; break; case CharacterClassType.Magician: minimumLevel = skillShop.Skill.MinimumMagicianLevel; break; case CharacterClassType.Wrestler: minimumLevel = skillShop.Skill.MinimumWrestlerLevel; break; case CharacterClassType.Unknown: break; } if (skillShop.Skill.MinimumSwordmanLevel == 0 && skillShop.Skill.MinimumArcherLevel == 0 && skillShop.Skill.MinimumMagicianLevel == 0) { minimumLevel = skillShop.Skill.MinimumAdventurerLevel; } if (minimumLevel == 0) { // can't learn the skill return; } // level is required for passive skills if (player.Character.Level < minimumLevel && skillShop.Skill.Id <= 200) { return; } // job level requirement if (player.Character.JobLevel < minimumLevel && skillShop.SkillId >= 200) { return; } if (skillShop.SkillId < 200) { foreach (CharacterSkillDto skill in player.SkillComponent.CharacterSkills.Select(s => s.Value)) { if (skillShop.Skill.CastId == skill.Skill.CastId && skill.Skill.Id < 200) { player.SkillComponent.CharacterSkills.Remove(skill.Id); } } } // check skill upgrades // remove old upgrade if (skillShop.SkillId >= 200 && skillShop.Skill.UpgradeSkill != 0) { CharacterSkillDto oldupgrade = player.SkillComponent.CharacterSkills.FirstOrDefault(s => s.Value.Skill.UpgradeSkill == skillShop.Skill.UpgradeSkill && s.Value.Skill.UpgradeType == skillShop.Skill.UpgradeType && s.Value.Skill.UpgradeSkill != 0).Value; if (oldupgrade != null) { player.SkillComponent.CharacterSkills.Remove(oldupgrade.Id); } } await player.AddCharacterSkillAsync(new CharacterSkillDto { Id = Guid.NewGuid(), SkillId = skillShop.SkillId, Skill = skillShop.Skill, CharacterId = player.Id }); player.Character.Gold -= skillShop.Skill.Price; await player.ActualizeUiGold(); await player.ActualizeUiSkillList(); await player.ActualizeUiQuicklist(); await player.SendChatMessageAsync(PlayerMessages.SKILL_YOU_LEARNED_SKILL_X, SayColorType.LightGreen); await player.ActualizeUiExpBar(); }