Forum

> > CS2D > Scripts > Bot following you
Forums overviewCS2D overview Scripts overviewLog in to reply

English Bot following you

10 replies
To the start Previous 1 Next To the start

old Bot following you

BrunoRZ
User Off Offline

Quote
Hi, I was trying to call a bot, by saying "come".
But I can't get the x and y position on say, I tried different ways, but there's something I may be missing.
     How can I do that ?


addhook("say","follow")
function follow(id,txt)
     if txt == "come" then
     ai_goto(2, (myposX), (myposY), 1)
     end
end

old ...

sheeL
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
addhook("Say","Followme")
function Followme(id,txt)
      if txt == "come" then
       x = player(id,"x")
       y = player(id,"y")
       for id = 1,32 do
       parse("setpos "..id.." "..x.." "..y)
	end
end

Untested , but is good idea
Follow bot is not pro, but in his position of SetPos

old Re: Bot following you

Apache uwu
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
addhook("say","_say")
addhook("always","_always")

parse("bot_add_t")
parse("mp_autoteambalance 0")

function _say(id,message,x,y)
	if id==1 then
		if player(1,"health")>0 then
			if message=="come" then
				vai_mode[2]=7
				vai_smode[2]=1
			end
		end
	end
end

function _always() --when the bot reaches you, it will stop following
	if vai_mode[2]==7 and vai_smode[2]==1 then
		if player(1,"tilex")==player(2,"tilex") and player(1,"tiley")==player(2,"tiley") then
			vai_mode[2]=0
			vai_smode[2]=0
		end
	end
end

You and the bot must be on terrorist team:
     Saying "come" will make the bot follow you until it reaches the same tile, then will continue.
     To change this and have the bot follow no matter what: remove the always hook and function.

old Re: Bot following you

BrunoRZ
User Off Offline

Quote
user Apache uwu has written
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
addhook("say","_say")
addhook("always","_always")

parse("bot_add_t")
parse("mp_autoteambalance 0")

function _say(id,message,x,y)
	if id==1 then
		if player(1,"health")>0 then
			if message=="come" then
				vai_mode[2]=7
				vai_smode[2]=1
			end
		end
	end
end

function _always() --when the bot reaches you, it will stop following
	if vai_mode[2]==7 and vai_smode[2]==1 then
		if player(1,"tilex")==player(2,"tilex") and player(1,"tiley")==player(2,"tiley") then
			vai_mode[2]=0
			vai_smode[2]=0
		end
	end
end

You and the bot must be on terrorist team:
     Saying "come" will make the bot follow you until it reaches the same tile, then will continue.
     To change this and have the bot follow no matter what: remove the always hook and function.


Thanks !
It's working, but is there any explanations possible about the 'vai_smode' ?
I still dont get that one

old Re: Bot following you

Apache uwu
User Off Offline

Quote
vai_mode is a table used to determine the state of the bot.

when mode is 7 an additional table must also be supplied with a number to indicate the player to follow.

old Re: Bot following you

BrunoRZ
User Off Offline

Quote
user Apache uwu has written
vai_mode is a table used to determine the state of the bot.

when mode is 7 an additional table must also be supplied with a number to indicate the player to follow.


And what is vai_Smode function ?

old Re: Bot following you

BrunoRZ
User Off Offline

Quote
If I want the bot to follow me 1tile on my left, I'll have to change something in the Standard Lua script ?

old Re: Bot following you

DC
Admin Off Offline

Quote
it was actually planned that you can control bots with radio commands that way. it's even in the bot Lua code already but it has a bug in 0.1.1.9 so it didn't work. it will work with the next release though

old Re: Bot following you

Apache uwu
User Off Offline

Quote
You will need to make your own bot ai, and rename Standard_AI.lua...

Look @ info.txt and search ai_
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview