Jump to content

Asphyxiation script help needed


Recommended Posts

Aim : Mimic the under water asphyxiation on land.

Here's what I'm trying to achieve : the player enters in a room with not much air, there's a limited time to perform actions. After 1 real minute the player dies slowly of suffocation.

If the player goes out of the room to take some fresh air and come back, the timer should reset and count one minute again and so one.

Problem : my timer doesn't reset.

The script:

 

Scn PixTechRoomEnterScript

short DoOnce
short State
float Timer

Begin OnTrigger

    if DoOnce == 0
        ShowMessage PixSasDoorSmellMssg
        Set DoOnce to 1
    endif
    if SasMainGenSoundRef.GetDisabled == 1
        if Timer  > 0
            Set Timer to Timer - GetSecondsPassed
        elseif State == 0
            Set State to 1
            Set Timer to 5
        elseif State == 1
            Player.DamageActorValue Health 25
            Set State to 2
            Set Timer to 5
        elseif State == 2
            ShowMessage PixSasOxygenMissMssg
            Player.DamageActorValue Health 25
            Set State to 3
            Set Timer to 5
        elseif State == 3
            Player.DamageActorValue Health 25
            Set State to 4
            Set Timer to 5
        elseif State == 4
            Player.DamageActorValue Health 25
            Set State to 5
            Set Timer to 5
        elseif State == 5
            Player.DamageActorValue Health 25
            ShowMessage PixSasOxygenMissMssg
            Set State to 6
            Set Timer to 5
        elseif State == 6
            Player.DamageActorValue Health 25
            Set State to 7
            Set Timer to 5
        elseif State == 7
            Player.DamageActorValue Health 25
            Set State to 8
            Set Timer to 5
        elseif State == 8
            Player.DamageActorValue Health 35
            ShowMessage PixSasOxygenMissMssg
            ApplyImagespaceModifier SasDead
            Set State to 9
            Set Timer to 5
        elseif State == 9
            ShowMessage PixSasZFailMssg
            Player.DamageActorValue Health 35
            Set State to 10
            Set Timer to 4
        elseif State == 10
            Player.DamageActorValue Health 250
            Set State to 11
        endif
    endif
End

Begin OnTriggerLeave
    Set State to 0
    Set Timer to 0
End

 


The UI clock would be ideal, but I couldn't figure out how it is scripted in game...

Thank you for any help or advice.
Pix.

Link to comment
Share on other sites

Am I correct in assuming that your trigger encompasses the entire room? If your script never resets, then I am assuming that the OnTriggerLeave block never runs. You can test that by adding a (debug) message to that block and seeing if it ever gets displayed. My guess is that it does not. So, is it possible that upon leaving the trigger, the player also exits the cell? That would stop the trigger script from running entirely.

 

But in general, your script looks good to me except that you probably want to specify the player as the action ref for the trigger blocks so that only the player's movement/collision triggers the trigger scripts:

OnTrigger Player

OnTriggerLeave Player

 

Then you may want to reset the DoOnce variable such that the player receives the same early smell warning message if he re-enters the room.

Edited by pkleiss
Link to comment
Share on other sites

Let's see...

 

You could limit the size of your trigger such that there is enough room to leave it before using the teleport exit door...

 

OR

 

You could put a script on the teleport door that intercepts the activation of the door and resets the variables in your trigger script before activating the door. To do this, the first thing you'll need to do is make your trigger a persistent reference and give it a valid Ref ID. The you can access the variables from your trigger script in other scripts using the convention TriggerRefID.Variable

SCN ExitDoorScript

Begin OnActivate Player
    Set TriggerRefId.State to 0
    Set TriggerRefID.Timer to 0
    Set TriggerRefID.DoOnce to 0   (this is optional if you want to see the initial note each time you enter the cell)
    Activate
End

Oh yeah... If you go this route, you can remove the OnTriggerLeave block from your original script.

Edited by pkleiss
Link to comment
Share on other sites

  • Recently Browsing   0 members

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