• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Anyway to make Defend useful against ALL types of damage?

Status
Not open for further replies.
Level 4
Joined
Jan 1, 2008
Messages
99
Defend currently only mitigates piercing damage, but is it possible to make it defend against ALL types of damage?
 
Level 20
Joined
Oct 21, 2006
Messages
3,231
Unit is issued order

Or - any conditions is true:
Issued order equal to defend
Issued order equal to undefend

If issued order equal to defend then:
Add ability Item Armor Bonus (+5)
Else:
Remove ability Item armor bonus (+5)

Now it reduces dmg when used.
 
Level 13
Joined
May 11, 2008
Messages
1,198
well...you could try something like the ability i just made for my new map i'm making...

you have to choose the unit that takes damage in the trigger, which would mean you make a trigger that gets you your hero and then tags the trigger with it, or else you get your hero the normal way and you make the trigger tag the trigger with the specific unit.
an example would be...

events
a unit trains a unit
conditions
trained unit equal to footman hero
actions
trigger add event to trigger: footmandefendtrigger trained unit takes damage

and again...
events
a unit sells a unit
conditions
sold unit equal to footman hero
actions
trigger add event to trigger: footmandefendtrigger sold unit takes damage

or this...
events
a unit changes ownership
conditions
ownership-changed unit equal to footman hero
actions
trigger add event to trigger: footmandefendtrigger ownership-changed unit takes damage

and there are a lot more ways to get your hero, just do it like that.

then you make the trigger something like this:
JASS:
function Trig_dmgdodgeskill_Actions takes nothing returns nothing
local integer i
//the first three ifs check if the ability has been learned yet,
//and levels up the trigger along with the hero ability
//the return there makes the trigger end if the ability is still
//level zero, in other words it isn't learned yet
    if GetUnitAbilityLevelSwapped('A00V', GetTriggerUnit()) == 1 then
    set i =GetRandomInt(1,200)
    else
    if GetUnitAbilityLevelSwapped('A00V', GetTriggerUnit()) == 2 then
    set i =GetRandomInt(31,200)
    else
    if GetUnitAbilityLevelSwapped('A00V', GetTriggerUnit()) == 3 then
    set i =GetRandomInt(61,200)
    else
    return
    endif
    endif
    endif
    if i >= 191 then
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + GetEventDamage() ) )
    else
    if i >= 181 and i < 191 then
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + ( GetEventDamage() * 0.50 ) ) )
    else
    if i >= 171 and i < 181 then
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + GetEventDamage() ) )
    call UnitDamageTargetBJ( GetTriggerUnit(), GetEventDamageSource(), ( GetEventDamage() * 1.00 ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
    else
    if i >= 161 and i < 171 then
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + GetEventDamage() ) )
    call UnitDamageTargetBJ( GetTriggerUnit(), GetEventDamageSource(), ( GetEventDamage() * 2.00 ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
    else
    if i >= 151 and i < 161 then
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + ( GetEventDamage() * 0.75 ) ) )
    call UnitDamageTargetBJ( GetTriggerUnit(), GetEventDamageSource(), ( GetEventDamage() * 3.00 ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
    else
    if i >= 141 and i < 151 then
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + GetEventDamage() ) )
    call UnitDamageTargetBJ( GetTriggerUnit(), GetEventDamageSource(), ( GetEventDamage() * 0.50 ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
    else
    if i >= 131 and i < 141 then    
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + ( GetEventDamage() * 0.50 ) ) )
    call UnitDamageTargetBJ( GetTriggerUnit(), GetEventDamageSource(), ( GetEventDamage() * 4.00 ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
    else
    if i >= 121 and i < 131 then    
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + ( GetEventDamage() * 0.25 ) ) )
    else
    if i >= 111 and i < 121 then    
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + ( GetEventDamage() * 0.75 ) ) )
    endif
    endif
    endif
    endif
    endif
    endif
    endif
    endif
    endif
endfunction

//===========================================================================
function InitTrig_dmgdodgeskill takes nothing returns nothing
    set gg_trg_dmgdodgeskill = CreateTrigger(  )
    call TriggerAddAction( gg_trg_dmgdodgeskill, function Trig_dmgdodgeskill_Actions )
endfunction
[/HIDDEN]
the 'A00U' is the raw data id of the ability. the one i'm using is evasion, and i set it's levels to 5% 6% and 7% evasion it's an ultimate ability so the numbers are a bit high. here's the tooltips:

Gives a percent chance to avoid damage in one of 10 ways:
Way 1 - Block out all the damage.
Way 2 - Block out 0.5x of the damage.
Way 3 - Block out 0.25x of the damage.
Way 4 - Block out 0.75x of the damage.
Way 5 - Deflect it back at the source.
Way 6 - Deflect it back at the source at 2x speed.
Way 7 - Deflect it back at the source at 3x speed, taking 0.25x damage.
Way 8 - Deflect it back at the source at 4x speed, taking 0.5x damage.
Way 9 - Deflect it back at the source at 0.5x speed.
Way 10 - Evade the attack.
Level 1 - 5% Level 2 - 6% Level 3 - 7%


level one tooltip:
Gives a 45% chance to defend or deflect an attack, and an extra 5% chance for an attack to miss completely.

by the way it is designed to be an ultimate ability, so 50-70 percent isn't that big of a deal especially considering some of those he still takes some damage. if you need movement speed reduction i suggest making a separate trigger that turns this trigger on and off when you defend. i'm not sure what the events would be but try message debugging for that. it might be what supersheep mentioned, i'm not sure, you can always put an action that displays a message to you in the game to test the ability to make sure the events and conditions are compatible, that's message debugging. anyway it's most likely gonna be either order or an ability so try all that.

keep in mind the above trigger could probably be rewritten to be more effecient than it is, perhaps it has too many function calls or something like that. any opinions?

at any rate my ability is a bit complex and it probably isn't exactly what you're looking for, but hopefully it will give you some ideas. oh and i hope you can read some jass.

another thing to keep in mind about this ability i made up is that it doesn't actually redirect the attack like defend does. in other words a footman can kill a wind rider with his own poison attack but this just attacks with a simple chaos attack no matter what attack was thrown at them.

i'm totally open to someone coming along and improving the ability of course. i just came up with a simple but crude concept that works. if no one else improves it i will eventually.
 
Last edited:
Level 4
Joined
Jan 1, 2008
Messages
99
well...you could try something like the ability i just made for my new map i'm making...

you have to choose the unit that takes damage in the trigger, which would mean you make a trigger that gets you your hero and then tags the trigger with it, or else you get your hero the normal way and you make the trigger tag the trigger with the specific unit.
an example would be...

events
a unit trains a unit
conditions
trained unit equal to footman hero
actions
trigger add event to trigger: footmandefendtrigger trained unit takes damage

and again...
events
a unit sells a unit
conditions
sold unit equal to footman hero
actions
trigger add event to trigger: footmandefendtrigger sold unit takes damage

or this...
events
a unit changes ownership
conditions
ownership-changed unit equal to footman hero
actions
trigger add event to trigger: footmandefendtrigger ownership-changed unit takes damage

and there are a lot more ways to get your hero, just do it like that.

