public static MapleItem CreateItem(int itemId, string source, short quantity = 1, bool randomStats = false) { MapleInventoryType type = ItemConstants.GetInventoryType(itemId); if (type == MapleInventoryType.Equip) { WzEquip wzInfo = DataBuffer.GetEquipById(itemId); if (wzInfo != null) { MapleEquip equip = new MapleEquip(itemId, source); equip.SetDefaultStats(wzInfo, randomStats); return(equip); } } else if (type != MapleInventoryType.Undefined) { WzItem wzInfo = DataBuffer.GetItemById(itemId); if (wzInfo != null) { if (wzInfo.SlotMax > 0 && quantity > wzInfo.SlotMax) { quantity = (short)wzInfo.SlotMax; } MapleItem item = new MapleItem(itemId, source, quantity); return(item); } } return(null); }
private static bool CanCube(MapleEquip equip, WzEquip equipInfo) { if (equip.PotentialState < MaplePotentialState.Rare) { return(false); //Potential is hidden or non-existant, can't be cubed } return(true); }
public void SetDefaultStats(WzEquip info, bool randomizeStats = false, bool addRandomPotential = false) { UpgradeCount = 0; Enhancements = 0; Diligence = 0; CustomLevel = 0; CustomExp = 0; HammersApplied = 0; if (info != null) { RemainingUpgradeCount = info.TotalUpgradeCount; if (randomizeStats) { Str = GetRandomizedStat(info.IncStr); Int = GetRandomizedStat(info.IncInt); Dex = GetRandomizedStat(info.IncDex); Luk = GetRandomizedStat(info.IncLuk); IncMhp = GetRandomizedStat(info.IncMhp); IncMmp = GetRandomizedStat(info.IncMmp); Pad = GetRandomizedStat(info.IncPad); Mad = GetRandomizedStat(info.IncMad); Pdd = GetRandomizedStat(info.IncPdd); Mdd = GetRandomizedStat(info.IncMdd); Acc = GetRandomizedStat(info.IncAcc); Eva = GetRandomizedStat(info.IncEva); Speed = GetRandomizedStat(info.IncSpeed); Jump = GetRandomizedStat(info.IncJump); } else { Str = info.IncStr; Int = info.IncInt; Dex = info.IncDex; Luk = info.IncLuk; IncMhp = info.IncMhp; IncMmp = info.IncMmp; Pad = info.IncPad; Mad = info.IncMad; Pdd = info.IncPdd; Mdd = info.IncMdd; Acc = info.IncAcc; Eva = info.IncEva; Speed = info.IncSpeed; Jump = info.IncJump; } if (addRandomPotential) //todo: check if this equip can have potential { MapleEquipEnhancer.AddRandomPotential(this, equipInfo: info); } } else { ServerConsole.Error("Equip id {0} not in Data Buffer!", ItemId); } }
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 bool CubeItem(MapleEquip equip, CubeType cubeType, MapleCharacter chr, bool reveal = false) { WzEquip equipInfo = DataBuffer.GetEquipById(equip.ItemId); if (equipInfo == null || !CanCube(equip, equipInfo)) { return(false); } int currentLines = equip.Potential3 > 0 ? 3 : 2; double lineIncreaseChance = 0; double gradeIncreaseChance = 0; double gradeDecreaseChance = 0; int otherLinesIncreaseChance = 0; //chance to increase the other lines' grade to the current grade switch (cubeType) { case CubeType.Occult: { switch (equip.PotentialState) { case MaplePotentialState.Rare: { gradeIncreaseChance = 4; break; } case MaplePotentialState.Epic: { gradeIncreaseChance = 2; gradeDecreaseChance = 2; otherLinesIncreaseChance = 15; break; } case MaplePotentialState.Unique: { gradeDecreaseChance = 3; otherLinesIncreaseChance = 5; break; } default: return(false); } break; } case CubeType.MasterCraftsman: { switch (equip.PotentialState) { case MaplePotentialState.Rare: { gradeIncreaseChance = 5; break; } case MaplePotentialState.Epic: { otherLinesIncreaseChance = 20; gradeIncreaseChance = 3; break; } case MaplePotentialState.Unique: otherLinesIncreaseChance = 5; break; default: return(false); } break; } case CubeType.Meister: { lineIncreaseChance = 5; switch (equip.PotentialState) { case MaplePotentialState.Rare: { gradeIncreaseChance = 6; break; } case MaplePotentialState.Epic: { otherLinesIncreaseChance = 30; gradeIncreaseChance = 4; break; } case MaplePotentialState.Unique: { otherLinesIncreaseChance = 20; gradeIncreaseChance = 2; break; } case MaplePotentialState.Legendary: { otherLinesIncreaseChance = 10; break; } default: return(false); } break; } case CubeType.PlatinumMiracle: { lineIncreaseChance = 7; switch (equip.PotentialState) { case MaplePotentialState.Rare: { gradeIncreaseChance = 15; break; } case MaplePotentialState.Epic: { otherLinesIncreaseChance = 40; gradeIncreaseChance = 10; break; } case MaplePotentialState.Unique: { otherLinesIncreaseChance = 30; gradeIncreaseChance = 4; break; } case MaplePotentialState.Legendary: { otherLinesIncreaseChance = 20; break; } default: return(false); } break; } default: return(false); } if (currentLines == 2 && Functions.MakeChance(lineIncreaseChance)) { currentLines = 3; } if (Functions.MakeChance(gradeIncreaseChance) && equip.PotentialState < MaplePotentialState.Legendary) { equip.PotentialState++; } else if (Functions.MakeChance(gradeDecreaseChance) && equip.PotentialState > MaplePotentialState.Rare) { equip.PotentialState--; } ushort[] newLines = new ushort[currentLines]; newLines[0] = DataBuffer.GetRandomPotential(equip.PotentialState, equipInfo.ReqLevel, equip.ItemId); for (int i = 1; i < newLines.Length; i++) { if (equip.PotentialState == MaplePotentialState.Rare || Functions.MakeChance(otherLinesIncreaseChance)) { newLines[i] = DataBuffer.GetRandomPotential(equip.PotentialState, equipInfo.ReqLevel, equip.ItemId); } else { newLines[i] = DataBuffer.GetRandomPotential(equip.PotentialState - 1, equipInfo.ReqLevel, equip.ItemId); } } newLines = newLines.OrderByDescending(x => x).ToArray(); equip.Potential1 = newLines[0]; equip.Potential2 = newLines[1]; if (currentLines == 3) { equip.Potential3 = newLines[2]; } if (!reveal) { equip.PotentialState -= 16; // Hide potential, needs to be revealed } equip.SaveToDatabase(chr); chr.Client.SendPacket(MapleInventory.Packets.AddItem(equip, MapleInventoryType.Equip, equip.Position)); return(true); }
public static void AddRandomBonusPotential(MapleEquip equip, MaplePotentialState grade = MaplePotentialState.Rare, WzEquip equipInfo = null) { if (equipInfo == null) { equipInfo = DataBuffer.GetEquipById(equip.ItemId); } }
public static void AddRandomPotential(MapleEquip equip, MaplePotentialState minimumGrade = MaplePotentialState.HiddenRare, WzEquip equipInfo = null) { if (equipInfo == null) { equipInfo = DataBuffer.GetEquipById(equip.ItemId); } // 0.25% chance for unique, 5% chance for epic, otherwise rare if (minimumGrade > MaplePotentialState.HiddenLegendary) { minimumGrade -= 16; } equip.PotentialState = Functions.MakeChance(5) ? (Functions.MakeChance(5) ? MaplePotentialState.HiddenUnique : MaplePotentialState.HiddenEpic) : MaplePotentialState.HiddenRare; if (equip.PotentialState < minimumGrade) { equip.PotentialState = minimumGrade; } MaplePotentialState lowerGrade = equip.PotentialState == MaplePotentialState.HiddenRare ? MaplePotentialState.HiddenRare : equip.PotentialState - 1; equip.Potential1 = DataBuffer.GetRandomPotential(equip.PotentialState, equipInfo.ReqLevel, equip.ItemId); equip.Potential2 = DataBuffer.GetRandomPotential(Functions.MakeChance(20) ? equip.PotentialState : lowerGrade, equipInfo.ReqLevel, equip.ItemId); // 20% chance to be of the same grade as line 1, otherwise 1 lower equip.Potential3 = Functions.MakeChance(7) ? DataBuffer.GetRandomPotential(lowerGrade, equipInfo.ReqLevel, equip.ItemId) : (ushort)0; // 7% chance for 3rd line }
public static void UseRegularEquipScroll(MapleCharacter chr, MapleEquip equip, MapleItem scroll, bool whiteScroll) { WzItemEnhancer scrollInfo = DataBuffer.GetItemById(scroll.ItemId) as WzItemEnhancer; if (scrollInfo == null) { return; } WzEquip equipInfo = DataBuffer.GetEquipById(equip.ItemId); string reason = ""; if (equipInfo == null || !CanScroll(equip, equipInfo, scrollInfo, out reason)) { chr.SendPopUpMessage("You cannot use that scroll on this item. " + reason); chr.EnableActions(); return; } byte upgradeSlotsUsed = 1; int scrollBaseId = scroll.ItemId / 100; if (scrollBaseId == 20490 || //clean slate scroll scrollBaseId == 20493 || //equip enhancement scroll scrollBaseId == 20496) //innocence scroll { upgradeSlotsUsed = 0; } switch (scroll.ItemId) { case 2040727: //Scroll for Spikes on Shoes case 2041058: //Scroll for Cape for Cold Protection upgradeSlotsUsed = 0; break; } int value; if (scrollInfo.StatEnhancements.TryGetValue("tuc", out value)) //Uses multiple upgrade slots { upgradeSlotsUsed = (byte)value; } if (equip.RemainingUpgradeCount < upgradeSlotsUsed) { chr.SendPopUpMessage(string.Format("This item does not have enough upgrades available")); chr.EnableActions(); return; } byte scrollResult = 0; bool destroyed = false; bool removeScroll = true; int chance = scrollInfo.Chance; bool scrollProtection = equip.CheckAndRemoveFlag(MapleItemFlags.ScrollProtection); bool upgradeCountProtection = upgradeSlotsUsed > 0 && equip.CheckAndRemoveFlag(MapleItemFlags.UpgradeCountProtection); bool curseProtection = equip.CheckAndRemoveFlag(MapleItemFlags.CurseProtection); if (equip.CheckAndRemoveFlag(MapleItemFlags.LuckyDay)) { chance += 10; } if (Functions.MakeChance(chance)) { scrollResult = 1; equip.UpgradeCount += upgradeSlotsUsed; foreach (var kvp in scrollInfo.StatEnhancements) { switch (kvp.Key) { case "incPDD": equip.Pdd += (short)kvp.Value; break; case "incMDD": equip.Mdd += (short)kvp.Value; break; case "incACC": equip.Acc += (short)kvp.Value; break; case "incMHP": equip.IncMhp += (short)kvp.Value; break; case "incINT": equip.Int += (short)kvp.Value; break; case "incDEX": equip.Dex += (short)kvp.Value; break; case "incMAD": equip.Mad += (short)kvp.Value; break; case "incPAD": equip.Pad += (short)kvp.Value; break; case "incEVA": equip.Eva += (short)kvp.Value; break; case "incLUK": equip.Luk += (short)kvp.Value; break; case "incMMP": equip.IncMmp += (short)kvp.Value; break; case "incSTR": equip.Str += (short)kvp.Value; break; case "incSpeed": equip.Speed += (short)kvp.Value; break; case "incJump": equip.Jump += (short)kvp.Value; break; case "incCraft": equip.Diligence += (short)kvp.Value; break; case "preventslip": equip.Flags |= MapleItemFlags.NoSlip; break; case "warmsupport": equip.Flags |= MapleItemFlags.ColdResistance; break; case "recover": { int totalPossibleUpgrades = equipInfo.TotalUpgradeCount + equip.HammersApplied; int failedUpgrades = totalPossibleUpgrades - equip.UpgradeCount - equip.RemainingUpgradeCount; int toRestore = Math.Min(failedUpgrades, kvp.Value); if (toRestore > 0) { equip.RemainingUpgradeCount += (byte)toRestore; } break; } case "randstat": //chaos scroll { bool betterStats = scrollInfo.StatEnhancements.ContainsKey("incRandVol"); bool noNegative = scrollInfo.StatEnhancements.ContainsKey("noNegative"); if (equip.Str > 0) { equip.Str = GetNewChaosStat(equip.Str, betterStats, noNegative); } if (equip.Dex > 0) { equip.Dex = GetNewChaosStat(equip.Dex, betterStats, noNegative); } if (equip.Int > 0) { equip.Int = GetNewChaosStat(equip.Int, betterStats, noNegative); } if (equip.Luk > 0) { equip.Luk = GetNewChaosStat(equip.Luk, betterStats, noNegative); } if (equip.Pad > 0) { equip.Pad = GetNewChaosStat(equip.Pad, betterStats, noNegative); } if (equip.Mad > 0) { equip.Mad = GetNewChaosStat(equip.Mad, betterStats, noNegative); } if (equip.Pdd > 0) { equip.Pdd = GetNewChaosStat(equip.Pdd, betterStats, noNegative); } if (equip.Mdd > 0) { equip.Mdd = GetNewChaosStat(equip.Mdd, betterStats, noNegative); } if (equip.Acc > 0) { equip.Acc = GetNewChaosStat(equip.Acc, betterStats, noNegative); } if (equip.Eva > 0) { equip.Eva = GetNewChaosStat(equip.Eva, betterStats, noNegative); } if (equip.Speed > 0) { equip.Speed = GetNewChaosStat(equip.Speed, betterStats, noNegative); } if (equip.Jump > 0) { equip.Jump = GetNewChaosStat(equip.Jump, betterStats, noNegative); } if (equip.IncMhp > 0) { equip.IncMhp = GetNewChaosStat(equip.IncMhp, betterStats, noNegative); } if (equip.IncMmp > 0) { equip.IncMmp = GetNewChaosStat(equip.IncMmp, betterStats, noNegative); } break; } case "reset": { equip.SetDefaultStats(equipInfo, true); break; } case "perfectReset": { equip.SetDefaultStats(equipInfo); break; } } equip.SaveToDatabase(chr); } } else //Fail { int cursedChance; if (scrollInfo.StatEnhancements.TryGetValue("cursed", out cursedChance)) { destroyed = !curseProtection && Functions.MakeChance(cursedChance); } if (scrollProtection) { removeScroll = false; } if (upgradeCountProtection) { upgradeSlotsUsed = 0; } //todo: white scroll } equip.RemainingUpgradeCount -= upgradeSlotsUsed; if (removeScroll) { chr.Inventory.RemoveItemsFromSlot(scroll.InventoryType, scroll.Position, 1); } if (destroyed) { chr.Inventory.RemoveItem(equip.InventoryType, equip.Position); scrollResult = 2; } else { chr.Client.SendPacket(MapleInventory.Packets.AddItem(equip, equip.InventoryType, equip.Position)); //Update item stats } chr.Map.BroadcastPacket(Packets.ShowScrollEffect(chr.Id, scrollResult, scroll.ItemId, equip.ItemId), chr, true); }
public static void UseSpecialEquipScroll(MapleEquip equip, MapleItem scroll, MapleCharacter chr) { WzEquip equipInfo = DataBuffer.GetEquipById(equip.ItemId); if (equipInfo == null || equipInfo.IsCashItem) { return; } bool success = false; switch (scroll.ItemId) { //Safety scroll: case 5064101: //Safety Scroll Lite { if (equipInfo.ReqLevel > 105) { break; } goto case 2532000; } case 2532001: // Pet equip Safety Scrolls case 2532004: case 5068100: { //todo: check if it's a pet equip goto case 2532000; } case 2532000: case 2532002: case 2532003: case 5064100: { if (equip.RemainingUpgradeCount > 0 && !equip.Flags.HasFlag(MapleItemFlags.UpgradeCountProtection)) { equip.Flags |= MapleItemFlags.UpgradeCountProtection; success = true; } break; } //Recovery scroll: case 5064301: //lite { if (equipInfo.ReqLevel > 105) { break; } goto case 2533000; } case 2533001: case 2533002: case 5068200: { //todo: check if it's a pet equip goto case 2533000; } case 2533000: case 5064300: { if (!equip.Flags.HasFlag(MapleItemFlags.ScrollProtection)) { equip.Flags |= MapleItemFlags.ScrollProtection; success = true; } break; } //Lucky day scroll: case 5068000: case 2530003: case 2530006: { //todo: check if it's a pet equip goto case 2530000; } case 2530000: case 2530002: case 2530004: case 5063000: { if (equip.RemainingUpgradeCount > 0 && !equip.Flags.HasFlag(MapleItemFlags.LuckyDay)) { equip.Flags |= MapleItemFlags.LuckyDay; success = true; } break; } //Protection scroll: case 5064002: //Protection Scroll Lite { if (equipInfo.ReqLevel > 105) { break; } goto case 2531000; } case 2531000: case 2531001: case 2531004: case 2531005: case 2531007: case 5064000: { if (equip.Enhancements < 12 && !equip.Flags.HasFlag(MapleItemFlags.CurseProtection)) { equip.Flags |= MapleItemFlags.CurseProtection; success = true; } break; } } if (success) { chr.Inventory.RemoveItemsFromSlot(scroll.InventoryType, scroll.Position, 1); chr.Client.SendPacket(MapleInventory.Packets.AddItem(equip, MapleInventoryType.Equip, equip.Position)); chr.Client.SendPacket(Packets.ShowScrollEffect(chr.Id, 1, scroll.ItemId, equip.ItemId)); } else { chr.SendPopUpMessage("You cannot use that on this item"); } }
public static void UseEquipEnhancementScroll(MapleEquip equip, MapleItem scroll, MapleCharacter chr) { if (equip == null || scroll == null) { return; } WzItemEnhancer wzScrollInfo = DataBuffer.GetItemById(scroll.ItemId) as WzItemEnhancer; WzEquip equipInfo = DataBuffer.GetEquipById(equip.ItemId); if (wzScrollInfo == null || equipInfo == null) { return; } int maxEnhancements; if (wzScrollInfo == null || equipInfo == null || (maxEnhancements = equipInfo.MaxStarEnhance) - equip.Enhancements < 1 || equip.RemainingUpgradeCount > 0) { chr.SendPopUpMessage("You cannot use that on this item."); chr.EnableActions(); return; } int chance; bool diminishChance = false; int enhancements; int curseChance = 100; switch (scroll.ItemId) { case 2049323: //advanced equip enhancement scroll curseChance = 0; goto case 2049300; case 2049300: case 2049303: case 2049306: case 2049325: { chance = 100; diminishChance = true; enhancements = 1; break; } case 2049301: //equip enhancement scroll case 2049307: { chance = 80; diminishChance = true; enhancements = 1; break; } default: { if (wzScrollInfo.StatEnhancements.TryGetValue("forceUpgrade", out enhancements) && //multiple star enhances wzScrollInfo.StatEnhancements.TryGetValue("success", out chance)) { if (!wzScrollInfo.StatEnhancements.TryGetValue("cursed", out curseChance)) { curseChance = 100; } break; } chr.SendPopUpMessage("This item is not coded, please report it on the forums. ItemId " + scroll.ItemId); ServerConsole.Debug("ItemID {0} is unhandled in UseEnhancementScroll", scroll.ItemId); return; } } bool scrollProtection = equip.CheckAndRemoveFlag(MapleItemFlags.ScrollProtection); bool curseProtection = equip.CheckAndRemoveFlag(MapleItemFlags.CurseProtection) && equip.Enhancements < 12; bool success = EnhanceEquip(equip, chance, diminishChance, enhancements, maxEnhancements); bool destroyed = false; byte scrollResult = 1; bool removeScroll = success || !scrollProtection; if (!success) { scrollResult = 0; if (!curseProtection && Functions.MakeChance(curseChance)) { scrollResult = 2; destroyed = true; } } if (removeScroll) { chr.Inventory.RemoveItemsFromSlot(scroll.InventoryType, scroll.Position, 1); } if (destroyed) { chr.Inventory.RemoveItem(equip.InventoryType, equip.Position); } else { chr.Client.SendPacket(MapleInventory.Packets.AddItem(equip, equip.InventoryType, equip.Position)); //Update item } chr.Map.BroadcastPacket(Packets.ShowScrollEffect(chr.Id, scrollResult, scroll.ItemId, equip.ItemId), chr, true); }
private static bool CanScroll(MapleEquip equip, WzEquip equipInfo, WzItemEnhancer enhancerInfo, out string message) { message = ""; if (enhancerInfo.ItemId < 2046000) { if ((equip.ItemId - 1000000) / 10000 != (enhancerInfo.ItemId - 2040000) / 100) { return(false); } } else if (enhancerInfo.ItemId < 2047000) { int type = (enhancerInfo.ItemId - 2046000) / 100; switch (type) { case 0: if (!IsOneHandedWeaponScrollable(equip.ItemId)) { return(false); } break; case 1: if (!IsTwoHandedWeaponScrollable(equip.ItemId)) { return(false); } break; case 2: if (!IsArmorScrollable(equip.ItemId)) { return(false); } break; case 3: if (!IsAccessoryScrollable(equip.ItemId)) { return(false); } break; default: message = "Unhandled scroll, please report this on the forums. ItemId: " + enhancerInfo.ItemId; return(false); } } if (enhancerInfo.UseableOnIds.Count > 0 && !enhancerInfo.UseableOnIds.Contains(equip.ItemId)) { return(false); } int value; if (enhancerInfo.StatEnhancements.TryGetValue("reqCUC", out value) && equip.UpgradeCount < value) { message = "Item does not have the required upgrade count."; return(false); } if ((enhancerInfo.StatEnhancements.TryGetValue("reqRUC", out value) || enhancerInfo.StatEnhancements.TryGetValue("tuc", out value)) && equip.RemainingUpgradeCount < value) { message = "Item does not have the required remaining upgrade count."; return(false); } if (enhancerInfo.StatEnhancements.TryGetValue("reqEquipLevelMin", out value)) { if (equipInfo.ReqLevel < value) { message = "Item does not have the required level."; return(false); } } if (enhancerInfo.StatEnhancements.TryGetValue("reqEquipLevelMax", out value)) { if (equipInfo.ReqLevel > value) { message = "Item does not have the required level."; return(false); } } if (enhancerInfo.StatEnhancements.TryGetValue("recover", out value)) //clean slate { int totalPossibleUpgrades = equipInfo.TotalUpgradeCount + equip.HammersApplied; int failedUpgrades = totalPossibleUpgrades - equip.UpgradeCount - equip.RemainingUpgradeCount; if (failedUpgrades <= 0) { message = "There are no upgrades to recover."; return(false); } } return(true); }
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 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 override long GetEquipRevealCost(int equipItemId) { WzEquip equipInfo = DataBuffer.GetEquipById(equipItemId); return(equipInfo == null ? 0 : equipInfo.RevealPotentialCost); }
public override byte GetEquipRequiredLevel(int equipItemId) { WzEquip equipInfo = DataBuffer.GetEquipById(equipItemId); return(equipInfo == null ? (byte)0 : equipInfo.ReqLevel); }