Ideas on implementing Crafting Failure?

Post » Wed Feb 15, 2017 9:14 pm

I wanted to do some things that made crafting occaisionally fail under certain conditions,



There is a Condition Function called GetRandomPercent that returns 0-99; but that would only make something not show up in the crafting menu, not actually return a faulty item or a failure message.



if the crafting/forge menu were recognized as a container, there's an OnClose Event I could keep track of what comes out, but that would have to be a script on the player i think which is not feasible. thoughts?



things that don't work:



Spoiler


exiting from the forge menu does not send an OnClose Event call, like a container would.





things that might work:



Spoiler


this looks promising, although I'm unsure how to safely use it on the Player


https://www.creationkit.com/index.php?title=OnGetUp_-_Actor





++++++++++++++++++++++++++


https://www.creationkit.com/index.php?title=RegisterForAnimationEvent_-_Form


https://www.creationkit.com/index.php?title=OnAnimationEventUnregistered_-_Form



maybe the animation for accessing/stepping away from the forge will trigger the above events.


===



since none of the forge or tanning rack furniture is actually being controlled through a papyrus script, there may be an internal script that uses states and those might register with the OnEndState event, although unlikely


https://www.creationkit.com/index.php?title=OnEndState



User avatar
Shelby McDonald
 
Posts: 3497
Joined: Sat Jan 13, 2007 2:29 pm

Post » Wed Feb 15, 2017 6:54 pm

If you are using SKSE, you can look at the RegisterForMenu Functions; otherwise you'll need a way to work out exactly when you're in the right Menu for the following idea to work* :



1) When the Player enters the Crafting Menu, toggle a Global to 1, indicating they're in the Crafting Menu


2) Add an Ability->Magic Effect to the Player using :



Event OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

3) Whenever an Item is added, check that the Global is set to 1, and if so calculate the Failure Chance, then remove the added item.



4) You can add a Perk that nullifies the Experience Gain, and use Game.AdvanceSkill(Skill, Uses) to give the experience - But I do not know how that would work with Crafting, since experience there is based on the value of the item created.



*You might be able to use Perk Entry Point->Activate and a Utility.IsInMenuMode() Check to determine when to toggle the Variable back and forth, but not 100% sure if it would be reliable.



Edit :


If you have the SE, this will 95% work :


https://www.dropbox.com/s/12uic9ofuwedi5d/Crafting%20Must%20Fail.rar?dl=0



It does everything, except that I cannot get the Variable to 'stick' when activating it; you'll have to set it manually via the console--just use the Forge outside Arianne's in Whiterun (it uses a different Forge, apparently, and it was the one I was testing on), open the console and type : "Set ZCDMCMFGlobal to 1", then forge something--you'll get the item, and then a 'Crafting Must Fail' Message. I am sure the issue with the Global can be resolved, I just have to go now, otherwise I'd look into it more.



But it should be a base at least that can be built on, if you like.

User avatar
Wane Peters
 
Posts: 3359
Joined: Tue Jul 31, 2007 9:34 pm

Post » Thu Feb 16, 2017 2:17 am

awesome! thanks i'll give it a go

User avatar
Causon-Chambers
 
Posts: 3503
Joined: Sun Oct 15, 2006 11:47 pm

Post » Thu Feb 16, 2017 2:32 am

When you craft, the result enters your inventory, and you can catch the event (on the player or the item constructed) and then randomly "break" the item.



The item would have OnContainerChanged triggered, and the player OnItemAdded



The Hearthfires DLC uses the OnContainerChanged events on tokens that you make, to trigger the placement (enabling) of the non-inventory items they represent. You could do the same with tokens that represent a chance of a constructed inventory item. I.e when the event occurs, roll the dice, and add the target item or not, while removing the token.

User avatar
Zualett
 
Posts: 3567
Joined: Mon Aug 20, 2007 6:36 pm

Post » Wed Feb 15, 2017 7:13 pm


