Difference between revisions of "Flying"

Jump to navigation Jump to search
661 bytes added ,  11:49, 24 December 2011
m
no edit summary
imported>8asrun6aer
m
imported>8asrun6aer
m
Line 43: Line 43:
;*******************************
;*******************************
float cstmXVelocity ; velocity towards x 0 point
float cstmXVelocity ; velocity towards x 0 point
float cstmYVelocity ; velocity towards z 0 point
float cstmYVelocity ; velocity towards y 0 point
float cstmZVelocity ; velocity towards y 0 point
float cstmZVelocity ; velocity towards z 0 point
float cstmZGravityModifyer ; counteracts effects of world gravity on Z
float cstmZGravityModifyer ; counteracts effects of world gravity on Z
float cstmPitch ; up/down angle player is facing
float cstmPitch ; up/down angle player is facing
float cstmZPitchModifyer ; modifies applied up/down speed based on the angle player is facing up or down
float cstmZPitchModifyer ; modifies applied up/down speed based on -100-100% of player's Z angle
float cstmHeading ; 0-360 degrees from North player is facing
float cstmHeading ; 0-360 degrees from North player is facing
float cstmSpeed ; updated rate of player movement in any given direction
float cstmSpeed ; updated rate of player movement in any given direction
Line 85: Line 85:


;*******************************
;*******************************
; Reset Key bindings on game load
; Reset Flight Key bindings on game load
;*******************************
;*******************************
if ( GetGameRestarted || GetGameLoaded )
if ( GetGameRestarted || GetGameLoaded )
Line 119: Line 119:
; Invalid states are if player is not in air, is swimming, etc
; Invalid states are if player is not in air, is swimming, etc
;*******************************
;*******************************
if ( Player.IsInAir != 1 || Player.IsSwimming )
if ( Player.IsInAir != 1 )
set cstmGlobalPlayerIsFlying to 0
set cstmGlobalPlayerIsFlying to 0
; flying stopped, skip rest of script update
; flying stopped, skip rest of script update
Line 138: Line 138:
</pre>
</pre>


Pausing here for a second.  This script damages the player's fatigue while flying to avoid encouraging the player to fly over every dangerous situation in the game.  If you're only testing a new map you've just made, you'll want to comment out or delete this section of the script as it'll only be an inconvenience.  Otherwise, think twice about letting the player fly around without a care in the world.
Pausing here for a second.  This script damages the player's fatigue while flying to avoid encouraging the player to fly over every dangerous situation in the game.  You may also add in damage to magika over time as well.  If you're only testing a new map you've just made, or if you're making this script part of a regular short-duration spell, you'll want to comment out or delete this section of the script as it'll only be an inconvenience.  Otherwise, think twice about letting the player fly around without a care in the world.


<pre>
<pre>
Line 233: Line 233:
; Set up/down velocity adjusting for gravity's influence and player's pitch
; Set up/down velocity adjusting for gravity's influence and player's pitch
set cstmZGravityModifyer to ( ( GetLocalGravity z ) / ( 21 + ( 1 / 3 ) ) ) * cstmSecondsPassed ; see GetLocalGravity elderscrolls.com article for this formula
set cstmZGravityModifyer to ( ( GetLocalGravity z ) / ( 21 + ( 1 / 3 ) ) ) * cstmSecondsPassed
set cstmZVelocity to ( cstmZPitchModifyer * cstmSpeed ) + cstmZGravityModifyer
set cstmZVelocity to ( cstmZPitchModifyer * cstmSpeed ) + cstmZGravityModifyer


Line 251: Line 251:
== Notes ==
== Notes ==
# This script requires that the player be in the air in order to activate flying.  In other words, the player must be jumping or falling before flying can be activated.  This catch is necessary to not produce the same wall/ceiling clipping that the customary [[SetPos]] method does, and for initially adjusting player velocities.
# This script requires that the player be in the air in order to activate flying.  In other words, the player must be jumping or falling before flying can be activated.  This catch is necessary to not produce the same wall/ceiling clipping that the customary [[SetPos]] method does, and for initially adjusting player velocities.
# At line ~194, the formula used to counteract local gravity can be found in the [[GetLocalGravity]] page.  This might not be exact as the player still loses elevation very slowly if hovering in place.
# Sometimes, activating flying only causes the player to rise 20 or so feet and then fall.  Click the ''activate'' key a few more times to really activate flying.  The exact location of this bug in this script is not yet known, but likely somewhere in the initial flight activation check area (line ~69).
# Sometimes, activating flying only causes the player to rise 20 or so feet and then fall.  Click the ''activate'' key a few more times to really activate flying.  The exact location of this bug in this script is not yet known, but likely somewhere in the initial flight activation check area (line ~69).
# A player can fly over castle walls in exterior world spaces.  Because they didn't enter the castle grounds through the front door, they'll be bewildered by how every building within the castle walls is nothing but a fake graphics placeholder.  Although as yet untested with this script, you may want to mention to your mod users any "Open Cities" mods that may be out there to correct this issue.
# A player can fly over castle walls in exterior world spaces.  Because they didn't enter the castle grounds through the front door, they'll be bewildered by how every building within the castle walls is nothing but a fake graphics placeholder.  Although as yet untested with this script, you may want to mention to your mod users any "Open Cities" mods that may be out there to correct this issue.
# Though modified heavily from the original code and using different procedural flow with new methods and solutions for flying controls and effects, the basic flight concepts of the above script were based on the flying script packaged with the "A Chingari and Ismelda Demon Race:Demon Race v3-0-3" mod found at the [[TESNexus]] site: http://www.tesnexus.com/downloads/file.php?id=14528 (''adult content warning'')


[[Category: Useful Code]]
[[Category: Useful Code]]
Anonymous user

Navigation menu