Add back blindfire support lost in 99073e.

This was lost at the very beginning, when I first merged the baseq2 and
xatrix bugfixes into rogue. I did that by hand, not with my infamous
cleanup script. That came later for the big cleanup before version
2.00... For some reason my playstyle has a very low chance to trigger
blindfiring, so I never realized that it's missing and wasn't able to
reproduce the problem when it was reported in yquake2/yquake2#435.

Reported by @BjossiAlfreds in #34, closes #34.
This commit is contained in:
Yamagi Burmeister 2019-09-27 11:46:49 +02:00
parent b059224bc3
commit 4466b3111a
3 changed files with 194 additions and 14 deletions

View file

@ -394,6 +394,8 @@ tank_pain(edict_t *self, edict_t *other /* unused */, float kick, int damage)
return; /* no pain anims in nightmare */ return; /* no pain anims in nightmare */
} }
self->monsterinfo.aiflags &= ~AI_MANUAL_STEERING;
if (damage <= 30) if (damage <= 30)
{ {
self->monsterinfo.currentmove = &tank_move_pain1; self->monsterinfo.currentmove = &tank_move_pain1;
@ -465,12 +467,25 @@ TankRocket(edict_t *self)
vec3_t dir; vec3_t dir;
vec3_t vec; vec3_t vec;
int flash_number; int flash_number;
trace_t trace;
int rocketSpeed;
vec3_t target;
qboolean blindfire = false;
if (!self) if (!self || !self->enemy || !self->enemy->inuse)
{ {
return; return;
} }
if (self->monsterinfo.aiflags & AI_MANUAL_STEERING)
{
blindfire = true;
}
else
{
blindfire = false;
}
if (self->s.frame == FRAME_attak324) if (self->s.frame == FRAME_attak324)
{ {
flash_number = MZ2_TANK_ROCKET_1; flash_number = MZ2_TANK_ROCKET_1;
@ -485,15 +500,111 @@ TankRocket(edict_t *self)
} }
AngleVectors(self->s.angles, forward, right, NULL); AngleVectors(self->s.angles, forward, right, NULL);
G_ProjectSource(self->s.origin, monster_flash_offset[flash_number], forward, G_ProjectSource(self->s.origin, monster_flash_offset[flash_number], forward, right, start);
right, start);
rocketSpeed = 500 + (100 * skill->value);
if (blindfire)
{
VectorCopy (self->monsterinfo.blind_fire_target, target);
}
else
{
VectorCopy (self->enemy->s.origin, target);
}
if (blindfire)
{
VectorCopy(target, vec);
VectorSubtract(vec, start, dir);
}
else if(random() < 0.66 || (start[2] < self->enemy->absmin[2]))
{
// Don't shoot at the feed if enemy is above.
VectorCopy(self->enemy->s.origin, vec);
vec[2] += self->enemy->viewheight;
VectorSubtract(vec, start, dir);
}
else
{
// Shoot at the feed.
VectorCopy(self->enemy->s.origin, vec);
vec[2] = self->enemy->absmin[2];
VectorSubtract(vec, start, dir);
}
// Lead target: 20, 35, 50, 65 chance of leading.
if ((!blindfire) && ((random() < (0.2 + ((3 - skill->value) * 0.15)))))
{
float dist;
float time;
dist = VectorLength(dir);
time = dist/rocketSpeed;
VectorMA(vec, time, self->enemy->velocity, vec);
VectorSubtract(vec, start, dir);
}
VectorCopy(self->enemy->s.origin, vec);
vec[2] += self->enemy->viewheight;
VectorSubtract(vec, start, dir);
VectorNormalize(dir); VectorNormalize(dir);
monster_fire_rocket(self, start, dir, 50, 550, flash_number); // Blindfire doesn't check target (done in checkattack). Paranoia:
// Make sure we're not shooting a target right next to us.
trace = gi.trace(start, vec3_origin, vec3_origin, vec, self, MASK_SHOT);
if (blindfire)
{
// Blindfire has different fail criteria for the trace
if (!(trace.startsolid || trace.allsolid || (trace.fraction < 0.5)))
{
monster_fire_rocket (self, start, dir, 50, rocketSpeed, flash_number);
}
else
{
// Try shifting the target to the left a little (to help counter large offset)
VectorCopy(target, vec);
VectorMA(vec, -20, right, vec);
VectorSubtract(vec, start, dir);
VectorNormalize(dir);
trace = gi.trace(start, vec3_origin, vec3_origin, vec, self, MASK_SHOT);
if (!(trace.startsolid || trace.allsolid || (trace.fraction < 0.5)))
{
monster_fire_rocket (self, start, dir, 50, rocketSpeed, flash_number);
}
else
{
// OK, that failed. Try to the right.
VectorCopy(target, vec);
VectorMA(vec, 20, right, vec);
VectorSubtract(vec, start, dir);
VectorNormalize(dir);
trace = gi.trace(start, vec3_origin, vec3_origin, vec, self, MASK_SHOT);
if (!(trace.startsolid || trace.allsolid || (trace.fraction < 0.5)))
{
monster_fire_rocket (self, start, dir, 50, rocketSpeed, flash_number);
}
else if ((g_showlogic) && (g_showlogic->value))
{
gi.dprintf ("tank avoiding blindfire shot\n");
}
}
}
}
else
{
trace = gi.trace(start, vec3_origin, vec3_origin, vec, self, MASK_SHOT);
if (trace.ent == self->enemy || trace.ent == world)
{
if (trace.fraction > 0.5 || (trace.ent && trace.ent->client))
{
monster_fire_rocket (self, start, dir, 50, rocketSpeed, MZ2_CHICK_ROCKET_1);
}
}
}
} }
void void
@ -505,7 +616,7 @@ TankMachineGun(edict_t *self)
vec3_t forward, right; vec3_t forward, right;
int flash_number; int flash_number;
if (!self) if (!self || !self->enemy || !self->enemy->inuse)
{ {
return; return;
} }
@ -564,9 +675,12 @@ mframe_t tank_frames_attack_blast[] = {
{ai_charge, 0, NULL}, {ai_charge, 0, NULL},
{ai_charge, 0, TankBlaster} /* 16 */ {ai_charge, 0, TankBlaster} /* 16 */
}; };
mmove_t tank_move_attack_blast = mmove_t tank_move_attack_blast = {
{FRAME_attak101, FRAME_attak116, tank_frames_attack_blast, FRAME_attak101,
tank_reattack_blaster}; FRAME_attak116,
tank_frames_attack_blast,
tank_reattack_blaster
};
mframe_t tank_frames_reattack_blast[] = { mframe_t tank_frames_reattack_blast[] = {
{ai_charge, 0, NULL}, {ai_charge, 0, NULL},
@ -820,6 +934,13 @@ tank_refire_rocket(edict_t *self)
return; return;
} }
if (self->monsterinfo.aiflags & AI_MANUAL_STEERING)
{
self->monsterinfo.aiflags &= ~AI_MANUAL_STEERING;
self->monsterinfo.currentmove = &tank_move_attack_post_rocket;
return;
}
/* Only on hard or nightmare */ /* Only on hard or nightmare */
if (skill->value >= 2) if (skill->value >= 2)
{ {
@ -856,8 +977,9 @@ tank_attack(edict_t *self)
vec3_t vec; vec3_t vec;
float range; float range;
float r; float r;
float chance;
if (!self) if (!self || !self->enemy || !self->enemy->inuse)
{ {
return; return;
} }
@ -869,6 +991,45 @@ tank_attack(edict_t *self)
return; return;
} }
if (self->monsterinfo.attack_state == AS_BLIND)
{
if (self->monsterinfo.blind_fire_delay < 1.0)
{
chance = 1.0;
}
else if (self->monsterinfo.blind_fire_delay < 7.5)
{
chance = 0.4;
}
else
{
chance = 0.1;
}
r = random();
self->monsterinfo.blind_fire_delay += 3.2 + 2.0 + random() * 3.0;
// Don't shoot at the origin.
if (VectorCompare (self->monsterinfo.blind_fire_target, vec3_origin))
{
return;
}
// Don't shoot if the dice say not to.
if (r > chance)
{
return;
}
// turn on manual steering to signal both manual steering and blindfire
self->monsterinfo.aiflags |= AI_MANUAL_STEERING;
self->monsterinfo.currentmove = &tank_move_attack_fire_rocket;
self->monsterinfo.attack_finished = level.time + 3.0 + 2*random();
self->pain_debounce_time = level.time + 5.0; // no pain for a while
return;
}
VectorSubtract(self->enemy->s.origin, self->s.origin, vec); VectorSubtract(self->enemy->s.origin, self->s.origin, vec);
range = VectorLength(vec); range = VectorLength(vec);
@ -986,8 +1147,7 @@ tank_die(edict_t *self, edict_t *inflictor /* unused */, edict_t *attacker /* un
/* check for gib */ /* check for gib */
if (self->health <= self->gib_health) if (self->health <= self->gib_health)
{ {
gi.sound(self, CHAN_VOICE, gi.soundindex( gi.sound(self, CHAN_VOICE, gi.soundindex("misc/udeath.wav"), 1, ATTN_NORM, 0);
"misc/udeath.wav"), 1, ATTN_NORM, 0);
for (n = 0; n < 1 /*4*/; n++) for (n = 0; n < 1 /*4*/; n++)
{ {
@ -1018,6 +1178,20 @@ tank_die(edict_t *self, edict_t *inflictor /* unused */, edict_t *attacker /* un
self->monsterinfo.currentmove = &tank_move_death; self->monsterinfo.currentmove = &tank_move_death;
} }
qboolean tank_blocked(edict_t *self, float dist)
{
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value) ))
{
return true;
}
if(blocked_checkplat(self, dist))
{
return true;
}
return false;
}
/* /*
* QUAKED monster_tank (1 .5 0) (-32 -32 -16) (32 32 72) Ambush Trigger_Spawn Sight * QUAKED monster_tank (1 .5 0) (-32 -32 -16) (32 32 72) Ambush Trigger_Spawn Sight
@ -1086,6 +1260,7 @@ SP_monster_tank(edict_t *self)
self->monsterinfo.melee = NULL; self->monsterinfo.melee = NULL;
self->monsterinfo.sight = tank_sight; self->monsterinfo.sight = tank_sight;
self->monsterinfo.idle = tank_idle; self->monsterinfo.idle = tank_idle;
self->monsterinfo.blocked = tank_blocked;
gi.linkentity(self); gi.linkentity(self);
@ -1094,6 +1269,9 @@ SP_monster_tank(edict_t *self)
walkmonster_start(self); walkmonster_start(self);
self->monsterinfo.aiflags |= AI_IGNORE_SHOTS;
self->monsterinfo.blindfire = true;
if (strcmp(self->classname, "monster_tank_commander") == 0) if (strcmp(self->classname, "monster_tank_commander") == 0)
{ {
self->s.skinnum = 2; self->s.skinnum = 2;

View file

@ -330,6 +330,7 @@ extern void tank_windup ( edict_t * self ) ;
extern void tank_thud ( edict_t * self ) ; extern void tank_thud ( edict_t * self ) ;
extern void tank_footstep ( edict_t * self ) ; extern void tank_footstep ( edict_t * self ) ;
extern void tank_sight ( edict_t * self , edict_t * other ) ; extern void tank_sight ( edict_t * self , edict_t * other ) ;
extern qboolean tank_blocked( edict_t *self, float dist );
extern void SP_monster_supertank ( edict_t * self ) ; extern void SP_monster_supertank ( edict_t * self ) ;
extern qboolean supertank_blocked ( edict_t * self , float dist ) ; extern qboolean supertank_blocked ( edict_t * self , float dist ) ;
extern void supertank_die ( edict_t * self , edict_t * inflictor , edict_t * attacker , int damage , vec3_t point ) ; extern void supertank_die ( edict_t * self , edict_t * inflictor , edict_t * attacker , int damage , vec3_t point ) ;

View file

@ -330,6 +330,7 @@
{"tank_thud", (byte *)tank_thud}, {"tank_thud", (byte *)tank_thud},
{"tank_footstep", (byte *)tank_footstep}, {"tank_footstep", (byte *)tank_footstep},
{"tank_sight", (byte *)tank_sight}, {"tank_sight", (byte *)tank_sight},
{"tank_blocked", (byte *)tank_blocked},
{"SP_monster_supertank", (byte *)SP_monster_supertank}, {"SP_monster_supertank", (byte *)SP_monster_supertank},
{"supertank_blocked", (byte *)supertank_blocked}, {"supertank_blocked", (byte *)supertank_blocked},
{"supertank_die", (byte *)supertank_die}, {"supertank_die", (byte *)supertank_die},