Forum

> > CS2D > Scripts > bot doesent work correct
Forums overviewCS2D overview Scripts overviewLog in to reply

English bot doesent work correct

14 replies
To the start Previous 1 Next To the start

old bot doesent work correct

EnderCrypt
User Off Offline

Quote
my bot doesent work correct, it gives error:
LUA ERROR: attempt to call a nil value
mosltly after it killed its target, its suppose to walk random untill someone in vision and range shots...

but it seems like only the bot with highest id reacts

im pretty new to lua nd dont se the wrong

Spoiler >
edited 1×, last 18.02.11 06:11:49 pm

old Re: bot doesent work correct

MrShock
User Off Offline

Quote
Do not push "Mark as new/unread" everytime, please.

EDIT : Ohh no .. Epic fail ... I do not know that you do not push it

old Re: bot doesent work correct

Robotic-Brain
User Off Offline

Quote
omg please add tabs

and where (which line) did the error occur?

EDIT:

I figured it out

first the code with tabs:

More >


your misthake ist, that you try to call a function, wich does not exist
player_die is defined nowhere
and I'm not sure if player_attack and player_new_tile ist correctly implemented as well
edited 2×, last 17.02.11 12:12:48 am

old Re: bot doesent work correct

EnderCrypt
User Off Offline

Quote
hm bot doesent work correctly still... only the bot with highest id attacks...
LUA ERROR: attempt to call a nil value

problably anothere script
thx for help

btw: what does "attempt to call a nil value" maybe i could figure whats wrong in othere lua if i would know what that means

edit:
ok seems like it was the bot script that gives the error
it eithere gives it as soon as i spawn, or when first bot spawn

[b]Feuersturm connected
[b]Feuersturm joins the counter-terrorist forces
LUA ERROR: attempt to call a nil value
[b]Feuersturm changes name to police bot

and exacly after a bot killed me, or someone
(after the text that bot has killed player)
then i get

LUA ERROR: attempt to call a nil value

but it doesent seem to cause any trouble, but i would be happy if someone tryd find it

thx

old Re: bot doesent work correct

J4x
User Off Offline

Quote
Well, nil means something without value. Try by closing and opening again c2sd, if this doesn't work thne its a error.

old Re: bot doesent work correct

Robotic-Brain
User Off Offline

Quote
mostly it means the function/arrayindex does not exist

e.g.:
1
2
3
4
5
6
7
8
9
10
11
12
13
array={}
array[1]=0
array[2]=1
array[3]=2

if array[4]==2 then
	-- this would produce the error because array[4] does not exist
end

-- Attention! 0 ~= nil

phantomFunction(a,b)
-- this would produce the error because you have not defined phantomFunction

@2nd Error:
this is caused because you define the function player_new_tile within ai_update_living

but the first call of player_new_tile is before the first call of ai_update_living
so it isn't defined at this time

old Re: bot doesent work correct

EnderCrypt
User Off Offline

Quote
ehh... yeah.. could you try fix, im still beginner at lua... and i dont really understand what caused the problem, could anyone fix it, if you got time...

cause i tryd alot and still nothing

old Re: bot doesent work correct

Robotic-Brain
User Off Offline

Quote
eh... sorry but i don't really understand what this script should do

if i'm wrong correct me:

on spawn:          <- thats easy
     set mode to 1
     equip some things
     set random starting direction

normal behavior:          <- thats the confusing part
     if mode 1:
          randomly run around
          if shoot by someone set him as target and switch to mode 2
     if mode 2:
          if clear field of fire
               atack
          else
               switch to mode 1


mode 1 = ROAM!
mode 2 = attack

is that correct?

old Re: bot doesent work correct

EnderCrypt
User Off Offline

Quote
yeah you andurstand
mode 1 mean run around randomly (lol)
mode 2 is attack mode, where it attacks target variable (id) of target if its a free feild

mode 1 switch to 2 if theres nothing beetween and in range (250)
mode 2 switches to mode 1
if theres somheting in way

old Re: bot doesent work correct

Robotic-Brain
User Off Offline

Quote
so now it's working:

More >


i hope that's helpful

old Re: bot doesent work correct

EnderCrypt
User Off Offline

Quote
thx works perfect but missing 1 thing

first of all i would want it to attack if someone shot, i mean, theres 2 way for it to go to mode 2

1. someone damages it
2. someone shots with gun (or primary attack) whitin a certain range and theres nothing beetween, weapon does not need to damage anything, as long as its fired by player in range and vision (then i mean no walls in way)

also could you make it change back to mode 1 if target leaves... else it just kills the next person that joins (and get that id lol)

edit: lol also fix so bot check if the target is a bot... they sometimes accidently shot each other...

thx
edited 1×, last 18.02.11 08:39:55 pm

old Re: bot doesent work correct

Robotic-Brain
User Off Offline

Quote
Quote
edit: lol also fix so bot check if the target is a bot... they sometimes accidently shot each other...

eh... you mean check if the target is an enemy?

Quote
also could you make it change back to mode 1 if target leaves... else it just kills the next person that joins (and get that id lol)


just check if traget is dead and then go back to mode 1

the rest:
just look in the normal AI script
     bots/Standart AI.lua

i can't script you everything
if you get stuck ask and I'll help you
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview