Connect events

This commit is contained in:
mittorn 2017-01-10 21:37:23 +00:00
parent 10d95581fa
commit 41136c6e30
6 changed files with 66 additions and 2 deletions

View File

@ -23,6 +23,7 @@
#include "cbase.h"
#include "doors.h"
#include "game.h"
#include "bot_exports.h"
extern void SetMovedir( entvars_t *ev );
#define noiseMoving noise1
@ -651,8 +652,12 @@ void CBaseDoor::DoorGoUp( void )
// emit door moving and stop sounds on CHAN_STATIC so that the multicast doesn't
// filter them out and leave a client stuck with looping door sounds!
if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) )
{
if( m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN )
EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ), 1, ATTN_NORM );
if( TheBots )
TheBots->OnEvent( EVENT_DOOR, m_hActivator );
}
m_toggle_state = TS_GOING_UP;
@ -735,8 +740,12 @@ void CBaseDoor::DoorHitTop( void )
void CBaseDoor::DoorGoDown( void )
{
if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) )
{
if( m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN )
EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ), 1, ATTN_NORM );
EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ), 1, ATTN_NORM );
if( TheBots )
TheBots->OnEvent( EVENT_DOOR, m_hActivator );
}
#ifdef DOOR_ASSERT
ASSERT( m_toggle_state == TS_AT_TOP );
#endif // DOOR_ASSERT

View File

@ -26,6 +26,7 @@
#include "func_break.h"
#include "decals.h"
#include "explode.h"
#include "bot_exports.h"
extern DLL_GLOBAL Vector g_vecAttackDir;
@ -605,6 +606,8 @@ void CBreakable::Die( void )
break;
}
cFlag = BREAK_GLASS;
if( TheBots )
TheBots->OnEvent( EVENT_BREAK_GLASS, this );
break;
case matWood:
switch( RANDOM_LONG( 0, 1 ) )
@ -617,6 +620,8 @@ void CBreakable::Die( void )
break;
}
cFlag = BREAK_WOOD;
if( TheBots )
TheBots->OnEvent( EVENT_BREAK_WOOD, this );
break;
case matComputer:
case matMetal:
@ -630,6 +635,8 @@ void CBreakable::Die( void )
break;
}
cFlag = BREAK_METAL;
if( TheBots )
TheBots->OnEvent( EVENT_BREAK_METAL, this );
break;
case matFlesh:
switch( RANDOM_LONG( 0, 1 ) )
@ -642,6 +649,8 @@ void CBreakable::Die( void )
break;
}
cFlag = BREAK_FLESH;
if( TheBots )
TheBots->OnEvent( EVENT_BREAK_FLESH, this );
break;
case matRocks:
case matCinderBlock:
@ -655,6 +664,8 @@ void CBreakable::Die( void )
break;
}
cFlag = BREAK_CONCRETE;
if( TheBots )
TheBots->OnEvent( EVENT_BREAK_CONCRETE, this );
break;
case matCeilingTile:
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustceiling.wav", fvol, ATTN_NORM, 0, pitch );

View File

@ -26,6 +26,7 @@
#include "nodes.h"
#include "soundent.h"
#include "decals.h"
#include "bot_exports.h"
//===================grenade
@ -180,6 +181,8 @@ void CGrenade::Detonate( void )
UTIL_TraceLine( vecSpot, vecSpot + Vector( 0, 0, -40 ), ignore_monsters, ENT(pev), &tr );
Explode( &tr, DMG_BLAST );
if( TheBots )
TheBots->OnEvent( EVENT_HE_GRENADE_EXPLODED, CBaseEntity::Instance( pev->owner ) );
}

View File

