Наследование: MonoBehaviour
 // Used by addon to create the deed
 public BloodPentagramPartDeed(BitArray partsArray, bool bloodSoaked, int hue, LootType lootType)
 {
     m_PartsArray = partsArray;
     BloodSoaked = bloodSoaked;
     Hue = hue;
     LootType = lootType;
 }
Пример #2
0
 public Loot(string id, float dropRate, int amount, LootType type)
 {
     this.id = id;
     this.dropRate = dropRate;
     this.amount = amount;
     this.type = type;
 }
Пример #3
0
 public void AddMineralsByType(LootType mineralType, int amount)
 {
     switch (mineralType)
     {
         case LootType.MineralA:
             this.MineralA += amount;
             break;
         case LootType.MineralB:
             this.MineralB += amount;
             break;
         case LootType.MineralC:
             this.MineralC += amount;
             break;
     }
 }
        public BloodPentagramPartAddon(BitArray partsArray, bool bloodSoaked, int hue, LootType lootType)
        {
            m_PartsArray = partsArray;
            m_bBloodSoaked = bloodSoaked;
            Hue = hue;
            LootType = lootType;

            for (int i = 0; i < m_PartsArray.Count; ++i)
            {
                if (m_PartsArray[i])
                {
                    AddonComponent addonComp = new AddonComponent(PentagramParts[i].ItemID);
                    addonComp.Hue = Hue;
                    AddComponent(addonComp, PentagramParts[i].xOffset, PentagramParts[i].yOffset, PentagramParts[i].zOffset);
                }
            }
        }
Пример #5
0
        public void Add(Item item, byte count, LootType lootType)
        {
            var id = _byItem.LookupByKey(item);

            if (id != 0)
            {
                var resultValue = _byOrder[id];
                resultValue.count += count;
            }
            else
            {
                _byItem[item] = _byOrder.Count;
                ResultValue value;
                value.item     = item;
                value.count    = count;
                value.lootType = lootType;
                _byOrder.Add(value);
            }
        }
Пример #6
0
        public KeyringEntry(GenericReader reader)
        {
            int version = reader.ReadByte();

            switch (version)
            {
            case 0:
            {
                m_KeyValue    = reader.ReadUInt();
                m_Link        = reader.ReadItem();
                m_MaxRange    = reader.ReadInt();
                m_ItemID      = reader.ReadInt();
                m_LootType    = (LootType)reader.ReadByte();
                m_Description = reader.ReadString();

                break;
            }
            }
        }
Пример #7
0
        //private SynchronizedSettings globalsettings;
        /// <summary>
        /// Initializes a new instance of the <see cref="T:CorpsesAutoopen"/> class.
        /// </summary>
        public CalebConfig()
        {
            // Pozn: Snazim se mit staticky jen uplne minimum, protoze co je v instanci sezere pri rekompilaci GC
            // globalsettings = new SynchronizedSettings("Phoenix");

            // Core.Directory;

            autoHeal          = Config.Profile.UserSettings.GetAttribute(true, "Value", "AutoHeal");
            healMoby          = Config.Profile.UserSettings.GetAttribute(true, "Value", "HealMoby");
            destroySpiderWeb  = Config.Profile.UserSettings.GetAttribute(true, "Value", "DestroySpiderWeb");
            handleFrozen      = Config.Profile.UserSettings.GetAttribute(true, "Value", "HandleFrozen");
            rename            = (RenameType)Config.Profile.UserSettings.GetAttribute((int)RenameType.OnAppeared, "Value", "Rename");
            healMinDamagePerc = Config.Profile.UserSettings.GetAttribute(0, "Value", "HealMinDamagePerc");
            attackDelay       = Config.Profile.UserSettings.GetAttribute(1500, "Value", "AttackDelay");
            useWatcher        = Config.Profile.UserSettings.GetAttribute(false, "Value", "UseWatcher");

            healType = (AutoHealType)Config.Profile.UserSettings.GetAttribute((int)AutoHealType.Automatic, "Value", "HealType");
            loot     = (LootType)Config.Profile.UserSettings.GetAttribute((int)LootType.OpenCorpse, "Value", "Loot");

            trainPoison = Config.Profile.UserSettings.GetAttribute(true, "Value", "TrainPoison");

            friendHitsMessageType = (MessagePrintType)Config.Profile.UserSettings.GetAttribute((int)MessagePrintType.Default, "Value", "FriendHitsMessageType");
            enemyHitsMessageType  = (MessagePrintType)Config.Profile.UserSettings.GetAttribute((int)MessagePrintType.Default, "Value", "EnemyHitsMessageType");
            castMessageType       = (MessagePrintType)Config.Profile.UserSettings.GetAttribute((int)MessagePrintType.Default, "Value", "CastMessageType");
            playerHitsMessageType = (MessagePrintType)Config.Profile.UserSettings.GetAttribute((int)MessagePrintType.Default, "Value", "PlayerHitsMessageType");

            useWallTime = Config.Profile.UserSettings.GetAttribute(true, "Value", "UseWallTime");

            lootItemTypes = Config.Profile.UserSettings.GetAttribute(CalExtension.UOExtensions.Loot.LootDefaultItemTypes, "Value", "LootItemTypes");
            playerAliases = GetGlobalFile("PlayerAliases.txt", "");// Config.Profile.UserSettings.GetAttribute(String.Empty, "Value", "PlayerAliases");

            salatAlertHp = Config.Profile.UserSettings.GetAttribute("33%", "Value", "SalatAlertHp");

            bakGlobalCalebConfig = globalCalebConfig = GetGlobalFile("globalCalebConfig.xml", "<Config></Config>");// Config.Profile.UserSettings.GetAttribute(String.Empty, "Value", "PlayerAliases");

            Config.Profile.UserSettings.Loaded += new EventHandler(UserSettings_Loaded);
            Config.Profile.UserSettings.Saving += new EventHandler(UserSettings_Saving);
            globalDocument = null;
            //globalsettings.Loaded += Globalsettings_Loaded;
            //globalsettings.Saving += Globalsettings_Saving;
        }
Пример #8
0
    void InitLootType()
    {
        int RNG = Random.Range(0, 100);

        if (RNG >= 40 && RNG < 60)
        {
            loot = LootType.GUN_AMMO;
        }
        else if (RNG >= 60 && RNG < 70)
        {
            loot = LootType.SHOTGUN_AMMO;
        }
        else if (RNG >= 70 && RNG < 80)
        {
            loot = LootType.SNIPER_AMMO;
        }
        else if (RNG >= 80 && RNG < 90)
        {
            loot = LootType.PISTOL;
        }
        else if (RNG >= 90 && RNG < 100)
        {
            int RNG2 = Random.Range(0, 4);
            if (RNG == 2)
            {
                loot = LootType.SHOTGUN;
            }
            else if (RNG == 3)
            {
                loot = LootType.SNIPER;
            }
            else
            {
                loot = LootType.RIFLE;
            }
        }
        else
        {
            loot = LootType.HEALTH_PACK;
        }
    }
Пример #9
0
        public static string GetPrefab(LootType type)
        {
            switch (type)
            {
            case LootType.BoxLoot:
                return("BoxLoot");

            case LootType.AmmoLootBox:
                return("AmmoLootBox");

            case LootType.MedicalLootBox:
                return("MedicalLootBox");

            case LootType.WeaponLootBox:
                return("WeaponLootBox");
            }

            int i = Randomizer.Next(1, 5);

            return(GetPrefab(i));
        }
    public void InitializeLoot(LootType loot, int lootAmount)
    {
        lootType = loot;
        amount   = lootAmount;

        switch (loot)
        {
        case LootType.GUN_AMMO:
            sprite.sprite = gunAmmo;
            break;

        case LootType.SHOTGUN_AMMO:
            sprite.sprite = shotgunAmmo;
            break;

        case LootType.SNIPER_AMMO:
            sprite.sprite = sniperAmmo;
            break;

        case LootType.PISTOL:
            sprite.sprite = pistol;
            break;

        case LootType.RIFLE:
            sprite.sprite = rifle;
            break;

        case LootType.SHOTGUN:
            sprite.sprite = shotgun;
            break;

        case LootType.SNIPER:
            sprite.sprite = sniper;
            break;

        case LootType.HEALTH_PACK:
            sprite.sprite = medicPack;
            break;
        }
    }
Пример #11
0
		public FactionItem( GenericReader reader, Faction faction )
		{
			int version = reader.ReadEncodedInt();

			switch ( version )
			{
				case 1:
				{
					m_OrigLootType = (LootType)reader.ReadByte();
					m_OrigHue = reader.ReadInt();
					goto case 0;
				}
				case 0:
				{
					m_Item = reader.ReadItem();
					m_Expiration = reader.ReadDateTime();
					break;
				}
			}

			m_Faction = faction;
		}
Пример #12
0
    // Use this for initialization
    void Start()
    {
        int typeVal = Random.Range(0, 100);

        myType = (typeVal >= 90 ? LootType.HEALTH : typeVal >= 30 ? LootType.AMMO : LootType.WEAPON);
        if (myType == LootType.WEAPON)
        {
            myWeaponType = (Random.Range(0, 100) <= 75 ? WeaponType.BROAD : WeaponType.MISSILE);
        }
        else if (myType == LootType.AMMO)
        {
            ammo = Random.Range(0, 30);
        }
        else
        {
            heal = Random.Range(0, 10);
        }
        SpriteRenderer temp = transform.Find("Sprite").GetComponent <SpriteRenderer>();

        if (myType == LootType.WEAPON)
        {
            if (myWeaponType == WeaponType.BROAD)
            {
                temp.sprite = Broad;
            }
            else if (myWeaponType == WeaponType.MISSILE)
            {
                temp.sprite = Missile;
            }
        }
        else if (myType == LootType.AMMO)
        {
            temp.sprite = AmmoSprite;
        }
        else if (myType == LootType.HEALTH)
        {
            temp.sprite = Health;
        }
    }
Пример #13
0
    private void SetupLoot()
    {
        var discoveredLoot = allLoot.Where(x => x.IsActive == true && x.progressionAmount == 0).ToList();

        // var staffMembers = ScriptableObjectUtils.GetAllInstances<StaffScriptable>("Staff").ToList();

        pointsOnlyLoot = discoveredLoot.FirstOrDefault(x => x.weaponUpgrade == WeaponUpgradeTypeEnum.None && x.genericUpgrade == GenericUpgradeEnum.None);

        var staffCopy = staffMembers.ToList();

        foreach (var loot in discoveredLoot)
        {
            if (staffCopy.Count == 0)
            {
                staffCopy = staffMembers.ToList();
            }

            var randomUnusedStaff = staffCopy[Random.Range(0, staffCopy.Count)];
            loot.staff = randomUnusedStaff;

            staffCopy.Remove(randomUnusedStaff);
        }

        var possibleWeapons    = discoveredLoot.Where(x => x.weaponUpgrade != WeaponUpgradeTypeEnum.None).ToList();
        var possibleNonWeapons = discoveredLoot.Where(x => (x.genericUpgrade != GenericUpgradeEnum.None && x.genericUpgrade != GenericUpgradeEnum.Immunity)).ToList();

        var numWeapons = possibleWeapons.Count;

        // randomize order of weapons first in possible loot
        for (int i = 0; i < numWeapons; i++)
        {
            var randomLoot = possibleWeapons[Random.Range(0, possibleWeapons.Count)];
            possibleWeapons.Remove(randomLoot);
            possibleLoot.Add(randomLoot);
        }

        possibleLoot.AddRange(possibleNonWeapons);
    }
