Trigger help

NetherHawk

New Member
Reaction score
26
I have tried making an ability called Overload.

what it does: everytime the hero damages(via attacks) a unit, it stores lightning charges which after reaching limit, the charge is unleashed dealing damage to the attacked unit and surrounding others, slowing them down as well.

what i have tried to do: every time a hero learns this skill(a001), if a001 = 1
, create a trigger which registers when a unit is attacked.

from there, i have a filter that registers the attacking unit as this learning hero.

if it is the learning hero, i create another trigger to register when the attacked unit is damaged and subtract from the counter.

when the counter reaches 0 , i create a dummy to thunderclap(a000).

the problem im having is that nothing is happening in the game.

this is the trigger:
JASS:
function Overload_Jass_Conditions takes nothing returns boolean
    return GetLearnedSkill() == 'A001'
endfunction  

function Overload_Filter takes nothing returns boolean
    local trigger tr = GetTriggeringTrigger()
    local unit u = GetHandleUnit(tr,"caster")
    return GetAttacker() == u and IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(u)) == true
endfunction

function Overload_Check takes nothing returns boolean
    local trigger tx = GetTriggeringTrigger()
    local unit u = GetHandleUnit(tx,"caster")
    return GetEventDamageSource() == u
endfunction

function Overload_Recount takes nothing returns nothing
    local trigger tx = GetTriggeringTrigger()
    local unit ux = GetTriggerUnit()
    local unit u = GetEventDamageSource()
    local integer i = GetUnitAbilityLevel(u,'A001')
    local integer c = GetHandleInt(tx,"counter")
    local effect fx = GetHandleFX(tx,"effectx")
    local effect fy = GetHandleFX(tx,"effecty")
    local unit d
    
    set c = c - 1
    if c == 1 then
        set fx =  AddSpecialEffectTarget("Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl" ,u,"right + hand")
        set fy =  AddSpecialEffectTarget("Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl" ,u,"left + hand")
        call SetHandleHandle(tx,"effectx",fx)
        call SetHandleHandle(tx,"effecty",fy)
    else
        if c == 0 then
            call DestroyEffect(fx)
            call DestroyEffect(fy)
            set d = CreateUnit(GetOwningPlayer(u),'h000',GetUnitX(ux),GetUnitY(ux),bj_UNIT_FACING)
            call SetUnitAbilityLevel(d,'A000',i)
            call UnitApplyTimedLife(d,'BTLF',1)
            call IssueImmediateOrder(d,"thunderclap")
            set fx = null
            set fy = null
            set d = null
        endif
    endif
    set u = null
    set ux = null
    call DisableTrigger(tx)
    call DestroyTrigger(tx)
    set tx = null
endfunction
        
function Overload_Charge takes nothing returns nothing
    local trigger tr = GetTriggeringTrigger()
    local unit u = GetAttacker()
    local integer i = GetUnitAbilityLevel(u,'A001')
    local unit ux = GetTriggerUnit()
    local integer cx = 9 - i 
    local trigger tx = CreateTrigger()
    local integer c = GetHandleInt(tx,"counter")
    
    if c == 0 then
        set c = cx
    else
        call SetHandleInt(tx,"counter",c)
    endif 
    call SetHandleHandle(tx,"caster",u)        
    call TriggerRegisterUnitEvent(tx,ux,EVENT_UNIT_DAMAGED)
    call TriggerAddCondition(tx, Condition(function Overload_Check)) 
    call TriggerAddAction(tx, function Overload_Recount)   
    
    set u = null
    set ux = null
endfunction    
    

function Overload_Jass_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer i = GetUnitAbilityLevel(u,'A001')    
    local trigger tr 
                
    if i == 1 then
        set tr = CreateTrigger()
        call SetHandleHandle(tr,"caster",u)                 
        call TriggerRegisterAnyUnitEventBJ(tr,EVENT_PLAYER_UNIT_ATTACKED)
        call TriggerAddCondition(tr, Condition(function Overload_Filter)) 
        call TriggerAddAction(tr, function Overload_Charge)  
        set tr = null 
    endif   
    set u = null
endfunction

//===========================================================================
function InitTrig_Overload_Jass takes nothing returns nothing
    set gg_trg_Overload_Jass = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Overload_Jass, EVENT_PLAYER_HERO_SKILL)
    call TriggerAddCondition( gg_trg_Overload_Jass, Condition( function Overload_Jass_Conditions ) )
    call TriggerAddAction( gg_trg_Overload_Jass, function Overload_Jass_Actions )
endfunction
 

yes9111

New Member
Reaction score
8
Err... I haven't finished completely reading over the script but I think this may be the problem.

JASS:
function Overload_Jass_Conditions takes nothing returns boolean
    return GetLearnedSkill() == 'A001'
endfunction

JASS:

function InitTrig_Overload_Jass takes nothing returns nothing
    set gg_trg_Overload_Jass = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Overload_Jass, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Overload_Jass, Condition( function Overload_Jass_Conditions ) )
    call TriggerAddAction( gg_trg_Overload_Jass, function Overload_Jass_Actions )
endfunction


the event EVENT_PLAYER_UNIT_SPELL_EFFECT is equal to "Starts the effect of an ability" so GetLearnedSkill() won't work with this trigger...

Wait a mo' while I finish reading the script :)
 

NetherHawk

New Member
Reaction score
26
ahhh freak, cant believe i didnt see that...

thx man... im always making stupid mistakes like this. +rep
changed it to event hero skill

edit: still dosnt work =(
 

Sim

Forum Administrator
Staff member
Reaction score
534
> call DestroyTrigger(tx)

I believe that destroying the trigger in which you stored your handles is not the right thing to do right in the middle of your "handle loop".

How can you "GetHandleInt" c later on then? :p

Also, between every attack another trigger is created. What happens is that "c" will never reach 0, as it is always a "new" c.
 

NetherHawk

New Member
Reaction score
26
huh?
if you see carefully, i use the maximum number of attacks needed before the thunderclap is released as cx.
if c = 0, i set it to cx, otherwise, i leave it as the variable i stored in the function Recount.

let me try out a simpler action on the GetHandleInt thing, if im not wrong it should still work.

>> i found 1 error x.x the specialeffect was typed in for AddSpecialEffectTarget, i didnt remove the BJ from AddSpecialEffectTargetUnitBJ

EDIT: THX daxtreme , you were right.. destroying was the problem. so now i've attached the variables to the unit instead. Daxt, could you look at it again, this new one, and tell me if its MUI?

JASS:
function Overload_Jass_Conditions takes nothing returns boolean
    return GetLearnedSkill() == 'A001'
endfunction  

function Overload_Filter takes nothing returns boolean
    local trigger tr = GetTriggeringTrigger()
    local unit u = GetHandleUnit(tr,"caster")
    return GetAttacker() == u and IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(u)) == true
endfunction

function Overload_Check takes nothing returns boolean
    local trigger tx = GetTriggeringTrigger()
    local unit u = GetHandleUnit(tx,"caster")
    return GetEventDamageSource() == u
endfunction

function Overload_Recount takes nothing returns nothing
    local trigger tx = GetTriggeringTrigger()
    local unit u = GetHandleUnit(tx,"caster")
    local unit ux = GetTriggerUnit()
    local integer i = GetUnitAbilityLevel(u,'A001')
    local integer c = GetHandleInt(u,"counter")
    local effect fx = GetHandleFX(u,"effectx")
    local effect fy = GetHandleFX(u,"effecty")
    local unit d

    set c = c - 1  
    call SetHandleInt(u,"counter",c)
    if c == 1 then
        set fx =  AddSpecialEffectTarget("Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl" ,u,"right + hand")
        set fy =  AddSpecialEffectTarget("Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl" ,u,"left + hand")
        call SetHandleHandle(u,"effectx",fx)
        call SetHandleHandle(u,"effecty",fy)
    else
        if c == 0 then
            call DestroyEffect(fx)
            call DestroyEffect(fy)
            set d = CreateUnit(GetOwningPlayer(u),'h000',GetUnitX(ux),GetUnitY(ux),bj_UNIT_FACING)
            call SetUnitAbilityLevel(d,'A000',i)
            call UnitApplyTimedLife(d,'BTLF',1)
            call IssueImmediateOrder(d,"thunderclap")
            set fx = null
            set fy = null
            set d = null
        endif
    endif

    call DisableTrigger(tx)
    call DestroyTrigger(tx)
    set tx = null
endfunction
        
function Overload_Charge takes nothing returns nothing
    local trigger tx = CreateTrigger()
    local trigger tr = GetTriggeringTrigger()
    local unit ux = GetTriggerUnit()
    local unit u = GetHandleUnit(tr,"caster")
    local integer i = GetUnitAbilityLevel(u,'A001')
    local integer cx = 9 - i
    local integer c = GetHandleInt(u,"counter")

    if c == 0 then
        set c = cx
    endif 
    call SetHandleInt(u,"counter",c)
    call SetHandleHandle(tx,"caster",u)
    call TriggerRegisterUnitEvent(tx,ux,EVENT_UNIT_DAMAGED)
    call TriggerAddCondition(tx, Condition(function Overload_Check)) 
    call TriggerAddAction(tx, function Overload_Recount) 

    set u = null
    set ux = null  
endfunction    
    

function Overload_Jass_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer i = GetUnitAbilityLevel(u,'A001')    
    local trigger tr 
                  
    if i == 1 then
        set tr = CreateTrigger()
        call SetHandleHandle(tr,"caster",u)                 
        call TriggerRegisterAnyUnitEventBJ(tr,EVENT_PLAYER_UNIT_ATTACKED)
        call TriggerAddCondition(tr, Condition(function Overload_Filter)) 
        call TriggerAddAction(tr, function Overload_Charge)  
    endif   
    set u = null
endfunction

//===========================================================================
function InitTrig_Overload_Jass takes nothing returns nothing
    set gg_trg_Overload_Jass = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Overload_Jass, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddCondition( gg_trg_Overload_Jass, Condition( function Overload_Jass_Conditions ) )
    call TriggerAddAction( gg_trg_Overload_Jass, function Overload_Jass_Actions )
endfunction
 

Sim

Forum Administrator
Staff member
Reaction score
534
It looks like it is MUI, although only testing could really confirm this :rolleyes:

Give the spell to 2 different heroes and try to cast it at the same time.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top