Skip to content

Commit

Permalink
bool CBaseEntity::IsMonster()
Browse files Browse the repository at this point in the history
return true on CBaseMonster that are not:
- CEnvExplosion
- CCycler
- CMonsterMaker
- CFurniture
- COp4Mortar
- CGunTarget
- CBasePlayer
- CTestHull
  • Loading branch information
Mikk155 committed Apr 2, 2024
1 parent 321388e commit fb192a0
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/game/server/entities/CBaseEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ class SINGLE_INHERITANCE CBaseEntity
virtual bool IsInWorld();
virtual bool IsPlayer() { return false; }
virtual bool IsNetClient() { return false; }
virtual bool IsMonster() { return false; }
virtual const char* TeamID() { return ""; }


Expand Down
3 changes: 3 additions & 0 deletions src/game/server/entities/NPCs/basemonster.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ class CBaseMonster : public CBaseToggle
void Listen();

bool IsAlive() override { return (pev->deadflag != DEAD_DEAD); }

bool IsMonster() override { return true; }

virtual bool ShouldFadeOnDeath();

// Basic Monster AI functions
Expand Down
1 change: 1 addition & 0 deletions src/game/server/entities/NPCs/monstermaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class CMonsterMaker : public CBaseMonster
DECLARE_DATAMAP();

public:
bool IsMonster() override { return false; }
void Spawn() override;
void Precache() override;
bool KeyValue(KeyValueData* pkvd) override;
Expand Down
1 change: 1 addition & 0 deletions src/game/server/entities/NPCs/scripted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,7 @@ bool CScriptedSentence::StartSentence(CBaseMonster* pTarget)
class CFurniture : public CBaseMonster
{
public:
bool IsMonster() override { return false; }
void OnCreate() override;

/**
Expand Down
1 change: 1 addition & 0 deletions src/game/server/entities/explode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class CEnvExplosion : public CBaseMonster
DECLARE_DATAMAP();

public:
bool IsMonster() override { return false; }
void Spawn() override;
void Smoke();
bool KeyValue(KeyValueData* pkvd) override;
Expand Down
2 changes: 2 additions & 0 deletions src/game/server/entities/h_cycler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class CCycler : public CBaseMonster
DECLARE_DATAMAP();

public:
bool IsMonster() override { return false; }
int ObjectCaps() override { return (CBaseEntity::ObjectCaps() | FCAP_IMPULSE_USE); }

/**
Expand Down Expand Up @@ -252,6 +253,7 @@ class CWreckage : public CBaseMonster
DECLARE_DATAMAP();

public:
bool IsMonster() override { return false; }
void Spawn() override;
void Precache() override;
void Think() override;
Expand Down
1 change: 1 addition & 0 deletions src/game/server/entities/op4mortar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ class COp4Mortar : public CBaseMonster
DECLARE_DATAMAP();

public:
bool IsMonster() override { return false; }
bool KeyValue(KeyValueData* pkvd) override;

void OnCreate() override;
Expand Down
1 change: 1 addition & 0 deletions src/game/server/entities/plats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2170,6 +2170,7 @@ class CGunTarget : public CBaseMonster
DECLARE_DATAMAP();

public:
bool IsMonster() override { return false; }
void OnCreate() override;
void Spawn() override;
void Activate() override;
Expand Down
1 change: 1 addition & 0 deletions src/game/server/entities/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class CBasePlayer : public CBaseMonster
DECLARE_DATAMAP();

public:
bool IsMonster() override { return false; }
// Spectator camera
/**
* @brief Find the next client in the game for this player to spectate
Expand Down
15 changes: 8 additions & 7 deletions src/game/server/nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,14 @@ bool CGraph::HandleLinkEnt(int iNode, entvars_t* pevLinkEnt, int afCapMask, NODE
// FindNearestLink - finds the connection (line) nearest
// the given point. Returns false if fails, or true if it
// has stuffed the index into the nearest link pool connection
// into the passed int pointer, and a bool telling whether or
// into the passed int pointer, and a bool telling whether or
// not the point is along the line into the passed bool pointer.
//=========================================================
int CGraph::FindNearestLink(const Vector& vecTestPoint, int* piNearestLink, bool* pfAlongLine)
{
int i, j;// loops

int iNearestLink;// index into the link pool, this is the nearest node at any time.
int iNearestLink;// index into the link pool, this is the nearest node at any time.
float flMinDist;// the distance of of the nearest case so far
float flDistToLine;// the distance of the current test case

Expand All @@ -289,7 +289,7 @@ int CGraph::FindNearestLink(const Vector& vecTestPoint, int* piNearestLink, bool

flMinDist = 9999;// anything will be closer than this

// go through all of the nodes, and each node's connections
// go through all of the nodes, and each node's connections
int cSkip = 0;// how many links proper pairing allowed us to skip
int cChecked = 0;// how many links were checked

Expand Down Expand Up @@ -323,15 +323,15 @@ int CGraph::FindNearestLink(const Vector& vecTestPoint, int* piNearestLink, bool
// these values need a little attention now and then, or sometimes ramps cause trouble.
if (fabs(vecSpot1.z - vecTestPoint.z) > 48 && fabs(vecSpot2.z - vecTestPoint.z) > 48)
{
// if both endpoints of the line are 32 units or more above or below the monster,
// if both endpoints of the line are 32 units or more above or below the monster,
// the monster won't be able to get to them, so we do a bit of trivial rejection here.
// this may change if monsters are allowed to jump down.
//
// this may change if monsters are allowed to jump down.
//
// !!!LATER: some kind of clever X/Y hashing should be used here, too
continue;
}

// now we have two endpoints for a line segment that we've not already checked.
// now we have two endpoints for a line segment that we've not already checked.
// since all lines that make it this far are within -/+ 32 units of the test point's
// Z Plane, we can get away with doing the point->line check in 2d.

Expand Down Expand Up @@ -1448,6 +1448,7 @@ class CTestHull : public CBaseMonster
DECLARE_DATAMAP();

public:
bool IsMonster() override { return false; }
void Spawn(CBaseEntity* masterNode);
int ObjectCaps() override { return CBaseMonster::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
void CallBuildNodeGraph();
Expand Down

0 comments on commit fb192a0

Please sign in to comment.