Forum

Frikbots in QW?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Frikbots in QW?

Postby redrum » Fri Oct 01, 2010 4:31 pm

How can I get these nifty little guyz in my QW server.

Problem: When a bot is in the server and a human player connects the server crashes.
I think it has something to do with slots or something?
If there are humans on the server and I add a bot everything works. If a player connects after there are bots, then it crashes.
Any help would be greatly appreciated.
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby Spike » Fri Oct 01, 2010 4:56 pm

When a client connects to a QuakeWorld server, the client's player entity is fully cleared. ClientConnect is called a few frames later (ie: not instantly).
This results in frikbot's playerslot links being corrupted (usually an infinite loop).

You can 'fix' it the lame way by regenerating the list every time, instead of simply editing it. This will give small periods where not all players can be targetted by bots.

A more correct way to fix it is to just remove the list entirely, and use nextent or something to walk it instead.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby redrum » Fri Oct 01, 2010 7:39 pm

Don't quite understand. What do you mean by "remove the list"?
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby redrum » Mon Oct 04, 2010 2:36 pm

Spike, Orion, FrikaC??? Anybody?.....
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby redrum » Wed Oct 06, 2010 12:57 am

nothing?
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby redrum » Thu Oct 07, 2010 2:41 pm

Found a simple fix.
I've been asking bout this for years, surprised nobody came up with this solution.
Anyone interested?
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby Chip » Fri Oct 08, 2010 10:10 am

redrum wrote:Found a simple fix.
I've been asking bout this for years, surprised nobody came up with this solution.
Anyone interested?


I'd be interested in this. I've been updating Open Quartz 2 with frikbots by default, and adding QW to it would be a blast.
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays

Fear not the dark, but what the dark hides.
User avatar
Chip
 
Posts: 575
Joined: Wed Jan 21, 2009 9:12 am
Location: Dublin, Ireland

Postby redrum » Fri Oct 08, 2010 7:54 pm

So, the problem seemed to be that when a player entered the server that had a bot already in it the server would crash.
Apparently the player was overlapping the bots client slot which would cause the server to crash.
So I thought what if I moved the bots client slot a bit further up the list?
I looked into bot_qw.qc and found float() ClientNextAvailable(), made one small change and wala!

Code: Select all
float() ClientNextAvailable =
{
   local float clientno;

   clientno = 0;  // I want to do this top down, but QW won't let me - FrikaC
   while(clientno < max_clients)
   {
      clientno = clientno + 8;  // changed from 1 to 8, so it adds the bot into the 9th slot (if there's 1 player on server) - Redrum

      if(!ClientIsActive(clientno))
         return clientno;
   }
   return -1;
};


Simple as that!
Now there could be an issue if too many people join the server and a player tries to fill that 9th slot, but so far so good! :D
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby frag.machine » Fri Oct 08, 2010 8:29 pm

redrum wrote:So, the problem seemed to be that when a player entered the server that had a bot already in it the server would crash.
Apparently the player was overlapping the bots client slot which would cause the server to crash.
So I thought what if I moved the bots client slot a bit further up the list?
I looked into bot_qw.qc and found float() ClientNextAvailable(), made one small change and wala!

Code: Select all
float() ClientNextAvailable =
{
   local float clientno;

   clientno = 0;  // I want to do this top down, but QW won't let me - FrikaC
   while(clientno < max_clients)
   {
      clientno = clientno + 8;  // changed from 1 to 8, so it adds the bot into the 9th slot (if there's 1 player on server) - Redrum

      if(!ClientIsActive(clientno))
         return clientno;
   }
   return -1;
};


Simple as that!
Now there could be an issue if too many people join the server and a player tries to fill that 9th slot, but so far so good! :D


I see 2 problems in your solution:

1) first, you're assuming that bot will always start from a fixed slot (9th). I suspect that if maxplayers changes to less than 16 your code may crash;

2) your checking loop is using an increment by 8 starting from 0, so the check order will be: 8, 16, 24, 32, etc. The correct would be start from N and use an increment by 1.

So, I suggest you to do this way instead:

Code: Select all
float() ClientNextAvailable =
{
   local float clientno;

   clientno = max_clients / 2;  // now this can change and our code won't fail
   while(clientno < max_clients)
   {
      clientno = clientno + 1;  // back to unit increment
      if(!ClientIsActive(clientno))
         return clientno;
   }
   return -1;
};
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby Spike » Fri Oct 08, 2010 8:51 pm

maxplayers in quakeworld is 32, always.
maxclients and maxspectators is variable, but there are _always_ 32 slots.

Your bots will still crash if more than 8 people join the server. Or the same one in a join/qportchange/rejoin flood (you can ban them, but they still can consume multiple slots from a single ip).
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby FrikaC » Fri Oct 08, 2010 9:43 pm

The comment from me is interesting. I wonder what the issue I had with doing it from the end of the list down.
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Postby FrikaC » Fri Oct 08, 2010 9:50 pm

Spike wrote:When a client connects to a QuakeWorld server, the client's player entity is fully cleared. ClientConnect is called a few frames later (ie: not instantly).
This results in frikbot's playerslot links being corrupted (usually an infinite loop).

You can 'fix' it the lame way by regenerating the list every time, instead of simply editing it. This will give small periods where not all players can be targetted by bots.

A more correct way to fix it is to just remove the list entirely, and use nextent or something to walk it instead.


The Quakeworld version of Frikbot doesn't use the linked list for players. It sets it up yes, but it never walks that list in QuakeWorld. It uses nextent instead.
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Postby FrikaC » Fri Oct 08, 2010 9:55 pm

Also I should mention that it definitely used to work (it was broken in 0.09 and I made a point of fixing it in FBX). So either some subtle bug creeped in before the last release of FrikBot or it's a bug with the QuakeWorld server you are running. Does it outright crash, hang or spit out a QuakeC error?
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Postby redrum » Mon Oct 11, 2010 4:29 pm

When it crashed there were bot related errors, don't remember exactly what they were.

So now that I got the little bastards on the server, I'm trying to tweak their fighting skills in bot_weapon_switch().
What does this line of code mean?
Code: Select all
   it = self.items & 127;


The thing is that the bot will sometimes be in your face but he won't pull out the axe and start hacking away, just stands there for an easy kill?
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby redrum » Wed Oct 13, 2010 6:47 pm

What does this line of code mean?

it = self.items & 127;

Anyone?
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Next

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest