diff --git a/src/actor.h b/src/actor.h index 16f979c96..c74714e94 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1235,7 +1235,7 @@ public: SBYTE LastLookPlayerNumber;// Player number last looked for (if TIDtoHate == 0) ActorBounceFlags BounceFlags; // which bouncing type? DWORD SpawnFlags; // Increased to DWORD because of Doom 64 - fixed_t meleerange; // specifies how far a melee attack reaches. + double meleerange; // specifies how far a melee attack reaches. double meleethreshold; // Distance below which a monster doesn't try to shoot missiles anynore // but instead tries to come closer for a melee attack. // This is not the same as meleerange @@ -1246,7 +1246,7 @@ public: double Gravity; // [GRB] Gravity factor fixed_t Friction; int FastChaseStrafeCount; - fixed_t pushfactor; + double pushfactor; int lastpush; int activationtype; // How the thing behaves when activated with USESPECIAL or BUMPSPECIAL int lastbump; // Last time the actor was bumped, used to control BUMPSPECIAL @@ -1478,10 +1478,6 @@ public: { return Z() + Height/2; } - double _pushfactor() const - { - return FIXED2DBL(pushfactor); - } void SetZ(double newz, bool moving = true) { __pos.z = FLOAT2FIXED(newz); diff --git a/src/info.cpp b/src/info.cpp index 68488e0f2..e997d9717 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -230,7 +230,7 @@ PClassActor::PClassActor() WoundHealth = 6; PoisonDamage = 0; FastSpeed = -1.; - RDFactor = FRACUNIT; + RDFactor = 1.; CameraHeight = INT_MIN; DropItems = NULL; diff --git a/src/info.h b/src/info.h index f0a08048c..decfd72df 100644 --- a/src/info.h +++ b/src/info.h @@ -250,7 +250,7 @@ public: int WoundHealth; // Health needed to enter wound state int PoisonDamage; // Amount of poison damage double FastSpeed; // speed in fast mode - fixed_t RDFactor; // Radius damage factor + double RDFactor; // Radius damage factor double CameraHeight; // Height of camera when used as such FSoundID HowlSound; // Sound being played when electrocuted or poisoned FName BloodType; // Blood replacement type diff --git a/src/p_acs.cpp b/src/p_acs.cpp index ffb854575..4885389ed 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -3998,7 +3998,7 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) break; case APROP_MeleeRange: - actor->meleerange = value; + actor->meleerange = ACSToDouble(value); break; case APROP_ViewHeight: @@ -4093,10 +4093,10 @@ int DLevelScript::GetActorProperty (int tid, int property) case APROP_Mass: return actor->Mass; case APROP_Accuracy: return actor->accuracy; case APROP_Stamina: return actor->stamina; - case APROP_Height: return actor->_f_height(); - case APROP_Radius: return actor->_f_radius(); + case APROP_Height: return DoubleToACS(actor->Height); + case APROP_Radius: return DoubleToACS(actor->radius); case APROP_ReactionTime:return actor->reactiontime; - case APROP_MeleeRange: return actor->meleerange; + case APROP_MeleeRange: return DoubleToACS(actor->meleerange); case APROP_ViewHeight: if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn))) { return DoubleToACS(static_cast(actor)->ViewHeight); diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 4a99b7f6c..e63185638 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -264,14 +264,14 @@ bool AActor::CheckMeleeRange () { AActor *pl = target; - fixed_t dist; + double dist; if (!pl) return false; - dist = AproxDistance (pl); + dist = Distance2D (pl); - if (dist >= meleerange + pl->_f_radius()) + if (dist >= meleerange + pl->radius) return false; // [RH] If moving toward goal, then we've reached it. @@ -306,7 +306,7 @@ bool AActor::CheckMeleeRange () bool P_CheckMeleeRange2 (AActor *actor) { AActor *mo; - fixed_t dist; + double dist; if (!actor->target) @@ -314,8 +314,8 @@ bool P_CheckMeleeRange2 (AActor *actor) return false; } mo = actor->target; - dist = mo->AproxDistance (actor); - if (dist >= (128 << FRACBITS) || dist < actor->meleerange + mo->_f_radius()) + dist = mo->Distance2D (actor); + if (dist >= 128 || dist < actor->meleerange + mo->radius) { return false; } @@ -965,16 +965,16 @@ void P_NewChaseDir(AActor * actor) if (actor->flags3 & MF3_AVOIDMELEE) { bool ismeleeattacker = false; - fixed_t dist = actor->AproxDistance(target); + double dist = actor->Distance2D(target); if (target->player == NULL) { - ismeleeattacker = (target->MissileState == NULL && dist < (target->meleerange + target->_f_radius())*2); + ismeleeattacker = (target->MissileState == NULL && dist < (target->meleerange + target->radius)*2); } else if (target->player->ReadyWeapon != NULL) { // melee range of player weapon is a parameter of the action function and cannot be checked here. // Add a new weapon property? - ismeleeattacker = (target->player->ReadyWeapon->WeaponFlags & WIF_MELEEWEAPON && dist < (192 << FRACBITS)); + ismeleeattacker = ((target->player->ReadyWeapon->WeaponFlags & WIF_MELEEWEAPON) && dist < 192); } if (ismeleeattacker) { @@ -1198,7 +1198,7 @@ bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams { // if real close, react anyway // [KS] but respect minimum distance rules - if (mindist || dist > lookee->meleerange + lookee->_f_radius()) + if (mindist || dist > FLOAT2FIXED(lookee->meleerange + lookee->radius)) return false; // outside of fov } } diff --git a/src/p_map.cpp b/src/p_map.cpp index bb4cc08f1..c2eefcda2 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -1477,7 +1477,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch { // Push thing if (thing->lastpush != tm.PushTime) { - thing->Vel += tm.thing->Vel.XY() * thing->_pushfactor(); + thing->Vel += tm.thing->Vel.XY() * thing->pushfactor; thing->lastpush = tm.PushTime; } } @@ -1535,7 +1535,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch { // Push thing if (thing->lastpush != tm.PushTime) { - thing->Vel += tm.thing->Vel.XY() * thing->_pushfactor(); + thing->Vel += tm.thing->Vel.XY() * thing->pushfactor; thing->lastpush = tm.PushTime; } } @@ -5328,7 +5328,7 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo { points = points * splashfactor; } - points *= thing->GetClass()->RDFactor / (float)FRACUNIT; + points *= thing->GetClass()->RDFactor; // points and bombdamage should be the same sign if (((points * bombdamage) > 0) && P_CheckSight(thing, bombspot, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY)) @@ -5400,9 +5400,9 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo { // OK to damage; target is in direct path dist = clamp(dist - fulldamagedistance, 0, dist); int damage = Scale(bombdamage, bombdistance - dist, bombdistance); - damage = (int)((double)damage * splashfactor); - damage = Scale(damage, thing->GetClass()->RDFactor, FRACUNIT); + double factor = splashfactor * thing->GetClass()->RDFactor; + damage = int(damage * factor); if (damage > 0) { int newdam = P_DamageMobj(thing, bombspot, bombsource, damage, bombmod); diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index e9686532d..1531b46f7 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -649,7 +649,7 @@ void InitThingdef() symt.AddSymbol(new PField(NAME_Height, TypeFloat64, VARF_Native, myoffsetof(AActor,Height))); symt.AddSymbol(new PField(NAME_Radius, TypeFloat64, VARF_Native, myoffsetof(AActor,radius))); symt.AddSymbol(new PField(NAME_ReactionTime,TypeSInt32, VARF_Native, myoffsetof(AActor,reactiontime))); - symt.AddSymbol(new PField(NAME_MeleeRange, TypeFixed, VARF_Native, myoffsetof(AActor,meleerange))); + symt.AddSymbol(new PField(NAME_MeleeRange, TypeFloat64, VARF_Native, myoffsetof(AActor,meleerange))); symt.AddSymbol(new PField(NAME_Speed, TypeFloat64, VARF_Native, myoffsetof(AActor,Speed))); symt.AddSymbol(new PField(NAME_Threshold, TypeSInt32, VARF_Native, myoffsetof(AActor,threshold))); symt.AddSymbol(new PField(NAME_DefThreshold,TypeSInt32, VARF_Native, myoffsetof(AActor,DefThreshold))); diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index e43d18493..5ab622dce 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -964,7 +964,7 @@ DEFINE_PROPERTY(meleedamage, I, Actor) //========================================================================== DEFINE_PROPERTY(meleerange, F, Actor) { - PROP_FIXED_PARM(id, 0); + PROP_DOUBLE_PARM(id, 0); defaults->meleerange = id; } @@ -1003,7 +1003,7 @@ DEFINE_PROPERTY(missileheight, F, Actor) //========================================================================== DEFINE_PROPERTY(pushfactor, F, Actor) { - PROP_FIXED_PARM(id, 0); + PROP_DOUBLE_PARM(id, 0); defaults->pushfactor = id; } @@ -1310,7 +1310,7 @@ DEFINE_PROPERTY(fastspeed, F, Actor) //========================================================================== DEFINE_PROPERTY(radiusdamagefactor, F, Actor) { - PROP_FIXED_PARM(i, 0); + PROP_DOUBLE_PARM(i, 0); assert(info->IsKindOf(RUNTIME_CLASS(PClassActor))); static_cast(info)->RDFactor = i; }