mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
- Cleaned up some of the reflective code.
- Added null checks to AIMREFLECT. - The missile being reflected now corrects the z velocity to perfectly reflect towards the actor's middle.
This commit is contained in:
parent
1aa00f1b0e
commit
fdf2d6c493
1 changed files with 45 additions and 34 deletions
|
@ -1961,37 +1961,36 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly)
|
||||||
// Don't change the angle if there's THRUREFLECT on the monster.
|
// Don't change the angle if there's THRUREFLECT on the monster.
|
||||||
if (!(BlockingMobj->flags7 & MF7_THRUREFLECT))
|
if (!(BlockingMobj->flags7 & MF7_THRUREFLECT))
|
||||||
{
|
{
|
||||||
int dir;
|
//int dir;
|
||||||
angle_t delta;
|
//angle_t delta;
|
||||||
|
bool dontReflect = (mo->AdjustReflectionAngle(BlockingMobj, angle));
|
||||||
if (BlockingMobj->flags7 & MF7_MIRRORREFLECT)
|
|
||||||
angle = mo->angle + ANG180;
|
|
||||||
else
|
|
||||||
angle = R_PointToAngle2(BlockingMobj->x, BlockingMobj->y, mo->x, mo->y);
|
|
||||||
|
|
||||||
// Change angle for deflection/reflection
|
// Change angle for deflection/reflection
|
||||||
// AIMREFLECT calls precedence so make sure not to bother with adjusting here if declared.
|
|
||||||
if (!(BlockingMobj->flags7 & MF7_AIMREFLECT) && (mo->AdjustReflectionAngle(BlockingMobj, angle)))
|
|
||||||
{
|
|
||||||
goto explode;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reflect the missile along angle
|
if (!dontReflect)
|
||||||
if (BlockingMobj->flags7 & MF7_AIMREFLECT)
|
|
||||||
{
|
{
|
||||||
dir = P_FaceMobj(mo, mo->target, &delta);
|
bool tg = (mo->target != NULL);
|
||||||
if (dir)
|
bool blockingtg = (BlockingMobj->target != NULL);
|
||||||
{ // Turn clockwise
|
if (BlockingMobj->flags7 & MF7_AIMREFLECT && (tg || blockingtg))
|
||||||
mo->angle += delta;
|
{
|
||||||
}
|
AActor *origin;
|
||||||
else
|
if (tg)
|
||||||
{ // Turn counter clockwise
|
origin = mo->target;
|
||||||
mo->angle -= delta;
|
else if (blockingtg)
|
||||||
}
|
origin = BlockingMobj->target;
|
||||||
|
|
||||||
|
float speed = (float)(mo->Speed);
|
||||||
|
//dest->x - source->x
|
||||||
|
FVector3 velocity(origin->x - mo->x, origin->y - mo->y, (origin->z + (origin->height/2)) - mo->z);
|
||||||
|
velocity.Resize(speed);
|
||||||
angle = mo->angle >> ANGLETOFINESHIFT;
|
angle = mo->angle >> ANGLETOFINESHIFT;
|
||||||
|
mo->velx = (fixed_t)(velocity.X);
|
||||||
|
mo->vely = (fixed_t)(velocity.Y);
|
||||||
|
mo->velz = (fixed_t)(velocity.Z);
|
||||||
|
/*
|
||||||
mo->velx = FixedMul(mo->Speed, finecosine[angle]);
|
mo->velx = FixedMul(mo->Speed, finecosine[angle]);
|
||||||
mo->vely = FixedMul(mo->Speed, finesine[angle]);
|
mo->vely = FixedMul(mo->Speed, finesine[angle]);
|
||||||
mo->velz = -mo->velz;
|
mo->velz = -mo->velz;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2001,8 +2000,11 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly)
|
||||||
mo->vely = FixedMul(mo->Speed >> 1, finesine[angle]);
|
mo->vely = FixedMul(mo->Speed >> 1, finesine[angle]);
|
||||||
mo->velz = -mo->velz / 2;
|
mo->velz = -mo->velz / 2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
goto explode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (mo->flags2 & MF2_SEEKERMISSILE)
|
if (mo->flags2 & MF2_SEEKERMISSILE)
|
||||||
{
|
{
|
||||||
|
@ -2928,8 +2930,10 @@ bool AActor::AdjustReflectionAngle (AActor *thing, angle_t &angle)
|
||||||
if (flags2 & MF2_DONTREFLECT) return true;
|
if (flags2 & MF2_DONTREFLECT) return true;
|
||||||
if (thing->flags7 & MF7_THRUREFLECT) return false;
|
if (thing->flags7 & MF7_THRUREFLECT) return false;
|
||||||
|
|
||||||
|
if (thing->flags7 & MF7_MIRRORREFLECT)
|
||||||
|
angle += ANGLE_180;
|
||||||
// Change angle for reflection
|
// Change angle for reflection
|
||||||
if (thing->flags4&MF4_SHIELDREFLECT)
|
else if (thing->flags4&MF4_SHIELDREFLECT)
|
||||||
{
|
{
|
||||||
// Shield reflection (from the Centaur
|
// Shield reflection (from the Centaur
|
||||||
if (abs (angle - thing->angle)>>24 > 45)
|
if (abs (angle - thing->angle)>>24 > 45)
|
||||||
|
@ -2952,6 +2956,13 @@ bool AActor::AdjustReflectionAngle (AActor *thing, angle_t &angle)
|
||||||
else
|
else
|
||||||
angle -= ANG45;
|
angle -= ANG45;
|
||||||
}
|
}
|
||||||
|
else if (thing->flags7 & MF7_AIMREFLECT)
|
||||||
|
{
|
||||||
|
if (this->target != NULL)
|
||||||
|
A_Face(this, this->target);
|
||||||
|
else if (thing->target != NULL)
|
||||||
|
A_Face(this, thing->target);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
angle += ANGLE_1 * ((pr_reflect()%16)-8);
|
angle += ANGLE_1 * ((pr_reflect()%16)-8);
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue