Jump to content

Papyrus Help


Recommended Posts

Are there any events that will fire when the player is using the terminal, BEFORE the animation plays. There are OnSit() and onMenuOpenCloseEvent() but both works after the animation has played. I need my script to run at background instead of attached to every terminal for compatibility and safety, so onActivate() is out of the picture.

All my script does is to scale the player to 1 when the terminal is activated BEFORE the animation plays. Please help me if you have any insights. Thanks!

 

Link to comment
Share on other sites

Try to use remote events, this might do it.

 

Register your quest script or player alias script for receiving OnActivate() event from all activators, terminals included, and then run:

ObjectReference.OnActivate(ObjectRererence akSender, ObjectReference akActionRef)
Checking akSender's base object is terminal, while the akActionRef is Player. Edited by werr92
Link to comment
Share on other sites

Thanks for the tip! But how would I able to register all terminals as reference at once? Doesn't the object reference can only be a single reference?

 

Edit: Here is my script. What would I need to write as "Terminal" in the commented section?

Scriptname PlayerScaleScript extends Quest

Actor PlayerREF
float PlayerScale

Event OnInit()
	Debug.Notification("PlayerScaleScriptInitialized")
	PlayerREF = Game.GetPlayer()
	RegisterForRemoteEvent(PlayerREF, "OnGetUp")
;	RegisterForRemoteEvent(Terminal, "OnActivate")
EndEvent

Event ObjectReference.OnActivate(ObjectReference akSender, ObjectReference akActionRef)
	PlayerREF = Game.GetPlayer()
	If(akSender.getbaseobject() is Terminal && akActionRef == PlayerREF)
		PlayerScale = PlayerREF.getScale()
		PlayerREF.SetScale(1.0)
	EndIf
EndEvent

Event Actor.OnGetUp(Actor akSender, ObjectReference akActionRef)
	PlayerREF = Game.GetPlayer()
	If(akSender == PlayerREF)
		PlayerREF.SetScale(PlayerScale)
	EndIf
EndEvent
Edited by PrestonGarvey76
Link to comment
Share on other sites

You could use a perk to replace the default activation. Do what you need, then call the default activation method. However, this will be incompatible with anything which also adds extra activation options to terminals. If two perks add/change activation option of the same object, none have any effect.

 

You could also try to run some script in the background which checks the area around the player for terminals and subscribes to the events there. Or puts them into a refcollalias, where you listen to onactivate. But I have no idea how performant this would be/inhowfar this would actually work well enough...

Link to comment
Share on other sites

Thanks for the advice. I plan to attach the script to power armor and vault door console as well so player can be scaled to one before the animations, for duh imuhsion. But it sounds like the perk method could be incompatible with other mods in the long run. Might risk ruining saves when trying to make it compatible with other mods.

 

The second method kinda defeats my purpose of extreme lightweight script, I'm afraid it could hurt performance, but I would probably try it as a last resort. I'm running horizon and the background scripts is starting to strain my system already.

 

How about rewriting the script and attach the script to every base terminals/powerarmor/vaultdoorconsole dynamically at runtime through a formlist? It will not work on terminals added by mods but at least it won't break any saves and it is easier and less risky to make patches. Is this a good method?

Link to comment
Share on other sites

First do some tests and read the documentation (and talk pages) for GetScale() and SetScale() because I think they don't behave as expected:

PlayerRef.SetScale(PlayerRef.GetScale())

may actually change the scale.

 

Second, I don't know if you can do this using an event because the events may be received by scripts few seconds after they were dispatched. In your example you may receive the OnActivate event after the player found the password :)

Maybe BlockActivation + OnActivate is an exception.

 

Link to comment
Share on other sites

PlayerRef.SetScale(PlayerRef.GetScale())

Simply won't work because you are setting the player scale to his current scale, they cancel out and don't serve any purpose. Say player scale is currently 0.95 and you set the scale back to 0.95 again.

 

OnAnimationEvent() may actually works and it works similarly to remote events. Though I'm not sure how to know the name because I don't have 3dsmax and I believe the names are stored in .hkx. I'm also not sure if events are received before or after the name of the animation played.

 

I really hope the f4se team would make a function probably OnPlayerActivate() where events are fire right after player activate anything, which also returning the ObjectReference that is activated. The best bet now is to write a f4se .dll plugin to get that function implemented. I could also dynamically attaching scripts to the terminals for the onActivate.

Edited by PrestonGarvey76
Link to comment
Share on other sites

  • Recently Browsing   0 members

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