Skip to content

Commit

Permalink
Add Drop to Floor flag for xen plants
Browse files Browse the repository at this point in the history
  • Loading branch information
RedSprend committed Dec 1, 2024
1 parent fd8f837 commit 025fad9
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
9 changes: 9 additions & 0 deletions dlls/monster/CActAnimating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ void CActAnimating::SetActivity(Activity act)
ResetSequenceInfo();
}
}

void CActAnimating::DropToFloor()
{
if( DROP_TO_FLOOR(ENT( pev ) ) == 0 )
{
ALERT(at_error, "Entity %s fell out of level at %f,%f,%f\n", STRING( pev->classname ), pev->origin.x, pev->origin.y, pev->origin.z);
UTIL_Remove( this );
}
}
4 changes: 4 additions & 0 deletions dlls/monster/CActAnimating.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once
#include "CBaseAnimating.h"

#define SF_XEN_PLANT_DROP_TO_FLOOR 2

class CActAnimating : public CBaseAnimating
{
public:
Expand All @@ -13,6 +15,8 @@ class CActAnimating : public CBaseAnimating
virtual int Restore(CRestore& restore);
static TYPEDESCRIPTION m_SaveData[];

protected:
void DropToFloor();
private:
Activity m_Activity;
};
3 changes: 3 additions & 0 deletions dlls/monster/CXenHair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ void CXenHair::Spawn(void)
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NONE;
pev->nextthink = gpGlobals->time + RANDOM_FLOAT(0.1, 0.4); // Load balance these a bit

if (FBitSet(pev->spawnflags, SF_XEN_PLANT_DROP_TO_FLOOR))
DropToFloor();
}


Expand Down
10 changes: 8 additions & 2 deletions dlls/monster/CXenPLight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "effects.h"
#include "CActAnimating.h"

#define SF_XEN_PLATN_LIGHT_IGNORE_PLAYER 64
#define SF_XEN_PLANT_LIGHT_IGNORE_PLAYER 64

#define XEN_PLANT_GLOW_SPRITE "sprites/flare3.spr"
#define XEN_PLANT_HIDE_TIME 5
Expand Down Expand Up @@ -49,6 +49,12 @@ void CXenPLight::Spawn(void)
SetActivity(ACT_IDLE);
pev->nextthink = gpGlobals->time + 0.1;
pev->frame = RANDOM_FLOAT(0, 255);

if (FBitSet(pev->spawnflags, SF_XEN_PLANT_DROP_TO_FLOOR))
DropToFloor();

if (FBitSet(pev->flags, FL_KILLME))
return;

m_pGlow = CSprite::SpriteCreate(XEN_PLANT_GLOW_SPRITE, pev->origin + Vector(0, 0, (pev->mins.z + pev->maxs.z) * 0.5), FALSE);
m_pGlow->SetTransparency(kRenderGlow, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, pev->renderamt, pev->renderfx);
Expand Down Expand Up @@ -100,7 +106,7 @@ void CXenPLight::Think(void)

void CXenPLight::Touch(CBaseEntity* pOther)
{
if( !FBitSet(pev->spawnflags, SF_XEN_PLATN_LIGHT_IGNORE_PLAYER) && pOther->IsPlayer() )
if( !FBitSet(pev->spawnflags, SF_XEN_PLANT_LIGHT_IGNORE_PLAYER) && pOther->IsPlayer() )
{
pev->dmgtime = gpGlobals->time + XEN_PLANT_HIDE_TIME;
if (GetActivity() == ACT_IDLE || GetActivity() == ACT_STAND)
Expand Down
3 changes: 3 additions & 0 deletions dlls/monster/CXenSpore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ void CXenSpore::Spawn(void)
pev->framerate = RANDOM_FLOAT(0.7, 1.4);
ResetSequenceInfo();
pev->nextthink = gpGlobals->time + RANDOM_FLOAT(0.1, 0.4); // Load balance these a bit

if (FBitSet(pev->spawnflags, SF_XEN_PLANT_DROP_TO_FLOOR))
DropToFloor();
}

const char* CXenSpore::pModelNames[] =
Expand Down
6 changes: 6 additions & 0 deletions dlls/monster/CXenTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ void CXenTree::Spawn(void)
pev->frame = RANDOM_FLOAT(0, 255);
pev->framerate = RANDOM_FLOAT(0.7, 1.4);

if (FBitSet(pev->spawnflags, SF_XEN_PLANT_DROP_TO_FLOOR))
DropToFloor();

if (FBitSet(pev->flags, FL_KILLME))
return;

Vector triggerPosition;
UTIL_MakeVectorsPrivate(pev->angles, triggerPosition, NULL, NULL);
triggerPosition = pev->origin + (triggerPosition * 64);
Expand Down

0 comments on commit 025fad9

Please sign in to comment.