Advertisement
Guest User

SapMagickaEffect.psc

a guest
Dec 20th, 2022
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. Scriptname SapMagickaEffect extends ActiveMagicEffect
  2.  
  3. int ACTOR_ACTION_DRAW_START = 7
  4. int ACTOR_ACTION_SHEATH_END = 10
  5. float playerBaseMagicka
  6. int updateCount = 0
  7. Actor akWhoHasEquipped
  8.  
  9. Event OnInit()
  10. akWhoHasEquipped = GetTargetActor()
  11. RegisterForActorAction(ACTOR_ACTION_DRAW_START)
  12. RegisterForActorAction(ACTOR_ACTION_SHEATH_END)
  13. EndEvent
  14.  
  15. Event OnActorAction(int actionType, actor akActor, Form source, int slot)
  16. If akActor == akWhoHasEquipped
  17. If actionType == ACTOR_ACTION_DRAW_START
  18. if akActor == Game.GetPlayer()
  19. playerBaseMagicka = Game.GetPlayer().GetBaseActorValue("Magicka")
  20. RegisterForSingleUpdate(2.0)
  21. ElseIf actionType == ACTOR_ACTION_SHEATH_END
  22. UnregisterForUpdate()
  23. EndIf
  24. EndIf
  25. Endif
  26. EndEvent
  27.  
  28. Event OnUpdate()
  29. // Calculate the amount of magicka to drain from the player
  30. float drainAmount = playerBaseMagicka * 0.01 * (1 - Game.GetPlayer().GetActorValue("Conjuration") / 100)
  31. // Drain the player's magicka by the calculated amount
  32. Game.GetPlayer().DamageActorValue("Magicka", drainAmount)
  33.  
  34. if (updateCount < 30)
  35. // Check if the player's magicka is below 0
  36. if (Game.GetPlayer().GetActorValue("Magicka") <= 0)
  37. // If so, unregister from updates
  38. UnregisterForUpdate()
  39. else
  40. // Otherwise, register for another update and increment the update count
  41. RegisterForSingleUpdate(2.0)
  42. updateCount += 1
  43. EndIf
  44. else
  45. // If the update count has reached 30, unregister from updates
  46. UnregisterForUpdate()
  47. EndIf
  48. EndEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement