From 44ccc8a6e8b3a2b9084216cb1716b7e32a710b69 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 20 Sep 2016 00:40:05 +0500 Subject: [PATCH 1/7] Merge @malortie's patches for Times of Troubles. --- dlls/python.cpp | 11 +++- dlls/scientist.cpp | 75 +----------------------- dlls/scientist.h | 93 +++++++++++++++++++++++++++++ dlls/scripted.cpp | 26 +++++++++ dlls/tot/civ.cpp | 143 +++++++++++++++++++++++++++++++++++++++++++++ dlls/weapons.cpp | 7 +++ dlls/weapons.h | 5 ++ 7 files changed, 283 insertions(+), 77 deletions(-) create mode 100644 dlls/scientist.h create mode 100644 dlls/tot/civ.cpp diff --git a/dlls/python.cpp b/dlls/python.cpp index 7bb71325..cdd860cd 100644 --- a/dlls/python.cpp +++ b/dlls/python.cpp @@ -111,6 +111,8 @@ BOOL CPython::Deploy() pev->body = 0; } + m_flSoundDelay = 0; + return DefaultDeploy( "models/v_357.mdl", "models/p_357.mdl", PYTHON_DRAW, "python", UseDecrement(), pev->body ); } @@ -126,6 +128,8 @@ void CPython::Holster( int skiplocal /* = 0 */ ) m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); SendWeaponAnim( PYTHON_HOLSTER ); + + m_flSoundDelay = 0; } void CPython::SecondaryAttack( void ) @@ -227,9 +231,10 @@ void CPython::Reload( void ) #else bUseScope = g_pGameRules->IsMultiplayer(); #endif - if( DefaultReload( 6, PYTHON_RELOAD, 2.0, bUseScope ) ) + int iResult = DefaultReload( PYTHON_MAX_CLIP, PYTHON_RELOAD, 2.0, bUseScope ); + if( iResult ) { - m_flSoundDelay = 1.5; + m_flSoundDelay = gpGlobals->time + 1.5f; } } @@ -240,7 +245,7 @@ void CPython::WeaponIdle( void ) m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); // ALERT( at_console, "%.2f\n", gpGlobals->time - m_flSoundDelay ); - if( m_flSoundDelay != 0 && m_flSoundDelay <= UTIL_WeaponTimeBase() ) + if( m_flSoundDelay != 0 && ( m_flSoundDelay <= UTIL_WeaponTimeBase() || m_flSoundDelay <= gpGlobals->time ) ) { EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_reload1.wav", RANDOM_FLOAT( 0.8, 0.9 ), ATTN_NORM ); m_flSoundDelay = 0; diff --git a/dlls/scientist.cpp b/dlls/scientist.cpp index 4e60c58e..b27a156d 100644 --- a/dlls/scientist.cpp +++ b/dlls/scientist.cpp @@ -26,16 +26,7 @@ #include "scripted.h" #include "animation.h" #include "soundent.h" - -#define NUM_SCIENTIST_HEADS 4 // four heads available for scientist model - -enum -{ - HEAD_GLASSES = 0, - HEAD_EINSTEIN = 1, - HEAD_LUTHER = 2, - HEAD_SLICK = 3 -}; +#include "scientist.h" enum { @@ -68,56 +59,6 @@ enum //======================================================= // Scientist //======================================================= -class CScientist : public CTalkMonster -{ -public: - void Spawn( void ); - void Precache( void ); - - void SetYawSpeed( void ); - int Classify( void ); - void HandleAnimEvent( MonsterEvent_t *pEvent ); - void RunTask( Task_t *pTask ); - void StartTask( Task_t *pTask ); - int ObjectCaps( void ) { return CTalkMonster::ObjectCaps() | FCAP_IMPULSE_USE; } - int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); - virtual int FriendNumber( int arrayNumber ); - void SetActivity( Activity newActivity ); - Activity GetStoppedActivity( void ); - int ISoundMask( void ); - void DeclineFollowing( void ); - - float CoverRadius( void ) { return 1200; } // Need more room for cover because scientists want to get far away! - BOOL DisregardEnemy( CBaseEntity *pEnemy ) { return !pEnemy->IsAlive() || ( gpGlobals->time - m_fearTime ) > 15; } - - BOOL CanHeal( void ); - void Heal( void ); - void Scream( void ); - - // Override these to set behavior - Schedule_t *GetScheduleOfType( int Type ); - Schedule_t *GetSchedule( void ); - MONSTERSTATE GetIdealState( void ); - - void DeathSound( void ); - void PainSound( void ); - - void TalkInit( void ); - - void Killed( entvars_t *pevAttacker, int iGib ); - - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; - - CUSTOM_SCHEDULES - -private: - float m_painTime; - float m_healTime; - float m_fearTime; -}; - LINK_ENTITY_TO_CLASS( monster_scientist, CScientist ) TYPEDESCRIPTION CScientist::m_SaveData[] = @@ -1082,20 +1023,6 @@ int CScientist::FriendNumber( int arrayNumber ) //========================================================= // Dead Scientist PROP //========================================================= -class CDeadScientist : public CBaseMonster -{ -public: - void Spawn( void ); - int Classify( void ) - { - return CLASS_HUMAN_PASSIVE; - } - - void KeyValue( KeyValueData *pkvd ); - int m_iPose;// which sequence to display - static char *m_szPoses[7]; -}; - char *CDeadScientist::m_szPoses[] = { "lying_on_back", diff --git a/dlls/scientist.h b/dlls/scientist.h new file mode 100644 index 00000000..d8318b31 --- /dev/null +++ b/dlls/scientist.h @@ -0,0 +1,93 @@ +/*** +* +* 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. +* +* This source code contains proprietary and confidential information of +* Valve LLC and its suppliers. Access to this code is restricted to +* persons who have executed a written SDK license with Valve. Any access, +* use or distribution of this code by or to any unlicensed person is illegal. +* +****/ + +#ifndef SCIENTIST_H +#define SCIENTIST_H + + +#if defined ( TOT_DLL ) +#define NUM_SCIENTIST_HEADS 4 // four heads available for scientist model +enum { HEAD_GLASSES = 0, HEAD_EINSTEIN = 1, HEAD_LUTHER = 2, HEAD_SLICK = 3 }; + +//======================================================= +// Scientist +//======================================================= + +class CScientist : public CTalkMonster +{ +public: + virtual void Spawn(void); + virtual void Precache(void); + + void SetYawSpeed(void); + int Classify(void); + void HandleAnimEvent(MonsterEvent_t *pEvent); + void RunTask(Task_t *pTask); + void StartTask(Task_t *pTask); + int ObjectCaps(void) { return CTalkMonster::ObjectCaps() | FCAP_IMPULSE_USE; } + int TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); + virtual int FriendNumber(int arrayNumber); + void SetActivity(Activity newActivity); + Activity GetStoppedActivity(void); + int ISoundMask(void); + void DeclineFollowing(void); + + float CoverRadius(void) { return 1200; } // Need more room for cover because scientists want to get far away! + BOOL DisregardEnemy(CBaseEntity *pEnemy) { return !pEnemy->IsAlive() || (gpGlobals->time - m_fearTime) > 15; } + + virtual BOOL CanHeal(void); + void Heal(void); + void Scream(void); + + // Override these to set behavior + Schedule_t *GetScheduleOfType(int Type); + Schedule_t *GetSchedule(void); + MONSTERSTATE GetIdealState(void); + + void DeathSound(void); + void PainSound(void); + + void TalkInit(void); + + void Killed(entvars_t *pevAttacker, int iGib); + + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + static TYPEDESCRIPTION m_SaveData[]; + + CUSTOM_SCHEDULES; + +private: + float m_painTime; + float m_healTime; + float m_fearTime; +}; + +//========================================================= +// Dead Scientist PROP +//========================================================= +class CDeadScientist : public CBaseMonster +{ +public: + virtual void Spawn(void); + int Classify(void) { return CLASS_HUMAN_PASSIVE; } + + void KeyValue(KeyValueData *pkvd); + int m_iPose;// which sequence to display + static char *m_szPoses[7]; +}; +#endif // defined ( TOT_DLL ) + +#endif // SCIENTIST_H \ No newline at end of file diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index f3cf37c5..00fa7024 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -372,6 +372,32 @@ void CCineMonster::PossessEntity( void ) pTarget->pev->framerate = 0; } } + + // + // Fix a bug where barney would not run to the osprey on map 7. + // + if( FStrEq( STRING( gpGlobals->mapname ), "map7" ) ) + { + if( FStrEq(STRING( pev->target ), "jan_osprey15" ) ) + { + CCineMonster *pSeq = (CCineMonster*)UTIL_FindEntityByTargetname( NULL, "jan_osprey3" ); + if( pSeq ) + { + pTarget->m_pGoalEnt = pSeq; + pTarget->m_pCine = pSeq; + pTarget->m_hTargetEnt = pSeq; + + UTIL_SetOrigin( pTarget->pev, pSeq->pev->origin ); + pTarget->pev->ideal_yaw = pSeq->pev->angles.y; + pTarget->pev->avelocity = Vector( 0, 0, 0 ); + pTarget->pev->velocity = Vector( 0, 0, 0 ); + pTarget->pev->effects |= EF_NOINTERP; + pTarget->pev->angles.y = pSeq->pev->angles.y; + pTarget->m_scriptState = SCRIPT_WAIT; + m_startTime = gpGlobals->time + 1E6; + } + } + } } } diff --git a/dlls/tot/civ.cpp b/dlls/tot/civ.cpp new file mode 100644 index 00000000..8895f26f --- /dev/null +++ b/dlls/tot/civ.cpp @@ -0,0 +1,143 @@ +/*** +* +* 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. +* +* This source code contains proprietary and confidential information of +* Valve LLC and its suppliers. Access to this code is restricted to +* persons who have executed a written SDK license with Valve. Any access, +* use or distribution of this code by or to any unlicensed person is illegal. +* +****/ + +#include "extdll.h" +#include "util.h" +#include "cbase.h" +#include "monsters.h" +#include "talkmonster.h" +#include "schedule.h" +#include "defaultai.h" +#include "scripted.h" +#include "animation.h" +#include "soundent.h" +#include "scientist.h" + +class CCivScientist : public CScientist +{ +public: + void Spawn(void); + void Precache(void); + + BOOL CanHeal(void); +}; + +LINK_ENTITY_TO_CLASS(monster_civ, CCivScientist); + + +//========================================================= +// Spawn +//========================================================= +void CCivScientist::Spawn(void) +{ + Precache(); + + SET_MODEL(ENT(pev), "models/civ_sci.mdl"); + UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); + + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_STEP; + m_bloodColor = BLOOD_COLOR_RED; + pev->health = gSkillData.scientistHealth; + pev->view_ofs = Vector(0, 0, 50);// position of the eyes relative to monster's origin. + m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so scientists will notice player and say hello + m_MonsterState = MONSTERSTATE_NONE; + + // m_flDistTooFar = 256.0; + + m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_OPEN_DOORS | bits_CAP_AUTO_DOORS | bits_CAP_USE; + + // White hands + pev->skin = 0; + + if (pev->body == -1) + {// -1 chooses a random head + pev->body = RANDOM_LONG(0, NUM_SCIENTIST_HEADS - 1);// pick a head, any head + } + + // Luther is black, make his hands black + if (pev->body == HEAD_LUTHER) + pev->skin = 1; + + MonsterInit(); + SetUse(&CCivScientist::FollowerUse); +} + + +//========================================================= +// Precache - precaches all resources this monster needs +//========================================================= +void CCivScientist::Precache(void) +{ + CScientist::Precache(); + + PRECACHE_MODEL("models/civ_sci.mdl"); +} + +BOOL CCivScientist::CanHeal(void) +{ + return FALSE; +} + + +//========================================================= +// Dead Scientist PROP +//========================================================= +class CDeadCivScientist : public CDeadScientist +{ +public: + void Spawn(void); + + static char *m_szPoses[7]; +}; + +char *CDeadCivScientist::m_szPoses[] = { "lying_on_back", "lying_on_stomach", "dead_sitting", "dead_hang", "dead_table1", "dead_table2", "dead_table3" }; + +LINK_ENTITY_TO_CLASS(monster_civ_dead, CDeadCivScientist); + +// +// ********** DeadScientist SPAWN ********** +// +void CDeadCivScientist::Spawn() +{ + PRECACHE_MODEL("models/civ_sci.mdl"); + SET_MODEL(ENT(pev), "models/civ_sci.mdl"); + + pev->effects = 0; + pev->sequence = 0; + // Corpses have less health + pev->health = 8;//gSkillData.scientistHealth; + + m_bloodColor = BLOOD_COLOR_RED; + + if (pev->body == -1) + {// -1 chooses a random head + pev->body = RANDOM_LONG(0, NUM_SCIENTIST_HEADS - 1);// pick a head, any head + } + // Luther is black, make his hands black + if (pev->body == HEAD_LUTHER) + pev->skin = 1; + else + pev->skin = 0; + + pev->sequence = LookupSequence(m_szPoses[m_iPose]); + if (pev->sequence == -1) + { + ALERT(at_console, "Dead scientist with bad pose\n"); + } + + // pev->skin += 2; // use bloody skin -- UNDONE: Turn this back on when we have a bloody skin again! + MonsterInitDead(); +} diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 3e2ef386..8642955c 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -1527,3 +1527,10 @@ TYPEDESCRIPTION CSatchel::m_SaveData[] = }; IMPLEMENT_SAVERESTORE( CSatchel, CBasePlayerWeapon ) + +TYPEDESCRIPTION CPython::m_SaveData[] = +{ + DEFINE_FIELD( CPython, m_flSoundDelay, FIELD_TIME ), +}; + +IMPLEMENT_SAVERESTORE( CPython, CBasePlayerWeapon ) diff --git a/dlls/weapons.h b/dlls/weapons.h index 5112254a..6d677111 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -514,6 +514,11 @@ private: class CPython : public CBasePlayerWeapon { public: +#ifndef CLIENT_DLL + int Save( CSave &save ); + int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; +#endif void Spawn( void ); void Precache( void ); int iItemSlot( void ) { return 2; } From 32f262d8727bfc7bff4f321edba9efacb5dacf7e Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 20 Sep 2016 00:41:54 +0500 Subject: [PATCH 2/7] Update CMakeLists.txt. --- dlls/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index cc0063b4..5b705e20 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -29,6 +29,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LINUX -DCLIENT_WEAPONS -Dstricmp=strcasec set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") set (SVDLL_SOURCES + tot/civ.cpp agrunt.cpp airtank.cpp aflock.cpp From 98815c198b71adbc0e93b081441298fdc3a556eb Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 20 Sep 2016 00:43:34 +0500 Subject: [PATCH 3/7] Update Android.mk. --- dlls/Android.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/Android.mk b/dlls/Android.mk index 7f107a12..3430d815 100644 --- a/dlls/Android.mk +++ b/dlls/Android.mk @@ -124,6 +124,7 @@ LOCAL_SRC_FILES := agrunt.cpp airtank.cpp \ world.cpp \ xen.cpp \ zombie.cpp \ + tot/civ.cpp \ ../pm_shared/pm_debug.c \ ../pm_shared/pm_math.c \ ../pm_shared/pm_shared.c From 8607d227071fd7bd1e78ce6fa38f65b11ab17313 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 20 Sep 2016 00:52:10 +0500 Subject: [PATCH 4/7] Remove unneeded macro. --- dlls/scientist.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dlls/scientist.h b/dlls/scientist.h index d8318b31..a82d6ee9 100644 --- a/dlls/scientist.h +++ b/dlls/scientist.h @@ -16,10 +16,15 @@ #ifndef SCIENTIST_H #define SCIENTIST_H +#define NUM_SCIENTIST_HEADS 4 // four heads available for scientist model -#if defined ( TOT_DLL ) -#define NUM_SCIENTIST_HEADS 4 // four heads available for scientist model -enum { HEAD_GLASSES = 0, HEAD_EINSTEIN = 1, HEAD_LUTHER = 2, HEAD_SLICK = 3 }; +enum +{ + HEAD_GLASSES = 0, + HEAD_EINSTEIN = 1, + HEAD_LUTHER = 2, + HEAD_SLICK = 3 +}; //======================================================= // Scientist @@ -88,6 +93,5 @@ public: int m_iPose;// which sequence to display static char *m_szPoses[7]; }; -#endif // defined ( TOT_DLL ) -#endif // SCIENTIST_H \ No newline at end of file +#endif // SCIENTIST_H From 08cada116aa70872c482b8746defd5761ea50f96 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Fri, 9 Dec 2016 00:38:29 +0500 Subject: [PATCH 5/7] Remove unneeded check. --- dlls/python.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/python.cpp b/dlls/python.cpp index cdd860cd..f610bf32 100644 --- a/dlls/python.cpp +++ b/dlls/python.cpp @@ -245,7 +245,7 @@ void CPython::WeaponIdle( void ) m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); // ALERT( at_console, "%.2f\n", gpGlobals->time - m_flSoundDelay ); - if( m_flSoundDelay != 0 && ( m_flSoundDelay <= UTIL_WeaponTimeBase() || m_flSoundDelay <= gpGlobals->time ) ) + if( m_flSoundDelay != 0 && m_flSoundDelay <= UTIL_WeaponTimeBase() ) { EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_reload1.wav", RANDOM_FLOAT( 0.8, 0.9 ), ATTN_NORM ); m_flSoundDelay = 0; From 53722b448fce963fe81de24fdacc84cf693a7cb9 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 27 Dec 2017 00:54:18 +0500 Subject: [PATCH 6/7] Fix warning. --- dlls/tot/civ.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/tot/civ.cpp b/dlls/tot/civ.cpp index 8895f26f..a784e0e2 100644 --- a/dlls/tot/civ.cpp +++ b/dlls/tot/civ.cpp @@ -100,10 +100,10 @@ class CDeadCivScientist : public CDeadScientist public: void Spawn(void); - static char *m_szPoses[7]; + static const char *m_szPoses[7]; }; -char *CDeadCivScientist::m_szPoses[] = { "lying_on_back", "lying_on_stomach", "dead_sitting", "dead_hang", "dead_table1", "dead_table2", "dead_table3" }; +const char *CDeadCivScientist::m_szPoses[] = { "lying_on_back", "lying_on_stomach", "dead_sitting", "dead_hang", "dead_table1", "dead_table2", "dead_table3" }; LINK_ENTITY_TO_CLASS(monster_civ_dead, CDeadCivScientist); From 3027310741985a726c4ef31f77df0a49916a9bfa Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 14 Feb 2018 17:41:09 +0500 Subject: [PATCH 7/7] Merge https://github.com/malortie/halflife/pull/13 --- dlls/h_battery.cpp | 9 +++++++++ dlls/healthkit.cpp | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/dlls/h_battery.cpp b/dlls/h_battery.cpp index 976a5733..56d8d742 100644 --- a/dlls/h_battery.cpp +++ b/dlls/h_battery.cpp @@ -47,6 +47,7 @@ public: int m_iJuice; int m_iOn; // 0 = off, 1 = startup, 2 = going float m_flSoundTime; + BOOL m_bTriggerable; }; TYPEDESCRIPTION CRecharge::m_SaveData[] = @@ -56,6 +57,7 @@ TYPEDESCRIPTION CRecharge::m_SaveData[] = DEFINE_FIELD( CRecharge, m_iJuice, FIELD_INTEGER ), DEFINE_FIELD( CRecharge, m_iOn, FIELD_INTEGER ), DEFINE_FIELD( CRecharge, m_flSoundTime, FIELD_TIME ), + DEFINE_FIELD( CRecharge, m_bTriggerable, FIELD_BOOLEAN ) }; IMPLEMENT_SAVERESTORE( CRecharge, CBaseEntity ) @@ -92,6 +94,7 @@ void CRecharge::Spawn() UTIL_SetSize( pev, pev->mins, pev->maxs ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_iJuice = (int)gSkillData.suitchargerCapacity; + m_bTriggerable = !FStringNull( pev->target ); pev->frame = 0; } @@ -112,6 +115,11 @@ void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use if( m_iJuice <= 0 ) { pev->frame = 1; + if( m_bTriggerable ) + { + FireTargets( STRING( pev->target ), pActivator, this, USE_TOGGLE, 0 ); + m_bTriggerable = FALSE; + } Off(); } @@ -173,6 +181,7 @@ void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use void CRecharge::Recharge( void ) { m_iJuice = (int)gSkillData.suitchargerCapacity; + m_bTriggerable = !FStringNull( pev->target ); pev->frame = 0; SetThink( &CBaseEntity::SUB_DoNothing ); } diff --git a/dlls/healthkit.cpp b/dlls/healthkit.cpp index 99d53d35..172589f3 100644 --- a/dlls/healthkit.cpp +++ b/dlls/healthkit.cpp @@ -115,6 +115,7 @@ public: int m_iJuice; int m_iOn; // 0 = off, 1 = startup, 2 = going float m_flSoundTime; + BOOL m_bTriggerable; }; TYPEDESCRIPTION CWallHealth::m_SaveData[] = @@ -124,6 +125,7 @@ TYPEDESCRIPTION CWallHealth::m_SaveData[] = DEFINE_FIELD( CWallHealth, m_iJuice, FIELD_INTEGER ), DEFINE_FIELD( CWallHealth, m_iOn, FIELD_INTEGER ), DEFINE_FIELD( CWallHealth, m_flSoundTime, FIELD_TIME ), + DEFINE_FIELD( CWallHealth, m_bTriggerable, FIELD_BOOLEAN ) }; IMPLEMENT_SAVERESTORE( CWallHealth, CBaseEntity ) @@ -160,6 +162,7 @@ void CWallHealth::Spawn() UTIL_SetSize( pev, pev->mins, pev->maxs ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_iJuice = (int)gSkillData.healthchargerCapacity; + m_bTriggerable = !FStringNull( pev->target ); pev->frame = 0; } @@ -182,6 +185,11 @@ void CWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u // if there is no juice left, turn it off if( m_iJuice <= 0 ) { + if( m_bTriggerable ) + { + FireTargets( STRING( pev->target ), pActivator, this, USE_TOGGLE, 0 ); + m_bTriggerable = FALSE; + } pev->frame = 1; Off(); } @@ -231,6 +239,7 @@ void CWallHealth::Recharge( void ) { EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/medshot4.wav", 1.0, ATTN_NORM ); m_iJuice = (int)gSkillData.healthchargerCapacity; + m_bTriggerable = !FStringNull( pev->target ); pev->frame = 0; SetThink( &CBaseEntity::SUB_DoNothing ); }