请选择 进入手机版 | 继续访问电脑版

 找回密码
 点一下
查看: 1200|回复: 8

AI的debug函数如何使用?

[复制链接]
发表于 2014-2-4 07:41:58 | 显示全部楼层 |阅读模式
表示除了用DisplayTextToPlayer外都显示不了文本啊。。
而AI脚本里又不能使用I2S这种东西,这样debug的难度一下子就上了好几个台阶啊……

比如:
call DisplayText(0, "123")或者call DisplayText(1, "123")我都试过
我以玩家1的身份开游戏然后神马都显示不了
是参数有问题么。。还是这些函数本来就有bug
发表于 2014-2-5 13:19:49 | 显示全部楼层

  1. function Trace takes string message returns nothing
  2.     if trace_on then
  3.         call DisplayText(GetAiPlayer(),message)
  4.     endif
  5. endfunction

  6. //============================================================================
  7. function TraceI takes string message, integer val returns nothing
  8.     if trace_on then
  9.         call DisplayTextI(GetAiPlayer(),message,val)
  10.     endif
  11. endfunction

  12. //============================================================================
  13. function TraceII takes string message, integer v1, integer v2 returns nothing
  14.     if trace_on then
  15.         call DisplayTextII(GetAiPlayer(),message,v1,v2)
  16.     endif
  17. endfunction

  18. //============================================================================
  19. function TraceIII takes string message, integer v1, integer v2, integer v3 returns nothing
  20.     if trace_on then
  21.         call DisplayTextIII(GetAiPlayer(),message,v1,v2,v3)
  22.     endif
  23. endfunction
复制代码

这些不可以嘛?
回复

使用道具 举报

发表于 2014-2-5 13:35:09 | 显示全部楼层
本帖最后由 夜の星 于 2014-2-5 14:08 编辑

DisplayText系列的确好诡异...不管是直接调用还是按ls说的用包装过的Trace,都没法在游戏或者replay里面看到文本...
不知道是不是哪里有个开关之类的呢...

I2S似乎是无解,也没办法像j中声明native GetUnitGoldCost一样的方式进行调用...

不过既然是debug用,那么还是有解决方案的~没有I2S函数就自己造一个嘛...
毕竟ai脚本里面,还是支持 "cirno"+"_"+"baka"="cirno_baka"这种字符串连接操作的~
globals
    string array digit
endglobals

function init_digits takes nothing returns nothing
    set digit[0]="0"
    set digit[1]="1"
    set digit[2]="2"
    set digit[3]="3"
    set digit[4]="4"
    set digit[5]="5"
    set digit[6]="6"
    set digit[7]="7"
    set digit[8]="8"
    set digit[9]="9"
endfunction

function my_i2s takes integer i returns string
    local boolean sign=true
    local string s=""
    if (i<0) then
        set i=-i
        set sign=false
    endif
    loop
        set s=digit[i-i/10*10]+s
        set i=i/10
        exitwhen i<=0
    endloop
    if (not sign) then
        set s="-"+s
    endif
    return s
endfunction

function test_func takes nothing returns nothing
    local integer i=-120
    loop
        set i=i+1
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, my_i2s(i))
        call Sleep(0.05)
    endloop
endfunction

function main takes nothing returns nothing
    call init_digits()
    call StartThread(function test_func)
endfunction
话说回来...为什么不直接在war3map.j里面写ai呢...ai函数本身又不怎么好用,尤其是和其他系统的交互之类的又极其麻烦...

点评

好复杂的样子...不知道有没有更好的方法呢.... 对AI函数不是很熟悉呢....  详情 回复 发表于 2014-2-5 14:08
回复

使用道具 举报

发表于 2014-2-5 14:08:42 | 显示全部楼层
夜の星 发表于 2014-2-5 13:35
DisplayText系列的确好诡异...不管是直接调用还是按ls说的用包装过的Trace,都没法在游戏或者replay里面看 ...

好复杂的样子...不知道有没有更好的方法呢....
对AI函数不是很熟悉呢....

点评

同不熟悉...翻了下common.ai...发现自带的一些函数有奇怪的写法: function ReformUntilTargetDead takes unit target returns nothing debug call Trace("ReformUntilTargetDead\n") call CommonSleepUn  详情 回复 发表于 2014-2-5 14:20
回复

使用道具 举报

发表于 2014-2-5 14:27:13 | 显示全部楼层
同不熟悉...翻了下common.ai...发现自带的一些函数有奇怪的写法:
function ReformUntilTargetDead takes unit target returns nothing
    debug call Trace("ReformUntilTargetDead\n")
    call CommonSleepUntilTargetDead(target,true)
endfunction
试了下没成功...不知道是不是和玩家有关...
回复

使用道具 举报

发表于 2014-2-5 19:21:03 | 显示全部楼层
在ai代码中用
回复

使用道具 举报

 楼主| 发表于 2014-2-5 22:59:58 | 显示全部楼层
夜の星 发表于 2014-2-5 13:35
DisplayText系列的确好诡异...不管是直接调用还是按ls说的用包装过的Trace,都没法在游戏或者replay里面看 ...

因为写的是常规对战AI,就是魔兽自带的AI那种,倒不是说不能写到.j里,而是要跟暴雪的做法统一
回复

使用道具 举报

 楼主| 发表于 2014-2-5 23:10:28 | 显示全部楼层
又试了下发现
DoAiScriptDebug
这货返回false。。

根据前辈的帖子,这函数是返回“AI脚本是否允许显示文本”的,但是似乎没试出过返回true
回复

使用道具 举报

发表于 2014-2-5 23:15:33 | 显示全部楼层
DoAiScriptDebug 返回 false +1
所以说不清楚是不是哪里有开关(war3启动的命令行?),或许debug call的奇怪写法和这个有关的说...

对战AI的话,用ai脚本还是非常方便的呢...
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-3-28 19:36 , Processed in 0.198757 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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