- added a no-parameter Spawn function for inventory items that never show on the map, because the coordinate and replacement parameters will always be 0 for them.

- started converting g_hexen.

Most importantly this removes CHolyWeave as it is just a specialized version of A_Weave with far more convoluted use of parameters.
This commit is contained in:
Christoph Oelckers 2016-03-21 14:00:05 +01:00
parent 4e60ea0252
commit f1602882c8
33 changed files with 168 additions and 175 deletions

View File

@ -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<T *>(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), zz, allowreplacement));
}
template<class T>
inline T *Spawn() // for inventory items we do not need coordinates and replacement info.
{
return static_cast<T *>(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]),

View File

@ -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<AInventory *>(Spawn (info, 0,0,0, NO_REPLACE));
AInventory *item = static_cast<AInventory *>(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<AAmmo *>(Spawn (ammotype, 0, 0, 0, NO_REPLACE));
iammo = static_cast<AAmmo *>(Spawn (ammotype));
iammo->Amount = 0;
iammo->AttachToOwner (players[playernum].mo);
}

View File

@ -206,7 +206,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw)
if (armorbonustype != NULL)
{
assert(armorbonustype->IsDescendantOf (RUNTIME_CLASS(ABasicArmorBonus)));
ABasicArmorBonus *armorbonus = static_cast<ABasicArmorBonus *>(Spawn(armorbonustype, 0,0,0, NO_REPLACE));
ABasicArmorBonus *armorbonus = static_cast<ABasicArmorBonus *>(Spawn(armorbonustype));
armorbonus->SaveAmount = int(armorbonus->SaveAmount * actualdamage * lifesteal);
armorbonus->MaxSaveAmount = lifestealmax <= 0 ? armorbonus->MaxSaveAmount : lifestealmax;
armorbonus->flags |= MF_DROPPED;

View File

@ -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"); }

View File

@ -29,7 +29,7 @@ bool AArtiBoostArmor::Use (bool pickup)
for (int i = 0; i < 4; ++i)
{
armor = Spawn<AHexenArmor> (0,0,0, NO_REPLACE);
armor = Spawn<AHexenArmor>();
armor->flags |= MF_DROPPED;
armor->health = i;
armor->Amount = 1;
@ -46,7 +46,7 @@ bool AArtiBoostArmor::Use (bool pickup)
}
else
{
ABasicArmorBonus *armor = Spawn<ABasicArmorBonus> (0,0,0, NO_REPLACE);
ABasicArmorBonus *armor = Spawn<ABasicArmorBonus>();
armor->flags |= MF_DROPPED;
armor->SaveAmount = 50;
armor->MaxSaveAmount = 300;

View File

@ -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.;

View File

@ -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;

View File

@ -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;
}

View File

@ -265,7 +265,7 @@ AInventory *AArtiPoisonBag::CreateCopy (AActor *other)
AInventory *copy;
PClassActor *spawntype = GetFlechetteType(other);
copy = static_cast<AInventory *>(Spawn (spawntype, 0, 0, 0, NO_REPLACE));
copy = static_cast<AInventory *>(Spawn (spawntype));
copy->Amount = Amount;
copy->MaxAmount = MaxAmount;
GoAwayAndDie ();

View File

@ -52,7 +52,7 @@ bool AArtiHealingRadius::Use (bool pickup)
case NAME_Armor:
for (int j = 0; j < 4; ++j)
{
AHexenArmor *armor = Spawn<AHexenArmor> (0,0,0, NO_REPLACE);
AHexenArmor *armor = Spawn<AHexenArmor> ();
armor->health = j;
armor->Amount = 1;
if (!armor->CallTryPickup (players[i].mo))

View File

@ -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;
}

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -249,7 +249,7 @@ bool ABasicArmorPickup::Use (bool pickup)
if (armor == NULL)
{
armor = Spawn<ABasicArmor> (0,0,0, NO_REPLACE);
armor = Spawn<ABasicArmor> ();
armor->BecomeItem ();
Owner->AddInventory (armor);
}
@ -332,7 +332,7 @@ bool ABasicArmorBonus::Use (bool pickup)
if (armor == NULL)
{
armor = Spawn<ABasicArmor> (0,0,0, NO_REPLACE);
armor = Spawn<ABasicArmor> ();
armor->BecomeItem ();
armor->Amount = 0;
armor->MaxAmount = MaxSaveAmount;

View File

@ -66,7 +66,7 @@ bool APowerupGiver::Use (bool pickup)
{
if (PowerupType == NULL) return true; // item is useless
APowerup *power = static_cast<APowerup *> (Spawn (PowerupType, 0, 0, 0, NO_REPLACE));
APowerup *power = static_cast<APowerup *> (Spawn (PowerupType));
if (EffectTics != 0)
{

View File

@ -204,7 +204,7 @@ AInventory *AAmmo::CreateCopy (AActor *other)
Destroy ();
}
copy = static_cast<AInventory *>(Spawn (type, 0, 0, 0, NO_REPLACE));
copy = static_cast<AInventory *>(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<AInventory *>(Spawn (GetClass(), 0, 0, 0, NO_REPLACE));
copy = static_cast<AInventory *>(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<AAmmo *>(Spawn(atype, 0, 0, 0, NO_REPLACE));
ammo = static_cast<AAmmo *>(Spawn(atype));
ammo->Amount = bDepleted ? 0 : amount;
if (ammo->BackpackMaxAmount > ammo->MaxAmount)
{

View File

@ -89,7 +89,7 @@ bool AWeaponPiece::TryPickup (AActor *&toucher)
}
if (!hold)
{
hold=static_cast<AWeaponHolder*>(Spawn(RUNTIME_CLASS(AWeaponHolder), 0, 0, 0, NO_REPLACE));
hold=static_cast<AWeaponHolder*>(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<AWeapon*>(Spawn(WeaponClass, 0, 0, 0, NO_REPLACE));
FullWeapon= static_cast<AWeapon*>(Spawn(WeaponClass));
// The weapon itself should not give more ammo to the player!
FullWeapon->AmmoGive1=0;

View File

@ -387,7 +387,7 @@ AAmmo *AWeapon::AddAmmo (AActor *other, PClassActor *ammotype, int amount)
ammo = static_cast<AAmmo *>(other->FindInventory (ammotype));
if (ammo == NULL)
{
ammo = static_cast<AAmmo *>(Spawn (ammotype, 0, 0, 0, NO_REPLACE));
ammo = static_cast<AAmmo *>(Spawn (ammotype));
ammo->Amount = MIN (amount, ammo->MaxAmount);
ammo->AttachToOwner (other);
}
@ -449,7 +449,7 @@ AWeapon *AWeapon::AddWeapon (PClassWeapon *weapontype)
weap = static_cast<AWeapon *>(Owner->FindInventory (weapontype));
if (weap == NULL)
{
weap = static_cast<AWeapon *>(Spawn (weapontype, 0, 0, 0, NO_REPLACE));
weap = static_cast<AWeapon *>(Spawn (weapontype));
weap->AttachToOwner (Owner);
}
return weap;
@ -749,7 +749,7 @@ bool AWeaponGiver::TryPickup(AActor *&toucher)
{
if (master == NULL)
{
master = weap = static_cast<AWeapon*>(Spawn(di->Name, 0, 0, 0, NO_REPLACE));
master = weap = static_cast<AWeapon*>(Spawn(di->Name));
if (weap != NULL)
{
weap->ItemFlags &= ~IF_ALWAYSPICKUP; // use the flag of this item only.

View File

@ -54,7 +54,7 @@ AInventory *ACoin::CreateCopy (AActor *other)
{
return Super::CreateCopy (other);
}
AInventory *copy = Spawn<ACoin> (0,0,0, NO_REPLACE);
AInventory *copy = Spawn<ACoin> ();
copy->Amount = Amount;
copy->BecomeItem ();
GoAwayAndDie ();

View File

@ -82,7 +82,7 @@ bool AHealthTraining::TryPickup (AActor *&toucher)
if (Super::TryPickup (toucher))
{
toucher->GiveInventoryType (PClass::FindActor("GunTraining"));
AInventory *coin = Spawn<ACoin> (0,0,0, NO_REPLACE);
AInventory *coin = Spawn<ACoin> ();
if (coin != NULL)
{
coin->Amount = toucher->player->mo->accuracy*5 + 300;

View File

@ -814,7 +814,7 @@ bool ASigil::HandlePickup (AInventory *item)
AInventory *ASigil::CreateCopy (AActor *other)
{
ASigil *copy = Spawn<ASigil> (0,0,0, NO_REPLACE);
ASigil *copy = Spawn<ASigil> ();
copy->Amount = Amount;
copy->MaxAmount = MaxAmount;
copy->NumPieces = NumPieces;
@ -1167,7 +1167,7 @@ int ASigil::GiveSigilPiece (AActor *receiver)
sigil = receiver->FindInventory<ASigil> ();
if (sigil == NULL)
{
sigil = static_cast<ASigil*>(Spawn("Sigil1", 0,0,0, NO_REPLACE));
sigil = static_cast<ASigil*>(Spawn("Sigil1"));
if (!sigil->CallTryPickup (receiver))
{
sigil->Destroy ();

View File

@ -38,7 +38,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveQuestItem)
{
if (playeringame[i])
{
AInventory *item = static_cast<AInventory *>(Spawn (QuestItemClasses[questitem - 1], 0,0,0, NO_REPLACE));
AInventory *item = static_cast<AInventory *>(Spawn (QuestItemClasses[questitem - 1]));
if (!item->CallTryPickup (players[i].mo))
{
item->Destroy ();

View File

@ -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<AInventory *>(Spawn (atype, 0, 0, 0, NO_REPLACE));
ammo = static_cast<AInventory *>(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<ABasicArmorPickup> (0,0,0, NO_REPLACE);
ABasicArmorPickup *armor = Spawn<ABasicArmorPickup> ();
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<AHexenArmor> (0,0,0, NO_REPLACE);
AHexenArmor *armor = Spawn<AHexenArmor> ();
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<AKey *>(Spawn(static_cast<PClassActor *>(PClassActor::AllActorClasses[i]), 0,0,0, NO_REPLACE));
key = static_cast<AKey *>(Spawn(static_cast<PClassActor *>(PClassActor::AllActorClasses[i])));
if (!key->CallTryPickup (player->mo))
{
key->Destroy ();

View File

@ -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<AInventory *>(Spawn (info, 0,0,0, NO_REPLACE));
AInventory *item = static_cast<AInventory *>(Spawn (info));
// This shouldn't count for the item statistics!
item->ClearCounters();

View File

@ -1268,7 +1268,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply
if (takestuff)
{
AInventory *item = static_cast<AInventory *>(Spawn(reply->GiveType, 0, 0, 0, NO_REPLACE));
AInventory *item = static_cast<AInventory *>(Spawn(reply->GiveType));
// Items given here should not count as items!
item->ClearCounters();
if (item->GetClass()->TypeName == NAME_FlameThrower)

View File

@ -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)

View File

@ -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

View File

@ -898,7 +898,7 @@ AInventory *AActor::GiveInventoryType (PClassActor *type)
if (type != NULL)
{
item = static_cast<AInventory *>(Spawn (type, 0,0,0, NO_REPLACE));
item = static_cast<AInventory *>(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<AInventory *>(Spawn (type, 0, 0, 0, NO_REPLACE));
AInventory *item = static_cast<AInventory *>(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;
}

View File

@ -1053,7 +1053,7 @@ void APlayerPawn::GiveDeathmatchInventory()
AKey *key = (AKey *)GetDefaultByType (PClassActor::AllActorClasses[i]);
if (key->KeyNumber != 0)
{
key = static_cast<AKey *>(Spawn(static_cast<PClassActor *>(PClassActor::AllActorClasses[i]), 0,0,0, NO_REPLACE));
key = static_cast<AKey *>(Spawn(static_cast<PClassActor *>(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<ABasicArmor> (0,0,0, NO_REPLACE);
ABasicArmor *barmor = Spawn<ABasicArmor> ();
barmor->BecomeItem ();
barmor->SavePercent = 0;
barmor->Amount = 0;
@ -1350,7 +1350,7 @@ void APlayerPawn::GiveDefaultInventory ()
}
else
{
item = static_cast<AInventory *>(Spawn (ti, 0,0,0, NO_REPLACE));
item = static_cast<AInventory *>(Spawn (ti));
item->ItemFlags |= IF_IGNORESKILL; // no skill multiplicators here
item->Amount = di->Amount;
if (item->IsKindOf (RUNTIME_CLASS (AWeapon)))

View File

@ -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];

View File

@ -1758,7 +1758,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
if (armorbonustype != NULL)
{
assert(armorbonustype->IsDescendantOf(RUNTIME_CLASS(ABasicArmorBonus)));
ABasicArmorBonus *armorbonus = static_cast<ABasicArmorBonus *>(Spawn(armorbonustype, 0,0,0, NO_REPLACE));
ABasicArmorBonus *armorbonus = static_cast<ABasicArmorBonus *>(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<AInventory *>(Spawn(mi, 0, 0, 0, NO_REPLACE));
AInventory *item = static_cast<AInventory *>(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<AInventory *>(Spawn(item, 0, 0, 0, NO_REPLACE));
AInventory *gift = static_cast<AInventory *>(Spawn(item));
if (gift->IsKindOf(RUNTIME_CLASS(AHealth)))
{
gift->Amount *= amount;

View File

@ -1076,6 +1076,12 @@ inline TAngle<double> ToDegrees (double rad)
return TAngle<double> (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>(double(fb * (180.0 / 32))).Sin() * 8;
}
template<class T>
inline TAngle<T> fabs (const TAngle<T> &deg)
{