找回密码
 点一下
查看: 2577|回复: 10

怎样才能让不是电脑的玩家运行common.ai?

  [复制链接]
发表于 2007-9-5 14:45:34 | 显示全部楼层 |阅读模式
怎样才能让不是电脑的玩家运行common.ai?或者玩家离开游戏后在不改变所属的情况下,怎样才能让他变成电脑玩家?
发表于 2007-9-5 15:48:46 | 显示全部楼层
[codes=jass]
    local integer index
    local player  indexPlayer
    local race    indexRace

    set index = 0
    loop
        set indexPlayer = Player(index)
        if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
            set indexRace = GetPlayerRace(indexPlayer)
            if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
                // Run a race-specific melee AI script.
                if (indexRace == RACE_HUMAN) then
                    call PickMeleeAI(indexPlayer, "human.ai", null, null)
                elseif (indexRace == RACE_ORC) then
                    call PickMeleeAI(indexPlayer, "orc.ai", null, null)
                elseif (indexRace == RACE_UNDEAD) then
                    call PickMeleeAI(indexPlayer, "undead.ai", null, null)
                    call RecycleGuardPosition(bj_ghoul[index])
                elseif (indexRace == RACE_NIGHTELF) then
                    call PickMeleeAI(indexPlayer, "elf.ai", null, null)
                else
                    // Unrecognized race.
                endif
                call ShareEverythingWithTeamAI(indexPlayer)
            endif
        endif

        set index = index + 1
        exitwhen index == bj_MAX_PLAYERS
    endloop
[/codes]

以上是BJ里面的实现过程。楼主也可以参考一下。

大致意思就是判断是否是电脑玩家,如果是,就判断相应的种族,并且执行相应的AI。
回复

使用道具 举报

 楼主| 发表于 2007-9-5 16:22:08 | 显示全部楼层
不会写自定义脚本!! 能不能帮忙写个!
回复

使用道具 举报

发表于 2007-9-5 17:52:00 | 显示全部楼层
[codes=jass]function PickMeleeAI takes player num, string s1, string s2, string s3 returns nothing[/codes]

这个函数,需要测试下。
如果楼主对JASS有抵抗的种族特长,那么不要试了。
回复

使用道具 举报

发表于 2007-9-5 19:31:12 | 显示全部楼层
  [s:129]
回复

使用道具 举报

 楼主| 发表于 2007-9-6 14:15:18 | 显示全部楼层
引用第3楼蚊子叮于2007-09-05 17:52发表的  :
[codes=jass]function PickMeleeAI takes player num, string s1, string s2, string s3 returns nothing[/codes]

这个函数,需要测试下。
如果楼主对JASS有抵抗的种族特长,那么不要试了。



完全不明白!!能不能做个演示??
回复

使用道具 举报

发表于 2007-9-6 20:12:14 | 显示全部楼层
以下未经测试。

test.w3x

14 KB, 下载次数: 14

回复

使用道具 举报

 楼主| 发表于 2007-9-7 09:59:07 | 显示全部楼层
引用第6楼amp34于2007-09-06 20:12发表的  :
以下未经测试。



晕!!如果这样写有用的话早就可以了!!
回复

使用道具 举报

 楼主| 发表于 2007-9-7 10:11:00 | 显示全部楼层
call SetPlayerController( Player(3), MAP_CONTROL_COMPUTER )

这句怎样才能有效??
回复

使用道具 举报

发表于 2007-9-7 13:38:49 | 显示全部楼层
hmm。如果这样不行的话。偶也不是很清楚了呢。
因为偶也米有研究过AI的说。
回复

使用道具 举报

 楼主| 发表于 2007-9-7 17:35:09 | 显示全部楼层
这里好像没什么人啊
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-17 10:34 , Processed in 0.033227 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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