mirror of
https://github.com/yquake2/rogue.git
synced 2024-11-22 20:31:50 +00:00
g_ai.c aufgeräumt
This commit is contained in:
parent
2f70ee701a
commit
ebfd333fab
1 changed files with 34 additions and 146 deletions
180
src/g_ai.c
180
src/g_ai.c
|
@ -129,7 +129,6 @@ void ai_stand (edict_t *self, float dist)
|
|||
FindTarget (self);
|
||||
return;
|
||||
}
|
||||
// ai_checkattack (self, 0);
|
||||
// pmm
|
||||
}
|
||||
else
|
||||
|
@ -223,14 +222,8 @@ void ai_charge (edict_t *self, float dist)
|
|||
{
|
||||
VectorSubtract (self->enemy->s.origin, self->s.origin, v);
|
||||
self->ideal_yaw = vectoyaw(v);
|
||||
// gi.dprintf ("enemy = %s\n", vtos (self->enemy->s.origin));
|
||||
// gi.dprintf ("enemy: ideal yaw is %f\n", self->ideal_yaw);
|
||||
}
|
||||
// if (!(self->monsterinfo.aiflags & AI_MANUAL_STEERING))
|
||||
M_ChangeYaw (self);
|
||||
// PMM
|
||||
// if (dist)
|
||||
// M_walkmove (self, self->s.angles[YAW], dist);
|
||||
|
||||
if (dist)
|
||||
{
|
||||
|
@ -259,7 +252,7 @@ void ai_charge (edict_t *self, float dist)
|
|||
else
|
||||
M_walkmove (self, self->s.angles[YAW], dist);
|
||||
}
|
||||
// PMM
|
||||
// PMM
|
||||
}
|
||||
|
||||
|
||||
|
@ -356,7 +349,7 @@ qboolean visible (edict_t *self, edict_t *other)
|
|||
spot2[2] += other->viewheight;
|
||||
trace = gi.trace (spot1, vec3_origin, vec3_origin, spot2, self, MASK_OPAQUE);
|
||||
|
||||
if (trace.fraction == 1.0 || trace.ent == other) // PGM
|
||||
if (trace.fraction == 1.0 || trace.ent == other)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -411,8 +404,6 @@ void FoundTarget (edict_t *self)
|
|||
{
|
||||
if(self->enemy->flags & FL_DISGUISED)
|
||||
{
|
||||
// level.disguise_violator = self->enemy;
|
||||
// level.disguise_violation_framenum = level.framenum + 5;
|
||||
self->enemy->flags &= ~FL_DISGUISED;
|
||||
}
|
||||
|
||||
|
@ -497,12 +488,12 @@ qboolean FindTarget (edict_t *self)
|
|||
if (self->monsterinfo.aiflags & AI_COMBAT_POINT)
|
||||
return false;
|
||||
|
||||
// if the first spawnflag bit is set, the monster will only wake up on
|
||||
// really seeing the player, not another monster getting angry or hearing
|
||||
// something
|
||||
// if the first spawnflag bit is set, the monster will only wake up on
|
||||
// really seeing the player, not another monster getting angry or hearing
|
||||
// something
|
||||
|
||||
// revised behavior so they will wake up if they "see" a player make a noise
|
||||
// but not weapon impact/explosion noises
|
||||
// revised behavior so they will wake up if they "see" a player make a noise
|
||||
// but not weapon impact/explosion noises
|
||||
|
||||
heardit = false;
|
||||
if ((level.sight_entity_framenum >= (level.framenum - 1)) && !(self->spawnflags & 1) )
|
||||
|
@ -544,8 +535,6 @@ qboolean FindTarget (edict_t *self)
|
|||
//PMM - hintpath coop fix
|
||||
if ((self->monsterinfo.aiflags & AI_HINT_PATH) && (coop) && (coop->value))
|
||||
{
|
||||
// if ((heardit) && (g_showlogic) && (g_showlogic->value))
|
||||
// gi.dprintf ("ignoring coop sound target\n");
|
||||
heardit = false;
|
||||
}
|
||||
// pmm
|
||||
|
@ -578,8 +567,6 @@ qboolean FindTarget (edict_t *self)
|
|||
if (r == RANGE_FAR)
|
||||
return false;
|
||||
|
||||
// this is where we would check invisibility
|
||||
|
||||
// is client in an spot too dark to be seen?
|
||||
if (client->light_level <= 5)
|
||||
return false;
|
||||
|
@ -647,7 +634,7 @@ qboolean FindTarget (edict_t *self)
|
|||
if (client->areanum != self->areanum)
|
||||
if (!gi.AreasConnected(self->areanum, client->areanum))
|
||||
return false;
|
||||
|
||||
|
||||
self->ideal_yaw = vectoyaw(temp);
|
||||
if (!(self->monsterinfo.aiflags & AI_MANUAL_STEERING))
|
||||
M_ChangeYaw (self);
|
||||
|
@ -657,15 +644,12 @@ qboolean FindTarget (edict_t *self)
|
|||
self->enemy = client;
|
||||
}
|
||||
|
||||
//
|
||||
// got one
|
||||
//
|
||||
//
|
||||
// got one
|
||||
//
|
||||
// PMM - if we got an enemy, we need to bail out of hint paths, so take over here
|
||||
if (self->monsterinfo.aiflags & AI_HINT_PATH)
|
||||
{
|
||||
// if(g_showlogic && g_showlogic->value)
|
||||
// gi.dprintf("stopped following hint paths in FindTarget\n");
|
||||
|
||||
// this calls foundtarget for us
|
||||
hintpath_stop (self);
|
||||
}
|
||||
|
@ -740,17 +724,10 @@ qboolean M_CheckAttack (edict_t *self)
|
|||
}
|
||||
else
|
||||
{
|
||||
// gi.WriteByte (svc_temp_entity);
|
||||
// gi.WriteByte (TE_DEBUGTRAIL);
|
||||
// gi.WritePosition (spot1);
|
||||
// gi.WritePosition (self->monsterinfo.blind_fire_target);
|
||||
// gi.multicast (self->s.origin, MULTICAST_ALL);
|
||||
// make sure we're not going to shoot a monster
|
||||
tr = gi.trace (spot1, NULL, NULL, self->monsterinfo.blind_fire_target, self, CONTENTS_MONSTER);
|
||||
if (tr.allsolid || tr.startsolid || ((tr.fraction < 1.0) && (tr.ent != self->enemy)))
|
||||
{
|
||||
// if ((g_showlogic) && (g_showlogic->value))
|
||||
// gi.dprintf ("blindfire blocked\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -782,7 +759,7 @@ qboolean M_CheckAttack (edict_t *self)
|
|||
return true;
|
||||
}
|
||||
|
||||
// missile attack
|
||||
// missile attack
|
||||
if (!self->monsterinfo.attack)
|
||||
{
|
||||
// PMM - fix for melee only monsters & strafing
|
||||
|
@ -850,7 +827,7 @@ qboolean M_CheckAttack (edict_t *self)
|
|||
else
|
||||
self->monsterinfo.attack_state = AS_STRAIGHT;
|
||||
}
|
||||
// do we want the monsters strafing?
|
||||
// do we want the monsters strafing?
|
||||
#ifdef SLIDING_TROOPS
|
||||
else
|
||||
{
|
||||
|
@ -860,7 +837,7 @@ qboolean M_CheckAttack (edict_t *self)
|
|||
self->monsterinfo.attack_state = AS_STRAIGHT;
|
||||
}
|
||||
#endif
|
||||
//-PMM
|
||||
//-PMM
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -903,13 +880,10 @@ void ai_run_missile(edict_t *self)
|
|||
if (FacingIdeal(self))
|
||||
{
|
||||
self->monsterinfo.attack (self);
|
||||
// if (self->monsterinfo.attack_state == AS_MISSILE)
|
||||
if ((self->monsterinfo.attack_state == AS_MISSILE) || (self->monsterinfo.attack_state == AS_BLIND))
|
||||
self->monsterinfo.attack_state = AS_STRAIGHT;
|
||||
// else if (self->monsterinfo.attack_state != AS_SLIDING)
|
||||
// gi.dprintf ("ai_run_missile: Unexpected attack state %d !\n", self->monsterinfo.attack_state);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -925,40 +899,16 @@ void ai_run_slide(edict_t *self, float distance)
|
|||
float angle;
|
||||
|
||||
self->ideal_yaw = enemy_yaw;
|
||||
|
||||
// if (self->flags & FL_FLY)
|
||||
// angle = 90;
|
||||
// else
|
||||
// angle = 45;
|
||||
|
||||
angle = 90;
|
||||
|
||||
|
||||
if (self->monsterinfo.lefty)
|
||||
ofs = angle;
|
||||
else
|
||||
ofs = -angle;
|
||||
//
|
||||
// if (!(self->flags & FL_FLY))
|
||||
// {
|
||||
// // non fliers should actually turn towards the direction their trying to run
|
||||
// self->ideal_yaw += ofs;
|
||||
// }
|
||||
//
|
||||
|
||||
if (!(self->monsterinfo.aiflags & AI_MANUAL_STEERING))
|
||||
M_ChangeYaw (self);
|
||||
|
||||
/*
|
||||
if (!(self->flags & FL_FLY))
|
||||
{
|
||||
if (M_walkmove (self, self->ideal_yaw + ofs, distance))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (M_walkmove (self, self->ideal_yaw, distance))
|
||||
return;
|
||||
}
|
||||
*/
|
||||
// PMM - clamp maximum sideways move for non flyers to make them look less jerky
|
||||
if (!self->flags & FL_FLY)
|
||||
distance = min (distance, MAX_SIDESTEP);
|
||||
|
@ -1009,7 +959,7 @@ qboolean ai_checkattack (edict_t *self, float dist)
|
|||
// PMM
|
||||
qboolean retval;
|
||||
|
||||
// this causes monsters to run blindly to the combat point w/o firing
|
||||
// this causes monsters to run blindly to the combat point w/o firing
|
||||
if (self->goalentity)
|
||||
{
|
||||
if (self->monsterinfo.aiflags & AI_COMBAT_POINT)
|
||||
|
@ -1020,10 +970,12 @@ qboolean ai_checkattack (edict_t *self, float dist)
|
|||
if ((level.time - self->enemy->teleport_time) > 5.0)
|
||||
{
|
||||
if (self->goalentity == self->enemy)
|
||||
{
|
||||
if (self->movetarget)
|
||||
self->goalentity = self->movetarget;
|
||||
else
|
||||
self->goalentity = NULL;
|
||||
}
|
||||
self->monsterinfo.aiflags &= ~AI_SOUND_TARGET;
|
||||
if (self->monsterinfo.aiflags & AI_TEMP_STAND_GROUND)
|
||||
self->monsterinfo.aiflags &= ~(AI_STAND_GROUND | AI_TEMP_STAND_GROUND);
|
||||
|
@ -1049,7 +1001,6 @@ qboolean ai_checkattack (edict_t *self, float dist)
|
|||
if (!(self->enemy->inuse) || (self->enemy->health > 0))
|
||||
{
|
||||
hesDeadJim = true;
|
||||
// self->monsterinfo.aiflags &= ~AI_MEDIC;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1077,17 +1028,15 @@ qboolean ai_checkattack (edict_t *self, float dist)
|
|||
self->oldenemy = NULL;
|
||||
HuntTarget (self);
|
||||
}
|
||||
//ROGUE - multiple teslas make monsters lose track of the player.
|
||||
//ROGUE - multiple teslas make monsters lose track of the player.
|
||||
else if(self->monsterinfo.last_player_enemy && self->monsterinfo.last_player_enemy->health > 0)
|
||||
{
|
||||
// if ((g_showlogic) && (g_showlogic->value))
|
||||
// gi.dprintf("resorting to last_player_enemy...\n");
|
||||
self->enemy = self->monsterinfo.last_player_enemy;
|
||||
self->oldenemy = NULL;
|
||||
self->monsterinfo.last_player_enemy = NULL;
|
||||
HuntTarget (self);
|
||||
}
|
||||
//ROGUE
|
||||
//ROGUE
|
||||
else
|
||||
{
|
||||
if (self->movetarget)
|
||||
|
@ -1110,7 +1059,7 @@ qboolean ai_checkattack (edict_t *self, float dist)
|
|||
|
||||
self->show_hostile = level.time + 1; // wake up other monsters
|
||||
|
||||
// check knowledge of enemy
|
||||
// check knowledge of enemy
|
||||
enemy_vis = visible(self, self->enemy);
|
||||
if (enemy_vis)
|
||||
{
|
||||
|
@ -1124,12 +1073,6 @@ qboolean ai_checkattack (edict_t *self, float dist)
|
|||
// pmm
|
||||
}
|
||||
|
||||
// look for other coop players here
|
||||
// if (coop && self->monsterinfo.search_time < level.time)
|
||||
// {
|
||||
// if (FindTarget (self))
|
||||
// return true;
|
||||
// }
|
||||
|
||||
enemy_infront = infront(self, self->enemy);
|
||||
enemy_range = range(self, self->enemy);
|
||||
|
@ -1209,47 +1152,24 @@ void ai_run (edict_t *self, float dist)
|
|||
// PMM
|
||||
if (self->monsterinfo.aiflags & AI_DUCKED)
|
||||
{
|
||||
// if ((g_showlogic) && (g_showlogic->value))
|
||||
// gi.dprintf ("%s - duck flag cleaned up!\n", self->classname);
|
||||
self->monsterinfo.aiflags &= ~AI_DUCKED;
|
||||
}
|
||||
if (self->maxs[2] != self->monsterinfo.base_height)
|
||||
{
|
||||
// if ((g_showlogic) && (g_showlogic->value))
|
||||
// gi.dprintf ("%s - ducked height corrected!\n", self->classname);
|
||||
monster_duck_up (self);
|
||||
}
|
||||
// if ((self->monsterinfo.aiflags & AI_MANUAL_STEERING) && (strcmp(self->classname, "monster_turret")))
|
||||
// {
|
||||
// if ((g_showlogic) && (g_showlogic->value))
|
||||
// gi.dprintf ("%s - manual steering in ai_run!\n", self->classname);
|
||||
// }
|
||||
// pmm
|
||||
|
||||
//==========
|
||||
//PGM
|
||||
//==========
|
||||
//PGM
|
||||
// if we're currently looking for a hint path
|
||||
if (self->monsterinfo.aiflags & AI_HINT_PATH)
|
||||
{
|
||||
// determine direction to our destination hintpath.
|
||||
// FIXME - is this needed EVERY time? I was having trouble with them
|
||||
// sometimes not going after it, and this fixed it.
|
||||
// VectorSubtract(self->movetarget->s.origin, self->s.origin, v);
|
||||
// vectoangles(v, v_forward);
|
||||
// self->ideal_yaw = v_forward[YAW];
|
||||
// gi.dprintf("seeking hintpath. origin: %s %0.1f\n", vtos(v), self->ideal_yaw);
|
||||
M_MoveToGoal (self, dist);
|
||||
if(!self->inuse)
|
||||
return; // PGM - g_touchtrigger free problem
|
||||
// return;
|
||||
|
||||
// if we've already seen the player, and can't see him now, return
|
||||
// if(self->enemy && !visible(self, self->enemy))
|
||||
// return;
|
||||
|
||||
// if not and can't find the player, return
|
||||
// if(!FindTarget(self))
|
||||
// return;
|
||||
|
||||
// first off, make sure we're looking for the player, not a noise he made
|
||||
if (self->enemy)
|
||||
|
@ -1297,18 +1217,14 @@ void ai_run (edict_t *self, float dist)
|
|||
// if we see the player, stop following hintpaths.
|
||||
if (gotcha)
|
||||
{
|
||||
// if(g_showlogic && g_showlogic->value)
|
||||
// gi.dprintf("stopped following hint paths in ai_run\n");
|
||||
|
||||
// disconnect from hintpaths and start looking normally for players.
|
||||
hintpath_stop (self);
|
||||
// pmm - no longer needed, since hintpath_stop does it
|
||||
// HuntTarget(self);
|
||||
}
|
||||
return;
|
||||
}
|
||||
//PGM
|
||||
//==========
|
||||
//PGM
|
||||
//==========
|
||||
|
||||
if (self->monsterinfo.aiflags & AI_SOUND_TARGET)
|
||||
{
|
||||
|
@ -1389,20 +1305,10 @@ void ai_run (edict_t *self, float dist)
|
|||
return;
|
||||
}
|
||||
//PMM
|
||||
// if (ai_checkattack (self, dist))
|
||||
// return;
|
||||
|
||||
// if (self->monsterinfo.attack_state == AS_SLIDING)
|
||||
// {
|
||||
// ai_run_slide (self, dist);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// PGM - added a little paranoia checking here... 9/22/98
|
||||
if ((self->enemy) && (self->enemy->inuse) && (enemy_vis))
|
||||
{
|
||||
// if (self->monsterinfo.aiflags & AI_LOST_SIGHT)
|
||||
// gi.dprintf("regained sight\n");
|
||||
// PMM - check for alreadyMoved
|
||||
if (!alreadyMoved)
|
||||
M_MoveToGoal (self, dist);
|
||||
|
@ -1419,8 +1325,8 @@ void ai_run (edict_t *self, float dist)
|
|||
return;
|
||||
}
|
||||
|
||||
//=======
|
||||
//PGM
|
||||
//=======
|
||||
//PGM
|
||||
// if we've been looking (unsuccessfully) for the player for 10 seconds
|
||||
// PMM - reduced to 5, makes them much nastier
|
||||
if((self->monsterinfo.trail_time + 5) <= level.time)
|
||||
|
@ -1434,17 +1340,17 @@ void ai_run (edict_t *self, float dist)
|
|||
return;
|
||||
}
|
||||
}
|
||||
//PGM
|
||||
//=======
|
||||
//PGM
|
||||
//=======
|
||||
|
||||
// PMM - moved down here to allow monsters to get on hint paths
|
||||
// PMM - moved down here to allow monsters to get on hint paths
|
||||
// coop will change to another enemy if visible
|
||||
if (coop->value)
|
||||
{ // FIXME: insane guys get mad with this, which causes crashes!
|
||||
if (FindTarget (self))
|
||||
return;
|
||||
}
|
||||
// pmm
|
||||
// pmm
|
||||
|
||||
if ((self->monsterinfo.search_time) && (level.time > (self->monsterinfo.search_time + 20)))
|
||||
{
|
||||
|
@ -1452,7 +1358,6 @@ void ai_run (edict_t *self, float dist)
|
|||
if (!alreadyMoved)
|
||||
M_MoveToGoal (self, dist);
|
||||
self->monsterinfo.search_time = 0;
|
||||
// gi.dprintf("search timeout\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1465,7 +1370,6 @@ void ai_run (edict_t *self, float dist)
|
|||
if (!(self->monsterinfo.aiflags & AI_LOST_SIGHT))
|
||||
{
|
||||
// just lost sight of the player, decide where to go first
|
||||
// gi.dprintf("lost sight of player, last seen at %s\n", vtos(self->monsterinfo.last_sighting));
|
||||
self->monsterinfo.aiflags |= (AI_LOST_SIGHT | AI_PURSUIT_LAST_SEEN);
|
||||
self->monsterinfo.aiflags &= ~(AI_PURSUE_NEXT | AI_PURSUE_TEMP);
|
||||
new = true;
|
||||
|
@ -1473,18 +1377,13 @@ void ai_run (edict_t *self, float dist)
|
|||
|
||||
if (self->monsterinfo.aiflags & AI_PURSUE_NEXT)
|
||||
{
|
||||
// vec3_t debug_vec;
|
||||
|
||||
self->monsterinfo.aiflags &= ~AI_PURSUE_NEXT;
|
||||
// VectorSubtract(self->monsterinfo.last_sighting, self->s.origin, debug_vec);
|
||||
// gi.dprintf("reached current goal: %s %s %f", vtos(self->s.origin), vtos(self->monsterinfo.last_sighting), VectorLength(debug_vec));
|
||||
|
||||
// give ourself more time since we got this far
|
||||
self->monsterinfo.search_time = level.time + 5;
|
||||
|
||||
if (self->monsterinfo.aiflags & AI_PURSUE_TEMP)
|
||||
{
|
||||
// gi.dprintf("was temp goal; retrying original\n");
|
||||
self->monsterinfo.aiflags &= ~AI_PURSUE_TEMP;
|
||||
marker = NULL;
|
||||
VectorCopy (self->monsterinfo.saved_goal, self->monsterinfo.last_sighting);
|
||||
|
@ -1505,9 +1404,6 @@ void ai_run (edict_t *self, float dist)
|
|||
VectorCopy (marker->s.origin, self->monsterinfo.last_sighting);
|
||||
self->monsterinfo.trail_time = marker->timestamp;
|
||||
self->s.angles[YAW] = self->ideal_yaw = marker->s.angles[YAW];
|
||||
// gi.dprintf("heading is %0.1f\n", self->ideal_yaw);
|
||||
|
||||
// debug_drawline(self.origin, self.last_sighting, 52);
|
||||
new = true;
|
||||
}
|
||||
}
|
||||
|
@ -1524,8 +1420,6 @@ void ai_run (edict_t *self, float dist)
|
|||
|
||||
if (new)
|
||||
{
|
||||
// gi.dprintf("checking for course correction\n");
|
||||
|
||||
tr = gi.trace(self->s.origin, self->mins, self->maxs, self->monsterinfo.last_sighting, self, MASK_PLAYERSOLID);
|
||||
if (tr.fraction < 1)
|
||||
{
|
||||
|
@ -1553,7 +1447,6 @@ void ai_run (edict_t *self, float dist)
|
|||
{
|
||||
VectorSet(v, d2 * left * 0.5, -16, 0);
|
||||
G_ProjectSource (self->s.origin, v, v_forward, v_right, left_target);
|
||||
// gi.dprintf("incomplete path, go part way and adjust again\n");
|
||||
}
|
||||
VectorCopy (self->monsterinfo.last_sighting, self->monsterinfo.saved_goal);
|
||||
self->monsterinfo.aiflags |= AI_PURSUE_TEMP;
|
||||
|
@ -1561,8 +1454,6 @@ void ai_run (edict_t *self, float dist)
|
|||
VectorCopy (left_target, self->monsterinfo.last_sighting);
|
||||
VectorSubtract (self->goalentity->s.origin, self->s.origin, v);
|
||||
self->s.angles[YAW] = self->ideal_yaw = vectoyaw(v);
|
||||
// gi.dprintf("adjusted left\n");
|
||||
// debug_drawline(self.origin, self.last_sighting, 152);
|
||||
}
|
||||
else if (right >= center && right > left)
|
||||
{
|
||||
|
@ -1570,7 +1461,6 @@ void ai_run (edict_t *self, float dist)
|
|||
{
|
||||
VectorSet(v, d2 * right * 0.5, 16, 0);
|
||||
G_ProjectSource (self->s.origin, v, v_forward, v_right, right_target);
|
||||
// gi.dprintf("incomplete path, go part way and adjust again\n");
|
||||
}
|
||||
VectorCopy (self->monsterinfo.last_sighting, self->monsterinfo.saved_goal);
|
||||
self->monsterinfo.aiflags |= AI_PURSUE_TEMP;
|
||||
|
@ -1578,11 +1468,8 @@ void ai_run (edict_t *self, float dist)
|
|||
VectorCopy (right_target, self->monsterinfo.last_sighting);
|
||||
VectorSubtract (self->goalentity->s.origin, self->s.origin, v);
|
||||
self->s.angles[YAW] = self->ideal_yaw = vectoyaw(v);
|
||||
// gi.dprintf("adjusted right\n");
|
||||
// debug_drawline(self.origin, self.last_sighting, 152);
|
||||
}
|
||||
}
|
||||
// else gi.dprintf("course was fine\n");
|
||||
}
|
||||
|
||||
M_MoveToGoal (self, dist);
|
||||
|
@ -1594,3 +1481,4 @@ void ai_run (edict_t *self, float dist)
|
|||
if (self)
|
||||
self->goalentity = save;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue