public static void DoHammer(MapleItem hammer, MapleEquip equip, MapleCharacter chr) { if (!CanHammer(equip)) { chr.SendPopUpMessage("You cannot use that on this item."); chr.EnableActions(); return; } switch (hammer.ItemId) { case 2470000: case 2470003: case 2470007: case 2470011: case 5570000: { equip.RemainingUpgradeCount++; equip.HammersApplied++; chr.Inventory.RemoveItemsFromSlot(hammer.InventoryType, hammer.Position, 1); chr.Client.SendPacket(MapleInventory.Packets.AddItem(equip, MapleInventoryType.Equip, equip.Position)); chr.Client.SendPacket(Packets.HammerEffect(true)); chr.Client.SendPacket(Packets.HammerResult(false, true, equip.HammersApplied)); PacketWriter finishPacket = Packets.HammerResult(true, true, 0); Scheduler.ScheduleDelayedAction(() => chr.Client.SendPacket(finishPacket), 1500); break; } default: { chr.SendPopUpMessage("You cannot use this hammer."); chr.EnableActions(); return; } } }
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 override bool CubeAndRevealEquip(dynamic dEquip, int cubeIndex) { MapleEquip equip = dEquip as MapleEquip; if (equip == null) { return(false); } CubeType cubeType = (CubeType)cubeIndex; return(MapleEquipEnhancer.CubeItem(equip, cubeType, Character, true)); }
private static bool CanHammer(MapleEquip equip) { WzEquip equipInfo = DataBuffer.GetEquipById(equip.ItemId); if (equipInfo == null || equipInfo.TotalUpgradeCount == 0) { return(false); } switch (equip.ItemId) { case 1122000: //horntail necklaces case 1122076: case 1122151: case 1122278: return(false); } return(equip.HammersApplied < 2); }
public static void SetPotential(string[] split, MapleClient c) { int pot = int.Parse(split[1]); MapleEquip equip = (MapleEquip)c.Account.Character.Inventory.GetEquippedItem(-11); if (equip == null) { return; } switch (pot) { case 0: equip.PotentialState = (MaplePotentialState)byte.Parse(split[2]); break; case 1: equip.Potential1 = ushort.Parse(split[2]); break; case 2: equip.Potential2 = ushort.Parse(split[2]); break; case 3: equip.Potential3 = ushort.Parse(split[2]); break; case 4: equip.BonusPotential1 = ushort.Parse(split[2]); break; case 5: equip.BonusPotential2 = ushort.Parse(split[2]); break; } c.SendPacket(MapleInventory.Packets.AddItem(equip, MapleInventoryType.Equip, -11)); }
public void Recalculate(MapleCharacter chr) { int mhpX = 0, mmpX = 0; int mhpR = 0, mmpR = 0; int lv2mhp = 0, lv2mmp = 0; int strR = 0, dexR = 0, intR = 0, lukR = 0; int watk = 0, matk = 9; int damR = 100, pdR = 0; Str = chr.Str + 5; Dex = chr.Dex + 5; Int = chr.Int + 5; Luk = chr.Luk + 5; MinDamage = 0; MaxDamage = 0; AsrR = 0; RecoveryHp = 0; RecoveryMp = 0; RecoveryHpR = 0; RecoveryMpR = 0; RecoveryTime = 0; watk = 3; matk = 3; LifeStealR = 0; LifeStealProp = 0; MpEaterR = 0; MpEaterProp = 0; DoTTimeInc = 0; CostMpR = 0; ExpR = 100; MesoR = 100; DropR = 100; PickPocketR = 0; StunR = 0; AmmoInc = 0; MasteryR = 0; BuffTimeR = 100; PotionEffectR = 100; ElixirEffectR = 100; CritRate = 5; ExpLossReductionR = 0; #region PassiveSkills IEnumerable <Skill> passiveSkills = chr.GetSkillList().Where(x => x.SkillId % 10000 < 1000); foreach (Skill skill in passiveSkills) { if (skill.Level < 1) { continue; } WzCharacterSkill skillInfo = DataBuffer.GetCharacterSkillById(skill.SkillId); if (skillInfo == null) { continue; } SkillEffect effect = skillInfo.GetEffect(skill.Level); if (effect == null) { continue; } foreach (var kvp in effect.Info) { switch (kvp.Key) { case CharacterSkillStat.mhpX: mhpX += kvp.Value; break; case CharacterSkillStat.mmpX: mmpX += kvp.Value; break; case CharacterSkillStat.mhpR: mhpR += kvp.Value; break; case CharacterSkillStat.mmpR: mmpR += kvp.Value; break; case CharacterSkillStat.lv2mhp: lv2mhp += kvp.Value; break; case CharacterSkillStat.lv2mmp: lv2mmp += kvp.Value; break; case CharacterSkillStat.strX: Str += kvp.Value; break; case CharacterSkillStat.dexX: Dex += kvp.Value; break; case CharacterSkillStat.intX: Int += kvp.Value; break; case CharacterSkillStat.lukX: Luk += kvp.Value; break; case CharacterSkillStat.asrR: AsrR += kvp.Value; break; case CharacterSkillStat.mastery: MasteryR = Math.Max(MasteryR, kvp.Value); break; case CharacterSkillStat.costmpR: CostMpR += kvp.Value; break; case CharacterSkillStat.bufftimeR: BuffTimeR += kvp.Value; break; case CharacterSkillStat.padX: watk += kvp.Value; break; case CharacterSkillStat.madX: matk += kvp.Value; break; case CharacterSkillStat.pdR: pdR += kvp.Value; break; case CharacterSkillStat.damR: damR += kvp.Value; break; case CharacterSkillStat.cr: CritRate += kvp.Value; break; } } } #region Specific passive skill handling byte skillLevel; if (chr.IsWarrior) { if ((skillLevel = chr.GetSkillLevel(Swordman.IRON_BODY)) > 0) { mhpR += DataBuffer.CharacterSkillBuffer[Swordman.IRON_BODY].GetEffect(skillLevel).Info[CharacterSkillStat.mhpR]; } if (chr.IsFighter) { if ((skillLevel = chr.GetSkillLevel(Crusader.SELF_RECOVERY)) > 0) { var info = DataBuffer.CharacterSkillBuffer[Crusader.SELF_RECOVERY].GetEffect(skillLevel).Info; RecoveryHp += info[CharacterSkillStat.hp]; RecoveryMp += info[CharacterSkillStat.mp]; } } else if (chr.IsSpearman) { if ((skillLevel = chr.GetSkillLevel(Berserker.LORD_OF_DARKNESS)) > 0) { var info = DataBuffer.CharacterSkillBuffer[Berserker.LORD_OF_DARKNESS].GetEffect(skillLevel).Info; LifeStealProp += info[CharacterSkillStat.prop]; LifeStealR += info[CharacterSkillStat.x]; } } } else if (chr.IsMagician) { if (chr.IsFirePoisonMage) { if ((skillLevel = chr.GetSkillLevel(FirePoison2.SPELL_MASTERY)) > 0) { matk += DataBuffer.CharacterSkillBuffer[FirePoison2.SPELL_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } if ((skillLevel = chr.GetSkillLevel(FirePoison2.MP_EATER)) > 0) { var info = DataBuffer.CharacterSkillBuffer[FirePoison2.MP_EATER].GetEffect(skillLevel).Info; MpEaterProp += info[CharacterSkillStat.prop]; MpEaterR += info[CharacterSkillStat.x]; } } if (chr.IsIceLightningMage) { if ((skillLevel = chr.GetSkillLevel(IceLightning2.MP_EATER)) > 0) { var info = DataBuffer.CharacterSkillBuffer[IceLightning2.MP_EATER].GetEffect(skillLevel).Info; MpEaterProp += info[CharacterSkillStat.prop]; MpEaterR += info[CharacterSkillStat.x]; } if ((skillLevel = chr.GetSkillLevel(IceLightning2.SPELL_MASTERY)) > 0) { matk += DataBuffer.CharacterSkillBuffer[IceLightning2.SPELL_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } } if (chr.IsCleric) { if ((skillLevel = chr.GetSkillLevel(Cleric.MP_EATER)) > 0) { var info = DataBuffer.CharacterSkillBuffer[Cleric.MP_EATER].GetEffect(skillLevel).Info; MpEaterProp += info[CharacterSkillStat.prop]; MpEaterR += info[CharacterSkillStat.x]; } if ((skillLevel = chr.GetSkillLevel(Cleric.SPELL_MASTERY)) > 0) { matk += DataBuffer.CharacterSkillBuffer[Cleric.SPELL_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } if ((skillLevel = chr.GetSkillLevel(Priest.DIVINE_PROTECTION)) > 0) { AsrR += DataBuffer.CharacterSkillBuffer[Priest.DIVINE_PROTECTION].GetEffect(skillLevel).Info[CharacterSkillStat.asrR]; } } } else if (chr.IsArcher) { if (chr.IsHunter) { if ((skillLevel = chr.GetSkillLevel(Bowmaster.BOW_EXPERT)) > 0) { watk += DataBuffer.CharacterSkillBuffer[Bowmaster.BOW_EXPERT].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } } else if (chr.IsCrossbowman) { if ((skillLevel = chr.GetSkillLevel(Marksman.CROSSBOW_EXPERT)) > 0) { watk += DataBuffer.CharacterSkillBuffer[Marksman.CROSSBOW_EXPERT].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } } } else if (chr.IsThief) { if (chr.IsAssassin) { if ((skillLevel = chr.GetSkillLevel(Assassin.CLAW_MASTERY)) > 0) { AmmoInc += DataBuffer.CharacterSkillBuffer[Assassin.CLAW_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.y]; } if ((skillLevel = chr.GetSkillLevel(Hermit.ALCHEMIC_ADRENALINE)) > 0) { PotionEffectR += DataBuffer.CharacterSkillBuffer[Hermit.ALCHEMIC_ADRENALINE].GetEffect(skillLevel).Info[CharacterSkillStat.x] - 100; } if ((skillLevel = chr.GetSkillLevel(NightLord.CLAW_EXPERT)) > 0) { watk += DataBuffer.CharacterSkillBuffer[NightLord.CLAW_EXPERT].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } } else if (chr.IsBandit) { if ((skillLevel = chr.GetSkillLevel(Bandit.SHIELD_MASTERY)) > 0) { watk += DataBuffer.CharacterSkillBuffer[Bandit.SHIELD_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.y]; } if ((skillLevel = chr.GetSkillLevel(ChiefBandit.MESO_MASTERY)) > 0) { var info = DataBuffer.CharacterSkillBuffer[ChiefBandit.MESO_MASTERY].GetEffect(skillLevel).Info; MesoR += info[CharacterSkillStat.mesoR]; PickPocketR += info[CharacterSkillStat.u]; } if ((skillLevel = chr.GetSkillLevel(Shadower.DAGGER_EXPERT)) > 0) { watk += DataBuffer.CharacterSkillBuffer[Shadower.DAGGER_EXPERT].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } } } else if (chr.IsDualBlade) { if ((skillLevel = chr.GetSkillLevel(DualBlade3p.LIFE_DRAIN)) > 0) { var info = DataBuffer.CharacterSkillBuffer[DualBlade3p.LIFE_DRAIN].GetEffect(skillLevel).Info; LifeStealR += info[CharacterSkillStat.x]; LifeStealProp += info[CharacterSkillStat.prop]; } if ((skillLevel = chr.GetSkillLevel(DualBlade4.KATARA_EXPERT)) > 0) { watk += DataBuffer.CharacterSkillBuffer[DualBlade4.KATARA_EXPERT].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } } else if (chr.IsPirate) { if (chr.IsBrawler) { if ((skillLevel = chr.GetSkillLevel(Brawler.PERSEVERANCE)) > 0) { var info = DataBuffer.CharacterSkillBuffer[Brawler.PERSEVERANCE].GetEffect(skillLevel).Info; int x = info[CharacterSkillStat.x]; RecoveryHpR += x; RecoveryMpR += x; RecoveryTime = info[CharacterSkillStat.y]; } if ((skillLevel = chr.GetSkillLevel(Marauder.STUN_MASTERY)) > 0) { StunR += DataBuffer.CharacterSkillBuffer[Marauder.STUN_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.subProp]; } } else if (chr.IsGunslinger) { if ((skillLevel = skillLevel = chr.GetSkillLevel(Gunslinger.GUN_MASTERY)) > 0) { AmmoInc += DataBuffer.CharacterSkillBuffer[Gunslinger.GUN_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.y]; } } } else if (chr.IsCannonneer) { if ((skillLevel = chr.GetSkillLevel(Cannoneer3.BARREL_ROULETTE)) > 0) { damR += DataBuffer.CharacterSkillBuffer[Cannoneer3.BARREL_ROULETTE].GetEffect(skillLevel).Info[CharacterSkillStat.damR]; } } else if (chr.IsJett) { /*if ((skillLevel = chr.GetSkillLevel(Jett2.PERSEVERANCE)) > 0) * { * var info = DataBuffer.CharacterSkillBuffer[Jett2.PERSEVERANCE].GetSkillEffect(skillLevel).Info; * int x = info[CharacterSkillStat.x]; * RecoveryHpR += x; * RecoveryMpR += x; * RecoveryTime = info[CharacterSkillStat.y] * 1000; * } */ } #endregion #endregion #region Buffs foreach (Buff buff in chr.GetBuffs()) { var buffInfo = buff.Effect.BuffInfo; foreach (var pair in buffInfo) { //if (pair.Key == MapleBuffStat.ENHANCED_MAXHP || pair.Key == MapleBuffStat.STACKING_MAXHP) //mhpX += pair.Value; if (pair.Key == MapleBuffStat.MAXHP_R || pair.Key == MapleBuffStat.STACKING_MAXHP_R) { mhpR += pair.Value; } //else if (pair.Key == MapleBuffStat.ENHANCED_MAXMP || pair.Key == MapleBuffStat.STACKING_MAXMP) //mmpX += pair.Value; else if (pair.Key == MapleBuffStat.MAXMP_R || pair.Key == MapleBuffStat.STACKING_MAXMP_R) { mmpR += pair.Value; } //else if (pair.Key == MapleBuffStat.WATK || pair.Key == MapleBuffStat.ENHANCED_WATK || pair.Key == MapleBuffStat.STACKING_WATK) //watk += pair.Value; //else if (pair.Key == MapleBuffStat.MATK || pair.Key == MapleBuffStat.ENHANCED_MATK || pair.Key == MapleBuffStat.STACKING_MATK) //matk += pair.Value; //else if (pair.Key == MapleBuffStat.CRIT || pair.Key == MapleBuffStat.STACKING_CRIT) //CritRate += pair.Value; else if (pair.Key == MapleBuffStat.STACKING_STATS) { Str += pair.Value; Dex += pair.Value; Int += pair.Value; Luk += pair.Value; } else if (pair.Key == MapleBuffStat.STACKING_STATS_R) { Str += (int)(chr.Str * (pair.Value / 100.0)); //todo: check if this isnt math.ceil Dex += (int)(chr.Dex * (pair.Value / 100.0)); Int += (int)(chr.Int * (pair.Value / 100.0)); Luk += (int)(chr.Luk * (pair.Value / 100.0)); } //else if (pair.Key == MapleBuffStat.HOLY_SYMBOL) { // ExpR += pair.Value; } } } #endregion #region Equips foreach (MapleItem item in chr.Inventory.GetItemsFromInventory(MapleInventoryType.Equipped)) { MapleEquip equip = item as MapleEquip; if (equip == null) { continue; } mhpX += equip.IncMhp; mmpX += equip.IncMmp; Str += equip.Str; Dex += equip.Dex; Int += equip.Int; Luk += equip.Luk; watk += equip.Pad; matk += equip.Mad; //todo: potential stuff from here } #endregion MaxHp = chr.MaxHp; MaxHp += lv2mhp * chr.Level; MaxHp += (int)((MaxHp) * (mhpR / 100.0)); MaxHp += mhpX; if (chr.Hp > MaxHp) { chr.AddHP(-(chr.Hp - MaxHp)); } MaxMp = chr.MaxMp; MaxMp += (int)(chr.MaxMp * (double)(mmpR / 100.0)); MaxMp += lv2mmp * chr.Level; MaxMp += mhpX; if (chr.Mp > MaxMp) { chr.AddMP(-(chr.Mp - MaxMp)); } Str += (short)(chr.Str * (double)(strR / 100.0)); Dex += (short)(chr.Dex * (double)(dexR / 100.0)); Int += (short)(chr.Int * (double)(intR / 100.0)); Luk += (short)(chr.Luk * (double)(lukR / 100.0)); bool mage = false; int primaryStat = 0; int secondaryStat = 0; MapleItem weapon = chr.Inventory.GetEquippedItem((short)MapleEquipPosition.Weapon); if (weapon == null) { MinDamage = 1; MaxDamage = 1; return; } MapleItemType weaponItemType = ItemConstants.GetMapleItemType(weapon.ItemId); switch ((chr.Job % 1000) / 100) { case 1: //Warrior-type primaryStat = Str; secondaryStat = Dex; break; case 2: //Magician-type case 7: //Luminous primaryStat = Int; secondaryStat = Luk; mage = true; break; case 3: //Archer-type primaryStat = Dex; secondaryStat = Str; break; case 4: //Thief-type primaryStat = Luk; secondaryStat = Dex; break; case 5: //Pirate-type if (weaponItemType == MapleItemType.Gun || weaponItemType == MapleItemType.SoulShooter) { primaryStat = Dex; secondaryStat = Str; } else //counts for cannons too { primaryStat = Str; secondaryStat = Dex; } break; case 6: //Xenon primaryStat = (Str + Dex + Luk); break; } if (!mage) { damR += pdR; //TODO: check, Not sure about this } CalculateDamageRange(weaponItemType, primaryStat, secondaryStat, mage ? matk : watk, damR, chr.IsFighter); }
public void packetAction(Client c, PacketReader packet) { try { if (packet.Length > 7) { byte identifier = packet.Read(); if (identifier == 0x00) //Gained item { MapleItem mapleEquip; short items = packet.ReadShort(); for (short y = 0; y < items; y++) { byte miniID = packet.Read(); if (miniID == 0x01) { byte invent = packet.Read(); short slotz = packet.ReadShort(); short amtt = packet.ReadShort(); if (amtt > 0) { c.myCharacter.Inventorys[c.myCharacter.Inventorys[InventoryType.EQUIP].getInvenType(invent)].updateItemCount((byte)slotz, amtt); MapleItem item = c.myCharacter.Inventorys[c.myCharacter.Inventorys[InventoryType.EQUIP].getInvenType(invent)].getItem((byte)slotz); if (item != null) { c.updateLog("[Inventory] Slot " + slotz.ToString() + ": " + item.quantity + " " + Database.getItemName(item.ID) + "s"); } } continue; } else if (miniID == 0x03) { byte invent = packet.Read(); short slotz = packet.ReadShort(); c.myCharacter.Inventorys[c.myCharacter.Inventorys[InventoryType.EQUIP].getInvenType(invent)].removeSlot((byte)slotz); if (c.clientMode != ClientMode.WBMESOEXPLOIT) { c.updateLog("[Inventory] Slot " + slotz.ToString() + " freed."); } } else // miniID == 0x00 { byte itemType = packet.Read(); byte slot = packet.Read(); packet.Read(); packet.Read(); //?????? switch (itemType) { case 1: { mapleEquip = new MapleEquip(packet.ReadInt(), slot); break; } case 2: { mapleEquip = new MapleItem(packet.ReadInt(), slot, 1); break; } case 3: { mapleEquip = null; packet.ReadInt(); break; } default: { return; } } InventoryType type = c.myCharacter.Inventorys[InventoryType.EQUIP].getInvenTypeByID(mapleEquip.ID); if (mapleEquip != null) { if (!c.myCharacter.Inventorys[type].inventory.ContainsKey(mapleEquip.position)) { c.myCharacter.Inventorys[type].inventory.Add(mapleEquip.position, mapleEquip); } if (mapleEquip.type == 1) { while (true) { while (true) { if (packet.Read() == 0x4) { int x = 0; byte bytes = 0; bool complete = false; while (true) { bytes = packet.Read(); if (bytes == 0) { x++; } else if (bytes == 4) { x = 0; } else { break; } if (x >= 3) { complete = true; break; } } if (complete) { packet.Read(); break; } } Thread.Sleep(1); } mapleEquip.craftedBy = packet.ReadMapleString(); mapleEquip.potLevel = packet.Read(); mapleEquip.enhancements = packet.Read(); int potLine1 = packet.ReadShort(); int potLine2 = packet.ReadShort(); int potLine3 = packet.ReadShort(); short bonuspotline1 = packet.ReadShort(); short bonuspotline2 = packet.ReadShort(); short bonuspotline3 = packet.ReadShort(); packet.ReadShort(); mapleEquip.bonuspotLevel = packet.Read(); packet.Read(); short nebulite = packet.ReadShort(); while (true) { while (packet.Read() != 0x40) { } if (packet.Read() == 0xE0) { break; } Thread.Sleep(1); } while (packet.Read() != 0xFF) { Thread.Sleep(1); } packet.Skip(3); while (true) { while (packet.Read() != 0x40) { Thread.Sleep(1); } if (packet.Read() == 0xE0) { break; } Thread.Sleep(1); } while (packet.Read() != 0x01) { Thread.Sleep(1); } packet.Skip(16); break; } } else { packet.Skip(13); mapleEquip.quantity = packet.ReadShort(); packet.ReadInt(); } if (c.clientMode == ClientMode.CASSANDRA) { if (mapleEquip.ID == 2431042 || mapleEquip.ID == 2049402 || mapleEquip.ID == 1122221) { continue; } } c.updateLog("[Inventory] Gained " + mapleEquip.quantity + " " + Database.getItemName(mapleEquip.ID)); } } } } else if (identifier == 0x01) //Drop { packet.ReadShort(); byte action = packet.Read(); byte invenType = packet.Read(); byte slotNum = packet.Read(); packet.Read(); InventoryType type = c.myCharacter.Inventorys[InventoryType.EQUIP].getInvenType(invenType); if (action == 0x01) //D { short remaining = packet.ReadShort(); c.myCharacter.Inventorys[type].updateItemCount(slotNum, remaining); } else if (action == 0x03) { c.myCharacter.Inventorys[type].removeSlot(slotNum); } } /* * * byte inventoryType = packet.Read(); * if (inventoryType != 0) * { * short slot = packet.ReadShort(); * try * { * packet.Read(); * int itemID = packet.ReadInt(); * short itemCount = packet.ReadShort(); * string itemName = ""; * switch (inventoryType) * { * case 1: * c.myCharacter.Inventorys[InventoryType.EQUIP].updateItemCount((byte)slot, itemCount, itemID); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.EQUIP].getItem((byte)slot).ID); * break; * case 2: * c.myCharacter.Inventorys[InventoryType.USE].updateItemCount((byte)slot, itemCount, itemID); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.USE].getItem((byte)slot).ID); * break; * case 3: * c.myCharacter.Inventorys[InventoryType.SETUP].updateItemCount((byte)slot, itemCount, itemID); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.SETUP].getItem((byte)slot).ID); * break; * case 4: * c.myCharacter.Inventorys[InventoryType.ETC].updateItemCount((byte)slot, itemCount, itemID); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.ETC].getItem((byte)slot).ID); * break; * case 5: * c.myCharacter.Inventorys[InventoryType.CASH].updateItemCount((byte)slot, itemCount, itemID); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.CASH].getItem((byte)slot).ID); * break; * } * c.updateAccountStatus(itemCount.ToString() + " " + itemName + "s"); * c.updateLog("[Inventory] " + itemCount.ToString() + " " + itemName + "s"); * } * catch * { * string itemName = ""; * switch (inventoryType) * { * case 1: * c.myCharacter.Inventorys[InventoryType.EQUIP].removeSlot((byte)slot); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.EQUIP].getItem((byte)slot).ID); * break; * case 2: * c.myCharacter.Inventorys[InventoryType.USE].removeSlot((byte)slot); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.USE].getItem((byte)slot).ID); * break; * case 3: * c.myCharacter.Inventorys[InventoryType.SETUP].removeSlot((byte)slot); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.SETUP].getItem((byte)slot).ID); * break; * case 4: * c.myCharacter.Inventorys[InventoryType.ETC].removeSlot((byte)slot); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.ETC].getItem((byte)slot).ID); * break; * case 5: * c.myCharacter.Inventorys[InventoryType.CASH].removeSlot((byte)slot); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.CASH].getItem((byte)slot).ID); * break; * } * c.updateLog("[Inventory] " + "You now have 0 " + itemName + "s"); * } * } * else //Item Gained * { * } * * */ } } catch (Exception e) { c.updateLog("INVEN UPDATE ERROR " + e.ToString()); } }
public static void Handle(MapleClient c, PacketReader pr) { MapleCharacter newCharacter = MapleCharacter.GetDefaultCharacter(c); bool succesful = false; string name = pr.ReadMapleString(); if (!Functions.IsAlphaNumerical(name)) { return; } bool nameAvailable = !MapleCharacter.CharacterExists(name); if (nameAvailable) { bool basicKeyLayout = pr.ReadInt() == 0; pr.Skip(4); //-1 int jobId = pr.ReadInt(); JobType jobType = (JobType)jobId; bool jobIsEnabled; if (!GameConstants.CreateJobOptions.TryGetValue(jobType, out jobIsEnabled) || !jobIsEnabled) { return; } /*ServerConsole.Debug("Jobtype " + jobId); * PacketWriter pws = new PacketWriter(); * pws.WriteHeader(SendHeader.AddCharacter); * pws.WriteBool(!false); //0 = succesful, 1 = failed * c.SendPacket(pws); * return;*/ short subJob = pr.ReadShort(); byte gender = pr.ReadByte(); byte skinColor = pr.ReadByte(); byte availableInts = pr.ReadByte(); // amount of following integers in the packet representing hair, skin and equips if (pr.Available / 4 != availableInts) //Must be a packet edit { return; } int face = pr.ReadInt(); int hair = pr.ReadInt(); int hairColor = 0; int faceMark = 0; int tamerTail = 0; int tamerEars = 0; Dictionary <MapleEquipPosition, int> items = new Dictionary <MapleEquipPosition, int>(); switch (jobType) { case JobType.Explorer: case JobType.DualBlade: case JobType.Cannonneer: case JobType.Cygnus: pr.Skip(4); //skin color again items.Add(MapleEquipPosition.Top, pr.ReadInt()); items.Add(MapleEquipPosition.Shoes, pr.ReadInt()); items.Add(MapleEquipPosition.Weapon, pr.ReadInt()); break; case JobType.Resistance: case JobType.Aran: case JobType.Evan: case JobType.Mihile: hairColor = pr.ReadInt(); pr.Skip(4); //skin color again items.Add(MapleEquipPosition.Top, pr.ReadInt()); items.Add(MapleEquipPosition.Bottom, pr.ReadInt()); items.Add(MapleEquipPosition.Shoes, pr.ReadInt()); items.Add(MapleEquipPosition.Weapon, pr.ReadInt()); break; case JobType.Jett: items.Add(MapleEquipPosition.Top, pr.ReadInt()); items.Add(MapleEquipPosition.Cape, pr.ReadInt()); items.Add(MapleEquipPosition.Shoes, pr.ReadInt()); items.Add(MapleEquipPosition.Weapon, pr.ReadInt()); break; case JobType.Mercedes: items.Add(MapleEquipPosition.Top, pr.ReadInt()); items.Add(MapleEquipPosition.Shoes, pr.ReadInt()); items.Add(MapleEquipPosition.Weapon, pr.ReadInt()); break; case JobType.Phantom: case JobType.Luminous: pr.Skip(4); //skin color again items.Add(MapleEquipPosition.Top, pr.ReadInt()); items.Add(MapleEquipPosition.Cape, pr.ReadInt()); items.Add(MapleEquipPosition.Shoes, pr.ReadInt()); items.Add(MapleEquipPosition.Weapon, pr.ReadInt()); break; case JobType.Demon: faceMark = pr.ReadInt(); items.Add(MapleEquipPosition.Top, pr.ReadInt()); items.Add(MapleEquipPosition.Shoes, pr.ReadInt()); items.Add(MapleEquipPosition.Weapon, pr.ReadInt()); items.Add(MapleEquipPosition.SecondWeapon, pr.ReadInt()); break; case JobType.Xenon: hairColor = pr.ReadInt(); pr.Skip(4); //skin color again faceMark = pr.ReadInt(); items.Add(MapleEquipPosition.Top, pr.ReadInt()); items.Add(MapleEquipPosition.Shoes, pr.ReadInt()); items.Add(MapleEquipPosition.Weapon, pr.ReadInt()); break; case JobType.Hayato: case JobType.Kanna: hairColor = pr.ReadInt(); pr.Skip(4); //skin color again items.Add(MapleEquipPosition.Hat, pr.ReadInt()); items.Add(MapleEquipPosition.Top, pr.ReadInt()); items.Add(MapleEquipPosition.Shoes, pr.ReadInt()); items.Add(MapleEquipPosition.Weapon, pr.ReadInt()); break; case JobType.Kaiser: case JobType.AngelicBuster: pr.Skip(4); //skin color again items.Add(MapleEquipPosition.Top, pr.ReadInt()); items.Add(MapleEquipPosition.Shoes, pr.ReadInt()); items.Add(MapleEquipPosition.Weapon, pr.ReadInt()); break; case JobType.BeastTamer: pr.Skip(4); //skin color again faceMark = pr.ReadInt(); tamerEars = pr.ReadInt(); tamerTail = pr.ReadInt(); items.Add(MapleEquipPosition.Top, pr.ReadInt()); items.Add(MapleEquipPosition.Shoes, pr.ReadInt()); items.Add(MapleEquipPosition.Weapon, pr.ReadInt()); break; } if (CreateInfo.IsValidCharacter(jobType, gender, hair, face, items, hairColor, skinColor, faceMark, tamerEars, tamerTail)) { if (jobType == JobType.Xenon) { hair = (hair / 10) * 10; //male1 and female1 hair is 36487 and 37467 instead of 36480 and 37460 ... } if (jobType != JobType.Mihile) //Mihile hair color is already in the hair ID, but is still sent in the packet { hair += hairColor; } newCharacter = MapleCharacter.GetDefaultCharacter(c); newCharacter.Name = name; newCharacter.Gender = gender; newCharacter.Skin = skinColor; newCharacter.Face = face; newCharacter.Hair = hair; newCharacter.Job = CreateInfo.GetJobIdByJobType(jobType); newCharacter.SubJob = subJob; newCharacter.FaceMark = faceMark; newCharacter.TamerEars = CreateInfo.GetTamerItemEffectId(tamerEars); newCharacter.TamerTail = CreateInfo.GetTamerItemEffectId(tamerTail); foreach (KeyValuePair <MapleEquipPosition, int> item in items) { WzEquip wzInfo = DataBuffer.GetEquipById(item.Value); if (wzInfo != null) { MapleEquip equip = new MapleEquip(item.Value, "Character creation with jobId: " + jobId, position: (short)item.Key); equip.SetDefaultStats(wzInfo); newCharacter.Inventory.SetItem(equip, MapleInventoryType.Equipped, equip.Position, false); } } if (basicKeyLayout) { newCharacter.SetKeyMap(GameConstants.DefaultBasicKeyBinds); newCharacter.SetQuickSlotKeys(GameConstants.DefaultBasicQuickSlotKeyMap); } else { newCharacter.SetKeyMap(GameConstants.DefaultSecondaryKeyBinds); newCharacter.SetQuickSlotKeys(GameConstants.DefaultSecondaryQuickSlotKeyMap); } CreateInfo.AddBeginnerJobSkills(newCharacter, jobType); newCharacter.InsertCharacter(); newCharacter.Inventory.SaveToDatabase(true); succesful = true; } else { ServerConsole.Warning("Invalid item/hair/face ID on char creation, type: " + Enum.GetName(typeof(JobType), jobType)); } } //AddCharacter response PacketWriter pw = new PacketWriter(); pw.WriteHeader(SendHeader.AddCharacter); pw.WriteBool(!succesful); //0 = succesful, 1 = failed if (succesful) { MapleCharacter.AddCharEntry(pw, newCharacter); } c.SendPacket(pw); //cleanup newCharacter?.Release(); }
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); }
private static bool GetAndCheckItemsFromInventory(MapleInventory inventory, short equipSlot, short scrollSlot, out MapleEquip equip, out MapleItem scroll) { MapleInventoryType equipInventory = equipSlot < 0 ? MapleInventoryType.Equipped : MapleInventoryType.Equip; equip = inventory.GetItemSlotFromInventory(equipInventory, equipSlot) as MapleEquip; scroll = inventory.GetItemSlotFromInventory(MapleInventoryType.Use, scrollSlot); return(equip != null && scroll != null); }
//Returns false if character doensn't have ammo public static bool HandleRangedAttackAmmoUsage(MapleCharacter chr, int bulletCon) { if (!chr.IsMechanic && !chr.IsMercedes) // Don't use ammo { MapleEquip weapon = chr.Inventory.GetEquippedItem((short)MapleEquipPosition.Weapon) as MapleEquip; MapleItemType weaponType = weapon.ItemType; int ammoItemId = 0; switch (weaponType) { case MapleItemType.Bow: if (!chr.HasBuff(Hunter.SOUL_ARROW_BOW) && !chr.HasBuff(WindArcher2.SOUL_ARROW)) { MapleItem ammoItem = chr.Inventory.GetFirstItemFromInventory(MapleInventoryType.Use, item => item.IsBowArrow && item.Quantity > 0); if (ammoItem == null) { return(false); //player has no bow arrows } ammoItemId = ammoItem.ItemId; } break; case MapleItemType.Crossbow: if (!chr.HasBuff(Crossbowman.SOUL_ARROW_CROSSBOW) && !chr.HasBuff(WildHunter2.SOUL_ARROW_CROSSBOW)) { MapleItem ammoItem = chr.Inventory.GetFirstItemFromInventory(MapleInventoryType.Use, item => item.IsCrossbowArrow && item.Quantity > 0); if (ammoItem == null) { return(false); //player has no xbow arrows } ammoItemId = ammoItem.ItemId; } break; case MapleItemType.Claw: if (!chr.HasBuff(Hermit.SHADOW_STARS) && !chr.HasBuff(NightWalker3.SHADOW_STARS)) { MapleItem ammoItem = chr.Inventory.GetFirstItemFromInventory(MapleInventoryType.Use, item => item.IsThrowingStar && item.Quantity > 0); if (ammoItem == null) { return(false); //player has no bullets } ammoItemId = ammoItem.ItemId; } break; case MapleItemType.Gun: if (!chr.HasBuff(Gunslinger.INFINITY_BLAST)) { MapleItem ammoItem = chr.Inventory.GetFirstItemFromInventory(MapleInventoryType.Use, item => item.IsBullet && item.Quantity > 0); if (ammoItem == null) { return(false); //player has no bullets } ammoItemId = ammoItem.ItemId; } break; } if (ammoItemId > 0) { chr.Inventory.RemoveItemsById(ammoItemId, bulletCon, false); //Even if player only has 1 bullet left and bulletCon is > 1, we'll allow it since it removes the item or stack anyway } } return(true); }
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(); } }