function Trig_Spell_BARB_Battle_Cry_Actions takes nothing returns nothing
local integer ilevel
local unit ucurr
local unit utarget = GetSpellTargetUnit()
local player powner
local location lpoint = GetUnitLoc( utarget )
local group gunits = GetUnitsInRangeOfLocAll(300.00, lpoint)
// Auto caster for the defense lowering ability
loop
set ucurr = FirstOfGroup(gunits)
exitwhen ucurr == null
call GroupRemoveUnit( gunits, ucurr )
set powner = GetOwningPlayer( ucurr )
if ( ( powner == Player(11 - 1) ) or ( powner == Player(12 - 1) ) ) then
// ! it's very important to check if unit is alive ! crashes otherwise
if ( IsUnitAliveBJ( ucurr ) ) then
set ilevel = GetUnitAbilityLevel( ucurr, 'A01N' )
if ( ilevel == 0 ) then
call UnitAddAbility( ucurr, 'A01N' )
elseif ( ilevel < 5 ) then
call IncUnitAbilityLevel( ucurr, 'A01N' )
endif
endif
endif
endloop
call RemoveLocation( lpoint )
call DestroyGroup( gunits )
call AddSpecialEffectTargetUnitBJ( "origin", GetTriggerUnit(), "Abilities\\Spells\\Other\\HowlOfTerror\\HowlTarget.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
// clean up local variable pointers
set lpoint = null
set gunits = null
set powner = null
set utarget = null
set ucurr = null
endfunction
function Trig_Spell_BARB_Battle_Cry_Conditions takes nothing returns boolean
return ( GetUnitTypeId(GetTriggerUnit()) == 'h005' )
endfunction
//===========================================================================
function InitTrig_Spell_BARB_Battle_Cry takes nothing returns nothing
set gg_trg_Spell_BARB_Battle_Cry = CreateTrigger( )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Spell_BARB_Battle_Cry, Player(0), EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Spell_BARB_Battle_Cry, Player(1), EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Spell_BARB_Battle_Cry, Player(2), EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Spell_BARB_Battle_Cry, Player(3), EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Spell_BARB_Battle_Cry, Player(4), EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Spell_BARB_Battle_Cry, Player(5), EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Spell_BARB_Battle_Cry, Player(6), EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Spell_BARB_Battle_Cry, Player(7), EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Spell_BARB_Battle_Cry, Condition( function Trig_Spell_BARB_Battle_Cry_Conditions ) )
call TriggerAddAction( gg_trg_Spell_BARB_Battle_Cry, function Trig_Spell_BARB_Battle_Cry_Actions )
endfunction