2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-25 03:09:24 +01:00
hlsdk-xash3d/dlls/gargantua.cpp

1310 lines
34 KiB
C++
Raw Normal View History

2016-06-04 15:24:23 +02:00
/***
*
* 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.
*
****/
2021-06-07 02:05:58 +02:00
#if !OEM_BUILD
2016-06-04 15:24:23 +02:00
//=========================================================
// Gargantua
//=========================================================
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "nodes.h"
#include "monsters.h"
#include "schedule.h"
#include "customentity.h"
#include "weapons.h"
#include "effects.h"
#include "soundent.h"
#include "decals.h"
#include "explode.h"
#include "func_break.h"
//=========================================================
// Gargantua Monster
//=========================================================
2019-10-13 13:49:25 +02:00
const float GARG_ATTACKDIST = 80.0f;
2016-06-04 15:24:23 +02:00
// Garg animation events
#define GARG_AE_SLASH_LEFT 1
//#define GARG_AE_BEAM_ATTACK_RIGHT 2 // No longer used
#define GARG_AE_LEFT_FOOT 3
#define GARG_AE_RIGHT_FOOT 4
2016-07-31 15:48:50 +02:00
#define GARG_AE_STOMP 5
#define GARG_AE_BREATHE 6
2019-10-13 13:49:25 +02:00
#define STOMP_FRAMETIME 0.015f // gpGlobals->frametime
2016-06-04 15:24:23 +02:00
// Gargantua is immune to any damage but this
#define GARG_DAMAGE (DMG_ENERGYBEAM|DMG_CRUSH|DMG_MORTAR|DMG_BLAST)
#define GARG_EYE_SPRITE_NAME "sprites/gargeye1.spr"
#define GARG_BEAM_SPRITE_NAME "sprites/xbeam3.spr"
2016-07-31 15:48:50 +02:00
#define GARG_BEAM_SPRITE2 "sprites/xbeam3.spr"
2016-06-04 15:24:23 +02:00
#define GARG_STOMP_SPRITE_NAME "sprites/gargeye1.spr"
#define GARG_STOMP_BUZZ_SOUND "weapons/mine_charge.wav"
2016-07-31 15:48:50 +02:00
#define GARG_FLAME_LENGTH 330
#define GARG_GIB_MODEL "models/metalplategibs.mdl"
2016-06-04 15:24:23 +02:00
#define ATTN_GARG (ATTN_NORM)
#define STOMP_SPRITE_COUNT 10
int gStompSprite = 0, gGargGibModel = 0;
void SpawnExplosion( Vector center, float randomRange, float time, int magnitude );
class CSmoker;
// Spiral Effect
class CSpiral : public CBaseEntity
{
public:
void Spawn( void );
void Think( void );
int ObjectCaps( void ) { return FCAP_DONT_SAVE; }
static CSpiral *Create( const Vector &origin, float height, float radius, float duration );
};
LINK_ENTITY_TO_CLASS( streak_spiral, CSpiral )
2016-06-04 15:24:23 +02:00
class CStomp : public CBaseEntity
{
public:
void Spawn( void );
void Think( void );
static CStomp *StompCreate( const Vector &origin, const Vector &end, float speed );
private:
// UNDONE: re-use this sprite list instead of creating new ones all the time
2016-07-31 15:48:50 +02:00
// CSprite *m_pSprites[STOMP_SPRITE_COUNT];
2016-06-04 15:24:23 +02:00
};
LINK_ENTITY_TO_CLASS( garg_stomp, CStomp )
2016-06-04 15:24:23 +02:00
CStomp *CStomp::StompCreate( const Vector &origin, const Vector &end, float speed )
{
CStomp *pStomp = GetClassPtr( (CStomp *)NULL );
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
pStomp->pev->origin = origin;
2016-07-31 15:48:50 +02:00
Vector dir = end - origin;
2016-06-04 15:24:23 +02:00
pStomp->pev->scale = dir.Length();
pStomp->pev->movedir = dir.Normalize();
pStomp->pev->speed = speed;
pStomp->Spawn();
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
return pStomp;
}
void CStomp::Spawn( void )
{
pev->nextthink = gpGlobals->time;
2016-07-31 15:48:50 +02:00
pev->classname = MAKE_STRING( "garg_stomp" );
2016-06-04 15:24:23 +02:00
pev->dmgtime = gpGlobals->time;
pev->framerate = 30;
2016-07-31 15:48:50 +02:00
pev->model = MAKE_STRING( GARG_STOMP_SPRITE_NAME );
2016-06-04 15:24:23 +02:00
pev->rendermode = kRenderTransTexture;
pev->renderamt = 0;
2019-10-13 13:49:25 +02:00
EMIT_SOUND_DYN( edict(), CHAN_BODY, GARG_STOMP_BUZZ_SOUND, 1, ATTN_NORM, 0, PITCH_NORM * 0.55f );
2016-06-04 15:24:23 +02:00
}
2019-10-13 13:49:25 +02:00
#define STOMP_INTERVAL 0.025f
2016-06-04 15:24:23 +02:00
void CStomp::Think( void )
{
TraceResult tr;
2019-10-13 13:49:25 +02:00
pev->nextthink = gpGlobals->time + 0.1f;
2016-06-04 15:24:23 +02:00
// Do damage for this frame
Vector vecStart = pev->origin;
vecStart.z += 30;
2016-07-31 15:48:50 +02:00
Vector vecEnd = vecStart + ( pev->movedir * pev->speed * STOMP_FRAMETIME );
2016-06-04 15:24:23 +02:00
UTIL_TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT(pev), &tr );
2016-07-31 15:48:50 +02:00
if( tr.pHit && tr.pHit != pev->owner )
2016-06-04 15:24:23 +02:00
{
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
entvars_t *pevOwner = pev;
2016-07-31 15:48:50 +02:00
if( pev->owner )
pevOwner = VARS( pev->owner );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
if( pEntity )
2016-06-04 15:24:23 +02:00
pEntity->TakeDamage( pev, pevOwner, gSkillData.gargantuaDmgStomp, DMG_SONIC );
}
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
// Accelerate the effect
2016-07-31 15:48:50 +02:00
pev->speed = pev->speed + ( STOMP_FRAMETIME ) * pev->framerate;
2019-10-13 13:49:25 +02:00
pev->framerate = pev->framerate + ( STOMP_FRAMETIME ) * 1500.0f;
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
// Move and spawn trails
2016-07-31 15:48:50 +02:00
while( gpGlobals->time - pev->dmgtime > STOMP_INTERVAL )
2016-06-04 15:24:23 +02:00
{
pev->origin = pev->origin + pev->movedir * pev->speed * STOMP_INTERVAL;
2016-07-31 15:48:50 +02:00
for( int i = 0; i < 2; i++ )
2016-06-04 15:24:23 +02:00
{
CSprite *pSprite = CSprite::SpriteCreate( GARG_STOMP_SPRITE_NAME, pev->origin, TRUE );
2016-07-31 15:48:50 +02:00
if( pSprite )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
UTIL_TraceLine( pev->origin, pev->origin - Vector( 0, 0, 500 ), ignore_monsters, edict(), &tr );
2016-06-04 15:24:23 +02:00
pSprite->pev->origin = tr.vecEndPos;
2019-10-13 13:49:25 +02:00
pSprite->pev->velocity = Vector( RANDOM_FLOAT( -200.0f, 200.0f ), RANDOM_FLOAT( -200.0f, 200.0f ), 175 );
// pSprite->AnimateAndDie( RANDOM_FLOAT( 8.0f, 12.0f ) );
pSprite->pev->nextthink = gpGlobals->time + 0.3f;
2016-06-04 15:24:23 +02:00
pSprite->SetThink( &CBaseEntity::SUB_Remove );
pSprite->SetTransparency( kRenderTransAdd, 255, 255, 255, 255, kRenderFxFadeFast );
}
}
pev->dmgtime += STOMP_INTERVAL;
2016-06-04 15:24:23 +02:00
// Scale has the "life" of this effect
pev->scale -= STOMP_INTERVAL * pev->speed;
2016-07-31 15:48:50 +02:00
if( pev->scale <= 0 )
2016-06-04 15:24:23 +02:00
{
// Life has run out
2016-07-31 15:48:50 +02:00
UTIL_Remove( this );
2016-06-04 15:24:23 +02:00
STOP_SOUND( edict(), CHAN_BODY, GARG_STOMP_BUZZ_SOUND );
}
}
}
void StreakSplash( const Vector &origin, const Vector &direction, int color, int count, int speed, int velocityRange )
{
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, origin );
WRITE_BYTE( TE_STREAK_SPLASH );
WRITE_COORD( origin.x ); // origin
WRITE_COORD( origin.y );
WRITE_COORD( origin.z );
WRITE_COORD( direction.x ); // direction
WRITE_COORD( direction.y );
WRITE_COORD( direction.z );
WRITE_BYTE( color ); // Streak color 6
WRITE_SHORT( count ); // count
WRITE_SHORT( speed );
WRITE_SHORT( velocityRange ); // Random velocity modifier
MESSAGE_END();
}
class CGargantua : public CBaseMonster
{
public:
void Spawn( void );
void Precache( void );
void UpdateOnRemove();
2016-06-04 15:24:23 +02:00
void SetYawSpeed( void );
2016-07-31 15:48:50 +02:00
int Classify( void );
2016-06-04 15:24:23 +02:00
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType );
void HandleAnimEvent( MonsterEvent_t *pEvent );
BOOL CheckMeleeAttack1( float flDot, float flDist ); // Swipe
BOOL CheckMeleeAttack2( float flDot, float flDist ); // Flames
BOOL CheckRangeAttack1( float flDot, float flDist ); // Stomp attack
void SetObjectCollisionBox( void )
{
pev->absmin = pev->origin + Vector( -80, -80, 0 );
pev->absmax = pev->origin + Vector( 80, 80, 214 );
}
Schedule_t *GetScheduleOfType( int Type );
void StartTask( Task_t *pTask );
void RunTask( Task_t *pTask );
void PrescheduleThink( void );
void Killed( entvars_t *pevAttacker, int iGib );
void DeathEffect( void );
void EyeOff( void );
void EyeOn( int level );
void EyeUpdate( void );
void Leap( void );
void StompAttack( void );
void FlameCreate( void );
void FlameUpdate( void );
void FlameControls( float angleX, float angleY );
void FlameDestroy( void );
inline BOOL FlameIsOn( void ) { return m_pFlame[0] != NULL; }
void FlameDamage( Vector vecStart, Vector vecEnd, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType );
2016-07-31 15:48:50 +02:00
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
2016-06-04 15:24:23 +02:00
2016-06-25 20:21:01 +02:00
CUSTOM_SCHEDULES
2016-06-04 15:24:23 +02:00
private:
static const char *pAttackHitSounds[];
static const char *pBeamAttackSounds[];
static const char *pAttackMissSounds[];
static const char *pRicSounds[];
static const char *pFootSounds[];
static const char *pIdleSounds[];
static const char *pAlertSounds[];
static const char *pPainSounds[];
static const char *pAttackSounds[];
static const char *pStompSounds[];
static const char *pBreatheSounds[];
CBaseEntity* GargantuaCheckTraceHullAttack(float flDist, int iDamage, int iDmgType);
CSprite *m_pEyeGlow; // Glow around the eyes
CBeam *m_pFlame[4]; // Flame beams
2016-07-31 15:48:50 +02:00
int m_eyeBrightness; // Brightness target
float m_seeTime; // Time to attack (when I see the enemy, I set this)
2016-06-04 15:24:23 +02:00
float m_flameTime; // Time of next flame attack
float m_painSoundTime; // Time of next pain sound
float m_streakTime; // streak timer (don't send too many)
2016-07-31 15:48:50 +02:00
float m_flameX; // Flame thrower aim
2016-06-04 15:24:23 +02:00
float m_flameY;
};
LINK_ENTITY_TO_CLASS( monster_gargantua, CGargantua )
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
TYPEDESCRIPTION CGargantua::m_SaveData[] =
2016-06-04 15:24:23 +02:00
{
DEFINE_FIELD( CGargantua, m_pEyeGlow, FIELD_CLASSPTR ),
DEFINE_FIELD( CGargantua, m_eyeBrightness, FIELD_INTEGER ),
DEFINE_FIELD( CGargantua, m_seeTime, FIELD_TIME ),
DEFINE_FIELD( CGargantua, m_flameTime, FIELD_TIME ),
DEFINE_FIELD( CGargantua, m_streakTime, FIELD_TIME ),
DEFINE_FIELD( CGargantua, m_painSoundTime, FIELD_TIME ),
DEFINE_ARRAY( CGargantua, m_pFlame, FIELD_CLASSPTR, 4 ),
DEFINE_FIELD( CGargantua, m_flameX, FIELD_FLOAT ),
DEFINE_FIELD( CGargantua, m_flameY, FIELD_FLOAT ),
};
IMPLEMENT_SAVERESTORE( CGargantua, CBaseMonster )
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
const char *CGargantua::pAttackHitSounds[] =
2016-06-04 15:24:23 +02:00
{
"zombie/claw_strike1.wav",
"zombie/claw_strike2.wav",
"zombie/claw_strike3.wav",
};
2016-07-31 15:48:50 +02:00
const char *CGargantua::pBeamAttackSounds[] =
2016-06-04 15:24:23 +02:00
{
"garg/gar_flameoff1.wav",
"garg/gar_flameon1.wav",
"garg/gar_flamerun1.wav",
};
2016-07-31 15:48:50 +02:00
const char *CGargantua::pAttackMissSounds[] =
2016-06-04 15:24:23 +02:00
{
"zombie/claw_miss1.wav",
"zombie/claw_miss2.wav",
};
2016-07-31 15:48:50 +02:00
const char *CGargantua::pRicSounds[] =
2016-06-04 15:24:23 +02:00
{
#if 0
"weapons/ric1.wav",
"weapons/ric2.wav",
"weapons/ric3.wav",
"weapons/ric4.wav",
"weapons/ric5.wav",
#else
"debris/metal4.wav",
"debris/metal6.wav",
"weapons/ric4.wav",
"weapons/ric5.wav",
#endif
};
2016-07-31 15:48:50 +02:00
const char *CGargantua::pFootSounds[] =
2016-06-04 15:24:23 +02:00
{
"garg/gar_step1.wav",
"garg/gar_step2.wav",
};
2016-07-31 15:48:50 +02:00
const char *CGargantua::pIdleSounds[] =
2016-06-04 15:24:23 +02:00
{
"garg/gar_idle1.wav",
"garg/gar_idle2.wav",
"garg/gar_idle3.wav",
"garg/gar_idle4.wav",
"garg/gar_idle5.wav",
};
2016-07-31 15:48:50 +02:00
const char *CGargantua::pAttackSounds[] =
2016-06-04 15:24:23 +02:00
{
"garg/gar_attack1.wav",
"garg/gar_attack2.wav",
"garg/gar_attack3.wav",
};
2016-07-31 15:48:50 +02:00
const char *CGargantua::pAlertSounds[] =
2016-06-04 15:24:23 +02:00
{
"garg/gar_alert1.wav",
"garg/gar_alert2.wav",
"garg/gar_alert3.wav",
};
2016-07-31 15:48:50 +02:00
const char *CGargantua::pPainSounds[] =
2016-06-04 15:24:23 +02:00
{
"garg/gar_pain1.wav",
"garg/gar_pain2.wav",
"garg/gar_pain3.wav",
};
2016-07-31 15:48:50 +02:00
const char *CGargantua::pStompSounds[] =
2016-06-04 15:24:23 +02:00
{
"garg/gar_stomp1.wav",
};
2016-07-31 15:48:50 +02:00
const char *CGargantua::pBreatheSounds[] =
2016-06-04 15:24:23 +02:00
{
"garg/gar_breathe1.wav",
"garg/gar_breathe2.wav",
"garg/gar_breathe3.wav",
};
//=========================================================
// AI Schedules Specific to this monster
//=========================================================
#if 0
enum
{
SCHED_ = LAST_COMMON_SCHEDULE + 1
2016-06-04 15:24:23 +02:00
};
#endif
enum
{
TASK_SOUND_ATTACK = LAST_COMMON_TASK + 1,
TASK_FLAME_SWEEP
2016-06-04 15:24:23 +02:00
};
2016-07-31 15:48:50 +02:00
Task_t tlGargFlame[] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_STOP_MOVING, (float)0 },
{ TASK_FACE_ENEMY, (float)0 },
{ TASK_SOUND_ATTACK, (float)0 },
// { TASK_PLAY_SEQUENCE, (float)ACT_SIGNAL1 },
{ TASK_SET_ACTIVITY, (float)ACT_MELEE_ATTACK2 },
{ TASK_FLAME_SWEEP, (float)4.5 },
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
2016-06-04 15:24:23 +02:00
};
2016-07-31 15:48:50 +02:00
Schedule_t slGargFlame[] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGargFlame,
2016-07-31 15:48:50 +02:00
ARRAYSIZE( tlGargFlame ),
2016-06-04 15:24:23 +02:00
0,
0,
"GargFlame"
},
};
// primary melee attack
2016-07-31 15:48:50 +02:00
Task_t tlGargSwipe[] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_STOP_MOVING, 0 },
{ TASK_FACE_ENEMY, (float)0 },
{ TASK_MELEE_ATTACK1, (float)0 },
2016-06-04 15:24:23 +02:00
};
2016-07-31 15:48:50 +02:00
Schedule_t slGargSwipe[] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGargSwipe,
2016-07-31 15:48:50 +02:00
ARRAYSIZE( tlGargSwipe ),
2016-06-04 15:24:23 +02:00
bits_COND_CAN_MELEE_ATTACK2,
0,
"GargSwipe"
},
};
DEFINE_CUSTOM_SCHEDULES( CGargantua )
{
slGargFlame,
slGargSwipe,
};
IMPLEMENT_CUSTOM_SCHEDULES( CGargantua, CBaseMonster )
2016-06-04 15:24:23 +02:00
void CGargantua::EyeOn( int level )
{
2016-07-31 15:48:50 +02:00
m_eyeBrightness = level;
2016-06-04 15:24:23 +02:00
}
void CGargantua::EyeOff( void )
{
m_eyeBrightness = 0;
}
void CGargantua::EyeUpdate( void )
{
2016-07-31 15:48:50 +02:00
if( m_pEyeGlow )
2016-06-04 15:24:23 +02:00
{
m_pEyeGlow->pev->renderamt = UTIL_Approach( m_eyeBrightness, m_pEyeGlow->pev->renderamt, 26 );
2016-07-31 15:48:50 +02:00
if( m_pEyeGlow->pev->renderamt == 0 )
2016-06-04 15:24:23 +02:00
m_pEyeGlow->pev->effects |= EF_NODRAW;
else
m_pEyeGlow->pev->effects &= ~EF_NODRAW;
UTIL_SetOrigin( m_pEyeGlow->pev, pev->origin );
}
}
void CGargantua::StompAttack( void )
{
TraceResult trace;
UTIL_MakeVectors( pev->angles );
Vector vecStart = pev->origin + Vector(0,0,60) + 35 * gpGlobals->v_forward;
Vector vecAim = ShootAtEnemy( vecStart );
Vector vecEnd = (vecAim * 1024) + vecStart;
UTIL_TraceLine( vecStart, vecEnd, ignore_monsters, edict(), &trace );
CStomp::StompCreate( vecStart, trace.vecEndPos, 0 );
UTIL_ScreenShake( pev->origin, 12.0, 100.0, 2.0, 1000 );
EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pStompSounds ), 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) );
2016-06-04 15:24:23 +02:00
UTIL_TraceLine( pev->origin, pev->origin - Vector(0,0,20), ignore_monsters, edict(), &trace );
2019-10-13 13:49:25 +02:00
if( trace.flFraction < 1.0f )
2016-06-04 15:24:23 +02:00
UTIL_DecalTrace( &trace, DECAL_GARGSTOMP1 );
}
2016-07-31 15:48:50 +02:00
void CGargantua::FlameCreate( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
int i;
Vector posGun, angleGun;
2016-06-04 15:24:23 +02:00
TraceResult trace;
UTIL_MakeVectors( pev->angles );
2016-07-31 15:48:50 +02:00
for( i = 0; i < 4; i++ )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if( i < 2 )
2016-06-04 15:24:23 +02:00
m_pFlame[i] = CBeam::BeamCreate( GARG_BEAM_SPRITE_NAME, 240 );
else
m_pFlame[i] = CBeam::BeamCreate( GARG_BEAM_SPRITE2, 140 );
2016-07-31 15:48:50 +02:00
if( m_pFlame[i] )
2016-06-04 15:24:23 +02:00
{
int attach = i%2;
// attachment is 0 based in GetAttachment
2016-07-31 15:48:50 +02:00
GetAttachment( attach + 1, posGun, angleGun );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
Vector vecEnd = ( gpGlobals->v_forward * GARG_FLAME_LENGTH ) + posGun;
2016-06-04 15:24:23 +02:00
UTIL_TraceLine( posGun, vecEnd, dont_ignore_monsters, edict(), &trace );
m_pFlame[i]->PointEntInit( trace.vecEndPos, entindex() );
2016-07-31 15:48:50 +02:00
if( i < 2 )
2016-06-04 15:24:23 +02:00
m_pFlame[i]->SetColor( 255, 130, 90 );
else
m_pFlame[i]->SetColor( 0, 120, 255 );
m_pFlame[i]->SetBrightness( 190 );
m_pFlame[i]->SetFlags( BEAM_FSHADEIN );
m_pFlame[i]->SetScrollRate( 20 );
// attachment is 1 based in SetEndAttachment
m_pFlame[i]->SetEndAttachment( attach + 2 );
CSoundEnt::InsertSound( bits_SOUND_COMBAT, posGun, 384, 0.3 );
}
}
2016-07-31 15:48:50 +02:00
EMIT_SOUND_DYN( edict(), CHAN_BODY, pBeamAttackSounds[1], 1.0, ATTN_NORM, 0, PITCH_NORM );
EMIT_SOUND_DYN( edict(), CHAN_WEAPON, pBeamAttackSounds[2], 1.0, ATTN_NORM, 0, PITCH_NORM );
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
void CGargantua::FlameControls( float angleX, float angleY )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if( angleY < -180 )
2016-06-04 15:24:23 +02:00
angleY += 360;
2016-07-31 15:48:50 +02:00
else if( angleY > 180 )
2016-06-04 15:24:23 +02:00
angleY -= 360;
2016-07-31 15:48:50 +02:00
if( angleY < -45 )
2016-06-04 15:24:23 +02:00
angleY = -45;
2016-07-31 15:48:50 +02:00
else if( angleY > 45 )
2016-06-04 15:24:23 +02:00
angleY = 45;
m_flameX = UTIL_ApproachAngle( angleX, m_flameX, 4 );
m_flameY = UTIL_ApproachAngle( angleY, m_flameY, 8 );
SetBoneController( 0, m_flameY );
SetBoneController( 1, m_flameX );
}
2016-07-31 15:48:50 +02:00
void CGargantua::FlameUpdate( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
int i;
TraceResult trace;
Vector vecStart, angleGun;
BOOL streaks = FALSE;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
for( i = 0; i < 2; i++ )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if( m_pFlame[i] )
2016-06-04 15:24:23 +02:00
{
Vector vecAim = pev->angles;
vecAim.x += m_flameX;
vecAim.y += m_flameY;
UTIL_MakeVectors( vecAim );
2016-07-31 15:48:50 +02:00
GetAttachment( i + 1, vecStart, angleGun );
Vector vecEnd = vecStart + ( gpGlobals->v_forward * GARG_FLAME_LENGTH ); // - offset[i] * gpGlobals->v_right;
2016-06-04 15:24:23 +02:00
UTIL_TraceLine( vecStart, vecEnd, dont_ignore_monsters, edict(), &trace );
m_pFlame[i]->SetStartPos( trace.vecEndPos );
2019-10-13 13:49:25 +02:00
m_pFlame[i+2]->SetStartPos( ( vecStart * 0.6f ) + ( trace.vecEndPos * 0.4f ) );
2016-06-04 15:24:23 +02:00
2019-10-13 13:49:25 +02:00
if( trace.flFraction != 1.0f && gpGlobals->time > m_streakTime )
2016-06-04 15:24:23 +02:00
{
StreakSplash( trace.vecEndPos, trace.vecPlaneNormal, 6, 20, 50, 400 );
streaks = TRUE;
2016-07-31 15:48:50 +02:00
UTIL_DecalTrace( &trace, DECAL_SMALLSCORCH1 + RANDOM_LONG( 0, 2 ) );
2016-06-04 15:24:23 +02:00
}
2016-06-04 15:24:23 +02:00
// RadiusDamage( trace.vecEndPos, pev, pev, gSkillData.gargantuaDmgFire, CLASS_ALIEN_MONSTER, DMG_BURN );
FlameDamage( vecStart, trace.vecEndPos, pev, pev, gSkillData.gargantuaDmgFire, CLASS_ALIEN_MONSTER, DMG_BURN );
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_ELIGHT );
2016-07-31 15:48:50 +02:00
WRITE_SHORT( entindex() + 0x1000 * ( i + 2 ) ); // entity, attachment
2016-06-04 15:24:23 +02:00
WRITE_COORD( vecStart.x ); // origin
WRITE_COORD( vecStart.y );
WRITE_COORD( vecStart.z );
2019-10-13 13:49:25 +02:00
WRITE_COORD( RANDOM_FLOAT( 32.0f, 48.0f ) ); // radius
2016-06-04 15:24:23 +02:00
WRITE_BYTE( 255 ); // R
WRITE_BYTE( 255 ); // G
WRITE_BYTE( 255 ); // B
WRITE_BYTE( 2 ); // life * 10
WRITE_COORD( 0 ); // decay
MESSAGE_END();
}
}
2016-07-31 15:48:50 +02:00
if( streaks )
2016-06-04 15:24:23 +02:00
m_streakTime = gpGlobals->time;
}
2016-07-31 15:48:50 +02:00
void CGargantua::FlameDamage( Vector vecStart, Vector vecEnd, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
CBaseEntity *pEntity = NULL;
2016-06-04 15:24:23 +02:00
TraceResult tr;
float flAdjustedDamage;
Vector vecSpot;
2019-10-13 13:49:25 +02:00
Vector vecMid = ( vecStart + vecEnd ) * 0.5f;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
float searchRadius = ( vecStart - vecMid).Length();
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
Vector vecAim = ( vecEnd - vecStart ).Normalize();
2016-06-04 15:24:23 +02:00
// iterate on all entities in the vicinity.
2016-07-31 15:48:50 +02:00
while( ( pEntity = UTIL_FindEntityInSphere( pEntity, vecMid, searchRadius ) ) != NULL )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if( pEntity->pev->takedamage != DAMAGE_NO )
2016-06-04 15:24:23 +02:00
{
// UNDONE: this should check a damage mask, not an ignore
2016-07-31 15:48:50 +02:00
if( iClassIgnore != CLASS_NONE && pEntity->Classify() == iClassIgnore )
{
// houndeyes don't hurt other houndeyes with their attack
2016-06-04 15:24:23 +02:00
continue;
}
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
vecSpot = pEntity->BodyTarget( vecMid );
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
float dist = DotProduct( vecAim, vecSpot - vecMid );
2016-07-31 15:48:50 +02:00
if( dist > searchRadius )
2016-06-04 15:24:23 +02:00
dist = searchRadius;
2016-07-31 15:48:50 +02:00
else if( dist < -searchRadius )
2016-06-04 15:24:23 +02:00
dist = searchRadius;
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
Vector vecSrc = vecMid + dist * vecAim;
2016-07-31 15:48:50 +02:00
UTIL_TraceLine( vecSrc, vecSpot, dont_ignore_monsters, ENT( pev ), &tr );
2016-06-04 15:24:23 +02:00
2019-10-13 13:49:25 +02:00
if( tr.flFraction == 1.0f || tr.pHit == pEntity->edict() )
{
// the explosion can 'see' this entity, so hurt them!
2016-06-04 15:24:23 +02:00
// decrease damage for an ent that's farther from the flame.
dist = ( vecSrc - tr.vecEndPos ).Length();
2019-10-13 13:49:25 +02:00
if( dist > 64.0f )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
flAdjustedDamage = flDamage - ( dist - 64.0f ) * 0.4f;
2016-07-31 15:48:50 +02:00
if( flAdjustedDamage <= 0 )
2016-06-04 15:24:23 +02:00
continue;
}
else
{
flAdjustedDamage = flDamage;
}
// ALERT( at_console, "hit %s\n", STRING( pEntity->pev->classname ) );
2019-10-13 13:49:25 +02:00
if( tr.flFraction != 1.0f )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
ClearMultiDamage();
pEntity->TraceAttack( pevInflictor, flAdjustedDamage, ( tr.vecEndPos - vecSrc ).Normalize(), &tr, bitsDamageType );
2016-06-04 15:24:23 +02:00
ApplyMultiDamage( pevInflictor, pevAttacker );
}
else
{
2016-07-31 15:48:50 +02:00
pEntity->TakeDamage( pevInflictor, pevAttacker, flAdjustedDamage, bitsDamageType );
2016-06-04 15:24:23 +02:00
}
}
}
}
}
2016-07-31 15:48:50 +02:00
void CGargantua::FlameDestroy( void )
2016-06-04 15:24:23 +02:00
{
int i;
2016-07-31 15:48:50 +02:00
EMIT_SOUND_DYN( edict(), CHAN_WEAPON, pBeamAttackSounds[0], 1.0, ATTN_NORM, 0, PITCH_NORM );
for( i = 0; i < 4; i++ )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if( m_pFlame[i] )
2016-06-04 15:24:23 +02:00
{
UTIL_Remove( m_pFlame[i] );
m_pFlame[i] = NULL;
}
}
}
2016-07-31 15:48:50 +02:00
void CGargantua::PrescheduleThink( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if( !HasConditions( bits_COND_SEE_ENEMY ) )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
m_seeTime = gpGlobals->time + 5.0f;
2016-06-04 15:24:23 +02:00
EyeOff();
}
else
EyeOn( 200 );
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
EyeUpdate();
}
//=========================================================
// Classify - indicates this monster's place in the
// relationship table.
//=========================================================
2016-07-31 15:48:50 +02:00
int CGargantua::Classify( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
return CLASS_ALIEN_MONSTER;
2016-06-04 15:24:23 +02:00
}
//=========================================================
// SetYawSpeed - allows each sequence to have a different
// turn rate associated with it.
//=========================================================
2016-07-31 15:48:50 +02:00
void CGargantua::SetYawSpeed( void )
2016-06-04 15:24:23 +02:00
{
int ys;
switch ( m_Activity )
{
case ACT_IDLE:
ys = 60;
break;
case ACT_TURN_LEFT:
case ACT_TURN_RIGHT:
ys = 180;
break;
case ACT_WALK:
case ACT_RUN:
ys = 60;
break;
default:
ys = 60;
break;
}
pev->yaw_speed = ys;
}
//=========================================================
// Spawn
//=========================================================
2016-07-31 15:48:50 +02:00
void CGargantua::Spawn()
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
Precache();
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
SET_MODEL( ENT( pev ), "models/garg.mdl" );
2016-06-04 15:24:23 +02:00
UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) );
2016-07-31 15:48:50 +02:00
pev->solid = SOLID_SLIDEBOX;
2016-06-04 15:24:23 +02:00
pev->movetype = MOVETYPE_STEP;
m_bloodColor = BLOOD_COLOR_GREEN;
2016-07-31 15:48:50 +02:00
pev->health = gSkillData.gargantuaHealth;
2016-06-04 15:24:23 +02:00
//pev->view_ofs = Vector ( 0, 0, 96 );// taken from mdl file
m_flFieldOfView = -0.2;// width of forward view cone ( as a dotproduct result )
m_MonsterState = MONSTERSTATE_NONE;
MonsterInit();
m_pEyeGlow = CSprite::SpriteCreate( GARG_EYE_SPRITE_NAME, pev->origin, FALSE );
m_pEyeGlow->SetTransparency( kRenderGlow, 255, 255, 255, 0, kRenderFxNoDissipation );
m_pEyeGlow->SetAttachment( edict(), 1 );
EyeOff();
m_seeTime = gpGlobals->time + 5;
m_flameTime = gpGlobals->time + 2;
}
//=========================================================
// Precache - precaches all resources this monster needs
//=========================================================
2016-07-31 15:48:50 +02:00
void CGargantua::Precache()
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
PRECACHE_MODEL( "models/garg.mdl" );
2016-06-04 15:24:23 +02:00
PRECACHE_MODEL( GARG_EYE_SPRITE_NAME );
PRECACHE_MODEL( GARG_BEAM_SPRITE_NAME );
PRECACHE_MODEL( GARG_BEAM_SPRITE2 );
gStompSprite = PRECACHE_MODEL( GARG_STOMP_SPRITE_NAME );
gGargGibModel = PRECACHE_MODEL( GARG_GIB_MODEL );
PRECACHE_SOUND( GARG_STOMP_BUZZ_SOUND );
PRECACHE_SOUND_ARRAY( pAttackHitSounds );
PRECACHE_SOUND_ARRAY( pBeamAttackSounds );
PRECACHE_SOUND_ARRAY( pAttackMissSounds );
PRECACHE_SOUND_ARRAY( pRicSounds );
PRECACHE_SOUND_ARRAY( pFootSounds );
PRECACHE_SOUND_ARRAY( pIdleSounds );
PRECACHE_SOUND_ARRAY( pAlertSounds );
PRECACHE_SOUND_ARRAY( pPainSounds );
PRECACHE_SOUND_ARRAY( pAttackSounds );
PRECACHE_SOUND_ARRAY( pStompSounds );
PRECACHE_SOUND_ARRAY( pBreatheSounds );
2016-06-04 15:24:23 +02:00
}
void CGargantua::UpdateOnRemove()
{
CBaseEntity::UpdateOnRemove();
if( m_pEyeGlow )
{
UTIL_Remove( m_pEyeGlow );
m_pEyeGlow = 0;
}
FlameDestroy();
}
2016-06-04 15:24:23 +02:00
void CGargantua::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType )
{
2016-07-31 15:48:50 +02:00
ALERT( at_aiconsole, "CGargantua::TraceAttack\n" );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
if( !IsAlive() )
2016-06-04 15:24:23 +02:00
{
CBaseMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType );
return;
}
// UNDONE: Hit group specific damage?
2016-07-31 15:48:50 +02:00
if( bitsDamageType & ( GARG_DAMAGE | DMG_BLAST ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if( m_painSoundTime < gpGlobals->time )
2016-06-04 15:24:23 +02:00
{
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pPainSounds ), 1.0, ATTN_GARG, 0, PITCH_NORM );
2016-06-04 15:24:23 +02:00
m_painSoundTime = gpGlobals->time + RANDOM_FLOAT( 2.5, 4 );
}
}
bitsDamageType &= GARG_DAMAGE;
2016-07-31 15:48:50 +02:00
if( bitsDamageType == 0 )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if( pev->dmgtime != gpGlobals->time || (RANDOM_LONG( 0, 100 ) < 20 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 0.5 ,1.5 ) );
2016-06-04 15:24:23 +02:00
pev->dmgtime = gpGlobals->time;
2016-07-31 15:48:50 +02:00
//if ( RANDOM_LONG( 0, 100 ) < 25 )
// EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, pRicSounds[RANDOM_LONG( 0, ARRAYSIZE( pRicSounds ) - 1 )], 1.0, ATTN_NORM, 0, PITCH_NORM );
2016-06-04 15:24:23 +02:00
}
flDamage = 0;
}
CBaseMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType );
}
int CGargantua::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{
2016-07-31 15:48:50 +02:00
ALERT( at_aiconsole, "CGargantua::TakeDamage\n" );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
if( IsAlive() )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if( !( bitsDamageType & GARG_DAMAGE ) )
2019-10-13 13:49:25 +02:00
flDamage *= 0.01f;
2016-07-31 15:48:50 +02:00
if( bitsDamageType & DMG_BLAST )
2016-06-04 15:24:23 +02:00
SetConditions( bits_COND_LIGHT_DAMAGE );
}
return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
}
void CGargantua::DeathEffect( void )
{
int i;
2016-07-31 15:48:50 +02:00
UTIL_MakeVectors( pev->angles );
2016-06-04 15:24:23 +02:00
Vector deathPos = pev->origin + gpGlobals->v_forward * 100;
// Create a spiral of streaks
2019-10-13 13:49:25 +02:00
CSpiral::Create( deathPos, ( pev->absmax.z - pev->absmin.z ) * 0.6f, 125, 1.5 );
2016-06-04 15:24:23 +02:00
Vector position = pev->origin;
position.z += 32;
2016-07-31 15:48:50 +02:00
for( i = 0; i < 7; i+=2 )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
SpawnExplosion( position, 70, ( i * 0.3f ), 60 + ( i * 20 ) );
2016-06-04 15:24:23 +02:00
position.z += 15;
}
CBaseEntity *pSmoker = CBaseEntity::Create( "env_smoker", pev->origin, g_vecZero, NULL );
pSmoker->pev->health = 1; // 1 smoke balls
pSmoker->pev->scale = 46; // 4.6X normal size
pSmoker->pev->dmg = 0; // 0 radial distribution
2019-10-13 13:49:25 +02:00
pSmoker->pev->nextthink = gpGlobals->time + 2.5f; // Start in 2.5 seconds
2016-06-04 15:24:23 +02:00
}
void CGargantua::Killed( entvars_t *pevAttacker, int iGib )
{
EyeOff();
UTIL_Remove( m_pEyeGlow );
m_pEyeGlow = NULL;
CBaseMonster::Killed( pevAttacker, GIB_NEVER );
}
//=========================================================
// CheckMeleeAttack1
// Garg swipe attack
//
//=========================================================
BOOL CGargantua::CheckMeleeAttack1( float flDot, float flDist )
{
2016-07-31 15:48:50 +02:00
//ALERT( at_aiconsole, "CheckMelee(%f, %f)\n", flDot, flDist );
2016-06-04 15:24:23 +02:00
2019-10-13 13:49:25 +02:00
if( flDot >= 0.7f )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if( flDist <= GARG_ATTACKDIST )
2016-06-04 15:24:23 +02:00
return TRUE;
}
return FALSE;
}
// Flame thrower madness!
BOOL CGargantua::CheckMeleeAttack2( float flDot, float flDist )
{
2016-07-31 15:48:50 +02:00
//ALERT( at_aiconsole, "CheckMelee(%f, %f)\n", flDot, flDist );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
if( gpGlobals->time > m_flameTime )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
if( flDot >= 0.8f && flDist > GARG_ATTACKDIST )
2016-06-04 15:24:23 +02:00
{
if ( flDist <= GARG_FLAME_LENGTH )
return TRUE;
}
}
return FALSE;
}
//=========================================================
// CheckRangeAttack1
// flDot is the cos of the angle of the cone within which
// the attack can occur.
//=========================================================
//
// Stomp attack
//
//=========================================================
BOOL CGargantua::CheckRangeAttack1( float flDot, float flDist )
{
2016-07-31 15:48:50 +02:00
if( gpGlobals->time > m_seeTime )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
if( flDot >= 0.7f && flDist > GARG_ATTACKDIST )
2016-06-04 15:24:23 +02:00
{
return TRUE;
}
}
return FALSE;
}
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
2016-07-31 15:48:50 +02:00
void CGargantua::HandleAnimEvent( MonsterEvent_t *pEvent )
2016-06-04 15:24:23 +02:00
{
switch( pEvent->event )
{
case GARG_AE_SLASH_LEFT:
{
// HACKHACK!!!
2019-10-13 13:49:25 +02:00
CBaseEntity *pHurt = GargantuaCheckTraceHullAttack( GARG_ATTACKDIST + 10.0f, gSkillData.gargantuaDmgSlash, DMG_SLASH );
2016-07-31 15:48:50 +02:00
if( pHurt )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if( pHurt->pev->flags & ( FL_MONSTER | FL_CLIENT ) )
2016-06-04 15:24:23 +02:00
{
pHurt->pev->punchangle.x = -30; // pitch
pHurt->pev->punchangle.y = -30; // yaw
pHurt->pev->punchangle.z = 30; // roll
2016-07-31 15:48:50 +02:00
//UTIL_MakeVectors( pev->angles ); // called by CheckTraceHullAttack
2016-06-04 15:24:23 +02:00
pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 100;
}
EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG( 0, 15 ) );
2016-06-04 15:24:23 +02:00
}
else // Play a random attack miss sound
EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG( 0, 15 ) );
2016-06-04 15:24:23 +02:00
Vector forward;
UTIL_MakeVectorsPrivate( pev->angles, forward, NULL, NULL );
}
break;
case GARG_AE_RIGHT_FOOT:
case GARG_AE_LEFT_FOOT:
UTIL_ScreenShake( pev->origin, 4.0, 3.0, 1.0, 750 );
EMIT_SOUND_DYN( edict(), CHAN_BODY, RANDOM_SOUND_ARRAY( pFootSounds ), 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) );
2016-06-04 15:24:23 +02:00
break;
case GARG_AE_STOMP:
StompAttack();
2019-10-13 13:49:25 +02:00
m_seeTime = gpGlobals->time + 12.0f;
2016-06-04 15:24:23 +02:00
break;
case GARG_AE_BREATHE:
EMIT_SOUND_DYN( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pBreatheSounds ), 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) );
2016-06-04 15:24:23 +02:00
break;
default:
2016-07-31 15:48:50 +02:00
CBaseMonster::HandleAnimEvent( pEvent );
2016-06-04 15:24:23 +02:00
break;
}
}
//=========================================================
// CheckTraceHullAttack - expects a length to trace, amount
// of damage to do, and damage type. Returns a pointer to
// the damaged entity in case the monster wishes to do
// other stuff to the victim (punchangle, etc)
// Used for many contact-range melee attacks. Bites, claws, etc.
// Overridden for Gargantua because his swing starts lower as
// a percentage of his height (otherwise he swings over the
// players head)
//=========================================================
CBaseEntity* CGargantua::GargantuaCheckTraceHullAttack(float flDist, int iDamage, int iDmgType)
{
TraceResult tr;
UTIL_MakeVectors( pev->angles );
Vector vecStart = pev->origin;
vecStart.z += 64;
2019-10-13 13:49:25 +02:00
Vector vecEnd = vecStart + ( gpGlobals->v_forward * flDist ) - ( gpGlobals->v_up * flDist * 0.3f );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
UTIL_TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT( pev ), &tr );
if( tr.pHit )
2016-06-04 15:24:23 +02:00
{
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
2016-07-31 15:48:50 +02:00
if( iDamage > 0 )
2016-06-04 15:24:23 +02:00
{
pEntity->TakeDamage( pev, pev, iDamage, iDmgType );
}
return pEntity;
}
return NULL;
}
Schedule_t *CGargantua::GetScheduleOfType( int Type )
{
// HACKHACK - turn off the flames if they are on and garg goes scripted / dead
2016-07-31 15:48:50 +02:00
if( FlameIsOn() )
2016-06-04 15:24:23 +02:00
FlameDestroy();
switch( Type )
{
case SCHED_MELEE_ATTACK2:
return slGargFlame;
case SCHED_MELEE_ATTACK1:
return slGargSwipe;
break;
}
return CBaseMonster::GetScheduleOfType( Type );
}
void CGargantua::StartTask( Task_t *pTask )
{
2016-07-31 15:48:50 +02:00
switch( pTask->iTask )
2016-06-04 15:24:23 +02:00
{
case TASK_FLAME_SWEEP:
FlameCreate();
m_flWaitFinished = gpGlobals->time + pTask->flData;
2019-10-13 13:49:25 +02:00
m_flameTime = gpGlobals->time + 6.0f;
2016-06-04 15:24:23 +02:00
m_flameX = 0;
m_flameY = 0;
break;
case TASK_SOUND_ATTACK:
2016-07-31 15:48:50 +02:00
if( RANDOM_LONG( 0, 100 ) < 30 )
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAttackSounds ), 1.0, ATTN_GARG, 0, PITCH_NORM );
2016-06-04 15:24:23 +02:00
TaskComplete();
break;
case TASK_DIE:
2019-10-13 13:49:25 +02:00
m_flWaitFinished = gpGlobals->time + 1.6f;
2016-06-04 15:24:23 +02:00
DeathEffect();
// FALL THROUGH
default:
CBaseMonster::StartTask( pTask );
break;
}
}
//=========================================================
// RunTask
//=========================================================
void CGargantua::RunTask( Task_t *pTask )
{
2016-07-31 15:48:50 +02:00
switch( pTask->iTask )
2016-06-04 15:24:23 +02:00
{
case TASK_DIE:
2016-07-31 15:48:50 +02:00
if( gpGlobals->time > m_flWaitFinished )
2016-06-04 15:24:23 +02:00
{
pev->renderfx = kRenderFxExplode;
pev->rendercolor.x = 255;
pev->rendercolor.y = 0;
pev->rendercolor.z = 0;
StopAnimation();
2019-10-13 13:49:25 +02:00
pev->nextthink = gpGlobals->time + 0.15f;
2016-06-04 15:24:23 +02:00
SetThink( &CBaseEntity::SUB_Remove );
int i;
int parts = MODEL_FRAMES( gGargGibModel );
2016-07-31 15:48:50 +02:00
for( i = 0; i < 10; i++ )
2016-06-04 15:24:23 +02:00
{
CGib *pGib = GetClassPtr( (CGib *)NULL );
pGib->Spawn( GARG_GIB_MODEL );
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
int bodyPart = 0;
2016-07-31 15:48:50 +02:00
if( parts > 1 )
bodyPart = RANDOM_LONG( 0, pev->body - 1 );
2016-06-04 15:24:23 +02:00
pGib->pev->body = bodyPart;
pGib->m_bloodColor = BLOOD_COLOR_YELLOW;
pGib->m_material = matNone;
pGib->pev->origin = pev->origin;
pGib->pev->velocity = UTIL_RandomBloodVector() * RANDOM_FLOAT( 300, 500 );
2019-10-13 13:49:25 +02:00
pGib->pev->nextthink = gpGlobals->time + 1.25f;
2016-06-04 15:24:23 +02:00
pGib->SetThink( &CBaseEntity::SUB_FadeOut );
}
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
2016-07-31 15:48:50 +02:00
WRITE_BYTE( TE_BREAKMODEL );
2016-06-04 15:24:23 +02:00
// position
WRITE_COORD( pev->origin.x );
WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z );
// size
WRITE_COORD( 200 );
WRITE_COORD( 200 );
WRITE_COORD( 128 );
// velocity
WRITE_COORD( 0 );
WRITE_COORD( 0 );
WRITE_COORD( 0 );
// randomization
WRITE_BYTE( 200 );
// Model
WRITE_SHORT( gGargGibModel ); //model id#
// # of shards
WRITE_BYTE( 50 );
// duration
WRITE_BYTE( 20 );// 3.0 seconds
// flags
WRITE_BYTE( BREAK_FLESH );
MESSAGE_END();
return;
}
else
2016-07-31 15:48:50 +02:00
CBaseMonster::RunTask( pTask );
2016-06-04 15:24:23 +02:00
break;
case TASK_FLAME_SWEEP:
2016-07-31 15:48:50 +02:00
if( gpGlobals->time > m_flWaitFinished )
2016-06-04 15:24:23 +02:00
{
FlameDestroy();
TaskComplete();
FlameControls( 0, 0 );
SetBoneController( 0, 0 );
SetBoneController( 1, 0 );
}
else
{
BOOL cancel = FALSE;
Vector angles = g_vecZero;
FlameUpdate();
CBaseEntity *pEnemy = m_hEnemy;
2016-07-31 15:48:50 +02:00
if( pEnemy )
2016-06-04 15:24:23 +02:00
{
Vector org = pev->origin;
org.z += 64;
2016-07-31 15:48:50 +02:00
Vector dir = pEnemy->BodyTarget( org ) - org;
2016-06-04 15:24:23 +02:00
angles = UTIL_VecToAngles( dir );
angles.x = -angles.x;
angles.y -= pev->angles.y;
2016-07-31 15:48:50 +02:00
if( dir.Length() > 400 )
2016-06-04 15:24:23 +02:00
cancel = TRUE;
}
2016-07-31 15:48:50 +02:00
if( fabs(angles.y) > 60 )
2016-06-04 15:24:23 +02:00
cancel = TRUE;
2016-07-31 15:48:50 +02:00
if( cancel )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
m_flWaitFinished -= 0.5f;
m_flameTime -= 0.5f;
2016-06-04 15:24:23 +02:00
}
2019-10-13 13:49:25 +02:00
// FlameControls( angles.x + 2.0f * sin( gpGlobals->time * 8.0f ), angles.y + 28.0f * sin( gpGlobals->time * 8.5f ) );
2016-06-04 15:24:23 +02:00
FlameControls( angles.x, angles.y );
}
break;
default:
CBaseMonster::RunTask( pTask );
break;
}
}
class CSmoker : public CBaseEntity
{
public:
void Spawn( void );
void Think( void );
};
LINK_ENTITY_TO_CLASS( env_smoker, CSmoker )
2016-06-04 15:24:23 +02:00
void CSmoker::Spawn( void )
{
pev->movetype = MOVETYPE_NONE;
pev->nextthink = gpGlobals->time;
pev->solid = SOLID_NOT;
UTIL_SetSize(pev, g_vecZero, g_vecZero );
pev->effects |= EF_NODRAW;
pev->angles = g_vecZero;
}
void CSmoker::Think( void )
{
// lots of smoke
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE( TE_SMOKE );
2016-07-31 15:48:50 +02:00
WRITE_COORD( pev->origin.x + RANDOM_FLOAT( -pev->dmg, pev->dmg ) );
WRITE_COORD( pev->origin.y + RANDOM_FLOAT( -pev->dmg, pev->dmg ) );
2016-06-04 15:24:23 +02:00
WRITE_COORD( pev->origin.z);
WRITE_SHORT( g_sModelIndexSmoke );
2019-10-13 13:49:25 +02:00
WRITE_BYTE( RANDOM_LONG(pev->scale, pev->scale * 1.1f ) );
2016-07-31 15:48:50 +02:00
WRITE_BYTE( RANDOM_LONG( 8, 14 ) ); // framerate
2016-06-04 15:24:23 +02:00
MESSAGE_END();
pev->health--;
2016-07-31 15:48:50 +02:00
if( pev->health > 0 )
2019-10-13 13:49:25 +02:00
pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1f, 0.2f );
2016-06-04 15:24:23 +02:00
else
UTIL_Remove( this );
}
void CSpiral::Spawn( void )
{
pev->movetype = MOVETYPE_NONE;
pev->nextthink = gpGlobals->time;
pev->solid = SOLID_NOT;
2016-07-31 15:48:50 +02:00
UTIL_SetSize( pev, g_vecZero, g_vecZero );
2016-06-04 15:24:23 +02:00
pev->effects |= EF_NODRAW;
pev->angles = g_vecZero;
}
CSpiral *CSpiral::Create( const Vector &origin, float height, float radius, float duration )
{
2016-07-31 15:48:50 +02:00
if( duration <= 0 )
2016-06-04 15:24:23 +02:00
return NULL;
CSpiral *pSpiral = GetClassPtr( (CSpiral *)NULL );
pSpiral->Spawn();
pSpiral->pev->dmgtime = pSpiral->pev->nextthink;
pSpiral->pev->origin = origin;
pSpiral->pev->scale = radius;
pSpiral->pev->dmg = height;
pSpiral->pev->speed = duration;
pSpiral->pev->health = 0;
pSpiral->pev->angles = g_vecZero;
return pSpiral;
}
2019-10-13 13:49:25 +02:00
#define SPIRAL_INTERVAL 0.1f //025
2016-06-04 15:24:23 +02:00
void CSpiral::Think( void )
{
float time = gpGlobals->time - pev->dmgtime;
2016-07-31 15:48:50 +02:00
while( time > SPIRAL_INTERVAL )
2016-06-04 15:24:23 +02:00
{
Vector position = pev->origin;
Vector direction = Vector(0,0,1);
2016-07-31 15:48:50 +02:00
2019-10-13 13:49:25 +02:00
float fraction = 1.0f / pev->speed;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
float radius = ( pev->scale * pev->health ) * fraction;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
position.z += ( pev->health * pev->dmg ) * fraction;
pev->angles.y = ( pev->health * 360 * 8 ) * fraction;
2016-06-04 15:24:23 +02:00
UTIL_MakeVectors( pev->angles );
position = position + gpGlobals->v_forward * radius;
2016-07-31 15:48:50 +02:00
direction = ( direction + gpGlobals->v_forward ).Normalize();
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
StreakSplash( position, Vector( 0, 0, 1 ), RANDOM_LONG( 8, 11 ), 20, RANDOM_LONG( 50, 150 ), 400 );
2016-06-04 15:24:23 +02:00
// Jeez, how many counters should this take ? :)
pev->dmgtime += SPIRAL_INTERVAL;
pev->health += SPIRAL_INTERVAL;
time -= SPIRAL_INTERVAL;
}
pev->nextthink = gpGlobals->time;
2016-07-31 15:48:50 +02:00
if( pev->health >= pev->speed )
2016-06-04 15:24:23 +02:00
UTIL_Remove( this );
}
// HACKHACK Cut and pasted from explode.cpp
void SpawnExplosion( Vector center, float randomRange, float time, int magnitude )
{
KeyValueData kvd;
2016-07-31 15:48:50 +02:00
char buf[128];
2016-06-04 15:24:23 +02:00
center.x += RANDOM_FLOAT( -randomRange, randomRange );
center.y += RANDOM_FLOAT( -randomRange, randomRange );
CBaseEntity *pExplosion = CBaseEntity::Create( "env_explosion", center, g_vecZero, NULL );
sprintf( buf, "%3d", magnitude );
kvd.szKeyName = "iMagnitude";
kvd.szValue = buf;
pExplosion->KeyValue( &kvd );
pExplosion->pev->spawnflags |= SF_ENVEXPLOSION_NODAMAGE;
pExplosion->Spawn();
pExplosion->SetThink( &CBaseEntity::SUB_CallUseToggle );
pExplosion->pev->nextthink = gpGlobals->time + time;
}
2016-04-17 22:30:05 +02:00
#endif