I am making a trigger and I was wondering if there is a way (probably with a condition) to check to make sure a unit (will not be the triggering unit) has not attacked or been attacked in the last 5 seconds.
If the unit has been in combat within the last few seconds, I would also like it to say something like "Please wait 5 seconds after combat before using this feature."
Could always use a boolean variable "var" and a trigger with the events "Unit Takes Damage" and "Unit Deals Damage" that makes var true, waits 5 seconds, then makes it false.
Well I am wanting it all to be in 1 trigger. It is going to be a loading trigger for loading a hero. People are going to be able to use this when ever they want but I don't want people doing things like "I have 10 life left and someone is attacking me *loads*"
I don't want to make a check for 100% HP or something because that's too specific.
Unless there is maybe a way I could make the load have a cast bar or something? or have an idle check?
Edit: Never mind I think i miss read your post, I think that should work.
A straight implementation of that could lead to hidden and unexpected issues. For example, what if I attacked someone, waited 4.9 seconds, and attacked again? In the following 0.1 seconds, the wait time from the first instance would expire and the value would be set to false immediately, effectively counting me as out of combat even though I attacked someone again just 0.1 seconds earlier.
Since you're saving a global variable here anyway, a cleaner method would be to save the real time elapsed since the start of the game (or game time, but game time is affected by game speed) to a variable whenever the unit attacks or is attacked (overwriting the previous value each time so that only the latest attack time is kept), and when loading/saving/whatever you check the current game time versus the last attack time (the variable), and if the difference is greater than five seconds you proceed with the save/load, if it's smaller you warn the player or do whatever you want to do when not loading.
or you could just make a timer variable, use the Start Timer action and make it last 5 seconds, and just check the remaining time of the timer, if its greater than 0 seconds, the unit is still in combat
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I am making a trigger and I was wondering if there is a way (probably with a condition) to check to make sure a unit (will not be the triggering unit) has not attacked or been attacked in the last 5 seconds.
If the unit has been in combat within the last few seconds, I would also like it to say something like "Please wait 5 seconds after combat before using this feature."
@Nugs0153: Go
Could always use a boolean variable "var" and a trigger with the events "Unit Takes Damage" and "Unit Deals Damage" that makes var true, waits 5 seconds, then makes it false.
Well I am wanting it all to be in 1 trigger. It is going to be a loading trigger for loading a hero. People are going to be able to use this when ever they want but I don't want people doing things like "I have 10 life left and someone is attacking me *loads*"
I don't want to make a check for 100% HP or something because that's too specific.
Unless there is maybe a way I could make the load have a cast bar or something? or have an idle check?
Edit: Never mind I think i miss read your post, I think that should work.
@Abion47: Go
A straight implementation of that could lead to hidden and unexpected issues. For example, what if I attacked someone, waited 4.9 seconds, and attacked again? In the following 0.1 seconds, the wait time from the first instance would expire and the value would be set to false immediately, effectively counting me as out of combat even though I attacked someone again just 0.1 seconds earlier.
Since you're saving a global variable here anyway, a cleaner method would be to save the real time elapsed since the start of the game (or game time, but game time is affected by game speed) to a variable whenever the unit attacks or is attacked (overwriting the previous value each time so that only the latest attack time is kept), and when loading/saving/whatever you check the current game time versus the last attack time (the variable), and if the difference is greater than five seconds you proceed with the save/load, if it's smaller you warn the player or do whatever you want to do when not loading.
or you could just make a timer variable, use the Start Timer action and make it last 5 seconds, and just check the remaining time of the timer, if its greater than 0 seconds, the unit is still in combat