2017-03-10 01:22:42 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "actor.h"
|
|
|
|
#include "r_defs.h"
|
2018-04-01 18:17:39 +00:00
|
|
|
#include "g_levellocals.h"
|
2019-01-03 17:01:58 +00:00
|
|
|
#include "d_player.h"
|
2018-04-01 18:17:39 +00:00
|
|
|
// These depend on both actor.h and r_defs.h so they cannot be in either file without creating a circular dependency.
|
2017-03-10 01:22:42 +00:00
|
|
|
|
|
|
|
inline DVector3 AActor::PosRelative(int portalgroup) const
|
|
|
|
{
|
2019-01-27 15:08:22 +00:00
|
|
|
return Pos() + Level->Displacements.getOffset(Sector->PortalGroup, portalgroup);
|
2017-03-10 01:22:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline DVector3 AActor::PosRelative(const AActor *other) const
|
|
|
|
{
|
2019-01-27 15:08:22 +00:00
|
|
|
return Pos() + Level->Displacements.getOffset(Sector->PortalGroup, other->Sector->PortalGroup);
|
2017-03-10 01:22:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline DVector3 AActor::PosRelative(sector_t *sec) const
|
|
|
|
{
|
2019-01-27 15:08:22 +00:00
|
|
|
return Pos() + Level->Displacements.getOffset(Sector->PortalGroup, sec->PortalGroup);
|
2017-03-10 01:22:42 +00:00
|
|
|
}
|
|
|
|
|
2018-11-30 10:22:34 +00:00
|
|
|
inline DVector3 AActor::PosRelative(const line_t *line) const
|
2017-03-10 01:22:42 +00:00
|
|
|
{
|
2019-01-27 15:08:22 +00:00
|
|
|
return Pos() + Level->Displacements.getOffset(Sector->PortalGroup, line->frontsector->PortalGroup);
|
2017-03-10 01:22:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void AActor::ClearInterpolation()
|
|
|
|
{
|
|
|
|
Prev = Pos();
|
|
|
|
PrevAngles = Angles;
|
|
|
|
if (Sector) PrevPortalGroup = Sector->PortalGroup;
|
|
|
|
else PrevPortalGroup = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline double secplane_t::ZatPoint(const AActor *ac) const
|
|
|
|
{
|
|
|
|
return (D + normal.X*ac->X() + normal.Y*ac->Y()) * negiC;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline double sector_t::HighestCeilingAt(AActor *a, sector_t **resultsec)
|
|
|
|
{
|
2018-11-28 23:27:09 +00:00
|
|
|
return ::HighestCeilingAt(this, a->X(), a->Y(), resultsec);
|
2017-03-10 01:22:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline double sector_t::LowestFloorAt(AActor *a, sector_t **resultsec)
|
|
|
|
{
|
2018-11-28 23:27:09 +00:00
|
|
|
return ::LowestFloorAt(this, a->X(), a->Y(), resultsec);
|
2017-03-10 01:22:42 +00:00
|
|
|
}
|
|
|
|
|
2018-12-04 23:21:16 +00:00
|
|
|
inline double AActor::GetBobOffset(double ticfrac) const
|
|
|
|
{
|
|
|
|
if (!(flags2 & MF2_FLOATBOB))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2019-01-27 15:08:22 +00:00
|
|
|
return BobSin(FloatBobPhase + Level->maptime + ticfrac) * FloatBobStrength;
|
2018-12-04 23:21:16 +00:00
|
|
|
}
|
|
|
|
|
2018-12-05 16:34:11 +00:00
|
|
|
inline double AActor::GetCameraHeight() const
|
|
|
|
{
|
|
|
|
return CameraHeight == INT_MIN ? Height / 2 : CameraHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline FDropItem *AActor::GetDropItems() const
|
|
|
|
{
|
|
|
|
return GetInfo()->DropItems;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline double AActor::GetGravity() const
|
|
|
|
{
|
|
|
|
if (flags & MF_NOGRAVITY) return 0;
|
2019-01-27 15:08:22 +00:00
|
|
|
return Level->gravity * Sector->gravity * Gravity * 0.00125;
|
2018-12-05 16:34:11 +00:00
|
|
|
}
|
2019-01-03 17:01:58 +00:00
|
|
|
|
|
|
|
inline double AActor::AttackOffset(double offset)
|
|
|
|
{
|
|
|
|
if (player != NULL)
|
|
|
|
{
|
|
|
|
return (FloatVar(NAME_AttackZOffset) + offset) * player->crouchfactor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 8 + offset;
|
|
|
|
}
|
|
|
|
|
2019-01-23 23:02:51 +00:00
|
|
|
}
|
|
|
|
|
2019-01-24 23:30:55 +00:00
|
|
|
inline DVector2 AActor::Vec2Offset(double dx, double dy, bool absolute)
|
|
|
|
{
|
|
|
|
if (absolute)
|
|
|
|
{
|
|
|
|
return { X() + dx, Y() + dy };
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-27 15:08:22 +00:00
|
|
|
return Level->GetPortalOffsetPosition(X(), Y(), dx, dy);
|
2019-01-24 23:30:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline DVector3 AActor::Vec2OffsetZ(double dx, double dy, double atz, bool absolute)
|
|
|
|
{
|
|
|
|
if (absolute)
|
|
|
|
{
|
|
|
|
return{ X() + dx, Y() + dy, atz };
|
|
|
|
}
|
2019-01-28 19:15:48 +00:00
|
|
|
else
|
2019-01-24 23:30:55 +00:00
|
|
|
{
|
2019-01-27 15:08:22 +00:00
|
|
|
DVector2 v = Level->GetPortalOffsetPosition(X(), Y(), dx, dy);
|
2019-01-24 23:30:55 +00:00
|
|
|
return DVector3(v, atz);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline DVector2 AActor::Vec2Angle(double length, DAngle angle, bool absolute)
|
|
|
|
{
|
|
|
|
if (absolute)
|
|
|
|
{
|
|
|
|
return{ X() + length * angle.Cos(), Y() + length * angle.Sin() };
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-27 15:08:22 +00:00
|
|
|
return Level->GetPortalOffsetPosition(X(), Y(), length*angle.Cos(), length*angle.Sin());
|
2019-01-24 23:30:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline DVector3 AActor::Vec3Offset(double dx, double dy, double dz, bool absolute)
|
|
|
|
{
|
|
|
|
if (absolute)
|
|
|
|
{
|
|
|
|
return { X() + dx, Y() + dy, Z() + dz };
|
|
|
|
}
|
|
|
|
else
|
2019-01-28 19:15:48 +00:00
|
|
|
{
|
2019-01-27 15:08:22 +00:00
|
|
|
DVector2 v = Level->GetPortalOffsetPosition(X(), Y(), dx, dy);
|
2019-01-24 23:30:55 +00:00
|
|
|
return DVector3(v, Z() + dz);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline DVector3 AActor::Vec3Offset(const DVector3 &ofs, bool absolute)
|
|
|
|
{
|
|
|
|
return Vec3Offset(ofs.X, ofs.Y, ofs.Z, absolute);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline DVector3 AActor::Vec3Angle(double length, DAngle angle, double dz, bool absolute)
|
|
|
|
{
|
|
|
|
if (absolute)
|
|
|
|
{
|
|
|
|
return{ X() + length * angle.Cos(), Y() + length * angle.Sin(), Z() + dz };
|
|
|
|
}
|
|
|
|
else
|
2019-01-28 19:15:48 +00:00
|
|
|
{
|
2019-01-27 15:08:22 +00:00
|
|
|
DVector2 v = Level->GetPortalOffsetPosition(X(), Y(), length*angle.Cos(), length*angle.Sin());
|
2019-01-24 23:30:55 +00:00
|
|
|
return DVector3(v, Z() + dz);
|
|
|
|
}
|
|
|
|
}
|
2019-01-28 19:15:48 +00:00
|
|
|
|
|
|
|
inline bool AActor::isFrozen()
|
|
|
|
{
|
|
|
|
if (!(flags5 & MF5_NOTIMEFREEZE))
|
|
|
|
{
|
|
|
|
auto state = Level->isFrozen();
|
|
|
|
if (state)
|
|
|
|
{
|
|
|
|
if (player == nullptr || player->Bot != nullptr) return true;
|
|
|
|
|
|
|
|
// This is the only place in the entire game where the two freeze flags need different treatment.
|
|
|
|
// The time freezer flag also freezes other players, the global setting does not.
|
|
|
|
|
|
|
|
if ((state & 1) && player->timefreezer == 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|