public void UseItem(S.UseItem p) { MirItemCell cell = GetCell(Inventory.Cells, p.UniqueID) ?? GetCell(BeltCells, p.UniqueID); if (cell == null) { return; } cell.Locked = false; if (!p.Success) { return; } if (cell.Item.Count > 1) { cell.Item.Count--; } else { cell.Item = null; } User.RefreshStats(); }
public static void UseItem(S.UseItem p) { GameManager.GameScene.UseItem(p); }
public void UseItem(ulong id) { S.UseItem p = new S.UseItem { UniqueID = id, Success = false }; UserItem item = null; int index = -1; for (int i = 0; i < Info.Inventory.Length; i++) { item = Info.Inventory[i]; if (item == null || item.UniqueID != id) continue; index = i; break; } if (item == null || index == -1 || !CanUseItem(item)) { Enqueue(p); return; } if (Dead && item.Info.Type != ItemType.Scroll && item.Info.Shape != 6) { Enqueue(p); return; } switch (item.Info.Type) { case ItemType.Potion: switch (item.Info.Shape) { case 0: //NormalPotion PotHealthAmount = (ushort)Math.Min(ushort.MaxValue, PotHealthAmount + item.Info.HP); PotManaAmount = (ushort)Math.Min(ushort.MaxValue, PotManaAmount + item.Info.MP); break; case 1: //SunPotion ChangeHP(item.Info.HP); ChangeMP(item.Info.MP); break; case 2: //MysteryWater if (UnlockCurse) { ReceiveChat("You can already unequip a cursed item.", ChatType.Hint); Enqueue(p); return; } ReceiveChat("You can now unequip a cursed item.", ChatType.Hint); UnlockCurse = true; break; case 3: //Buff int time = item.Info.Durability; if ((item.Info.MaxDC + item.DC) > 0) AddBuff(new Buff { Type = BuffType.Impact, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.MaxDC + item.DC } }); if ((item.Info.MaxMC + item.MC) > 0) AddBuff(new Buff { Type = BuffType.Magic, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.MaxMC + item.MC } }); if ((item.Info.MaxSC + item.SC) > 0) AddBuff(new Buff { Type = BuffType.Taoist, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.MaxSC + item.SC } }); if ((item.Info.AttackSpeed + item.AttackSpeed) > 0) AddBuff(new Buff { Type = BuffType.Storm, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.AttackSpeed + item.AttackSpeed } }); if ((item.Info.HP + item.HP) > 0) AddBuff(new Buff { Type = BuffType.HealthAid, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.HP + item.HP } }); if ((item.Info.MP + item.MP) > 0) AddBuff(new Buff { Type = BuffType.ManaAid, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.MP + item.MP } }); if ((item.Info.MaxAC + item.AC) > 0) AddBuff(new Buff { Type = BuffType.Defence, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.MaxAC + item.AC } }); if ((item.Info.MaxMAC + item.MAC) > 0) AddBuff(new Buff { Type = BuffType.MagicDefence, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.MaxMAC + item.MAC } }); break; case 4: //Exp time = item.Info.Durability; AddBuff(new Buff { Type = BuffType.Exp, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.Luck + item.Luck } }); break; } break; case ItemType.Scroll: UserItem temp; switch (item.Info.Shape) { case 0: //DE if (!TeleportEscape(20)) { Enqueue(p); return; } break; case 1: //TT if (!Teleport(Envir.GetMap(BindMapIndex), BindLocation)) { Enqueue(p); return; } break; case 2: //RT if (!TeleportRandom(200, item.Info.Durability)) { Enqueue(p); return; } break; case 3: //BenedictionOil if (!TryLuckWeapon()) { Enqueue(p); return; } break; case 4: //RepairOil temp = Info.Equipment[(int)EquipmentSlot.Weapon]; if (temp == null || temp.MaxDura == temp.CurrentDura) { Enqueue(p); return; } if (temp.Info.Bind.HasFlag(BindMode.DontRepair)) { Enqueue(p); return; } temp.MaxDura = (ushort)Math.Max(0, temp.MaxDura - Math.Min(5000, temp.MaxDura - temp.CurrentDura) / 30); temp.CurrentDura = (ushort)Math.Min(temp.MaxDura, temp.CurrentDura + 5000); temp.DuraChanged = false; ReceiveChat("Your weapon has been partially repaired", ChatType.Hint); Enqueue(new S.ItemRepaired { UniqueID = temp.UniqueID, MaxDura = temp.MaxDura, CurrentDura = temp.CurrentDura }); break; case 5: //WarGodOil temp = Info.Equipment[(int)EquipmentSlot.Weapon]; if (temp == null || temp.MaxDura == temp.CurrentDura) { Enqueue(p); return; } if (temp.Info.Bind.HasFlag(BindMode.DontRepair) || (temp.Info.Bind.HasFlag(BindMode.NoSRepair))) { Enqueue(p); return; } temp.CurrentDura = temp.MaxDura; temp.DuraChanged = false; ReceiveChat("Your weapon has been completely repaired", ChatType.Hint); Enqueue(new S.ItemRepaired { UniqueID = temp.UniqueID, MaxDura = temp.MaxDura, CurrentDura = temp.CurrentDura }); break; case 6: //ResurrectionScroll if (Dead) { MP = MaxMP; Revive(MaxHealth, true); } break; case 7: //CreditScroll if (item.Info.Price > 0) { GainCredit(item.Info.Price); ReceiveChat(String.Format("{0} Credits have been added to your Account", item.Info.Price), ChatType.Hint); } break; case 8: //MapShoutScroll HasMapShout = true; ReceiveChat("You have been given one free shout across your current map", ChatType.Hint); break; case 9://ServerShoutScroll HasServerShout = true; ReceiveChat("You have been given one free shout across the server", ChatType.Hint); break; case 10://GuildSkillScroll MyGuild.NewBuff(item.Info.Effect, false); break; case 11://HomeTeleport if (MyGuild != null && MyGuild.Conquest != null && !MyGuild.Conquest.WarIsOn && MyGuild.Conquest.PalaceMap != null && !TeleportRandom(200, 0, MyGuild.Conquest.PalaceMap)) { Enqueue(p); return; } break; } break; case ItemType.Book: UserMagic magic = new UserMagic((Spell)item.Info.Shape); if (magic.Info == null) { Enqueue(p); return; } Info.Magics.Add(magic); Enqueue(magic.GetInfo()); RefreshStats(); break; case ItemType.Script: CallDefaultNPC(DefaultNPCType.UseItem, item.Info.Shape); break; case ItemType.Food: temp = Info.Equipment[(int)EquipmentSlot.Mount]; if (temp == null || temp.MaxDura == temp.CurrentDura) { Enqueue(p); return; } switch (item.Info.Shape) { case 0: temp.MaxDura = (ushort)Math.Max(0, temp.MaxDura - Math.Min(1000, temp.MaxDura - (temp.CurrentDura / 30))); break; case 1: break; } temp.CurrentDura = (ushort)Math.Min(temp.MaxDura, temp.CurrentDura + item.CurrentDura); temp.DuraChanged = false; ReceiveChat("Your mount has been fed.", ChatType.Hint); Enqueue(new S.ItemRepaired { UniqueID = temp.UniqueID, MaxDura = temp.MaxDura, CurrentDura = temp.CurrentDura }); RefreshStats(); break; case ItemType.Pets: if (item.Info.Shape >= 20) { switch (item.Info.Shape) { case 20://Mirror Enqueue(new S.IntelligentCreatureEnableRename()); break; case 21://BlackStone if (item.Count > 1) item.Count--; else Info.Inventory[index] = null; RefreshBagWeight(); p.Success = true; Enqueue(p); BlackstoneRewardItem(); return; case 22://Nuts if (CreatureSummoned) for (int i = 0; i < Pets.Count; i++) { if (Pets[i].Info.AI != 64) continue; if (((IntelligentCreatureObject)Pets[i]).petType != SummonedCreatureType) continue; ((IntelligentCreatureObject)Pets[i]).maintainfoodTime = item.Info.Effect * Settings.Hour / 1000; UpdateCreatureMaintainFoodTime(SummonedCreatureType, 0); break; } break; case 23://FairyMoss, FreshwaterClam, Mackerel, Cherry if (CreatureSummoned) for (int i = 0; i < Pets.Count; i++) { if (Pets[i].Info.AI != 64) continue; if (((IntelligentCreatureObject)Pets[i]).petType != SummonedCreatureType) continue; if (((IntelligentCreatureObject)Pets[i]).Fullness < 10000) ((IntelligentCreatureObject)Pets[i]).IncreaseFullness(item.Info.Effect * 100); break; } break; case 24://WonderPill if (CreatureSummoned) for (int i = 0; i < Pets.Count; i++) { if (Pets[i].Info.AI != 64) continue; if (((IntelligentCreatureObject)Pets[i]).petType != SummonedCreatureType) continue; if (((IntelligentCreatureObject)Pets[i]).Fullness == 0) ((IntelligentCreatureObject)Pets[i]).IncreaseFullness(100); break; } break; case 25://Strongbox byte boxtype = item.Info.Effect; if (item.Count > 1) item.Count--; else Info.Inventory[index] = null; RefreshBagWeight(); p.Success = true; Enqueue(p); StrongboxRewardItem(boxtype); return; case 26://Wonderdrugs int time = item.Info.Durability; switch (item.Info.Effect) { case 0://exp low/med/high AddBuff(new Buff { Type = BuffType.WonderDrug, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.Effect, item.Info.Luck + item.Luck } }); break; case 1://drop low/med/high AddBuff(new Buff { Type = BuffType.WonderDrug, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.Effect, item.Info.Luck + item.Luck } }); break; case 2://hp low/med/high AddBuff(new Buff { Type = BuffType.WonderDrug, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.Effect, item.Info.HP + item.HP } }); break; case 3://mp low/med/high AddBuff(new Buff { Type = BuffType.WonderDrug, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.Effect, item.Info.MP + item.MP } }); break; case 4://ac-ac low/med/high AddBuff(new Buff { Type = BuffType.WonderDrug, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.Effect, item.Info.MaxAC + item.AC } }); break; case 5://mac-mac low/med/high AddBuff(new Buff { Type = BuffType.WonderDrug, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.Effect, item.Info.MaxMAC + item.MAC } }); break; case 6://speed low/med/high AddBuff(new Buff { Type = BuffType.WonderDrug, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.Effect, item.Info.AttackSpeed + item.AttackSpeed } }); break; } break; case 27://FortuneCookies break; case 28://Knapsack time = item.Info.Durability; AddBuff(new Buff { Type = BuffType.Knapsack, Caster = this, ExpireTime = Envir.Time + time * Settings.Minute, Values = new int[] { item.Info.Luck + item.Luck } }); break; } } else { int slotIndex = Info.IntelligentCreatures.Count; UserIntelligentCreature petInfo = new UserIntelligentCreature((IntelligentCreatureType)item.Info.Shape, slotIndex, item.Info.Effect); if (Info.CheckHasIntelligentCreature((IntelligentCreatureType)item.Info.Shape)) { ReceiveChat("You already have this creature.", ChatType.Hint); petInfo = null; } if (petInfo == null || slotIndex >= 10) { Enqueue(p); return; } ReceiveChat("Obtained a new creature {" + petInfo.CustomName + "}.", ChatType.Hint); Info.IntelligentCreatures.Add(petInfo); Enqueue(petInfo.GetInfo()); } break; case ItemType.Transform: //Transforms int tTime = item.Info.Durability; int tType = item.Info.Shape; AddBuff(new Buff { Type = BuffType.Transform, Caster = this, ExpireTime = Envir.Time + tTime * 1000, Values = new int[] { tType } }); break; default: return; } if (item.Count > 1) item.Count--; else Info.Inventory[index] = null; RefreshBagWeight(); Report.ItemChanged("UseItem", item, 1, 1); p.Success = true; Enqueue(p); }
public void UseItem(ulong id) { S.UseItem p = new S.UseItem { UniqueID = id, Success = false }; if (Dead) { Enqueue(p); return; } UserItem item = null; int index = -1; for (int i = 0; i < Info.Inventory.Length; i++) { item = Info.Inventory[i]; if (item == null || item.UniqueID != id) continue; index = i; break; } if (item == null || index == -1 || !CanUseItem(item)) { Enqueue(p); return; } switch (item.Info.Type) { case ItemType.Potion: switch (item.Info.Shape) { case 0: PotHealthAmount = (ushort)Math.Min(ushort.MaxValue,PotHealthAmount + item.Info.HP); PotManaAmount = (ushort)Math.Min(ushort.MaxValue, PotManaAmount + item.Info.MP); break; case 1: //Sun Potion ChangeHP(item.Info.HP); ChangeMP(item.Info.MP); break; case 2: if (UnlockCurse) { ReceiveChat("You can already unequip a cursed item.", ChatType.Hint); Enqueue(p); return; } ReceiveChat("You can now unequip a cursed item.", ChatType.Hint); UnlockCurse = true; break; } break; case ItemType.Scroll: UserItem temp; switch (item.Info.Shape) { case 0: //DE if (!TeleportEscape(20)) { Enqueue(p); return; } break; case 1: //TT if (!Teleport(Envir.GetMap(BindMapIndex), BindLocation)) { Enqueue(p); return; } break; case 2: //RT if (!TeleportRandom(200, item.Info.Durability)) { Enqueue(p); return; } break; case 3: if (!TryLuckWeapon()) { Enqueue(p); return; } break; case 4: temp = Info.Equipment[(int)EquipmentSlot.Weapon]; if (temp == null || temp.MaxDura == temp.CurrentDura) { Enqueue(p); return; } if (temp.Info.Bind.HasFlag(BindMode.DontRepair)) { Enqueue(p); return; } temp.MaxDura = (ushort)Math.Max(0, temp.MaxDura - Math.Min(5000, temp.MaxDura - temp.CurrentDura) / 8); temp.CurrentDura = (ushort)Math.Min(temp.MaxDura, temp.CurrentDura + 5000); temp.DuraChanged = false; ReceiveChat("Your weapon has been partially repaired", ChatType.Hint); Enqueue(new S.ItemRepaired {UniqueID = temp.UniqueID, MaxDura = temp.MaxDura, CurrentDura = temp.CurrentDura}); break; case 5: temp = Info.Equipment[(int)EquipmentSlot.Weapon]; if (temp == null || temp.MaxDura == temp.CurrentDura) { Enqueue(p); return; } if (temp.Info.Bind.HasFlag(BindMode.DontRepair) || temp.Info.BindNoSRepair) { Enqueue(p); return; } temp.CurrentDura = temp.MaxDura; temp.DuraChanged = false; ReceiveChat("Your weapon has been completely repaired", ChatType.Hint); Enqueue(new S.ItemRepaired { UniqueID = temp.UniqueID, MaxDura = temp.MaxDura, CurrentDura = temp.CurrentDura }); break; } break; case ItemType.Book: UserMagic magic = new UserMagic((Spell)item.Info.Shape); if (magic.Info == null) { Enqueue(p); return; } Info.Magics.Add(magic); Enqueue(magic.GetInfo()); break; default: return; } if (item.Count > 1) item.Count--; else Info.Inventory[index] = null; RefreshBagWeight(); p.Success = true; Enqueue(p); }
public void UseItem(ulong id) { S.UseItem p = new S.UseItem { UniqueID = id, Success = false }; if (Dead) { Enqueue(p); return; } UserItem item = null; int index = -1; for (int i = 0; i < Info.Inventory.Length; i++) { item = Info.Inventory[i]; if (item == null || item.UniqueID != id) continue; index = i; break; } if (item == null || index == -1 || !CanUseItem(item)) { Enqueue(p); return; } switch (item.Info.Type) { case ItemType.Potion: switch (item.Info.Shape) { case 0: //NormalPotion PotHealthAmount = (ushort)Math.Min(ushort.MaxValue, PotHealthAmount + item.Info.HP); PotManaAmount = (ushort)Math.Min(ushort.MaxValue, PotManaAmount + item.Info.MP); break; case 1: //SunPotion ChangeHP(item.Info.HP); ChangeMP(item.Info.MP); break; case 2: //MysteryWater if (UnlockCurse) { ReceiveChat("You can already unequip a cursed item.", ChatType.Hint); Enqueue(p); return; } ReceiveChat("You can now unequip a cursed item.", ChatType.Hint); UnlockCurse = true; break; case 3: int time = item.Info.Durability; if ((item.Info.MaxDC + item.DC) > 0) AddBuff(new Buff { Type = BuffType.Impact, Caster = this, ExpireTime = Envir.Time + time * 1000, Value = item.Info.MaxDC + item.DC }); if ((item.Info.MaxMC + item.MC) > 0) AddBuff(new Buff { Type = BuffType.Magic, Caster = this, ExpireTime = Envir.Time + time * 1000, Value = item.Info.MaxMC + item.MC }); if ((item.Info.MaxSC + item.SC) > 0) AddBuff(new Buff { Type = BuffType.Taoist, Caster = this, ExpireTime = Envir.Time + time * 1000, Value = item.Info.MaxSC + item.SC }); if ((item.Info.AttackSpeed + item.AttackSpeed) > 0) AddBuff(new Buff { Type = BuffType.Storm, Caster = this, ExpireTime = Envir.Time + time * 1000, Value = item.Info.AttackSpeed + item.AttackSpeed }); if ((item.Info.HP + item.HP) > 0) AddBuff(new Buff { Type = BuffType.HealthAid, Caster = this, ExpireTime = Envir.Time + time * 1000, Value = item.Info.HP + item.HP }); if ((item.Info.MP + item.MP) > 0) AddBuff(new Buff { Type = BuffType.ManaAid, Caster = this, ExpireTime = Envir.Time + time * 1000, Value = item.Info.MP + item.MP }); break; } break; case ItemType.Scroll: UserItem temp; switch (item.Info.Shape) { case 0: //DE if (!TeleportEscape(20)) { Enqueue(p); return; } break; case 1: //TT if (!Teleport(Envir.GetMap(BindMapIndex), BindLocation)) { Enqueue(p); return; } break; case 2: //RT if (!TeleportRandom(200, item.Info.Durability)) { Enqueue(p); return; } break; case 3: //BenedictionOil if (!TryLuckWeapon()) { Enqueue(p); return; } break; case 4: //RepairOil temp = Info.Equipment[(int)EquipmentSlot.Weapon]; if (temp == null || temp.MaxDura == temp.CurrentDura) { Enqueue(p); return; } if (temp.Info.Bind.HasFlag(BindMode.DontRepair)) { Enqueue(p); return; } temp.MaxDura = (ushort)Math.Max(0, temp.MaxDura - Math.Min(5000, temp.MaxDura - temp.CurrentDura) / 30); temp.CurrentDura = (ushort)Math.Min(temp.MaxDura, temp.CurrentDura + 5000); temp.DuraChanged = false; ReceiveChat("Your weapon has been partially repaired", ChatType.Hint); Enqueue(new S.ItemRepaired { UniqueID = temp.UniqueID, MaxDura = temp.MaxDura, CurrentDura = temp.CurrentDura }); break; case 5: //WarGodOil temp = Info.Equipment[(int)EquipmentSlot.Weapon]; if (temp == null || temp.MaxDura == temp.CurrentDura) { Enqueue(p); return; } if (temp.Info.Bind.HasFlag(BindMode.DontRepair) || temp.Info.BindNoSRepair) { Enqueue(p); return; } temp.CurrentDura = temp.MaxDura; temp.DuraChanged = false; ReceiveChat("Your weapon has been completely repaired", ChatType.Hint); Enqueue(new S.ItemRepaired { UniqueID = temp.UniqueID, MaxDura = temp.MaxDura, CurrentDura = temp.CurrentDura }); break; } break; case ItemType.Book: UserMagic magic = new UserMagic((Spell)item.Info.Shape); if (magic.Info == null) { Enqueue(p); return; } Info.Magics.Add(magic); Enqueue(magic.GetInfo()); RefreshStats(); break; case ItemType.Script: CallDefaultNPC(DefaultNPCType.UseItem, item.Info.Shape); break; case ItemType.Food: temp = Info.Equipment[(int)EquipmentSlot.Mount]; if (temp == null || temp.MaxDura == temp.CurrentDura) { Enqueue(p); return; } switch (item.Info.Shape) { case 0: temp.MaxDura = (ushort)Math.Max(0, temp.MaxDura - Math.Min(1000, temp.MaxDura - (temp.CurrentDura / 30))); break; } temp.CurrentDura = (ushort)Math.Min(temp.MaxDura, temp.CurrentDura + item.CurrentDura); temp.DuraChanged = false; ReceiveChat("Your mount has been fed.", ChatType.Hint); Enqueue(new S.ItemRepaired { UniqueID = temp.UniqueID, MaxDura = temp.MaxDura, CurrentDura = temp.CurrentDura }); RefreshStats(); break; default: return; } if (item.Count > 1) item.Count--; else Info.Inventory[index] = null; RefreshBagWeight(); p.Success = true; Enqueue(p); }
public override void UseItem(ulong id) { S.UseItem p = new S.UseItem { UniqueID = id, Grid = MirGridType.HeroInventory, Success = false }; UserItem item = null; int index = -1; for (int i = 0; i < Info.Inventory.Length; i++) { item = Info.Inventory[i]; if (item == null || item.UniqueID != id) { continue; } index = i; break; } if (item == null || index == -1 || !CanUseItem(item)) { Owner.Enqueue(p); return; } if (Dead && !(item.Info.Type == ItemType.Scroll && item.Info.Shape == 6)) { Owner.Enqueue(p); return; } switch (item.Info.Type) { case ItemType.Potion: switch (item.Info.Shape) { case 0: //NormalPotion PotHealthAmount = (ushort)Math.Min(ushort.MaxValue, PotHealthAmount + item.Info.Stats[Stat.HP]); PotManaAmount = (ushort)Math.Min(ushort.MaxValue, PotManaAmount + item.Info.Stats[Stat.MP]); break; case 1: //SunPotion ChangeHP(item.Info.Stats[Stat.HP]); ChangeMP(item.Info.Stats[Stat.MP]); break; case 2: //MysteryWater if (UnlockCurse) { ReceiveChat("You can already unequip a cursed item.", ChatType.Hint); Owner.Enqueue(p); return; } ReceiveChat("You can now unequip a cursed item.", ChatType.Hint); UnlockCurse = true; break; case 3: //Buff { int time = item.Info.Durability; if (item.GetTotal(Stat.MaxDC) > 0) { AddBuff(BuffType.Impact, this, time * Settings.Minute, new Stats { [Stat.MaxDC] = item.GetTotal(Stat.MaxDC) }); } if (item.GetTotal(Stat.MaxMC) > 0) { AddBuff(BuffType.Magic, this, time * Settings.Minute, new Stats { [Stat.MaxMC] = item.GetTotal(Stat.MaxMC) }); } if (item.GetTotal(Stat.MaxSC) > 0) { AddBuff(BuffType.Taoist, this, time * Settings.Minute, new Stats { [Stat.MaxSC] = item.GetTotal(Stat.MaxSC) }); } if (item.GetTotal(Stat.AttackSpeed) > 0) { AddBuff(BuffType.Storm, this, time * Settings.Minute, new Stats { [Stat.AttackSpeed] = item.GetTotal(Stat.AttackSpeed) }); } if (item.GetTotal(Stat.HP) > 0) { AddBuff(BuffType.HealthAid, this, time * Settings.Minute, new Stats { [Stat.HP] = item.GetTotal(Stat.HP) }); } if (item.GetTotal(Stat.MP) > 0) { AddBuff(BuffType.ManaAid, this, time * Settings.Minute, new Stats { [Stat.MP] = item.GetTotal(Stat.MP) }); } if (item.GetTotal(Stat.MaxAC) > 0) { AddBuff(BuffType.Defence, this, time * Settings.Minute, new Stats { [Stat.MaxAC] = item.GetTotal(Stat.MaxAC) }); } if (item.GetTotal(Stat.MaxMAC) > 0) { AddBuff(BuffType.MagicDefence, this, time * Settings.Minute, new Stats { [Stat.MaxMAC] = item.GetTotal(Stat.MaxMAC) }); } if (item.GetTotal(Stat.BagWeight) > 0) { AddBuff(BuffType.BagWeight, this, time * Settings.Minute, new Stats { [Stat.BagWeight] = item.GetTotal(Stat.BagWeight) }); } } break; case 4: //Exp { int time = item.Info.Durability; AddBuff(BuffType.Exp, this, Settings.Minute * time, new Stats { [Stat.ExpRatePercent] = item.GetTotal(Stat.Luck) }); } break; case 5: //Drop { int time = item.Info.Durability; AddBuff(BuffType.Drop, this, Settings.Minute * time, new Stats { [Stat.ItemDropRatePercent] = item.GetTotal(Stat.Luck) }); } break; } break; case ItemType.Scroll: UserItem temp; switch (item.Info.Shape) { case 3: //BenedictionOil if (!TryLuckWeapon()) { Owner.Enqueue(p); return; } break; case 4: //RepairOil temp = Info.Equipment[(int)EquipmentSlot.Weapon]; if (temp == null || temp.MaxDura == temp.CurrentDura) { Owner.Enqueue(p); return; } if (temp.Info.Bind.HasFlag(BindMode.DontRepair)) { Owner.Enqueue(p); return; } temp.MaxDura = (ushort)Math.Max(0, temp.MaxDura - Math.Min(5000, temp.MaxDura - temp.CurrentDura) / 30); temp.CurrentDura = (ushort)Math.Min(temp.MaxDura, temp.CurrentDura + 5000); temp.DuraChanged = false; ReceiveChat("Your weapon has been partially repaired", ChatType.Hint); Owner.Enqueue(new S.ItemRepaired { UniqueID = temp.UniqueID, MaxDura = temp.MaxDura, CurrentDura = temp.CurrentDura }); break; case 5: //WarGodOil temp = Info.Equipment[(int)EquipmentSlot.Weapon]; if (temp == null || temp.MaxDura == temp.CurrentDura) { Owner.Enqueue(p); return; } if (temp.Info.Bind.HasFlag(BindMode.DontRepair) || (temp.Info.Bind.HasFlag(BindMode.NoSRepair))) { Owner.Enqueue(p); return; } temp.CurrentDura = temp.MaxDura; temp.DuraChanged = false; ReceiveChat("Your weapon has been completely repaired", ChatType.Hint); Owner.Enqueue(new S.ItemRepaired { UniqueID = temp.UniqueID, MaxDura = temp.MaxDura, CurrentDura = temp.CurrentDura }); break; case 6: //ResurrectionScroll if (CurrentMap.Info.NoReincarnation) { ReceiveChat(string.Format("Cannot use on this map"), ChatType.System); Owner.Enqueue(p); return; } if (Dead) { MP = Stats[Stat.MP]; Revive(MaxHealth, true); } break; } break; case ItemType.Book: UserMagic magic = new UserMagic((Spell)item.Info.Shape); if (magic.Info == null) { Owner.Enqueue(p); return; } Info.Magics.Add(magic); SendMagicInfo(magic); RefreshStats(); break; case ItemType.Food: temp = Info.Equipment[(int)EquipmentSlot.Mount]; if (temp == null || temp.MaxDura == temp.CurrentDura) { Owner.Enqueue(p); return; } switch (item.Info.Shape) { case 0: temp.MaxDura = (ushort)Math.Max(0, temp.MaxDura - Math.Min(1000, temp.MaxDura - (temp.CurrentDura / 30))); break; case 1: break; } temp.CurrentDura = (ushort)Math.Min(temp.MaxDura, temp.CurrentDura + item.CurrentDura); temp.DuraChanged = false; ReceiveChat("Your mount has been fed.", ChatType.Hint); Owner.Enqueue(new S.ItemRepaired { UniqueID = temp.UniqueID, MaxDura = temp.MaxDura, CurrentDura = temp.CurrentDura }); RefreshStats(); break; case ItemType.Transform: //Transforms { AddBuff(BuffType.Transform, this, (Settings.Second * item.Info.Durability), new Stats(), values: item.Info.Shape); } break; case ItemType.Deco: DecoObject decoOb = new DecoObject { Image = item.Info.Shape, CurrentMap = CurrentMap, CurrentLocation = CurrentLocation, }; CurrentMap.AddObject(decoOb); decoOb.Spawned(); Owner.Enqueue(decoOb.GetInfo()); break; case ItemType.MonsterSpawn: var monsterID = item.Info.Stats[Stat.HP]; var spawnAsPet = item.Info.Shape == 1; var conquestOnly = item.Info.Shape == 2; var monsterInfo = Envir.GetMonsterInfo(monsterID); if (monsterInfo == null) { break; } MonsterObject monster = MonsterObject.GetMonster(monsterInfo); if (monster == null) { break; } if (spawnAsPet) { if (Pets.Count(t => !t.Dead && t.Race != ObjectType.Creature) >= Globals.MaxPets) { ReceiveChat("Maximum number of pets already reached.", ChatType.Hint); Owner.Enqueue(p); return; } monster.Master = this; monster.PetLevel = 0; monster.MaxPetLevel = 7; Pets.Add(monster); } if (conquestOnly) { var con = CurrentMap.GetConquest(CurrentLocation); if (con == null) { ReceiveChat(string.Format("{0} can only be spawned during a conquest.", monsterInfo.GameName), ChatType.Hint); Owner.Enqueue(p); return; } } monster.Direction = Direction; monster.ActionTime = Envir.Time + 5000; if (!monster.Spawn(CurrentMap, Front)) { monster.Spawn(CurrentMap, CurrentLocation); } break; case ItemType.SiegeAmmo: //TODO; break; default: return; } if (item.Count > 1) { item.Count--; } else { Info.Inventory[index] = null; } RefreshBagWeight(); Report?.ItemChanged(item, 1, 1); p.Success = true; Owner.Enqueue(p); }