private void Response(PlayerObject player, NPCPage page) { player.Enqueue(new S.NPCResponse { Page = player.NPCSpeech }); ProcessSpecial(player, page); }
public override void Add(PlayerObject player) { if (player == this) return; //base.Add(player); Enqueue(player.GetInfoEx(this)); player.Enqueue(GetInfoEx(player)); player.SendHealth(this); SendHealth(player); }
public virtual void Add(PlayerObject player) { player.Enqueue(GetInfo()); }
public virtual void Add(PlayerObject player) { player.Enqueue(GetInfo()); //if (Race == ObjectType.Player) //{ // PlayerObject me = (PlayerObject)this; // player.Enqueue(me.GetInfoEx(player)); //} //else //{ // player.Enqueue(GetInfo()); //} }
public void BroadcastHealthChange() { if (Race != ObjectType.Player && Race != ObjectType.Monster) { return; } byte time = Math.Min(byte.MaxValue, (byte)Math.Max(5, (RevTime - Envir.Time) / 1000)); Packet p = new S.ObjectHealth { ObjectID = ObjectID, Percent = PercentHealth, Expire = time }; if (Envir.Time < RevTime) { CurrentMap.Broadcast(p, CurrentLocation); return; } if (Race == ObjectType.Monster && !AutoRev && Master == null) { return; } if (Race == ObjectType.Player) { if (GroupMembers != null) //Send HP to group { for (int i = 0; i < GroupMembers.Count; i++) { PlayerObject member = GroupMembers[i]; if (this == member) { continue; } if (member.CurrentMap != CurrentMap || !Functions.InRange(member.CurrentLocation, CurrentLocation, Globals.DataRange)) { continue; } member.Enqueue(p); } } return; } if (Master != null && Master.Race == ObjectType.Player) { PlayerObject player = (PlayerObject)Master; player.Enqueue(p); if (player.GroupMembers != null) //Send pet HP to group { for (int i = 0; i < player.GroupMembers.Count; i++) { PlayerObject member = player.GroupMembers[i]; if (player == member) { continue; } if (member.CurrentMap != CurrentMap || !Functions.InRange(member.CurrentLocation, CurrentLocation, Globals.DataRange)) { continue; } member.Enqueue(p); } } } if (EXPOwner != null && EXPOwner.Race == ObjectType.Player) { PlayerObject player = (PlayerObject)EXPOwner; if (player.IsMember(Master)) { return; } player.Enqueue(p); if (player.GroupMembers != null) { for (int i = 0; i < player.GroupMembers.Count; i++) { PlayerObject member = player.GroupMembers[i]; if (player == member) { continue; } if (member.CurrentMap != CurrentMap || !Functions.InRange(member.CurrentLocation, CurrentLocation, Globals.DataRange)) { continue; } member.Enqueue(p); } } } }
public virtual void Remove(PlayerObject player) { player.Enqueue(new S.ObjectRemove {ObjectID = ObjectID}); }
private void Failed(PlayerObject player) { Act(ElseActList, player); var parseElseSay = new List<String>(ElseSay); parseElseSay = ParseSay(player, parseElseSay); player.Enqueue(new S.NPCResponse { Page = parseElseSay }); }
private void Act(List<NPCActions> acts, PlayerObject player) { for (int i = 0; i < acts.Count; i++) { NPCActions act = acts[i]; uint gold; uint count; switch (act.Type) { case ActionType.Teleport: Map temp = SMain.Envir.GetMap((int) act.Params[0]); if (temp == null) return; player.Teleport(temp, (Point) act.Params[1]); break; case ActionType.GiveGold: gold = (uint)act.Params[0]; if (gold + player.Account.Gold >= uint.MaxValue) gold = uint.MaxValue - player.Account.Gold; player.GainGold(gold); break; case ActionType.TakeGold: gold = (uint) act.Params[0]; if (gold >= player.Account.Gold) gold = player.Account.Gold; player.Account.Gold -= gold; player.Enqueue(new S.LoseGold { Gold = gold }); break; case ActionType.GiveItem: count = (uint)act.Params[1]; while (count > 0) { UserItem item = SMain.Envir.CreateFreshItem((ItemInfo)act.Params[0]); if (item == null) { SMain.Enqueue(string.Format("Failed to create UserItem: {0}, Page: {1}", act.Params[0], Key)); return; } if (item.Info.StackSize > count) { item.Count = count; count = 0; } else { count -= item.Info.StackSize; item.Count = item.Info.StackSize; } if (player.CanGainItem(item, false)) player.GainItem(item); } break; case ActionType.TakeItem: ItemInfo info = (ItemInfo) act.Params[0]; count = (uint) act.Params[1]; for (int o = 0; o < player.Info.Inventory.Length; o++) { UserItem item = player.Info.Inventory[o]; if (item.Info != info) continue; if (count > item.Count) { player.Enqueue(new S.DeleteItem {UniqueID = item.UniqueID, Count = item.Count}); player.Info.Inventory[o] = null; count -= item.Count; continue; } player.Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = count }); if (count == item.Count) player.Info.Inventory[o] = null; else item.Count -= count; break; } player.RefreshStats(); break; } } }
private void Failed(PlayerObject player) { Act(ElseActList, player); player.Enqueue(new S.NPCResponse {Page = ElseSay}); }
public void Buy(PlayerObject player, int index, uint count) { ItemInfo info = null; for (int i = 0; i < Goods.Count; i++) { if (Goods[i].Index != index) continue; info = Goods[i]; break; } if (count == 0 || info == null || count > info.StackSize) return; uint cost = info.Price*count; cost = (uint) (cost*Info.PriceRate); if (cost > player.Account.Gold) return; UserItem item = Envir.CreateFreshItem(info); item.Count = count; if (!player.CanGainItem(item)) return; player.Account.Gold -= cost; player.Enqueue(new S.LoseGold {Gold = cost}); player.GainItem(item); }
private void ProcessPage(PlayerObject player, NPCPage page) { player.NPCID = ObjectID; player.NPCPage = page; player.NPCSuccess = page.Check(player); switch (page.Key) { case BuyKey: for (int i = 0; i < Goods.Count; i++) player.CheckItemInfo(Goods[i]); player.Enqueue(new S.NPCGoods {List = GoodsIndex, Rate = Info.PriceRate}); break; case SellKey: player.Enqueue(new S.NPCSell()); break; case RepairKey: player.Enqueue(new S.NPCRepair { Rate = Info.PriceRate }); break; case SRepairKey: player.Enqueue(new S.NPCSRepair { Rate = Info.PriceRate }); break; case StorageKey: player.SendStorage(); player.Enqueue(new S.NPCStorage()); break; case BuyBackKey: break; case ConsignKey: player.Enqueue(new S.NPCConsign()); break; case MarketKey: player.UserMatch = false; player.GetMarket(string.Empty, ItemType.Nothing); break; case ConsignmentsKey: player.UserMatch = true; player.GetMarket(string.Empty, ItemType.Nothing); break; } }
public override void Enqueue(Packet p) { if (p == null) { return; } switch ((ServerPacketIds)p.Index) { case ServerPacketIds.AddBuff: case ServerPacketIds.RemoveBuff: case ServerPacketIds.PauseBuff: case ServerPacketIds.MagicDelay: case ServerPacketIds.MagicLeveled: case ServerPacketIds.DeleteItem: case ServerPacketIds.UseItem: Owner.Enqueue(p); break; } }
public void NewMember(PlayerObject newmember) { if (Ranks.Count < 2) Ranks.Add(new Rank() { Name = "Members", Index = 1}); Rank currentrank = Ranks[Ranks.Count - 1]; GuildMember Member = new GuildMember() { name = newmember.Info.Name, Player = newmember, Id = newmember.Info.Index, LastLogin = Envir.Now, Online = true }; currentrank.Members.Add(Member); PlayerLogged(newmember, true, true); newmember.RefreshStats(); newmember.Enqueue(new ServerPackets.GuildBuffList() { ActiveBuffs = BuffList }); Membercount++; NeedSave = true; }
private void Success(PlayerObject player) { Act(ActList, player); var parseSay = new List<String>(Say); parseSay = ParseSay(player, parseSay); player.Enqueue(new S.NPCResponse { Page = parseSay }); }
public void Call(PlayerObject player, string key) { key = key.ToUpper(); if (!player.NPCDelayed) { if (key != MainKey) // && ObjectID != player.DefaultNPC.ObjectID { if (player.NPCID != ObjectID) return; bool found = false; if (player.NPCSuccess) { foreach (NPCSegment segment in player.NPCPage.SegmentList) { if (segment.Buttons.Any(c => c.ToUpper().Contains(key))) found = true; } } else { foreach (NPCSegment segment in player.NPCPage.SegmentList) { if (!segment.ElseButtons.Any(c => c.ToUpper().Contains(key))) found = true; } } if (!found) return; } } else { player.NPCDelayed = false; } if (key.StartsWith("[@@") && player.NPCInputStr == string.Empty) { //send off packet to request input player.Enqueue(new S.NPCRequestInput { NPCID = ObjectID, PageName = key }); return; } for (int i = 0; i < NPCPages.Count; i++) { NPCPage page = NPCPages[i]; if (!String.Equals(page.Key, key, StringComparison.CurrentCultureIgnoreCase)) continue; player.NPCSpeech = new List<string>(); foreach (NPCSegment segment in page.SegmentList) { ProcessSegment(player, page, segment); } Response(player, page); } player.NPCInputStr = string.Empty; }
private void Success(PlayerObject player) { Act(ActList, player); player.Enqueue(new S.NPCResponse {Page = Say}); }
public void SendGuildStatus(PlayerObject member) { member.Enqueue(new ServerPackets.GuildStatus() { GuildName = Name, GuildRankName = member.MyGuildRank != null? member.MyGuildRank.Name: "", Experience = Experience, MaxExperience = MaxExperience, MemberCount = Membercount, MaxMembers = MemberCap, Gold = Gold, Level = Level, Voting = Voting, SparePoints = SparePoints, ItemCount = (byte)StoredItems.Length, BuffCount = (byte)0,//(byte)BuffList.Count, MyOptions = member.MyGuildRank != null? member.MyGuildRank.Options: (RankOptions)0, MyRankId = member.MyGuildRank != null? member.MyGuildRank.Index: 256 }); }
public void Craft(PlayerObject player, ulong index, ushort count, int[] slots) { S.CraftItem p = new S.CraftItem(); RecipeInfo recipe = null; for (int i = 0; i < CraftGoods.Count; i++) { if (CraftGoods[i].Item.UniqueID != index) continue; recipe = CraftGoods[i]; break; } UserItem goods = recipe.Item; if (goods == null || count == 0 || count > goods.Info.StackSize) { player.Enqueue(p); return; } if (player.Account.Gold < recipe.Gold) { player.Enqueue(p); return; } bool hasItems = true; List<int> usedSlots = new List<int>(); //Check Tools foreach (var tool in recipe.Tools) { for (int i = 0; i < slots.Length; i++) { int slot = slots[i]; if (usedSlots.Contains(slot)) continue; if (slot < 0 || slot > player.Info.Inventory.Length) continue; UserItem item = player.Info.Inventory[slot]; if (item == null || item.Info != tool.Info) continue; usedSlots.Add(slot); if ((uint)Math.Floor(item.CurrentDura / 1000M) < count) { hasItems = false; break; } } if (!hasItems) { break; } } //Check Ingredients foreach (var ingredient in recipe.Ingredients) { if (ingredient.Count * count > ingredient.Info.StackSize) { player.Enqueue(p); return; } ushort amount = (ushort)(ingredient.Count * count); for (int i = 0; i < slots.Length; i++) { int slot = slots[i]; if (usedSlots.Contains(slot)) continue; if (slot < 0 || slot > player.Info.Inventory.Length) continue; UserItem item = player.Info.Inventory[slot]; if (item == null || item.Info != ingredient.Info) continue; usedSlots.Add(slot); if (ingredient.CurrentDura < ingredient.MaxDura && ingredient.CurrentDura > item.CurrentDura) { hasItems = false; break; } if (amount > item.Count) { hasItems = false; break; } amount = 0; break; } if (amount > 0) { hasItems = false; break; } } if (!hasItems || usedSlots.Count != (recipe.Tools.Count + recipe.Ingredients.Count)) { player.Enqueue(p); return; } if (count > (goods.Info.StackSize / goods.Count) || count < 1) { player.Enqueue(p); return; } UserItem craftedItem = Envir.CreateFreshItem(goods.Info); craftedItem.Count = (ushort)(goods.Count * count); if (!player.CanGainItem(craftedItem)) { player.Enqueue(p); return; } List<int> usedSlots2 = new List<int>(); //Use Tool Durability foreach (var tool in recipe.Tools) { for (int i = 0; i < slots.Length; i++) { int slot = slots[i]; if (usedSlots2.Contains(slot)) continue; if (slot < 0 || slot > player.Info.Inventory.Length) continue; UserItem item = player.Info.Inventory[slot]; if (item == null || item.Info != tool.Info) continue; usedSlots2.Add(slot); player.DamageItem(item, (int)(count * 1000), true); break; } } //Take Ingredients foreach (var ingredient in recipe.Ingredients) { ushort amount = (ushort)(ingredient.Count * count); for (int i = 0; i < slots.Length; i++) { int slot = slots[i]; if (usedSlots2.Contains(slot)) continue; if (slot < 0 || slot > player.Info.Inventory.Length) continue; UserItem item = player.Info.Inventory[slot]; if (item == null || item.Info != ingredient.Info) continue; usedSlots2.Add(slot); if (item.Count > amount) { player.Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = amount }); player.Info.Inventory[slot].Count -= amount; break; } else { player.Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = item.Count }); amount -= item.Count; player.Info.Inventory[slot] = null; } break; } } //Take Gold player.Account.Gold -= recipe.Gold; player.Enqueue(new S.LoseGold { Gold = recipe.Gold }); if (Envir.Random.Next(100) >= recipe.Chance + player.Stats[Stat.CraftRatePercent]) { player.ReceiveChat("Crafting attempt failed.", ChatType.System); } else { //Give Item player.GainItem(craftedItem); } p.Success = true; player.Enqueue(p); }
public override void SendHealth(PlayerObject player) { if (!player.IsMember(Master) && !(player.IsMember(EXPOwner) && AutoRev) && Envir.Time > RevTime) return; byte time = Math.Min(byte.MaxValue, (byte) Math.Max(5, (RevTime - Envir.Time)/1000)); player.Enqueue(new S.ObjectHealth { ObjectID = ObjectID, Percent = PercentHealth, Expire = time }); }
public void Call(PlayerObject player, uint objectID, string key) { key = key.ToUpper(); if (!player.NPCDelayed) { if (key != MainKey) { if (player.NPCObjectID != objectID) { return; } bool found = false; foreach (NPCSegment segment in player.NPCPage.SegmentList) { if (!player.NPCSuccess.TryGetValue(segment, out bool result)) { break; //no result for segment ? } if ((result ? segment.Buttons : segment.ElseButtons).Any(s => s.ToUpper() == key)) { found = true; } } if (!found) { MessageQueue.Enqueue(string.Format("Player: {0} was prevented access to NPC key: '{1}' ", player.Name, key)); return; } } } else { player.NPCDelayed = false; } if (key.StartsWith("[@@") && player.NPCInputStr == string.Empty) { //send off packet to request input player.Enqueue(new S.NPCRequestInput { NPCID = player.NPCObjectID, PageName = key }); return; } for (int i = 0; i < NPCPages.Count; i++) { NPCPage page = NPCPages[i]; if (!String.Equals(page.Key, key, StringComparison.CurrentCultureIgnoreCase)) { continue; } player.NPCSpeech = new List <string>(); player.NPCSuccess.Clear(); foreach (NPCSegment segment in page.SegmentList) { if (page.BreakFromSegments) { page.BreakFromSegments = false; break; } ProcessSegment(player, page, segment, objectID); } Response(player, page); } player.NPCInputStr = string.Empty; }
public virtual void Add(PlayerObject player) { if (Race == ObjectType.Merchant) { NPCObject NPC = (NPCObject)this; NPC.CheckVisible(player, true); return; } player.Enqueue(GetInfo()); //if (Race == ObjectType.Player) //{ // PlayerObject me = (PlayerObject)this; // player.Enqueue(me.GetInfoEx(player)); //} //else //{ // player.Enqueue(GetInfo()); //} }
public bool ChangeRank(PlayerObject Self, string membername, byte RankIndex, string RankName = "Members") { if ((Self.MyGuild != this) || (Self.MyGuildRank == null)) { return(false); } if (RankIndex >= Ranks.Count) { return(false); } GuildMember Member = null; Rank MemberRank = null; for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if (Ranks[i].Members[j].name == membername) { Member = Ranks[i].Members[j]; MemberRank = Ranks[i]; goto Found; } } } Found: if (Member == null) { return(false); } MirDatabase.CharacterInfo Character = Envir.GetCharacterInfo(membername); if (Character == null) { return(false); } if ((RankIndex == 0) && (Character.Level < Settings.Guild_RequiredLevel)) { Self.ReceiveChat(String.Format("A guild leader needs to be at least level {0}", Settings.Guild_RequiredLevel), ChatType.System); return(false); } if ((MemberRank.Index >= Self.MyGuildRank.Index) && (Self.MyGuildRank.Index != 0)) { return(false); } if (MemberRank.Index == 0) { if (MemberRank.Members.Count <= 2) { Self.ReceiveChat("A guild needs at least 2 leaders.", ChatType.System); return(false); } for (int i = 0; i < MemberRank.Members.Count; i++) { if ((MemberRank.Members[i].Player != null) && (MemberRank.Members[i] != Member)) { goto AllOk; } } Self.ReceiveChat("You need at least 1 leader online.", ChatType.System); return(false); } AllOk: Ranks[RankIndex].Members.Add(Member); MemberRank.Members.Remove(Member); MemberRank = Ranks[RankIndex]; List <Rank> NewRankList = new List <Rank>(); NewRankList.Add(Ranks[RankIndex]); NeedSave = true; PlayerObject player = (PlayerObject)Member.Player; if (player != null) { player.MyGuildRank = Ranks[RankIndex]; player.Enqueue(new ServerPackets.GuildMemberChange() { Name = Self.Info.Name, Status = (byte)8, Ranks = NewRankList }); player.BroadcastInfo(); } for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if ((Ranks[i].Members[j].Player != null) && (Ranks[i].Members[j].Player != Member.Player)) { player = (PlayerObject)Ranks[i].Members[j].Player; player.Enqueue(new ServerPackets.GuildMemberChange() { Name = Member.name, Status = (byte)5, RankIndex = (byte)MemberRank.Index }); player.GuildMembersChanged = true; } } } return(true); }
private void Reincarnation(UserMagic magic, PlayerObject target, out bool cast) { cast = true; if (target == null || !target.Dead) return; // if (ReincarnationTarget == null || !ReincarnationTarget.Dead) return; UserItem item = GetAmulet(1, 3); if (item == null) return; if (!ActiveReincarnation && !ReincarnationReady) { cast = false; ActiveReincarnation = true; ReincarnationTarget = target; SpellObject ob = new SpellObject { Spell = Spell.Reincarnation, ExpireTime = Envir.Time + 3000, TickSpeed = 1000, Caster = this, CurrentLocation = CurrentLocation, CastLocation = CurrentLocation, Show = true, CurrentMap = CurrentMap, }; CurrentMap.AddObject(ob); ob.Spawned(); Packet p = new S.Chat { Message = string.Format("{0} is attempting to revive {1}", Name, target.Name), Type = ChatType.Shout }; ReincarnationReady = false; if (Envir.Random.Next(30) > (magic.Level) * 10) { ReceiveChat("Reviving failed.", ChatType.System); return; } ConsumeItem(item, 1); Envir.Broadcast(p); ReincarnationTarget.Enqueue(new S.RequestReincarnation { }); return; } //else //{ // if (ReincarnationTarget == null || ReincarnationTarget.Node == null || !ReincarnationTarget.Dead) return; // ReincarnationReady = false; // //if (Envir.Random.Next(50) > (magic.Level + 2) * 10) // //{ // // ReceiveChat("Reviving failed.", ChatType.System); // // return; // //} // ReincarnationTarget.Enqueue(new S.RequestReincarnation { }); // ConsumeItem(item, 1); // return; //} }
public virtual void Remove(PlayerObject player) { player.Enqueue(new S.ObjectRemove { ObjectID = ObjectID }); }
public void Buy(PlayerObject player, ulong index, uint count) { UserItem goods = null; for (int i = 0; i < Goods.Count; i++) { if (Goods[i].UniqueID != index) continue; goods = Goods[i]; break; } bool isUsed = false; if (goods == null) { for (int i = 0; i < UsedGoods.Count; i++) { if (UsedGoods[i].UniqueID != index) continue; goods = UsedGoods[i]; isUsed = true; break; } } bool isBuyBack = false; if (goods == null) { if (!BuyBack.ContainsKey(player.Name)) BuyBack[player.Name] = new List<UserItem>(); for (int i = 0; i < BuyBack[player.Name].Count; i++) { if (BuyBack[player.Name][i].UniqueID != index) continue; goods = BuyBack[player.Name][i]; isBuyBack = true; break; } } if (goods == null || count == 0 || count > goods.Info.StackSize) return; goods.Count = count; uint cost = goods.Price(); cost = (uint)(cost * PriceRate(player)); uint baseCost = (uint)(goods.Price() * PriceRate(player, true)); if (player.NPCPage.Key.ToUpper() == PearlBuyKey)//pearl currency { if (cost > player.Info.PearlCount) return; } else if (cost > player.Account.Gold) return; UserItem item = (isBuyBack || isUsed) ? goods : Envir.CreateFreshItem(goods.Info); item.Count = goods.Count; if (!player.CanGainItem(item)) return; if (player.NPCPage.Key.ToUpper() == PearlBuyKey)//pearl currency { player.Info.PearlCount -= (int)cost; } else { player.Account.Gold -= cost; player.Enqueue(new S.LoseGold { Gold = cost }); if (Conq != null) Conq.GoldStorage += (cost - baseCost); } player.GainItem(item); if (isUsed) { UsedGoods.Remove(goods); //If used or buyback will destroy whole stack instead of reducing to remaining quantity List<UserItem> newGoodsList = new List<UserItem>(); newGoodsList.AddRange(Goods); newGoodsList.AddRange(UsedGoods); NeedSave = true; player.Enqueue(new S.NPCGoods { List = newGoodsList, Rate = PriceRate(player) }); } if (isBuyBack) { BuyBack[player.Name].Remove(goods); //If used or buyback will destroy whole stack instead of reducing to remaining quantity player.Enqueue(new S.NPCGoods { List = BuyBack[player.Name], Rate = PriceRate(player) }); } }
public void TradeReply(bool accept) { if (TradeInvitation == null || TradeInvitation.Info == null) { TradeInvitation = null; return; } if (!accept) { TradeInvitation.ReceiveChat(string.Format("Player {0} has refused to trade.", Info.Name), ChatType.System); TradeInvitation = null; return; } if (TradePartner != null) { ReceiveChat("You are already trading.", ChatType.System); TradeInvitation = null; return; } if (TradeInvitation.TradePartner != null) { ReceiveChat(string.Format("Player {0} is already trading.", TradeInvitation.Info.Name), ChatType.System); TradeInvitation = null; return; } TradePartner = TradeInvitation; TradeInvitation.TradePartner = this; TradeInvitation = null; Enqueue(new S.TradeAccept { Name = TradePartner.Info.Name }); TradePartner.Enqueue(new S.TradeAccept { Name = Info.Name }); }
public void Call(PlayerObject player, string key) { key = key.ToUpper(); if (!player.NPCDelayed) { if (key != MainKey) // && ObjectID != player.DefaultNPC.ObjectID { if (player.NPCID != ObjectID) return; bool found = false; foreach (NPCSegment segment in player.NPCPage.SegmentList) { bool result; if (!player.NPCSuccess.TryGetValue(segment, out result)) break; //no result for segement ? if ((result ? segment.Buttons : segment.ElseButtons).Any(s => s.ToUpper() == key)) //key is already uppercase found = true; } if (!found) { SMain.Enqueue(string.Format("Player: {0} was prevented access to NPC key: '{1}' ", player.Name, key)); return; } } } else { player.NPCDelayed = false; } if (key.StartsWith("[@@") && player.NPCInputStr == string.Empty) { //send off packet to request input player.Enqueue(new S.NPCRequestInput { NPCID = ObjectID, PageName = key }); return; } for (int i = 0; i < NPCPages.Count; i++) { NPCPage page = NPCPages[i]; if (!String.Equals(page.Key, key, StringComparison.CurrentCultureIgnoreCase)) continue; player.NPCSpeech = new List<string>(); player.NPCSuccess.Clear(); foreach (NPCSegment segment in page.SegmentList) { if (page.BreakFromSegments) { page.BreakFromSegments = false; break; } ProcessSegment(player, page, segment); } Response(player, page); } player.NPCInputStr = string.Empty; }
private void ProcessSpecial(PlayerObject player, NPCPage page) { List<UserItem> allGoods = new List<UserItem>(); switch (page.Key.ToUpper()) { case BuyKey: for (int i = 0; i < Goods.Count; i++) player.CheckItem(Goods[i]); player.Enqueue(new S.NPCGoods { List = Goods, Rate = Info.PriceRate }); break; case SellKey: player.Enqueue(new S.NPCSell()); break; case BuySellKey: for (int i = 0; i < Goods.Count; i++) player.CheckItem(Goods[i]); player.Enqueue(new S.NPCGoods { List = Goods, Rate = Info.PriceRate }); player.Enqueue(new S.NPCSell()); break; case RepairKey: player.Enqueue(new S.NPCRepair { Rate = Info.PriceRate }); break; case SRepairKey: player.Enqueue(new S.NPCSRepair { Rate = Info.PriceRate }); break; case RefineKey: if (player.Info.CurrentRefine != null) { player.ReceiveChat("You're already refining an item.", ChatType.System); player.Enqueue(new S.NPCRefine { Rate = (Settings.RefineCost), Refining = true }); break; } else player.Enqueue(new S.NPCRefine { Rate = (Settings.RefineCost), Refining = false }); break; case RefineCheckKey: player.Enqueue(new S.NPCCheckRefine()); break; case RefineCollectKey: player.CollectRefine(); break; case ReplaceWedRingKey: player.Enqueue(new S.NPCReplaceWedRing { Rate = Settings.ReplaceWedRingCost }); break; case StorageKey: player.SendStorage(); player.Enqueue(new S.NPCStorage()); break; case BuyBackKey: if (!BuyBack.ContainsKey(player.Name)) BuyBack[player.Name] = new List<UserItem>(); for (int i = 0; i < BuyBack[player.Name].Count; i++) { player.CheckItem(BuyBack[player.Name][i]); } player.Enqueue(new S.NPCGoods { List = BuyBack[player.Name], Rate = Info.PriceRate }); break; case BuyUsedKey: for (int i = 0; i < UsedGoods.Count; i++) player.CheckItem(UsedGoods[i]); player.Enqueue(new S.NPCGoods { List = UsedGoods, Rate = Info.PriceRate }); break; case ConsignKey: player.Enqueue(new S.NPCConsign()); break; case MarketKey: player.UserMatch = false; player.GetMarket(string.Empty, ItemType.Nothing); break; case ConsignmentsKey: player.UserMatch = true; player.GetMarket(string.Empty, ItemType.Nothing); break; case GuildCreateKey: if (player.Info.Level < Settings.Guild_RequiredLevel) { player.ReceiveChat(String.Format("You have to be at least level {0} to create a guild.", Settings.Guild_RequiredLevel), ChatType.System); } if (player.MyGuild == null) { player.CanCreateGuild = true; player.Enqueue(new S.GuildNameRequest()); } else player.ReceiveChat("You are already part of a guild.", ChatType.System); break; case RequestWarKey: if (player.MyGuild != null) { if (player.MyGuildRank != player.MyGuild.Ranks[0]) { player.ReceiveChat("You must be the leader to request a war.", ChatType.System); return; } player.Enqueue(new S.GuildRequestWar()); } else { player.ReceiveChat("You are not in a guild.", ChatType.System); } break; case SendParcelKey: player.Enqueue(new S.MailSendRequest()); break; case CollectParcelKey: sbyte result = 0; if (player.GetMailAwaitingCollectionAmount() < 1) { result = -1; } else { foreach (var mail in player.Info.Mail) { if (mail.Parcel) mail.Collected = true; } } player.Enqueue(new S.ParcelCollected { Result = result }); player.GetMail(); break; case AwakeningKey: player.Enqueue(new S.NPCAwakening()); break; case DisassembleKey: player.Enqueue(new S.NPCDisassemble()); break; case DowngradeKey: player.Enqueue(new S.NPCDowngrade()); break; case ResetKey: player.Enqueue(new S.NPCReset()); break; case PearlBuyKey: for (int i = 0; i < Goods.Count; i++) player.CheckItem(Goods[i]); player.Enqueue(new S.NPCPearlGoods { List = Goods, Rate = Info.PriceRate }); break; } }
public void Buy(PlayerObject player, ulong index, uint count) { UserItem goods = null; for (int i = 0; i < Goods.Count; i++) { if (Goods[i].UniqueID != index) { continue; } goods = Goods[i]; break; } bool isUsed = false; if (goods == null) { for (int i = 0; i < UsedGoods.Count; i++) { if (UsedGoods[i].UniqueID != index) { continue; } goods = UsedGoods[i]; isUsed = true; break; } } bool isBuyBack = false; if (goods == null) { if (!BuyBack.ContainsKey(player.Name)) { BuyBack[player.Name] = new List <UserItem>(); } for (int i = 0; i < BuyBack[player.Name].Count; i++) { if (BuyBack[player.Name][i].UniqueID != index) { continue; } goods = BuyBack[player.Name][i]; isBuyBack = true; break; } } if (goods == null || goods.Count == 0 || goods.Count > goods.Info.StackSize) { return; } uint cost = goods.Price(); cost = (uint)(cost * Info.PriceRate); if (player.NPCPage.Key.ToUpper() == PearlBuyKey)//pearl currency { if (cost > player.Info.PearlCount) { return; } } else if (cost > player.Account.Gold) { return; } UserItem item = (isBuyBack || isUsed ? goods : Envir.CreateFreshItem(goods.Info)); item.Count = goods.Count; if (!player.CanGainItem(item)) { return; } if (player.NPCPage.Key.ToUpper() == PearlBuyKey)//pearl currency { player.Info.PearlCount -= (int)cost; } else { player.Account.Gold -= cost; player.Enqueue(new S.LoseGold { Gold = cost }); } player.GainItem(item); if (isUsed) { UsedGoods.Remove(goods); List <UserItem> newGoodsList = new List <UserItem>(); newGoodsList.AddRange(Goods); newGoodsList.AddRange(UsedGoods); NeedSave = true; player.Enqueue(new S.NPCGoods { List = newGoodsList, Rate = Info.PriceRate }); } if (isBuyBack) { BuyBack[player.Name].Remove(goods); player.Enqueue(new S.NPCGoods { List = BuyBack[player.Name], Rate = Info.PriceRate }); } }
public void Buy(PlayerObject player, ulong index, uint count) { UserItem goods = null; for (int i = 0; i < Goods.Count; i++) { if (Goods[i].UniqueID != index) continue; goods = Goods[i]; break; } bool isUsed = false; if (goods == null) { for (int i = 0; i < UsedGoods.Count; i++) { if (UsedGoods[i].UniqueID != index) continue; goods = UsedGoods[i]; isUsed = true; break; } } bool isBuyBack = false; if (goods == null) { if (!BuyBack.ContainsKey(player.Name)) BuyBack[player.Name] = new List<UserItem>(); for (int i = 0; i < BuyBack[player.Name].Count; i++) { if (BuyBack[player.Name][i].UniqueID != index) continue; goods = BuyBack[player.Name][i]; isBuyBack = true; break; } } if (goods == null || goods.Count == 0 || goods.Count > goods.Info.StackSize) return; uint cost = goods.Price(); cost = (uint)(cost * Info.PriceRate); if (player.NPCPage.Key.ToUpper() == PearlBuyKey)//pearl currency { if (cost > player.Info.PearlCount) return; } else if (cost > player.Account.Gold) return; UserItem item = (isBuyBack || isUsed ? goods : Envir.CreateFreshItem(goods.Info)); item.Count = goods.Count; if (!player.CanGainItem(item)) return; if (player.NPCPage.Key.ToUpper() == PearlBuyKey)//pearl currency { player.Info.PearlCount -= (int)cost; } else { player.Account.Gold -= cost; player.Enqueue(new S.LoseGold { Gold = cost }); } player.GainItem(item); if (isUsed) { UsedGoods.Remove(goods); List<UserItem> newGoodsList = new List<UserItem>(); newGoodsList.AddRange(Goods); newGoodsList.AddRange(UsedGoods); NeedSave = true; player.Enqueue(new S.NPCGoods { List = newGoodsList, Rate = Info.PriceRate }); } if (isBuyBack) { BuyBack[player.Name].Remove(goods); player.Enqueue(new S.NPCGoods { List = BuyBack[player.Name], Rate = Info.PriceRate }); } }
public void Call(PlayerObject player, string key) { key = key.ToUpper(); if (!player.NPCDelayed) { if (key != MainKey) // && ObjectID != player.DefaultNPC.ObjectID { if (player.NPCID != ObjectID) { return; } bool found = false; if (player.NPCSuccess) { foreach (NPCSegment segment in player.NPCPage.SegmentList) { if (segment.Buttons.Any(c => c.ToUpper().Contains(key))) { found = true; } } } else { foreach (NPCSegment segment in player.NPCPage.SegmentList) { if (!segment.ElseButtons.Any(c => c.ToUpper().Contains(key))) { found = true; } } } if (!found) { return; } } } else { player.NPCDelayed = false; } if (key.StartsWith("[@@") && player.NPCInputStr == string.Empty) { //send off packet to request input player.Enqueue(new S.NPCRequestInput { NPCID = ObjectID, PageName = key }); return; } for (int i = 0; i < NPCPages.Count; i++) { NPCPage page = NPCPages[i]; if (!String.Equals(page.Key, key, StringComparison.CurrentCultureIgnoreCase)) { continue; } player.NPCSpeech = new List <string>(); foreach (NPCSegment segment in page.SegmentList) { ProcessSegment(player, page, segment); } Response(player, page); } player.NPCInputStr = string.Empty; }
public void MemberDeleted(string name, PlayerObject formermember, bool kickself) { PlayerObject player = null; for (int i = 0; i < Ranks.Count; i++) for (int j = 0; j < Ranks[i].Members.Count; j++) { if ((Ranks[i].Members[j].Player != null) && (Ranks[i].Members[j].Player != formermember)) { player = (PlayerObject)Ranks[i].Members[j].Player; player.Enqueue(new ServerPackets.GuildMemberChange() { Name = name, Status = (byte)(kickself ? 4:3) }); player.GuildMembersChanged = true; } } if (formermember != null) { formermember.Info.GuildIndex = -1; formermember.MyGuild = null; formermember.MyGuildRank = null; formermember.ReceiveChat(kickself ? "You have left your guild." : "You have been removed from your guild.", ChatType.Guild); formermember.Enqueue(new ServerPackets.GuildStatus() { GuildName = "", GuildRankName = "", MyOptions = (RankOptions)0 }); formermember.BroadcastInfo(); } }
private void ProcessSpecial(PlayerObject player, NPCPage page) { List <UserItem> allGoods = new List <UserItem>(); switch (page.Key.ToUpper()) { case BuyKey: for (int i = 0; i < Goods.Count; i++) { player.CheckItem(Goods[i]); } player.Enqueue(new S.NPCGoods { List = Goods, Rate = PriceRate(player), Type = PanelType.Buy }); break; case SellKey: player.Enqueue(new S.NPCSell()); break; case BuySellKey: for (int i = 0; i < Goods.Count; i++) { player.CheckItem(Goods[i]); } player.Enqueue(new S.NPCGoods { List = Goods, Rate = PriceRate(player), Type = PanelType.Buy }); player.Enqueue(new S.NPCSell()); break; case RepairKey: player.Enqueue(new S.NPCRepair { Rate = PriceRate(player) }); break; case SRepairKey: player.Enqueue(new S.NPCSRepair { Rate = PriceRate(player) }); break; case CraftKey: for (int i = 0; i < CraftGoods.Count; i++) { player.CheckItemInfo(CraftGoods[i].Item.Info); } player.Enqueue(new S.NPCGoods { List = (from x in CraftGoods where x.CanCraft(player) select x.Item).ToList(), Rate = PriceRate(player), Type = PanelType.Craft }); break; case RefineKey: if (player.Info.CurrentRefine != null) { player.ReceiveChat("You're already refining an item.", ChatType.System); player.Enqueue(new S.NPCRefine { Rate = (Settings.RefineCost), Refining = true }); break; } else { player.Enqueue(new S.NPCRefine { Rate = (Settings.RefineCost), Refining = false }); } break; case RefineCheckKey: player.Enqueue(new S.NPCCheckRefine()); break; case RefineCollectKey: player.CollectRefine(); break; case ReplaceWedRingKey: player.Enqueue(new S.NPCReplaceWedRing { Rate = Settings.ReplaceWedRingCost }); break; case StorageKey: player.SendStorage(); player.Enqueue(new S.NPCStorage()); break; case BuyBackKey: { var callingNPC = NPCObject.Get(player.NPCObjectID); if (callingNPC != null) { if (!callingNPC.BuyBack.ContainsKey(player.Name)) { callingNPC.BuyBack[player.Name] = new List <UserItem>(); } for (int i = 0; i < callingNPC.BuyBack[player.Name].Count; i++) { player.CheckItem(callingNPC.BuyBack[player.Name][i]); } player.Enqueue(new S.NPCGoods { List = callingNPC.BuyBack[player.Name], Rate = PriceRate(player), Type = PanelType.Buy }); } } break; case BuyUsedKey: { var callingNPC = NPCObject.Get(player.NPCObjectID); if (callingNPC != null) { for (int i = 0; i < callingNPC.UsedGoods.Count; i++) { player.CheckItem(callingNPC.UsedGoods[i]); } player.Enqueue(new S.NPCGoods { List = callingNPC.UsedGoods, Rate = PriceRate(player), Type = PanelType.Buy }); } } break; case ConsignKey: player.Enqueue(new S.NPCConsign()); break; case MarketKey: player.UserMatch = false; player.GetMarket(string.Empty, ItemType.Nothing); break; case GuildCreateKey: if (player.Info.Level < Settings.Guild_RequiredLevel) { player.ReceiveChat(String.Format("You have to be at least level {0} to create a guild.", Settings.Guild_RequiredLevel), ChatType.System); } else if (player.MyGuild == null) { player.CanCreateGuild = true; player.Enqueue(new S.GuildNameRequest()); } else { player.ReceiveChat("You are already part of a guild.", ChatType.System); } break; case RequestWarKey: if (player.MyGuild != null) { if (player.MyGuildRank != player.MyGuild.Ranks[0]) { player.ReceiveChat("You must be the leader to request a war.", ChatType.System); return; } player.Enqueue(new S.GuildRequestWar()); } else { player.ReceiveChat(GameLanguage.NotInGuild, ChatType.System); } break; case SendParcelKey: player.Enqueue(new S.MailSendRequest()); break; case CollectParcelKey: sbyte result = 0; if (player.GetMailAwaitingCollectionAmount() < 1) { result = -1; } else { foreach (var mail in player.Info.Mail) { if (mail.Parcel) { mail.Collected = true; } } } player.Enqueue(new S.ParcelCollected { Result = result }); player.GetMail(); break; case AwakeningKey: player.Enqueue(new S.NPCAwakening()); break; case DisassembleKey: player.Enqueue(new S.NPCDisassemble()); break; case DowngradeKey: player.Enqueue(new S.NPCDowngrade()); break; case ResetKey: player.Enqueue(new S.NPCReset()); break; case PearlBuyKey: for (int i = 0; i < Goods.Count; i++) { player.CheckItem(Goods[i]); } player.Enqueue(new S.NPCPearlGoods { List = Goods, Rate = PriceRate(player), Type = PanelType.Buy }); break; } }
public virtual void Add(PlayerObject player) { if (Race == ObjectType.Player) { PlayerObject me = (PlayerObject)this; player.Enqueue(me.GetInfoEx(player)); } else player.Enqueue(GetInfo()); }
public void Buy(PlayerObject player, ulong index, uint count) { UserItem goods = null; for (int i = 0; i < Goods.Count; i++) { if (Goods[i].UniqueID != index) { continue; } goods = Goods[i]; break; } bool isUsed = false; bool isBuyBack = false; var callingNPC = NPCObject.Get(player.NPCObjectID); if (callingNPC != null) { if (goods == null) { for (int i = 0; i < callingNPC.UsedGoods.Count; i++) { if (callingNPC.UsedGoods[i].UniqueID != index) { continue; } goods = callingNPC.UsedGoods[i]; isUsed = true; break; } } if (goods == null) { if (!callingNPC.BuyBack.ContainsKey(player.Name)) { callingNPC.BuyBack[player.Name] = new List <UserItem>(); } for (int i = 0; i < callingNPC.BuyBack[player.Name].Count; i++) { if (callingNPC.BuyBack[player.Name][i].UniqueID != index) { continue; } goods = callingNPC.BuyBack[player.Name][i]; isBuyBack = true; break; } } } if (goods == null || count == 0 || count > goods.Info.StackSize) { return; } if (isBuyBack && count > goods.Count) { count = goods.Count; } else { goods.Count = count; } uint cost = goods.Price(); cost = (uint)(cost * PriceRate(player)); uint baseCost = (uint)(goods.Price() * PriceRate(player, true)); if (player.NPCPage.Key.ToUpper() == PearlBuyKey)//pearl currency { if (cost > player.Info.PearlCount) { return; } } else if (cost > player.Account.Gold) { return; } UserItem item = (isBuyBack || isUsed) ? goods : Envir.CreateFreshItem(goods.Info); item.Count = goods.Count; if (!player.CanGainItem(item)) { return; } if (player.NPCPage.Key.ToUpper() == PearlBuyKey)//pearl currency { player.Info.PearlCount -= (int)cost; } else { player.Account.Gold -= cost; player.Enqueue(new S.LoseGold { Gold = cost }); if (callingNPC != null && callingNPC.Conq != null) { callingNPC.Conq.GoldStorage += (cost - baseCost); } } player.GainItem(item); if (isUsed) { callingNPC.UsedGoods.Remove(goods); //If used or buyback will destroy whole stack instead of reducing to remaining quantity List <UserItem> newGoodsList = new List <UserItem>(); newGoodsList.AddRange(Goods); newGoodsList.AddRange(callingNPC.UsedGoods); callingNPC.NeedSave = true; player.Enqueue(new S.NPCGoods { List = newGoodsList, Rate = PriceRate(player) }); } if (isBuyBack) { callingNPC.BuyBack[player.Name].Remove(goods); //If used or buyback will destroy whole stack instead of reducing to remaining quantity player.Enqueue(new S.NPCGoods { List = callingNPC.BuyBack[player.Name], Rate = PriceRate(player) }); } }
public void Broadcast(Packet p, Point location, PlayerObject Player) { if (p == null) return; if (Functions.InRange(location, Player.CurrentLocation, Globals.DataRange)) { Player.Enqueue(p); } }
public void Craft(PlayerObject player, ulong index, uint count, int[] slots) { S.CraftItem p = new S.CraftItem(); RecipeInfo recipe = null; for (int i = 0; i < CraftGoods.Count; i++) { if (CraftGoods[i].Item.UniqueID != index) { continue; } recipe = CraftGoods[i]; break; } UserItem goods = recipe.Item; if (goods == null || count == 0 || count > goods.Info.StackSize) { player.Enqueue(p); return; } bool hasItems = true; List <int> usedSlots = new List <int>(); //Check Items foreach (var ingredient in recipe.Ingredients) { uint amount = ingredient.Count * count; for (int i = 0; i < slots.Length; i++) { int slot = slots[i]; if (usedSlots.Contains(slot)) { continue; } if (slot < 0 || slot > player.Info.Inventory.Length) { continue; } UserItem item = player.Info.Inventory[slot]; if (item == null || item.Info != ingredient.Info) { continue; } usedSlots.Add(slot); if (amount <= item.Count) { amount = 0; } else { hasItems = false; } break; } if (amount > 0) { hasItems = false; break; } } if (!hasItems) { player.Enqueue(p); return; } UserItem craftedItem = Envir.CreateFreshItem(goods.Info); craftedItem.Count = count; if (!player.CanGainItem(craftedItem)) { player.Enqueue(p); return; } //Take Items foreach (var ingredient in recipe.Ingredients) { uint amount = ingredient.Count * count; for (int i = 0; i < slots.Length; i++) { int slot = slots[i]; if (slot < 0) { continue; } UserItem item = player.Info.Inventory[slot]; if (item == null || item.Info != ingredient.Info) { continue; } if (item.Count > amount) { player.Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = amount }); player.Info.Inventory[slot].Count -= amount; break; } else { player.Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = item.Count }); amount -= item.Count; player.Info.Inventory[slot] = null; } break; } } //Give Item player.GainItem(craftedItem); p.Success = true; player.Enqueue(p); }
public override void Add(PlayerObject player) { player.Enqueue(GetInfo()); SendHealth(player); }
private void Act(IList<NPCActions> acts, PlayerObject player) { for (var i = 0; i < acts.Count; i++) { NPCActions act = acts[i]; uint gold; uint count; string path; switch (act.Type) { case ActionType.Teleport: var map = SMain.Envir.GetMapByNameAndInstance((string)act.Params[0]); if (map == null) return; var coords = (Point)act.Params[1]; if (coords.X > 0 && coords.Y > 0) player.Teleport(map, coords); else player.TeleportRandom(200, 0, map); break; case ActionType.InstanceTeleport: map = SMain.Envir.GetMapByNameAndInstance((string)act.Params[0], (int)act.Params[1]); if (map == null) return; player.Teleport(map, (Point)act.Params[2]); break; case ActionType.GiveGold: gold = (uint)act.Params[0]; if (gold + player.Account.Gold >= uint.MaxValue) gold = uint.MaxValue - player.Account.Gold; player.GainGold(gold); break; case ActionType.TakeGold: gold = (uint)act.Params[0]; if (gold >= player.Account.Gold) gold = player.Account.Gold; player.Account.Gold -= gold; player.Enqueue(new S.LoseGold { Gold = gold }); break; case ActionType.GiveItem: count = (uint)act.Params[1]; while (count > 0) { UserItem item = SMain.Envir.CreateFreshItem((ItemInfo)act.Params[0]); if (item == null) { SMain.Enqueue(string.Format("Failed to create UserItem: {0}, Page: {1}", act.Params[0], Key)); return; } if (item.Info.StackSize > count) { item.Count = count; count = 0; } else { count -= item.Info.StackSize; item.Count = item.Info.StackSize; } if (player.CanGainItem(item, false)) player.GainItem(item); } break; case ActionType.TakeItem: ItemInfo info = (ItemInfo)act.Params[0]; count = (uint)act.Params[1]; for (int o = 0; o < player.Info.Inventory.Length; o++) { UserItem item = player.Info.Inventory[o]; if (item == null) continue; if (item.Info != info) continue; if (count > item.Count) { player.Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = item.Count }); player.Info.Inventory[o] = null; count -= item.Count; continue; } player.Enqueue(new S.DeleteItem { UniqueID = item.UniqueID, Count = count }); if (count == item.Count) player.Info.Inventory[o] = null; else item.Count -= count; break; } player.RefreshStats(); break; case ActionType.GiveExp: player.GainExp((uint)act.Params[0]); break; case ActionType.GivePet: for (var c = 0; c < (byte)act.Params[1]; c++) { MonsterObject monster = MonsterObject.GetMonster((MonsterInfo)act.Params[0]); if (monster == null) return; monster.PetLevel = (byte)act.Params[2]; monster.Master = player; monster.MaxPetLevel = 7; monster.Direction = player.Direction; monster.ActionTime = SMain.Envir.Time + 1000; monster.Spawn(player.CurrentMap, player.CurrentLocation); player.Pets.Add(monster); } break; case ActionType.AddNameList: path = (string)act.Params[0]; if (File.ReadAllLines(path).All(t => player.Name != t)) { using (var line = File.AppendText(path)) { line.WriteLine(player.Name); } } break; case ActionType.DelNameList: path = (string)act.Params[0]; File.WriteAllLines(path, File.ReadLines(path).Where(l => l != player.Name).ToList()); break; case ActionType.ClearNameList: path = (string)act.Params[0]; File.WriteAllLines(path, new string[] { }); break; case ActionType.GiveHP: player.ChangeHP((int)act.Params[0]); break; case ActionType.GiveMP: player.ChangeMP((int)act.Params[0]); break; case ActionType.ChangeLevel: player.Level = (byte) act.Params[0]; player.LevelUp(); break; case ActionType.SetPkPoint: player.PKPoints = (int) act.Params[0]; break; case ActionType.ChangeGender: switch (player.Info.Gender) { case MirGender.Male: player.Info.Gender = MirGender.Female; break; case MirGender.Female: player.Info.Gender = MirGender.Male; break; } break; case ActionType.ChangeClass: var data = (MirClass)act.Params[0]; switch (data) { case MirClass.Warrior: player.Info.Class = MirClass.Warrior; break; case MirClass.Taoist: player.Info.Class = MirClass.Taoist; break; case MirClass.Wizard: player.Info.Class = MirClass.Wizard; break; case MirClass.Assassin: player.Info.Class = MirClass.Assassin; break; } break; case ActionType.LineMessage: player.ReceiveChat((string)act.Params[0], (ChatType)act.Params[1]); break; case ActionType.GiveSkill: var magic = new UserMagic((Spell)act.Params[0]) { Level = (byte)act.Params[1] }; player.Info.Magics.Add(magic); player.Enqueue(magic.GetInfo()); break; case ActionType.Goto: player.NPCGoto = true; player.NPCGotoPage = "[" + act.Params[0] + "]"; break; case ActionType.Set: player.Info.Flags[(uint) act.Params[0]] = (bool) act.Params[1]; break; } } }