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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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