would an OnContainerChanged event be sent though? it seems like the forge menu just creates an objectReference that directly deposits an item into the player's inventory.



The general idea would be to have a special workbench where any item can be deconstructed (destroyed), giving the player a crafting recipe that would succeed, say, 20% of the time. On success, it gives the full recipe.




@_CDM



I'm pretty new to using this type of system,



I'm interested in how this works exactly, I would like to keep it from running constantly, it appears you have a condition set to check if a forge furniture item is being used, which is good. I'm wondering how it all ties in so i can recreate it and test it. does the quest run first, give a spell, then applies activeMagicEffect to run constantly? it looks like the magicEffect is what applies the perk, which calls the quest function that polls for an exiting of the menumode. I'm sort of lost on how the spell is initially applied to the player.

User avatar
Calum Campbell
 
Posts: 3574
Joined: Tue Jul 10, 2007 7:55 am

Post » Thu Feb 16, 2017 5:05 am

@Marth,


The Quest is 'Always Running' as a Form, but not as a Script (i.e., there should be no cost to Papyrus under 99.99% of situations). I *think* (It's been a while) that you could set it to NOT be enabled, and it will still work--what matters is the Alias on the Quest, which points to the Player Character, and gives them an Ability. This Ability adds both the 'Activate Perk' (which fires when you use a Forge) and the 'Item Added' effect. You can look up Aliases on the CK Wiki for more info, but basically--you put an Actor in an Alias, and you can give them Factions, Spells, Keywords, one-off Items, etc.



Once an item is added to the Player, and the Global is set, the Perk runs the Function on the Quest, which is *meant* to reset the Variable once you leave Crafting, but that's the part I cannot get working. Crafting is like a... Soft-Menu. Time still passes, which means that a Utility.Wait(1.0) will not 'freeze' the Function like it would on a Hard-Menu such as the Inventory :/ That's the big problem right now with my demo.



The Magic Effect does run constantly, but should only fire when an item is added to the Player's Inventory--by default, it will fire every time the Player receives an Item, regardless of the Source. That's why the Global is used to check if we should react or not. After the Global == 1, you can add in whatever condition you want:



Chance = Utility.RandomInt(1,100)
If ( Chance > 20 )
;Works
EndIf

Is it a specific Crafting Recipe you want, or the Object's own? The latter would be a nightmare given the number of items :S



You know, it might be simpler to use an Activator, and a Chest... There's a Forge, I think it is called the Arcane Forge, or something similar (part of the College Questline) which works something like that). It'd be much easier in that case: Put an item in the chest, hit a button, and run your 'Did it work' Script.



Edit : Atronach Forge -- http://www.uesp.net/wiki/Skyrim:Atronach_Forge

User avatar
tiffany Royal
 
Posts: 3340
Joined: Mon Dec 25, 2006 1:48 pm

Post » Wed Feb 15, 2017 11:29 pm

Yes, and the "original container" is none. The item is created, and immediately gets that notification.



If you're creating a custom workstation for this crafting, you get a lot more leeway, and can script the crafting station, even if it's making regular stuff. The use of the events will work at any crafting station, but is most appropriate for new recipes, as you'd have to add the script to each token's form.

User avatar
Juan Suarez
 
Posts: 3395
Joined: Sun Nov 25, 2007 4:09 am

Post » Wed Feb 15, 2017 8:53 pm

thanks _CDM & ghastley, i'll look into it.



ideally, i'd like to only have the magicEffect applied whenever the forge is activated, looking at how you did it, i think i may be able to work it out somehow.



if not, I may just default this to only jewelry with, like you said, a special crafting workbench or custom forge that can do this. Originally i intended for it to only be jewelry because making these highly complex, detailed items shouldn't be able to be done with an anvil and hammer.



I'll post something back when i figure it out.

User avatar
Nienna garcia
 
Posts: 3407
Joined: Wed Apr 25, 2007 3:23 am


Return to V - Skyrim