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




how to use ai_build
25 repliesBut what do you want to do? How can we help you if all you did was post some code that was horribly incorrect?
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?
1
if (player(id,"exists") and player(id,"bot") and player(id,"health")>0) then

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