Сделал систему опыта, иногда работает нестабильно в чем проблема?
function Trig_SystemExperience_Actions takes nothing returns nothing
    local unit dead = GetDyingUnit()
    local integer level = GetUnitLevel(dead)
    local real xdead = GetUnitX(dead)
    local real ydead = GetUnitY(dead)
    local group groupAct = CreateGroup()
    local integer i = 0
    local integer exp = level * 35 + GetRandomInt(1,12)
    local unit u
    
    if IsUnitType(dead, UNIT_TYPE_SUMMONED) == true then
        set exp = exp / 2
    endif
    
    call GroupEnumUnitsInRange(groupAct,xdead, ydead, 1350, null)
    loop
        set u = FirstOfGroup(groupAct)
        exitwhen u == null
        if GetWidgetLife(u) > 0.405 and IsUnitEnemy(u, GetOwningPlayer(dead)) and IsUnitType(u, UNIT_TYPE_HERO) then
            set i = i + 1
            call GroupAddUnit(groupAct, u)
        endif
        call GroupRemoveUnit(groupAct, u)
    endloop
    set u = null
    
    set exp = exp / i

    call GroupEnumUnitsInRange(groupAct, xdead, ydead, 1350, null)
    loop
        set u = FirstOfGroup(groupAct)
        exitwhen u == null
        if GetWidgetLife(u) > 0.405 and IsUnitEnemy(u, GetOwningPlayer(dead)) and IsUnitType(u, UNIT_TYPE_HERO) then
            call AddHeroXP(u, exp, true)
            call GroupRemoveUnit(groupAct, u)
        endif
        set u = null
    endloop
    call DestroyGroup(groupAct)
    
    set groupAct = null
    set u = null
    set dead = null
endfunction

function Trig_SystemExperience_Conditions takes nothing returns boolean
    return IsUnitType(GetDyingUnit(),UNIT_TYPE_STRUCTURE) == false
endfunction

function InitTrig_SystemExperience takes nothing returns nothing
    set gg_trg_SystemExperience = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_SystemExperience, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_SystemExperience, Condition( function Trig_SystemExperience_Conditions ) )
    call TriggerAddAction( gg_trg_SystemExperience, function Trig_SystemExperience_Actions )
endfunction

попробуй этот код, я не знаю
код
globals
    constant group TempG   = CreateGroup( )
    constant group TempG_1 = CreateGroup( )
    player TempPlayer = null
endglobals

native UnitAlive takes unit id returns boolean

function Trig_SystemExperience_Actions takes nothing returns nothing
    local unit dead   = GetTriggerUnit( )
    local real xdead  = GetUnitX( dead )
    local real ydead  = GetUnitY( dead )
    local integer i   = 0
    local integer exp = GetUnitLevel( dead ) * 35 + GetRandomInt( 1, 12 )
    local unit u
    
    set TempPlayer = GetOwningPlayer( dead )
    
    if IsUnitType( dead, UNIT_TYPE_SUMMONED ) then
        set exp = exp / 2
    endif
    
    call GroupEnumUnitsInRange( TempG, xdead, ydead, 1350.00, null )
    
    loop
        set u = FirstOfGroup( TempG )
        exitwhen u == null
        call GroupRemoveUnit( TempG, u )
        
        if UnitAlive( u ) and IsUnitEnemy( u, TempPlayer ) and IsUnitType( u, UNIT_TYPE_HERO ) then
            call GroupAddUnit( TempG_1, u )
            set i = i + 1
        endif
    endloop
    
    set exp = exp / i
    
    loop
        set u = FirstOfGroup( TempG_1 )
        exitwhen u == null
        call GroupRemoveUnit( TempG_1, u )
        
        call AddHeroXP( u, exp, true )
        call GroupRemoveUnit( TempG_1, u )
    endloop
    
    set dead = null
endfunction

function Trig_SystemExperience_Conditions takes nothing returns boolean
    return not IsUnitType( GetTriggerUnit( ), UNIT_TYPE_STRUCTURE )
endfunction

function InitTrig_SystemExperience takes nothing returns nothing
    set gg_trg_SystemExperience = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_SystemExperience, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_SystemExperience, Condition( function Trig_SystemExperience_Conditions ) )
    call TriggerAddAction( gg_trg_SystemExperience, function Trig_SystemExperience_Actions )
endfunction
`
ОЖИДАНИЕ РЕКЛАМЫ...
28
    call GroupEnumUnitsInRange(groupAct, xdead, ydead, 1350, null)
    loop
        set u = FirstOfGroup(groupAct)
        exitwhen u == null
        if GetWidgetLife(u) > 0.405 and IsUnitEnemy(u, GetOwningPlayer(dead)) and IsUnitType(u, UNIT_TYPE_HERO) then
            call AddHeroXP(u, exp, true)
            call GroupRemoveUnit(groupAct, u)
        endif
        set u = null
    endloop
    call DestroyGroup(groupAct)
бесконечный цикл может произойти если юнит не прошёл условия, да и банальное страдание логики тут наблюдается, к примеру зачем выставлять null после этого цикла переменной u, если условие выхода из цикла: u == null?

ну как бесконечный, этот цикл прервётся от оп лимита

как и все последующие действия
28
попробуй этот код, я не знаю
код
globals
    constant group TempG   = CreateGroup( )
    constant group TempG_1 = CreateGroup( )
    player TempPlayer = null
endglobals

native UnitAlive takes unit id returns boolean

function Trig_SystemExperience_Actions takes nothing returns nothing
    local unit dead   = GetTriggerUnit( )
    local real xdead  = GetUnitX( dead )
    local real ydead  = GetUnitY( dead )
    local integer i   = 0
    local integer exp = GetUnitLevel( dead ) * 35 + GetRandomInt( 1, 12 )
    local unit u
    
    set TempPlayer = GetOwningPlayer( dead )
    
    if IsUnitType( dead, UNIT_TYPE_SUMMONED ) then
        set exp = exp / 2
    endif
    
    call GroupEnumUnitsInRange( TempG, xdead, ydead, 1350.00, null )
    
    loop
        set u = FirstOfGroup( TempG )
        exitwhen u == null
        call GroupRemoveUnit( TempG, u )
        
        if UnitAlive( u ) and IsUnitEnemy( u, TempPlayer ) and IsUnitType( u, UNIT_TYPE_HERO ) then
            call GroupAddUnit( TempG_1, u )
            set i = i + 1
        endif
    endloop
    
    set exp = exp / i
    
    loop
        set u = FirstOfGroup( TempG_1 )
        exitwhen u == null
        call GroupRemoveUnit( TempG_1, u )
        
        call AddHeroXP( u, exp, true )
        call GroupRemoveUnit( TempG_1, u )
    endloop
    
    set dead = null
endfunction

function Trig_SystemExperience_Conditions takes nothing returns boolean
    return not IsUnitType( GetTriggerUnit( ), UNIT_TYPE_STRUCTURE )
endfunction

function InitTrig_SystemExperience takes nothing returns nothing
    set gg_trg_SystemExperience = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_SystemExperience, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_SystemExperience, Condition( function Trig_SystemExperience_Conditions ) )
    call TriggerAddAction( gg_trg_SystemExperience, function Trig_SystemExperience_Actions )
endfunction
Принятый ответ
Чтобы оставить комментарий, пожалуйста, войдите на сайт.