- Joined
- Aug 26, 2016
- Messages
- 139
I wrote an attack system, it works great, but only one of the group of enemies near you receives damage, how can I do damage to the entire group of enemies near you?
JASS:
library CopperSwordMelee///1
function Attack_Filter takes nothing returns boolean
return not IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD)
endfunction
function Trig_CopperSword1_Actions takes nothing returns nothing
local unit u = udg_HeroBody[1]
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real f = GetUnitFacing(u) * bj_DEGTORAD
local player p = GetOwningPlayer(u)
local unit t
local real x2
local real y2
call SetUnitTimeScalePercent( udg_HeroBody[1], 290.00 )
call SetUnitAnimationByIndex(udg_HeroBody[1],GetRandomInt(1, 3))
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x ,y, 150+140, function Attack_Filter)
loop
set t = FirstOfGroup(bj_lastCreatedGroup)
exitwhen t == null
set x2 = GetUnitX(t)
set y2 = GetUnitY(t)
if IsUnitEnemy(t, p) and IsUnitInRangeXY(t, x, y, 110) and Cos(f-Atan2(y2-y, x2-x)) > 0 then
call UnitDamageTarget(u, t, 10, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_CLAW_HEAVY_SLICE)
call CameraSetTargetNoiseForPlayer( GetOwningPlayer(udg_HeroBody[1]),24.80, 7.60 )
call StopSoundBJ( gg_snd_m1hAxeHitFlesh1a, false )
call PlaySoundOnUnitBJ( gg_snd_m1hAxeHitFlesh1a, 50.00, GetSpellAbilityUnit() )
call GroupClear(bj_lastCreatedGroup)
else
call GroupRemoveUnit(bj_lastCreatedGroup, t)
endif
endloop
set u = null
set p = null
call TriggerSleepAction( 0.24 )
call SetUnitTimeScalePercent( udg_HeroBody[1], 100.00 )
call SetUnitAnimationByIndex(udg_HeroBody[1],udg_AnimTag[1])
endfunction
function Trig_CopperSword1_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A001' ) ) then
return false
endif
return true
endfunction
//===========================================================================
function InitTrig_CopperSword1 takes nothing returns nothing
local trigger t22 = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t22, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( t22, Condition( function Trig_CopperSword1_Conditions ) )
call TriggerAddAction( t22, function Trig_CopperSword1_Actions )
set t22 = null
endfunction
endlibrary