diff --git a/fbxa/bot_ai.qc b/fbxa/bot_ai.qc index 63e74af..755898a 100644 --- a/fbxa/bot_ai.qc +++ b/fbxa/bot_ai.qc @@ -557,10 +557,10 @@ the bot finds things it wants to kill/grab. if (thing.current_way) { // check to see if it's unreachable - if (thing.current_way.items == -1) + if (thing.current_way.distance == -1) return 0; else - p += (integer) ((13000 - thing.current_way.items) * 0.05); + p += (integer) ((13000 - thing.current_way.distance) * 0.05); } return p; } diff --git a/fbxa/bot_move.qc b/fbxa/bot_move.qc index 93bed16..2387806 100644 --- a/fbxa/bot_move.qc +++ b/fbxa/bot_move.qc @@ -166,17 +166,17 @@ void (vector start, vector mins, vector maxs, vector end, float type, { local integer ret; + if (!(ent.flags & FL_ONGROUND)) + return FALSE; ret = [super recognizePlat:flag]; - if (ret) { - if (flag) { - // afect bot movement too - if (keys & KEY_MOVEUP) { - if (trace_ent.velocity_z > 0) - keys &= ~KEY_MOVE; - } else if (keys & KEY_MOVEDOWN) { - if (trace_ent.velocity_z < 0) - keys &= ~KEY_MOVE; - } + if (ret && flag) { + // afect bot movement too + if (keys & KEY_MOVEUP) { + if (trace_ent.velocity_z > 0) + keys &= ~KEY_MOVE; + } else if (keys & KEY_MOVEDOWN) { + if (trace_ent.velocity_z < 0) + keys &= ~KEY_MOVE; } } return ret; @@ -229,7 +229,7 @@ manuever around. if (danger) { b_aiflags |= AI_DANGER; - keys = [self keysForDir:'0 0 0' - whichway]; + keys = [self keysForDir:-whichway]; } if (b_aiflags & AI_PRECISION) return; @@ -354,9 +354,10 @@ Also responsible for jumping gaps. } if (targets[0]) { + local vector org = [targets[0] origin]; // getting furter away from my target? - test = vlen ([targets[0] origin] - (ang + ent.origin)); - if (test > vlen ([targets[0] origin] - ent.origin)) { + test = vlen (org - (ang + ent.origin)); + if (test > vlen (org - ent.origin)) { if (conts < -3) { // bad stuff down dare [self obstructed: ang :TRUE]; diff --git a/fbxa/bot_qw.qc b/fbxa/bot_qw.qc index 75d926f..866d287 100644 --- a/fbxa/bot_qw.qc +++ b/fbxa/bot_qw.qc @@ -104,6 +104,7 @@ bot_map_load = map_dm6 (); break; } + [Waypoint fixWaypoints]; }; /* diff --git a/fbxa/bot_way.qc b/fbxa/bot_way.qc index 262b8d9..e6f9b75 100644 --- a/fbxa/bot_way.qc +++ b/fbxa/bot_way.qc @@ -115,7 +115,7 @@ an object. for (i = 0; i < count; i++) { t = [waypoint_array getItemAt:i]; tdst = vlen(t.origin - ent.origin); - if ((tdst < dst) && (t.b_sound & flag)) { + if ((tdst < dst) && (t.bot_bits & flag)) { if ((lastone == NIL) || ([lastone isLinkedTo:t])) { dst = tdst; best = t; @@ -161,11 +161,11 @@ different bot. flag = b_clientflag; while(t) { - if (t.b_sound & flag) + if (t.bot_bits & flag) return; if (t == last_way) return; - t.b_sound |= flag; + t.bot_bits |= flag; t = t.enemy; } } @@ -204,7 +204,7 @@ Boy it's confusing. last_way = [self findWaypoint:current_way]; if (last_way != NIL) { - last_way.items = vlen(last_way.origin - ent.origin); + last_way.distance = vlen(last_way.origin - ent.origin); [last_way queueForThink]; last_way.busy = TRUE; busy_waypoints = 1; diff --git a/fbxa/libfrikbot.h b/fbxa/libfrikbot.h index 65ed292..2b51af8 100644 --- a/fbxa/libfrikbot.h +++ b/fbxa/libfrikbot.h @@ -38,9 +38,9 @@ typedef struct bot_data_t bot_data_t; integer is_temp; - integer b_sound; + integer bot_bits; integer busy; //??? - float items; + float distance; Waypoint enemy; float search_time; diff --git a/fbxa/target.r b/fbxa/target.r index 49fd037..b927b33 100644 --- a/fbxa/target.r +++ b/fbxa/target.r @@ -108,13 +108,13 @@ struct target_s = { { local vector spot1, spot2; - spot1 = ent.origin; + spot1 = [self origin]; spot2 = [targ realorigin]; do { traceline (spot1, spot2, TRUE, ignore); spot1 = realorigin(trace_ent); - ignore = trace_ent; + ignore = trace_ent; } while ((trace_ent != world) && (trace_fraction != 1)); if (trace_endpos == spot2) return TRUE; @@ -147,40 +147,49 @@ struct target_s = { // ugly hack if (_last != bot) return 20; - if (ent.classname == "item_artifact_super_damage") - return 65; - else if (ent.classname == "item_artifact_invulnerability") - return 65; - else if (ent.classname == "item_health") { - if (ent.spawnflags & 2) - return 55; - if (bot.ent.health < 40) - return 55 + 50; - } else if (ent.model == "progs/armor.mdl") { - if (bot.ent.armorvalue < 200) { - if (ent.skin == 2) + switch (ent.classname) { + case "item_artifact_super_damage": + return 65; + case "item_artifact_invulnerability": + return 65; + case "item_health": + if (ent.spawnflags & 2) + return 55; + if (bot.ent.health < 40) + return 55 + 50; + break; + case "progs/armor.mdl": + if (bot.ent.armorvalue < 200) { + if (ent.skin == 2) + return 60; + else if (bot.ent.armorvalue < 100) + return 60 + 25; + } + break; + case "weapon_supershotgun": + if (!(bot.ent.items & IT_SUPER_SHOTGUN)) + return 25; + break; + case "weapon_nailgun": + if (!(bot.ent.items & IT_NAILGUN)) + return 30; + break; + case "weapon_supernailgun": + if (!(bot.ent.items & IT_SUPER_NAILGUN)) + return 35; + break; + case "weapon_grenadelauncher": + if (!(bot.ent.items & IT_GRENADE_LAUNCHER)) + return 45; + break; + case "weapon_rocketlauncher": + if (!(bot.ent.items & IT_ROCKET_LAUNCHER)) return 60; - else if (bot.ent.armorvalue < 100) - return 60 + 25; - } - } else if (ent.classname == "weapon_supershotgun") { - if (!(bot.ent.items & IT_SUPER_SHOTGUN)) - return 25; - } else if (ent.classname == "weapon_nailgun") { - if (!(bot.ent.items & IT_NAILGUN)) - return 30; - } else if (ent.classname == "weapon_supernailgun") { - if (!(bot.ent.items & IT_SUPER_NAILGUN)) - return 35; - } else if (ent.classname == "weapon_grenadelauncher") { - if (!(bot.ent.items & IT_GRENADE_LAUNCHER)) - return 45; - } else if (ent.classname == "weapon_rocketlauncher") { - if (!(bot.ent.items & IT_ROCKET_LAUNCHER)) - return 60; - } else if (ent.classname == "weapon_lightning") { - if (!(bot.ent.items & IT_LIGHTNING)) - return 50; + break; + case "weapon_lightning": + if (!(bot.ent.items & IT_LIGHTNING)) + return 50; + break; } } else if ((ent.flags & FL_MONSTER) && ent.health > 0) return 45; diff --git a/fbxa/waypoint.r b/fbxa/waypoint.r index fd9e138..a32cc43 100644 --- a/fbxa/waypoint.r +++ b/fbxa/waypoint.r @@ -76,13 +76,7 @@ Array waypoint_array; [waypoint_array addItem: self]; origin = org; search_time = time; - items = -1; - if ([waypoint_array count] == 1) { - local id obj = [Waypoint class]; - local IMP imp = [obj methodForSelector: @selector (fixWaypoints)]; - waypoint_thinker.think = (void ()) imp; - waypoint_thinker.nextthink = time; - } + distance = -1; return self; } @@ -211,9 +205,40 @@ Waypoint Loading from file } } +#if 0 +// you don't want this. it's harsh. overflows normal servers and clients +-(void) debug +{ + local integer i; + local vector dir, dest, pos; + + @self = spawn (); + @self.origin = origin; + light_globe (); + + for (i = 0; i < 4; i++) { + if (!links[i]) + continue; + dest = [links[i] origin]; + dir = normalize (dest - origin) * 15; + pos = origin; + while ((pos-origin)*(pos-origin) < (dest-origin)*(dest-origin)) { + @self = spawn (); + @self.origin = pos; + precache_model ("progs/s_bubble.spr"); + setmodel (@self, "progs/s_bubble.spr"); + makestatic (@self); + pos += dir; + } + } +} +#endif + +(void) fixWaypoints { [waypoint_array makeObjectsPerformSelector:@selector(fix)]; + //see -debug above + //[waypoint_array makeObjectsPerformSelector:@selector(debug)]; } +(Waypoint)find:(vector)org radius:(float)rad @@ -250,7 +275,7 @@ Route & path table management { busy = FALSE; enemy = NIL; - items = -1; // not in table + distance = -1; // not in table } +(void)clearRouteTable @@ -261,9 +286,7 @@ Route & path table management -(void)clearRouteForBot:(Bot)bot { - local integer flag; - flag = bot.b_clientflag; - b_sound &= ~flag; + bot_bits &= ~bot.b_clientflag; } +(void)clearMyRoute:(Bot) bot @@ -288,9 +311,9 @@ tripping the runaway loop counter local float dist; if (flags & bBit) - dist = items; + dist = distance; else - dist = vlen(origin - e2.origin) + items; + dist = vlen(origin - e2.origin) + distance; // check if this is an RJ link if (e2.flags & AI_SUPER_JUMP) { @@ -302,11 +325,11 @@ tripping the runaway loop counter dist = dist + random() * 100; // add a little chaos - if ((dist < e2.items) || (e2.items == -1)) { + if ((dist < e2.distance) || (e2.distance == -1)) { if (!e2.busy) busy_waypoints = busy_waypoints + 1; e2.busy = TRUE; - e2.items = dist; + e2.distance = dist; e2.enemy = self; [e2 queueForThink]; } @@ -316,7 +339,7 @@ tripping the runaway loop counter { local integer i; - if (items == -1) + if (distance == -1) return; // can you say ugly? if (flags & AI_TRACE_TEST) { @@ -405,6 +428,15 @@ void() waypoint = local Waypoint way = [[Waypoint alloc] initFromEntity: @self]; }; +/* create a new waypoint using frikbot style info + org origin of the waypoint + bit1 first 3 links (cast to integer) + bit4 fourth link + flargs various flags + + links are 1 based with 0 being no link and 1 being the first waypoint + created, 2 the second and so on. +*/ void(vector org, vector bit1, integer bit4, integer flargs) make_way = { local Waypoint y = [[Waypoint alloc] initAt:org];