2003-02-18 23:11:05 +00:00
|
|
|
/*
|
|
|
|
======================================
|
|
|
|
FrikBot X (Version 0.10.0) QW
|
|
|
|
======================================
|
|
|
|
|
|
|
|
This program is in the Public Domain. My crack legal
|
|
|
|
team would like to add:
|
|
|
|
|
|
|
|
RYAN "FRIKAC" SMITH IS PROVIDING THIS SOFTWARE "AS IS"
|
|
|
|
AND MAKES NO WARRANTY, EXPRESS OR IMPLIED, AS TO THE
|
|
|
|
ACCURACY, CAPABILITY, EFFICIENCY, MERCHANTABILITY, OR
|
|
|
|
FUNCTIONING OF THIS SOFTWARE AND/OR DOCUMENTATION. IN
|
|
|
|
NO EVENT WILL RYAN "FRIKAC" SMITH BE LIABLE FOR ANY
|
|
|
|
GENERAL, CONSEQUENTIAL, INDIRECT, INCIDENTAL,
|
|
|
|
EXEMPLARY, OR SPECIAL DAMAGES, EVEN IF RYAN "FRIKAC"
|
|
|
|
SMITH HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
|
DAMAGES, IRRESPECTIVE OF THE CAUSE OF SUCH DAMAGES.
|
|
|
|
|
|
|
|
You accept this software on the condition that you
|
|
|
|
indemnify and hold harmless Ryan "FrikaC" Smith from
|
|
|
|
any and all liability or damages to third parties,
|
|
|
|
including attorney fees, court costs, and other
|
|
|
|
related costs and expenses, arising out of your use
|
|
|
|
of this software irrespective of the cause of said
|
|
|
|
liability.
|
|
|
|
|
|
|
|
The export from the United States or the subsequent
|
|
|
|
reexport of this software is subject to compliance
|
|
|
|
with United States export control and munitions
|
|
|
|
control restrictions. You agree that in the event you
|
|
|
|
seek to export this software, you assume full
|
|
|
|
responsibility for obtaining all necessary export
|
|
|
|
licenses and approvals and for assuring compliance
|
|
|
|
with applicable reexport restrictions.
|
|
|
|
|
|
|
|
Any reproduction of this software must contain
|
|
|
|
this notice in its entirety.
|
|
|
|
|
|
|
|
======================================
|
|
|
|
These installation instructions only apply to QuakeWorld (as does this entire
|
|
|
|
file). For Normal Quake, please refer to bot.qc
|
|
|
|
|
|
|
|
--------------------------------------
|
|
|
|
To install on a new mod, do all this:
|
|
|
|
--------------------------------------
|
2003-03-05 04:59:11 +00:00
|
|
|
FIXME installing and linking instrunctions here
|
2003-02-18 23:11:05 +00:00
|
|
|
--------------------------------------
|
2003-03-04 21:59:49 +00:00
|
|
|
* Comment out the following functions in defs.qc
|
|
|
|
sound, aim, setspawnparms
|
|
|
|
--------------------------------------
|
2003-02-18 23:11:05 +00:00
|
|
|
* Add this to worldspawn() in world.qc, right at the very top, before InitBodyQue();
|
|
|
|
BotInit(); // FrikBot
|
|
|
|
--------------------------------------
|
|
|
|
* add this line to StartFrame() in world.qc, at the very top
|
|
|
|
BotFrame(); // FrikBot
|
|
|
|
--------------------------------------
|
|
|
|
* Add these two lines to PlayerPreThink in client.qc at the very top
|
|
|
|
if (BotPreFrame()) // FrikBot
|
|
|
|
return;
|
|
|
|
--------------------------------------
|
|
|
|
* Add this line to PlayerPostThink in client.qc at the very top
|
|
|
|
if (BotPostFrame()) // FrikBot
|
|
|
|
return;
|
|
|
|
--------------------------------------
|
|
|
|
* Add the following line to the very top of Client Connect in client.qc
|
|
|
|
ClientInRankings(); // FrikBot
|
|
|
|
--------------------------------------
|
|
|
|
* Add these lines to the very top of ClientDisconnect in client.qc
|
|
|
|
ClientDisconnected(); // FrikBot
|
|
|
|
--------------------------------------
|
|
|
|
* Add these lines to the very top of SpectatorConnect in spectate.qc
|
|
|
|
ClientFixRankings(); // FrikBot
|
|
|
|
--------------------------------------
|
|
|
|
*/
|
|
|
|
|
2003-02-24 16:05:25 +00:00
|
|
|
#include "libfrikbot.h"
|
|
|
|
|
2003-03-13 19:15:42 +00:00
|
|
|
@implementation Bot
|
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
return [super init];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithEntity:(entity) e
|
|
|
|
{
|
|
|
|
return [super initWithEntity:e];
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
void ()
|
|
|
|
bot_map_load =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
// place your qc loaded waypoints here
|
2003-03-08 03:20:32 +00:00
|
|
|
switch (mapname) {
|
|
|
|
case "dm1":
|
|
|
|
map_dm1 ();
|
|
|
|
break;
|
|
|
|
case "dm2":
|
|
|
|
map_dm2 ();
|
|
|
|
break;
|
|
|
|
case "dm3":
|
|
|
|
map_dm3 ();
|
|
|
|
break;
|
|
|
|
case "dm4":
|
|
|
|
map_dm4 ();
|
|
|
|
break;
|
|
|
|
case "dm5":
|
|
|
|
map_dm5 ();
|
|
|
|
break;
|
|
|
|
case "dm6":
|
|
|
|
map_dm6 ();
|
2003-03-08 05:43:26 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-02-18 23:11:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
Variables and shtuff
|
|
|
|
|
|
|
|
bot.qc has become pretty much a header file
|
|
|
|
for all variable in the bot...
|
|
|
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
*/
|
|
|
|
|
2003-03-04 07:29:42 +00:00
|
|
|
entity [32] players;
|
|
|
|
entity [32] phys_objects;
|
|
|
|
|
2003-02-18 23:11:05 +00:00
|
|
|
// ----- entity fields ---
|
|
|
|
.float wallhug, keys, oldkeys, ishuman;
|
2003-03-04 07:29:42 +00:00
|
|
|
.float b_frags, b_shirt, b_pants;
|
|
|
|
.integer b_clientno;
|
2003-03-05 00:10:15 +00:00
|
|
|
.float ai_time, b_sound, missile_speed;
|
2003-03-05 03:57:55 +00:00
|
|
|
.float portal_time;
|
|
|
|
.integer b_skill;
|
|
|
|
.float switch_wallhug;
|
2003-02-18 23:11:05 +00:00
|
|
|
.float b_aiflags, b_num, b_chattime;
|
2003-03-04 23:19:07 +00:00
|
|
|
.float b_entertime; // QW shtuff
|
2003-02-18 23:11:05 +00:00
|
|
|
.float b_menu, b_menu_time, b_menu_value;
|
|
|
|
.float route_failed, dyn_flags, dyn_time;
|
|
|
|
.float dyn_plat;
|
|
|
|
.entity temp_way, last_way, phys_obj;
|
|
|
|
.entity target1, target2, target3, target4;
|
|
|
|
.entity _next, _last;
|
|
|
|
.entity current_way;
|
2003-03-05 00:10:15 +00:00
|
|
|
.vector b_angle, mouse_emu, obs_dir;
|
2003-02-18 23:11:05 +00:00
|
|
|
.vector movevect, b_dir;
|
|
|
|
.vector dyn_dest;
|
|
|
|
.vector punchangle; // HACK - Don't want to screw with bot_phys
|
|
|
|
|
|
|
|
// -------globals-----
|
2003-03-04 07:29:42 +00:00
|
|
|
integer max_clients;
|
|
|
|
float real_frametime;
|
2003-02-18 23:11:05 +00:00
|
|
|
float bot_count, b_options, lasttime;
|
|
|
|
float waypoint_mode, dump_mode;
|
|
|
|
float waypoints, direct_route, userid;
|
|
|
|
float sv_friction, sv_gravity;
|
|
|
|
float sv_accelerate, sv_maxspeed, sv_stopspeed;
|
|
|
|
entity fixer;
|
|
|
|
entity route_table;
|
|
|
|
entity b_temp1, b_temp2, b_temp3;
|
2003-03-04 07:29:42 +00:00
|
|
|
entity way_head;
|
2003-02-18 23:11:05 +00:00
|
|
|
float busy_waypoints;
|
|
|
|
|
|
|
|
float coop = 0; // hack
|
|
|
|
|
2003-03-04 21:59:49 +00:00
|
|
|
void(entity e, float chan, string samp, float vol, float atten) frik_sound = #8;
|
|
|
|
vector(entity e, float sped) frik_aim = #44;
|
|
|
|
void(entity e) frik_setspawnparms = #78;
|
|
|
|
|
2003-03-04 07:29:42 +00:00
|
|
|
entity () SV_AllocClient = #0;
|
|
|
|
void (entity e) SV_FreeClient = #0;
|
2003-03-04 17:46:04 +00:00
|
|
|
void (entity e, string str) SV_SetUserinfo = #0;
|
2003-03-05 03:57:55 +00:00
|
|
|
void (entity e, integer ping) SV_SetPing = #0;
|
2003-03-10 23:54:41 +00:00
|
|
|
void (entity cl, float sec, vector angles, vector move, integer buttons, integer impulse) SV_UserCmd = #0;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2003-03-04 21:59:49 +00:00
|
|
|
/*
|
|
|
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
2003-03-08 03:20:32 +00:00
|
|
|
Function redeclarations. These allow function
|
2003-03-04 21:59:49 +00:00
|
|
|
designed to work for clients (sprint, so forth)
|
|
|
|
to mainly not complain when working with a bot
|
|
|
|
|
|
|
|
Although these shouldn't be needed anymore,
|
|
|
|
as the bots truly are clients now, if you don't
|
|
|
|
stop the SZ_ buffer from filling up by disabling
|
|
|
|
direct messages to the bots, it crashes quake :-(
|
|
|
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
*/
|
2003-03-08 03:20:32 +00:00
|
|
|
void (entity e)
|
|
|
|
setspawnparms =
|
2003-03-04 21:59:49 +00:00
|
|
|
{
|
|
|
|
if (e.ishuman)
|
2003-03-08 03:20:32 +00:00
|
|
|
frik_setspawnparms (e);
|
2003-03-04 21:59:49 +00:00
|
|
|
else
|
2003-03-08 03:20:32 +00:00
|
|
|
SetNewParms ();
|
2003-03-04 21:59:49 +00:00
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
vector (entity e, float sped)
|
|
|
|
aim =
|
2003-03-04 21:59:49 +00:00
|
|
|
{
|
|
|
|
e.missile_speed = sped;
|
2003-03-08 03:20:32 +00:00
|
|
|
return frik_aim (e, sped);
|
2003-03-04 21:59:49 +00:00
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
void (entity e, float chan, string samp, float vol, float atten)
|
|
|
|
sound =
|
2003-03-04 21:59:49 +00:00
|
|
|
{
|
2003-03-08 03:20:32 +00:00
|
|
|
frik_sound (e, chan, samp, vol, atten);
|
2003-03-04 21:59:49 +00:00
|
|
|
if (samp == "items/inv3.wav")
|
|
|
|
return;
|
|
|
|
else if (e.classname == "player")
|
|
|
|
e.b_sound = time + 1;
|
|
|
|
else if (other.classname == "player")
|
|
|
|
other.b_sound = time + 1;
|
|
|
|
};
|
2003-02-18 23:11:05 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
Stuff mentioned up top
|
|
|
|
it just links the bot into the mod
|
|
|
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
*/
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
void ()
|
|
|
|
ClientFixRankings =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-04 07:29:42 +00:00
|
|
|
local integer cno;
|
2003-02-18 23:11:05 +00:00
|
|
|
if (self.switch_wallhug > time)
|
|
|
|
return;
|
|
|
|
self.switch_wallhug = 0;
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
b_temp2 = nextent (NIL);
|
2003-02-18 23:11:05 +00:00
|
|
|
cno = 0;
|
|
|
|
|
2003-03-04 18:26:17 +00:00
|
|
|
while (cno < max_clients) {
|
|
|
|
if (!b_temp2.ishuman) {
|
2003-03-04 07:29:42 +00:00
|
|
|
if (players[cno])
|
2003-03-08 03:20:32 +00:00
|
|
|
UpdateClient (b_temp2);
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
2003-03-04 07:29:42 +00:00
|
|
|
cno++;
|
2003-03-08 03:20:32 +00:00
|
|
|
b_temp2 = nextent (b_temp2);
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
void ()
|
|
|
|
ClientInRankings =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
local float cno;
|
2003-03-04 07:29:42 +00:00
|
|
|
local integer cl_no = ClientNumber (self);
|
2003-02-21 15:33:05 +00:00
|
|
|
|
2003-03-04 07:29:42 +00:00
|
|
|
players[cl_no] = self;
|
|
|
|
self.b_clientno = cl_no + 1;
|
2003-03-04 17:46:04 +00:00
|
|
|
userid++;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-03-04 07:29:42 +00:00
|
|
|
self.phys_obj = phys_objects[cl_no];
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-03-04 18:26:17 +00:00
|
|
|
if (self.ishuman == 2) {
|
2003-02-18 23:11:05 +00:00
|
|
|
self.ishuman = FALSE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cno = self.colormap - 1;
|
2003-03-04 07:29:42 +00:00
|
|
|
self.b_clientno = (integer) cno;
|
2003-02-18 23:11:05 +00:00
|
|
|
self.ishuman = TRUE;
|
|
|
|
self.switch_wallhug = time + 1;
|
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
void ()
|
|
|
|
ClientDisconnected =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-04 07:29:42 +00:00
|
|
|
local integer cl_no = ClientNumber (self);
|
|
|
|
players[cl_no] = NIL;
|
2003-02-18 23:11:05 +00:00
|
|
|
};
|
2003-03-08 03:20:32 +00:00
|
|
|
|
2003-02-18 23:11:05 +00:00
|
|
|
/*
|
|
|
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
|
|
|
|
BotPreFrame & BotPostFrame, used to make the
|
|
|
|
bot easier to install
|
|
|
|
|
|
|
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
*/
|
2003-03-08 03:20:32 +00:00
|
|
|
float ()
|
|
|
|
BotPreFrame =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
if (self.b_clientno == -1)
|
|
|
|
return TRUE;
|
|
|
|
if (self.ishuman)
|
|
|
|
if (self.switch_wallhug)
|
2003-03-08 03:20:32 +00:00
|
|
|
ClientFixRankings ();
|
2003-03-04 18:26:17 +00:00
|
|
|
if (self.b_frags != self.frags) {
|
|
|
|
if (self.b_frags > self.frags) {
|
2003-03-08 03:20:32 +00:00
|
|
|
if (pointcontents (self.origin) == CONTENT_LAVA)
|
|
|
|
bot_start_topic (10);
|
2003-02-18 23:11:05 +00:00
|
|
|
else
|
2003-03-08 03:20:32 +00:00
|
|
|
bot_start_topic (9);
|
2003-03-04 18:26:17 +00:00
|
|
|
} else
|
2003-03-08 03:20:32 +00:00
|
|
|
bot_start_topic (2);
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_frags = self.frags;
|
|
|
|
}
|
|
|
|
DynamicWaypoint();
|
|
|
|
return FALSE;
|
|
|
|
};
|
2003-03-08 03:20:32 +00:00
|
|
|
float ()
|
|
|
|
BotPostFrame =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
if (self.b_clientno == -1)
|
|
|
|
return TRUE;
|
|
|
|
if (self.ishuman)
|
2003-03-08 03:20:32 +00:00
|
|
|
BotImpulses ();
|
2003-02-18 23:11:05 +00:00
|
|
|
return FALSE;
|
|
|
|
};
|
2003-03-08 03:20:32 +00:00
|
|
|
|
2003-02-18 23:11:05 +00:00
|
|
|
/*
|
|
|
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
|
|
|
|
Bot Chat code
|
|
|
|
|
|
|
|
The rest of this code is in bot_rank.qc
|
|
|
|
|
|
|
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
*/
|
2003-03-08 03:20:32 +00:00
|
|
|
void (string h)
|
|
|
|
BotSay = // simulate talking by composing a 'chat' message
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-08 03:20:32 +00:00
|
|
|
WriteByte (MSG_ALL, 8);
|
|
|
|
WriteByte (MSG_ALL, 3);
|
|
|
|
WriteByte (MSG_ALL, 1);
|
|
|
|
WriteString (MSG_ALL, self.netname);
|
|
|
|
WriteByte (MSG_ALL, 8);
|
|
|
|
WriteByte (MSG_ALL, 3);
|
|
|
|
WriteByte (MSG_ALL, 2);
|
|
|
|
WriteString (MSG_ALL, h);
|
2003-02-18 23:11:05 +00:00
|
|
|
};
|
2003-03-08 03:20:32 +00:00
|
|
|
|
|
|
|
void ()
|
|
|
|
BotSayInit =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-08 03:20:32 +00:00
|
|
|
WriteByte (MSG_ALL, 8);
|
|
|
|
WriteByte (MSG_ALL, 3);
|
|
|
|
WriteByte (MSG_ALL, 1);
|
|
|
|
WriteString (MSG_ALL, self.netname);
|
2003-02-18 23:11:05 +00:00
|
|
|
};
|
2003-03-08 03:20:32 +00:00
|
|
|
void (string h)
|
|
|
|
BotSay2 =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-08 03:20:32 +00:00
|
|
|
WriteByte (MSG_ALL, 8);
|
|
|
|
WriteByte (MSG_ALL, 3);
|
|
|
|
WriteByte (MSG_ALL, 2);
|
|
|
|
WriteString (MSG_ALL, h);
|
2003-02-18 23:11:05 +00:00
|
|
|
};
|
2003-03-08 03:20:32 +00:00
|
|
|
void (string h)
|
|
|
|
BotSayTeam =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
// FBX QW doesn't support teamplay...yet
|
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
// BotInit ====================================================================
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
void ()
|
|
|
|
BotInit =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-04 07:29:42 +00:00
|
|
|
local entity ent;
|
|
|
|
local integer numents = 0;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
|
|
|
// spawn entities for the physics
|
2003-03-08 03:20:32 +00:00
|
|
|
ent = nextent (NIL);
|
2003-02-18 23:11:05 +00:00
|
|
|
max_clients = 0;
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
while (ent != NIL) {
|
|
|
|
max_clients++;
|
|
|
|
ent = nextent (ent);
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
ent = nextent (NIL);
|
2003-03-04 18:26:17 +00:00
|
|
|
while (numents < max_clients) {
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
phys_objects[numents] = spawn ();
|
2003-03-04 07:29:42 +00:00
|
|
|
phys_objects[numents].classname = "phys_obj";
|
|
|
|
phys_objects[numents].owner = ent;
|
|
|
|
numents++;
|
2003-03-08 03:20:32 +00:00
|
|
|
ent = nextent (ent);
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
2003-03-08 03:20:32 +00:00
|
|
|
bot_map_load ();
|
2003-02-18 23:11:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
Rankings 'utilities'. Written by Alan Kivlin,
|
|
|
|
this code just fools clients by sending precisely
|
|
|
|
the same network messages as when a real player
|
|
|
|
signs on to the server.
|
|
|
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
*/
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
void (entity who)
|
|
|
|
UpdateClient =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-04 17:46:04 +00:00
|
|
|
local string bottomcolor = ftos (who.b_pants);
|
|
|
|
local string topcolor = ftos (who.b_shirt);
|
2003-03-08 03:20:32 +00:00
|
|
|
|
|
|
|
dprint (who.netname);
|
|
|
|
dprint ("\n");
|
2003-03-05 03:57:55 +00:00
|
|
|
SV_SetPing (who, 100 * (3 - who.b_skill));
|
2003-03-04 17:46:04 +00:00
|
|
|
SV_SetUserinfo (who, "\\bottomcolor\\" + bottomcolor
|
|
|
|
+ "\\topcolor\\" + topcolor
|
|
|
|
+ "\\team\\bot\\skin\\base\\name\\" + who.netname);
|
2003-02-18 23:11:05 +00:00
|
|
|
// FIXME: do teams properly
|
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
float (integer clientno)
|
|
|
|
ClientBitFlag =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
local float bitflag;
|
2003-03-08 03:20:32 +00:00
|
|
|
|
2003-02-18 23:11:05 +00:00
|
|
|
bitflag = 1;
|
2003-03-08 03:20:32 +00:00
|
|
|
while (clientno > 0) {
|
|
|
|
bitflag *= 2;
|
|
|
|
clientno--;
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
return bitflag;
|
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
integer ()
|
|
|
|
ClientNextAvailable =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-04 07:29:42 +00:00
|
|
|
local integer clientno;
|
2003-03-08 03:20:32 +00:00
|
|
|
|
2003-02-18 23:11:05 +00:00
|
|
|
// I want to do this top down, but QW won't let me
|
|
|
|
clientno = 0;
|
2003-03-08 03:20:32 +00:00
|
|
|
while (clientno < max_clients) {
|
|
|
|
clientno++;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
//FIXME if (!ClientIsActive (clientno))
|
2003-02-18 23:11:05 +00:00
|
|
|
return clientno;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
};
|
|
|
|
|
|
|
|
void(entity e1, entity e2, float flag) DeveloperLightning = {};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
// BotConnect and related functions. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
entity (float num)
|
|
|
|
GetClientEntity =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
local entity upsy;
|
2003-03-08 03:20:32 +00:00
|
|
|
|
2003-02-24 16:05:25 +00:00
|
|
|
upsy = NIL;
|
2003-03-08 03:20:32 +00:00
|
|
|
num++;
|
2003-03-04 18:26:17 +00:00
|
|
|
while (num > 0) {
|
2003-03-08 03:20:32 +00:00
|
|
|
num--;
|
|
|
|
upsy = nextent (upsy);
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
return upsy;
|
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
integer (entity cl)
|
|
|
|
ClientNumber =
|
2003-03-04 07:29:42 +00:00
|
|
|
{
|
|
|
|
local entity e = NIL;
|
|
|
|
local integer f = -1;
|
|
|
|
|
|
|
|
do {
|
|
|
|
f++;
|
|
|
|
e = nextent (e);
|
|
|
|
} while (e != cl);
|
|
|
|
return f;
|
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
void (float whatbot, integer whatskill)
|
|
|
|
BotConnect =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-04 07:29:42 +00:00
|
|
|
local integer f;
|
2003-02-18 23:11:05 +00:00
|
|
|
local entity uself;
|
|
|
|
|
2003-03-04 07:29:42 +00:00
|
|
|
//f = ClientNextAvailable();
|
2003-02-18 23:11:05 +00:00
|
|
|
uself = self;
|
2003-03-04 07:29:42 +00:00
|
|
|
self = SV_AllocClient ();
|
|
|
|
if (!self) {
|
2003-03-08 03:20:32 +00:00
|
|
|
bprint (PRINT_HIGH, "Unable to connect a bot, server is full.\n");
|
2003-03-04 07:29:42 +00:00
|
|
|
self = uself;
|
2003-02-18 23:11:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-03-04 07:29:42 +00:00
|
|
|
bot_count++;
|
2003-03-08 03:20:32 +00:00
|
|
|
bot_start_topic (1);
|
2003-03-04 07:29:42 +00:00
|
|
|
f = ClientNumber (self) + 1;
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_clientno = f;
|
2003-03-06 22:06:59 +00:00
|
|
|
self.colormap = (float) f;
|
2003-02-18 23:11:05 +00:00
|
|
|
if (whatbot)
|
2003-03-08 03:20:32 +00:00
|
|
|
self.netname = BotName (whatbot);
|
2003-02-18 23:11:05 +00:00
|
|
|
else
|
2003-03-08 03:20:32 +00:00
|
|
|
self.netname = PickARandomName ();
|
2003-02-18 23:11:05 +00:00
|
|
|
|
|
|
|
// players can set skill all weird, so leave these checks in
|
|
|
|
if (whatskill > 3)
|
|
|
|
whatskill = 3;
|
|
|
|
else if (whatskill < 0)
|
|
|
|
whatskill = 0;
|
|
|
|
self.b_skill = whatskill;
|
|
|
|
self.b_entertime = time;
|
|
|
|
self.team = self.b_pants + 1;
|
2003-03-08 03:20:32 +00:00
|
|
|
UpdateClient (self);
|
|
|
|
SetNewParms ();
|
2003-02-18 23:11:05 +00:00
|
|
|
self.ishuman = 2;
|
2003-03-08 03:20:32 +00:00
|
|
|
ClientConnect ();
|
|
|
|
PutClientInServer ();
|
2003-02-18 23:11:05 +00:00
|
|
|
self = uself;
|
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
void (entity bot)
|
|
|
|
BotDisconnect =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
local entity uself;
|
2003-03-08 03:20:32 +00:00
|
|
|
|
2003-02-18 23:11:05 +00:00
|
|
|
uself = self;
|
|
|
|
self = bot;
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
bot_count--;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
ClientDisconnect ();
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-03-05 18:16:46 +00:00
|
|
|
setmodel (self.phys_obj, "");
|
|
|
|
SV_FreeClient (self);
|
2003-02-18 23:11:05 +00:00
|
|
|
self = uself;
|
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
void ()
|
|
|
|
BotFrame =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-04 07:29:42 +00:00
|
|
|
local integer num;
|
2003-02-18 23:11:05 +00:00
|
|
|
local string h;
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
h = infokey (NIL, "bot_options");
|
|
|
|
b_options = stof (h);
|
2003-02-18 23:11:05 +00:00
|
|
|
|
|
|
|
// for the sake of speed
|
2003-03-08 03:20:32 +00:00
|
|
|
sv_maxspeed = cvar ("sv_maxspeed");
|
|
|
|
sv_gravity = cvar ("sv_gravity");
|
|
|
|
sv_friction = cvar ("sv_friction");
|
|
|
|
sv_accelerate = cvar ("sv_accelerate");
|
|
|
|
sv_stopspeed = cvar ("sv_stopspeed");
|
2003-02-18 23:11:05 +00:00
|
|
|
real_frametime = time - lasttime; // in QW frametime is fuxx0red
|
|
|
|
lasttime = time;
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
self = nextent (NIL);
|
2003-02-18 23:11:05 +00:00
|
|
|
num = 0;
|
2003-03-04 18:26:17 +00:00
|
|
|
while (num < max_clients) {
|
|
|
|
if (self.ishuman == FALSE) {
|
|
|
|
if (self.b_clientno > 0) {
|
2003-03-08 03:20:32 +00:00
|
|
|
frik_obstacles ();
|
|
|
|
CL_KeyMove ();
|
|
|
|
SV_ClientThink ();
|
|
|
|
SV_Physics_Client ();
|
2003-02-18 23:11:05 +00:00
|
|
|
// this is sickening
|
2003-03-04 18:26:17 +00:00
|
|
|
if (self.phys_obj) {
|
|
|
|
if (self.phys_obj.modelindex != self.modelindex) {
|
2003-02-18 23:11:05 +00:00
|
|
|
setmodel(self.phys_obj, "progs/player.mdl");
|
|
|
|
self.phys_obj.modelindex = self.modelindex;
|
|
|
|
}
|
|
|
|
self.phys_obj.frame = self.frame;
|
|
|
|
self.phys_obj.angles = self.angles;
|
|
|
|
self.phys_obj.colormap = self.colormap;
|
|
|
|
self.phys_obj.effects = self.effects;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-03-08 03:20:32 +00:00
|
|
|
self = nextent (self);
|
|
|
|
num++;
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Bot Impulses. Allows the player to perform bot
|
|
|
|
related functions.
|
|
|
|
*/
|
2003-03-08 03:20:32 +00:00
|
|
|
void () BotImpulses =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-05 03:57:55 +00:00
|
|
|
local integer f;
|
2003-02-18 23:11:05 +00:00
|
|
|
local string h;
|
|
|
|
|
2003-03-04 18:26:17 +00:00
|
|
|
if (self.impulse == 100) {
|
2003-03-08 03:20:32 +00:00
|
|
|
h = infokey (NIL, "skill");
|
|
|
|
f = (integer) stof (h);
|
|
|
|
BotConnect (0, f);
|
2003-03-04 18:26:17 +00:00
|
|
|
} else if (self.impulse == 102)
|
2003-03-08 03:20:32 +00:00
|
|
|
KickABot ();
|
2003-02-18 23:11:05 +00:00
|
|
|
else
|
|
|
|
return;
|
|
|
|
self.impulse = 0;
|
2003-02-18 23:12:03 +00:00
|
|
|
};
|