Added by jasonrus96
Накидал код на костюмную атаку, все работает норм но вот только урон получает только один юнит из группы врагов хотя вроде радиус указан чтоб
цепляло взмахом нескольких, подскажите где ошибка пж.
цепляло взмахом нескольких, подскажите где ошибка пж.
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
Accepted answer
jasonrus96, удали эту строку, else тоже удали, а удаление юнита перенеси после endif, готово, не зависнет.
Uploaded files
`
LOADING AD...
To leave a comment please sign in to the site.
Edited by konvan5
Edited by jasonrus96
И поэтому чистить группу тоже нельзя во время перебора, ибо мы тогда не чекнем остальных юнитов, что были в группе на этот момент.