Inheritance: MonoBehaviour
Beispiel #1
0
    public void Init(ItemTemplate template) {    // This function must be called once,for initiating the item
        if (!initiated) {
            _id = template.id;
            _name = template.name;
            _icon = template.icon;
            _stackable = template.stackable;
            _type = template.type;
            _description = template.description;
            _canBeUsed = template.canBeUsed;
			_onUseEvent = template.onUseEvent;
			foreach(var atrb in template.assigners) {
				attributes.Add(atrb);
			}
            initiated = true;

            if (_stackable) {
                this._maxInStack = template.maxInStack;
			}
			this.CurrentInStack = 1;

            // Adding the components
            myCanvasGroup = gameObject.AddComponent<CanvasGroup>();
			myCanvasGroup.blocksRaycasts = false;
			myCanvasGroup.interactable = false;
            gameObject.AddComponent<RectTransform>();
            gameObject.AddComponent<CanvasRenderer>();
            Image image = gameObject.AddComponent<Image>();
            image.sprite = _icon;
        }
    }
Beispiel #2
0
		public override void Initialise()
		{
			base.Initialise();

			var generatorParameters = new LevelGeneratorParameters()
				.SetParameter(RogueLevelGenerator.ParameterNames.LevelWidth, 80)
				.SetParameter(RogueLevelGenerator.ParameterNames.LevelHeight, 25)
				.SetParameter(RogueLevelGenerator.ParameterNames.MaxRooms, 9)
				.SetParameter(RogueLevelGenerator.ParameterNames.HorizontalCellCount, 3)
				.SetParameter(RogueLevelGenerator.ParameterNames.VerticalCellCount, 3);

			this.LevelGenerator = new RogueLevelGenerator(generatorParameters);
			this.GenerateLevel();

			this.PlayerCharacter.PaperDoll
				.AddSlot("head")
				.AddSlot("neck")
				.AddSlot("torso")
				.AddSlot("hand")
				.AddSlot("hand")
				.AddSlot("finger")
				.AddSlot("finger")
				.AddSlot("legs")
				.AddSlot("feet");

			var template = new ItemTemplate("leather armor");
			template.AddEquipSlot("torso");
			template.Attributes.SetAttribute("armor", 3);

			var item = new Item(template);

			this.PlayerCharacter.PaperDoll.EquipItem(item);
		}
Beispiel #3
0
 private int FindFreeSlot(ItemTemplate template)
 {
     int[] slots = template.CanBeEquipedIn;
     int slot = FindFreeSlot(slots);
     if(slot == -1 && !template.IsBag && slots.Length > 0) {
         return slots[0];
     }
     return slot;
 }
Beispiel #4
0
 void AddItem(ItemTemplate it)
 {
     string itModelName = Program.s_items.ContainsKey(it.Model) ? Program.s_items[it.Model].ToString() : "Unknown";
     ListViewItem lvi = lvItems.Items.Add(itModelName);
     lvi.SubItems.Add(it.Type.ToString());
     lvi.SubItems.Add(it.GenDQMin.ToString());
     lvi.SubItems.Add(it.GenDQMax.ToString());
     lvi.SubItems.Add(it.DQMax.ToString());
     lvi.Tag = it;
 }
Beispiel #5
0
    public void initObject()
    {
        itemImage = transform.GetChild (0).GetComponentInChildren<Image> ();
        if (itemImage == null) {
            Debug.LogError ("image not found");
        }

        if (moveHolder == null) {
            GameObject gameObject = GameObject.FindGameObjectWithTag ("item_move_holder");
            moveHolder = gameObject.GetComponent<ItemTemplate> ();
        }
    }
Beispiel #6
0
        private void btnNewItem_Click(object sender, EventArgs e)
        {
            byte genDQMin = 0;
            byte genDQMax = 0;
            byte dqMax = 0;
            try { genDQMin = Convert.ToByte(tbDurabilityMin.Text); } catch (Exception) { }
            try { genDQMax = Convert.ToByte(tbDurabilityMax.Text); } catch (Exception) { }
            try { dqMax = Convert.ToByte(tbDurationMax.Text); } catch (Exception) { }

            ItemTemplate it = new ItemTemplate(0, (ushort)Math.Max(cbModel.SelectedIndex, 0), (byte)Math.Max(cbType.SelectedIndex, 0), genDQMin, genDQMax, dqMax);
            it.New = true;
            AddItem(it);
        }
Beispiel #7
0
        public ItemTemplate CreateItemTemplate(object[] data)
        {
            long Entry = long.Parse(data[0].ToString());
            int Class = int.Parse(data[1].ToString());
            int SubClass = int.Parse(data[2].ToString());
            int DisplayId = int.Parse(data[3].ToString());
            int InventoryType = int.Parse(data[4].ToString());
            int Material = int.Parse(data[5].ToString());
            int Sheath = int.Parse(data[6].ToString());

            ItemTemplate it = new ItemTemplate(Entry, Class, SubClass, DisplayId, Material, Sheath, InventoryType);

            return it;
        }
Beispiel #8
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<ItemTemplate>(m_MoonMace));

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

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

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

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

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

            else
            {
                MessageToCaster("The powers of the Belt of Moon, can only be Summon under the Moon light!", eChatType.CT_SpellResisted);
                return;
            }
        }
Beispiel #9
0
        /// <summary>
        /// Binds a particular item to this control.
        /// </summary>
        /// <param name="itemTemplate"></param>
        public void BindItem(ItemTemplate itemTemplate)
        {
            // Bind all the properties required

            // Textbox bindings
            textName.DataBindings.Add("Text", BoundObject, "Name");
            textDescription.DataBindings.Add("Text", BoundObject, "Description");

            // Numeric stuff will be validated here
            numericPrice.DataBindings.Add("Value", BoundObject, "Price");
            numericUseSpeed.DataBindings.Add("Value", BoundObject, "UseSpeed");

            // Checkboxes
            checkConsume.DataBindings.Add("Checked", BoundObject, "Consumed");

            // Bind the combobox we need
            comboItemType.DataSource = Enum.GetValues(typeof(ItemType)).Cast<ItemType>();
            comboItemType.DataBindings.Add("SelectedItem", BoundObject, "Type");

            // Enable this object
            Enabled = true;
        }
Beispiel #10
0
        public AtensShield(GameLiving caster, Spell spell, SpellLine line)
            : base(caster, spell, line)
        {
            if (caster.Realm == eRealm.Albion)
            {
                m_goldenTridentofFlame = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Golden_Trident_of_Flame'") ?? Javelin;
                items.Add (GameInventoryItem.Create(m_goldenTridentofFlame));
                return;
            }

            if (caster.Realm == eRealm.Midgard)
            {
                m_goldenTridentofFlame = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Golden_Trident_of_Flame'") ?? JavelinM;
                items.Add (GameInventoryItem.Create(m_goldenTridentofFlame));
                return;
            }
            if (caster.Realm == eRealm.Hibernia)
            {
                m_goldenTridentofFlame = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Golden_Trident_of_Flame'") ?? JavelinH;
                items.Add (GameInventoryItem.Create(m_goldenTridentofFlame));
                return;
            }
        }
Beispiel #11
0
        public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_QUESTS)
            {
                return;
            }

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initializing ...");
            }

            /* First thing we do in here is to search for the NPCs inside
             * the world who comes from the Albion realm. If we find a the players,
             * this means we don't have to create a new one.
             *
             * NOTE: You can do anything you want in this method, you don't have
             * to search for NPC's ... you could create a custom item, place it
             * on the ground and if a player picks it up, he will get the quest!
             * Just examples, do anything you like and feel comfortable with :)
             */

            dalikor = GetDalikor();

            generalLocations[0] = new GameLocation(generalNames[0], 100, 100, 40124, 44594, 4712, 216);
            generalLocations[1] = new GameLocation(generalNames[1], 100, 100, 46821, 40884, 4972, 21);
            generalLocations[2] = new GameLocation(generalNames[2], 100, 100, 56104, 43865, 5460, 48);

            GameNPC[] npcs = null;
            for (int i = 0; i < general.Length; i++)
            {
                npcs = WorldMgr.GetObjectsByName <GameNPC>(generalNames[i], eRealm.None);
                if (npcs.Length > 0)
                {
                    general[i] = npcs[0] as GameNPC;
                }
                else
                {
                    if (log.IsWarnEnabled)
                    {
                        log.Warn("Could not find " + generalNames[i] + ", creating ...");
                    }

                    general[i] = new GameNPC();

                    general[i].Model = 678;

                    general[i].GuildName = "Part of " + questTitle + " Quest";
                    general[i].Name      = generalNames[i];
                    general[i].X         = generalLocations[i].X;
                    general[i].Y         = generalLocations[i].Y;
                    general[i].Z         = generalLocations[i].Z;
                    general[i].Heading   = generalLocations[i].Heading;

                    general[i].Realm           = eRealm.None;
                    general[i].CurrentRegionID = generalLocations[i].RegionID;
                    general[i].Size            = 49;
                    general[i].Level           = 2;

                    StandardMobBrain brain = new StandardMobBrain();
                    brain.AggroLevel = 80;
                    brain.AggroRange = 1000;
                    general[i].SetOwnBrain(brain);

                    if (SAVE_INTO_DATABASE)
                    {
                        general[i].SaveIntoDatabase();
                    }

                    general[i].AddToWorld();
                }
            }

            /*
             * TODO Model for Campfire doesn't work. Very Stange!
             */
            /*
             * // Add campfires to generals
             * for (int i = 0; i < generalLocations.Length; i++)
             * {
             *  GameStaticItem campfire = null;
             *
             *  IEnumerable items =  WorldMgr.GetItemsCloseToSpot(generalLocations[i].RegionID,generalLocations[i].X, generalLocations[i].Y, generalLocations[i].Z, 400,true);
             *  foreach (GameObject obj in items)
             *  {
             *      if (obj is GameStaticItem && obj.Name=="Camp Fire")
             *      {
             *          campfire= (GameStaticItem) obj;
             *          break;
             *      }
             *  }
             *
             *  if (campfire==null)
             *  {
             *      campfire = new GameStaticItem();
             *      campfire.Name="Camp Fire";
             *
             *      campfire.Model = 2593;
             *      campfire.Heading = generalLocations[i].Heading;
             *      campfire.X = generalLocations[i].X;
             *      campfire.Y = generalLocations[i].Y;
             *      campfire.Z = generalLocations[i].Z;
             *      campfire.CurrentRegionID = generalLocations[i].RegionID;
             *
             *      if (SAVE_INTO_DATABASE)
             *          campfire.SaveIntoDatabase();
             *
             *      campfire.AddToWorld();
             *
             *      DOLConsole.WriteLine("Camp Fire added"+generalNames[i]);
             *  }
             * }
             */

            askefruerWings = GameServer.Database.FindObjectByKey <ItemTemplate>("askefruer_wings");
            if (askefruerWings == null)
            {
                askefruerWings      = new ItemTemplate();
                askefruerWings.Name = "Wings of Askefruer";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + askefruerWings.Name + " , creating it ...");
                }

                askefruerWings.Weight = 2;
                askefruerWings.Model  = 551;

                askefruerWings.Object_Type = (int)eObjectType.GenericItem;

                askefruerWings.Id_nb      = "askefruer_wings";
                askefruerWings.IsPickable = true;
                askefruerWings.IsDropable = false;

                // You don't have to store the created item in the db if you don't want,
                // it will be recreated each time it is not found, just comment the following
                // line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(askefruerWings);
                }
            }

            dustyOldMap = GameServer.Database.FindObjectByKey <ItemTemplate>("dusty_old_map");
            if (dustyOldMap == null)
            {
                dustyOldMap      = new ItemTemplate();
                dustyOldMap.Name = "Dusty Old Map";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + dustyOldMap.Name + " , creating it ...");
                }

                dustyOldMap.Weight = 10;
                dustyOldMap.Model  = 498;

                dustyOldMap.Object_Type = (int)eObjectType.GenericItem;

                dustyOldMap.Id_nb      = "dusty_old_map";
                dustyOldMap.IsPickable = true;
                dustyOldMap.IsDropable = false;

                // You don't have to store the created item in the db if you don't want,
                // it will be recreated each time it is not found, just comment the following
                // line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(dustyOldMap);
                }
            }

            // item db check
            recruitsArms = GameServer.Database.FindObjectByKey <ItemTemplate>("recruits_studded_arms_mid");
            if (recruitsArms == null)
            {
                recruitsArms      = new ItemTemplate();
                recruitsArms.Name = "Recruit's Studded Arms (Mid)";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + recruitsArms.Name + ", creating it ...");
                }

                recruitsArms.Level = 7;

                recruitsArms.Weight = 36;
                recruitsArms.Model  = 83;  // studded Boots

                recruitsArms.DPS_AF  = 10; // Armour
                recruitsArms.SPD_ABS = 19; // Absorption

                recruitsArms.Object_Type = (int)eObjectType.Studded;
                recruitsArms.Item_Type   = (int)eEquipmentItems.ARMS;
                recruitsArms.Id_nb       = "recruits_studded_arms_mid";
                recruitsArms.Price       = Money.GetMoney(0, 0, 0, 4, 0);
                recruitsArms.IsPickable  = true;
                recruitsArms.IsDropable  = true;
                recruitsArms.Color       = 36; // blue cloth

                recruitsArms.Bonus = 5;        // default bonus

                recruitsArms.Bonus1     = 4;
                recruitsArms.Bonus1Type = (int)eStat.QUI;

                recruitsArms.Bonus2     = 1;
                recruitsArms.Bonus2Type = (int)eResist.Body;

                recruitsArms.Quality       = 100;
                recruitsArms.Condition     = 1000;
                recruitsArms.MaxCondition  = 1000;
                recruitsArms.Durability    = 1000;
                recruitsArms.MaxDurability = 1000;

                // You don't have to store the created item in the db if you don't want,
                // it will be recreated each time it is not found, just comment the following
                // line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(recruitsArms);
                }
            }

            recruitsSleeves = GameServer.Database.FindObjectByKey <ItemTemplate>("recruits_quilted_sleeves");
            if (recruitsSleeves == null)
            {
                recruitsSleeves      = new ItemTemplate();
                recruitsSleeves.Name = "Recruit's Quilted Sleeves";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + recruitsSleeves.Name + ", creating it ...");
                }

                recruitsSleeves.Level = 7;

                recruitsSleeves.Weight = 12;
                recruitsSleeves.Model  = 153;

                recruitsSleeves.DPS_AF  = 6; // Armour
                recruitsSleeves.SPD_ABS = 0; // Absorption

                recruitsSleeves.Object_Type = (int)eObjectType.Cloth;
                recruitsSleeves.Item_Type   = (int)eEquipmentItems.ARMS;
                recruitsSleeves.Id_nb       = "recruits_quilted_sleeves";
                recruitsSleeves.Price       = Money.GetMoney(0, 0, 0, 4, 0);
                recruitsSleeves.IsPickable  = true;
                recruitsSleeves.IsDropable  = true;
                recruitsSleeves.Color       = 27; // red cloth

                recruitsSleeves.Bonus = 5;        // default bonus

                recruitsSleeves.Bonus1     = 4;
                recruitsSleeves.Bonus1Type = (int)eStat.DEX;

                recruitsSleeves.Bonus2     = 1;
                recruitsSleeves.Bonus2Type = (int)eResist.Body;

                recruitsSleeves.Quality       = 100;
                recruitsSleeves.Condition     = 1000;
                recruitsSleeves.MaxCondition  = 1000;
                recruitsSleeves.Durability    = 1000;
                recruitsSleeves.MaxDurability = 1000;

                // You don't have to store the created item in the db if you don't want,
                // it will be recreated each time it is not found, just comment the following
                // line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(recruitsSleeves);
                }
            }

            /* Now we add some hooks to the npc we found.
             * Actually, we want to know when a player interacts with him.
             * So, we hook the right-click (interact) and the whisper method
             * of npc and set the callback method to the "TalkToXXX"
             * method. This means, the "TalkToXXX" method is called whenever
             * a player right clicks on him or when he whispers to him.
             */

            // We want to be notified whenever a player enters the world
            GameEventMgr.AddHandler(GamePlayerEvent.GameEntered, new DOLEventHandler(PlayerEnterWorld));

            GameEventMgr.AddHandler(dalikor, GameLivingEvent.Interact, new DOLEventHandler(TalkToDalikor));
            GameEventMgr.AddHandler(dalikor, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToDalikor));

            GameEventMgr.AddHandler(GamePlayerEvent.AcceptQuest, new DOLEventHandler(SubscribeQuest));
            GameEventMgr.AddHandler(GamePlayerEvent.DeclineQuest, new DOLEventHandler(SubscribeQuest));

            /* Now we bring to dalikor the possibility to give this quest to players */
            dalikor.AddQuestToGive(typeof(Collection));

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
        protected static bool PreloadLootOTDs()
        {
            lock (m_mobOTDList)
            {
                m_mobOTDList.Clear();
                IList <LootOTD> lootOTDs;

                try
                {
                    lootOTDs = GameServer.Database.SelectAllObjects <LootOTD>();
                }
                catch (Exception e)
                {
                    if (log.IsErrorEnabled)
                    {
                        log.Error("LootGeneratorOneTimeDrop: Drops could not be loaded:", e);
                    }

                    return(false);
                }

                if (lootOTDs != null && lootOTDs.Count > 0)
                {
                    int count = 0;

                    foreach (LootOTD l in lootOTDs)
                    {
                        IList <Mob> mobs = GameServer.Database.SelectObjects <Mob>("`Name` = @Name", new QueryParameter("@Name", l.MobName));

                        if (mobs == null || mobs.Count == 0)
                        {
                            log.ErrorFormat("Can't find MobName {0} for OTD {1}", l.MobName, l.ItemTemplateID);
                            continue;
                        }

                        ItemTemplate item = GameServer.Database.FindObjectByKey <ItemTemplate>(l.ItemTemplateID);

                        if (item == null)
                        {
                            log.ErrorFormat("Can't find ItemTemplate {0} for OTD MobName {1}", l.ItemTemplateID, l.MobName);
                            continue;
                        }

                        if (m_mobOTDList.ContainsKey(l.MobName.ToLower()))
                        {
                            List <LootOTD> drops = m_mobOTDList[l.MobName.ToLower()];

                            if (drops.Contains(l) == false)
                            {
                                drops.Add(l);
                                count++;
                            }
                            else
                            {
                                log.ErrorFormat("Same OTD ItemTemplate {0} specified multiple times for MobName {1}", l.ItemTemplateID, l.MobName);
                            }
                        }
                        else
                        {
                            List <LootOTD> drops = new List <LootOTD>();
                            drops.Add(l);
                            m_mobOTDList.Add(l.MobName.ToLower(), drops);
                            count++;
                        }
                    }

                    log.InfoFormat("One Time Drop generator pre-loaded {0} drops.", count);
                }
            }

            return(true);
        }
