Portable Half-Life SDK. GoldSource and Xash3D. Crossplatform.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1411 lines
34 KiB

7 years ago
/***
*
* Copyright (c) 1996-2002, 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.
*
****/
#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD )
//=========================================================
// CONTROLLER
//=========================================================
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "effects.h"
#include "schedule.h"
#include "weapons.h"
#include "squadmonster.h"
#include "scripted.h"
//=========================================================
// Monster's Anim Events Go Here
//=========================================================
8 years ago
#define CONTROLLER_AE_HEAD_OPEN 1
#define CONTROLLER_AE_BALL_SHOOT 2
#define CONTROLLER_AE_SMALL_SHOOT 3
#define CONTROLLER_AE_POWERUP_FULL 4
#define CONTROLLER_AE_POWERUP_HALF 5
7 years ago
#define CONTROLLER_FLINCH_DELAY 2 // at most one flinch every n secs
class CController : public CSquadMonster
{
public:
8 years ago
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
7 years ago
void Spawn( void );
void Precache( void );
void UpdateOnRemove();
7 years ago
void SetYawSpeed( void );
8 years ago
int Classify( void );
7 years ago
void HandleAnimEvent( MonsterEvent_t *pEvent );
void RunAI( void );
8 years ago
BOOL CheckRangeAttack1( float flDot, float flDist ); // balls
BOOL CheckRangeAttack2( float flDot, float flDist ); // head
BOOL CheckMeleeAttack1( float flDot, float flDist ); // block, throw
Schedule_t *GetSchedule( void );
Schedule_t *GetScheduleOfType( int Type );
void StartTask( Task_t *pTask );
void RunTask( Task_t *pTask );
CUSTOM_SCHEDULES
7 years ago
void Stop( void );
8 years ago
void Move( float flInterval );
int CheckLocalMove( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist );
7 years ago
void MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval );
8 years ago
void SetActivity( Activity NewActivity );
7 years ago
BOOL ShouldAdvanceRoute( float flWaypointDist );
8 years ago
int LookupFloat();
7 years ago
float m_flNextFlinch;
float m_flShootTime;
float m_flShootEnd;
void PainSound( void );
void AlertSound( void );
void IdleSound( void );
void AttackSound( void );
void DeathSound( void );
static const char *pAttackSounds[];
static const char *pIdleSounds[];
static const char *pAlertSounds[];
static const char *pPainSounds[];
static const char *pDeathSounds[];
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
void Killed( entvars_t *pevAttacker, int iGib );
void GibMonster( void );
CSprite *m_pBall[2]; // hand balls
8 years ago
int m_iBall[2]; // how bright it should be
7 years ago
float m_iBallTime[2]; // when it should be that color
int m_iBallCurrent[2]; // current brightness
Vector m_vecEstVelocity;
Vector m_velocity;
int m_fInCombat;
};
LINK_ENTITY_TO_CLASS( monster_alien_controller, CController )
7 years ago
8 years ago
TYPEDESCRIPTION CController::m_SaveData[] =
7 years ago
{
DEFINE_ARRAY( CController, m_pBall, FIELD_CLASSPTR, 2 ),
DEFINE_ARRAY( CController, m_iBall, FIELD_INTEGER, 2 ),
DEFINE_ARRAY( CController, m_iBallTime, FIELD_TIME, 2 ),
DEFINE_ARRAY( CController, m_iBallCurrent, FIELD_INTEGER, 2 ),
DEFINE_FIELD( CController, m_vecEstVelocity, FIELD_VECTOR ),
};
IMPLEMENT_SAVERESTORE( CController, CSquadMonster )
7 years ago
8 years ago
const char *CController::pAttackSounds[] =
7 years ago
{
"controller/con_attack1.wav",
"controller/con_attack2.wav",
"controller/con_attack3.wav",
};
8 years ago
const char *CController::pIdleSounds[] =
7 years ago
{
"controller/con_idle1.wav",
"controller/con_idle2.wav",
"controller/con_idle3.wav",
"controller/con_idle4.wav",
"controller/con_idle5.wav",
};
8 years ago
const char *CController::pAlertSounds[] =
7 years ago
{
"controller/con_alert1.wav",
"controller/con_alert2.wav",
"controller/con_alert3.wav",
};
8 years ago
const char *CController::pPainSounds[] =
7 years ago
{
"controller/con_pain1.wav",
"controller/con_pain2.wav",
"controller/con_pain3.wav",
};
8 years ago
const char *CController::pDeathSounds[] =
7 years ago
{
"controller/con_die1.wav",
"controller/con_die2.wav",
};
//=========================================================
// Classify - indicates this monster's place in the
// relationship table.
//=========================================================
8 years ago
int CController::Classify( void )
7 years ago
{
return m_iClass?m_iClass:CLASS_ALIEN_MILITARY;
}
//=========================================================
// SetYawSpeed - allows each sequence to have a different
// turn rate associated with it.
//=========================================================
8 years ago
void CController::SetYawSpeed( void )
7 years ago
{
int ys;
ys = 120;
#if 0
switch ( m_Activity )
{
}
#endif
pev->yaw_speed = ys;
}
8 years ago
int CController::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
7 years ago
{
// HACK HACK -- until we fix this.
8 years ago
if( IsAlive() )
7 years ago
PainSound();
return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
}
void CController::Killed( entvars_t *pevAttacker, int iGib )
{
// shut off balls
/*
m_iBall[0] = 0;
m_iBallTime[0] = gpGlobals->time + 4.0;
m_iBall[1] = 0;
m_iBallTime[1] = gpGlobals->time + 4.0;
*/
// fade balls
8 years ago
if( m_pBall[0] )
7 years ago
{
m_pBall[0]->SUB_StartFadeOut();
m_pBall[0] = NULL;
}
8 years ago
if( m_pBall[1] )
7 years ago
{
m_pBall[1]->SUB_StartFadeOut();
m_pBall[1] = NULL;
}
CSquadMonster::Killed( pevAttacker, iGib );
}
void CController::GibMonster( void )
{
// delete balls
8 years ago
if( m_pBall[0] )
7 years ago
{
UTIL_Remove( m_pBall[0] );
m_pBall[0] = NULL;
}
8 years ago
if( m_pBall[1] )
7 years ago
{
UTIL_Remove( m_pBall[1] );
m_pBall[1] = NULL;
}
8 years ago
CSquadMonster::GibMonster();
7 years ago
}
8 years ago
void CController::PainSound( void )
7 years ago
{
8 years ago
if( RANDOM_LONG( 0, 5 ) < 2 )
7 years ago
EMIT_SOUND_ARRAY_DYN( CHAN_VOICE, pPainSounds );
}
8 years ago
void CController::AlertSound( void )
7 years ago
{
EMIT_SOUND_ARRAY_DYN( CHAN_VOICE, pAlertSounds );
}
8 years ago
void CController::IdleSound( void )
7 years ago
{
EMIT_SOUND_ARRAY_DYN( CHAN_VOICE, pIdleSounds );
}
8 years ago
void CController::AttackSound( void )
7 years ago
{
EMIT_SOUND_ARRAY_DYN( CHAN_VOICE, pAttackSounds );
}
8 years ago
void CController::DeathSound( void )
7 years ago
{
EMIT_SOUND_ARRAY_DYN( CHAN_VOICE, pDeathSounds );
}
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
8 years ago
void CController::HandleAnimEvent( MonsterEvent_t *pEvent )
7 years ago
{
switch( pEvent->event )
{
case CONTROLLER_AE_HEAD_OPEN:
{
Vector vecStart, angleGun;
8 years ago
7 years ago
GetAttachment( 0, vecStart, angleGun );
8 years ago
7 years ago
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_ELIGHT );
8 years ago
WRITE_SHORT( entindex() + 0x1000 ); // entity, attachment
7 years ago
WRITE_COORD( vecStart.x ); // origin
WRITE_COORD( vecStart.y );
WRITE_COORD( vecStart.z );
WRITE_COORD( 1 ); // radius
WRITE_BYTE( 255 ); // R
WRITE_BYTE( 192 ); // G
WRITE_BYTE( 64 ); // B
WRITE_BYTE( 20 ); // life * 10
WRITE_COORD( -32 ); // decay
MESSAGE_END();
m_iBall[0] = 192;
m_iBallTime[0] = gpGlobals->time + atoi( pEvent->options ) / 15.0;
m_iBall[1] = 255;
m_iBallTime[1] = gpGlobals->time + atoi( pEvent->options ) / 15.0;
}
break;
case CONTROLLER_AE_BALL_SHOOT:
{
Vector vecStart, angleGun;
GetAttachment( 0, vecStart, angleGun );
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_ELIGHT );
8 years ago
WRITE_SHORT( entindex() + 0x1000 ); // entity, attachment
7 years ago
WRITE_COORD( 0 ); // origin
WRITE_COORD( 0 );
WRITE_COORD( 0 );
WRITE_COORD( 32 ); // radius
WRITE_BYTE( 255 ); // R
WRITE_BYTE( 192 ); // G
WRITE_BYTE( 64 ); // B
WRITE_BYTE( 10 ); // life * 10
WRITE_COORD( 32 ); // decay
MESSAGE_END();
CBaseMonster *pBall = (CBaseMonster*)Create( "controller_head_ball", vecStart, pev->angles, edict() );
pBall->pev->velocity = Vector( 0, 0, 32 );
if (m_pCine)
{
pBall->m_hEnemy = m_hTargetEnt;
}
else
{
9 years ago
pBall->m_hEnemy = m_hEnemy;
7 years ago
}
m_iBall[0] = 0;
m_iBall[1] = 0;
}
break;
case CONTROLLER_AE_SMALL_SHOOT:
{
8 years ago
AttackSound();
7 years ago
m_flShootTime = gpGlobals->time;
m_flShootEnd = m_flShootTime + atoi( pEvent->options ) / 15.0;
}
break;
case CONTROLLER_AE_POWERUP_FULL:
{
m_iBall[0] = 255;
m_iBallTime[0] = gpGlobals->time + atoi( pEvent->options ) / 15.0;
m_iBall[1] = 255;
m_iBallTime[1] = gpGlobals->time + atoi( pEvent->options ) / 15.0;
}
break;
case CONTROLLER_AE_POWERUP_HALF:
{
m_iBall[0] = 192;
m_iBallTime[0] = gpGlobals->time + atoi( pEvent->options ) / 15.0;
m_iBall[1] = 192;
m_iBallTime[1] = gpGlobals->time + atoi( pEvent->options ) / 15.0;
}
break;
default:
CBaseMonster::HandleAnimEvent( pEvent );
break;
}
}
//=========================================================
// Spawn
//=========================================================
8 years ago
void CController::Spawn()
7 years ago
{
8 years ago
Precache();
7 years ago
if (pev->model)
SET_MODEL(ENT(pev), STRING(pev->model)); //LRC
else
8 years ago
SET_MODEL( ENT( pev ), "models/controller.mdl" );
UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) );
7 years ago
8 years ago
pev->solid = SOLID_SLIDEBOX;
7 years ago
pev->movetype = MOVETYPE_FLY;
8 years ago
pev->flags |= FL_FLY;
7 years ago
m_bloodColor = BLOOD_COLOR_GREEN;
if (pev->health == 0)
8 years ago
pev->health = gSkillData.controllerHealth;
7 years ago
pev->view_ofs = Vector( 0, 0, -2 );// position of the eyes relative to monster's origin.
m_flFieldOfView = VIEW_FIELD_FULL;// indicates the width of this monster's forward view cone ( as a dotproduct result )
m_MonsterState = MONSTERSTATE_NONE;
MonsterInit();
}
//=========================================================
// Precache - precaches all resources this monster needs
//=========================================================
8 years ago
void CController::Precache()
7 years ago
{
if (pev->model)
PRECACHE_MODEL(STRING(pev->model)); //LRC
7 years ago
else
8 years ago
PRECACHE_MODEL( "models/controller.mdl" );
7 years ago
PRECACHE_SOUND_ARRAY( pAttackSounds );
PRECACHE_SOUND_ARRAY( pIdleSounds );
PRECACHE_SOUND_ARRAY( pAlertSounds );
PRECACHE_SOUND_ARRAY( pPainSounds );
PRECACHE_SOUND_ARRAY( pDeathSounds );
8 years ago
PRECACHE_MODEL( "sprites/xspark4.spr" );
7 years ago
UTIL_PrecacheOther( "controller_energy_ball" );
UTIL_PrecacheOther( "controller_head_ball" );
}
void CController::UpdateOnRemove()
{
CBaseEntity::UpdateOnRemove();
if( m_pBall[0] )
{
UTIL_Remove( m_pBall[0] );
m_pBall[0] = 0;
}
if( m_pBall[1] )
{
UTIL_Remove( m_pBall[1] );
m_pBall[1] = 0;
}
}
7 years ago
//=========================================================
// AI Schedules Specific to this monster
//=========================================================
// Chase enemy schedule
8 years ago
Task_t tlControllerChaseEnemy[] =
7 years ago
{
8 years ago
{ TASK_GET_PATH_TO_ENEMY, (float)128 },
{ TASK_WAIT_FOR_MOVEMENT, (float)0 },
7 years ago
};
Schedule_t slControllerChaseEnemy[] =
{
8 years ago
{
7 years ago
tlControllerChaseEnemy,
8 years ago
ARRAYSIZE( tlControllerChaseEnemy ),
bits_COND_NEW_ENEMY |
7 years ago
bits_COND_TASK_FAILED,
0,
"ControllerChaseEnemy"
},
};
8 years ago
Task_t tlControllerStrafe[] =
7 years ago
{
8 years ago
{ TASK_WAIT, (float)0.2 },
{ TASK_GET_PATH_TO_ENEMY, (float)128 },
{ TASK_WAIT_FOR_MOVEMENT, (float)0 },
{ TASK_WAIT, (float)1 },
7 years ago
};
8 years ago
Schedule_t slControllerStrafe[] =
7 years ago
{
8 years ago
{
7 years ago
tlControllerStrafe,
8 years ago
ARRAYSIZE( tlControllerStrafe ),
7 years ago
bits_COND_NEW_ENEMY,
0,
"ControllerStrafe"
},
};
8 years ago
Task_t tlControllerTakeCover[] =
7 years ago
{
8 years ago
{ TASK_WAIT, (float)0.2 },
{ TASK_FIND_COVER_FROM_ENEMY, (float)0 },
{ TASK_WAIT_FOR_MOVEMENT, (float)0 },
{ TASK_WAIT, (float)1 },
7 years ago
};
8 years ago
Schedule_t slControllerTakeCover[] =
7 years ago
{
8 years ago
{
7 years ago
tlControllerTakeCover,
8 years ago
ARRAYSIZE( tlControllerTakeCover ),
7 years ago
bits_COND_NEW_ENEMY,
0,
"ControllerTakeCover"
},
};
8 years ago
Task_t tlControllerFail[] =
7 years ago
{
8 years ago
{ TASK_STOP_MOVING, 0 },
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
{ TASK_WAIT, (float)2 },
{ TASK_WAIT_PVS, (float)0 },
7 years ago
};
8 years ago
Schedule_t slControllerFail[] =
7 years ago
{
{
tlControllerFail,
8 years ago
ARRAYSIZE( tlControllerFail ),
7 years ago
0,
0,
"ControllerFail"
},
};
DEFINE_CUSTOM_SCHEDULES( CController )
{
slControllerChaseEnemy,
slControllerStrafe,
slControllerTakeCover,
slControllerFail,
};
IMPLEMENT_CUSTOM_SCHEDULES( CController, CSquadMonster )
7 years ago
//=========================================================
// StartTask
//=========================================================
8 years ago
void CController::StartTask( Task_t *pTask )
7 years ago
{
8 years ago
switch( pTask->iTask )
7 years ago
{
case TASK_RANGE_ATTACK1:
8 years ago
CSquadMonster::StartTask( pTask );
7 years ago
break;
case TASK_GET_PATH_TO_ENEMY_LKP:
{
8 years ago
if( BuildNearestRoute( m_vecEnemyLKP, pev->view_ofs, pTask->flData, (m_vecEnemyLKP - pev->origin).Length() + 1024 ) )
7 years ago
{
TaskComplete();
}
else
{
// no way to get there =(
8 years ago
ALERT( at_aiconsole, "GetPathToEnemyLKP failed!!\n" );
7 years ago
TaskFail();
}
break;
}
case TASK_GET_PATH_TO_ENEMY:
{
CBaseEntity *pEnemy = m_hEnemy;
8 years ago
if( pEnemy == NULL )
7 years ago
{
TaskFail();
return;
}
8 years ago
if( BuildNearestRoute( pEnemy->pev->origin, pEnemy->pev->view_ofs, pTask->flData, ( pEnemy->pev->origin - pev->origin).Length() + 1024 ) )
7 years ago
{
TaskComplete();
}
else
{
// no way to get there =(
8 years ago
ALERT( at_aiconsole, "GetPathToEnemy failed!!\n" );
7 years ago
TaskFail();
}
break;
}
default:
8 years ago
CSquadMonster::StartTask( pTask );
7 years ago
break;
}
}
Vector Intersect( Vector vecSrc, Vector vecDst, Vector vecMove, float flSpeed )
{
Vector vecTo = vecDst - vecSrc;
float a = DotProduct( vecMove, vecMove ) - flSpeed * flSpeed;
8 years ago
float b = 0 * DotProduct( vecTo, vecMove ); // why does this work?
7 years ago
float c = DotProduct( vecTo, vecTo );
float t;
8 years ago
if( a == 0 )
7 years ago
{
8 years ago
t = c / ( flSpeed * flSpeed );
7 years ago
}
else
{
t = b * b - 4 * a * c;
8 years ago
t = sqrt( t ) / ( 2.0 * a );
7 years ago
float t1 = -b +t;
float t2 = -b -t;
8 years ago
if( t1 < 0 || t2 < t1 )
7 years ago
t = t2;
else
t = t1;
}
// ALERT( at_console, "Intersect %f\n", t );
8 years ago
if( t < 0.1 )
7 years ago
t = 0.1;
8 years ago
if( t > 10.0 )
7 years ago
t = 10.0;
Vector vecHit = vecTo + vecMove * t;
8 years ago
return vecHit.Normalize() * flSpeed;
7 years ago
}
8 years ago
int CController::LookupFloat()
7 years ago
{
8 years ago
if( m_velocity.Length() < 32.0 )
7 years ago
{
return LookupSequence( "up" );
}
UTIL_MakeAimVectors( pev->angles );
float x = DotProduct( gpGlobals->v_forward, m_velocity );
float y = DotProduct( gpGlobals->v_right, m_velocity );
float z = DotProduct( gpGlobals->v_up, m_velocity );
8 years ago
if( fabs( x ) > fabs( y ) && fabs( x ) > fabs( z ) )
7 years ago
{
8 years ago
if( x > 0 )
return LookupSequence( "forward" );
7 years ago
else
8 years ago
return LookupSequence( "backward" );
7 years ago
}
8 years ago
else if( fabs( y ) > fabs( z ) )
7 years ago
{
8 years ago
if( y > 0 )
return LookupSequence( "right" );
7 years ago
else
8 years ago
return LookupSequence( "left" );
7 years ago
}
else
{
8 years ago
if( z > 0 )
return LookupSequence( "up" );
7 years ago
else
8 years ago
return LookupSequence( "down" );
7 years ago
}
}
//=========================================================
// RunTask
//=========================================================
8 years ago
void CController::RunTask( Task_t *pTask )
7 years ago
{
8 years ago
if( m_flShootEnd > gpGlobals->time )
7 years ago
{
Vector vecHand, vecAngle;
8 years ago
7 years ago
GetAttachment( 2, vecHand, vecAngle );
8 years ago
while( m_flShootTime < m_flShootEnd && m_flShootTime < gpGlobals->time )
7 years ago
{
8 years ago
Vector vecSrc = vecHand + pev->velocity * ( m_flShootTime - gpGlobals->time );
7 years ago
Vector vecDir;
8 years ago
if (m_pCine != 0 || m_hEnemy != 0 )
7 years ago
{
if (m_pCine != 0) // LRC- is this a script that's telling it to fire?
7 years ago
{
if (m_hTargetEnt != 0 && m_pCine->PreciseAttack())
7 years ago
{
vecDir = (m_hTargetEnt->pev->origin - pev->origin).Normalize() * gSkillData.controllerSpeedBall;
}
else
{
UTIL_MakeVectors(pev->angles);
vecDir = gpGlobals->v_forward * gSkillData.controllerSpeedBall;
}
}
else if (m_hEnemy != 0)
9 years ago
{
8 years ago
if( HasConditions( bits_COND_SEE_ENEMY ) )
7 years ago
{
9 years ago
m_vecEstVelocity = m_vecEstVelocity * 0.5 + m_hEnemy->pev->velocity * 0.5;
}
else
{
m_vecEstVelocity = m_vecEstVelocity * 0.8;
}
vecDir = Intersect( vecSrc, m_hEnemy->BodyTarget( pev->origin ), m_vecEstVelocity, gSkillData.controllerSpeedBall );
7 years ago
}
float delta = 0.03490; // +-2 degree
vecDir = vecDir + Vector( RANDOM_FLOAT( -delta, delta ), RANDOM_FLOAT( -delta, delta ), RANDOM_FLOAT( -delta, delta ) ) * gSkillData.controllerSpeedBall;
8 years ago
vecSrc = vecSrc + vecDir * ( gpGlobals->time - m_flShootTime );
7 years ago
CBaseMonster *pBall = (CBaseMonster*)Create( "controller_energy_ball", vecSrc, pev->angles, edict() );
pBall->pev->velocity = vecDir;
}
m_flShootTime += 0.2;
}
8 years ago
if( m_flShootTime > m_flShootEnd )
7 years ago
{
m_iBall[0] = 64;
m_iBallTime[0] = m_flShootEnd;
m_iBall[1] = 64;
m_iBallTime[1] = m_flShootEnd;
m_fInCombat = FALSE;
}
}
8 years ago
switch( pTask->iTask )
7 years ago
{
case TASK_WAIT_FOR_MOVEMENT:
case TASK_WAIT:
case TASK_WAIT_FACE_ENEMY:
case TASK_WAIT_PVS:
MakeIdealYaw( m_vecEnemyLKP );
ChangeYaw( pev->yaw_speed );
8 years ago
if( m_fSequenceFinished )
7 years ago
{
m_fInCombat = FALSE;
}
8 years ago
CSquadMonster::RunTask( pTask );
7 years ago
8 years ago
if( !m_fInCombat )
7 years ago
{
8 years ago
if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) )
7 years ago
{
pev->sequence = LookupActivity( ACT_RANGE_ATTACK1 );
pev->frame = 0;
8 years ago
ResetSequenceInfo();
7 years ago
m_fInCombat = TRUE;
}
8 years ago
else if( HasConditions( bits_COND_CAN_RANGE_ATTACK2 ) )
7 years ago
{
pev->sequence = LookupActivity( ACT_RANGE_ATTACK2 );
pev->frame = 0;
8 years ago
ResetSequenceInfo();
7 years ago
m_fInCombat = TRUE;
}
else
{
8 years ago
int iFloat = LookupFloat();
if( m_fSequenceFinished || iFloat != pev->sequence )
7 years ago
{
pev->sequence = iFloat;
pev->frame = 0;
8 years ago
ResetSequenceInfo();
7 years ago
}
}
}
break;
default:
8 years ago
CSquadMonster::RunTask( pTask );
7 years ago
break;
}
}
//=========================================================
// GetSchedule - Decides which type of schedule best suits
// the monster's current state and conditions. Then calls
// monster's member function to get a pointer to a schedule
// of the proper type.
//=========================================================
8 years ago
Schedule_t *CController::GetSchedule( void )
7 years ago
{
8 years ago
switch( m_MonsterState )
7 years ago
{
case MONSTERSTATE_COMBAT:
{
// Vector vecTmp = Intersect( Vector( 0, 0, 0 ), Vector( 100, 4, 7 ), Vector( 2, 10, -3 ), 20.0 );
7 years ago
// dead enemy
8 years ago
if( HasConditions( bits_COND_LIGHT_DAMAGE ) )
7 years ago
{
// m_iFrustration++;
}
8 years ago
if( HasConditions( bits_COND_HEAVY_DAMAGE ) )
7 years ago
{
// m_iFrustration++;
}
}
break;
case MONSTERSTATE_IDLE:
case MONSTERSTATE_ALERT:
break;
7 years ago
default:
break;
}
8 years ago
return CSquadMonster::GetSchedule();
7 years ago
}
//=========================================================
//=========================================================
8 years ago
Schedule_t *CController::GetScheduleOfType( int Type )
7 years ago
{
// ALERT( at_console, "%d\n", m_iFrustration );
8 years ago
switch( Type )
7 years ago
{
case SCHED_CHASE_ENEMY:
return slControllerChaseEnemy;
case SCHED_RANGE_ATTACK1:
return slControllerStrafe;
case SCHED_RANGE_ATTACK2:
case SCHED_MELEE_ATTACK1:
case SCHED_MELEE_ATTACK2:
case SCHED_TAKE_COVER_FROM_ENEMY:
return slControllerTakeCover;
case SCHED_FAIL:
return slControllerFail;
}
8 years ago
return CBaseMonster::GetScheduleOfType( Type );
7 years ago
}
//=========================================================
// CheckRangeAttack1 - shoot a bigass energy ball out of their head
//
//=========================================================
8 years ago
BOOL CController::CheckRangeAttack1( float flDot, float flDist )
7 years ago
{
8 years ago
if( flDot > 0.5 && flDist > 256 && flDist <= 2048 )
7 years ago
{
return TRUE;
}
return FALSE;
}
8 years ago
BOOL CController::CheckRangeAttack2( float flDot, float flDist )
7 years ago
{
8 years ago
if( flDot > 0.5 && flDist > 64 && flDist <= 2048 )
7 years ago
{
return TRUE;
}
return FALSE;
}
8 years ago
BOOL CController::CheckMeleeAttack1( float flDot, float flDist )
7 years ago
{
return FALSE;
}
8 years ago
void CController::SetActivity( Activity NewActivity )
7 years ago
{
CBaseMonster::SetActivity( NewActivity );
8 years ago
switch( m_Activity )
7 years ago
{
case ACT_WALK:
m_flGroundSpeed = 100;
break;
default:
m_flGroundSpeed = 100;
break;
}
}
//=========================================================
// RunAI
//=========================================================
8 years ago
void CController::RunAI( void )
7 years ago
{
8 years ago
CBaseMonster::RunAI();
7 years ago
Vector vecStart, angleGun;
8 years ago
if( HasMemory( bits_MEMORY_KILLED ) )
7 years ago
return;
8 years ago
for( int i = 0; i < 2; i++ )
7 years ago
{
8 years ago
if( m_pBall[i] == NULL )
7 years ago
{
m_pBall[i] = CSprite::SpriteCreate( "sprites/xspark4.spr", pev->origin, TRUE );
m_pBall[i]->SetTransparency( kRenderGlow, 255, 255, 255, 255, kRenderFxNoDissipation );
8 years ago
m_pBall[i]->SetAttachment( edict(), ( i + 3 ) );
7 years ago
m_pBall[i]->SetScale( 1.0 );
}
float t = m_iBallTime[i] - gpGlobals->time;
8 years ago
if( t > 0.1 )
7 years ago
t = 0.1 / t;
else
t = 1.0;
8 years ago
m_iBallCurrent[i] += ( m_iBall[i] - m_iBallCurrent[i] ) * t;
7 years ago
m_pBall[i]->SetBrightness( m_iBallCurrent[i] );
GetAttachment( i + 2, vecStart, angleGun );
UTIL_SetOrigin( m_pBall[i], vecStart );
8 years ago
7 years ago
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_ELIGHT );
8 years ago
WRITE_SHORT( entindex() + 0x1000 * ( i + 3 ) ); // entity, attachment
7 years ago
WRITE_COORD( vecStart.x ); // origin
WRITE_COORD( vecStart.y );
WRITE_COORD( vecStart.z );
WRITE_COORD( m_iBallCurrent[i] / 8 ); // radius
WRITE_BYTE( 255 ); // R
WRITE_BYTE( 192 ); // G
WRITE_BYTE( 64 ); // B
WRITE_BYTE( 5 ); // life * 10
WRITE_COORD( 0 ); // decay
MESSAGE_END();
}
}
extern void DrawRoute( entvars_t *pev, WayPoint_t *m_Route, int m_iRouteIndex, int r, int g, int b );
8 years ago
void CController::Stop( void )
7 years ago
{
m_IdealActivity = GetStoppedActivity();
}
#define DIST_TO_CHECK 200
8 years ago
void CController::Move( float flInterval )
7 years ago
{
float flWaypointDist;
float flCheckDist;
float flDist;// how far the lookahead check got before hitting an object.
float flMoveDist;
Vector vecDir;
Vector vecApex;
CBaseEntity *pTargetEnt;
// Don't move if no valid route
8 years ago
if( FRouteClear() )
7 years ago
{
ALERT( at_aiconsole, "Tried to move with no route!\n" );
TaskFail();
return;
}
8 years ago
if( m_flMoveWaitFinished > gpGlobals->time )
7 years ago
return;
// Debug, test movement code
#if 0
8 years ago
// if( CVAR_GET_FLOAT( "stopmove" ) != 0 )
7 years ago
{
8 years ago
if( m_movementGoal == MOVEGOAL_ENEMY )
7 years ago
RouteSimplify( m_hEnemy );
else
RouteSimplify( m_hTargetEnt );
FRefreshRoute();
return;
}
#else
// Debug, draw the route
// DrawRoute( pev, m_Route, m_iRouteIndex, 0, 0, 255 );
#endif
// if the monster is moving directly towards an entity (enemy for instance), we'll set this pointer
// to that entity for the CheckLocalMove and Triangulate functions.
pTargetEnt = NULL;
8 years ago
if( m_flGroundSpeed == 0 )
7 years ago
{
m_flGroundSpeed = 100;
8 years ago
// TaskFail();
7 years ago
// return;
}
flMoveDist = m_flGroundSpeed * flInterval;
8 years ago
do
7 years ago
{
// local move to waypoint.
8 years ago
vecDir = ( m_Route[m_iRouteIndex].vecLocation - pev->origin ).Normalize();
flWaypointDist = ( m_Route[m_iRouteIndex].vecLocation - pev->origin ).Length();
// MakeIdealYaw( m_Route[m_iRouteIndex].vecLocation );
// ChangeYaw( pev->yaw_speed );
7 years ago
// if the waypoint is closer than CheckDist, CheckDist is the dist to waypoint
8 years ago
if( flWaypointDist < DIST_TO_CHECK )
7 years ago
{
flCheckDist = flWaypointDist;
}
else
{
flCheckDist = DIST_TO_CHECK;
}
8 years ago
if( ( m_Route[m_iRouteIndex].iType & ( ~bits_MF_NOT_TO_MASK ) ) == bits_MF_TO_ENEMY )
7 years ago
{
// only on a PURE move to enemy ( i.e., ONLY MF_TO_ENEMY set, not MF_TO_ENEMY and DETOUR )
pTargetEnt = m_hEnemy;
}
8 years ago
else if( ( m_Route[m_iRouteIndex].iType & ~bits_MF_NOT_TO_MASK ) == bits_MF_TO_TARGETENT )
7 years ago
{
pTargetEnt = m_hTargetEnt;
}
// !!!BUGBUG - CheckDist should be derived from ground speed.
// If this fails, it should be because of some dynamic entity blocking this guy.
// We've already checked this path, so we should wait and time out if the entity doesn't move
flDist = 0;
8 years ago
if( CheckLocalMove( pev->origin, pev->origin + vecDir * flCheckDist, pTargetEnt, &flDist ) != LOCALMOVE_VALID )
7 years ago
{
CBaseEntity *pBlocker;
// Can't move, stop
Stop();
// Blocking entity is in global trace_ent
pBlocker = CBaseEntity::Instance( gpGlobals->trace_ent );
8 years ago
if( pBlocker )
7 years ago
{
DispatchBlocked( edict(), pBlocker->edict() );
}
8 years ago
if( pBlocker && m_moveWaitTime > 0 && pBlocker->IsMoving() && !pBlocker->IsPlayer() && (gpGlobals->time-m_flMoveWaitFinished) > 3.0 )
7 years ago
{
// Can we still move toward our target?
8 years ago
if( flDist < m_flGroundSpeed )
7 years ago
{
// Wait for a second
m_flMoveWaitFinished = gpGlobals->time + m_moveWaitTime;
//ALERT( at_aiconsole, "Move %s!!!\n", STRING( pBlocker->pev->classname ) );
7 years ago
return;
}
}
8 years ago
else
7 years ago
{
// try to triangulate around whatever is in the way.
8 years ago
if( FTriangulate( pev->origin, m_Route[m_iRouteIndex].vecLocation, flDist, pTargetEnt, &vecApex ) )
7 years ago
{
InsertWaypoint( vecApex, bits_MF_TO_DETOUR );
RouteSimplify( pTargetEnt );
}
else
{
ALERT ( at_aiconsole, "Couldn't Triangulate\n" );
7 years ago
Stop();
8 years ago
if( m_moveWaitTime > 0 )
7 years ago
{
FRefreshRoute();
m_flMoveWaitFinished = gpGlobals->time + m_moveWaitTime * 0.5;
}
else
{
TaskFail();
ALERT( at_aiconsole, "Failed to move!\n" );
8 years ago
//ALERT( at_aiconsole, "%f, %f, %f\n", pev->origin.z, ( pev->origin + ( vecDir * flCheckDist ) ).z, m_Route[m_iRouteIndex].vecLocation.z );
7 years ago
}
return;
}
}
}
// UNDONE: this is a hack to quit moving farther than it has looked ahead.
8 years ago
if( flCheckDist < flMoveDist )
7 years ago
{
MoveExecute( pTargetEnt, vecDir, flCheckDist / m_flGroundSpeed );
// ALERT( at_console, "%.02f\n", flInterval );
AdvanceRoute( flWaypointDist );
flMoveDist -= flCheckDist;
}
else
{
MoveExecute( pTargetEnt, vecDir, flMoveDist / m_flGroundSpeed );
8 years ago
if( ShouldAdvanceRoute( flWaypointDist - flMoveDist ) )
7 years ago
{
AdvanceRoute( flWaypointDist );
}
flMoveDist = 0;
}
8 years ago
if( MovementIsComplete() )
7 years ago
{
Stop();
RouteClear();
}
8 years ago
} while( flMoveDist > 0 && flCheckDist > 0 );
7 years ago
// cut corner?
8 years ago
if( flWaypointDist < 128 )
7 years ago
{
8 years ago
if( m_movementGoal == MOVEGOAL_ENEMY )
7 years ago
RouteSimplify( m_hEnemy );
else
RouteSimplify( m_hTargetEnt );
FRefreshRoute();
8 years ago
if( m_flGroundSpeed > 100 )
7 years ago
m_flGroundSpeed -= 40;
}
else
{
8 years ago
if( m_flGroundSpeed < 400 )
7 years ago
m_flGroundSpeed += 10;
}
}
8 years ago
BOOL CController::ShouldAdvanceRoute( float flWaypointDist )
7 years ago
{
8 years ago
if( flWaypointDist <= 32 )
7 years ago
{
return TRUE;
}
return FALSE;
}
8 years ago
int CController::CheckLocalMove( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist )
7 years ago
{
TraceResult tr;
8 years ago
UTIL_TraceHull( vecStart + Vector( 0, 0, 32 ), vecEnd + Vector( 0, 0, 32 ), dont_ignore_monsters, large_hull, edict(), &tr );
7 years ago
// ALERT( at_console, "%.0f %.0f %.0f : ", vecStart.x, vecStart.y, vecStart.z );
// ALERT( at_console, "%.0f %.0f %.0f\n", vecEnd.x, vecEnd.y, vecEnd.z );
8 years ago
if( pflDist )
7 years ago
{
8 years ago
*pflDist = ( ( tr.vecEndPos - Vector( 0, 0, 32 ) ) - vecStart ).Length();// get the distance.
7 years ago
}
// ALERT( at_console, "check %d %d %f\n", tr.fStartSolid, tr.fAllSolid, tr.flFraction );
8 years ago
if( tr.fStartSolid || tr.flFraction < 1.0 )
7 years ago
{
8 years ago
if( pTarget && pTarget->edict() == gpGlobals->trace_ent )
7 years ago
return LOCALMOVE_VALID;
return LOCALMOVE_INVALID;
}
return LOCALMOVE_VALID;
}
void CController::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval )
{
8 years ago
if( m_IdealActivity != m_movementActivity )
7 years ago
m_IdealActivity = m_movementActivity;
// ALERT( at_console, "move %.4f %.4f %.4f : %f\n", vecDir.x, vecDir.y, vecDir.z, flInterval );
// float flTotal = m_flGroundSpeed * pev->framerate * flInterval;
8 years ago
// UTIL_MoveToOrigin ( ENT( pev ), m_Route[m_iRouteIndex].vecLocation, flTotal, MOVE_STRAFE );
7 years ago
m_velocity = m_velocity * 0.8 + m_flGroundSpeed * vecDir * 0.2;
8 years ago
UTIL_MoveToOrigin( ENT( pev ), pev->origin + m_velocity, m_velocity.Length() * flInterval, MOVE_STRAFE );
7 years ago
}
//=========================================================
// Controller bouncy ball attack
//=========================================================
class CControllerHeadBall : public CBaseMonster
{
void Spawn( void );
void Precache( void );
void EXPORT HuntThink( void );
void EXPORT DieThink( void );
void EXPORT BounceTouch( CBaseEntity *pOther );
void MovetoTarget( Vector vecTarget );
void Crawl( void );
int m_iTrail;
int m_flNextAttack;
Vector m_vecIdeal;
EHANDLE m_hOwner;
};
LINK_ENTITY_TO_CLASS( controller_head_ball, CControllerHeadBall )
7 years ago
8 years ago
void CControllerHeadBall::Spawn( void )
7 years ago
{
8 years ago
Precache();
7 years ago
// motor
pev->movetype = MOVETYPE_FLY;
pev->solid = SOLID_BBOX;
8 years ago
SET_MODEL(ENT( pev ), "sprites/xspark4.spr" );
7 years ago
pev->rendermode = kRenderTransAdd;
pev->rendercolor.x = 255;
pev->rendercolor.y = 255;
pev->rendercolor.z = 255;
pev->renderamt = 255;
pev->scale = 2.0;
8 years ago
UTIL_SetSize(pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) );
7 years ago
UTIL_SetOrigin( this, pev->origin );
9 years ago
SetThink( &CControllerHeadBall::HuntThink );
SetTouch( &CControllerHeadBall::BounceTouch );
7 years ago
m_vecIdeal = Vector( 0, 0, 0 );
SetNextThink( 0.1 );
m_hOwner = Instance( pev->owner );
pev->dmgtime = gpGlobals->time;
}
8 years ago
void CControllerHeadBall::Precache( void )
7 years ago
{
8 years ago
PRECACHE_MODEL( "sprites/xspark1.spr" );
PRECACHE_SOUND( "debris/zap4.wav" );
PRECACHE_SOUND( "weapons/electro4.wav" );
7 years ago
}
8 years ago
void CControllerHeadBall::HuntThink( void )
7 years ago
{
SetNextThink( 0.1 );
pev->renderamt -= 5;
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_ELIGHT );
8 years ago
WRITE_SHORT( entindex() ); // entity, attachment
7 years ago
WRITE_COORD( pev->origin.x ); // origin
WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z );
WRITE_COORD( pev->renderamt / 16 ); // radius
WRITE_BYTE( 255 ); // R
WRITE_BYTE( 255 ); // G
WRITE_BYTE( 255 ); // B
WRITE_BYTE( 2 ); // life * 10
WRITE_COORD( 0 ); // decay
MESSAGE_END();
// check world boundaries
if( gpGlobals->time - pev->dmgtime > 5 || pev->renderamt < 64 || m_hEnemy == 0 || m_hOwner == 0 || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 )
7 years ago
{
SetTouch( NULL );
UTIL_Remove( this );
return;
}
8 years ago
MovetoTarget( m_hEnemy->Center() );
7 years ago
8 years ago
if( ( m_hEnemy->Center() - pev->origin ).Length() < 64 )
7 years ago
{
TraceResult tr;
8 years ago
UTIL_TraceLine( pev->origin, m_hEnemy->Center(), dont_ignore_monsters, ENT( pev ), &tr );
7 years ago
8 years ago
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
if( pEntity != NULL && pEntity->pev->takedamage )
7 years ago
{
8 years ago
ClearMultiDamage();
7 years ago
pEntity->TraceAttack( m_hOwner->pev, gSkillData.controllerDmgZap, pev->velocity, &tr, DMG_SHOCK );
ApplyMultiDamage( pev, m_hOwner->pev );
}
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_BEAMENTPOINT );
WRITE_SHORT( entindex() );
WRITE_COORD( tr.vecEndPos.x );
WRITE_COORD( tr.vecEndPos.y );
WRITE_COORD( tr.vecEndPos.z );
WRITE_SHORT( g_sModelIndexLaser );
WRITE_BYTE( 0 ); // frame start
WRITE_BYTE( 10 ); // framerate
WRITE_BYTE( 3 ); // life
WRITE_BYTE( 20 ); // width
WRITE_BYTE( 0 ); // noise
WRITE_BYTE( 255 ); // r, g, b
WRITE_BYTE( 255 ); // r, g, b
WRITE_BYTE( 255 ); // r, g, b
WRITE_BYTE( 255 ); // brightness
WRITE_BYTE( 10 ); // speed
MESSAGE_END();
8 years ago
UTIL_EmitAmbientSound( ENT( pev ), tr.vecEndPos, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, RANDOM_LONG( 140, 160 ) );
7 years ago
m_flNextAttack = gpGlobals->time + 3.0;
9 years ago
SetThink( &CControllerHeadBall::DieThink );
7 years ago
SetNextThink( 0.3 );
}
8 years ago
//Crawl();
7 years ago
}
8 years ago
void CControllerHeadBall::DieThink( void )
7 years ago
{
UTIL_Remove( this );
}
8 years ago
void CControllerHeadBall::MovetoTarget( Vector vecTarget )
7 years ago
{
// accelerate
float flSpeed = m_vecIdeal.Length();
8 years ago
if( flSpeed == 0 )
7 years ago
{
m_vecIdeal = pev->velocity;
flSpeed = m_vecIdeal.Length();
}
8 years ago
if( flSpeed > 400 )
7 years ago
{
8 years ago
m_vecIdeal = m_vecIdeal.Normalize() * 400;
7 years ago
}
8 years ago
m_vecIdeal = m_vecIdeal + ( vecTarget - pev->origin ).Normalize() * 100;
7 years ago
pev->velocity = m_vecIdeal;
}
8 years ago
void CControllerHeadBall::Crawl( void )
7 years ago
{
8 years ago
Vector vecAim = Vector( RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ) ).Normalize();
7 years ago
Vector vecPnt = pev->origin + pev->velocity * 0.3 + vecAim * 64;
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_BEAMENTPOINT );
WRITE_SHORT( entindex() );
WRITE_COORD( vecPnt.x);
WRITE_COORD( vecPnt.y);
WRITE_COORD( vecPnt.z);
WRITE_SHORT( g_sModelIndexLaser );
WRITE_BYTE( 0 ); // frame start
WRITE_BYTE( 10 ); // framerate
WRITE_BYTE( 3 ); // life
WRITE_BYTE( 20 ); // width
WRITE_BYTE( 0 ); // noise
WRITE_BYTE( 255 ); // r, g, b
WRITE_BYTE( 255 ); // r, g, b
WRITE_BYTE( 255 ); // r, g, b
WRITE_BYTE( 255 ); // brightness
WRITE_BYTE( 10 ); // speed
MESSAGE_END();
}
void CControllerHeadBall::BounceTouch( CBaseEntity *pOther )
{
8 years ago
Vector vecDir = m_vecIdeal.Normalize();
7 years ago
8 years ago
TraceResult tr = UTIL_GetGlobalTrace();
7 years ago
8 years ago
float n = -DotProduct( tr.vecPlaneNormal, vecDir );
7 years ago
vecDir = 2.0 * tr.vecPlaneNormal * n + vecDir;
m_vecIdeal = vecDir * m_vecIdeal.Length();
}
class CControllerZapBall : public CBaseMonster
{
void Spawn( void );
void Precache( void );
void EXPORT AnimateThink( void );
void EXPORT ExplodeTouch( CBaseEntity *pOther );
EHANDLE m_hOwner;
};
LINK_ENTITY_TO_CLASS( controller_energy_ball, CControllerZapBall )
7 years ago
8 years ago
void CControllerZapBall::Spawn( void )
7 years ago
{
8 years ago
Precache();
7 years ago
// motor
pev->movetype = MOVETYPE_FLY;
pev->solid = SOLID_BBOX;
8 years ago
SET_MODEL( ENT( pev ), "sprites/xspark4.spr" );
7 years ago
pev->rendermode = kRenderTransAdd;
pev->rendercolor.x = 255;
pev->rendercolor.y = 255;
pev->rendercolor.z = 255;
pev->renderamt = 255;
pev->scale = 0.5;
8 years ago
UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) );
7 years ago
UTIL_SetOrigin( this, pev->origin );
9 years ago
SetThink( &CControllerZapBall::AnimateThink );
SetTouch( &CControllerZapBall::ExplodeTouch );
7 years ago
m_hOwner = Instance( pev->owner );
pev->dmgtime = gpGlobals->time; // keep track of when ball spawned
SetNextThink( 0.1 );
}
8 years ago
void CControllerZapBall::Precache( void )
7 years ago
{
8 years ago
PRECACHE_MODEL( "sprites/xspark4.spr" );
// PRECACHE_SOUND( "debris/zap4.wav" );
// PRECACHE_SOUND( "weapons/electro4.wav" );
7 years ago
}
8 years ago
void CControllerZapBall::AnimateThink( void )
7 years ago
{
SetNextThink( 0.1 );
8 years ago
pev->frame = ( (int)pev->frame + 1 ) % 11;
if( gpGlobals->time - pev->dmgtime > 5 || pev->velocity.Length() < 10 )
7 years ago
{
SetTouch( NULL );
UTIL_Remove( this );
}
}
void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther )
{
8 years ago
if( pOther->pev->takedamage )
7 years ago
{
8 years ago
TraceResult tr = UTIL_GetGlobalTrace();
entvars_t *pevOwner;
7 years ago
if( m_hOwner != 0 )
7 years ago
{
pevOwner = m_hOwner->pev;
}
else
{
pevOwner = pev;
}
8 years ago
ClearMultiDamage();
7 years ago
pOther->TraceAttack(pevOwner, gSkillData.controllerDmgBall, pev->velocity.Normalize(), &tr, DMG_ENERGYBEAM );
ApplyMultiDamage( pevOwner, pevOwner );
8 years ago
UTIL_EmitAmbientSound( ENT( pev ), tr.vecEndPos, "weapons/electro4.wav", 0.3, ATTN_NORM, 0, RANDOM_LONG( 90, 99 ) );
7 years ago
}
UTIL_Remove( this );
}
#endif //!OEM && !HLDEMO