public static MyWorldObject Create(WorldObject wo)
		{
			MyWorldObject mwo = new MyWorldObject();

			Dictionary<int, bool> boolValues = new Dictionary<int,bool>();
			Dictionary<int, double> doubleValues = new Dictionary<int,double>();
			Dictionary<int, int> intValues = new Dictionary<int, int>();
			Dictionary<int, string> stringValues = new Dictionary<int,string>();
			List<int> activeSpells = new List<int>();
			List<int> spells = new List<int>();

			foreach (var key in wo.BoolKeys)
				boolValues.Add(key, wo.Values((BoolValueKey)key));

			foreach (var key in wo.DoubleKeys)
				doubleValues.Add(key, wo.Values((DoubleValueKey)key));

			foreach (var key in wo.LongKeys)
				intValues.Add(key, wo.Values((LongValueKey)key));

			foreach (var key in wo.StringKeys)
				stringValues.Add(key, wo.Values((StringValueKey)key));

			for (int i = 0 ; i < wo.ActiveSpellCount ; i++)
				activeSpells.Add(wo.ActiveSpell(i));

			for (int i = 0; i < wo.SpellCount; i++)
				spells.Add(wo.Spell(i));

			mwo.Init(wo.HasIdData, wo.Id, wo.LastIdTime, (int)wo.ObjectClass, boolValues, doubleValues, intValues, stringValues, activeSpells, spells);

			return mwo;
		}
        internal CapturedWorldObject(WorldObject wo)
        {
            this.Id = wo.Id;
            this.Name = wo.Name;
            this.ObjectClass = wo.ObjectClass;

            this.Behavior = wo.Behavior;
            this.Category = wo.Category;
            this.Container = wo.Container;
            this.GameDataFlags1 = wo.GameDataFlags1;
            this.Icon = wo.Icon;
            this.LastIdTime = wo.LastIdTime;
            this.PhysicsDataFlags = wo.PhysicsDataFlags;
            this.Type = wo.Type;

            this.HasIdData = wo.HasIdData;

            this._coordinates = wo.Coordinates();
            this._orientation = wo.Orientation();
            this._offset = wo.Offset();
            this._rawCoordinates = wo.RawCoordinates();

            var tmpIntList = new List<int>();
            for (int i = 0; i < wo.ActiveSpellCount; i++)
            {
                tmpIntList.Add(wo.ActiveSpell(i));
            }

            this._activeSpells = General.ListOperations.Capture(tmpIntList).AsReadOnly();

            tmpIntList.Clear();
            for (int i = 0; i < wo.SpellCount; i++)
            {
                tmpIntList.Add(wo.Spell(i));
            }

            this._spells = General.ListOperations.Capture(tmpIntList).AsReadOnly();

            foreach (var key in wo.BoolKeys)
                _boolValues.Add(key, wo.Values((BoolValueKey)key));

            foreach (var key in wo.DoubleKeys)
                _doubleValues.Add(key, wo.Values((DoubleValueKey)key));

            foreach (var key in wo.LongKeys)
                this._longValues.Add(key, wo.Values((LongValueKey)key));

            foreach (var key in wo.StringKeys)
                _stringValues.Add(key, wo.Values((StringValueKey)key));
        }
