Raised This Month: $32 Target: $400
 8% 

Bots vs. Humans (co-op) for TFC


Post New Thread Reply   
 
Thread Tools Display Modes
C1PA
Junior Member
Join Date: Oct 2012
Location: The Netherlands, Dordrec
Old 11-01-2012 , 11:51   Re: Bots vs. Humans (co-op) for TFC
Reply With Quote #11

Does this work for counter strike to?
If not, can someone change it so it will?
C1PA is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 04-03-2013 , 17:57   Re: Bots vs. Humans (co-op) for TFC
Reply With Quote #12

I had v4.2 with the engclient_cmd and some minor changes lying around on my HDD since October last year. I guess I didn't publish it because I wasn't satisfied with it, probably to do with FoxBot behaving a bit random and maybe latency issues (things working fine on listen but not on a dedicated due to different reaction times). So here it is (added to the 1st post).

From comparing the source code, changes I did:

- Added handling of changeteam command - it uses the same function as jointeam.
- The function used by above commands was renamed from "clcmd_jointeam" to "force_human_team" because it's not used by jointeam exclusively any more.
- With the engclient_cmd testing whether the human player wants to join the right team isn't needed any more, since the "jointeam" command isn't sent to the player. Saves parsing of the team argument (read_argv) as well.
- Added some additional checks of bvh_enabled so tasks won't even be started. There already was/is another check in the task itself though.

Last edited by pizzahut; 04-03-2013 at 18:05.
pizzahut is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-09-2016 , 05:38   Re: Bots vs. Humans (co-op) for TFC
Reply With Quote #13

Some thoughts:
  • static is misused in client commands(also in task_adjust_bot_count), you should initialize them with "new".
  • Instead of this:
    Code:
    get_players(Players, playerCount, "c")  // skip bots, don't skip the HLTV     for(i = 0; i < playerCount; i++)     {         teamnumber = get_user_team(Players[i])         if((1 <= teamnumber) && (teamnumber <= 4))             HumanCount++         else             SpecCount++     }
    You could do something like:
    Code:
    new TeroCount, CtCound get_players(Players, TeroCount, "ce", "TERRORIST") get_players(Players, CtCount, "ce", "CT") get_players(Players, SpecCount, "ce", "SPECTATOR") HumanCount = TeroCount + CtCound
    Anyway, it's also ok to loop and count.
  • Be consistent with your style. For example, in some places you use camelcase and in some you don't. Just choose one style and use it everywhere.
  • Instead of format, use formatex, it's faster.
  • In task_check_bot_team cache g_bvh_bot_team cvar value before looping.

Also, because I don't know much about TFC I am just asking.
I see from the wiki that TeamInfo message is present also in TFC, so maybe you could use it instead of creating a permanent looping task. My point is, all team changes are send with this message, so you could hook it and do your checks and fix bot team.

Unapproved until you make changes, because section needs to be cleaned. PM me and I'll check again.
__________________

Last edited by HamletEagle; 04-10-2016 at 05:31.
HamletEagle is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 04-10-2016 , 10:49   Re: Bots vs. Humans (co-op) for TFC
Reply With Quote #14

Quote:
Originally Posted by HamletEagle View Post
static is misused in client commands(also in task_adjust_bot_count), you should initialize them with "new".
I use static for speed. As I understand it, "new" creates a variable every time the function is called, and the variable is destroyed every time the function ends. With static, the variable is kept in memory, but has to be initialised manually if necessary.

Quote:
Originally Posted by HamletEagle View Post
Instead of this:
Code:
get_players(Players, playerCount, "c")  // skip bots, don't skip the HLTV     for(i = 0; i < playerCount; i++)     {         teamnumber = get_user_team(Players[i])         if((1 <= teamnumber) && (teamnumber <= 4))             HumanCount++         else             SpecCount++     }
You could do something like:
Code:
new TeroCount, CtCound get_players(Players, TeroCount, "ce", "TERRORIST") get_players(Players, CtCount, "ce", "CT") get_players(Players, SpecCount, "ce", "SPECTATOR") HumanCount = TeroCount + CtCound
Anyway, it's also ok to loop and count.
Team names in TFC aren't fixed like in CS. Each map can have custom names.

