2017-03-10 01:22:42 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "actor.h"
|
|
|
|
#include "r_defs.h"
|
2019-04-17 13:10:11 +00:00
|
|
|
#include "g_levellocals.h"
|
2019-01-03 17:01:58 +00:00
|
|
|
#include "d_player.h"
|
2019-04-17 13:10:11 +00:00
|
|
|
|
2019-01-03 17:01:58 +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
|
|
|
|
{
|
|
|
|
return Pos() + Displacements.getOffset(Sector->PortalGroup, portalgroup);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline DVector3 AActor::PosRelative(const AActor *other) const
|
|
|
|
{
|
|
|
|
return Pos() + Displacements.getOffset(Sector->PortalGroup, other->Sector->PortalGroup);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline DVector3 AActor::PosRelative(sector_t *sec) const
|
|
|
|
{
|
|
|
|
return Pos() + Displacements.getOffset(Sector->PortalGroup, sec->PortalGroup);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
return Pos() + Displacements.getOffset(Sector->PortalGroup, line->frontsector->PortalGroup);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline DVector3 PosRelative(const DVector3 &pos, line_t *line, sector_t *refsec = NULL)
|
|
|
|
{
|
|
|
|
return pos + Displacements.getOffset(refsec->PortalGroup, line->frontsector->PortalGroup);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
return BobSin(FloatBobPhase + level.maptime + ticfrac) * FloatBobStrength;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
return level.gravity * Sector->gravity * Gravity * 0.00125;
|
|
|
|
}
|
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-28 19:15:48 +00:00
|
|
|
}
|
|
|
|
|
make various getter and pure-math methods clearscope, and where applicable, const
Original PR: https://github.com/coelckers/gzdoom/pull/532
Status of the original PR
1. Actor
- [already in] deltaangle
- [already in] absangle
- [already in] AngleToVector
- [already in] RotateVector
- [already in] Normalize180
- [already in] BobSin
- [already in] GetDefaultSpeed
- [this PR] GetBobOffset
- [this PR] InStateSequence
- [already in] FindState
- [already in] GetDropItems
- [this PR] DistanceBySpeed
- [this PR] AccuracyFactor
- [not in original PR, for PlayerInfo.isTotallyFrozen] isFrozen
2. PlayerInfo
- [this PR] GetUserName
- [this PR] GetColor
- [this PR] GetDisplayColor
- [this PR] GetColorSet
- [this PR] GetPlayerClassNum
- [this PR] GetSkin
- [this PR] GetNeverSwitch
- [this PR] GetGender
- [this PR] GetTeam
- [this PR] GetAutoaim
- [this PR] GetNoAutostartMap
- [this PR] GetClassicFlight
- [this PR] IsTotallyFrozen
3. C++ methods, to match ZScript:
- [scriptified] AActor::AccuracyFactor() to Actor.AccuracyFactor
- [this PR] AActor::DistanceBySpeed(AActor *, double) — it is a combination of getter and pure math
- [this PR] AActor::Distance2D(AActor *, bool) — called by DistanceBySpeed
- [this PR] AActor::Distance2D(AActor *, double, double, bool) — called by DistanceBySpeed
- [not in original PR, for PlayerInfo.isTotallyFrozen] AActor::isFrozen
# Conflicts:
# src/actor.h
# src/actorinlines.h
2020-06-07 06:47:27 +00:00
|
|
|
inline bool AActor::isFrozen() const
|
2019-01-28 19:15:48 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|