mirror of
https://git.code.sf.net/p/quake/game-source
synced 2024-11-25 13:21:30 +00:00
bot_ai.qc bot_way.qc:
test classname `properly' (ie, with -classname) bot_move.qc: re-implement the lost obstruction detection code in a way suitable for the new physics handling. Probably needs tuning. bot_qw.qc libfrikbot.h: Break and itos for debugging waypoint.r: implement -realorigin. oops. that caused how long a wild goose chase?
This commit is contained in:
parent
8b784f2ede
commit
8935fc4c84
6 changed files with 66 additions and 29 deletions
|
@ -150,7 +150,7 @@ Bot has lost its target.
|
|||
return;
|
||||
|
||||
[self targetDrop:targ];
|
||||
if ([targ isKindOfClass:[Waypoint class]])
|
||||
if ([targ classname] == "waypoint")
|
||||
[(Waypoint)targ clearRouteForBot:self];
|
||||
|
||||
// find a new route
|
||||
|
@ -160,19 +160,19 @@ Bot has lost its target.
|
|||
[Waypoint clearMyRoute:self];
|
||||
b_aiflags = 0;
|
||||
} else {
|
||||
if (targ.ent.classname == "item_artifact_invisibility")
|
||||
if ([targ classname] == "item_artifact_invisibility")
|
||||
if (ent.items & IT_INVISIBILITY)
|
||||
[self startTopic:3];
|
||||
|
||||
if (targ.ent.flags & FL_ITEM) {
|
||||
if (!targ.ent.model)
|
||||
targ._last = NIL;
|
||||
else
|
||||
targ._last = self;
|
||||
}
|
||||
}
|
||||
if (targ.ent.flags & FL_ITEM) {
|
||||
if (!targ.ent.model)
|
||||
targ._last = NIL;
|
||||
else
|
||||
targ._last = self;
|
||||
}
|
||||
}
|
||||
|
||||
if (targ.ent.classname != "player")
|
||||
if ([targ classname] != "player")
|
||||
[self setSearchTime:time + 5];
|
||||
}
|
||||
|
||||
|
@ -199,25 +199,28 @@ removed.
|
|||
// waypoints and items are lost if you get close enough to them
|
||||
if ([targ isKindOfClass:[Waypoint class]]) {
|
||||
local Waypoint way = (Waypoint) targ;
|
||||
if (!(b_aiflags & (AI_SNIPER | AI_AMBUSH))) {
|
||||
if (b_aiflags & AI_RIDE_TRAIN) {
|
||||
if (vlen (way.origin - ent.origin) < 48)
|
||||
if ([way classname] == "waypoint") {
|
||||
if (!(b_aiflags & (AI_SNIPER | AI_AMBUSH))) {
|
||||
if (b_aiflags & AI_RIDE_TRAIN) {
|
||||
if (vlen (way.origin - ent.origin) < 48)
|
||||
[self lost:way :TRUE];
|
||||
} else if (b_aiflags & AI_PRECISION) {
|
||||
if (vlen (way.origin - ent.origin) < 24)
|
||||
[self lost:way :TRUE];
|
||||
} else if (vlen (way.origin - ent.origin) < 32)
|
||||
[self lost:way :TRUE];
|
||||
} else if (b_aiflags & AI_PRECISION) {
|
||||
if (vlen (way.origin - ent.origin) < 24)
|
||||
[self lost:way :TRUE];
|
||||
} else if (vlen (way.origin - ent.origin) < 32)
|
||||
}
|
||||
} else {
|
||||
//temp_waypoint
|
||||
if (vlen (way.origin - ent.origin) < 32)
|
||||
[self lost:way :TRUE];
|
||||
}
|
||||
//temp_waypoint
|
||||
if (vlen (way.origin - ent.origin) < 32)
|
||||
[self lost:way :TRUE];
|
||||
} else if ([targ isKindOfClass:[Bot class]]) {
|
||||
local Bot bot = (Bot) targ;
|
||||
if (bot.ent.health <= 0)
|
||||
[self lost:bot :TRUE];
|
||||
else if ((coop) || (teamplay && bot.ent.team == ent.team)) {
|
||||
if (bot.targets[0].ent.classname == "player") {
|
||||
if ([bot.targets[0] classname] == "player") {
|
||||
if (![bot.targets[0] ishuman])
|
||||
[self lost:bot :TRUE];
|
||||
} else if (bot.ent.teleport_time > time) {
|
||||
|
@ -526,12 +529,12 @@ the bot finds things it wants to kill/grab.
|
|||
if (ent.items & IT_INVISIBILITY) //FIXME
|
||||
p = 2;
|
||||
else if (coop) {
|
||||
if (targets[0].ent.classname == "player")
|
||||
if ([targets[0] classname] == "player")
|
||||
if (![targets[0] ishuman])
|
||||
return 0;
|
||||
p = 100;
|
||||
} else if (teamplay && ent.team == bot.ent.team) {
|
||||
if (targets[0].ent.classname == "player")
|
||||
if ([targets[0] classname] == "player")
|
||||
return 0;
|
||||
p = 100;
|
||||
} else
|
||||
|
@ -661,7 +664,7 @@ generally making the bot look good.
|
|||
view = view + '0 0 48';
|
||||
view -= (ent.origin + ent.view_ofs);
|
||||
view = vectoangles (view);
|
||||
view_x *= -1;
|
||||
view_x = -view_x;
|
||||
b_angle = view;
|
||||
} else
|
||||
b_angle.x = 0;
|
||||
|
|
|
@ -49,6 +49,10 @@ float (integer keys, integer key) key_state =
|
|||
return ((keys & key) != 0) ? 1.0 : 0.0;
|
||||
};
|
||||
|
||||
void (vector start, vector mins, vector maxs, vector end, float type,
|
||||
entity passent) checkmove = #98; // Wrapper around SV_Move.
|
||||
|
||||
|
||||
@implementation Bot (Move)
|
||||
|
||||
-(void)sendMove
|
||||
|
@ -56,6 +60,8 @@ float (integer keys, integer key) key_state =
|
|||
local vector movevect = '0 0 0';
|
||||
local float anglespeed;
|
||||
local vector view;
|
||||
local vector probe, start;
|
||||
local integer obstructed = 0;
|
||||
|
||||
movevect.y += (350 * key_state (keys, KEY_MOVERIGHT));
|
||||
movevect.y -= (350 * key_state (keys, KEY_MOVELEFT));
|
||||
|
@ -94,10 +100,31 @@ float (integer keys, integer key) key_state =
|
|||
ent.v_angle += mouse_emu * real_frametime;
|
||||
|
||||
|
||||
}
|
||||
start = ent.origin;
|
||||
//start.z += 16; // step offset
|
||||
makevectors (ent.v_angle);
|
||||
probe = v_forward * movevect.x + v_right * movevect.y + ent.velocity;
|
||||
probe.z = 0;
|
||||
if (probe) {
|
||||
probe = normalize (probe);
|
||||
probe = probe * 32 + start;
|
||||
checkmove (start, ent.mins, ent.maxs, probe, 1, ent);
|
||||
if (trace_fraction != 1) {
|
||||
obstructed = 1;
|
||||
probe = (probe - start);
|
||||
if (trace_fraction)
|
||||
probe *= trace_fraction;
|
||||
else
|
||||
probe = normalize (probe);
|
||||
}
|
||||
}
|
||||
//dprint (itos (buttons) + " " + itos (impulse) + "\n");
|
||||
//dprint (ftos (real_frametime) + "\n");
|
||||
SV_UserCmd (ent, real_frametime, ent.v_angle, movevect, buttons, impulse);
|
||||
impulse = 0;
|
||||
if (obstructed)
|
||||
[self obstructed:probe:FALSE];
|
||||
}
|
||||
|
||||
- (void) jump
|
||||
|
@ -199,7 +226,6 @@ manuever around.
|
|||
// TODO: something
|
||||
if (b_aiflags & AI_BLIND)
|
||||
return;
|
||||
org = [targets[0] realorigin];
|
||||
|
||||
if (danger) {
|
||||
b_aiflags |= AI_DANGER;
|
||||
|
@ -208,6 +234,7 @@ manuever around.
|
|||
if (b_aiflags & AI_PRECISION)
|
||||
return;
|
||||
|
||||
disway_z = 0;
|
||||
|
||||
if (targets[0]) {
|
||||
if (b_aiflags & AI_OBSTRUCTED) {
|
||||
|
@ -217,10 +244,10 @@ manuever around.
|
|||
} else if (!danger)
|
||||
return;
|
||||
}
|
||||
org = [targets[0] realorigin];
|
||||
obs_dir = whichway;
|
||||
disway_x = whichway_y * -1;
|
||||
disway_y = whichway_x;
|
||||
disway_z = 0;
|
||||
dist = vlen (org - (ent.origin + disway));
|
||||
disway_x = whichway_y;
|
||||
disway_y = whichway_x * -1;
|
||||
|
@ -230,7 +257,6 @@ manuever around.
|
|||
} else {
|
||||
disway_x = whichway_y * -1;
|
||||
disway_y = whichway_x;
|
||||
disway_z = 0;
|
||||
dist = vlen (disway - obs_dir);
|
||||
disway_x = whichway_y;
|
||||
disway_y = whichway_x * -1;
|
||||
|
|
|
@ -139,7 +139,8 @@ void (entity e, string str) SV_SetUserinfo = #0;
|
|||
void (entity e, integer ping) SV_SetPing = #0;
|
||||
void (entity cl, float sec, vector angles, vector move, integer buttons, integer impulse) SV_UserCmd = #0;
|
||||
void (entity cl) SV_Spawn = #0;
|
||||
|
||||
void () Break = #6;
|
||||
string (integer i) itos = #112;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ different bot.
|
|||
t = [this findWaypoint:this.current_way];
|
||||
// FIXME
|
||||
// ugh, better way to find players please!!!
|
||||
if (this.ent.classname != "player")
|
||||
if ([this classname] != "player")
|
||||
this.current_way = t;
|
||||
|
||||
if (t.enemy == NIL) {
|
||||
|
|
|
@ -317,6 +317,8 @@ typedef struct bot_data_t bot_data_t;
|
|||
move is forward right up
|
||||
*/
|
||||
@extern void (entity cl, float sec, vector angles, vector move, integer buttons, integer impulse) SV_UserCmd;
|
||||
@extern void () Break;
|
||||
@extern string (integer i) itos;
|
||||
|
||||
@extern integer bot_way_linker;
|
||||
@extern integer bot_move_linker;
|
||||
|
|
|
@ -102,6 +102,11 @@ Array waypoint_array;
|
|||
return origin;
|
||||
}
|
||||
|
||||
-(vector)realorigin
|
||||
{
|
||||
return origin;
|
||||
}
|
||||
|
||||
-(integer)isLinkedTo:(Waypoint)way
|
||||
{
|
||||
local integer i;
|
||||
|
|
Loading…
Reference in a new issue