diff --git a/src/actor.h b/src/actor.h index 75574f457..8f317b71a 100644 --- a/src/actor.h +++ b/src/actor.h @@ -804,6 +804,12 @@ public: return bloodcls; } + double Distance2DSquared(AActor *other, bool absolute = false) + { + DVector2 otherpos = absolute ? other->Pos() : other->PosRelative(this); + return (Pos().XY() - otherpos).LengthSquared(); + } + double Distance2D(AActor *other, bool absolute = false) { DVector2 otherpos = absolute ? other->Pos() : other->PosRelative(this); diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 050a6215f..d36cdfe65 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -1629,7 +1629,7 @@ void APowerDamage::ModifyDamage(int damage, FName damageType, int &newdamage, bo DmgFactors *df = GetClass()->DamageFactors; if (df != NULL && df->CountUsed() != 0) { - newdam = MIN(1, df->Apply(damageType, damage));// don't allow zero damage as result of an underflow + newdam = MAX(1, df->Apply(damageType, damage));// don't allow zero damage as result of an underflow } else { diff --git a/src/info.h b/src/info.h index decfd72df..285894dc7 100644 --- a/src/info.h +++ b/src/info.h @@ -53,6 +53,7 @@ struct Baggage; class FScanner; struct FActorInfo; class FArchive; +class FIntCVar; // Sprites that are fixed in position because they can have special meanings. enum @@ -259,6 +260,7 @@ public: DDropItem *DropItems; FString SourceLumpName; + FIntCVar *distancecheck; // Old Decorate compatibility stuff bool DontHurtShooter; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index c880d87bf..0877ad2c9 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -8900,10 +8900,11 @@ scriptwait: break; case PCD_ENDTRANSLATION: - // This might be useful for hardware rendering, but - // for software it is superfluous. - translation->UpdateNative(); - translation = NULL; + if (translation != NULL) + { + translation->UpdateNative(); + translation = NULL; + } break; case PCD_SIN: diff --git a/src/r_things.cpp b/src/r_things.cpp index 2033423e8..c2fa165db 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1246,9 +1246,20 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) // Handle all things in sector. for (thing = sec->thinglist; thing; thing = thing->snext) { + FIntCVar *cvar = thing->GetClass()->distancecheck; + if (cvar != NULL && *cvar >= 0) + { + double dist = thing->Distance2DSquared(camera); + double check = (double)**cvar; + if (dist >= check * check) + { + continue; + } + } + // find fake level - for(int i = 0; i < (int)frontsector->e->XFloor.ffloors.Size(); i++) { - rover = frontsector->e->XFloor.ffloors[i]; + for(auto rover : frontsector->e->XFloor.ffloors) + { if(!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) continue; if(!(rover->flags & FF_SOLID) || rover->alpha != 255) continue; if(!fakefloor) diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index c435cd575..3ec4c624d 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1523,6 +1523,28 @@ DEFINE_PROPERTY(riplevelmax, I, Actor) defaults->RipLevelMax = id; } +//========================================================================== +// +//========================================================================== +DEFINE_PROPERTY(distancecheck, S, Actor) +{ + PROP_STRING_PARM(cvar, 0); + FBaseCVar *scratch; + FBaseCVar *cv = FindCVar(cvar, &scratch); + if (cv == NULL) + { + I_Error("CVar %s not defined", cvar); + } + else if (cv->GetRealType() == CVAR_Int) + { + static_cast(info)->distancecheck = static_cast(cv); + } + else + { + I_Error("CVar %s must of type Int", cvar); + } +} + //========================================================================== // // Special inventory properties