public static void HandlePlayer(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } pr.Skip(1); try { int tickCount = pr.ReadInt(); Point position = pr.ReadPoint(); int objectId = pr.ReadInt(); if (position.DistanceTo(chr.Position) >= 50) { c.CheatTracker.AddOffence(AntiCheat.OffenceType.LootFarAwayItem); } bool success = chr.Map.HandlePlayerItemPickup(c, objectId); chr.EnableActions(!success); //Client doesn't need to be notified if it was succesful } catch { chr.EnableActions(); } }
public static void Handle(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions(ActionState.NpcTalking)) { return; } try { int objectId = pr.ReadInt(); WzMap.Npc npc = chr.Map.GetNpc(objectId); if (npc == null) { ServerConsole.Warning("NPC is not on player {0}'s map: {1}", chr.Name, chr.Map.MapId); chr.EnableActions(); return; } NpcEngine.OpenNpc(npc.Id, objectId, c); } catch (Exception ex) { ServerConsole.Error("NpcChatHandler.Handle : " + ex); chr.EnableActions(); } }
public static void HandleRegularEquipScroll(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } //[BC E0 27 09] [09 00] [05 00] [01 00] [00] int tickCount = pr.ReadInt(); short useSlot = pr.ReadShort(); short equipSlot = pr.ReadShort(); short whiteScrollMask = pr.ReadShort(); bool whiteScroll = (whiteScrollMask & 0x2) > 0; //1 byte left, don't know what it is MapleEquip equip; MapleItem scroll; if (GetAndCheckItemsFromInventory(chr.Inventory, equipSlot, useSlot, out equip, out scroll)) { if (scroll.ItemType == MapleItemType.RegularEquipScroll) { MapleEquipEnhancer.UseRegularEquipScroll(chr, equip, scroll, whiteScroll); } } chr.EnableActions(false); }
public static void Handle(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } int tickCount = pr.ReadInt(); int hammerSlot = pr.ReadInt(); int hammerItemId = pr.ReadInt(); MapleItem hammer = chr.Inventory.GetItemSlotFromInventory(MapleInventoryType.Use, (short)hammerSlot); if (hammer == null || hammer.ItemId != hammerItemId) { return; } pr.Skip(4); //Integer, inventory type? int equipSlot = pr.ReadInt(); MapleEquip equip = chr.Inventory.GetItemSlotFromInventory(MapleInventoryType.Equip, (short)equipSlot) as MapleEquip; if (equip == null) { return; } DoHammer(hammer, equip, chr); chr.EnableActions(false); }
public static void HandleReturnScroll(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } int tickCount = pr.ReadInt(); pr.Skip(2); //Unk int itemId = pr.ReadInt(); if (!chr.Inventory.HasItem(itemId)) { return; } WzConsume item = DataBuffer.GetItemById(itemId) as WzConsume; if (item == null) { return; } if (item.MoveTo > 0) { int toMap = 0; toMap = item.MoveTo == 999999999 ? chr.Map.ReturnMap : item.MoveTo; if (toMap != 0) { MapleMap map = Program.GetChannelServer(c.Channel).GetMap(toMap); if (map == null || map.PortalScrollLimit) { return; } if (chr.Inventory.RemoveItemsById(itemId, 1)) { chr.ChangeMap(toMap); } } } else { string msg = "Unhandled return scroll: " + itemId; ServerConsole.Warning(msg); FileLogging.Log("Unhandled items", msg); chr.EnableActions(); } }
public static void Handle(MapleClient c, PacketReader pw) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } int tickCount = pw.ReadInt(); MapleInventoryType type = (MapleInventoryType)pw.ReadByte(); short oldPosition = pw.ReadShort(); short newPosition = pw.ReadShort(); short quantity = pw.ReadShort(); bool success = false; if (oldPosition == newPosition) { return; } try { MapleInventory inventory = chr.Inventory; if (newPosition < 0 && oldPosition > 0) //equip item { success = inventory.EquipItem(oldPosition, newPosition); } else if (oldPosition < 0 && newPosition > 0) //unequip item { success = inventory.UnEquip(oldPosition, newPosition); } else if (newPosition == 0) //drop item { if (!chr.Map.DropItemLimit) { success = inventory.DropItem(type, oldPosition, quantity); } } else //item moved within inventory { success = inventory.MoveItem(type, oldPosition, newPosition); } } finally { chr.EnableActions(!success); } }
public static void HandleItemSort(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } int tickCount = pr.ReadInt(); byte inventory = pr.ReadByte(); if (inventory < 1 || inventory > 5) { return; } MapleInventoryType type = (MapleInventoryType)inventory; chr.Inventory.SortItems(type, c); chr.EnableActions(false); c.SendPacket(Packets.ItemSortResponse(type)); }
public static void Handle(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } int tickCount = pr.ReadInt(); int skillId = pr.ReadInt(); byte skillLevel = pr.ReadByte(); if (skillId != Constants.Cleric.HEAL && skillId != Constants.Bishop.ANGEL_RAY) // Heal is already handled through MagicAttack { SkillEffect.CheckAndApplySkillEffect(c.Account.Character, skillId, DataBuffer.GetCharacterSkillById(skillId)); } else { chr.EnableActions(); } }
public static void HandlePotentialScroll(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } int tickCount = pr.ReadInt(); short useSlot = pr.ReadShort(); short equipSlot = pr.ReadShort(); MapleEquip equip; MapleItem scroll; if (GetAndCheckItemsFromInventory(chr.Inventory, equipSlot, useSlot, out equip, out scroll)) { MapleEquipEnhancer.UsePotentialScroll(equip, scroll, chr); } chr.EnableActions(false); }
public static void Handle(MapleClient c, PacketReader pw) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } int tickCount = pw.ReadInt(); int mesos = pw.ReadInt(); if (mesos > 50000 || mesos < 10 || chr.Inventory.Mesos < mesos) { return; } chr.Inventory.RemoveMesos(mesos, false); Point targetPosition = chr.Map.GetDropPositionBelow(new Point(chr.Position.X, chr.Position.Y - 50), chr.Position); chr.Map.SpawnMesoMapItem(mesos, chr.Position, targetPosition, true, MapleDropType.Unk, chr); chr.EnableActions(false); }
public static void Handle(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (chr.Hp <= 0 || chr.ActionState == ActionState.Dead) { chr.Revive(true); return; } if (!chr.DisableActions()) { return; } if (pr.Available <= 0) { chr.EnableActions(); return; } pr.Skip(1); int targetMap = pr.ReadInt(); pr.Skip(4); string portalName = pr.ReadMapleString(); if (pr.Available >= 4) { int tickCount = pr.ReadInt(); } if (c.Account.Character.Map != null) { if (targetMap == -1) { c.Account.Character.Map.EnterPortal(c, portalName); } } }
public static void Handle(MapleClient c, PacketReader packet) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } try { int tickCount = packet.ReadInt(); int skillId = packet.ReadInt(); byte amount = packet.ReadByte(); //new v137, multiple sp if (amount <= 0) { amount = 1; } short skillJobId = (short)(skillId / 10000); WzCharacterSkill wzSkill = DataBuffer.GetCharacterSkillById(skillId); if (wzSkill == null) { return; } if (wzSkill.IsGmSkill && !chr.IsStaff) { return; } if (!JobConstants.JobCanLearnSkill(skillId, chr.Job)) { return; } if (wzSkill.HasFixedLevel) { return; } if (chr.Level < wzSkill.RequiredLevel) { return; } if (wzSkill.RequiredSkills != null) { foreach (var kvp in wzSkill.RequiredSkills) { if (!chr.HasSkill(kvp.Key, kvp.Value)) { return; } } } if (wzSkill.IsHyperSkill) { chr.SendPopUpMessage("Hyper skills aren't functional yet."); chr.EnableActions(); return; } if (JobConstants.IsBeginnerJob(skillJobId)) { switch (skillId) { //Three snails: case Explorer.THREE_SNAILS: case Cygnus.THREE_SNAILS: case AranBasics.THREE_SNAILS: case EvanBasics.THREE_SNAILS: case MihileBasics.THREE_SNAILS: //Recovery: case Explorer.RECOVERY: case Cygnus.RECOVERY: case AranBasics.RECOVERY: case EvanBasics.RECOVER: case MihileBasics.RECOVERY: //Nimble Feet: case Explorer.NIMBLE_FEET: case Cygnus.NIMBLE_FEET: case AranBasics.AGILE_BODY: case EvanBasics.NIMBLE_FEET: case MihileBasics.NIMBLE_FEET: //Resistance: case Resistance.POTION_MASTERY: case Resistance.INFILTRATE: case Resistance.CRYSTAL_THROW: if (chr.GetSkillLevel(skillId) + amount > 3) //already maxed { return; } int baseNum = 0; switch (skillId / 100000) { case 300: //resistance { if (!chr.IsResistance) { return; } int usedBeginnerSP = chr.GetSkillLevel(Resistance.CRYSTAL_THROW) + chr.GetSkillLevel(Resistance.INFILTRATE) + chr.GetSkillLevel(Resistance.POTION_MASTERY); if (usedBeginnerSP + amount <= 9 && chr.GetSkillLevel(skillId) + amount <= 3) { chr.IncreaseSkillLevel(skillId, amount); } break; } case 0: if (!chr.IsExplorer) { return; } goto common; case 100: //cygnus if (!chr.IsCygnus) { return; } baseNum = 10000000; goto common; case 200: //hero if (!chr.IsAran && !chr.IsEvan) { return; } baseNum = 20000000; goto common; case 500: //mihile if (!chr.IsMihile) { return; } baseNum = 50000000; common: { int usedBeginnerSP = chr.GetSkillLevel(baseNum + 1000) + chr.GetSkillLevel(baseNum + 1001) + chr.GetSkillLevel(baseNum + 1002); if (usedBeginnerSP + amount <= 6 && chr.GetSkillLevel(skillId) + amount <= 3) { chr.IncreaseSkillLevel(skillId, amount); } break; } default: return; } break; default: return; } } else { int spTableIndex = JobConstants.GetSkillBookForJob(skillJobId); if (chr.SpTable[spTableIndex] >= amount) { Skill skill = chr.GetSkill(skillId); if (skill == null) //Player doesnt have the skill yet { int maxLevel = wzSkill.HasMastery ? wzSkill.DefaultMastery : wzSkill.MaxLevel; if (amount <= maxLevel) { chr.LearnSkill(skillId, amount, wzSkill); chr.SpTable[spTableIndex] -= amount; MapleCharacter.UpdateSingleStat(c, MapleCharacterStat.Sp, chr.SpTable[0], true); } } else { if (skill.Level + amount <= skill.MasterLevel) { chr.IncreaseSkillLevel(skillId, amount); chr.SpTable[spTableIndex] -= amount; MapleCharacter.UpdateSingleStat(c, MapleCharacterStat.Sp, chr.SpTable[0], true); } } } } } finally { chr.EnableActions(false); } }
public static void Handle(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } int tickCount = pr.ReadInt(); short slot = pr.ReadShort(); int itemId = pr.ReadInt(); MapleItem item = chr.Inventory.GetItemSlotFromInventory(ItemConstants.GetInventoryType(itemId), slot); bool removeItem = true; if (item == null || item.ItemId != itemId) { return; } switch (itemId) { case 5062006: //Platinum Miracle Cube { int equipSlot = pr.ReadInt(); if (equipSlot < 0) { return; } MapleEquip equip = chr.Inventory.GetItemSlotFromInventory(MapleInventoryType.Equip, (short)equipSlot) as MapleEquip; if (equip == null) { return; } if (!MapleEquipEnhancer.CubeItem(equip, CubeType.PlatinumMiracle, chr)) { removeItem = false; } break; } case 5072000: //Super Megaphone case 5072001: //Super Megaphone { if (!CanMegaPhone(c.Account.Character)) { chr.EnableActions(); break; } string message = pr.ReadMapleString(); if (message.Length > 60) { return; } bool whisperIcon = pr.ReadBool(); message = string.Format("{0} : {1}", c.Account.Character.Name, message); Program.BroadCastWorldPacket(MapleCharacter.ServerNotice(message, 3, c.Channel, whisperIcon)); break; } case 5570000: //Vicious hammer { removeItem = false; //Handled in UseGoldenHammerHandler pr.Skip(4); short equipSlot = (short)pr.ReadInt(); MapleEquip equip = chr.Inventory.GetItemSlotFromInventory(MapleInventoryType.Equip, equipSlot) as MapleEquip; if (equip != null) { UseGoldenHammerHandler.DoHammer(item, equip, chr); } break; } default: { ServerConsole.Warning("Unhandled UseSpecialItem: {0}", itemId); removeItem = false; chr.SendPopUpMessage("You cannot use this item"); chr.EnableActions(); break; } } if (removeItem) { chr.Inventory.RemoveItemsFromSlot(item.InventoryType, item.Position, 1); } chr.EnableActions(false); }
public static void HandleCube(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } int tickCount = pr.ReadInt(); short useSlot = pr.ReadShort(); short equipSlot = pr.ReadShort(); MapleEquip equip; MapleItem cube; if (GetAndCheckItemsFromInventory(chr.Inventory, equipSlot, useSlot, out equip, out cube)) { CubeType cubeType; switch (cube.ItemId) { //Occult: case 2710000: case 2711000: case 2710001: { cubeType = CubeType.Occult; break; } //Master craftsman: case 2710002: case 2710007: case 2711003: case 2711005: { cubeType = CubeType.MasterCraftsman; break; } //Meister: case 2710003: case 2711004: case 2711006: { cubeType = CubeType.Meister; break; } default: { chr.SendPopUpMessage("You cannot use this item"); chr.EnableActions(); return; } } if (MapleEquipEnhancer.CubeItem(equip, cubeType, chr)) { chr.Inventory.RemoveItemsFromSlot(MapleInventoryType.Use, cube.Position, 1); chr.EnableActions(false); } } }
public static void Handle(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } int tickCount = pr.ReadInt(); short magnifySlot = pr.ReadShort(); short equipSlot = pr.ReadShort(); MapleItem magnifyer = null; MapleEquip equip = c.Account.Character.Inventory.GetItemSlotFromInventory(MapleInventoryType.Equip, equipSlot) as MapleEquip; if (magnifySlot != 0x7F) // Using magnify button in inventory sends 0x007F as the slot { magnifyer = chr.Inventory.GetItemSlotFromInventory(MapleInventoryType.Use, magnifySlot); if (magnifyer == null) { return; //todo: check if it's a magnifying glass } } if (equip == null) { return; } WzEquip equipInfo = DataBuffer.GetEquipById(equip.ItemId); if (equipInfo == null) { return; } if (equip.PotentialState >= MaplePotentialState.HiddenRare && equip.PotentialState <= MaplePotentialState.HiddenLegendary) { long price = equipInfo.RevealPotentialCost; ServerConsole.Debug("pot cost: " + price); if (chr.Mesos < price) { chr.SendPopUpMessage(string.Format("You do not have {0} mesos", price)); chr.EnableActions(); } else { chr.Inventory.RemoveMesos(price); equip.PotentialState += 16; if (magnifyer != null) { chr.Inventory.RemoveItemsFromSlot(magnifyer.InventoryType, magnifyer.Position, 1); } c.SendPacket(MapleInventory.Packets.AddItem(equip, equip.InventoryType, equip.Position)); chr.Map.BroadcastPacket(MagnifyEffectPacket(chr.Id, equip.Position, true), chr, true); chr.EnableActions(false); } } else { chr.SendPopUpMessage("You cannot use that on this item"); chr.EnableActions(); } }
public static void Handle(MapleClient c, PacketReader pr) { byte func = pr.ReadByte(); MapleCharacter chr = c.Account.Character; switch (func) { case 0x00: //okay so i have no idea why these 4 functions exist case 0x01: //add equip item? case 0x02: //add stackable item to trade? case 0x03: //partner add equip item? { if (chr.Trade != null) { HandleAddItem(pr, chr); } break; } case 0x04: case 0x05: //add meso case 0x06: case 0x07: long mesos = pr.ReadLong(); if (mesos > 0) { if (chr.Trade != null && chr.Trade.Type == MapleTrade.TradeType.Trade) { chr.Trade.AddMesos(chr, mesos); } } break; case 0x10: //Create if (chr.Trade == null) { if (!chr.DisableActions(ActionState.Trading)) { return; } byte creationType = pr.ReadByte(); switch (creationType) { case 4: MapleTrade t = MapleTrade.CreateTrade(MapleTrade.TradeType.Trade, chr); chr.Trade = t; break; case 5: case 6: //create shop break; case 1: case 2: //minigame break; } } break; case 0x15: //invite { int ID = pr.ReadInt(); MapleCharacter inviteChr = Program.GetClientByCharacterId(ID).Account.Character; if (inviteChr.Trade == null && chr.Trade != null && chr.Trade.Type == MapleTrade.TradeType.Trade && chr.Trade.IsOwner(chr)) { if (chr.Trade.Partners.Count == 0) { chr.Trade.Invite(inviteChr, chr); //i should check to make sure that i can invite them. i'll figure it out later. chr.Trade.Partners.Add(inviteChr); //this way the trade can't invite two people. } } } break; case 0x13: //invite accept { if (chr.Trade == null) { uint tradeID = pr.ReadUInt(); Invite invite = null; if (chr.Invites.TryGetValue(InviteType.Trade, out invite)) { if (invite.SenderId == tradeID) { MapleTrade t = null; if (MapleTrade.TradeIDs.TryGetValue(tradeID, out t)) { chr.Trade = t; c.SendPacket(t.GenerateTradeStart(chr, true)); t.Owner.Client.SendPacket(t.GenerateTradePartnerAdd(chr, 1)); } else { chr.Client.SendPacket(t.GenerateRoomClosedMessage()); } } } } } break; case 0x16: //invite deny if (chr.Trade == null) { uint tradeID = pr.ReadUInt(); //there's one byte after this. in testing it was 03 Invite invite = null; if (chr.Invites.TryGetValue(InviteType.Trade, out invite)) { if (invite.SenderId == tradeID) { MapleTrade t = null; if (MapleTrade.TradeIDs.TryGetValue(tradeID, out t)) { t.Owner.Client.SendPacket(t.GenerateTradeDeny(chr)); t.Partners.Clear(); } else { } chr.Invites.Remove(InviteType.Trade); } } } break; case 0x1C: //cancel trade. if (chr.Trade != null && chr.Trade.Type == MapleTrade.TradeType.Trade) { chr.Trade.Close(false, false); } break; case 0x08: case 0x09: case 0x0A: //Trade accept case 0x0B: if (chr.Trade != null && chr.Trade.Type == MapleTrade.TradeType.Trade && chr.Trade.Partners.Count == 1) { chr.Trade.AcceptTrade(chr); } break; case 0x18: pr.ReadInt(); //timestamp string text = pr.ReadMapleString(); if (chr.Trade != null && chr.Trade.Type == MapleTrade.TradeType.Trade && chr.Trade.Partners.Count == 1) { chr.Trade.Chat(chr, text); } break; } }