2022-12-17 13:32:43 +01:00
|
|
|
/***
|
2013-08-30 13:34:05 -07:00
|
|
|
*
|
|
|
|
* Copyright (c) 1996-2001, Valve LLC. All rights reserved.
|
|
|
|
*
|
|
|
|
* This product contains software technology licensed from Id
|
|
|
|
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use, distribution, and modification of this source code and/or resulting
|
|
|
|
* object code is restricted to non-commercial enhancements to products from
|
|
|
|
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
|
|
* without written permission from Valve LLC.
|
|
|
|
*
|
|
|
|
****/
|
2021-11-18 19:17:53 +01:00
|
|
|
|
|
|
|
#pragma once
|
2013-08-30 13:34:05 -07:00
|
|
|
|
2021-11-28 16:54:48 +01:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
expRandom,
|
|
|
|
expDirected
|
|
|
|
} Explosions;
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
matGlass = 0,
|
|
|
|
matWood,
|
|
|
|
matMetal,
|
|
|
|
matFlesh,
|
|
|
|
matCinderBlock,
|
|
|
|
matCeilingTile,
|
|
|
|
matComputer,
|
|
|
|
matUnbreakableGlass,
|
|
|
|
matRocks,
|
|
|
|
matNone,
|
|
|
|
matLastMaterial
|
|
|
|
} Materials;
|
2013-08-30 13:34:05 -07:00
|
|
|
|
2021-11-28 16:54:48 +01:00
|
|
|
#define NUM_SHARDS 6 // this many shards spawned when breakable objects break;
|
2013-08-30 13:34:05 -07:00
|
|
|
|
|
|
|
class CBreakable : public CBaseDelay
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// basic functions
|
2021-03-05 23:07:22 +01:00
|
|
|
void Spawn() override;
|
|
|
|
void Precache() override;
|
2021-11-28 16:54:48 +01:00
|
|
|
bool KeyValue(KeyValueData* pkvd) override;
|
|
|
|
void EXPORT BreakTouch(CBaseEntity* pOther);
|
|
|
|
void Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value) override;
|
2021-03-05 20:54:33 +01:00
|
|
|
void DamageSound();
|
2013-08-30 13:34:05 -07:00
|
|
|
|
|
|
|
// breakables use an overridden takedamage
|
2021-11-28 16:54:48 +01:00
|
|
|
bool TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType) override;
|
2013-08-30 13:34:05 -07:00
|
|
|
// To spark when hit
|
2021-11-28 16:54:48 +01:00
|
|
|
void TraceAttack(entvars_t* pevAttacker, float flDamage, Vector vecDir, TraceResult* ptr, int bitsDamageType) override;
|
2013-08-30 13:34:05 -07:00
|
|
|
|
2021-11-19 14:31:11 +01:00
|
|
|
bool IsBreakable();
|
|
|
|
bool SparkWhenHit();
|
2013-08-30 13:34:05 -07:00
|
|
|
|
2021-11-28 16:54:48 +01:00
|
|
|
int DamageDecal(int bitsDamageType) override;
|
2013-08-30 13:34:05 -07:00
|
|
|
|
2021-11-28 16:54:48 +01:00
|
|
|
void EXPORT Die();
|
2021-11-29 20:31:17 +01:00
|
|
|
int ObjectCaps() override { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); }
|
2021-11-28 16:54:48 +01:00
|
|
|
bool Save(CSave& save) override;
|
|
|
|
bool Restore(CRestore& restore) override;
|
2013-08-30 13:34:05 -07:00
|
|
|
|
2021-11-28 16:54:48 +01:00
|
|
|
inline bool Explodable() { return ExplosionMagnitude() > 0; }
|
|
|
|
inline int ExplosionMagnitude() { return pev->impulse; }
|
|
|
|
inline void ExplosionSetMagnitude(int magnitude) { pev->impulse = magnitude; }
|
2013-08-30 13:34:05 -07:00
|
|
|
|
2021-11-28 16:54:48 +01:00
|
|
|
static void MaterialSoundPrecache(Materials precacheMaterial);
|
|
|
|
static void MaterialSoundRandom(edict_t* pEdict, Materials soundMaterial, float volume);
|
|
|
|
static const char** MaterialSoundList(Materials precacheMaterial, int& soundCount);
|
2013-08-30 13:34:05 -07:00
|
|
|
|
2021-11-28 16:54:48 +01:00
|
|
|
static const char* pSoundsWood[];
|
|
|
|
static const char* pSoundsFlesh[];
|
|
|
|
static const char* pSoundsGlass[];
|
|
|
|
static const char* pSoundsMetal[];
|
|
|
|
static const char* pSoundsConcrete[];
|
|
|
|
static const char* pSpawnObjects[];
|
2013-08-30 13:34:05 -07:00
|
|
|
|
2021-11-28 16:54:48 +01:00
|
|
|
static TYPEDESCRIPTION m_SaveData[];
|
2013-08-30 13:34:05 -07:00
|
|
|
|
2021-11-28 16:54:48 +01:00
|
|
|
Materials m_Material;
|
|
|
|
Explosions m_Explosion;
|
|
|
|
int m_idShard;
|
|
|
|
float m_angle;
|
|
|
|
int m_iszGibModel;
|
|
|
|
int m_iszSpawnObject;
|
2013-08-30 13:34:05 -07:00
|
|
|
};
|