Jump to content

How to Execute a Script on the Player: Resurrect and Teleport on Death


Recommended Posts

Maybe someone can help me out with a little issue I've been running into for a quest I've been trying to implement.

 

I'm working on a mod where the player fights several waves of enemies until they are able to defeat the final boss. Since it like an arena of sorts, I decided I wanted to have the player be "penalized" for losing the fight. My thought process was to have a script be executed when the player dies, then they are teleported to an XMarker I have set in a separate Interior Cell. This is what I had written and compiled:

 

Scriptname MMUROnDeathTeleport extends Actor
Actor Property PlayerRef Auto
ObjectReference Property MMURPenaltyBoxMarker Auto
Event OnDeath(Actor akKiller)
if akKiller == Game.GetPlayer()
akKiller.MoveTo(MMURPenaltyBoxMarker)
akKiller.Resurrect()
endif
EndEvent
I have both the player and Xmarker defined as properties, and I have the script attacked to a Quest Alias linked to the player. This compiles, but does not work in game. I have not added the lines that Fail the quest on death, or have it be running only during the quest, but I think I understand how to implement those. The big issue is just getting the OnDeath event to actually run.
Does anyone have any suggestions of how to get this to work? Or could there be an easier way to do this, such as having it run when the player gets to 1 HP instead of actually dead.
Thanks in advance!
Link to comment
Share on other sites

When the player dies the game ends.

 

Also your script logic is checking if the player has killed the player [ if akKiller == Game.GetPlayer() ] ... that cant be right ?

 

What you probably need to do is make the player essential and use the OnEnterBleedout event and then handle bleedout recovery.

 

But need to check if the player is ALREADY essential from another mod (like PlayerUndead) which may be managing bleedout recovery to avoid collisions.

Link to comment
Share on other sites

When the player dies the game ends.

 

Also your script logic is checking if the player has killed the player [ if akKiller == Game.GetPlayer() ] ... that cant be right ?

 

What you probably need to do is make the player essential and use the OnEnterBleedout event and then handle bleedout recovery.

 

But need to check if the player is ALREADY essential from another mod (like PlayerUndead) which may be managing bleedout recovery to avoid collisions.

I had not thought to account for other mods that might effect what I'm looking to achieve. I'd imagine I have to set a function to set the player as essential, like this?

 

Scriptname MMUROnDeathTeleport01 extends Actor
Actor Property PlayerRef Auto
ObjectReference Property MMURPenaltyBoxMarker Auto
Quest Property MMUR_Arena_Fight_01 Auto
Function Startup()
If (MMUR_Arena_Fight_01.GetStageDone(20) == 1)
PlayerRef.setessential(True)
EndIf
EndFunction
Event OnEnterBleedout()
PlayerRef.Resurrect()
PlayerRef.MoveTo(MMURPenaltyBoxMarker)
EndEvent
​Apologies if I'm not understanding your explanation, I've been trying to understand the papyrus tutorials on the Creation Kit Wiki, but I'm just not grasping how to properly write then, and where the script needs to be applied to.
Link to comment
Share on other sites

You are trying to do some fairly complicated/advanced stuff.

 

I suggest you download my PlayerUndead mod, extract the script (using BAE and Champollion) and step through that to get a feel for how to do this stuff. Otherwise I'll just end up having to explain that whole script to you.

Link to comment
Share on other sites

You are trying to do some fairly complicated/advanced stuff.

 

I suggest you download my PlayerUndead mod, extract the script (using BAE and Champollion) and step through that to get a feel for how to do this stuff. Otherwise I'll just end up having to explain that whole script to you.

Fair enough, thank you for the help though! I will take a look through your work and see if I can get a better understanding.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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