diff --git a/src/actor.h b/src/actor.h index 787f5bbefb..285fded76c 100644 --- a/src/actor.h +++ b/src/actor.h @@ -638,7 +638,7 @@ public: // Called when an actor is to be reflected by a disc of repulsion. // Returns true to continue normal blast processing. - virtual bool SpecialBlastHandling (AActor *source, fixed_t strength); + virtual bool SpecialBlastHandling (AActor *source, double strength); // Called by RoughBlockCheck bool IsOkayToAttack (AActor *target); @@ -937,6 +937,7 @@ public: } } + DVector3 Vec2OffsetZ(double dx, double dy, double atz, bool absolute = false) { if (absolute) @@ -961,6 +962,19 @@ public: else return P_GetOffsetPosition(_f_X(), _f_Y(), FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), FixedMul(length, finesine[angle >> ANGLETOFINESHIFT])); } + DVector2 Vec2Angle(double length, DAngle angle, bool absolute = false) + { + if (absolute) + { + return{ X() + length * angle.Cos(), Y() + length * angle.Sin() }; + } + else + { + fixedvec2 op = P_GetOffsetPosition(_f_X(), _f_Y(), FLOAT2FIXED(length*angle.Cos()), FLOAT2FIXED(length*angle.Sin())); + return{ FIXED2DBL(op.x), FIXED2DBL(op.y) }; + } + } + fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz, bool absolute = false) { if (absolute) @@ -1454,6 +1468,16 @@ public: __pos.x = xx; __pos.y = yy; } + void SetXY(const fixedvec2 &npos) + { + __pos.x = npos.x; + __pos.y = npos.y; + } + void SetXY(const DVector2 &npos) + { + __pos.x = FLOAT2FIXED(npos.X); + __pos.y = FLOAT2FIXED(npos.Y); + } void SetXYZ(fixed_t xx, fixed_t yy, fixed_t zz) { __pos.x = xx; @@ -1466,11 +1490,6 @@ public: __pos.y = FLOAT2FIXED(yy); __pos.z = FLOAT2FIXED(zz); } - void SetXY(const fixedvec2 &npos) - { - __pos.x = npos.x; - __pos.y = npos.y; - } void SetXYZ(const fixedvec3 &npos) { __pos.x = npos.x; @@ -1630,6 +1649,10 @@ inline AActor *Spawn (PClassActor *type, fixed_t x, fixed_t y, fixed_t z, replac { return AActor::StaticSpawn (type, x, y, z, allowreplacement); } +inline AActor *Spawn(PClassActor *type) +{ + return AActor::StaticSpawn(type, 0, 0, 0, NO_REPLACE); +} inline AActor *Spawn (PClassActor *type, const fixedvec3 &pos, replace_t allowreplacement) { return AActor::StaticSpawn (type, pos.x, pos.y, pos.z, allowreplacement); @@ -1646,6 +1669,11 @@ inline AActor *Spawn(PClassActor *type, const DVector3 &pos, replace_t allowrepl AActor *Spawn (const char *type, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement); AActor *Spawn (FName classname, fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement); +inline AActor *Spawn(FName type) +{ + return Spawn(type, 0, 0, 0, NO_REPLACE); +} + inline AActor *Spawn (const char *type, const fixedvec3 &pos, replace_t allowreplacement) { return Spawn (type, pos.x, pos.y, pos.z, allowreplacement); @@ -1694,6 +1722,12 @@ inline T *Spawn(const DVector3 &pos, replace_t allowreplacement) return static_cast(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), zz, allowreplacement)); } +template +inline T *Spawn() // for inventory items we do not need coordinates and replacement info. +{ + return static_cast(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), 0, 0, 0, NO_REPLACE)); +} + inline fixedvec2 Vec2Angle(fixed_t length, angle_t angle) { fixedvec2 ret = { FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 0e9216d808..307297c15e 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -2575,7 +2575,7 @@ static void FS_GiveInventory (AActor *actor, const char * type, int amount) AWeapon *savedPendingWeap = actor->player != NULL? actor->player->PendingWeapon : NULL; bool hadweap = actor->player != NULL ? actor->player->ReadyWeapon != NULL : true; - AInventory *item = static_cast(Spawn (info, 0,0,0, NO_REPLACE)); + AInventory *item = static_cast(Spawn (info)); // This shouldn't count for the item statistics! item->ClearCounters(); @@ -2783,7 +2783,7 @@ void FParser::SF_MaxPlayerAmmo() if(amount < 0) amount = 0; if (!iammo) { - iammo = static_cast(Spawn (ammotype, 0, 0, 0, NO_REPLACE)); + iammo = static_cast(Spawn (ammotype)); iammo->Amount = 0; iammo->AttachToOwner (players[playernum].mo); } diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index 22f471482a..9365745708 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -206,7 +206,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw) if (armorbonustype != NULL) { assert(armorbonustype->IsDescendantOf (RUNTIME_CLASS(ABasicArmorBonus))); - ABasicArmorBonus *armorbonus = static_cast(Spawn(armorbonustype, 0,0,0, NO_REPLACE)); + ABasicArmorBonus *armorbonus = static_cast(Spawn(armorbonustype)); armorbonus->SaveAmount = int(armorbonus->SaveAmount * actualdamage * lifesteal); armorbonus->MaxSaveAmount = lifestealmax <= 0 ? armorbonus->MaxSaveAmount : lifestealmax; armorbonus->flags |= MF_DROPPED; diff --git a/src/g_hexen/a_blastradius.cpp b/src/g_hexen/a_blastradius.cpp index 2e9f358f1f..58ff083acc 100644 --- a/src/g_hexen/a_blastradius.cpp +++ b/src/g_hexen/a_blastradius.cpp @@ -9,8 +9,8 @@ */ /* For reference, the default values: -#define BLAST_RADIUS_DIST 255*FRACUNIT -#define BLAST_SPEED 20*FRACUNIT +#define BLAST_RADIUS_DIST 255*F.RACUNIT +#define BLAST_SPEED 20*F.RACUNIT #define BLAST_FULLSTRENGTH 255 */ @@ -22,7 +22,7 @@ // //========================================================================== -void BlastActor (AActor *victim, fixed_t strength, double speed, AActor *Owner, PClassActor *blasteffect, bool dontdamage) +void BlastActor (AActor *victim, double strength, double speed, AActor *Owner, PClassActor *blasteffect, bool dontdamage) { DAngle angle; AActor *mo; @@ -97,7 +97,7 @@ DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_Blast) { PARAM_ACTION_PROLOGUE; PARAM_INT_OPT (blastflags) { blastflags = 0; } - PARAM_FIXED_OPT (strength) { strength = 255*FRACUNIT; } + PARAM_FLOAT_OPT (strength) { strength = 255; } PARAM_FLOAT_OPT (radius) { radius = 255; } PARAM_FLOAT_OPT (speed) { speed = 20; } PARAM_CLASS_OPT (blasteffect, AActor) { blasteffect = PClass::FindActor("BlastEffect"); } diff --git a/src/g_hexen/a_boostarmor.cpp b/src/g_hexen/a_boostarmor.cpp index 2d6bde4e38..3234174f36 100644 --- a/src/g_hexen/a_boostarmor.cpp +++ b/src/g_hexen/a_boostarmor.cpp @@ -29,7 +29,7 @@ bool AArtiBoostArmor::Use (bool pickup) for (int i = 0; i < 4; ++i) { - armor = Spawn (0,0,0, NO_REPLACE); + armor = Spawn(); armor->flags |= MF_DROPPED; armor->health = i; armor->Amount = 1; @@ -46,7 +46,7 @@ bool AArtiBoostArmor::Use (bool pickup) } else { - ABasicArmorBonus *armor = Spawn (0,0,0, NO_REPLACE); + ABasicArmorBonus *armor = Spawn(); armor->flags |= MF_DROPPED; armor->SaveAmount = 50; armor->MaxSaveAmount = 300; diff --git a/src/g_hexen/a_clericflame.cpp b/src/g_hexen/a_clericflame.cpp index 10aff1ca04..5b4eba2e85 100644 --- a/src/g_hexen/a_clericflame.cpp +++ b/src/g_hexen/a_clericflame.cpp @@ -14,7 +14,6 @@ */ const double FLAMESPEED = 0.45; -const fixed_t CFLAMERANGE = 12*64*FRACUNIT; const double FLAMEROTSPEED = 2.; static FRandom pr_missile ("CFlameMissile"); @@ -46,7 +45,7 @@ void ACFlameMissile::Effect () if (!--special1) { special1 = 4; - double newz = Z()-12; + double newz = Z() - 12; if (newz < floorz) { newz = floorz; @@ -114,7 +113,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CFlameMissile) int i; DAngle an; - fixed_t dist; + double dist; AActor *mo; self->renderflags &= ~RF_INVISIBLE; @@ -122,13 +121,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_CFlameMissile) AActor *BlockingMobj = self->BlockingMobj; if (BlockingMobj && BlockingMobj->flags&MF_SHOOTABLE) { // Hit something, so spawn the flame circle around the thing - dist = BlockingMobj->_f_radius()+18*FRACUNIT; + dist = BlockingMobj->radius + 18; for (i = 0; i < 4; i++) { an = i*45.; - mo = Spawn ("CircleFlame", BlockingMobj->Vec3Offset( - xs_CRoundToInt(an.Cos()*dist), xs_CRoundToInt(an.Sin()*dist), - 5*FRACUNIT), ALLOW_REPLACE); + mo = Spawn ("CircleFlame", BlockingMobj->Vec3Angle(dist, an, 5), ALLOW_REPLACE); if (mo) { mo->Angles.Yaw = an; @@ -138,9 +135,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CFlameMissile) mo->specialf2 = mo->Vel.Y; mo->tics -= pr_missile()&3; } - mo = Spawn ("CircleFlame", BlockingMobj->Vec3Offset( - -xs_CRoundToInt(an.Cos()*dist), -xs_CRoundToInt(an.Sin()*dist), - 5*FRACUNIT), ALLOW_REPLACE); + mo = Spawn("CircleFlame", BlockingMobj->Vec3Angle(dist, an, 5), ALLOW_REPLACE); if(mo) { mo->Angles.Yaw = an + 180.; diff --git a/src/g_hexen/a_clericholy.cpp b/src/g_hexen/a_clericholy.cpp index 7e61721cdc..749ad3dad2 100644 --- a/src/g_hexen/a_clericholy.cpp +++ b/src/g_hexen/a_clericholy.cpp @@ -63,7 +63,7 @@ IMPLEMENT_CLASS (ACWeapWraithverge) IMPLEMENT_CLASS (AHolySpirit) -bool AHolySpirit::Slam (AActor *thing) +bool AHolySpirit::Slam(AActor *thing) { if (thing->flags&MF_SHOOTABLE && thing != target) { @@ -91,14 +91,14 @@ bool AHolySpirit::Slam (AActor *thing) // ghost burns out faster when attacking players/bosses health -= 6; } - P_DamageMobj (thing, this, target, dam, NAME_Melee); + P_DamageMobj(thing, this, target, dam, NAME_Melee); if (pr_spiritslam() < 128) { - Spawn ("HolyPuff", Pos(), ALLOW_REPLACE); - S_Sound (this, CHAN_WEAPON, "SpiritAttack", 1, ATTN_NORM); + Spawn("HolyPuff", Pos(), ALLOW_REPLACE); + S_Sound(this, CHAN_WEAPON, "SpiritAttack", 1, ATTN_NORM); if (thing->flags3&MF3_ISMONSTER && pr_spiritslam() < 128) { - thing->Howl (); + thing->Howl(); } } } @@ -110,7 +110,7 @@ bool AHolySpirit::Slam (AActor *thing) return true; } -bool AHolySpirit::SpecialBlastHandling (AActor *source, fixed_t strength) +bool AHolySpirit::SpecialBlastHandling (AActor *source, double strength) { if (tracer == source) { @@ -133,7 +133,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyAttack2) PARAM_ACTION_PROLOGUE; int j; - int i; AActor *mo; for (j = 0; j < 4; j++) @@ -145,21 +144,22 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyAttack2) } switch (j) { // float bob index + case 0: - mo->special2 = pr_holyatk2(8 << BOBTOFINESHIFT); // upper-left + mo->WeaveIndexZ = pr_holyatk2() & 7; // upper-left break; case 1: - mo->special2 = FINEANGLES/2 + pr_holyatk2(8 << BOBTOFINESHIFT); // upper-right + mo->WeaveIndexZ = 32 + (pr_holyatk2() & 7); // upper-right break; case 2: - mo->special2 = (FINEANGLES/2 + pr_holyatk2(8 << BOBTOFINESHIFT)) << 16; // lower-left + mo->WeaveIndexXY = 32 + (pr_holyatk2() & 7); // lower-left break; case 3: - i = pr_holyatk2(8 << BOBTOFINESHIFT); - mo->special2 = ((FINEANGLES/2 + i) << 16) + FINEANGLES/2 + pr_holyatk2(8 << BOBTOFINESHIFT); + mo->WeaveIndexXY = 32 + (pr_holyatk2() & 7); + mo->WeaveIndexZ = 32 + (pr_holyatk2() & 7); break; } - mo->_f_SetZ(self->_f_Z()); + mo->SetZ(self->Z()); mo->Angles.Yaw = self->Angles.Yaw + 67.5 - 45.*j; mo->Thrust(); mo->target = self->target; @@ -263,42 +263,41 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyPalette) // //============================================================================ -static void CHolyTailFollow (AActor *actor, fixed_t dist) +static void CHolyTailFollow(AActor *actor, double dist) { AActor *child; - int an; - fixed_t oldDistance, newDistance; + DAngle an; + double oldDistance, newDistance; while (actor) { child = actor->tracer; if (child) { - an = actor->__f_AngleTo(child) >> ANGLETOFINESHIFT; - oldDistance = child->AproxDistance (actor); - if (P_TryMove (child, actor->_f_X()+FixedMul(dist, finecosine[an]), - actor->_f_Y()+FixedMul(dist, finesine[an]), true)) + an = actor->AngleTo(child); + oldDistance = child->Distance2D(actor); + if (P_TryMove(child, actor->Pos().XY() + an.ToVector(dist), true)) { - newDistance = child->AproxDistance (actor)-FRACUNIT; - if (oldDistance < FRACUNIT) + newDistance = child->Distance2D(actor) - 1; + if (oldDistance < 1) { if (child->Z() < actor->Z()) { - child->_f_SetZ(actor->_f_Z()-dist); + child->SetZ(actor->Z() - dist); } else { - child->_f_SetZ(actor->_f_Z()+dist); + child->SetZ(actor->Z() + dist); } } else { - child->_f_SetZ(actor->_f_Z() + Scale (newDistance, child->_f_Z()-actor->_f_Z(), oldDistance)); + child->SetZ(actor->Z() + (newDistance * (child->Z() - actor->Z()) / oldDistance)); } } } actor = child; - dist -= FRACUNIT; + dist -= 1; } } @@ -341,13 +340,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyTail) } else { - if (P_TryMove (self, - parent->_f_X() - 14*finecosine[parent->_f_angle()>>ANGLETOFINESHIFT], - parent->_f_Y() - 14*finesine[parent->_f_angle()>>ANGLETOFINESHIFT], true)) + if (P_TryMove(self, parent->Vec2Angle(14., parent->Angles.Yaw, true), true)) { - self->_f_SetZ(parent->_f_Z()-5*FRACUNIT); + self->SetZ(parent->Z() - 5.); } - CHolyTailFollow (self, 10*FRACUNIT); + CHolyTailFollow(self, 10); } return 0; } @@ -380,24 +377,23 @@ static void CHolyFindTarget (AActor *actor) static void CHolySeekerMissile (AActor *actor, DAngle thresh, DAngle turnMax) { int dir; - int dist; DAngle delta; AActor *target; - fixed_t newZ; - fixed_t deltaZ; + double newZ; + double deltaZ; target = actor->tracer; if (target == NULL) { return; } - if(!(target->flags&MF_SHOOTABLE) - || (!(target->flags3&MF3_ISMONSTER) && !target->player)) + if (!(target->flags&MF_SHOOTABLE) + || (!(target->flags3&MF3_ISMONSTER) && !target->player)) { // Target died/target isn't a player or creature actor->tracer = NULL; - actor->flags &= ~(MF_NOCLIP|MF_SKULLFLY); + actor->flags &= ~(MF_NOCLIP | MF_SKULLFLY); actor->flags |= MF_MISSILE; - CHolyFindTarget (actor); + CHolyFindTarget(actor); return; } dir = P_FaceMobj (actor, target, &delta); @@ -423,59 +419,24 @@ static void CHolySeekerMissile (AActor *actor, DAngle thresh, DAngle turnMax) || actor->Z() > target->Top() || actor->Top() < target->Z()) { - newZ = target->_f_Z()+((pr_holyseeker()*target->_f_height())>>8); - deltaZ = newZ - actor->_f_Z(); - if (abs(deltaZ) > 15*FRACUNIT) + newZ = target->Z() + ((pr_holyseeker()*target->Height) / 256.); + deltaZ = newZ - actor->Z(); + if (fabs(deltaZ) > 15) { if (deltaZ > 0) { - deltaZ = 15*FRACUNIT; + deltaZ = 15; } else { - deltaZ = -15*FRACUNIT; + deltaZ = -15; } } - dist = actor->AproxDistance (target); - dist = dist / actor->_f_speed(); - if (dist < 1) - { - dist = 1; - } - actor->Vel.Z = FIXED2DBL(deltaZ / dist); + actor->Vel.Z = deltaZ / actor->DistanceBySpeed(target, actor->Speed); } return; } -//============================================================================ -// -// A_CHolyWeave -// -//============================================================================ - -void CHolyWeave (AActor *actor, FRandom &pr_random) -{ - fixed_t newX, newY, newZ; - int weaveXY, weaveZ; - int angle; - - weaveXY = actor->special2 >> 16; - weaveZ = actor->special2 & FINEMASK; - angle = (actor->_f_angle() + ANG90) >> ANGLETOFINESHIFT; - newX = actor->_f_X() - FixedMul(finecosine[angle], finesine[weaveXY] * 32); - newY = actor->_f_Y() - FixedMul(finesine[angle], finesine[weaveXY] * 32); - weaveXY = (weaveXY + pr_random(5 << BOBTOFINESHIFT)) & FINEMASK; - newX += FixedMul(finecosine[angle], finesine[weaveXY] * 32); - newY += FixedMul(finesine[angle], finesine[weaveXY] * 32); - P_TryMove(actor, newX, newY, true); - newZ = actor->_f_Z(); - newZ -= finesine[weaveZ] * 16; - weaveZ = (weaveZ + pr_random(5 << BOBTOFINESHIFT)) & FINEMASK; - newZ += finesine[weaveZ] * 16; - actor->_f_SetZ(newZ); - actor->special2 = weaveZ + (weaveXY << 16); -} - //============================================================================ // // A_CHolySeek @@ -504,7 +465,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolySeek) self->args[0] = 5+(pr_holyseek()/20); } } - CHolyWeave (self, pr_holyweave); + + int xyspeed = (pr_holyweave() % 5); + int zspeed = (pr_holyweave() % 5); + A_Weave(self, xyspeed, zspeed, 4., 2.); return 0; } @@ -543,7 +507,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ClericAttack) if (!self->target) return 0; - AActor * missile = P_SpawnMissileZ (self, self->_f_Z() + 40*FRACUNIT, self->target, PClass::FindActor ("HolyMissile")); + AActor * missile = P_SpawnMissileZ (self, self->Z() + 40., self->target, PClass::FindActor ("HolyMissile")); if (missile != NULL) missile->tracer = NULL; // No initial target S_Sound (self, CHAN_WEAPON, "HolySymbolFire", 1, ATTN_NORM); return 0; diff --git a/src/g_hexen/a_clericstaff.cpp b/src/g_hexen/a_clericstaff.cpp index 2b6c88d6f3..d936e8d1db 100644 --- a/src/g_hexen/a_clericstaff.cpp +++ b/src/g_hexen/a_clericstaff.cpp @@ -155,7 +155,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffMissileSlither) { PARAM_ACTION_PROLOGUE; - A_Weave(self, 3, 0, FRACUNIT, 0); + A_Weave(self, 3, 0, 1., 0.); return 0; } diff --git a/src/g_hexen/a_flechette.cpp b/src/g_hexen/a_flechette.cpp index 19cb3132c1..59276be18e 100644 --- a/src/g_hexen/a_flechette.cpp +++ b/src/g_hexen/a_flechette.cpp @@ -265,7 +265,7 @@ AInventory *AArtiPoisonBag::CreateCopy (AActor *other) AInventory *copy; PClassActor *spawntype = GetFlechetteType(other); - copy = static_cast(Spawn (spawntype, 0, 0, 0, NO_REPLACE)); + copy = static_cast(Spawn (spawntype)); copy->Amount = Amount; copy->MaxAmount = MaxAmount; GoAwayAndDie (); diff --git a/src/g_hexen/a_healingradius.cpp b/src/g_hexen/a_healingradius.cpp index 2563df0893..fd2f6f000b 100644 --- a/src/g_hexen/a_healingradius.cpp +++ b/src/g_hexen/a_healingradius.cpp @@ -52,7 +52,7 @@ bool AArtiHealingRadius::Use (bool pickup) case NAME_Armor: for (int j = 0; j < 4; ++j) { - AHexenArmor *armor = Spawn (0,0,0, NO_REPLACE); + AHexenArmor *armor = Spawn (); armor->health = j; armor->Amount = 1; if (!armor->CallTryPickup (players[i].mo)) diff --git a/src/g_hexen/a_heresiarch.cpp b/src/g_hexen/a_heresiarch.cpp index 87a3d17aef..dc5a94d765 100644 --- a/src/g_hexen/a_heresiarch.cpp +++ b/src/g_hexen/a_heresiarch.cpp @@ -109,7 +109,7 @@ public: arc << AngleOffset; } - bool SpecialBlastHandling (AActor *source, fixed_t strength) + bool SpecialBlastHandling (AActor *source, double strength) { // don't blast sorcerer balls return false; } diff --git a/src/g_hexen/a_hexenglobal.h b/src/g_hexen/a_hexenglobal.h index 5544afb241..3455b684df 100644 --- a/src/g_hexen/a_hexenglobal.h +++ b/src/g_hexen/a_hexenglobal.h @@ -10,7 +10,7 @@ class AHolySpirit : public AActor DECLARE_CLASS (AHolySpirit, AActor) public: bool Slam (AActor *thing); - bool SpecialBlastHandling (AActor *source, fixed_t strength); + bool SpecialBlastHandling (AActor *source, double strength); }; class AFighterWeapon : public AWeapon diff --git a/src/g_hexen/a_korax.cpp b/src/g_hexen/a_korax.cpp index 0cb8f1149a..e05b8d379c 100644 --- a/src/g_hexen/a_korax.cpp +++ b/src/g_hexen/a_korax.cpp @@ -339,15 +339,6 @@ void KoraxFire (AActor *actor, PClassActor *type, int arm) P_SpawnKoraxMissile (pos.x, pos.y, pos.z, actor, actor->target, type); } -//============================================================================ -// -// A_KSpiritWeave -// [BL] Was identical to CHolyWeave so lets just use that -// -//============================================================================ - -void CHolyWeave (AActor *actor, FRandom &pr_random); - //============================================================================ // // A_KSpiritSeeker @@ -435,7 +426,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_KSpiritRoam) { A_KSpiritSeeker(self, (double)self->args[0], self->args[0] * 2.); } - CHolyWeave(self, pr_kspiritweave); + int xyspeed = (pr_kspiritweave() % 5); + int zspeed = (pr_kspiritweave() % 5); + A_Weave(self, xyspeed, zspeed, 4., 2.); + if (pr_kspiritroam()<50) { S_Sound (self, CHAN_VOICE, "SpiritActive", 1, ATTN_NONE); diff --git a/src/g_hexen/a_magestaff.cpp b/src/g_hexen/a_magestaff.cpp index dff795dcdc..c0b9c2b5bc 100644 --- a/src/g_hexen/a_magestaff.cpp +++ b/src/g_hexen/a_magestaff.cpp @@ -64,7 +64,7 @@ class AMageStaffFX2 : public AActor DECLARE_CLASS(AMageStaffFX2, AActor) public: int SpecialMissileHit (AActor *victim); - bool SpecialBlastHandling (AActor *source, fixed_t strength); + bool SpecialBlastHandling (AActor *source, double strength); }; IMPLEMENT_CLASS (AMageStaffFX2) @@ -81,7 +81,7 @@ int AMageStaffFX2::SpecialMissileHit (AActor *victim) return -1; } -bool AMageStaffFX2::SpecialBlastHandling (AActor *source, fixed_t strength) +bool AMageStaffFX2::SpecialBlastHandling (AActor *source, double strength) { // Reflect to originator tracer = target; diff --git a/src/g_shared/a_armor.cpp b/src/g_shared/a_armor.cpp index 12e841d7e0..016633effa 100644 --- a/src/g_shared/a_armor.cpp +++ b/src/g_shared/a_armor.cpp @@ -249,7 +249,7 @@ bool ABasicArmorPickup::Use (bool pickup) if (armor == NULL) { - armor = Spawn (0,0,0, NO_REPLACE); + armor = Spawn (); armor->BecomeItem (); Owner->AddInventory (armor); } @@ -332,7 +332,7 @@ bool ABasicArmorBonus::Use (bool pickup) if (armor == NULL) { - armor = Spawn (0,0,0, NO_REPLACE); + armor = Spawn (); armor->BecomeItem (); armor->Amount = 0; armor->MaxAmount = MaxSaveAmount; diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 201f621c6a..a09c03c3db 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -66,7 +66,7 @@ bool APowerupGiver::Use (bool pickup) { if (PowerupType == NULL) return true; // item is useless - APowerup *power = static_cast (Spawn (PowerupType, 0, 0, 0, NO_REPLACE)); + APowerup *power = static_cast (Spawn (PowerupType)); if (EffectTics != 0) { diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index 2aea9fa14c..2e1db7c5d7 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -204,7 +204,7 @@ AInventory *AAmmo::CreateCopy (AActor *other) Destroy (); } - copy = static_cast(Spawn (type, 0, 0, 0, NO_REPLACE)); + copy = static_cast(Spawn (type)); copy->Amount = amount; copy->BecomeItem (); } @@ -747,7 +747,7 @@ AInventory *AInventory::CreateCopy (AActor *other) Amount = MIN(Amount, MaxAmount); if (GoAway ()) { - copy = static_cast(Spawn (GetClass(), 0, 0, 0, NO_REPLACE)); + copy = static_cast(Spawn (GetClass())); copy->Amount = Amount; copy->MaxAmount = MaxAmount; } @@ -1861,7 +1861,7 @@ AInventory *ABackpackItem::CreateCopy (AActor *other) if (amount < 0) amount = 0; if (ammo == NULL) { // The player did not have the ammo. Add it. - ammo = static_cast(Spawn(atype, 0, 0, 0, NO_REPLACE)); + ammo = static_cast(Spawn(atype)); ammo->Amount = bDepleted ? 0 : amount; if (ammo->BackpackMaxAmount > ammo->MaxAmount) { diff --git a/src/g_shared/a_weaponpiece.cpp b/src/g_shared/a_weaponpiece.cpp index 9612b17167..2d7549db7f 100644 --- a/src/g_shared/a_weaponpiece.cpp +++ b/src/g_shared/a_weaponpiece.cpp @@ -89,7 +89,7 @@ bool AWeaponPiece::TryPickup (AActor *&toucher) } if (!hold) { - hold=static_cast(Spawn(RUNTIME_CLASS(AWeaponHolder), 0, 0, 0, NO_REPLACE)); + hold=static_cast(Spawn(RUNTIME_CLASS(AWeaponHolder))); hold->BecomeItem(); hold->AttachToOwner(toucher); hold->PieceMask=0; @@ -129,7 +129,7 @@ bool AWeaponPiece::TryPickup (AActor *&toucher) { if (!toucher->FindInventory (WeaponClass)) { - FullWeapon= static_cast(Spawn(WeaponClass, 0, 0, 0, NO_REPLACE)); + FullWeapon= static_cast(Spawn(WeaponClass)); // The weapon itself should not give more ammo to the player! FullWeapon->AmmoGive1=0; diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index 93036b031a..5e00d90252 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -387,7 +387,7 @@ AAmmo *AWeapon::AddAmmo (AActor *other, PClassActor *ammotype, int amount) ammo = static_cast(other->FindInventory (ammotype)); if (ammo == NULL) { - ammo = static_cast(Spawn (ammotype, 0, 0, 0, NO_REPLACE)); + ammo = static_cast(Spawn (ammotype)); ammo->Amount = MIN (amount, ammo->MaxAmount); ammo->AttachToOwner (other); } @@ -449,7 +449,7 @@ AWeapon *AWeapon::AddWeapon (PClassWeapon *weapontype) weap = static_cast(Owner->FindInventory (weapontype)); if (weap == NULL) { - weap = static_cast(Spawn (weapontype, 0, 0, 0, NO_REPLACE)); + weap = static_cast(Spawn (weapontype)); weap->AttachToOwner (Owner); } return weap; @@ -749,7 +749,7 @@ bool AWeaponGiver::TryPickup(AActor *&toucher) { if (master == NULL) { - master = weap = static_cast(Spawn(di->Name, 0, 0, 0, NO_REPLACE)); + master = weap = static_cast(Spawn(di->Name)); if (weap != NULL) { weap->ItemFlags &= ~IF_ALWAYSPICKUP; // use the flag of this item only. diff --git a/src/g_strife/a_coin.cpp b/src/g_strife/a_coin.cpp index 0796abc548..5848164bde 100644 --- a/src/g_strife/a_coin.cpp +++ b/src/g_strife/a_coin.cpp @@ -54,7 +54,7 @@ AInventory *ACoin::CreateCopy (AActor *other) { return Super::CreateCopy (other); } - AInventory *copy = Spawn (0,0,0, NO_REPLACE); + AInventory *copy = Spawn (); copy->Amount = Amount; copy->BecomeItem (); GoAwayAndDie (); diff --git a/src/g_strife/a_strifeitems.cpp b/src/g_strife/a_strifeitems.cpp index 896357c8de..c9f10cb834 100644 --- a/src/g_strife/a_strifeitems.cpp +++ b/src/g_strife/a_strifeitems.cpp @@ -82,7 +82,7 @@ bool AHealthTraining::TryPickup (AActor *&toucher) if (Super::TryPickup (toucher)) { toucher->GiveInventoryType (PClass::FindActor("GunTraining")); - AInventory *coin = Spawn (0,0,0, NO_REPLACE); + AInventory *coin = Spawn (); if (coin != NULL) { coin->Amount = toucher->player->mo->accuracy*5 + 300; diff --git a/src/g_strife/a_strifeweapons.cpp b/src/g_strife/a_strifeweapons.cpp index 1447603ab6..0fb4c2cb42 100644 --- a/src/g_strife/a_strifeweapons.cpp +++ b/src/g_strife/a_strifeweapons.cpp @@ -814,7 +814,7 @@ bool ASigil::HandlePickup (AInventory *item) AInventory *ASigil::CreateCopy (AActor *other) { - ASigil *copy = Spawn (0,0,0, NO_REPLACE); + ASigil *copy = Spawn (); copy->Amount = Amount; copy->MaxAmount = MaxAmount; copy->NumPieces = NumPieces; @@ -1167,7 +1167,7 @@ int ASigil::GiveSigilPiece (AActor *receiver) sigil = receiver->FindInventory (); if (sigil == NULL) { - sigil = static_cast(Spawn("Sigil1", 0,0,0, NO_REPLACE)); + sigil = static_cast(Spawn("Sigil1")); if (!sigil->CallTryPickup (receiver)) { sigil->Destroy (); diff --git a/src/g_strife/a_thingstoblowup.cpp b/src/g_strife/a_thingstoblowup.cpp index 5e4b5deff3..3042623a30 100644 --- a/src/g_strife/a_thingstoblowup.cpp +++ b/src/g_strife/a_thingstoblowup.cpp @@ -38,7 +38,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveQuestItem) { if (playeringame[i]) { - AInventory *item = static_cast(Spawn (QuestItemClasses[questitem - 1], 0,0,0, NO_REPLACE)); + AInventory *item = static_cast(Spawn (QuestItemClasses[questitem - 1])); if (!item->CallTryPickup (players[i].mo)) { item->Destroy (); diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index 595b19e82d..664264cdd6 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -694,7 +694,7 @@ void cht_Give (player_t *player, const char *name, int amount) AInventory *ammo = player->mo->FindInventory(atype); if (ammo == NULL) { - ammo = static_cast(Spawn (atype, 0, 0, 0, NO_REPLACE)); + ammo = static_cast(Spawn (atype)); ammo->AttachToOwner (player->mo); ammo->Amount = ammo->MaxAmount; } @@ -713,7 +713,7 @@ void cht_Give (player_t *player, const char *name, int amount) { if (gameinfo.gametype != GAME_Hexen) { - ABasicArmorPickup *armor = Spawn (0,0,0, NO_REPLACE); + ABasicArmorPickup *armor = Spawn (); armor->SaveAmount = 100*deh.BlueAC; armor->SavePercent = gameinfo.Armor2Percent > 0? gameinfo.Armor2Percent : FRACUNIT/2; if (!armor->CallTryPickup (player->mo)) @@ -725,7 +725,7 @@ void cht_Give (player_t *player, const char *name, int amount) { for (i = 0; i < 4; ++i) { - AHexenArmor *armor = Spawn (0,0,0, NO_REPLACE); + AHexenArmor *armor = Spawn (); armor->health = i; armor->Amount = 0; if (!armor->CallTryPickup (player->mo)) @@ -748,7 +748,7 @@ void cht_Give (player_t *player, const char *name, int amount) AKey *key = (AKey *)GetDefaultByType (PClassActor::AllActorClasses[i]); if (key->KeyNumber != 0) { - key = static_cast(Spawn(static_cast(PClassActor::AllActorClasses[i]), 0,0,0, NO_REPLACE)); + key = static_cast(Spawn(static_cast(PClassActor::AllActorClasses[i]))); if (!key->CallTryPickup (player->mo)) { key->Destroy (); diff --git a/src/p_acs.cpp b/src/p_acs.cpp index e2043f33d2..9a00075296 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -1150,7 +1150,7 @@ static void DoGiveInv (AActor *actor, PClassActor *info, int amount) ? actor->player->PendingWeapon : NULL; bool hadweap = actor->player != NULL ? actor->player->ReadyWeapon != NULL : true; - AInventory *item = static_cast(Spawn (info, 0,0,0, NO_REPLACE)); + AInventory *item = static_cast(Spawn (info)); // This shouldn't count for the item statistics! item->ClearCounters(); diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index 78a420616b..e8aaa6912c 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -1268,7 +1268,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply if (takestuff) { - AInventory *item = static_cast(Spawn(reply->GiveType, 0, 0, 0, NO_REPLACE)); + AInventory *item = static_cast(Spawn(reply->GiveType)); // Items given here should not count as items! item->ClearCounters(); if (item->GetClass()->TypeName == NAME_FlameThrower) diff --git a/src/p_enemy.h b/src/p_enemy.h index ed1c9fcbc0..797d468ee4 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -57,7 +57,7 @@ void P_NewChaseDir (AActor *actor); AInventory *P_DropItem (AActor *source, PClassActor *type, int special, int chance); void P_TossItem (AActor *item); bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params); -void A_Weave(AActor *self, int xyspeed, int zspeed, fixed_t xydist, fixed_t zdist); +void A_Weave(AActor *self, int xyspeed, int zspeed, double xydist, double zdist); void A_Unblock(AActor *self, bool drop); DECLARE_ACTION(A_Look) diff --git a/src/p_local.h b/src/p_local.h index aa691d4ce5..55acdc48fc 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -283,6 +283,10 @@ inline bool P_TryMove(AActor* thing, double x, double y, int dropoff, const secp { return P_TryMove(thing, FLOAT2FIXED(x), FLOAT2FIXED(y), dropoff, onfloor); } +inline bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const secplane_t * onfloor = NULL) +{ + return P_TryMove(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), dropoff, onfloor); +} bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y); void P_ApplyTorque(AActor *mo); bool P_TeleportMove (AActor* thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag, bool modifyactor = true); // [RH] Added z and telefrag parameters diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index d4166f43f3..6180ef0936 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -898,7 +898,7 @@ AInventory *AActor::GiveInventoryType (PClassActor *type) if (type != NULL) { - item = static_cast(Spawn (type, 0,0,0, NO_REPLACE)); + item = static_cast(Spawn (type)); if (!item->CallTryPickup (this)) { item->Destroy (); @@ -920,7 +920,7 @@ bool AActor::GiveAmmo (PClassAmmo *type, int amount) { if (type != NULL) { - AInventory *item = static_cast(Spawn (type, 0, 0, 0, NO_REPLACE)); + AInventory *item = static_cast(Spawn (type)); if (item) { item->Amount = amount; @@ -3068,7 +3068,7 @@ bool AActor::Slam (AActor *thing) return false; // stop moving } -bool AActor::SpecialBlastHandling (AActor *source, fixed_t strength) +bool AActor::SpecialBlastHandling (AActor *source, double strength) { return true; } diff --git a/src/p_user.cpp b/src/p_user.cpp index 840d10c946..88bb1f58ae 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -1053,7 +1053,7 @@ void APlayerPawn::GiveDeathmatchInventory() AKey *key = (AKey *)GetDefaultByType (PClassActor::AllActorClasses[i]); if (key->KeyNumber != 0) { - key = static_cast(Spawn(static_cast(PClassActor::AllActorClasses[i]), 0,0,0, NO_REPLACE)); + key = static_cast(Spawn(static_cast(PClassActor::AllActorClasses[i]))); if (!key->CallTryPickup (this)) { key->Destroy (); @@ -1327,7 +1327,7 @@ void APlayerPawn::GiveDefaultInventory () // BasicArmor must come right after that. It should not affect any // other protection item as well but needs to process the damage // before the HexenArmor does. - ABasicArmor *barmor = Spawn (0,0,0, NO_REPLACE); + ABasicArmor *barmor = Spawn (); barmor->BecomeItem (); barmor->SavePercent = 0; barmor->Amount = 0; @@ -1350,7 +1350,7 @@ void APlayerPawn::GiveDefaultInventory () } else { - item = static_cast(Spawn (ti, 0,0,0, NO_REPLACE)); + item = static_cast(Spawn (ti)); item->ItemFlags |= IF_IGNORESKILL; // no skill multiplicators here item->Amount = di->Amount; if (item->IsKindOf (RUNTIME_CLASS (AWeapon))) diff --git a/src/tables.h b/src/tables.h index 790deed5fb..6fe767a4f5 100644 --- a/src/tables.h +++ b/src/tables.h @@ -53,7 +53,6 @@ #define ANGLETOFINESHIFT 19 #define BOBTOFINESHIFT (FINEANGLEBITS - 6) -#define BOBTORAD(v) ((v) * (M_PI/32)) // from FloatBobTable to radians. // Effective size is 10240. extern fixed_t finesine[5*FINEANGLES/4]; diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index b89dd61882..d1bf9c9302 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1758,7 +1758,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch) if (armorbonustype != NULL) { assert(armorbonustype->IsDescendantOf(RUNTIME_CLASS(ABasicArmorBonus))); - ABasicArmorBonus *armorbonus = static_cast(Spawn(armorbonustype, 0,0,0, NO_REPLACE)); + ABasicArmorBonus *armorbonus = static_cast(Spawn(armorbonustype)); armorbonus->SaveAmount *= (actualdamage * lifesteal) >> FRACBITS; armorbonus->MaxSaveAmount = lifestealmax <= 0 ? armorbonus->MaxSaveAmount : lifestealmax; armorbonus->flags |= MF_DROPPED; @@ -1996,7 +1996,7 @@ static bool DoGiveInventory(AActor *receiver, bool orresult, VM_ARGS) } if (mi) { - AInventory *item = static_cast(Spawn(mi, 0, 0, 0, NO_REPLACE)); + AInventory *item = static_cast(Spawn(mi)); if (item == NULL) { return false; @@ -4936,47 +4936,44 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_QuakeEx) // //=========================================================================== -void A_Weave(AActor *self, int xyspeed, int zspeed, fixed_t xydist, fixed_t zdist) +void A_Weave(AActor *self, int xyspeed, int zspeed, double xydist, double zdist) { - fixed_t newX, newY; + DVector2 newpos; int weaveXY, weaveZ; - int angle; - fixed_t dist; + DAngle angle; + double dist; weaveXY = self->WeaveIndexXY & 63; weaveZ = self->WeaveIndexZ & 63; - angle = (self->_f_angle() + ANG90) >> ANGLETOFINESHIFT; + angle = self->Angles.Yaw + 90; if (xydist != 0 && xyspeed != 0) { - dist = MulScale13(finesine[weaveXY << BOBTOFINESHIFT], xydist); - newX = self->_f_X() - FixedMul (finecosine[angle], dist); - newY = self->_f_Y() - FixedMul (finesine[angle], dist); + dist = BobSin(weaveXY) * xydist; + newpos = self->Pos().XY() - angle.ToVector(dist); weaveXY = (weaveXY + xyspeed) & 63; - dist = MulScale13(finesine[weaveXY << BOBTOFINESHIFT], xydist); - newX += FixedMul (finecosine[angle], dist); - newY += FixedMul (finesine[angle], dist); + dist = BobSin(weaveXY) * xydist; + newpos += angle.ToVector(dist); if (!(self->flags5 & MF5_NOINTERACTION)) { - P_TryMove (self, newX, newY, true); + P_TryMove (self, newpos, true); } else { self->UnlinkFromWorld (); self->flags |= MF_NOBLOCKMAP; // We need to do portal offsetting here explicitly, because SetXY cannot do that. - newX -= self->_f_X(); - newY -= self->_f_Y(); - self->SetXY(self->Vec2Offset(newX, newY)); + newpos -= self->Pos().XY(); + self->SetXY(self->Vec2Offset(newpos.X, newpos.Y)); self->LinkToWorld (); } self->WeaveIndexXY = weaveXY; } if (zdist != 0 && zspeed != 0) { - self->_f_AddZ(-MulScale13(finesine[weaveZ << BOBTOFINESHIFT], zdist)); + self->AddZ(-BobSin(weaveZ) * zdist); weaveZ = (weaveZ + zspeed) & 63; - self->_f_AddZ(MulScale13(finesine[weaveZ << BOBTOFINESHIFT], zdist)); + self->AddZ(BobSin(weaveZ) * zdist); self->WeaveIndexZ = weaveZ; } } @@ -4986,8 +4983,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Weave) PARAM_ACTION_PROLOGUE; PARAM_INT (xspeed); PARAM_INT (yspeed); - PARAM_FIXED (xdist); - PARAM_FIXED (ydist); + PARAM_FLOAT (xdist); + PARAM_FLOAT (ydist); A_Weave(self, xspeed, yspeed, xdist, ydist); return 0; } @@ -5463,7 +5460,7 @@ static bool DoRadiusGive(AActor *self, AActor *thing, PClassActor *item, int amo if ((flags & RGF_NOSIGHT) || P_CheckSight(thing, self, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY)) { // OK to give; target is in direct path, or the monster doesn't care about it being in line of sight. - AInventory *gift = static_cast(Spawn(item, 0, 0, 0, NO_REPLACE)); + AInventory *gift = static_cast(Spawn(item)); if (gift->IsKindOf(RUNTIME_CLASS(AHealth))) { gift->Amount *= amount; diff --git a/src/vectors.h b/src/vectors.h index 9eaa375cf3..798b49259b 100644 --- a/src/vectors.h +++ b/src/vectors.h @@ -1076,6 +1076,12 @@ inline TAngle ToDegrees (double rad) return TAngle (double(rad * (180.0 / M_PI))); } +// Emulates the old floatbob offset table with direct calls to trig functions. +inline double BobSin(double fb) +{ + return TAngle(double(fb * (180.0 / 32))).Sin() * 8; +} + template inline TAngle fabs (const TAngle °) {