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.
|
|
|
|
*
|
|
|
|
****/
|
|
|
|
//=========================================================
|
|
|
|
// human scientist (passive lab worker)
|
|
|
|
//=========================================================
|
|
|
|
|
|
|
|
#include "extdll.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "cbase.h"
|
|
|
|
#include "monsters.h"
|
|
|
|
#include "talkmonster.h"
|
|
|
|
#include "schedule.h"
|
|
|
|
#include "defaultai.h"
|
|
|
|
#include "scripted.h"
|
|
|
|
#include "animation.h"
|
|
|
|
#include "soundent.h"
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
#define NUM_SCIENTIST_HEADS 4 // four heads available for scientist model
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
HEAD_GLASSES = 0,
|
|
|
|
HEAD_EINSTEIN = 1,
|
|
|
|
HEAD_LUTHER = 2,
|
|
|
|
HEAD_SLICK = 3
|
|
|
|
};
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SCHED_HIDE = LAST_TALKMONSTER_SCHEDULE + 1,
|
|
|
|
SCHED_FEAR,
|
|
|
|
SCHED_PANIC,
|
|
|
|
SCHED_STARTLE,
|
|
|
|
SCHED_TARGET_CHASE_SCARED,
|
2016-06-25 18:33:39 +02:00
|
|
|
SCHED_TARGET_FACE_SCARED
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
TASK_SAY_HEAL = LAST_TALKMONSTER_TASK + 1,
|
|
|
|
TASK_HEAL,
|
|
|
|
TASK_SAY_FEAR,
|
|
|
|
TASK_RUN_PATH_SCARED,
|
|
|
|
TASK_SCREAM,
|
|
|
|
TASK_RANDOM_SCREAM,
|
2016-06-25 18:33:39 +02:00
|
|
|
TASK_MOVE_TO_TARGET_RANGE_SCARED
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Monster's Anim Events Go Here
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
#define SCIENTIST_AE_HEAL ( 1 )
|
2016-06-04 15:24:23 +02:00
|
|
|
#define SCIENTIST_AE_NEEDLEON ( 2 )
|
|
|
|
#define SCIENTIST_AE_NEEDLEOFF ( 3 )
|
|
|
|
|
|
|
|
//=======================================================
|
|
|
|
// Scientist
|
|
|
|
//=======================================================
|
|
|
|
class CScientist : public CTalkMonster
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void Spawn( void );
|
|
|
|
void Precache( void );
|
|
|
|
|
|
|
|
void SetYawSpeed( void );
|
2016-07-31 15:48:50 +02:00
|
|
|
int Classify( void );
|
2016-06-04 15:24:23 +02:00
|
|
|
void HandleAnimEvent( MonsterEvent_t *pEvent );
|
|
|
|
void RunTask( Task_t *pTask );
|
|
|
|
void StartTask( Task_t *pTask );
|
2016-07-31 15:48:50 +02:00
|
|
|
int ObjectCaps( void ) { return CTalkMonster::ObjectCaps() | FCAP_IMPULSE_USE; }
|
|
|
|
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
|
2016-06-04 15:24:23 +02:00
|
|
|
virtual int FriendNumber( int arrayNumber );
|
2016-07-31 15:48:50 +02:00
|
|
|
void SetActivity( Activity newActivity );
|
2016-06-04 15:24:23 +02:00
|
|
|
Activity GetStoppedActivity( void );
|
|
|
|
int ISoundMask( void );
|
|
|
|
void DeclineFollowing( void );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
float CoverRadius( void ) { return 1200; } // Need more room for cover because scientists want to get far away!
|
|
|
|
BOOL DisregardEnemy( CBaseEntity *pEnemy ) { return !pEnemy->IsAlive() || ( gpGlobals->time - m_fearTime ) > 15; }
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
BOOL CanHeal( void );
|
|
|
|
void Heal( void );
|
|
|
|
void Scream( void );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Override these to set behavior
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t *GetScheduleOfType( int Type );
|
|
|
|
Schedule_t *GetSchedule( void );
|
|
|
|
MONSTERSTATE GetIdealState( void );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
void DeathSound( void );
|
|
|
|
void PainSound( void );
|
2016-06-25 18:33:39 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
void TalkInit( void );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void Killed( entvars_t *pevAttacker, int iGib );
|
|
|
|
|
|
|
|
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 18:33:39 +02:00
|
|
|
CUSTOM_SCHEDULES
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
float m_painTime;
|
|
|
|
float m_healTime;
|
|
|
|
float m_fearTime;
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
LINK_ENTITY_TO_CLASS( monster_scientist, CScientist )
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
TYPEDESCRIPTION CScientist::m_SaveData[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
DEFINE_FIELD( CScientist, m_painTime, FIELD_TIME ),
|
|
|
|
DEFINE_FIELD( CScientist, m_healTime, FIELD_TIME ),
|
|
|
|
DEFINE_FIELD( CScientist, m_fearTime, FIELD_TIME ),
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
IMPLEMENT_SAVERESTORE( CScientist, CTalkMonster )
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// AI Schedules Specific to this monster
|
|
|
|
//=========================================================
|
|
|
|
Task_t tlFollow[] =
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_SET_FAIL_SCHEDULE, (float)SCHED_CANT_FOLLOW }, // If you fail, bail out of follow
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_MOVE_TO_TARGET_RANGE, 128.0f }, // Move within 128 of target ent (client)
|
2016-07-31 15:48:50 +02:00
|
|
|
//{ TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE },
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t slFollow[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
{
|
|
|
|
tlFollow,
|
2016-07-31 15:48:50 +02:00
|
|
|
ARRAYSIZE( tlFollow ),
|
2016-06-04 15:24:23 +02:00
|
|
|
bits_COND_NEW_ENEMY |
|
|
|
|
bits_COND_LIGHT_DAMAGE |
|
|
|
|
bits_COND_HEAVY_DAMAGE |
|
|
|
|
bits_COND_HEAR_SOUND,
|
|
|
|
bits_SOUND_COMBAT |
|
|
|
|
bits_SOUND_DANGER,
|
|
|
|
"Follow"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Task_t tlFollowScared[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_SET_FAIL_SCHEDULE, (float)SCHED_TARGET_CHASE },// If you fail, follow normally
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_MOVE_TO_TARGET_RANGE_SCARED, 128.0f }, // Move within 128 of target ent (client)
|
2016-07-31 15:48:50 +02:00
|
|
|
//{ TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE_SCARED },
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t slFollowScared[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
{
|
|
|
|
tlFollowScared,
|
2016-07-31 15:48:50 +02:00
|
|
|
ARRAYSIZE( tlFollowScared ),
|
2016-06-04 15:24:23 +02:00
|
|
|
bits_COND_NEW_ENEMY |
|
|
|
|
bits_COND_HEAR_SOUND |
|
|
|
|
bits_COND_LIGHT_DAMAGE |
|
|
|
|
bits_COND_HEAVY_DAMAGE,
|
|
|
|
bits_SOUND_DANGER,
|
|
|
|
"FollowScared"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Task_t tlFaceTargetScared[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_FACE_TARGET, 0.0f },
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_SET_ACTIVITY, (float)ACT_CROUCHIDLE },
|
|
|
|
{ TASK_SET_SCHEDULE, (float)SCHED_TARGET_CHASE_SCARED },
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t slFaceTargetScared[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
{
|
|
|
|
tlFaceTargetScared,
|
2016-07-31 15:48:50 +02:00
|
|
|
ARRAYSIZE( tlFaceTargetScared ),
|
2016-06-04 15:24:23 +02:00
|
|
|
bits_COND_HEAR_SOUND |
|
|
|
|
bits_COND_NEW_ENEMY,
|
|
|
|
bits_SOUND_DANGER,
|
|
|
|
"FaceTargetScared"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Task_t tlStopFollowing[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_CANT_FOLLOW, 0.0f },
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t slStopFollowing[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
{
|
|
|
|
tlStopFollowing,
|
2016-07-31 15:48:50 +02:00
|
|
|
ARRAYSIZE( tlStopFollowing ),
|
2016-06-04 15:24:23 +02:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"StopFollowing"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Task_t tlHeal[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_MOVE_TO_TARGET_RANGE, 50.0f }, // Move within 60 of target ent (client)
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_SET_FAIL_SCHEDULE, (float)SCHED_TARGET_CHASE }, // If you fail, catch up with that guy! (change this to put syringe away and then chase)
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_FACE_IDEAL, 0.0f },
|
|
|
|
{ TASK_SAY_HEAL, 0.0f },
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_PLAY_SEQUENCE_FACE_TARGET, (float)ACT_ARM }, // Whip out the needle
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_HEAL, 0.0f }, // Put it in the player
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_PLAY_SEQUENCE_FACE_TARGET, (float)ACT_DISARM }, // Put away the needle
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t slHeal[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
{
|
|
|
|
tlHeal,
|
2016-07-31 15:48:50 +02:00
|
|
|
ARRAYSIZE( tlHeal ),
|
2016-06-04 15:24:23 +02:00
|
|
|
0, // Don't interrupt or he'll end up running around with a needle all the time
|
|
|
|
0,
|
|
|
|
"Heal"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Task_t tlFaceTarget[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_STOP_MOVING, 0.0f },
|
|
|
|
{ TASK_FACE_TARGET, 0.0f },
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
|
|
|
|
{ TASK_SET_SCHEDULE, (float)SCHED_TARGET_CHASE },
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t slFaceTarget[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
{
|
|
|
|
tlFaceTarget,
|
2016-07-31 15:48:50 +02:00
|
|
|
ARRAYSIZE( tlFaceTarget ),
|
2016-06-04 15:24:23 +02:00
|
|
|
bits_COND_CLIENT_PUSH |
|
|
|
|
bits_COND_NEW_ENEMY |
|
|
|
|
bits_COND_HEAR_SOUND,
|
|
|
|
bits_SOUND_COMBAT |
|
|
|
|
bits_SOUND_DANGER,
|
|
|
|
"FaceTarget"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Task_t tlSciPanic[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_STOP_MOVING, 0.0f },
|
|
|
|
{ TASK_FACE_ENEMY, 0.0f },
|
|
|
|
{ TASK_SCREAM, 0.0f },
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_EXCITED }, // This is really fear-stricken excitement
|
|
|
|
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t slSciPanic[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
{
|
|
|
|
tlSciPanic,
|
2016-07-31 15:48:50 +02:00
|
|
|
ARRAYSIZE( tlSciPanic ),
|
2016-06-04 15:24:23 +02:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
"SciPanic"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Task_t tlIdleSciStand[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_STOP_MOVING, 0 },
|
|
|
|
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_WAIT, 2.0f }, // repick IDLESTAND every two seconds.
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_TLK_HEADRESET, (float)0 }, // reset head position
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t slIdleSciStand[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
{
|
2016-06-04 15:24:23 +02:00
|
|
|
tlIdleSciStand,
|
2016-07-31 15:48:50 +02:00
|
|
|
ARRAYSIZE( tlIdleSciStand ),
|
|
|
|
bits_COND_NEW_ENEMY |
|
|
|
|
bits_COND_LIGHT_DAMAGE |
|
|
|
|
bits_COND_HEAVY_DAMAGE |
|
|
|
|
bits_COND_HEAR_SOUND |
|
|
|
|
bits_COND_SMELL |
|
|
|
|
bits_COND_CLIENT_PUSH |
|
2016-06-04 15:24:23 +02:00
|
|
|
bits_COND_PROVOKED,
|
2016-07-31 15:48:50 +02:00
|
|
|
bits_SOUND_COMBAT |// sound flags
|
|
|
|
//bits_SOUND_PLAYER |
|
|
|
|
//bits_SOUND_WORLD |
|
|
|
|
bits_SOUND_DANGER |
|
|
|
|
bits_SOUND_MEAT |// scents
|
|
|
|
bits_SOUND_CARCASS |
|
2016-06-04 15:24:23 +02:00
|
|
|
bits_SOUND_GARBAGE,
|
|
|
|
"IdleSciStand"
|
|
|
|
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Task_t tlScientistCover[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic!
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_STOP_MOVING, 0.0f },
|
|
|
|
{ TASK_FIND_COVER_FROM_ENEMY, 0.0f },
|
|
|
|
{ TASK_RUN_PATH_SCARED, 0.0f },
|
|
|
|
{ TASK_TURN_LEFT, 179.0f },
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_SET_SCHEDULE, (float)SCHED_HIDE },
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t slScientistCover[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
{
|
2016-06-04 15:24:23 +02:00
|
|
|
tlScientistCover,
|
2016-07-31 15:48:50 +02:00
|
|
|
ARRAYSIZE( tlScientistCover ),
|
2016-06-04 15:24:23 +02:00
|
|
|
bits_COND_NEW_ENEMY,
|
|
|
|
0,
|
|
|
|
"ScientistCover"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Task_t tlScientistHide[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic!
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_STOP_MOVING, 0.0f },
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_PLAY_SEQUENCE, (float)ACT_CROUCH },
|
|
|
|
{ TASK_SET_ACTIVITY, (float)ACT_CROUCHIDLE }, // FIXME: This looks lame
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_WAIT_RANDOM, 10.0f },
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t slScientistHide[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
{
|
2016-06-04 15:24:23 +02:00
|
|
|
tlScientistHide,
|
2016-07-31 15:48:50 +02:00
|
|
|
ARRAYSIZE( tlScientistHide ),
|
2016-06-04 15:24:23 +02:00
|
|
|
bits_COND_NEW_ENEMY |
|
|
|
|
bits_COND_HEAR_SOUND |
|
|
|
|
bits_COND_SEE_ENEMY |
|
|
|
|
bits_COND_SEE_HATE |
|
|
|
|
bits_COND_SEE_FEAR |
|
|
|
|
bits_COND_SEE_DISLIKE,
|
|
|
|
bits_SOUND_DANGER,
|
|
|
|
"ScientistHide"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Task_t tlScientistStartle[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_SET_FAIL_SCHEDULE, (float)SCHED_PANIC }, // If you fail, just panic!
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_RANDOM_SCREAM, 0.3f }, // Scream 30% of the time
|
|
|
|
{ TASK_STOP_MOVING, 0.0f },
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_CROUCH },
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_RANDOM_SCREAM, 0.1f }, // Scream again 10% of the time
|
2016-07-31 15:48:50 +02:00
|
|
|
{ TASK_PLAY_SEQUENCE_FACE_ENEMY, (float)ACT_CROUCHIDLE },
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_WAIT_RANDOM, 1.0f },
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t slScientistStartle[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
{
|
2016-06-04 15:24:23 +02:00
|
|
|
tlScientistStartle,
|
2016-07-31 15:48:50 +02:00
|
|
|
ARRAYSIZE( tlScientistStartle ),
|
2016-06-04 15:24:23 +02:00
|
|
|
bits_COND_NEW_ENEMY |
|
|
|
|
bits_COND_SEE_ENEMY |
|
|
|
|
bits_COND_SEE_HATE |
|
|
|
|
bits_COND_SEE_FEAR |
|
|
|
|
bits_COND_SEE_DISLIKE,
|
|
|
|
0,
|
|
|
|
"ScientistStartle"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Task_t tlFear[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
{ TASK_STOP_MOVING, 0.0f },
|
|
|
|
{ TASK_FACE_ENEMY, 0.0f },
|
|
|
|
{ TASK_SAY_FEAR, 0.0f },
|
2016-07-31 15:48:50 +02:00
|
|
|
//{ TASK_PLAY_SEQUENCE, (float)ACT_FEAR_DISPLAY },
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t slFear[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
{
|
2016-06-04 15:24:23 +02:00
|
|
|
tlFear,
|
2016-07-31 15:48:50 +02:00
|
|
|
ARRAYSIZE( tlFear ),
|
2016-06-04 15:24:23 +02:00
|
|
|
bits_COND_NEW_ENEMY,
|
|
|
|
0,
|
|
|
|
"Fear"
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_CUSTOM_SCHEDULES( CScientist )
|
|
|
|
{
|
|
|
|
slFollow,
|
|
|
|
slFaceTarget,
|
|
|
|
slIdleSciStand,
|
|
|
|
slFear,
|
|
|
|
slScientistCover,
|
|
|
|
slScientistHide,
|
|
|
|
slScientistStartle,
|
|
|
|
slHeal,
|
|
|
|
slStopFollowing,
|
|
|
|
slSciPanic,
|
|
|
|
slFollowScared,
|
|
|
|
slFaceTargetScared,
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
IMPLEMENT_CUSTOM_SCHEDULES( CScientist, CTalkMonster )
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
void CScientist::DeclineFollowing( void )
|
|
|
|
{
|
|
|
|
Talk( 10 );
|
|
|
|
m_hTalkTarget = m_hEnemy;
|
|
|
|
PlaySentence( "SC_POK", 2, VOL_NORM, ATTN_NORM );
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CScientist::Scream( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( FOkToSpeak() )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
Talk( 10 );
|
|
|
|
m_hTalkTarget = m_hEnemy;
|
2019-10-13 13:49:25 +02:00
|
|
|
PlaySentence( "SC_SCREAM", RANDOM_FLOAT( 3.0f, 6.0f ), VOL_NORM, ATTN_NORM );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Activity CScientist::GetStoppedActivity( void )
|
|
|
|
{
|
2017-06-29 15:56:03 +02:00
|
|
|
if( m_hEnemy != 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
return ACT_EXCITED;
|
|
|
|
return CTalkMonster::GetStoppedActivity();
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CScientist::StartTask( Task_t *pTask )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
switch( pTask->iTask )
|
|
|
|
{
|
|
|
|
case TASK_SAY_HEAL:
|
2016-07-31 15:48:50 +02:00
|
|
|
//if( FOkToSpeak() )
|
2016-06-04 15:24:23 +02:00
|
|
|
Talk( 2 );
|
|
|
|
m_hTalkTarget = m_hTargetEnt;
|
|
|
|
PlaySentence( "SC_HEAL", 2, VOL_NORM, ATTN_IDLE );
|
|
|
|
TaskComplete();
|
|
|
|
break;
|
|
|
|
case TASK_SCREAM:
|
|
|
|
Scream();
|
|
|
|
TaskComplete();
|
|
|
|
break;
|
|
|
|
case TASK_RANDOM_SCREAM:
|
2019-10-13 13:49:25 +02:00
|
|
|
if( RANDOM_FLOAT( 0.0f, 1.0f ) < pTask->flData )
|
2016-06-04 15:24:23 +02:00
|
|
|
Scream();
|
|
|
|
TaskComplete();
|
|
|
|
break;
|
|
|
|
case TASK_SAY_FEAR:
|
2016-07-31 15:48:50 +02:00
|
|
|
if( FOkToSpeak() )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
Talk( 2 );
|
|
|
|
m_hTalkTarget = m_hEnemy;
|
2017-07-02 18:17:51 +02:00
|
|
|
|
|
|
|
//The enemy can be null here. - Solokiller
|
|
|
|
//Discovered while testing the barnacle grapple on headcrabs with scientists in view.
|
2017-10-14 21:12:26 +02:00
|
|
|
if( m_hEnemy != 0 && m_hEnemy->IsPlayer() )
|
2016-06-04 15:24:23 +02:00
|
|
|
PlaySentence( "SC_PLFEAR", 5, VOL_NORM, ATTN_NORM );
|
|
|
|
else
|
|
|
|
PlaySentence( "SC_FEAR", 5, VOL_NORM, ATTN_NORM );
|
|
|
|
}
|
|
|
|
TaskComplete();
|
|
|
|
break;
|
|
|
|
case TASK_HEAL:
|
|
|
|
m_IdealActivity = ACT_MELEE_ATTACK1;
|
|
|
|
break;
|
|
|
|
case TASK_RUN_PATH_SCARED:
|
|
|
|
m_movementActivity = ACT_RUN_SCARED;
|
|
|
|
break;
|
|
|
|
case TASK_MOVE_TO_TARGET_RANGE_SCARED:
|
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
if( ( m_hTargetEnt->pev->origin - pev->origin ).Length() < 1.0f )
|
|
|
|
{
|
2016-06-04 15:24:23 +02:00
|
|
|
TaskComplete();
|
2019-10-13 13:49:25 +02:00
|
|
|
}
|
2016-06-04 15:24:23 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_vecMoveGoal = m_hTargetEnt->pev->origin;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !MoveToTarget( ACT_WALK_SCARED, 0.5 ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
TaskFail();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CTalkMonster::StartTask( pTask );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CScientist::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_RUN_PATH_SCARED:
|
2016-07-31 15:48:50 +02:00
|
|
|
if( MovementIsComplete() )
|
2016-06-04 15:24:23 +02:00
|
|
|
TaskComplete();
|
2016-07-31 15:48:50 +02:00
|
|
|
if( RANDOM_LONG( 0, 31 ) < 8 )
|
2016-06-04 15:24:23 +02:00
|
|
|
Scream();
|
|
|
|
break;
|
|
|
|
case TASK_MOVE_TO_TARGET_RANGE_SCARED:
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( RANDOM_LONG( 0, 63 ) < 8 )
|
2016-06-04 15:24:23 +02:00
|
|
|
Scream();
|
|
|
|
|
2017-06-29 15:56:03 +02:00
|
|
|
if( m_hEnemy == 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
TaskFail();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float distance;
|
|
|
|
|
|
|
|
distance = ( m_vecMoveGoal - pev->origin ).Length2D();
|
|
|
|
// Re-evaluate when you think your finished, or the target has moved too far
|
2019-10-13 13:49:25 +02:00
|
|
|
if( ( distance < pTask->flData ) || ( m_vecMoveGoal - m_hTargetEnt->pev->origin ).Length() > pTask->flData * 0.5f )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_vecMoveGoal = m_hTargetEnt->pev->origin;
|
|
|
|
distance = ( m_vecMoveGoal - pev->origin ).Length2D();
|
|
|
|
FRefreshRoute();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the appropriate activity based on an overlapping range
|
|
|
|
// overlap the range to prevent oscillation
|
2016-07-31 15:48:50 +02:00
|
|
|
if( distance < pTask->flData )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
TaskComplete();
|
|
|
|
RouteClear(); // Stop moving
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( distance < 190 && m_movementActivity != ACT_WALK_SCARED )
|
2016-06-04 15:24:23 +02:00
|
|
|
m_movementActivity = ACT_WALK_SCARED;
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( distance >= 270 && m_movementActivity != ACT_RUN_SCARED )
|
2016-06-04 15:24:23 +02:00
|
|
|
m_movementActivity = ACT_RUN_SCARED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TASK_HEAL:
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_fSequenceFinished )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
TaskComplete();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( TargetDistance() > 90 )
|
2016-06-04 15:24:23 +02:00
|
|
|
TaskComplete();
|
|
|
|
pev->ideal_yaw = UTIL_VecToYaw( m_hTargetEnt->pev->origin - pev->origin );
|
|
|
|
ChangeYaw( pev->yaw_speed );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CTalkMonster::RunTask( pTask );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Classify - indicates this monster's place in the
|
|
|
|
// relationship table.
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
int CScientist::Classify( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
return CLASS_HUMAN_PASSIVE;
|
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 CScientist::SetYawSpeed( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
int ys;
|
|
|
|
|
|
|
|
ys = 90;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
switch( m_Activity )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
case ACT_IDLE:
|
|
|
|
ys = 120;
|
|
|
|
break;
|
|
|
|
case ACT_WALK:
|
|
|
|
ys = 180;
|
|
|
|
break;
|
|
|
|
case ACT_RUN:
|
|
|
|
ys = 150;
|
|
|
|
break;
|
|
|
|
case ACT_TURN_LEFT:
|
|
|
|
case ACT_TURN_RIGHT:
|
|
|
|
ys = 120;
|
|
|
|
break;
|
2016-06-13 16:29:45 +02:00
|
|
|
default:
|
|
|
|
break;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pev->yaw_speed = ys;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// HandleAnimEvent - catches the monster-specific messages
|
|
|
|
// that occur when tagged animation frames are played.
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CScientist::HandleAnimEvent( MonsterEvent_t *pEvent )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
switch( pEvent->event )
|
|
|
|
{
|
|
|
|
case SCIENTIST_AE_HEAL: // Heal my target (if within range)
|
|
|
|
Heal();
|
|
|
|
break;
|
|
|
|
case SCIENTIST_AE_NEEDLEON:
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
int oldBody = pev->body;
|
|
|
|
pev->body = ( oldBody % NUM_SCIENTIST_HEADS ) + NUM_SCIENTIST_HEADS * 1;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCIENTIST_AE_NEEDLEOFF:
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
int oldBody = pev->body;
|
|
|
|
pev->body = ( oldBody % NUM_SCIENTIST_HEADS ) + NUM_SCIENTIST_HEADS * 0;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CTalkMonster::HandleAnimEvent( pEvent );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Spawn
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CScientist::Spawn( void )
|
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/scientist.mdl" );
|
|
|
|
UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->solid = SOLID_SLIDEBOX;
|
|
|
|
pev->movetype = MOVETYPE_STEP;
|
|
|
|
m_bloodColor = BLOOD_COLOR_RED;
|
|
|
|
pev->health = gSkillData.scientistHealth;
|
|
|
|
pev->view_ofs = Vector( 0, 0, 50 );// position of the eyes relative to monster's origin.
|
|
|
|
m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so scientists will notice player and say hello
|
|
|
|
m_MonsterState = MONSTERSTATE_NONE;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
//m_flDistTooFar = 256.0;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_OPEN_DOORS | bits_CAP_AUTO_DOORS | bits_CAP_USE;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// White hands
|
|
|
|
pev->skin = 0;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->body == -1 )
|
2016-06-25 18:33:39 +02:00
|
|
|
{
|
|
|
|
// -1 chooses a random head
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->body = RANDOM_LONG( 0, NUM_SCIENTIST_HEADS - 1 );// pick a head, any head
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Luther is black, make his hands black
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->body == HEAD_LUTHER )
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->skin = 1;
|
2016-06-25 18:33:39 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
MonsterInit();
|
|
|
|
SetUse( &CTalkMonster::FollowerUse );
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Precache - precaches all resources this monster needs
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CScientist::Precache( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
PRECACHE_MODEL( "models/scientist.mdl" );
|
|
|
|
PRECACHE_SOUND( "scientist/sci_pain1.wav" );
|
|
|
|
PRECACHE_SOUND( "scientist/sci_pain2.wav" );
|
|
|
|
PRECACHE_SOUND( "scientist/sci_pain3.wav" );
|
|
|
|
PRECACHE_SOUND( "scientist/sci_pain4.wav" );
|
|
|
|
PRECACHE_SOUND( "scientist/sci_pain5.wav" );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// every new scientist must call this, otherwise
|
|
|
|
// when a level is loaded, nobody will talk (time is reset to 0)
|
|
|
|
TalkInit();
|
|
|
|
|
|
|
|
CTalkMonster::Precache();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Init talk data
|
2016-07-31 15:48:50 +02:00
|
|
|
void CScientist::TalkInit()
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
CTalkMonster::TalkInit();
|
|
|
|
|
|
|
|
// scientists speach group names (group names are in sentences.txt)
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
m_szGrp[TLK_ANSWER] = "SC_ANSWER";
|
|
|
|
m_szGrp[TLK_QUESTION] = "SC_QUESTION";
|
|
|
|
m_szGrp[TLK_IDLE] = "SC_IDLE";
|
|
|
|
m_szGrp[TLK_STARE] = "SC_STARE";
|
|
|
|
m_szGrp[TLK_USE] = "SC_OK";
|
|
|
|
m_szGrp[TLK_UNUSE] = "SC_WAIT";
|
|
|
|
m_szGrp[TLK_STOP] = "SC_STOP";
|
|
|
|
m_szGrp[TLK_NOSHOOT] = "SC_SCARED";
|
|
|
|
m_szGrp[TLK_HELLO] = "SC_HELLO";
|
|
|
|
|
|
|
|
m_szGrp[TLK_PLHURT1] = "!SC_CUREA";
|
|
|
|
m_szGrp[TLK_PLHURT2] = "!SC_CUREB";
|
|
|
|
m_szGrp[TLK_PLHURT3] = "!SC_CUREC";
|
|
|
|
|
|
|
|
m_szGrp[TLK_PHELLO] = "SC_PHELLO";
|
|
|
|
m_szGrp[TLK_PIDLE] = "SC_PIDLE";
|
2016-06-04 15:24:23 +02:00
|
|
|
m_szGrp[TLK_PQUESTION] = "SC_PQUEST";
|
2016-07-31 15:48:50 +02:00
|
|
|
m_szGrp[TLK_SMELL] = "SC_SMELL";
|
2016-06-25 18:33:39 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
m_szGrp[TLK_WOUND] = "SC_WOUND";
|
|
|
|
m_szGrp[TLK_MORTAL] = "SC_MORTAL";
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// get voice for head
|
2016-07-31 15:48:50 +02:00
|
|
|
switch( pev->body % 3 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
default:
|
2016-07-31 15:48:50 +02:00
|
|
|
case HEAD_GLASSES:
|
|
|
|
m_voicePitch = 105;
|
|
|
|
break; //glasses
|
|
|
|
case HEAD_EINSTEIN:
|
|
|
|
m_voicePitch = 100;
|
|
|
|
break; //einstein
|
|
|
|
case HEAD_LUTHER:
|
|
|
|
m_voicePitch = 95;
|
|
|
|
break; //luther
|
|
|
|
case HEAD_SLICK:
|
|
|
|
m_voicePitch = 100;
|
|
|
|
break; //slick
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
int CScientist::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pevInflictor && pevInflictor->flags & FL_CLIENT )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
Remember( bits_MEMORY_PROVOKED );
|
|
|
|
StopFollowing( TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
// make sure friends talk about it if player hurts scientist...
|
2016-07-31 15:48:50 +02:00
|
|
|
return CTalkMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// ISoundMask - returns a bit mask indicating which types
|
|
|
|
// of sounds this monster regards. In the base class implementation,
|
|
|
|
// monsters care about all sounds, but no scents.
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
int CScientist::ISoundMask( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
return bits_SOUND_WORLD |
|
|
|
|
bits_SOUND_COMBAT |
|
|
|
|
bits_SOUND_DANGER |
|
2016-06-04 15:24:23 +02:00
|
|
|
bits_SOUND_PLAYER;
|
|
|
|
}
|
2016-06-25 18:33:39 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
//=========================================================
|
|
|
|
// PainSound
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CScientist::PainSound( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( gpGlobals->time < m_painTime )
|
2016-06-04 15:24:23 +02:00
|
|
|
return;
|
2016-06-25 18:33:39 +02:00
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
m_painTime = gpGlobals->time + RANDOM_FLOAT( 0.5f, 0.75f );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
switch( RANDOM_LONG( 0, 4 ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
case 0:
|
|
|
|
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "scientist/sci_pain1.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "scientist/sci_pain2.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "scientist/sci_pain3.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "scientist/sci_pain4.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "scientist/sci_pain5.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
|
|
|
break;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// DeathSound
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CScientist::DeathSound( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
PainSound();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CScientist::Killed( entvars_t *pevAttacker, int iGib )
|
|
|
|
{
|
|
|
|
SetUse( NULL );
|
|
|
|
CTalkMonster::Killed( pevAttacker, iGib );
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CScientist::SetActivity( Activity newActivity )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
int iSequence;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
iSequence = LookupActivity( newActivity );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Set to the desired anim, or default anim if the desired is not present
|
2016-07-31 15:48:50 +02:00
|
|
|
if( iSequence == ACTIVITY_NOT_AVAILABLE )
|
2016-06-04 15:24:23 +02:00
|
|
|
newActivity = ACT_IDLE;
|
|
|
|
CTalkMonster::SetActivity( newActivity );
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t *CScientist::GetScheduleOfType( int Type )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
Schedule_t *psched;
|
|
|
|
|
|
|
|
switch( Type )
|
|
|
|
{
|
|
|
|
// Hook these to make a looping schedule
|
|
|
|
case SCHED_TARGET_FACE:
|
|
|
|
// call base class default so that scientist will talk
|
2016-07-31 15:48:50 +02:00
|
|
|
// when 'used'
|
|
|
|
psched = CTalkMonster::GetScheduleOfType( Type );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( psched == slIdleStand )
|
2016-06-04 15:24:23 +02:00
|
|
|
return slFaceTarget; // override this for different target face behavior
|
|
|
|
else
|
|
|
|
return psched;
|
|
|
|
case SCHED_TARGET_CHASE:
|
|
|
|
return slFollow;
|
|
|
|
case SCHED_CANT_FOLLOW:
|
|
|
|
return slStopFollowing;
|
|
|
|
case SCHED_PANIC:
|
|
|
|
return slSciPanic;
|
|
|
|
case SCHED_TARGET_CHASE_SCARED:
|
|
|
|
return slFollowScared;
|
|
|
|
case SCHED_TARGET_FACE_SCARED:
|
|
|
|
return slFaceTargetScared;
|
|
|
|
case SCHED_IDLE_STAND:
|
|
|
|
// call base class default so that scientist will talk
|
|
|
|
// when standing during idle
|
2016-07-31 15:48:50 +02:00
|
|
|
psched = CTalkMonster::GetScheduleOfType( Type );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( psched == slIdleStand )
|
2016-06-04 15:24:23 +02:00
|
|
|
return slIdleSciStand;
|
|
|
|
else
|
|
|
|
return psched;
|
|
|
|
case SCHED_HIDE:
|
|
|
|
return slScientistHide;
|
|
|
|
case SCHED_STARTLE:
|
|
|
|
return slScientistStartle;
|
|
|
|
case SCHED_FEAR:
|
|
|
|
return slFear;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CTalkMonster::GetScheduleOfType( Type );
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
Schedule_t *CScientist::GetSchedule( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// so we don't keep calling through the EHANDLE stuff
|
|
|
|
CBaseEntity *pEnemy = m_hEnemy;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( HasConditions( bits_COND_HEAR_SOUND ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
CSound *pSound;
|
|
|
|
pSound = PBestSound();
|
|
|
|
|
|
|
|
ASSERT( pSound != NULL );
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pSound && ( pSound->m_iType & bits_SOUND_DANGER ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
return GetScheduleOfType( SCHED_TAKE_COVER_FROM_BEST_SOUND );
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( m_MonsterState )
|
|
|
|
{
|
2016-06-25 18:33:39 +02:00
|
|
|
case MONSTERSTATE_ALERT:
|
2016-06-04 15:24:23 +02:00
|
|
|
case MONSTERSTATE_IDLE:
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pEnemy )
|
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
|
|
|
m_fearTime = gpGlobals->time;
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( DisregardEnemy( pEnemy ) ) // After 15 seconds of being hidden, return to alert
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2017-06-29 15:56:03 +02:00
|
|
|
m_hEnemy = 0;
|
|
|
|
pEnemy = 0;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// flinch if hurt
|
|
|
|
return GetScheduleOfType( SCHED_SMALL_FLINCH );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cower when you hear something scary
|
2016-07-31 15:48:50 +02:00
|
|
|
if( HasConditions( bits_COND_HEAR_SOUND ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
CSound *pSound;
|
|
|
|
pSound = PBestSound();
|
|
|
|
|
|
|
|
ASSERT( pSound != NULL );
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pSound )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pSound->m_iType & ( bits_SOUND_DANGER | bits_SOUND_COMBAT ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( gpGlobals->time - m_fearTime > 3 ) // Only cower every 3 seconds or so
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_fearTime = gpGlobals->time; // Update last fear
|
|
|
|
return GetScheduleOfType( SCHED_STARTLE ); // This will just duck for a second
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Behavior for following the player
|
2016-07-31 15:48:50 +02:00
|
|
|
if( IsFollowing() )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !m_hTargetEnt->IsAlive() )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// UNDONE: Comment about the recently dead player here?
|
|
|
|
StopFollowing( FALSE );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
int relationship = R_NO;
|
|
|
|
|
|
|
|
// Nothing scary, just me and the player
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pEnemy != NULL )
|
2016-06-04 15:24:23 +02:00
|
|
|
relationship = IRelationship( pEnemy );
|
|
|
|
|
|
|
|
// UNDONE: Model fear properly, fix R_FR and add multiple levels of fear
|
2016-07-31 15:48:50 +02:00
|
|
|
if( relationship != R_DL && relationship != R_HT )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// If I'm already close enough to my target
|
2016-07-31 15:48:50 +02:00
|
|
|
if( TargetDistance() <= 128 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( CanHeal() ) // Heal opportunistically
|
2016-06-04 15:24:23 +02:00
|
|
|
return slHeal;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( HasConditions( bits_COND_CLIENT_PUSH ) ) // Player wants me to move
|
2016-06-04 15:24:23 +02:00
|
|
|
return GetScheduleOfType( SCHED_MOVE_AWAY_FOLLOW );
|
|
|
|
}
|
|
|
|
return GetScheduleOfType( SCHED_TARGET_FACE ); // Just face and follow.
|
|
|
|
}
|
|
|
|
else // UNDONE: When afraid, scientist won't move out of your way. Keep This? If not, write move away scared
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( HasConditions( bits_COND_NEW_ENEMY ) ) // I just saw something new and scary, react
|
2016-06-04 15:24:23 +02:00
|
|
|
return GetScheduleOfType( SCHED_FEAR ); // React to something scary
|
|
|
|
return GetScheduleOfType( SCHED_TARGET_FACE_SCARED ); // face and follow, but I'm scared!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( HasConditions( bits_COND_CLIENT_PUSH ) ) // Player wants me to move
|
2016-06-04 15:24:23 +02:00
|
|
|
return GetScheduleOfType( SCHED_MOVE_AWAY );
|
|
|
|
|
|
|
|
// try to say something about smells
|
|
|
|
TrySmellTalk();
|
|
|
|
break;
|
|
|
|
case MONSTERSTATE_COMBAT:
|
2016-07-31 15:48:50 +02:00
|
|
|
if( HasConditions( bits_COND_NEW_ENEMY ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
return slFear; // Point and scream!
|
2016-07-31 15:48:50 +02:00
|
|
|
if( HasConditions( bits_COND_SEE_ENEMY ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
return slScientistCover; // Take Cover
|
2016-07-31 15:48:50 +02:00
|
|
|
|
|
|
|
if( HasConditions( bits_COND_HEAR_SOUND ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
return slTakeCoverFromBestSound; // Cower and panic from the scary sound!
|
|
|
|
|
|
|
|
return slScientistCover; // Run & Cower
|
|
|
|
break;
|
2016-06-13 16:29:45 +02:00
|
|
|
default:
|
|
|
|
break;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return CTalkMonster::GetSchedule();
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
MONSTERSTATE CScientist::GetIdealState( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
switch( m_MonsterState )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
case MONSTERSTATE_ALERT:
|
|
|
|
case MONSTERSTATE_IDLE:
|
2016-07-31 15:48:50 +02:00
|
|
|
if( HasConditions( bits_COND_NEW_ENEMY ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( IsFollowing() )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
int relationship = IRelationship( m_hEnemy );
|
2016-07-31 15:48:50 +02:00
|
|
|
if( relationship != R_FR || ( relationship != R_HT && !HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// Don't go to combat if you're following the player
|
|
|
|
m_IdealMonsterState = MONSTERSTATE_ALERT;
|
|
|
|
return m_IdealMonsterState;
|
|
|
|
}
|
|
|
|
StopFollowing( TRUE );
|
|
|
|
}
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// Stop following if you take damage
|
2016-07-31 15:48:50 +02:00
|
|
|
if( IsFollowing() )
|
2016-06-04 15:24:23 +02:00
|
|
|
StopFollowing( TRUE );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MONSTERSTATE_COMBAT:
|
|
|
|
{
|
|
|
|
CBaseEntity *pEnemy = m_hEnemy;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pEnemy != NULL )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( DisregardEnemy( pEnemy ) ) // After 15 seconds of being hidden, return to alert
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// Strip enemy when going to alert
|
|
|
|
m_IdealMonsterState = MONSTERSTATE_ALERT;
|
2017-06-29 15:56:03 +02:00
|
|
|
m_hEnemy = 0;
|
2016-06-04 15:24:23 +02:00
|
|
|
return m_IdealMonsterState;
|
|
|
|
}
|
2016-06-25 18:33:39 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
// Follow if only scared a little
|
2017-06-29 15:56:03 +02:00
|
|
|
if( m_hTargetEnt != 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_IdealMonsterState = MONSTERSTATE_ALERT;
|
|
|
|
return m_IdealMonsterState;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( HasConditions( bits_COND_SEE_ENEMY ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_fearTime = gpGlobals->time;
|
|
|
|
m_IdealMonsterState = MONSTERSTATE_COMBAT;
|
|
|
|
return m_IdealMonsterState;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2016-06-13 16:29:45 +02:00
|
|
|
default:
|
|
|
|
break;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return CTalkMonster::GetIdealState();
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CScientist::CanHeal( void )
|
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
if( ( m_healTime > gpGlobals->time ) || ( m_hTargetEnt == 0 ) || ( m_hTargetEnt->pev->health > ( m_hTargetEnt->pev->max_health * 0.5f ) ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CScientist::Heal( void )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !CanHeal() )
|
2016-06-04 15:24:23 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
Vector target = m_hTargetEnt->pev->origin - pev->origin;
|
2019-10-13 13:49:25 +02:00
|
|
|
if( target.Length() > 100.0f )
|
2016-06-04 15:24:23 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
m_hTargetEnt->TakeHealth( gSkillData.scientistHeal, DMG_GENERIC );
|
|
|
|
// Don't heal again for 1 minute
|
|
|
|
m_healTime = gpGlobals->time + 60;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CScientist::FriendNumber( int arrayNumber )
|
|
|
|
{
|
|
|
|
static int array[3] = { 1, 2, 0 };
|
2016-07-31 15:48:50 +02:00
|
|
|
if( arrayNumber < 3 )
|
|
|
|
return array[arrayNumber];
|
2016-06-04 15:24:23 +02:00
|
|
|
return arrayNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Dead Scientist PROP
|
|
|
|
//=========================================================
|
|
|
|
class CDeadScientist : public CBaseMonster
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void Spawn( void );
|
2016-07-31 15:48:50 +02:00
|
|
|
int Classify( void )
|
|
|
|
{
|
|
|
|
return CLASS_HUMAN_PASSIVE;
|
|
|
|
}
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
void KeyValue( KeyValueData *pkvd );
|
2016-07-31 15:48:50 +02:00
|
|
|
int m_iPose;// which sequence to display
|
2017-06-29 15:56:03 +02:00
|
|
|
static const char *m_szPoses[7];
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2017-06-29 15:56:03 +02:00
|
|
|
const char *CDeadScientist::m_szPoses[] =
|
2016-07-31 15:48:50 +02:00
|
|
|
{
|
|
|
|
"lying_on_back",
|
|
|
|
"lying_on_stomach",
|
|
|
|
"dead_sitting",
|
|
|
|
"dead_hang",
|
|
|
|
"dead_table1",
|
|
|
|
"dead_table2",
|
|
|
|
"dead_table3"
|
|
|
|
};
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
void CDeadScientist::KeyValue( KeyValueData *pkvd )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( FStrEq( pkvd->szKeyName, "pose" ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
m_iPose = atoi( pkvd->szValue );
|
2016-06-04 15:24:23 +02:00
|
|
|
pkvd->fHandled = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
CBaseMonster::KeyValue( pkvd );
|
|
|
|
}
|
2016-06-25 18:33:39 +02:00
|
|
|
LINK_ENTITY_TO_CLASS( monster_scientist_dead, CDeadScientist )
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// ********** DeadScientist SPAWN **********
|
|
|
|
//
|
2016-07-31 15:48:50 +02:00
|
|
|
void CDeadScientist::Spawn()
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
PRECACHE_MODEL( "models/scientist.mdl" );
|
|
|
|
SET_MODEL( ENT( pev ), "models/scientist.mdl" );
|
|
|
|
|
|
|
|
pev->effects = 0;
|
|
|
|
pev->sequence = 0;
|
2016-06-25 18:33:39 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
// Corpses have less health
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->health = 8;//gSkillData.scientistHealth;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
m_bloodColor = BLOOD_COLOR_RED;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->body == -1 )
|
2016-06-25 18:33:39 +02:00
|
|
|
{
|
|
|
|
// -1 chooses a random head
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->body = RANDOM_LONG( 0, NUM_SCIENTIST_HEADS - 1 );// pick a head, any head
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2016-06-25 18:33:39 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
// Luther is black, make his hands black
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->body == HEAD_LUTHER )
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->skin = 1;
|
|
|
|
else
|
|
|
|
pev->skin = 0;
|
|
|
|
|
|
|
|
pev->sequence = LookupSequence( m_szPoses[m_iPose] );
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->sequence == -1 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
ALERT ( at_console, "Dead scientist with bad pose\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
// pev->skin += 2; // use bloody skin -- UNDONE: Turn this back on when we have a bloody skin again!
|
|
|
|
MonsterInitDead();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Sitting Scientist PROP
|
|
|
|
//=========================================================
|
|
|
|
class CSittingScientist : public CScientist // kdb: changed from public CBaseMonster so he can speak
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void Spawn( void );
|
2016-07-31 15:48:50 +02:00
|
|
|
void Precache( void );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
void EXPORT SittingThink( void );
|
2016-07-31 15:48:50 +02:00
|
|
|
int Classify( void );
|
|
|
|
virtual int Save( CSave &save );
|
|
|
|
virtual int Restore( CRestore &restore );
|
|
|
|
static TYPEDESCRIPTION m_SaveData[];
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
virtual void SetAnswerQuestion( CTalkMonster *pSpeaker );
|
|
|
|
int FriendNumber( int arrayNumber );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
int FIdleSpeak( void );
|
|
|
|
int m_baseSequence;
|
|
|
|
int m_headTurn;
|
|
|
|
float m_flResponseDelay;
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
LINK_ENTITY_TO_CLASS( monster_sitting_scientist, CSittingScientist )
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
TYPEDESCRIPTION CSittingScientist::m_SaveData[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// Don't need to save/restore m_baseSequence (recalced)
|
|
|
|
DEFINE_FIELD( CSittingScientist, m_headTurn, FIELD_INTEGER ),
|
|
|
|
DEFINE_FIELD( CSittingScientist, m_flResponseDelay, FIELD_FLOAT ),
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
IMPLEMENT_SAVERESTORE( CSittingScientist, CScientist )
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// animation sequence aliases
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
SITTING_ANIM_sitlookleft,
|
|
|
|
SITTING_ANIM_sitlookright,
|
|
|
|
SITTING_ANIM_sitscared,
|
|
|
|
SITTING_ANIM_sitting2,
|
|
|
|
SITTING_ANIM_sitting3
|
|
|
|
} SITTING_ANIM;
|
|
|
|
|
|
|
|
//
|
|
|
|
// ********** Scientist SPAWN **********
|
|
|
|
//
|
2016-07-31 15:48:50 +02:00
|
|
|
void CSittingScientist::Spawn()
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
PRECACHE_MODEL( "models/scientist.mdl" );
|
|
|
|
SET_MODEL( ENT( pev ), "models/scientist.mdl" );
|
2016-06-04 15:24:23 +02:00
|
|
|
Precache();
|
|
|
|
InitBoneControllers();
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
UTIL_SetSize( pev, Vector( -14, -14, 0 ), Vector( 14, 14, 36 ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->solid = SOLID_SLIDEBOX;
|
|
|
|
pev->movetype = MOVETYPE_STEP;
|
|
|
|
pev->effects = 0;
|
|
|
|
pev->health = 50;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
m_bloodColor = BLOOD_COLOR_RED;
|
2016-07-31 15:48:50 +02:00
|
|
|
m_flFieldOfView = VIEW_FIELD_WIDE; // indicates the width of this monster's forward view cone ( as a dotproduct result )
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
m_afCapability= bits_CAP_HEAR | bits_CAP_TURN_HEAD;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
SetBits( pev->spawnflags, SF_MONSTER_PREDISASTER ); // predisaster only!
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->body == -1 )
|
2016-06-25 18:33:39 +02:00
|
|
|
{
|
|
|
|
// -1 chooses a random head
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->body = RANDOM_LONG( 0, NUM_SCIENTIST_HEADS - 1 );// pick a head, any head
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2016-06-25 18:33:39 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
// Luther is black, make his hands black
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->body == HEAD_LUTHER )
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->skin = 1;
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
m_baseSequence = LookupSequence( "sitlookleft" );
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->sequence = m_baseSequence + RANDOM_LONG( 0, 4 );
|
|
|
|
ResetSequenceInfo();
|
|
|
|
|
|
|
|
SetThink( &CSittingScientist::SittingThink );
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->nextthink = gpGlobals->time + 0.1f;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
DROP_TO_FLOOR( ENT( pev ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CSittingScientist::Precache( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_baseSequence = LookupSequence( "sitlookleft" );
|
|
|
|
TalkInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// ID as a passive human
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
int CSittingScientist::Classify( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
return CLASS_HUMAN_PASSIVE;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int CSittingScientist::FriendNumber( int arrayNumber )
|
|
|
|
{
|
|
|
|
static int array[3] = { 2, 1, 0 };
|
2016-07-31 15:48:50 +02:00
|
|
|
if( arrayNumber < 3 )
|
|
|
|
return array[arrayNumber];
|
2016-06-04 15:24:23 +02:00
|
|
|
return arrayNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// sit, do stuff
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CSittingScientist::SittingThink( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
CBaseEntity *pent;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
StudioFrameAdvance();
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// try to greet player
|
2016-07-31 15:48:50 +02:00
|
|
|
if( FIdleHello() )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
pent = FindNearestFriend( TRUE );
|
|
|
|
if( pent )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
float yaw = VecToYaw( pent->pev->origin - pev->origin ) - pev->angles.y;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( yaw > 180 )
|
|
|
|
yaw -= 360;
|
|
|
|
if( yaw < -180 )
|
|
|
|
yaw += 360;
|
|
|
|
|
|
|
|
if( yaw > 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->sequence = m_baseSequence + SITTING_ANIM_sitlookleft;
|
|
|
|
else
|
|
|
|
pev->sequence = m_baseSequence + SITTING_ANIM_sitlookright;
|
2016-07-31 15:48:50 +02:00
|
|
|
|
|
|
|
ResetSequenceInfo();
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->frame = 0;
|
|
|
|
SetBoneController( 0, 0 );
|
|
|
|
}
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( m_fSequenceFinished )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
int i = RANDOM_LONG( 0, 99 );
|
2016-06-04 15:24:23 +02:00
|
|
|
m_headTurn = 0;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_flResponseDelay && gpGlobals->time > m_flResponseDelay )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// respond to question
|
|
|
|
IdleRespond();
|
|
|
|
pev->sequence = m_baseSequence + SITTING_ANIM_sitscared;
|
|
|
|
m_flResponseDelay = 0;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( i < 30 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pev->sequence = m_baseSequence + SITTING_ANIM_sitting3;
|
|
|
|
|
|
|
|
// turn towards player or nearest friend and speak
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !FBitSet( m_bitsSaid, bit_saidHelloPlayer ) )
|
|
|
|
pent = FindNearestFriend( TRUE );
|
2016-06-04 15:24:23 +02:00
|
|
|
else
|
2016-07-31 15:48:50 +02:00
|
|
|
pent = FindNearestFriend( FALSE );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !FIdleSpeak() || !pent )
|
|
|
|
{
|
|
|
|
m_headTurn = RANDOM_LONG( 0, 8 ) * 10 - 40;
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->sequence = m_baseSequence + SITTING_ANIM_sitting3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// only turn head if we spoke
|
2016-07-31 15:48:50 +02:00
|
|
|
float yaw = VecToYaw( pent->pev->origin - pev->origin ) - pev->angles.y;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( yaw > 180 )
|
|
|
|
yaw -= 360;
|
|
|
|
if( yaw < -180 )
|
|
|
|
yaw += 360;
|
|
|
|
|
|
|
|
if( yaw > 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->sequence = m_baseSequence + SITTING_ANIM_sitlookleft;
|
|
|
|
else
|
|
|
|
pev->sequence = m_baseSequence + SITTING_ANIM_sitlookright;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
//ALERT( at_console, "sitting speak\n" );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( i < 60 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pev->sequence = m_baseSequence + SITTING_ANIM_sitting3;
|
2016-07-31 15:48:50 +02:00
|
|
|
m_headTurn = RANDOM_LONG( 0, 8 ) * 10 - 40;
|
|
|
|
if( RANDOM_LONG( 0, 99 ) < 5 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
//ALERT( at_console, "sitting speak2\n" );
|
2016-06-04 15:24:23 +02:00
|
|
|
FIdleSpeak();
|
|
|
|
}
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( i < 80 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pev->sequence = m_baseSequence + SITTING_ANIM_sitting2;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( i < 100 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pev->sequence = m_baseSequence + SITTING_ANIM_sitscared;
|
|
|
|
}
|
|
|
|
|
|
|
|
ResetSequenceInfo( );
|
|
|
|
pev->frame = 0;
|
|
|
|
SetBoneController( 0, m_headTurn );
|
|
|
|
}
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->nextthink = gpGlobals->time + 0.1f;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// prepare sitting scientist to answer a question
|
2016-07-31 15:48:50 +02:00
|
|
|
void CSittingScientist::SetAnswerQuestion( CTalkMonster *pSpeaker )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
m_flResponseDelay = gpGlobals->time + RANDOM_FLOAT( 3.0f, 4.0f );
|
2016-06-04 15:24:23 +02:00
|
|
|
m_hTalkTarget = (CBaseMonster *)pSpeaker;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// FIdleSpeak
|
|
|
|
// ask question of nearby friend, or make statement
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
int CSittingScientist::FIdleSpeak( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// try to start a conversation, or make statement
|
|
|
|
int pitch;
|
2016-07-31 15:48:50 +02:00
|
|
|
|
|
|
|
if( !FOkToSpeak() )
|
2016-06-04 15:24:23 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
// set global min delay for next conversation
|
2016-07-31 15:48:50 +02:00
|
|
|
CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT( 4.8, 5.2 );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
pitch = GetVoicePitch();
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
// if there is a friend nearby to speak to, play sentence, set friend's response time, return
|
|
|
|
|
|
|
|
// try to talk to any standing or sitting scientists nearby
|
2016-07-31 15:48:50 +02:00
|
|
|
CBaseEntity *pentFriend = FindNearestFriend( FALSE );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pentFriend && RANDOM_LONG( 0, 1 ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
CTalkMonster *pTalkMonster = GetClassPtr( (CTalkMonster *)pentFriend->pev );
|
2016-06-04 15:24:23 +02:00
|
|
|
pTalkMonster->SetAnswerQuestion( this );
|
2016-07-31 15:48:50 +02:00
|
|
|
|
|
|
|
IdleHeadTurn( pentFriend->pev->origin );
|
|
|
|
SENTENCEG_PlayRndSz( ENT( pev ), m_szGrp[TLK_PQUESTION], 1.0, ATTN_IDLE, 0, pitch );
|
2016-06-04 15:24:23 +02:00
|
|
|
// set global min delay for next conversation
|
2016-07-31 15:48:50 +02:00
|
|
|
CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT( 4.8, 5.2 );
|
2016-06-04 15:24:23 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// otherwise, play an idle statement
|
2016-07-31 15:48:50 +02:00
|
|
|
if( RANDOM_LONG( 0, 1 ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
SENTENCEG_PlayRndSz( ENT( pev ), m_szGrp[TLK_PIDLE], 1.0, ATTN_IDLE, 0, pitch );
|
2016-06-04 15:24:23 +02:00
|
|
|
// set global min delay for next conversation
|
2016-07-31 15:48:50 +02:00
|
|
|
CTalkMonster::g_talkWaitTime = gpGlobals->time + RANDOM_FLOAT( 4.8, 5.2 );
|
2016-06-04 15:24:23 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// never spoke
|
|
|
|
CTalkMonster::g_talkWaitTime = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|