Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scriptname HimexxTeleportSpellActivator extends ObjectReference
- Import GlobalVariable
- ;-- Properties --------------------------------------
- Float Property fWaitDelay = 0.0 Auto
- {Pause between Animation/sound start and movement. Default: 0.0}
- Float Property fMoveSpeed = 768.0 Auto
- {Modifier on translation speed. Default: 768.0}
- Float Property fRecastDelay = 0.0 Auto
- {Delay before the spell can be recast. Default: 0.0}
- Float Property fMagickaCost = 40.0 Auto
- {Magicka Cost. Default: 40.0}
- Float Property fSkillAdvanceMult = 1.2 Auto
- {Multiplied by Magicka Cost for skill advancement. Default: 1.2}
- String Property sAssociatedSkill = "Alteration" Auto
- {Skill advanced when cast. Default: "Alteration"}
- Float property fAlphaValue = 0.2 auto
- {Alpha Value to fade to. 0.0 will not work with fade, use 0.1. Default: 0.2}
- Bool property bFadeToAlpha = True auto
- {Fade alpha to value over time? Default: True}
- Float Property fIModDelay = 0.05 auto
- {Time to wait before switching to constant IMod. Default: 0.05}
- Float Property fImodStrength = 1.0 auto
- {IsMod Strength from 0.0 to 1.0. Default: 1.0}
- ImageSpaceModifier Property IModIntroFX auto
- {IMod applied at the start of the spell effect}
- ImageSpaceModifier Property IModStaticFX auto
- {Main IMod for spell}
- ImageSpaceModifier Property IModOutroFX auto
- {IMod applied at the end of the spell effect}
- Spell Property NoDetectSpell Auto
- {Spell to make the player undetected during movement}
- Perk Property perkNoFallDamage Auto
- {Perk to negate fall damage}
- Sound Property TeleportSound Auto
- {Sound to use before movement}
- Sound Property NotEnoughMagickaSound Auto
- {Sound for Insufficient Magicka Reserves}
- VisualEffect Property TeleportOutEffect Auto
- {Teleport Start Animation}
- VisualEffect Property TeleportInEffect Auto
- {Teleport End Animation}
- Message Property mTimeLeft Auto
- {Message box for time remaining before recast}
- GlobalVariable Property gTeleportRecast Auto
- {Variable storing recast state}
- GlobalVariable Property gTimeLeft Auto
- {Variable storing time remaining before recast}
- GlobalVariable Property gUseDebug Auto
- {Variable to toggle Debug messages on or off}
- ;-- Variables ---------------------------------------
- Int intSoundInstanceTeleport
- Int intSoundInstanceMagicka
- Int intEmergencyBreak
- Int intUseDebug
- Bool bPlayerArrived
- Float fTimeLeft
- Actor PlayerRef
- ;-- Functions ---------------------------------------
- Function TeleportSpellReset()
- PlayerRef.DispelSpell(NoDetectSpell)
- Playerref.SetGhost(False)
- PlayerRef.StopTranslation()
- bPlayerArrived = True
- IModIntroFX.Remove()
- IModStaticFX.Remove() ;Kill Imods from erroneous cast, if running.
- IModOutroFX.Remove()
- gTeleportRecast.SetValue(0)
- gTimeLeft.SetValue(0)
- PlayerRef.RemovePerk(perkNoFallDamage)
- TeleportOutEffect.Stop(PlayerRef)
- TeleportInEffect.Stop(PlayerRef)
- If intUseDebug == 1
- debug.notification("Teleport spell error. Failsafe engaged, Spell Reset.")
- EndIf
- EndFunction
- Function AtEndMovement()
- If intUseDebug == 1
- debug.notification("Teleport Spell EndMove.")
- EndIf
- bPlayerArrived = True
- Utility.Wait(0.3)
- TeleportOutEffect.Stop(PlayerRef)
- TeleportInEffect.Play(PlayerRef,1)
- Utility.Wait(0.2)
- If fAlphaValue != 1.0
- PlayerRef.SetAlpha(1.0, bFadeToAlpha)
- EndIf
- If IModOutroFX != None
- IModOutroFX.apply(fImodStrength)
- Utility.wait(fIModDelay)
- EndIf
- If IModStaticFX != None
- IModStaticFX.Remove()
- EndIf
- PlayerRef.SetGhost(False)
- PlayerRef.DispelSpell(NoDetectSpell)
- EndFunction
- ;-- Code Start --------------------------------------
- Event OnInit()
- PlayerRef = Game.GetPlayer()
- intUseDebug = gUseDebug.GetValueInt()
- PlayerRef.DispelSpell(NoDetectSpell)
- If (gTeleportRecast.GetValue() == 0) && (PlayerRef.GetActorValue("Magicka") >= fMagickaCost)
- PlayerRef.DamageActorValue("Magicka",fMagickaCost)
- Game.AdvanceSkill(sAssociatedSkill, (fMagickaCost * fSkillAdvanceMult))
- gTeleportRecast.SetValue(1)
- If fWaitDelay != 0.0
- Utility.Wait(fWaitDelay)
- EndIf
- PlayerRef.AddPerk(perkNoFallDamage) ;Remove fall damage so the player doesn't die
- TeleportOutEffect.play(PlayerRef)
- If fAlphaValue != 1.0
- Utility.Wait(0.08)
- PlayerRef.SetAlpha(fAlphaValue, bFadeToAlpha)
- EndIf
- PlayerRef.SetGhost()
- NoDetectSpell.Cast(self,PlayerRef)
- IModIntroFX.Remove()
- IModStaticFX.Remove() ;Kill Imods from another cast, if running.
- IModOutroFX.Remove()
- If IModIntroFX != None
- IModIntroFX.apply(fImodStrength)
- Utility.wait(fIModDelay)
- EndIf
- If IModStaticFX != None
- IModStaticFX.apply(fImodStrength)
- EndIf
- If TeleportSound != None
- intSoundInstanceTeleport = TeleportSound.Play(PlayerRef)
- Sound.SetInstanceVolume(intSoundInstanceTeleport, 1.0)
- EndIf
- Self.GetDistance(PlayerRef)
- PlayerRef.TranslateToRef(Self,(Self.GetDistance(PlayerRef) + fMoveSpeed))
- Utility.Wait(0.05)
- PlayerRef.ClearExtraArrows()
- bPlayerArrived = False
- intEmergencyBreak = 0
- While bPlayerArrived == False
- If (Self.GetDistance(PlayerRef) <= 256) || (intEmergencyBreak >= 15)
- AtEndMovement()
- If (intUseDebug == 1) && (intEmergencyBreak >= 15)
- debug.notification("Error: Skipping End Teleport Animation")
- ElseIf intUseDebug == 1
- debug.notification("2nd Teleport Animation Start. Break: " + intEmergencyBreak)
- EndIf
- Else
- intEmergencyBreak += 1
- EndIf
- Utility.Wait(0.1)
- EndWhile
- If intEmergencyBreak < 5
- Utility.Wait(0.5)
- EndIf
- PlayerRef.RemovePerk(perkNoFallDamage)
- If intUseDebug == 1
- debug.notification("Fall Damage Returned." )
- EndIf
- ;Float PlayerZ = PlayerRef.GetAngleZ() ;Previous method, causes fadeout often. Left for reference.
- ;PlayerRef.MoveTo(self)
- ;PlayerRef.SetAngle(PlayerRef.GetAngleZ(),GetAngleY(),PlayerZ)
- gTeleportRecast.SetValue(2)
- gTimeLeft.SetValue(fRecastDelay)
- While gTimeLeft.GetValue() >= 0.1
- Utility.Wait(0.1)
- fTimeLeft = gTimeLeft.GetValue()
- gTimeLeft.SetValue((fTimeLeft - 0.1))
- EndWhile
- gTeleportRecast.SetValue(0)
- ElseIf gTeleportRecast.GetValue() == 2
- mTimeLeft.Show((gTimeLeft.GetValue()))
- ElseIf (gTeleportRecast.GetValue() == 0) && (PlayerRef.GetActorValue("Magicka") < fMagickaCost)
- intSoundInstanceMagicka = NotEnoughMagickaSound.Play(PlayerRef)
- Sound.SetInstanceVolume(intSoundInstanceMagicka, 1.0)
- ElseIf gTeleportRecast.GetValue() == 1
- If intUseDebug == 1
- debug.notification("Last Teleport Still Running." )
- EndIf
- Else
- TeleportSpellReset()
- EndIf
- Utility.Wait(5)
- Self.Delete()
- EndEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement