|
问题如下面脚本注释,不清楚这个让主线程休眠的方法或函数是什么。虽然AI的函数我自己全部重写了,按照自己的思路来实现进攻等操作但是还是想弄清楚这个东东。
- //===========================================================================
- // 这个是发动攻击的函数,执行到此函数后,循环进攻的函数将会休眠,直到进攻结束
- //===========================================================================
- function AttackTarget takes unit target, boolean addAlliance returns nothing
- if (target == null) then
- return
- endif
- if (addAlliance) then
- call SetAllianceTarget( target )
- endif
- call FormGroup( 3, false )
- call AttackMoveKillA( target )
- if (not addAlliance) then
- call SetAllianceTarget( null )
- endif
- endfunction
复制代码 贴出我怀疑的调用的两个函数
- //===========================================================================
- // 一个是FormGroup函数
- //===========================================================================
- function FormGroup takes integer seconds,boolean testReady returns nothing
- local integer index
- local integer count
- local integer unitid
- local integer desire
- local integer readyPercent
- if testReady == true then
- set readyPercent = 50
- call Trace("forming group, requiring healthy guys\n") //xxx
- else
- set readyPercent = 0
- call Trace("forming group, unit health not important\n") //xxx
- endif
- call Trace("trying to gather forces\n") //xxx
- loop
- call SuicideSleep(seconds)
- call InitAssault()
- set index = 0
- loop
- exitwhen index == harass_length
- set unitid = harass_units[index]
- set desire = harass_max[index]
- set count = TownCountDone(unitid)
- call Conversions(desire,unitid)
- if count >= desire then
- call AddAssault(desire,unitid)
- else
- set desire = harass_qty[index]
- if count < desire then
- call AddAssault(desire,unitid)
- else
- call AddAssault(count,unitid)
- endif
- endif
- set index = index + 1
- endloop
- if form_group_timeouts and (sleep_seconds < -60) then
- call Trace("exit form group -- timeout\n")
- elseif CaptainInCombat(true) then
- call Trace("exit form group -- can't form while already in combat\n")
- elseif CaptainIsFull() and CaptainReadiness() >= readyPercent then
- call Trace("exit form group -- ready\n")
- endif
- exitwhen form_group_timeouts and (sleep_seconds < -60)
- exitwhen CaptainInCombat(true)
- exitwhen CaptainIsFull() and CaptainReadiness() >= readyPercent
- endloop
- endfunction
- //===========================================================================
- // 另一个是AttackMoveKillA函数
- //===========================================================================
- function AttackMoveKillA takes unit target returns nothing
- if target == null then
- call SuicideSleep(3)
- return
- endif
- debug call Trace("AttackMoveKillA\n")
- call AttackMoveKill(target)
- call ReformUntilTargetDead(target)
- call SleepInCombat()
- endfunction
复制代码 有兴趣的朋友一起讨论一下,顺便交流写AI的心得,虽然我对AI研究还不深,望高手请教。呵呵··
|
|