- cleaned up the RipLevel logic a bit to be less confusing.

This commit is contained in:
Christoph Oelckers 2014-12-31 10:13:15 +01:00
parent 4ddfd0f46a
commit c57cc91d7c
2 changed files with 28 additions and 11 deletions

View File

@ -887,6 +887,20 @@ bool PIT_CheckLine(line_t *ld, const FBoundingBox &box, FCheckPosition &tm)
return true;
}
//==========================================================================
//
// Isolated to keep the code readable and fix the logic
//
//==========================================================================
static bool CheckRipLevel(AActor *victim, AActor *projectile)
{
if (victim->RipLevelMin > 0 && projectile->RipperLevel < victim->RipLevelMin) return false;
if (victim->RipLevelMax > 0 && projectile->RipperLevel > victim->RipLevelMax) return false;
return true;
}
//==========================================================================
//
// PIT_CheckThing
@ -1207,17 +1221,8 @@ bool PIT_CheckThing(AActor *thing, FCheckPosition &tm)
{
return true;
}
// Rippers will rip through anything with an equivalent ripper level,
// or if the missile's ripper level is within the min/max range,
// or if there's no min/max range and the missile's ripper level is
// >= the monster's, then let 'er rip!
bool ripmin = (thing->RipLevelMin != 0) ? true : false;
bool ripmax = (thing->RipLevelMax != 0) ? true : false;
if ((tm.DoRipping && !(thing->flags5 & MF5_DONTRIP)) &&
((!(ripmin) && !(ripmax) && (thing->RipperLevel <= tm.thing->RipperLevel)) ||
((thing->RipperLevel == tm.thing->RipperLevel) ||
(thing->RipLevelMin <= tm.thing->RipperLevel) &&
(thing->RipLevelMax >= tm.thing->RipperLevel))))
if ((tm.DoRipping && !(thing->flags5 & MF5_DONTRIP)) && CheckRipLevel(thing, tm.thing))
{
if (!(tm.thing->flags6 & MF6_NOBOSSRIP) || !(thing->flags2 & MF2_BOSS))
{

View File

@ -1442,6 +1442,10 @@ DEFINE_PROPERTY(telefogdesttype, S, Actor)
DEFINE_PROPERTY(ripperlevel, I, Actor)
{
PROP_INT_PARM(id, 0);
if (id < 0)
{
I_Error ("RipperLevel must not be negative");
}
defaults->RipperLevel = id;
}
@ -1451,6 +1455,10 @@ DEFINE_PROPERTY(ripperlevel, I, Actor)
DEFINE_PROPERTY(riplevelmin, I, Actor)
{
PROP_INT_PARM(id, 0);
if (id < 0)
{
I_Error ("RipLevelMin must not be negative");
}
defaults->RipLevelMin = id;
}
@ -1460,6 +1468,10 @@ DEFINE_PROPERTY(riplevelmin, I, Actor)
DEFINE_PROPERTY(riplevelmax, I, Actor)
{
PROP_INT_PARM(id, 0);
if (id < 0)
{
I_Error ("RipLevelMax must not be negative");
}
defaults->RipLevelMax = id;
}