Beispiel #3
0
        public static MyWorldObject Create(WorldObject wo)
        {
            MyWorldObject mwo = new MyWorldObject();

            Dictionary <int, bool>   boolValues   = new Dictionary <int, bool>();
            Dictionary <int, double> doubleValues = new Dictionary <int, double>();
            Dictionary <int, int>    intValues    = new Dictionary <int, int>();
            Dictionary <int, string> stringValues = new Dictionary <int, string>();
            List <int> activeSpells = new List <int>();
            List <int> spells       = new List <int>();

            foreach (var key in wo.BoolKeys)
            {
                boolValues.Add(key, wo.Values((BoolValueKey)key));
            }

            foreach (var key in wo.DoubleKeys)
            {
                doubleValues.Add(key, wo.Values((DoubleValueKey)key));
            }

            foreach (var key in wo.LongKeys)
            {
                intValues.Add(key, wo.Values((LongValueKey)key));
            }

            foreach (var key in wo.StringKeys)
            {
                stringValues.Add(key, wo.Values((StringValueKey)key));
            }

            for (int i = 0; i < wo.ActiveSpellCount; i++)
            {
                activeSpells.Add(wo.ActiveSpell(i));
            }

            for (int i = 0; i < wo.SpellCount; i++)
            {
                spells.Add(wo.Spell(i));
            }

            mwo.Init(wo.HasIdData, wo.Id, wo.LastIdTime, (int)wo.ObjectClass, boolValues, doubleValues, intValues, stringValues, activeSpells, spells);

            return(mwo);
        }
		private EquipmentTrackedItemState RecaclulteState(WorldObject wo)
		{
			// We need basic IdData to determine if an item is active
			if (!wo.HasIdData)
				return EquipmentTrackedItemState.Unknown;

			// If this item has no spells, its not activateable
			if (wo.SpellCount == 0 || wo.Values(LongValueKey.MaximumMana) == 0)
				return EquipmentTrackedItemState.NotActivatable;

			// If this item has no mana in it, it's not active
			if (wo.Values(LongValueKey.CurrentMana, 0) == 0)
				return EquipmentTrackedItemState.NotActive;


			// Go through and find all of our current active spells (enchantments)
			List<int> activeSpellsOnChar = new List<int>();

			foreach (EnchantmentWrapper wrapper in CoreManager.Current.CharacterFilter.Enchantments)
			{
				// Only add ones that are cast by items (have no duration)
				if (wrapper.TimeRemaining <= 0)
					activeSpellsOnChar.Add(wrapper.SpellId);
			}

			FileService service = CoreManager.Current.Filter<FileService>();


			// Lets check if the item is not active We check to see if this item has any spells that are not activated.
			bool inactiveSpellFound = false;

			// Go through all of this items spells to determine if all are active.
			for (int i = 0 ; i < wo.SpellCount ; i++)
			{
				int spellOnItemId = wo.Spell(i);

				if (wo.Exists(LongValueKey.AssociatedSpell) && (wo.Values(LongValueKey.AssociatedSpell) == spellOnItemId))
					continue;

				Spell spellOnItem = service.SpellTable.GetById(spellOnItemId);

				// If it is offensive, it is probably a cast on strike spell
				if (spellOnItem.IsDebuff || spellOnItem.IsOffensive)
					continue;


				// Check if this particular spell is active
				bool thisSpellIsActive = false;


				// Check to see if this item cast any spells on itself.
				for (int j = 0 ; j < wo.ActiveSpellCount ; j++)
				{
					int activeSpellOnItemId = wo.ActiveSpell(j);

					if ((service.SpellTable.GetById(activeSpellOnItemId).Family == spellOnItem.Family) && (service.SpellTable.GetById(activeSpellOnItemId).Difficulty >= spellOnItem.Difficulty))
					{
						thisSpellIsActive = true;
						break;
					}
				}

				if (thisSpellIsActive)
					continue;


				// Check to see if this item cast any spells on the player.
				foreach (int j in activeSpellsOnChar)
				{
					if (service.SpellTable.GetById(j) != null && (service.SpellTable.GetById(j).Family == spellOnItem.Family) && (service.SpellTable.GetById(j).Difficulty >= spellOnItem.Difficulty))
					{
						thisSpellIsActive = true;
						break;
					}
				}

				if (thisSpellIsActive)
					continue;

				// This item has not cast this particular spell.
				inactiveSpellFound = true;
				break;
			}


			if (inactiveSpellFound)
				return EquipmentTrackedItemState.NotActive;

			return EquipmentTrackedItemState.Active;
		}
Beispiel #5
0
        private void LogItem(WorldObject item)
        {
            FileInfo logFile = new FileInfo(logFileName);

            if (!logFile.Exists)
            {
                CoreManager.Current.Actions.AddChatTextRaw("<{Mag-VendorLogger}>: Log file appears deleted...", 5);
                return;
            }


            using (StreamWriter writer = new StreamWriter(logFileName, true))
            {
                bool needsComma = false;

                StringBuilder output = new StringBuilder();

                output.Append("{");

                output.Append("\"Id\":\"" + item.Id + "\",");
                output.Append("\"ObjectClass\":\"" + item.ObjectClass + "\",");

                output.Append("\"BoolValues\":{");
                foreach (var value in item.BoolKeys)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append("\"" + value + "\":\"" + item.Values((BoolValueKey)value) + "\"");
                }
                output.Append("},");

                output.Append("\"DoubleValues\":{");
                needsComma = false;
                foreach (var value in item.DoubleKeys)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append("\"" + value + "\":\"" + item.Values((DoubleValueKey)value) + "\"");
                }
                output.Append("},");

                output.Append("\"LongValues\":{");
                needsComma = false;
                foreach (var value in item.LongKeys)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append("\"" + value + "\":\"" + item.Values((LongValueKey)value) + "\"");
                }
                output.Append("},");

                output.Append("\"StringValues\":{");
                needsComma = false;
                foreach (var value in item.StringKeys)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append("\"" + value + "\":\"" + item.Values((StringValueKey)value) + "\"");
                }
                output.Append("},");

                output.Append("\"ActiveSpells\":\"");
                needsComma = false;
                for (int i = 0; i < item.ActiveSpellCount; i++)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append(item.ActiveSpell(i));
                }
                output.Append("\",");

                output.Append("\"Spells\":\"");
                needsComma = false;
                for (int i = 0; i < item.SpellCount; i++)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append(item.Spell(i));
                }
                output.Append("\"");

                output.Append("}");

                writer.WriteLine(output);

                writer.Close();
            }
        }
