Jump to content

How to add scripts to FO4?


Recommended Posts

After rage-quitting messing with the Skyrim CK several times I decided to give FO4CK a try and attempt to make a "small mod".

I'm a programmer in RL so the scripting/papyrus part of the process is more or less clear and intuitive. But the part where the script is attached to CK is not.

What I want to do is a mod that undresses actors while sleeping or replaces their outfits.
I understand what the script part of this should do - strip the slots, remember what was equipped where and equip the sleep outfit. And then on wakeup do the opposite.
What I don't understand is where to put this script. 

I see there is a sleep package template and multiple sleep packages but I can see no way to put the script there.
And I keep thinking there should be some other way to trigger the script, some kind of event listener somewhere or something else
I'm assuming there should be a place where to assign the script so it is called every time an actor goes to bed - any actor to any bed.

But I can't find it. 

Any leads, ideas and suggestions are appreciated. Thanks!

 

Link to comment

After rage-quitting messing with the Skyrim CK several times I decided to give FO4CK a try and attempt to make a "small mod".

I'm a programmer in RL so the scripting/papyrus part of the process is more or less clear and intuitive. But the part where the script is attached to CK is not.

What I want to do is a mod that undresses actors while sleeping or replaces their outfits.

I understand what the script part of this should do - strip the slots, remember what was equipped where and equip the sleep outfit. And then on wakeup do the opposite.

What I don't understand is where to put this script. 

I see there is a sleep package template and multiple sleep packages but I can see no way to put the script there.

And I keep thinking there should be some other way to trigger the script, some kind of event listener somewhere or something else

I'm assuming there should be a place where to assign the script so it is called every time an actor goes to bed - any actor to any bed.

But I can't find it. 

Any leads, ideas and suggestions are appreciated. Thanks!

 

Are you trying to run that on every single actor in the game or just the player / specific actors?

 

Link to comment

What just happened?

 

Merging posts for topics like those will be nightmare for the users. 

I suggest adding a new subforum for CK and similar questions that would keep this subforum clean but will not make it impossible to follow replies.

Link to comment

What just happened?

 

CPU went slightly over-board with merging threads. I think he wanted to add your question to the General Help Thread that I opened shortly after - he did it the other way around. I'm sure he'll fix it shortly.

Link to comment

The thread was merged by mistake.

I copied a wrong link.

 

I renamed it to something close to the original name, and removed the non relevant posts.

 

Sorry for the error.

Link to comment

Back to topic, I suppose.

prinyo, on 08 May 2016 - 3:11 PM, said:snapback.png

After rage-quitting messing with the Skyrim CK several times I decided to give FO4CK a try and attempt to make a "small mod".

I'm a programmer in RL so the scripting/papyrus part of the process is more or less clear and intuitive. But the part where the script is attached to CK is not.

What I want to do is a mod that undresses actors while sleeping or replaces their outfits.
I understand what the script part of this should do - strip the slots, remember what was equipped where and equip the sleep outfit. And then on wakeup do the opposite.
What I don't understand is where to put this script. 

I see there is a sleep package template and multiple sleep packages but I can see no way to put the script there.
And I keep thinking there should be some other way to trigger the script, some kind of event listener somewhere or something else
I'm assuming there should be a place where to assign the script so it is called every time an actor goes to bed - any actor to any bed.

But I can't find it. 

Any leads, ideas and suggestions are appreciated. Thanks!

 

Are you trying to run that on every single actor in the game or just the player / specific actors?

Link to comment

 

Back to topic, I suppose.

prinyo, on 08 May 2016 - 3:11 PM, said:snapback.png

After rage-quitting messing with the Skyrim CK several times I decided to give FO4CK a try and attempt to make a "small mod".

I'm a programmer in RL so the scripting/papyrus part of the process is more or less clear and intuitive. But the part where the script is attached to CK is not.

What I want to do is a mod that undresses actors while sleeping or replaces their outfits.

I understand what the script part of this should do - strip the slots, remember what was equipped where and equip the sleep outfit. And then on wakeup do the opposite.

What I don't understand is where to put this script. 

I see there is a sleep package template and multiple sleep packages but I can see no way to put the script there.

And I keep thinking there should be some other way to trigger the script, some kind of event listener somewhere or something else

I'm assuming there should be a place where to assign the script so it is called every time an actor goes to bed - any actor to any bed.

But I can't find it. 

Any leads, ideas and suggestions are appreciated. Thanks!

 

Are you trying to run that on every single actor in the game or just the player / specific actors?

 

 

 

 

 

I'm trying to run them on any actor (PC and NPC) on any sleep event - on any furniture. 

The way I see it is this - there is a central point in the flow where the game decides that some actor is sleeping and triggers the sleep "sandbox". Then at some point the game decides that the actor needs to wake up and starts another procedure. This seems a good place to inject a script. But I can't find such a place.

I'm trying to find a solution that relies more on script than on CK tweaking. It seems one possibility is to do all via a quest that for my current abilities is quite challenging, but is also probably a good way to learn.

However I'm still hoping there is a way to intercept the sleep start and end events without a quest.

Link to comment

Adding scripts to "all actors" is for sure not a good idea.

 

The sleep package can be a solution, but it is a template, so you need to edit the template itself.

And add two fragments to it, one (on begin) to save the clothes and replace them, and another fragment (on end) to restore the original clothes.

 

Link to comment

Adding scripts to "all actors" is for sure not a good idea.

 

The sleep package can be a solution, but it is a template, so you need to edit the template itself.

And add two fragments to it, one (on begin) to save the clothes and replace them, and another fragment (on end) to restore the original clothes.

 

That is no solution. Package Templates don't have fragments - only normal Packages have fragments.

 

 

@prinyo: CPU already said it, it's a bad idea to add scripts onto all actors. That's a lot of actors. And the mess that is bound to happen earlier or later is not going to be fun to deal with.

 

I'd still prefer attaching a script that handles it to each and every Furniture/Bed object. That's already a bit messy, but not as messy as force-feeding a script to I-dont-know-how-many actors. If you were to limit the scope to the player or certain actors, Quest Aliases would be the way to go. They usually are the way to go anyhow. I'll think about it a bit longer, but I don't see a feasible way to push that script onto all actors without possible side-effects.

Link to comment

I'm trying to find a solution that doesn't have to be applied to many objects but at a specific core moment of the game's decision flow. So adding something to the packages themselves seems the cleanest solution. But I don't understand how to do it.

 

First problem I have is with the interface:

 

post-925979-0-05859500-1462718198_thumb.jpg

 

I tried clicking all around and adding or editing stuff, but I see no way to attach scripts to anything related.

 

 

The second thing I don't understand at the moment - as I read the documentation the templates are used exactly as templates when creating a package. It is not that the packages have anything to do with the template after their creation. That would mean that I actually need to edit all the packages?

Link to comment

I'm trying to find a solution that doesn't have to be applied to many objects but at a specific core moment of the game's decision flow. So adding something to the packages themselves seems the cleanest solution. But I don't understand how to do it.

 

First problem I have is with the interface:

 

attachicon.gifsleeppack.jpg

 

I tried clicking all around and adding or editing stuff, but I see no way to attach scripts to anything related.

 

 

The second thing I don't understand at the moment - as I read the documentation the templates are used exactly as templates when creating a package. It is not that the packages have anything to do with the template after their creation. That would mean that I actually need to edit all the packages?

 

As I stated above: Package Templates don't allow for fragments, only the Packages based off that allow for fragments.

So, yes. If you want to add the script directly into the packages, you'll have to edit each and every package.

 

Concerning the second part: no, packages get updated when their template updates.

I use a template as well and the actual package keeps itself updated automatically.

Link to comment

The way I see it is this:

 

1. Game evaluates the AI packages stack of the NPC

2. Game decides the NPC has to sleep 

3. Game runs procedures in order to make the NPC sleep    <-------- this is the point where the mod's script need to add it's own changes

4. NPC sleeps

 

 

In the flow of the application there is a moment where the current package applied to the actor is changed. Is it possible to intercept this moment? onSleepStart(), onSLeepEnd(), onPackageChange() or something?  And where this something would be in the CK interface?

Link to comment

Find the package template in the object window, then right-click, and "use info", this should give you an idea of how many packages you may have to alter.

Again, I don't think is a good idea, but you can try.

Link to comment

The way I see it is this:

 

1. Game evaluates the AI packages stack of the NPC

2. Game decides the NPC has to sleep 

3. Game runs procedures in order to make the NPC sleep    <-------- this is the point where the mod's script need to add it's own changes

4. NPC sleeps

 

 

In the flow of the application there is a moment where the current package applied to the actor is changed. Is it possible to intercept this moment? onSleepStart(), onSLeepEnd(), onPackageChange() or something?  And where this something would be in the CK interface?

 

You can employ events within a script only.

So still the same old problem of getting said script onto the actors that you want.

Link to comment

Find the package template in the object window, then right-click, and "use info", this should give you an idea of how many packages you may have to alter.

Again, I don't think is a good idea, but you can try.

 

63....

Some of them are sleeping children and some of them are too custom that would still leave about 40 - 45 packages to update....

So this is not a good solution it seems.

 

The way I see it is this:

 

1. Game evaluates the AI packages stack of the NPC

2. Game decides the NPC has to sleep 

3. Game runs procedures in order to make the NPC sleep    <-------- this is the point where the mod's script need to add it's own changes

4. NPC sleeps

 

 

In the flow of the application there is a moment where the current package applied to the actor is changed. Is it possible to intercept this moment? onSleepStart(), onSLeepEnd(), onPackageChange() or something?  And where this something would be in the CK interface?

 

You can employ events within a script only.

So still the same old problem of getting said script onto the actors that you want.

 

 

I don't want to use my event, I want to "intercept" an event of the game.

Link to comment

Another solution (but it will be the same effort) is:

Create a quest, add one referencealias to it.

Add a script to the alias.

Inside Use RegisterForSleep()

Then on the event OnSleep do what you need.

 

Then duplicate a bunch of times this alias and fill it with the actors you want.

 

Still very long to fill all actors you need.

 

 

Just for info:

For Skyrim CK there was something called "Sleep Outfit", but it was a leftover from GECK, and never used for real.

In FO4 CK it was completely removed.

 

Link to comment

 

Find the package template in the object window, then right-click, and "use info", this should give you an idea of how many packages you may have to alter.

Again, I don't think is a good idea, but you can try.

 

63....

Some of them are sleeping children and some of them are too custom that would still leave about 40 - 45 packages to update....

So this is not a good solution it seems.

 

The way I see it is this:

 

1. Game evaluates the AI packages stack of the NPC

2. Game decides the NPC has to sleep 

3. Game runs procedures in order to make the NPC sleep    <-------- this is the point where the mod's script need to add it's own changes

4. NPC sleeps

 

 

In the flow of the application there is a moment where the current package applied to the actor is changed. Is it possible to intercept this moment? onSleepStart(), onSLeepEnd(), onPackageChange() or something?  And where this something would be in the CK interface?

 

You can employ events within a script only.

So still the same old problem of getting said script onto the actors that you want.

 

 

I don't want to use my event, I want to "intercept" an event of the game.

 

 

That is literally what events do.

 

Another solution (but it will be the same effort) is:

Create a quest, add one referencealias to it.

Add a script to the alias.

Inside Use RegisterForSleep()

Then on the event OnSleep do what you need.

 

Then duplicate a bunch of times this alias and fill it with the actors you want.

 

Still very long to fill all actors you need.

 

 

Just for info:

For Skyrim CK there was something called "Sleep Outfit", but it was a leftover from GECK, and never used for real.

In FO4 CK it was completely removed.

Where do you get that information? Yes, Sleep Outfits were never used since the GECK, but they haven't been touched ever since. They are still there, .SetOutfit() still has the bool to define the sleep outfit, etc. etc.

It's just that they haven't had any sort of functionality since the GECK.

Link to comment

 

...

 

 

Where do you get that information? Yes, Sleep Outfits were never used since the GECK, but they haven't been touched ever since. They are still there, .SetOutfit() still has the bool to define the sleep outfit, etc. etc.

 

 

It's just that they haven't had any sort of functionality since the GECK.

 

 

By trying to use it a million times (Skyrim) without any success?

Link to comment

Somewhere in the core of the game there is a package change event. I realize I'm applying the logic of the Java "beans" here but there is something that should be interceptable in order to inject a functionality in a "clean" way.

 

Or maybe simply there is no. Because if there was then it would have been in the packages templates. The CK itself is forcing us to make slower and resource-hungry mods.

Link to comment

Yes, "package change event" is one of the three events supported by packages.

OnBegin, OnEnd, OnChange.

 

But they can only run what is inside a fragment attached to the package (not a template.)

 

Link to comment

Somewhere in the core of the game there is a package change event. I realize I'm applying the logic of the Java "beans" here but there is something that should be interceptable in order to inject a functionality in a "clean" way.

 

Or maybe simply there is no. Because if there was then it would have been in the packages templates. The CK itself is forcing us to make slower and resource-hungry mods.

 

Now I get your approach. You'll need to mess with the base scripts, if you want to do that.

That has the potential to ruin your installation.

Link to comment

Package change event is event of the package, not of the higher node (the package "changer").

 

What I'm hoping to find is an event of the package evaluator or "changer" that would give me references to the actor and the package that is been applied.

 

 

Link to comment

You can do this on Actor or ReferenceAlias.

 

You have these events that are available:

 

 

; Event received when this actor starts a new package
Event OnPackageStart(Package akNewPackage)
EndEvent
 
; Event received when this actor's package changes
Event OnPackageChange(Package akOldPackage)
EndEvent
 
; Event received when this actor's package ends
Event OnPackageEnd(Package akOldPackage)
EndEvent
Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use