HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Impale as Arrows

06-11-2006, 11:30 PM#1
st33m
I have an ability, Impale, which is an ability based off of Frost Arrows that shoots impale. What this trigger does is when a unit is attacked it checks for the buff, and then shoots impale. The problem is, it does not work. Any ideas?

Trigger:
Impale
Collapse Events
Unit - A unit Is attacked
Conditions
Collapse Actions
Set ImpaleTarget = (Attacked unit)
Set ImpaleCaster = (Attacking unit)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(ImpaleTarget has buff Impale (Custom) ) Equal to True
Collapse Then - Actions
Unit - Create 1 Dummy Unit for (Owner of ImpaleCaster) at (Position of ImpaleCaster) facing Default building facing degrees
Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
Unit - Add Impale (Dummy) to (Last created unit)
Unit - Order (Last created unit) to Undead Crypt Lord - Impale ((Position of ImpaleTarget) offset by 400.00 towards (Facing of ImpaleCaster) degrees)
Else - Actions
06-11-2006, 11:42 PM#2
Naakaloh
The events for a unit being attacked and taking damage are different, so the trigger is probably firing before the buff is applied.
06-12-2006, 12:06 AM#3
st33m
So I should use takes damage?
06-12-2006, 01:00 AM#4
TaintedReality
Yes. You might even need to add a 0.01 second timer (or wait, although timer would look much smoother) after they take damage to make sure they have the buff. I'm not sure if damage or the buff is applied first, so try it out.
06-12-2006, 01:17 AM#5
st33m
Will attacking and attacked unit still work?
06-12-2006, 02:54 AM#6
Naakaloh
Possibly, but there should be a Damaging and DamagedUnit or somethings like those.
06-12-2006, 02:57 AM#7
st33m
Erm, there is no unit takes damage that I can find.
06-12-2006, 06:48 AM#8
Naakaloh
Trigger:
Events
Unit - No unit Takes damage

It's a Specific Unit Event, so yes, JASS in order to create the trigger. You could actually do something like.

Collapse Impale Example Code:

function Impale_OrderCast takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit source = GetEventDamageSource()
    local unit caster = CreateUnit( GetOwningPlayer(source), [CASTER-RAWCODE], GetUnitX(source), GetUnitY(source), 0 )
    local trigger trig = GetTriggeringTrigger()

    if( (GetUnitAbilityLevel(whichUnit, [IMPALEBUFF-RAWCODE]) > 0) )
        call UnitAddAbility( caster, [IMPALE-RAWCODE] )
        call IssuePointOrder( caster, "impale", GetUnitX(u), GetUnitY(u) )
    endif

    call RemoveUnit( caster )
    call DestroyTrigger( trig )
    set u = null
    set source = null
    set caster = null
endfunction

function Impale_DamageCheck takes nothing returns nothing
    local unit u = GetAttackedUnit()
    local trigger trig = CreateTrigger()
    
    call TriggerAddAction( trig, function Impale_OrderCast )
    call TriggerRegisterUnitEvent( trig, u, EVENT_UNIT_DAMAGED )

    set u = null
    set trig = null
endfunction

function InitTrig_Impale takes nothing reutrns nothing
    set gg_trg_Impale = CreateTrigger()

    call TriggerRegisterAnyUnitEventBJ( gg_trg_Impale, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddAction( gg_trg_Impale, function Impale_DamageCheck )
endfunction

That's just and example, I didn't take the time to actually try it, but something like that should do it. Also if the attack ends up not dealing damage the trigger will still exist, so you'll probably want a timer that will clean up that trigger if it doesn't fire in a set amount of time.
06-12-2006, 09:39 AM#9
blu_da_noob
Naakaloh's method, while not the best, will work for general intents and purposes (although it does 'leak' a dummy, because it is never killed/removed). It also has a potential leak in the trigger action not being removed (I actually want to check if that is necessary).
06-12-2006, 05:11 PM#10
MysticGeneral
Quote:
Impale, which is an ability based off of Frost Arrows that shoots impale.

If the ability is based off of Frost Arrows, then why are you issuing the order of Impale?
06-12-2006, 05:14 PM#11
Rising_Dusk
Blu, yes the triggeraction will leak.
06-12-2006, 06:27 PM#12
blu_da_noob
I know that trigger actions are supposed to leak, I was just saying I want to test to confirm that.