• 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.

[JASS] Get 2 triggers into 1

Status
Not open for further replies.
Hi guys, i have a small problem. I have 2 simple triggers but i want to put them into 1 trigger. I want to use "Call Add Event" but i don't know how that works.
Anyway here they are:

trigger 1:
JASS:
function LightningAttack_Conds takes nothing returns boolean
    return GetItemTypeId(GetManipulatedItem()) == 'I012'
endfunction
//================================================================
function LightningAttack_Acts takes nothing returns nothing
    local group Targets = CreateGroup()  
    local unit vic 
    local unit caster = GetTriggerUnit() 
    local unit dummy 
    call GroupEnumUnitsInRange( Targets, GetUnitX( caster ), GetUnitY( caster ), 600, Filter(null) )  
    loop  
        set vic = FirstOfGroup( Targets )  
        exitwhen vic==null  
        if IsUnitAlly(vic, GetOwningPlayer(caster)) then  
            set dummy = CreateUnit(GetOwningPlayer(caster), 'h01H', GetUnitX(vic), GetUnitY(vic), 0)  
            call UnitAddAbility(dummy, 'A046')  
            call IssueTargetOrder(dummy, "innerfire", vic)  
            call UnitApplyTimedLife(dummy, 'BTLF', 2.5)
        endif  
        call GroupRemoveUnit(Targets,vic)  
    endloop  
    call DestroyGroup(Targets) 
    call SetUnitExploded(dummy, true)  
    set Targets = null  
    set caster = null   
    set dummy = null 
endfunction 
//===========================================================================
function InitTrig_Lightning_Attack_Cast takes nothing returns nothing
    local trigger LightningAttack = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( LightningAttack, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddCondition( LightningAttack, Condition( function LightningAttack_Conds) )
    call TriggerAddAction( LightningAttack, function LightningAttack_Acts )
    set LightningAttack = null
endfunction

trigger 2:
JASS:
function LightningAttackDamage_Conds takes nothing returns boolean
    local integer Dchance = 5
    return GetUnitAbilityLevel(GetAttacker(), 'B02G')>0 and GetRandomInt(1, 100)<= Dchance
endfunction
//==========================================================================
function LightningAttackDamage_Acts takes nothing returns nothing
    local unit att = GetAttacker()
    local unit dum = CreateUnit( GetOwningPlayer(att), 'h01H', GetUnitX(att), GetUnitY(att), 0) 
    call UnitApplyTimedLife(dum, 'BTLF', 2.5)
    call UnitAddAbility(dum, 'A045')
    call IssueTargetOrder(dum, "chainlightning", GetTriggerUnit())
    call SetUnitExploded(dum, true)
    set att = null
    set dum = null
endfunction
//===========================================================================
function InitTrig_Lightning_Attack_Damage takes nothing returns nothing
    local trigger LightningAttackDamage = CreateTrigger() 
    call TriggerRegisterAnyUnitEventBJ( LightningAttackDamage, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( LightningAttackDamage, Condition( function LightningAttackDamage_Conds ) )
    call TriggerAddAction( LightningAttackDamage, function LightningAttackDamage_Acts )
    set LightningAttackDamage = null
endfunction

The 1st trigger is fired when the unit uses the item. All units are picked and a buff is give to them.
The second trigger sets a chance to cast an ability, to the units who have that same buff.

I don't like using buffs because they don't stack ... Is there any other solution ?? Can i get these 2 triggers together ?
 
Thx by the tip but, i already know about that script and about that tutorial, and unfortunately i can't use it because i don't understand it and i don't know how it works =S. Anyway if i did that using that method i wouldn't be able to have the icon in the bottom of the unit (i think) and therefore i wouldn't be able to dispel the buff, making this way the spell unbalanced.

Another i know these two triggers are very different, but if i fuse them i will actually save some space from memory correct ?
By the way, is it important that two triggers must have stuff in common so i can fuse them??? is it possible for me to fuse these two triggers ??
 
Level 9
Joined
Mar 25, 2005
Messages
252
There is no reason why you couldnt have buffs ("the icon in the bottom of the unit") when using local handle vars.

What do you mean by fusing? Do you want to have both triggers inside 1 trigger? If thats the case you can do this:

combined trigger:
JASS:
function LightningAttack_Conds takes nothing returns boolean
    return GetItemTypeId(GetManipulatedItem()) == 'I012'
endfunction
//================================================================
function LightningAttack_Acts takes nothing returns nothing
    local group Targets = CreateGroup()
    local unit vic
    local unit caster = GetTriggerUnit()
    local unit dummy
    call GroupEnumUnitsInRange( Targets, GetUnitX( caster ), GetUnitY( caster ), 600, Filter(null) )
    loop
        set vic = FirstOfGroup( Targets )
        exitwhen vic==null
        if IsUnitAlly(vic, GetOwningPlayer(caster)) then
            set dummy = CreateUnit(GetOwningPlayer(caster), 'h01H', GetUnitX(vic), GetUnitY(vic), 0)
            call UnitAddAbility(dummy, 'A046')
            call IssueTargetOrder(dummy, "innerfire", vic)
            call UnitApplyTimedLife(dummy, 'BTLF', 2.5)
        endif
        call GroupRemoveUnit(Targets,vic)
    endloop
    call DestroyGroup(Targets)
    call SetUnitExploded(dummy, true)
    set Targets = null
    set caster = null
    set dummy = null
endfunction
function LightningAttackDamage_Conds takes nothing returns boolean
    local integer Dchance = 5
    return GetUnitAbilityLevel(GetAttacker(), 'B02G')>0 and GetRandomInt(1, 100)<= Dchance
endfunction
//==========================================================================
function LightningAttackDamage_Acts takes nothing returns nothing
    local unit att = GetAttacker()
    local unit dum = CreateUnit( GetOwningPlayer(att), 'h01H', GetUnitX(att), GetUnitY(att), 0)
    call UnitApplyTimedLife(dum, 'BTLF', 2.5)
    call UnitAddAbility(dum, 'A045')
    call IssueTargetOrder(dum, "chainlightning", GetTriggerUnit())
    call SetUnitExploded(dum, true)
    set att = null
    set dum = null
endfunction
//===========================================================================
function InitTrig_Lightning_Attack_Cast takes nothing returns nothing
    local trigger LightningAttack = CreateTrigger(  )
    local trigger LightningAttackDamage = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( LightningAttack, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddCondition( LightningAttack, Condition( function LightningAttack_Conds) )
    call TriggerAddAction( LightningAttack, function LightningAttack_Acts )
    set LightningAttack = null
    call TriggerRegisterAnyUnitEventBJ( LightningAttackDamage, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( LightningAttackDamage, Condition( function LightningAttackDamage_Conds ) )
    call TriggerAddAction( LightningAttackDamage, function LightningAttackDamage_Acts )
    set LightningAttackDamage = null
endfunction

You can copy paste this inside 1 trigger and it should work.
 
OMG DiscipleOfLife this is EXACTLY what i wanted... REALLY THANK... thx to you my JASS knowledge was greatly improved.
But now i am confused ... you say that i can have a normal buff with Handle Vars ... and that buff can be normally dispelled ... I am interested in learning how as long as the buff doesn't have any stacking problems with other warcraft spells.
 
Level 9
Joined
Mar 25, 2005
Messages
252
[jass=Well you just need to check if the unit still has the buff before you do any actions]if UnitHasBuffBJ(whichUnit, buffcode) then
endif[/code]
[jass=or]if GetUnitAbilityLevel(whichUnit, buffcode) > 0 then
endif[/code]
...and if the unit doesnt have the buff, you just do whatever you would normally do when the spell ends, ie. flush handle vars and destroy the trigger/timer.
 
mm i don't understand what you mean .... Imagine this situation: A unit has inner Fire, and i will cast upon that same unit another ability, a different, but that is based in inner fire. Well, because those 2 abilities have the same string firing code ("innerfire") they will not stack properly and one will replace the other or there will be an error and both abilities will be removed.

With this situation, is it possible to make those two spells properly ??? And if the unit has the two buffs is it possible to make them be removed probably with the 1st buff affect the 2nd and vice-versa ?
 
Level 9
Joined
Mar 25, 2005
Messages
252
-- because those 2 abilities have the same string firing code ("innerfire") they will not stack properly and one will replace the other or there will be an error and both abilities will be removed. --

Where did you get that idea from?

With this situation, is it possible to make those two spells properly ??? And if the unit has the two buffs is it possible to make them be removed probably with the 1st buff affect the 2nd and vice-versa ?

Yes.
 
What i mean is that if you cast innerfire on a unit, and after that a spell based on innner fire, those spells won't stack properly. My question is if i can change that.

And the idea, is no idea, is a fact. Just use the w3 object editor to see what i mean. the buffs can be different but because the main spell is the same, they will never stack properly (already tried that).

Acan that be fixed by using handle vars ?
 
Status
Not open for further replies.
Top