Forum

> > CS2D > Scripts > ai_goto walk?
Forums overviewCS2D overview Scripts overviewLog in to reply

English ai_goto walk?

9 replies
To the start Previous 1 Next To the start

old ai_goto walk?

Powermonger
User Off Offline

Quote
Hi,

I have managed to take control of bot movement, but I countered a problem with ai_goto.

How can you make bots walk?

I know that it should work like this ai_goto(id,10,10,1), but the bot still runs. The previous command still return 2 "bot is still on its way" and the bot does go to tile 10,10. So that's working.
I also tried to use ai_move, but same thing, bots keep on runnin'!

Are all bots Forrest Gumps, or is there a way to slow them down?
Can someone help me out, thank you very much!

old Re: ai_goto walk?

Powermonger
User Off Offline

Quote
@user Masea:
I tried it, but then this happened:
1
LUA ERROR: sys/lua/csgo.lua:255: bad argument #4 to 'ai_goto' (number expected, got boolean)
It requires a number value, so tried other numbers, but no effect.

old Re: ai_goto walk?

DC
Admin Off Offline

Quote
Reading the documentation carefully can solve many problems
See cs2d lua cmd ai_goto - it says in the description that a number is expected. 1 for walking, 0 (default) for running.

I know it's confusing and bad design but it does not accept true or false. I think there are no Boolean parameters at all in the CS2D Lua API because of type conversion issues or something like that. I don't remember though.

old Re: ai_goto walk?

DC
Admin Off Offline

Quote
I should have read the whole thread, sorry. It might be a bug then. I didn't try it but from the code it looks like it should work.

@user Powermonger: Are you aware that you have to constantly call it with walking set to 1? Not just once. Otherwise the bot will walk for 1 single frame and run all the other frames.

old Re: ai_goto walk?

Avo
User Off Offline

Quote
user DC has written
I know it's confusing and bad design but it does not accept true or false. I think there are no Boolean parameters at all in the CS2D Lua API because of type conversion issues or something like that. I don't remember though.

Maybe becayse lua is implemented in ANSI C which has no boolean type? But I believe that lua booleans are stored on lua stack (which is used to call functions for example) as ints as well, so there shouldn't be any problem with conversion.

old Re: ai_goto walk?

Powermonger
User Off Offline

Quote
user DC has written
@user Powermonger: Are you aware that you have to constantly call it with walking set to 1? Not just once. Otherwise the bot will walk for 1 single frame and run all the other frames.

Oh no... I didn't know that... I'm very sorry about it

I rarely use always hook, because my computer isn't the most powerfull one (it's a Dell laptop...).

I tested it on walktile & ms100, those doesn't work.
Just wondering, does it work with walk hook? Also, which one is better option walk or always?

That's my last question about this matter

old Re: ai_goto walk?

DC
Admin Off Offline

Quote
@user Powermonger: What exactly are you doing? If you are trying to write custom bot AI you can take the original AI scripts in the bots folder as reference.

There are actually extra AI functions called by CS2D so you can script AI without using any hooks (the original AI works like that).

Just declare a function like this:
function ai_update_living(id)
and CS2D will call it for each existing bot, putting in the player ID of the bot each time.

The benefit of using the ai_ functions instead of hooks: CS2D will only invoke them if there are actually bots in the game. Resulting in the best possible performance. Moreover you have less conflicts with normal Lua scripts if you have AI which doesn't use any hooks.

If you're NOT writing a custom bot AI there are two options:
• cs2d lua hook always hook. Best choice if it's a long term thing which runs most of the time.
• cs2d lua cmd timer. Best choice if it's a thing which runs only for a limited time.

old Re: ai_goto walk?

Powermonger
User Off Offline

Quote
Oookay, so that's how it all works...
Custom AI is indeed what I am now trying to make, this helps a lot in that matter!

I know that there are some good scripts already in File Archive, but making own scripts makes learning easier

I once learned "Less hooks equals better performance" the hard way, but now it's a "standard" to me.

Anyway, thanks again a million to you guys!
Hope you had a spooky halloween and have a pleasant xmas
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview