找回密码
 点一下
查看: 1857|回复: 0

[求解]关于触发创建

[复制链接]
发表于 2007-9-16 11:55:37 | 显示全部楼层 |阅读模式
我写的像DOTA野外刷兵.
下面红字的地方该怎么优化啊!?
---------------------------
function RefreshUnit takes real x, real y returns nothing
local group tempgroup = CreateGroup()
local integer randomi
local integer unitloop
local integer array unitid
local integer array unitcount
local integer unitloop = 0
call GroupEnumUnitsInRange(tempgroup,x,y,600,null)
if FirstOfGroup(tempgroup) == null then
set randomi = GetRandomInt(1, 7)        
set unitid[5] = 'nspr'
set unitid[6] = 'nspr'
set unitid[7] = 'nspr'
set unitid[8] = 'nsgt'
set unitid[9] = 'nogm'
set unitid[10] = 'nogm'
set unitid[11] = 'nomg'
set unitid[13] = 'nwlg'
set unitid[14] = 'nwlg'
set unitid[15] = 'nwlg'
set unitid[17] = 'nban'
set unitid[18] = 'nban'
set unitid[19] = 'nban'
set unitid[20] = 'nrog'
set unitid[21] = 'nkob'
set unitid[22] = 'nkob'
set unitid[23] = 'nkot'
set unitid[24] = 'nkol'
set unitid[25] = 'ncnk'
set unitid[26] = 'ncen'
set unitid[29] = 'nfra'
set unitid[30] = 'nfrg'
set unitcount [1] = 4
set unitcount [2] = 3
set unitcount [3] = 3
set unitcount [4] = 4
set unitcount [5] = 4
set unitcount [6] = 2
set unitcount [7] = 2
loop
    set unitloop = unitloop + 1
    exitwhen unitloop > unitcount[randomi]
    call CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), unitid[unitloop+(randomi*4)], x, y, 0)
endloop
endif
call DestroyGroup( tempgroup )
set tempgroup = null
endfunction

function Trig_RefreshUnit_Actions takes nothing returns nothing
    local real array x
    local real array y
    local integer Loop = 0
    set x[1] = GetRectCenterX(gg_rct_RectA)
    set x[2] = GetRectCenterX(gg_rct_RectB)
    set x[3] = GetRectCenterX(gg_rct_RectC)
    set x[4] = GetRectCenterX(gg_rct_RectD)
    set x[5] = GetRectCenterX(gg_rct_RectE)
    set x[6] = GetRectCenterX(gg_rct_RectF)
    set x[7] = GetRectCenterX(gg_rct_RectG)
    set x[8] = GetRectCenterX(gg_rct_RectH)
    set x[9] = GetRectCenterX(gg_rct_RectI)
    set x[10] = GetRectCenterX(gg_rct_RectJ)
    set x[11] = GetRectCenterX(gg_rct_RectK)
    set x[12] = GetRectCenterX(gg_rct_RectL)
    set x[13] = GetRectCenterX(gg_rct_RectM)
    set x[14] = GetRectCenterX(gg_rct_RectN)
    set x[15] = GetRectCenterX(gg_rct_RectO)
    set x[16] = GetRectCenterX(gg_rct_RectP)
    // y
    set y[1] = GetRectCenterY(gg_rct_RectA)
    set y[2] = GetRectCenterY(gg_rct_RectB)
    set y[3] = GetRectCenterY(gg_rct_RectC)
    set y[4] = GetRectCenterY(gg_rct_RectD)
    set y[5] = GetRectCenterY(gg_rct_RectE)
    set y[6] = GetRectCenterY(gg_rct_RectF)
    set y[7] = GetRectCenterY(gg_rct_RectG)
    set y[8] = GetRectCenterY(gg_rct_RectH)
    set y[9] = GetRectCenterY(gg_rct_RectI)
    set y[10] = GetRectCenterY(gg_rct_RectJ)
    set y[11] = GetRectCenterY(gg_rct_RectK)
    set y[12] = GetRectCenterY(gg_rct_RectL)
    set y[13] = GetRectCenterY(gg_rct_RectM)
    set y[14] = GetRectCenterY(gg_rct_RectN)
    set y[15] = GetRectCenterY(gg_rct_RectO)
    set y[16] = GetRectCenterY(gg_rct_RectP)
    // loop
    loop
        set Loop = Loop + 1
        exitwhen Loop > 16
        call RefreshUnit(x[Loop],y[Loop])
    endloop
endfunction

//===========================================================================
function InitTrig_RefreshUnit takes nothing returns nothing
    set gg_trg_RefreshUnit = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_RefreshUnit, 120.00 )
    call TriggerAddAction( gg_trg_RefreshUnit, function Trig_RefreshUnit_Actions )
endfunction
您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-11-22 20:40 , Processed in 0.352427 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表