Forum

> > CS2D > Scripts > how to use ai_build
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch how to use ai_build

25 Antworten
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

alt Re: how to use ai_build

DannyDeth
User Off Offline

Zitieren
@DragonAwper:
But what do you want to do? How can we help you if all you did was post some code that was horribly incorrect?

alt Re: how to use ai_build

DragonAwper
User Off Offline

Zitieren
@DannyDeath
I want the bots can build in the game

@TimeQuesT
no only here but i fix look:
1
if (player(id,"exists") and player(id,"bot") and player(id,"health")>0 then

a ")" is missing but i fix look
1
if (player(id,"exists")) and player(id,"bot") and player(id,"health")>0 then

And nothing happens when i start the game, the hooks are ok.


Can you fix it?

alt Re: how to use ai_build

TimeQuesT
User Off Offline

Zitieren
lolz i saw you fixed it....

1
if (player(id,"exists") and player(id,"bot") and player(id,"health")>0) then

alt Re: how to use ai_build

TimeQuesT
User Off Offline

Zitieren
i found the problem. The main ai script is telling the bot that he has to move to a spawn/dom point and you are telling him that he has to walk to x y.
example:
(ai position is 4 5)

--your script
ai_goto(id,5,5) --parsed first (one step forwards)
--ai mainscript
ai_goto(id,3,5) --one step backwards


forwards+backwards = old position

i tested my script and that's the solution

edit:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
--hooks
addhook("always","trybuild")

--functions
function trybuild()
for id=1,32 do
if (player(id,"exists") and player(id,"bot") and player(id,"health")>0) then
vai_destx[id]=5; --we need to change variables in the main bot lua file
vai_desty[id]=5;
parse ("setweapon "..id.." 74")
if (player(id,"tilex")>=4 and player(id,"tilex")<=6 and player(id,"tiley")>=4 and player(id,"tiley")<=6) then
ai_build(id,1,5,5);
msg ("reached");
end
break;
end
end
end

this works but you have to change some things.. now the bot always trys to build there. Only sme changes are needed like telling the bot "it's enough.. you can go fight" etc. but i'm to lazy to do that
2× editiert, zuletzt 06.03.11 22:21:55

alt Re: how to use ai_build

DragonAwper
User Off Offline

Zitieren
hmmmm....
i tested and don't work

i change always to minute, yeah... i wait 1 minute and the bot go to 5|5 tile change to wrench and after 1 sec he change weapon and walk w/o build anything

=================================================================
Read This:

My map is a rectangle (30|30) and the tile 5|5 is disponible
Game mode: Construction
TSpawn > 2|2 tile
CTSpawn > 29|29 tile

=================================================================

What the bot do on start of the game?
He walks to ctspawn, after 1 minute he go to 5|5 change to wrench but don't build anything

Look the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
--hooks
addhook("minute","trybuild")

--functions
function trybuild()
for id=1,32 do
if (player(id,"exists") and player(id,"bot") and player(id,"health")>0) then
vai_destx[id]=5; --we need to change variables in the main bot lua file
vai_desty[id]=5;
parse ("setweapon "..id.." 74")
if (player(id,"tilex")>=4 and player(id,"tilex")<=6 and player(id,"tiley")>=4 and player(id,"tiley")<=6) then
ai_build(id,1,5,5);
msg ("reached");
end
break;
end
end
end

Yes! I only changed the hook.
1
addhook("always","trybuild")

to
1
addhook("minute","trybuild")

Why it's don't working?
Zum Anfang Vorherige 1 2 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht