Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scriptname SapMagickaEffect extends ActiveMagicEffect
- int ACTOR_ACTION_DRAW_START = 7
- int ACTOR_ACTION_SHEATH_END = 10
- float playerBaseMagicka
- int updateCount = 0
- Actor akWhoHasEquipped
- Event OnInit()
- akWhoHasEquipped = GetTargetActor()
- RegisterForActorAction(ACTOR_ACTION_DRAW_START)
- RegisterForActorAction(ACTOR_ACTION_SHEATH_END)
- EndEvent
- Event OnActorAction(int actionType, actor akActor, Form source, int slot)
- If akActor == akWhoHasEquipped
- If actionType == ACTOR_ACTION_DRAW_START
- if akActor == Game.GetPlayer()
- playerBaseMagicka = Game.GetPlayer().GetBaseActorValue("Magicka")
- RegisterForSingleUpdate(2.0)
- ElseIf actionType == ACTOR_ACTION_SHEATH_END
- UnregisterForUpdate()
- EndIf
- EndIf
- Endif
- EndEvent
- Event OnUpdate()
- // Calculate the amount of magicka to drain from the player
- float drainAmount = playerBaseMagicka * 0.01 * (1 - Game.GetPlayer().GetActorValue("Conjuration") / 100)
- // Drain the player's magicka by the calculated amount
- Game.GetPlayer().DamageActorValue("Magicka", drainAmount)
- if (updateCount < 30)
- // Check if the player's magicka is below 0
- if (Game.GetPlayer().GetActorValue("Magicka") <= 0)
- // If so, unregister from updates
- UnregisterForUpdate()
- else
- // Otherwise, register for another update and increment the update count
- RegisterForSingleUpdate(2.0)
- updateCount += 1
- EndIf
- else
- // If the update count has reached 30, unregister from updates
- UnregisterForUpdate()
- EndIf
- EndEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement