Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.43 KB | None | 0 0
  1. Scriptname InnerPowerAnimationScript extends activemagiceffect
  2.  
  3. event OnEffectStart(Actor akTarget, Actor akCaster)
  4. Debug.trace("player effect starting")
  5. tryToLoadDlcForms()
  6.  
  7. isCancelled = false
  8. wasFirstPerson = false
  9. if(akTarget == Game.getPlayer() && checkDlcLocations() && checkMiraak())
  10. makePlayerPlayTheAnim(akTarget)
  11. else
  12. self.dispel()
  13. endif
  14. endevent
  15.  
  16. function makePlayerPlayTheAnim(Actor player)
  17. Utility.wait(preAnimationWait)
  18. recheckMiraakAndMaybeCancel()
  19. if(isCancelled)
  20. return
  21. endif
  22.  
  23. Debug.trace("will play the anim")
  24. ; Disable movement and combat
  25. Game.DisablePlayerControls()
  26. wasFirstPerson = player.GetAnimationVariableBool("IsFirstPerson")
  27. Game.ForceThirdPerson()
  28.  
  29. if(player.isWeaponDrawn())
  30. player.playIdle(DefaultSheathe)
  31. Utility.wait(weaponSheatheTime)
  32. endif
  33. if(isCancelled)
  34. return
  35. endif
  36.  
  37. Debug.trace("player dismount effect starting")
  38. if(akTarget.isOnMount())
  39. if(akTarget.dismount())
  40. Utility.wait(4.0) ; wait for them to dismount
  41. else ; dismounting failed
  42. self.dispel()
  43. return
  44. endif
  45. endif
  46.  
  47. player.playIdle(RitualSpellStart)
  48. Utility.wait(spellHoldingTime)
  49. recheckMiraakAndMaybeCancel()
  50. if(isCancelled)
  51. return
  52. endif
  53. player.playIdle(RitualSpellRelease)
  54. Utility.wait(spellReleaseTime)
  55.  
  56. ; spell
  57. if(SpellToAdd)
  58. SpellToAdd.cast(player)
  59. endif
  60.  
  61. Utility.wait(afterEffectTime)
  62.  
  63. ; Enable all controls
  64. Game.EnablePlayerControls()
  65. if(wasFirstPerson)
  66. Game.ForceFirstPerson()
  67. endif
  68. self.dispel()
  69. endfunction
  70.  
  71. Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
  72. ; if akAggressor is the player itself, don't do anything
  73.  
  74. ; Debug.trace("PLAYER WAS HIT, "+akAggressor)
  75. Actor player = Game.getPlayer()
  76.  
  77. if(player != akAggressor)
  78. cancelAnimation()
  79. endif
  80. EndEvent
  81.  
  82. function cancelAnimation()
  83. isCancelled = true
  84. Game.GetPlayer().playIdle(RitualSpellCancel)
  85. Game.EnablePlayerControls()
  86. if(wasFirstPerson)
  87. Game.ForceFirstPerson()
  88. endif
  89. self.dispel()
  90. endfunction
  91.  
  92. function recheckMiraakAndMaybeCancel()
  93. if(!checkMiraak())
  94. cancelAnimation()
  95. endif
  96. endfunction
  97.  
  98. function tryToLoadDlcForms()
  99. DLC2ApocryphaLocation = Game.GetFormFromFile(0x03016E2B, "Dragonborn.esm") As Location
  100. DLC2ApocryphaWorld = Game.GetFormFromFile(0x0301C0B2, "Dragonborn.esm") As Worldspace
  101. DLC2SoulSteal = Game.GetFormFromFile(0x030200D8, "Dragonborn.esm") As DLC2SoulStealScript
  102.  
  103. DLC2MQ02 = Game.GetFormFromFile(0x03017F8F, "Dragonborn.esm") As Quest
  104. DLC2MQ06 = Game.GetFormFromFile(0x030179D7, "Dragonborn.esm") As Quest
  105. DLC2BendToWillWord1 = Game.GetFormFromFile(0x030179D9, "Dragonborn.esm") As WordOfPower
  106.  
  107. Debug.trace("Loaded dragonborn forms: "+DLC2ApocryphaLocation+" "+DLC2ApocryphaWorld+" "+DLC2SoulSteal)
  108. Debug.trace("Loaded dragonborn forms: "+DLC2MQ02+" "+DLC2MQ06+" "+DLC2BendToWillWord1)
  109. endfunction
  110.  
  111. bool function checkDlcLocations()
  112. if(DLC2ApocryphaLocation == none || DLC2ApocryphaWorld == none)
  113. Debug.trace("DLC2 not loaded, return true")
  114. return true
  115. endif
  116.  
  117. if(game.getPlayer().isInLocation(DLC2ApocryphaLocation))
  118. Debug.trace("Player is in apocrypha")
  119. return false
  120. endif
  121.  
  122. if(game.getPlayer().getWorldSpace() == DLC2ApocryphaWorld)
  123. Debug.trace("Player is in apocrypha worldspace")
  124. return false
  125. endif
  126.  
  127. return true
  128. endfunction
  129.  
  130. bool function checkMiraak()
  131. if(DLC2SoulSteal == none)
  132. Debug.trace("checkMiraak: DLC2 not loaded, return true")
  133. return true
  134. endif
  135.  
  136. ; now the complicated part
  137.  
  138. ; TestMiraak seems to override everything
  139. if(DLC2SoulSteal.TestMiraak)
  140. Debug.trace("checkMiraak: testMiraak => false")
  141. return false
  142. endif
  143.  
  144.  
  145. ; miraak is impossible if either:
  146. ; - DLC2MQ02.GetStage() < 200
  147. ; - DLC2MQ06.GetStage() >= 500
  148. ; - DLC2BendToWillWord1 IS NOT unlocked AND player has 0 souls
  149. if (DLC2MQ02.GetStage() < 200 || DLC2MQ06.GetStage() >= 500 || (!Game.IsWordUnlocked(DLC2BendToWillWord1) && Game.GetPlayer().GetActorValue("DragonSouls") <= 0))
  150. Debug.trace("checkMiraak: impossible due to quests, word or souls => true")
  151. return true
  152. endif
  153.  
  154. Actor MiraakRef = DLC2SoulSteal.Miraak.GetReference() as Actor
  155. ; I can't access the "appeared" bool in there...
  156. ; if he's enabled, he's PROBABLY stealing a soul right now. I see no other way of checking this...
  157. Debug.trace("checkMiraak: is Miraak disabled? => "+MiraakRef.IsDisabled())
  158. return (MiraakRef.IsDisabled())
  159.  
  160.  
  161. endfunction
  162.  
  163. SPELL Property SpellToAdd Auto
  164. {This spell, if any, will be cast onto the player when the animation ends, after spellReleaseTime has passed}
  165.  
  166. Idle property RitualSpellStart auto
  167. {Idle to use for Start+Hold idle}
  168. Idle property RitualSpellCancel auto
  169. {Idle for when the animation is cancelled}
  170. Idle property RitualSpellRelease auto
  171. {Animation "releasing" the spell}
  172. Idle property DefaultSheathe auto
  173. {The Sheathe Weapon animation}
  174.  
  175. float property preAnimationWait = 5.0 auto
  176. {Time to wait before starting the animation}
  177. float property weaponSheatheTime = 2.0 auto
  178. {If the weapon is drawn, it must be sheathed. This should be about the length of that animation}
  179. float property spellHoldingTime = 10.0 auto
  180. {How long to hold the spell. Or rather, it should be the time of RitualSpellStart, plus some extra}
  181. float property spellReleaseTime = 2.0 auto
  182. {How long the "release" animation takes}
  183. float property afterEffectTime = 2.0 auto
  184. {How long to wait after the effect finishes. Important if the player started the effect while in first person}
  185.  
  186. bool property isCancelled = false auto hidden
  187. bool property wasFirstPerson = false auto hidden
  188.  
  189.  
  190. ; DLC2 STUFF
  191. DLC2SoulStealScript Property DLC2SoulSteal Auto hidden
  192. Location Property DLC2ApocryphaLocation Auto hidden
  193. Worldspace Property DLC2ApocryphaWorld Auto hidden
  194. Quest Property DLC2MQ02 auto hidden
  195. Quest Property DLC2MQ06 auto hidden
  196. WordOfPower Property DLC2BendToWillWord1 auto hidden
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement