通常测试时候是需要加入一些机器人的。那么在workshop中如何加入呢?

与bot相关的几个函数

int GetConnectionState(int iPlayerID)

Returns a status code indication the connection state of the player. 0 - no connection. 1 - bot connected. 2 - player connected. 3 bot/player disconnected.

bool IsControllableByAnyPlayer()

Is this unit controlled by any non-bot player?

bool IsOwnedByAnyPlayer()

Is this unit owned by any non-bot player?

void SetBotDifficulty(int nDifficulty)

Sets the bot's difficulty level (0 = passive, 1 = easy, 2 = medium, 3 = hard, 4 = unfair)

bool AddBot(string string_1, string string_2, string string_3, bool bool_4)

Add a computer controlled bot.

AddBot用法

这里面比较重要的就是AddBot方法了。
string_1 = 英雄单位的名字(默认的和自定义应该都是可以的)
string_2 = 英雄位置(mid, top, bot)三条线的分路
string_3 = passive/positive ??
bool_4 = 这个表示是否和玩家为队友,但可以不在一个阵营

如果要设置阵营,需要调用

PlayerResource:SetCustomTeamAssignment( 0, DOTA_TEAM_GOODGUYS )
PlayerResource:SetCustomTeamAssignment( 1, DOTA_TEAM_GOODGUYS )

当然,我可以枚举上面的组合来达到一下效果:同阵营队友,同阵营非队友,不同阵营队友,不同阵营非队友之类。

最终效果,不通阵营的队友,互相不能攻击