Jump to content

Photo

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

scripts quests

  • Please log in to reply
4 replies to this topic

#1
Mlucci4036

Mlucci4036

    Fan

  • Members
  • PipPipPip
  • 295 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! 
 


#2
SKK50

SKK50

    Institutum delenda est

  • Premium Member
  • 4,044 posts

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.



#3
Mlucci4036

Mlucci4036

    Fan

  • Members
  • PipPipPip
  • 295 posts

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. 


#4
SKK50

SKK50

    Institutum delenda est

  • Premium Member
  • 4,044 posts

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.



#5
Mlucci4036

Mlucci4036

    Fan

  • Members
  • PipPipPip
  • 295 posts

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. 







Also tagged with one or more of these keywords: scripts, quests

Page loaded in: 1.077 seconds