Beispiel #6
0
        private void LogItem(WorldObject item)
        {
            string logFileName = pluginPersonalFolder.FullName + @"\" + CoreManager.Current.Actions.Landcell.ToString("X8") + ".csv";

            FileInfo logFile = new FileInfo(logFileName);

            if (!logFile.Exists)
            {
                using (StreamWriter writer = new StreamWriter(logFile.FullName, true))
                {
                    writer.WriteLine("\"Timestamp\",\"LandCell\",\"RawCoordinates\",\"JSON\"");

                    writer.Close();
                }
            }


            using (StreamWriter writer = new StreamWriter(logFileName, true))
            {
                bool needsComma = false;

                StringBuilder output = new StringBuilder();

                // "Timestamp,Landcell,RawCoordinates,JSON"
                output.Append('"' + String.Format("{0:u}", DateTime.UtcNow) + ",");
                output.Append('"' + CoreManager.Current.Actions.Landcell.ToString("X8") + '"' + ",");
                output.Append('"' + item.RawCoordinates().X + " " + item.RawCoordinates().Y + " " + item.RawCoordinates().Z + '"' + ",");

                output.Append("\"{");

                output.Append("\"Id\":\"" + item.Id + "\",");
                output.Append("\"ObjectClass\":\"" + item.ObjectClass + "\",");

                output.Append("\"BoolValues\":{");
                foreach (var value in item.BoolKeys)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append("\"" + value + "\":\"" + item.Values((BoolValueKey)value) + "\"");
                }
                output.Append("},");

                output.Append("\"DoubleValues\":{");
                needsComma = false;
                foreach (var value in item.DoubleKeys)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append("\"" + value + "\":\"" + item.Values((DoubleValueKey)value) + "\"");
                }
                output.Append("},");

                output.Append("\"LongValues\":{");
                needsComma = false;
                foreach (var value in item.LongKeys)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append("\"" + value + "\":\"" + item.Values((LongValueKey)value) + "\"");
                }
                output.Append("},");

                output.Append("\"StringValues\":{");
                needsComma = false;
                foreach (var value in item.StringKeys)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append("\"" + value + "\":\"" + item.Values((StringValueKey)value) + "\"");
                }
                output.Append("},");

                output.Append("\"ActiveSpells\":\"");
                needsComma = false;
                for (int i = 0; i < item.ActiveSpellCount; i++)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append(item.ActiveSpell(i));
                }
                output.Append("\",");

                output.Append("\"Spells\":\"");
                needsComma = false;
                for (int i = 0; i < item.SpellCount; i++)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append(item.Spell(i));
                }
                output.Append("\"");

                if (identAttributes.ContainsKey(item.Id))
                {
                    var extendedIDAttributeInfo = identAttributes[item.Id];

                    output.Append(",\"Attributes\":{");
                    output.Append("\"healthMax\":\"" + extendedIDAttributeInfo.healthMax + "\",");
                    output.Append("\"staminaMax\":\"" + extendedIDAttributeInfo.staminaMax + "\",");
                    output.Append("\"manaMax\":\"" + extendedIDAttributeInfo.manaMax + "\",");
                    output.Append("\"strength\":\"" + extendedIDAttributeInfo.strength + "\",");
                    output.Append("\"endurance\":\"" + extendedIDAttributeInfo.endurance + "\",");
                    output.Append("\"quickness\":\"" + extendedIDAttributeInfo.quickness + "\",");
                    output.Append("\"coordination\":\"" + extendedIDAttributeInfo.coordination + "\",");
                    output.Append("\"focus\":\"" + extendedIDAttributeInfo.focus + "\",");
                    output.Append("\"self\":\"" + extendedIDAttributeInfo.self + "\"");
                    output.Append("}");
                }

                if (identResources.ContainsKey(item.Id))
                {
                    var resources = identResources[item.Id];

                    output.Append(",\"Resources\":{");
                    needsComma = false;
                    foreach (var value in resources)
                    {
                        if (!needsComma)
                        {
                            needsComma = true;
                        }
                        else
                        {
                            output.Append(",");
                        }

                        output.Append("\"" + value.Key + "\":\"" + value.Value + "\"");
                    }
                    output.Append("}");
                }

                output.Append("}\"");

                writer.WriteLine(output);

                writer.Close();
            }
        }
Beispiel #7
0
        private void LogItem(WorldObject item)
        {
            if (currentOpenContainerIsSingleUseChest)
            {
                if (chestItemsLogged.Contains(item.Id))
                {
                    return;
                }

                chestItemsLogged.Add(item.Id);
            }
            else
            {
                if (corpseItemsLogged.ContainsKey(item.Id) && corpseItemsLogged[item.Id] == item.Container)
                {
                    return;
                }

                corpseItemsLogged[item.Id] = item.Container;
            }


            string logFileName = pluginPersonalFolder.FullName + @"\" + CoreManager.Current.Actions.Landcell.ToString("X8") + ".csv";

            FileInfo logFile = new FileInfo(logFileName);

            if (!logFile.Exists)
            {
                using (StreamWriter writer = new StreamWriter(logFile.FullName, true))
                {
                    writer.WriteLine("\"Timestamp\",\"ContainerName\",\"ContainerID\",\"LandCell\",\"Location\",\"JSON\"");

                    writer.Close();
                }
            }


            using (StreamWriter writer = new StreamWriter(logFileName, true))
            {
                bool needsComma = false;

                StringBuilder output = new StringBuilder();

                // "Timestamp,ContainerName,ContainerID,Landcell,Location,JSON"
                output.Append('"' + String.Format("{0:u}", DateTime.UtcNow) + ",");
                output.Append('"' + currentOpenContainer.Name + '"' + ",");
                output.Append('"' + currentOpenContainer.Id + '"' + ",");
                output.Append('"' + CoreManager.Current.Actions.Landcell.ToString("X8") + '"' + ",");
                output.Append('"' + currentOpenContainer.Coordinates().ToString() + '"' + ",");

                output.Append("\"{");

                output.Append("\"Id\":\"" + item.Id + "\",");
                output.Append("\"ObjectClass\":\"" + item.ObjectClass + "\",");

                output.Append("\"BoolValues\":{");
                foreach (var value in item.BoolKeys)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append("\"" + value + "\":\"" + item.Values((BoolValueKey)value) + "\"");
                }
                output.Append("},");

                output.Append("\"DoubleValues\":{");
                needsComma = false;
                foreach (var value in item.DoubleKeys)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append("\"" + value + "\":\"" + item.Values((DoubleValueKey)value) + "\"");
                }
                output.Append("},");

                output.Append("\"LongValues\":{");
                needsComma = false;
                foreach (var value in item.LongKeys)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append("\"" + value + "\":\"" + item.Values((LongValueKey)value) + "\"");
                }
                output.Append("},");

                output.Append("\"StringValues\":{");
                needsComma = false;
                foreach (var value in item.StringKeys)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append("\"" + value + "\":\"" + item.Values((StringValueKey)value) + "\"");
                }
                output.Append("},");

                output.Append("\"ActiveSpells\":\"");
                needsComma = false;
                for (int i = 0; i < item.ActiveSpellCount; i++)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append(item.ActiveSpell(i));
                }
                output.Append("\",");

                output.Append("\"Spells\":\"");
                needsComma = false;
                for (int i = 0; i < item.SpellCount; i++)
                {
                    if (!needsComma)
                    {
                        needsComma = true;
                    }
                    else
                    {
                        output.Append(",");
                    }

                    output.Append(item.Spell(i));
                }
                output.Append("\"");

                output.Append("}\"");

                writer.WriteLine(output);

                writer.Close();
            }
        }
