mouzerball1000 Posted August 19, 2016 Share Posted August 19, 2016 (edited) Hello, I'm working on a mod for Fallout 4 and despite being used to making mods for F3/FNV, I've never really done much scripting and never even touched papyrus, so I'm having a lot of trouble figuring this out on my own. What I'm trying to accomplish is have a menu open when a player interacts with a certain miscellaneous object in the environment. I'm having the following issues: How do I get a script to fire on activating a miscellaneous object in the environment? I see you can use OnActivate for activators, but this is a Misc Item. The default behavior is to pick the item up, but I would like to "hijack" that and open a menu with a couple buttons asking the player what they'd like to do. Sciptname 01ModActivator extends ObjectReference Event OnActivate(ObjectReference akActionRef) Int iButton = 01ModMessage.Show() ; Shows the menu. If iButton == 0 ; Save your game Wait( 0.5 ) Game.RequestSave() ElseIf iButton == 1 ; Pick up the item akActionRef.Disable(true) ; Not sure if this is how you disable the misc item you activated. Game.GetPlayer().AddItem(Typewriter, 1, false) ; This should add the item to your inventory to simulate picking up the item? ElseIf iButton == 2 ; Cancel EndIf EndEvent So here's what I've come up with on my own here. In the CK, I created a message named 01ModMessage as a test with the three buttons and the text I want. So I'm assuming that when you activate the misc item I've attached this script to, you'll see 01ModMessage pop up. Clicking button 0 will close the menu, wait 0.5 seconds, then save the game. I don't know if it's redundant, I don't know how menus work so I was hoping this would fire a game save 0.5 seconds after the menu closes upon clicking button 0. Clicking button 1 will disable the misc item and add it to the player's inventory, to mimic the vanilla "pick up item" default behavior. Finally, clicking button 2 should just close the menu and cancel. Here are my questions, because I feel like I might be on the right track but I'm pretty positive this just isn't going to work. 1) How can I get this script to fire interacting with the misc object it's attached to? I've heard you can use OnEquip for when you've got the item in your inventory and click on it, but that's not what I'm after. I want it to run in the game world when you interact with the item. If that's not possible through scripting, I'd like to hear something alternative. It's a vanilla game item, the typewriter, so it's not a custom asset I can just make an entry for and do it properly. If anyone has a suggestion there, I'm more than open to input. It's kind of like that mod for FNV where you could interact with static objects like clocks that could tell you the time, and so on. That's the kind of thing I'm going for here. 2) For button 1, I want you to still have the ability to pick up the misc item as normal. I'm pretty sure I shouldn't be using akActionRef as my reference for disable, so how can I assign a ref to the object that was "activated"? Otherwise, is there a better/more efficient way to get rid of the object and add it to the player's inventory like it would as if you normally activated a misc object? In case you were wondering, the goal here is to give the option to players to save at typewriters similar to the Resident Evil series, a small additional way to save for survival players like me. Obviously more work would need to be done here for gameplay's sake, but this is the first step and the only one that I can't seem to figure out as I've never done any papyrus scripts. I really would appreciate any input, thank you so much for reading. Edited August 19, 2016 by mouzerball1000 Link to comment Share on other sites More sharing options...
TummaSuklaa Posted August 19, 2016 Share Posted August 19, 2016 (edited) Before I say anything else. Are you intentionally leaving out your message as a property in that script just for example sake? If not.. that's why it wont work. Edited August 19, 2016 by TummaSuklaa Link to comment Share on other sites More sharing options...
mouzerball1000 Posted August 19, 2016 Author Share Posted August 19, 2016 Before I say anything else. Are you intentionally leaving out your message as a property in that script just for example sake? If not.. that's why it wont work. Not intentionally. I truly never even touched any papyrus scripting, and looking over the Creation Kit wiki for awhile, this was what I came up with. I was more along the lines of trying to see how far I could get on my own and if I needed to resort to asking on the nexus forums, at least have something to show to help people better understand what I'm trying to go for. How would I go about doing that then? Link to comment Share on other sites More sharing options...
TummaSuklaa Posted August 19, 2016 Share Posted August 19, 2016 Pick up items all send activation events.. the thing is I believe they "block" activation from other sources for obvious reasons. There is a clever way around it but it's advanced for you.A perk and a quest script. Perks can override activation prompts and run code in their place. I can't take screens shot to make it easier, so I will walk you through it the best I can. Create a perk.Under Perk Entries, right click -> Select "Entry Point" in the next window.Leave everything as is, except give it a name in the small field.For the conditions section, choose the "Target" tab. Here you can define what will make this perk "work". As you're wanting this to work on a specific object, you have to find the condition suitable for this. Try using HasKeyword first. Condition fundamentals crash course:1.00 = true0.00 = false> : greater than< : less than== : equal!= : not equal>= : greater than or equal to<= : less than or equal to When done there.. save the perk. Almost done. Create a quest, because the perk will call a function from this.Uncheck "run once" That's the only other thing you need to do. Click "ok" or save to close the script. Then open again, and head to the script tab.Add this code: Scriptname NameOfYourQuestScript extends Quest Perk property YourPerk auto Message property 01ModMessage auto Event OnQuestInit() Game.GetPlayer().AddPerk(YourPerk) EndEvent Function SomeCoolFunctionName(ObjectReference akRef) Int iButton = 01ModMessage.Show() ; Shows the menu. If iButton == 0 ; Save your game Wait( 0.5 ) Game.RequestSave() ElseIf iButton == 1 ; Pick up the item akActionRef.Disable(true) ; Not sure if this is how you disable the misc item you activated. Game.GetPlayer().AddItem(Typewriter, 1, false) ; This should add the item to your inventory to simulate picking up the item? ElseIf iButton == 2 ; Cancel EndIf EndFunction Now for the perk script.. open script tab. Put a ";" in it and compile, otherwise it wont let you add any script. Click ok, close the perk, and open it again. Now add the property of your quest. And then in the script field add this line:(NameOfYourQuest as NameOfYourQuestScript).SomeCoolFunctionName(akTargetRef) And my soon to be wife is home now, so I had to rush through this a bit. I expect this wont be a flawless post and you may need some help with it. But this is how I get around things like that. Link to comment Share on other sites More sharing options...
mouzerball1000 Posted August 19, 2016 Author Share Posted August 19, 2016 Pick up items all send activation events.. the thing is I believe they "block" activation from other sources for obvious reasons. There is a clever way around it but it's advanced for you. A perk and a quest script. Perks can override activation prompts and run code in their place. I can't take screens shot to make it easier, so I will walk you through it the best I can. Create a perk. Under Perk Entries, right click -> Select "Entry Point" in the next window. Leave everything as is, except give it a name in the small field. For the conditions section, choose the "Target" tab. Here you can define what will make this perk "work". As you're wanting this to work on a specific object, you have to find the condition suitable for this. Try using HasKeyword first. Condition fundamentals crash course:1.00 = true0.00 = false> : greater than< : less than== : equal!= : not equal>= : greater than or equal to<= : less than or equal to When done there.. save the perk. Almost done. Create a quest, because the perk will call a function from this.Uncheck "run once" That's the only other thing you need to do. Click "ok" or save to close the script. Then open again, and head to the script tab. Add this code: Scriptname NameOfYourQuestScript extends Quest Perk property YourPerk auto Message property 01ModMessage auto Event OnQuestInit() Game.GetPlayer().AddPerk(YourPerk) EndEvent Function SomeCoolFunctionName(ObjectReference akRef) Int iButton = 01ModMessage.Show() ; Shows the menu. If iButton == 0 ; Save your game Wait( 0.5 ) Game.RequestSave() ElseIf iButton == 1 ; Pick up the item akActionRef.Disable(true) ; Not sure if this is how you disable the misc item you activated. Game.GetPlayer().AddItem(Typewriter, 1, false) ; This should add the item to your inventory to simulate picking up the item? ElseIf iButton == 2 ; Cancel EndIf EndFunction Now for the perk script.. open script tab. Put a ";" in it and compile, otherwise it wont let you add any script. Click ok, close the perk, and open it again. Now add the property of your quest. And then in the script field add this line: (NameOfYourQuest as NameOfYourQuestScript).SomeCoolFunctionName(akTargetRef)And my soon to be wife is home now, so I had to rush through this a bit. I expect this wont be a flawless post and you may need some help with it. But this is how I get around things like that. Oh man, thank you so much! I'll give this a try a bit later and report back with any issues. I think I can take it from here, but if not I'll reply with more info. Glad to see that the script itself was close, I can start branching off from this then. Link to comment Share on other sites More sharing options...
Recommended Posts