CodeJunkie

CoD4x and PeZBots

Recommended Posts

So...since I'm new to cod4x.me I'll present a little background before I get to my question.  I bought CoD4 back when it came out ~10 years ago and played it a lot.  It really is a great game and it raised the bar for FPS multiplayer games.  Of course, as time went on, I eventually found other games or just simply got busy with real-world stuff and haven't played it in a long time.  Well, my kids are now at the age where I wanted to introduce them to some FPS multiplayer games so I searched through my collection for something that wasn't too old, but was fun and quick to pick up and low and be hold I found my CoD4 disc.  (yeah, disc)  Luckily I was able to (since it was on disc and it came out before DRM got super crazy) install it on my computer as well the kids' computers and we were all able to play together.  Fun times!  

However, after a while it kinda got a little dull just playing between the three of us (haven't roped my wife in yet, but I'm trying) and I was getting tired of holding back on the kids so I looked into how to add bots to the game.  I knew the game didn't have them built in, but quickly found the PeZBots mod...great!  So I read up on it and saw that is had some bugs, but it is pretty much the best, if not the only, bot mod for CoD4.  So I tested it out locally on my PC first and wow, it's awesome.  It added a lot of enjoyment to an already awesome game.  So then I went about getting the game setup on a stand alone computer to run it as a dedicated server.  Great, for a short while.  Until I experienced the issue where the bots (test clients) aren't dropped properly and they eventually won't add anymore...boooo!  Now, try as I might I just spent about a week trying to come up with some way to get the dedicated server to work properly with this mod.  I downloaded the mod source and tried to correct it thinking maybe it was just a simple bug.  I ended up learning way more about modding CoD4 then I thought I ever would, including the fact that there is just missing functionality, most important the ability to properly handle test clients such as removing them or getting them after a map change.  I also, after messing around with the source, discovered that the test clients would stay connected between map changes and the mod was trying to kick them...probably because the author tried to compensate for the weirdness...anyway, nothing worked.  I discovered that I could execute "killserver" and then "map_rotate" at the console on the server and it would disconnected the bots and pick up in the map rotation where it left.  This I thought was good and I could possibly just automate a kill server and map rotate process via an rcon program.  So I set out and wrote an rcon program...then I discovered that when you execute killserver remotely you lose connection to the server...bah...foiled again!  So I had pretty much given up at that point until I stumbled across CoD4x...a custom dedicated server for CoD4, and it solves these issues while adding new functionality.  

Awesome!

Almost.

Well, I got the CoD4x 1.8 server setup and working (pezbots and all) and then setup the modified client for it.  It took a while as I had to figure out the difference in dvar/cvars for the server and change the getdvarint calls in the pezbot mod to just getdvar to it would load and run.  Once the server was running I noticed that it properly disconnected the bots between map rotation which was great.  This was already better.  So I log in to the server for the first time from my PC ... the bots are not working correctly.  They aren't firing their weapons.  In a lot of cases are sliding around instead of walking or running.  Their battle chatter is lacking, but not gone completely.  Their animations are sometimes epileptic in nature and they are getting hung up a lot.  It was a huge difference between the stock server and this one.  I was pretty sad as I was looking forward to keeping the server up and running and not having to baby sit it while we play on it, but it looks like that is what I'll have to do for now.

But that brings me to my question.  Have any of you successfully used pezbots with CoD4x?  If so what did you have to do to get it working properly.  Does the mod need to be updated in any way and if so where would one start in order to do this?  I am a software engineer (~25 years and still going) so getting down into the guts of this project is not a problem for me, but any guidance that could be offered up would be great.

Thanks!

Share this post


Link to post
Share on other sites

Hi CodeJunkie :)

Personally I haven't used pezbots really yet, idk how well its working or should work.

If you are interested in coding some gsc for bots take a look at this:
https://github.com/callofduty4x/CoD4x_Server/blob/master/scriptdocumentation/script_functions_reference.md#bot-related-functions
T-Max has put some work into making the interface to bots more functional

 

I recently also discovered this video, I have no idea if it is available .. but maybe that's something for the kids ;)

 

 

 

 

 

 

 

 

Share this post


Link to post
Share on other sites

Oh, I know this will be asked, so I'll head it off at the pass:

Windows 7

Intel i7 CPUs (dekstop = 4790k, server = 3770k) 

My desktop has 32GB ram and the dedicated server has 8GB.  So hot hurting in the hardware department.

