Jump to content

Need help! How do I add a cooldown to a spell?


morogoth35

Recommended Posts

A secondary cooldown magic effect that fires at the same time as the actual effect except the cooldown effect lasts as long as the cooldown needs to last. Then just add a condition that doesn't allow the spell to fire if the magic effect is on the actor.

 

So..

Silence and cooldown are under the same spell(hide from UI if you want) is cast, the silence spell hits the actor, does its thing, the cooldown effect that is on the player is in effect and the condition for silence can't be used as long as the cooldown is active.

Link to comment
Share on other sites

This is assuming you already have done the Spell and the MGEF.

 

What you're going to do is create another spell and mgef. The mgef contains a script, that casts your actual silence spell on the caster and if it is cast again it checks if the effect is active. If it is, the spell is not cast, and a notification is displayed informing that you have to wait for it to cooldown.

 

 

Scriptname yourscriptnamehere extends activemagiceffect  


Spell Property YourActualSpell Auto  ;your spell goes here
bool SpellActive



Event OnEffectStart(Actor akTarget, Actor akCaster)
        GoToState("Ready")
EndEvent


State Ready
        YourActualSpell.Cast(GetTargetActor(), GetTargetActor())     ;casts the spell
        SpellActive = true        ;sets the bool to true
        RegisterForSingleUpdate(10)   ;waits 10 seconds
EndState

Event OnUpdate()
    If SpellActive                   ;checks if your effect is active
        debug.notification("You have to wait for the spell to cooldown.")  ;the notification
        SpellActive = false          ;if it is active sets the bool to false
        RegisterForSingleUpdate(20)  ;wait another 20 seconds
    Else                             ;if the cooldown is over then the spell can be cast again.
        GoToState("Ready")
    EndIf
EndEvent

 

 

You have to adjust the RegisterForSingleUpdate values to match the cooldown you want.

 

And if i made any mistake in the code above, i hope someone else corrects me. I'm still new to scripting.

Edited by Magnusen2
Link to comment
Share on other sites

This is assuming you already have done the Spell and the MGEF.

 

What you're going to do is create another spell and mgef. The mgef contains a script, that casts your actual silence spell on the caster and if it is cast again it checks if the effect is active. If it is, the spell is not cast, and a notification is displayed informing that you have to wait for it to cooldown.

 

 

 

Scriptname yourscriptnamehere extends activemagiceffect  


Spell Property YourActualSpell Auto  ;your spell goes here
bool SpellActive



Event OnEffectStart(Actor akTarget, Actor akCaster)
        GoToState("Ready")
EndEvent


State Ready
        YourActualSpell.Cast(GetTargetActor(), GetTargetActor())     ;casts the spell
        SpellActive = true        ;sets the bool to true
        RegisterForSingleUpdate(10)   ;waits 10 seconds
EndState

Event OnUpdate()
    If SpellActive                   ;checks if your effect is active
        debug.notification("You have to wait for the spell to cooldown.")  ;the notification
        SpellActive = false          ;if it is active sets the bool to false
        RegisterForSingleUpdate(20)  ;wait another 20 seconds
    Else                             ;if the cooldown is over then the spell can be cast again.
        GoToState("Ready")
    EndIf
EndEvent

 

 

You have to adjust the RegisterForSingleUpdate values to match the cooldown you want.

 

And if i made any mistake in the code above, i hope someone else corrects me. I'm still new to scripting.

Thanks a lot for the script. However I can't use it because when I try and make a new script I get an error message saying something like this: "The extends script does not exist, please choose one that does". I have read that this is a common issue and that the solution is to extract some scripts files to a directory, the only problem with that is that I don't even have the scripts files...

Link to comment
Share on other sites

A secondary cooldown magic effect that fires at the same time as the actual effect except the cooldown effect lasts as long as the cooldown needs to last. Then just add a condition that doesn't allow the spell to fire if the magic effect is on the actor.

 

So..

Silence and cooldown are under the same spell(hide from UI if you want) is cast, the silence spell hits the actor, does its thing, the cooldown effect that is on the player is in effect and the condition for silence can't be used as long as the cooldown is active.

What magic effect are you talking about? What effect should I use?

Link to comment
Share on other sites

 

This is assuming you already have done the Spell and the MGEF.

 

What you're going to do is create another spell and mgef. The mgef contains a script, that casts your actual silence spell on the caster and if it is cast again it checks if the effect is active. If it is, the spell is not cast, and a notification is displayed informing that you have to wait for it to cooldown.

 

 

 

Scriptname yourscriptnamehere extends activemagiceffect  


Spell Property YourActualSpell Auto  ;your spell goes here
bool SpellActive



Event OnEffectStart(Actor akTarget, Actor akCaster)
        GoToState("Ready")
EndEvent


State Ready
        YourActualSpell.Cast(GetTargetActor(), GetTargetActor())     ;casts the spell
        SpellActive = true        ;sets the bool to true
        RegisterForSingleUpdate(10)   ;waits 10 seconds
EndState

Event OnUpdate()
    If SpellActive                   ;checks if your effect is active
        debug.notification("You have to wait for the spell to cooldown.")  ;the notification
        SpellActive = false          ;if it is active sets the bool to false
        RegisterForSingleUpdate(20)  ;wait another 20 seconds
    Else                             ;if the cooldown is over then the spell can be cast again.
        GoToState("Ready")
    EndIf
EndEvent

 

 

You have to adjust the RegisterForSingleUpdate values to match the cooldown you want.

 

