找回密码
 点一下
查看: 1285|回复: 6

可以这样写吗?

[复制链接]
发表于 2008-3-10 18:52:50 | 显示全部楼层 |阅读模式
function InitTrig_Change takes nothing returns nothing
    local integer I
    set I = 1
    set gg_trg_Change = CreateTrigger()
    loop
           exitwhen I>20
           call TriggerRegisterEnterRectSimple( gg_trg_Change, udg_Location[I] )
           set I = I + 1
    endloop
    call TriggerAddAction( gg_trg_Change, function Trig_Change_Actions )
endfunction

我可以这样写吗?
发表于 2008-3-10 18:56:14 | 显示全部楼层
貌似这样写的话,初始的时候Location数组都是空的吧,我觉得是无效的~~

这个完全能用触发完成的呀,在地图初始化的时候对那些点变量数组赋值,然后为Change触发添加事件就好了吧
回复

使用道具 举报

 楼主| 发表于 2008-3-10 19:12:03 | 显示全部楼层
谢谢。那么是不是下面的代码有问题?
[jass]
function Trig_Change_Actions takes nothing returns nothing
    local integer I
    local integer J
    set I = 1
    set J = 1
    loop
        exitwhen I> 20
        if ( RectContainsUnit(udg_Location[I], GetTriggerUnit()) == true ) then
            loop
                exitwhen J>5
                if ( GetOwningPlayer(GetTriggerUnit()) == Player(J-1) ) then
                    if ( Conditions(J-1,I)) then
                        call RemoveUnit( GetTriggerUnit() )
                        call CreateNUnitsAtLoc( 1, String2UnitIdBJ(udg_Hero_name[I]), Player(J-1), GetRectCenter(gg_rct_Location021), bj_UNIT_FACING )
                        call PanCameraToTimedLocForPlayer( Player(J-1), GetRectCenter(gg_rct_Location021), 0.50 )
                    else
                        call Directions(Player(J-1),I)
                    endif
                endif
                set J = J + 1
            endloop
        endif
        set I = I + 1        
    endloop
endfunction
[/jass]
其中Conditions()和Directions()都是自定义函数,udg_Hero_name[]和udg_Location数组已经定义。
回复

使用道具 举报

发表于 2008-3-10 19:25:09 | 显示全部楼层
额,似乎记得哪里看到过String2UnitIdBJ函数已经失效了………………
回复

使用道具 举报

 楼主| 发表于 2008-3-10 19:41:02 | 显示全部楼层
有没有一个可以替代的函数?
回复

使用道具 举报

发表于 2008-3-10 19:51:32 | 显示全部楼层
要自己写………………

参考一下
回复

使用道具 举报

 楼主| 发表于 2008-3-10 19:58:22 | 显示全部楼层
谢谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

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

GMT+8, 2024-7-9 01:13 , Processed in 0.029661 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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