|
发表于 2009-11-14 13:38:55
|
显示全部楼层
楼主可以试下这个演示。
利用Jass的timer来报时。
当然实际情况下不要用这么笨的办法,用sleep计时即可。这里只是介绍下jass和AI的通讯方式。
[trigger]
Init AI
Events
Map initialization
Conditions
Actions
AI - Start melee AI script for Player 2 (Blue): war3mapImported\\1.ai
[/trigger]
[trigger]
Send Command
Events
Time - Elapsed game time is 20.00 seconds
Conditions
Actions
AI - Send Player 2 (Blue) the AI Command (1, 1)
[/trigger]
1.ai的内容:
[jass]
function main takes nothing returns nothing
call Sleep( 2.0 )
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,1,"Hallo World")
loop
if (GetLastCommand()==1 and GetLastData()==1) then //获得从JASS来的上一个AI命令。
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,1,"Hello World")
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,1,"Over")
call PopLastCommand() //将命令出栈,否则GetLastCommand()永远都是1,这样就会循环显示了。
endif
call Sleep( 1.0 )
endloop
endfunction
[/jass] |
|