mirror of
https://github.com/yquake2/xatrix.git
synced 2024-11-10 14:52:06 +00:00
Merge pull request #45 from BjossiAlfreds/fixbot-stuck
Fix for fixbots getting permanently stuck until angered
This commit is contained in:
commit
02531143e7
3 changed files with 59 additions and 45 deletions
|
@ -3167,8 +3167,6 @@ SP_object_repair(edict_t *ent)
|
|||
ent->movetype = MOVETYPE_NONE;
|
||||
ent->solid = SOLID_BBOX;
|
||||
ent->classname = "object_repair";
|
||||
VectorSet(ent->mins, -8, -8, 8);
|
||||
VectorSet(ent->maxs, 8, 8, 8);
|
||||
ent->think = object_repair_sparks;
|
||||
ent->nextthink = level.time + 1.0;
|
||||
ent->health = 100;
|
||||
|
@ -3177,5 +3175,7 @@ SP_object_repair(edict_t *ent)
|
|||
{
|
||||
ent->delay = 1.0;
|
||||
}
|
||||
|
||||
gi.linkentity(ent);
|
||||
}
|
||||
|
||||
|
|
|
@ -1031,10 +1031,11 @@ struct edict_s
|
|||
void (*die)(edict_t *self, edict_t *inflictor, edict_t *attacker,
|
||||
int damage, vec3_t point);
|
||||
|
||||
float touch_debounce_time;
|
||||
float touch_debounce_time; /* now also used by fixbots for timeouts when getting stuck */
|
||||
float pain_debounce_time;
|
||||
float damage_debounce_time;
|
||||
float fly_sound_debounce_time; /* now also used by insane marines to store pain sound timeout */
|
||||
/* and by fixbots for storing object_repair timeout when getting stuck */
|
||||
float last_move_time;
|
||||
|
||||
int health;
|
||||
|
|
|
@ -350,57 +350,63 @@ void
|
|||
use_scanner(edict_t *self)
|
||||
{
|
||||
edict_t *ent = NULL;
|
||||
float radius = 1024;
|
||||
vec3_t vec;
|
||||
int len;
|
||||
|
||||
if (!self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while ((ent = findradius(ent, self->s.origin, radius)) != NULL)
|
||||
if (self->fly_sound_debounce_time < level.time &&
|
||||
strcmp(self->goalentity->classname, "object_repair") != 0)
|
||||
{
|
||||
if (ent->health >= 100)
|
||||
while ((ent = findradius(ent, self->s.origin, 1024)) != NULL)
|
||||
{
|
||||
if (strcmp(ent->classname, "object_repair") == 0)
|
||||
if (strcmp(ent->classname, "object_repair") != 0)
|
||||
{
|
||||
if (visible(self, ent))
|
||||
{
|
||||
/* remove the old one */
|
||||
if (strcmp(self->goalentity->classname, "bot_goal") == 0)
|
||||
{
|
||||
self->goalentity->nextthink = level.time + 0.1;
|
||||
self->goalentity->think = G_FreeEdict;
|
||||
}
|
||||
|
||||
self->goalentity = self->enemy = ent;
|
||||
|
||||
VectorSubtract(self->s.origin, self->goalentity->s.origin, vec);
|
||||
len = VectorNormalize(vec);
|
||||
|
||||
if (len < 32)
|
||||
{
|
||||
self->monsterinfo.currentmove = &fixbot_move_weld_start;
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ent->health < 100)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!visible(self, ent))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* remove the old one */
|
||||
if (strcmp(self->goalentity->classname, "bot_goal") == 0)
|
||||
{
|
||||
self->goalentity->nextthink = level.time + 0.1;
|
||||
self->goalentity->think = G_FreeEdict;
|
||||
}
|
||||
|
||||
self->goalentity = self->enemy = ent;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
VectorSubtract(self->s.origin, self->goalentity->s.origin, vec);
|
||||
len = VectorLength(vec);
|
||||
|
||||
if (len < 32)
|
||||
if (strcmp(self->goalentity->classname, "object_repair") == 0)
|
||||
{
|
||||
if (strcmp(self->goalentity->classname, "object_repair") == 0)
|
||||
VectorSubtract(self->s.origin, self->goalentity->s.origin, vec);
|
||||
|
||||
if (VectorLength(vec) < 56)
|
||||
{
|
||||
self->monsterinfo.currentmove = &fixbot_move_weld_start;
|
||||
}
|
||||
else
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(self->goalentity->classname, "bot_goal") == 0)
|
||||
{
|
||||
VectorSubtract(self->s.origin, self->goalentity->s.origin, vec);
|
||||
|
||||
if (VectorLength(vec) < 32)
|
||||
{
|
||||
self->goalentity->nextthink = level.time + 0.1;
|
||||
self->goalentity->think = G_FreeEdict;
|
||||
|
@ -412,22 +418,29 @@ use_scanner(edict_t *self)
|
|||
}
|
||||
|
||||
VectorSubtract(self->s.origin, self->s.old_origin, vec);
|
||||
len = VectorLength(vec);
|
||||
|
||||
/* bot is stuck get new goalentity */
|
||||
if (len == 0)
|
||||
if (VectorLength(vec) > 0)
|
||||
{
|
||||
if (strcmp(self->goalentity->classname, "object_repair") == 0)
|
||||
{
|
||||
self->monsterinfo.currentmove = &fixbot_move_stand;
|
||||
}
|
||||
else
|
||||
self->touch_debounce_time = level.time + 1;
|
||||
}
|
||||
|
||||
if (self->touch_debounce_time < level.time)
|
||||
{
|
||||
/* bot is stuck, get new goalentity */
|
||||
|
||||
if (strcmp(self->goalentity->classname, "bot_goal") == 0)
|
||||
{
|
||||
self->goalentity->nextthink = level.time + 0.1;
|
||||
self->goalentity->think = G_FreeEdict;
|
||||
self->goalentity = self->enemy = NULL;
|
||||
self->monsterinfo.currentmove = &fixbot_move_stand;
|
||||
}
|
||||
else if (strcmp(self->goalentity->classname, "object_repair") == 0)
|
||||
{
|
||||
/* don't try to go for welding targets again for a while */
|
||||
self->fly_sound_debounce_time = level.time + 10;
|
||||
}
|
||||
|
||||
self->monsterinfo.currentmove = &fixbot_move_stand;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue