Exemplo n.º 1
0
        public override void Execute(GameLiving living)
        {
            if (CheckPreconditions(living, DEAD | SITTING | MEZZED | STUNNED))
            {
                return;
            }
            GamePlayer   player            = living as GamePlayer;
            ItemTemplate arrow_summoning_1 = GameServer.Database.FindObjectByKey <ItemTemplate>("arrow_summoning1");
            ItemTemplate arrow_summoning_2 = GameServer.Database.FindObjectByKey <ItemTemplate>("arrow_summoning2");
            ItemTemplate arrow_summoning_3 = GameServer.Database.FindObjectByKey <ItemTemplate>("arrow_summoning3");

            // what are these used for? - tolakram
            WorldInventoryItem as1 = WorldInventoryItem.CreateFromTemplate(arrow_summoning_1);
            WorldInventoryItem as2 = WorldInventoryItem.CreateFromTemplate(arrow_summoning_2);
            WorldInventoryItem as3 = WorldInventoryItem.CreateFromTemplate(arrow_summoning_3);

            if (!player.Inventory.AddTemplate(GameInventoryItem.Create(arrow_summoning_1), 10, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
            {
                player.Out.SendMessage("You do not have enough inventory space to place this item!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }
            else if (!player.Inventory.AddTemplate(GameInventoryItem.Create(arrow_summoning_2), 10, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
            {
                player.Out.SendMessage("You do not have enough inventory space to place this item!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }
            else if (!player.Inventory.AddTemplate(GameInventoryItem.Create(arrow_summoning_3), 10, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
            {
                player.Out.SendMessage("You do not have enough inventory space to place this item!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }

            GameEventMgr.AddHandler(player, GamePlayerEvent.Quit, new DOLEventHandler(PlayerQuit));
            DisableSkill(living);
        }
Exemplo n.º 2
0
        public void GenerateROG(GamePlayer player, eObjectType objectType, eSlot slot)
        {
            player.RemoveBountyPoints(2000);
            GameNPC mob = new GameNPC();

            mob.Name            = "Unique Object";
            mob.CurrentRegionID = 1;
            mob.Level           = (byte)(player.Level);
            if (mob.Level > 50)
            {
                mob.Level = 51;
            }

            LootList   lootlist = new LootList();
            ItemUnique item     = null;

            item             = new ItemUnique();
            item.Object_Type = (int)objectType;
            item.Item_Type   = (int)slot;

            mob.Level           = 60;
            mob.Name            = "TOA Mob";
            mob.CurrentRegionID = 30;
            mob.Z = 9999;
            lootlist.AddFixed(LootGeneratorUniqueObject.GenerateUniqueItem(mob, player, item), 1);
            foreach (ItemUnique unique in lootlist.GetLoot())
            {
                unique.Price = 0;
                GameServer.Database.AddObject(unique);
                InventoryItem invitem = GameInventoryItem.Create <ItemUnique>(unique);
                player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, invitem);
                player.Out.SendMessage("Generated: " + unique.Name, eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }
        }
Exemplo n.º 3
0
        /// <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(TaskItems);

            return(InvTaskItems);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Load or reload all items into the market cache
        /// </summary>
        public static bool Initialize()
        {
            log.Info("Building Market Cache ....");
            try
            {
                m_itemCache = new Dictionary <string, InventoryItem>();

                IList <InventoryItem> list = GameServer.Database.SelectObjects <InventoryItem>("`SlotPosition` >= @SlotPositionFirst AND `SlotPosition` <= @SlotPositionLast AND `OwnerLot` > @OwnerLot",
                                                                                               new[] { new QueryParameter("@SlotPositionFirst", (int)eInventorySlot.Consignment_First), new QueryParameter("@SlotPositionLast", (int)eInventorySlot.Consignment_Last), new QueryParameter("@OwnerLot", 0) });

                foreach (InventoryItem item in list)
                {
                    GameInventoryItem playerItem = GameInventoryItem.Create(item);
                    m_itemCache.Add(item.ObjectId, playerItem);
                }

                log.Info("Market Cache initialized with " + m_itemCache.Count + " items.");
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
        protected static bool GiveItem(GameLiving source, GamePlayer player, ItemTemplate itemTemplate, bool canDrop)
        {
            InventoryItem item = null;

            if (itemTemplate is ItemUnique)
            {
                GameServer.Database.AddObject(itemTemplate as ItemUnique);
                item = GameInventoryItem.Create <ItemUnique>(itemTemplate as ItemUnique);
            }
            else
            {
                item = GameInventoryItem.Create <ItemTemplate>(itemTemplate);
            }

            if (!player.ReceiveItem(source, item))
            {
                if (canDrop)
                {
                    player.CreateItemOnTheGround(item);
                    player.Out.SendMessage(String.Format("Your backpack is full, {0} is dropped on the ground.", itemTemplate.Name), eChatType.CT_Important, eChatLoc.CL_PopupWindow);
                }
                else
                {
                    player.Out.SendMessage("Your backpack is full!", eChatType.CT_Important, eChatLoc.CL_PopupWindow);
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 6
0
        public override void Die(GameObject killer)
        {
            GamePlayer player = killer as GamePlayer;

            if (player != null)
            {
                if (Util.Chance(40))
                {
                    #region rog_stuff

                    GameNPC mob = new GameNPC();
                    mob.Name            = "Unique Object";
                    mob.CurrentRegionID = 1;
                    mob.Level           = (byte)(player.Level);
                    if (mob.Level > 50)
                    {
                        mob.Level = 51;
                    }

                    mob.Level           = 60;
                    mob.Name            = "TOA Mob";
                    mob.CurrentRegionID = 30;
                    mob.Z = 9999;

                    ItemUnique unique = LootGeneratorUniqueObject.GenerateUniqueItem(mob, player, null);
                    GameServer.Database.AddObject(unique);
                    InventoryItem item = GameInventoryItem.Create <ItemUnique>(unique);
                    player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, item);

                    #endregion
                }
            }
            base.Die(killer);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Exchange special currency for merchant currency type
        /// </summary>
        /// <param name="source"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool ReceiveItem(GameLiving source, InventoryItem item)
        {
            if (source is GamePlayer player && item != null && m_currencyValues != null &&
                m_currencyValues.TryGetValue(item.Id_nb, out int receiveCost) &&
                m_currencyValues.TryGetValue(MoneyKey, out int giveCost))
            {
                int giveCount = item.Count * receiveCost / giveCost;

                if (giveCount > 0)
                {
                    // Create and give new item to player
                    InventoryItem newItem = GameInventoryItem.Create(m_itemTemplate);
                    newItem.OwnerID = player.InternalID;
                    newItem.Count   = giveCount;

                    if (!player.Inventory.AddTemplate(newItem, newItem.Count, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
                    {
                        player.CreateItemOnTheGround(newItem);
                    }

                    // Remove received items
                    InventoryItem playerItem = player.Inventory.GetItem((eInventorySlot)item.SlotPosition);
                    playerItem.Count -= giveCount * giveCost;

                    if (playerItem.Count < 1)
                    {
                        player.Inventory.RemoveItem(item);
                    }

                    return(true);
                }
            }

            return(base.ReceiveItem(source, item));
        }
Exemplo n.º 8
0
        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 + ".");
        }
Exemplo n.º 9
0
        public SummonWarcrystalSpellHandler(GameLiving caster, Spell spell, SpellLine line)
            : base(caster, spell, line)
        {
            string ammo = "";

            switch (Util.Random(1, 2))
            {
            case 1:
                ammo = "mystic_ammo_heat";
                break;

            case 2:
                ammo = "mystic_ammo_cold";
                break;
            }
            ItemTemplate template = GameServer.Database.FindObjectByKey <ItemTemplate>(ammo);

            if (template != null)
            {
                items.Add(GameInventoryItem.Create <ItemTemplate>(template));
                foreach (InventoryItem item in items)
                {
                    if (item.IsStackable)
                    {
                        item.Count  = 1;
                        item.Weight = item.Count * item.Weight;
                    }
                }
            }
        }
Exemplo n.º 10
0
        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();
        }
Exemplo n.º 11
0
        /// <summary>
        /// Load or reload all items into the market cache
        /// </summary>
        public static bool Initialize()
        {
            log.Info("Building Market Cache ....");
            try
            {
                m_itemCache = new Dictionary <string, InventoryItem>();
                string query = "(`SlotPosition` >= " + (int)eInventorySlot.Consignment_First + " AND `SlotPosition` <= " + (int)eInventorySlot.Consignment_Last + " AND OwnerLot > 0)";

                IList <InventoryItem> list = GameServer.Database.SelectObjects <InventoryItem>(query);

                foreach (InventoryItem item in list)
                {
                    GameInventoryItem playerItem = GameInventoryItem.Create(item);
                    m_itemCache.Add(item.ObjectId, playerItem);
                }

                log.Info("Market Cache initialized with " + m_itemCache.Count + " items.");
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Changes the commander's weapon to the specified weapon template
        /// </summary>
        public void MinionGetWeapon(CommanderPet.eWeaponType weaponType)
        {
            ItemTemplate itemTemp = CommanderPet.GetWeaponTemplate(weaponType);

            if (itemTemp == null)
            {
                return;
            }

            InventoryItem weapon;

            weapon = GameInventoryItem.Create(itemTemp);
            if (weapon != null)
            {
                if (Inventory == null)
                {
                    Inventory = new GameNPCInventory(new GameNpcInventoryTemplate());
                }
                else
                {
                    Inventory.RemoveItem(Inventory.GetItem((eInventorySlot)weapon.Item_Type));
                }

                Inventory.AddItem((eInventorySlot)weapon.Item_Type, weapon);
                SwitchWeapon((eActiveWeaponSlot)weapon.Hand);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Load or reload all items into the market cache
        /// </summary>
        public static bool Initialize()
        {
            log.Info("Building Market Cache ....");
            try
            {
                m_itemCache = new Dictionary <string, InventoryItem>();

                var filterBySlot = DB.Column("SlotPosition").IsGreaterOrEqualTo((int)eInventorySlot.Consignment_First).And(DB.Column("SlotPosition").IsLessOrEqualTo((int)eInventorySlot.Consignment_Last));
                var list         = DOLDB <InventoryItem> .SelectObjects(filterBySlot.And(DB.Column("OwnerLot").IsGreatherThan(0)));

                foreach (InventoryItem item in list)
                {
                    GameInventoryItem playerItem = GameInventoryItem.Create(item);
                    m_itemCache.Add(item.ObjectId, playerItem);
                }

                log.Info("Market Cache initialized with " + m_itemCache.Count + " items.");
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Creates a Guard Inventory from an Inventory Template
 /// </summary>
 /// <param name="template"></param>
 public GameNPCInventory(GameNpcInventoryTemplate template)
 {
     foreach (InventoryItem item in template.AllItems)
     {
         AddItem((eInventorySlot)item.SlotPosition, GameInventoryItem.Create <InventoryItem>(item));
     }
 }
Exemplo n.º 15
0
        public override void Perform(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer    player        = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);
            InventoryItem inventoryItem = GameInventoryItem.Create(P as ItemTemplate);

            player.CreateItemOnTheGround(inventoryItem);
            player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Behaviour.DropItemAction.DropsFrontYou", inventoryItem.Name), eChatType.CT_Loot, eChatLoc.CL_SystemWindow);
        }
Exemplo n.º 16
0
        public override void OnPlayerBuy(GamePlayer player, int item_slot, int number)
        {
            //Get the template
            int pagenumber = item_slot / MerchantTradeItems.MAX_ITEM_IN_TRADEWINDOWS;
            int slotnumber = item_slot % MerchantTradeItems.MAX_ITEM_IN_TRADEWINDOWS;

            ItemTemplate template = this.TradeItems.GetItem(pagenumber, (eMerchantWindowSlot)slotnumber);

            if (template == null)
            {
                return;
            }

            //Calculate the amout of items
            int amountToBuy = number;

            if (template.PackSize > 0)
            {
                amountToBuy *= template.PackSize;
            }

            if (amountToBuy <= 0)
            {
                return;
            }

            //Calculate the value of items
            long totalValue = number * template.Price;

            lock (player.Inventory)
            {
                if (player.BountyPoints < totalValue)
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "GameMerchant.OnPlayerBuy.YouNeedBP", totalValue), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }
                if (!player.Inventory.AddTemplate(GameInventoryItem.Create(template), amountToBuy, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "GameMerchant.OnPlayerBuy.NotInventorySpace"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }
                InventoryLogging.LogInventoryAction(this, player, eInventoryActionType.Merchant, template, amountToBuy);
                //Generate the buy message
                string message;
                if (number > 1)
                {
                    message = LanguageMgr.GetTranslation(player.Client.Account.Language, "GameMerchant.OnPlayerBuy.BoughtPiecesBP", totalValue, template.GetName(1, false));
                }
                else
                {
                    message = LanguageMgr.GetTranslation(player.Client.Account.Language, "GameMerchant.OnPlayerBuy.BoughtBP", template.GetName(1, false), totalValue);
                }
                player.BountyPoints -= totalValue;
                player.Out.SendUpdatePoints();
                player.Out.SendMessage(message, eChatType.CT_Merchant, eChatLoc.CL_SystemWindow);
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Apply effect on target or do spell action if non duration spell
        /// </summary>
        /// <param name="target">target that gets the effect</param>
        /// <param name="effectiveness">factor from 0..1 (0%-100%)</param>
        public override void ApplyEffectOnTarget(GameLiving target, double effectiveness)
        {
            if (Caster?.ControlledBrain == null)
            {
                return;
            }

            GameNPC temppet = Caster.ControlledBrain.Body;

            // Lets let NPC's able to cast minions.  Here we make sure that the Caster is a GameNPC
            // and that m_controlledNpc is initialized (since we aren't thread safe).
            if (temppet == null)
            {
                if (Caster is GameNPC npc)
                {
                    temppet = npc;

                    // We'll give default NPCs 2 minions!
                    if (temppet.ControlledNpcList == null)
                    {
                        temppet.InitControlledBrainArray(2);
                    }
                }
                else
                {
                    return;
                }
            }

            base.ApplyEffectOnTarget(target, effectiveness);

            if (m_pet.Brain is BDArcherBrain)
            {
                if (!(GameServer.Database.FindObjectByKey <ItemTemplate>("BD_Archer_Distance_bow") is ItemTemplate temp))
                {
                    log.Error("Unable to find Bonedancer Archer's Bow");
                }
                else
                {
                    if (m_pet.Inventory == null)
                    {
                        m_pet.Inventory = new GameNPCInventory(new GameNpcInventoryTemplate());
                    }
                    else
                    {
                        m_pet.Inventory.RemoveItem(m_pet.Inventory.GetItem(eInventorySlot.DistanceWeapon));
                    }

                    m_pet.Inventory.AddItem(eInventorySlot.DistanceWeapon, GameInventoryItem.Create(temp));
                }

                m_pet.BroadcastLivingEquipmentUpdate();
            }
Exemplo n.º 18
0
        public void SetBonus(string propertyName, InventoryItem item, GamePlayer player)
        {
            Console.WriteLine("1");
            eProperty prop = strToProperty(propertyName);

            if (prop == eProperty.MaxSpeed)
            {
                return;
            }
            Console.WriteLine("2");
            ItemUnique unique = new ItemUnique(item.Template);

            player.Inventory.RemoveItem(item);
            player.TempProperties.removeProperty(CRAFT_ITEM);

            int bonusVal = prop >= eProperty.Resist_First && prop <= eProperty.Resist_Last ? 5 : 20;

            if (unique.Bonus1Type == 0)
            {
                unique.Bonus1Type = (int)prop;
                unique.Bonus1     = 20;
            }
            else if (unique.Bonus2Type == 0)
            {
                unique.Bonus2Type = (int)prop;
                unique.Bonus2     = 20;
            }
            else if (unique.Bonus3Type == 0)
            {
                unique.Bonus3Type = (int)prop;
                unique.Bonus3     = 20;
            }
            else if (unique.Bonus4Type == 0)
            {
                unique.Bonus4Type = (int)prop;
                unique.Bonus4     = 20;
            }
            else if (unique.Bonus5Type == 0)
            {
                unique.Bonus5Type = (int)prop;
                unique.Bonus5     = 20;
            }
            Console.WriteLine("3");
            GameServer.Database.AddObject(unique);
            InventoryItem newInventoryItem = GameInventoryItem.Create <ItemUnique>(unique);

            player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, newInventoryItem);
            SendReply(player, "I have now imbued your " + unique.Name + " with the power of " + propertyName + "!");
            player.Out.SendInventoryItemsUpdate(new InventoryItem[] { newInventoryItem });
        }
Exemplo n.º 19
0
        /// <summary>
        /// Add a gift to the player
        /// </summary>
        /// <param name="template">the template ID of the item</param>
        /// <param name="player">the player to give it to</param>
        /// <returns>true if succesful</returns>
        public virtual bool addGift(String template, GamePlayer player)
        {
            ItemTemplate temp = GameServer.Database.FindObjectByKey <ItemTemplate>(template);

            if (temp != null)
            {
                if (!player.Inventory.AddTemplate(GameInventoryItem.Create(temp), 1, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "GameTrainer.AddGift.NotEnoughSpace"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return(false);
                }
                InventoryLogging.LogInventoryAction(this, player, eInventoryActionType.Other, temp);
            }
            return(true);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Move an item from the inventory object to a player's backpack (uses client slots)
        /// </summary>
        public static IDictionary <int, InventoryItem> MoveItemFromObject(this IGameInventoryObject thisObject, GamePlayer player, eInventorySlot fromClientSlot, eInventorySlot toClientSlot)
        {
            // We will only allow moving to the backpack.

            if (toClientSlot < eInventorySlot.FirstBackpack || toClientSlot > eInventorySlot.LastBackpack)
            {
                return(null);
            }

            lock (thisObject.LockObject())
            {
                Dictionary <int, InventoryItem> inventory = thisObject.GetClientInventory(player);

                if (inventory.ContainsKey((int)fromClientSlot) == false)
                {
                    ChatUtil.SendErrorMessage(player, "Item not found in slot " + (int)fromClientSlot);
                    return(null);
                }

                InventoryItem fromItem = inventory[(int)fromClientSlot];
                InventoryItem toItem   = player.Inventory.GetItem(toClientSlot);

                // if there is an item in the players target inventory slot then move it to the object
                if (toItem != null)
                {
                    player.Inventory.RemoveTradeItem(toItem);
                    toItem.SlotPosition = fromItem.SlotPosition;
                    toItem.OwnerID      = thisObject.GetOwner(player);
                    thisObject.OnAddItem(player, toItem);
                    GameServer.Database.SaveObject(toItem);
                }

                thisObject.OnRemoveItem(player, fromItem);

                // Create the GameInventoryItem from this InventoryItem.  This simply wraps the InventoryItem,
                // which is still updated when this item is moved around
                InventoryItem objectItem = GameInventoryItem.Create <InventoryItem>(fromItem);

                player.Inventory.AddTradeItem(toClientSlot, objectItem);

                var updateItems = new Dictionary <int, InventoryItem>(1);
                updateItems.Add((int)fromClientSlot, toItem);

                return(updateItems);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Loads the GameRelic from Database
        /// </summary>
        /// <param name="obj">The DBRelic-object for this relic</param>
        public override void LoadFromDatabase(DataObject obj)
        {
            InternalID      = obj.ObjectId;
            m_dbRelic       = obj as DBRelic;
            CurrentRegionID = (ushort)m_dbRelic.Region;
            X               = m_dbRelic.X;
            Y               = m_dbRelic.Y;
            Z               = m_dbRelic.Z;
            Heading         = (ushort)m_dbRelic.Heading;
            m_relicType     = (eRelicType)m_dbRelic.relicType;
            Realm           = (eRealm)m_dbRelic.Realm;
            m_originalRealm = (eRealm)m_dbRelic.OriginalRealm;
            m_lastRealm     = (eRealm)m_dbRelic.LastRealm;


            //get constant values
            MiniTemp template = GetRelicTemplate(m_originalRealm, m_relicType);

            m_name   = template.Name;
            m_model  = template.Model;
            template = null;

            //set still empty fields
            Emblem = 0;
            Level  = 99;

            //generate itemtemplate for inventoryitem
            ItemTemplate m_itemTemp;

            m_itemTemp             = new ItemTemplate();
            m_itemTemp.Name        = Name;
            m_itemTemp.Object_Type = (int)eObjectType.Magical;
            m_itemTemp.Model       = Model;
            m_itemTemp.IsDropable  = true;
            m_itemTemp.IsPickable  = false;
            m_itemTemp.Level       = 99;
            m_itemTemp.Quality     = 100;
            m_itemTemp.Price       = 0;
            m_itemTemp.PackSize    = 1;
            m_itemTemp.AllowAdd    = false;
            m_itemTemp.Weight      = 1000;
            m_itemTemp.Id_nb       = "GameRelic";
            m_itemTemp.IsTradable  = false;
            m_itemTemp.ClassType   = "DOL.GS.GameInventoryRelic";
            m_item = GameInventoryItem.Create <ItemTemplate>(m_itemTemp);
        }
            public void OnCommand(GameClient client, string[] args)
            {
                try
                {
                    for (int x = 0; x < 8; x++)
                    {
                        GeneratedUniqueItem item = null;

                        if (args.Length > 1)
                        {
                            if (Convert.ToString(args[1]).ToUpper() == "TOA")
                            {
                                item = new GeneratedUniqueItem(true, client.Player.Realm, 51);
                                item.GenerateItemQuality(GameObject.GetConLevel(client.Player.Level, 60));
                            }
                            else if (Convert.ToString(args[1]).ToUpper() == "L51")
                            {
                                item = new GeneratedUniqueItem(client.Player.Realm, 51);
                                item.GenerateItemQuality(GameObject.GetConLevel(client.Player.Level, 50));
                            }
                            else
                            {
                                if (args.Length > 2)
                                {
                                    item = new GeneratedUniqueItem(client.Player.Realm, client.Player.Level, (eObjectType)Convert.ToInt32(args[1]), (eInventorySlot)Convert.ToInt32(args[2]));
                                }
                                else
                                {
                                    item = new GeneratedUniqueItem(client.Player.Realm, client.Player.Level, (eObjectType)Convert.ToInt32(args[1]));
                                }
                            }
                        }

                        item.AllowAdd = true;
                        GameServer.Database.AddObject(item);
                        InventoryItem invitem = GameInventoryItem.Create <ItemUnique>(item);
                        client.Player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, invitem);
                        client.Player.Out.SendMessage("Generated: " + item.Name, eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    }
                }
                catch (Exception)
                {
                    DisplaySyntax(client);
                }
            }
Exemplo n.º 23
0
        public override void Perform(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer player = BehaviourUtils.GuessGamePlayerFromNotify(e, sender, args);

            ItemTemplate oldItem = P;
            ItemTemplate newItem = Q;

            // TODO: what about stacked items???
            if (player.Inventory.RemoveTemplate(oldItem.Id_nb, 1, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
            {
                InventoryLogging.LogInventoryAction(player, NPC, eInventoryActionType.Quest, oldItem, 1);
                InventoryItem inventoryItem = GameInventoryItem.Create(newItem);
                if (player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, inventoryItem))
                {
                    InventoryLogging.LogInventoryAction(NPC, player, eInventoryActionType.Quest, newItem, 1);
                }
            }
        }
Exemplo n.º 24
0
        public EssenceFlareSpellHandler(GameLiving caster, Spell spell, SpellLine line)
            : base(caster, spell, line)
        {
            ItemTemplate template = GameServer.Database.FindObjectByKey <ItemTemplate>("Meschgift");

            if (template != null)
            {
                items.Add(GameInventoryItem.Create(template));
                foreach (InventoryItem item in items)
                {
                    if (item.IsStackable)
                    {
                        item.Count  = 1;
                        item.Weight = item.Count * item.Weight;
                    }
                }
            }
        }
Exemplo n.º 25
0
        public SummonWoodSpellHandler(GameLiving caster, Spell spell, SpellLine line)
            : base(caster, spell, line)
        {
            ItemTemplate template = GameServer.Database.FindObjectByKey <ItemTemplate>("mysticwood_wooden_boards");

            if (template != null)
            {
                items.Add(GameInventoryItem.Create <ItemTemplate>(template));
                foreach (InventoryItem item in items)
                {
                    if (item.IsStackable)
                    {
                        item.Count  = 1;
                        item.Weight = item.Count * item.Weight;
                    }
                }
            }
        }
Exemplo n.º 26
0
        public void InventoryFromIT()
        {
            InventoryTestCreation();
            Console.WriteLine("Creation of Ghost Inventory entry based on ItemTemplate");

            InventoryItem ii = GameInventoryItem.Create(itemt);

            player.Inventory.AddItem(eInventorySlot.FirstBackpack, ii);
            Assert.IsNotNull(ii, "ii-t #1 : " + ii.Template.Id_nb + " created & added to " + ii.OwnerID);
            var iicheck = GameServer.Database.FindObjectByKey <InventoryItem>(ii.ObjectId);

            Assert.IsNotNull(iicheck, "ii-t #2 : saved in db " + ii.Template.Id_nb + " to " + ii.OwnerID);
            GameServer.Database.DeleteObject(ii);
            iicheck = GameServer.Database.FindObjectByKey <InventoryItem>(ii.ObjectId);
            Assert.IsNull(iicheck, "ii-t #3 : deleted from db " + ii.Template.Id_nb + " to " + ii.OwnerID);
            var itcheck = GameServer.Database.FindObjectByKey <ItemTemplate>(itemt.Id_nb);

            Assert.IsNotNull(itcheck, "ii-t #4 : not deleted from db " + itemt.Id_nb);
        }
Exemplo n.º 27
0
        public BeltOfMoon(GameLiving caster, Spell spell, SpellLine line)
            : base(caster, spell, line)
        {
            if (caster.CurrentRegion.IsNightTime)
            {
                if (caster.Realm == eRealm.Albion)
                {
                    m_MoonMace = GameServer.Database.SelectObject <ItemTemplate>("Id_nb='Moon_Mace'") ?? Mace;
                    items.Add(GameInventoryItem.Create(m_MoonMace));

                    m_MoonStaff = GameServer.Database.SelectObject <ItemTemplate>("Id_nb='Moon_Staff'") ?? Staff;
                    items.Add(GameInventoryItem.Create(m_MoonStaff));
                    return;
                }

                if (caster.Realm == eRealm.Midgard)
                {
                    m_MoonMace = GameServer.Database.SelectObject <ItemTemplate>("Id_nb='Moon_MaceM'") ?? MaceM;
                    items.Add(GameInventoryItem.Create(m_MoonMace));

                    m_MoonStaff = GameServer.Database.SelectObject <ItemTemplate>("Id_nb='Moon_Staff'") ?? Staff;
                    items.Add(GameInventoryItem.Create(m_MoonStaff));
                    return;
                }

                if (caster.Realm == eRealm.Hibernia)
                {
                    m_MoonMace = GameServer.Database.SelectObject <ItemTemplate>("Id_nb='Moon_MaceH'") ?? MaceH;
                    items.Add(GameInventoryItem.Create(m_MoonMace));

                    m_MoonStaff = GameServer.Database.SelectObject <ItemTemplate>("Id_nb='Moon_Staff'") ?? Staff;
                    items.Add(GameInventoryItem.Create(m_MoonStaff));
                    return;
                }
            }

            else
            {
                MessageToCaster("The powers of the Belt of Moon, can only be Summon under the Moon light!", eChatType.CT_SpellResisted);
                return;
            }
        }
Exemplo n.º 28
0
 public void GiveRewards(GamePlayer player)
 {
     if (rewards == null)
     {
         return;
     }
     try
     {
         ItemTemplate[] array = new ItemTemplate[rewards.Count];
         if (array == null)
         {
             return;
         }
         int current = 0;
         foreach (ItemTemplate temp in rewards)
         {
             if ((player.Realm == (eRealm)temp.Realm) || (temp.Realm == 0))
             {
                 array[current] = temp;
                 current       += 1;
             }
         }
         InventoryItem item = GameInventoryItem.Create <ItemTemplate>(array[Util.Random(0, array.Length - 2)]);
         if (item != null)
         {
             if (player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, item))
             {
                 player.Out.SendMessage("You receive " + item.GetName(0, false) + " from " + this.GetName(0, false) + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow);
             }
             else
             {
                 player.CreateItemOnTheGround(item);
                 player.Out.SendMessage("Your Inventory is full. You couldn't recieve the " + item.Name + ", so it's been placed on the ground. Pick it up as soon as possible or it will vanish in a few minutes.", eChatType.CT_Important, eChatLoc.CL_PopupWindow);
             }
         }
         else
         {
             player.Out.SendMessage("There seems to be a bug with this chest!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
         }
     }
     catch { }
 }
Exemplo n.º 29
0
        public void TestAddTemplate()
        {
            GameLivingInventory gameLivingInventory = new TestInventory();

            ItemTemplate template = new ItemTemplate();
            Random       rand     = new Random();

            template.Id_nb    = "blankItem" + rand.Next().ToString();
            template.Name     = "a blank item";
            template.MaxCount = 10;
            if (template == null)
            {
                Console.WriteLine("template null");
            }

            if (gameLivingInventory.AddTemplate(GameInventoryItem.Create(template), 7, eInventorySlot.RightHandWeapon, eInventorySlot.FourthQuiver))
            {
                Console.WriteLine("addtemplate 7 blank item");
            }
            else
            {
                Console.WriteLine("can not add 7 blank item");
            }

            Console.WriteLine("----PRINT AFTER FIRST ADD 7 TEMPLATE-----");
            PrintInventory(gameLivingInventory);

            if (gameLivingInventory.AddTemplate(GameInventoryItem.Create(template), 4, eInventorySlot.RightHandWeapon, eInventorySlot.FourthQuiver))
            {
                Console.WriteLine("addtemplate 4 blank item");
            }
            else
            {
                Console.WriteLine("can not add 4 blank item");
            }

            Console.WriteLine("----PRINT AFTER SECOND ADD 4 TEMPLATE-----");
            PrintInventory(gameLivingInventory);

            // here must have 10 item in a slot and 1 in another
        }
Exemplo n.º 30
0
        /// <summary>
        /// Creates a new GameInventoryItem based on an ItemTemplate. Will disappear
        /// after 3 minutes after being added to the world.
        /// </summary>
        /// <param name="template">The template to load and create an item from.</param>
        /// <returns>Item reference or null.</returns>
        public static WorldInventoryItem CreateFromTemplate(ItemTemplate template)
        {
            if (template == null)
            {
                return(null);
            }

            WorldInventoryItem invItem = new WorldInventoryItem();

            invItem.m_item = GameInventoryItem.Create(template);

            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);
        }