Detect when player crafts an item?

Post » Sat Nov 17, 2012 9:35 am

I'm trying to get this script to fire when the player crafts something (a fishing net from my fishing mod, to be specific). But I don't know where to put the event, or how to actually get the little #$^$%^ to trigger:

Scriptname FishingNetRepairQuestScript extends QuestEvent OnStoryCraftItem(ObjectReference akBench, Location akLocation, Form akCreatedItem)	 Debug.notification("MAKIN' COPIES!!!") ; yes I'm THAT old...	 Debug.Trace(akItemBase + " was made at " + akBench + " in location " + akLocation)endevent

So... I made a priority 60 Quest, assigned it to begin on startup, and added the script. Hit the crafting table... nada.

What am I missing here? The CK wiki offers this cryptic advice: "Event called when this quest is started via a craft item story manager event." and I have no clue what that means... isn't assign on startup enough? "Story Manager" is just the radiant system, yes???

This isn't a quest per se - no beginning or end or dialog etc - I just need to know when they craft a net so I can keep a running tally of how many they have made, and "repair" any broken ones in the process.
User avatar
Siobhan Wallis-McRobert
 
Posts: 3449
Joined: Fri Dec 08, 2006 4:09 pm

Post » Sat Nov 17, 2012 8:38 am

Yes, OnStoryCraftItem() is tied to the Radiant Story system. This means the event is not received by the Quest itself, but by the respective Story Manager Event Node and relayed to the Quest. You need to register your Quest with Radiant Story (specifically, you must register your Quest to the Craft Item Event Node) in order to allow your scripts to receive Events from the Story Manager.
User avatar
pinar
 
Posts: 3453
Joined: Thu Apr 19, 2007 1:35 pm

Post » Sat Nov 17, 2012 1:11 pm

You have to setup the quest in the "Quest Data Tab" to be started by the event and setup the SM Event Node.
Please let us know if you manage to get it work as I have problems with "Lock Pick" and onStoryPickLock http://www.gamesas.com/topic/1398736-not-working-sm-events/
User avatar
Katharine Newton
 
Posts: 3318
Joined: Tue Jun 13, 2006 12:33 pm

Post » Sat Nov 17, 2012 11:50 am

Ok this whole story manager/quest interaction thing is horrifically arcane. I modelled my quest / node after the dagger tutorial - "Things they don't tell you" : had to set the SM Node to "Shared" and had to create a quest stage 0 "Startup Stage" with a script fragment attached to get it to work at all, but at least now it sends out a message whenever I craft anything. However...

While I can get the script fragments to work, when I add in a full Quest with the above-mentioned script, it CTDs. I'll try again tomorrow but if anyone has any suggestions or tutorials, please let me know.

Gimme a good old scripted system any day... I think "Vorpal Donkey" on DungeonSiege took me all of 15 minutes to write and had 100k downloads... oi!
User avatar
m Gardner
 
Posts: 3510
Joined: Sun Jun 03, 2007 8:08 pm

Post » Sat Nov 17, 2012 10:20 pm

I agree, the new scripting system seems to be more complex with very little actual increase in flexibility. :/
User avatar
Pat RiMsey
 
Posts: 3306
Joined: Fri Oct 19, 2007 1:22 am

Post » Sat Nov 17, 2012 5:44 pm

I agree, the new scripting system seems to be more complex with very little actual increase in flexibility. :/

Not true. Papyrus is almost five times more versatile than the old scripting language. Several scripted mods out there now would have been impossible on previous engines without a Script Extender.

Radiant Story, on the other hand, is very difficult to understand. That's the issue here, not the scripting engine.
User avatar
Lory Da Costa
 
Posts: 3463
Joined: Fri Dec 15, 2006 12:30 pm

Post » Sat Nov 17, 2012 6:19 pm

You might be able to do something like IsFurnitureInUse or IsInMenuMode and if that is true look to see if the item is added to the player's inventory, if not in furniture/menu mode end the event. I think that IsFurnitureInUse looks to see if the player is using a specific crafting bench so if that is the case you would have to apply this script to all the crafting benches in the game, or basically attach it to the base of the crafting benches which will add it to all of the models of that bench. I'd try to make the actual script myself but I'm waiting for skyrim to finish downloading before I can download the CK so I can't test to see if this would work. Hope this helps! :biggrin:
Here's some links that might be helpful in achieving my method:
http://www.creationkit.com/IsFurnitureInUse_-_ObjectReference
http://www.creationkit.com/IsInMenuMode_-_Utility
User avatar
Symone Velez
 
Posts: 3434
Joined: Thu Sep 07, 2006 12:39 am

Post » Sat Nov 17, 2012 9:03 pm

Could you not...
PlayerAlias.AddInventoryEventFilter(FishingNet)
...and catch it OnItemAdded style?
User avatar
Amy Cooper
 
Posts: 3400
Joined: Thu Feb 01, 2007 2:38 am

Post » Sat Nov 17, 2012 1:57 pm

Could you not...
PlayerAlias.AddInventoryEventFilter(FishingNet)
...and catch it OnItemAdded style?
I think he wants it to happen only when the player makes the net, if he places nets across the world and the player picks it up then they wouldn't have crafted it, but if he doesn't plan to add fishing nets around the world and you can only acquire the fishing net by making it then yeah, that would be the easiest solution I can think of.
User avatar
xx_Jess_xx
 
Posts: 3371
Joined: Thu Nov 30, 2006 12:01 pm

Post » Sat Nov 17, 2012 12:46 pm

Justin is correct, I'm trying to detect if the user is actually crafting a fishing net, thereby "improving" it like a weapon, even thuogh its a misc. But i also just realized that in order to store something like hitpoints on the object, it needs to remain an object ref, but when put in the players inventory, it goes back to a form, making my entire concept useless. Still, it was a good intro to the hell that is the SM system lol.
User avatar
Scott
 
Posts: 3385
Joined: Fri Nov 30, 2007 2:59 am

Post » Sat Nov 17, 2012 2:02 pm

If you fill a ReferenceAlias with it (OnInit, perhaps), it should still be able to be referenced as an ObjectReference when in your inventory/a container. Alternatively, a persistent placed net (point a property at it) will also *retain its FormID.

*If using GetFormID to verify this, the FormID will be returned as an Int (decimal vs. hex).
User avatar
cosmo valerga
 
Posts: 3477
Joined: Sat Oct 13, 2007 10:21 am


Return to V - Skyrim