[B][SIZE=2]
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; Stormrider Ship Script - Copyright © Nov 2004 by Kellick Stormcrow
; Based on: Ship Script - Copyright © Feb 2003 by (MAD)MAX YUE
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
Begin KS_SR_Ship_Script
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
;GLOBAL PARMATERS
;===============================================================================
;short KS_SR_Ship_Sailmode ; 0=dismounted, 1=sailing
;short KS_SR_Ship_Cellchange ; flag when player change cell
;short KS_SR_Ship_Speed ; sailing speed
;float KS_SR_Ship_Angle ; store object angle before it gets deleted
;float KS_SR_Ship_Xmul ; pre-determined sin/cos multiplier
;float KS_SR_Ship_Ymul ; pre-determined sin/cos multiplier
;short KS_SR_Ship_Freemode ; flag set when in freemode
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
;LOCAL PARAMETERS
;===============================================================================
float xx ; object x coordinates
float yy ; object y coordinates
float zz ; object z coordinates
float oangle ; object z axis angle
float zangle ; player z axis angle
float xxx ; player x coordinates
float yyy ; player y coordinates
float zzz ; player z coordinates
float xxxx ; collision x coordinates
float yyyy ; collision y coordinates
short landed ; parameter set when player landed
float stimer ; timer used to delay delete object
short sscript ; parameter set when cell change
short doOnce ; parameter used to set boat position once immediately after creation
short select ; button used for selecting options
short selectflag1 ; flag set when boat is activated
short selectflag2 ; flag set when FTS or Fast Travel is selected
short selectflag3 ; flag set for boat
short delay ; parameter used to delay Disable/Enable
short pressed ; parameter to determine whether button is pressed
short temp ; temporary parameter
float xdist ; parameter used to calculate x distance
float ydist ; parameter used to calculate y distance
float distance ; parameter used to calculate avg distance
short startflag ; parameter used to check whether boat is docking
short disableflag ; flag used to disable ship script
short repair ; parameter used to calculate repair pts
short fflag
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; SCRIPT BEGINS
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( MenuMode == 1 )
return
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; DELETE OBJECT
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( disableflag == 1 )
Disable
set KS_SR_Ship_Flag to 0
if ( CellChanged == 1 )
SetDelete, 1
endif
return
endif
if ( KS_SR_Ship_Speed > 0 )
if ( CellChanged == 1 )
set KS_SR_Ship_Cellchange to 1
endif
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; Object will warp or remain in previous cell during cell change. To replace the object,
; a new object is created. Requires global script "KS_SR_Ship_Create" to create new object.
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( KS_SR_Ship_Sailmode == 1 )
if ( KS_SR_Ship_Cellchange == 1 )
set KS_SR_Ship_Flag to 0
startscript, "KS_SR_Ship_Create"
set KS_SR_Ship_Cellchange to 2
set stimer to 0
if ( sscript > 0 )
SetDelete, 1
return
endif
set sscript to 1
endif
endif
if ( sscript == 1 )
if ( KS_SR_Ship_Cellchange == 0 )
Disable
set sscript to 2
endif
endif
if ( sscript == 2 )
set stimer to ( stimer + GetSecondsPassed )
if ( stimer >= 1.5 )
SetDelete, 1
return
else
return
endif
endif
if ( KS_SR_Ship_Speed > 0 )
if ( delay == 0 )
Disable
set delay to 1
endif
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; Set ship initial coordinates
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( doOnce == 0 )
Disable
if ( KS_SR_Ship_X != 0 )
if ( KS_SR_Ship_Y != 0 )
set xx to KS_SR_Ship_X
set yy to KS_SR_Ship_Y
if ( KS_SR_Ship_Angle >= 0 )
set oangle to ( KS_SR_Ship_Angle - 180 )
else
set oangle to ( 180 + KS_SR_Ship_Angle )
endif
setpos, x, xx
setpos, y, yy
setpos, z, -100
setAngle, z, oangle
endif
endif
Enable
set KS_SR_Ship_Flag to 1
set doOnce to 1
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; Set coordinates correct ship coordinates immediately after load game
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( KS_SR_Ship_Sailmode == 0 )
set xx to KS_SR_Ship_X
set yy to KS_SR_Ship_Y
if ( KS_SR_Ship_Angle >= 0 )
set oangle to ( KS_SR_Ship_Angle - 180 )
else
set oangle to ( 180 + KS_SR_Ship_Angle )
endif
setpos, x, xx
setpos, y, yy
setpos, z, -100
setAngle, z, oangle
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; Select Menu Routine
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( selectflag1 == 1 )
set select to GetButtonPressed
if ( select == 0 )
messagebox "FAST TRAVEL", "Azura's Coast", "Bitter Coast", "Ebonheart", "Sheogorad", "Solstheim" "CANCEL"
set KS_SR_Ship_Sailmode to 0
set selectflag2 to 1
set selectflag1 to 0
elseif ( select == 1 )
startscript KS_SR_Boat_Multiplier_03
if ( KS_SR_Ship_Exist == 5 )
if ( GetPCCell "Wilderness" != 1 )
messagebox "Dispatch boat?", "Yes", "No"
set selectflag3 to 1
set selectflag1 to 0
else
messagebox "The seas are too rough to dispatch the boat"
set selectflag1 to 0
set KS_SR_Ship_Speed to temp
endif
else
messagebox "You do not have a boat on the ship!!!"
set selectflag1 to 0
set KS_SR_Ship_Speed to temp
endif
elseif ( select == 2 )
messagebox "Ship is slowly reversing......."
startscript "KS_SR_Ship_Create_Detect_R"
set KS_SR_Ship_Speed to -2
set selectflag1 to 0
elseif ( select == 3 )
messagebox "Ship has stopped and safely anchored........"
set landed to 2
set selectflag1 to 0
elseif ( select == 4 )
if ( KS_SR_Ship_Damage == 500 )
Messagebox "Ship is not damaged!"
elseif ( player->GetItemCount, "KS_SR_misc_ship_repair" > 0 )
playsound "Repair"
player->removeitem "KS_SR_misc_ship_repair", 1
set repair to Random, 100
set KS_SR_Ship_Damage to ( KS_SR_Ship_Damage + repair )
if ( KS_SR_Ship_Damage > 500 )
set KS_SR_Ship_Damage to 500
endif
messagebox "Ship Health = %.0f / 500", KS_SR_Ship_Damage
else
messagebox "You do not have any tools to repair the ship........"
endif
set selectflag1 to 0
elseif ( select == 5 )
EnablePlayerJumping
set KS_SR_Ship_Freemode to 1
set selectflag1 to 0
set KS_SR_Ship_Speed to temp
elseif ( select == 6 )
set selectflag1 to 0
set KS_SR_Ship_Speed to temp
endif
return
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; FAST TRAVEL ROUTINE
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( selectflag2 == 1 )
set select to GetButtonPressed
if ( select == 0 )
fadeto 100, 0.001
set KS_SR_Ship_Freemode to 0
set KS_SR_Ship_X to 182748
set KS_SR_Ship_Y to 19044
set KS_SR_Ship_Angle to -90
set selectflag2 to 2
set disableflag to 1
set KS_SR_Ship_Doorflag to 1
set KS_SR_Ship_Hatchflag to 1
startscript KS_SR_Ship_FTravel_AZ
elseif ( select == 1 )
fadeto 100, 0.001
set KS_SR_Ship_Freemode to 0
set KS_SR_Ship_X to -78608
set KS_SR_Ship_Y to 30836
set KS_SR_Ship_Angle to 0
set selectflag2 to 2
set disableflag to 1
set KS_SR_Ship_Doorflag to 1
set KS_SR_Ship_Hatchflag to 1
startscript KS_SR_Ship_FTravel_BC
elseif ( select == 2 )
fadeto 100, 0.001
set KS_SR_Ship_Freemode to 0
set KS_SR_Ship_X to 22816
set KS_SR_Ship_Y to -101708
set KS_SR_Ship_Angle to 180
set selectflag2 to 2
set disableflag to 1
set KS_SR_Ship_Doorflag to 1
set KS_SR_Ship_Hatchflag to 1
startscript KS_SR_Ship_FTravel_EH
elseif ( select == 3 )
fadeto 100, 0.001
set KS_SR_Ship_Freemode to 0
set KS_SR_Ship_X to 12786
set KS_SR_Ship_Y to 216832
set KS_SR_Ship_Angle to 180
set selectflag2 to 2
set disableflag to 1
set KS_SR_Ship_Doorflag to 1
set KS_SR_Ship_Hatchflag to 1
startscript KS_SR_Ship_FTravel_SH
elseif ( select == 4 )
fadeto 100, 0.001
set KS_SR_Ship_Freemode to 0
set KS_SR_Ship_X to -168102
set KS_SR_Ship_Y to 137248
set KS_SR_Ship_Angle to 180
set selectflag2 to 2
set disableflag to 1
set KS_SR_Ship_Doorflag to 1
set KS_SR_Ship_Hatchflag to 1
startscript KS_SR_Ship_FTravel_SS
elseif ( select == 5 )
set KS_SR_Ship_Speed to temp
set selectflag2 to 0
set KS_SR_Ship_Sailmode to 1
endif
return
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; BOAT DISPATCH ROUTINE
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( selectflag3 == 1 )
set select to GetButtonPressed
if ( select == 0 )
set landed to 2
set selectflag3 to 0
set KS_SR_Ship_Sailmode to 1
set KS_SR_Ship_Exist to 10
set KS_SR_Boat_X to ( KS_SR_Ship_X + ( 450 * KS_SR_Boat_Xmul ) )
set KS_SR_Boat_Y to ( KS_SR_Ship_Y + ( 450 * KS_SR_Boat_Ymul ) )
set KS_SR_Boat_Angle to KS_SR_Ship_Angle
startscript KS_SR_Boat_Create
elseif ( select == 1 )
set KS_SR_Ship_Speed to temp
set KS_SR_Ship_Sailmode to 1
set selectflag3 to 0
endif
return
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; Activate sailing
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( OnActivate = 1 )
if ( KS_SR_Ship_Sailmode == 0 )
Disable
if ( KS_SR_Boat_Sailmode > 0 )
messagebox "You parked your boat onto the ship........"
set KS_SR_Ship_Exist to 2
else
set KS_SR_Ship_Freemode to 0
DisablePlayerJumping
"player"->AddSpell, KS_SR_floatboat
StopScript "TribunalMain"
"player"->DisableLevitation
"player"->DisableTeleporting
messagebox "Make sure you are in RUNNING mode!!"
set startflag to 1
endif
Enable
else
set KS_SR_Ship_Freemode to 0
DisablePlayerJumping
set startflag to 1
elseif ( KS_SR_Ship_Sailmode == 1 )
messagebox "SAIL MODE"
endif
endif
if ( KS_SR_Ship_Exist == 3 )
set startflag to 1
endif
if ( startflag == 1 )
set xxx to ( KS_SR_Ship_X + ( KS_SR_Ship_Xmul * 500 ) )
set yyy to ( KS_SR_Ship_Y + ( KS_SR_Ship_Ymul * 500 ) )
"player"->setPos, x, xxx
"player"->setPos, y, yyy
"player"->setPos, z, 156.38
startscript "KS_SR_Ship_Multiplier"
startscript "KS_SR_Ship_Doormulti"
startscript "KS_SR_Ship_Hatchmulti"
startscript "KS_SR_Ship_Colmulti_02"
startscript "KS_SR_Ship_Colmulti_03"
startscript "KS_SR_Ship_Colmulti_04"
startscript "KS_SR_Ship_Colmulti_05"
startscript "KS_SR_Ship_Create_Detect_01"
startscript "KS_SR_Ship_Create_Detect_02"
startscript "KS_SR_Ship_Create_Detect_03"
startscript "KS_SR_Ship_Create_Detect_04"
startscript "KS_SR_Ship_Create_Detect_05"
set KS_SR_Ship_Sailmode to 1
set startflag to 0
if ( KS_SR_Ship_Exist == 3 )
set KS_SR_Ship_Exist to 4
endif
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; Gather object and player coordinates
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( KS_SR_Ship_Sailmode > 0 )
set xx to getPos, x
set yy to getPos, y
if ( xx != KS_SR_Ship_X )
set xx to KS_SR_Ship_X
endif
if ( yy != KS_SR_Ship_Y )
set yy to KS_SR_Ship_Y
endif
set zangle to "player"->getAngle, z
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; Collision Detection Check
-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( KS_SR_Ship_Sailmode == 1 )
set KS_SR_Ship_Xdist to ( "player"->getpos, x - xxx )
set KS_SR_Ship_Ydist to ( "player"->getpos, y - yyy )
set xdist to ( KS_SR_Ship_Xdist * KS_SR_Ship_Xdist )
set ydist to ( KS_SR_Ship_Ydist * KS_SR_Ship_Ydist )
set distance to ( xdist + ydist )
set KS_SR_Ship_Distance to GetSquareRoot, distance
endif
if ( KS_SR_Ship_Hitflag == 3 )
if ( KS_SR_Ship_Speed > 0 )
set KS_SR_Ship_Damage to ( KS_SR_Ship_Damage - KS_SR_Ship_Speed )
messagebox "Damage = %.0f, Ship Health = %.0f / 500", KS_SR_Ship_Speed, KS_SR_Ship_Damage
endif
if ( KS_SR_Ship_Damage <= 0 )
Disable
messagebox "Your ship is WRECKED!!"
set KS_SR_Ship_Speed to 0
set KS_SR_Ship_Hitflag to 0
playsound, "KS_SR_Boat_Wreck"
set KS_SR_Ship_Exist to 0
player->removespell, KS_SR_Floatboat
EnablePlayerJumping
"player"->EnableTeleporting
"player"->EnableLevitation
StartScript "TribunalMain"
set KS_SR_Ship_Sailmode to 0
set KS_SR_Ship_Freemode to 0
SetDelete, 1
return
endif
if ( KS_SR_Ship_Speed > 0 )
set xxxx to ( xx - ( KS_SR_Ship_Xmul * 100 ) )
set yyyy to ( yy - ( KS_SR_Ship_Ymul * 100 ) )
else
set xxxx to ( xx + ( KS_SR_Ship_Xmul * 10 ) )
set yyyy to ( yy + ( KS_SR_Ship_Ymul * 10 ) )
endif
set xx to xxxx
set yy to yyyy
set KS_SR_Ship_Speed to 0
set KS_SR_Ship_Hitflag to 0
endif
if ( KS_SR_Ship_Freemode == 1 )
if ( "player"->getpos, z < 0 )
messagebox "You have fallen off the ship"
set landed to 1
endif
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; Restore all parameters after landing
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( landed > 0 )
set KS_SR_Ship_Speed to 0
Stopscript "KS_SR_Ship_Multiplier"
Stopscript "KS_SR_Ship_Colmulti_02"
Stopscript "KS_SR_Ship_Colmulti_03"
Stopscript "KS_SR_Ship_Colmulti_04"
Stopscript "KS_SR_Ship_Colmulti_05"
Stopscript "KS_SR_Ship_Doormulti"
Stopscript "KS_SR_Ship_Hatchmulti"
Disable
set landed to 0
player->removespell, KS_SR_floatboat
EnablePlayerJumping
"player"->EnableLevitation
"player"->EnableTeleporting
StartScript "TribunalMain"
Enable
set KS_SR_Ship_Sailmode to 0
set KS_SR_Ship_Freemode to 0
return
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; Speed Control
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( KS_SR_Ship_Freemode == 0 )
if ( KS_SR_Ship_Sailmode == 1 )
if ( GetPCRunning == 1 )
if ( ScriptRunning, "KS_SR_Ship_Multiplier_02" == 0 )
startscript "KS_SR_Ship_Multiplier_02"
endif
endif
endif
if ( KS_SR_Ship_Sailmode == 1 )
if ( GetPCRunning == 1 )
if ( KS_SR_Ship_Gear == 1 )
if ( KS_SR_Ship_Speed < 30 ) ; max speed can be adjusted here ( default = 30 )
set KS_SR_Ship_Speed to ( KS_SR_Ship_Speed + 1 )
if ( KS_SR_Ship_Speed > 30 )
set KS_SR_Ship_Speed to 30
endif
messagebox "Ship Speed : %.0f", KS_SR_Ship_Speed
else
messagebox "Ship Speed : %.0f ( max. )", KS_SR_Ship_Speed
endif
elseif ( KS_SR_Ship_Gear == 2 )
if ( KS_SR_Ship_Speed > 0 )
rotate, z, -40
set oangle to getAngle, z
if ( oangle >= 0 )
set KS_SR_Ship_Angle to ( oangle - 180 )
else
set KS_SR_Ship_Angle to ( 180 + oangle )
endif
endif
elseif ( KS_SR_Ship_Gear == 3 )
if ( KS_SR_Ship_Speed > 0 )
rotate, z, 40
set oangle to getAngle, z
if ( oangle >= 0 )
set KS_SR_Ship_Angle to ( oangle - 180 )
else
set KS_SR_Ship_Angle to ( 180 + oangle )
endif
endif
elseif ( KS_SR_Ship_Gear == 4 )
if ( KS_SR_Ship_Speed > 0 ) ; min speed can be adjusted here ( default = 0 )
set KS_SR_Ship_Speed to ( KS_SR_Ship_Speed - 1 )
messagebox "Ship Speed : %.0f", KS_SR_Ship_Speed
else
set KS_SR_Ship_Speed to 0
messagebox "Ship Speed : 0 ( Stopped )"
endif
endif
else
stopscript "KS_SR_Ship_Multiplier_02"
endif
endif
endif
if ( KS_SR_Ship_Sailmode == 1 )
if ( pressed == 0 )
if ( GetPCSneaking == 1 )
set pressed to 1
endif
else
if ( GetPCSneaking == 0 )
set pressed to 0
messagebox "SELECT OPTIONS", "Fast Travel" "Boat" "Reverse" "Anchor" "Repair Ship" "Free Mode" "CANCEL"
set selectflag1 to 1
set temp to KS_SR_Ship_Speed
set KS_SR_Ship_Speed to 0
Enable
return
endif
endif
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; Sail direction calculation by using player zrot angle - resolution 1 degree
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( KS_SR_Ship_Sailmode > 0 )
set xx to ( xx + ( KS_SR_Ship_Xmul * KS_SR_Ship_Speed ) )
set yy to ( yy + ( KS_SR_Ship_Ymul * KS_SR_Ship_Speed ) )
if ( KS_SR_Ship_Freemode == 0 )
set xxx to ( xx + ( KS_SR_Ship_Xmul * 500 ) )
set yyy to ( yy + ( KS_SR_Ship_Ymul * 500 ) )
else
set xxx to "player"->getpos, x
set yyy to "player"->getpos, y
set xxx to ( xxx + ( KS_SR_Ship_Xmul * KS_SR_Ship_Speed ) )
set yyy to ( yyy + ( KS_SR_Ship_Ymul * KS_SR_Ship_Speed ) )
endif
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; Set the sailing motion
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( KS_SR_Ship_Sailmode > 0 )
"player"->setPos, x, xxx
"player"->setPos, y, yyy
if ( KS_SR_Ship_Freemode == 0 )
"player"->setPos, z, 156.4
endif
setPos, x, xx
setPos, y, yy
setPos, z, -100
set KS_SR_Ship_X to xx
set KS_SR_Ship_Y to yy
endif
if ( delay == 1 )
Enable
set delay to 0
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; Sound for ambiance
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
if ( CellChanged == 0 )
if ( GetSoundPlaying "Boat Hull" == 0 )
PlayLoopSound3DVP "Boat Hull" 0.4, 1.0
endif
endif
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
; SCRIPT ENDS
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
End KS_SR_Ship_Script
[/B][/SIZE]