Пример #14
0
        public FactionItem(GenericReader reader, Faction faction)
        {
            int version = reader.ReadEncodedInt();

            switch (version)
            {
            case 1:
            {
                m_OrigLootType = (LootType)reader.ReadByte();
                m_OrigHue      = reader.ReadInt();
                goto case 0;
            }

            case 0:
            {
                m_Item       = reader.ReadItem();
                m_Expiration = reader.ReadDateTime();
                break;
            }
            }

            m_Faction = faction;
        }
Пример #15
0
        public EthicsItem(GenericReader reader, Ethic ethic)
        {
            int version = reader.ReadEncodedInt();

            switch (version)
            {
            case 1:
            {
                m_OrigLootType = (LootType)reader.ReadByte();
                m_OrigHue      = reader.ReadInt();
                goto case 0;
            }

            case 0:
            {
                m_Item       = reader.ReadItem();
                m_Expiration = reader.ReadDateTime();
                break;
            }
            }

            m_Ethic = ethic;
        }
Пример #16
0
    /// <summary>
    /// Ajoute ou enlève quelque chose des stats du joueur, artefact ou item
    /// un seul à mettre avec value: , artefact: ou members:
    /// </summary>
    /// <param name="type">le type de loot</param>
    /// <param name="value">la valeur si pas artefact</param>
    /// <param name="artefact">l'artefact</param>
    /// <param name="members">l'artefact</param>
    public void AddLoot(LootType type, int value = 0, Artefact artefact = null, List <CharacterData> members = null)
    {
        switch (type)
        {
        case LootType.artefact:
            StateManager.Instance.AddArtefact(artefact);
            break;

        case LootType.megaArtefact:
            //TODO : Mega Atefact
            break;

        case LootType.beer:
            StateManager.Instance.AddBeer(value);
            break;

        case LootType.stuff:
            StateManager.Instance.AddStuff(value);
            break;

        case LootType.character:
            foreach (CharacterData item in members)
            {
                StateManager.Instance.AddMember(item);
            }
            break;

        case LootType.gold:
            StateManager.Instance.AddGold(value);
            break;

        default:
            Debug.LogError("Type pas connu!");
            break;
        }
    }
    void SwapGun()
    {
        LootType lootType = LootType.PISTOL;

        switch (shoot.gunMode)
        {
        case GunMode.RIFLE:
            lootType = LootType.RIFLE;
            break;

        case GunMode.SHOTGUN:
            lootType = LootType.SHOTGUN;
            break;

        case GunMode.SNIPER:
            lootType = LootType.SNIPER;
            break;
        }

        GameObject obj     = Instantiate(lootObj, transform.position, Quaternion.identity);
        Loot       objLoot = obj.GetComponent <Loot>();

        objLoot.InitializeLoot(lootType, 1);
    }
Пример #18
0
    private void ResetFishing()
    {
        boolAimingWater = false;
        boolRodBaited   = false;
        boolFishing     = false;
        boolBaitWait    = false;
        boolFishHooked  = false;
        intLoot         = LootType.nothing;
        if (animator)
        {
            animator.ResetTrigger("fishHook");
            animator.ResetTrigger("stopFishing");
            animator.ResetTrigger("hookPull");
            animator.ResetTrigger("waitBait");
            animator.ResetTrigger("smallFish");
            animator.ResetTrigger("bigFish");
            animator.ResetTrigger("head");

            animator.CrossFade("Idle", 0.0f);
            // go directly to idle
        }
        if (epLocalPlayer)
        {
            if (epLocalPlayer.Stats.Buffs.Count > 0)
            {
                foreach (Buff buff in epLocalPlayer.Stats.Buffs)
                {
                    if (buff.Name == "fishingWater")
                    {
                        epLocalPlayer.Stats.Debuff("fishingWater");
                        break;
                    }
                }
            }
        }
    }
Пример #19
0
    public DropContent GenerateEnemyLootCrateContent(bool hasToDropEquipment, bool canDropEquipment)
    {
        LootType lootType = LootType.Null;

        #region Select loot type
        if (hasToDropEquipment)
        {
            lootType = LootType.Equipment;
        }
        else
        {
            int[] lootTypeProbas = new int[3];
            lootTypeProbas[0] = goldLootProbability;
            lootTypeProbas[1] = equipmentLootProbability;
            lootTypeProbas[2] = nullLootProbability;
            lootType          = (LootType)Probabilities.GetRandomIndexFromWeights(lootTypeProbas);
        }
        #endregion

        if (lootType == LootType.Null)
        {
            return(new DropContent());
        }



        int           lootedGoldAmount = 0;
        ShipEquipment lootedEquipment  = null;

        EquipmentType lootedEquipmentType = default;
        switch (lootType)
        {
        case (LootType.Gold):
            lootedGoldAmount = goldLootSystem.GetRandomElementFromSystem();
            break;

        case (LootType.Equipment):

            if (!canDropEquipment)
            {
                lootedGoldAmount = goldLootSystem.GetRandomElementFromSystem();
                break;
            }

            #region Select equipment type
            int[] lootEquipmentTypeProba = new int[2];
            lootEquipmentTypeProba[0] = hullEquipmentProbability;
            lootEquipmentTypeProba[1] = weaponEquipmentProbability;
            int equipmentType = Probabilities.GetRandomIndexFromWeights(lootEquipmentTypeProba);
            #endregion

            //loot une coque
            if (equipmentType == 0)
            {
                if (hullLootSystem.GetAllItems.Count > 0)
                {
                    lootedEquipmentType = EquipmentType.Hull;
                    lootedEquipment     = hullLootSystem.GetRandomElementFromSystem();
                }
                else
                {
                    lootedEquipmentType = EquipmentType.Canon;
                    lootedEquipment     = weaponLootSystem.GetRandomElementFromSystem();
                }
            }
            //loot une arme
            else if (equipmentType == 1)
            {
                if (weaponLootSystem.GetAllItems.Count > 0)
                {
                    lootedEquipmentType = EquipmentType.Canon;
                    lootedEquipment     = weaponLootSystem.GetRandomElementFromSystem();
                }
                else
                {
                    lootedEquipmentType = EquipmentType.Hull;
                    lootedEquipment     = hullLootSystem.GetRandomElementFromSystem();
                }
            }

            break;
        }

        if (lootedGoldAmount != 0)
        {
            int randomInt = Random.Range(-Mathf.Abs(goldLootRandomAmplitude) / 2, 1 + Mathf.Abs(goldLootRandomAmplitude) / 2);
            lootedGoldAmount += randomInt;
        }

        #region Remove Dropped Equipment from possibilities
        if (lootedEquipment != null)
        {
            if (lootedEquipmentType == EquipmentType.Hull)
            {
                hullLootSystem.RemoveEquipmentFromSystem(lootedEquipment);
            }
            else if (lootedEquipmentType == EquipmentType.Canon)
            {
                weaponLootSystem.RemoveEquipmentFromSystem(lootedEquipment);
            }
        }
        #endregion

        return(new DropContent(lootedGoldAmount, lootedEquipment));
    }
Пример #20
0
        /// <summary>
        /// Instantiates an item using static information.
        /// </summary>
        /// <param name="owner">The owner of this item</param>
        /// <param name="lot">The lot of this item</param>
        /// <param name="inventory">The inventory to add the item to, if left empty, this item will be left unmanaged</param>
        /// <param name="count">The count of the item to add</param>
        /// <param name="slot">The slot to add the item to</param>
        /// <param name="extraInfo">Optional LDD to set on the item</param>
        /// <param name="objectId">Explicit object Id for this item, generally only used for player instance items</param>
        /// <param name="rootItem">The root item this item is based on</param>
        /// <param name="isEquipped">Whether the game object has this item equipped or not</param>
        /// <param name="isBound">Whether the game object has bound this item or not</param>
        /// <param name="lootType">Where this item came from</param>
        /// <remarks>Note that <c>Start</c> still needs to be called on the item to be registered properly in the world.</remarks>
        /// <returns>The instantiated item or <c>null</c> if no slot could be acquired or if the item couldn't be added to the inventory</returns>
        public static async Task <Item> Instantiate(GameObject owner, Lot lot,
                                                    Inventory inventory, uint count, uint slot = default, LegoDataDictionary extraInfo = default,
                                                    ObjectId objectId = default, Item rootItem = default, bool isEquipped = false, bool isBound = false, LootType lootType = LootType.None)
        {
            // Try to find the slot at which this item should be inserted if no explicit slot is provided
            if (inventory != default && slot == default)
            {
                try
                {
                    slot = inventory.ClaimSlot();
                }
                catch (InventoryFullException)
                {
                    return(null);
                }
            }

            var itemTemplate      = (await ClientCache.FindAsync <Core.Client.Objects>(lot));
            var itemRegistryEntry = (await ClientCache.FindAllAsync <ComponentsRegistry>(lot)).FirstOrDefault(
                r => r.Componenttype == (int)ComponentId.ItemComponent
                );

            if (itemRegistryEntry == default)
            {
                return(default);
        private bool printData(String type)
        {
            clearOutputPanel();
            if (!map.ContainsKey(type))
            {
                editMessageLabel("No data found.");
                currentLoot = LootType.Unknown;
                return(false);
            }
            if (type.Equals("CHEST"))
            {
                ComboBox chestsComboBox = new ComboBox();
                chestsComboBox.Name  = "chestsComboBox";
                chestsComboBox.Width = 200;
                chestsComboBox.SelectedValueChanged += chestComboBoxChanged;
                chestsComboBox.Items.Insert(0, "Select material");
                outputPanel.Controls.Add(chestsComboBox);
                int index = 1;
                foreach (JsonObject item in map[type])
                {
                    Int64 count = 0;
                    count = (Int64)item["count"];
                    String lootId   = (String)item["lootId"];
                    String lootName = (String)item["lootName"];
                    String itemName = (String)item["localizedName"];
                    if (itemName.Equals(""))
                    {
                        if (lootNames == null)
                        {
                            getNamesFromCommunityDragon();
                        }
                        if (lootName.StartsWith("CHAMPION_TOKEN_"))
                        {
                            itemName = (String)lootNames["loot_name_" + lootName.ToLower()] + (String)item["itemDesc"];
                        }
                        else if (lootName.EndsWith("MATERIAL_key_fragment"))
                        {
                            itemName = (String)lootNames["loot_name_" + lootName.ToLower() + "[other]"] + (String)item["itemDesc"];
                        }
                        else
                        {
                            itemName = (String)lootNames["loot_name_" + lootId.ToLower()];
                        }
                    }
                    chestsComboBox.Items.Insert(index, count + "x " + itemName);
                    index++;
                }
                NumericUpDown numericUpDown = new NumericUpDown();
                numericUpDown.Minimum = 0;
                numericUpDown.Maximum = 999999;
                numericUpDown.Name    = "chestsRepeatNumericUpDown";

                Label label = new Label();
                label.Text     = "Repeat: ";
                label.AutoSize = true;


                ComboBox chestsRecipeComboBox = new ComboBox();
                chestsRecipeComboBox.Name  = "chestsRecipeComboBox";
                chestsRecipeComboBox.Width = 200;
                chestsRecipeComboBox.Items.Insert(0, "Select recipe");

                outputPanel.Controls.Add(label);
                outputPanel.Controls.Add(numericUpDown);
                outputPanel.Controls.Add(chestsRecipeComboBox);
            }
            else
            {
                Int64 numberOfShards = 0;
                foreach (JsonObject item in map[type])
                {
                    Int64 count = (Int64)item["count"];
                    numberOfShards += count;
                }

                Label uniqueLabel = new Label();
                uniqueLabel.Text  = "Unique shards:";
                uniqueLabel.Width = 200;
                outputPanel.Controls.Add(uniqueLabel);

                NumericUpDown uniqueNumbericUpDown = new NumericUpDown();
                uniqueNumbericUpDown.Minimum = map[type].Count;
                uniqueNumbericUpDown.Maximum = map[type].Count;
                outputPanel.Controls.Add(uniqueNumbericUpDown);

                Label totalLabel = new Label();
                totalLabel.Text  = "All shards:";
                totalLabel.Width = 200;
                outputPanel.Controls.Add(totalLabel);

                NumericUpDown totalNumbericUpDown = new NumericUpDown();
                totalNumbericUpDown.Minimum = numberOfShards;
                totalNumbericUpDown.Maximum = numberOfShards;
                outputPanel.Controls.Add(totalNumbericUpDown);

                foreach (JsonObject item in map[type])
                {
                    Int64 count = 0;
                    count = (Int64)item["count"];
                    String itemDesc = (String)item["localizedName"];
                    if (itemDesc.Equals(""))
                    {
                        itemDesc = (String)item["itemDesc"];
                    }
                    String        lootId        = (String)item["lootId"];
                    NumericUpDown numericUpDown = new NumericUpDown();
                    numericUpDown.Minimum = 0;
                    numericUpDown.Maximum = count;
                    numericUpDown.Name    = lootId;

                    Label label = new Label();
                    label.Text  = count + "x " + itemDesc;
                    label.Width = 200;

                    outputPanel.Controls.Add(label);
                    outputPanel.Controls.Add(numericUpDown);
                }
            }
            editMessageLabel("Loaded.");
            return(true);
        }
Пример #22
0
 public KeyringEntry( uint value, Item link, int range, int itemid, LootType loot, string desc )
 {
     m_KeyValue = value;
     m_Link = link;
     m_MaxRange = range;
     m_ItemID = itemid;
     m_LootType = loot;
     m_Description = desc;
 }
		public virtual void Deserialize( GenericReader reader )
		{
			int version = reader.ReadInt();
			
			switch( version )
			{
				case 2:
				{
					_LootType = (LootType)reader.ReadInt();
					_Insured = reader.ReadBool();
					goto case 1;
				}
				case 1:
				{
					_Hue = reader.ReadInt();
					goto case 0;
				}
				case 0:
				default:
				{
					_Type = ScriptCompiler.FindTypeByName( reader.ReadString() );
					_Name = reader.ReadString();
					break;
				}
			}
				
			
			if( version == 0 )
			{
				//default hue from previous version;
				_Hue = 1153;
			}
			
			
		}
		//master constructor
		public ItemListEntry( Item item, string name, int hue )
		{
			
			_Type = item.GetType();
			_Name = name;
			_Hue = hue;
			_LootType = item.LootType;
			_Insured = item.Insured;
			
		}
Пример #25
0
        public KeyringEntry( GenericReader reader )
        {
            int version = reader.ReadByte();

            switch ( version )
            {
                case 0:
                {
                    m_KeyValue = reader.ReadUInt();
                    m_Link = reader.ReadItem();
                    m_MaxRange = reader.ReadInt();
                    m_ItemID = reader.ReadInt();
                    m_LootType = (LootType)reader.ReadByte();
                    m_Description = reader.ReadString();

                    break;
                }
            }
        }
Пример #26
0
 public Loot(LootType lootType, params string[] critterKeys)
 {
     this.lootType = lootType;
     this.critterKeys = critterKeys;
 }
Пример #27
0
		public void Deserialize( GenericReader reader )
		{
			int version = reader.ReadInt();
			
			switch( version )
			{
				case 3:
				{
					LockWithdrawalAmount = reader.ReadBool();
					goto case 2;
				}
				
				case 2:
				{
					Insured = reader.ReadBool();
					goto case 1;
				}
					
				//case 1: added reference for loottype of parent object, as well as columns to display on gump
				case 1:
				{
					LootType = (LootType)reader.ReadInt();
					DisplayColumns = reader.ReadInt();
					goto case 0;
				}
				case 0:
				default:
				{
					Label = reader.ReadString();
					Dynamic = reader.ReadBool();
					OfferDeeds = reader.ReadBool();
					
					WithdrawAmount = reader.ReadInt();
					MinWithdrawAmount = reader.ReadInt();
					
					int entrycount = reader.ReadInt();
					
					//read in the active items
					if( entrycount > 0 )
					{
						for( int i = 0; i < entrycount; i++ )
						{
							//dynamically create store entries, ore derived ones, based on the type name stored in the serial data, then add it to the serial data reader
							
							//WARNING... this is very delicate!!  if an improper type name was saved to the serial data (eg. if a tool or resource used to belong to a tool, and was removed from the shard) then an exception will be thrown here.
							//be sure to remove any and all tool types from keys, and cycle a world load/save before taking that class out
							
							StoreEntry entry = (StoreEntry)Activator.CreateInstance( ScriptCompiler.FindTypeByName( reader.ReadString() ), new object[]{ reader } );
						
							//register this store with the entry for refresh purposes
							entry.Store = this;
							StoreEntries.Add( entry );
						}
					}
					
					//read in the expelled items
					
					entrycount = reader.ReadInt();
					
					if( entrycount > 0 )
					{
						for( int i = 0; i < entrycount; i++ )
						{
							StoreEntry entry = (StoreEntry)Activator.CreateInstance( ScriptCompiler.FindTypeByName( reader.ReadString() ), new object[]{ reader } );
							//register this store with the entry for refresh purposes
							entry.Store = this;
							
							ExpelStoreEntries.Add( entry );
						}
					}
					break;
				}
				
				
				
			}
			
			
			
		}//deserialize
Пример #28
0
 public void SetLootToAward(LootType loot)
 {
     lootOnKill = loot;
 }
Пример #29
0
 /// <summary>
 /// Sets attributes loottype and implemented
 /// </summary>
 /// <param name="type"></param>
 /// <param name="implemented"></param>
 public GameItemAttribute(LootType type, bool implemented = true)
 {
     this.LootType    = type;
     this.Implemented = implemented;
 }
Пример #30
0
 public LootData(LootType lootType, int amount, int[] param)
 {
     LootType = lootType;
     Amount   = amount;
     Params   = param;
 }
Пример #31
0
 public static string GetFullLootName(LootType type, int[] prms)
 {
     return(type.ToString("d") + "_" + string.Join("", prms));
 }
Пример #32
0
    public void SetAlert(LootType loot)
    {
        var newAlert = alertPanel.Get <AlertPanel>(alertPosition, Quaternion.identity);

        newAlert.TriggerAlert(loot);
    }
Пример #33
0
		public static Item ChangeLootType( Item item, LootType type )
		{
			item.LootType = type;
			return item;
		}
Пример #34
0
		public void AddItem(Item item, LootType type)
		{
			item.LootType = type;
			AddItem(item);
		}
Пример #35
0
 public Loot( LootType lootType, uint amount = 1)
 {
     this.lootType = lootType;
     this.amount = amount;
 }
Пример #36
0
 public void LootGround(LootType lootType)
 {
     LootGround(lootType, false);
 }
		//clone constructor
		public ItemListEntry( ItemListEntry entry )
		{
			_Type = entry.Type;
			_Name = entry.Name;
			_Hue = entry.Hue;
			_LootType = entry.LootType;
			_Insured = entry.Insured;
			
		}
Пример #38
0
        public void LootGround(LootType lootType, bool lootAll)
        {
            //List<UOItem> searchItems = new List<UOItem>();
            List <UOItem> ground = new List <UOItem>();

            ground.AddRange(World.Ground.ToArray());

            List <UOItem> search = new List <UOItem>();

            int done   = 0;
            int toDo   = 0;
            int bodies = 0;

            List <Serial> bpkState = ItemHelper.ContainerState(World.Player.Backpack);

            foreach (UOItem item in ground)
            {
                if (item.Graphic == 0x2006)
                {
                    bodies++;
                    if (cutedBodies.Contains(item.Serial))
                    {
                        done++;
                    }
                    else
                    {
                        toDo++;
                        if (item.Distance <= 6)
                        {
                            search.Add(item);
                        }
                    }
                }
            }

            for (int i = 0; i < search.Count; i++)//(UOItem item in search)
            {
                UOItem item = search[i];
                Game.PrintMessage(String.Format("Try Loot Body [{0}/{1}]", i + 1, search.Count), Game.Val_LightGreen);

                if (!item.Opened)
                {
                    Journal.Clear();
                    item.Use();
                    if (Journal.WaitForText(true, 250, "You can't reach that"))
                    {
                        UO.PrintObject(item.Serial, Game.Val_LightGreen, "[Can't reach]");
                        continue;
                    }
                }

                List <UOItem> items = new List <UOItem>();
                items.AddRange(item.Items.ToArray());

                bool hasLootBag = items.Count(si => si.Graphic == 0x0E76 && si.Color == 0x049A) > 0;



                if (!hasLootBag)
                {
                    foreach (UOItem bag in items.Where(b => b.Graphic == 0x0E76))
                    {
                        if (String.IsNullOrEmpty(bag.Name))
                        {
                            bag.Click();
                            Game.Wait(175);


                            if ((bag.Name + String.Empty).ToLower().StartsWith("loot"))
                            {
                                hasLootBag = true;
                                break;
                            }
                        }
                    }
                }

                //Notepad.WriteLine("LootManual: " + item.Description);
                //Notepad.WriteLine("LootManual hasLootBag: " + hasLootBag);
                //Notepad.WriteLine("LootManual items: " + items.Count);

                //return;

                if (hasLootBag || lootAll || item.Distance <= 1) //item.Items.FindType(0x0E76, 0x049A).Exist)// lootbag
                {
                    UO.PrintObject(item.Serial, Game.Val_LightGreen, "[Looting...]");

                    if (DwarfKnife.Exist && (hasLootBag || item.Distance <= 1) && !lootAll)//TODO predelat nejak jinak, ted kvuly tamingu aby to nelotovalo maso a kuze
                    {
                        toDo--;
                        done++;

                        foreach (UOItem lootItem in items)
                        {
                            if (Loot.IsLootItem(lootItem))
                            {
                                lootItem.Move(65000, LootBag);
                                Game.Wait(300);
                            }
                        }

                        DwarfKnife.Use();
                        UO.WaitTargetObject(item);
                        Game.Wait(350);

                        items = new List <UOItem>();
                        items.AddRange(item.Items.ToArray());
                    }

                    if (item.Exist)
                    {
                        foreach (UOItem lootItem in items)
                        {
                            if (Loot.IsLootItem(lootItem) || lootAll)
                            {
                                lootItem.Move(60000, LootBag);
                                Game.Wait(425);
                            }
                        }
                    }
                }

                //cutedBodies.Add(item.Serial);
            }

            World.Player.PrintMessage(String.Format("Bodies remain [{0}]", toDo), Game.Val_LightGreen);

            foreach (UOItem item in World.Ground)
            {
                if (item.Distance <= 6 && item.Graphic == 0x0E76 && item.Color == 0x049A)//IsLootItem(item))//jen lootbag
                {
                    item.Move(60000, LootBag);
                    Game.Wait(425);
                }
            }

            List <Serial> bpkAfterLoot = ItemHelper.ContainerState(World.Player.Backpack);
            List <Serial> diff         = ItemHelper.ContainerStateDiff(bpkState, bpkAfterLoot);

            Game.PrintMessage("Diff... " + diff.Count);
            if (LootBag.Serial != World.Player.Backpack.Serial)
            {
                foreach (Serial lootedItem in diff)
                {
                    UOItem item = new UOItem(lootedItem);

                    if (item.Container == World.Player.Backpack.Serial)
                    {
                        if (item.Move(65000, LootBag))
                        {
                            Game.PrintMessage("LootItem Moved to Bag...");
                        }
                        Game.Wait();
                    }
                }
            }
        }
Пример #39
0
        /// <summary>
        /// Creates an item drop at the specified location
        /// </summary>
        public void privateItemSpawn(ItemInfo item, ushort quantity, short positionX, short positionY, Player p, LootType type, Bot dead, string name)
        {
            using (LogAssume.Assume(_logger))
            {
                Log.write("[DROP] - {0} dropped for {1}", item.name, p._alias);

                if (item == null)
                {
                    Log.write(TLog.Error, "Attempted to spawn invalid item.");
                    return;
                }

                if (quantity == 0)
                {
                    Log.write(TLog.Warning, "Attempted to spawn 0 of an item.");
                    return;
                }

                //Too many items?
                if (_arena._items.Count == Arena.maxItems)
                {
                    Log.write(TLog.Warning, "Item count full.");
                    return;
                }

                int            blockedAttempts = 35;
                Arena.ItemDrop spawn           = null;

                short pX;
                short pY;
                while (true)
                {
                    pX = positionX;
                    pY = positionY;
                    Helpers.randomPositionInArea(_arena, _arena._server._zoneConfig.arena.pruneDropRadius, ref pX, ref pY);
                    if (_arena.getTile(pX, pY).Blocked)
                    {
                        blockedAttempts--;
                        if (blockedAttempts <= 0)
                        {
                            //Consider the spawn to be blocked
                            return;
                        }
                        continue;
                    }

                    //We want to continue wrapping around the vehicleid limits
                    //looking for empty spots.
                    ushort ik;

                    for (ik = _arena._lastItemKey; ik <= Int16.MaxValue; ++ik)
                    {   //If we've reached the maximum, wrap around
                        if (ik == Int16.MaxValue)
                        {
                            ik = (ushort)ZoneServer.maxPlayers;
                            continue;
                        }

                        //Does such an item exist?
                        if (_arena._items.ContainsKey(ik))
                        {
                            continue;
                        }

                        //We have a space!
                        break;
                    }



                    _arena._lastItemKey = ik;

                    //Create our drop class
                    Arena.ItemDrop id = new Arena.ItemDrop();

                    id.item       = item;
                    id.id         = ik;
                    id.quantity   = (short)quantity;
                    id.positionX  = pX;
                    id.positionY  = pY;
                    id.relativeID = item.relativeID;
                    id.freq       = p._team._id;

                    id.owner = p; //For bounty abuse upon pickup

                    //Add it to our private loot tracker
                    _script._privateLoot.Add(id.id, new LootDrop(id, p, Environment.TickCount, ik));

                    int expire = _arena.getTerrain(positionX, positionY).prizeExpire;
                    id.tickExpire = (expire > 0 ? (Environment.TickCount + (expire * 1000)) : 0);

                    //Add it to our list
                    _arena._items[ik] = id;
                    //Notify the player
                    Helpers.Object_ItemDrop(_arena.Players, id);


                    if (type > LootType.Common)
                    {
                        foreach (Player player in _arena.Players)
                        {
                            if (player == p)
                            {
                                player.sendMessage(1, String.Format("$A {0} just dropped {1} for you at {2}",
                                                                    dead._type.Name, name, Helpers.posToLetterCoord(id.positionX, id.positionY)));
                            }
                            else
                            {
                                player.triggerMessage(5, 1000, String.Format("A {0} just dropped {1} for {2} at {3}",
                                                                             dead._type.Name, name, p._alias, Helpers.posToLetterCoord(id.positionX, id.positionY)));
                            }
                        }
                    }
                    break;
                }
            }
        }
Пример #40
0
        public void Deserialize(GenericReader reader)
        {
            int version = reader.ReadInt();

            switch (version)
            {
            case 3:
            {
                LockWithdrawalAmount = reader.ReadBool();
                goto case 2;
            }

            case 2:
            {
                Insured = reader.ReadBool();
                goto case 1;
            }

            //case 1: added reference for loottype of parent object, as well as columns to display on gump
            case 1:
            {
                LootType       = (LootType)reader.ReadInt();
                DisplayColumns = reader.ReadInt();
                goto case 0;
            }

            case 0:
            default:
            {
                Label      = reader.ReadString();
                Dynamic    = reader.ReadBool();
                OfferDeeds = reader.ReadBool();

                WithdrawAmount    = reader.ReadInt();
                MinWithdrawAmount = reader.ReadInt();

                int entrycount = reader.ReadInt();

                //read in the active items
                if (entrycount > 0)
                {
                    for (int i = 0; i < entrycount; i++)
                    {
                        //dynamically create store entries, ore derived ones, based on the type name stored in the serial data, then add it to the serial data reader

                        //WARNING... this is very delicate!!  if an improper type name was saved to the serial data (eg. if a tool or resource used to belong to a tool, and was removed from the shard) then an exception will be thrown here.
                        //be sure to remove any and all tool types from keys, and cycle a world load/save before taking that class out

                        StoreEntry entry = (StoreEntry)Activator.CreateInstance(ScriptCompiler.FindTypeByName(reader.ReadString()), new object[] { reader });

                        //register this store with the entry for refresh purposes
                        entry.Store = this;
                        StoreEntries.Add(entry);
                    }
                }

                //read in the expelled items

                entrycount = reader.ReadInt();

                if (entrycount > 0)
                {
                    for (int i = 0; i < entrycount; i++)
                    {
                        StoreEntry entry = (StoreEntry)Activator.CreateInstance(ScriptCompiler.FindTypeByName(reader.ReadString()), new object[] { reader });
                        //register this store with the entry for refresh purposes
                        entry.Store = this;

                        ExpelStoreEntries.Add(entry);
                    }
                }
                break;
            }
            }
        }        //deserialize
Пример #41
0
    public void AddItem(LootType type, int info)
    {
        if (type == LootType.Item)
        {
            GameObject tempItem = null;
            if (itemNum == 0)
            {
                sdLootItem item = itemList[0] as sdLootItem;
                item.SetInfo(type, info);
                item.gameObject.SetActive(true);
                itemNum++;
            }
            else if (itemNum < MaxLootItem)
            {
                tempItem = GameObject.Instantiate(copyItem) as GameObject;
                tempItem.transform.parent        = copyItem.transform.parent;
                tempItem.transform.localScale    = new Vector3(1, 1, 1);
                tempItem.transform.localPosition = copyItem.transform.localPosition;
                tempItem.SetActive(true);
                sdLootItem item = tempItem.GetComponent <sdLootItem>();
                item.SetInfo(type, info);
                item.index = itemNum;
                itemList.Add(itemNum, item);
                itemNum++;
            }
            else
            {
                sdLootItem changeItem = null;
                for (int i = 0; i < MaxLootItem; ++i)
                {
                    sdLootItem item = itemList[i] as sdLootItem;
                    if (i == 0)
                    {
                        item.index = MaxLootItem - 1;
                        changeItem = item;
                        item.SetInfo(type, info);
                        itemList[i] = null;
                    }
                    else if (i != MaxLootItem - 1)
                    {
                        item.index      = i - 1;
                        itemList[i - 1] = item;
                        itemList[i]     = null;
                    }
                    else
                    {
                        item.index      = i - 1;
                        itemList[i - 1] = item;
                        itemList[i]     = changeItem;
                    }
                }
            }
        }
        else
        {
            GameObject tempItem = null;
            if (itemNum == 0)
            {
                sdLootItem item = itemList[0] as sdLootItem;
                item.SetInfo(type, info);
                item.gameObject.SetActive(true);
                itemNum++;
            }
            else if (itemNum < MaxLootItem)
            {
                bool flag = false;
                for (int i = 0; i < itemNum; ++i)
                {
                    sdLootItem lootItem = itemList[i] as sdLootItem;
                    if (lootItem.lootType == LootType.Money && !lootItem.isFinish)
                    {
                        lootItem.RefreshMoney(info);
                        flag = true;
                    }
                }

                if (!flag)
                {
                    tempItem = GameObject.Instantiate(copyItem) as GameObject;
                    tempItem.transform.parent        = copyItem.transform.parent;
                    tempItem.transform.localScale    = new Vector3(1, 1, 1);
                    tempItem.transform.localPosition = copyItem.transform.localPosition;
                    tempItem.SetActive(true);
                    sdLootItem item = tempItem.GetComponent <sdLootItem>();
                    item.SetInfo(type, info);
                    item.index = itemNum;
                    itemList.Add(itemNum, item);
                    itemNum++;
                }
            }
            else
            {
                bool flag = false;
                for (int i = 0; i < itemNum; ++i)
                {
                    sdLootItem lootItem = itemList[i] as sdLootItem;
                    if (lootItem.lootType == LootType.Money && !lootItem.isFinish)
                    {
                        lootItem.RefreshMoney(info);
                        flag = true;
                    }
                }
                if (!flag)
                {
                    sdLootItem changeItem = null;
                    for (int i = 0; i < MaxLootItem; ++i)
                    {
                        sdLootItem item = itemList[i] as sdLootItem;
                        if (i == 0)
                        {
                            item.index = MaxLootItem - 1;
                            changeItem = item;
                            item.SetInfo(type, info);
                            itemList[i] = null;
                        }
                        else if (i != MaxLootItem - 1)
                        {
                            item.index      = i - 1;
                            itemList[i - 1] = item;
                            itemList[i]     = null;
                        }
                        else
                        {
                            item.index      = i - 1;
                            itemList[i - 1] = item;
                            itemList[i]     = changeItem;
                        }
                    }
                }
            }
        }

        Reposition();
    }
Пример #42
0
        public virtual void Deserialize( GenericReader reader )
        {
            int version = reader.ReadInt();

            SetLastMoved();

            switch ( version )
            {
                case 7:
                case 6:
                {
                    SaveFlag flags = (SaveFlag)reader.ReadInt();

                    if ( version < 7 )
                    {
                        LastMoved = reader.ReadDeltaTime();
                    }
                    else
                    {
                        int minutes = reader.ReadEncodedInt();

                        try{ LastMoved = Core.Now - TimeSpan.FromMinutes( minutes ); }
                        catch{ LastMoved = Core.Now; }
                    }

                    if ( GetSaveFlag( flags, SaveFlag.Direction ) )
                        m_Direction = (Direction)reader.ReadByte();

                    if ( GetSaveFlag( flags, SaveFlag.Bounce ) )
                        m_Bounce = BounceInfo.Deserialize( reader );

                    if ( GetSaveFlag( flags, SaveFlag.LootType ) )
                        m_LootType = (LootType)reader.ReadByte();

                    int x = 0, y = 0, z = 0;

                    if ( GetSaveFlag( flags, SaveFlag.LocationFull ) )
                    {
                        x = reader.ReadEncodedInt();
                        y = reader.ReadEncodedInt();
                        z = reader.ReadEncodedInt();
                    }
                    else
                    {
                        if ( GetSaveFlag( flags, SaveFlag.LocationByteXY ) )
                        {
                            x = reader.ReadByte();
                            y = reader.ReadByte();
                        }
                        else if ( GetSaveFlag( flags, SaveFlag.LocationShortXY ) )
                        {
                            x = reader.ReadShort();
                            y = reader.ReadShort();
                        }

                        if ( GetSaveFlag( flags, SaveFlag.LocationSByteZ ) )
                            z = reader.ReadSByte();
                    }

                    m_Location = new Point3D( x, y, z );

                    if ( GetSaveFlag( flags, SaveFlag.ItemID ) )
                        m_ItemID = reader.ReadEncodedInt();

                    if ( GetSaveFlag( flags, SaveFlag.Hue ) )
                        m_Hue = reader.ReadEncodedInt();

                    if ( GetSaveFlag( flags, SaveFlag.Amount ) )
                        m_Amount = reader.ReadEncodedInt();
                    else
                        m_Amount = 1;

                    if ( GetSaveFlag( flags, SaveFlag.Layer ) )
                        m_Layer = (Layer)reader.ReadByte();

                    if ( GetSaveFlag( flags, SaveFlag.Name ) )
                        m_Name = string.Intern(reader.ReadString());

                    if ( GetSaveFlag( flags, SaveFlag.Parent ) )
                    {
                        Serial parent = reader.ReadInt();

                        if ( parent.IsMobile )
                            m_Parent = World.FindMobile( parent );
                        else if ( parent.IsItem )
                            m_Parent = World.FindItem( parent );
                        else
                            m_Parent = null;

                        if ( m_Parent == null && (parent.IsMobile || parent.IsItem) )
                            Delete();
                    }

                    if ( GetSaveFlag( flags, SaveFlag.Items ) )
                        m_Items = reader.ReadItemList();
                    //else
                    //	m_Items = new ArrayList( 1 );

                    if ( GetSaveFlag( flags, SaveFlag.IntWeight ) )
                        m_Weight = reader.ReadEncodedInt();
                    else if ( GetSaveFlag( flags, SaveFlag.WeightNot1or0 ) )
                        m_Weight = reader.ReadDouble();
                    else if ( GetSaveFlag( flags, SaveFlag.WeightIs0 ) )
                        m_Weight = 0.0;
                    else
                        m_Weight = 1.0;

                    if ( GetSaveFlag( flags, SaveFlag.Map ) )
                        m_Map = reader.ReadMap();
                    else
                        m_Map = Map.Internal;

                    if ( GetSaveFlag( flags, SaveFlag.Visible ) )
                        SetFlag( ImplFlag.Visible, reader.ReadBool() );
                    else
                        SetFlag( ImplFlag.Visible, true );

                    if ( GetSaveFlag( flags, SaveFlag.Movable ) )
                        SetFlag( ImplFlag.Movable, reader.ReadBool() );
                    else
                        SetFlag( ImplFlag.Movable, true );

                    if ( GetSaveFlag( flags, SaveFlag.Stackable ) )
                        SetFlag( ImplFlag.Stackable, reader.ReadBool() );

                    if ( GetSaveFlag( flags, SaveFlag.ImplFlags ) )
                        m_Flags = (ImplFlag)reader.ReadEncodedInt();

                    if ( GetSaveFlag( flags, SaveFlag.InsuredFor ) )
                        /*m_InsuredFor = */reader.ReadMobile();

                    if ( GetSaveFlag( flags, SaveFlag.BlessedFor ) )
                        m_BlessedFor = reader.ReadMobile();

                    if ( GetSaveFlag( flags, SaveFlag.HeldBy ) )
                        m_HeldBy = reader.ReadMobile();

                    if ( GetSaveFlag( flags, SaveFlag.SavedFlags ) )
                        m_SavedFlags = reader.ReadEncodedInt();

                    if ( m_Map != null && m_Parent == null )
                        m_Map.OnEnter( this );

                    break;
                }
                case 5:
                {
                    SaveFlag flags = (SaveFlag)reader.ReadInt();

                    LastMoved = reader.ReadDeltaTime();

                    if ( GetSaveFlag( flags, SaveFlag.Direction ) )
                        m_Direction = (Direction)reader.ReadByte();

                    if ( GetSaveFlag( flags, SaveFlag.Bounce ) )
                        m_Bounce = BounceInfo.Deserialize( reader );

                    if ( GetSaveFlag( flags, SaveFlag.LootType ) )
                        m_LootType = (LootType)reader.ReadByte();

                    if ( GetSaveFlag( flags, SaveFlag.LocationFull ) )
                        m_Location = reader.ReadPoint3D();

                    if ( GetSaveFlag( flags, SaveFlag.ItemID ) )
                        m_ItemID = reader.ReadInt();

                    if ( GetSaveFlag( flags, SaveFlag.Hue ) )
                        m_Hue = reader.ReadInt();

                    if ( GetSaveFlag( flags, SaveFlag.Amount ) )
                        m_Amount = reader.ReadInt();
                    else
                        m_Amount = 1;

                    if ( GetSaveFlag( flags, SaveFlag.Layer ) )
                        m_Layer = (Layer)reader.ReadByte();

                    if ( GetSaveFlag( flags, SaveFlag.Name ) )
                        m_Name = string.Intern(reader.ReadString());

                    if ( GetSaveFlag( flags, SaveFlag.Parent ) )
                    {
                        Serial parent = reader.ReadInt();

                        if ( parent.IsMobile )
                            m_Parent = World.FindMobile( parent );
                        else if ( parent.IsItem )
                            m_Parent = World.FindItem( parent );
                        else
                            m_Parent = null;

                        if ( m_Parent == null && (parent.IsMobile || parent.IsItem) )
                            Delete();
                    }

                    if ( GetSaveFlag( flags, SaveFlag.Items ) )
                        m_Items = reader.ReadItemList();
                    //else
                    //	m_Items = new ArrayList( 1 );

                    if ( GetSaveFlag( flags, SaveFlag.IntWeight ) )
                        m_Weight = reader.ReadEncodedInt();
                    else if ( GetSaveFlag( flags, SaveFlag.WeightNot1or0 ) )
                        m_Weight = reader.ReadDouble();
                    else if ( GetSaveFlag( flags, SaveFlag.WeightIs0 ) )
                        m_Weight = 0.0;
                    else
                        m_Weight = 1.0;

                    if ( GetSaveFlag( flags, SaveFlag.Map ) )
                        m_Map = reader.ReadMap();
                    else
                        m_Map = Map.Internal;

                    if ( GetSaveFlag( flags, SaveFlag.Visible ) )
                        SetFlag( ImplFlag.Visible, reader.ReadBool() );
                    else
                        SetFlag( ImplFlag.Visible, true );

                    if ( GetSaveFlag( flags, SaveFlag.Movable ) )
                        SetFlag( ImplFlag.Movable, reader.ReadBool() );
                    else
                        SetFlag( ImplFlag.Movable, true );

                    if ( GetSaveFlag( flags, SaveFlag.Stackable ) )
                        SetFlag( ImplFlag.Stackable, reader.ReadBool() );

                    if ( m_Map != null && m_Parent == null )
                        m_Map.OnEnter( this );

                    break;
                }
                case 4: // Just removed variables
                case 3:
                {
                    m_Direction = (Direction)reader.ReadInt();

                    goto case 2;
                }
                case 2:
                {
                    m_Bounce = BounceInfo.Deserialize( reader );
                    LastMoved = reader.ReadDeltaTime();

                    goto case 1;
                }
                case 1:
                {
                    m_LootType = (LootType) reader.ReadByte();//m_Newbied = reader.ReadBool();

                    goto case 0;
                }
                case 0:
                {
                    m_Location = reader.ReadPoint3D();
                    m_ItemID = reader.ReadInt();
                    m_Hue = reader.ReadInt();
                    m_Amount = reader.ReadInt();
                    m_Layer = (Layer) reader.ReadByte();
                    m_Name = reader.ReadString();
                    if (m_Name != null)
                        m_Name = string.Intern(m_Name);

                    Serial parent = reader.ReadInt();

                    if ( parent.IsMobile )
                        m_Parent = World.FindMobile( parent );
                    else if ( parent.IsItem )
                        m_Parent = World.FindItem( parent );
                    else
                        m_Parent = null;

                    if ( m_Parent == null && (parent.IsMobile || parent.IsItem) )
                        Delete();

                    int count = reader.ReadInt();

                    if ( count > 0 )
                    {
                        m_Items = new ArrayList( count );

                        for ( int i = 0; i < count; ++i )
                        {
                            Item item = reader.ReadItem();

                            if ( item != null )
                                m_Items.Add( item );
                        }
                    }

                    m_Weight = reader.ReadDouble();

                    if ( version <= 3 )
                    {
                        /*m_TotalItems =*/ reader.ReadInt();
                        /*m_TotalWeight =*/ reader.ReadInt();
                        /*m_TotalGold =*/ reader.ReadInt();
                    }

                    m_Map = reader.ReadMap();
                    SetFlag( ImplFlag.Visible, reader.ReadBool() );
                    SetFlag( ImplFlag.Movable, reader.ReadBool() );

                    if ( version <= 3 )
                        /*m_Deleted =*/ reader.ReadBool();

                    Stackable = reader.ReadBool();

                    if ( m_Map != null && m_Parent == null )
                        m_Map.OnEnter( this );

                    break;
                }
            }

            if ( m_HeldBy != null )
                Timer.DelayCall( TimeSpan.Zero, new TimerCallback( FixHolding_Sandbox ) );
        }
Пример #43
0
    /// <summary>
    /// Called when holding the fishing rod
    /// </summary>
    /// <param name="_data">A reference to the items inventory data.</param>
    public override void OnHoldingUpdate(ItemInventoryData _data)
    {
        // Debug
        //DisplayChatAreaText("OnHoldingUpdate");

        // Base code - no need to run it for the rod.
        //base.OnHoldingUpdate(_data);

        // Don't run this code if remote entity
        if (_data.holdingEntity.isEntityRemote)
        {
            return;
        }
        // check if the player is aiming at water
        // Check reference to local player
        if (!epLocalPlayer)
        {
            // Get and store a reference to the local player
            epLocalPlayer = GameManager.Instance.World.GetLocalPlayer();

            // Debug
            //DisplayChatAreaText("Reference to local player stored.");
        }
        try
        {
            if (!CheckWaterInRange())
            {
                if (boolAimingWater)
                {
                    boolAimingWater = false;
                    DisplayToolTipText("Man... I can't fish here...");
                    ResetFishing();
                }
                return;
            }
            else
            {
                if (!boolAimingWater)
                {
                    if (CheckAnimatorReference(_data))
                    {
                        ResetFishing();
                        if (epLocalPlayer)
                        {
                            MultiBuffClassAction multiBuffClassAction = MultiBuffClassAction.NewAction("fishingWater");
                            multiBuffClassAction.Execute(epLocalPlayer.entityId, (EntityAlive)epLocalPlayer, false,
                                                         EnumBodyPartHit.None, (string)null);
                        }
                    }
                    boolAimingWater = true;
                    DisplayToolTipText("Yea... This looks like a nice spot.");
                }
            }
        }
        catch (Exception)
        {
            DisplayChatAreaText("DEBUG: Oops something went wrong with the fishing mod.");
        }
        // Check if the player is already fishing
        if (true)
        {
            #region Hook event expired;

            if (boolFishHooked && boolAimingWater)
            {
                if (DateTime.Now > dteEndHook)
                {
                    animator.SetTrigger("stopFishing");
                    DisplayToolTipText("Shit... Whatever it was... It's gone!");
                    boolFishHooked = false;
                    dteNextAction  = DateTime.Now.AddSeconds(0.5);
                }
            }

            #endregion ;

            #region fish event expired;

            if (boolFishing && boolAimingWater)
            {
                if (DateTime.Now > dteEndFish)
                {
                    animator.SetTrigger("stopFishing");
                    if (intLoot != LootType.nothing)
                    {
                        DisplayToolTipText("Great... It's gone... Let's be faster next time, shall we?");
                    }
                    else
                    {
                        DisplayToolTipText("Oh well... Shall we try again?");
                    }
                    boolFishing   = false;
                    intLoot       = LootType.nothing;
                    dteNextAction = DateTime.Now.AddSeconds(0.5);
                }
            }

            #endregion ;

            #region Wait for bait;

            if (!boolFishHooked && !boolRodBaited && !boolBaitWait && !boolFishing && boolAimingWater)
            {
                if (DateTime.Now > dteNextAction)
                {
                    if (animator)
                    {
                        animator.SetTrigger("waitBait");
                        boolBaitWait  = true;
                        dteNextAction = DateTime.Now.AddSeconds(0.5);
                    }
                }
            }

            #endregion ;

            #region Bait rod;

            // bait rod if not already baited, no hook event present, and no loot to get.
            if (Input.GetKey(KeyCode.R) && boolAimingWater && !boolRodBaited && !boolFishHooked && boolBaitWait)
            {
                if (DateTime.Now > dteNextAction)
                {
                    ItemValue earthworm = ItemClass.GetItem("earthworm", false);
                    int       numWorms  = epLocalPlayer.bag.GetItemCount(earthworm);
                    if (numWorms >= 1)
                    {
                        bool itemGood = true;
                        // cause decay
                        if (_data.itemValue.MaxUseTimes > 0)
                        {
                            ItemValue itemValue = _data.itemValue;
                            itemValue.UseTimes += AttributeBase.GetVal <AttributeDegradationRate>(_data.itemValue, 1);
                            _data.itemValue     = itemValue;
                            if (_data.itemValue.MaxUseTimes > 0 &&
                                _data.itemValue.UseTimes >= _data.itemValue.MaxUseTimes ||
                                _data.itemValue.UseTimes == 0 && _data.itemValue.MaxUseTimes == 0)
                            {
                                // cane is broken
                                itemGood = false;
                                DisplayToolTipText("Hmm, i think i've been fishing too much... Need to fix this...");
                            }
                        }
                        if (itemGood)
                        {
                            epLocalPlayer.bag.DecItem(earthworm, 1);
                            if (animator)
                            {
                                animator.SetTrigger("stopFishing");
                                DisplayToolTipText("Alright! Got this thing baited, let's see what I get...");
                                boolRodBaited = true;
                                boolBaitWait  = false;
                            }
                            dteNextAction = DateTime.Now.AddSeconds(2);
                        }
                        else
                        {
                            dteNextAction = DateTime.Now.AddSeconds(0.5);
                        }
                    }
                    else
                    {
                        DisplayToolTipText("You don't have enough earth worms...");
                        dteNextAction = DateTime.Now.AddSeconds(0.5);
                    }
                }
            }

            #endregion ;

            #region Hook event;

            // if baited and not fish hooked...
            if (boolRodBaited && !boolFishHooked && boolAimingWater && !boolFishing)
            {
                // randomly does hook warning -> it lasts 2 seconds.
                if (DateTime.Now > dteNextAction)
                {
                    System.Random r       = new System.Random();
                    int           hookNow = r.Next(1, 101);
                    if (hookNow <= 8)
                    {
                        if (animator)
                        {
                            this.boolFishHooked = true;
                            boolRodBaited       = false; // always looses the bait here.
                            // decides what the loot will be here, to determine what time the player will have to react
                            // the rarer the loot the less time he has
                            intLoot = Choose(_data);
                            double timeToReact = numLootTypes - 2;
                            if (intLoot > 0 && intLoot != LootType.nothing)
                            {
                                timeToReact = timeToReact / intLoot.GetHashCode();
                            }
                            animator.SetTrigger("fishHook");
                            dteEndHook = DateTime.Now.AddSeconds(timeToReact);
                            //DisplayToolTipText("You've hooked something");
                            dteNextAction = DateTime.Now.AddSeconds(0.1);
                        }
                    }
                    else
                    {
                        // next possible bite will only be evaluated every one second
                        dteNextAction = DateTime.Now.AddSeconds(1);
                    }
                }
            }

            #endregion ;

            #region Hook Pull;

            // pulls the rod, decides what is the loot and waits 2 seconds...
            // if the player doesn't react, puff... Loot is gone!
            if (boolFishHooked && boolAimingWater)
            {
                if (Input.GetKey(KeyCode.Keypad1) || Input.GetKey(KeyCode.Mouse0) || Input.GetMouseButton(0))
                {
                    if (DateTime.Now > dteNextAction)
                    {
                        boolFishHooked = false;
                        if (animator)
                        {
                            animator.SetTrigger("hookPull");
                            boolFishing = true;
                            // see what was gotten, and show the proper animation
                            if (intLoot == LootType.nothing)
                            {
                                DisplayToolTipText("What the f**k? Nothing?");
                            }
                            else if (intLoot == LootType.head)
                            {
                                DisplayToolTipText("What... the... f... AAAAAAHHHHH!");
                                animator.SetTrigger("head");
                            }
                            else if (intLoot == LootType.trashBag)
                            {
                                DisplayToolTipText("YES! Got it! hmm... no? what?");
                                animator.SetTrigger("trash");
                            }
                            else if (intLoot == LootType.bigBass || intLoot == LootType.bigSalmon)
                            {
                                DisplayToolTipText("YES! That's a big one!");
                                animator.SetTrigger("bigFish");
                            }
                            else if (intLoot == LootType.salmon)
                            {
                                DisplayToolTipText("A salmon... Tasty!");
                                animator.SetTrigger("smallFish");
                            }
                            else if (intLoot == LootType.bass)
                            {
                                DisplayToolTipText("A nice looking bass fish!");
                                animator.SetTrigger("smallFish");
                            }
                            else
                            {
                                DisplayToolTipText("Better then nothing. Food is food!");
                                animator.SetTrigger("smallFish");
                            }
                            if (intLoot != LootType.nothing)
                            {
                                dteEndFish = DateTime.Now.AddSeconds(10); // 10 seconds to pick the fish up
                            }
                            else
                            {
                                dteEndFish = DateTime.Now.AddSeconds(0.5);
                            }
                        }
                        dteNextAction = DateTime.Now.AddSeconds(0.5);
                    }
                }
            }

            #endregion ;

            #region Get loot;

            // get's whatever is in the hook
            if (boolFishing && boolAimingWater)
            {
                if (Input.GetKey(KeyCode.Keypad2) || Input.GetKey(KeyCode.Mouse1) || Input.GetMouseButton(1))
                {
                    if (DateTime.Now > dteNextAction)
                    {
                        boolFishing = false;
                        if (intLoot != LootType.nothing)
                        {
                            //DisplayToolTipText("Got it... Shall we try again?");
                            //ItemValue lootItem = ItemClass.GetItem(intLoot.ToString());
                            ItemValue lootItem  = ItemClass.GetItem(intLoot.ToString(), false);
                            ItemStack lootStack = new ItemStack(lootItem, 1);
                            epLocalPlayer.bag.AddItem(lootStack);
                        }
                        //else DisplayToolTipText("Oh well... Shall we try again?");
                        ResetFishing();
                        dteNextAction = DateTime.Now.AddSeconds(0.5);
                    }
                }
            }

            #endregion ;
        }
    }
Пример #44
0
 public LootEntry(LootType type = LootType.Nothing)
 {
     Type = type;
 }
Пример #45
0
		public virtual void Deserialize(GenericReader reader)
		{
			int version = reader.ReadInt();

			SetLastMoved();

			// must always read this first
			SaveFlag flags = 0;
			if (version >= 5)
				flags = (SaveFlag)reader.ReadInt32();

			switch (version)
			{
				case 10:
					{	// get the per item custom drop rate
						if (GetSaveFlag(flags, SaveFlag.DropRate))
							m_DropRate = reader.ReadDouble();
					}
					goto case 9;
				case 9:
					goto case 8;
				case 8:
					goto case 7;// change is at bottom of file after ImplFlags are read
				case 7:
					goto case 6;
				case 6:
					{
						if (version < 7)
						{
							LastMoved = reader.ReadDeltaTime();
						}
						else
						{
							int minutes = reader.ReadEncodedInt();

							try { LastMoved = DateTime.Now - TimeSpan.FromMinutes(minutes); }
							catch { LastMoved = DateTime.Now; }
						}

						if (GetSaveFlag(flags, SaveFlag.Direction))
							m_Direction = (Direction)reader.ReadByte();

						if (GetSaveFlag(flags, SaveFlag.Bounce))
							m_Bounce = BounceInfo.Deserialize(reader);

						if (GetSaveFlag(flags, SaveFlag.LootType))
							m_LootType = (LootType)reader.ReadByte();

						int x = 0, y = 0, z = 0;

						if (GetSaveFlag(flags, SaveFlag.LocationFull))
						{
							x = reader.ReadEncodedInt();
							y = reader.ReadEncodedInt();
							z = reader.ReadEncodedInt();
						}
						else
						{
							if (GetSaveFlag(flags, SaveFlag.LocationByteXY))
							{
								x = reader.ReadByte();
								y = reader.ReadByte();
							}
							else if (GetSaveFlag(flags, SaveFlag.LocationShortXY))
							{
								x = reader.ReadShort();
								y = reader.ReadShort();
							}

							if (GetSaveFlag(flags, SaveFlag.LocationSByteZ))
								z = reader.ReadSByte();
						}

						m_Location = new Point3D(x, y, z);

						if (GetSaveFlag(flags, SaveFlag.ItemID))
							m_ItemID = reader.ReadEncodedInt();

						if (GetSaveFlag(flags, SaveFlag.Hue))
							m_Hue = reader.ReadEncodedInt();

						if (GetSaveFlag(flags, SaveFlag.Amount))
							m_Amount = reader.ReadEncodedInt();
						else
							m_Amount = 1;

						if (GetSaveFlag(flags, SaveFlag.Layer))
							m_Layer = (Layer)reader.ReadByte();

						if (GetSaveFlag(flags, SaveFlag.Name))
							m_Name = reader.ReadString();

						if (GetSaveFlag(flags, SaveFlag.Parent))
						{
							Serial parent = reader.ReadInt32();

							if (parent.IsMobile)
								m_Parent = World.FindMobile(parent);
							else if (parent.IsItem)
								m_Parent = World.FindItem(parent);
							else
								m_Parent = null;

							if (m_Parent == null && (parent.IsMobile || parent.IsItem))
								Delete();
						}

						if (GetSaveFlag(flags, SaveFlag.Items))
							m_Items = reader.ReadItemList();
						//else
						//	m_Items = new ArrayList( 1 );

						if (GetSaveFlag(flags, SaveFlag.IntWeight))
							m_Weight = reader.ReadEncodedInt();
						else if (GetSaveFlag(flags, SaveFlag.WeightNot1or0))
							m_Weight = reader.ReadDouble();
						else if (GetSaveFlag(flags, SaveFlag.WeightIs0))
							m_Weight = 0.0;
						else
							m_Weight = 1.0;

						if (GetSaveFlag(flags, SaveFlag.Map))
							m_Map = reader.ReadMap();
						else
							m_Map = Map.Internal;

						if (GetSaveFlag(flags, SaveFlag.Visible))
							SetFlag(ImplFlag.Visible, reader.ReadBool());
						else
							SetFlag(ImplFlag.Visible, true);

						if (GetSaveFlag(flags, SaveFlag.Movable))
							SetFlag(ImplFlag.Movable, reader.ReadBool());
						else
							SetFlag(ImplFlag.Movable, true);

						if (GetSaveFlag(flags, SaveFlag.Stackable))
							SetFlag(ImplFlag.Stackable, reader.ReadBool());

						if (GetSaveFlag(flags, SaveFlag.ImplFlags))
						{
							m_Flags = (ImplFlag)reader.ReadEncodedInt();
						}

						// don't confuse ImplFlag.FreezeDried with SaveFlag.FreezeDried
						// we check different flags because of a version quirk - ask Taran
						if (GetFlag(ImplFlag.FreezeDried))
						{
							TotalWeight = reader.ReadInt32();
							TotalItems = reader.ReadInt32();
							TotalGold = reader.ReadInt32();
						}

						if (GetSaveFlag(flags, SaveFlag.FreezeDried))
						{
							int count = reader.ReadInt();
							m_SerializedContentsIdx = new byte[count];
							for (int i = 0; i < count; i++)
								m_SerializedContentsIdx[i] = reader.ReadByte();
							count = reader.ReadInt();
							m_SerializedContentsBin = new byte[count];
							for (int i = 0; i < count; i++)
								m_SerializedContentsBin[i] = reader.ReadByte();
						}

						if (GetSaveFlag(flags, SaveFlag.InsuredFor))
							/*m_InsuredFor = */
							reader.ReadMobile();

						if (GetSaveFlag(flags, SaveFlag.BlessedFor))
							m_BlessedFor = reader.ReadMobile();

						if (GetSaveFlag(flags, SaveFlag.HeldBy))
							m_HeldBy = reader.ReadMobile();

						if (GetSaveFlag(flags, SaveFlag.SavedFlags))
							m_SavedFlags = reader.ReadEncodedInt();

						//wea: 13/Mar/2007 Rare Factory
						if (GetSaveFlag(flags, SaveFlag.RareData))
							m_RareData = (UInt32)reader.ReadInt();

						if (m_Map != null && m_Parent == null)
							m_Map.OnEnter(this);

						break;
					}
				case 5:
					{
						//SaveFlag flags = (SaveFlag)reader.ReadInt();

						LastMoved = reader.ReadDeltaTime();

						if (GetSaveFlag(flags, SaveFlag.Direction))
							m_Direction = (Direction)reader.ReadByte();

						if (GetSaveFlag(flags, SaveFlag.Bounce))
							m_Bounce = BounceInfo.Deserialize(reader);

						if (GetSaveFlag(flags, SaveFlag.LootType))
							m_LootType = (LootType)reader.ReadByte();

						if (GetSaveFlag(flags, SaveFlag.LocationFull))
							m_Location = reader.ReadPoint3D();

						if (GetSaveFlag(flags, SaveFlag.ItemID))
							m_ItemID = reader.ReadInt();

						if (GetSaveFlag(flags, SaveFlag.Hue))
							m_Hue = reader.ReadInt();

						if (GetSaveFlag(flags, SaveFlag.Amount))
							m_Amount = reader.ReadInt();
						else
							m_Amount = 1;

						if (GetSaveFlag(flags, SaveFlag.Layer))
							m_Layer = (Layer)reader.ReadByte();

						if (GetSaveFlag(flags, SaveFlag.Name))
							m_Name = reader.ReadString();

						if (GetSaveFlag(flags, SaveFlag.Parent))
						{
							Serial parent = reader.ReadInt();

							if (parent.IsMobile)
								m_Parent = World.FindMobile(parent);
							else if (parent.IsItem)
								m_Parent = World.FindItem(parent);
							else
								m_Parent = null;

							if (m_Parent == null && (parent.IsMobile || parent.IsItem))
								Delete();
						}

						if (GetSaveFlag(flags, SaveFlag.Items))
							m_Items = reader.ReadItemList();
						//else
						//	m_Items = new ArrayList( 1 );

						if (GetSaveFlag(flags, SaveFlag.IntWeight))
							m_Weight = reader.ReadEncodedInt();
						else if (GetSaveFlag(flags, SaveFlag.WeightNot1or0))
							m_Weight = reader.ReadDouble();
						else if (GetSaveFlag(flags, SaveFlag.WeightIs0))
							m_Weight = 0.0;
						else
							m_Weight = 1.0;

						if (GetSaveFlag(flags, SaveFlag.Map))
							m_Map = reader.ReadMap();
						else
							m_Map = Map.Internal;

						if (GetSaveFlag(flags, SaveFlag.Visible))
							SetFlag(ImplFlag.Visible, reader.ReadBool());
						else
							SetFlag(ImplFlag.Visible, true);

						if (GetSaveFlag(flags, SaveFlag.Movable))
							SetFlag(ImplFlag.Movable, reader.ReadBool());
						else
							SetFlag(ImplFlag.Movable, true);

						if (GetSaveFlag(flags, SaveFlag.Stackable))
							SetFlag(ImplFlag.Stackable, reader.ReadBool());

						if (m_Map != null && m_Parent == null)
							m_Map.OnEnter(this);


						break;
					}
				case 4: // Just removed variables
				case 3:
					{
						m_Direction = (Direction)reader.ReadInt();

						goto case 2;
					}
				case 2:
					{
						m_Bounce = BounceInfo.Deserialize(reader);
						LastMoved = reader.ReadDeltaTime();

						goto case 1;
					}
				case 1:
					{
						m_LootType = (LootType)reader.ReadByte();//m_Newbied = reader.ReadBool();

						goto case 0;
					}
				case 0:
					{
						m_Location = reader.ReadPoint3D();
						m_ItemID = reader.ReadInt();
						m_Hue = reader.ReadInt();
						m_Amount = reader.ReadInt();
						m_Layer = (Layer)reader.ReadByte();
						m_Name = reader.ReadString();

						Serial parent = reader.ReadInt();

						if (parent.IsMobile)
							m_Parent = World.FindMobile(parent);
						else if (parent.IsItem)
							m_Parent = World.FindItem(parent);
						else
							m_Parent = null;

						if (m_Parent == null && (parent.IsMobile || parent.IsItem))
							Delete();

						int count = reader.ReadInt();

						if (count > 0)
						{
							m_Items = new ArrayList(count);

							for (int i = 0; i < count; ++i)
							{
								Item item = reader.ReadItem();

								if (item != null)
									m_Items.Add(item);
							}
						}

						m_Weight = reader.ReadDouble();

						if (version <= 3)
						{
							/*m_TotalItems =*/
							reader.ReadInt();
							/*m_TotalWeight =*/
							reader.ReadInt();
							/*m_TotalGold =*/
							reader.ReadInt();
						}

						m_Map = reader.ReadMap();
						SetFlag(ImplFlag.Visible, reader.ReadBool());
						SetFlag(ImplFlag.Movable, reader.ReadBool());

						if (version <= 3)
							/*m_Deleted =*/
							reader.ReadBool();

						Stackable = reader.ReadBool();

						if (m_Map != null && m_Parent == null)
							m_Map.OnEnter(this);

						break;
					}
			}

			if (m_HeldBy != null)
				Timer.DelayCall(TimeSpan.Zero, new TimerCallback(FixHolding_Sandbox));
		}
Пример #46
0
        public virtual void Deserialize( GenericReader reader )
        {
            int version = reader.ReadInt();

            SetLastMoved();

            switch ( version )
            {
                case 14:
                    {
                        m_InstanceID = reader.ReadInt();

                        SaveFlag flags = (SaveFlag) reader.ReadInt();

                        int minutes = reader.ReadEncodedInt();

                        try { LastMoved = DateTime.Now - TimeSpan.FromMinutes( minutes ); }
                        catch { LastMoved = DateTime.Now; }

                        if ( GetSaveFlag( flags, SaveFlag.Direction ) )
                            m_Direction = (Direction) reader.ReadByte();

                        if ( GetSaveFlag( flags, SaveFlag.LightType ) )
                            m_LightType = (LightType) reader.ReadByte();

                        if ( GetSaveFlag( flags, SaveFlag.Bounce ) )
                            m_Bounce = BounceInfo.Deserialize( reader );

                        if ( GetSaveFlag( flags, SaveFlag.LootType ) )
                            m_LootType = (LootType) reader.ReadByte();

                        int x = 0, y = 0, z = 0;

                        if ( GetSaveFlag( flags, SaveFlag.LocationFull ) )
                        {
                            x = reader.ReadEncodedInt();
                            y = reader.ReadEncodedInt();
                            z = reader.ReadEncodedInt();
                        }
                        else
                        {
                            if ( GetSaveFlag( flags, SaveFlag.LocationByteXY ) )
                            {
                                x = reader.ReadByte();
                                y = reader.ReadByte();
                            }
                            else if ( GetSaveFlag( flags, SaveFlag.LocationShortXY ) )
                            {
                                x = reader.ReadShort();
                                y = reader.ReadShort();
                            }

                            if ( GetSaveFlag( flags, SaveFlag.LocationSByteZ ) )
                                z = reader.ReadSByte();
                        }

                        m_Location = new Point3D( x, y, z );

                        if ( GetSaveFlag( flags, SaveFlag.ItemID ) )
                            m_ItemID = reader.ReadEncodedInt();

                        if ( GetSaveFlag( flags, SaveFlag.Hue ) )
                            m_Hue = reader.ReadEncodedInt();

                        if ( GetSaveFlag( flags, SaveFlag.Amount ) )
                            m_Amount = reader.ReadEncodedInt();
                        else
                            m_Amount = 1;

                        if ( GetSaveFlag( flags, SaveFlag.Layer ) )
                            m_Layer = (Layer) reader.ReadByte();

                        if ( GetSaveFlag( flags, SaveFlag.Name ) )
                            m_Name = string.Intern( reader.ReadString() );

                        if ( GetSaveFlag( flags, SaveFlag.Parent ) )
                        {
                            Serial parent = reader.ReadInt();

                            if ( parent.IsMobile )
                                m_Parent = World.Instance.FindMobile( parent );
                            else if ( parent.IsItem )
                                m_Parent = World.Instance.FindItem( parent );
                            else
                                m_Parent = null;

                            if ( m_Parent == null && ( parent.IsMobile || parent.IsItem ) )
                                Delete();
                        }

                        if ( GetSaveFlag( flags, SaveFlag.Items ) )
                            m_Items = reader.ReadStrongItemList();

                        if ( GetSaveFlag( flags, SaveFlag.IntWeight ) )
                            m_Weight = reader.ReadEncodedInt();
                        else if ( GetSaveFlag( flags, SaveFlag.WeightNot1or0 ) )
                            m_Weight = reader.ReadDouble();
                        else if ( GetSaveFlag( flags, SaveFlag.WeightIs0 ) )
                            m_Weight = 0.0;
                        else
                            m_Weight = 1.0;

                        if ( GetSaveFlag( flags, SaveFlag.Map ) )
                            m_Map = reader.ReadMap();
                        else
                            m_Map = Map.Internal;

                        if ( GetSaveFlag( flags, SaveFlag.Visible ) )
                            SetFlag( ImplFlag.Visible, reader.ReadBool() );
                        else
                            SetFlag( ImplFlag.Visible, true );

                        if ( GetSaveFlag( flags, SaveFlag.Movable ) )
                            SetFlag( ImplFlag.Movable, reader.ReadBool() );
                        else
                            SetFlag( ImplFlag.Movable, true );

                        if ( GetSaveFlag( flags, SaveFlag.Stackable ) )
                            SetFlag( ImplFlag.Stackable, reader.ReadBool() );

                        if ( GetSaveFlag( flags, SaveFlag.ImplFlags ) )
                            m_Flags = (ImplFlag) reader.ReadEncodedInt();

                        if ( GetSaveFlag( flags, SaveFlag.BlessedFor ) )
                            m_BlessedFor = reader.ReadMobile();

                        if ( GetSaveFlag( flags, SaveFlag.HeldBy ) )
                            m_HeldBy = reader.ReadMobile();

                        if ( GetSaveFlag( flags, SaveFlag.LabelNumber ) )
                            m_LabelNumber = reader.ReadInt();

                        #region Labels
                        if ( GetSaveFlag( flags, SaveFlag.Labels ) )
                        {
                            int length = reader.ReadInt();

                            m_Labels = new string[length];

                            for ( int i = 0; i < length; i++ )
                                m_Labels[i] = reader.ReadString();
                        }
                        #endregion

                        if ( GetSaveFlag( flags, SaveFlag.SavedFlags ) )
                            m_SavedFlags = reader.ReadEncodedInt();

                        if ( m_Map != null && m_Parent == null )
                            m_Map.OnEnter( this );

                        break;
                    }
            }

            if ( m_HeldBy != null )
                Timer.DelayCall( TimeSpan.Zero, new TimerCallback( FixHolding_Sandbox ) );
        }
Пример #47
0
 public PrefabPath(string id, string path, LootType type)
 {
     this.id = id;
     this.path = path;
     this.type = type;
 }
Пример #48
0
        public void LootGround(LootType lootType, bool lootAll)
        {
            //List<UOItem> searchItems = new List<UOItem>();
            List <UOItem> ground = new List <UOItem>();

            ground.AddRange(World.Ground.ToArray());

            List <UOItem> search = new List <UOItem>();

            int done   = 0;
            int toDo   = 0;
            int bodies = 0;

            List <Serial> bpkState = ItemHelper.ContainerState(World.Player.Backpack);

            foreach (UOItem item in ground)
            {
                if (item.Graphic == 0x2006)
                {
                    bodies++;
                    if (cutedBodies.Contains(item.Serial))
                    {
                        done++;
                    }
                    else
                    {
                        toDo++;
                        if (item.Distance <= 6)
                        {
                            search.Add(item);
                        }
                    }
                }
            }

            for (int i = 0; i < search.Count; i++)//(UOItem item in search)
            {
                UOItem item = search[i];
                Game.PrintMessage(String.Format("Try Loot Body [{0}/{1}]", i + 1, search.Count), Game.Val_LightGreen);

                if (!item.Opened)
                {
                    Journal.Clear();
                    item.Use();
                    if (Journal.WaitForText(true, 250, "You can't reach that"))
                    {
                        UO.PrintObject(item.Serial, Game.Val_LightGreen, "[Can't reach]");
                        continue;
                    }
                }

                List <UOItem> items = new List <UOItem>();
                items.AddRange(item.Items.ToArray());


                if (items.FirstOrDefault(si => si.Graphic == 0x0E76 && si.Color == 0x049A) != null || lootAll) //item.Items.FindType(0x0E76, 0x049A).Exist)// lootbag
                {
                    UO.PrintObject(item.Serial, Game.Val_LightGreen, "[Looting...]");

                    if (DwarfKnife.Exist && item.Distance <= 3 && !lootAll)//TODO predelat nejak jinak, ted kvuly tamingu aby to nelotovalo maso a kuze
                    {
                        toDo--;
                        done++;

                        foreach (UOItem lootItem in items)
                        {
                            if (Loot.IsLootItem(lootItem))
                            {
                                lootItem.Move(65000, LootBag);
                                Game.Wait(300);
                            }
                        }

                        DwarfKnife.Use();
                        UO.WaitTargetObject(item);
                        Game.Wait(350);

                        items = new List <UOItem>();
                        items.AddRange(item.Items.ToArray());
                    }

                    if (item.Exist)
                    {
                        foreach (UOItem lootItem in items)
                        {
                            if (Loot.IsLootItem(lootItem) || lootAll)
                            {
                                lootItem.Move(60000, LootBag);
                                Game.Wait(425);
                            }
                        }
                    }
                }

                cutedBodies.Add(item.Serial);
            }

            World.Player.PrintMessage(String.Format("Bodies remain [{0}]", toDo), Game.Val_LightGreen);

            foreach (UOItem item in World.Ground)
            {
                if (item.Distance <= 6 && IsLootItem(item))
                {
                    item.Move(60000, LootBag);
                    Game.Wait(425);
                }
            }

            List <Serial> bpkAfterLoot = ItemHelper.ContainerState(World.Player.Backpack);
            List <Serial> diff         = ItemHelper.ContainerStateDiff(bpkState, bpkAfterLoot);

            Game.PrintMessage("Diff... " + diff.Count);
            if (LootBag.Serial != World.Player.Backpack.Serial)
            {
                foreach (Serial lootedItem in diff)
                {
                    UOItem item = new UOItem(lootedItem);

                    if (item.Container == World.Player.Backpack.Serial)
                    {
                        if (item.Move(65000, LootBag))
                        {
                            Game.PrintMessage("LootItem Moved to Bag...");
                        }
                        Game.Wait();
                    }
                }
            }
        }
Пример #49
0
        public virtual bool StackWith( Mobile from, Item dropped, bool playSound )
        {
            if ( Stackable && dropped.Stackable && dropped.GetType() == GetType() && dropped.ItemID == ItemID && dropped.Hue == Hue && (dropped.Amount + Amount) <= 60000 )
            {
                if ( m_LootType != dropped.m_LootType )
                    m_LootType = LootType.Regular;

                Amount += dropped.Amount;
                dropped.Delete();

                if ( playSound )
                {
                    int soundID = GetDropSound();

                    if ( soundID == -1 )
                        soundID = 0x42;

                    from.SendSound( soundID, GetWorldLocation() );
                }

                return true;
            }

            return false;
        }
Пример #50
0
        void StartClick()
        {
            if (bWorking)
            {
                return;
            }
            bWorking = true;
            // listBox1.Items.Add("gg");
            //加载配置文件,运行时文件
            if (Program.config == null)
            {
                string filename = "Config\\" + cbConfig.Text;
                if (filename.Length < 1)
                {
                    MessageBox.Show("請選擇一個配置方案,首次使用,點擊設定配置以創建新配置方案");
                    return;
                }
                Stream fStream = null;
                try
                {
                    fStream = new FileStream(filename, FileMode.Open, FileAccess.Read);
                    BinaryFormatter binFormat = new BinaryFormatter();
                    Program.config = (ConfigData)binFormat.Deserialize(fStream);
                    fStream.Close();

                    //设置运行时配置,全局配置在程序载入时即加载进内存
                    lbMap.Items.Clear();
                    foreach (var item in Program.config.MissionMapList)
                    {
                        lbMap.Items.Add(item);
                    }
                    List <LootType> lootTypeList = new List <LootType>();
                    foreach (var item in Program.config.LootTypeList)
                    {
                        LootType newItem = new LootType();
                        newItem.Type  = item.Key;
                        newItem.Color = item.Value;
                        lootTypeList.Add(newItem);
                    }
                    Program.client.SetLootTypeList(
                        lootTypeList,
                        Program.config.LootSocketFilter,
                        Program.config.LootSocketConnectFilter,
                        Program.config.LootThreeColor,
                        Program.config.LootSkillQuality);

                    Program.runtime     = new RunTimeData();
                    lbMap.SelectedIndex = 0;

                    InitSaveIndexFilter(Program.config);
                    Program.runtime.reset();
                    lbNotice.Text = "使用中配置:" + cbConfig.Text + ",如果您修改了該配置方案或選擇了其他配置方案,請點擊重載配置.";
                }
                catch (Exception ex)
                {
                    MessageBox.Show("載入配置文件失敗,文件不存在或已損壞,請重新創建");
                    return;
                }
            }
            else
            {
                Program.runtime.curMissionMapIndex = lbMap.SelectedIndex;
            }
            if (cbHandModel.Checked)
            {
                worker.bHandModel = true;
            }
            else
            {
                worker.bHandModel = false;
            }
            Program.client.ReloadPollutantGateName();//重载门名称列表
            worker.UI = this;
            worker.begin();
        }