mirror of
https://git.code.sf.net/p/quake/game-source
synced 2024-11-22 03:51:12 +00:00
make a 1:1 mapping for entities that get targeted and Targets
This commit is contained in:
parent
e33e7a73c1
commit
f5c5b2a9a2
3 changed files with 48 additions and 7 deletions
|
@ -321,7 +321,7 @@ based b_aiflags.
|
|||
[self weaponSwitch:1];
|
||||
} else {
|
||||
// targetDrop (last_way);
|
||||
[self targetAdd:newt]; //FIXME newt wrong type
|
||||
[self targetAdd:[Target forEntity:newt]];
|
||||
// [self getPath:newt :TRUE];
|
||||
}
|
||||
}
|
||||
|
@ -421,8 +421,8 @@ confused
|
|||
-(void)path
|
||||
{
|
||||
|
||||
local Waypoint jj, tele;
|
||||
local entity e;
|
||||
local Waypoint jj;
|
||||
local entity e, tele;
|
||||
|
||||
[self checkLost:targets[0]];
|
||||
if (!targets[0]) {
|
||||
|
@ -456,8 +456,8 @@ confused
|
|||
if (last_way) {
|
||||
if ([last_way isLinkedTo:jj] == 2) {
|
||||
// waypoints are telelinked
|
||||
tele = [self findThing:"trigger_teleport"].@this; // this is probbly the teleport responsible FIXME shouldn't use @this here
|
||||
[self targetAdd:tele];
|
||||
tele = [self findThing:"trigger_teleport"]; // this is probbly the teleport responsible
|
||||
[self targetAdd:[Target forEntity:tele]];
|
||||
}
|
||||
traceline (last_way.origin, jj.origin, FALSE, ent); // check for blockage
|
||||
if (trace_fraction != 1) {
|
||||
|
@ -477,7 +477,7 @@ confused
|
|||
[self weaponSwitch:1];
|
||||
} else {
|
||||
// targetDrop (jj);
|
||||
[self targetAdd:e]; //FIXME e wrong type
|
||||
[self targetAdd:[Target forEntity:e]];
|
||||
// [self getPath:tele :TRUE];
|
||||
b_aiflags |= AI_BLIND; // give a bot a bone
|
||||
return;
|
||||
|
@ -628,7 +628,7 @@ the bot finds things it wants to kill/grab.
|
|||
if (best == NIL)
|
||||
return;
|
||||
if (![self targetOnstack:best]) {
|
||||
[self targetAdd:best]; //FIXME best wrong type
|
||||
[self targetAdd:[Target forEntity:best]];
|
||||
if (scope) {
|
||||
[self getPath:best :FALSE];
|
||||
b_aiflags |= AI_WAIT;
|
||||
|
|
|
@ -12,6 +12,7 @@ typedef struct bot_data_t bot_data_t;
|
|||
@interface Target: Entity
|
||||
{
|
||||
}
|
||||
+(Target)forEntity:(entity)ent;
|
||||
-(vector)realorigin;
|
||||
-(vector)origin;
|
||||
-(integer)canSee:(Target)targ ignoring:(entity)ignore;
|
||||
|
|
|
@ -44,10 +44,50 @@ this notice in its entirety.
|
|||
|
||||
#include "libfrikbot.h"
|
||||
#include "Array.h"
|
||||
#include "hash.h"
|
||||
#include "List.h"
|
||||
|
||||
@static hashtab_t target_tab;
|
||||
|
||||
struct target_s = {
|
||||
@defs (Target)
|
||||
};
|
||||
|
||||
@static unsigned (void []ele, void []unused) target_get_hash =
|
||||
{
|
||||
local Target t = ele;
|
||||
return ((unsigned[])&t.ent)[0];
|
||||
};
|
||||
|
||||
@static integer (void []e1, void[]e2, void []unused) target_compare =
|
||||
{
|
||||
local Target t1 = e1;
|
||||
local Target t2 = e2;
|
||||
return t1.ent == t2.ent;
|
||||
};
|
||||
|
||||
@implementation Target
|
||||
|
||||
+(Target)forEntity:(entity)ent
|
||||
{
|
||||
local Target t;
|
||||
local struct target_s ele;
|
||||
|
||||
if (!target_tab) {
|
||||
target_tab = Hash_NewTable (1021, NIL, NIL, NIL);
|
||||
Hash_SetHashCompare (target_tab, target_get_hash, target_compare);
|
||||
}
|
||||
ele.ent = ent;
|
||||
t = Hash_FindElement (target_tab, &ele);
|
||||
if (t)
|
||||
return t;
|
||||
|
||||
t = [[Target alloc] init];
|
||||
t.ent = ent;
|
||||
Hash_AddElement (target_tab, t);
|
||||
return t;
|
||||
}
|
||||
|
||||
-(vector)realorigin
|
||||
{
|
||||
return realorigin (ent);
|
||||
|
|
Loading…
Reference in a new issue