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

View file

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

View file

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

View file

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

View file

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

View file

@ -60,6 +60,12 @@ Array waypoint_array;
waypoint_thinker = spawn ();
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];
}
@ -74,6 +80,11 @@ Array waypoint_array;
{
[self initAt:ent.origin];
}
-(void)setOrigin:(vector)org
{
origin = org;
}
/*
entity (vector org)
make_waypoint =
@ -90,17 +101,7 @@ make_waypoint =
setorigin (point, org);
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
setmodel (point, "progs/s_bubble.spr");
return point;