Warcraft III resources & community, 2003–2006 · archived
How to make 'backstab' ability like the one in dota
14 posts
13lack.1)ragon
#1
How to make 'backstab' ability like the one in dota
As the title says, id like to know how to do the ability with all the triggers. I don't want it to be a hero spell, just a unit spell that all my herooes have. I want it to do 50% more damage (150% dmg) to targets in the back. TY for any help
Events A unit is attacked Conditions (((Facing of (Attacked unit)) - 45.00) - (Facing of (Attacking unit))) Less than or equal to 90.00 Actions Make Attacking unit damage Attacked unit for X damage. There's probably a better way to do this, like, a lot better way, but this is what came to mind first. --donut3.5--
if a = facing angle of attacker and b = facing angle of target
a - b < 90 and a - b > 270 OR a - b > -90 and a - b < -270
EDIT: just realized i worded the list badly; the "and"s should actually be "or"s
13lack.1)ragon
#5
how/where do i find the 'facing' of the unit in the triggers in conditions. I searched for a long time and couldnt find. is it in the unit category? integer? sry if this sounds noobish.
Azn ricepuff i didnt understand what you wrote and its true that donut's method doesnt work (not properly at least) I made two footmen fight each other with one on the upper-left side and the other on the bottom-right left side. The bottom footman wasnt scoring any 'backstabs' (like hes supposed to) but the top one was, even if he was fighting him ehad on. Need more help on this topic, or explain aznricepuffs method.
wait, wait! He want their units to deal 1.5x damage, and not to damage a fix ammount. So you'll need the attack damage detection system that we've discussed before in an other topic (you see, PurplePoot, this is an exactly ideal situation to detect attack damage, and not all type of damage ) To get the angle difference, you must subrtact the two angles from each other, BUT BE SURE TO SUBTRACT THE LESSER ANGLE FROM THE GREATER ONE.
function DifferanceBetweenAngles takes real alpha, real beta returns real
if alpha > beta then
return alpha - beta
endif
return beta-alpha
endfunction
function Trig_Damage_Event_Conditions takes nothing returns boolean
return GetEventDamageSource() == GetHandleUnit(GetTriggeringTrigger(), "Attacker")
endfunction
function Trig_Damage_Event takes nothing returns nothing
local trigger t = GetTriggeringTrigger()
call UnitDamageTarget(GetEventDamageSource(), GetTriggerUnit(), GetEventDamage()/2, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null)
call FlushHandleLocals(t)
call DestroyTrigger(t)
set t = null
endfunction
function Trig_Damage_Conditions takes nothing returns boolean
return DifferanceBetweenAngles(GetUnitFacing(GetAttacker()), GetUnitFacing(GetTriggerUnit())) < 45
endfunction
function Trig_Damage_Actions takes nothing returns nothing
local trigger t = CreateTrigger()
call SetHandleHandle(t, "Attacker", GetAttacker())
call TriggerRegisterUnitEvent( t, GetTriggerUnit(), EVENT_UNIT_DAMAGED )
call TriggerAddCondition(t, Condition( function Trig_Damage_Event_Conditions))
call TriggerAddAction( t, function Trig_Damage_Event )
call TriggerSleepAction(1)
call FlushHandleLocals(t)
call DestroyTrigger(t)
set t = null
endfunction
//====================================================================
function InitTrig_Damage takes nothing returns nothing
set gg_trg_Damage = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Damage, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_Damage , Condition( function Trig_Damage_Conditions))
call TriggerAddAction( gg_trg_Damage, function Trig_Damage_Actions )
endfunction
Legal question! It was my mistake. In this case, both subtraction gives good values, only the angle intervals change from [0,40] to [-20,20]. BUT what if we want to detect a unit in front of an other one. It's not the same: a = 90 b = 180 =>They are facing each other -> a-b = -90 -> b-a = 90 You cannot add an exact interval.
But you are right. There's no need to check here which one is greater, but then set the intervals exactly.