Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scriptname InnerPowerAnimationScript extends activemagiceffect
- event OnEffectStart(Actor akTarget, Actor akCaster)
- Debug.trace("player effect starting")
- tryToLoadDlcForms()
- isCancelled = false
- wasFirstPerson = false
- if(akTarget == Game.getPlayer() && checkDlcLocations() && checkMiraak())
- makePlayerPlayTheAnim(akTarget)
- else
- self.dispel()
- endif
- endevent
- function makePlayerPlayTheAnim(Actor player)
- Utility.wait(preAnimationWait)
- recheckMiraakAndMaybeCancel()
- if(isCancelled)
- return
- endif
- Debug.trace("will play the anim")
- ; Disable movement and combat
- Game.DisablePlayerControls()
- wasFirstPerson = player.GetAnimationVariableBool("IsFirstPerson")
- Game.ForceThirdPerson()
- if(player.isWeaponDrawn())
- player.playIdle(DefaultSheathe)
- Utility.wait(weaponSheatheTime)
- endif
- if(isCancelled)
- return
- endif
- Debug.trace("player dismount effect starting")
- if(akTarget.isOnMount())
- if(akTarget.dismount())
- Utility.wait(4.0) ; wait for them to dismount
- else ; dismounting failed
- self.dispel()
- return
- endif
- endif
- player.playIdle(RitualSpellStart)
- Utility.wait(spellHoldingTime)
- recheckMiraakAndMaybeCancel()
- if(isCancelled)
- return
- endif
- player.playIdle(RitualSpellRelease)
- Utility.wait(spellReleaseTime)
- ; spell
- if(SpellToAdd)
- SpellToAdd.cast(player)
- endif
- Utility.wait(afterEffectTime)
- ; Enable all controls
- Game.EnablePlayerControls()
- if(wasFirstPerson)
- Game.ForceFirstPerson()
- endif
- self.dispel()
- endfunction
- Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
- ; if akAggressor is the player itself, don't do anything
- ; Debug.trace("PLAYER WAS HIT, "+akAggressor)
- Actor player = Game.getPlayer()
- if(player != akAggressor)
- cancelAnimation()
- endif
- EndEvent
- function cancelAnimation()
- isCancelled = true
- Game.GetPlayer().playIdle(RitualSpellCancel)
- Game.EnablePlayerControls()
- if(wasFirstPerson)
- Game.ForceFirstPerson()
- endif
- self.dispel()
- endfunction
- function recheckMiraakAndMaybeCancel()
- if(!checkMiraak())
- cancelAnimation()
- endif
- endfunction
- function tryToLoadDlcForms()
- DLC2ApocryphaLocation = Game.GetFormFromFile(0x03016E2B, "Dragonborn.esm") As Location
- DLC2ApocryphaWorld = Game.GetFormFromFile(0x0301C0B2, "Dragonborn.esm") As Worldspace
- DLC2SoulSteal = Game.GetFormFromFile(0x030200D8, "Dragonborn.esm") As DLC2SoulStealScript
- DLC2MQ02 = Game.GetFormFromFile(0x03017F8F, "Dragonborn.esm") As Quest
- DLC2MQ06 = Game.GetFormFromFile(0x030179D7, "Dragonborn.esm") As Quest
- DLC2BendToWillWord1 = Game.GetFormFromFile(0x030179D9, "Dragonborn.esm") As WordOfPower
- Debug.trace("Loaded dragonborn forms: "+DLC2ApocryphaLocation+" "+DLC2ApocryphaWorld+" "+DLC2SoulSteal)
- Debug.trace("Loaded dragonborn forms: "+DLC2MQ02+" "+DLC2MQ06+" "+DLC2BendToWillWord1)
- endfunction
- bool function checkDlcLocations()
- if(DLC2ApocryphaLocation == none || DLC2ApocryphaWorld == none)
- Debug.trace("DLC2 not loaded, return true")
- return true
- endif
- if(game.getPlayer().isInLocation(DLC2ApocryphaLocation))
- Debug.trace("Player is in apocrypha")
- return false
- endif
- if(game.getPlayer().getWorldSpace() == DLC2ApocryphaWorld)
- Debug.trace("Player is in apocrypha worldspace")
- return false
- endif
- return true
- endfunction
- bool function checkMiraak()
- if(DLC2SoulSteal == none)
- Debug.trace("checkMiraak: DLC2 not loaded, return true")
- return true
- endif
- ; now the complicated part
- ; TestMiraak seems to override everything
- if(DLC2SoulSteal.TestMiraak)
- Debug.trace("checkMiraak: testMiraak => false")
- return false
- endif
- ; miraak is impossible if either:
- ; - DLC2MQ02.GetStage() < 200
- ; - DLC2MQ06.GetStage() >= 500
- ; - DLC2BendToWillWord1 IS NOT unlocked AND player has 0 souls
- if (DLC2MQ02.GetStage() < 200 || DLC2MQ06.GetStage() >= 500 || (!Game.IsWordUnlocked(DLC2BendToWillWord1) && Game.GetPlayer().GetActorValue("DragonSouls") <= 0))
- Debug.trace("checkMiraak: impossible due to quests, word or souls => true")
- return true
- endif
- Actor MiraakRef = DLC2SoulSteal.Miraak.GetReference() as Actor
- ; I can't access the "appeared" bool in there...
- ; if he's enabled, he's PROBABLY stealing a soul right now. I see no other way of checking this...
- Debug.trace("checkMiraak: is Miraak disabled? => "+MiraakRef.IsDisabled())
- return (MiraakRef.IsDisabled())
- endfunction
- SPELL Property SpellToAdd Auto
- {This spell, if any, will be cast onto the player when the animation ends, after spellReleaseTime has passed}
- Idle property RitualSpellStart auto
- {Idle to use for Start+Hold idle}
- Idle property RitualSpellCancel auto
- {Idle for when the animation is cancelled}
- Idle property RitualSpellRelease auto
- {Animation "releasing" the spell}
- Idle property DefaultSheathe auto
- {The Sheathe Weapon animation}
- float property preAnimationWait = 5.0 auto
- {Time to wait before starting the animation}
- float property weaponSheatheTime = 2.0 auto
- {If the weapon is drawn, it must be sheathed. This should be about the length of that animation}
- float property spellHoldingTime = 10.0 auto
- {How long to hold the spell. Or rather, it should be the time of RitualSpellStart, plus some extra}
- float property spellReleaseTime = 2.0 auto
- {How long the "release" animation takes}
- float property afterEffectTime = 2.0 auto
- {How long to wait after the effect finishes. Important if the player started the effect while in first person}
- bool property isCancelled = false auto hidden
- bool property wasFirstPerson = false auto hidden
- ; DLC2 STUFF
- DLC2SoulStealScript Property DLC2SoulSteal Auto hidden
- Location Property DLC2ApocryphaLocation Auto hidden
- Worldspace Property DLC2ApocryphaWorld Auto hidden
- Quest Property DLC2MQ02 auto hidden
- Quest Property DLC2MQ06 auto hidden
- WordOfPower Property DLC2BendToWillWord1 auto hidden
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement