- Joined
- Jun 17, 2014
- Messages
- 236
can we detect if unit has finish his attack animation then deal X damage, can we?
except using wait.
except using wait.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
i dont know what your mean.
how can i do that?
Events
Unit - Unit Finishes Casting An Ability
There is no good way to do this as far as I know.
You can manually check how long the animation lasts in the model preview window and then just wait that long with the code. However all units do obviously not have attack animations that last for exactly the same time so in some maps it wont work.
If you decide to wait for one second it will more or less suit most animaions because they are between 0.8 and 1.5 seconds most of the time.
CP

Events


Unit - A unit Finishes casting an ability

Conditions


(Ability being cast) Equal to Colt Phyton

Actions


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




Colt_IndexSize Equal to 0



Then - Actions




Trigger - Turn on CP Loop <gen>



Else - Actions


Set Colt_IndexSize = (Colt_IndexSize + 1)


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




Colt_IndexSize Greater than Colt_MaxIndex



Then - Actions




Set Colt_Index[Colt_IndexSize] = Colt_IndexSize




Set Colt_MaxIndex = Colt_IndexSize



Else - Actions


Set Colt_TempInt = Colt_Index[Colt_IndexSize]


Set Colt_Caster[Colt_TempInt] = (Triggering unit)


Set Colt_Target[Colt_TempInt] = (Target unit of ability being cast)


Set Colt_Level[Colt_TempInt] = (Level of Colt Phyton for Colt_Caster[Colt_TempInt])


Set Colt_Damage_Base[1] = 250.00


Set Colt_Damage_Base[2] = 375.00


Set Colt_Damage_Base[3] = 500.00


Set Colt_Damage_Base[4] = 350.00


Set Colt_Damage_Base[5] = 550.00


Set Colt_Damage_Base[6] = 750.00


Set Colt_DamageN[Colt_TempInt] = (UnitAttack[UDex] + Colt_Damage_Base[Colt_Level[Colt_TempInt]])


Set Colt_DamageG[Colt_TempInt] = (UnitAttack[UDex] + Colt_Damage_Base[(3 + Colt_Level[Colt_TempInt])])


Set Colt_Loc1[Colt_TempInt] = (Position of Colt_Caster[Colt_TempInt])


Set Colt_Loc2[Colt_TempInt] = (Position of Colt_Target[Colt_TempInt])


Set Colt_Dis[Colt_TempInt] = (Distance between Colt_Loc1[Colt_TempInt] and Colt_Loc2[Colt_TempInt])


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




Colt_Dis[Colt_TempInt] Less than or equal to 800.00



Then - Actions




Set Colt_RealDamage[Colt_TempInt] = Colt_DamageN[Colt_TempInt]




Unit - Pause Colt_Caster[Colt_TempInt]




Animation - Play Colt_Caster[Colt_TempInt]'s Spell Chain animation




Unit - Unpause Colt_Caster[Colt_TempInt]




Unit - Create 1 Shade EFX for (Owner of Colt_Caster[Colt_TempInt]) at Colt_Loc1[Colt_TempInt] facing Default building facing degrees




Set Colt_Dumu[Colt_TempInt] = (Last created unit)




Set Colt_Loc3[Colt_TempInt] = (Position of Colt_Dumu[Colt_TempInt])




Custom script: call RemoveLocation (udg_Colt_Loc1[udg_Colt_TempInt])




Custom script: call RemoveLocation (udg_Colt_Loc2[udg_Colt_TempInt])



Else - Actions




Set Colt_RealDamage[Colt_TempInt] = Colt_DamageG[Colt_TempInt]




Unit - Pause Colt_Caster[Colt_TempInt]




Animation - Play Colt_Caster[Colt_TempInt]'s Spell Channel animation




Unit - Unpause Colt_Caster[Colt_TempInt]




Unit - Pause Colt_Caster[Colt_TempInt]




Animation - Play Colt_Caster[Colt_TempInt]'s Spell Chain animation




Unit - Unpause Colt_Caster[Colt_TempInt]




Unit - Create 1 Shade EFX for (Owner of Colt_Caster[Colt_TempInt]) at Colt_Loc1[Colt_TempInt] facing Default building facing degrees




Set Colt_Dumu[Colt_TempInt] = (Last created unit)




Set Colt_Loc3[Colt_TempInt] = (Position of Colt_Dumu[Colt_TempInt])




Custom script: call RemoveLocation (udg_Colt_Loc1[udg_Colt_TempInt])




Custom script: call RemoveLocation (udg_Colt_Loc2[udg_Colt_TempInt])
CP Loop

Events


Time - Every 0.03 seconds of game time

Conditions

Actions


For each (Integer Colt_Looper) from 1 to Colt_IndexSize, do (Actions)



Loop - Actions




Set Colt_TempInt = Colt_Index[Colt_Looper]




Set Colt_Loc3[Colt_TempInt] = (Position of Colt_Dumu[Colt_TempInt])




Set Colt_Loc2[Colt_TempInt] = (Position of Colt_Target[Colt_TempInt])




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






(Colt_Target[Colt_TempInt] is alive) Equal to True





Then - Actions






If (All Conditions are True) then do (Then Actions) else do (Else Actions)







If - Conditions








(Distance between Colt_Loc3[Colt_TempInt] and Colt_Loc3[Colt_TempInt]) Greater than 20.00







Then - Actions








Set Colt_Angle[Colt_TempInt] = (Angle from Colt_Loc2[Colt_TempInt] to Colt_Loc3[Colt_TempInt])








Set Colt_Loc4[Colt_TempInt] = (Colt_Loc3[Colt_TempInt] offset by (1200.00 x 0.03) towards Colt_Angle[Colt_TempInt] degrees)








Unit - Move Colt_Dumu[Colt_TempInt] instantly to Colt_Loc4[Colt_TempInt]








Custom script: call RemoveLocation (udg_Colt_Loc4[udg_Colt_TempInt])








Custom script: call RemoveLocation (udg_Colt_Loc2[udg_Colt_TempInt])







Else - Actions








Unit - Cause Colt_Caster[Colt_TempInt] to damage Colt_Target[Colt_TempInt], dealing Colt_RealDamage[Colt_TempInt] damage of attack type Hero and damage type Normal








Unit - Kill Colt_Dumu[Colt_TempInt]








Set Colt_Index[Colt_Looper] = Colt_Index[Colt_IndexSize]








Set Colt_Index[Colt_IndexSize] = Colt_TempInt








Set Colt_IndexSize = (Colt_IndexSize - 1)








Set Colt_Looper = (Colt_Looper - 1)








If (All Conditions are True) then do (Then Actions) else do (Else Actions)









If - Conditions










Colt_IndexSize Equal to 0









Then - Actions










Trigger - Turn off (This trigger)









Else - Actions





Else - Actions






Set Colt_Index[Colt_Looper] = Colt_Index[Colt_IndexSize]






Set Colt_Index[Colt_IndexSize] = Colt_TempInt






Set Colt_IndexSize = (Colt_IndexSize - 1)






Set Colt_Looper = (Colt_Looper - 1)






If (All Conditions are True) then do (Then Actions) else do (Else Actions)







If - Conditions








Colt_IndexSize Equal to 0







Then - Actions








Trigger - Turn off (This trigger)







Else - Actions
I'll assume you want to deal damage after the animation, then in that case you could use:
with the Channel Ability with a Follow Through Time.
Events
Unit - Unit Finishes Casting An Ability
The Follow Through Time will dictate how long the unit will play the animation before the effects start, so go trial and error until you find the appropriate Follow Through Time that matches the animation.
Note: It may not match every unit type's attack animation.
A common misconceptionand if i use wait, the spell not MUI anymore
After reading the description, I'm pretty sure my suggestiion would work. But meh, too lazy to create a test map.and this does'nt work ;-;
After reading the description, I'm pretty sure my suggestiion would work. But meh, too lazy to create a test map.
It would not.
The animation duration is (likely) not the same of all units. Thus the animation is not necessarily finished when the spell goes on cooldown. Do not confuse animation with cast time.
Would be kinda funny if stormbolt had a 1 second cast time (due the animation being 1 second long) while it has a 2 second casttime for a paladin (just an example).
You might have to use an integer or real if you want it to be MUI, and make a timer using them. If the animation is 0.66s long, you would pry want the periodic trigger run every 0.03s, and set the integer for that instance at 22.
Every time it runs, it checks to see if the integer is at 0, and if it is then run the spell or whatever. The integer variable would have to be an array, of course, but this could definitely be MUI.
A common misconception
You might have to use an integer or real if you want it to be MUI, and make a timer using them. If the animation is 0.66s long, you would pry want the periodic trigger run every 0.03s, and set the integer for that instance at 22.
Every time it runs, it checks to see if the integer is at 0, and if it is then run the spell or whatever. The integer variable would have to be an array, of course, but this could definitely be MUI.
