- fixed: Explosions directly under a water surface would not hurt any actor directly above this surface.

- cleaned up P_CheckSight flag handling.


SVN r2249 (trunk)
This commit is contained in:
Christoph Oelckers 2010-03-27 07:42:31 +00:00
parent e83a9a2a00
commit a357a70f82
8 changed files with 56 additions and 42 deletions

View File

@ -118,7 +118,7 @@ bool FCajunMaster::Reachable (AActor *looker, AActor *rtarget)
//in doom is 90 degrees infront.
bool FCajunMaster::Check_LOS (AActor *from, AActor *to, angle_t vangle)
{
if (!P_CheckSight (from, to, 2))
if (!P_CheckSight (from, to, SF_SEEPASTBLOCKEVERYTHING))
return false; // out of sight
if (vangle == ANGLE_MAX)
return true;
@ -339,7 +339,7 @@ AActor *FCajunMaster::Choose_Mate (AActor *bot)
&& !p_leader[count]) //taken?
{
if (P_CheckSight (bot, client->mo, 1))
if (P_CheckSight (bot, client->mo, SF_IGNOREVISIBILITY))
{
test = P_AproxDistance (client->mo->x - bot->x,
client->mo->y - bot->y);
@ -525,7 +525,7 @@ angle_t FCajunMaster::FireRox (AActor *bot, AActor *enemy, ticcmd_t *cmd)
enemy->y + FixedMul(enemy->vely, (m+2*FRACUNIT)), ONFLOORZ, 1);
dist = P_AproxDistance(actor->x-bglobal.body1->x, actor->y-bglobal.body1->y);
//try the predicted location
if (P_CheckSight (actor, bglobal.body1, 1)) //See the predicted location, so give a test missile
if (P_CheckSight (actor, bglobal.body1, SF_IGNOREVISIBILITY)) //See the predicted location, so give a test missile
{
FCheckPosition tm;
if (SafeCheckPosition (bot, actor->x, actor->y, tm))

View File

@ -198,16 +198,16 @@ void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soun
//
//----------------------------------------------------------------------------
void P_NoiseAlert (AActor *target, AActor *emmiter, bool splash)
void P_NoiseAlert (AActor *target, AActor *emitter, bool splash)
{
if (emmiter == NULL)
if (emitter == NULL)
return;
if (target != NULL && target->player && (target->player->cheats & CF_NOTARGET))
return;
validcount++;
P_RecursiveSound (emmiter->Sector, target, splash, 0);
P_RecursiveSound (emitter->Sector, target, splash, 0);
}
@ -308,7 +308,7 @@ bool P_CheckMissileRange (AActor *actor)
{
fixed_t dist;
if (!P_CheckSight (actor, actor->target, 4))
if (!P_CheckSight (actor, actor->target, SF_SEEPASTBLOCKEVERYTHING|SF_SEEPASTSHOOTABLELINES))
return false;
if (actor->flags & MF_JUSTHIT)
@ -1136,7 +1136,7 @@ bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams
}
// P_CheckSight is by far the most expensive operation in here so let's do it last.
return P_CheckSight(lookee, other, 2);
return P_CheckSight(lookee, other, SF_SEEPASTBLOCKEVERYTHING);
}
//---------------------------------------------------------------------------
@ -1154,7 +1154,7 @@ bool P_LookForMonsters (AActor *actor)
AActor *mo;
TThinkerIterator<AActor> iterator;
if (!P_CheckSight (players[0].mo, actor, 2))
if (!P_CheckSight (players[0].mo, actor, SF_SEEPASTBLOCKEVERYTHING))
{ // Player can't see monster
return false;
}
@ -1183,7 +1183,7 @@ bool P_LookForMonsters (AActor *actor)
{ // [RH] Don't go after same species
continue;
}
if (!P_CheckSight (actor, mo, 2))
if (!P_CheckSight (actor, mo, SF_SEEPASTBLOCKEVERYTHING))
{ // Out of sight
continue;
}
@ -1764,7 +1764,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look)
if (self->flags & MF_AMBUSH)
{
if (P_CheckSight (self, self->target, 2))
if (P_CheckSight (self, self->target, SF_SEEPASTBLOCKEVERYTHING))
goto seeyou;
}
else
@ -1931,7 +1931,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
{
dist = P_AproxDistance (self->target->x - self->x,
self->target->y - self->y);
if (P_CheckSight (self, self->target, 2) &&
if (P_CheckSight (self, self->target, SF_SEEPASTBLOCKEVERYTHING) &&
(!minseedist || dist > minseedist) &&
(!maxseedist || dist < maxseedist))
{
@ -2062,7 +2062,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look2)
{
if (self->flags & MF_AMBUSH)
{
if (!P_CheckSight (self, targ, 2))
if (!P_CheckSight (self, targ, SF_SEEPASTBLOCKEVERYTHING))
goto nosee;
}
self->target = targ;

View File

@ -390,6 +390,15 @@ void P_SlideMove (AActor* mo, fixed_t tryx, fixed_t tryy, int numsteps);
bool P_BounceWall (AActor *mo);
bool P_BounceActor (AActor *mo, AActor * BlockingMobj);
bool P_CheckSight (const AActor* t1, const AActor* t2, int flags=0);
enum ESightFlags
{
SF_IGNOREVISIBILITY=1,
SF_SEEPASTSHOOTABLELINES=2,
SF_SEEPASTBLOCKEVERYTHING=4,
SF_IGNOREWATERBOUNDARY=8
};
void P_ResetSightCounters (bool full);
bool P_TalkFacing (AActor *player);
void P_UseLines (player_t* player);

View File

@ -3053,7 +3053,7 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e
if (crossedffloors)
{
// if 3D floors were in the way do an extra visibility check for safety
if (!P_CheckSight(shootthing, th, 1))
if (!P_CheckSight(shootthing, th, SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY))
{
// the thing can't be seen so we can safely exclude its range from our aiming field
if (thingtoppitch<toppitch)
@ -4324,7 +4324,7 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b
}
points *= thing->GetClass()->Meta.GetMetaFixed(AMETA_RDFactor, FRACUNIT)/(float)FRACUNIT;
if (points > 0.f && P_CheckSight (thing, bombspot, 1))
if (points > 0.f && P_CheckSight (thing, bombspot, SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY))
{ // OK to damage; target is in direct path
float velz;
float thrust;
@ -4382,7 +4382,7 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b
if (dist >= bombdistance)
continue; // out of range
if (P_CheckSight (thing, bombspot, 1))
if (P_CheckSight (thing, bombspot, SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY))
{ // OK to damage; target is in direct path
dist = clamp<int>(dist - fulldamagedistance, 0, dist);
int damage = Scale (bombdamage, bombdistance-dist, bombdistance);

View File

@ -3016,7 +3016,7 @@ void AActor::Tick ()
&& !players[i].enemy
&& player ? !IsTeammate (players[i].mo) : true
&& P_AproxDistance (players[i].mo->x-x, players[i].mo->y-y) < MAX_MONSTER_TARGET_DIST
&& P_CheckSight (players[i].mo, this, 2))
&& P_CheckSight (players[i].mo, this, SF_SEEPASTBLOCKEVERYTHING))
{ //Probably a monster, so go kill it.
players[i].enemy = this;
}

View File

@ -53,7 +53,7 @@ class SightCheck
fixed_t lastzbottom; // z at last line
sector_t * lastsector; // last sector being entered by trace
fixed_t topslope, bottomslope; // slopes to top and bottom of target
int SeePastBlockEverything, SeePastShootableLines;
int Flags;
divline_t trace;
int myseethrough;
@ -73,9 +73,8 @@ public:
seeingthing=t2;
bottomslope = t2->z - sightzstart;
topslope = bottomslope + t2->height;
Flags = flags;
SeePastBlockEverything = flags & 6;
SeePastShootableLines = flags & 4;
myseethrough = FF_SEETHROUGH;
}
};
@ -144,6 +143,7 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in)
F3DFloor* rover=s->e->XFloor.ffloors[j];
if((rover->flags & FF_SEETHROUGH) == myseethrough || !(rover->flags & FF_EXISTS)) continue;
if ((Flags & SF_IGNOREWATERBOUNDARY) && (rover->flags & FF_SOLID) == 0) continue;
fixed_t ff_bottom=rover->bottom.plane->ZatPoint(trX, trY);
fixed_t ff_top=rover->top.plane->ZatPoint(trX, trY);
@ -176,6 +176,7 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in)
F3DFloor* rover2=sb->e->XFloor.ffloors[k];
if((rover2->flags & FF_SEETHROUGH) == myseethrough || !(rover2->flags & FF_EXISTS)) continue;
if ((Flags & SF_IGNOREWATERBOUNDARY) && (rover->flags & FF_SOLID) == 0) continue;
fixed_t ffb_bottom=rover2->bottom.plane->ZatPoint(trX, trY);
fixed_t ffb_top=rover2->top.plane->ZatPoint(trX, trY);
@ -255,7 +256,7 @@ bool SightCheck::P_SightCheckLine (line_t *ld)
// [RH] don't see past block everything lines
if (ld->flags & ML_BLOCKEVERYTHING)
{
if (!SeePastBlockEverything)
if (!(Flags & SF_SEEPASTBLOCKEVERYTHING))
{
return false;
}
@ -263,7 +264,7 @@ bool SightCheck::P_SightCheckLine (line_t *ld)
// that runs a script on the current map. Used to prevent monsters
// from trying to attack through a block everything line unless
// there's a chance their attack will make it nonblocking.
if (!SeePastShootableLines)
if (!(Flags & SF_SEEPASTSHOOTABLELINES))
{
if (!(ld->activation & SPAC_Impact))
{
@ -407,6 +408,7 @@ bool SightCheck::P_SightTraverseIntercepts ()
F3DFloor* rover = lastsector->e->XFloor.ffloors[i];
if((rover->flags & FF_SOLID) == myseethrough || !(rover->flags & FF_EXISTS)) continue;
if ((Flags & SF_IGNOREWATERBOUNDARY) && (rover->flags & FF_SOLID) == 0) continue;
fixed_t ff_bottom=rover->bottom.plane->ZatPoint(seeingthing->x, seeingthing->y);
fixed_t ff_top=rover->top.plane->ZatPoint(seeingthing->x, seeingthing->y);
@ -670,7 +672,7 @@ sightcounts[0]++;
//
// [RH] Andy Baker's stealth monsters:
// Cannot see an invisible object
if ((flags & 1) == 0 && ((t2->renderflags & RF_INVISIBLE) || !t2->RenderStyle.IsVisible(t2->alpha)))
if ((flags & SF_IGNOREVISIBILITY) == 0 && ((t2->renderflags & RF_INVISIBLE) || !t2->RenderStyle.IsVisible(t2->alpha)))
{ // small chance of an attack being made anyway
if ((bglobal.m_Thinking ? pr_botchecksight() : pr_checksight()) > 50)
{
@ -681,20 +683,23 @@ sightcounts[0]++;
// killough 4/19/98: make fake floors and ceilings block monster view
if ((s1->GetHeightSec() &&
((t1->z + t1->height <= s1->heightsec->floorplane.ZatPoint (t1->x, t1->y) &&
t2->z >= s1->heightsec->floorplane.ZatPoint (t2->x, t2->y)) ||
(t1->z >= s1->heightsec->ceilingplane.ZatPoint (t1->x, t1->y) &&
t2->z + t1->height <= s1->heightsec->ceilingplane.ZatPoint (t2->x, t2->y))))
||
(s2->GetHeightSec() &&
((t2->z + t2->height <= s2->heightsec->floorplane.ZatPoint (t2->x, t2->y) &&
t1->z >= s2->heightsec->floorplane.ZatPoint (t1->x, t1->y)) ||
(t2->z >= s2->heightsec->ceilingplane.ZatPoint (t2->x, t2->y) &&
t1->z + t2->height <= s2->heightsec->ceilingplane.ZatPoint (t1->x, t1->y)))))
if (!(flags & SF_IGNOREWATERBOUNDARY))
{
res = false;
goto done;
if ((s1->GetHeightSec() &&
((t1->z + t1->height <= s1->heightsec->floorplane.ZatPoint (t1->x, t1->y) &&
t2->z >= s1->heightsec->floorplane.ZatPoint (t2->x, t2->y)) ||
(t1->z >= s1->heightsec->ceilingplane.ZatPoint (t1->x, t1->y) &&
t2->z + t1->height <= s1->heightsec->ceilingplane.ZatPoint (t2->x, t2->y))))
||
(s2->GetHeightSec() &&
((t2->z + t2->height <= s2->heightsec->floorplane.ZatPoint (t2->x, t2->y) &&
t1->z >= s2->heightsec->floorplane.ZatPoint (t1->x, t1->y)) ||
(t2->z >= s2->heightsec->ceilingplane.ZatPoint (t2->x, t2->y) &&
t1->z + t2->height <= s2->heightsec->ceilingplane.ZatPoint (t1->x, t1->y)))))
{
res = false;
goto done;
}
}
// An unobstructed LOS is possible.

View File

@ -1939,7 +1939,7 @@ void DPusher::Tick ()
// If speed <= 0, you're outside the effective radius. You also have
// to be able to see the push/pull source point.
if ((speed > 0) && (P_CheckSight (thing, m_Source, 1)))
if ((speed > 0) && (P_CheckSight (thing, m_Source, SF_IGNOREVISIBILITY)))
{
angle_t pushangle = R_PointToAngle2 (thing->x, thing->y, sx, sy);
if (m_Source->GetClass()->TypeName == NAME_PointPusher)

View File

@ -1891,9 +1891,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSight)
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
for (int i=0;i<MAXPLAYERS;i++)
for (int i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && P_CheckSight(players[i].camera,self,true)) return;
if (playeringame[i] && P_CheckSight(players[i].camera, self, SF_IGNOREVISIBILITY)) return;
}
ACTION_JUMP(jump);
@ -1944,7 +1944,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSightOrRange)
}
// Now check LOS.
if (P_CheckSight(camera, self, true))
if (P_CheckSight(camera, self, SF_IGNOREVISIBILITY))
{ // Visible
return;
}
@ -2395,7 +2395,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS)
if (!target) return; // [KS] Let's not call P_CheckSight unnecessarily in this case.
if (!P_CheckSight (self, target, 1))
if (!P_CheckSight (self, target, SF_IGNOREVISIBILITY))
return;
if (fov && (fov < ANGLE_MAX))
@ -2458,7 +2458,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS)
if (!target) return; // [KS] Let's not call P_CheckSight unnecessarily in this case.
if (!P_CheckSight (target, self, 1))
if (!P_CheckSight (target, self, SF_IGNOREVISIBILITY))
return;
if (fov && (fov < ANGLE_MAX))