Jump to content

[Modding] How to recognize when an item gets tempered/enchanted


Recommended Posts

There's a quest "TutorialBlacksmithingDaggerSharpen". Its Start Up Stage has a papyrus fragment to set the "TutorialBlacksmithing" quest to stage 40.

Then in "Object Window" -> "SM Event Node" there is a form "Craft Item". In this click on "Expand all" in the top. Now you should see the node "Quest: TutorialBlacksmithingDaggerSharpen". If you click on it you see in the Node Conditions in the bottom that it triggers when the crafting operation is temepring, "TutorialBlacksmithing" is at stage 30 and the modified item was an IronDagger.
In other words whenever all those conditions are met the quest "TutorialBlackSmithingDaggerSharpen" is run which sets "TutorialBlacksmithing" to the next stage. To create your own nodes in the SM Event Node tree start by creating a new "Stacked Branch Node" at the top level or your mod will conflict with other mods modifying the same nodes. For listening to enchanting refer to the event node "Quest: WICraftItem02".

Link to comment

 

That method used in the base game, as you can see, is very complex because use multiple quest inter connected trough Story Manager. Additionally are linked to specific items, like Iron Dagger, and is impossible expand it to others specific items and enchantments created by others mods. Can works only to control yours own enchantments created in your own mod.

 

Is better use pure papyrus code to know if the item is enchanted using GetEnchantment, a function that works with any item, not mater what mod put it in the game. But that function only works correctly when is called from the Armor or Weapon script over the original items and return the enchantment from the base object, that is, the original enchantment that is defined inside the ESP files over the original item before the player disenchant it to learn the enchantment..

 

The function GetEnchantment from the ObjectReference Script was theoretically designed to works in items enchanted by the player but a lot of times not works correctly, simply because any enchanted item by the player is an item created at run time that start with code FF, and the internal functions, normally, go crazy and can not return the correct enchantment. Additionally, the main down side of that function is, when works, only works over items outside a container. That mean, not works when the item is inside a chest or inside the inventory of one actor. Only works when the item is over the ground.

 

The only way, as i know, to get the correct enchantment in items enchanted by the player is use the undocumented function GetEnchantment from the SKSE WornObject script but the down side is that only works when the item is equipped and, sometimes, the NPC really not equip the item, the game show it as equipped in the render, but the function IsEquipped return false and the GetEnchantment returns none.

 

Edited by alex77r4
Link to comment

OK, basically it seems to work, now I have another problem:

 

I need to know, WHAT item got tempered, I don't want to track one specific item. I've found the OnStoryCraftItem Quest event, which seems like it would give me what I need, but as the note says, it leads to a CTD when I try to use it. Is there another way to get to know WHICH item got tempered if I don't want to track a specific one?

 

@alex77r4 Thanks for that, but for enchantments I already have a solution. It's for my mod Devious Mimic Clothes, so user enchantments can't dispel the Mimic Curse, but only prevent the destruction of the object.

Now I want to achieve, that an item counts as new and not already worn anymore, when a player tempers it. But for that I have the problem described above

Edited by Mister X
Link to comment

 

That event seems to be designed to be sended every time an item is created and exactly have the info you need, the ID of the created item. But if the wiki say "it seems to crash the game" i trust them with closed eyes.

 

But I not see another way to get the ID of the created item because, if you start a quest with the Story Manager, that only start the quest and not provide any additional data to the quest. You can try GetEventData to make some filters and multiple quest depending of the item but is complex and can easy skip any unfiltered item. I not see a good way to make what you want with the Story manager. Is very powerful but i never like it.

 

The only trick that i can imagine is make a RegisterForMenu("Crafting Menu") in a player alias and activate an state or an AddInventoryEventFilter to be used with OnItemAdded() to catch every created item by the player. As example:

 

---> States
RegisterForMenu("Crafting Menu")
event OnMenuOpen(String menuName)
	If menuName == "Crafting Menu"
		GotoState("CatchItems)
	endif
endEvent
event OnMenuClose(String menuName)
	GotoState("NoCatch")
endEvent

State "CatchItems"
	Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
		Call my_own_control_for_created_Items
	endEvent
EndState
State "NoCatch"
	Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
	endEvent
EndState

---> Filter
RegisterForMenu("Crafting Menu")
event OnMenuOpen(String menuName)
	If menuName == "Crafting Menu"
		RemoveInventoryEventFilter("unexistent_item")
	endif
endEvent
event OnMenuClose(String menuName)
	AddInventoryEventFilter("unexistent_item")
endEvent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
	Call my_own_control_for_created_Items
endEvent

 

 

 

Edited by alex77r4
Link to comment

OK, little update: I've tried using OnMenuOpen() together with OnItemAdded() and OnItemRemoved(), but that only seems to recognize newly forged items.

 

I simply tried to call out the name and ID of the created item for debugging, but that only worked when forging a new item at the smith. When I tried the same thing for a Workbench, it only called the required things that get removed when tempering an item (eg Leather is called as removed when tempering a Leather Armor)

But the armor itself doesn't get added or removed while tempering, so the events don't catch that.

 

Now, is there another way to track tempering (NOT crafting!), as the Radiant Story Event (potentially the best resource) only leads to crashes?

Keep in mind, that I want to track the event for any armor, not a specific one

Edited by Mister X
Link to comment

 

I'm thinking, looking documentation, reading code.... but seems that the game not have any metod to detect tempering. As i understand, the tempering only change the value of the ItemHealthPercent, you can make Get/Set, and the game use that value to show a different name and compute the damage/resistance. We have a similar problem with the recharge of enchanted items, we can know how many charges have the item but we can not know, exactly, when the item is recharged.

 

All the mods with tempering have their own metod based in dialog and none of them use the normal tempring system of the base game. That must have a motive. Why create a new system based in dialog and not use the base system of the game? Because the game no offer any way to manage it.

 

This time i not have a good idea but, as is an idea, i go to show it. Ussing the Menu technique:

When open the craft menu, scan all the armors and weapons and store their healt ussing GetItemHealthPercent.

When close the craft menu, scan all the armors and weapons and compare their healt ussing GetItemHealthPercent.

That can say you, exactly, what items has been tempered.

The wiki state that SetItemHealthPercent not works if the item is inside a container.

But GetItemHealthPercent not have that limitation. I really doubth it but test it.

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use