This shouldn't matter though because everything works beautifully with the stock CoD4 server.  Also connecting to the stock server with the CoD4x client works fine too so it's definitely a server side issue.  I did see that you can make a "main_shared" folder for server side mods.  I started going down the path of moving the pezbot server files to there and changing the extensions, but it was a lot of files and I wasn't sure if it would even work or change anything.  Any ideas or suggestions on this?  pezbot is a server side mod with a client side mod which allows you to add mods via the quick message menu, but the client side mod does not work with a dedicated server.  

I'm also not getting any error messages on server startup or operation, but that doesn't mean that something is being swallowed, although script errors usually bring everything to a screeching halt.

Share this post


Link to post
Share on other sites
5 minutes ago, D4edalus said:

Hi CodeJunkie :)

Personally I haven't used pezbots really yet, idk how well its working or should work.

If you are interested in coding some gsc for bots take a look at this:
https://github.com/callofduty4x/CoD4x_Server/blob/master/scriptdocumentation/script_functions_reference.md#bot-related-functions
T-Max has put some work into making the interface to bots more functional

Thanks for replying :) I'll definitely take a look at the scripting reference.  I or somene might have to rewrite pezmod to work with CoD4, who knows.  The fact that it has built in bot functionality might make it a not so painful process.

Share this post


Link to post
Share on other sites

if you plan on fixing up pezbots for cod4x i ll try to support you where I can.

making it a serverside only modification would be nice, as it makes integration into other mods easier.

Share this post


Link to post
Share on other sites
5 minutes ago, D4edalus said:

if you plan on fixing up pezbots for cod4x i ll try to support you where I can.

making it a serverside only modification would be nice, as it makes integration into other mods easier.

I really appreciate it and I'll definitely see what I can do.  I agree server side only would be the best way to approach a rewrite.

Share this post


Link to post
Share on other sites

Is it possible to rename the bots in CoD4x?  It was one of the limitations in the stock server, but I suppose the ability could be added if it's not currently possible.

Share this post


Link to post
Share on other sites

https://github.com/callofduty4x/CoD4x_Server/blob/21952bfd65ab965d5aa67806ae9e7d06a81e2672/src/sv_client.c#L1226

that should work i guess

But careful there: if you want your server to be listed on gametracker.com you should probably not change the names. They filter servers with bots to get the correct player count .. im not sure if they really do filter by name, but i think so. Why are they doing that? Because some server hosters tried to get their servers popular by renaming bots to pose as valid players. So if you get reported, or they somehow detect that your server gets probably excluded from ranking.

Maybe somebody else knows what gametracker is filtering on?

e.g.: http://www.gametracker.com/server_info/94.23.215.215:28974/

Share this post


Link to post
Share on other sites

Right now I'm more focused on LAN play, but I'll be sure to keep it safe.  Ideally bot names should be a configurable option anyway, along with an option to add a decoration such as "[bot]" to the name.

So, I've actually started working on this and I've copied all the files for pezbots to the main_shared folder and I've changed the extensions on the necessary files.  So far the server is loading the scripts, but is crashing on a call to precacheItem() saying the item isn't found, however the file is located in "weapons\mp" along with about 9 other files which are supposed to be precached.  Any ideas on this?  The files are in their original location from inside the .iwd file.  Now, there was a .csv file named pezbot.csv which contains these assets and it normally lived in the mods/pezbot folder.  I've tried placing it in several locations and it doesn't seem to be being read.

Share this post


Link to post
Share on other sites

PezBots are not server-side mod. Because there was no script functions to make bots moving, creator links bot with "script_origin" and uses custom weapon files to play movement animation. That's a common practice. So pezbot contains scripts, menu files and weapon files which makes it not possible to use as server side mod. That's might be the reason why animations not working for you on CoD4x server. Just try original mod and you'll see there's no big differences in servers' behaviour.

I'm currently working on RotU 2.2.2, 2-years old (last) release and it's using pezbots pathfinding routines. One of my target is to move entire mod on CoD4x server as it using some script tricks which may be simplified.

About this killserver stuff. I have allways thought mod creators just initiates player reconnection and then kicks all, but this makes sense too. I think, you can add simple config file to be executed at level end with next content:

killserver
map_rotate

I think, executing configs can not be interrupted with killing server.

About bot names, there's available filed called botnames.txt. As I remember a half of thousand builds ago it had been used to give bots names.

 

Also, for now wiki entrance about bot movement functions is not recent. Few days ago the creator of CoD4 Frontlines mod asks me about it. Here the answer I gave him:

Quote

Hello.

Yes I had added few bot related movement functions. I don't know how it was in Quake 3 but with this functions bots moves exactly like players. You can read about new functions here. Oh, just found out I forgot to update wiki. It's a bit outdated but you can find few functions from list below. (Others are not implemented)

Here's a list of all new functions and it's usage:

  • botMoveTo - Usage: bot botMoveTo(<vec3 position>);
  • botLookAt - Usage: <bot> botLookAt(<origin>, [duration]);
  • botStop - Usage: <bot> botStop();
  • botAction - Usage: <bot> botAction(<action>);
  • botLookAtPlayer - Usage: <bot> botLookAtPlayer(<player>, [tag_name]);

Available actions: (excluding +\- signs)

  • "gostand"
  • "gocrouch"
  • "goprone"
  • "fire"
  • "melee"
  • "frag"
  • "smoke"
  • "reload"
  • "sprint"
  • "leanleft"
  • "leanright"
  • "ads"
  • "holdbreath"

For example, if you need to make bot move to waypoint, you should use botLookAt(to look at waypoint origin) and botMoveTo(this one forces to move bot to waypoint, straight from A to B, no matter where it aims at). If you need to shot player, you should use botLookAtPlayer() and botAction("+fire") to start shooting and botAction("-fire") to stop shooting. Works like console commands.

If you need more information feel free to ask.

 

Share this post


Link to post
Share on other sites

Just realized that the link to that bot name code was server source code and not script.  That's still pretty cool though.  Definitely need to worry about get the script working correctly first.

Share this post


Link to post
Share on other sites

T-Max, thanks for the information and insight.  It makes a lot of sense.  Last night when I was trying to get to pezbots running as pure server-side mod I started to wonder if the error I was receiving was because the stuff it was trying to do were not strictly server-side methods.  You confirmed that, so I think I know what I need to do now.

Share this post


Link to post
Share on other sites

I've made some progress on this, although I have had to break down the original pezbot scripts to figure out how exactly they were working.  I have managed to correct some bugs which is nice, however I'm running into some anomalous behavior.  The first being with the botAction() function.  It doesn't seem to work consistently.  For example, I have my config setup to create 10 bots auto assign to teams which ends up with 5 on each team.  What I'm seeing as that 1 and sometimes maybe 2 bots will actually fire their weapons when using the botAction("+fire").  Seems really odd and I'm not sure if it has something to do with the internal server code or script.  I did a test where I made it so the bots could not move, but would look at the player and fire their weapon and I would go from my side of the map to the enemies side of the map and all the enemies would track me, but only one bot would fire...and sometimes none of them would.  Even if this worked like it should it would be better, because the bots still play the game correctly and follow the waypoints for the maps setup by the original scripts.

Now, the other weirdness is with the botMoveTo() function.  It doesn't seem to work at all.  The original scripts were using SetOrigin() to move the bot and then a monitor thread was determining which animations to play (which I believe is probably not need anymore), however, when I make it use botMoveTo() instead they don't move.  I even tried using botLookAt() and then botMoveTo() and... nothing.  Not sure what's going on there, but I need to try and setup a way to test this better.

 

Share this post


Link to post
Share on other sites

just played a bit with the bot functions .. and i can't really get them to work.

i have tried to make some bots look at me, and move towards me. the bots were just spinning around doing random shit :/
https://gist.github.com/D4edalus/7a511d1a398060f1acc20bf83c6db8ae

@T-Max could you maybe provide the gsc script for this test? do you know if the bots still work with the masterbranch?

 

Share this post


Link to post
Share on other sites

I was experiencing the weird spinning and everything else, but that was after enabling the code from pezbots to make them follow the way points.  I'll try compiling the master branch and see if they work better.  As far as a test script goes, I'm working within the original pezbot scripts since it has all the path finding logic and logic to test if the bots can actually see a player or not, which prevents them from being able to shoot you through walls and what not.  Trying to preserve as much as possible from it.

If you could try testing with more than one bot and see if they all shoot their weapons.

I'll keep you posted on my progress.

Share this post


Link to post
Share on other sites

Looking at the source code and I'm wondering if this is the problem with the move to function: 

vec2_copy(g_botai[ent_num].moveTo, moveTo);

This probably needs to be updated to a call to vec3_copy()

Downloading dev tools and will make the change and see if it fixes it.

Edited by CodeJunkie

Share this post


Link to post
Share on other sites
1 hour ago, CodeJunkie said:

Looking at the source code and I'm wondering if this is the problem with the move to function: 

vec2_copy(g_botai[ent_num].moveTo, moveTo);

This probably needs to be updated to a call to vec3_copy()

Downloading dev tools and will make the change and see if it fixes it.

Well, I got everything setup, made the change, compiled and tested and the bot just spins in a circle now...Closer though.

Share this post


Link to post
Share on other sites

Well, actually there's no error, you can not force bot to move on Z axis :)

I'll take a look on script functions today. Maybe something is really broken.

Share this post


Link to post
Share on other sites
23 minutes ago, T-Max said:

Well, actually there's no error, you can not force bot to move on Z axis :)

I'll take a look on script functions today. Maybe something is really broken.

Yeah, I dug down deeper and saw that internal function SV_BotUserMove() worked on a 2D plane... :(  Something is funky though.

Share this post


Link to post
Share on other sites

Well, actually you can move bot up and down like it's working with spectator "lean left" and "lean right" buttons but the gravity force like: "Uh, meh".

Share this post


Link to post
Share on other sites

Hi Guys,

This thread remind me about the pezbot mod that helped me in my server for testing & play when Im alone in my server :) .

I tested it recently and found that its not working anymore.. The problem is bots are not firing.. It used to be run fine with older version,  I guess, last I ran it fine on v1.8-16.0  ...

(Though its movement animations are like sliding. Anyway it doesnt matter. But I want those bots to be able to fire like it does in older versions :)  )

 It still works fine with 1.7a build 3360  but not with 1.8 build 1972   (See the demo files attached  (All players are bots except me :) ) )

 

I also tried the bot functions in cod4x, & it doesn't seems to be working. Here is the test script that I used

/*
Use these client side commands to test bots

/openscriptmenu x spawnbot:<number of bots to spawn>
   Example:    /openscriptmenu x spawnbot:3    spawns 3 bots

/openscriptmenu x botaction:<entity number of bot>:<action>
  Example:   /openscriptmenu x botaction:1:+fire      bot with entity number 1 is supposed to fire 
  
/openscriptmenu x botlookat:<entity number of bot>:<entity number of a player>
    Example:   /openscriptmenu x botlookat:1:5      bot with entity number 1 is supposed to look at player whose entity number is 5 

/openscriptmenu x botmoveto:<entity number of bot>:<entity number of a player>
    Example:   /openscriptmenu x botmoveto:1:5      bot with entity number 1 is supposed move to player whose entity number is 5 
*/

init()
{
	precache();

	level thread onPlayerConnected();
	wait 10;
	//	setdvar("svr_pezbots", 10);
}

precache()
{
}

onPlayerConnected()
{

	level endon("game_ended");

	while(1)
	{
		self waittill("connected", peep);
		//	peep thread onSpawnedPlayer();
		peep thread onmenuresponse();
	}

}

onSpawnedPlayer()
{
	self endon("intermission");
	self endon("disconnect");

	self waittill("spawned_player");

}




onmenuresponse()
{
	self endon("disconnect");

	while(1)
	{

		self waittill("menuresponse",menu,response);
		self iprintln("Response:"+response);

		if(issubstr(response,"spawnbot"))
		{
			if(isdefined(strtok(response,":")[1])){
				for(i=0;i<int(strtok(response,":")[1]);i++){
					addBot();
				} 
			}
			else{
				addBot();
			}
		}

			if(issubstr(response,"botmoveto"))
			{   bot= findPlayerByNumber(int(strtok(response,":")[1]));
				if(bot isbot())
				{
				  player=findPlayerByNumber(int(strtok(response,":")[2]));
				   if(isplayer(player))
				   {
				   bot botmoveto(player getorigin()) ;
				   self iprintln("Bot is moving");
				   }
				}
			}
			if(issubstr(response,"botlookat"))
			{   bot= findPlayerByNumber(int(strtok(response,":")[1]));
				if(bot isbot())
				{
				  player=findPlayerByNumber(int(strtok(response,":")[2]));
				   if(isplayer(player))
				   {
				   bot botlookat(player getorigin(), 0.1 ) ;
				   self iprintln("Bot is looking at");
				   }
				}
			}

			if(issubstr(response,"botaction"))
			{   bot= findPlayerByNumber(int(strtok(response,":")[1]));
				if(bot isbot())
				{
				  action=(strtok(response,":")[2]);
				   bot botaction(action) ;
				   self iprintln("Bot is performing an Action");
				}
			}

		}

	}


