more work. get there eventually

This commit is contained in:
Bill Currie 2003-08-01 05:25:07 +00:00
parent d4b5b87334
commit 3b77c09310
6 changed files with 77 additions and 87 deletions

View File

@ -41,13 +41,9 @@ this notice in its entirety.
*/ */
#include "libfrikbot.h" #include "libfrikbot.h"
#include "Array.h"
struct bot_data_t = { bot_data_t [32] bot_data = {
string name;
float pants, shirt;
};
struct bot_data_t [32] bot_data = {
{"Vincent", 11, 0}, {"Vincent", 11, 0},
{"Bishop", 1, 3}, {"Bishop", 1, 3},
{"Nomad", 13, 2}, {"Nomad", 13, 2},
@ -82,53 +78,43 @@ struct bot_data_t [32] bot_data = {
{"Mercury", 10, 5}, {"Mercury", 10, 5},
}; };
Array bot_array;
@implementation Bot (Misc) @implementation Bot (Misc)
/* /*
BotName BotName
Sets bot's name and colors Sets bot's name and colors
*/ */
-(string)name:(integer)r +(bot_data_t [])name:(integer)r
{ {
b_num = r;
if (r < 0 || r >= 32) if (r < 0 || r >= 32)
return NIL; return NIL;
b_pants = bot_data[r].pants; return &bot_data[r];
b_shirt = bot_data[r].shirt;
return bot_data[r].name;
} }
-(string)randomName +(bot_data_t [])randomName
{ {
local integer y, test; local integer test;
local string h; local bot_data_t [] h;
local entity t; local entity t;
y = TRUE;
while (y) { while (1) {
test = (integer) (32 * random ()); test = (integer) (32 * random ());
h = [self name:test]; h = [Bot name:test];
t = find (NIL, netname, h); t = find (NIL, netname, h.name);
if (t == NIL) if (t == NIL)
y = FALSE; return h;
} }
return h;
} }
+(void)kick +(void)kick
{ {
local entity ty; local Bot ty;
ty = find (NIL, classname, "player"); ty = [bot_array removeItemAt:0];
while (ty != NIL) { if (ty)
/*XXX [ty disconnect];
if (!(ty.ishuman)) {
BotDisconnect (ty);
ty.ishuman = TRUE;
ty = NIL;
} else
ty = find (ty, classname, "player");
*/
}
} }
/* /*

View File

@ -268,20 +268,6 @@ void(Waypoint e1, Waypoint e2, integer flag) DeveloperLightning = {};
// BotConnect and related functions. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // BotConnect and related functions. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
entity (float num)
GetClientEntity =
{
local entity upsy;
upsy = NIL;
num++;
while (num > 0) {
num--;
upsy = nextent (upsy);
}
return upsy;
};
integer (entity cl) integer (entity cl)
ClientNumber = ClientNumber =
{ {
@ -298,30 +284,23 @@ ClientNumber =
void (integer whatbot, integer whatskill) void (integer whatbot, integer whatskill)
BotConnect = BotConnect =
{ {
local entity uself; local entity cl;
local Bot bot; local Bot bot;
local bot_data_t [] name;
uself = @self; cl = SV_AllocClient ();
@self = SV_AllocClient (); if (!cl) {
if (!@self) {
bprint (PRINT_HIGH, "Unable to connect a bot, server is full.\n"); bprint (PRINT_HIGH, "Unable to connect a bot, server is full.\n");
@self = uself;
return; return;
} }
bot = [[Bot alloc] initWithEntity: @self];
if (whatbot) if (whatbot)
@self.netname = [bot name:whatbot]; name = [Bot name:whatbot];
else else
@self.netname = [bot randomName]; name = [Bot randomName];
bot_count++;
// players can set skill all weird, so leave these checks in bot = [[Bot alloc] initWithEntity: cl named:name skill:whatskill];
if (whatskill > 3)
whatskill = 3;
else if (whatskill < 0)
whatskill = 0;
bot.b_skill = whatskill;
[bot start_topic:1]; [bot start_topic:1];
@self = uself;
}; };
/* /*
@ -350,9 +329,10 @@ void () BotImpulses =
return [super init]; return [super init];
} }
- (id) initWithEntity:(entity) e - (id) initWithEntity:(entity) e named:(bot_data_t [])name skill:(integer)skill
{ {
local integer cl_no = ClientNumber (@self); local integer cl_no = ClientNumber (@self);
local entity uself;
if (!(self = [super initWithEntity:e])) if (!(self = [super initWithEntity:e]))
return NIL; return NIL;
@ -365,10 +345,26 @@ void () BotImpulses =
b_entertime = time; b_entertime = time;
ent.team = b_pants + 1; ent.team = b_pants + 1;
[self updateClient]; [self updateClient];
SetNewParms ();
ent.netname = name.name;
b_pants = name.pants;
b_shirt = name.shirt;
//b_num = I
bot_count++;
if (skill > 3)
skill = 3;
else if (skill < 0)
skill = 0;
b_skill = skill;
ishuman = 2; ishuman = 2;
uself = @self;
@self = ent;
SetNewParms ();
ClientConnect (); ClientConnect ();
PutClientInServer (); PutClientInServer ();
@self = uself;
return self; return self;
} }

View File

@ -289,22 +289,17 @@ Temporary Marker code
-(void)spawnTempWaypoint:(vector)org -(void)spawnTempWaypoint:(vector)org
{ {
/*XXX local Waypoint tep;
local entity tep;
if (!temp_way) if (!temp_way)
temp_way = tep = spawn(); temp_way = tep = [[Waypoint alloc] init];
else else
tep = temp_way; tep = temp_way;
tep.classname = "temp_waypoint"; [tep setOrigin:org];
tep.search_time = 0; tep.search_time = 0;
tep.solid = SOLID_TRIGGER;
tep.movetype = MOVETYPE_NOCLIP; [self target_add:tep];
setorigin(tep, org);
target_add(tep);
setsize(tep, VEC_HULL_MIN, VEC_HULL_MAX); // FIXME: convert these to numerical
*/
} }
/* /*

View File

@ -3,11 +3,18 @@
@class Bot; @class Bot;
@class Waypoint; @class Waypoint;
struct bot_data_t = {
string name;
float pants, shirt;
};
typedef struct bot_data_t bot_data_t;
@interface Target: Entity @interface Target: Entity
{ {
} }
-(vector)realorigin; -(vector)realorigin;
-(integer)canSee:(Target)targ ignoring:(entity)ignore; -(integer)canSee:(Target)targ ignoring:(entity)ignore;
-(void)setOrigin:(vector) org;
@end @end
@interface Waypoint: Target @interface Waypoint: Target
@ -95,7 +102,7 @@
float teleport_time, portal_time; float teleport_time, portal_time;
} }
- (id) init; - (id) init;
- (id) initWithEntity: (entity) e; - (id) initWithEntity: (entity) e named:(bot_data_t [])name skill:(integer)skill;
- (id) initFromPlayer: (entity) e; - (id) initFromPlayer: (entity) e;
- (integer) preFrame; - (integer) preFrame;
- (integer) postFrame; - (integer) postFrame;
@ -106,8 +113,8 @@
@end @end
@interface Bot (Misc) @interface Bot (Misc)
-(string)name:(integer)r; +(bot_data_t [])name:(integer)r;
-(string)randomName; +(bot_data_t [])randomName;
-(integer)fov:(entity)targ; -(integer)fov:(entity)targ;
+(void)kick; +(void)kick;

View File

@ -70,4 +70,9 @@ this notice in its entirety.
else else
return FALSE; return FALSE;
} }
-(void)setOrigin:(vector)org
{
}
@end @end

View File

@ -60,6 +60,12 @@ Array waypoint_array;
waypoint_thinker = spawn (); waypoint_thinker = spawn ();
waypoint_thinker.classname = "waypoint_thinker"; waypoint_thinker.classname = "waypoint_thinker";
} }
/*XXX
ent.classname = "temp_waypoint";
ent.solid = SOLID_TRIGGER;
ent.movetype = MOVETYPE_NOCLIP;
setsize(ent, VEC_HULL_MIN, VEC_HULL_MAX); // FIXME: convert these to numerical
*/
return [super init]; return [super init];
} }
@ -74,6 +80,11 @@ Array waypoint_array;
{ {
[self initAt:ent.origin]; [self initAt:ent.origin];
} }
-(void)setOrigin:(vector)org
{
origin = org;
}
/* /*
entity (vector org) entity (vector org)
make_waypoint = make_waypoint =
@ -90,17 +101,7 @@ make_waypoint =
setorigin (point, org); setorigin (point, org);
setsize (point, VEC_HULL_MIN, VEC_HULL_MAX); setsize (point, VEC_HULL_MIN, VEC_HULL_MAX);
waypoints++;
if (!way_head) {
way_head = point;
way_foot = point;
} else {
way_foot._next = point;
point._last = way_foot;
way_foot = point;
}
point.count = waypoints;
if (waypoint_mode > WM_LOADED) // editor modes if (waypoint_mode > WM_LOADED) // editor modes
setmodel (point, "progs/s_bubble.spr"); setmodel (point, "progs/s_bubble.spr");
return point; return point;