Beispiel #13
0
        /// <summary>
        /// Calculate the count per Object_Type
        /// </summary>
        public static int GetCountForSalvage(InventoryItem item, ItemTemplate rawMaterial)
        {
            long maxCount = 0;

            if (rawMaterial == null)
            {
                return(0);
            }

            #region Weapons

            switch ((eObjectType)item.Object_Type)
            {
            case eObjectType.RecurvedBow:
            case eObjectType.CompositeBow:
            case eObjectType.Longbow:
            case eObjectType.Crossbow:
            case eObjectType.Staff:
            case eObjectType.Fired:
                maxCount += 36;
                break;

            case eObjectType.Thrown:
            case eObjectType.CrushingWeapon:
            case eObjectType.SlashingWeapon:
            case eObjectType.ThrustWeapon:
            case eObjectType.Flexible:
            case eObjectType.Blades:
            case eObjectType.Blunt:
            case eObjectType.Piercing:
            case eObjectType.Sword:
            case eObjectType.Hammer:
            case eObjectType.LeftAxe:
            case eObjectType.Axe:
            case eObjectType.HandToHand:
            {
                int dps = item.DPS_AF;
                if (dps > 520)
                {
                    maxCount += 10;
                }
                else
                {
                    maxCount += 5;
                }
                break;
            }

            case eObjectType.TwoHandedWeapon:
            case eObjectType.PolearmWeapon:
            case eObjectType.LargeWeapons:
            case eObjectType.CelticSpear:
            case eObjectType.Scythe:
            case eObjectType.Spear:
            {
                int dps = item.DPS_AF;
                if (dps > 520)
                {
                    maxCount += 15;
                }
                else
                {
                    maxCount += 10;
                }
            }
            break;

            case eObjectType.Shield:
                switch (item.Type_Damage)
                {
                case 1:
                    maxCount += 5;
                    break;

                case 2:
                    maxCount += 8;
                    break;

                case 3:
                    maxCount += 12;
                    break;

                default:
                    maxCount += 5;
                    break;
                }
                break;

            case eObjectType.Instrument:
                switch (item.Type_Damage)
                {
                case 1:
                    maxCount += 5;
                    break;

                case 2:
                    maxCount += 8;
                    break;

                case 3:
                    maxCount += 12;
                    break;

                default:
                    maxCount += 5;
                    break;
                }
                break;

                #endregion Weapons

                #region Armor

            case eObjectType.Cloth:
            case eObjectType.Leather:
            case eObjectType.Reinforced:
            case eObjectType.Studded:
            case eObjectType.Scale:
            case eObjectType.Chain:
            case eObjectType.Plate:
                switch (item.Item_Type)
                {
                case Slot.HELM:
                    maxCount += 12;
                    break;

                case Slot.TORSO:
                    maxCount += 17;
                    break;

                case Slot.LEGS:
                    maxCount += 15;
                    break;

                case Slot.ARMS:
                    maxCount += 10;
                    break;

                case Slot.HANDS:
                    maxCount += 6;
                    break;

                case Slot.FEET:
                    maxCount += 5;
                    break;

                default:
                    maxCount += 5;
                    break;
                }
                break;
            }
            #endregion Armor

            #region Modifications

            if (maxCount < 1)
            {
                maxCount = (int)(item.Price * 0.45 / rawMaterial.Price);
            }

            int toadd = 0;

            if (item.Quality > 97 && !item.IsCrafted)
            {
                for (int i = 97; i < item.Quality;)
                {
                    toadd += 3;
                    i++;
                }
            }

            if (item.Price > 300000 && !item.IsCrafted)
            {
                long i = item.Price / 100000;
                toadd += (int)i;
            }

            if (toadd > 0)
            {
                maxCount += toadd;
            }

            #region SpecialFix MerchantList

            if (item.Bonus8 > 0)
            {
                if (item.Bonus8Type == 0 || item.Bonus8Type.ToString() == "")
                {
                    maxCount = item.Bonus8;
                }
            }

            #endregion SpecialFix MerchantList

            if (item.Condition != item.MaxCondition && item.Condition < item.MaxCondition)
            {
                long usureoverall = (maxCount * ((item.Condition / 5) / 1000)) / 100; // assume that all items have 50000 base con
                maxCount = usureoverall;
            }

            if (maxCount < 1)
            {
                maxCount = 1;
            }
            else if (maxCount > 500)
            {
                maxCount = 500;
            }

            #endregion Modifications

            return((int)maxCount);
        }
 public GoldenSpearJavelin(GameLiving caster, Spell spell, SpellLine line)
     : base(caster, spell, line)
 {
     _artefJavelin = GameServer.Database.FindObjectByKey<ItemTemplate>("Artef_Javelin") ?? Javelin;
     items.Add (GameInventoryItem.Create(_artefJavelin));
 }
        /// <summary>
        /// Generate loot for given mob
        /// </summary>
        /// <param name="mob"></param>
        /// <param name="killer"></param>
        /// <returns></returns>
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            try
            {
                GamePlayer player = killer as GamePlayer;
                if (killer is GameNPC && ((GameNPC)killer).Brain is IControlledBrain)
                {
                    player = ((ControlledNpcBrain)((GameNPC)killer).Brain).GetPlayerOwner();
                }
                if (player == null)
                {
                    return(loot);
                }


                ItemTemplate dragonscales = new ItemTemplate(m_dragonscales);

                int killedcon = (int)player.GetConLevel(mob) + 3;

                if (killedcon <= 0)
                {
                    return(loot);
                }

                int lvl = mob.Level + 1;
                if (lvl < 1)
                {
                    lvl = 1;
                }
                int maxcount = 1;

                //Switch pack size
                if (lvl > 0 && lvl < 10)
                {
                    //Single Dragonscales
                    maxcount = (int)Math.Floor((double)(lvl / 2)) + 1;
                }
                else if (lvl >= 10 && lvl < 20)
                {
                    //Double
                    dragonscales.PackSize = 2;
                    maxcount = (int)Math.Floor((double)((lvl - 10) / 2)) + 1;
                }
                else if (lvl >= 20 && lvl < 30)
                {
                    //Triple
                    dragonscales.PackSize = 3;
                    maxcount = (int)Math.Floor((double)((lvl - 20) / 2)) + 1;
                }
                else if (lvl >= 30 && lvl < 40)
                {
                    //Quad
                    dragonscales.PackSize = 4;
                    maxcount = (int)Math.Floor((double)((lvl - 30) / 2)) + 1;
                }
                else if (lvl >= 40 && lvl < 50)
                {
                    //Quint
                    dragonscales.PackSize = 5;
                    maxcount = (int)Math.Floor((double)((lvl - 40) / 2)) + 1;
                }
                else
                {
                    //Cache (x10)
                    dragonscales.PackSize = 10;
                    maxcount = (int)Math.Round((double)(lvl / 10));
                }

                if (!mob.Name.ToLower().Equals(mob.Name))
                {
                    //Named mob, more cash !
                    maxcount = (int)Math.Round(maxcount * ServerProperties.Properties.LOOTGENERATOR_DRAGONSCALES_NAMED_COUNT);
                }

                if (maxcount > 0 && Util.Chance(ServerProperties.Properties.LOOTGENERATOR_DRAGONSCALES_BASE_CHANCE + Math.Max(10, killedcon)))
                {
                    loot.AddFixed(dragonscales, maxcount);
                }
            }
            catch
            {
                return(loot);
            }

            return(loot);
        }
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList       loot     = base.GenerateLoot(mob, killer);
            List <LootOTD> lootOTDs = null;

            try
            {
                if (m_mobOTDList.ContainsKey(mob.Name.ToLower()))
                {
                    lootOTDs = m_mobOTDList[mob.Name.ToLower()];
                }

                if (lootOTDs != null)
                {
                    foreach (GameObject gainer in mob.XPGainers.Keys)
                    {
                        GamePlayer player = null;

                        if (gainer is GamePlayer)
                        {
                            player = gainer as GamePlayer;
                        }
                        else if (gainer is GameNPC)
                        {
                            IControlledBrain brain = ((GameNPC)gainer).Brain as IControlledBrain;
                            if (brain != null)
                            {
                                player = brain.GetPlayerOwner();
                            }
                        }

                        if (player != null)
                        {
                            foreach (LootOTD drop in lootOTDs)
                            {
                                if (drop.MinLevel <= player.Level)
                                {
                                    CharacterXOneTimeDrop hasDrop = GameServer.Database.SelectObjects <CharacterXOneTimeDrop>("`CharacterID` = @CharacterID AND `ItemTemplateID` = @ItemTemplateID", new [] { new QueryParameter("@CharacterID", player.QuestPlayerID), new QueryParameter("@ItemTemplateID", drop.ItemTemplateID) }).FirstOrDefault();

                                    if (hasDrop == null)
                                    {
                                        ItemTemplate item = GameServer.Database.FindObjectByKey <ItemTemplate>(drop.ItemTemplateID);

                                        if (item != null)
                                        {
                                            if (player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, GameInventoryItem.Create(item)))
                                            {
                                                CharacterXOneTimeDrop charXDrop = new CharacterXOneTimeDrop();
                                                charXDrop.CharacterID    = player.QuestPlayerID;
                                                charXDrop.ItemTemplateID = drop.ItemTemplateID;
                                                GameServer.Database.AddObject(charXDrop);

                                                player.Out.SendMessage(string.Format("You receive {0} from {1}!", item.GetName(1, false), mob.GetName(1, false)), eChatType.CT_Loot, eChatLoc.CL_SystemWindow);
                                                InventoryLogging.LogInventoryAction(mob, player, eInventoryActionType.Loot, item);
                                            }
                                            else
                                            {
                                                // do not drop, player will have to try again
                                                player.Out.SendMessage("Your inventory is full and a one time drop cannot be added!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                                                log.DebugFormat("OTD Failed, Inventory full: {0} from mob {1} for player {2}.", drop.ItemTemplateID, drop.MobName, player.Name);
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            log.ErrorFormat("Error trying to drop ItemTemplate {0} from {1}.  Item not found.", drop.ItemTemplateID, drop.MobName);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("LootGeneratorOneTimeDrop exception for mob " + mob.Name + ":", ex);
            }

            return(loot);
        }
        /// <summary>
        /// Check if the player has enough secondary crafting skill to build the item
        /// </summary>
        /// <param name="player"></param>
        /// <param name="recipe"></param>
        /// <returns></returns>
        public virtual bool CheckSecondCraftingSkillRequirement(GamePlayer player, DBCraftedItem recipe, ItemTemplate itemToCraft, IList <DBCraftedXItem> rawMaterials)
        {
            int minimumLevel = GetSecondaryCraftingSkillMinimumLevel(recipe, itemToCraft);

            if (minimumLevel <= 0)
            {
                return(true);                // no requirement needed
            }
            foreach (DBCraftedXItem material in rawMaterials)
            {
                ItemTemplate template = GameServer.Database.FindObjectByKey <ItemTemplate>(material.IngredientId_nb);

                if (template == null)
                {
                    player.Out.SendMessage("Can't find a material (" + material.IngredientId_nb + ") needed for recipe.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    log.Error("Cannot find raw material ItemTemplate: " + material.IngredientId_nb + ") needed for recipe: " + recipe.CraftedItemID);
                    return(false);
                }

                switch (template.Model)
                {
                case 522:                               //"cloth square"
                case 537:                               //"heavy thread"
                {
                    if (player.GetCraftingSkillValue(eCraftingSkill.ClothWorking) < minimumLevel)
                    {
                        player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.CheckSecondCraftingSkillRequirement.NoClothworkingSkill", minimumLevel, template.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return(false);
                    }
                    break;
                }

                case 521:                               //"leather square"
                {
                    if (player.GetCraftingSkillValue(eCraftingSkill.LeatherCrafting) < minimumLevel)
                    {
                        player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.CheckSecondCraftingSkillRequirement.NoLeathercraftingSkill", minimumLevel, template.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return(false);
                    }
                    break;
                }

                case 519:                               //"metal bars"
                {
                    if (player.GetCraftingSkillValue(eCraftingSkill.MetalWorking) < minimumLevel)
                    {
                        player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.CheckSecondCraftingSkillRequirement.NoMetalworkingSkill", minimumLevel, template.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return(false);
                    }
                    break;
                }

                case 520:                               //"wooden boards"
                {
                    if (player.GetCraftingSkillValue(eCraftingSkill.WoodWorking) < minimumLevel)
                    {
                        player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.CheckSecondCraftingSkillRequirement.NoWoodworkingSkill", minimumLevel, template.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return(false);
                    }
                    break;
                }
                }
            }
            return(true);
        }
 /// <summary>
 /// Check if the player is near the needed tools (forge, lathe, etc)
 /// </summary>
 /// <param name="player">the crafting player</param>
 /// <param name="recipe">the recipe being used</param>
 /// <param name="itemToCraft">the item to make</param>
 /// <param name="rawMaterials">a list of raw materials needed to create this item</param>
 /// <returns>true if required tools are found</returns>
 protected virtual bool CheckForTools(GamePlayer player, DBCraftedItem recipe, ItemTemplate itemToCraft, IList <DBCraftedXItem> rawMaterials)
 {
     return(true);
 }
        protected virtual bool CanPlayerStartToCraftItem(GamePlayer player, DBCraftedItem recipe, ItemTemplate itemToCraft, IList <DBCraftedXItem> rawMaterials)
        {
            if (!GameServer.ServerRules.IsAllowedToCraft(player, itemToCraft))
            {
                return(false);
            }

            if (!CheckForTools(player, recipe, itemToCraft, rawMaterials))
            {
                return(false);
            }

            if (!CheckSecondCraftingSkillRequirement(player, recipe, itemToCraft, rawMaterials))
            {
                return(false);
            }

            if (!CheckRawMaterials(player, recipe, itemToCraft, rawMaterials))
            {
                return(false);
            }

            if (player.IsMoving || player.IsStrafing)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.CraftItem.MoveAndInterrupt"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            if (player.InCombat)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.CraftItem.CantCraftInCombat"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(false);
            }

            return(true);
        }
 protected virtual void StopCraftingCurrentItem(GamePlayer player, ItemTemplate itemToCraft)
 {
     player.CraftTimer.Stop();
     player.Out.SendCloseTimerWindow();
     player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.CraftItem.StopWork", itemToCraft.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
 }
    void UpdateUI()
    {
        mStrenthObj.SetActive(false);

        //刷新右上角消耗显示;
        long count1 = 0;

        ObjectSelf.GetInstance().TryGetResourceCountById(1400000002, ref count1);
        mCostTxt1.text = count1.ToString();

        ItemTemplate itemT      = ItemEquipInfo.GetItemRowData();
        int          strengthLv = ItemEquipInfo.GetStrenghLevel();

        //是否是特殊符文;
        EM_RUNE_TYPE runeType = (EM_RUNE_TYPE)itemT.getRune_type();
        bool         isUnique = runeType == EM_RUNE_TYPE.EM_RUNE_TYPE_SPECIAL || runeType == EM_RUNE_TYPE.EM_RUNE_TYPE_SPECIAL_UNIQUE;

        mStrenthBtn[0].gameObject.SetActive(!isUnique);
        mStrenthBtn[1].gameObject.SetActive(isUnique);
        mCloseBtn[0].gameObject.SetActive(!isUnique);
        mCloseBtn[1].gameObject.SetActive(isUnique);


        //判断符文是否满级了;
        bool isFullLv = DataTemplate.GetInstance().IsRuneStrenthFullLevel(itemT, strengthLv);

        mRuneObj[0].SetActive(!isFullLv);
        mRuneObj[1].SetActive(!isFullLv);
        mRuneObj[2].SetActive(isFullLv);

        if (isFullLv)
        {
            //mStrenthRuneItem[i].SetIsSpecial(isUnique);
            RuneItemCommonData ricd = new RuneItemCommonData();
            ricd.IsShowMaxEffect = true;
            ricd.ItemT           = itemT;
            ricd.RuneLevel       = strengthLv;
            ricd.EquipedHeroName = RuneModule.GetItemEuipHeroName(ItemEquipInfo);
            mItemCommons[2].SetRuneItemData(ricd, RuneItemCommon.RuneItemShowType.IconWithRightName);
        }
        else
        {
            RuneItemCommonData ricd = new RuneItemCommonData();
            ricd.IsShowMaxEffect = true;
            ricd.ItemT           = itemT;
            ricd.RuneLevel       = strengthLv;
            ricd.EquipedHeroName = RuneModule.GetItemEuipHeroName(ItemEquipInfo);
            mItemCommons[0].SetRuneItemData(ricd, RuneItemCommon.RuneItemShowType.IconWithRightName);

            RuneItemCommonData ricd1 = new RuneItemCommonData();
            ricd1.IsShowMaxEffect = true;
            ricd1.ItemT           = itemT;
            ricd1.RuneLevel       = strengthLv + 1;
            ricd1.EquipedHeroName = RuneModule.GetItemEuipHeroName(ItemEquipInfo);
            mItemCommons[1].SetRuneItemData(ricd1, RuneItemCommon.RuneItemShowType.IconWithRightName);
        }

        mCostObj[0].SetActive(!isFullLv);
        mCostObj[1].SetActive(!isFullLv);

        GameUtils.SetBtnSpriteGrayState(mStrenthBtn[0], isFullLv);
        GameUtils.SetBtnSpriteGrayState(mStrenthBtn[1], isFullLv);

        mStrenthFullObj1.SetActive(isFullLv);
        mStrenthFullObj2.SetActive(isFullLv);

        if (isFullLv)
        {
        }
        else // 没满级判断资源消耗;
        {
            if (isUnique)
            {
                mStrenthTitleTxt.text = GameUtils.getString("rune_title2");

                //消耗资源处刷新;
                RunecostTemplate rt = DataTemplate.GetInstance().GetRuneCostTemplate(itemT.getRune_strengthenId(), strengthLv + 1);

                if (rt.getAttriType1() == 1400000002)//是金币;
                {
                    long countTmp = 0;
                    ObjectSelf.GetInstance().TryGetResourceCountById(rt.getAttriType1(), ref countTmp);
                    mCost2Txt1.text = countTmp.ToString();
                    ObjectSelf.GetInstance().TryGetResourceCountById(rt.getAttriType2(), ref countTmp);
                    mCost2Txt2.text = countTmp.ToString();

                    TEXT_COLOR tc = countTmp >= rt.getAttriValue2() ? TEXT_COLOR.WHITE : TEXT_COLOR.RED;
                    mCostItemCountTxt.text = GameUtils.StringWithColor(rt.getAttriValue2().ToString(), tc);
                    tc = ObjectSelf.GetInstance().Money >= rt.getAttriValue1() ? TEXT_COLOR.WHITE : TEXT_COLOR.RED;
                    mCostGoldTxt[1].text = GameUtils.StringWithColor(rt.getAttriValue1().ToString(), tc);
                }
                else//不是金币;
                {
                    long countTmp = 0;
                    ObjectSelf.GetInstance().TryGetResourceCountById(rt.getAttriType2(), ref countTmp);
                    mCost2Txt1.text = countTmp.ToString();
                    ObjectSelf.GetInstance().TryGetResourceCountById(rt.getAttriType1(), ref countTmp);
                    mCost2Txt2.text = countTmp.ToString();

                    TEXT_COLOR tc = countTmp >= rt.getAttriValue1() ? TEXT_COLOR.WHITE : TEXT_COLOR.RED;
                    mCostItemCountTxt.text = GameUtils.StringWithColor(rt.getAttriValue1().ToString(), tc);
                    tc = ObjectSelf.GetInstance().Money >= rt.getAttriValue2() ? TEXT_COLOR.WHITE : TEXT_COLOR.RED;
                    mCostGoldTxt[1].text = GameUtils.StringWithColor(rt.getAttriValue2().ToString(), tc);
                }

                mNorCostItemImg.sprite  = GameUtils.GetSpriteByResourceType(rt.getAttriType1());
                mSpecCostItemImg.sprite = GameUtils.GetSpriteByResourceType(rt.getAttriType2());

                mCostGoldImg.sprite = GameUtils.GetSpriteByResourceType(rt.getAttriType1());
                mCost2Img1.sprite   = GameUtils.GetSpriteByResourceType(rt.getAttriType1());
                mCost2Img2.sprite   = GameUtils.GetSpriteByResourceType(rt.getAttriType2());

                mCostObj1.SetActive(false);
                mCostObj2.SetActive(true);
            }
            else
            {
                mStrenthTitleTxt.text = GameUtils.getString("rune_title1");

                RunecostTemplate rt = DataTemplate.GetInstance().GetRuneCostTemplate(itemT.getRune_strengthenId(), strengthLv + 1);

                if (rt.getAttriType1() == 1400000002)//是金币;
                {
                    TEXT_COLOR tc = ObjectSelf.GetInstance().Money >= rt.getAttriValue1() ? TEXT_COLOR.WHITE : TEXT_COLOR.RED;
                    mCostGoldTxt[0].text = GameUtils.StringWithColor(rt.getAttriValue1().ToString(), tc);
                }
                else//不是金币;
                {
                    TEXT_COLOR tc = ObjectSelf.GetInstance().Money >= rt.getAttriValue2() ? TEXT_COLOR.WHITE : TEXT_COLOR.RED;
                    mCostGoldTxt[0].text = GameUtils.StringWithColor(rt.getAttriValue2().ToString(), tc);
                }

                mCostObj1.SetActive(true);
                mCostObj2.SetActive(false);
            }
        }

        mStrenthBtn[0].GetComponent <Button>().enabled = true;
        mStrenthBtn[1].GetComponent <Button>().enabled = true;

        //RuneData runeData = ItemEquipInfo.GetRuneData();
        ////基础属性;
        //bool titleDone1 = false;
        //foreach (int id in runeData.BaseAttributeID)
        //{
        //    if (id == -1)
        //        continue;

        //    if (!titleDone1)
        //    {
        //        titleDone1 = true;
        //        if (isFullLv)
        //        {
        //            CreateTitle(mDetailTransPos[2], GameUtils.getString("hero_rune_content8"));
        //        }
        //        else
        //        {
        //            CreateTitle(mDetailTransPos[0], GameUtils.getString("hero_rune_content8"));
        //            CreateTitle(mDetailTransPos[1], GameUtils.getString("hero_rune_content8"));
        //        }
        //    }

        //    BaseruneattributeTemplate bt1 = DataTemplate.GetInstance().GetBaseruneattributeTemplate(id);
        //    if (isFullLv)
        //    {
        //        if (bt1.getNumshow() == 0)
        //        {
        //            //CreateTitle(mAttriList[2], GameUtils.getString(bt1.getAttriDes()));
        //            CreateDetailTxts(mDetailTransPos[2], GameUtils.getString(bt1.getAttriDes()));
        //        }
        //        else
        //        {
        //            CreateBaseAttriObj(mDetailTransPos[2], GameUtils.getString(bt1.getAttriDes()), "+" + bt1.getAttriValue().ToString());
        //        }
        //        //CreateBaseAttriObj(mAttriList[2], GameUtils.GetAttriName(bt1.getAttriType()), "+" + bt1.getAttriValue().ToString());
        //    }
        //    else
        //    {
        //        if (bt1.getNumshow() == 0)
        //        {
        //            //CreateTitle(mAttriList[0], GameUtils.getString(bt1.getAttriDes()));
        //            CreateDetailTxts(mDetailTransPos[0], GameUtils.getString(bt1.getAttriDes()));
        //        }
        //        else
        //        {
        //            CreateBaseAttriObj(mDetailTransPos[0], GameUtils.getString(bt1.getAttriDes()), "+" + bt1.getAttriValue().ToString());
        //        }
        //        //CreateBaseAttriObj(mAttriList[0], GameUtils.GetAttriName(bt1.getAttriType()), "+" + bt1.getAttriValue().ToString());
        //        BaseruneattributeTemplate bt2 = DataTemplate.GetInstance().GetBaseruneattributeTemplate(id + 1);
        //        if (bt2.getNumshow() == 0)
        //        {
        //            //CreateTitle(mAttriList[1], GameUtils.getString(bt2.getAttriDes()));
        //            CreateDetailTxts(mDetailTransPos[1], GameUtils.getString(bt2.getAttriDes()));
        //        }
        //        else
        //        {
        //            CreateBaseAttriObj(mDetailTransPos[1], GameUtils.getString(bt2.getAttriDes()), "+" + bt2.getAttriValue().ToString());
        //        }
        //        //CreateBaseAttriObj(mAttriList[1], GameUtils.GetAttriName(bt2.getAttriType()), "+" + bt2.getAttriValue().ToString());
        //    }
        //}

        ////附加属性;
        //bool titleDone2 = false;
        //int count = DataTemplate.GetInstance().GetRuneMaxRedefineTimes(itemT);
        //int m = 0;
        //bool curIsGray = false, nextIsGray = false;

        //foreach (int id in runeData.AppendAttribute)
        //{
        //    m++;

        //    curIsGray = m * 3 > strengthLv;
        //    nextIsGray = m * 3 > strengthLv + 1;

        //    if (id == -1)
        //    {
        //        if (m <= count)
        //        {
        //            if (!titleDone2)
        //            {
        //                titleDone2 = true;

        //                if (isFullLv)
        //                {
        //                    CreateTitle(mDetailTransPos[2], GameUtils.getString("hero_rune_content9"));
        //                }
        //                else
        //                {
        //                    CreateTitle(mDetailTransPos[0], GameUtils.getString("hero_rune_content9"));
        //                    CreateTitle(mDetailTransPos[1], GameUtils.getString("hero_rune_content9"));
        //                }
        //            }

        //            //位置属性,未鉴定;
        //            if (isFullLv)
        //            {
        //                CreateAddAttriObj(mDetailTransPos[2], GameUtils.getString("rune_content2"), "", GameUtils.getString("rune_content3"), curIsGray);
        //            }
        //            else
        //            {
        //                CreateAddAttriObj(mDetailTransPos[0], GameUtils.getString("rune_content2"), "", GameUtils.getString("rune_content3"), curIsGray);
        //                CreateAddAttriObj(mDetailTransPos[1], GameUtils.getString("rune_content2"), "", GameUtils.getString("rune_content3"), nextIsGray);
        //            }
        //        }

        //        continue;
        //    }

        //    if (!titleDone2)
        //    {
        //        titleDone2 = true;
        //        if (isFullLv)
        //        {
        //            CreateTitle(mDetailTransPos[2], GameUtils.getString("hero_rune_content9"));
        //        }
        //        else
        //        {
        //            CreateTitle(mDetailTransPos[0], GameUtils.getString("hero_rune_content9"));
        //            CreateTitle(mDetailTransPos[1], GameUtils.getString("hero_rune_content9"));
        //        }
        //    }

        //    AddruneattributeTemplate bt = DataTemplate.GetInstance().GetAddruneattributeTemplate(id);
        //    bool isPercent = bt.getIspercentage() > 0;
        //    string val = isPercent ? ((float)bt.getAttriValue() / (float)10f + "%") : bt.getAttriValue().ToString();
        //    if (isFullLv)
        //    {
        //        CreateAddAttriObj(mDetailTransPos[2], GameUtils.getString(bt.getAttriDes1()), GameUtils.getString(bt.getAttriDes2()), bt.getSymbol() + val, curIsGray);
        //    }
        //    else
        //    {
        //        CreateAddAttriObj(mDetailTransPos[0], GameUtils.getString(bt.getAttriDes1()), GameUtils.getString(bt.getAttriDes2()), bt.getSymbol() + val, curIsGray);
        //        CreateAddAttriObj(mDetailTransPos[1], GameUtils.getString(bt.getAttriDes1()), GameUtils.getString(bt.getAttriDes2()), bt.getSymbol() + val, nextIsGray);
        //    }
        //}
    }
Beispiel #22
0
        static bool HandleSendItemsCommand(StringArguments args, CommandHandler handler)
        {
            // format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12]
            Player     receiver;
            ObjectGuid receiverGuid;
            string     receiverName;

            if (!handler.ExtractPlayerTarget(args, out receiver, out receiverGuid, out receiverName))
            {
                return(false);
            }

            string tail1 = args.NextString("");

            if (string.IsNullOrEmpty(tail1))
            {
                return(false);
            }

            string subject = handler.ExtractQuotedArg(tail1);

            if (string.IsNullOrEmpty(subject))
            {
                return(false);
            }

            string tail2 = args.NextString("");

            if (string.IsNullOrEmpty(tail2))
            {
                return(false);
            }

            string text = handler.ExtractQuotedArg(tail2);

            if (string.IsNullOrEmpty(text))
            {
                return(false);
            }

            // extract items
            List <KeyValuePair <uint, uint> > items = new List <KeyValuePair <uint, uint> >();

            // get all tail string
            StringArguments tail = new StringArguments(args.NextString(""));

            // get from tail next item str
            StringArguments itemStr;

            while (!(itemStr = new StringArguments(tail.NextString(" "))).Empty())
            {
                // parse item str
                string itemIdStr    = itemStr.NextString(":");
                string itemCountStr = itemStr.NextString(" ");

                if (!uint.TryParse(itemIdStr, out uint itemId) || itemId == 0)
                {
                    return(false);
                }

                ItemTemplate item_proto = Global.ObjectMgr.GetItemTemplate(itemId);
                if (item_proto == null)
                {
                    handler.SendSysMessage(CypherStrings.CommandItemidinvalid, itemId);
                    return(false);
                }

                uint itemCount = 0;
                if (string.IsNullOrEmpty(itemCountStr) || !uint.TryParse(itemCountStr, out itemCount))
                {
                    itemCount = 1;
                }

                if (itemCount < 1 || (item_proto.GetMaxCount() > 0 && itemCount > item_proto.GetMaxCount()))
                {
                    handler.SendSysMessage(CypherStrings.CommandInvalidItemCount, itemCount, itemId);
                    return(false);
                }

                while (itemCount > item_proto.GetMaxStackSize())
                {
                    items.Add(new KeyValuePair <uint, uint>(itemId, item_proto.GetMaxStackSize()));
                    itemCount -= item_proto.GetMaxStackSize();
                }

                items.Add(new KeyValuePair <uint, uint>(itemId, itemCount));

                if (items.Count > SharedConst.MaxMailItems)
                {
                    handler.SendSysMessage(CypherStrings.CommandMailItemsLimit, SharedConst.MaxMailItems);
                    return(false);
                }
            }

            // from console show not existed sender
            MailSender sender = new MailSender(MailMessageType.Normal, handler.GetSession() ? handler.GetSession().GetPlayer().GetGUID().GetCounter() : 0, MailStationery.Gm);

            // fill mail
            MailDraft draft = new MailDraft(subject, text);

            SQLTransaction trans = new SQLTransaction();

            foreach (var pair in items)
            {
                Item item = Item.CreateItem(pair.Key, pair.Value, ItemContext.None, handler.GetSession() ? handler.GetSession().GetPlayer() : null);
                if (item)
                {
                    item.SaveToDB(trans);                               // save for prevent lost at next mail load, if send fail then item will deleted
                    draft.AddItem(item);
                }
            }

            draft.SendMailTo(trans, new MailReceiver(receiver, receiverGuid.GetCounter()), sender);
            DB.Characters.CommitTransaction(trans);

            string nameLink = handler.PlayerLink(receiverName);

            handler.SendSysMessage(CypherStrings.MailSent, nameLink);
            return(true);
        }
 protected override DependencyObject GetContainerForItemOverride()
 {
     return(ItemTemplate?.LoadContent() ?? base.GetContainerForItemOverride());
 }
Beispiel #24
0
		public static uint GetRandomSuffixFactor(ItemTemplate template)
		{
			var suffixCat = GetSuffixCategory(template);
			if (suffixCat >= ItemSuffixCategory.None)
			{
				return 0;
			}

			var levelInfo = ItemMgr.GetLevelInfo(template.Level);
			if (levelInfo != null)
			{
				switch (template.Quality)
				{
					case ItemQuality.Uncommon:
						return levelInfo.UncommonPoints[(uint)suffixCat];
					case ItemQuality.Rare:
						return levelInfo.RarePoints[(uint)suffixCat];
					case ItemQuality.Epic:
					case ItemQuality.Legendary:
					case ItemQuality.Artifact:
						return levelInfo.EpicPoints[(uint)suffixCat];
				}
			}
			return 0;
		}
        /// <summary>
        /// Verify that player has the needed materials to craft an item
        /// </summary>
        public virtual bool CheckRawMaterials(GamePlayer player, DBCraftedItem recipe, ItemTemplate itemToCraft, IList <DBCraftedXItem> rawMaterials)
        {
            ArrayList missingMaterials = null;

            lock (player.Inventory)
            {
                foreach (DBCraftedXItem material in rawMaterials)
                {
                    ItemTemplate template = GameServer.Database.FindObjectByKey <ItemTemplate>(material.IngredientId_nb);

                    if (template == null)
                    {
                        player.Out.SendMessage("Can't find a material (" + material.IngredientId_nb + ") needed for this recipe.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        log.Error("Cannot find raw material ItemTemplate: " + material.IngredientId_nb + ") needed for recipe: " + recipe.CraftedItemID);
                        return(false);
                    }

                    bool result = false;
                    int  count  = material.Count;

                    foreach (InventoryItem item in player.Inventory.GetItemRange(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
                    {
                        if (item != null && item.Name == template.Name)
                        {
                            if (item.Count >= count)
                            {
                                result = true;
                                break;
                            }
                            else
                            {
                                count -= item.Count;
                            }
                        }
                    }

                    if (result == false)
                    {
                        if (missingMaterials == null)
                        {
                            missingMaterials = new ArrayList(5);
                        }

                        missingMaterials.Add("(" + count + ") " + template.Name);
                    }
                }

                if (missingMaterials != null)
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.CheckRawMaterial.NoIngredients", itemToCraft.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.CheckRawMaterial.YouAreMissing", itemToCraft.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                    foreach (string materialName in missingMaterials)
                    {
                        player.Out.SendMessage(materialName, eChatType.CT_Important, eChatLoc.CL_ChatWindow);
                    }

                    if (player.Client.Account.PrivLevel == (uint)ePrivLevel.Player)
                    {
                        return(false);
                    }
                }

                return(true);
            }
        }
        /// <summary>
        /// Remove used raw material from player inventory
        /// </summary>
        /// <param name="player"></param>
        /// <param name="recipe"></param>
        /// <returns></returns>
        public virtual bool RemoveUsedMaterials(GamePlayer player, DBCraftedItem recipe, IList <DBCraftedXItem> rawMaterials)
        {
            Dictionary <int, int?> dataSlots = new Dictionary <int, int?>(10);

            lock (player.Inventory)
            {
                foreach (DBCraftedXItem material in rawMaterials)
                {
                    ItemTemplate template = GameServer.Database.FindObjectByKey <ItemTemplate>(material.IngredientId_nb);

                    if (template == null)
                    {
                        player.Out.SendMessage("Can't find a material (" + material.IngredientId_nb + ") needed for this recipe.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        log.Error("RemoveUsedMaterials: Cannot find raw material ItemTemplate: " + material.IngredientId_nb + " needed for recipe: " + recipe.CraftedItemID);
                        return(false);
                    }

                    bool result = false;
                    int  count  = material.Count;

                    foreach (InventoryItem item in player.Inventory.GetItemRange(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
                    {
                        if (item != null && item.Name == template.Name)
                        {
                            if (item.Count >= count)
                            {
                                if (item.Count == count)
                                {
                                    dataSlots.Add(item.SlotPosition, null);
                                }
                                else
                                {
                                    dataSlots.Add(item.SlotPosition, count);
                                }
                                result = true;
                                break;
                            }
                            else
                            {
                                dataSlots.Add(item.SlotPosition, null);
                                count -= item.Count;
                            }
                        }
                    }
                    if (result == false)
                    {
                        return(false);
                    }
                }
            }

            player.Inventory.BeginChanges();
            Dictionary <int, int?> .Enumerator enumerator = dataSlots.GetEnumerator();
            while (enumerator.MoveNext())
            {
                KeyValuePair <int, int?> de   = enumerator.Current;
                InventoryItem            item = player.Inventory.GetItem((eInventorySlot)de.Key);
                if (item != null)
                {
                    if (!de.Value.HasValue)
                    {
                        player.Inventory.RemoveItem(item);
                    }
                    else
                    {
                        player.Inventory.RemoveCountFromStack(item, de.Value.Value);
                    }
                    InventoryLogging.LogInventoryAction(player, "(craft)", eInventoryActionType.Craft, item.Template, de.Value.HasValue ? de.Value.Value : item.Count);
                }
            }
            player.Inventory.CommitChanges();

            return(true);           //all raw material removed and item created
        }
Beispiel #27
0
 public bool IsFull(ItemTemplate item, int count)
 {
     return((Weight + (item.RealWeight * count)) > WeightTotal && WeightEnabled);
 }
Beispiel #28
0
        public ItemSelectorPage()
        {
            InitializeComponent();

            nav = DependencyService.Get <INavigation>(DependencyFetchTarget.GlobalInstance);


            this.BindingContext = this;

            selectButton.Clicked += async(s, e) => {
                if (valueSelected)
                {
                    return;
                }
                valueSelected = true;
                INavigation nav = DependencyService.Get <INavigation>(DependencyFetchTarget.GlobalInstance);
                await nav.PopModalAsync();

                CompletionSource.SetResult(SelectedItem);
            };

            cancelButton.Clicked += async(s, e) => {
                if (valueSelected)
                {
                    return;
                }
                valueSelected = true;
                await nav.PopModalAsync();

                CompletionSource.SetResult(previousSelection);
            };

            searchBar.TextChanged += (s, e) => {
                FilterItems();
            };

            Device.BeginInvokeOnMainThread(async() => {
                await Task.Delay(1);
                FilterItems();
                previousSelection = SelectedItem;
                if (ItemTemplate != null)
                {
                    listView.ItemTemplate = new DataTemplate(() =>
                    {
                        var c = ItemTemplate.CreateContent() as View;
                        return(new ViewCell {
                            View = c
                        });
                    });
                }


                /* we don't want to look for ItemSelected event immediately
                 * because SelectedItem is set by binding framework after initialization,
                 * there is no way to detect human selection over default selection*/
                await Task.Delay(100);



                listView.ItemSelected += async(s, e) => {
                    if (valueSelected)
                    {
                        return;
                    }
                    valueSelected = true;
                    // delay to display little animation...
                    await Task.Delay(500);
                    await nav.PopModalAsync(true);
                    CompletionSource.SetResult(e.SelectedItem);
                };
            });

            if (AddNew != null)
            {
                selectButton.IsVisible = true;
                Grid.SetColumnSpan(cancelButton, 1);
            }
            else
            {
                selectButton.IsVisible = false;
                Grid.SetColumnSpan(cancelButton, 2);
            }
        }
Beispiel #29
0
        private void UpdateSwipeFrameLayout()
        {
            var content = ItemTemplate.CreateContent();
            var view    = content as Xamarin.Forms.View;

            if (view == null)
            {
                throw new InvalidOperationException($"DataTemplate returned non-view content: '{content}'.");
            }

            view.Parent = this;

            int index = 0;

            foreach (var item in _itemSource)
            {
                if (index.Equals(SelectedIndex))
                {
                    view.BindingContext = item;
                    break;
                }
                ++index;
            }

            Children.RemoveAt(1);
            _tabLayout            = new SwipeFrame();
            _tabLayout.SwipeLeft += (sender, e) =>
            {
                if ((SelectedIndex + 1).Equals(_count))
                {
                    return;                    //SelectedIndex = 0;
                }
                SelectedIndex++;
            };
            _tabLayout.SwipeRight += (sender, e) =>
            {
                if ((SelectedIndex - 1) < 0)
                {
                    return;                     // SelectedIndex = _count;
                }
                SelectedIndex--;
            };
            _tabLayout.Content = view;
            Children.Add(_tabLayout, 0, 1);


            //TODO
            //update selected tab
            var headerLayout = Children[0] as StackLayout;

            foreach (var i in headerLayout.Children)
            {
                var j = i as TabLayout;
            }
            var c = headerLayout.Children.ElementAt(SelectedIndex) as TabLayout;

            foreach (var child in headerLayout.Children)
            {
                (child as TabLayout).IsSelected      = false;
                (child as TabLayout).BackgroundColor = Color.Silver;
            }
            c.IsSelected      = true;
            c.BackgroundColor = Color.White;
        }
Beispiel #30
0
        /// <summary>
        /// Return the material yield for this salvage.
        /// </summary>
        public static int GetMaterialYield(GamePlayer player, InventoryItem item, SalvageYield salvageYield, ItemTemplate rawMaterial)
        {
            int maxCount;

            if (rawMaterial == null)
            {
                return(0);
            }

            if (ServerProperties.Properties.USE_NEW_SALVAGE)
            {
                maxCount = GetCountForSalvage(item, rawMaterial);
            }
            else
            {
                maxCount = (int)(item.Price * 0.45 / rawMaterial.Price);                 // crafted item return max 45% of the item value in material

                if (item.IsCrafted)
                {
                    maxCount = (int)Math.Ceiling((double)maxCount / 2);
                }
            }

            int playerPercent = player.GetCraftingSkillValue(CraftingMgr.GetSecondaryCraftingSkillToWorkOnItem(item)) * 100 / CraftingMgr.GetItemCraftLevel(item);

            if (playerPercent > 100)
            {
                playerPercent = 100;
            }
            else if (playerPercent < 75)
            {
                playerPercent = 75;
            }

            int minCount = (int)(((maxCount - 1) / 25f) * playerPercent) - ((3 * maxCount) - 4);             //75% => min = 1; 100% => min = maxCount;

            salvageYield.Count = Util.Random(minCount, maxCount);
            return(salvageYield.Count);
        }
    public void SetItemTemplate(ItemTemplate template)
    {
        int[] statTypes = new int[6];
        int[] statMins = new int[6];
        int[] statMaxs = new int[6];
        int[] abilityTypes = new int[4];
        float[] abilityChances = new float[4];

        statTypes[0] = (int)template.StatA_Type;
        statTypes[1] = (int)template.StatB_Type;
        statTypes[2] = (int)template.StatC_Type;
        statTypes[3] = (int)template.StatD_Type;
        statTypes[4] = (int)template.StatE_Type;
        statTypes[5] = (int)template.StatF_Type;

        statMins[0] = template.StatA_Min;
        statMins[1] = template.StatB_Min;
        statMins[2] = template.StatC_Min;
        statMins[3] = template.StatD_Min;
        statMins[4] = template.StatE_Min;
        statMins[5] = template.StatF_Min;

        statMaxs[0] = template.StatA_Max;
        statMaxs[1] = template.StatB_Max;
        statMaxs[2] = template.StatC_Max;
        statMaxs[3] = template.StatD_Max;
        statMaxs[4] = template.StatE_Max;
        statMaxs[5] = template.StatF_Max;

        abilityTypes[0] = (int)template.AbilityA_Type;
        abilityTypes[1] = (int)template.AbilityB_Type;
        abilityTypes[2] = (int)template.AbilityC_Type;
        abilityTypes[3] = (int)template.AbilityD_Type;

        abilityChances[0] = template.AbilityA_Chance;
        abilityChances[1] = template.AbilityB_Chance;
        abilityChances[2] = template.AbilityC_Chance;
        abilityChances[3] = template.AbilityD_Chance;

        _ffc.SetItemTemplate(template.TemplateID, statTypes, statMins, statMaxs, abilityTypes, abilityChances);
    }
 /// <summary>
 /// </summary>
 /// <param name="slot">
 /// </param>
 /// <param name="item">
 /// </param>
 /// <exception cref="NotImplementedException">
 /// </exception>
 public void Removed(int slot, ItemTemplate item)
 {
     throw new NotImplementedException();
 }
Beispiel #33
0
        /// <summary>
        /// Begin salvaging an inventory item
        /// </summary>
        /// <param name="item"></param>
        /// <param name="player"></param>
        /// <returns></returns>
        public static int BeginWork(GamePlayer player, InventoryItem item)
        {
            SalvageYield salvageYield = null;

            if (!IsAllowedToBeginWork(player, item))
            {
                return(0);
            }

            int salvageLevel = CraftingMgr.GetItemCraftLevel(item) / 100;

            if (salvageLevel > 9)
            {
                salvageLevel = 9;                              // max 9
            }
            string sql = "";

            List <QueryParameter> qp = new List <QueryParameter>();

            if (item.SalvageYieldID == 0)
            {
                sql = "`ObjectType` = @objectype AND `SalvageLevel` = @salvagelvl";
                qp.Add(new QueryParameter("@objectype", item.Object_Type));
                qp.Add(new QueryParameter("@salvagelvl", salvageLevel));
            }
            else
            {
                sql = "`ID` = @salvageyieldid";
                qp.Add(new QueryParameter("@salvageyieldid", item.SalvageYieldID));
            }

            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` = 0 OR `Realm` = @realm )";
                qp.Add(new QueryParameter("@realm", item.Realm));
            }

            salvageYield = GameServer.Database.SelectObject <SalvageYield>(sql, qp);
            ItemTemplate material = null;

            if (salvageYield != null && string.IsNullOrEmpty(salvageYield.MaterialId_nb) == false)
            {
                material = GameServer.Database.FindObjectByKey <ItemTemplate>(salvageYield.MaterialId_nb);

                if (material == null)
                {
                    player.Out.SendMessage("Can't find material (" + material.Id_nb + ") needed to salvage this item!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                    log.ErrorFormat("Salvage Error for ID: {0}:  Material not found: {1}", salvageYield.ID, material.Id_nb);
                }
            }

            if (material == null)
            {
                if (salvageYield == null && item.SalvageYieldID > 0)
                {
                    player.Out.SendMessage("This items salvage recipe (" + item.SalvageYieldID + ") not implemented yet.", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                    log.ErrorFormat("SalvageYield ID {0} not found for item: {1}", item.SalvageYieldID, item.Name);
                }
                else if (salvageYield == null)
                {
                    player.Out.SendMessage("Salvage recipe not found for this item.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    log.ErrorFormat("Salvage Lookup Error: ObjectType: {0}, Item: {1}", item.Object_Type, item.Name);
                }
                return(0);
            }

            if (player.IsMoving || player.IsStrafing)
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.BeginWork.InterruptSalvage"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(0);
            }

            if (player.IsStealthed)
            {
                player.Stealth(false);
            }

            player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.BeginWork.BeginSalvage", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);

            // clone the yield entry and update values to work with this salvage (not saved to the DB)
            SalvageYield yield = salvageYield.Clone() as SalvageYield;

            if (item.SalvageYieldID == 0 || yield.Count == 0)
            {
                // Calculated salvage values
                int count = GetMaterialYield(player, item, yield, material);
                if (count < 1)
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.BeginWork.NoSalvage", item.Name + ". The material returned amount is zero"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return(0);
                }
            }

            player.Out.SendTimerWindow(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.BeginWork.Salvaging", item.Name), yield.Count);
            player.CraftTimer = new RegionTimer(player)
            {
                Callback = new RegionTimerCallback(Proceed)
            };
            player.CraftTimer.Properties.setProperty(AbstractCraftingSkill.PLAYER_CRAFTER, player);
            player.CraftTimer.Properties.setProperty(SALVAGED_ITEM, item);
            player.CraftTimer.Properties.setProperty(SALVAGE_YIELD, yield);

            player.CraftTimer.Start(yield.Count * 1000);
            return(1);
        }
 /// <summary>
 /// </summary>
 /// <param name="slot">
 /// </param>
 /// <param name="item">
 /// </param>
 /// <param name="err">
 /// </param>
 /// <exception cref="NotImplementedException">
 /// </exception>
 public void CheckAdd(int slot, ItemTemplate item, ref InventoryError err)
 {
     throw new NotImplementedException();
 }
Beispiel #35
0
        /// <summary>
        /// Called when craft time is finished
        /// </summary>
        /// <param name="timer"></param>
        /// <returns></returns>
        protected static int Proceed(RegionTimer timer)
        {
            GamePlayer    player        = timer.Properties.getProperty <GamePlayer>(AbstractCraftingSkill.PLAYER_CRAFTER, null);
            InventoryItem itemToSalvage = timer.Properties.getProperty <InventoryItem>(SALVAGED_ITEM, null);
            SalvageYield  yield         = timer.Properties.getProperty <SalvageYield>(SALVAGE_YIELD, null);
            int           materialCount = yield.Count;

            if (player == null || itemToSalvage == null || yield == null || materialCount == 0)
            {
                player.Out.SendMessage("Error retrieving salvage data for this item!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                log.Error("Salvage: There was a problem getting back salvage info from the craft timer.");
                return(0);
            }

            ItemTemplate rawMaterial = null;

            if (string.IsNullOrEmpty(yield.MaterialId_nb) == false)
            {
                rawMaterial = GameServer.Database.FindObjectByKey <ItemTemplate>(yield.MaterialId_nb);
            }

            if (rawMaterial == null)
            {
                player.Out.SendMessage("Error finding the raw material needed to salvage this item!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                log.Error("Salvage: Error finding raw material " + yield.MaterialId_nb);
                return(0);
            }

            player.CraftTimer.Stop();
            player.Out.SendCloseTimerWindow();

            if (!player.Inventory.RemoveItem(itemToSalvage))             // clean the free of the item to salvage
            {
                player.Out.SendMessage("Error finding the item to salvage!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                return(0);
            }

            InventoryLogging.LogInventoryAction(player, "(salvage)", eInventoryActionType.Craft, itemToSalvage.Template, itemToSalvage.Count);

            Dictionary <int, int> changedSlots = new Dictionary <int, int>(5);           // value: < 0 = new item count; > 0 = add to old

            lock (player.Inventory)
            {
                int count = materialCount;
                foreach (InventoryItem item in player.Inventory.GetItemRange(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
                {
                    if (item == null)
                    {
                        continue;
                    }
                    if (item.Id_nb != rawMaterial.Id_nb)
                    {
                        continue;
                    }
                    if (item.Count >= item.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);
                    changedSlots.Add((int)firstEmptySlot, -count);                     // Create the item in the free slot (always at least one)
                }
            }

            InventoryItem newItem;

            player.Inventory.BeginChanges();
            Dictionary <int, int> .Enumerator enumerator = changedSlots.GetEnumerator();
            while (enumerator.MoveNext())
            {
                KeyValuePair <int, int> de = enumerator.Current;
                int countToAdd             = de.Value;
                if (countToAdd > 0)                     // Add to exiting item
                {
                    newItem = player.Inventory.GetItem((eInventorySlot)de.Key);
                    player.Inventory.AddCountToStack(newItem, countToAdd);
                    InventoryLogging.LogInventoryAction("(salvage)", player, eInventoryActionType.Craft, newItem.Template, countToAdd);
                }
                else
                {
                    newItem       = GameInventoryItem.Create(rawMaterial);
                    newItem.Count = -countToAdd;
                    player.Inventory.AddItem((eInventorySlot)de.Key, newItem);
                    InventoryLogging.LogInventoryAction("(salvage)", player, eInventoryActionType.Craft, newItem.Template, newItem.Count);
                }
            }

            player.Inventory.CommitChanges();
            player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Salvage.Proceed.GetBackMaterial", materialCount, rawMaterial.Name, itemToSalvage.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow);

            return(0);
        }
Beispiel #36
0
 public GoldenSpearJavelin(GameLiving caster, Spell spell, SpellLine line)
     : base(caster, spell, line)
 {
     _artefJavelin = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Artef_Javelin'") ?? Javelin;
     item = GameInventoryItem.Create<ItemTemplate>(_artefJavelin);
 }
        /// <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(adjItemToCraft);
                        }
                        else
                        {
                            newItem = GameInventoryItem.Create(itemToCraft);
                        }
                    }
                    else
                    {
                        ItemUnique unique = new ItemUnique(itemToCraft);
                        GameServer.Database.AddObject(unique);
                        newItem         = GameInventoryItem.Create(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);
                }
            }
        }
Beispiel #38
0
 // Called when the item expires (is destroyed).
 public virtual bool OnExpire(Player player, ItemTemplate proto)
 {
     return(false);
 }
Beispiel #39
0
 protected override void InitControl()
 {
     base.InitControl();
     //ShowHeader = false;
     fileTemplate = new ItemTemplate();
     ItemTemplate = fileTemplate;
     ItemHeight = ItemTemplate.Height;
 }
 /// <summary>
 /// Calculate the minumum needed secondary crafting skill level to make the item
 /// </summary>
 public virtual int GetSecondaryCraftingSkillMinimumLevel(DBCraftedItem recipe, ItemTemplate itemToCraft)
 {
     return(0);
 }
Beispiel #41
0
        private void lstTemplates_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtDescription.Text = string.Empty;
            if (lstTemplates.SelectedItems.Count == 1)
            {
                var li = lstTemplates.SelectedItems[0];
                var tpl = (ItemTemplate)li.Tag;

                txtDescription.Text = tpl.Description;
                this.SelectedTemplate = tpl;
                CheckButtonState();
            }
        }
Beispiel #42
0
    public static void chargeLoot()
    {
        List <HabilidadTemplate> listHabilid = new List <HabilidadTemplate>();

        //por defecto le metemos uno a piñon para las pruebas.
        HabilidadTemplate habilidaBuild1 = new HabilidadTemplate();

        habilidaBuild1.nombre       = "habEspadazo";
        habilidaBuild1.maxProximity = 5;
        habilidaBuild1.damage       = 5;
        habilidaBuild1.cooldown     = 5;
        listHabilid.Add(habilidaBuild1);

        HabilidadTemplate habilidaBuild2 = new HabilidadTemplate();

        habilidaBuild2.nombre       = "habEstocada";
        habilidaBuild2.maxProximity = 5;
        habilidaBuild2.damage       = 5;
        habilidaBuild2.cooldown     = 5;
        listHabilid.Add(habilidaBuild2);

        HabilidadTemplate habilidaBuild3 = new HabilidadTemplate();

        habilidaBuild3.nombre       = "habEscudo";
        habilidaBuild3.maxProximity = 5;
        habilidaBuild3.damage       = 5;
        habilidaBuild3.cooldown     = 5;
        listHabilid.Add(habilidaBuild3);

        HabilidadTemplate habilidaBuild4 = new HabilidadTemplate();

        habilidaBuild4.nombre       = "habSalto";
        habilidaBuild4.maxProximity = 5;
        habilidaBuild4.damage       = 5;
        habilidaBuild4.cooldown     = 5;
        listHabilid.Add(habilidaBuild4);

        HabilidadTemplate habilidaBuild5 = new HabilidadTemplate();

        habilidaBuild5.nombre       = "habArrowBasic";
        habilidaBuild5.maxProximity = 15;
        habilidaBuild5.damage       = 5;
        habilidaBuild5.cooldown     = 5;
        listHabilid.Add(habilidaBuild5);

        HabilidadTemplate habilidaBuild6 = new HabilidadTemplate();

        habilidaBuild6.nombre = "habReduccionDano";
        listHabilid.Add(habilidaBuild6);

        HabilidadTemplate habilidaBuild7 = new HabilidadTemplate();

        habilidaBuild7.nombre   = "habCura";
        habilidaBuild7.curacion = 20;
        habilidaBuild7.cooldown = 25;
        listHabilid.Add(habilidaBuild7);

        HabilidadTemplate habilidaBuild8 = new HabilidadTemplate();

        habilidaBuild8.nombre       = "habPasoSombras";
        habilidaBuild8.maxProximity = 15;
        habilidaBuild8.damage       = 10;
        habilidaBuild8.cooldown     = 10;
        listHabilid.Add(habilidaBuild8);



        getPlayerTemp().addHabilidades(listHabilid);


        List <ItemTemplate> listItem = new List <ItemTemplate>();
        ItemTemplate        item1    = new ItemTemplate();

        item1.identificador = "head1";
        item1.itemLevel     = 1;
        listItem.Add(item1);

        ItemTemplate item2 = new ItemTemplate();

        item2.identificador = "head2";
        item2.itemLevel     = 1;
        listItem.Add(item2);

        ItemTemplate item3 = new ItemTemplate();

        item3.identificador = "head3";
        item3.itemLevel     = 1;
        listItem.Add(item3);

        ItemTemplate item4 = new ItemTemplate();

        item4.identificador = "head4";
        item4.itemLevel     = 1;
        listItem.Add(item4);

        ItemTemplate item5 = new ItemTemplate();

        item5.identificador = "tronco1";
        item5.itemLevel     = 1;
        listItem.Add(item5);

        ItemTemplate item6 = new ItemTemplate();

        item6.identificador = "tronco2";
        item6.itemLevel     = 1;
        listItem.Add(item6);

        ItemTemplate item7 = new ItemTemplate();

        item1.identificador = "tronco3";
        item7.itemLevel     = 1;
        listItem.Add(item7);

        ItemTemplate item8 = new ItemTemplate();

        item8.identificador = "tronco4";
        item8.itemLevel     = 1;
        listItem.Add(item8);

        ItemTemplate item9 = new ItemTemplate();

        item9.identificador = "zapas1";
        item9.itemLevel     = 1;
        listItem.Add(item9);

        ItemTemplate item10 = new ItemTemplate();

        item10.identificador = "zapas2";
        item10.itemLevel     = 1;
        listItem.Add(item10);

        ItemTemplate item11 = new ItemTemplate();

        item11.identificador = "zapas3";
        item11.itemLevel     = 1;
        listItem.Add(item11);

        ItemTemplate item12 = new ItemTemplate();

        item12.identificador = "zapas4";
        item12.itemLevel     = 1;
        listItem.Add(item12);

        getPlayerTemp().addItems(listItem);


        List <WeaponTemplate> listWeap = new List <WeaponTemplate>();

        WeaponTemplate weap = new WeaponTemplate();

        weap.identificador = "arpon1";
        weap.weaponLevel   = 1;
        listWeap.Add(weap);

        WeaponTemplate weap1 = new WeaponTemplate();

        weap1.identificador = "axe1";
        weap1.weaponLevel   = 1;
        listWeap.Add(weap1);

        WeaponTemplate weap2 = new WeaponTemplate();

        weap2.identificador = "axe2";
        weap2.weaponLevel   = 1;
        listWeap.Add(weap2);

        WeaponTemplate weap3 = new WeaponTemplate();

        weap3.identificador = "dest1";
        weap3.weaponLevel   = 1;
        listWeap.Add(weap3);

        WeaponTemplate weap4 = new WeaponTemplate();

        weap4.identificador = "mace1";
        weap4.weaponLevel   = 1;
        listWeap.Add(weap4);

        getPlayerTemp().addWeapons(listWeap);


        savePlayerTemp(playerTemplate);
    }
 /// <summary>
 /// </summary>
 /// <param name="item">
 /// </param>
 /// <exception cref="NotImplementedException">
 /// </exception>
 public void Added(ItemTemplate item)
 {
     throw new NotImplementedException();
 }
Beispiel #44
0
        public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_QUESTS)
            {
                return;
            }
            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initializing ...");
            }

            #region defineNPCs
            GameNPC[] npcs;

            npcs = WorldMgr.GetNPCsByName("Helen", (eRealm)2);
            if (npcs.Length == 0)
            {
                Helen       = new DOL.GS.GameNPC();
                Helen.Model = 193;
                Helen.Name  = "Helen";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + Helen.Name + ", creating ...");
                }
                Helen.GuildName       = "Part of " + questTitle + " Quest";
                Helen.Realm           = eRealm.Midgard;
                Helen.CurrentRegionID = 100;
                Helen.Size            = 49;
                Helen.Level           = 41;
                Helen.MaxSpeedBase    = 191;
                Helen.Faction         = FactionMgr.GetFactionByID(0);
                Helen.X               = 805693;
                Helen.Y               = 701160;
                Helen.Z               = 4960;
                Helen.Heading         = 3470;
                Helen.RespawnInterval = -1;
                Helen.BodyType        = 0;


                StandardMobBrain brain = new StandardMobBrain();
                brain.AggroLevel = 0;
                brain.AggroRange = 500;
                Helen.SetOwnBrain(brain);

                //You don't have to store the created mob in the db if you don't want,
                //it will be recreated each time it is not found, just comment the following
                //line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    Helen.SaveIntoDatabase();
                }

                Helen.AddToWorld();
            }
            else
            {
                Helen = npcs[0];
            }


            #endregion

            #region defineItems

            smallmaulerskin = GameServer.Database.FindObjectByKey <ItemTemplate>("smallmaulerskin");
            if (smallmaulerskin == null)
            {
                smallmaulerskin      = new ItemTemplate();
                smallmaulerskin.Name = "Small Mauler Skin";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + smallmaulerskin.Name + ", creating it ...");
                }
                smallmaulerskin.Level            = 1;
                smallmaulerskin.Weight           = 5;
                smallmaulerskin.Model            = 100;
                smallmaulerskin.Object_Type      = 0;
                smallmaulerskin.Item_Type        = 40;
                smallmaulerskin.Id_nb            = "smallmaulerskin";
                smallmaulerskin.Hand             = 0;
                smallmaulerskin.Price            = 0;
                smallmaulerskin.IsPickable       = true;
                smallmaulerskin.IsDropable       = true;
                smallmaulerskin.IsTradable       = true;
                smallmaulerskin.CanDropAsLoot    = false;
                smallmaulerskin.Color            = 0;
                smallmaulerskin.Bonus            = 35;      // default bonus
                smallmaulerskin.Bonus1           = 0;
                smallmaulerskin.Bonus1Type       = (int)0;
                smallmaulerskin.Bonus2           = 0;
                smallmaulerskin.Bonus2Type       = (int)0;
                smallmaulerskin.Bonus3           = 0;
                smallmaulerskin.Bonus3Type       = (int)0;
                smallmaulerskin.Bonus4           = 0;
                smallmaulerskin.Bonus4Type       = (int)0;
                smallmaulerskin.Bonus5           = 0;
                smallmaulerskin.Bonus5Type       = (int)0;
                smallmaulerskin.Bonus6           = 0;
                smallmaulerskin.Bonus6Type       = (int)0;
                smallmaulerskin.Bonus7           = 0;
                smallmaulerskin.Bonus7Type       = (int)0;
                smallmaulerskin.Bonus8           = 0;
                smallmaulerskin.Bonus8Type       = (int)0;
                smallmaulerskin.Bonus9           = 0;
                smallmaulerskin.Bonus9Type       = (int)0;
                smallmaulerskin.Bonus10          = 0;
                smallmaulerskin.Bonus10Type      = (int)0;
                smallmaulerskin.ExtraBonus       = 0;
                smallmaulerskin.ExtraBonusType   = (int)0;
                smallmaulerskin.Effect           = 0;
                smallmaulerskin.Emblem           = 0;
                smallmaulerskin.Charges          = 0;
                smallmaulerskin.MaxCharges       = 0;
                smallmaulerskin.SpellID          = 0;
                smallmaulerskin.ProcSpellID      = 0;
                smallmaulerskin.Type_Damage      = 0;
                smallmaulerskin.Realm            = 0;
                smallmaulerskin.MaxCount         = 1;
                smallmaulerskin.PackSize         = 1;
                smallmaulerskin.Extension        = 0;
                smallmaulerskin.Quality          = 99;
                smallmaulerskin.Condition        = 100;
                smallmaulerskin.MaxCondition     = 100;
                smallmaulerskin.Durability       = 100;
                smallmaulerskin.MaxDurability    = 100;
                smallmaulerskin.PoisonCharges    = 0;
                smallmaulerskin.PoisonMaxCharges = 0;
                smallmaulerskin.PoisonSpellID    = 0;
                smallmaulerskin.ProcSpellID1     = 0;
                smallmaulerskin.SpellID1         = 0;
                smallmaulerskin.MaxCharges1      = 0;
                smallmaulerskin.Charges1         = 0;

                //You don't have to store the created item in the db if you don't want,
                //it will be recreated each time it is not found, just comment the following
                //line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    GameServer.Database.AddObject(smallmaulerskin);
                }
            }


            #endregion

            #region defineAreas

            #endregion

            #region defineQuestParts

            QuestBuilder   builder = QuestMgr.getBuilder(typeof(Bearskins));
            QuestBehaviour a;
            a = builder.CreateBehaviour(Helen, -1);
            a.AddTrigger(eTriggerType.Interact, null, Helen);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.Bearskins), Helen);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.Bearskins), null, (eComparator)5);
            a.AddAction(eActionType.Talk, "I have lived in this village since I was a young girl. My father is a great bear hunter you know.", Helen);
            a.AddAction(eActionType.Talk, "In my years I have learned to work with all kinds of materials, specially [the skin of bears].", Helen);
            AddBehaviour(a);
            a = builder.CreateBehaviour(Helen, -1);
            a.AddTrigger(eTriggerType.Whisper, "the skin of bears", Helen);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.Bearskins), Helen);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.Bearskins), null, (eComparator)5);
            a.AddAction(eActionType.Talk, "Hmm...A new person here to Haggerfel. Let me offer you some [advice].", Helen);
            AddBehaviour(a);
            a = builder.CreateBehaviour(Helen, -1);
            a.AddTrigger(eTriggerType.Whisper, "advice", Helen);
            a.AddRequirement(eRequirementType.QuestGivable, typeof(DOL.GS.Quests.Midgard.Bearskins), Helen);
            a.AddRequirement(eRequirementType.QuestPending, typeof(DOL.GS.Quests.Midgard.Bearskins), null, (eComparator)5);
            a.AddAction(eActionType.OfferQuest, typeof(DOL.GS.Quests.Midgard.Bearskins), "Helen has offered you the Bear skins quest.?Do you accept?");
            AddBehaviour(a);
            a = builder.CreateBehaviour(Helen, -1);
            a.AddTrigger(eTriggerType.DeclineQuest, null, typeof(DOL.GS.Quests.Midgard.Bearskins));
            a.AddAction(eActionType.Talk, "No problem. See you", Helen);
            AddBehaviour(a);
            a = builder.CreateBehaviour(Helen, -1);
            a.AddTrigger(eTriggerType.AcceptQuest, null, typeof(DOL.GS.Quests.Midgard.Bearskins));
            a.AddAction(eActionType.Talk, "If you bring me the hide of a mauler cub I shall pay you well!", Helen);
            a.AddAction(eActionType.GiveQuest, typeof(DOL.GS.Quests.Midgard.Bearskins), Helen);
            AddBehaviour(a);
            a = builder.CreateBehaviour(Helen, -1);
            a.AddTrigger(eTriggerType.EnemyKilled, "black mauler cub", null);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.Bearskins), 1, (eComparator)3);
            a.AddAction(eActionType.GiveItem, smallmaulerskin, null);
            a.AddAction(eActionType.SetQuestStep, typeof(DOL.GS.Quests.Midgard.Bearskins), 2);
            AddBehaviour(a);
            a = builder.CreateBehaviour(Helen, -1);
            a.AddTrigger(eTriggerType.Interact, null, Helen);
            a.AddRequirement(eRequirementType.QuestStep, typeof(DOL.GS.Quests.Midgard.Bearskins), 2, (eComparator)3);
            a.AddAction(eActionType.Talk, "You have returned! Did you bring me the skin?", Helen);
            a.AddAction(eActionType.TakeItem, smallmaulerskin, null);
            a.AddAction(eActionType.Talk, "Wonderful, wonderful, you have done well, and brought a good hide.", Helen);
            a.AddAction(eActionType.Talk, "The hide is small yet sturdy. Here is some coin for your efforts. Thank you.", Helen);
            a.AddAction(eActionType.GiveXP, 10, null);
            a.AddAction(eActionType.GiveGold, 105, null);
            a.AddAction(eActionType.FinishQuest, typeof(DOL.GS.Quests.Midgard.Bearskins), null);
            AddBehaviour(a);

            #endregion

            // Custom Scriptloaded Code Begin

            // Custom Scriptloaded Code End

            Helen.AddQuestToGive(typeof(Bearskins));
            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
 /// <summary>
 /// </summary>
 /// <param name="slot">
 /// </param>
 /// <param name="templ">
 /// </param>
 /// <param name="err">
 /// </param>
 /// <exception cref="NotImplementedException">
 /// </exception>
 public void CheckRemove(int slot, ItemTemplate templ, ref InventoryError err)
 {
     throw new NotImplementedException();
 }
Beispiel #46
0
        public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_QUESTS)
            {
                return;
            }
            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initializing ...");
            }

            /* First thing we do in here is to search for the NPCs inside
             * the world who comes from the certain Realm. If we find a the players,
             * this means we don't have to create a new one.
             *
             * NOTE: You can do anything you want in this method, you don't have
             * to search for NPC's ... you could create a custom item, place it
             * on the ground and if a player picks it up, he will get the quest!
             * Just examples, do anything you like and feel comfortable with :)
             */

            #region defineNPCs

            GameNPC[] npcs = WorldMgr.GetNPCsByName("Brice Yarley", eRealm.Albion);
            if (npcs.Length == 0)
            {
                briceYarley       = new GameNPC();
                briceYarley.Model = 10;
                briceYarley.Name  = "Brice Yarley";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + briceYarley.Name + ", creating him ...");
                }
                briceYarley.Realm           = eRealm.Albion;
                briceYarley.CurrentRegionID = 1;
                briceYarley.Size            = 51;
                briceYarley.Level           = 43;
                briceYarley.X            = 370236;
                briceYarley.Y            = 679755;
                briceYarley.Z            = 5558;
                briceYarley.Heading      = 2468;
                briceYarley.MaxSpeedBase = 191;

                //You don't have to store the created mob in the db if you don't want,
                //it will be recreated each time it is not found, just comment the following
                //line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    briceYarley.SaveIntoDatabase();
                }


                briceYarley.AddToWorld();
            }
            else
            {
                briceYarley = npcs[0];
            }

            npcs = WorldMgr.GetNPCsByName("Patrick Yarley", eRealm.Albion);
            if (npcs.Length == 0)
            {
                patrickYarley       = new GameNPC();
                patrickYarley.Model = 9;
                patrickYarley.Name  = "Patrick Yarley";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + patrickYarley.Name + ", creating him ...");
                }
                patrickYarley.Realm           = eRealm.Albion;
                patrickYarley.CurrentRegionID = 1;
                patrickYarley.Size            = 51;
                patrickYarley.Level           = 43;
                patrickYarley.X            = 371752;
                patrickYarley.Y            = 680486;
                patrickYarley.Z            = 5595;
                patrickYarley.Heading      = 0;
                patrickYarley.MaxSpeedBase = 200;

                //You don't have to store the created mob in the db if you don't want,
                //it will be recreated each time it is not found, just comment the following
                //line if you rather not modify your database
                if (SAVE_INTO_DATABASE)
                {
                    patrickYarley.SaveIntoDatabase();
                }


                patrickYarley.AddToWorld();
            }
            else
            {
                patrickYarley = npcs[0];
            }



            #endregion

            #region defineItems



            elderWood = GameServer.Database.FindObjectByKey <ItemTemplate>("elder_wood");
            if (elderWood == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Elder Wood, creating it ...");
                }
                elderWood             = new ItemTemplate();
                elderWood.Object_Type = 0;
                elderWood.Id_nb       = "elder_wood";
                elderWood.Name        = "Elder Wood";
                elderWood.Level       = 1;
                elderWood.Model       = 520;
                elderWood.IsDropable  = false;
                elderWood.IsPickable  = false;
                elderWood.Weight      = 5;
                GameServer.Database.AddObject(elderWood);
            }

            boogeyTeeth = GameServer.Database.FindObjectByKey <ItemTemplate>("boogey_teeth");
            if (boogeyTeeth == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find Boogey Teeth, creating it ...");
                }
                boogeyTeeth             = new ItemTemplate();
                boogeyTeeth.Object_Type = 0;
                boogeyTeeth.Id_nb       = "boogey_teeth";
                boogeyTeeth.Name        = "Boogey Teeth";
                boogeyTeeth.Level       = 1;
                boogeyTeeth.Model       = 106;
                boogeyTeeth.IsDropable  = false;
                boogeyTeeth.IsPickable  = false;
                boogeyTeeth.Weight      = 4;
                GameServer.Database.AddObject(boogeyTeeth);
            }

            #endregion

            /* Now we add some hooks to the Sir Quait we found.
             * Actually, we want to know when a player interacts with him.
             * So, we hook the right-click (interact) and the whisper method
             * of Sir Quait and set the callback method to the "TalkToXXX"
             * method. This means, the "TalkToXXX" method is called whenever
             * a player right clicks on him or when he whispers to him.
             */
            GameEventMgr.AddHandler(GamePlayerEvent.AcceptQuest, new DOLEventHandler(SubscribeQuest));
            GameEventMgr.AddHandler(GamePlayerEvent.DeclineQuest, new DOLEventHandler(SubscribeQuest));

            GameEventMgr.AddHandler(briceYarley, GameLivingEvent.Interact, new DOLEventHandler(TalkToBriceYarley));
            GameEventMgr.AddHandler(briceYarley, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToBriceYarley));

            GameEventMgr.AddHandler(patrickYarley, GameLivingEvent.Interact, new DOLEventHandler(TalkToPatrickYarley));
            GameEventMgr.AddHandler(patrickYarley, GameLivingEvent.WhisperReceive, new DOLEventHandler(TalkToPatrickYarley));



            /* Now we bring to briceYarley the possibility to give this quest to players */
            briceYarley.AddQuestToGive(typeof(AFewRepairs));

            if (log.IsInfoEnabled)
            {
                log.Info("Quest \"" + questTitle + "\" initialized");
            }
        }
Beispiel #47
0
		public static ItemSuffixCategory GetSuffixCategory(ItemTemplate template)
		{
			if (template.IsRangedWeapon)
			{
				return ItemSuffixCategory.Ranged;
			}
			if (template.IsWeapon)
			{
				return ItemSuffixCategory.Weapon;
			}
			switch (template.InventorySlotType)
			{
				case InventorySlotType.Head:
				case InventorySlotType.Body:
				case InventorySlotType.Chest:
				case InventorySlotType.Legs:
				case InventorySlotType.Robe:
					return ItemSuffixCategory.MainArmor;
				case InventorySlotType.Shoulder:
				case InventorySlotType.Waist:
				case InventorySlotType.Feet:
				case InventorySlotType.Hand:
				case InventorySlotType.Trinket:
					return ItemSuffixCategory.SecondaryArmor;
				case InventorySlotType.Neck:
				case InventorySlotType.Wrist:
				case InventorySlotType.Finger:
				case InventorySlotType.Shield:
				case InventorySlotType.Cloak:
				case InventorySlotType.Holdable:
					return ItemSuffixCategory.Other;
			}

			return ItemSuffixCategory.None;
		}
Beispiel #48
0
        // Calls processor of corresponding LootTemplate (which handles everything including references)
        public bool FillLoot(uint lootId, LootStore store, Player lootOwner, bool personal, bool noEmptyError = false, LootModes lootMode = LootModes.Default, ItemContext context = 0)
        {
            // Must be provided
            if (lootOwner == null)
            {
                return(false);
            }

            LootTemplate tab = store.GetLootFor(lootId);

            if (tab == null)
            {
                if (!noEmptyError)
                {
                    Log.outError(LogFilter.Sql, "Table '{0}' loot id #{1} used but it doesn't have records.", store.GetName(), lootId);
                }
                return(false);
            }

            _itemContext = context;

            tab.Process(this, store.IsRatesAllowed(), (byte)lootMode);          // Processing is done there, callback via Loot.AddItem()

            // Setting access rights for group loot case
            Group group = lootOwner.GetGroup();

            if (!personal && group != null)
            {
                roundRobinPlayer = lootOwner.GetGUID();

                for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.Next())
                {
                    Player player = refe.GetSource();
                    if (player)   // should actually be looted object instead of lootOwner but looter has to be really close so doesnt really matter
                    {
                        if (player.IsInMap(lootOwner))
                        {
                            FillNotNormalLootFor(player, player.IsAtGroupRewardDistance(lootOwner));
                        }
                    }
                }

                for (byte i = 0; i < items.Count; ++i)
                {
                    ItemTemplate proto = Global.ObjectMgr.GetItemTemplate(items[i].itemid);
                    if (proto != null)
                    {
                        if (proto.GetQuality() < group.GetLootThreshold())
                        {
                            items[i].is_underthreshold = true;
                        }
                    }
                }
            }
            // ... for personal loot
            else
            {
                FillNotNormalLootFor(lootOwner, true);
            }

            return(true);
        }
Beispiel #49
0
 public Ingredient(int count, ItemTemplate ingredient)
 {
     Count    = count;
     Material = ingredient;
 }
Beispiel #50
0
 public Recipe(ItemTemplate product, List <Ingredient> ingredients)
 {
     this.ingredients = ingredients.ToArray();
     Product          = product;
 }
Beispiel #51
0
        public BeltOfSun(GameLiving caster, Spell spell, SpellLine line)
            : base(caster, spell, line)
        {
            if (caster.CurrentRegion.IsNightTime)
            {
                MessageToCaster("The powers of the Belt of Sun, can only be Summon under the Sun light!", eChatType.CT_SpellResisted);
                return;
            }

            GamePlayer player = caster as GamePlayer;

            #region Alb
            if (player.CharacterClass.ID == (int)eCharacterClass.Armsman)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? Crush;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

                m_SunSlash = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? Slash;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunThrust = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Thrust'") ?? Thrust;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunThrust));

                m_SunTwoHanded = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_TwoHanded'") ?? TwoHanded;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunTwoHanded));

                m_SunPolearmSpear = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Polearm'") ?? Polearm;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunPolearmSpear));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Friar)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? Crush;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

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

            if (player.CharacterClass.ID == (int)eCharacterClass.Heretic)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? Crush;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

                m_SunFlexScytheClaw = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Flex'") ?? Flex;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunFlexScytheClaw));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Infiltrator)
            {
                m_SunSlash = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? Slash;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunThrust = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Thrust'") ?? Thrust;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunThrust));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Mercenary)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? Crush;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

                m_SunSlash = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? Slash;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunThrust = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Thrust'") ?? Thrust;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunThrust));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Minstrel)
            {
                m_SunSlash = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? Slash;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunThrust = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Thrust'") ?? Thrust;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunThrust));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Paladin)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? Crush;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

                m_SunSlash = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? Slash;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunThrust = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Thrust'") ?? Thrust;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunThrust));

                m_SunTwoHanded = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_TwoHanded'") ?? TwoHanded;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunTwoHanded));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Reaver)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? Crush;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

                m_SunSlash = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? Slash;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunThrust = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Thrust'") ?? Thrust;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunThrust));

                m_SunFlexScytheClaw = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Flex'") ?? Flex;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunFlexScytheClaw));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Scout)
            {
                m_SunSlash = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? Slash;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunThrust = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Thrust'") ?? Thrust;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunThrust));

                m_SunBow = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Bow'") ?? Bow;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunBow));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.MaulerAlb)
            {
                m_SunMFist = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_MFist'") ?? MFist;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunMFist));

                m_SunMStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_MStaff'") ?? MStaff;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunMStaff));
                return;
            }
            #endregion Alb

            #region Mid
            if (player.CharacterClass.ID == (int)eCharacterClass.Berserker)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? CrushM; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

                m_SunSlash = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? SlashM; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunAxe = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Axe'") ?? Axe; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunAxe));

                m_SunTwoHanded = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_TwoHanded'") ?? TwoHandedM; // 2handed Sword
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunTwoHanded));

                m_Sun2HCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_2HCrush'") ?? THCrushM;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_Sun2HCrush));

                m_Sun2HAxe = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_2HAxe'") ?? THAxe;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_Sun2HAxe));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Hunter)
            {
                m_SunSlash = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? SlashM; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunPolearmSpear = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Trust'") ?? SpearM; // Spear
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunPolearmSpear));

                m_SunBow = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Bow'") ?? BowM; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunBow));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Savage)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? CrushM; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

                m_SunSlash = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? SlashM; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunAxe = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Axe'") ?? Axe; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunAxe));

                m_SunThrust = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Claw'") ?? Claw; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunThrust));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Shadowblade)
            {
                m_SunSlash = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? SlashM; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunAxe = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Axe'") ?? Axe; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunAxe));

                m_SunLeftAxe = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_LeftAxe'") ?? LeftAxe; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunLeftAxe));

                m_SunTwoHanded = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_TwoHanded'") ?? TwoHandedM; // 2handed Sword
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunTwoHanded));

                m_Sun2HAxe = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_2HAxe'") ?? THAxe;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_Sun2HAxe));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Skald)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? CrushM; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

                m_SunSlash = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? SlashM; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunAxe = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Axe'") ?? Axe; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunAxe));

                m_SunTwoHanded = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_TwoHanded'") ?? TwoHandedM; // 2handed Sword
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunTwoHanded));

                m_Sun2HCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_2HCrush'") ?? THCrushM;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_Sun2HCrush));

                m_Sun2HAxe = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_2HAxe'") ?? THAxe;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_Sun2HAxe));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Thane)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? CrushM; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

                m_SunSlash = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? SlashM; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunAxe = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Axe'") ?? Axe; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunAxe));

                m_SunTwoHanded = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_TwoHanded'") ?? TwoHandedM; // 2handed Sword
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunTwoHanded));

                m_Sun2HCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_2HCrush'") ?? THCrushM;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_Sun2HCrush));

                m_Sun2HAxe = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_2HAxe'") ?? THAxe;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_Sun2HAxe));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Thane)
            {
                m_SunSlash = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? SlashM; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunTwoHanded = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_TwoHanded'") ?? TwoHandedM; // 2handed Sword
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunTwoHanded));

                m_SunPolearmSpear = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Trust'") ?? SpearM; // Spear
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunPolearmSpear));
                return;
            }


            if (player.CharacterClass.ID == (int)eCharacterClass.Warrior)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? CrushM; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

                m_SunSlash = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? SlashM; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunAxe = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Axe'") ?? Axe; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunAxe));

                m_SunTwoHanded = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_TwoHanded'") ?? TwoHandedM; // 2handed Sword
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunTwoHanded));

                m_Sun2HCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_2HCrush'") ?? THCrushM;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_Sun2HCrush));

                m_Sun2HAxe = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_2HAxe'") ?? THAxe;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_Sun2HAxe));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.MaulerMid)
            {
                m_SunMFist = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_MFist'") ?? MFist;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunMFist));

                m_SunMStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_MStaff'") ?? MStaff;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunMStaff));
                return;
            }

            #endregion Mid

            #region Hib
            if (player.CharacterClass.ID == (int)eCharacterClass.Bard)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? CrushH; // Blunt
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? SlashH; // Blades
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Blademaster)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? CrushH; // Blunt
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? SlashH; // Blades
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Thrust'") ?? ThrustH; // Piercing
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunThrust));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Champion)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? CrushH; // Blunt
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? SlashH; // Blades
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Thrust'") ?? ThrustH; // Piercing
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunThrust));

                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? TwoHandedH; // LargeWeapon
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunTwoHanded));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Hero)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? CrushH; // Blunt
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? SlashH; // Blades
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Thrust'") ?? ThrustH; // Piercing
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunThrust));

                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? TwoHandedH; // LargeWeapon
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunTwoHanded));

                m_SunPolearmSpear = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Spear'") ?? SpearH; // Spear
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunPolearmSpear));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Nightshade)
            {
                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? SlashH; // Blades
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Thrust'") ?? ThrustH; // Piercing
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunThrust));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Ranger)
            {
                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? SlashH; // Blades
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));

                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Thrust'") ?? ThrustH; // Piercing
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunThrust));

                m_SunBow = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Bow'") ?? BowH; //
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunBow));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Valewalker)
            {
                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_FlexScythe'") ?? Scythe;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunFlexScytheClaw));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Valewalker)
            {
                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Thrust'") ?? ThrustH; // Piercing
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunThrust));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.Warden)
            {
                m_SunCrush = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Crush'") ?? CrushH; // Blunt
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunCrush));

                m_SunStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_Slash'") ?? SlashH; // Blades
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunSlash));
                return;
            }

            if (player.CharacterClass.ID == (int)eCharacterClass.MaulerHib)
            {
                m_SunMFist = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_MFist'") ?? MFist;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunMFist));

                m_SunMStaff = GameServer.Database.SelectObject<ItemTemplate>("Id_nb='Sun_MStaff'") ?? MStaff;
                items.Add(GameInventoryItem.Create<ItemTemplate>(m_SunMStaff));
                return;
            }

            else
            {
                player.Out.SendMessage("" + player.CharacterClass.Name + "'s cant Summon Light!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }
        }
Beispiel #52
0
        public void StockShopShelf(PlayerGPS.DiscoveredBuilding buildingData)
        {
            stockedDate = CreateStockedDate(DaggerfallUnity.Instance.WorldTime.Now);
            items.Clear();

            DFLocation.BuildingTypes buildingType = buildingData.buildingType;
            int shopQuality = buildingData.quality;

            Game.Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;
            ItemHelper itemHelper = DaggerfallUnity.Instance.ItemHelper;

            byte[] itemGroups = { 0 };

            switch (buildingType)
            {
            case DFLocation.BuildingTypes.Alchemist:
                itemGroups = DaggerfallLootDataTables.itemGroupsAlchemist;
                RandomlyAddPotionRecipe(25, items);
                break;

            case DFLocation.BuildingTypes.Armorer:
                itemGroups = DaggerfallLootDataTables.itemGroupsArmorer;
                break;

            case DFLocation.BuildingTypes.Bookseller:
                itemGroups = DaggerfallLootDataTables.itemGroupsBookseller;
                break;

            case DFLocation.BuildingTypes.ClothingStore:
                itemGroups = DaggerfallLootDataTables.itemGroupsClothingStore;
                break;

            case DFLocation.BuildingTypes.GemStore:
                itemGroups = DaggerfallLootDataTables.itemGroupsGemStore;
                break;

            case DFLocation.BuildingTypes.GeneralStore:
                itemGroups = DaggerfallLootDataTables.itemGroupsGeneralStore;
                items.AddItem(ItemBuilder.CreateItem(ItemGroups.Transportation, (int)Transportation.Horse));
                items.AddItem(ItemBuilder.CreateItem(ItemGroups.Transportation, (int)Transportation.Small_cart));
                break;

            case DFLocation.BuildingTypes.PawnShop:
                itemGroups = DaggerfallLootDataTables.itemGroupsPawnShop;
                break;

            case DFLocation.BuildingTypes.WeaponSmith:
                itemGroups = DaggerfallLootDataTables.itemGroupsWeaponSmith;
                break;
            }

            for (int i = 0; i < itemGroups.Length; i += 2)
            {
                ItemGroups itemGroup = (ItemGroups)itemGroups[i];
                int        chanceMod = itemGroups[i + 1];
                if (itemGroup == ItemGroups.MensClothing && playerEntity.Gender == Game.Entity.Genders.Female)
                {
                    itemGroup = ItemGroups.WomensClothing;
                }
                if (itemGroup == ItemGroups.WomensClothing && playerEntity.Gender == Game.Entity.Genders.Male)
                {
                    itemGroup = ItemGroups.MensClothing;
                }

                if (itemGroup != ItemGroups.Furniture && itemGroup != ItemGroups.UselessItems1)
                {
                    if (itemGroup == ItemGroups.Books)
                    {
                        int qualityMod = (shopQuality + 3) / 5;
                        if (qualityMod >= 4)
                        {
                            --qualityMod;
                        }
                        qualityMod++;
                        for (int j = 0; j <= qualityMod; ++j)
                        {
                            items.AddItem(ItemBuilder.CreateRandomBook());
                        }
                    }
                    else
                    {
                        System.Array enumArray = itemHelper.GetEnumArray(itemGroup);
                        for (int j = 0; j < enumArray.Length; ++j)
                        {
                            ItemTemplate itemTemplate = itemHelper.GetItemTemplate(itemGroup, j);
                            if (itemTemplate.rarity <= shopQuality)
                            {
                                int stockChance = chanceMod * 5 * (21 - itemTemplate.rarity) / 100;
                                if (Dice100.SuccessRoll(stockChance))
                                {
                                    DaggerfallUnityItem item = null;
                                    if (itemGroup == ItemGroups.Weapons)
                                    {
                                        item = ItemBuilder.CreateWeapon(j + Weapons.Dagger, ItemBuilder.RandomMaterial(playerEntity.Level));
                                    }
                                    else if (itemGroup == ItemGroups.Armor)
                                    {
                                        item = ItemBuilder.CreateArmor(playerEntity.Gender, playerEntity.Race, j + Armor.Cuirass, ItemBuilder.RandomArmorMaterial(playerEntity.Level));
                                    }
                                    else if (itemGroup == ItemGroups.MensClothing)
                                    {
                                        item          = ItemBuilder.CreateMensClothing(j + MensClothing.Straps, playerEntity.Race);
                                        item.dyeColor = ItemBuilder.RandomClothingDye();
                                    }
                                    else if (itemGroup == ItemGroups.WomensClothing)
                                    {
                                        item          = ItemBuilder.CreateWomensClothing(j + WomensClothing.Brassier, playerEntity.Race);
                                        item.dyeColor = ItemBuilder.RandomClothingDye();
                                    }
                                    else if (itemGroup == ItemGroups.MagicItems)
                                    {
                                        item = ItemBuilder.CreateRandomMagicItem(playerEntity.Level, playerEntity.Gender, playerEntity.Race);
                                    }
                                    else
                                    {
                                        item = new DaggerfallUnityItem(itemGroup, j);
                                        if (DaggerfallUnity.Settings.PlayerTorchFromItems && item.IsOfTemplate(ItemGroups.UselessItems2, (int)UselessItems2.Oil))
                                        {
                                            item.stackCount = Random.Range(5, 20 + 1);  // Shops stock 5-20 bottles
                                        }
                                    }
                                    items.AddItem(item);
                                }
                            }
                        }
                        // Add any modded items registered in applicable groups
                        int[] customItemTemplates = itemHelper.GetCustomItemsForGroup(itemGroup);
                        for (int j = 0; j < customItemTemplates.Length; j++)
                        {
                            ItemTemplate itemTemplate = itemHelper.GetItemTemplate(itemGroup, customItemTemplates[j]);
                            if (itemTemplate.rarity <= shopQuality)
                            {
                                int stockChance = chanceMod * 5 * (21 - itemTemplate.rarity) / 100;
                                if (Dice100.SuccessRoll(stockChance))
                                {
                                    DaggerfallUnityItem item = ItemBuilder.CreateItem(itemGroup, customItemTemplates[j]);

                                    // Setup specific group stats
                                    if (itemGroup == ItemGroups.Weapons)
                                    {
                                        WeaponMaterialTypes material = ItemBuilder.RandomMaterial(playerEntity.Level);
                                        ItemBuilder.ApplyWeaponMaterial(item, material);
                                    }
                                    else if (itemGroup == ItemGroups.Armor)
                                    {
                                        ArmorMaterialTypes material = ItemBuilder.RandomArmorMaterial(playerEntity.Level);
                                        ItemBuilder.ApplyArmorSettings(item, playerEntity.Gender, playerEntity.Race, material);
                                    }

                                    items.AddItem(item);
                                }
                            }
                        }
                    }
                }
            }
        }