addBot(team) {
	if(isDefined(team) && team == "myteam")
		bot = addBotClient(self.pers["team"]);
	else 
		bot = addBotClient(level.otherteam[self.pers["team"]]);
	bot setOrigin(self.origin);
}


addBotClient(team) {
	bot = AddTestClient();
	bot.pers["isBot"] = true;
	wait .5;
	if(team == "allies")
		bot [[level.allies]]();
	else
		bot [[level.axis]]();
	wait .5;
	bot notify("menuresponse", "changeclass", "specops_mp,0");
	wait .5;
	bot.sessionstate = "playing";
	bot setRank(54);
	bot.pers["score"] = 0;
	bot.pers["kills"] = 0;
	bot.pers["assists"] = 0;
	bot.pers["deaths"] = 0;
	bot.score = 0;
	bot.kills = 0;
	bot.assists = 0;
	bot.deaths = 0;

	return bot;
}	
	

	findPlayerByNumber( entityNumber ) {
		foundPlayer = undefined;
		entityNumber = int(entityNumber);
		players= getEntArray( "player", "classname" );
		for ( index = 0; index < players.size; index++ ) {
			player = players[index];
			if ( player getEntityNumber() == entityNumber ) {
				foundPlayer = player;
				break;
			}
		}
		return foundPlayer;
	}


	isbot()
	{
		if(self getGuid() == "BOT-Client")
		return true;
		else
		return false;
		
	}

 

 

 

 

 

demo0015_Pezbot_on_v1.7a.dm_1

demo0016_Pezbot_on_v1.8.dm_1

Share this post


Link to post
Share on other sites

Hello, I'm the Frontlines creator and T-Max told me about this thread...

I didn't started yet to work with COD4X, but is my desire to do as soon as possible. :D

My best work with Bots was to Black Frontlines (Black Ops) and there's no relation with PezBots.

Nothing against PezBots, aside I was the only one which stay at his side saying it's possible to make Bots to COD when all the devs said was impossible at that time, I sent all the MOHAA bots documentation that I had to him and I'm glad he succeed few years later!

He did the bots move in the same way I did the R2D2 move in the cancelled gametype to Star Wars mod and also how I did the paratroopers in Frontlines (also the credits). We add a hidden entity, attach the player to that entity, then move the entity... once attached to that entity the player will not be able to walk/run, but still can aim, look around, etc...

So if you are porting PezBots to COD4X, you should not even create that entity. All related code must be removed or the Quake function botMove will not work, since he will be stuck in that entity. Maybe is the problem that you are having right now.

The first thing that I would try, would be simple add a bot, then move it to some location... just to test the function.

Another tip, the latest versions of PezBots weren't made by Pez, and aside added few nice stuff and become a new mod and not just a bot mod anymore, added lots and lots of bugs, and IMO it's almost unplayable. So all my work with PezBot that I did with COD5, MW2 and COD4 Star Wars, I did with the latest version released by Pez (don't remember which is right now).

Even that, my versions are heavily modified, to be more close of what I did in Black Frontlines. The main thing that I use is the paths (waypoints), waypoints maker, anims and basic structure. The bot thinking is all new, mainly because I don't like to play against bots moving over and over at the same paths.

Here you can take a look in the differences in gameplay:

Star Wars doesn't have anims YET!!!

I'm working right now in the Bot Thinking to be able to work with Frontlines in COD4, which is not a simple task since we have 50 different gametypes and lots of options of play in each one.

You can read in details here: http://hajas.freeforums.org/status-bots-to-frontlines-t376.html

The video was posted was a test at our Frontlines Server, it's 24/7 and aside be a "working in progress" state, it's already very stable and you all are free to join to taste yourself. Anims will only be added later.

To connect, type in the console:

/connect war.hajas.org

Then hit enter to download the mod and enjoy the bots.

It's fixed with Domination and one map, witch is randomly pickup at each restart.

Soon as I finished the COD4 version, I'll start to move to COD4X version, which I hope to be very fast and easy to port.

And I think the hard work will be create waypoints too all maps, bacause the original ones are just basic, and not enough to play with Frontlines. How much better are the waypoints, better will be the bots movement in game. Sadly with the original waypoints have several places not reachable, and lots of isolated paths, without links to each other, so when change the objetive, the bots need to make a long turn to go in the right path which would be in few steps from him, making them a lot more stupid.

cheers

 

 

 

Edited by Hajas

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.