public void RefreshPetHandle(GameClient client, bool refreshBtn, string msg) { int num = Convert.ToInt32(PetMgr.FindConfig("AdoptRefereshCost").Value); int templateId = Convert.ToInt32(PetMgr.FindConfig("FreeRefereshID").Value); ItemInfo itemByTemplateID = client.Player.PropBag.GetItemByTemplateID(0, templateId); if (refreshBtn) { if (itemByTemplateID != null) { client.Player.PropBag.RemoveTemplate(templateId, 1); } else { if (client.Player.PlayerCharacter.Money >= num) { client.Player.RemoveMoney(num); client.Player.AddPetScore(num / 10); } else { client.Player.SendMessage(msg); } } List <UsersPetinfo> list = PetMgr.CreateAdoptList(client.Player.PlayerCharacter.ID); client.Player.PetBag.ClearAdoptPets(); foreach (UsersPetinfo current in list) { client.Player.PetBag.AddAdoptPetTo(current, current.Place); } } client.Player.Out.SendRefreshPet(client.Player, client.Player.PetBag.GetAdoptPet(), null, refreshBtn); }
public virtual void CreateFarm(int ID, string name) { string value = PetMgr.FindConfig("PayFieldMoney").Value; string value2 = PetMgr.FindConfig("PayAutoMoney").Value; UserFarmInfo userFarmInfo = new UserFarmInfo(); userFarmInfo.FarmID = ID; userFarmInfo.FarmerName = name; userFarmInfo.isFarmHelper = false; userFarmInfo.isAutoId = 0; userFarmInfo.AutoPayTime = DateTime.Now; userFarmInfo.AutoValidDate = 1; userFarmInfo.GainFieldId = 0; userFarmInfo.KillCropId = 0; userFarmInfo.PayAutoMoney = value2; userFarmInfo.PayFieldMoney = value; object @lock; Monitor.Enter(@lock = this.m_lock); try { this.m_farm = userFarmInfo; } finally { Monitor.Exit(@lock); } this.CreateNewField(ID, 0, 8); }
public int GetPetBaseAtt() { try { string[] array = this.m_pet.SkillEquip.Split(new char[] { '|' }); for (int i = 0; i < array.Length; i++) { int skillID = Convert.ToInt32(array[i].Split(new char[] { ',' })[0]); PetSkillInfo petSkillInfo = PetMgr.FindPetSkill(skillID); if (petSkillInfo != null && petSkillInfo.Damage > 0) { int result = petSkillInfo.Damage; return(result); } } } catch (Exception ex) { Console.WriteLine("______________GetPetBaseAtt ERROR______________"); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.WriteLine("_______________________________________________"); int result = 0; return(result); } return(0); }
public static void HandleListStabledPets(IRealmClient client, RealmPacketIn packet) { EntityId id = packet.ReadEntityId(); Character activeCharacter = client.ActiveCharacter; NPC stableMaster = activeCharacter.Map.GetObject(id) as NPC; PetMgr.ListStabledPets(activeCharacter, stableMaster); }
/// <summary> /// Makes this the pet of the given owner /// </summary> internal void MakePet(uint ownerId) { PetRecord = PetMgr.CreatePermanentPetRecord(Entry, ownerId); if (!HasTalents && IsHunterPet) { m_petTalents = new PetTalentCollection(this); } }
public static void HandleListStabledPets(IRealmClient client, RealmPacketIn packet) { var guid = packet.ReadEntityId(); var chr = client.ActiveCharacter; var stableMaster = chr.Map.GetObject(guid) as NPC; PetMgr.ListStabledPets(chr, stableMaster); }
public static void HandleStableSwapPet(IRealmClient client, RealmPacketIn packet) { EntityId id = packet.ReadEntityId(); uint petNumber = packet.ReadUInt32(); Character activeCharacter = client.ActiveCharacter; NPC stableMaster = activeCharacter.Map.GetObject(id) as NPC; PetMgr.SwapStabledPet(activeCharacter, stableMaster, petNumber); }
public static void HandleStableSwapPet(IRealmClient client, RealmPacketIn packet) { var guid = packet.ReadEntityId(); var petNumber = packet.ReadUInt32(); var chr = client.ActiveCharacter; var stableMaster = chr.Map.GetObject(guid) as NPC; PetMgr.SwapStabledPet(chr, stableMaster, petNumber); }
public void TestBeastMasteryEffects() { Master.Level = 50; Cat.Level = 50; Master.Talents.LearnAll(); TestMakePet(); var basePoints = PetMgr.GetPetTalentPointsByLevel(Cat.Level); Cat.FreeTalentPoints = basePoints; Asser.GreaterThan(Cat.FreeTalentPoints, basePoints); }
public void ResetFreeTalentPoints() { var points = 0; var owner = m_master as Character; if (owner != null) { points += owner.PetBonusTalentPoints; } points += PetMgr.GetPetTalentPointsByLevel(Level); FreeTalentPoints = points; }
public void RevertPetHandle(GameClient client, int place, string msg) { int num = Convert.ToInt32(PetMgr.FindConfig("RecycleCost").Value); if (client.Player.PlayerCharacter.Money >= num) { UsersPetinfo petAt = client.Player.PetBag.GetPetAt(place); UsersPetinfo usersPetinfo = new UsersPetinfo(); ItemTemplateInfo goods = ItemMgr.FindItemTemplate(334100); ItemInfo itemInfo = ItemInfo.CreateFromTemplate(goods, 1, 0); itemInfo.IsBinds = true; itemInfo.DefendCompose = petAt.GP; itemInfo.AgilityCompose = petAt.MaxGP; if (!client.Player.PropBag.AddTemplate(itemInfo, 1)) { client.Player.SendItemToMail(itemInfo, LanguageMgr.GetTranslation("UserChangeItemPlaceHandler.full", new object[0]), LanguageMgr.GetTranslation("UserChangeItemPlaceHandler.full", new object[0]), eMailType.ItemOverdue); client.Player.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Receiver); } int iD = petAt.ID; using (PlayerBussiness playerBussiness = new PlayerBussiness()) { usersPetinfo = playerBussiness.GetAdoptPetSingle(iD); } petAt.Blood = usersPetinfo.Blood; petAt.Attack = usersPetinfo.Attack; petAt.Defence = usersPetinfo.Defence; petAt.Agility = usersPetinfo.Agility; petAt.Luck = usersPetinfo.Luck; int arg_158_0 = client.Player.PlayerCharacter.ID; int templateID = usersPetinfo.TemplateID; petAt.TemplateID = templateID; petAt.Skill = usersPetinfo.Skill; petAt.SkillEquip = usersPetinfo.SkillEquip; petAt.GP = 0; petAt.Level = 1; petAt.MaxGP = 55; bool flag = client.Player.PetBag.UpGracePet(petAt, place, false, 0, 0, ref msg); client.Player.SendMessage("Phục hồi thành công!"); client.Player.RemoveMoney(num); if (flag) { client.Player.Out.SendUpdatePetInfo(client.Player.PlayerCharacter, client.Player.PetBag.GetPets()); return; } } else { client.Player.SendMessage(msg); } }
public static BaseGame StartPVEGame(int roomId, List <IGamePlayer> players, int copyId, eRoomType roomType, eGameType gameType, int timeType, eHardLevel hardLevel, int levelLimits) { BaseGame result; try { List <PetSkillElementInfo> gameNeedPetSkillInfoList = PetMgr.GameNeedPetSkill(); PveInfo pveInfo; if (copyId == 0 || copyId == 100000) { pveInfo = PveInfoMgr.GetPveInfoByType(roomType, levelLimits); } else { pveInfo = PveInfoMgr.GetPveInfoById(copyId); } if (pveInfo != null) { PVEGame pVEGame = new PVEGame(GameMgr.m_gameId++, roomId, pveInfo, players, null, roomType, gameType, timeType, hardLevel, gameNeedPetSkillInfoList); pVEGame.GameOverLog += new BaseGame.GameOverLogEventHandle(LogMgr.LogFightAdd); List <BaseGame> games; Monitor.Enter(games = GameMgr.m_games); try { GameMgr.m_games.Add(pVEGame); } finally { Monitor.Exit(games); } pVEGame.Prepare(); result = pVEGame; } else { result = null; } } catch (Exception exception) { GameMgr.log.Error("Create game error:", exception); result = null; } return(result); }
/// <summary> /// Tries to have this Character purchase another Stable Slot. /// </summary> /// <returns>True if successful.</returns> public bool TryBuyStableSlot() { if (StableSlotCount >= PetMgr.MaxStableSlots) { return(false); } var price = PetMgr.GetStableSlotPrice(StableSlotCount); if (Money < price) { return(false); } Money -= price; StableSlotCount++; return(true); }
public void PetUseKill(int skillID) { if (skillID == this.skillcu) { return; } this.skillcu = skillID; PetSkillInfo petSkillInfo = PetMgr.FindPetSkill(skillID); this.m_game.SendPetUseKill(this, skillID, true); if (petSkillInfo.NewBallID != -1) { this.m_delay += petSkillInfo.Delay; this.SetBall(petSkillInfo.NewBallID); base.critActive = true; } base.PetMP -= petSkillInfo.CostMP; this.CurrentDamagePlus += (float)(petSkillInfo.DamageCrit / 100); }
/// <summary> /// Validates the given name and sends the reason if it was not valid. /// </summary> /// <param name="chr">The pet's owner.</param> /// <param name="name">The proposed name.</param> /// <returns>True if the name is kosher.</returns> public PetNameInvalidReason TrySetPetName(Character chr, string name) { if (!PetMgr.InfinitePetRenames && !chr.GodMode) { if (!PetState.HasFlag(PetState.CanBeRenamed)) { return(PetNameInvalidReason.Invalid); } } var response = PetMgr.ValidatePetName(ref name); if (response != PetNameInvalidReason.Ok) { return(response); } Name = name; // also sets the timestamp PetState &= ~PetState.CanBeRenamed; return(response); }
internal T GetOrCreatePetRecord <T>(NPCEntry entry, IList <T> list) where T : IPetRecord, new() { foreach (var record in list) { if (record.EntryId == entry.NPCId) { return(record); } } if (typeof(T) == typeof(SummonedPetRecord)) { m_record.PetSummonedCount++; } else { m_record.PetCount++; } return(PetMgr.CreateDefaultPetRecord <T>(entry, m_record.EntityLowId)); }
public virtual bool UpGracePet(UsersPetinfo pet, int place, bool isUpdateProp, int min, int max, ref string msg) { if (isUpdateProp) { int blood = 0; int attack = 0; int defence = 0; int agility = 0; int luck = 0; PetMgr.PlusPetProp(pet, min, max, ref blood, ref attack, ref defence, ref agility, ref luck); pet.Blood = blood; pet.Attack = attack; pet.Defence = defence; pet.Agility = agility; pet.Luck = luck; int num = PetMgr.UpdateEvolution(pet.TemplateID, max); pet.TemplateID = ((num == 0) ? pet.TemplateID : num); string skill = pet.Skill; string text = PetMgr.UpdateSkillPet(max, pet.TemplateID); pet.Skill = ((text == "") ? skill : text); pet.SkillEquip = PetMgr.ActiveEquipSkill(max); if (max > min) { msg = pet.Name + " thăng cấp " + max; } } object @lock; Monitor.Enter(@lock = this.m_lock); try { this.m_pets[place] = pet; } finally { Monitor.Exit(@lock); } return(true); }
public static BaseGame StartPVPGame(int roomId, List <IGamePlayer> red, List <IGamePlayer> blue, int mapIndex, eRoomType roomType, eGameType gameType, int timeType) { BaseGame result; try { int mapIndex2 = MapMgr.GetMapIndex(mapIndex, (byte)roomType, GameMgr.m_serverId); Map map = MapMgr.CloneMap(mapIndex2); List <PetSkillElementInfo> gameNeedPetSkillInfoList = PetMgr.GameNeedPetSkill(); if (map != null) { PVPGame pVPGame = new PVPGame(GameMgr.m_gameId++, roomId, red, blue, map, roomType, gameType, timeType, gameNeedPetSkillInfoList); pVPGame.GameOverLog += new BaseGame.GameOverLogEventHandle(LogMgr.LogFightAdd); List <BaseGame> games; Monitor.Enter(games = GameMgr.m_games); try { GameMgr.m_games.Add(pVPGame); } finally { Monitor.Exit(games); } pVPGame.Prepare(); result = pVPGame; } else { result = null; } } catch (Exception exception) { GameMgr.log.Error("Create game error:", exception); result = null; } return(result); }
public static BattleGame StartBattleGame(List <IGamePlayer> red, ProxyRoom roomRed, List <IGamePlayer> blue, ProxyRoom roomBlue, int mapIndex, eRoomType roomType, eGameType gameType, int timeType) { BattleGame result; try { int mapIndex2 = MapMgr.GetMapIndex(mapIndex, (byte)roomType, GameMgr.m_serverId); Map map = MapMgr.CloneMap(mapIndex2); List <PetSkillElementInfo> gameNeedPetSkill = PetMgr.GameNeedPetSkill(); if (map != null) { BattleGame battleGame = new BattleGame(GameMgr.m_gameId++, red, roomRed, blue, roomBlue, map, roomType, gameType, timeType, gameNeedPetSkill); Dictionary <int, BaseGame> games; Monitor.Enter(games = GameMgr.m_games); try { GameMgr.m_games.Add(battleGame.Id, battleGame); } finally { Monitor.Exit(games); } battleGame.Prepare(); GameMgr.SendStartMessage(battleGame); result = battleGame; } else { result = null; } } catch (Exception exception) { GameMgr.log.Error("Create battle game error:", exception); result = null; } return(result); }
public int HandlePacket(GameClient client, GSPacketIn packet) { byte b = packet.ReadByte(); string text = "Xu không đủ!"; int num = 1; switch (b) { case 1: this.UpdatePetHandle(client, packet.ReadInt()); break; case 2: { Console.WriteLine("//ADD_PET "); int place = packet.ReadInt(); num = packet.ReadInt(); int iD = client.Player.PlayerCharacter.ID; int num2 = client.Player.PetBag.FindFirstEmptySlot(); if (num2 == -1) { client.Player.SendMessage("Số lượng pet đã đạt giới hạn!"); } else { ItemInfo itemAt = client.Player.GetItemAt((eBageType)num, place); PetTemplateInfo petTemplateInfo = PetMgr.FindPetTemplate(itemAt.Template.Property5); UsersPetinfo usersPetinfo = PetMgr.CreatePet(petTemplateInfo, iD, num2); using (PlayerBussiness playerBussiness = new PlayerBussiness()) { usersPetinfo.IsExit = false; playerBussiness.AddUserAdoptPet(usersPetinfo, true); } usersPetinfo.IsExit = true; PlayerInventory inventory = client.Player.GetInventory((eBageType)num); if (inventory.RemoveCountFromStack(itemAt, 1)) { client.Player.PetBag.AddPetTo(usersPetinfo, num2); client.Player.SendMessage("Bạn nhận được 1 " + petTemplateInfo.Name); } client.Player.SaveIntoDatabase(); } break; } case 3: { int num3 = packet.ReadInt(); break; } case 4: { int place = packet.ReadInt(); num = packet.ReadInt(); int num3 = packet.ReadInt(); bool flag = false; ItemInfo itemAt2 = client.Player.GetItemAt((eBageType)num, place); if (itemAt2 == null) { client.Player.SendMessage("Vật phẩm lạ không tìm thấy!!! Hack chăng???!!!"); return(0); } int num4 = Convert.ToInt32(PetMgr.FindConfig("MaxHunger").Value); int num5 = Convert.ToInt32(PetMgr.FindConfig("MaxLevel").Value); UsersPetinfo petAt = client.Player.PetBag.GetPetAt(num3); int num6 = itemAt2.Count; int property = itemAt2.Template.Property2; int property2 = itemAt2.Template.Property3; int num7 = num6 * property2; int num8 = num7 + petAt.Hunger; int num9 = num6 * property; text = ""; if (itemAt2.TemplateID == 334100) { num9 = itemAt2.DefendCompose; } if (petAt.Level > 11 && itemAt2.TemplateID == 334100) { text = "Pet level 10 trở xuống mới dùng đuợc " + itemAt2.Template.Name; } else { if (petAt.Level < num5) { num9 += petAt.GP; int level = petAt.Level; int level2 = PetMgr.GetLevel(num9); int gP = PetMgr.GetGP(level2 + 1); int gP2 = PetMgr.GetGP(num5); int num10 = num9; if (num9 > gP2) { num9 -= gP2; if (num9 >= property && property != 0) { num6 = num9 / property; } } petAt.GP = ((num10 >= gP2) ? gP2 : num10); petAt.Level = level2; petAt.MaxGP = ((gP == 0) ? gP2 : gP); petAt.Hunger = ((num8 > num4) ? num4 : num8); flag = client.Player.PetBag.UpGracePet(petAt, num3, true, level, level2, ref text); if (itemAt2.TemplateID == 334100) { client.Player.StoreBag.RemoveItem(itemAt2); } else { client.Player.StoreBag.RemoveCountFromStack(itemAt2, num6); client.Player.OnUsingItem(itemAt2.TemplateID); } } else { int hunger = petAt.Hunger; int num11 = num4 - hunger; if (num8 >= num4 && num8 >= property2) { num6 = num8 / property2; } num8 = hunger + num11; petAt.Hunger = num8; if (hunger < num4) { client.Player.StoreBag.RemoveCountFromStack(itemAt2, num6); flag = client.Player.PetBag.UpGracePet(petAt, num3, false, 0, 0, ref text); text = "Ðộ vui vẻ tang thêm " + num11; } else { text = "Ðộ vui vui đã đạt mức tối da"; } } } if (flag) { UsersPetinfo[] pets = client.Player.PetBag.GetPets(); client.Player.Out.SendUpdatePetInfo(client.Player.PlayerCharacter, pets); } if (!string.IsNullOrEmpty(text)) { client.Player.SendMessage(text); } break; } case 5: { bool refreshBtn = packet.ReadBoolean(); this.RefreshPetHandle(client, refreshBtn, text); break; } case 6: { int num3 = packet.ReadInt(); int num12 = client.Player.PetBag.FindFirstEmptySlot(); if (num12 == -1) { client.Player.Out.SendRefreshPet(client.Player, client.Player.PetBag.GetAdoptPet(), null, false); client.Player.SendMessage("Số lượng pet đã đạt giới hạn!"); } else { UsersPetinfo adoptPetAt = client.Player.PetBag.GetAdoptPetAt(num3); if (client.Player.PetBag.AddPetTo(adoptPetAt, num12)) { client.Player.PetBag.RemoveAdoptPet(adoptPetAt); client.Player.OnAdoptPetEvent(); } } break; } case 7: { int num3 = packet.ReadInt(); int killId = packet.ReadInt(); int killindex = packet.ReadInt(); if (client.Player.PetBag.EquipSkillPet(num3, killId, killindex)) { UsersPetinfo[] pets = client.Player.PetBag.GetPets(); client.Player.Out.SendUpdatePetInfo(client.Player.PlayerCharacter, pets); } else { client.Player.SendMessage("Skill này đã trang bị!"); } break; } case 8: { int num3 = packet.ReadInt(); UsersPetinfo petAt2 = client.Player.PetBag.GetPetAt(num3); if (client.Player.PetBag.RemovePet(petAt2)) { using (PlayerBussiness playerBussiness2 = new PlayerBussiness()) { playerBussiness2.UpdateUserAdoptPet(petAt2.ID); } } client.Player.SendMessage("Thả pet thành công!"); break; } case 9: { int num3 = packet.ReadInt(); string name = packet.ReadString(); int num13 = Convert.ToInt32(PetMgr.FindConfig("ChangeNameCost").Value); if (client.Player.PlayerCharacter.Money >= num13) { if (client.Player.PetBag.RenamePet(num3, name)) { UsersPetinfo[] pets = client.Player.PetBag.GetPets(); client.Out.SendUpdatePetInfo(client.Player.PlayerCharacter, pets); text = "Đổi tên thành công!"; } client.Player.RemoveMoney(num13); } client.Player.SendMessage(text); break; } case 16: { Console.WriteLine("//PAY_SKILL "); int num3 = packet.ReadInt(); break; } case 17: { int num3 = packet.ReadInt(); bool isEquip = packet.ReadBoolean(); if (client.Player.PetBag.SetIsEquip(num3, isEquip)) { UsersPetinfo[] pets = client.Player.PetBag.GetPets(); client.Player.MainBag.UpdatePlayerProperties(); client.Player.Out.SendUpdatePetInfo(client.Player.PlayerCharacter, pets); } break; } case 18: { int num3 = packet.ReadInt(); this.RevertPetHandle(client, num3, text); break; } case 19: { Console.WriteLine("//BUY_PET_EXP_ITEM "); bool buyPetExpItem = packet.ReadBoolean(); int GoodsID = packet.ReadInt(); int count = 20 * 80; ShopItemInfo shopItem = ShopMgr.GetShopItemInfoById(GoodsID); SqlDataProvider.Data.ItemInfo item = SqlDataProvider.Data.ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(334103), 20, 0x66); client.Player.RemoveMoney(count); client.Player.AddItem(item); text = "Mua thức ăn thành công."; client.Player.SendMessage(text); break; } } client.Player.PetBag.SaveToDatabase(); return(0); }
/// <summary>Add default Gossip options for Vendors etc</summary> private static void AddDefaultGossipOptions() { foreach (NPCEntry entry1 in NPCMgr.Entries) { NPCEntry entry = entry1; if (entry != null && entry.NPCFlags.HasAnyFlag(NPCFlags.Gossip)) { GossipMenu gossipMenu = entry.DefaultGossip; if (gossipMenu == null) { entry.DefaultGossip = gossipMenu = new GossipMenu(); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.Banker)) { gossipMenu.AddItem((GossipMenuItemBase) new LocalizedGossipMenuItem(GossipMenuIcon.Bank, (GossipActionHandler)(convo => convo.Character.OpenBank(convo.Speaker)), RealmLangKey.GossipOptionBanker, new object[0])); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.BattleMaster)) { gossipMenu.AddItem((GossipMenuItemBase) new GossipMenuItem(GossipMenuIcon.Battlefield, "Battlefield...", (GossipActionHandler)(convo => { if (entry.BattlegroundTemplate == null) { return; } ((NPC)convo.Speaker).TalkToBattlemaster(convo.Character); }))); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.InnKeeper)) { gossipMenu.AddItem((GossipMenuItemBase) new LocalizedGossipMenuItem(GossipMenuIcon.Bind, (GossipActionHandler)(convo => convo.Character.BindTo((NPC)convo.Speaker)), RealmLangKey.GossipOptionInnKeeper, new object[0])); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.GuildBanker)) { gossipMenu.AddItem((GossipMenuItemBase) new GossipMenuItem(GossipMenuIcon.Guild, "Guild Bank...", (GossipActionHandler)(convo => convo.Character.SendSystemMessage(RealmLangKey.FeatureNotYetImplemented, new object[0])))); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.SpiritHealer)) { gossipMenu.AddItem((GossipMenuItemBase) new LocalizedGossipMenuItem(GossipMenuIcon.Resurrect, (GossipActionHandler)(convo => convo.Character.ResurrectWithConsequences()), RealmLangKey.GossipOptionSpiritHealer, new object[0])); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.Petitioner)) { gossipMenu.AddItem((GossipMenuItemBase) new GossipMenuItem(GossipMenuIcon.Bank, "Petitions...", (GossipActionHandler)(convo => ((NPC)convo.Speaker).SendPetitionList(convo.Character)))); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.TabardDesigner)) { gossipMenu.AddItem((GossipMenuItemBase) new LocalizedGossipMenuItem(GossipMenuIcon.Tabard, (GossipActionHandler)(convo => convo.Character.SendSystemMessage(RealmLangKey.FeatureNotYetImplemented, new object[0])), RealmLangKey.GossipOptionTabardDesigner, new object[0])); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.FlightMaster)) { gossipMenu.AddItem((GossipMenuItemBase) new LocalizedGossipMenuItem(GossipMenuIcon.Taxi, (GossipActionHandler)(convo => ((NPC)convo.Speaker).TalkToFM(convo.Character)), RealmLangKey.GossipOptionFlightMaster, new object[0])); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.StableMaster)) { gossipMenu.AddItem((GossipMenuItemBase) new LocalizedGossipMenuItem( (GossipActionHandler)(convo => PetMgr.ListStabledPets(convo.Character, (NPC)convo.Speaker)), RealmLangKey.GossipOptionStableMaster, new object[0])); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.AnyTrainer)) { gossipMenu.AddItem((GossipMenuItemBase) new LocalizedGossipMenuItem(GossipMenuIcon.Taxi, (GossipActionHandler)(convo => ((NPC)convo.Speaker).TalkToTrainer(convo.Character)), RealmLangKey.GossipOptionTrainer, new object[0])); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.AnyVendor)) { gossipMenu.AddItem((GossipMenuItemBase) new LocalizedGossipMenuItem(GossipMenuIcon.Trade, (GossipActionHandler)(convo => { if (((NPC)convo.Speaker).VendorEntry == null) { return; } ((NPC)convo.Speaker).VendorEntry.UseVendor(convo.Character); }), RealmLangKey.GossipOptionVendor, new object[0])); } } } }
/// <summary> /// Add default Gossip options for Vendors etc /// </summary> private static void AddDefaultGossipOptions() { foreach (var _entry in NPCMgr.Entries) { var entry = _entry; // copy object to prevent access to modified closure in callbacks if (entry != null) { if (entry.NPCFlags.HasAnyFlag(NPCFlags.Gossip)) { var menu = entry.DefaultGossip; if (menu == null) { entry.DefaultGossip = menu = new GossipMenu(); } //else if (menu.GossipItems.Count > 0) //{ // // Talk option -> Should it be in a sub menu? // entry.DefaultGossip = menu = new GossipMenu(menu.GossipEntry, new GossipMenuItem("Talk") // { // SubMenu = menu // }); //} // NPC professions if (entry.NPCFlags.HasAnyFlag(NPCFlags.Banker)) { menu.AddItem(new LocalizedGossipMenuItem(GossipMenuIcon.Bank, convo => { convo.Character.OpenBank(convo.Speaker); }, RealmLangKey.GossipOptionBanker)); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.BattleMaster)) { menu.AddItem(new GossipMenuItem(GossipMenuIcon.Battlefield, "Battlefield...", convo => { if (entry.BattlegroundTemplate != null) { ((NPC)convo.Speaker).TalkToBattlemaster(convo.Character); } })); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.InnKeeper)) { menu.AddItem(new LocalizedGossipMenuItem(GossipMenuIcon.Bind, convo => { convo.Character.BindTo((NPC)convo.Speaker); }, RealmLangKey.GossipOptionInnKeeper)); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.GuildBanker)) { menu.AddItem(new GossipMenuItem(GossipMenuIcon.Guild, "Guild Bank...", convo => { convo.Character.SendSystemMessage(RealmLangKey.FeatureNotYetImplemented); })); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.SpiritHealer)) { menu.AddItem(new LocalizedGossipMenuItem(GossipMenuIcon.Resurrect, convo => { convo.Character.ResurrectWithConsequences(); }, RealmLangKey.GossipOptionSpiritHealer)); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.Petitioner)) { menu.AddItem(new GossipMenuItem(GossipMenuIcon.Bank, "Petitions...", convo => { ((NPC)convo.Speaker).SendPetitionList(convo.Character); })); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.TabardDesigner)) { menu.AddItem(new LocalizedGossipMenuItem(GossipMenuIcon.Tabard, convo => { convo.Character.SendSystemMessage(RealmLangKey.FeatureNotYetImplemented); }, RealmLangKey.GossipOptionTabardDesigner)); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.FlightMaster)) { menu.AddItem(new LocalizedGossipMenuItem(GossipMenuIcon.Taxi, convo => { ((NPC)convo.Speaker).TalkToFM(convo.Character); }, RealmLangKey.GossipOptionFlightMaster)); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.StableMaster)) { menu.AddItem(new LocalizedGossipMenuItem(convo => { PetMgr.ListStabledPets(convo.Character, ((NPC)convo.Speaker)); }, RealmLangKey.GossipOptionStableMaster)); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.AnyTrainer)) { menu.AddItem(new LocalizedGossipMenuItem(GossipMenuIcon.Train, convo => { ((NPC)convo.Speaker).TalkToTrainer(convo.Character); }, RealmLangKey.GossipOptionTrainer)); } if (entry.NPCFlags.HasAnyFlag(NPCFlags.AnyVendor)) { menu.AddItem(new LocalizedGossipMenuItem(GossipMenuIcon.Trade, convo => { if (((NPC)convo.Speaker).VendorEntry != null) { ((NPC)convo.Speaker).VendorEntry.UseVendor(convo.Character); } }, RealmLangKey.GossipOptionVendor)); } } } } }
public int HandlePacket(GameClient client, GSPacketIn packet) { byte b = packet.ReadByte(); if (client.Player.PlayerCharacter.GP < 1437053) { client.Out.SendMessage(eMessageType.Normal, "Hack level sao bạn!"); return(0); } if (client.Player.PlayerCharacter.Grade < 25) { client.Out.SendMessage(eMessageType.Normal, "Hack level sao bạn!"); return(0); } switch (b) { case 0: Console.WriteLine("//FRUSH_FIELD "); break; case 1: { int num = packet.ReadInt(); if (num == client.Player.PlayerCharacter.ID) { client.Player.Farm.EnterFarm(); if (client.Player.PlayerCharacter.IsFistGetPet) { List <UsersPetinfo> list = PetMgr.CreateFirstAdoptList(num); client.Player.PetBag.ClearAdoptPets(); foreach (UsersPetinfo current in list) { client.Player.PetBag.AddAdoptPetTo(current, current.Place); } client.Player.RemoveFistGetPet(); } else { if (client.Player.PlayerCharacter.LastRefreshPet.Date < DateTime.Now.Date) { List <UsersPetinfo> list2 = PetMgr.CreateAdoptList(num); client.Player.PetBag.ClearAdoptPets(); foreach (UsersPetinfo current2 in list2) { client.Player.PetBag.AddAdoptPetTo(current2, current2.Place); } client.Player.RemoveLastRefreshPet(); } } client.Player.Farm.CropHelperSwitchField(false); } else { client.Player.Farm.EnterFriendFarm(num); } break; } case 2: { packet.ReadByte(); int num2 = packet.ReadInt(); int fieldId = packet.ReadInt(); if (client.Player.Farm.GrowField(fieldId, num2)) { client.Player.FarmBag.RemoveTemplate(num2, 1); client.Player.OnSeedFoodPetEvent(); } break; } case 3: packet.ReadByte(); packet.ReadInt(); packet.ReadInt(); packet.ReadInt(); Console.WriteLine("//ACCELERATE_FIELD "); break; case 4: { int num3 = packet.ReadInt(); int fieldId2 = packet.ReadInt(); string message = "Giờ bạn khác giờ hệ thống. Vui lòng chờ một lúc sau rồi vào thu hoạch lại nhé!"; if (num3 == client.Player.PlayerCharacter.ID) { if (client.Player.Farm.GainField(fieldId2)) { message = "Thu hoạch thành công!"; } } else { if (client.Player.Farm.GainFriendFields(num3, fieldId2)) { message = "Thao tác thành công."; } else { message = "Không thể chộm nửa."; } } client.Player.Out.SendMessage(eMessageType.Normal, message); break; } case 5: packet.ReadInt(); packet.ReadInt(); Console.WriteLine("//COMPOSE_FOOD "); break; case 6: { string message2 = "Mở rộng thành công!"; List <int> list3 = new List <int>(); int num4 = packet.ReadInt(); for (int i = 0; i < num4; i++) { int item = packet.ReadInt(); list3.Add(item); } int num5 = packet.ReadInt(); PlayerFarm farm = client.Player.Farm; int num6; if (farm.payFieldTimeToMonth() == num5) { num6 = num4 * farm.payFieldMoneyToMonth(); } else { num6 = num4 * farm.payFieldMoneyToWeek(); } if (client.Player.PlayerCharacter.Money >= num6) { farm.PayField(list3, num5); client.Player.RemoveMoney(num6); } else { message2 = "Xu không đủ!"; } client.Out.SendMessage(eMessageType.Normal, message2); break; } case 7: { int fieldId3 = packet.ReadInt(); client.Player.Farm.killCropField(fieldId3); break; } case 8: Console.WriteLine("//HELPER_PAY_FIELD "); break; case 9: { string message3 = "Chức năng này hiện đang bảo trì."; bool flag = packet.ReadBoolean(); int seedID = packet.ReadInt(); int seedTime = packet.ReadInt(); int haveCount = packet.ReadInt(); int getCount = packet.ReadInt(); int num7 = packet.ReadInt(); int num8 = packet.ReadInt(); bool flag2 = false; if (flag) { if (client.Player.PlayerCharacter.Money >= num8 && num7 == -1) { client.Player.RemoveMoney(num8); flag2 = true; } else { if (client.Player.PlayerCharacter.GiftToken >= num8 && num7 == -2) { client.Player.RemoveGiftToken(num8); flag2 = true; } else { if (num7 == -1) { message3 = "Xu không đủ!"; } else { message3 = "Xu khóa không đủ!"; } } } } else { message3 = "Hủy trợ thủ thành công!"; client.Player.Farm.CropHelperSwitchField(true); } if (flag2) { client.Player.Farm.HelperSwitchField(flag, seedID, seedTime, haveCount, getCount); message3 = "Kích hoạt trợ thủ thành công!"; } client.Out.SendMessage(eMessageType.Normal, message3); break; } case 16: client.Player.Farm.ExitFarm(); break; } client.Player.Farm.SaveToDatabase(); return(0); }