Is it possible to add a delay to a scripted spell?

Post » Wed Jun 20, 2012 3:54 am

I want to prevent the player from spamming the lesser powers/spells I've created through scripting. Is there some way I can add say a 5 second delay between casting the spell? It's important that you know I don't mean a utility wait in the script. What I'm looking for is an actual delay so the 'Z' button can't be used like a machine gun to keep casting and canceling the spell/power.

Thanks guys and gals.
User avatar
Jennifer May
 
Posts: 3376
Joined: Thu Aug 16, 2007 3:51 pm

Post » Wed Jun 20, 2012 12:21 am

Longer charge time?
User avatar
Adam
 
Posts: 3446
Joined: Sat Jun 02, 2007 2:56 pm

Post » Wed Jun 20, 2012 3:07 pm

Well the spell technically has no charge time. You hit 'Z' and the script fires. It's a scripted Lesser Power essentially.
User avatar
Yung Prince
 
Posts: 3373
Joined: Thu Oct 11, 2007 10:45 pm

Post » Wed Jun 20, 2012 7:36 am

OK, set a boolean TimerRunning to True in the start, and registerForSingleUpdate(5) - turn the boolean to False in the OnUpdate, and encapsulate your original starting effect in an If !TimerRunning check.
User avatar
Joey Avelar
 
Posts: 3370
Joined: Sat Aug 11, 2007 11:11 am

Post » Wed Jun 20, 2012 3:31 pm

OK, set a boolean TimerRunning to True in the start, and registerForSingleUpdate(5) - turn the boolean to False in the OnUpdate, and encapsulate your original starting effect in an If !TimerRunning check.

Again, you're the man. Thanks for that. Gonna help me a lot with other scripted spells.

*high five*
User avatar
BRIANNA
 
Posts: 3438
Joined: Thu Jan 11, 2007 7:51 pm

Post » Wed Jun 20, 2012 1:07 am

I've been trying to get this to work but I'm starting to guess that it wont because my spell is Fire and Forget and not a constant. So therefore it doesn't/can't track game time?
User avatar
gandalf
 
Posts: 3400
Joined: Wed Feb 21, 2007 6:57 pm

Post » Wed Jun 20, 2012 1:13 am

If it's registered for an update, the script should stick around at least until it gets the update.
User avatar
Anne marie
 
Posts: 3454
Joined: Tue Jul 11, 2006 1:05 pm

Post » Wed Jun 20, 2012 3:06 pm

I could not get the OnUpdate to work either. I tried with this script on a spell with 0 duration:

Spoiler
Scriptname TestMEScript extends ActiveMagicEffectEvent OnEffectStart(Actor akTarget, Actor akCaster)	Debug.Notification("Start")	RegisterForSingleUpdate(5)EndEventEvent OnUpdate()	Debug.Notification("Update")EndEventEvent OnEffectFinish(Actor akTarget, Actor akCaster)	Debug.Notification("Finish")EndEvent

On the other hand, this showed all three messages:

Spoiler
Scriptname TestMEScript extends ActiveMagicEffectEvent OnEffectStart(Actor akTarget, Actor akCaster)	Debug.Notification("Start")	Utility.Wait(5)	Debug.Notification("Update")EndEventEvent OnEffectFinish(Actor akTarget, Actor akCaster)	Debug.Notification("Finish")EndEvent

To simulate a cool down without using OnUpdate, I would try this:

Spoiler
;;;GlobalVariable property TimeLastUsed autoBool AbortedEvent OnEffectStart(Actor akTarget, Actor akCaster)    if ((Game.GetRealHoursPassed() - TimeLastUsed) < (1.0/60.0))        Aborted = True        Dispel()        Return    endif        ;;;;EndEvent;;;Event OnEffectFinish(Actor akTarget, Actor akCaster)    if !Aborted        TimeLastUsed.SetValue(Game.GetRealHoursPassed())    endif    ;;;    EndEvent

This probably wouldn't work correctly though if the player opens up a menu and waits it out.
User avatar
Judy Lynch
 
Posts: 3504
Joined: Fri Oct 20, 2006 8:31 am

Post » Wed Jun 20, 2012 1:31 pm

Couldn't you just use Utility.wait instead of register for update?

Set a global variable, utility wait, set global variable to false.
User avatar
Ilona Neumann
 
Posts: 3308
Joined: Sat Aug 19, 2006 3:30 am

Post » Wed Jun 20, 2012 3:26 pm

Ive tried that but the problem is it freezes the player.

Im looking for a way to delay any use of the casting while its effects are still playing. Problem is it doesnt seem to work with Fire and Forget. Probably because those kinds of spells are getting new IDs every time they cast. At least thats my theory and the reason I had to create a globalvariable for stopping any looping sounds I used.

I'll look into using a Global for the delay. Just seems like a lot of extra work to do something simple.

