MSFD Water Level Functions
[no fix] GetWaterLevel (float)
[no fix] SetWaterLevel newWaterLevel_float
[no fix] ModWaterLevel waterLevelChange_float
A great opportunity for cruel traps… These functions are used to determine and modify the Water Level of the current interior cell. When an Actor suddenly finds itself underwater, it will wait until it is halfway out of breath and then begin to make its way to the surface in a straight line up. Floating corpses are moved with the water without regard for collision.
Note: If you use GetWaterLevel in a interior cell with no water, GetWaterLevel will still return a result other than 0.
Note: Set/ModWaterLevel doesn’t work in exteriors.
Sample scripts:
This script goes on a crank to make it raise or lower the water level in the room.
Begin crank
short changelevel
float direction
float waterlift
short crankturn
short currcrank
float newwaterlevel
if ( MenuMode )
return
endif
if ( OnActivate == 1 )
if ( changelevel == 0 )
if ( direction == 1 )
set direction to -1
else
set direction to 1
endif
set changelevel to 1
endif
endif
if ( changelevel == 0 )
return
endif
set crankturn to 360 * GetSecondsPassed
set crankturn to crankturn * direction
set currcrank to GetAngle X
set crankturn to currcrank + crankturn
SetAngle X crankturn
set waterlift to 120 * GetSecondsPassed
set waterlift to waterlift * direction
ModWaterLevel waterlift
set newwaterlevel to GetWaterLevel
if ( direction == 1 )
if ( newwaterlevel >= 600 )
SetWaterLevel 600
set changelevel to 0
endif
else
if ( newwaterlevel <= 0 )
SetWaterLevel 0
set changelevel to 0
endif
endif
end crank
This modified “Float” script is placed on any object with a centered pivot point to make it float on the water’s surface regardless of water level. It also will make the object stop bobbing if the PC is standing on it.
Begin NewFloat
float timer
float swingTime
float startAngle
float currangle
short reset
float xvalue
float zvalue
float zoffset
float tmpoffset
float weightoffset
set startAngle to GetStartingAngle, x
if ( MenuMode == 0 )
if ( timer == 0 )
if ( reset == 0 )
set timer to Random 100
set timer to timer / 4
endif
endif
set swingTime to 1
set timer to ( timer + GetSecondsPassed )
set currangle to GetAngle X
set xvalue to 10 * GetSecondsPassed
set zvalue to 5 * GetSecondsPassed
if ( GetStandingPC )
set zoffset to -30
SetAngle X 0
else
;rotate up
if ( timer < swingTime )
set currangle to currangle + xvalue
SetAngle X currangle
set zoffset to zoffset + zvalue
;rotate down
elseif ( timer < (swingTime * 3) )
set currangle to currangle - xvalue
SetAngle X currangle
set zoffset to zoffset - zvalue
;up again
elseif (timer < (swingTime * 4 ) )
set currangle to currangle + xvalue
SetAngle X currangle
set zoffset to zoffset + zvalue
;reset timer to zero
else
set timer to 0
set reset to 1
set zoffset to 0
SetAngle, x, startangle
endif
endif
set tmpoffset to GetWaterLevel
set tmpoffset to tmpoffset + zoffset
SetPos Z tmpoffset
endif
end NewFloat