make sisible more generic (still ick) and make lookForCrap look for

waypoints, too.
This commit is contained in:
Bill Currie 2003-08-22 06:56:31 +00:00
parent f4f6e897b3
commit 88df663ce7
5 changed files with 49 additions and 11 deletions

View file

@ -559,28 +559,42 @@ the bot finds things it wants to kill/grab.
-(void)lookForCrap:(integer)scope
{
local Target foe, best = NIL;
local Waypoint way;
local integer thatp, bestp;
local float dist;
local float radius;
if (scope == 1)
foe = [Target forEntity:findradius (ent.origin, 13000)];
radius = 13000;
else
foe = [Target forEntity:findradius (ent.origin, 500)];
radius = 500;
foe = [Target forEntity:findradius (ent.origin, radius)];
bestp = 1;
while (foe) {
thatp = [self priorityForThing:foe];
if (thatp)
if (!scope)
if (!sisible (ent, foe.ent))
if (!sisible (ent, foe.ent, foe.ent.origin))
thatp = 0;
if (thatp > bestp) {
bestp = thatp;
best = foe;
dist = vlen (ent.origin - foe.ent.origin);
}
foe = [Target forEntity:foe.ent.chain];
}
way = [Waypoint find:ent.origin radius:radius];
while (way) {
thatp = [self priorityForThing:way];
if (thatp)
if (!scope)
if (!sisible (ent, NIL, way.origin))
thatp = 0;
if (thatp > bestp) {
bestp = thatp;
best = way;
}
way = way.chain;
}
if (best == NIL)
return;
if (![self targetOnstack:best]) {

View file

@ -165,11 +165,11 @@ sisible
Now this is getting ridiculous. Simple visible,
used when we need just a simple traceline nothing else
*/
float (entity ent, entity targ)
float (entity ent, entity targ, vector targ_origin)
sisible =
{
traceline (ent.origin, targ.origin, TRUE, ent);
if (trace_ent == targ)
traceline (ent.origin, targ_origin, TRUE, ent);
if (targ && trace_ent == targ)
return TRUE;
else if (trace_fraction == 1)
return TRUE;

View file

@ -37,6 +37,8 @@ typedef struct bot_data_t bot_data_t;
float items;
Waypoint enemy;
float search_time;
Waypoint chain;
}
+(void)clearAll;
+(Waypoint)waypointForNum:(integer)num;
@ -44,6 +46,7 @@ typedef struct bot_data_t bot_data_t;
+(void)clearRouteTable;
+(void)clearMyRoute:(Bot) bot;
+(Waypoint)find:(vector)org radius:(float)rad;
-(void)fix;
-(id)init;
@ -299,7 +302,7 @@ typedef struct bot_data_t bot_data_t;
// ai & misc
@extern float(float y1, float y2) angcomp;
@extern float(entity ent, entity targ) sisible;
@extern float(entity ent, entity targ, vector targ_origin) sisible;
@extern vector(entity ent) realorigin;
@extern float(float v) frik_anglemod;

View file

@ -221,8 +221,7 @@ Finds the closest, fisible, waypoint to e
if (!(t.flags & AI_IGNORE_TYPES) || ishuman) {
tdst = vlen (t.origin - org);
if (tdst < dst) {
traceline (ent.origin, t.origin, TRUE, ent);
if (trace_fraction == 1) {
if (sisible (ent, NIL, t.origin)) {
dst = tdst;
best = t;
}

View file

@ -219,6 +219,28 @@ Waypoint Loading from file
[waypoint_array makeObjectsPerformSelector:@selector(fix)];
}
+(Waypoint)find:(vector)org radius:(float)rad
{
local vector dif;
local float dist;
local integer i, count;
local Waypoint way = NIL, w;
rad = rad * rad; // radius squared
count = [waypoint_array count];
for (i = 1; i < count; i++) {
w = [waypoint_array getItemAt:i];
dif = w.origin - org;
dist = dif * dif; // dist squared, really
if (dist < rad) {
w.chain = way;
way = w;
}
}
return way;
}
/*
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=