Jump to content

Some newbie scripting questions


randomtguy

Recommended Posts

Hi, I'm struggling to write my first real Papyrus script and was hoping someone could answer some of my questions.

 

1) What's the best way to add functionality to a script from an existing mod without replacing the script fully? For example, I'm trying to design a script that activates when an activemagiceffect from another mod kicks in, applies an additional effect and then deactivates when the activemagiceffect is disabled.

 

2) How do I call and store a variable that's set by another script, manipulate that variable using my script temporarily and then set it back to the initial number?

 

3) How do can you make it so that every, say, 5 in game minutes, there's a 10% chance of an effect firing, and if that effect doesn't fire, then the script loops back and there's another roll of the dice in another five minutes? I know Utility.randomInt is the way to do the dice roll, but I can't figure out how to make it recur.

Edited by randomtguy
Link to comment
Share on other sites

#3 -- StartTimerGameTime to start the countdown then OnTimerGameTime to run the code you want. If your random value is not in range, start a new timer.

This would be FO4s process replacing Skyrim's RegisterForSingleUpdateGameTime and OnUpdateGameTime

 

#2 -- See here: https://www.creationkit.com/fallout4/index.php?title=Inter-mod_Communication

FO4s process is different than Skyrim as such I have no practice. The above link should help you figure it out.

 

#1 -- I will have to pass on that one for sure.

 

Hopefully, you'll get some FO4 experienced script writers to reply soon.

Link to comment
Share on other sites

#1 Extending scripts: https://www.creationkit.com/index.php?title=Extending_Scripts_(Papyrus)

#2 If the variable is a property and is not constant then it can be accessed and modified, otherwise I doubt you can find a way other than modifying the original script.

To access the property you need a cast of the script on the object, for example, if you are accessing to a quest script property, you modify it like this:

(theQuest As theScript).theProperty = 1

To access the quest of another mod you would need to use Game.GetFormFromFile as described in "Inter-mod Communication" (see answer to #2 in IsharaMeradin's reply).

#3 IsharaMeradin's reply is perfectly fine.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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