Jump to content

Flight Scripting Help !


DarthBain

Recommended Posts

Wow Seriously, Thank you everyone who's replied on this :thumbsup:

 

@Rickerhk Yeah ive got NVSE installed and loading geck via the NVSE loader and ive checked that NVSE is working too. I just tried that example and it still wont save thanks for your help though

 

@Ozziefire that kryponite radiation script is a great idea nice one !

 

@PaladinRider ive got everything into the .esp (the idle anims & spells) except from these last 2 scripts, ive got this script too that goes with it but this wont save either, its the acutal flight effect script

 

scriptname AFlightEffectScript

 

float PositionX ;store the characters position

float PositionY

float PositionZ

 

float PositionZPrevious

float PositionZNew

 

float AngleX ;stored to where the character looks

float AngleZ

 

float VelocityX ;character stored velocity

float VelocityY

float VelocityZ

 

float Velocity ;stored velocity

 

float Timer

 

Short VelocityChangeKey

 

ref Cell ;stores the cell in which the character is

 

;carries out flight

 

Begin ScriptEffectStart

;initializes the variables to start flight

 

Set PositionX to Player.GetPos X

Set PositionY to Player.GetPos Y

Set PositionZPrevious to Player.GetPos Z

 

Set AngleX to Player.GetAngle X

Set AngleZ to Player.GetAngle Z

 

Set Velocity to 0

 

Set VelocityX to 0

Set VelocityY to 0

Set VelocityZ to 0

 

Set Cell to Player.GetParentCell

End

 

Begin ScriptEffectUpdate

Set Timer to ScriptEffectElapsedSeconds

Set PositionZ to Player.GetPos Z

Set VelocityX to 0

Set VelocityY to 0

Set VelocityZ to 0

Set AngleX to Player.GetAngle X

Set AngleZ to Player.GetAngle Z

 

;check if you changed your cell and adjust values

If Cell != Player.GetParentCell

Set Cell to Player.GetParentCell

 

Set PositionZNew to Player.GetPos X - PositionX

If PositionZNew > 200 || PositionZNew < -200 ;detect a sudden change in the X axis

Set PositionZPrevious to Player.GetPos Z + 20

Set PositionX to Player.GetPos X

Set PositionY to Player.GetPos Y

EndIf

 

Set PositionZNew to Player.GetPos Y - PositionY

If PositionZNew > 200 || PositionZNew < -200 ;detect a sudden change in the Y axis

Set PositionZPrevious to Player.GetPos Z + 20

Set PositionX to Player.GetPos X

Set PositionY to Player.GetPos Y

EndIf

 

EndIf

 

;forward motion

If IsKeyPressed 17 AForwardKey ;forward key pressed

If AngleX < 0

Set Velocity to 1 + AngleX * 0.01111111

Else

If AngleX <= 45

Set Velocity to 1 + AngleX * 0.0222222

Else

Set Velocity to 2 - ((AngleX - 44) * 0.0444444)

EndIf

EndIf

 

Set Velocity to Velocity * AChangeVelocity

Set VelocityX to Sin AngleZ * Velocity

Set VelocityY to Cos AngleZ * Velocity

Set VelocityZ to Timer * -20 * AngleX

EndIf

 

;up motion

If IsKeyPressed 36 AJumpKey ;up key pressed

Set VelocityZ to VelocityZ + 20

EndIf

 

;change velocity

If IsKeyPressed35 AFasterKey != VelocityChangeKey

Set VelocityChangeKey to VelocityChangeKey == 0

If Velocity ;press key to change velocity

If AChangeVelocity == 1 ;going slowly and accelerate

Set AChangeVelocity to 2

Player.CastImmediateOnSelf APlayFlightFastIdleEffect

Else ;going fast and slow down

Set AChangeVelocity to 1

Player.CastImmediateOnSelf APlayFlightIdleEffect

EndIf

EndIf

EndIf

 

;detects that you have landed and enters the main script to finish the command

If VelocityZ < 0 && PositionZPrevious < PositionZ

Set VelocityZ to 0

Set AFlightQuest.Collision to 1

EndIf

Set PositionZNew to PositionZPrevious + VelocityZ

 

;detects that you hit the ceiling and enters the main script to finish the command

If VelocityZ >= 0 && PositionZNew < PositionZ

Set PositionZNew to PositionZ

Set AFlightQuest.Collision to 1

EndIf

 

 

;you move to the new position

Set VelocityX to VelocityX * Timer * 500

Set VelocityY to VelocityY * Timer * 500

 

Set PositionX to PositionX + VelocityX

Set PositionY to PositionY + VelocityY

 

Player.SetPos X PositionX

Player.SetPos Y PositionY

Player.SetPos Z PositionZNew

Set PositionZPrevious to PositionZNew

 

ResetFallDamageTimer

End

 

Begin ScriptEffectFinish

End

 

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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