Hey guys,
for 2 months I tryed to change the player model into a dragon, everything works fine I can walk as a dragon, bite or attack someone with a fireball.
My problem know is, if I want to let him fly it doesn't will work, skyrim crashes.
I hope somebody can help me with my script.
It's a MagicEffect:
Scriptname DragonMoveMScript extends activemagiceffect
Quest property DragonQST Auto
Bool bIsHotkeyPressed
Int Property iHotkey = 57 Auto
Armor property DragonRing auto
Actor property Player auto
import utility
import form
import game
import debug
import ObjectReference
import Math
perk property NoFallDmg auto
Action property JumpS auto
race DefaultRace
race[] property FlyableRace auto
race[] property NormalRace auto
GlobalVariable property DirF auto
GlobalVariable property DirB Auto
GlobalVariable property DirR auto
GlobalVariable property DirL Auto
idle property idleplayer auto
float bearing
float elevation
float speed
float posx
float posy
float posz
int i
int n
Idle property DragonDefaultIdle auto
Spell property HazardDragonFire auto
Spell property DragonHide auto
Spell property dunCGVoiceDragonFire1 auto
Perk property DragonTakeOffPerk auto
Perk property DragonStopFlyPerk auto
Idle property DragonFlyingIdle auto
Idle property DragonStopFlyingIdle auto
float Dflying = 0.0
Race Property DragonRace Auto
Message Property DragonUsageDisplay Auto
Event OnEffectStart(Actor Player, Actor Caster)
Debug.SendAnimationEvent(Player, "summonedstart")
bTakeOffAllowed = True
bLandingAllowed = False
Game.ForceThirdPerson()
Player = GetPlayer()
Player.AddPerk(NoFallDmg)
Utility.SetINIFloat("fVATSSmartCameraCheckHeight", 200) ;48
Utility.SetINIFloat("fVATSSmartCameraCheckStepDistance", 210) ;64
Game.ForceThirdPerson()
Player.AddSpell(DragonHide)
Player.AddSpell(dunCGVoiceDragonFire1)
SetIniFloat("fInAirFallingCharGravityMult:Havok",0)
DefaultRace = Player.GetRace()
CheckRace()
if Player.IsEquipped(DragonRing)
while Player.IsEquipped(DragonRing)
RegisterForAnimationEvent(Player, "takeoff")
RegisterForAnimationEvent(Player, "FlyStopInjuredSafe")
OnUpdate()
endWhile
endIf
endEvent
function CheckRace()
While i < 20
if DefaultRace == NormalRace[i]
Player.SetRace(FlyableRace[i])
Player.SetRace(DragonRace)
endif
i += 1
endWhile
i = 0
endFunction
function Fly()
posx = Player.GetPositionX()
posy = Player.GetPositionY()
bearing = Player.GetAngleZ()
elevation = Player.GetAngleX()
posz = Player.GetPositionZ()
if Player.IsRunning() && DirF.GetValueInt() == 1
speed = 2200
posx += sin(bearing)*speed
posy += cos(bearing)*speed
posz -= sin(elevation)*speed
Player.TranslateTo(posx,posy,posz,bearing,0,elevation,speed,1)
else
speed = 1000
endIf
if DirF.GetValueInt() == 1 && DirB.GetValueInt() == 0 && DirL.GetValueInt() == 0 && DirR.GetValueInt() == 0
If Player.IsSneaking()
speed = 200
else
speed = 500
endif
posx += sin(bearing)*speed
posy += cos(bearing)*speed
posz -= sin(elevation)*speed
Player.TranslateTo(posx,posy,posz,bearing,0,elevation,speed,1)
endif
if DirF.GetValueInt() == 0 && DirB.GetValueInt() == 1 && DirL.GetValueInt() == 0 && DirR.GetValueInt() == 0
If Player.IsSneaking()
speed = 200
else
speed = 500
endif
posx -= sin(bearing)*speed
posy -= cos(bearing)*speed
posz += sin(elevation)*speed
Player.TranslateTo(posx,posy,posz,bearing,0,elevation,speed,1)
endif
if DirF.GetValueInt() == 0 && DirB.GetValueInt() == 0 && DirL.GetValueInt() == 1 && DirR.GetValueInt() == 0
If Player.IsSneaking()
speed = 200
else
speed = 500
endif
posx += sin(bearing - 90)*speed
posy += cos(bearing - 90)*speed
posz -= sin(elevation)*speed
Player.TranslateTo(posx,posy,posz,bearing,0,elevation,speed,1)
endif
if DirF.GetValueInt() == 0 && DirB.GetValueInt() == 0 && DirL.GetValueInt() == 0 && DirR.GetValueInt() == 1
If Player.IsSneaking()
speed = 200
else
speed = 500
endif
posx += sin(bearing + 90)*speed
posy += cos(bearing + 90)*speed
posz -= sin(elevation)*speed
Player.TranslateTo(posx,posy,posz,bearing,0,elevation,speed,1)
endif
if DirF.GetValueInt() == 0 && DirB.GetValueInt() == 0 && DirL.GetValueInt() == 0 && DirR.GetValueInt() == 0 && !Player.IsSprinting()
Player.StopTranslation()
Speed = 0
endIf
endFunction
bool bTakeOffAllowed
bool bLandingAllowed
Event OnUpdate()
If bIsHotkeyPressed != Input.IsKeyPressed(iHotkey)
bIsHotkeyPressed = !bIsHotkeyPressed
If bIsHotkeyPressed
if Dflying == 0.0 && bTakeOffAllowed == true
Player.AddPerk(DragonTakeOffPerk)
;Debug.Notification("Perk added")
Player.RemovePerk(DragonStopFlyPerk)
Dflying = 1.0
bLandingAllowed = true
bTakeOffAllowed = false
Endif
if Player.HasPerk(DragonTakeOffPerk) && (Dflying == 1.0) && (bTakeOffAllowed == false)
Debug.SendAnimationEvent(Player, "takeoff")
Fly()
Dflying = 2.0
Endif
bLandingAllowed = true
Endif
Endif
If bIsHotkeyPressed == Input.IsKeyPressed(iHotkey)
bIsHotkeyPressed = !bIsHotkeyPressed
If bIsHotkeyPressed
bTakeOffAllowed = false
if Dflying == 2.0 && bLandingAllowed == true
SetIniFloat("fInAirFallingCharGravityMult:Havok",1.35)
Player.StopTranslation()
Player.AddPerk(DragonStopFlyPerk)
Player.RemovePerk(DragonTakeOffPerk)
Debug.SendAnimationEvent(Player, "FlyStopInjuredSafe")
Endif
Dflying = 0.0
bTakeOffAllowed = true
EndIf
Endif
EndEvent
Event OnEffectFinish(Actor Player, Actor Caster)
UnregisterForUpdate()
UnregisterForAnimationEvent(Player, "takeoff")
UnregisterForAnimationEvent(Player, "FlyStopInjuredSafe")
Player.StopTranslation()
SetIniFloat("fInAirFallingCharGravityMult:Havok",1.35)
Player.SetRace(DefaultRace)
RemoveFallPerk()
Utility.SetINIFloat("fVATSSmartCameraCheckHeight", 48)
Utility.SetINIFloat("fVATSSmartCameraCheckStepDistance", 64)
endEvent
Event OnAnimationEvent(ObjectReference akSource, string asEventName)
if asEventName == "takeoff"
bLandingAllowed = True
bTakeOffAllowed = False
elseif asEventName == "FlyStopInjuredSafe"
bTakeOffAllowed = True
bLandingAllowed = False
endif
EndEvent
Function RemoveFallPerk()
Wait(5)
Player.RemovePerk(NoFallDmg)
endFunction