English ai_goto walk?

9 replies
Goto Page
To the start Previous 1 Next To the start
02.11.17 06:27:03 pm
Up
Powermonger
User
Offline Off
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!
02.11.17 06:58:12 pm
Up
Masea
Super User
Offline Off
Well, it's been also showed in cs2d.com as you should set it to 1 but did you ever try "true"?
Create and design your GUI easy and fast: file cs2d GUI Framework (v1.3) (7) | Go deep of the darkness and try your intrepidity: file cs2d Outlast 2 Modification (24)
02.11.17 10:58:06 pm
Up
Powermonger
User
Offline Off
@user Masea:
I tried it, but then this happened:
Code:
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.
03.11.17 01:09:20 pm
Up
DC
Admin
Offline Off
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.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
03.11.17 01:29:46 pm
Up
Masea
Super User
Offline Off
@user DC: The actual problem that is so. 1 is also not working for it.
Create and design your GUI easy and fast: file cs2d GUI Framework (v1.3) (7) | Go deep of the darkness and try your intrepidity: file cs2d Outlast 2 Modification (24)
03.11.17 01:32:57 pm
Up
DC
Admin
Offline Off
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.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
04.11.17 12:23:39 am
Up
Avo
User
Offline Off
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.
04.11.17 02:36:43 pm
Up
Powermonger
User
Offline Off
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
05.11.17 02:44:56 pm
Up
DC
Admin
Offline Off
@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.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
05.11.17 04:56:06 pm
Up
Powermonger
User
Offline Off
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