Jump to content
ℹ️ Intermittent Download History issues ×

OnKill() Event delay


moriz

Recommended Posts

Hey guys, I have another scripting question:

 

I've made a script that emulates Grim Reaper's Sprint, but removes the "in VATS" requirement, so it can be procced by a kill outside of it. I've done this by adding a script on the Player Actor, which goes kinda like this:

ScriptName GrimReapersSprintTest Extends Actor

Event OnKill(Actor akVictim)
    Actor Player = Game.GetPlayer()

    If (akVictim != Player)
        ;do stuff
    EndIf
EndEvent

This works, except for one problem: the OnKill() event seems to only trigger a few seconds after the target dies, basically removing all of the responsiveness of the trait.

 

So my question is: is there a way to make this event trigger faster, or if there's a better way to do this?

 

Thanks in advance!

Edited by moriz
Link to comment
Share on other sites

Hey guys, I have another scripting question:

 

I've made a script that emulates Grim Reaper's Sprint, but removes the "in VATS" requirement, so it can be procced by a kill outside of it. I've done this by adding a script on the Player Actor, which goes kinda like this:

ScriptName GrimReapersSprintTest Extends Actor

Event OnKill(Actor akVictim)
	Actor Player = Game.GetPlayer()
	
	If (akVictim != Player)
		;do stuff
	EndIf
EndEvent
This works, except for one problem: the OnKill() event seems to only trigger a few seconds after the target dies, basically removing all of the responsiveness of the trait.

 

So my question is: is there a way to make this event trigger faster, or if there's a better way to do this?

 

Thanks in advance!

 

A few ways of speeding it up might be to try running the script in a Quest and using:

Self.RegisterForRemoteEvent(Game.GetPlayer() As ScriptObject, "OnKill")
And in another function:

Function ::remote_Actor_OnKill(Actor akSender, Actor akVictim)
	; do stuff here
EndFunction
That -might- be faster.

 

On another note, I'd ask, personally, that you use "code=auto:0" when writing out code, otherwise it makes it really hard to read every other line of text.

Edited by Reneer
Link to comment
Share on other sites

 

On another note, I'd ask, personally, that you use "code=auto:0" when writing out code, otherwise it makes it really hard to read every other line of text.

 

 

fixed. i previously just used the built-in code function, and it made the code lines really awkward. thanks for the heads up.

 

 

 

A few ways of speeding it up might be to try running the script in a Quest and using:

Self.RegisterForRemoteEvent(Game.GetPlayer() As ScriptObject, "OnKill")
And in another function:

Function ::remote_Actor_OnKill(Actor akSender, Actor akVictim)
	; do stuff here
EndFunction
That -might- be faster.

 

I'm probably gonna need a more detailed breakdown on what's going on here. I'm not too familiar with Papyrus just yet, and I'm not sure what's going on.

 

also, is there a reason why the OnKill event triggers so slowly?

Link to comment
Share on other sites

Sure thing. This is a quick and dirty script that should do what you want (haven't tested if it compiles):

 

Scriptname GrimReaperSprintQuestScript extends Quest
 
Event OnInit()
   Self.RegisterForRemoteEvent(Game.GetPlayer() As ScriptObject, "OnKill")
   ; Self is an "automatic" variable that tells Papyrus that you are
   ; directly referring to the Quest / Quest script itself.
   ; Basically what this does is it tells the quest to watch for
   ; events coming from the player specifically the OnKill event
   ; and the event gets sent to the ::remote function below
   ; The "As ScriptObject" is a "Cast" that basically
   ; tells Papyrus that it should treat the player
   ; reference as a ScriptObject
   ; Mostly this is done so that native functions
   ; which are compiled directly into Fallout4.exe
   ; will actually work properly.
EndEvent
 
Function ::remote_Actor_OnKill(Actor akSender, Actor akVictim)
   ; note the akSender variable. This is added by the remote
   ; function call above, so any function you set up with
   ; a RegisterForRemoteEvent will have the
   ; type (in this case Actor) sent as the
   ; first variable
   if (akSender == Game.GetPlayer() && akVictim != Game.GetPlayer())
      ; stuff goes here
   endif
EndFunction

 

Now, as for why you are getting slow function calls in your above script, my guess would be that A) Papyrus is slower than previous Bethedsa scripting systems because it is threaded / asynchronous (kinda-sorta), and B) Lots of stuff going on related to the player reference.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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