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-08-22 20:14:04 +00:00
|
|
|
* Change all occurrences of "self" to "@self". One way of doing this is to
|
|
|
|
pass the code through a preprocessor with "-Dself=@self"
|
|
|
|
--------------------------------------
|
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 this line to PlayerPostThink in client.qc at the very top
|
2003-08-22 19:57:44 +00:00
|
|
|
BotImpulses (); // FrikBot
|
2003-02-18 23:11:05 +00:00
|
|
|
--------------------------------------
|
|
|
|
* 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-08-31 06:18:37 +00:00
|
|
|
#include "cmd.h"
|
2003-02-24 16:05:25 +00:00
|
|
|
|
2003-08-18 06:30:05 +00:00
|
|
|
integer []bot_way_ref;
|
|
|
|
integer []bot_move_ref;
|
|
|
|
integer []bot_chat_ref;
|
|
|
|
float []stagger_think_ref;
|
|
|
|
integer []bot_fight_ref;
|
|
|
|
|
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-07-24 21:54:24 +00:00
|
|
|
Bot [32] players;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
|
|
|
// -------globals-----
|
2003-03-04 07:29:42 +00:00
|
|
|
float real_frametime;
|
2003-02-18 23:11:05 +00:00
|
|
|
float bot_count, b_options, lasttime;
|
|
|
|
float waypoint_mode, dump_mode;
|
2003-07-24 23:16:43 +00:00
|
|
|
float direct_route;
|
2003-02-18 23:11:05 +00:00
|
|
|
float sv_friction, sv_gravity;
|
|
|
|
float sv_accelerate, sv_maxspeed, sv_stopspeed;
|
2003-07-24 18:23:13 +00:00
|
|
|
Bot route_table;
|
2003-07-24 23:16:43 +00:00
|
|
|
integer busy_waypoints;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
|
|
|
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-08-21 03:53:15 +00:00
|
|
|
void (entity cl) SV_Spawn = #0;
|
2003-09-04 07:44:47 +00:00
|
|
|
void () Break = #6;
|
|
|
|
string (integer i) itos = #112;
|
2003-07-29 20:27:41 +00:00
|
|
|
|
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
|
|
|
{
|
2003-07-24 21:54:24 +00:00
|
|
|
if (((Bot)e.@this).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
|
|
|
{
|
2003-07-24 21:54:24 +00:00
|
|
|
((Bot)e.@this).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")
|
2003-07-24 21:54:24 +00:00
|
|
|
((Bot)e.@this).b_sound = time + 1;
|
2003-03-04 21:59:49 +00:00
|
|
|
else if (other.classname == "player")
|
2003-07-24 21:54:24 +00:00
|
|
|
((Bot)other.@this).b_sound = time + 1;
|
2003-03-04 21:59:49 +00:00
|
|
|
};
|
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-07-24 21:54:24 +00:00
|
|
|
local Bot bot = @self.@this;
|
|
|
|
local entity btmp;
|
|
|
|
local Bot btmp_bot;
|
|
|
|
|
|
|
|
if (bot.switch_wallhug > time)
|
2003-02-18 23:11:05 +00:00
|
|
|
return;
|
2003-07-24 21:54:24 +00:00
|
|
|
bot.switch_wallhug = 0;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-07-24 21:54:24 +00:00
|
|
|
btmp = nextent (NIL);
|
2003-07-24 23:16:43 +00:00
|
|
|
for (cno = 0; cno < 32; cno++) {
|
2003-07-24 21:54:24 +00:00
|
|
|
btmp_bot = btmp.@this;
|
|
|
|
if (!btmp_bot.ishuman) {
|
2003-03-04 07:29:42 +00:00
|
|
|
if (players[cno])
|
2003-07-31 16:57:01 +00:00
|
|
|
[btmp_bot updateClient];
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
2003-03-04 07:29:42 +00:00
|
|
|
cno++;
|
2003-07-24 21:54:24 +00:00
|
|
|
btmp = nextent (btmp);
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
};
|
2003-08-22 16:19:42 +00:00
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
void ()
|
|
|
|
ClientInRankings =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-07-24 21:54:24 +00:00
|
|
|
local integer cl_no = ClientNumber (@self);
|
2003-02-21 15:33:05 +00:00
|
|
|
|
2003-08-18 06:30:05 +00:00
|
|
|
if (!players[cl_no])
|
|
|
|
players[cl_no] = [[Bot alloc] initFromPlayer:@self];
|
2003-02-18 23:11:05 +00:00
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
void ()
|
|
|
|
ClientDisconnected =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-07-29 20:09:30 +00:00
|
|
|
local integer cl_no = ClientNumber (@self);
|
2003-09-02 06:25:03 +00:00
|
|
|
local Bot p = NIL;
|
|
|
|
|
|
|
|
p = players[cl_no];
|
2003-03-04 07:29:42 +00:00
|
|
|
players[cl_no] = NIL;
|
2003-09-02 06:25:03 +00:00
|
|
|
if (p) {
|
|
|
|
local entity e = p.ent;
|
|
|
|
local integer i;
|
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
if (!players[i])
|
|
|
|
continue;
|
|
|
|
if (players[i].ent.enemy == e)
|
|
|
|
[players[i] lost:p:0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[p dealloc];
|
2003-02-18 23:11:05 +00:00
|
|
|
};
|
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
|
|
|
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-04-07 18:25:14 +00:00
|
|
|
void (integer whatbot, integer whatskill)
|
2003-03-08 03:20:32 +00:00
|
|
|
BotConnect =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-08-01 05:25:07 +00:00
|
|
|
local entity cl;
|
2003-07-24 21:54:24 +00:00
|
|
|
local Bot bot;
|
2003-08-01 05:25:07 +00:00
|
|
|
local bot_data_t [] name;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-08-01 05:25:07 +00:00
|
|
|
cl = SV_AllocClient ();
|
|
|
|
if (!cl) {
|
2003-03-08 03:20:32 +00:00
|
|
|
bprint (PRINT_HIGH, "Unable to connect a bot, server is full.\n");
|
2003-02-18 23:11:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-08-01 05:25:07 +00:00
|
|
|
|
2003-02-18 23:11:05 +00:00
|
|
|
if (whatbot)
|
2003-08-01 05:25:07 +00:00
|
|
|
name = [Bot name:whatbot];
|
2003-02-18 23:11:05 +00:00
|
|
|
else
|
2003-08-01 05:25:07 +00:00
|
|
|
name = [Bot randomName];
|
|
|
|
|
|
|
|
bot = [[Bot alloc] initWithEntity: cl named:name skill:whatskill];
|
2003-08-18 16:48:53 +00:00
|
|
|
[bot startTopic:1];
|
2003-07-24 21:54:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Bot Impulses. Allows the player to perform bot
|
|
|
|
related functions.
|
|
|
|
*/
|
|
|
|
void () BotImpulses =
|
|
|
|
{
|
|
|
|
local integer f;
|
|
|
|
local string h;
|
|
|
|
|
2003-07-29 20:09:30 +00:00
|
|
|
if (@self.impulse == 100) {
|
2003-07-24 21:54:24 +00:00
|
|
|
h = infokey (NIL, "skill");
|
|
|
|
f = (integer) stof (h);
|
|
|
|
BotConnect (0, f);
|
2003-07-29 20:09:30 +00:00
|
|
|
} else if (@self.impulse == 102)
|
2003-07-24 21:54:24 +00:00
|
|
|
[Bot kick];
|
|
|
|
else
|
|
|
|
return;
|
2003-07-29 20:09:30 +00:00
|
|
|
@self.impulse = 0;
|
2003-07-24 21:54:24 +00:00
|
|
|
};
|
|
|
|
|
2003-08-31 06:18:37 +00:00
|
|
|
void ()
|
|
|
|
bot_add_f =
|
|
|
|
{
|
|
|
|
local integer whatbot = 0;
|
|
|
|
local integer skill;
|
|
|
|
local integer c = Cmd_Argc ();
|
|
|
|
|
|
|
|
if (c == 1) {
|
|
|
|
skill = (integer) stof (infokey (NIL, "skill"));
|
|
|
|
} else if (c == 2) {
|
|
|
|
skill = (integer) stof (Cmd_Argv (1));
|
|
|
|
} else {
|
|
|
|
whatbot = (integer) stof (Cmd_Argv (1));
|
|
|
|
skill = (integer) stof (Cmd_Argv (2));
|
|
|
|
}
|
|
|
|
BotConnect (whatbot, skill);
|
|
|
|
};
|
|
|
|
|
|
|
|
void ()
|
|
|
|
bot_kick_f =
|
|
|
|
{
|
|
|
|
[Bot kick];
|
|
|
|
};
|
|
|
|
|
|
|
|
// BotInit ====================================================================
|
|
|
|
|
|
|
|
void ()
|
|
|
|
BotInit =
|
|
|
|
{
|
|
|
|
[Waypoint clearAll];
|
|
|
|
bot_way_ref = &bot_way_linker;
|
|
|
|
bot_move_ref = &bot_move_linker;
|
|
|
|
bot_chat_ref = &bot_chat_linker;
|
|
|
|
stagger_think_ref = &stagger_think;
|
|
|
|
bot_fight_ref = &bot_fight_linker;
|
|
|
|
bot_map_load ();
|
|
|
|
Cmd_AddCommand ("bot_add", bot_add_f);
|
|
|
|
Cmd_AddCommand ("bot_kick", bot_kick_f);
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
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.
|
|
|
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
*/
|
|
|
|
|
|
|
|
void(Waypoint e1, Waypoint e2, integer flag) DeveloperLightning = {};
|
|
|
|
|
2003-07-24 21:54:24 +00:00
|
|
|
@implementation Bot
|
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
return [super init];
|
|
|
|
}
|
|
|
|
|
2003-08-01 05:25:07 +00:00
|
|
|
- (id) initWithEntity:(entity) e named:(bot_data_t [])name skill:(integer)skill
|
2003-07-24 21:54:24 +00:00
|
|
|
{
|
2003-08-22 16:19:42 +00:00
|
|
|
local integer cl_no = ClientNumber (e);
|
2003-08-01 05:25:07 +00:00
|
|
|
local entity uself;
|
2003-07-24 21:54:24 +00:00
|
|
|
|
2003-08-21 03:53:15 +00:00
|
|
|
SV_Spawn (e);
|
|
|
|
|
2003-07-24 21:54:24 +00:00
|
|
|
if (!(self = [super initWithEntity:e]))
|
|
|
|
return NIL;
|
|
|
|
|
2003-08-25 05:12:41 +00:00
|
|
|
[self add];
|
|
|
|
|
2003-08-22 16:19:42 +00:00
|
|
|
players[cl_no] = self;
|
|
|
|
|
2003-07-24 21:54:24 +00:00
|
|
|
b_clientno = cl_no + 1;
|
2003-07-31 16:57:01 +00:00
|
|
|
b_clientflag = 1 << cl_no;
|
2003-07-24 21:54:24 +00:00
|
|
|
|
2003-08-21 03:53:15 +00:00
|
|
|
//ent.colormap = (float) (cl_no + 1);
|
|
|
|
//ent.team = b_pants + 1;
|
2003-07-24 21:54:24 +00:00
|
|
|
|
|
|
|
b_entertime = time;
|
2003-08-01 05:25:07 +00:00
|
|
|
|
|
|
|
ent.netname = name.name;
|
|
|
|
b_pants = name.pants;
|
|
|
|
b_shirt = name.shirt;
|
2003-08-18 06:30:05 +00:00
|
|
|
|
|
|
|
[self updateClient];
|
2003-08-01 05:25:07 +00:00
|
|
|
//b_num = I
|
|
|
|
bot_count++;
|
|
|
|
if (skill > 3)
|
|
|
|
skill = 3;
|
|
|
|
else if (skill < 0)
|
|
|
|
skill = 0;
|
|
|
|
b_skill = skill;
|
2003-08-18 06:30:05 +00:00
|
|
|
ishuman = FALSE;
|
2003-08-01 05:25:07 +00:00
|
|
|
|
|
|
|
uself = @self;
|
|
|
|
@self = ent;
|
|
|
|
SetNewParms ();
|
2003-03-08 03:20:32 +00:00
|
|
|
ClientConnect ();
|
|
|
|
PutClientInServer ();
|
2003-08-01 05:25:07 +00:00
|
|
|
@self = uself;
|
|
|
|
|
2003-07-24 21:54:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-07-24 21:54:24 +00:00
|
|
|
- (id) initFromPlayer: (entity) e
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-07-24 21:54:24 +00:00
|
|
|
local integer cno;
|
2003-03-08 03:20:32 +00:00
|
|
|
|
2003-07-24 21:54:24 +00:00
|
|
|
if (!(self = [super initWithEntity:e]))
|
|
|
|
return NIL;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-07-24 21:54:24 +00:00
|
|
|
cno = (integer)e.colormap - 1;
|
|
|
|
b_clientno = cno;
|
|
|
|
ishuman = TRUE;
|
|
|
|
switch_wallhug = time + 1;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2003-08-18 06:30:05 +00:00
|
|
|
- (void) preThink
|
2003-07-24 21:54:24 +00:00
|
|
|
{
|
2003-08-18 06:30:05 +00:00
|
|
|
if (switch_wallhug)
|
|
|
|
ClientFixRankings ();
|
2003-07-24 21:54:24 +00:00
|
|
|
if (b_frags != ent.frags) {
|
|
|
|
if (b_frags > ent.frags) {
|
|
|
|
if (pointcontents (ent.origin) == CONTENT_LAVA)
|
2003-08-18 16:48:53 +00:00
|
|
|
[self startTopic:10];
|
2003-07-24 21:54:24 +00:00
|
|
|
else
|
2003-08-18 16:48:53 +00:00
|
|
|
[self startTopic:9];
|
2003-07-24 21:54:24 +00:00
|
|
|
} else
|
2003-08-18 16:48:53 +00:00
|
|
|
[self startTopic:2];
|
2003-07-30 16:53:57 +00:00
|
|
|
b_frags = ent.frags;
|
2003-07-24 21:54:24 +00:00
|
|
|
}
|
|
|
|
[self dynamicWaypoint];
|
|
|
|
}
|
|
|
|
|
2003-08-18 06:30:05 +00:00
|
|
|
- (void) postThink
|
2003-07-24 21:54:24 +00:00
|
|
|
{
|
2003-08-18 06:30:05 +00:00
|
|
|
local entity uself;
|
|
|
|
|
|
|
|
uself = @self;
|
|
|
|
@self = ent;
|
|
|
|
PlayerPostThink ();
|
|
|
|
@self = uself;
|
2003-07-24 21:54:24 +00:00
|
|
|
}
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-07-24 21:54:24 +00:00
|
|
|
-(void)disconnect
|
|
|
|
{
|
|
|
|
local entity uself;
|
|
|
|
|
|
|
|
uself = @self;
|
|
|
|
@self = ent;
|
2003-03-08 03:20:32 +00:00
|
|
|
ClientDisconnect ();
|
2003-07-24 21:54:24 +00:00
|
|
|
@self = uself;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-07-24 21:54:24 +00:00
|
|
|
bot_count--;
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-07-24 21:54:24 +00:00
|
|
|
SV_FreeClient (ent);
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)frame
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-07-24 21:54:24 +00:00
|
|
|
[self obstacles];
|
2003-08-31 07:11:04 +00:00
|
|
|
[self preThink];
|
2003-08-17 23:12:25 +00:00
|
|
|
[self sendMove];
|
2003-08-31 07:11:04 +00:00
|
|
|
[self AI];
|
2003-07-24 21:54:24 +00:00
|
|
|
}
|
2003-07-31 16:57:01 +00:00
|
|
|
|
|
|
|
-(void) updateClient
|
|
|
|
{
|
|
|
|
local string bottomcolor = ftos (b_pants);
|
|
|
|
local string topcolor = ftos (b_shirt);
|
|
|
|
|
|
|
|
SV_SetPing (ent, 100 * (3 - b_skill));
|
|
|
|
SV_SetUserinfo (ent, "\\bottomcolor\\" + bottomcolor
|
|
|
|
+ "\\topcolor\\" + topcolor
|
|
|
|
+ "\\team\\bot\\skin\\base\\name\\" + ent.netname);
|
|
|
|
// FIXME: do teams properly
|
|
|
|
}
|
2003-08-22 00:37:36 +00:00
|
|
|
|
|
|
|
-(integer)ishuman
|
|
|
|
{
|
|
|
|
return ishuman;
|
|
|
|
}
|
2003-07-24 21:54:24 +00:00
|
|
|
@end
|
2003-08-18 06:30:05 +00:00
|
|
|
|
|
|
|
void ()
|
|
|
|
BotFrame =
|
|
|
|
{
|
|
|
|
local string h;
|
|
|
|
local integer i;
|
|
|
|
|
|
|
|
h = infokey (NIL, "bot_options");
|
|
|
|
b_options = stof (h);
|
|
|
|
|
|
|
|
// for the sake of speed
|
|
|
|
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");
|
|
|
|
real_frametime = time - lasttime; // in QW frametime is fuxx0red
|
|
|
|
lasttime = time;
|
|
|
|
|
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
if (players[i] && !players[i].ishuman)
|
|
|
|
[players[i] frame];
|
|
|
|
}
|
|
|
|
};
|