Beispiel #8
0
 private void outputObjectPropsToChat(WorldObject o)
 {
     // so far, I know o.Type is the weenieId of the object.
     WriteToChat("--------------B - E - G - I - N -----------------------------");
     WriteToChat("          o.Name: " + o.Name);
     WriteToChat("            o.Id: " + o.Id);
     WriteToChat("          o.Type: " + o.Type); // <-- I bet this is the "WeenieId"
     WriteToChat("   Active Spells:");
     WriteToChat("  --------------");
     for (int i = 0; i < o.ActiveSpellCount; i++)
     {
         WriteToChat(o.ActiveSpell(i).ToString());
     }
     WriteToChat("  --------------");
     WriteToChat("      o.Behavior: " + o.Behavior.ToString());
     WriteToChat("      o.BoolKeys: " + o.BoolKeys.ToString());
     WriteToChat("--- o.BoolKeys ---");
     foreach (int x in o.BoolKeys)
     {
         WriteToChat(x.ToString());
     }
     WriteToChat("---");
     WriteToChat("      o.Category: " + o.Category.ToString());
     // Alinco has some logic about "container" ... like Chests and Toon...
     WriteToChat("     o.Container: " + o.Container.ToString());
     WriteToChat("   o.Coordinates: " + o.Coordinates().ToString());
     //WriteToChat("o.CreateObjRef looks like a _utility_ method I might need....");
     //WriteToChat("o." + o.Dispose());  o.Dispose() looks like utility.
     WriteToChat("    o.DoubleKeys: " + o.DoubleKeys.ToString());
     WriteToChat("--- o.DoubleKeys ---");
     foreach (int x in o.DoubleKeys)
     {
         WriteToChat(x.ToString());
     }
     WriteToChat("---");
     // DoubleKeys and BoolKeys might be _collections_... like in the Tank attrs...
     WriteToChat("o.GameDataFlags1: " + o.GameDataFlags1.ToString());
     WriteToChat("     o.HasIdData: " + o.HasIdData.ToString()); // alinco has some logic around hasIdData
     WriteToChat("          o.Icon: " + o.Icon.ToString());
     WriteToChat("    o.LastIdTime: " + o.LastIdTime.ToString());
     WriteToChat("----- LongKeys -----");
     foreach (long x in o.LongKeys)
     {
         WriteToChat(x.ToString());
     }
     WriteToChat("----- /LongKeys -----");
     WriteToChat("      o.LongKeys: " + o.LongKeys.ToString()); // probably another place spells and such are...
     WriteToChat("   o.ObjectClass: " + o.ObjectClass.ToString());
     /// Alinco has a "If this object is in the world detection..."
     //
     if (o.Container == 0)                                          // container = 0 if it's in the "game world"
     {
         WriteToChat("      o.Offset(): " + o.Offset().ToString()); // offset in Landblock
         WriteToChat(" o.Orientation(): " + o.Orientation().ToString());
     }
     WriteToChat("o.PhysicsDataFlags(): " + o.PhysicsDataFlags.ToString());
     WriteToChat("o.RawCoordinates(): " + o.RawCoordinates().ToString());
     WriteToChat("o.SpellCount.ToString():" + o.SpellCount.ToString());
     WriteToChat("----- ActiveSpells -----");
     if (o.ActiveSpellCount > 0)
     {
         for (int i = 0; i < o.ActiveSpellCount; i++)
         {
             WriteToChat(o.ActiveSpell(i).ToString());
         }
     }
     WriteToChat("----- /ActiveSpells -----");
     WriteToChat("o.ToString: " + o.ToString());
     WriteToChat("o.Type.ToString(): " + o.Type.ToString());
     WriteToChat("--- StringKeys ---");
     foreach (int key in o.StringKeys)
     {
         WriteToChat(key.ToString());
     }
     WriteToChat("--- End StringKeys ---");
     // So, o.Values() is _odd_...
     // o.Values() takes a BoolValueKey index... huh?
     // I'm assuming it's like '10010010' like a boolean "Key index" mask.
     WriteToChat("--------------E - N - D-------------------------------------");
 }
        private EquipmentTrackedItemState RecaclulteState(WorldObject wo)
        {
            // We need basic IdData to determine if an item is active
            if (!wo.HasIdData)
            {
                return(EquipmentTrackedItemState.Unknown);
            }

            // If this item has no spells, its not activateable
            if (wo.SpellCount == 0 || wo.Values(LongValueKey.MaximumMana) == 0)
            {
                return(EquipmentTrackedItemState.NotActivatable);
            }

            // If this item has no mana in it, it's not active
            if (wo.Values(LongValueKey.CurrentMana, 0) == 0)
            {
                return(EquipmentTrackedItemState.NotActive);
            }


            // Go through and find all of our current active spells (enchantments)
            List <int> activeSpellsOnChar = new List <int>();

            foreach (EnchantmentWrapper wrapper in CoreManager.Current.CharacterFilter.Enchantments)
            {
                // Only add ones that are cast by items (have no duration)
                if (wrapper.TimeRemaining <= 0)
                {
                    activeSpellsOnChar.Add(wrapper.SpellId);
                }
            }

            FileService service = CoreManager.Current.Filter <FileService>();


            // Lets check if the item is not active We check to see if this item has any spells that are not activated.
            bool inactiveSpellFound = false;

            // Go through all of this items spells to determine if all are active.
            for (int i = 0; i < wo.SpellCount; i++)
            {
                int spellOnItemId = wo.Spell(i);

                if (wo.Exists(LongValueKey.AssociatedSpell) && (wo.Values(LongValueKey.AssociatedSpell) == spellOnItemId))
                {
                    continue;
                }

                Spell spellOnItem = service.SpellTable.GetById(spellOnItemId);

                // If it is offensive, it is probably a cast on strike spell
                if (spellOnItem.IsDebuff || spellOnItem.IsOffensive)
                {
                    continue;
                }


                // Check if this particular spell is active
                bool thisSpellIsActive = false;


                // Check to see if this item cast any spells on itself.
                for (int j = 0; j < wo.ActiveSpellCount; j++)
                {
                    int activeSpellOnItemId = wo.ActiveSpell(j);

                    if ((service.SpellTable.GetById(activeSpellOnItemId).Family == spellOnItem.Family) && (service.SpellTable.GetById(activeSpellOnItemId).Difficulty >= spellOnItem.Difficulty))
                    {
                        thisSpellIsActive = true;
                        break;
                    }
                }

                if (thisSpellIsActive)
                {
                    continue;
                }


                // Check to see if this item cast any spells on the player.
                foreach (int j in activeSpellsOnChar)
                {
                    if (service.SpellTable.GetById(j) != null && (service.SpellTable.GetById(j).Family == spellOnItem.Family) && (service.SpellTable.GetById(j).Difficulty >= spellOnItem.Difficulty))
                    {
                        thisSpellIsActive = true;
                        break;
                    }
                }

                if (thisSpellIsActive)
                {
                    continue;
                }

                // This item has not cast this particular spell.
                inactiveSpellFound = true;
                break;
            }


            if (inactiveSpellFound)
            {
                return(EquipmentTrackedItemState.NotActive);
            }

            return(EquipmentTrackedItemState.Active);
        }
Beispiel #10
0
 public static void DumpWorldObject(WorldObject obj)
 {
     try
     {
         Utility.AddChatText("--- DEFIANCE Dump ---", 6);
         using (FileStream fileStream = File.Create(GetDumpFolder() + DateTime.Now.Ticks + ".xml"))
         {
             using (XmlWriter xmlWriter = XmlWriter.Create(fileStream, new XmlWriterSettings
             {
                 Encoding = new UTF8Encoding(false),
                 ConformanceLevel = ConformanceLevel.Document,
                 Indent = true
             }))
             {
                 xmlWriter.WriteStartDocument();
                 xmlWriter.WriteStartElement("WorldObject");
                 Utility.AddChatText(string.Format("ID: {0}", obj.Id), 0);
                 xmlWriter.WriteStartElement("ID");
                 xmlWriter.WriteString(obj.Id.ToString());
                 xmlWriter.WriteEndElement();
                 Utility.AddChatText(string.Format("Name: {0}", obj.Name), 0);
                 xmlWriter.WriteStartElement("Name");
                 xmlWriter.WriteString(string.Format("Name: {0}", obj.Name ?? string.Empty));
                 xmlWriter.WriteEndElement();
                 if (obj.ActiveSpellCount > 0)
                 {
                     xmlWriter.WriteStartElement("ActiveSpells");
                     Utility.AddChatText("***ActiveSpells***", 6);
                     for (int i = 0; i < obj.ActiveSpellCount; i++)
                     {
                         Utility.AddChatText(string.Format("Spell: {0}", obj.ActiveSpell(i)), 0);
                         xmlWriter.WriteStartElement("Spell");
                         xmlWriter.WriteString(obj.ActiveSpell(i).ToString());
                         xmlWriter.WriteEndElement();
                     }
                     xmlWriter.WriteEndElement();
                 }
                 Utility.AddChatText(string.Format("Behavior: {0}", obj.Behavior), 0);
                 xmlWriter.WriteStartElement("Behavior");
                 xmlWriter.WriteString(obj.Behavior.ToString());
                 xmlWriter.WriteEndElement();
                 if (obj.BoolKeys.Count > 0)
                 {
                     xmlWriter.WriteStartElement("BoolKeys");
                     Utility.AddChatText("***BoolKeys***", 6);
                     foreach (int num in obj.BoolKeys)
                     {
                         Utility.AddChatText(string.Format("Key: {0}, {1}", (BoolValueKey)num, obj.Values((BoolValueKey)num, false)), 0);
                         xmlWriter.WriteStartElement("Key");
                         xmlWriter.WriteStartElement("Bool");
                         XmlWriter    xmlWriter2   = xmlWriter;
                         BoolValueKey boolValueKey = (BoolValueKey)num;
                         xmlWriter2.WriteString(boolValueKey.ToString());
                         xmlWriter.WriteEndElement();
                         xmlWriter.WriteStartElement("Value");
                         xmlWriter.WriteString(obj.Values((BoolValueKey)num, false).ToString());
                         xmlWriter.WriteEndElement();
                         xmlWriter.WriteEndElement();
                     }
                     xmlWriter.WriteEndElement();
                 }
                 Utility.AddChatText(string.Format("Category: {0}", obj.Category), 0);
                 xmlWriter.WriteStartElement("Category");
                 xmlWriter.WriteString(obj.Category.ToString());
                 xmlWriter.WriteEndElement();
                 Utility.AddChatText(string.Format("Container: {0}", obj.Container), 0);
                 xmlWriter.WriteStartElement("Container");
                 xmlWriter.WriteString(obj.Container.ToString());
                 xmlWriter.WriteEndElement();
                 xmlWriter.WriteStartElement("Coordinates");
                 Utility.AddChatText("***Coordinates***", 6);
                 Utility.AddChatText(string.Format("EastWest: {0}", obj.Coordinates().EastWest), 0);
                 xmlWriter.WriteStartElement("EastWest");
                 xmlWriter.WriteString(obj.Coordinates().EastWest.ToString());
                 xmlWriter.WriteEndElement();
                 Utility.AddChatText(string.Format("NorthSouth: {0}", obj.Coordinates().NorthSouth), 0);
                 xmlWriter.WriteStartElement("NorthSouth");
                 xmlWriter.WriteString(obj.Coordinates().NorthSouth.ToString());
                 xmlWriter.WriteEndElement();
                 xmlWriter.WriteEndElement();
                 if (obj.DoubleKeys.Count > 0)
                 {
                     xmlWriter.WriteStartElement("DoubleKeys");
                     Utility.AddChatText("***DoubleKeys***", 6);
                     foreach (int num2 in obj.DoubleKeys)
                     {
                         Utility.AddChatText(string.Format("Key: {0}, {1}", (DoubleValueKey)num2, obj.Values((DoubleValueKey)num2, -1.0)), 0);
                         xmlWriter.WriteStartElement("Key");
                         xmlWriter.WriteStartElement("Double");
                         XmlWriter      xmlWriter3     = xmlWriter;
                         DoubleValueKey doubleValueKey = (DoubleValueKey)num2;
                         xmlWriter3.WriteString(doubleValueKey.ToString());
                         xmlWriter.WriteEndElement();
                         xmlWriter.WriteStartElement("Value");
                         xmlWriter.WriteString(obj.Values((DoubleValueKey)num2, -1.0).ToString());
                         xmlWriter.WriteEndElement();
                         xmlWriter.WriteEndElement();
                     }
                     xmlWriter.WriteEndElement();
                 }
                 Utility.AddChatText(string.Format("GameDataFlags1: {0}", obj.GameDataFlags1), 0);
                 xmlWriter.WriteStartElement("GameDataFlags1");
                 xmlWriter.WriteString(obj.GameDataFlags1.ToString());
                 xmlWriter.WriteEndElement();
                 Utility.AddChatText(string.Format("HasIdData: {0}", obj.HasIdData), 0);
                 xmlWriter.WriteStartElement("HasIdData");
                 xmlWriter.WriteString(obj.HasIdData.ToString());
                 xmlWriter.WriteEndElement();
                 Utility.AddChatText(string.Format("Icon: {0}", obj.Icon), 0);
                 xmlWriter.WriteStartElement("Icon");
                 xmlWriter.WriteString(obj.Icon.ToString());
                 xmlWriter.WriteEndElement();
                 Utility.AddChatText(string.Format("LastIdTime: {0}", obj.LastIdTime), 0);
                 xmlWriter.WriteStartElement("LastIdTime");
                 xmlWriter.WriteString(obj.LastIdTime.ToString());
                 xmlWriter.WriteEndElement();
                 if (obj.LongKeys.Count > 0)
                 {
                     xmlWriter.WriteStartElement("LongKeys");
                     Utility.AddChatText("***LongKeys***", 6);
                     foreach (int num3 in obj.LongKeys)
                     {
                         Utility.AddChatText(string.Format("Key: {0}, {1}", (LongValueKey)num3, obj.Values((LongValueKey)num3, -1)), 0);
                         xmlWriter.WriteStartElement("Key");
                         xmlWriter.WriteStartElement("Long");
                         XmlWriter    xmlWriter4   = xmlWriter;
                         LongValueKey longValueKey = (LongValueKey)num3;
                         xmlWriter4.WriteString(longValueKey.ToString());
                         xmlWriter.WriteEndElement();
                         xmlWriter.WriteStartElement("Value");
                         xmlWriter.WriteString(obj.Values((LongValueKey)num3, -1).ToString());
                         xmlWriter.WriteEndElement();
                         xmlWriter.WriteEndElement();
                     }
                     xmlWriter.WriteEndElement();
                 }
                 Utility.AddChatText(string.Format("PhysicsDataFlags: {0}", obj.PhysicsDataFlags), 0);
                 xmlWriter.WriteStartElement("PhysicsDataFlags");
                 xmlWriter.WriteString(obj.PhysicsDataFlags.ToString());
                 xmlWriter.WriteEndElement();
                 Utility.AddChatText(string.Format("ObjectClass: {0}", obj.ObjectClass), 0);
                 xmlWriter.WriteStartElement("ObjectClass");
                 xmlWriter.WriteString(obj.ObjectClass.ToString());
                 xmlWriter.WriteEndElement();
                 xmlWriter.WriteStartElement("RawCoordinates");
                 Utility.AddChatText("***RawCoordinates***", 6);
                 Utility.AddChatText(string.Format("X: {0}", obj.RawCoordinates().X), 0);
                 xmlWriter.WriteStartElement("X");
                 xmlWriter.WriteString(obj.RawCoordinates().X.ToString());
                 xmlWriter.WriteEndElement();
                 Utility.AddChatText(string.Format("Y: {0}", obj.RawCoordinates().Y), 0);
                 xmlWriter.WriteStartElement("Y");
                 xmlWriter.WriteString(obj.RawCoordinates().Y.ToString());
                 xmlWriter.WriteEndElement();
                 Utility.AddChatText(string.Format("Z: {0}", obj.RawCoordinates().Z), 0);
                 xmlWriter.WriteStartElement("Z");
                 xmlWriter.WriteString(obj.RawCoordinates().Z.ToString());
                 xmlWriter.WriteEndElement();
                 xmlWriter.WriteEndElement();
                 if (obj.StringKeys.Count > 0)
                 {
                     xmlWriter.WriteStartElement("StringKeys");
                     Utility.AddChatText("***StringKeys***", 6);
                     foreach (int num4 in obj.StringKeys)
                     {
                         Utility.AddChatText(string.Format("Key: {0}, {1}", (StringValueKey)num4, obj.Values((StringValueKey)num4, string.Empty)), 0);
                         xmlWriter.WriteStartElement("Key");
                         xmlWriter.WriteStartElement("String");
                         XmlWriter      xmlWriter5     = xmlWriter;
                         StringValueKey stringValueKey = (StringValueKey)num4;
                         xmlWriter5.WriteString(stringValueKey.ToString());
                         xmlWriter.WriteEndElement();
                         xmlWriter.WriteStartElement("Value");
                         xmlWriter.WriteString(obj.Values((StringValueKey)num4, string.Empty) ?? string.Empty);
                         xmlWriter.WriteEndElement();
                         xmlWriter.WriteEndElement();
                     }
                     xmlWriter.WriteEndElement();
                 }
                 if (obj.SpellCount > 0)
                 {
                     xmlWriter.WriteStartElement("SpellCount");
                     Utility.AddChatText("***SpellCount***", 6);
                     for (int j = 0; j < obj.SpellCount; j++)
                     {
                         Utility.AddChatText(string.Format("Spell: {0}", obj.Spell(j)), 0);
                         xmlWriter.WriteStartElement("Spell");
                         xmlWriter.WriteString(obj.Spell(j).ToString());
                         xmlWriter.WriteEndElement();
                     }
                     xmlWriter.WriteEndElement();
                 }
                 Utility.AddChatText(string.Format("Type: {0}", obj.Type), 0);
                 xmlWriter.WriteStartElement("Type");
                 xmlWriter.WriteString(obj.Type.ToString());
                 xmlWriter.WriteEndElement();
                 xmlWriter.WriteEndElement();
                 xmlWriter.WriteEndDocument();
             }
         }
     }
     catch (Exception ex) { Repo.RecordException(ex); }
 }