HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Auto-casting 'Block' ability

01-07-2007, 04:48 PM#1
vedath
I wish for an ability to base my custom skill off of which will be auto-casted when a unit is attacked, but has not yet sustained damage. I want the unit casting the ability to be protected from a single blow, then have to wait for the cooldown of the ability to finish before it can protect again. I've tried Plane Shift, but it seems to only activate AFTER a unit has been hit. Any ideas or suggestions?
01-07-2007, 04:56 PM#2
Taur
well you could always base it on some random autocast ability, like searing arrows or something, and then cast it when the unit is attacked.
01-07-2007, 05:11 PM#3
rulerofiron99
The only thing I can think of is that the unit takes the damage but the unit is then instantly healed by the damage amount. This will work fine until you have 15 hp and you are attacked and the spell should block the damage, and you die...
01-07-2007, 05:43 PM#4
oNdizZ
it will even work beyond that ruleroffireon99, just give the hero/unit a life bonus ability (on Unit Takes Damage) with a value higher than any possible attack, 1k or so, then heal and finally remove the life bonus.
01-07-2007, 06:15 PM#5
rulerofiron99
I've never quite tried this before, but will that ability be acquired before the damage is actually dealt?

PS: it's ruler of iron, not ruler of fire on.
01-07-2007, 06:39 PM#6
vedath
Good calls everyone; I've thought about the 'heal the same amount of damage inflicted' many times, but the problem is calculating the health difference without a 0.03 constant timer monitoring HP changes. The life bonus seems plausible, but again, I can't calculate the damage. On this map, three strikes to your unit may result in a death, so this skill is very important. Thanks; please continue to suggest things.
01-07-2007, 06:58 PM#7
rulerofiron99
Use the Unit - Damage Taken event so that you can get the exact damage.

How to use it for multiple units:

Make 2 triggers, one for initialization and one that runs each time a new unit enters the map. those triggers should add to your trigger the event Triggering unit / Picked unit takes damage, so in this way you can detect the exact damage taken.
01-07-2007, 07:10 PM#8
oNdizZ
Quote:
Originally Posted by rulerofiron99
I've never quite tried this before, but will that ability be acquired before the damage is actually dealt?

PS: it's ruler of iron, not ruler of fire on.

yes, Unit Takes Damage fires before the damage is actually dealt.
Sorry about the mistake regarding your nick :)
01-07-2007, 07:17 PM#9
vedath
Hmm. Do any of you guys know of an auto-cast spell that's right before damage is taken then?
01-07-2007, 08:14 PM#10
Pyrogasm
How about using a modified Frost armor that gives a ton of armor and has a duration of ~5 seconds (if there are any units with long attack range/slow projectiles in your map)? It'd even not do anything against a spell, as a block should.
Attack Register:
Collapse Events
Unit - A unit is attacked
Collapse Conditions
<If you have any conditions regarding different levels/what units have this ability, put them here>
Collapse Actions
Unit - Order (Attacked Unit) to (Undead Lich - Frost Armor) (Attacked Unit) [That won't fire if the spell is still cooling down]
Buff Remove:
Collapse Events
Unit - <Your unit/variable [since this isn't an "any unit" function]> takes damage
Conditions
Collapse Actions
Wait 0.05 Game-Time seconds [this may or may not be needed]
Unit - Remove (Block Buff) from (Triggering Unit)
The only two problems with this being that
1) the buff will go away if a unit deals damage with a spell to the unit with the block spell while it has the buff, and
2) There'll be ugly green numbers in the armor area when the ability fires.

There are some advantages:
1) Easily configurable SFX options
2) Easy way to make it not work if the spell is still cooling down
3) No messy damage taken calculation and the sort
4) It won't fire when a unit takes damage from a spell.

Maybe I've been helpful...
01-07-2007, 08:40 PM#11
vedath
Thanks Pyrogasm, but I was wondering if there was any way to only 'block' when a spell is set to auto-cast. Is there such a way to detect auto-cast? Can I change cooldown by any means (besides natives editing)?
01-08-2007, 12:02 AM#12
Pyrogasm
Quote:
Originally Posted by vedath
Thanks Pyrogasm, but I was wondering if there was any way to only 'block' when a spell is set to auto-cast. Is there such a way to detect auto-cast? Can I change cooldown by any means (besides natives editing)?
There is a way to detect when autocast is turned on for a spell. Check the orderId's for the spell and find the strings used for "autocast on/off". I think the frost armor one is "Froston" and "Frostoff". Just use an order check when the unit is issued an order to see if the autocast is turned on.

If you're talking about detecting when a spell is cast via autocast, there's nothing to it. It just registers as a regular cast via the "A unit starts the effect of an ability" event.

And what do you mean by "Can I change Cooldown by any means"? You can change the cooldown in the object editor...
01-08-2007, 12:19 AM#13
Pheonix-IV
I was going to suggest using Hardened Skin, but if you want it to autocast then you're still going to need the damage triggers.