Forum

> > CS2D > Scripts > how to use ai_build
Forums overviewCS2D overview Scripts overviewLog in to reply

English how to use ai_build

25 replies
Page
To the start Previous 1 2 Next To the start

old Re: how to use ai_build

DannyDeth
User Off Offline

Quote
@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?

old Re: how to use ai_build

DragonAwper
User Off Offline

Quote
@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?

old Re: how to use ai_build

TimeQuesT
User Off Offline

Quote
lolz i saw you fixed it....

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

old Re: how to use ai_build

TimeQuesT
User Off Offline

Quote
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
edited 2×, last 06.03.11 10:21:55 pm

old Re: how to use ai_build

DragonAwper
User Off Offline

Quote
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?
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview