Jump to content

I need help using moveable water with a switch


jlghost117

Recommended Posts

Scriptname ccrp_WaterSwitchScript extends ObjectReference Conditional

ObjectReference Property WaterSwitch Auto Const

Int Property Status Auto Conditional

Float Property WaterLevelFlooded Auto Const
{ Water level (height) when flooded }

Float Property WaterLevelDrained Auto Const
{ Water level (height) when drained }

Float Property PumpSpeed Auto Const
{ Rate of change (units per second) }

ObjectReference[] Property WaterPlanes Auto Const
{ Array of water planes to effect }

Bool Property InitiallyFlooded Auto Const
{ Set to true if chamber is initially flooded }

Event OnActivate(ObjectReference AkActionRef)

    If AkActionRef == Game.GetPlayer()

        If Status == 0
            TranslateWaterPlanes(WaterLevelFlooded)
            GotoState("Flooded")
            Status = 1
        ElseIf Status == 1
            TranslateWaterPlanes(WaterLevelDrained)
            GotoState("Drained")
            Status = 0
        EndIf
    EndIf
EndEvent
Function TranslateWaterPlanes(Float targetZ)
        Int i = 0
        ObjectReference wp

        ; remote event registration
        If (WaterPlanes.Length > 0)            
            UnRegisterForRemoteEvent(WaterPlanes[0], "OnTranslationComplete")
            RegisterForRemoteEvent(WaterPlanes[0], "OnTranslationComplete")
        EndIf

        ; set keyframed motion type on all planes
        While (i < WaterPlanes.Length)
            wp = WaterPlanes
            wp.SetMotionType(wp.Motion_Keyframed)
            i += 1
        EndWhile
        
        ; translate planes
        i = 0
        While (i < WaterPlanes.Length)
            wp = WaterPlanes
            If (i > 0)
                wp.TranslateTo(wp.GetPositionX(), wp.GetPositionY(), targetZ - 0.1, wp.GetAngleX(), wp.GetAngleY(), wp.GetAngleZ(), PumpSpeed)
            Else
                wp.TranslateTo(wp.GetPositionX(), wp.GetPositionY(), targetZ, wp.GetAngleX(), wp.GetAngleY(), wp.GetAngleZ(), PumpSpeed)
            EndIf
            i += 1
        EndWhile
EndFunction

 

 

 

Also Anyone know how i can add sounds to the script when the water is rising/falling?

Link to comment
Share on other sites

  • 2 weeks later...
  • Recently Browsing   0 members

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