then you make the trigger something like this:
JASS:
function Trig_dmgdodgeskill_Actions takes nothing returns nothing
local integer i
//the first three ifs check if the ability has been learned yet,
//and levels up the trigger along with the hero ability
//the return there makes the trigger end if the ability is still
//level zero, in other words it isn't learned yet
    if GetUnitAbilityLevelSwapped('A00V', GetTriggerUnit()) == 1 then
    set i =GetRandomInt(1,200)
    else
    if GetUnitAbilityLevelSwapped('A00V', GetTriggerUnit()) == 2 then
    set i =GetRandomInt(31,200)
    else
    if GetUnitAbilityLevelSwapped('A00V', GetTriggerUnit()) == 3 then
    set i =GetRandomInt(61,200)
    else
    return
    endif
    endif
    endif
    if i >= 191 then
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + GetEventDamage() ) )
    else
    if i >= 181 and i < 191 then
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + ( GetEventDamage() * 0.50 ) ) )
    else
    if i >= 171 and i < 181 then
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + GetEventDamage() ) )
    call UnitDamageTargetBJ( GetTriggerUnit(), GetEventDamageSource(), ( GetEventDamage() * 1.00 ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
    else
    if i >= 161 and i < 171 then
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + GetEventDamage() ) )
    call UnitDamageTargetBJ( GetTriggerUnit(), GetEventDamageSource(), ( GetEventDamage() * 2.00 ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
    else
    if i >= 151 and i < 161 then
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + ( GetEventDamage() * 0.75 ) ) )
    call UnitDamageTargetBJ( GetTriggerUnit(), GetEventDamageSource(), ( GetEventDamage() * 3.00 ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
    else
    if i >= 141 and i < 151 then
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + GetEventDamage() ) )
    call UnitDamageTargetBJ( GetTriggerUnit(), GetEventDamageSource(), ( GetEventDamage() * 0.50 ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
    else
    if i >= 131 and i < 141 then    
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + ( GetEventDamage() * 0.50 ) ) )
    call UnitDamageTargetBJ( GetTriggerUnit(), GetEventDamageSource(), ( GetEventDamage() * 4.00 ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
    else
    if i >= 121 and i < 131 then    
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + ( GetEventDamage() * 0.25 ) ) )
    else
    if i >= 111 and i < 121 then    
    call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + ( GetEventDamage() * 0.75 ) ) )
    endif
    endif
    endif
    endif
    endif
    endif
    endif
    endif
    endif
endfunction

//===========================================================================
function InitTrig_dmgdodgeskill takes nothing returns nothing
    set gg_trg_dmgdodgeskill = CreateTrigger(  )
    call TriggerAddAction( gg_trg_dmgdodgeskill, function Trig_dmgdodgeskill_Actions )
endfunction
[/HIDDEN]
the 'A00U' is the raw data id of the ability. the one i'm using is evasion, and i set it's levels to 5% 6% and 7% evasion it's an ultimate ability so the numbers are a bit high. here's the tooltips:

Gives a percent chance to avoid damage in one of 10 ways:
Way 1 - Block out all the damage.
Way 2 - Block out 0.5x of the damage.
Way 3 - Block out 0.25x of the damage.
Way 4 - Block out 0.75x of the damage.
Way 5 - Deflect it back at the source.
Way 6 - Deflect it back at the source at 2x speed.
Way 7 - Deflect it back at the source at 3x speed, taking 0.25x damage.
Way 8 - Deflect it back at the source at 4x speed, taking 0.5x damage.
Way 9 - Deflect it back at the source at 0.5x speed.
Way 10 - Evade the attack.
Level 1 - 5% Level 2 - 6% Level 3 - 7%


level one tooltip:
Gives a 45% chance to defend or deflect an attack, and an extra 5% chance for an attack to miss completely.

by the way it is designed to be an ultimate ability, so 50-70 percent isn't that big of a deal especially considering some of those he still takes some damage. if you need movement speed reduction i suggest making a separate trigger that turns this trigger on and off when you defend. i'm not sure what the events would be but try message debugging for that. it might be what supersheep mentioned, i'm not sure, you can always put an action that displays a message to you in the game to test the ability to make sure the events and conditions are compatible, that's message debugging. anyway it's most likely gonna be either order or an ability so try all that.

keep in mind the above trigger could probably be rewritten to be more effecient than it is, perhaps it has too many function calls or something like that. any opinions?

at any rate my ability is a bit complex and it probably isn't exactly what you're looking for, but hopefully it will give you some ideas. oh and i hope you can read some jass.

another thing to keep in mind about this ability i made up is that it doesn't actually redirect the attack like defend does. in other words a footman can kill a wind rider with his own poison attack but this just attacks with a simple chaos attack no matter what attack was thrown at them.

i'm totally open to someone coming along and improving the ability of course. i just came up with a simple but crude concept that works. if no one else improves it i will eventually.


Intresting, I'm reviewing this right now.
 
Status
Not open for further replies.
Top