Jump to content

{Perk Fragments} Preventing spamming.


adzscott

Recommended Posts

So I've been messing around a little with perk fragments, and have made a mod which triggers a perk fragment script when an object is activated in game.

 

Is there anyway I can prevent the script from being triggered again before it has finished running? I'm trying to prevent a situation where the player can simply mash the "activate" button and run the script a dozen times before it has even finished the first run.

 

 

States cannot be used (this would be the obvious goto) as fragments are const scripts and therefore cannot support states.

 

I've looked into setting up a perk-conditon which prevents the perk from being used if the fragment is running, but cannot find a relevant conditional.

 

Any advice on how to approach this?

Link to comment
Share on other sites

You could use Quest Stages to 'track your progress'.

 

Create quest

0 stage: nothing done yet

Your code only executes when quest is stage 0 (conditional)

First line of code sets quest to stage 10

10 stage: working

Last line of code sets quest to stage 20

20 stage: done, do nothing

Link to comment
Share on other sites

So a fragment can't have states right?

 

Why not instead just have an almost empty quest that only has the activation script in it?

 

You have the perk fragment use that quest as a property, and have the quest script have a function with the code you want to execute.

 

In the fragment you just call QuestProperty.Function()

 

Within the quest script you have your states, one which has the function with the stuff you want to do, and the other state a busy state that does nothing.

Edited by Ashnal
Link to comment
Share on other sites

So a fragment can't have states right?

 

Why not instead just have an almost empty quest that only has the activation script in it?

 

You have the perk fragment use that quest as a property, and have the quest script have a function with the code you want to execute.

 

In the fragment you just call QuestProperty.Function()

 

Within the quest script you have your states, one which has the function with the stuff you want to do, and the other state a busy state that does nothing.

That's... not a bad idea. It would certainly remove a lot of the limitations of perk fragments (They don't hang on to variables too well). Let me give it a go and see what happens.

 

EDIT: So I gave it a go.

 

Can't find a way to get the quest script to target the activated object. Also, QuestProperty.Function() doesn't appear to be working.

Edited by adzscott
Link to comment
Share on other sites

How would you normally get the fragment to target the activated object?

 

If the fragment has a reference to the object, you can simply pass it to the quest script via a function parameter.

 

I looked itup on the CK wiki

Scriptname ActivationQuest extends Quest

function PerformAction(ObectReference akTarget)
	GotoState("Busy")

	;Stuff you want to do goes here
	;akTarget shouldbe the reference to the activated object

	GotoState("")
EndFunction

State Busy
	function PerformAction()
		;Do nothing
	EndFunction
EndState 

that's the script attached to the quest

 

then you have as the perk fragment:

ActivationQuest.PerformAction(akTarget)

BUT you have to link the property. To do that hit "Properties" underneath the fragment window. Then at the bottom of that window, "Add Property." Type in the type as "Quest" and name it "ActivationQuest." Then once the property is created, select it in the property list and click "Edit Value." For the "Pick Object" dropdown, find and select "ActivationQuest." Note that you have to have created the quest and named it ActivationQuest before doing the perk fragment.

 

I referenced these two articles just now to come up with this :)

http://www.creationkit.com/fallout4/index.php?title=States_(Papyrus)

http://www.creationkit.com/fallout4/index.php?title=Perk_Fragments

Edited by Ashnal
Link to comment
Share on other sites

  • 2 weeks later...

I have been trying to accomplish a similar task. I tried many different combinations including your exact setup. Some of the functions in the quest script would function, some would not. Also I was still able to spam the activation.

 

Another weird issue, when I added the properties from the quest script to the perk fragment the previously non functioning functions would get performed...

 

Papyrus is killing me, fragments even more so.

 

Edit:

I managed to accomplish my goal by creating a global variable, using it to set an int in the fragment, then using if/else. So far its working well.

 

;BEGIN CODE
int Running = MyGlobal.GetValueInt()
If Running == 0
MyGlobal.SetValue(1)
;do stuff
;do more stuff
;continue doing stuff
MyGlobal.SetValue(0)
Else
Endif
;END CODE
EndFunction
;END FRAGMENT
Then I added a condition to my custom activator that also checked for the global and removed the custom activator while the script is running (global is 1)
Edited by colebylamoreau
Link to comment
Share on other sites

  • Recently Browsing   0 members

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