Even if they were fixed, the effort in terms of performance to compare against a string instead of a numeric variable is probably higher.

Quote:
Originally Posted by HamletEagle View Post
  • Be consistent with your style. For example, in some places you use camelcase and in some you don't. Just choose one style and use it everywhere.
  • Instead of format, use formatex, it's faster.
  • In task_check_bot_team cache g_bvh_bot_team cvar value before looping.
I agree with this, thank you for your input and time looking into new plugin releases - much appreciated.

Quote:
Originally Posted by HamletEagle View Post
I see from the wiki that TeamInfo message is present also in TFC, so maybe you could use it instead of creating a permanent looping task. My point is, all team changes are send with this message, so you could hook it and do your checks and fix bot team.
There's no permanent looping task, but yes it's better to use a TeamInfo message (game event) instead of a log event.
pizzahut is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-10-2016 , 12:05   Re: Bots vs. Humans (co-op) for TFC
Reply With Quote #15

Quote:
Originally Posted by pizzahut View Post
I use static for speed. As I understand it, "new" creates a variable every time the function is called, and the variable is destroyed every time the function ends. With static, the variable is kept in memory, but has to be initialised manually if necessary.
That's correct, but it only matters when you are working in "heavy" forwards(I mean forwards called per frame - PreThink, AddToFullPack, CmdStart, etc) or on big arrays. Here it's not the case, so I would prefer you to use "new", it makes more sense.

Quote:
Originally Posted by pizzahut View Post
Team names in TFC aren't fixed like in CS. Each map can have custom names.

Even if they were fixed, the effort in terms of performance to compare against a string instead of a numeric variable is probably higher.
Like I said before, it's okay to count, was just showing another way, most of people don't know that get_players can filter by team.

Quote:
Originally Posted by pizzahut View Post
There's no permanent looping task, but yes it's better to use a TeamInfo message (game event) instead of a log event.
My bad about the task. Anyway, I would still go for TeamInfo message.

If you decide to make the changes, PM me when you are ready so I can approve this.
__________________
HamletEagle is offline
tarantula2
New Member
Join Date: Dec 2020
Old 12-18-2020 , 05:41   Re: Bots vs. Humans (co-op) for TFC
Reply With Quote #16

Does anyone know why my bots randomly try to switch to the red team? Then they immediately switch back to blue.

foxbot are settings correct:

max_bots -1
min_bots -1
Bot chat 500
Bot auto team balance Off
Bot per team balance Off

I also have:
tfc_autoteam 0
tfc_balance_teams 0

Also, do I need to have 41.amxx and 42.amxx loaded?
Or just one of them? Currently only have 41 loaded. Also tried swapping them with same issue.

Thanks in advance,
tarantula
tarantula2 is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 12-20-2020 , 17:00   Re: Bots vs. Humans (co-op) for TFC
Reply With Quote #17

The bots don't keep assigned teams, they can switch when they die AFAIK.

Maybe -X- (server admin) or RoboCop (FoxBot maintainer) have an idea how to prevent this from happening.

https://steamcommunity.com/profiles/76561198213218781/
https://steamcommunity.com/id/SCO_RoboCop/

I'm not sure why I kept v4.1 in this thread. There might have been a reason, so I'll leave it be.

I made a customised version for -X- which doesn't adjust bot count / ratio. I think it also fixes a minor issue present in v4.1 and v4.2 - the scoreboard might not get updated when using the "jointeam" command on a bot.

https://rv.apg-clan.org/dlds/amxx_pl..._humans_x2.sma

Last edited by pizzahut; 12-21-2020 at 12:50.
pizzahut is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:06.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode