Hi there,
I am trying to create a script that resets the player to the entrance of each new room, when he is detected by an enemy (i.e. when he enters combat).
Therefore I created three things in the first room:
- an XMarker (RoomMarker1) that serves as a teleport destination
- a trigger area that determines the XMarker that will serve as a target for the reset in a current room
- a script inside the player that listens to the combat-event
The Script in the player looks like this:
Scriptname ResetAfterDetection extends ObjectReferenceimport gameObjectReference Property PreviousPosition AutoEvent OnCombatStateChanged(Actor actorRef, int combatState) If (actorRef == game.getplayer()) If (combatState == 1) game.getplayer().MoveTo(PreviousPosition) EndIf EndIfEndEvent
The PreviousPosition is set up as a property so that it can be accessed by another script and if I understood correctly, MoveTo requires an ObjectReference as a target. The Idea ist to use a variable in the MoveTo expression to change the ObjectReference for each new room the player enters. Is this possible? The trigger area has the following script:
ScriptName SetPrevPosRoom1 extends objectReference{Default script that simply activates itself when player enters trigger}import gameimport debugResetAfterDetection property player auto{access other script}bool property doOnce = TRUE auto{Fire only once? Default: TRUE};************************************auto State waiting Event onTriggerEnter(objectReference triggerRef) if(triggerRef == game.getPlayer()) if doOnce == TRUE ResetAfterDetection.PreviousPosition = MarkerRoom1 gotoState("allDone") endif endif endEventendState;************************************State allDone ;do nothingendState;************************************
However, I get the following errors concerning the highlighted change of the ObjectReference: