Advertisement
Himeki

Example Script

Dec 7th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.30 KB | None | 0 0
  1. Scriptname HimexxTeleportSpellActivator extends ObjectReference
  2.  
  3. Import GlobalVariable
  4. ;-- Properties --------------------------------------
  5. Float Property fWaitDelay = 0.0 Auto
  6. {Pause between Animation/sound start and movement. Default: 0.0}
  7. Float Property fMoveSpeed = 768.0 Auto
  8. {Modifier on translation speed. Default: 768.0}
  9.  
  10. Float Property fRecastDelay = 0.0 Auto
  11. {Delay before the spell can be recast. Default: 0.0}
  12. Float Property fMagickaCost = 40.0 Auto
  13. {Magicka Cost. Default: 40.0}
  14.  
  15. Float Property fSkillAdvanceMult = 1.2 Auto
  16. {Multiplied by Magicka Cost for skill advancement. Default: 1.2}
  17. String Property sAssociatedSkill = "Alteration" Auto
  18. {Skill advanced when cast. Default: "Alteration"}
  19.  
  20. Float property fAlphaValue = 0.2 auto
  21. {Alpha Value to fade to. 0.0 will not work with fade, use 0.1. Default: 0.2}
  22. Bool property bFadeToAlpha = True auto
  23. {Fade alpha to value over time? Default: True}
  24.  
  25. Float Property fIModDelay = 0.05 auto
  26. {Time to wait before switching to constant IMod. Default: 0.05}
  27. Float Property fImodStrength = 1.0 auto
  28. {IsMod Strength from 0.0 to 1.0. Default: 1.0}
  29.  
  30. ImageSpaceModifier Property IModIntroFX auto
  31. {IMod applied at the start of the spell effect}
  32. ImageSpaceModifier Property IModStaticFX auto
  33. {Main IMod for spell}
  34. ImageSpaceModifier Property IModOutroFX auto
  35. {IMod applied at the end of the spell effect}
  36.  
  37. Spell Property NoDetectSpell Auto
  38. {Spell to make the player undetected during movement}
  39.  
  40. Perk Property perkNoFallDamage Auto
  41. {Perk to negate fall damage}
  42.  
  43. Sound Property TeleportSound Auto
  44. {Sound to use before movement}
  45. Sound Property NotEnoughMagickaSound Auto
  46. {Sound for Insufficient Magicka Reserves}
  47.  
  48. VisualEffect Property TeleportOutEffect Auto
  49. {Teleport Start Animation}
  50. VisualEffect Property TeleportInEffect Auto
  51. {Teleport End Animation}
  52.  
  53. Message Property mTimeLeft Auto
  54. {Message box for time remaining before recast}
  55.  
  56. GlobalVariable Property gTeleportRecast Auto
  57. {Variable storing recast state}
  58. GlobalVariable Property gTimeLeft Auto
  59. {Variable storing time remaining before recast}
  60. GlobalVariable Property gUseDebug Auto
  61. {Variable to toggle Debug messages on or off}
  62. ;-- Variables ---------------------------------------
  63. Int intSoundInstanceTeleport
  64. Int intSoundInstanceMagicka
  65. Int intEmergencyBreak
  66. Int intUseDebug
  67. Bool bPlayerArrived
  68. Float fTimeLeft
  69. Actor PlayerRef
  70. ;-- Functions ---------------------------------------
  71. Function TeleportSpellReset()
  72. PlayerRef.DispelSpell(NoDetectSpell)
  73. Playerref.SetGhost(False)
  74. PlayerRef.StopTranslation()
  75. bPlayerArrived = True
  76. IModIntroFX.Remove()
  77. IModStaticFX.Remove() ;Kill Imods from erroneous cast, if running.
  78. IModOutroFX.Remove()
  79. gTeleportRecast.SetValue(0)
  80. gTimeLeft.SetValue(0)
  81. PlayerRef.RemovePerk(perkNoFallDamage)
  82. TeleportOutEffect.Stop(PlayerRef)
  83. TeleportInEffect.Stop(PlayerRef)
  84. If intUseDebug == 1
  85. debug.notification("Teleport spell error. Failsafe engaged, Spell Reset.")
  86. EndIf
  87. EndFunction
  88.  
  89. Function AtEndMovement()
  90. If intUseDebug == 1
  91. debug.notification("Teleport Spell EndMove.")
  92. EndIf
  93. bPlayerArrived = True
  94. Utility.Wait(0.3)
  95. TeleportOutEffect.Stop(PlayerRef)
  96. TeleportInEffect.Play(PlayerRef,1)
  97. Utility.Wait(0.2)
  98. If fAlphaValue != 1.0
  99. PlayerRef.SetAlpha(1.0, bFadeToAlpha)
  100. EndIf
  101. If IModOutroFX != None
  102. IModOutroFX.apply(fImodStrength)
  103. Utility.wait(fIModDelay)
  104. EndIf
  105. If IModStaticFX != None
  106. IModStaticFX.Remove()
  107. EndIf
  108. PlayerRef.SetGhost(False)
  109. PlayerRef.DispelSpell(NoDetectSpell)
  110. EndFunction
  111.  
  112. ;-- Code Start --------------------------------------
  113. Event OnInit()
  114. PlayerRef = Game.GetPlayer()
  115. intUseDebug = gUseDebug.GetValueInt()
  116. PlayerRef.DispelSpell(NoDetectSpell)
  117.  
  118. If (gTeleportRecast.GetValue() == 0) && (PlayerRef.GetActorValue("Magicka") >= fMagickaCost)
  119. PlayerRef.DamageActorValue("Magicka",fMagickaCost)
  120. Game.AdvanceSkill(sAssociatedSkill, (fMagickaCost * fSkillAdvanceMult))
  121. gTeleportRecast.SetValue(1)
  122.  
  123. If fWaitDelay != 0.0
  124. Utility.Wait(fWaitDelay)
  125. EndIf
  126.  
  127. PlayerRef.AddPerk(perkNoFallDamage) ;Remove fall damage so the player doesn't die
  128.  
  129. TeleportOutEffect.play(PlayerRef)
  130. If fAlphaValue != 1.0
  131. Utility.Wait(0.08)
  132. PlayerRef.SetAlpha(fAlphaValue, bFadeToAlpha)
  133. EndIf
  134.  
  135. PlayerRef.SetGhost()
  136. NoDetectSpell.Cast(self,PlayerRef)
  137.  
  138. IModIntroFX.Remove()
  139. IModStaticFX.Remove() ;Kill Imods from another cast, if running.
  140. IModOutroFX.Remove()
  141. If IModIntroFX != None
  142. IModIntroFX.apply(fImodStrength)
  143. Utility.wait(fIModDelay)
  144. EndIf
  145.  
  146. If IModStaticFX != None
  147. IModStaticFX.apply(fImodStrength)
  148. EndIf
  149.  
  150. If TeleportSound != None
  151. intSoundInstanceTeleport = TeleportSound.Play(PlayerRef)
  152. Sound.SetInstanceVolume(intSoundInstanceTeleport, 1.0)
  153. EndIf
  154.  
  155. Self.GetDistance(PlayerRef)
  156. PlayerRef.TranslateToRef(Self,(Self.GetDistance(PlayerRef) + fMoveSpeed))
  157.  
  158. Utility.Wait(0.05)
  159. PlayerRef.ClearExtraArrows()
  160.  
  161. bPlayerArrived = False
  162. intEmergencyBreak = 0
  163. While bPlayerArrived == False
  164. If (Self.GetDistance(PlayerRef) <= 256) || (intEmergencyBreak >= 15)
  165. AtEndMovement()
  166. If (intUseDebug == 1) && (intEmergencyBreak >= 15)
  167. debug.notification("Error: Skipping End Teleport Animation")
  168. ElseIf intUseDebug == 1
  169. debug.notification("2nd Teleport Animation Start. Break: " + intEmergencyBreak)
  170. EndIf
  171. Else
  172. intEmergencyBreak += 1
  173. EndIf
  174. Utility.Wait(0.1)
  175. EndWhile
  176.  
  177. If intEmergencyBreak < 5
  178. Utility.Wait(0.5)
  179. EndIf
  180. PlayerRef.RemovePerk(perkNoFallDamage)
  181. If intUseDebug == 1
  182. debug.notification("Fall Damage Returned." )
  183. EndIf
  184. ;Float PlayerZ = PlayerRef.GetAngleZ() ;Previous method, causes fadeout often. Left for reference.
  185. ;PlayerRef.MoveTo(self)
  186. ;PlayerRef.SetAngle(PlayerRef.GetAngleZ(),GetAngleY(),PlayerZ)
  187.  
  188. gTeleportRecast.SetValue(2)
  189. gTimeLeft.SetValue(fRecastDelay)
  190. While gTimeLeft.GetValue() >= 0.1
  191. Utility.Wait(0.1)
  192. fTimeLeft = gTimeLeft.GetValue()
  193. gTimeLeft.SetValue((fTimeLeft - 0.1))
  194. EndWhile
  195. gTeleportRecast.SetValue(0)
  196.  
  197. ElseIf gTeleportRecast.GetValue() == 2
  198. mTimeLeft.Show((gTimeLeft.GetValue()))
  199.  
  200. ElseIf (gTeleportRecast.GetValue() == 0) && (PlayerRef.GetActorValue("Magicka") < fMagickaCost)
  201. intSoundInstanceMagicka = NotEnoughMagickaSound.Play(PlayerRef)
  202. Sound.SetInstanceVolume(intSoundInstanceMagicka, 1.0)
  203. ElseIf gTeleportRecast.GetValue() == 1
  204. If intUseDebug == 1
  205. debug.notification("Last Teleport Still Running." )
  206. EndIf
  207. Else
  208. TeleportSpellReset()
  209. EndIf
  210.  
  211. Utility.Wait(5)
  212. Self.Delete()
  213. EndEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement