cerebii Posted May 22, 2021 Share Posted May 22, 2021 So I've been trying to make a mod for grenade deconstruction to match my mod for ammo deconstruction, unfortunately while the ammo one is simple, the grenade one isn't so simple as some of the grenade recipes I've added (based on the recipes from 76) require non-CMPO items like Nuka-Cola and other Grenades. SKK50 helped me a little by telling me what I'd need to do, i.e. make a dummy CMPO item (for example c_nukacola) and have a player attached questalias (whatever that is) with an inventory filter script running to scan for the dummy components and swap them out with the real stuff on pickup. I'd like to say I've really tried but I just can't get my head around it at all, try as I might... I guess I'm just too stupid. Anyway I found this script on the SkyrimSE section posted a while back, as I understand it SkyrimSE scripts don't work in Fallout 4 but it might give an idea of what it is I'm trying to achieve: MiscObject Property c_nade AutoMiscObject Property fragGrenade AutoEvent OnInit() AddInventoryEventFilter(c_nade)EndEventEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Actor PlayerRef = Game.GetPlayer() If akBaseItem == c_nade PlayerRef.removeItem(c_nade,1 * Count , TRUE) PlayerRef.addItem(fragGrenade,1 * Count , TRUE) EndIfendEvent Also if anyone has any resources as to what a QuestAlias is that they can point me to, that'd also be useful, but tbh the script is the most important bit. So yeah, if anyone can help me with getting this up and running I'd be super grateful, and of course when the mod releases I'd give you equal credit :smile: Many thanks! Link to comment Share on other sites More sharing options...
SKKmods Posted May 22, 2021 Share Posted May 22, 2021 Are you using CreationKit or xEdit for this ? Link to comment Share on other sites More sharing options...
cerebii Posted May 22, 2021 Author Share Posted May 22, 2021 Are you using CreationKit or xEdit for this ? Hi again SKK, thanks for replying :smile:I'm using xEdit but I can definitely use the CK if I need to make a quest or something.Does the script I quoted look okay? Link to comment Share on other sites More sharing options...
SKKmods Posted May 22, 2021 Share Posted May 22, 2021 You will need to create a start game enabled quest to attach an inventory filter/monitor script to the player. I have no idea if you can create quests, reference aliases and attach scripts in xEdit. If you are going to be using a ReferenceAlias to attach a script to the player I dont beleve that it will receive an OnInit() event, rather use OnAliasInit() Link to comment Share on other sites More sharing options...
cerebii Posted May 22, 2021 Author Share Posted May 22, 2021 Okay so I'm pretty sure I've gotten the quest set up fine, now I just need to fix the script... So far I've got: ScriptName nadescript extends QuestMiscObject Property c_grenade_frag_scrap AutoMiscObject Property fragGrenade AutoEvent OnAliasInit() AddInventoryEventFilter(c_grenade_frag_scrap)EndEventEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Actor PlayerRef = Game.GetPlayer() If akBaseItem == c_grenade_frag_scrap PlayerRef.removeItem(c_grenade_frag_scrap,1 * Count , TRUE) PlayerRef.addItem(fragGrenade,1 * Count , TRUE) EndIfendEventAnd I get the following errors when trying to compile with Papyrus Plus Plus: new event onaliasinit cannot be defined because the script is not flagged as native Ln 5 Col 0variable Count is undefined Ln 12 Col 48cannot multiply an int with a none (cast missing or types unrelated) Ln 12 Col 48variable Count is undefined Ln 13 Col 36cannot multiply an int with a none (cast missing or types unrelated) Ln 13 Col 34new event onitemadded cannot be defined because the script is not flagged as native Ln 9 Col 0 Google didn't help unfortunately. Link to comment Share on other sites More sharing options...
SKKmods Posted May 22, 2021 Share Posted May 22, 2021 What are you trying to attach the script to ? Also Where does "Count" come from ... thats one of the problems. Link to comment Share on other sites More sharing options...
cerebii Posted May 22, 2021 Author Share Posted May 22, 2021 What are you trying to attach the script to ?A blank quest that runs on game start... I think that's what you suggested? Is this related to why the script won't compile? Also Where does "Count" come from ... thats one of the problems.Yeah so I found this script from some old SkyrimSE page so I'm not sure what it means... I was thinking "1 * Count" was like "1 of the item" but idk. Sorry I'm completely new to Papyrus and scripting in general :confused: Link to comment Share on other sites More sharing options...
LarannKiar Posted May 22, 2021 Share Posted May 22, 2021 (edited) Also if anyone has any resources as to what a QuestAlias is that they can point me to, that'd also be useful, but tbh the script is the most important bit. This is the Quest Alias (it's not Fallout 4 specific info but it's still useful). Quest Aliases point to references in the game world. If you're using a quest script (a script that's attached to the quest), here: Scriptname YOURSCRIPTNAME extends Quest Const ;YOURSCRIPTNAME: this should match with your actual script's name Weapon Property c_nade Auto Const Weapon Property fragGrenade Auto Const Actor Property PlayerRef Auto Const Event OnQuestInit() AddInventoryEventFilter(c_nade) EndEvent Event ObjectReference.OnItemAdded(ObjectReference akSource, Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) If akBaseItem == c_nade int c_nade_Count = PlayerRef.GetItemCount(c_nade) int fragGrenade_Count = PlayerRef.GetItemCount(fragGrenade) PlayerRef.RemoveItem(c_nade, c_nade_Count, abSilent = true) PlayerRef.AddItem(fragGrenade, fragGrenade_Count, abSilent = true) EndIf EndEvent But you can also create a Reference Alias (same as quest alias) with a reference alias script. Note that the code I've pasted here won't work in a reference alias script. Edited May 22, 2021 by LarannKiar Link to comment Share on other sites More sharing options...
SKKmods Posted May 22, 2021 Share Posted May 22, 2021 That script will not work either as your trying to add an inventory event filter to a quest script which has no inventory context so OnItemAdded will never actually fire. But I am too tired to argue to points, so good luck. Link to comment Share on other sites More sharing options...
cerebii Posted May 22, 2021 Author Share Posted May 22, 2021 A bunch of stuffThanks so much for the reply! So I've got: Scriptname nadescript extends Quest Const MiscObject Property c_grenade_frag_scrap Auto ConstWeapon Property fragGrenade Auto ConstActor Property PlayerRef Auto Const Event OnQuestInit() AddInventoryEventFilter(c_grenade_frag_scrap) AddInventoryEventFilter(fragGrenade)EndEvent Event ObjectReference.OnItemAdded(ObjectReference akSource, Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) If akBaseItem == c_grenade_frag_scrap int c_grenade_frag_scrapCount = PlayerRef.GetItemCount(c_grenade_frag_scrap) int fragGrenade_Count = PlayerRef.GetItemCount(fragGrenade) PlayerRef.removeItem(c_grenade_frag_scrap, c_grenade_frag_scrap_Count, abSilent = true) PlayerRef.addItem(fragGrenade, fragGrenade_Count, abSilent = true) EndIf EndEvent And the following errors: variable c_grenade_frag_scrap_Count is undefined Ln 20 Col 45type mismatch on parameter 2 - cannot pass a none to an int ln 20 Col 45 Link to comment Share on other sites More sharing options...
Recommended Posts