The purpose of having a delay is to prevent the player from spamming my Bat Form spell. Because if you machine gun the Z key it will eventually cause a sound looping error that so far can't be fixed. Now, no one has bothered to do something so silly so it may never be a problem but it's the only real bug left with the spell (thankfully I cured the others).
User avatar
Leticia Hernandez
 
Posts: 3426
Joined: Tue Oct 23, 2007 9:46 am

Post » Wed Jun 20, 2012 3:45 am

How about adding a second magic effect to your spell?
Have your script check whether the magic effect is still active, if it is, it does not fire.
You can then use the duration of the magic effect as a cooldown.
Or use the second magic effect to apply a separate script that does nothing else but set a global variable, ultility.wait, and then reset the variable. That way it should not freeze the player.
User avatar
Ben sutton
 
Posts: 3427
Joined: Sun Jun 10, 2007 4:01 am

Post » Wed Jun 20, 2012 2:51 pm

not sure if this addresses your issue:
from the http://www.creationkit.com/Magic_Effect Conditions Topic:
"This means that if you for example try to make an effect that doesn't stick if it's already there, you can put the check into the effect's condition window, but if you put it into the spell itself, it will get canceled because it finds itself.

Or, would it be feasible to temporarily http://www.creationkit.com/RemoveSpell_-_Actor (silently) from the player after casting it , then add it back after your desired cooldown? or maybe just http://www.creationkit.com/UnequipSpell_-_Acto would suffice
User avatar
Krystina Proietti
 
Posts: 3388
Joined: Sat Dec 23, 2006 9:02 pm

Post » Wed Jun 20, 2012 1:50 pm

Removing the spell I can't do because it is already doing that in order to toggle. Unequipping the spell is annoying because it forces you to reset the spell in your favorites.

I kind of like the idea of using a second magic effect to act act as a timer. I will try that and see what happens. If it isnt feesible I'll try using a global.

Thanks to each of you.
User avatar
Andy durkan
 
Posts: 3459
Joined: Fri Aug 03, 2007 3:05 pm

Post » Wed Jun 20, 2012 10:22 am

Have you considered turning your power into a shout? That would let you take advantage of the cooldown mechanic already implemented by the game.
User avatar
Amysaurusrex
 
Posts: 3432
Joined: Wed Aug 09, 2006 2:45 pm

Post » Wed Jun 20, 2012 1:00 am

Have you considered turning your power into a shout? That would let you take advantage of the cooldown mechanic already implemented by the game.

That's an interesting idea. How would I utilize that? I've never toyed with Shouts.
User avatar
Avril Churchill
 
Posts: 3455
Joined: Wed Aug 09, 2006 10:00 am

Post » Wed Jun 20, 2012 9:28 am

From what I can tell, shouts are just an additional layer on top of the spell system, so all you'd have to do is create a new shout with your desired cooldown and set the first word to your already existing spell (with its type changed to voice power), and you'd be pretty much done.
User avatar
Blaine
 
Posts: 3456
Joined: Wed May 16, 2007 4:24 pm

Post » Wed Jun 20, 2012 11:21 am

From what I can tell, shouts are just an additional layer on top of the spell system, so all you'd have to do is create a new shout with your desired cooldown and set the first word to your already existing spell (with its type changed to voice power), and you'd be pretty much done.

It's interesting because turning it into a Shout also means it requires Dragon Souls to acquire/use. Interesting.
User avatar
Bee Baby
 
Posts: 3450
Joined: Sun Jun 18, 2006 4:47 am

Post » Tue Jun 19, 2012 11:47 pm

Well, it for some reason crashes the game instead of unlocks the shout when I add it as a shout.
User avatar
lexy
 
Posts: 3439
Joined: Tue Jul 11, 2006 6:37 pm

Post » Wed Jun 20, 2012 3:05 am

Well, it for some reason crashes the game instead of unlocks the shout when I add it as a shout.

you may need one or both of these before you can use the shout:
http://www.creationkit.com/UnlockWord_-_Game
http://www.creationkit.com/TeachWord_-_Game

also make sure you gave your shout a name - i think it will crash the game without it
User avatar
luke trodden
 
Posts: 3445
Joined: Sun Jun 24, 2007 12:48 am

Post » Wed Jun 20, 2012 2:18 am

The Shout was a good idea but it is adding to the mod in a way I did not intend.

i tried using the magic effect and so far it has not worked.

For some reason the magic effect is being detected before I cast the spell. So the spell wont even work if I
!Caster.HasMagicEffect(BatFormTimer)
If instead use
Caster.HasMagicEffect(BatFormTimer)
Then of course it works but essentially does not change the spell just adds more argument to the script.
User avatar
Sammygirl
 
Posts: 3378
Joined: Fri Jun 16, 2006 6:15 pm


Return to V - Skyrim