Forum

> > CS2D > Scripts > Bot following you
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Bot following you

10 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Bot following you

BrunoRZ
User Off Offline

Zitieren
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

alt ...

sheeL
User Off Offline

Zitieren
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

alt Re: Bot following you

Apache uwu
User Off Offline

Zitieren
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.

alt Re: Bot following you

BrunoRZ
User Off Offline

Zitieren
user Apache uwu hat geschrieben
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

alt Re: Bot following you

Apache uwu
User Off Offline

Zitieren
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.

alt Re: Bot following you

BrunoRZ
User Off Offline

Zitieren
user Apache uwu hat geschrieben
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 ?

alt Re: Bot following you

BrunoRZ
User Off Offline

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

alt Re: Bot following you

DC
Admin Off Offline

Zitieren
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
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht