Item Condition Issue/Question

Discuss modding questions and implementation details.
Post Reply
l3lessed
Posts: 1403
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Item Condition Issue/Question

Post by l3lessed »

My minimap mod has a permanent compass setting that creates a compass, assigns it to a daggerfallunityitem object, and then uses that to store a permanent hidden compass for players who don't want to have to equip it.

However, this permanent compass condition continually defaults to 650 no matter what I do, while the equipable one I spawn in the player inventory has the proper max condition of 100 set in the item template.

The question is, does an items condition stats not work unless it is actually created via additem call? That is, does it not assign the template properties until the item is actually added to player or enemy inventory.

The behavior I'm observing seems to indicate this, as the spawned compass in the players inventory always has the correct max condition I set in the item template file but the one not added does not.

Code: Select all

//generates an equipable compass in their inventory or generates a hidden permanent compass if they don't want an equippable item compass.                
if(equippableCompass)
	GameManager.Instance.PlayerEntity.Items.AddItem(ItemBuilder.CreateItem(ItemGroups.UselessItems2, ItemMagicalCompass.templateIndex));
else if (permCompass == null)
	permCompass = ItemBuilder.CreateItem(ItemGroups.MagicItems, ItemMagicalCompass.templateIndex);
	
//if they want equippable compass, run code to check equipment state of compass amulet slot.
if (equippableCompass)
	{
		//default to false, so when the compass is changed to a new one, it updates everything only once.
		changedCompass = false;
                bool Amulet0Changed = false;

                //if the equipped amulet isn't null, check to see if it has changed, and if so, update the item.               
                if (Amulet0Item != null && Amulet0Item.UID != lastAmuletID)
	{
		Amulet0Item = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.Amulet0);
		lastCompassCondition = 0;
		lastAmuletID = Amulet0Item.UID;
		
		//if there is a equipped item in compass slot loaded and its a magical compass, then.
		if (equippableCompass && Amulet0Item != null && Amulet0Item.TemplateIndex == 720)
		{
			//assign current compass.
                        currentEquippedCompass = Amulet0Item;
                        //update the last compass condition for script operation.
                        lastCompassCondition = currentEquippedCompass.currentCondition;
                        //activate minimap.
                        changedCompass = true;
                    }
                }
                
		//if amulet is null, but the player has something equipped in the slot, load it to the amulet item for checking if compass.
                else if (Amulet0Item == null && GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.Amulet0) != null)
                    Amulet0Item = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.Amulet0);
                //if amulet is not empty, but the amulet slot is, set amulet item to null to deactivate compass.
                else if(Amulet0Item != null && GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.Amulet0) == null)
                    Amulet0Item = null;

                //if the amulet is not equipped or not a compass, reset null out current equipped compass and turn off minimap.
                if ((Amulet0Item == null || Amulet0Item.TemplateIndex != 720) && lastAmuletID != 0)
                {
                    lastAmuletID = 0;
                    currentEquippedCompass = null;
                    minimapActive = false;
                }

                //if a compass is equipped, the minimap is off, and the toggle is on, turn minimap on.
                if (currentEquippedCompass != null && minimapToggle && !minimapActive)
                {
                    minimapActive = true;
                }                   
            }
            //if the player doesn't want equippable compasses, setup hidden permanent compass so they still get effects and turn on minimap.
            else
            {
                if (currentEquippedCompass == null || currentEquippedCompass.UID != permCompass.UID)
                    currentEquippedCompass = permCompass;

                if (currentEquippedCompass != null && minimapToggle && !minimapActive)
                    minimapActive = true;
            }            
            compassHealth = currentEquippedCompass.currentCondition;
Again, when the equippable compass open is enabled, it shows the right item template health as 100, but when I use the permanent compass it jumps to 650, and even when I try to force a new max condition through code, it won't take.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

Post Reply