Jump to content

Recommended Posts

LTL, FTP here!

 

I want to write a script so that after casting a certain spell 4 times, it starts a 6-hour Cooldown for all the spells sharing a certain keyword on the caster. In this case, Separate teleport spells for each location, and a cooldown so that none can be cast again until the cooldown ends.

 

I have ultra-minimal Papyrus experience, but I'm reading the Bethesda tutorial. All I had come up with wouldn't compile, and for no apparent reason.

 

Scriptname CooldownScript Extends ActiveMagicEffect

;;Properties
Actor Property PlayerREF Auto ;;player
Spell Property cdSpell Auto ;;Set to your cooldown spell or whatever spell you want
Message Property cdMessage Auto ;;Message when the cdSpell is on cast on you
Message Property castMessage Auto ;;Message when you successfully cast your spell

int Count

Event OnEffectStart(Actor akTarget, Actor akCaster)
if count == 3
count = count - 3
cdSpell.cast(self)
cdMessage.show()
else
count = count + 1
castMessage.show()
endif
endevent

Spell Property cdSpell Auto ;;Set to your cooldown spell or whatever spell you want
Message Property cdMessage Auto ;;Message when the cdSpell is on Cooldown
Message Property castMessage Auto ;;Message when you successfully cast your spell

int Count

Event OnEffectStart(Actor akTarget, Actor akCaster)
if count == 3
count = count - 3
cdSpell.cast(self)
cdMessage.show()
else
count = count + 1
castMessage.show()
endif
endevent

 

All that is useless even though it looks fine to me.

I only got it to compile after I deleted everything except the properties, making it useless.

 

Any help would be so greatly appreciated. I can't seem to find an answer for this anywhere!

Edited by dodspringer
Link to comment
Share on other sites

Wont work because that event doesn't track when a spell is cast, and Cast() is to force spells to cast from a source.

The only event that tracks when a spell is cast is OnSpellCast and the method I'm thinking, opens the door to all kinds of scripting techniques to pull it off. First you'd need to make a quest and put the player in an alias, as OnSpellCast can only be placed on an ObjectReference hence reference alias for the player. Then you need this event to listen for the spells being cast based on their keywords, then check the current hour the spells were cast..from there, you may need to use an update to handle the cooldown and that's easy if it's just one spell. What about many spells?

Yeah I tried to work this out and came to the conclusion that limitations with OnUpdate would get in my way. Also tried you alternative suggestion, now that would mean making a lot of properties, each for specific spells and keeping a count of each but then I couldn't work out hours any of these would be cast.

Maybe someone can come up with something better and simpler. Usually I can think of easy small ways to do big things, but in this case I could not.

Edited by Lisselli
Link to comment
Share on other sites

There's a few approaches you could take. The simplest one, I think, would be to give the spell two effects. One is an immediate, fire-and-forget one, that executes the teleport; the other, an effect with a duration that adds a keyword to the caster.

 

Magic effects can have conditions applied to them at either the effect or spell level. I would in this case add a check to both effects at the effect level to see if the caster has that keyword. If they don't, then the effects happen. If they do, nothing occurs. When the keyword-adding effect's duration ends, the keyword will fall off and the spell will work again. All of this can be done without touching Papyrus, which is only going to be needed for the teleportation scripting.

 

EDIT: You might be able to get away with a single magic effect for all the different locations you want to teleport to, as well, though you'll need different Spells. You could take a magnitude parameter in each Spell and read that via SKSE functions in the ActiveMagicEffect, using that to choose between your various teleport targets. You'd need to absolutely ensure the magnitude couldn't be changed by anything in-game, though, which would mean at minimum setting the associated skill to NONE, and possibly overriding Necromage.

Edited by foamyesque
Link to comment
Share on other sites

There's a few approaches you could take. The simplest one, I think, would be to give the spell two effects. One is an immediate, fire-and-forget one, that executes the teleport; the other, an effect with a duration that adds a keyword to the caster.

 

Magic effects can have conditions applied to them at either the effect or spell level. I would in this case add a check to both effects at the effect level to see if the caster has that keyword. If they don't, then the effects happen. If they do, nothing occurs. When the keyword-adding effect's duration ends, the keyword will fall off and the spell will work again. All of this can be done without touching Papyrus, which is only going to be needed for the teleportation scripting.

 

Thanks! The less I have to use any scripts, the better, for compatibility and stability. Unfortunately I don't think it's worth it to try and condense it all to one effect, especially since I plan to add more teleport effects as well as scrolls.

 

I'm gonna try your keyword method out though and report back.

Link to comment
Share on other sites

So how do I actually get the Magic Effect to apply the keyword?

 

I got the conditions set at the spell level, hoping this keeps the teleport spell from being cast before trying to cast it, like powers or shouts.

 

But I don't see how to make the keyword set on the caster.

Link to comment
Share on other sites

So how do I actually get the Magic Effect to apply the keyword?

 

I got the conditions set at the spell level, hoping this keeps the teleport spell from being cast before trying to cast it, like powers or shouts.

 

But I don't see how to make the keyword set on the caster.

 

MagicEffects can apply a keyword to whatever their target is. If they're set as targeting Self, this will be the caster. There's two fields in the lower left of the MagicEffect window that let you set up what keywords the spell applies (or dispels). For example, all the fire damage effects add the keyword MagicDamageFire to whatever they hit, for as long as the fire effect is on them. You'll want to create your own custom keyword for all the teleportation spells, of course.

EDIT:

 

Also, this method will not stop casting animations or magicka consumption, FYI, nor give notice to the player about why it failed (though that could be done fairly simply with some script work); it will behave like attempting to cast a spell on an invalid target.

Edited by foamyesque
Link to comment
Share on other sites

I see. I thought that was just to assign a keyword to the effect, for reference purposes or something.

 

Thanks for your help, I'm about to actually test this out. If it works, I'll upload it right away.

Link to comment
Share on other sites

I see. I thought that was just to assign a keyword to the effect, for reference purposes or something.

 

Thanks for your help, I'm about to actually test this out. If it works, I'll upload it right away.

 

Strictly speaking, the keyword is on the magic effect, not the target, but it can be tested for just like an inherent or quest-added keyword, just with a slightly different conditional function, so I usually treat it as belonging to the target. Sloppy wording on my part.

 

Make sure your conditionals are testing for MagicEffectWithKeyword, not HasKeyword, BTW :v

Edited by foamyesque
Link to comment
Share on other sites

Everything works as intended with this method, other than having to go through the cast time and spend the mana before finding out it won't work.

 

What's the simplest way to add a message with a script? I assume it's an existing script and I just need to set my message as the property.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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