Здравствуйте, здесь 4 однотипных кода для 4 сторон на карте, код дублируется но переменные разные. Я постарался учесть многие утечки, но вопрос, будет ли утечка при добавлении одной группы юнитов в другую? и как правильно вычистить все утечки оттуда.
function Trig_CreepsCenter1_Actions takes nothing returns nothing
local group deter1
local group insp1
local group absorb1
local group destr1
local group deter11
local group insp11
local group absorb11
local group destr11
local location detloc1
local location insploc1
local location absorbloc1
local location destrloc1
set detloc1 = Location(0, 5300)
set insploc1 = Location(-5300, 0)
set absorbloc1 = Location(0, -5300)
set destrloc1 = Location(5300, 0)
call CreateNUnitsAtLoc( 1, 'o000', Player(0), detloc1, 0 )
set deter1 = GetLastCreatedGroup()
call DestroyGroup( GetLastCreatedGroup() )
call CreateNUnitsAtLoc( 1, 'o001', Player(0), detloc1, 0 )
set deter11 = GetLastCreatedGroup()
call DestroyGroup( GetLastCreatedGroup() )
call GroupAddGroup( deter11, deter1 )
call GroupPointOrderLocBJ( deter1, "attack", absorbloc1 )
call DestroyGroup( deter1 )
call DestroyGroup( deter11 )
set deter1 = null
set deter11 = null
call CreateNUnitsAtLoc( 1, 'h000', Player(1), insploc1, 0 )
set insp1 = GetLastCreatedGroup()
call DestroyGroup( GetLastCreatedGroup() )
call CreateNUnitsAtLoc( 1, 'h001', Player(1), insploc1, 0 )
set insp11 = GetLastCreatedGroup()
call DestroyGroup( GetLastCreatedGroup() )
call GroupAddGroup( insp11, insp1 )
call GroupPointOrderLocBJ( insp1, "attack", destrloc1 )
call DestroyGroup( insp1 )
call DestroyGroup( insp11 )
set insp1 = null
set insp11 = null
call CreateNUnitsAtLoc( 1, 'n000', Player(3), absorbloc1, 0 )
set absorb1 = GetLastCreatedGroup()
call DestroyGroup( GetLastCreatedGroup() )
call CreateNUnitsAtLoc( 1, 'n001', Player(3), absorbloc1, 0 )
set absorb11 = GetLastCreatedGroup()
call DestroyGroup( GetLastCreatedGroup() )
call GroupAddGroup( absorb11, absorb1 )
call GroupPointOrderLocBJ( absorb1, "attack", detloc1 )
call DestroyGroup( absorb1 )
call DestroyGroup( absorb11 )
set absorb1 = null
set absorb11 = null
call CreateNUnitsAtLoc( 1, 'u000', Player(6), destrloc1, 0 )
set destr1 = GetLastCreatedGroup()
call DestroyGroup( GetLastCreatedGroup() )
call CreateNUnitsAtLoc( 1, 'u001', Player(6), destrloc1, 0 )
set destr11 = GetLastCreatedGroup()
call DestroyGroup( GetLastCreatedGroup() )
call GroupAddGroup( destr11, destr1 )
call GroupPointOrderLocBJ( destr1, "attack", insploc1 )
call DestroyGroup( destr1 )
call DestroyGroup( destr11 )
set destr1 = null
set destr1 = null
call RemoveLocation(detloc1)
call RemoveLocation(insploc1)
call RemoveLocation(absorbloc1)
call RemoveLocation(destrloc1)
set detloc1 = null
set insploc1 = null
set absorbloc1 = null
set destrloc1 = null
endfunction
//===========================================================================
function InitTrig_CreepsCenter1 takes nothing returns nothing
set gg_trg_CreepsCenter1 = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_CreepsCenter1, 1.00 )
call TriggerAddAction( gg_trg_CreepsCenter1, function Trig_CreepsCenter1_Actions )
endfunction
Принятый ответ
globals
constant integer Order_attack = 851983
endglobals
function CreateCreepByTypeIdAndSend takes p player, integer id, real x, real y, real dx, real dy returns nothing
local unit u = CreateUnit(p, id, x, y, 0.)
call IssuePointOrderById(u, Order_attack, dx, dy) // Можно упростить и сделать как у ScopteRectuS
set u = null
endfunction
function Trig_CreepsCenter1_Actions takes nothing returns nothing
call CreateCreepByTypeIdAndSend(Player(0), 'o000', 0., 5300., 0., -5300.)
call CreateCreepByTypeIdAndSend(Player(0), 'o001', 0., 5300., 0., -5300.)
call CreateCreepByTypeIdAndSend(Player(1), 'h000', -5300., 0., 5300., 0.)
call CreateCreepByTypeIdAndSend(Player(1), 'h001', -5300., 0., 5300., 0.)
call CreateCreepByTypeIdAndSend(Player(3), 'n000', 0., -5300., 0., 5300.)
call CreateCreepByTypeIdAndSend(Player(3), 'n001', 0., -5300., 0., 5300.)
call CreateCreepByTypeIdAndSend(Player(6), 'u000', 5300., 0., -5300., 0.)
call CreateCreepByTypeIdAndSend(Player(6), 'u001', 5300., 0., -5300., 0.)
endfunction
function InitTrig_CreepsCenter1 takes nothing returns nothing
set gg_trg_CreepsCenter1 = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_CreepsCenter1, 1.00 )
call TriggerAddAction( gg_trg_CreepsCenter1, function Trig_CreepsCenter1_Actions )
endfunction
Нужно 40 одинаковых юнитов - циклы и массивы в помощь.
`
ОЖИДАНИЕ РЕКЛАМЫ...
Чтобы оставить комментарий, пожалуйста, войдите на сайт.
Отредактирован scopterectus
Отредактирован VVelikolepniy
Отредактирован PT153
Потому что я сначала присваиваю в переменную группу, а потом удаляю то, что я присваивал в эту группу
PT153:
не p player, а player p ))
обьясни плиз что это за цифры constant integer Order_attack = 851983