// the following is not in the constructor because TestFixtureSetup // is not initialized at this time, thus we can't connect to server public void InventoryTestCreation() { player = CreateMockGamePlayer(); Assert.IsNotNull(player, "Player is null !"); itemt = GameServer.Database.SelectObject<ItemTemplate>("Id_nb = 'championDocharWardenBlade'"); Assert.IsNotNull(itemt, "ItemTemplate is null !"); itemu = new ItemUnique(); itemu.Id_nb = "tunik" + DateTime.Now.Ticks; GameServer.Database.AddObject(itemu); Assert.IsNotNull(itemu, "ItemUnique is created !"); itema = GameServer.Database.SelectObject<ItemTemplate>("id_nb= 'traitors_dagger_hib"); }
/// <summary> /// Creates a new Inventoryitem based on the given ItemUnique /// ItemUnique will always be created in the ItemUnique table /// </summary> /// <param name="itemTemplate"></param> protected InventoryItem(ItemUnique template) : base() { m_ownerID = null; Template = (ItemTemplate)template; Template.Dirty = true; m_utemplate_id = template.Id_nb; m_itemplate_id = null; m_color = template.Color; m_emblem = template.Emblem; m_count = template.PackSize; m_extension = template.Extension; m_condition = template.MaxCondition; m_durability = template.MaxDurability; m_charges = template.Charges > 0 ? template.Charges : template.MaxCharges; m_charges1 = template.Charges1 > 0 ? template.Charges1 : template.MaxCharges1; m_poisonCharges = template.PoisonCharges; m_poisonMaxCharges = template.PoisonMaxCharges; m_poisonSpellID = template.PoisonSpellID; }
public GameSiegeItem(ItemUnique template) : base(template) { }
public void SetProc(GamePlayer player, int proc) { InventoryItem item = player.TempProperties.getProperty<InventoryItem>(TempProperty); player.TempProperties.removeProperty(TempProperty); if (item == null || item.OwnerID != player.InternalID || item.OwnerID == null) return; player.Inventory.RemoveItem(item); ItemUnique unique = new ItemUnique(item.Template); unique.ProcSpellID = proc; GameServer.Database.AddObject(unique); player.RemoveBountyPoints(300); InventoryItem newInventoryItem = GameInventoryItem.Create<ItemUnique>(unique); player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, newInventoryItem); player.Out.SendInventoryItemsUpdate(new InventoryItem[] { newInventoryItem }); SendReply(player, "My work upon " + item.Name + " is complete.\n Farewell " + player.Name + "."); }
public GameInventoryRelic(ItemUnique template) : base(template) { }
/// <summary> /// Make the crafted item and add it to player's inventory /// </summary> /// <param name="player"></param> /// <param name="recipe"></param> /// <returns></returns> protected virtual void BuildCraftedItem(GamePlayer player, DBCraftedItem recipe, ItemTemplate itemToCraft) { Dictionary<int, int> changedSlots = new Dictionary<int, int>(5); // key : > 0 inventory ; < 0 ground || value: < 0 = new item count; > 0 = add to old lock (player.Inventory) { int count = itemToCraft.PackSize < 1 ? 1 : itemToCraft.PackSize; foreach (InventoryItem item in player.Inventory.GetItemRange(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack)) { if (item == null) continue; if (item.Id_nb.Equals(itemToCraft.Id_nb) == false) continue; if (item.Count >= itemToCraft.MaxCount) continue; int countFree = item.MaxCount - item.Count; if (count > countFree) { changedSlots.Add(item.SlotPosition, countFree); // existing item should be changed count -= countFree; } else { changedSlots.Add(item.SlotPosition, count); // existing item should be changed count = 0; break; } } if (count > 0) // Add new object { eInventorySlot firstEmptySlot = player.Inventory.FindFirstEmptySlot(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack); if (firstEmptySlot == eInventorySlot.Invalid) { changedSlots.Add(-1, -count); // Create the item on the ground } else { changedSlots.Add((int)firstEmptySlot, -count); // Create the item in the free slot } count = 0; } InventoryItem newItem = null; player.Inventory.BeginChanges(); Dictionary<int, int>.Enumerator enumerator = changedSlots.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair<int, int> slot = enumerator.Current; int countToAdd = slot.Value; if (countToAdd > 0) // Add to exiting item { newItem = player.Inventory.GetItem((eInventorySlot)slot.Key); if (newItem != null && player.Inventory.AddCountToStack(newItem, countToAdd)) { InventoryLogging.LogInventoryAction("(craft)", player, eInventoryActionType.Other, newItem.Template, countToAdd); // count incremented, continue with next change continue; } } if (recipe.MakeTemplated) { string adjItem = itemToCraft.Id_nb+(GetQuality(player, recipe).ToString()); ItemTemplate adjItemToCraft = GameServer.Database.FindObjectByKey<ItemTemplate>(adjItem); if (adjItemToCraft != null) { newItem = GameInventoryItem.Create<ItemTemplate>(adjItemToCraft); } else { newItem = GameInventoryItem.Create<ItemTemplate>(itemToCraft); } } else { ItemUnique unique = new ItemUnique(itemToCraft); GameServer.Database.AddObject(unique); newItem = GameInventoryItem.Create<ItemUnique>(unique); newItem.Quality = GetQuality(player, recipe); } newItem.IsCrafted = true; newItem.Creator = player.Name; newItem.Count = -countToAdd; if (slot.Key > 0) // Create new item in the backpack { player.Inventory.AddItem((eInventorySlot)slot.Key, newItem); InventoryLogging.LogInventoryAction("(craft)", player, eInventoryActionType.Craft, newItem.Template, newItem.Count); } else // Create new item on the ground { player.CreateItemOnTheGround(newItem); player.Out.SendDialogBox(eDialogCode.SimpleWarning, 0, 0, 0, 0, eDialogType.Ok, true, LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.BuildCraftedItem.BackpackFull", itemToCraft.Name)); } } player.Inventory.CommitChanges(); player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.BuildCraftedItem.Successfully", itemToCraft.Name, newItem.Quality), eChatType.CT_Missed, eChatLoc.CL_SystemWindow); if (recipe.MakeTemplated == false && newItem.Quality == 100) { player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.BuildCraftedItem.Masterpiece"), eChatType.CT_Important, eChatLoc.CL_SystemWindow); player.Out.SendPlaySound(eSoundType.Craft, 0x04); } else { player.Out.SendPlaySound(eSoundType.Craft, 0x03); } } }
/// <summary> /// Creates a new Inventoryitem based on the given ItemUnique /// ItemUnique will always be created in the ItemUnique table /// </summary> /// <param name="itemTemplate"></param> protected InventoryItem(ItemUnique template):base() { m_ownerID = null; Template = (ItemTemplate)template; Template.Dirty = true; m_utemplate_id = template.Id_nb; m_itemplate_id = null; m_color = template.Color; m_emblem = template.Emblem; m_count = template.PackSize; m_extension = template.Extension; m_condition = template.MaxCondition; m_durability = template.MaxDurability; m_charges = template.Charges > 0 ? template.Charges : template.MaxCharges; m_charges1 = template.Charges1 > 0 ? template.Charges1 : template.MaxCharges1; m_poisonCharges = template.PoisonCharges; m_poisonMaxCharges = template.PoisonMaxCharges; m_poisonSpellID = template.PoisonSpellID; }
public DesmonaCoin(ItemUnique template) : base(template) { }
public GameMythirian(ItemUnique template) : base(template) { }
/// <summary> /// Player receives this item (added to players inventory) /// </summary> /// <param name="player"></param> public override void OnReceive(GamePlayer player) { // for guild banners we don't actually add it to inventory but instead register // if it is rescued by a friendly player or taken by the enemy player.Inventory.RemoveItem(this); int trophyModel = 0; eRealm realm = eRealm.None; switch (Model) { case 3223: trophyModel = 3359; realm = eRealm.Albion; break; case 3224: trophyModel = 3361; realm = eRealm.Midgard; break; case 3225: trophyModel = 3360; realm = eRealm.Hibernia; break; } // if picked up by an enemy then turn this into a trophy if (realm != player.Realm) { ItemUnique template = new ItemUnique(Template); template.ClassType = ""; template.Model = trophyModel; template.IsDropable = true; template.IsIndestructible = false; GameServer.Database.AddObject(template); GameInventoryItem trophy = new GameInventoryItem(template); player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, trophy); OwnerGuild.SendMessageToGuildMembers(player.Name + " of " + GlobalConstants.RealmToName(player.Realm) + " has captured your guild banner!", eChatType.CT_Guild, eChatLoc.CL_SystemWindow); OwnerGuild.GuildBannerLostTime = DateTime.Now; } else { m_status = eStatus.Recovered; // A friendly player has picked up the banner. if (OwnerGuild != null) { OwnerGuild.SendMessageToGuildMembers(player.Name + " has recovered your guild banner!", eChatType.CT_Guild, eChatLoc.CL_SystemWindow); } if (SummonPlayer != null) { SummonPlayer.GuildBanner = null; } } }
public void SetSpeed(GamePlayer player, int speed) { InventoryItem item = player.TempProperties.getProperty<InventoryItem>(EFFECTNPC_ITEM_WEAK); player.TempProperties.removeProperty(EFFECTNPC_ITEM_WEAK); if (item == null) { SendReply(player, "I cannot work on anything else than weapons."); return; } if ((item.Object_Type < 1 || item.Object_Type > 28) && item.Object_Type != 42) { SendReply(player, "I cannot work on anything else than weapons."); return; } if (speed > 43 && item.Item_Type != 12 && item.Item_Type != 13) { SendReply(player, "This Item cannot be that slow."); return; } if (speed < 39 && item.Item_Type == 12) { SendReply(player, "This Item cannot be that fast."); return; } if (item == null || item.SlotPosition == (int)eInventorySlot.Ground || item.OwnerID == null || item.OwnerID != player.InternalID) { player.Out.SendMessage("Invalid item.", eChatType.CT_Important, eChatLoc.CL_SystemWindow); return; } if (player.GetCurrentMoney() <= Price) { SayTo(player, eChatLoc.CL_PopupWindow, "I need " + Money.GetString(Price) + " to enchant that."); return; } /* if (item.Name.StartsWith(Prefix0) || item.Name.StartsWith(Prefix1) || item.Name.StartsWith(Prefix2) || item.Name.StartsWith(Prefix3) || item.Name.StartsWith(Prefix4) || item.Name.StartsWith(Prefix5) || item.Name.StartsWith(Prefix6)) { ItemTemplate item2 = (ItemTemplate)GameServer.Database.FindObjectByKey(typeof(ItemTemplate), item.Id_nb); if (item2 != null) { item.Name = item2.Name; } } */ m_timer.Enqueue(new RegionTimer(this, new RegionTimerCallback(Effect), duration)); castplayer.Enqueue(player); player.Inventory.RemoveItem(item); ItemUnique unique = new ItemUnique(item.Template); unique.SPD_ABS = speed; GameServer.Database.AddObject(unique); InventoryItem newInventoryItem = GameInventoryItem.Create<ItemUnique>(unique); player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, newInventoryItem); player.Out.SendInventoryItemsUpdate(new InventoryItem[] { newInventoryItem }); SendReply(player, "It has been quite a piece of work but now it's done.\n May the " + item.Name + " aid you on your ways."); foreach (GamePlayer visplayer in this.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { visplayer.Out.SendSpellCastAnimation(this, spell, 30); } }
public void SetEffect(GamePlayer player, int effect) { if (player == null) return; InventoryItem item = player.TempProperties.getProperty<InventoryItem>(EFFECTNPC_ITEM_WEAK); player.TempProperties.removeProperty(EFFECTNPC_ITEM_WEAK); if (item == null) return; if (item.Object_Type < 1 || item.Object_Type > 26) { SendReply(player, "I cannot work on anything else than weapons."); return; } if (item == null || item.SlotPosition == (int)eInventorySlot.Ground || item.OwnerID == null || item.OwnerID != player.InternalID) { player.Out.SendMessage("Invalid item.", eChatType.CT_Important, eChatLoc.CL_SystemWindow); return; } if (player.GetCurrentMoney() <= Price) { SayTo(player, eChatLoc.CL_PopupWindow, "I need " + Money.GetString(Price) + " to enchant that."); return; } /* if (item.Name.StartsWith(Prefix0) || item.Name.StartsWith(Prefix1) || item.Name.StartsWith(Prefix2) || item.Name.StartsWith(Prefix3) || item.Name.StartsWith(Prefix4) || item.Name.StartsWith(Prefix5) || item.Name.StartsWith(Prefix6)) { ItemTemplate item2 = (ItemTemplate)GameServer.Database.FindObjectByKey(typeof(ItemTemplate), item.Id_nb); if (item2 != null) { item.Name = item2.Name; } } */ m_timer.Enqueue(new RegionTimer(this, new RegionTimerCallback(Effect), duration)); castplayer.Enqueue(player); /* Chance = rnd.Next(1, 100); if (effect == 0) item.Name = Prefix0 + item.Name; if (Chance >= 0 && Chance <= 25 && effect != 0) item.Name = Prefix1 + item.Name; if (Chance >= 25 && Chance <= 50 && effect != 0) item.Name = Prefix2 + item.Name; if (Chance >= 50 && Chance <= 75 && effect != 0) item.Name = Prefix3 + item.Name; if (Chance >= 75 && Chance <= 100 && effect != 0) item.Name = Prefix4 + item.Name; */ player.Inventory.RemoveItem(item); ItemUnique unique = new ItemUnique(item.Template); unique.Effect = effect; GameServer.Database.AddObject(unique); InventoryItem newInventoryItem = GameInventoryItem.Create<ItemUnique>(unique); player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, newInventoryItem); player.Out.SendInventoryItemsUpdate(new InventoryItem[] { newInventoryItem }); SendReply(player, "May the " + item.Name + " lead you to a bright future."); foreach (GamePlayer visplayer in this.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { visplayer.Out.SendSpellCastAnimation(this, spell, 30); } }
public void SetColor(GamePlayer player, int color) { InventoryItem item = player.TempProperties.getProperty<InventoryItem>(EFFECTNPC_ITEM_WEAK); player.TempProperties.removeProperty(EFFECTNPC_ITEM_WEAK); if (item == null || item.SlotPosition == (int)eInventorySlot.Ground || item.OwnerID == null || item.OwnerID != player.InternalID) { player.Out.SendMessage("Invalid item.", eChatType.CT_Important, eChatLoc.CL_SystemWindow); return; } if (item.Object_Type == 41 || item.Object_Type == 43 || item.Object_Type == 44 || item.Object_Type == 46) { SendReply(player, "You can't dye that."); } if (player.GetCurrentMoney() <= Price) { SayTo(player, eChatLoc.CL_PopupWindow, "I need " + Money.GetString(Price) + " to enchant that."); return; } m_timer.Enqueue(new RegionTimer(this, new RegionTimerCallback(Effect), duration)); castplayer.Enqueue(player); player.Inventory.RemoveItem(item); ItemUnique unique = new ItemUnique(item.Template); unique.Color = color; GameServer.Database.AddObject(unique); InventoryItem newInventoryItem = GameInventoryItem.Create<ItemUnique>(unique); player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, newInventoryItem); player.Out.SendInventoryItemsUpdate(new InventoryItem[] { newInventoryItem }); SendReply(player, "Look at that, the color has come out beautifully. Wear it with pride."); foreach (GamePlayer visplayer in this.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) { visplayer.Out.SendSpellCastAnimation(this, spell, 30); } }
public void RemoveProc(GamePlayer player, int procNumber) { InventoryItem item = player.TempProperties.getProperty<InventoryItem>(TempProperty); player.TempProperties.removeProperty(TempProperty); if (item == null || item.OwnerID != player.InternalID || item.OwnerID == null) return; player.Inventory.RemoveItem(item); ItemUnique unique = new ItemUnique(item.Template); if (procNumber == 1) { unique.ProcSpellID = 0; unique.SpellID = 0; } else if (procNumber == 2) { unique.ProcSpellID1 = 0; unique.SpellID1 = 0; } else { SendReply(player, "Error, contact a GM"); } GameServer.Database.AddObject(unique); InventoryItem newInventoryItem = GameInventoryItem.Create<ItemUnique>(unique); player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, newInventoryItem); player.Out.SendInventoryItemsUpdate(new InventoryItem[] { newInventoryItem }); player.SaveIntoDatabase(); }
public static WorldInventoryItem CreateUniqueFromTemplate(ItemTemplate template) { if (template == null) return null; WorldInventoryItem invItem = new WorldInventoryItem(); ItemUnique item = new ItemUnique(template); GameServer.Database.AddObject(item); invItem.m_item = GameInventoryItem.Create<ItemUnique>(item); invItem.m_item.SlotPosition = 0; invItem.m_item.OwnerID = null; invItem.Level = (byte)template.Level; invItem.Model = (ushort)template.Model; invItem.Emblem = template.Emblem; invItem.Name = template.Name; return invItem; }
public void OnCommand(GameClient client, string[] args) { if (args.Length < 2) { DisplaySyntax(client); return; } try { switch (args[1].ToLower()) { #region Blank case "blank": { ItemTemplate newTemplate = new ItemTemplate(); newTemplate.Name = "(blank item)"; newTemplate.Id_nb = InventoryItem.BLANK_ITEM; GameInventoryItem item = new GameInventoryItem(newTemplate); if (client.Player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, item)) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Blank.ItemCreated"), eChatType.CT_System, eChatLoc.CL_SystemWindow); InventoryLogging.LogInventoryAction(client.Player, client.Player, eInventoryActionType.Other, item.Template, item.Count); } else { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Blank.CreationError"), eChatType.CT_System, eChatLoc.CL_SystemWindow); } break; } #endregion Blank #region Scroll case "scroll": { WorldInventoryItem scroll = ArtifactMgr.CreateScroll(args[2], Convert.ToInt16(args[3])); if (scroll == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Scroll.NotFound", args[3], args[2]), eChatType.CT_SpellResisted, eChatLoc.CL_SystemWindow); return; } if (client.Player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, scroll.Item)) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Scroll.Created", scroll.Item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow); InventoryLogging.LogInventoryAction(client.Player, client.Player, eInventoryActionType.Other, scroll.Item.Template, scroll.Item.Count); } break; } #endregion Scroll #region Create case "create": { ItemTemplate template = GameServer.Database.FindObjectByKey<ItemTemplate>(args[2]); if (template == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Create.NotFound", args[2]), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } else { int count = 1; if (args.Length >= 4) { try { count = Convert.ToInt32(args[3]); if (count < 1) count = 1; } catch (Exception) { } } InventoryItem item = GameInventoryItem.Create<ItemTemplate>(template); if (item.IsStackable) { item.Count = count; } if (client.Player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, item)) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Create.Created", item.Level, item.GetName(0, false), count), eChatType.CT_System, eChatLoc.CL_SystemWindow); InventoryLogging.LogInventoryAction(client.Player, client.Player, eInventoryActionType.Other, item.Template, item.Count); } } break; } #endregion Create #region Count case "count": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { slot = Convert.ToInt32(args[3]); } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (!item.IsStackable) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NotStackable", item.GetName(0, true)), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (Convert.ToInt32(args[2]) < 1) { item.Count = 1; } else { item.Count = Convert.ToInt32(args[2]); } client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); client.Player.UpdateEncumberance(); break; } #endregion Count #region MaxCount case "maxcount": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { slot = Convert.ToInt32(args[3]); } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.MaxCount = Convert.ToInt32(args[2]); if (item.MaxCount < 1) item.MaxCount = 1; break; } #endregion MaxCount #region PackSize case "packsize": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { slot = Convert.ToInt32(args[3]); } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.PackSize = Convert.ToInt32(args[2]); if (item.PackSize < 1) item.PackSize = 1; break; } #endregion PackSize #region Info case "info": { ItemTemplate obj = GameServer.Database.FindObjectByKey<ItemTemplate>(args[2]); if (obj == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Info.ItemTemplateUnknown", args[2]), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } GameInventoryItem invItem = GameInventoryItem.Create<ItemTemplate>(obj); var objectInfo = new List<string>(); invItem.WriteTechnicalInfo(objectInfo); client.Out.SendCustomTextWindow(LanguageMgr.GetTranslation(client, "GMCommands.Item.Info.Informations", obj.Id_nb), objectInfo); break; } #endregion Info #region Model case "model": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Model = Convert.ToUInt16(args[2]); client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); if (item.SlotPosition < (int)eInventorySlot.FirstBackpack) client.Player.UpdateEquipmentAppearance(); break; } #endregion Model #region Extension case "extension": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Extension = Convert.ToByte(args[2]); if (item.Template is ItemUnique || (item.Template is ItemTemplate && (item.Template as ItemTemplate).AllowUpdate)) { item.Template.Extension = item.Extension; } client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); if (item.SlotPosition < (int)eInventorySlot.FirstBackpack) client.Player.UpdateEquipmentAppearance(); break; } #endregion Extension #region Color case "color": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Color = Convert.ToUInt16(args[2]); if (item.Template is ItemUnique || (item.Template is ItemTemplate && (item.Template as ItemTemplate).AllowUpdate)) { item.Template.Color = item.Color; } client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); if (item.SlotPosition < (int)eInventorySlot.FirstBackpack) client.Player.UpdateEquipmentAppearance(); break; } #endregion Color #region Effect case "effect": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Effect = Convert.ToUInt16(args[2]); client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); if (item.SlotPosition < (int)eInventorySlot.FirstBackpack) client.Player.UpdateEquipmentAppearance(); break; } #endregion Effect #region Type case "type": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Item_Type = Convert.ToInt32(args[2]); client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Type #region Object case "object": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Object_Type = Convert.ToInt32(args[2]); client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Object #region Hand case "hand": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Hand = Convert.ToInt32(args[2]); client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Hand #region DamageType case "damagetype": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Type_Damage = Convert.ToInt32(args[2]); client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion DamageType #region Name case "name": { string name = args[2]; int slot = (int)eInventorySlot.LastBackpack; if (int.TryParse(args[args.Length - 1], out slot)) { name = string.Join(" ", args, 2, args.Length - 3); } else { name = string.Join(" ", args, 2, args.Length - 2); slot = (int)eInventorySlot.LastBackpack; } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Name = name; client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Name #region Description case "description": { string desc = args[2]; int slot = (int)eInventorySlot.LastBackpack; if (int.TryParse(args[args.Length - 1], out slot)) { desc = string.Join(" ", args, 2, args.Length - 3); } else { desc = string.Join(" ", args, 2, args.Length - 2); slot = (int)eInventorySlot.LastBackpack; } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Description = desc; client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Name #region CrafterName case "craftername": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.IsCrafted = true; item.Creator = args[2]; client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion CrafterName #region Emblem case "emblem": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Emblem = Convert.ToInt32(args[2]); if (item.Template is ItemUnique || (item.Template is ItemTemplate && (item.Template as ItemTemplate).AllowUpdate)) { item.Template.Emblem = item.Emblem; } client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); if (item.SlotPosition < (int)eInventorySlot.FirstBackpack) client.Player.UpdateEquipmentAppearance(); break; } #endregion Emblem #region Level case "level": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Level = Convert.ToUInt16(args[2]); client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Level #region Price case "price": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 7) { try { slot = Convert.ToInt32(args[6]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Price = Money.GetMoney(0, (int)(Convert.ToInt16(args[2]) % 1000), (int)(Convert.ToInt16(args[3]) % 1000), (int)(Convert.ToByte(args[4]) % 100), (int)(Convert.ToByte(args[5]) % 100)); client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Price #region Condition case "condition": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 5) { try { slot = Convert.ToInt32(args[4]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } int con = Convert.ToInt32(args[2]); int maxcon = Convert.ToInt32(args[3]); item.Condition = con; item.MaxCondition = maxcon; if (item.Template is ItemUnique || (item.Template is ItemTemplate && (item.Template as ItemTemplate).AllowUpdate)) { item.Template.Condition = item.Condition; } client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Condition #region Durability case "durability": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 5) { try { slot = Convert.ToInt32(args[4]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } int Dur = Convert.ToInt32(args[2]); int MaxDur = Convert.ToInt32(args[3]); item.Durability = Dur; if (item.Template is ItemUnique || (item.Template is ItemTemplate && (item.Template as ItemTemplate).AllowUpdate)) { item.Template.Durability = item.Durability; } item.MaxDurability = MaxDur; client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Durability #region Quality case "quality": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } int Qua = Convert.ToInt32(args[2]); item.Quality = Qua; client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Quality #region Bonus case "bonus": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } int Bonus = Convert.ToInt32(args[2]); item.Bonus = Bonus; client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Bonus #region mBonus case "mbonus": { int slot = (int)eInventorySlot.LastBackpack; int num = 0; int bonusType = 0; int bonusValue = 0; if (args.Length >= 6) { try { slot = Convert.ToInt32(args[5]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } try { num = Convert.ToInt32(args[2]); } catch { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.mBonus.NonSetBonusNumber"), eChatType.CT_System, eChatLoc.CL_SystemWindow); } try { bonusType = Convert.ToInt32(args[3]); if (bonusType < 0 || bonusType >= (int)eProperty.MaxProperty) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.mBonus.TypeShouldBeInRange", (int)(eProperty.MaxProperty - 1)), eChatType.CT_System, eChatLoc.CL_SystemWindow); break; } } catch { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.mBonus.NonSetBonusType"), eChatType.CT_System, eChatLoc.CL_SystemWindow); } try { bonusValue = Convert.ToInt32(args[4]); switch (num) { case 0: { item.ExtraBonus = bonusValue; item.ExtraBonusType = bonusType; break; } case 1: { item.Bonus1 = bonusValue; item.Bonus1Type = bonusType; break; } case 2: { item.Bonus2 = bonusValue; item.Bonus2Type = bonusType; break; } case 3: { item.Bonus3 = bonusValue; item.Bonus3Type = bonusType; break; } case 4: { item.Bonus4 = bonusValue; item.Bonus4Type = bonusType; break; } case 5: { item.Bonus5 = bonusValue; item.Bonus5Type = bonusType; break; } case 6: { item.Bonus6 = bonusValue; item.Bonus6Type = bonusType; break; } case 7: { item.Bonus7 = bonusValue; item.Bonus7Type = bonusType; break; } case 8: { item.Bonus8 = bonusValue; item.Bonus8Type = bonusType; break; } case 9: { item.Bonus9 = bonusValue; item.Bonus9Type = bonusType; break; } case 10: { item.Bonus10 = bonusValue; item.Bonus10Type = bonusType; break; } default: client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.mBonus.UnknownBonusNumber", num), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (item.SlotPosition < (int)eInventorySlot.FirstBackpack) { client.Out.SendCharStatsUpdate(); client.Out.SendCharResistsUpdate(); } } catch { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.mBonus.NotSetBonusValue"), eChatType.CT_System, eChatLoc.CL_SystemWindow); } break; } #endregion mBonus #region Weight case "weight": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Weight = Convert.ToInt32(args[2]); client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Weight #region DPS_AF - DPS - AF case "dps_af": case "dps": case "af": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.DPS_AF = Convert.ToByte(args[2]); client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion DPS_AF - DPS - AF #region SPD_ABS - SPD - ABS case "spd_abs": case "spd": case "abs": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.SPD_ABS = Convert.ToByte(args[2]); client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion SPD_ABS - SPD - ABS #region IsDropable case "isdropable": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.IsDropable = Convert.ToBoolean(args[2]); break; } #endregion IsDropable #region IsPickable case "ispickable": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.IsPickable = Convert.ToBoolean(args[2]); break; } #endregion IsPickable #region IsNotLosingDur case "isnotlosingdur": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.IsNotLosingDur = Convert.ToBoolean(args[2]); break; } #endregion IsNotLosingDur #region IsIndestructible case "isindestructible": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.IsIndestructible = Convert.ToBoolean(args[2]); break; } #endregion IsIndestructible #region IsTradable case "istradable": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.IsTradable = Convert.ToBoolean(args[2]); break; } #endregion IsTradable #region CanDropAsLoot case "candropasloot": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.CanDropAsLoot = Convert.ToBoolean(args[2]); break; } #endregion CanDropAsLoot #region Spell case "spell": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 6) { try { slot = Convert.ToInt32(args[5]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } int Charges = Convert.ToInt32(args[2]); int MaxCharges = Convert.ToInt32(args[3]); int SpellID = Convert.ToInt32(args[4]); item.Charges = Charges; item.MaxCharges = MaxCharges; if (item.Template is ItemUnique || (item.Template is ItemTemplate && (item.Template as ItemTemplate).AllowUpdate)) { item.Template.Charges = item.Charges; item.Template.MaxCharges = item.MaxCharges; } item.SpellID = SpellID; client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Spell #region Spell1 case "spell1": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 6) { try { slot = Convert.ToInt32(args[5]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } int Charges = Convert.ToInt32(args[2]); int MaxCharges = Convert.ToInt32(args[3]); int SpellID1 = Convert.ToInt32(args[4]); item.Charges1 = Charges; item.MaxCharges1 = MaxCharges; if (item.Template is ItemUnique || (item.Template is ItemTemplate && (item.Template as ItemTemplate).AllowUpdate)) { item.Template.Charges1 = item.Charges1; item.Template.MaxCharges1 = item.MaxCharges1; } item.SpellID1 = SpellID1; client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Spell1 #region Proc case "proc": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.ProcSpellID = Convert.ToInt32(args[2]); client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Proc #region Proc1 case "proc1": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.ProcSpellID1 = Convert.ToInt32(args[2]); client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Proc1 #region ProcChance case "procchance": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.ProcChance = Convert.ToByte(args[2]); client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion ProcChance #region Poison case "poison": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 6) { try { slot = Convert.ToInt32(args[5]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } int Charges = Convert.ToInt32(args[2]); int MaxCharges = Convert.ToInt32(args[3]); int SpellID = Convert.ToInt32(args[4]); item.PoisonCharges = Charges; item.PoisonMaxCharges = MaxCharges; if (item.Template is ItemUnique || (item.Template is ItemTemplate && (item.Template as ItemTemplate).AllowUpdate)) { item.Template.PoisonCharges = item.PoisonCharges; item.Template.PoisonMaxCharges = item.PoisonMaxCharges; } item.PoisonSpellID = SpellID; client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Poison #region Realm case "realm": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Realm = int.Parse(args[2]); break; } #endregion Realm #region Level Required case "levelrequired": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } int setting = Convert.ToInt32(args[2]); item.LevelRequirement = setting; client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Level Required #region Bonus Level case "bonuslevel": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } int setting = Convert.ToInt32(args[2]); item.BonusLevel = setting; client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Bonus Level #region ClassType case "classtype": { string classType = args[2]; int slot = (int)eInventorySlot.LastBackpack; if (int.TryParse(args[args.Length - 1], out slot) == false) { slot = (int)eInventorySlot.LastBackpack; } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.ClassType = classType; client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion ClassType #region PackageID case "packageid": { string packageID = args[2]; int slot = (int)eInventorySlot.LastBackpack; if (int.TryParse(args[args.Length - 1], out slot) == false) { slot = (int)eInventorySlot.LastBackpack; } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.PackageID = packageID; client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion PackageID #region Flags case "flags": { int flags = Convert.ToInt32(args[2]); int slot = (int)eInventorySlot.LastBackpack; if (args.Length == 4) { slot = Convert.ToInt32(args[3]); } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.Flags = flags; client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } #endregion Flags #region Salvage case "salvageid": { int salvageID = Convert.ToInt32(args[2]); int slot = (int)eInventorySlot.LastBackpack; if (args.Length == 4) { slot = Convert.ToInt32(args[3]); } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } item.SalvageYieldID = salvageID; client.Out.SendInventoryItemsUpdate(new InventoryItem[] { item }); break; } case "salvageinfo": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length == 3) { slot = Convert.ToInt32(args[2]); } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } List<string> list = new List<string>(); SalvageYield salvageYield = null; bool calculated = true; string sql = ""; int salvageLevel = CraftingMgr.GetItemCraftLevel(item) / 100; if (salvageLevel > 9) salvageLevel = 9; // max 9 if (item.SalvageYieldID == 0) { sql = "ObjectType=" + item.Object_Type + " AND SalvageLevel=" + salvageLevel; } else { sql = "ID=" + item.SalvageYieldID; calculated = false; } if (ServerProperties.Properties.USE_SALVAGE_PER_REALM) { // Some items use realm, some do not, so allow a find of either a set realm, or 0 sql += " AND (Realm=" + item.Realm + " OR Realm=0)"; } salvageYield = GameServer.Database.SelectObject<SalvageYield>(sql); SalvageYield yield = null; if (salvageYield != null) { yield = salvageYield.Clone() as SalvageYield; } if (yield == null || yield.PackageID == SalvageYield.LEGACY_SALVAGE_ID) { if (calculated == false) { list.Add("SalvageYield ID " + item.SalvageYieldID + " specified but not found!"); } else if (ServerProperties.Properties.USE_NEW_SALVAGE) { list.Add("Calculated Values (USE_NEW_SALVAGE = True)"); } else { list.Add("Calculated Values (USE_NEW_SALVAGE = False)"); } } else { list.Add("Using SalvageYield ID: " + yield.ID); } list.Add(" "); ItemTemplate material = GameServer.Database.FindObjectByKey<ItemTemplate>(yield.MaterialId_nb); string materialName = yield.MaterialId_nb; if (material != null) { materialName = material.Name + " (" + materialName + ")"; } else { materialName = "Not Found! (" + materialName + ")"; } if (calculated == false) { if (yield != null) { list.Add("SalvageYield ID: " + yield.ID); list.Add(" Material: " + materialName); list.Add(" Count: " + yield.Count); list.Add(" Realm: " + (yield.Realm == 0 ? "Any" : GlobalConstants.RealmToName((eRealm)yield.Realm))); list.Add(" PackageID: " + yield.PackageID); } } else { list.Add("SalvageYield ID: " + yield.ID); list.Add(" ObjectType: " + yield.ObjectType); list.Add(" SalvageLevel: " + yield.SalvageLevel); list.Add(" Material: " + materialName); list.Add(" Count: " + Salvage.GetMaterialYield(client.Player, item, yield, material)); list.Add(" Realm: " + (yield.Realm == 0 ? "Any" : GlobalConstants.RealmToName((eRealm)yield.Realm))); list.Add(" PackageID: " + yield.PackageID); } client.Out.SendCustomTextWindow("Salvage info for " + item.Name, list); break; } #endregion Flags #region Update case "update": case "updatetemplate": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length == 3) { slot = Convert.ToInt32(args[2]); } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (item.Template is ItemUnique) { DisplayMessage(client, "This command is only applicable for items based on an ItemTemplate"); } else { (item.Template as ItemTemplate).AllowUpdate = true; client.Out.SendMessage("** When this item is saved all changes will also be made to the source ItemTemplate: " + item.Template.Id_nb, eChatType.CT_Staff, eChatLoc.CL_SystemWindow); DisplayMessage(client, "** When this item is saved all changes will also be made to the source ItemTemplate: " + item.Template.Id_nb); } break; } #endregion Update #region SaveUnique case "saveunique": { int slot = (int)eInventorySlot.LastBackpack; string idnb = string.Empty; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } if (slot > (int)eInventorySlot.LastBackpack) { slot = (int)eInventorySlot.LastBackpack; } if (slot < 0) { slot = 0; } idnb = args[2]; } else if (args.Length >= 3) { idnb = args[2]; } else if (args.Length < 2) { DisplaySyntax(client); return; } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } if (item.Template is ItemUnique) { ItemUnique itemUnique = item.Template as ItemUnique; Log.Debug("update ItemUnique " + item.Template.Id_nb); GameServer.Database.SaveObject(itemUnique); client.Out.SendMessage(string.Format("ItemUnique {0} updated!", itemUnique.Id_nb), eChatType.CT_System, eChatLoc.CL_SystemWindow); } else { DisplayMessage(client, "This is not an ItemUnique. To create a new ItemUnique use addunique"); return; } } break; #endregion SaveUnique #region Save / AddUnique case "save": case "addunique": { int slot = (int)eInventorySlot.LastBackpack; string idnb = string.Empty; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } if (slot > (int)eInventorySlot.LastBackpack) { slot = (int)eInventorySlot.LastBackpack; } if (slot < 0) { slot = 0; } idnb = args[2]; } else if (args.Length >= 3) { idnb = args[2]; } else if (args.Length < 2) { DisplaySyntax(client); return; } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } // if a blank item was created then AllowAdd will be false here if (idnb == string.Empty && (item.AllowAdd == false || item.Id_nb == InventoryItem.BLANK_ITEM || args[1].ToLower() == "addunique")) { DisplayMessage(client, "You need to provide a new id_nb for this item."); return; } else if (idnb == string.Empty) { if (args[1].ToLower() == "save" && item.Template is ItemUnique) { DisplayMessage(client, "You need to provide a new id_nb to save this ItemUnique as an ItemTemplate. Use saveunique to save this ItemUnique."); return; } idnb = item.Id_nb; } ItemTemplate temp = null; if (args[1].ToLower() == "save") { // if the item is allready in the database temp = GameServer.Database.FindObjectByKey<ItemTemplate>(idnb); } // save the new item if (temp == null) { if (args[1].ToLower() == "save") { try { client.Player.Inventory.RemoveItem(item); ItemTemplate itemTemplate = new ItemTemplate(item.Template); itemTemplate.Id_nb = idnb; GameServer.Database.AddObject(itemTemplate); Log.Debug("Added New Item Template: " + itemTemplate.Id_nb); DisplayMessage(client, "Added New Item Template: " + itemTemplate.Id_nb); GameInventoryItem newItem = GameInventoryItem.Create<ItemTemplate>(itemTemplate); if (client.Player.Inventory.AddItem((eInventorySlot)slot, newItem)) InventoryLogging.LogInventoryAction(client.Player, client.Player, eInventoryActionType.Other, newItem.Template, newItem.Count); } catch (Exception ex) { DisplayMessage(client, "Error adding template: " + ex.Message); return; } } else //addunique { try { client.Player.Inventory.RemoveItem(item); ItemUnique unique = new ItemUnique(item.Template); unique.Id_nb = idnb; GameServer.Database.AddObject(unique); Log.Debug("Added New ItemUnique: " + unique.Id_nb + " (" + unique.ObjectId + ")"); DisplayMessage(client, "Added New ItemUnique: " + unique.Id_nb + " (" + unique.ObjectId + ")"); GameInventoryItem newItem = GameInventoryItem.Create<ItemUnique>(unique); if (client.Player.Inventory.AddItem((eInventorySlot)slot, newItem)) InventoryLogging.LogInventoryAction(client.Player, client.Player, eInventoryActionType.Other, newItem.Template, newItem.Count); } catch (Exception ex) { DisplayMessage(client, "Error adding unique: " + ex.Message); return; } } } else // update the item { item.Template.Dirty = true; GameServer.Database.SaveObject(item.Template); GameServer.Database.UpdateInCache<ItemTemplate>(item.Template.Id_nb); DisplayMessage(client, "Updated Inventory Item: " + item.Id_nb); if (item.Template is ItemTemplate && (item.Template as ItemTemplate).AllowUpdate) { Log.Debug("Updated ItemTemplate: " + item.Template.Id_nb); DisplayMessage(client, "++ Source ItemTemplate Updated!"); } } } break; #endregion Save / AddUnique #region FindID case "findid": { string name = string.Join(" ", args, 2, args.Length - 2); if (name != "") { var items = GameServer.Database.SelectObjects<ItemTemplate>("id_nb like '%" + GameServer.Database.Escape(name) + "%'"); DisplayMessage(client, LanguageMgr.GetTranslation(client, "GMCommands.Item.FindID.MatchingIDsForX", name, items.Count), new object[] { }); foreach (ItemTemplate item in items) { DisplayMessage(client, item.Id_nb + " (" + item.Name + ")", new object[] { }); } } break; } #endregion FindID #region FindName case "findname": { string name = string.Join(" ", args, 2, args.Length - 2); if (name != "") { var items = GameServer.Database.SelectObjects<ItemTemplate>("name like '%" + GameServer.Database.Escape(name) + "%'"); DisplayMessage(client, LanguageMgr.GetTranslation(client, "GMCommands.Item.FindName.MatchingNamesForX", name, items.Count), new object[] { }); foreach (ItemTemplate item in items) { DisplayMessage(client, item.Name + " (" + item.Id_nb + ")", new object[] { }); } } break; } #endregion FindName #region Load case "load": { if (GameServer.Database.UpdateInCache<ItemTemplate>(args[2])) { Log.DebugFormat("Item {0} updated or added to ItemTemplate cache.", args[2]); DisplayMessage(client, "Item {0} updated or added to ItemTemplate cache.", args[2]); } else { Log.DebugFormat("Item {0} not found.", args[2]); DisplayMessage(client, "Item {0} not found.", args[2]); } break; } #endregion Load #region LoadPackage case "loadpackage": { if (args[2] != "") { if (args[2] == "**all**") args[2] = String.Empty; var packageItems = GameServer.Database.SelectObjects<ItemTemplate>("PackageID = '" + args[2] + "'") as ItemTemplate[]; if (packageItems != null) { int count = 0; foreach (ItemTemplate item in packageItems) { if (GameServer.Database.UpdateInCache<ItemTemplate>(item.Id_nb)) { count++; } } Log.DebugFormat("{0} items updated or added to the ItemTemplate cache.", count); DisplayMessage(client, "{0} items updated or added to the ItemTemplate cache.", count); } else { DisplayMessage(client, "No items found for package {0}.", args[2]); } } break; } #endregion LoadPackage #region LoadArtifacts case "loadartifacts": { DisplayMessage(client, "{0} Artifacts re-loaded.", DOL.GS.ArtifactMgr.LoadArtifacts()); } break; #endregion LoadArtifacts #region LoadSpells case "loadspells": { int slot = (int)eInventorySlot.LastBackpack; if (args.Length >= 4) { try { slot = Convert.ToInt32(args[3]); } catch { slot = (int)eInventorySlot.LastBackpack; } } InventoryItem item = client.Player.Inventory.GetItem((eInventorySlot)slot); if (item == null) { client.Out.SendMessage(LanguageMgr.GetTranslation(client, "GMCommands.Item.Count.NoItemInSlot", slot), eChatType.CT_System, eChatLoc.CL_SystemWindow); return; } LoadSpell(client, item.SpellID); LoadSpell(client, item.SpellID1); LoadSpell(client, item.ProcSpellID); LoadSpell(client, item.ProcSpellID1); break; } #endregion LoadSpells } } catch { DisplaySyntax(client); } }
/// <summary> /// Create an InventoryItem of given Name and Level /// </summary> /// <param name="ItemName">Name for the object</param> /// <param name="ItemLevel">Level to give to the object</param> /// <param name="Model">Model for the object</param> /// <returns>InventoryItem of given Name and Level</returns> public static InventoryItem GenerateItem(string ItemName, int ItemLevel, int Model) { ItemUnique TaskItems = new ItemUnique(); TaskItems.Name = ItemName; TaskItems.Level = ItemLevel; TaskItems.DPS_AF = 0; TaskItems.SPD_ABS = 0; TaskItems.Hand = 0; //TaskItems.Type_Damage = 0; TaskItems.Object_Type = 0; TaskItems.Item_Type = 1; TaskItems.Weight = 1; TaskItems.Model = Model; TaskItems.Price = 0; TaskItems.Color = 0; TaskItems.IsDropable = true; TaskItems.IsPickable = true; //TaskItems.IsStackable = false; TaskItems.Quality = 80+ItemLevel; TaskItems.MaxCondition = 90; TaskItems.MaxDurability = 1000; GameServer.Database.AddObject(TaskItems); InventoryItem InvTaskItems = GameInventoryItem.Create<ItemUnique>(TaskItems); return InvTaskItems; }
public void SetModel(GamePlayer player, int number) { InventoryItem item = player.TempProperties.getProperty<InventoryItem>(TempProperty); player.TempProperties.removeProperty(TempProperty); if (item == null || item.OwnerID != player.InternalID || item.OwnerID == null) return; player.Inventory.RemoveItem(item); ItemUnique unique = new ItemUnique(item.Template); unique.Model = number; GameServer.Database.AddObject(unique); InventoryItem newInventoryItem = GameInventoryItem.Create<ItemUnique>(unique); player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, newInventoryItem); player.Out.SendInventoryItemsUpdate(new InventoryItem[] { newInventoryItem }); player.RemoveBountyPoints(300); player.SaveIntoDatabase(); }