/* * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, the author gives permission to * link the code of this program with the Half-Life Game Engine ("HL * Engine") and Modified Game Libraries ("MODs") developed by Valve, * L.L.C ("Valve"). You must obey the GNU General Public License in all * respects for all of the code used other than the HL Engine and MODs * from Valve. If you modify this file, you may extend this exception * to your version of the file, but you are not obligated to do so. If * you do not wish to do so, delete this exception statement from your * version. * */ #pragma once // this many shards spawned when breakable objects break; #define NUM_SHARDS 6 // func breakable #define SF_BREAK_TRIGGER_ONLY 1 // may only be broken by trigger #define SF_BREAK_TOUCH 2 // can be 'crashed through' by running player (plate glass) #define SF_BREAK_PRESSURE 4 // can be broken by a player standing on it #define SF_BREAK_CROWBAR 256 // instant break if hit with crowbar // func_pushable (it's also func_breakable, so don't collide with those flags) #define SF_PUSH_BREAKABLE 128 typedef enum { expRandom = 0, expDirected, } Explosions; typedef enum { matGlass = 0, matWood, matMetal, matFlesh, matCinderBlock, matCeilingTile, matComputer, matUnbreakableGlass, matRocks, matNone, matLastMaterial, } Materials; class CBreakable: public CBaseDelay { public: // basic functions virtual void Spawn() = 0; virtual void Precache() = 0; virtual void Restart() = 0; virtual void KeyValue(KeyValueData *pkvd) = 0; virtual int Save(CSave &save) = 0; virtual int Restore(CRestore &restore) = 0; virtual int ObjectCaps() = 0; // To spark when hit virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) = 0; // breakables use an overridden takedamage virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; virtual int DamageDecal(int bitsDamageType) = 0; virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; public: BOOL Explodable() const { return ExplosionMagnitude() > 0; } int ExplosionMagnitude() const { return pev->impulse; } void ExplosionSetMagnitude(int magnitude) { pev->impulse = magnitude; } public: Materials m_Material; Explosions m_Explosion; int m_idShard; float m_angle; int m_iszGibModel; int m_iszSpawnObject; float m_flHealth; }; class CPushable: public CBreakable { public: virtual void Spawn() = 0; virtual void Precache() = 0; virtual void Restart() = 0; virtual void KeyValue(KeyValueData *pkvd) = 0; virtual int Save(CSave &save) = 0; virtual int Restore(CRestore &restore) = 0; virtual int ObjectCaps() = 0; virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; virtual void Touch(CBaseEntity *pOther) = 0; virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; public: float MaxSpeed() const { return m_maxSpeed; } public: int m_lastSound; float m_maxSpeed; float m_soundTime; };