@ -806,6 +806,8 @@ void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer )
return;
}
if( TheBots )
TheBots->OnEvent( EVENT_PLAYER_SPAWNED, pPlayer );
g_fPause = false;
pPlayer->pev->weapons |= ( 1 << WEAPON_SUIT );
@ -880,6 +882,9 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller,
if( ktmp && (ktmp->Classify() == CLASS_PLAYER ) )
peKiller = (CBasePlayer*)ktmp;
if( TheBots )
TheBots->OnEvent( EVENT_PLAYER_DIED, pVictim, peKiller );
if( pVictim->pev == pKiller )
{
// killed self

View File

@ -35,7 +35,7 @@
#include "gamerules.h"
#include "game.h"
#include "hltv.h"
#include "bot_exports.h"
// #define DUCKFIX
extern DLL_GLOBAL ULONG g_ulModelIndexPlayer;
@ -486,6 +486,10 @@ int CBasePlayer::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl
// as an int (zero) and think the player is dead! (this will incite a clientside screentilt, etc)
fTookDamage = CBaseMonster::TakeDamage( pevInflictor, pevAttacker, (int)flDamage, bitsDamageType );
if( TheBots && fTookDamage > 0 )
TheBots->OnEvent( EVENT_PLAYER_TOOK_DAMAGE, this, pAttacker );
// reset damage time countdown for each type of time based damage player just sustained
{
for( int i = 0; i < CDMG_TIMEBASED; i++ )
@ -895,6 +899,9 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib )
// UNDONE: Put this in, but add FFADE_PERMANENT and make fade time 8.8 instead of 4.12
// UTIL_ScreenFade( edict(), Vector( 128, 0, 0 ), 6, 15, 255, FFADE_OUT | FFADE_MODULATE );
if( TheBots )
TheBots->OnEvent( EVENT_DEATH_CAMERA_START, this );
if( ( pev->health < -40 && iGib != GIB_NEVER ) || iGib == GIB_ALWAYS )
{
pev->solid = SOLID_NOT;
@ -1532,6 +1539,9 @@ void CBasePlayer::Jump()
{
pev->velocity = pev->velocity + pev->basevelocity;
}
if( TheBots )
TheBots->OnEvent( EVENT_PLAYER_JUMPED, this );
}
// This is a glorious hack to find free space when you've crouched into some solid space
@ -2532,6 +2542,8 @@ void CBasePlayer::PostThink()
{
TakeDamage( VARS( eoNullEntity ), VARS( eoNullEntity ), flFallDamage, DMG_FALL );
pev->punchangle.x = 0;
if( TheBots )
TheBots->OnEvent( EVENT_PLAYER_LANDED_FROM_HEIGHT, this);
}
}
@ -2557,7 +2569,12 @@ void CBasePlayer::PostThink()
if( !pev->velocity.x && !pev->velocity.y )
SetAnimation( PLAYER_IDLE );
else if( ( pev->velocity.x || pev->velocity.y ) && ( FBitSet( pev->flags, FL_ONGROUND ) ) )
{
SetAnimation( PLAYER_WALK );
if( TheBots )
if( pev->velocity.Length2D() > 220 )
TheBots->OnEvent( EVENT_PLAYER_FOOTSTEP, this );
}
else if( pev->waterlevel > 1 )
SetAnimation( PLAYER_WALK );
}

View File

@ -30,6 +30,7 @@
#include "soundent.h"
#include "decals.h"
#include "gamerules.h"
#include "bot_exports.h"
extern CGraph WorldGraph;
extern int gEvilImpulse101;
@ -708,6 +709,13 @@ void CBasePlayerWeapon::ItemPostFrame( void )
m_pPlayer->TabulateAmmo();
SecondaryAttack();
if( TheBots )
{
if( m_fFireOnEmpty )
TheBots->OnEvent( EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer );
else
TheBots->OnEvent( EVENT_WEAPON_FIRED, m_pPlayer );
}
m_pPlayer->pev->button &= ~IN_ATTACK2;
}
else if( ( m_pPlayer->pev->button & IN_ATTACK ) && CanAttack( m_flNextPrimaryAttack, gpGlobals->time, UseDecrement() ) )
@ -719,11 +727,20 @@ void CBasePlayerWeapon::ItemPostFrame( void )
m_pPlayer->TabulateAmmo();
PrimaryAttack();
if( TheBots )
{
if( m_fFireOnEmpty )
TheBots->OnEvent( EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer );
else
TheBots->OnEvent( EVENT_WEAPON_FIRED, m_pPlayer );
}
}
else if( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload )
{
// reload when reload is pressed, or if no buttons are down and weapon is empty.
Reload();
if( TheBots )
TheBots->OnEvent( EVENT_WEAPON_RELOADED, m_pPlayer );
}
else if( !( m_pPlayer->pev->button & ( IN_ATTACK | IN_ATTACK2 ) ) )
{
@ -745,6 +762,8 @@ void CBasePlayerWeapon::ItemPostFrame( void )
if( m_iClip == 0 && !(iFlags() & ITEM_FLAG_NOAUTORELOAD ) && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0 : gpGlobals->time ) )
{
Reload();
if( TheBots )
TheBots->OnEvent( EVENT_WEAPON_RELOADED, m_pPlayer );
return;
}
}