I have a shooting trigger that reacts on the event of a player clicking left mouse button with boolean=false as condition
Then the action creates a dummy unit that shoots out some stuff
I don't want this trigger to be cast alot so to have a cooldown, I put in a "Turn current trigger off" and then "Run Reset Trigger" and set Boolean=true
The "Reset Trigger" has no event and only has 3 actions: wait 5 seconds (which is the cooldown), set boolean=false, and then turn the shooting trigger back on
Now these 2 triggers sort of work in making a cooldown for shooting, however, if the player spams the left mouse button, he can sometimes shoot multiple times at once!
What is a better way of making a trigger cooldown to prevent running the first shooting trigger more than once in succession?
its becouse of the wait action
got that problem too but with a time based attack for rpg i fixed this with making enemies units invurnable after hitting for few seconds
otherwhise u could do an condition that checks if the weapon from the dummy unit was shootet and then kill the unit or remove weapons
many ways
Create a constantglobal boolean variable that checks if the trigger is currently running. If you have more than one player, use a boolean array.
Event Left mouse clicked, Do the following
Conditions: Boolean for EventPlayer is true
Actions:
Set an integer variable 'p' to the EventPlayer
Flag boolean as true for p
Do you shoot actions for p
Flag boolean as false p
Same thing as what Nashadun said. But make sure you have one boolean for each player, or you're going to disable everyones shooting because of 1 person clicking left mouse.
The condition should be "Boolean for triggering player is false." There is no need to set an integer to the triggering player if you're using one trigger. Then your actions should just be "turn boolean switch on for triggering player (to prevent the event from firing during the cooldown), shoot stuff, wait (cooldown time) seconds, turn boolean switch off."
Yes, so long as the boolean is an array with the size set to the number of players in the game, and when you set the boolean you make the index (player number of triggering player)
I ususaly make it a trigger that casts a spell then you can just detect when the spell or the effect is cast to make the rest of the triggering, and you can use the cooldown of the ability to do it. That is also nice since its easier to use animations on the caster, and to make other costs (energy, life, shield), without having to check the if you have a sufficient amount of that stat.
Your trigger should work fine EXCEPT that your variable is local, like MaskedImposter said, if you make a global (Cooldown = False <boolean(8)>) variable and then reference that (delete the local Cooldown variable), it should work fine.
The reason your trigger would not work is because every time the mouse event triggers it, it will create a new "Cooldown[8]" variable which for all indexes is set to false. Therefore the condition will always evaluate to true.
I have a shooting trigger that reacts on the event of a player clicking left mouse button with boolean=false as condition
Then the action creates a dummy unit that shoots out some stuff
I don't want this trigger to be cast alot so to have a cooldown, I put in a "Turn current trigger off" and then "Run Reset Trigger" and set Boolean=true
The "Reset Trigger" has no event and only has 3 actions: wait 5 seconds (which is the cooldown), set boolean=false, and then turn the shooting trigger back on
Now these 2 triggers sort of work in making a cooldown for shooting, however, if the player spams the left mouse button, he can sometimes shoot multiple times at once!
What is a better way of making a trigger cooldown to prevent running the first shooting trigger more than once in succession?
I don't know if this would solve your issue, but why use 2 triggers? You can accomplish the same thing with 1 trigger.
Event: Mouse clicked
Condition: boolean=false
Actions:
set boolean = true
do stuff
wait 5 seconds
set boolean = false
Create a
constantglobal boolean variable that checks if the trigger is currently running. If you have more than one player, use a boolean array.Event Left mouse clicked, Do the following
Conditions: Boolean for EventPlayer is true
Actions:
Same thing as what Nashadun said. But make sure you have one boolean for each player, or you're going to disable everyones shooting because of 1 person clicking left mouse.
u sure? ;)
@Kueken531: Go
I have no idea how the word constant appeared there. Honest :D anyway, fixed it lol. Thanks for pointing out the error.
Ok thanks guys I think I got it to work!
I removed the extra unecessary cooldown trigger
And put the boolean array as the first action, and then the wait of 5 seconds, and the turn back on boolean as the very last action
The condition should be "Boolean for triggering player is false." There is no need to set an integer to the triggering player if you're using one trigger. Then your actions should just be "turn boolean switch on for triggering player (to prevent the event from firing during the cooldown), shoot stuff, wait (cooldown time) seconds, turn boolean switch off."
@BasharTeg: Go
im using triggering player right now instead of variable set to player, same as you said,
but i was wondering if there will there be problems after the 5 second wait?
will the set boolean action after the 5 second wait still be associated with the correct triggering player?
Yes, so long as the boolean is an array with the size set to the number of players in the game, and when you set the boolean you make the index (player number of triggering player)
I ususaly make it a trigger that casts a spell then you can just detect when the spell or the effect is cast to make the rest of the triggering, and you can use the cooldown of the ability to do it. That is also nice since its easier to use animations on the caster, and to make other costs (energy, life, shield), without having to check the if you have a sufficient amount of that stat.
Mouse clicked
Turn trigger off
wait 5sec
turn trigger on
Im not sure if this is what you looking for, but it should be doable with only 1 trigger...
Sorry for restarting this old thread but I am using it and it doesn't seem to work for me, here is my trigger please help:
Event- player clicks right mouse down
loc variables- Cooldown = False <boolean(8)>
Condition- Cooldown (triggering player) ==False
action- set cooldown (triggering player)== true
order hero(triggering player) to use (whatever abillity i am using)
Wait 10 real time seconds
Set cooldown (triggering player) ==False
Right now my ability casts without waiting 10 seconds, anyone got any idea ??
You should use a global variable, and not a local variable.
Doesn't seem to work, any other ideas or if anyone know a completely different way to do it, please post it or post a map with.
Thanks
Bump
@pokenoufl: Go
Your trigger should work fine EXCEPT that your variable is local, like MaskedImposter said, if you make a global (Cooldown = False <boolean(8)>) variable and then reference that (delete the local Cooldown variable), it should work fine.
The reason your trigger would not work is because every time the mouse event triggers it, it will create a new "Cooldown[8]" variable which for all indexes is set to false. Therefore the condition will always evaluate to true.