- made player_t::crouchoffset and FPlayerStart's coordinates doubles and added a float version of divline_t so that I could complete the conversion of Hexen's game code.

- consolidated the actor based damage factor code which was repeated multiple times in various damage inflicting functions.
This commit is contained in:
Christoph Oelckers 2016-03-22 00:06:58 +01:00
parent c830801da3
commit 4155e84a1c
24 changed files with 133 additions and 121 deletions

View file

@ -1272,7 +1272,7 @@ public:
int PainThreshold; int PainThreshold;
FNameNoInit DamageType; FNameNoInit DamageType;
FNameNoInit DamageTypeReceived; FNameNoInit DamageTypeReceived;
fixed_t DamageFactor; double DamageFactor;
fixed_t DamageMultiply; fixed_t DamageMultiply;
FNameNoInit PainType; FNameNoInit PainType;
@ -1577,6 +1577,8 @@ public:
return MAX(1., Distance2D(dest) / speed); return MAX(1., Distance2D(dest) / speed);
} }
int ApplyDamageFactor(FName damagetype, int damage) const;
}; };
class FActorIterator class FActorIterator

View file

@ -492,7 +492,7 @@ public:
DAngle MaxPitch; DAngle MaxPitch;
double crouchfactor; double crouchfactor;
fixed_t crouchoffset; double crouchoffset;
fixed_t crouchviewdelta; fixed_t crouchviewdelta;
FWeaponSlots weapons; FWeaponSlots weapons;

View file

@ -428,15 +428,19 @@ enum EMapThingFlags
// A simplified mapthing for player starts // A simplified mapthing for player starts
struct FPlayerStart struct FPlayerStart
{ {
fixed_t x, y, z; DVector3 pos;
short angle, type; short angle, type;
FPlayerStart() { } FPlayerStart() { }
FPlayerStart(const FMapThing *mthing, int pnum) FPlayerStart(const FMapThing *mthing, int pnum)
: x(mthing->x), y(mthing->y), z(mthing->z), : pos(FIXED2DBL(mthing->x), FIXED2DBL(mthing->y), FIXED2DBL(mthing->z)),
angle(mthing->angle), angle(mthing->angle),
type(pnum) type(pnum)
{ } { }
fixed_t _f_X() { return FLOAT2FIXED(pos.X); }
fixed_t _f_Y() { return FLOAT2FIXED(pos.Y); }
fixed_t _f_Z() { return FLOAT2FIXED(pos.Z); }
}; };
// Player spawn spots for deathmatch. // Player spawn spots for deathmatch.
extern TArray<FPlayerStart> deathmatchstarts; extern TArray<FPlayerStart> deathmatchstarts;

View file

@ -1430,9 +1430,9 @@ bool G_CheckSpot (int playernum, FPlayerStart *mthing)
if (mthing->type == 0) return false; if (mthing->type == 0) return false;
x = mthing->x; x = mthing->_f_X();
y = mthing->y; y = mthing->_f_Y();
z = mthing->z; z = mthing->_f_Z();
if (!(level.flags & LEVEL_USEPLAYERSTARTZ)) if (!(level.flags & LEVEL_USEPLAYERSTARTZ))
{ {
@ -1476,10 +1476,10 @@ bool G_CheckSpot (int playernum, FPlayerStart *mthing)
// //
// [RH] Returns the distance of the closest player to the given mapthing // [RH] Returns the distance of the closest player to the given mapthing
static fixed_t PlayersRangeFromSpot (FPlayerStart *spot) static double PlayersRangeFromSpot (FPlayerStart *spot)
{ {
fixed_t closest = INT_MAX; double closest = INT_MAX;
fixed_t distance; double distance;
int i; int i;
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
@ -1487,7 +1487,7 @@ static fixed_t PlayersRangeFromSpot (FPlayerStart *spot)
if (!playeringame[i] || !players[i].mo || players[i].health <= 0) if (!playeringame[i] || !players[i].mo || players[i].health <= 0)
continue; continue;
distance = players[i].mo->AproxDistance (spot->x, spot->y); distance = players[i].mo->Distance2D(spot->pos.X, spot->pos.Y);
if (distance < closest) if (distance < closest)
closest = distance; closest = distance;
@ -1499,13 +1499,13 @@ static fixed_t PlayersRangeFromSpot (FPlayerStart *spot)
// [RH] Select the deathmatch spawn spot farthest from everyone. // [RH] Select the deathmatch spawn spot farthest from everyone.
static FPlayerStart *SelectFarthestDeathmatchSpot (size_t selections) static FPlayerStart *SelectFarthestDeathmatchSpot (size_t selections)
{ {
fixed_t bestdistance = 0; double bestdistance = 0;
FPlayerStart *bestspot = NULL; FPlayerStart *bestspot = NULL;
unsigned int i; unsigned int i;
for (i = 0; i < selections; i++) for (i = 0; i < selections; i++)
{ {
fixed_t distance = PlayersRangeFromSpot (&deathmatchstarts[i]); double distance = PlayersRangeFromSpot (&deathmatchstarts[i]);
if (distance > bestdistance) if (distance > bestdistance)
{ {

View file

@ -94,7 +94,7 @@ bool AArtiPoisonBag3::Use (bool pickup)
{ {
AActor *mo; AActor *mo;
mo = Spawn("ThrowingBomb", Owner->PosPlusZ(-Owner->Floorclip+35. + FIXED2FLOAT(Owner->player? Owner->player->crouchoffset : 0)), ALLOW_REPLACE); mo = Spawn("ThrowingBomb", Owner->PosPlusZ(35. - Owner->Floorclip + (Owner->player? Owner->player->crouchoffset : 0)), ALLOW_REPLACE);
if (mo) if (mo)
{ {
mo->Angles.Yaw = Owner->Angles.Yaw + (((pr_poisonbag() & 7) - 4) * (360./256.)); mo->Angles.Yaw = Owner->Angles.Yaw + (((pr_poisonbag() & 7) - 4) * (360./256.));
@ -337,11 +337,7 @@ int APoisonCloud::DoSpecialDamage (AActor *victim, int damage, FName damagetype)
victim->Inventory->ModifyDamage(damage, damagetype, damage, true); victim->Inventory->ModifyDamage(damage, damagetype, damage, true);
} }
// Modify with damage factors // Modify with damage factors
damage = FixedMul(damage, victim->DamageFactor); damage = victim->ApplyDamageFactor(damagetype, damage);
if (damage > 0)
{
damage = DamageTypeDefinition::ApplyMobjDamageFactor(damage, damagetype, victim->GetClass()->DamageFactors);
}
if (damage > 0) if (damage > 0)
{ {
P_PoisonDamage (victim->player, this, P_PoisonDamage (victim->player, this,

View file

@ -171,26 +171,6 @@ IMPLEMENT_CLASS (ASorcBall3)
// Sorcerer spell 1 (The burning, bouncing head thing) ---------------------- // Sorcerer spell 1 (The burning, bouncing head thing) ----------------------
/*
class ASorcFX1 : public AActor
{
DECLARE_CLASS (ASorcFX1, AActor)
public:
bool FloorBounceMissile (secplane_t &plane)
{
fixed_t orgvelz = vel.z;
if (!Super::FloorBounceMissile (plane))
{
vel.z = -orgvelz; // no energy absorbed
return false;
}
return true;
}
};
IMPLEMENT_CLASS (ASorcFX1)
*/
//============================================================================ //============================================================================
// //
// SorcBall::DoFireSpell // SorcBall::DoFireSpell

View file

@ -144,10 +144,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_MStaffAttack)
P_AimLineAttack (self, angle, PLAYERMISSILERANGE, &t, 32.); P_AimLineAttack (self, angle, PLAYERMISSILERANGE, &t, 32.);
if (t.linetarget == NULL) if (t.linetarget == NULL)
{ {
BlockCheckLine.x = self->_f_X(); BlockCheckLine.x = self->X();
BlockCheckLine.y = self->_f_Y(); BlockCheckLine.y = self->Y();
BlockCheckLine.dx = FLOAT2FIXED(-angle.Sin()); BlockCheckLine.dx = -angle.Sin();
BlockCheckLine.dy = FLOAT2FIXED(-angle.Cos()); BlockCheckLine.dy = -angle.Cos();
t.linetarget = P_BlockmapSearch (self, 10, FrontBlockCheck); t.linetarget = P_BlockmapSearch (self, 10, FrontBlockCheck);
} }
MStaffSpawn (self, angle, t.linetarget); MStaffSpawn (self, angle, t.linetarget);
@ -213,7 +213,7 @@ static AActor *FrontBlockCheck (AActor *mo, int index, void *)
{ {
if (link->Me != mo) if (link->Me != mo)
{ {
if (P_PointOnDivlineSide (link->Me->_f_X(), link->Me->_f_Y(), &BlockCheckLine) == 0 && if (P_PointOnDivlineSidePrecise(link->Me->X(), link->Me->Y(), &BlockCheckLine) == 0 &&
mo->IsOkayToAttack (link->Me)) mo->IsOkayToAttack (link->Me))
{ {
return link->Me; return link->Me;

View file

@ -164,12 +164,12 @@ int ATelOtherFX1::DoSpecialDamage (AActor *target, int damage, FName damagetype)
void P_TeleportToPlayerStarts (AActor *victim) void P_TeleportToPlayerStarts (AActor *victim)
{ {
fixed_t destX,destY; DVector3 dest;
FPlayerStart *start = G_PickPlayerStart(0, PPS_FORCERANDOM | PPS_NOBLOCKINGCHECK); FPlayerStart *start = G_PickPlayerStart(0, PPS_FORCERANDOM | PPS_NOBLOCKINGCHECK);
destX = start->x; dest = start->pos;
destY = start->y; dest.Z = ONFLOORZ;
P_Teleport (victim, destX, destY, ONFLOORZ, (double)start->angle, TELF_SOURCEFOG | TELF_DESTFOG); P_Teleport (victim, dest, (double)start->angle, TELF_SOURCEFOG | TELF_DESTFOG);
} }
//=========================================================================== //===========================================================================
@ -181,15 +181,15 @@ void P_TeleportToPlayerStarts (AActor *victim)
void P_TeleportToDeathmatchStarts (AActor *victim) void P_TeleportToDeathmatchStarts (AActor *victim)
{ {
unsigned int i, selections; unsigned int i, selections;
fixed_t destX,destY; DVector3 dest;
selections = deathmatchstarts.Size (); selections = deathmatchstarts.Size ();
if (selections > 0) if (selections > 0)
{ {
i = pr_teledm() % selections; i = pr_teledm() % selections;
destX = deathmatchstarts[i].x; dest = deathmatchstarts[i].pos;
destY = deathmatchstarts[i].y; dest.Z = ONFLOORZ;
P_Teleport (victim, destX, destY, ONFLOORZ, (double)deathmatchstarts[i].angle, TELF_SOURCEFOG | TELF_DESTFOG); P_Teleport (victim, dest, (double)deathmatchstarts[i].angle, TELF_SOURCEFOG | TELF_DESTFOG);
} }
else else
{ {

View file

@ -547,7 +547,6 @@ enum ESkillProperty
{ {
SKILLP_AmmoFactor, SKILLP_AmmoFactor,
SKILLP_DropAmmoFactor, SKILLP_DropAmmoFactor,
SKILLP_DamageFactor,
SKILLP_FastMonsters, SKILLP_FastMonsters,
SKILLP_Respawn, SKILLP_Respawn,
SKILLP_RespawnLimit, SKILLP_RespawnLimit,
@ -566,7 +565,12 @@ enum ESkillProperty
SKILLP_SlowMonsters, SKILLP_SlowMonsters,
SKILLP_Infight, SKILLP_Infight,
}; };
enum EFSkillProperty // floating point properties
{
SKILLP_DamageFactor,
};
int G_SkillProperty(ESkillProperty prop); int G_SkillProperty(ESkillProperty prop);
double G_SkillProperty(EFSkillProperty prop);
const char * G_SkillName(); const char * G_SkillName();
typedef TMap<FName, FString> SkillMenuNames; typedef TMap<FName, FString> SkillMenuNames;
@ -577,7 +581,7 @@ struct FSkillInfo
{ {
FName Name; FName Name;
fixed_t AmmoFactor, DoubleAmmoFactor, DropAmmoFactor; fixed_t AmmoFactor, DoubleAmmoFactor, DropAmmoFactor;
fixed_t DamageFactor; double DamageFactor;
bool FastMonsters; bool FastMonsters;
bool SlowMonsters; bool SlowMonsters;
bool DisableCheats; bool DisableCheats;

View file

@ -27,26 +27,24 @@ IMPLEMENT_CLASS (AArtiTeleport)
bool AArtiTeleport::Use (bool pickup) bool AArtiTeleport::Use (bool pickup)
{ {
fixed_t destX; DVector3 dest;
fixed_t destY;
int destAngle; int destAngle;
if (deathmatch) if (deathmatch)
{ {
unsigned int selections = deathmatchstarts.Size (); unsigned int selections = deathmatchstarts.Size ();
unsigned int i = pr_tele() % selections; unsigned int i = pr_tele() % selections;
destX = deathmatchstarts[i].x; dest = deathmatchstarts[i].pos;
destY = deathmatchstarts[i].y;
destAngle = deathmatchstarts[i].angle; destAngle = deathmatchstarts[i].angle;
} }
else else
{ {
FPlayerStart *start = G_PickPlayerStart(int(Owner->player - players)); FPlayerStart *start = G_PickPlayerStart(int(Owner->player - players));
destX = start->x; dest = start->pos;
destY = start->y;
destAngle = start->angle; destAngle = start->angle;
} }
P_Teleport (Owner, destX, destY, ONFLOORZ, (double)destAngle, TELF_SOURCEFOG | TELF_DESTFOG); dest.Z = ONFLOORZ;
P_Teleport (Owner, dest, (double)destAngle, TELF_SOURCEFOG | TELF_DESTFOG);
bool canlaugh = true; bool canlaugh = true;
if (Owner->player->morphTics && (Owner->player->MorphStyle & MORPH_UNDOBYCHAOSDEVICE)) if (Owner->player->morphTics && (Owner->player->MorphStyle & MORPH_UNDOBYCHAOSDEVICE))
{ // Teleporting away will undo any morph effects (pig) { // Teleporting away will undo any morph effects (pig)

View file

@ -62,7 +62,7 @@ void FMapInfoParser::ParseSkill ()
skill.AmmoFactor = FRACUNIT; skill.AmmoFactor = FRACUNIT;
skill.DoubleAmmoFactor = 2*FRACUNIT; skill.DoubleAmmoFactor = 2*FRACUNIT;
skill.DropAmmoFactor = -1; skill.DropAmmoFactor = -1;
skill.DamageFactor = FRACUNIT; skill.DamageFactor = 1.;
skill.FastMonsters = false; skill.FastMonsters = false;
skill.SlowMonsters = false; skill.SlowMonsters = false;
skill.DisableCheats = false; skill.DisableCheats = false;
@ -115,7 +115,7 @@ void FMapInfoParser::ParseSkill ()
{ {
ParseAssign(); ParseAssign();
sc.MustGetFloat (); sc.MustGetFloat ();
skill.DamageFactor = FLOAT2FIXED(sc.Float); skill.DamageFactor = sc.Float;
} }
else if (sc.Compare ("fastmonsters")) else if (sc.Compare ("fastmonsters"))
{ {
@ -351,9 +351,6 @@ int G_SkillProperty(ESkillProperty prop)
case SKILLP_DropAmmoFactor: case SKILLP_DropAmmoFactor:
return AllSkills[gameskill].DropAmmoFactor; return AllSkills[gameskill].DropAmmoFactor;
case SKILLP_DamageFactor:
return AllSkills[gameskill].DamageFactor;
case SKILLP_FastMonsters: case SKILLP_FastMonsters:
return AllSkills[gameskill].FastMonsters || (dmflags & DF_FAST_MONSTERS); return AllSkills[gameskill].FastMonsters || (dmflags & DF_FAST_MONSTERS);
@ -416,6 +413,28 @@ int G_SkillProperty(ESkillProperty prop)
return 0; return 0;
} }
//==========================================================================
//
//
//
//==========================================================================
double G_SkillProperty(EFSkillProperty prop)
{
if (AllSkills.Size() > 0)
{
switch (prop)
{
case SKILLP_DamageFactor:
return AllSkills[gameskill].DamageFactor;
break;
}
}
return 0;
}
//========================================================================== //==========================================================================
// //
// //

View file

@ -1071,8 +1071,8 @@ public:
Pawn->flags |= MF_SHOOTABLE; Pawn->flags |= MF_SHOOTABLE;
Pawn->flags2 &= ~MF2_INVULNERABLE; Pawn->flags2 &= ~MF2_INVULNERABLE;
// Store the player's current damage factor, to restore it later. // Store the player's current damage factor, to restore it later.
fixed_t plyrdmgfact = Pawn->DamageFactor; double plyrdmgfact = Pawn->DamageFactor;
Pawn->DamageFactor = 65536; Pawn->DamageFactor = 1.;
P_DamageMobj (Pawn, Pawn, Pawn, TELEFRAG_DAMAGE, NAME_Suicide); P_DamageMobj (Pawn, Pawn, Pawn, TELEFRAG_DAMAGE, NAME_Suicide);
Pawn->DamageFactor = plyrdmgfact; Pawn->DamageFactor = plyrdmgfact;
if (Pawn->health <= 0) if (Pawn->health <= 0)

View file

@ -3954,7 +3954,7 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value)
break; break;
case APROP_DamageFactor: case APROP_DamageFactor:
actor->DamageFactor = value; actor->DamageFactor = ACSToDouble(value);
break; break;
case APROP_DamageMultiplier: case APROP_DamageMultiplier:
@ -4037,7 +4037,7 @@ int DLevelScript::GetActorProperty (int tid, int property)
case APROP_Health: return actor->health; case APROP_Health: return actor->health;
case APROP_Speed: return DoubleToACS(actor->Speed); case APROP_Speed: return DoubleToACS(actor->Speed);
case APROP_Damage: return actor->GetMissileDamage(0,1); case APROP_Damage: return actor->GetMissileDamage(0,1);
case APROP_DamageFactor:return actor->DamageFactor; case APROP_DamageFactor:return DoubleToACS(actor->DamageFactor);
case APROP_DamageMultiplier: return actor->DamageMultiply; case APROP_DamageMultiplier: return actor->DamageMultiply;
case APROP_Alpha: return DoubleToACS(actor->Alpha); case APROP_Alpha: return DoubleToACS(actor->Alpha);
case APROP_RenderStyle: for (int style = STYLE_None; style < STYLE_Count; ++style) case APROP_RenderStyle: for (int style = STYLE_None; style < STYLE_Count; ++style)

View file

@ -1046,7 +1046,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage,
if (player && damage > 1) if (player && damage > 1)
{ {
// Take half damage in trainer mode // Take half damage in trainer mode
damage = FixedMul(damage, G_SkillProperty(SKILLP_DamageFactor)); damage = int(damage * G_SkillProperty(SKILLP_DamageFactor));
} }
// Special damage types // Special damage types
if (inflictor) if (inflictor)
@ -1091,11 +1091,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage,
} }
if (damage > 0 && !(flags & DMG_NO_FACTOR)) if (damage > 0 && !(flags & DMG_NO_FACTOR))
{ {
damage = FixedMul(damage, target->DamageFactor); damage = target->ApplyDamageFactor(mod, damage);
if (damage > 0)
{
damage = DamageTypeDefinition::ApplyMobjDamageFactor(damage, mod, target->GetClass()->DamageFactors);
}
} }
if (damage >= 0) if (damage >= 0)
@ -1721,18 +1717,15 @@ void P_PoisonDamage (player_t *player, AActor *source, int damage,
return; return;
} }
// Take half damage in trainer mode // Take half damage in trainer mode
damage = FixedMul(damage, G_SkillProperty(SKILLP_DamageFactor)); damage = int(damage * G_SkillProperty(SKILLP_DamageFactor));
// Handle passive damage modifiers (e.g. PowerProtection) // Handle passive damage modifiers (e.g. PowerProtection)
if (target->Inventory != NULL) if (target->Inventory != NULL)
{ {
target->Inventory->ModifyDamage(damage, player->poisontype, damage, true); target->Inventory->ModifyDamage(damage, player->poisontype, damage, true);
} }
// Modify with damage factors // Modify with damage factors
damage = FixedMul(damage, target->DamageFactor); damage = target->ApplyDamageFactor(player->poisontype, damage);
if (damage > 0)
{
damage = DamageTypeDefinition::ApplyMobjDamageFactor(damage, player->poisontype, target->GetClass()->DamageFactors);
}
if (damage <= 0) if (damage <= 0)
{ // Damage was reduced to 0, so don't bother further. { // Damage was reduced to 0, so don't bother further.
return; return;

View file

@ -2281,8 +2281,8 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y,
side = P_PointOnLineSide(spec.refpos.x, spec.refpos.y, ld); side = P_PointOnLineSide(spec.refpos.x, spec.refpos.y, ld);
if (oldside == 0 && side == 1) if (oldside == 0 && side == 1)
{ {
divline_t dl2 = { ld->v1->x, ld->v1->y, ld->dx, ld->dy }; fdivline_t dl2 = { ld->v1->x, ld->v1->y, ld->dx, ld->dy };
divline_t dl1 = { spec.oldrefpos.x, spec.oldrefpos.y, spec.refpos.x - spec.oldrefpos.x, spec.refpos.y - spec.oldrefpos.y }; fdivline_t dl1 = { spec.oldrefpos.x, spec.oldrefpos.y, spec.refpos.x - spec.oldrefpos.x, spec.refpos.y - spec.oldrefpos.y };
fixed_t frac = P_InterceptVector(&dl1, &dl2); fixed_t frac = P_InterceptVector(&dl1, &dl2);
if (frac < bestfrac) if (frac < bestfrac)
{ {
@ -2337,7 +2337,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y,
// so that the renderer can properly calculate an interpolated position along the movement path. // so that the renderer can properly calculate an interpolated position along the movement path.
if (thing == players[consoleplayer].camera) if (thing == players[consoleplayer].camera)
{ {
divline_t dl1 = { besthit.oldrefpos.x,besthit. oldrefpos.y, besthit.refpos.x - besthit.oldrefpos.x, besthit.refpos.y - besthit.oldrefpos.y }; fdivline_t dl1 = { besthit.oldrefpos.x,besthit. oldrefpos.y, besthit.refpos.x - besthit.oldrefpos.x, besthit.refpos.y - besthit.oldrefpos.y };
fixedvec3a hit = { dl1.x + FixedMul(dl1.dx, bestfrac), dl1.y + FixedMul(dl1.dy, bestfrac), 0, 0. }; fixedvec3a hit = { dl1.x + FixedMul(dl1.dx, bestfrac), dl1.y + FixedMul(dl1.dy, bestfrac), 0, 0. };
R_AddInterpolationPoint(hit); R_AddInterpolationPoint(hit);
@ -2749,7 +2749,7 @@ void FSlide::HitSlideLine(line_t* ld)
} }
else else
{ {
divline_t dll, dlv; fdivline_t dll, dlv;
fixed_t inter1, inter2, inter3; fixed_t inter1, inter2, inter3;
P_MakeDivline(ld, &dll); P_MakeDivline(ld, &dll);
@ -3554,7 +3554,7 @@ struct aim_t
// //
//============================================================================ //============================================================================
bool AimTraverse3DFloors(const divline_t &trace, intercept_t * in, int frontflag, int *planestocheck) bool AimTraverse3DFloors(const fdivline_t &trace, intercept_t * in, int frontflag, int *planestocheck)
{ {
sector_t * nextsector; sector_t * nextsector;
secplane_t * nexttopplane, *nextbottomplane; secplane_t * nexttopplane, *nextbottomplane;

View file

@ -73,7 +73,7 @@ fixed_t P_AproxDistance (fixed_t dx, fixed_t dy)
// //
//========================================================================== //==========================================================================
fixed_t P_InterceptVector (const divline_t *v2, const divline_t *v1) fixed_t P_InterceptVector (const fdivline_t *v2, const fdivline_t *v1)
{ {
#if 0 // [RH] Use 64 bit ints, so long divlines don't overflow #if 0 // [RH] Use 64 bit ints, so long divlines don't overflow
@ -387,7 +387,7 @@ bool AActor::FixMapthingPos()
continue; continue;
// Get the exact distance to the line // Get the exact distance to the line
divline_t dll, dlv; fdivline_t dll, dlv;
fixed_t linelen = (fixed_t)g_sqrt((double)ldef->dx*ldef->dx + (double)ldef->dy*ldef->dy); fixed_t linelen = (fixed_t)g_sqrt((double)ldef->dx*ldef->dx + (double)ldef->dy*ldef->dy);
P_MakeDivline(ldef, &dll); P_MakeDivline(ldef, &dll);
@ -1197,7 +1197,7 @@ void FPathTraverse::AddLineIntercepts(int bx, int by)
int s1; int s1;
int s2; int s2;
fixed_t frac; fixed_t frac;
divline_t dl; fdivline_t dl;
// avoid precision problems with two routines // avoid precision problems with two routines
if ( trace.dx > FRACUNIT*16 if ( trace.dx > FRACUNIT*16
@ -1247,7 +1247,7 @@ void FPathTraverse::AddThingIntercepts (int bx, int by, FBlockThingsIterator &it
while ((thing = it.Next(compatible))) while ((thing = it.Next(compatible)))
{ {
int numfronts = 0; int numfronts = 0;
divline_t line; fdivline_t line;
int i; int i;
@ -1358,7 +1358,7 @@ void FPathTraverse::AddThingIntercepts (int bx, int by, FBlockThingsIterator &it
// Old code for compatibility purposes // Old code for compatibility purposes
fixed_t x1, y1, x2, y2; fixed_t x1, y1, x2, y2;
int s1, s2; int s1, s2;
divline_t dl; fdivline_t dl;
fixed_t frac; fixed_t frac;
bool tracepositive = (trace.dx ^ trace.dy)>0; bool tracepositive = (trace.dx ^ trace.dy)>0;
@ -1940,7 +1940,7 @@ int P_VanillaPointOnLineSide(fixed_t x, fixed_t y, const line_t* line)
// //
//=========================================================================== //===========================================================================
int P_VanillaPointOnDivlineSide(fixed_t x, fixed_t y, const divline_t* line) int P_VanillaPointOnDivlineSide(fixed_t x, fixed_t y, const fdivline_t* line)
{ {
fixed_t dx; fixed_t dx;
fixed_t dy; fixed_t dy;

View file

@ -7,7 +7,7 @@
extern int validcount; extern int validcount;
struct divline_t struct fdivline_t
{ {
fixed_t x; fixed_t x;
fixed_t y; fixed_t y;
@ -15,12 +15,12 @@ struct divline_t
fixed_t dy; fixed_t dy;
}; };
struct fdivline_t struct divline_t
{ {
fixed_t x; double x;
fixed_t y; double y;
fixed_t dx; double dx;
fixed_t dy; double dy;
}; };
struct intercept_t struct intercept_t
@ -81,20 +81,25 @@ inline int P_PointOnLineSidePrecise(const DVector3 &pt, const line_t *line)
// //
//========================================================================== //==========================================================================
inline int P_PointOnDivlineSide (fixed_t x, fixed_t y, const divline_t *line) inline int P_PointOnDivlineSide (fixed_t x, fixed_t y, const fdivline_t *line)
{ {
extern int P_VanillaPointOnDivlineSide(fixed_t x, fixed_t y, const divline_t* line); extern int P_VanillaPointOnDivlineSide(fixed_t x, fixed_t y, const fdivline_t* line);
return (i_compatflags2 & COMPATF2_POINTONLINE) return (i_compatflags2 & COMPATF2_POINTONLINE)
? P_VanillaPointOnDivlineSide(x, y, line) ? P_VanillaPointOnDivlineSide(x, y, line)
: (DMulScale32 (y-line->y, line->dx, line->x-x, line->dy) > 0); : (DMulScale32 (y-line->y, line->dx, line->x-x, line->dy) > 0);
} }
inline int P_PointOnDivlineSidePrecise (fixed_t x, fixed_t y, const divline_t *line) inline int P_PointOnDivlineSidePrecise (fixed_t x, fixed_t y, const fdivline_t *line)
{ {
return DMulScale32 (y-line->y, line->dx, line->x-x, line->dy) > 0; return DMulScale32 (y-line->y, line->dx, line->x-x, line->dy) > 0;
} }
inline int P_PointOnDivlineSidePrecise(double x, double y, const divline_t *line)
{
return (y - line->y) * line->dx + (line->x - x) * line->dy > 0;
}
//========================================================================== //==========================================================================
// //
@ -102,7 +107,7 @@ inline int P_PointOnDivlineSidePrecise (fixed_t x, fixed_t y, const divline_t *l
// //
//========================================================================== //==========================================================================
inline void P_MakeDivline (const line_t *li, divline_t *dl) inline void P_MakeDivline (const line_t *li, fdivline_t *dl)
{ {
dl->x = li->v1->x; dl->x = li->v1->x;
dl->y = li->v1->y; dl->y = li->v1->y;
@ -366,7 +371,7 @@ class FPathTraverse
protected: protected:
static TArray<intercept_t> intercepts; static TArray<intercept_t> intercepts;
divline_t trace; fdivline_t trace;
fixed_t startfrac; fixed_t startfrac;
unsigned int intercept_index; unsigned int intercept_index;
unsigned int intercept_count; unsigned int intercept_count;
@ -386,7 +391,7 @@ public:
void init(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int flags, fixed_t startfrac = 0); void init(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int flags, fixed_t startfrac = 0);
int PortalRelocate(intercept_t *in, int flags, fixedvec3 *optpos = NULL); int PortalRelocate(intercept_t *in, int flags, fixedvec3 *optpos = NULL);
virtual ~FPathTraverse(); virtual ~FPathTraverse();
const divline_t &Trace() const { return trace; } const fdivline_t &Trace() const { return trace; }
inline fixedvec2 InterceptPoint(const intercept_t *in) inline fixedvec2 InterceptPoint(const intercept_t *in)
{ {
@ -427,7 +432,7 @@ typedef bool(*traverser_t) (intercept_t *in);
fixed_t P_AproxDistance (fixed_t dx, fixed_t dy); fixed_t P_AproxDistance (fixed_t dx, fixed_t dy);
fixed_t P_InterceptVector (const divline_t *v2, const divline_t *v1); fixed_t P_InterceptVector (const fdivline_t *v2, const fdivline_t *v1);
#define PT_ADDLINES 1 #define PT_ADDLINES 1
#define PT_ADDTHINGS 2 #define PT_ADDTHINGS 2

View file

@ -1779,7 +1779,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly)
fixed_t oldz = mo->_f_Z(); fixed_t oldz = mo->_f_Z();
double maxmove = (mo->waterlevel < 1) || (mo->flags & MF_MISSILE) || double maxmove = (mo->waterlevel < 1) || (mo->flags & MF_MISSILE) ||
(mo->player && mo->player->crouchoffset<-10*FRACUNIT) ? MAXMOVE : MAXMOVE/4; (mo->player && mo->player->crouchoffset<-10) ? MAXMOVE : MAXMOVE/4;
if (mo->flags2 & MF2_WINDTHRUST && mo->waterlevel < 2 && !(mo->flags & MF_NOCLIP)) if (mo->flags2 & MF2_WINDTHRUST && mo->waterlevel < 2 && !(mo->flags & MF_NOCLIP))
{ {
@ -4634,8 +4634,8 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
} }
else else
{ {
spawn_x = mthing->x; spawn_x = mthing->_f_X();
spawn_y = mthing->y; spawn_y = mthing->_f_Y();
// Allow full angular precision // Allow full angular precision
SpawnAngle = (double)mthing->angle; SpawnAngle = (double)mthing->angle;
@ -4658,9 +4658,9 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
if (level.flags & LEVEL_USEPLAYERSTARTZ) if (level.flags & LEVEL_USEPLAYERSTARTZ)
{ {
if (spawn_z == ONFLOORZ) if (spawn_z == ONFLOORZ)
mobj->_f_AddZ(mthing->z); mobj->AddZ(mthing->pos.Z);
else if (spawn_z == ONCEILINGZ) else if (spawn_z == ONCEILINGZ)
mobj->_f_AddZ(-mthing->z); mobj->AddZ(-mthing->pos.Z);
P_FindFloorCeiling(mobj, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT); P_FindFloorCeiling(mobj, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT);
} }
@ -6631,6 +6631,17 @@ void AActor::ClearCounters()
} }
int AActor::ApplyDamageFactor(FName damagetype, int damage) const
{
damage = int(damage * DamageFactor);
if (damage > 0)
{
damage = DamageTypeDefinition::ApplyMobjDamageFactor(damage, damagetype, GetClass()->DamageFactors);
}
return damage;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// //
// DropItem handling // DropItem handling

View file

@ -95,7 +95,7 @@ class SightCheck
sector_t * lastsector; // last sector being entered by trace sector_t * lastsector; // last sector being entered by trace
fixed_t topslope, bottomslope; // slopes to top and bottom of target fixed_t topslope, bottomslope; // slopes to top and bottom of target
int Flags; int Flags;
divline_t trace; fdivline_t trace;
int portaldir; int portaldir;
int portalgroup; int portalgroup;
bool portalfound; bool portalfound;
@ -372,7 +372,7 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in)
bool SightCheck::P_SightCheckLine (line_t *ld) bool SightCheck::P_SightCheckLine (line_t *ld)
{ {
divline_t dl; fdivline_t dl;
if (ld->validcount == validcount) if (ld->validcount == validcount)
{ {
@ -508,7 +508,7 @@ bool SightCheck::P_SightTraverseIntercepts ()
fixed_t dist; fixed_t dist;
intercept_t *scan, *in; intercept_t *scan, *in;
unsigned scanpos; unsigned scanpos;
divline_t dl; fdivline_t dl;
count = intercepts.Size (); count = intercepts.Size ();
// //

View file

@ -135,7 +135,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo
return true; return true;
// calculate the point where the user would touch the wall. // calculate the point where the user would touch the wall.
divline_t dll, dlu; fdivline_t dll, dlu;
fixed_t inter, checkx, checky; fixed_t inter, checkx, checky;
P_MakeDivline (line, &dll); P_MakeDivline (line, &dll);

View file

@ -2430,7 +2430,7 @@ void P_PlayerThink (player_t *player)
player->Uncrouch(); player->Uncrouch();
} }
player->crouchoffset = -fixed_t(player->mo->ViewHeight * (1 - player->crouchfactor)); player->crouchoffset = -(FIXED2DBL(player->mo->ViewHeight) * (1 - player->crouchfactor));
// MUSINFO stuff // MUSINFO stuff
if (player->MUSINFOtics >= 0 && player->MUSINFOactor != NULL) if (player->MUSINFOtics >= 0 && player->MUSINFOactor != NULL)

View file

@ -162,7 +162,7 @@ void FLinePortalTraverse::AddLineIntercepts(int bx, int by)
{ {
line_t *ld = block.portallines[i]; line_t *ld = block.portallines[i];
fixed_t frac; fixed_t frac;
divline_t dl; fdivline_t dl;
if (ld->validcount == validcount) continue; // already processed if (ld->validcount == validcount) continue; // already processed

View file

@ -1218,7 +1218,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile)
angle_t ang = (self->_f_angle() - ANGLE_90) >> ANGLETOFINESHIFT; angle_t ang = (self->_f_angle() - ANGLE_90) >> ANGLETOFINESHIFT;
fixed_t x = spawnofs_xy * finecosine[ang]; fixed_t x = spawnofs_xy * finecosine[ang];
fixed_t y = spawnofs_xy * finesine[ang]; fixed_t y = spawnofs_xy * finesine[ang];
fixed_t z = spawnheight + self->GetBobOffset() - 32*FRACUNIT + (self->player? self->player->crouchoffset : 0); fixed_t z = spawnheight + self->GetBobOffset() - 32*FRACUNIT + (self->player? FLOAT2FIXED(self->player->crouchoffset) : 0);
fixedvec3 pos = self->_f_Pos(); fixedvec3 pos = self->_f_Pos();
switch (aimmode) switch (aimmode)
@ -2544,7 +2544,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade)
AActor *bo; AActor *bo;
bo = Spawn(missile, bo = Spawn(missile,
self->PosPlusZ(-self->_f_floorclip() + self->GetBobOffset() + zheight + 35*FRACUNIT + (self->player? self->player->crouchoffset : 0)), self->PosPlusZ(-self->_f_floorclip() + self->GetBobOffset() + zheight + 35*FRACUNIT + (self->player? FLOAT2FIXED(self->player->crouchoffset) : 0)),
ALLOW_REPLACE); ALLOW_REPLACE);
if (bo) if (bo)
{ {

View file

@ -1217,7 +1217,7 @@ DEFINE_PROPERTY(deathtype, S, Actor)
DEFINE_PROPERTY(damagefactor, ZF, Actor) DEFINE_PROPERTY(damagefactor, ZF, Actor)
{ {
PROP_STRING_PARM(str, 0); PROP_STRING_PARM(str, 0);
PROP_FIXED_PARM(id, 1); PROP_DOUBLE_PARM(id, 1);
if (str == NULL) if (str == NULL)
{ {
@ -1229,7 +1229,7 @@ DEFINE_PROPERTY(damagefactor, ZF, Actor)
if (!stricmp(str, "Normal")) dmgType = NAME_None; if (!stricmp(str, "Normal")) dmgType = NAME_None;
else dmgType=str; else dmgType=str;
info->SetDamageFactor(dmgType, id); info->SetDamageFactor(dmgType, FLOAT2FIXED(id));
} }
} }