And if i made any mistake in the code above, i hope someone else corrects me. I'm still new to scripting.

Thanks a lot for the script. However I can't use it because when I try and make a new script I get an error message saying something like this: "The extends script does not exist, please choose one that does". I have read that this is a common issue and that the solution is to extract some scripts files to a directory, the only problem with that is that I don't even have the scripts files...

 

 

In the Data folder there a "Scripts.rar" file, unpack it, then reinstall SKSE Scripts.

If it missing verify Creation Kit with Steam to download it.

Link to comment
Share on other sites

 

A secondary cooldown magic effect that fires at the same time as the actual effect except the cooldown effect lasts as long as the cooldown needs to last. Then just add a condition that doesn't allow the spell to fire if the magic effect is on the actor.

 

So..

Silence and cooldown are under the same spell(hide from UI if you want) is cast, the silence spell hits the actor, does its thing, the cooldown effect that is on the player is in effect and the condition for silence can't be used as long as the cooldown is active.

What magic effect are you talking about? What effect should I use?

 

You make it and have it apply to the player at the same time as the spell. Now that it's on the player you can add a condition to the spell that stops it from firing if the cooldown effect is active.

Link to comment
Share on other sites

This is assuming you already have done the Spell and the MGEF.

 

What you're going to do is create another spell and mgef. The mgef contains a script, that casts your actual silence spell on the caster and if it is cast again it checks if the effect is active. If it is, the spell is not cast, and a notification is displayed informing that you have to wait for it to cooldown.

 

 

 

Scriptname yourscriptnamehere extends activemagiceffect  


Spell Property YourActualSpell Auto  ;your spell goes here
bool SpellActive



Event OnEffectStart(Actor akTarget, Actor akCaster)
        GoToState("Ready")
EndEvent


State Ready
        YourActualSpell.Cast(GetTargetActor(), GetTargetActor())     ;casts the spell
        SpellActive = true        ;sets the bool to true
        RegisterForSingleUpdate(10)   ;waits 10 seconds
EndState

Event OnUpdate()
    If SpellActive                   ;checks if your effect is active
        debug.notification("You have to wait for the spell to cooldown.")  ;the notification
        SpellActive = false          ;if it is active sets the bool to false
        RegisterForSingleUpdate(20)  ;wait another 20 seconds
    Else                             ;if the cooldown is over then the spell can be cast again.
        GoToState("Ready")
    EndIf
EndEvent

 

 

You have to adjust the RegisterForSingleUpdate values to match the cooldown you want.

 

And if i made any mistake in the code above, i hope someone else corrects me. I'm still new to scripting.

Why do I need to make a new spell and MGEF? Can't I just add the script to my current magic effect? Btw, I tried doing that but when I tried compiling the script it gave me these errors:

 

Starting 1 compile threads for 1 files...
Compiling "ArcaneDisruptionCooldown"...
F:\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\ArcaneDisruptionCooldown.psc(15,8): no viable alternative at input 'ArcaneDisruption'
F:\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\ArcaneDisruptionCooldown.psc(15,24): mismatched input '.' expecting LPAREN
F:\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\ArcaneDisruptionCooldown.psc(0,0): error while attempting to read script ArcaneDisruptionCooldown: Object reference not set to an instance of an object.
No output generated for ArcaneDisruptionCooldown, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on ArcaneDisruptionCooldown
Link to comment
Share on other sites

Personally I use global variables and then make a condition when GameDaysPassed >= CoolDown with out using states and minimum scripting.

 

Scriptname CoolDownScript extends activemagiceffect

GlobalVariable Property GameDaysPassed Auto
GlobalVariable Property CoolDown Auto
Float Property fMaximum Auto
Float Property fMinimum Auto

;/
; fAmount "game hours" expressed in GameDaysPassed
; 0.01 about 15 in-game minutes
; 0.02 about 30 in-game minutes
; 0.04 about 1 in-game hour
; 0.06 about 1 hour and 30 minutes in-game
; 0.08 about 2 in-game hours
; 0.10 about 2 hours and 30 minutes in-game
/;

Function CoolDownFunction()

Float UntilNextAllowed = Utility.RandomFloat(fMinimum, fMaximum)

Float NextAllowed = GameDaysPassed.GetValue() + UntilNextAllowed

CoolDown.SetValue(NextAllowed)
EndFunction

 

Use Property Values to Adjust fMinimum & fMaximum

 

or Float UntilNextAllowed = 0.005 ; 7.5 ingame minutes etc etc

 

Just to give a different opinion

 

Edit:

 

Don't forget to tick Global Variable Box in Spell Conditions, Just Saying.

Edited by PeterMartyr
Link to comment
Share on other sites

Alright, I asked Wheeze for help and he gave me a script that he said would work. I added the script to the magic effect and loaded up the game and tested it out but it did nothing...

 

This is the script he made for me:

 

 

Scriptname ArcaneDisruptionCooldownScript01 extends activemagiceffect

Spell Property ArcaneDisruption Auto ;your spell goes here
bool CooldownReady = true



Event OnEffectStart(Actor akTarget, Actor akCaster)
if (CooldownReady)
ArcaneDisruption.Cast(GetTargetActor(), GetTargetActor())
CooldownReady = false
SpellCooldown()
Else
debug.notification("You have to wait for the spell to cooldown.")
endif
EndEvent

Function SpellCooldown()
utility.wait(300)
CooldownReady = true
EndFunction

 

 

Anyone that can see if it's something wrong with the code? The script compiled without any issues but it had no effect ingame.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...