From c45e996252a610e82bbc7d522fefad19b9961106 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 22 Aug 2003 00:37:36 +0000 Subject: [PATCH] impulse fixes plus partial (doesn't compile) changes to priorityForThing --- fbxa/bot_ai.qc | 20 ++++++++++---------- fbxa/bot_fight.qc | 24 +++++++++++------------- fbxa/bot_phys.qc | 4 +++- fbxa/bot_qw.qc | 7 +++++-- fbxa/libfrikbot.h | 3 ++- fbxa/target.r | 8 ++++++++ 6 files changed, 39 insertions(+), 27 deletions(-) diff --git a/fbxa/bot_ai.qc b/fbxa/bot_ai.qc index 8997b0c..7a1b029 100644 --- a/fbxa/bot_ai.qc +++ b/fbxa/bot_ai.qc @@ -223,7 +223,7 @@ removed. [self lost:targ :TRUE]; else if ((coop) || (teamplay && targ.ent.team == ent.team)) { if (targ.targets[0].ent.classname == "player") { - //XXX if (!targ.targets[0].ishuman) + if (![targ.targets[0] ishuman]) [self lost:targ :TRUE]; } else if (targ.ent.teleport_time > time) { // try not to telefrag teammates @@ -337,7 +337,7 @@ based b_aiflags. } } else if (b_aiflags & AI_SUPER_JUMP) { if (ent.weapon != 32) - ent.impulse = 7; + impulse = 7; else if (ent.flags & FL_ONGROUND) { b_aiflags &= ~AI_SUPER_JUMP; if ([self canRJ]) { @@ -512,7 +512,7 @@ the bot finds things it wants to kill/grab. // *!* Make sure you add code to checkLost to remove the target *!* --(float)priorityForThing:(entity)thing +-(float)priorityForThing:(Target)thing { local float thisp; @@ -603,32 +603,32 @@ the bot finds things it wants to kill/grab. -(void)lookForCrap:(integer)scope { - local entity foe, best = NIL; + local Target foe, best = NIL; local float thatp, bestp, dist; if (scope == 1) - foe = findradius (ent.origin, 13000); + foe = [Target forEntity:findradius (ent.origin, 13000)]; else - foe = findradius (ent.origin, 500); + foe = [Target forEntity:findradius (ent.origin, 500)]; bestp = 1; while (foe) { thatp = [self priorityForThing:foe]; if (thatp) if (!scope) - if (!sisible (ent, foe)) + if (!sisible (ent, foe.ent)) thatp = 0; if (thatp > bestp) { bestp = thatp; best = foe; - dist = vlen (ent.origin - foe.origin); + dist = vlen (ent.origin - foe.ent.origin); } - foe = foe.chain; + foe = [Target forEntity:foe.ent.chain]; } if (best == NIL) return; if (![self targetOnstack:best]) { - [self targetAdd:[Target forEntity:best]]; + [self targetAdd:best]; if (scope) { [self getPath:best :FALSE]; b_aiflags |= AI_WAIT; diff --git a/fbxa/bot_fight.qc b/fbxa/bot_fight.qc index 204c564..f276cdb 100644 --- a/fbxa/bot_fight.qc +++ b/fbxa/bot_fight.qc @@ -51,7 +51,7 @@ _x "sweet spot range" - try to maintain this range if possible _y minimum range bot can be to be effective (rl/gl) (move away) _z maximum range bot can be to be effective (lg/axe) (move in) */ -vector (float wep) +vector (integer wep) weapon_range = { switch (wep) { @@ -212,14 +212,12 @@ weapon_range = if (flen < foedist) { tsz = [self sizePlayer:foe]; if (tsz < foesz) { - /*XXX - if (fov(foe) || foe.b_sound > time || b_skill == 3) { + if ([self fov:foe.ent] || foe.b_sound > time || b_skill == 3) { if ([self canSee:foe]) { - ent.enemy = foe; - foedist = vlen (foe.origin - ent.origin); + ent.enemy = foe.ent; + foedist = vlen ([foe origin] - ent.origin); } } - */ } } } @@ -237,10 +235,10 @@ Pick a weapon based on range / ammo */ -(void)weaponSwitch:(float)brange { - local float it, flag = 0, pulse = 0; + local integer it, flag = 0, pulse = 0; local vector v; - it = ent.items & 127; + it = (integer) ent.items & 127; while (it) { if ((ent.ammo_rockets >= 1) && (it & 32)) { @@ -266,22 +264,22 @@ Pick a weapon based on range / ammo pulse = 2; } else { if (pulse) - ent.impulse = pulse; + impulse = pulse; return; } if (brange == -1) { if (pulse) - ent.impulse = pulse; + impulse = pulse; return; } v = weapon_range (flag); if (brange < v_y || brange > v_z) - it = it - flag; + it &= ~flag; else { if (pulse) - ent.impulse = pulse; + impulse = pulse; return; } } @@ -328,7 +326,7 @@ attacking an enemy. // decide if I should shoot foedist = vlen (org - ent.origin); - v = weapon_range (ent.weapon); + v = weapon_range ((integer)ent.weapon); if (foedist > v_y && foedist < v_z) { traceline (ent.origin + ent.view_ofs, ent.origin + ent.view_ofs + v_forward * v_z, FALSE, ent); if (vlen(trace_endpos - (ent.origin + ent.view_ofs)) >= v_y) { diff --git a/fbxa/bot_phys.qc b/fbxa/bot_phys.qc index baaa04a..93b3282 100644 --- a/fbxa/bot_phys.qc +++ b/fbxa/bot_phys.qc @@ -48,7 +48,7 @@ this notice in its entirety. */ #include "libfrikbot.h" - +string (integer i) itos = #112; integer bot_phys_linker; float (integer keys, integer key) key_state = @@ -102,6 +102,8 @@ float (integer keys, integer key) key_state = } + //dprint (itos (buttons) + " " + itos (impulse) + "\n"); SV_UserCmd (ent, real_frametime, ent.v_angle, movevect, buttons, impulse); + impulse = 0; } @end diff --git a/fbxa/bot_qw.qc b/fbxa/bot_qw.qc index 125d12d..60b61e8 100644 --- a/fbxa/bot_qw.qc +++ b/fbxa/bot_qw.qc @@ -439,14 +439,17 @@ void () BotImpulses = local string bottomcolor = ftos (b_pants); local string topcolor = ftos (b_shirt); - dprint (ent.netname); - dprint ("\n"); SV_SetPing (ent, 100 * (3 - b_skill)); SV_SetUserinfo (ent, "\\bottomcolor\\" + bottomcolor + "\\topcolor\\" + topcolor + "\\team\\bot\\skin\\base\\name\\" + ent.netname); // FIXME: do teams properly } + +-(integer)ishuman +{ + return ishuman; +} @end void () diff --git a/fbxa/libfrikbot.h b/fbxa/libfrikbot.h index 807d584..d53e8a8 100644 --- a/fbxa/libfrikbot.h +++ b/fbxa/libfrikbot.h @@ -18,6 +18,7 @@ typedef struct bot_data_t bot_data_t; -(integer)canSee:(Target)targ ignoring:(entity)ignore; -(void)setOrigin:(vector) org; -(integer)recognizePlat:(integer)flag; +-(integer)ishuman; @end @interface Waypoint: Target @@ -151,7 +152,7 @@ typedef struct bot_data_t bot_data_t; -(void)checkLost:(Waypoint)targ; -(void)handleAI; -(void)path; --(float)priorityForThing:(entity)thing; +-(float)priorityForThing:(Target)thing; -(void)lookForCrap:(integer)scope; -(void)angleSet; -(void)AI; diff --git a/fbxa/target.r b/fbxa/target.r index 586ca02..5d57cb9 100644 --- a/fbxa/target.r +++ b/fbxa/target.r @@ -73,6 +73,9 @@ struct target_s = { local Target t; local struct target_s ele; + if (ent.classname == "player") + return ent.@this; + if (!target_tab) { target_tab = Hash_NewTable (1021, NIL, NIL, NIL); Hash_SetHashCompare (target_tab, target_get_hash, target_compare); @@ -130,4 +133,9 @@ struct target_s = { return FALSE; } +-(integer)ishuman +{ + return 0; +} + @end