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.
|
|
|
|
*
|
|
|
|
****/
|
|
|
|
#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD )
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// icthyosaur - evin, satan fish monster
|
|
|
|
//=========================================================
|
|
|
|
|
|
|
|
#include "extdll.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "cbase.h"
|
|
|
|
#include "monsters.h"
|
|
|
|
#include "schedule.h"
|
2016-06-25 18:33:39 +02:00
|
|
|
#include "flyingmonster.h"
|
2016-06-04 15:24:23 +02:00
|
|
|
#include "nodes.h"
|
|
|
|
#include "soundent.h"
|
|
|
|
#include "animation.h"
|
|
|
|
#include "effects.h"
|
|
|
|
#include "weapons.h"
|
|
|
|
|
|
|
|
#define SEARCH_RETRY 16
|
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
#define ICHTHYOSAUR_SPEED 150.0f
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
extern CGraph WorldGraph;
|
|
|
|
|
|
|
|
#define EYE_MAD 0
|
|
|
|
#define EYE_BASE 1
|
|
|
|
#define EYE_CLOSED 2
|
|
|
|
#define EYE_BACK 3
|
|
|
|
#define EYE_LOOK 4
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Monster's Anim Events Go Here
|
|
|
|
//=========================================================
|
|
|
|
|
|
|
|
// UNDONE: Save/restore here
|
|
|
|
class CIchthyosaur : public CFlyingMonster
|
|
|
|
{
|
|
|
|
public:
|
2016-07-31 15:48:50 +02:00
|
|
|
void Spawn( void );
|
|
|
|
void Precache( void );
|
|
|
|
void SetYawSpeed( void );
|
|
|
|
int Classify( void );
|
|
|
|
void HandleAnimEvent( MonsterEvent_t *pEvent );
|
2016-06-25 18:33:39 +02:00
|
|
|
CUSTOM_SCHEDULES
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
int Save( CSave &save );
|
2016-06-04 15:24:23 +02:00
|
|
|
int Restore( CRestore &restore );
|
|
|
|
static TYPEDESCRIPTION m_SaveData[];
|
|
|
|
|
|
|
|
Schedule_t *GetSchedule( void );
|
|
|
|
Schedule_t *GetScheduleOfType ( int Type );
|
|
|
|
|
|
|
|
void Killed( entvars_t *pevAttacker, int iGib );
|
|
|
|
void BecomeDead( void );
|
|
|
|
|
|
|
|
void EXPORT CombatUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
|
|
|
void EXPORT BiteTouch( CBaseEntity *pOther );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void StartTask( Task_t *pTask );
|
|
|
|
void RunTask( Task_t *pTask );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
BOOL CheckMeleeAttack1( float flDot, float flDist );
|
|
|
|
BOOL CheckRangeAttack1( float flDot, float flDist );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
float ChangeYaw( int speed );
|
|
|
|
Activity GetStoppedActivity( void );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void Move( float flInterval );
|
|
|
|
void MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval );
|
|
|
|
void MonsterThink( void );
|
|
|
|
void Stop( void );
|
|
|
|
void Swim( void );
|
|
|
|
Vector DoProbe(const Vector &Probe );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
float VectorToPitch( const Vector &vec );
|
2016-06-04 15:24:23 +02:00
|
|
|
float FlPitchDiff( void );
|
|
|
|
float ChangePitch( int speed );
|
|
|
|
|
|
|
|
Vector m_SaveVelocity;
|
|
|
|
float m_idealDist;
|
|
|
|
|
|
|
|
float m_flBlink;
|
|
|
|
|
|
|
|
float m_flEnemyTouched;
|
|
|
|
BOOL m_bOnAttack;
|
|
|
|
|
|
|
|
float m_flMaxSpeed;
|
|
|
|
float m_flMinSpeed;
|
|
|
|
float m_flMaxDist;
|
|
|
|
|
|
|
|
CBeam *m_pBeam;
|
|
|
|
|
|
|
|
float m_flNextAlert;
|
|
|
|
|
|
|
|
static const char *pIdleSounds[];
|
|
|
|
static const char *pAlertSounds[];
|
|
|
|
static const char *pAttackSounds[];
|
|
|
|
static const char *pBiteSounds[];
|
|
|
|
static const char *pDieSounds[];
|
|
|
|
static const char *pPainSounds[];
|
|
|
|
|
|
|
|
void IdleSound( void );
|
|
|
|
void AlertSound( void );
|
|
|
|
void AttackSound( void );
|
|
|
|
void BiteSound( void );
|
|
|
|
void DeathSound( void );
|
|
|
|
void PainSound( void );
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
LINK_ENTITY_TO_CLASS( monster_ichthyosaur, CIchthyosaur )
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
TYPEDESCRIPTION CIchthyosaur::m_SaveData[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
DEFINE_FIELD( CIchthyosaur, m_SaveVelocity, FIELD_VECTOR ),
|
|
|
|
DEFINE_FIELD( CIchthyosaur, m_idealDist, FIELD_FLOAT ),
|
|
|
|
DEFINE_FIELD( CIchthyosaur, m_flBlink, FIELD_FLOAT ),
|
|
|
|
DEFINE_FIELD( CIchthyosaur, m_flEnemyTouched, FIELD_FLOAT ),
|
|
|
|
DEFINE_FIELD( CIchthyosaur, m_bOnAttack, FIELD_BOOLEAN ),
|
|
|
|
DEFINE_FIELD( CIchthyosaur, m_flMaxSpeed, FIELD_FLOAT ),
|
|
|
|
DEFINE_FIELD( CIchthyosaur, m_flMinSpeed, FIELD_FLOAT ),
|
|
|
|
DEFINE_FIELD( CIchthyosaur, m_flMaxDist, FIELD_FLOAT ),
|
|
|
|
DEFINE_FIELD( CIchthyosaur, m_flNextAlert, FIELD_TIME ),
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
IMPLEMENT_SAVERESTORE( CIchthyosaur, CFlyingMonster )
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
const char *CIchthyosaur::pIdleSounds[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
"ichy/ichy_idle1.wav",
|
|
|
|
"ichy/ichy_idle2.wav",
|
|
|
|
"ichy/ichy_idle3.wav",
|
|
|
|
"ichy/ichy_idle4.wav",
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
const char *CIchthyosaur::pAlertSounds[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
"ichy/ichy_alert2.wav",
|
|
|
|
"ichy/ichy_alert3.wav",
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
const char *CIchthyosaur::pAttackSounds[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
"ichy/ichy_attack1.wav",
|
|
|
|
"ichy/ichy_attack2.wav",
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
const char *CIchthyosaur::pBiteSounds[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
"ichy/ichy_bite1.wav",
|
|
|
|
"ichy/ichy_bite2.wav",
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
const char *CIchthyosaur::pPainSounds[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
"ichy/ichy_pain2.wav",
|
|
|
|
"ichy/ichy_pain3.wav",
|
|
|
|
"ichy/ichy_pain5.wav",
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
const char *CIchthyosaur::pDieSounds[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
"ichy/ichy_die2.wav",
|
|
|
|
"ichy/ichy_die4.wav",
|
|
|
|
};
|
|
|
|
|
|
|
|
#define EMIT_ICKY_SOUND( chan, array ) \
|
2016-07-31 15:48:50 +02:00
|
|
|
EMIT_SOUND_DYN( ENT( pev ), chan , array[RANDOM_LONG( 0, ARRAYSIZE( array ) - 1 )], 1.0, 0.6, 0, RANDOM_LONG( 95, 105 ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::IdleSound( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
EMIT_ICKY_SOUND( CHAN_VOICE, pIdleSounds );
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::AlertSound( void )
|
|
|
|
{
|
2016-06-04 15:24:23 +02:00
|
|
|
EMIT_ICKY_SOUND( CHAN_VOICE, pAlertSounds );
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::AttackSound( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
EMIT_ICKY_SOUND( CHAN_VOICE, pAttackSounds );
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::BiteSound( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
EMIT_ICKY_SOUND( CHAN_WEAPON, pBiteSounds );
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::DeathSound( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
EMIT_ICKY_SOUND( CHAN_VOICE, pDieSounds );
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::PainSound( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
EMIT_ICKY_SOUND( CHAN_VOICE, pPainSounds );
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// monster-specific tasks and states
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
enum
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
TASK_ICHTHYOSAUR_CIRCLE_ENEMY = LAST_COMMON_TASK + 1,
|
|
|
|
TASK_ICHTHYOSAUR_SWIM,
|
2016-06-25 18:33:39 +02:00
|
|
|
TASK_ICHTHYOSAUR_FLOAT
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// AI Schedules Specific to this monster
|
|
|
|
//=========================================================
|
|
|
|
|
|
|
|
static Task_t tlSwimAround[] =
|
|
|
|
{
|
|
|
|
{ TASK_SET_ACTIVITY, (float)ACT_WALK },
|
|
|
|
{ TASK_ICHTHYOSAUR_SWIM, 0.0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static Schedule_t slSwimAround[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tlSwimAround,
|
|
|
|
ARRAYSIZE(tlSwimAround),
|
|
|
|
bits_COND_LIGHT_DAMAGE |
|
|
|
|
bits_COND_HEAVY_DAMAGE |
|
|
|
|
bits_COND_SEE_ENEMY |
|
|
|
|
bits_COND_NEW_ENEMY |
|
|
|
|
bits_COND_HEAR_SOUND,
|
|
|
|
bits_SOUND_PLAYER |
|
|
|
|
bits_SOUND_COMBAT,
|
|
|
|
"SwimAround"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static Task_t tlSwimAgitated[] =
|
|
|
|
{
|
|
|
|
{ TASK_STOP_MOVING, (float) 0 },
|
|
|
|
{ TASK_SET_ACTIVITY, (float)ACT_RUN },
|
|
|
|
{ TASK_WAIT, (float)2.0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static Schedule_t slSwimAgitated[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tlSwimAgitated,
|
|
|
|
ARRAYSIZE(tlSwimAgitated),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"SwimAgitated"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static Task_t tlCircleEnemy[] =
|
|
|
|
{
|
|
|
|
{ TASK_SET_ACTIVITY, (float)ACT_WALK },
|
|
|
|
{ TASK_ICHTHYOSAUR_CIRCLE_ENEMY, 0.0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static Schedule_t slCircleEnemy[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tlCircleEnemy,
|
|
|
|
ARRAYSIZE(tlCircleEnemy),
|
|
|
|
bits_COND_NEW_ENEMY |
|
|
|
|
bits_COND_LIGHT_DAMAGE |
|
|
|
|
bits_COND_HEAVY_DAMAGE |
|
|
|
|
bits_COND_CAN_MELEE_ATTACK1 |
|
|
|
|
bits_COND_CAN_RANGE_ATTACK1,
|
|
|
|
0,
|
|
|
|
"CircleEnemy"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
Task_t tlTwitchDie[] =
|
|
|
|
{
|
|
|
|
{ TASK_STOP_MOVING, 0 },
|
|
|
|
{ TASK_SOUND_DIE, (float)0 },
|
|
|
|
{ TASK_DIE, (float)0 },
|
|
|
|
{ TASK_ICHTHYOSAUR_FLOAT, (float)0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
Schedule_t slTwitchDie[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tlTwitchDie,
|
|
|
|
ARRAYSIZE( tlTwitchDie ),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"Die"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
DEFINE_CUSTOM_SCHEDULES( CIchthyosaur )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
slSwimAround,
|
2016-06-04 15:24:23 +02:00
|
|
|
slSwimAgitated,
|
|
|
|
slCircleEnemy,
|
|
|
|
slTwitchDie,
|
|
|
|
};
|
2016-06-25 18:33:39 +02:00
|
|
|
|
|
|
|
IMPLEMENT_CUSTOM_SCHEDULES( CIchthyosaur, CFlyingMonster )
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Classify - indicates this monster's place in the
|
|
|
|
// relationship table.
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
int CIchthyosaur::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
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// CheckMeleeAttack1
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
BOOL CIchthyosaur::CheckMeleeAttack1( float flDot, float flDist )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
if( flDot >= 0.7f && m_flEnemyTouched > gpGlobals->time - 0.2f )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CIchthyosaur::BiteTouch( CBaseEntity *pOther )
|
|
|
|
{
|
|
|
|
// bite if we hit who we want to eat
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pOther == m_hEnemy )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_flEnemyTouched = gpGlobals->time;
|
|
|
|
m_bOnAttack = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CIchthyosaur::CombatUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !ShouldToggle( useType, m_bOnAttack ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
return;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_bOnAttack )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_bOnAttack = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_bOnAttack = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// CheckRangeAttack1 - swim in for a chomp
|
|
|
|
//
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
BOOL CIchthyosaur::CheckRangeAttack1( float flDot, float flDist )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
if( flDot > -0.7f && (m_bOnAttack || ( flDist <= 192 && m_idealDist <= 192 ) ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// SetYawSpeed - allows each sequence to have a different
|
|
|
|
// turn rate associated with it.
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::SetYawSpeed( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pev->yaw_speed = 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Killed - overrides CFlyingMonster.
|
|
|
|
//
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::Killed( entvars_t *pevAttacker, int iGib )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
CBaseMonster::Killed( pevAttacker, iGib );
|
|
|
|
pev->velocity = Vector( 0, 0, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void CIchthyosaur::BecomeDead( void )
|
|
|
|
{
|
|
|
|
pev->takedamage = DAMAGE_YES;// don't let autoaim aim at corpses.
|
|
|
|
|
|
|
|
// give the corpse half of the monster's original maximum health.
|
|
|
|
pev->health = pev->max_health / 2;
|
|
|
|
pev->max_health = 5; // max_health now becomes a counter for how many blood decals the corpse can place.
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ICHTHYOSAUR_AE_SHAKE_RIGHT 1
|
|
|
|
#define ICHTHYOSAUR_AE_SHAKE_LEFT 2
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// HandleAnimEvent - catches the monster-specific messages
|
|
|
|
// that occur when tagged animation frames are played.
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::HandleAnimEvent( MonsterEvent_t *pEvent )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
int bDidAttack = FALSE;
|
|
|
|
switch( pEvent->event )
|
|
|
|
{
|
|
|
|
case ICHTHYOSAUR_AE_SHAKE_RIGHT:
|
|
|
|
case ICHTHYOSAUR_AE_SHAKE_LEFT:
|
|
|
|
{
|
2017-06-29 15:56:03 +02:00
|
|
|
if( m_hEnemy != 0 && FVisible( m_hEnemy ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
CBaseEntity *pHurt = m_hEnemy;
|
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
if( m_flEnemyTouched < gpGlobals->time - 0.2f && ( m_hEnemy->BodyTarget( pev->origin ) - pev->origin).Length() > ( 32.0f + 16.0f + 32.0f ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
Vector vecShootDir = ShootAtEnemy( pev->origin );
|
2016-07-31 15:48:50 +02:00
|
|
|
UTIL_MakeAimVectors( pev->angles );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
if( DotProduct( vecShootDir, gpGlobals->v_forward ) > 0.707f )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_bOnAttack = TRUE;
|
|
|
|
pHurt->pev->punchangle.z = -18;
|
|
|
|
pHurt->pev->punchangle.x = 5;
|
2019-10-13 13:49:25 +02:00
|
|
|
pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 300.0f;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pHurt->IsPlayer() )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
pHurt->pev->angles.x += RANDOM_FLOAT( -35.0f, 35.0f );
|
|
|
|
pHurt->pev->angles.y += RANDOM_FLOAT( -90.0f, 90.0f );
|
2016-06-04 15:24:23 +02:00
|
|
|
pHurt->pev->angles.z = 0;
|
|
|
|
pHurt->pev->fixangle = TRUE;
|
|
|
|
}
|
|
|
|
pHurt->TakeDamage( pev, pev, gSkillData.ichthyosaurDmgShake, DMG_SLASH );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BiteSound();
|
|
|
|
|
|
|
|
bDidAttack = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CFlyingMonster::HandleAnimEvent( pEvent );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( bDidAttack )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
Vector vecSrc = pev->origin + gpGlobals->v_forward * 32.0f;
|
2016-06-04 15:24:23 +02:00
|
|
|
UTIL_Bubbles( vecSrc - Vector( 8, 8, 8 ), vecSrc + Vector( 8, 8, 8 ), 16 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Spawn
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::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/icky.mdl" );
|
2016-06-04 15:24:23 +02:00
|
|
|
UTIL_SetSize( pev, Vector( -32, -32, -32 ), Vector( 32, 32, 32 ) );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->solid = SOLID_BBOX;
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->movetype = MOVETYPE_FLY;
|
|
|
|
m_bloodColor = BLOOD_COLOR_GREEN;
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->health = gSkillData.ichthyosaurHealth;
|
|
|
|
pev->view_ofs = Vector( 0, 0, 16 );
|
2016-06-04 15:24:23 +02:00
|
|
|
m_flFieldOfView = VIEW_FIELD_WIDE;
|
|
|
|
m_MonsterState = MONSTERSTATE_NONE;
|
|
|
|
SetBits(pev->flags, FL_SWIM);
|
|
|
|
SetFlyingSpeed( ICHTHYOSAUR_SPEED );
|
2019-10-13 13:49:25 +02:00
|
|
|
SetFlyingMomentum( 2.5f ); // Set momentum constant
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
m_afCapability = bits_CAP_RANGE_ATTACK1 | bits_CAP_SWIM;
|
|
|
|
|
|
|
|
MonsterInit();
|
|
|
|
|
|
|
|
SetTouch( &CIchthyosaur::BiteTouch );
|
|
|
|
SetUse( &CIchthyosaur::CombatUse );
|
|
|
|
|
|
|
|
m_idealDist = 384;
|
|
|
|
m_flMinSpeed = 80;
|
|
|
|
m_flMaxSpeed = 300;
|
|
|
|
m_flMaxDist = 384;
|
|
|
|
|
|
|
|
Vector Forward;
|
2016-07-31 15:48:50 +02:00
|
|
|
UTIL_MakeVectorsPrivate( pev->angles, Forward, 0, 0 );
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->velocity = m_flightSpeed * Forward.Normalize();
|
|
|
|
m_SaveVelocity = pev->velocity;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Precache - precaches all resources this monster needs
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::Precache()
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
PRECACHE_MODEL( "models/icky.mdl" );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
PRECACHE_SOUND_ARRAY( pIdleSounds );
|
|
|
|
PRECACHE_SOUND_ARRAY( pAlertSounds );
|
|
|
|
PRECACHE_SOUND_ARRAY( pAttackSounds );
|
|
|
|
PRECACHE_SOUND_ARRAY( pBiteSounds );
|
|
|
|
PRECACHE_SOUND_ARRAY( pDieSounds );
|
|
|
|
PRECACHE_SOUND_ARRAY( pPainSounds );
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// GetSchedule
|
|
|
|
//=========================================================
|
|
|
|
Schedule_t* CIchthyosaur::GetSchedule()
|
|
|
|
{
|
|
|
|
// ALERT( at_console, "GetSchedule( )\n" );
|
2016-07-31 15:48:50 +02:00
|
|
|
switch( m_MonsterState )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
case MONSTERSTATE_IDLE:
|
|
|
|
m_flightSpeed = 80;
|
|
|
|
return GetScheduleOfType( SCHED_IDLE_WALK );
|
2016-06-13 16:29:45 +02:00
|
|
|
break;
|
2016-06-04 15:24:23 +02:00
|
|
|
case MONSTERSTATE_ALERT:
|
|
|
|
m_flightSpeed = 150;
|
|
|
|
return GetScheduleOfType( SCHED_IDLE_WALK );
|
2016-06-13 16:29:45 +02:00
|
|
|
break;
|
2016-06-04 15:24:23 +02:00
|
|
|
case MONSTERSTATE_COMBAT:
|
|
|
|
m_flMaxSpeed = 400;
|
|
|
|
// eat them
|
2016-07-31 15:48:50 +02:00
|
|
|
if( HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
return GetScheduleOfType( SCHED_MELEE_ATTACK1 );
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
// chase them down and eat them
|
2016-07-31 15:48:50 +02:00
|
|
|
if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
return GetScheduleOfType( SCHED_CHASE_ENEMY );
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
if( HasConditions( bits_COND_HEAVY_DAMAGE ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_bOnAttack = TRUE;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->health < pev->max_health - 20 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_bOnAttack = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GetScheduleOfType( SCHED_STANDOFF );
|
2016-06-13 16:29:45 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
return CFlyingMonster::GetSchedule();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t *CIchthyosaur::GetScheduleOfType( int Type )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// ALERT( at_console, "GetScheduleOfType( %d ) %d\n", Type, m_bOnAttack );
|
2016-07-31 15:48:50 +02:00
|
|
|
switch( Type )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
case SCHED_IDLE_WALK:
|
|
|
|
return slSwimAround;
|
|
|
|
case SCHED_STANDOFF:
|
|
|
|
return slCircleEnemy;
|
|
|
|
case SCHED_FAIL:
|
|
|
|
return slSwimAgitated;
|
|
|
|
case SCHED_DIE:
|
|
|
|
return slTwitchDie;
|
|
|
|
case SCHED_CHASE_ENEMY:
|
2016-07-31 15:48:50 +02:00
|
|
|
AttackSound();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
return CBaseMonster::GetScheduleOfType( Type );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Start task - selects the correct activity and performs
|
|
|
|
// any necessary calculations to start the next task on the
|
|
|
|
// schedule.
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::StartTask( Task_t *pTask )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
switch( pTask->iTask )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
case TASK_ICHTHYOSAUR_CIRCLE_ENEMY:
|
|
|
|
break;
|
|
|
|
case TASK_ICHTHYOSAUR_SWIM:
|
|
|
|
break;
|
|
|
|
case TASK_SMALL_FLINCH:
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_idealDist > 128 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_flMaxDist = 512;
|
|
|
|
m_idealDist = 512;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_bOnAttack = TRUE;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
CFlyingMonster::StartTask( pTask );
|
2016-06-04 15:24:23 +02:00
|
|
|
break;
|
|
|
|
case TASK_ICHTHYOSAUR_FLOAT:
|
|
|
|
pev->skin = EYE_BASE;
|
|
|
|
SetSequenceByName( "bellyup" );
|
|
|
|
break;
|
|
|
|
default:
|
2016-07-31 15:48:50 +02:00
|
|
|
CFlyingMonster::StartTask( pTask );
|
2016-06-04 15:24:23 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::RunTask( Task_t *pTask )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
switch( pTask->iTask )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
case TASK_ICHTHYOSAUR_CIRCLE_ENEMY:
|
2017-06-29 15:56:03 +02:00
|
|
|
if( m_hEnemy == 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
TaskComplete();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( FVisible( m_hEnemy ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
Vector vecFrom = m_hEnemy->EyePosition();
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Vector vecDelta = ( pev->origin - vecFrom ).Normalize();
|
|
|
|
Vector vecSwim = CrossProduct( vecDelta, Vector( 0, 0, 1 ) ).Normalize();
|
2016-06-25 18:33:39 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( DotProduct( vecSwim, m_SaveVelocity ) < 0 )
|
2019-10-13 13:49:25 +02:00
|
|
|
vecSwim = vecSwim * -1.0f;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
Vector vecPos = vecFrom + vecDelta * m_idealDist + vecSwim * 32.0f;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// ALERT( at_console, "vecPos %.0f %.0f %.0f\n", vecPos.x, vecPos.y, vecPos.z );
|
|
|
|
|
|
|
|
TraceResult tr;
|
2016-06-25 18:33:39 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
UTIL_TraceHull( vecFrom, vecPos, ignore_monsters, large_hull, m_hEnemy->edict(), &tr );
|
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
if( tr.flFraction > 0.5f )
|
2016-06-04 15:24:23 +02:00
|
|
|
vecPos = tr.vecEndPos;
|
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
m_SaveVelocity = m_SaveVelocity * 0.8f + 0.2f * ( vecPos - pev->origin ).Normalize() * m_flightSpeed;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// ALERT( at_console, "m_SaveVelocity %.2f %.2f %.2f\n", m_SaveVelocity.x, m_SaveVelocity.y, m_SaveVelocity.z );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( HasConditions( bits_COND_ENEMY_FACING_ME ) && m_hEnemy->FVisible( this ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
m_flNextAlert -= 0.1f;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_idealDist < m_flMaxDist )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_idealDist += 4;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
|
|
|
|
if( m_flightSpeed > m_flMinSpeed )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_flightSpeed -= 2;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( m_flightSpeed < m_flMinSpeed )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_flightSpeed += 2;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_flMinSpeed < m_flMaxSpeed )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
m_flMinSpeed += 0.5f;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
m_flNextAlert += 0.1f;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_idealDist > 128 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_idealDist -= 4;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_flightSpeed < m_flMaxSpeed )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_flightSpeed += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ALERT( at_console, "%.0f\n", m_idealDist );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
m_flNextAlert = gpGlobals->time + 0.2f;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_flNextAlert < gpGlobals->time )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
// ALERT( at_console, "AlertSound()\n" );
|
|
|
|
AlertSound();
|
2016-06-04 15:24:23 +02:00
|
|
|
m_flNextAlert = gpGlobals->time + RANDOM_FLOAT( 3, 5 );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TASK_ICHTHYOSAUR_SWIM:
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_fSequenceFinished )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
TaskComplete();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TASK_DIE:
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_fSequenceFinished )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pev->deadflag = DEAD_DEAD;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
TaskComplete();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TASK_ICHTHYOSAUR_FLOAT:
|
|
|
|
pev->angles.x = UTIL_ApproachAngle( 0, pev->angles.x, 20 );
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->velocity = pev->velocity * 0.8f;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->waterlevel > 1 && pev->velocity.z < 64 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pev->velocity.z += 8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pev->velocity.z -= 8;
|
|
|
|
}
|
|
|
|
// ALERT( at_console, "%f\n", pev->velocity.z );
|
|
|
|
break;
|
|
|
|
default:
|
2016-07-31 15:48:50 +02:00
|
|
|
CFlyingMonster::RunTask( pTask );
|
2016-06-04 15:24:23 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
float CIchthyosaur::VectorToPitch( const Vector &vec )
|
|
|
|
{
|
|
|
|
float pitch;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( vec.z == 0 && vec.x == 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
pitch = 0;
|
|
|
|
else
|
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
pitch = (int) ( atan2( vec.z, sqrt( vec.x * vec.x + vec.y * vec.y ) ) * 180.0f / M_PI_F );
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pitch < 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
pitch += 360;
|
|
|
|
}
|
|
|
|
return pitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::Move( float flInterval )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
CFlyingMonster::Move( flInterval );
|
|
|
|
}
|
|
|
|
|
|
|
|
float CIchthyosaur::FlPitchDiff( void )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
float flPitchDiff;
|
|
|
|
float flCurrentPitch;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
flCurrentPitch = UTIL_AngleMod( pev->angles.z );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( flCurrentPitch == pev->idealpitch )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
flPitchDiff = pev->idealpitch - flCurrentPitch;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->idealpitch > flCurrentPitch )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( flPitchDiff >= 180 )
|
2016-06-04 15:24:23 +02:00
|
|
|
flPitchDiff = flPitchDiff - 360;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( flPitchDiff <= -180 )
|
2016-06-04 15:24:23 +02:00
|
|
|
flPitchDiff = flPitchDiff + 360;
|
|
|
|
}
|
|
|
|
return flPitchDiff;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
float CIchthyosaur::ChangePitch( int speed )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->movetype == MOVETYPE_FLY )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
float diff = FlPitchDiff();
|
|
|
|
float target = 0;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_IdealActivity != GetStoppedActivity() )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( diff < -20 )
|
2016-06-04 15:24:23 +02:00
|
|
|
target = 45;
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( diff > 20 )
|
2016-06-04 15:24:23 +02:00
|
|
|
target = -45;
|
|
|
|
}
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->angles.x = UTIL_Approach(target, pev->angles.x, 220.0f * 0.1f );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
float CIchthyosaur::ChangeYaw( int speed )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->movetype == MOVETYPE_FLY )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
float diff = FlYawDiff();
|
|
|
|
float target = 0;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_IdealActivity != GetStoppedActivity() )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( diff < -20 )
|
2016-06-04 15:24:23 +02:00
|
|
|
target = 20;
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( diff > 20 )
|
2016-06-04 15:24:23 +02:00
|
|
|
target = -20;
|
|
|
|
}
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->angles.z = UTIL_Approach( target, pev->angles.z, 220.0f * 0.1f );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
return CFlyingMonster::ChangeYaw( speed );
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Activity CIchthyosaur::GetStoppedActivity( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->movetype != MOVETYPE_FLY ) // UNDONE: Ground idle here, IDLE may be something else
|
2016-06-04 15:24:23 +02:00
|
|
|
return ACT_IDLE;
|
|
|
|
return ACT_WALK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CIchthyosaur::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval )
|
|
|
|
{
|
|
|
|
m_SaveVelocity = vecDir * m_flightSpeed;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::MonsterThink( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
CFlyingMonster::MonsterThink();
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->deadflag == DEAD_NO )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_MonsterState != MONSTERSTATE_SCRIPT )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
Swim();
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// blink the eye
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_flBlink < gpGlobals->time )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pev->skin = EYE_CLOSED;
|
2019-10-13 13:49:25 +02:00
|
|
|
if( m_flBlink + 0.2f < gpGlobals->time )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
m_flBlink = gpGlobals->time + RANDOM_FLOAT( 3.0f, 4.0f );
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_bOnAttack )
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->skin = EYE_MAD;
|
|
|
|
else
|
|
|
|
pev->skin = EYE_BASE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::Stop( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !m_bOnAttack )
|
2016-06-04 15:24:23 +02:00
|
|
|
m_flightSpeed = 80.0;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CIchthyosaur::Swim()
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2017-06-29 15:56:03 +02:00
|
|
|
//int retValue = 0;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
Vector start = pev->origin;
|
|
|
|
|
|
|
|
Vector Angles;
|
|
|
|
Vector Forward, Right, Up;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( FBitSet( pev->flags, FL_ONGROUND ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->angles.x = 0.0f;
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->angles.y += RANDOM_FLOAT( -45, 45 );
|
|
|
|
ClearBits( pev->flags, FL_ONGROUND );
|
|
|
|
|
|
|
|
Angles = Vector( -pev->angles.x, pev->angles.y, pev->angles.z );
|
2016-07-31 15:48:50 +02:00
|
|
|
UTIL_MakeVectorsPrivate( Angles, Forward, Right, Up );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
pev->velocity = Forward * 200 + Up * 200;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_bOnAttack && m_flightSpeed < m_flMaxSpeed )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_flightSpeed += 40;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_flightSpeed < 180 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_IdealActivity == ACT_RUN )
|
2016-06-04 15:24:23 +02:00
|
|
|
SetActivity( ACT_WALK );
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_IdealActivity == ACT_WALK )
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->framerate = m_flightSpeed / 150.0f;
|
2016-06-04 15:24:23 +02:00
|
|
|
// ALERT( at_console, "walk %.2f\n", pev->framerate );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_IdealActivity == ACT_WALK )
|
2016-06-04 15:24:23 +02:00
|
|
|
SetActivity( ACT_RUN );
|
2019-10-13 13:49:25 +02:00
|
|
|
if( m_IdealActivity == ACT_RUN )
|
|
|
|
pev->framerate = m_flightSpeed / 150.0f;
|
2016-06-04 15:24:23 +02:00
|
|
|
// ALERT( at_console, "run %.2f\n", pev->framerate );
|
|
|
|
}
|
|
|
|
/*
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !m_pBeam )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_pBeam = CBeam::BeamCreate( "sprites/laserbeam.spr", 80 );
|
2016-07-31 15:48:50 +02:00
|
|
|
m_pBeam->PointEntInit( pev->origin + m_SaveVelocity, entindex() );
|
2016-06-04 15:24:23 +02:00
|
|
|
m_pBeam->SetEndAttachment( 1 );
|
|
|
|
m_pBeam->SetColor( 255, 180, 96 );
|
|
|
|
m_pBeam->SetBrightness( 192 );
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
#define PROBE_LENGTH 150
|
|
|
|
Angles = UTIL_VecToAngles( m_SaveVelocity );
|
|
|
|
Angles.x = -Angles.x;
|
2016-07-31 15:48:50 +02:00
|
|
|
UTIL_MakeVectorsPrivate( Angles, Forward, Right, Up );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
Vector f, u, l, r, d;
|
2016-07-31 15:48:50 +02:00
|
|
|
f = DoProbe( start + PROBE_LENGTH * Forward );
|
|
|
|
r = DoProbe( start + PROBE_LENGTH / 3 * Forward + Right );
|
|
|
|
l = DoProbe( start + PROBE_LENGTH / 3 * Forward - Right );
|
|
|
|
u = DoProbe( start + PROBE_LENGTH / 3 * Forward + Up );
|
|
|
|
d = DoProbe( start + PROBE_LENGTH / 3 * Forward - Up );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Vector SteeringVector = f + r + l + u + d;
|
|
|
|
m_SaveVelocity = ( m_SaveVelocity + SteeringVector / 2 ).Normalize();
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
Angles = Vector( -pev->angles.x, pev->angles.y, pev->angles.z );
|
2016-07-31 15:48:50 +02:00
|
|
|
UTIL_MakeVectorsPrivate( Angles, Forward, Right, Up );
|
2016-06-04 15:24:23 +02:00
|
|
|
// ALERT( at_console, "%f : %f\n", Angles.x, Forward.z );
|
|
|
|
|
|
|
|
float flDot = DotProduct( Forward, m_SaveVelocity );
|
2019-10-13 13:49:25 +02:00
|
|
|
if( flDot > 0.5f )
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->velocity = m_SaveVelocity = m_SaveVelocity * m_flightSpeed;
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( flDot > 0 )
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->velocity = m_SaveVelocity = m_SaveVelocity * m_flightSpeed * ( flDot + 0.5f );
|
2016-06-04 15:24:23 +02:00
|
|
|
else
|
|
|
|
pev->velocity = m_SaveVelocity = m_SaveVelocity * 80;
|
|
|
|
|
|
|
|
// ALERT( at_console, "%.0f %.0f\n", m_flightSpeed, pev->velocity.Length() );
|
|
|
|
|
|
|
|
// ALERT( at_console, "Steer %f %f %f\n", SteeringVector.x, SteeringVector.y, SteeringVector.z );
|
|
|
|
/*
|
|
|
|
m_pBeam->SetStartPos( pev->origin + pev->velocity );
|
2016-07-31 15:48:50 +02:00
|
|
|
m_pBeam->RelinkBeam();
|
2016-06-04 15:24:23 +02:00
|
|
|
*/
|
|
|
|
// ALERT( at_console, "speed %f\n", m_flightSpeed );
|
2016-06-25 18:33:39 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
Angles = UTIL_VecToAngles( m_SaveVelocity );
|
|
|
|
|
|
|
|
// Smooth Pitch
|
|
|
|
//
|
2016-07-31 15:48:50 +02:00
|
|
|
if( Angles.x > 180 )
|
2016-06-04 15:24:23 +02:00
|
|
|
Angles.x = Angles.x - 360;
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->angles.x = UTIL_Approach( Angles.x, pev->angles.x, 50 * 0.1f );
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->angles.x < -80 )
|
|
|
|
pev->angles.x = -80;
|
|
|
|
if( pev->angles.x > 80 )
|
|
|
|
pev->angles.x = 80;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Smooth Yaw and generate Roll
|
|
|
|
//
|
|
|
|
float turn = 360;
|
|
|
|
// ALERT( at_console, "Y %.0f %.0f\n", Angles.y, pev->angles.y );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( fabs( Angles.y - pev->angles.y ) < fabs( turn ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
turn = Angles.y - pev->angles.y;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
if( fabs( Angles.y - pev->angles.y + 360 ) < fabs( turn ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
turn = Angles.y - pev->angles.y + 360;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
if( fabs( Angles.y - pev->angles.y - 360 ) < fabs( turn ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
turn = Angles.y - pev->angles.y - 360;
|
|
|
|
}
|
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
float speed = m_flightSpeed * 0.1f;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// ALERT( at_console, "speed %.0f %f\n", turn, speed );
|
2016-07-31 15:48:50 +02:00
|
|
|
if( fabs( turn ) > speed )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
if( turn < 0.0f )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
turn = -speed;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
turn = speed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pev->angles.y += turn;
|
|
|
|
pev->angles.z -= turn;
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->angles.y = fmod( ( pev->angles.y + 360.0f ), 360.0f );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
static float yaw_adj;
|
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
yaw_adj = yaw_adj * 0.8f + turn;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// ALERT( at_console, "yaw %f : %f\n", turn, yaw_adj );
|
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
SetBoneController( 0, -yaw_adj * 0.25f );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Roll Smoothing
|
|
|
|
//
|
|
|
|
turn = 360;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( fabs( Angles.z - pev->angles.z ) < fabs( turn ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
turn = Angles.z - pev->angles.z;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
if( fabs( Angles.z - pev->angles.z + 360 ) < fabs( turn ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
turn = Angles.z - pev->angles.z + 360;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
if( fabs( Angles.z - pev->angles.z - 360 ) < fabs( turn ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
turn = Angles.z - pev->angles.z - 360;
|
|
|
|
}
|
2019-10-13 13:49:25 +02:00
|
|
|
speed = m_flightSpeed / 2 * 0.1f;
|
2016-07-31 15:48:50 +02:00
|
|
|
|
|
|
|
if( fabs( turn ) < speed )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pev->angles.z += turn;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
if( turn < 0.0f )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pev->angles.z -= speed;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pev->angles.z += speed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->angles.z < -20 )
|
|
|
|
pev->angles.z = -20;
|
|
|
|
if( pev->angles.z > 20 )
|
|
|
|
pev->angles.z = 20;
|
|
|
|
|
|
|
|
UTIL_MakeVectorsPrivate( Vector( -Angles.x, Angles.y, Angles.z ), Forward, Right, Up );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
// UTIL_MoveToOrigin ( ENT( pev ), pev->origin + Forward * speed, speed, MOVE_STRAFE );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Vector CIchthyosaur::DoProbe( const Vector &Probe )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
Vector WallNormal = Vector( 0, 0, -1 ); // WATER normal is Straight Down for fish.
|
2016-06-04 15:24:23 +02:00
|
|
|
float frac;
|
2016-07-31 15:48:50 +02:00
|
|
|
BOOL bBumpedSomething = ProbeZ( pev->origin, Probe, &frac );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
TraceResult tr;
|
2016-07-31 15:48:50 +02:00
|
|
|
TRACE_MONSTER_HULL( edict(), pev->origin, Probe, dont_ignore_monsters, edict(), &tr );
|
2019-10-13 13:49:25 +02:00
|
|
|
if( tr.fAllSolid || tr.flFraction < 0.99f )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
if( tr.flFraction < 0.0f )
|
|
|
|
tr.flFraction = 0.0f;
|
|
|
|
if( tr.flFraction > 1.0f )
|
|
|
|
tr.flFraction = 1.0f;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( tr.flFraction < frac )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
frac = tr.flFraction;
|
|
|
|
bBumpedSomething = TRUE;
|
|
|
|
WallNormal = tr.vecPlaneNormal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-29 15:56:03 +02:00
|
|
|
if( bBumpedSomething && ( m_hEnemy == 0 || tr.pHit != m_hEnemy->edict() ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
Vector ProbeDir = Probe - pev->origin;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Vector NormalToProbeAndWallNormal = CrossProduct( ProbeDir, WallNormal );
|
|
|
|
Vector SteeringVector = CrossProduct( NormalToProbeAndWallNormal, ProbeDir );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
float SteeringForce = m_flightSpeed * ( 1 -frac ) * ( DotProduct( WallNormal.Normalize(), m_SaveVelocity.Normalize() ) );
|
2019-10-13 13:49:25 +02:00
|
|
|
if( SteeringForce < 0.0f )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
SteeringForce = -SteeringForce;
|
|
|
|
}
|
|
|
|
SteeringVector = SteeringForce * SteeringVector.Normalize();
|
|
|
|
|
|
|
|
return SteeringVector;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
return Vector( 0, 0, 0 );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2016-04-17 22:30:05 +02:00
|
|
|
#endif
|