Skip to content

Commit

Permalink
Add panthereye
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed Sep 9, 2024
1 parent 3cb6651 commit c35a97f
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 0 deletions.
1 change: 1 addition & 0 deletions dlls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ set (SVDLL_SOURCES
observer.cpp
op4mortar.cpp
osprey.cpp
panthereye.cpp
pathcorner.cpp
pipewrench.cpp
pitdrone.cpp
Expand Down
6 changes: 6 additions & 0 deletions dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,9 @@ DECLARE_SKILL_VALUE(sk_otis_health, "0")
DECLARE_SKILL_VALUE(sk_kate_health, "0")
#endif

DECLARE_SKILL_VALUE(sk_panthereye_health, "150")
DECLARE_SKILL_VALUE(sk_panthereye_dmg_claw, "20")

#if FEATURE_PITDRONE
// Pitdrone
DECLARE_SKILL_VALUE(sk_pitdrone_health, "0")
Expand Down Expand Up @@ -1642,6 +1645,9 @@ void GameDLLInit( void )
REGISTER_SKILL_CVARS(sk_kate_health);
#endif

REGISTER_SKILL_CVARS(sk_panthereye_health);
REGISTER_SKILL_CVARS(sk_panthereye_dmg_claw);

#if FEATURE_PITDRONE
// Pitdrone
if (g_modFeatures.IsMonsterEnabled("pitdrone"))
Expand Down
2 changes: 2 additions & 0 deletions dlls/gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ void CGameRules::RefreshSkillData ( void )
// Nihilanth
gSkillData.nihilanthHealth = GetSkillCvar( "sk_nihilanth_health" );
gSkillData.nihilanthZap = GetSkillCvar( "sk_nihilanth_zap" );
gSkillData.panthereyeHealth = GetSkillCvar( "sk_panthereye_health" );
gSkillData.panthereyeDmgClaw = GetSkillCvar( "sk_panthereye_dmg_claw" );
#if FEATURE_PITDRONE
// Pitdrone
if (g_modFeatures.IsMonsterEnabled("pitdrone"))
Expand Down
229 changes: 229 additions & 0 deletions dlls/panthereye.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "game.h"
#include "common_soundscripts.h"

#define PANTHEREYE_AE_STRIKE_LEFT ( 1 )
#define PANTHEREYE_AE_STRIKE_RIGHT_LOW ( 2 )
#define PANTHEREYE_AE_STRIKE_RIGHT_HIGH ( 3 )

struct PantherStrikeParams
{
float forwardDistance = 70.0f;
float punchz = 0.0f;
float velRightScalar = 0.0f;
float velForwardScalar = 0.0f;
float velUpScalar = 0.0f;
};

class CPantherEye : public CBaseMonster
{
public:
void Spawn();
void Precache();
bool IsEnabledInMod() { return g_modFeatures.IsMonsterEnabled("panthereye"); }
void SetYawSpeed();
int DefaultClassify();
const char* DefaultDisplayName() { return "Panther Eye"; }

void HandleAnimEvent( MonsterEvent_t *pEvent );

BOOL CheckMeleeAttack1( float flDot, float flDist );
BOOL CheckMeleeAttack2( float flDot, float flDist ) {return FALSE;}
BOOL CheckRangeAttack1( float flDot, float flDist ) {return FALSE;}
BOOL CheckRangeAttack2( float flDot, float flDist ) {return FALSE;}

void PerformStrike(const PantherStrikeParams& params);

void TraceAttack( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType);

int DefaultSizeForGrapple() { return GRAPPLE_MEDIUM; }
bool IsDisplaceable() { return true; }

Vector DefaultMinHullSize() { return Vector( -32.0f, -32.0f, 0.0f ); }
Vector DefaultMaxHullSize() { return Vector( 32.0f, 32.0f, 64.0f ); }

static constexpr const char* attackHitSoundScript = "PantherEye.AttackHit";
static constexpr const char* attackMissSoundScript = "PantherEye.AttackMiss";

static const NamedSoundScript idleSoundScript;
static const NamedSoundScript alertSoundScript;
static const NamedSoundScript painSoundScript;
static const NamedSoundScript dieSoundScript;
static const NamedSoundScript attackSoundScript;

void IdleSound() {
EmitSoundScript(idleSoundScript);
}
void AlertSound() {
EmitSoundScript(alertSoundScript);
}
void PainSound() {
if(RANDOM_LONG(0, 5) < 2)
EmitSoundScript(painSoundScript);
}
void DeathSound() {
EmitSoundScript(dieSoundScript);
}
};

LINK_ENTITY_TO_CLASS( monster_panthereye, CPantherEye );
LINK_ENTITY_TO_CLASS( monster_panther, CPantherEye );

const NamedSoundScript CPantherEye::idleSoundScript = {
CHAN_VOICE,
{"panthereye/pa_idle1.wav", "panthereye/pa_idle2.wav","panthereye/pa_idle3.wav", "panthereye/pa_idle4.wav"},
IntRange(95, 105),
"PantherEye.Idle"
};

const NamedSoundScript CPantherEye::alertSoundScript = {
CHAN_VOICE,
{},
"PantherEye.Alert"
};

const NamedSoundScript CPantherEye::painSoundScript = {
CHAN_VOICE,
{},
"PantherEye.Pain"
};

const NamedSoundScript CPantherEye::dieSoundScript = {
CHAN_VOICE,
{"panthereye/pa_death1.wav"},
"PantherEye.Die"
};

const NamedSoundScript CPantherEye::attackSoundScript = {
CHAN_VOICE,
{"panthereye/pa_attack1.wav"},
"PantherEye.Attack"
};

int CPantherEye::DefaultClassify()
{
return CLASS_ALIEN_MONSTER;
}

void CPantherEye::SetYawSpeed ( void )
{
pev->yaw_speed = 90;
}

void CPantherEye::Spawn()
{
Precache();

SetMyModel("models/panthereye.mdl");
SetMySize(Vector (-32, -16, 0 ), Vector ( 32, 16, 64) );

pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP;
SetMyBloodColor(BLOOD_COLOR_YELLOW);
SetMyHealth(gSkillData.panthereyeHealth);
SetMyFieldOfView(0.5f);
m_MonsterState = MONSTERSTATE_NONE;

MonsterInit();
}

void CPantherEye::Precache()
{
PrecacheMyModel("models/panthereye.mdl");

RegisterAndPrecacheSoundScript(attackHitSoundScript, NPC::attackHitSoundScript);
RegisterAndPrecacheSoundScript(attackMissSoundScript, NPC::attackMissSoundScript);

RegisterAndPrecacheSoundScript(idleSoundScript);
RegisterAndPrecacheSoundScript(alertSoundScript);
RegisterAndPrecacheSoundScript(painSoundScript);
RegisterAndPrecacheSoundScript(dieSoundScript);
RegisterAndPrecacheSoundScript(attackSoundScript);
}

BOOL CPantherEye::CheckMeleeAttack1 ( float flDot, float flDist )
{
if ( flDist <= 64.0f && flDot >= 0.7f && m_hEnemy != 0 && FBitSet ( m_hEnemy->pev->flags, FL_ONGROUND ) )
{
return TRUE;
}
return FALSE;
}

void CPantherEye::PerformStrike(const PantherStrikeParams& params)
{
CBaseEntity *pHurt = CheckTraceHullAttack( params.forwardDistance, gSkillData.panthereyeDmgClaw, DMG_SLASH );
if ( pHurt )
{
if ( pHurt->pev->flags & (FL_MONSTER|FL_CLIENT) )
{
if (params.punchz) {
pHurt->pev->punchangle.z = params.punchz;
}
pHurt->pev->punchangle.x = 5;
pHurt->pev->velocity = pHurt->pev->velocity +
gpGlobals->v_right * params.velRightScalar +
gpGlobals->v_forward * params.velForwardScalar +
gpGlobals->v_up * params.velUpScalar;
}
EmitSoundScript(attackHitSoundScript);
}
else
EmitSoundScript(attackMissSoundScript);

if (RANDOM_LONG(0,1))
EmitSoundScript(attackSoundScript);
}

void CPantherEye::TraceAttack( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType)
{
CBaseMonster::TraceAttack( pevInflictor, pevAttacker, flDamage, vecDir, ptr, bitsDamageType );
}

void CPantherEye::HandleAnimEvent( MonsterEvent_t *pEvent )
{
switch (pEvent->event)
{
case PANTHEREYE_AE_STRIKE_LEFT:
{
PantherStrikeParams params;
params.punchz = 18.0f;
params.velRightScalar = 100.0f;
params.velForwardScalar = -50.0f;
params.velUpScalar = 50.0f;

PerformStrike(params);
break;
}

case PANTHEREYE_AE_STRIKE_RIGHT_LOW:
{
PantherStrikeParams params;
params.punchz = -9.0f;
params.velRightScalar = -25.0f;
params.velForwardScalar = -25.0f;
params.velUpScalar = 25.0f;

PerformStrike(params);
break;
}

case PANTHEREYE_AE_STRIKE_RIGHT_HIGH:
{
PantherStrikeParams params;
params.punchz = -18.0f;
params.velRightScalar = -100.0f;
params.velForwardScalar = -50.0f;
params.velUpScalar = 50.0f;

PerformStrike(params);
break;
}
default:
CBaseMonster::HandleAnimEvent(pEvent);
break;
}
}
3 changes: 3 additions & 0 deletions dlls/skill.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ struct skilldata_t
float nihilanthHealth;
float nihilanthZap;

float panthereyeHealth;
float panthereyeDmgClaw;

#if FEATURE_PITDRONE
float pitdroneHealth;
float pitdroneDmgBite;
Expand Down
2 changes: 2 additions & 0 deletions fgd/halflife.fgd
Original file line number Diff line number Diff line change
Expand Up @@ -6218,6 +6218,8 @@
]
]

@PointClass base(Monster) studio("models/panthereye.mdl") = monster_panthereye : "Panthereye" []

@PointClass base(Monster, FollowingMonster, Sequence) size(-24 -24 0, 24 24 32) studio("models/pit_drone.mdl") = monster_pitdrone : "PitDrone"
[
sequence(Choices) : "Animation Sequence (editor)" : 0 =
Expand Down

0 comments on commit c35a97f

Please sign in to comment.