HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Detect Autocast

04-21-2006, 12:31 AM#1
StockBreak
Hi all, I am almost-new of this forum (I used to post here before the forums reset)
I have just a question:

I made an ability based on "Flaming Arrow" (or something similar) and I noticed that I can trigger it ONLY when it's cast manually (the player actually clicks on the icon and select a target), but the trigger doesn't shot when autocast is on. How can I solve it? As the title suggests, my problem is: how to trigger autocast abilities (i searched 4 previous posts, but I couldn't find none similar...)? Thanks!

P.S: I want to make an ability that shots when the unit damages another unit, when the arrow starts.
04-21-2006, 04:10 PM#2
Captain Griffen
That last bit didn't make sense. Anyway, you could do it by tracking when the ability is enabled/disabled, or by a buff. All I can think of at the moment.
04-21-2006, 04:25 PM#3
Chuckle_Brother
Normal autocast abilities can be detected by orders, don't think that attack autocast can be detected.
04-21-2006, 05:35 PM#4
StockBreak
Quote:
Originally Posted by Captain Griffen
That last bit didn't make sense. Anyway, you could do it by tracking when the ability is enabled/disabled, or by a buff. All I can think of at the moment.
How can I track with triggers when the ability is enabled/disabled? And with buffs? Thanks.

Quote:
Originally Posted by Chuckle_Brother
Normal autocast abilities can be detected by orders, don't think that attack autocast can be detected.
How can I detect it by orders? Thanks.

I need an ability that triggers while the unit is attacking, I mean, the ability is casted AND and the unit attacks at the same time the target. Flaming Arrow it's the first ability that came to my mind, any suggest? Thanks.
04-21-2006, 05:43 PM#5
vile
This can be easily done. Add a trigger, that when the unit is issued an order equal to "flamingarrowson" or "flamingarrowsoff", and make a boolean. Set the boolean to false when its off, and true when its on.
Make another trigger, with conditions - a unit is attacked and attacking unit equal to your caster, and the boolean equal to true

then in the actions order it to "flamingarrows" attacked unit

then another trigger is requires - a unit starts the effect of an ability
ability being cast equal to (your spell)

and actions - whatever you like.
04-21-2006, 05:53 PM#6
Anitarf
You can't detect when autocast attack-based abilities fire, and even if you could, that would be when the attack started, not when the arrow actually hit.

How I did it was a sort of a work around. I used an arrow ability that creats a buff on the target (not black arrow, because it can't affect heroes, but either cold or frost arrow; one of them allows the use of custom buffs, the other one doesn't.) when it hits. Then I had a variable (variable array, actualy, so I could have more heroes of the same type) that stored the last unit my hero attacked, and I had a fast periodic trigger (running every 0.04 seconds) that checked those units for the arrow's buff. Because the periodic trigger was so fast, the delay between the arrow hitting the target and the trigger noticing the buff was unnoticable. The only problem you would get this way is, you don't know who the attacker was if two same heroes were targeting the same unit; The trigger would check the first hero's target, find the buff and assume it was the first hero that inflicted it, even if it was the second one. For me, it didn't really matter, because the effect I was applying was negative armour, and it really didn't matter to which player the dummy caster that cast the armor reduction spell belonged.

You could use a "unit takes damage" event instead of a periodic one, that is even more accurate than a periodic trigger, and you know who dealt the damage that created the buff, but since this is a specific unit event, it's hard to use without Jass, because if you are creating and killing a lot of units in your map, you have to add a new "unit takes damage" event to a trigger for each unit you make, and you can't remove events, so this can eventually cause lag (in Jass, you can just dynamicaly create a trigger for each unit, and you can remove the whole trigger when the unit dies).
04-26-2006, 03:02 PM#7
StockBreak
Thank you very much! I used both Anitarf's and Vile's hints and I solved my problem!
04-26-2006, 05:14 PM#8
Panto
While opposed to any use of periodic triggers on principle, I have to admit, Anitarf, that's a pretty sexah solution.
04-26-2006, 09:45 PM#9
shadow1500
Well if you change your mind and want a more stable solution, you can always try my JASS script "Any unit is damaged", if you arent too expirienced with jass yet, you can send damage detect calls to your damage trigger, just replace the code in AnyUnitTakesDamage function with this
Collapse JASS:
function AnyUnitTakesDamage takes nothing returns nothing
    call TriggerExecute( gg_trg_<trig name here> )
endfunction
replace <trig name here> with the name of your damage detect trigger.

Read the instruction at that page if you arent sure on how to impliment this.