• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How to make 'backstab' ability like the one in dota

Status
Not open for further replies.
Level 7
Joined
Dec 17, 2005
Messages
337
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.
 
Level 11
Joined
Jul 12, 2005
Messages
764
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.
JASS:
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
I haven't tested it...
 
Level 11
Joined
Jul 12, 2005
Messages
764
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.
 
Status
Not open for further replies.
Top