Skip to content

Commit

Permalink
fixes + tweaks
Browse files Browse the repository at this point in the history
fixes:
- inverted camera "No instant turn" flag. No actually means yes.
- rotating doors still instakilling when blocked
- snipers not shooting far enough again (infested)
- grunts and shock troopers dropping weapons inside walls
- antiblock swapping with turrets
- bullsquid attacking nothing after killing its enemy
- wrong kill icon for garg stomp attack
- alien slave getting stuck trying to talk until attacked/used

tweaks:
- sniper sound is heard further away
- monsters will keep moving if they want to talk while following
- allies only attack the player(s) who provoked them, then forgive the player when killed
- notarget cheat makes monsters forget the player as an enemy
  • Loading branch information
wootguy committed Dec 23, 2024
1 parent 26b3dca commit 057228f
Show file tree
Hide file tree
Showing 26 changed files with 149 additions and 85 deletions.
4 changes: 4 additions & 0 deletions cl_dll/hl/hl_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ int CBaseMonster::TaskIsRunning( void ) { return 0; }
void CBaseMonster::ScheduleChange( void ) { }
void CBaseMonster::SetClassify( int ) { }
void CBaseMonster::Revive( void ) { }
void CBaseMonster::Provoke(CBaseEntity* attacker) {}
void CBaseMonster::OnKillProvoker(CBaseEntity* provoker) {}
void CBaseMonster::Unprovoke(bool friendsToo) {}
int CBaseMonster::IRelationship(CBaseEntity* pTarget) { return 0; }
float CBaseMonster::GetDamage(float defaultDamage) { return defaultDamage; }
int CBaseEntity::IRelationship ( CBaseEntity *pTarget ) { return 0; }
BOOL CBaseMonster :: FindCover ( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) { return FALSE; }
Expand Down
1 change: 1 addition & 0 deletions dlls/func/CBaseDoor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ void CBaseDoor::Blocked(CBaseEntity* pOther)
if (pOther->IsMonster() && !pOther->IsAlive()) {
// don't let corpses block doors
pOther->Killed(pev, GIB_ALWAYS);
lastDamage = 0; // allow gibbing multiple players
return; // don't bounce back because the path is clear now
}

Expand Down
10 changes: 6 additions & 4 deletions dlls/func/CRotDoor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@ void CRotDoor::Blocked(CBaseEntity* pOther)
{
pev->dmg = initialDamage;

// increase damage exponentially as time goes on to account for monsters with insane health values
// and only hurt the entity preventing the door from opening
if (++blockedCounter > 8 && m_toggle_state == TS_GOING_UP) {
pev->dmg += V_min(1000, powf(10, (blockedCounter / 8)));
if (gpGlobals->time - lastDamage > DOOR_SMASH_MIN_DELAY) {
// increase damage exponentially as time goes on to account for monsters with insane health values
// and only hurt the entity preventing the door from opening
if (++blockedCounter > 8 && m_toggle_state == TS_GOING_UP) {
pev->dmg += V_min(1000, powf(10, (blockedCounter / 8)));
}
}

CBaseDoor::Blocked(pOther);
Expand Down
2 changes: 1 addition & 1 deletion dlls/game/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ void CHalfLifeMultiplay::DeathNotice( CBaseMonster *pVictim, entvars_t *pKiller,
break;
}

switch (pVictim->IRelationship(pVictim->Classify(), CLASS_PLAYER)) {
switch (CBaseEntity::IRelationship(pVictim->Classify(), CLASS_PLAYER)) {
case R_AL:
victimColor = FRIEND_TEAM_COLOR;
break;
Expand Down
3 changes: 1 addition & 2 deletions dlls/monster/CBarney.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,7 @@ int CBarney :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, floa
// Alright, now I'm pissed!
PlaySentence( "BA_MAD", 4, VOL_NORM, ATTN_NORM );

Remember( bits_MEMORY_PROVOKED );
StopFollowing( TRUE );
Provoke(attacker);
}
else
{
Expand Down
18 changes: 11 additions & 7 deletions dlls/monster/CBaseGrunt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ void CBaseGrunt::Killed(entvars_t* pevAttacker, int iGib)
{
if (HasMemory(bits_MEMORY_SUSPICIOUS) || IsFacing(pevAttacker, pev->origin))
{
Remember(bits_MEMORY_PROVOKED);

StopFollowing(true);
Provoke((CBaseEntity*)GET_PRIVATE(ENT(pevAttacker)));
}
}

Expand Down Expand Up @@ -479,8 +477,7 @@ int CBaseGrunt :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, f
// Alright, now I'm pissed!
PlaySentenceSound(HGRUNT_SENT_MAD);

Remember(bits_MEMORY_PROVOKED);
StopFollowing(TRUE);
Provoke(attacker);
ALERT(at_console, "Monster is now MAD!\n");
}
else
Expand Down Expand Up @@ -720,7 +717,7 @@ void CBaseGrunt::ShootMinigun(Vector& vecShootOrigin, Vector& vecShootDir) {
void CBaseGrunt::ShootSniper(Vector& vecShootOrigin, Vector& vecShootDir) {
//TODO: why is this 556? is 762 too damaging?
FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_1DEGREES, 8192, BULLET_MONSTER_762);
EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/sniper_fire.wav", 1, 0.3);
EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/sniper_fire.wav", 1, 0.2);
}

void CBaseGrunt ::ShootShotgun(Vector& vecShootOrigin, Vector& vecShootDir)
Expand Down Expand Up @@ -889,6 +886,11 @@ bool CBaseGrunt::DropEquipment(int attachmentIdx, int equipMask, Vector velocity
Vector vecGunAngles;
GetAttachment(attachmentIdx, vecGunPos, vecGunAngles);

if (POINT_CONTENTS(vecGunPos) == CONTENTS_SOLID) {
vecGunPos = pev->origin;
vecGunPos.z += pev->maxs.z * 0.5f;
}

int equipmentToDrop = m_iEquipment & equipMask;
bool droppedAnything = false;

Expand Down Expand Up @@ -1117,7 +1119,9 @@ void CBaseGrunt::InitAiFlags() {
canCallMedic = false;
suppressOccludedTarget = false;
maxSuppressTime = 3.0f;
maxShootDist = 2048;

if (!maxShootDist)
maxShootDist = 2048;
}

void CBaseGrunt::BasePrecache() {
Expand Down
82 changes: 74 additions & 8 deletions dlls/monster/CBaseMonster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,7 @@ int CBaseMonster::CheckEnemy(CBaseEntity* pEnemy)

if (!pEnemy->IsAlive())
{
OnKillProvoker(m_hEnemy);
SetConditions(bits_COND_ENEMY_DEAD);
ClearConditions(bits_COND_SEE_ENEMY | bits_COND_ENEMY_OCCLUDED);
return FALSE;
Expand Down Expand Up @@ -2187,8 +2188,10 @@ void CBaseMonster::MonsterInit(void)

m_hEnemy = NULL;

m_flDistTooFar = 1024.0;
m_flDistLook = 2048.0;
if (m_flDistLook == 0) {
m_flDistTooFar = 1024.0;
m_flDistLook = 2048.0;
}

m_lastInterpOrigin = pev->origin;

Expand Down Expand Up @@ -2372,7 +2375,7 @@ int CBaseMonster::Classify(int defaultClassify) {

// if player ally is set, then ally status towards players is inverted
if (m_IsPlayerAlly) {
bool isDefaultPlayerAlly = IRelationship(defaultClassify, CLASS_PLAYER) == R_AL;
bool isDefaultPlayerAlly = CBaseEntity::IRelationship(defaultClassify, CLASS_PLAYER) == R_AL;

if (isDefaultPlayerAlly) {
// if the monster is allied by default, then isPlayerAlly makes it hostile.
Expand Down Expand Up @@ -3798,6 +3801,10 @@ BOOL CBaseMonster::GetEnemy(void)
}
}

if (m_hEnemy && (m_hEnemy->pev->flags & FL_NOTARGET)) {
m_hEnemy = NULL;
}

// remember old enemies
if (m_hEnemy == NULL && PopEnemy())
{
Expand Down Expand Up @@ -7316,7 +7323,7 @@ BOOL CBaseMonster::CanFollow(void)
if (!IsAlive())
return FALSE;

return !IsFollowing();
return TRUE;
}


Expand All @@ -7333,7 +7340,7 @@ void CBaseMonster::FollowerUse(CBaseEntity* pActivator, CBaseEntity* pCaller, US
{
DeclineFollowing();
}
else if (CanFollow())
else if (CanFollow() && (!IsFollowing() || m_hTargetEnt.GetEntity() != pActivator))
{
if (canBeMadAtPlayer && (m_afMemory & bits_MEMORY_PROVOKED)) {
const char* name = DisplayName();
Expand Down Expand Up @@ -7484,7 +7491,7 @@ void CBaseMonster::SetHealth() {

void CBaseMonster::InitModel() {
SET_MODEL(edict(), GetModel());
bool isAlly = IRelationship(Classify(), CLASS_PLAYER) == R_AL;
bool isAlly = CBaseEntity::IRelationship(Classify(), CLASS_PLAYER) == R_AL;

if (isAlly != m_friendlySkinFirst) {
// use friendly skin
Expand All @@ -7511,7 +7518,7 @@ void CBaseMonster::Nerf() {
}
}

if (IRelationship(CLASS_PLAYER, Classify()) <= R_NO && !IsMachine()) {
if (CBaseEntity::IRelationship(CLASS_PLAYER, Classify()) <= R_NO && !IsMachine()) {
return; // don't care about friendlies
}

Expand Down Expand Up @@ -7601,7 +7608,7 @@ void CBaseMonster::Nerf() {
// allow the custom extra health
}

if (IRelationship(CLASS_PLAYER, Classify()) > R_NO || (IsTurret() && !m_IsPlayerAlly)) {
if (CBaseEntity::IRelationship(CLASS_PLAYER, Classify()) > R_NO || (IsTurret() && !m_IsPlayerAlly)) {
g_nerfStats.totalMonsterHealth += pev->health;
g_nerfStats.totalMonsters++;
}
Expand Down Expand Up @@ -7841,4 +7848,63 @@ float CBaseMonster::GetDamage(float defaultDamage) {

// owner damage overrides self damage (snarks, grenades, etc.)
return (mon ? mon->GetDamage(defaultDamage) : defaultDamage) * GetDamageModifier();
}

void CBaseMonster::Provoke(CBaseEntity* attacker) {
Remember(bits_MEMORY_PROVOKED);
StopFollowing(TRUE);

if (attacker)
m_bMadPlayer[attacker->entindex() - 1] = true;
}

void CBaseMonster::OnKillProvoker(CBaseEntity* provoker) {
if (!provoker || !provoker->IsPlayer()) {
return;
}

m_bMadPlayer[provoker->entindex() - 1] = false;

bool anyTargetsLeft = false;
for (int i = 0; i < 32; i++) {
if (m_bMadPlayer[i]) {
CBasePlayer* plr = UTIL_PlayerByIndex(i + 1);

if (!plr) {
m_bMadPlayer[i] = false;
continue;
}

anyTargetsLeft = true;
}
}

if (!anyTargetsLeft) {
Forget(bits_MEMORY_PROVOKED);
}
}

void CBaseMonster::Unprovoke(bool friendsToo) {
Forget(bits_MEMORY_PROVOKED);

if (m_hEnemy) {
int irel = IRelationship(m_hEnemy);

if (m_hEnemy && m_hEnemy->IsPlayer() && (irel == R_NO || irel == R_AL)) {
m_hEnemy = NULL;
}
}

if (friendsToo) {
UnprovokeFriends();
}
}

int CBaseMonster::IRelationship(CBaseEntity* pTarget)
{
if (m_afMemory & bits_MEMORY_PROVOKED)
if (pTarget->IsPlayer() && m_bMadPlayer[pTarget->entindex() - 1])
return R_HT;

return CBaseToggle::IRelationship(pTarget);
}
7 changes: 7 additions & 0 deletions dlls/monster/CBaseMonster.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class EXPORT CBaseMonster : public CBaseToggle
bool m_friendlySkinFirst; // true if the friendly skin comes before the enemy skin

bool canBeMadAtPlayer; // grunt will retaliate on too much friendly fire
bool m_bMadPlayer[32]; // players this friendly is mad at
int m_freeroam;
int m_lastNode;
int m_targetNode;
Expand Down Expand Up @@ -476,6 +477,12 @@ class EXPORT CBaseMonster : public CBaseToggle
virtual float GetDamageModifier();

virtual float GetDamage(float defaultDamage);

virtual void Provoke(CBaseEntity* attacker);
virtual void OnKillProvoker(CBaseEntity* provoker);
virtual void Unprovoke(bool friendsToo);
virtual void UnprovokeFriends(void) {} // calms an npc and friends down that was provoked by a player's friendly fire
virtual int IRelationship(CBaseEntity* pTarget) override;
};


Expand Down
2 changes: 1 addition & 1 deletion dlls/monster/CBaseTurret.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class EXPORT CBaseTurret : public CBaseMonster
virtual int Classify(void);
const char* GetDeathNoticeWeapon() { return "weapon_9mmAR"; }
BOOL IsMachine() { return 1; } // ignore classification overrides
BOOL IsTurret() { return 1; }
BOOL IsNormalMonster(void) { return FALSE; }
void DeathSound();

int BloodColor(void) { return DONT_BLEED; }
Expand Down
3 changes: 2 additions & 1 deletion dlls/monster/CBullsquid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,8 @@ Schedule_t *CBullsquid :: GetSchedule( void )
return GetScheduleOfType ( SCHED_MELEE_ATTACK2 );
}

return GetScheduleOfType ( SCHED_CHASE_ENEMY );
if (m_hEnemy && m_hEnemy->IsAlive())
return GetScheduleOfType ( SCHED_CHASE_ENEMY );

break;
}
Expand Down
6 changes: 3 additions & 3 deletions dlls/monster/CController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ void CController :: HandleAnimEvent( MonsterEvent_t *pEvent )
pBall->pev->velocity = Vector( 0, 0, 32 );
pBall->m_hEnemy = m_hEnemy;

if (CBaseMonster::IRelationship(Classify(), CLASS_PLAYER) == R_AL) {
if (CBaseEntity::IRelationship(Classify(), CLASS_PLAYER) == R_AL) {
pBall->pev->rendercolor = Vector(0, 255, 255);
}

Expand Down Expand Up @@ -673,7 +673,7 @@ void CController :: RunTask ( Task_t *pTask )
CBaseMonster *pBall = (CBaseMonster*)Create( "controller_energy_ball", vecSrc, pev->angles, edict() );
pBall->pev->velocity = vecDir;

if (CBaseMonster::IRelationship(Classify(), CLASS_PLAYER) == R_AL) {
if (CBaseEntity::IRelationship(Classify(), CLASS_PLAYER) == R_AL) {
pBall->pev->rendercolor = Vector(0, 255, 255);
}
}
Expand Down Expand Up @@ -881,7 +881,7 @@ void CController :: RunAI( void )
ball->SetAttachment( edict(), (i + 3) );
ball->SetScale( 1.0 );

if (CBaseMonster::IRelationship(Classify(), CLASS_PLAYER) == R_AL) {
if (CBaseEntity::IRelationship(Classify(), CLASS_PLAYER) == R_AL) {
ball->SetColor(0, 255, 255);
}

Expand Down
1 change: 1 addition & 0 deletions dlls/monster/CGargantua.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class CStomp : public CBaseEntity
void Spawn(void);
void Think(void);
static CStomp* StompCreate(const Vector& origin, const Vector& end, edict_t* owner, float speed, float damage);
const char* GetDeathNoticeWeapon() { return "weapon_crowbar"; }

private:
// UNDONE: re-use this sprite list instead of creating new ones all the time
Expand Down
2 changes: 1 addition & 1 deletion dlls/monster/CHornet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ old colors
*/
CBaseEntity* owner = CBaseEntity::Instance(pev->owner);
CBaseMonster* mon = owner ? owner->MyMonsterPointer() : NULL;
bool firedByAllyMonster = mon && !mon->IsPlayer() && mon->IRelationship(mon->Classify(), CLASS_PLAYER) == R_AL;
bool firedByAllyMonster = mon && !mon->IsPlayer() && CBaseEntity::IRelationship(mon->Classify(), CLASS_PLAYER) == R_AL;

// trail
RGBA color = RGBA(255,255,255);
Expand Down
8 changes: 4 additions & 4 deletions dlls/monster/CISlave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ void CISlave :: StartTask ( Task_t *pTask )
{
ClearBeams( );

CTalkSquadMonster :: StartTask ( pTask );
CTalkSquadMonster:: StartTask ( pTask );
}

void CISlave::RunTask(Task_t* pTask)
Expand All @@ -548,15 +548,15 @@ void CISlave::RunTask(Task_t* pTask)
{
case TASK_MOVE_TO_TARGET_RANGE:
{
CBaseMonster::RunTask(pTask);
CTalkSquadMonster::RunTask(pTask);

// always run when following someone because the walk speed is painfully slow
m_movementActivity = ACT_RUN;
break;
}
default:
{
CBaseMonster::RunTask(pTask);
CTalkSquadMonster::RunTask(pTask);
}
}
}
Expand Down Expand Up @@ -584,7 +584,7 @@ void CISlave :: Spawn()

MonsterInit();

if (CBaseMonster::IRelationship(Classify(), CLASS_PLAYER) == R_AL) {
if (CBaseEntity::IRelationship(Classify(), CLASS_PLAYER) == R_AL) {
m_beamColor = Vector(96, 180, 255);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion dlls/monster/CKingpin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ void CKingpin::Spawn()

MonsterInit();

if (CBaseMonster::IRelationship(Classify(), CLASS_PLAYER) == R_AL) {
if (CBaseEntity::IRelationship(Classify(), CLASS_PLAYER) == R_AL) {
m_beamColor = Vector(16, 255, 255);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion dlls/monster/CMonsterMaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ void CMonsterMaker::Nerf() {

int clazz = Classify();

if (IRelationship(CLASS_PLAYER, clazz) <= R_NO || !strcmp(spawnCname, "monster_snark")) {
if (CBaseEntity::IRelationship(CLASS_PLAYER, clazz) <= R_NO || !strcmp(spawnCname, "monster_snark")) {
return; // don't care about nerfing friendlies/insects/snarks
}

Expand Down
Loading

0 comments on commit 057228f

Please sign in to comment.