2003-02-18 23:11:05 +00:00
|
|
|
/***********************************************
|
|
|
|
* *
|
|
|
|
* FrikBot Misc Code *
|
|
|
|
* "Because you can't name it anything else" *
|
|
|
|
* *
|
|
|
|
***********************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2003-02-24 16:05:25 +00:00
|
|
|
#include "libfrikbot.h"
|
2003-08-01 05:25:07 +00:00
|
|
|
#include "Array.h"
|
2003-02-24 16:05:25 +00:00
|
|
|
|
2003-08-01 05:25:07 +00:00
|
|
|
bot_data_t [32] bot_data = {
|
2003-04-07 18:25:14 +00:00
|
|
|
{"Vincent", 11, 0},
|
|
|
|
{"Bishop", 1, 3},
|
|
|
|
{"Nomad", 13, 2},
|
|
|
|
{"Hudson", 7, 6},
|
|
|
|
{"Lore", 12, 6},
|
|
|
|
{"Servo", 4, 4},
|
|
|
|
{"Gort", 2, 5},
|
|
|
|
{"Kryten", 10, 3},
|
|
|
|
{"Pimp Bot", 9, 4},
|
|
|
|
{"Max", 4, 7},
|
|
|
|
{"Marvin", 3, 11},
|
|
|
|
{"Erwin", 13, 12},
|
|
|
|
{"FrikBot", 11, 2},
|
|
|
|
{"Krosis", 0, 2},
|
|
|
|
{"Gypsy", 8, 9},
|
|
|
|
{"Hal", 5, 10},
|
|
|
|
{"Orion", 0, 11},
|
|
|
|
{"Centauri", 3, 1},
|
|
|
|
{"Draco", 2, 13},
|
|
|
|
{"Casseopia", 6, 7},
|
|
|
|
{"Herculese", 6, 12},
|
|
|
|
{"Zeus", 4, 4},
|
|
|
|
{"Shiva", 5, 2},
|
|
|
|
{"Charon", 3, 10},
|
|
|
|
{"Apollo", 4, 9},
|
|
|
|
{"Jupiter", 7, 4},
|
|
|
|
{"Saturn", 11, 3},
|
|
|
|
{"Uranus", 12, 13},
|
|
|
|
{"Neptune", 2, 11},
|
|
|
|
{"Pluto", 2, 0},
|
|
|
|
{"Mars", 9, 8},
|
|
|
|
{"Mercury", 10, 5},
|
|
|
|
};
|
|
|
|
|
2003-08-01 05:25:07 +00:00
|
|
|
Array bot_array;
|
|
|
|
|
2003-07-24 18:23:13 +00:00
|
|
|
@implementation Bot (Misc)
|
2003-02-18 23:11:05 +00:00
|
|
|
/*
|
|
|
|
BotName
|
|
|
|
|
|
|
|
Sets bot's name and colors
|
|
|
|
*/
|
2003-08-01 05:25:07 +00:00
|
|
|
+(bot_data_t [])name:(integer)r
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-04-07 18:25:14 +00:00
|
|
|
if (r < 0 || r >= 32)
|
|
|
|
return NIL;
|
2003-08-01 05:25:07 +00:00
|
|
|
return &bot_data[r];
|
2003-07-24 18:23:13 +00:00
|
|
|
}
|
2003-03-08 03:20:32 +00:00
|
|
|
|
2003-08-01 05:25:07 +00:00
|
|
|
+(bot_data_t [])randomName
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-08-01 05:25:07 +00:00
|
|
|
local integer test;
|
|
|
|
local bot_data_t [] h;
|
2003-02-18 23:11:05 +00:00
|
|
|
local entity t;
|
2003-08-01 05:25:07 +00:00
|
|
|
|
|
|
|
while (1) {
|
2003-04-07 18:25:14 +00:00
|
|
|
test = (integer) (32 * random ());
|
2003-08-01 05:25:07 +00:00
|
|
|
h = [Bot name:test];
|
|
|
|
t = find (NIL, netname, h.name);
|
2003-02-24 16:05:25 +00:00
|
|
|
if (t == NIL)
|
2003-08-01 05:25:07 +00:00
|
|
|
return h;
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
2003-07-24 18:23:13 +00:00
|
|
|
}
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-07-24 18:23:13 +00:00
|
|
|
+(void)kick
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-08-01 05:25:07 +00:00
|
|
|
local Bot ty;
|
|
|
|
|
|
|
|
ty = [bot_array removeItemAt:0];
|
|
|
|
if (ty)
|
|
|
|
[ty disconnect];
|
2003-07-24 18:23:13 +00:00
|
|
|
}
|
|
|
|
|
2003-08-25 05:12:41 +00:00
|
|
|
-(void)add
|
|
|
|
{
|
|
|
|
if (!bot_array)
|
|
|
|
bot_array = [[Array alloc] init];
|
|
|
|
[bot_array addItem: self];
|
|
|
|
}
|
|
|
|
|
2003-07-24 18:23:13 +00:00
|
|
|
/*
|
|
|
|
fov
|
|
|
|
|
|
|
|
is the entity in the bot's field of view
|
|
|
|
*/
|
|
|
|
-(integer)fov:(entity)targ
|
|
|
|
{
|
|
|
|
local float g;
|
|
|
|
local vector yawn;
|
|
|
|
|
|
|
|
yawn = realorigin (targ);
|
|
|
|
yawn = (yawn + targ.view_ofs) - (ent.origin + ent.view_ofs);
|
|
|
|
yawn = normalize (yawn);
|
|
|
|
yawn = vectoangles (yawn);
|
|
|
|
g = angcomp (ent.v_angle_x, yawn_x);
|
|
|
|
if (fabs (g) > 45)
|
|
|
|
return FALSE;
|
|
|
|
g = angcomp (ent.v_angle_y, yawn_y);
|
|
|
|
if (fabs (g) > 60)
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
float (float v)
|
|
|
|
frik_anglemod =
|
|
|
|
{
|
|
|
|
return v - floor (v / 360) * 360;
|
2003-02-18 23:11:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Simplified origin checking.
|
|
|
|
|
|
|
|
God, I wish I had inline
|
|
|
|
*/
|
2003-03-08 03:20:32 +00:00
|
|
|
vector (entity ent)
|
|
|
|
realorigin =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-08 03:20:32 +00:00
|
|
|
// even more simplified...
|
2003-02-18 23:11:05 +00:00
|
|
|
return (ent.absmin + ent.absmax) * 0.5;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
sisible
|
|
|
|
|
|
|
|
Now this is getting ridiculous. Simple visible,
|
|
|
|
used when we need just a simple traceline nothing else
|
|
|
|
*/
|
2003-08-22 06:56:31 +00:00
|
|
|
float (entity ent, entity targ, vector targ_origin)
|
2003-03-08 03:20:32 +00:00
|
|
|
sisible =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-08-22 06:56:31 +00:00
|
|
|
traceline (ent.origin, targ_origin, TRUE, ent);
|
|
|
|
if (targ && trace_ent == targ)
|
2003-02-18 23:11:05 +00:00
|
|
|
return TRUE;
|
|
|
|
else if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
/*
|
2003-02-18 23:11:05 +00:00
|
|
|
angcomp
|
|
|
|
|
|
|
|
subtracts one angle from another
|
|
|
|
*/
|
2003-03-08 03:20:32 +00:00
|
|
|
float (float y1, float y2)
|
|
|
|
angcomp =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
local float answer;
|
2003-03-08 03:20:32 +00:00
|
|
|
|
|
|
|
y1 = frik_anglemod (y1);
|
|
|
|
y2 = frik_anglemod (y2);
|
|
|
|
|
2003-02-18 23:11:05 +00:00
|
|
|
answer = y1 - y2;
|
|
|
|
if (answer > 180)
|
2003-03-08 03:20:32 +00:00
|
|
|
answer -= 360;
|
2003-02-18 23:11:05 +00:00
|
|
|
else if (answer < -180)
|
2003-03-08 03:20:32 +00:00
|
|
|
answer += 360;
|
2003-02-18 23:11:05 +00:00
|
|
|
return answer;
|
|
|
|
};
|