I'm trying to change a mobs icon states, I have an idle,attack,defend,walk,run icon state. Now my problem is not with walk/run these are called with my movement procs. The problem is with attack/defense/idle/beinghit. I want when a unit attacks to go idle. My solution was to create a timer and check it with a proc, when timer==0 means attack animation is complete and I set icon-state to idle. Is there a better solution??
Also my animations last nearly 1.5 seconds, so if a unit A attacks unit B and unit C attacks unit A at the same time how is this going to be resolved??
Should I just apply damages to both B and A or is it better to wait until attack animation is complete to apply damages and if animation interrupted by another attack no damage is applied??
By the way the fight involves like 600 mobs so most details will not be noticeable.
ID:1974993
Oct 31 2015, 7:43 am
|
|
Thanks for the help but in my code attack is actually a proc performed by npc's so if I use sleep() code execution halts and waits for that one attack to finish before going to the next attack while I'm trying to achieve parallel attacks. So do I solve that by using spawn() instead of sleep() or is there any problem (asking that cause I've never used spawn before)??
my code is like |
You can use a counter. When you attack, change your icon state, and increment the counter. Then spawn(duration of state) and decrement the counter. Then check if the counter is equal to zero, and if it is, reset the icon state.
|
In response to Victorqr
|
|
Victorqr wrote:
Thanks for the help but in my code attack is actually a proc performed by npc's so if I use sleep() code execution halts and waits for that one attack to finish before going to the next attack while I'm trying to achieve parallel attacks. So do I solve that by using spawn() instead of sleep() or is there any problem (asking that cause I've never used spawn before)?? > my code is like spawn() works too. |
your solution , apply damage after and put a cool down between every attack.