Hey , I'm new to jass and still learning , I could make some triggers but this one is not working for me,
We have two groups of units , each group belongs to an player enemy to the other , the goal is that a random dragonhawk unit in the player (0) group will leash a random unit from the other player(1) group
, also keep in mind that I made aerial shackles (maigcleash) able to target ground units , I added the ("if") to make sure they do not cast it right away and added PolledWait to make a cooldown since there are more than one dragonhawk that can also cast the spell.
We have two groups of units , each group belongs to an player enemy to the other , the goal is that a random dragonhawk unit in the player (0) group will leash a random unit from the other player(1) group
, also keep in mind that I made aerial shackles (maigcleash) able to target ground units , I added the ("if") to make sure they do not cast it right away and added PolledWait to make a cooldown since there are more than one dragonhawk that can also cast the spell.
JASS:
Code (vJASS)
function targetcond5 takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'hdhw' )
endfunction
function targetcond1 takes nothing returns boolean
return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction
function targetcond2 takes nothing returns boolean
return ( IsUnitEnemy(GetFilterUnit() , Player(0)) == true )
endfunction
function cand takes nothing returns boolean
return GetBooleanAnd( targetcond1(), targetcond2() )
endfunction
function targetcond3 takes nothing returns boolean
return ( IsUnitOwnedByPlayer(GetFilterUnit(), Player(0)))
endfunction
function cand2 takes nothing returns boolean
return GetBooleanAnd( targetcond3(), targetcond5() )
endfunction
function targetcond4 takes nothing returns boolean
return ( IsUnitOwnedByPlayer(GetAttackedUnitBJ(), Player(0)))
endfunction
function Trig_Skywrath_Mage_Actions takes nothing returns nothing
local group skms = CreateGroup()
local group atrtempg = CreateGroup()
local unit atemp = GetAttackedUnitBJ()
local location temploc = GetUnitLoc(atemp)
local real rcounter = GetRandomReal(1, 10)
call GroupEnumUnitsInRangeOfLoc(skms, temploc, 500, Condition(function cand2))
call GroupEnumUnitsInRangeOfLoc(atrtempg, temploc, 500, Condition(function cand))
if rcounter < 2.5 then
call IssueTargetOrderBJ(GroupPickRandomUnit(skms), "magicleash", GroupPickRandomUnit(atrtempg))
call DestroyGroup(skms)
call DestroyGroup(atrtempg)
call DisableTrigger(gg_trg_Skywrath_Mage)
call PolledWait(30)
call EnableTrigger(gg_trg_Skywrath_Mage)
endif
endfunction
function InitTrig_Skywrath_Mage takes nothing returns nothing
set gg_trg_Skywrath_Mage = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(gg_trg_Skywrath_Mage, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition(gg_trg_Skywrath_Mage, Condition(function targetcond4))
call TriggerAddAction( gg_trg_Skywrath_Mage, function Trig_Skywrath_Mage_Actions )
endfunction[code=jass]