Skip to content

Commit

Permalink
fixes + tweaks
Browse files Browse the repository at this point in the history
- scores not resetting when a map restarts
- alien controller shooting orbs while dying
- "New score multiplier" shown for the same multiplier
- target_cdaudio stopping on level changes within the same series
- score overflow/underflow at max int16 value
- "stopped spectating" message not shown for yourself
- map join messages not shown (game_playerjoin triggered too soon)
- permanent shock effect on tentacles
- xen_tree not playing wrong animation when shot
- wrong player animation when all weapons are removed
- tiny explosions sinking into walls or not being visible at all
- crosshair visible if loading a map with no suit after having one

tweaks:
- tor slam attack can't be interrupted
- pitdrones have a 66% chance to have spikes preloaded (previously 0%)
- "Loading map" messages shows how many maps are in the series
- slime/Lava doesn't instakill you (looks like valve intended 1s delays between damage) (sc_strangers pro jump ending)
- rpg laser is thinner in first-person
- rename "Breakable (explosives only)" to "Explosives (explosives only)"
- add display names for "xen_tree" "nihilanth_energy_ball" and "item_airtank"
- enable weapon switching HUD when you have weapons but no suit
- player hover animation plays when moving slowly in water
- player use, reload, and drop animations shown in water
  • Loading branch information
wootguy committed Dec 22, 2024
1 parent 2bce527 commit bafbf7d
Show file tree
Hide file tree
Showing 25 changed files with 179 additions and 62 deletions.
7 changes: 5 additions & 2 deletions dlls/env/CEnvExplosion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void CEnvExplosion::Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE

Vector vecSpot;// trace starts here!

vecSpot = pev->origin + Vector(0, 0, 8);
vecSpot = pev->origin + Vector(0, 0, 8);

UTIL_TraceLine(vecSpot, vecSpot + Vector(0, 0, -40), ignore_monsters, ENT(pev), &tr);

Expand All @@ -90,7 +90,7 @@ void CEnvExplosion::Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE
// Pull out of the wall a bit
if (tr.flFraction != 1.0)
{
float dist = (m_iMagnitude - 24) * 0.6;
float dist = V_max(16, (m_iMagnitude - 24)) * 0.6;
m_effectOrigin = tr.vecEndPos + (tr.vecPlaneNormal * dist);

if (mp_explosionbug.value == 0) {
Expand All @@ -100,8 +100,11 @@ void CEnvExplosion::Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE

TraceResult tr;
TRACE_LINE(pev->origin, damageOrigin, ignore_monsters, NULL, &tr);

if (!tr.fStartSolid)
pev->origin = tr.vecEndPos;

te_debug_beam(pev->origin, m_effectOrigin, 100, RGB(255, 0, 0));
}
}

Expand Down
9 changes: 8 additions & 1 deletion dlls/func/CBaseDoor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ IMPLEMENT_SAVERESTORE(CBaseDoor, CBaseToggle)
#define DOOR_SOUNDWAIT 3
#define BUTTON_SOUNDWAIT 0.5

// minimum amount of seconds before applying block damage again
// (should be more than 0 to prevent damage every frame when a player gets stuck inside a door)
#define DOOR_SMASH_MIN_DELAY 0.5

// play door or button locked or unlocked sounds.
// pass in pointer to valid locksound struct.
// if flocked is true, play 'door is locked' sound,
Expand Down Expand Up @@ -780,7 +784,10 @@ void CBaseDoor::Blocked(CBaseEntity* pOther)

// Hurt the blocker a little.
if (pev->dmg || FClassnameIs(pOther->pev, "monster_tripmine")) {
pOther->TakeDamage(pev, pev, pev->dmg, DMG_CRUSH);
if (gpGlobals->time - lastDamage > DOOR_SMASH_MIN_DELAY) {
lastDamage = gpGlobals->time;
pOther->TakeDamage(pev, pev, pev->dmg, DMG_CRUSH);
}
}

if (pOther->IsMonster() && !pOther->IsAlive()) {
Expand Down
2 changes: 2 additions & 0 deletions dlls/func/CBaseDoor.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,6 @@ class CBaseDoor : public CBaseToggle
USE_TYPE m_fireOnStopMode;

ObeyTriggerMode m_iObeyTriggerMode;

float lastDamage;
};
13 changes: 11 additions & 2 deletions dlls/func/CBreakable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,10 @@ const char* CBreakable::DisplayName() {
if (m_displayName) {
return STRING(m_displayName);
}
return Explodable() && !(pev->spawnflags & SF_BREAK_EXPLOSIVES_ONLY) ? "Explosives" : "Breakable";

// May show "Explosives (explosives only)" in the HUD, but that's better than
// "Breakable (explosives only)" which is less imformative.
return Explodable() ? "Explosives" : "Breakable";
}

void CBreakable::BreakTouch(CBaseEntity* pOther)
Expand Down Expand Up @@ -745,7 +748,13 @@ void CBreakable::Die()

if (Explodable())
{
ExplosionCreate(Center(), pev->angles, edict(), ExplosionMagnitude(), TRUE);
SetObjectCollisionBox();
Vector center = Center();
Vector min = pev->absmin;
Vector max = pev->absmax;
Vector sz = max - min;

ExplosionCreate(center, pev->angles, edict(), ExplosionMagnitude(), TRUE);
}
}

Expand Down
1 change: 1 addition & 0 deletions dlls/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ std::unordered_map<std::string, std::string> g_soundReplacements;
std::unordered_set<std::string> g_mapWeapons;

std::unordered_map<uint64_t, player_score_t> g_playerScores;
std::unordered_map<uint64_t, player_score_t> g_oldPlayerScores;

std::unordered_map<std::string, const char*> g_itemNameRemap = {
{"weapon_9mmar", "weapon_9mmAR"},
Expand Down
1 change: 1 addition & 0 deletions dlls/game/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,6 @@ struct player_score_t {

// maps a steam ID to their score, for preserving scores across level changes and disconnects
EXPORT extern std::unordered_map<uint64_t, player_score_t> g_playerScores;
EXPORT extern std::unordered_map<uint64_t, player_score_t> g_oldPlayerScores; // state on level load, used in case of map restarts

#endif // GAME_H
15 changes: 14 additions & 1 deletion dlls/game/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1373,9 +1373,22 @@ void CHalfLifeMultiplay :: GoToIntermission( void )
MESSAGE_BEGIN(MSG_BROADCAST, SVC_INTERMISSION);
MESSAGE_END();

int seriesIdx = nextMap->seriesIdx + 1;
int seriesCount = seriesIdx;

// count maps in series
mapcycle_item_t* map = nextMap;
while (map->next) {
map = map->next;
if (map->seriesNum != currentMap->seriesNum || map->seriesIdx < seriesIdx) {
break;
}
seriesCount = map->seriesIdx + 1;
}

MESSAGE_BEGIN(MSG_BROADCAST, gmsgSayText);
WRITE_BYTE(0); // not a player
WRITE_STRING(UTIL_VarArgs("Loading %s...\n", nextmapname));
WRITE_STRING(UTIL_VarArgs("Loading map %s (%d of %d)...\n", nextmapname, seriesIdx, seriesCount));
MESSAGE_END();

m_flIntermissionEndTime = gpGlobals->time + 0.05f;
Expand Down
23 changes: 15 additions & 8 deletions dlls/hooks/hlds_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,11 @@ void ClientPutInServer( edict_t *pEntity )
pPlayer = GetClassPtr((CBasePlayer *)pev);
pPlayer->SetCustomDecalFrames(-1); // Assume none;
pPlayer->m_flLastSetRoomtype = -1; // fixup room type if joining from another server

if (g_mp3Command.size()) {

if (g_seriesMusic) {
// continue playing from last map
}
else if (g_mp3Command.size()) {
// start global music
MESSAGE_BEGIN(MSG_ONE, SVC_STUFFTEXT, NULL, pEntity);
WRITE_STRING(g_mp3Command.c_str());
Expand Down Expand Up @@ -399,10 +402,6 @@ void ClientPutInServer( edict_t *pEntity )

// Allocate a CBasePlayer for pev, and call spawn
pPlayer->Spawn();

if (g_pGameRules->IsMultiplayer()) {
FireTargets("game_playerjoin", pPlayer, pPlayer, USE_TOGGLE, 0);
}
}

/*
Expand Down Expand Up @@ -763,6 +762,12 @@ void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax )
g_playerScores.clear();
}

// reset scores if map was restarted
if (toLowerCase(g_lastMapName) == toLowerCase(STRING(gpGlobals->mapname))) {
g_playerScores = g_oldPlayerScores;
}
g_oldPlayerScores = g_playerScores;

PrintEntindexStats();

g_engfuncs.pfnServerPrint(UTIL_VarArgs("Precache stats: %d models (%d MDL, %d BSP), %d sounds, %d generic, %d events\n",
Expand Down Expand Up @@ -1856,6 +1861,10 @@ void UpdateClientData ( const edict_t *ent, int sendweapons, struct clientdata_s
cd->watertype = pev->watertype;
cd->weapons = pev->weapons;

if (pl->m_fakeSuit) {
cd->weapons |= 1 << WEAPON_SUIT;
}

// Vectors
cd->origin = pev->origin;
cd->velocity = pev->velocity;
Expand Down Expand Up @@ -1889,8 +1898,6 @@ void UpdateClientData ( const edict_t *ent, int sendweapons, struct clientdata_s
cd->iuser2 = pev->iuser2;
}



#if defined( CLIENT_WEAPONS )
if ( sendweapons )
{
Expand Down
1 change: 1 addition & 0 deletions dlls/item/CAirtank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class CAirtank : public CGrenade
void EXPORT TankTouch( CBaseEntity *pOther );
int BloodColor( void ) { return DONT_BLEED; };
void Killed( entvars_t *pevAttacker, int iGib );
const char* DisplayName() { return "Air Tank"; }

virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
Expand Down
2 changes: 2 additions & 0 deletions dlls/item/CItemSuit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class CItemSuit : public CItem
EMIT_SOUND_SUIT(pPlayer->edict(), "!HEV_AAx"); // long version of suit logon

pPlayer->pev->weapons |= (1 << WEAPON_SUIT);
pPlayer->m_iHideHUD &= ~HIDEHUD_HEALTH;

return TRUE;
}
};
Expand Down
2 changes: 1 addition & 1 deletion dlls/monster/CController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ int CController::LookupFloat( )
void CController :: RunTask ( Task_t *pTask )
{

if (m_flShootEnd > gpGlobals->time)
if (m_flShootEnd > gpGlobals->time && IsAlive())
{
Vector vecHand, vecAngle;

Expand Down
11 changes: 10 additions & 1 deletion dlls/monster/CNihilanth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class CNihilanthHVR : public CBaseMonster

void Spawn( void );
void Precache( void );
const char* DisplayName();

void CircleInit( CBaseEntity *pTarget );
void AbsorbInit( void );
Expand Down Expand Up @@ -330,7 +331,6 @@ void CNihilanth :: Spawn( void )
*/
}


void CNihilanth::Precache( void )
{
CBaseMonster::Precache();
Expand Down Expand Up @@ -1371,7 +1371,16 @@ void CNihilanthHVR :: HoverThink( void )
}


const char* CNihilanthHVR::DisplayName() {
if (pev->owner) {
CBaseEntity* owner = Instance(pev->owner);
if (owner) {
return owner->DisplayName();
}
}

return "Energy Ball";
}

void CNihilanthHVR :: ZapInit( CBaseEntity *pEnemy )
{
Expand Down
19 changes: 9 additions & 10 deletions dlls/monster/CPitdrone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

int iSpikeTrail;
int iPitdroneSpitSprite;
#define PITDRONE_CLIP_SIZE 6


//=========================================================
Expand Down Expand Up @@ -694,7 +695,7 @@ void CPitdrone :: HandleAnimEvent( MonsterEvent_t *pEvent )
else
{
SetBodygroup( PitdroneBodygroup::Weapons, PitdroneWeapon::Full );
m_cAmmoLoaded = 6;
m_cAmmoLoaded = PITDRONE_CLIP_SIZE;
}

ClearConditions( bits_COND_NO_AMMO_LOADED );
Expand Down Expand Up @@ -725,23 +726,21 @@ void CPitdrone :: Spawn()

m_flNextSpikeTime = gpGlobals->time;

if( m_iInitialAmmo == -1 )
{
SetBodygroup( PitdroneBodygroup::Weapons, PitdroneWeapon::Full );
// if not specified, randomly decide to havepreloaded ammo
if (m_iInitialAmmo == 0 && RANDOM_LONG(0,2) >= 1) {
m_iInitialAmmo = PITDRONE_CLIP_SIZE;
}
else if( m_iInitialAmmo <= 0 )

if( m_iInitialAmmo < 0 )
{
m_iInitialAmmo = -1;
SetBodygroup( PitdroneBodygroup::Weapons, PitdroneWeapon::Empty );
m_iInitialAmmo = 0;
SetBodygroup(PitdroneBodygroup::Weapons, PitdroneWeapon::Empty);
}
else
{
SetBodygroup( PitdroneBodygroup::Weapons, PitdroneWeapon::One - m_iInitialAmmo );
}

if( m_iInitialAmmo == -1 )
m_iInitialAmmo = 0;

m_cAmmoLoaded = m_iInitialAmmo;

m_flNextEatTime = gpGlobals->time;
Expand Down
2 changes: 2 additions & 0 deletions dlls/monster/CTentacle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ void CTentacle :: Cycle( void )

DispatchAnimEvents( );
StudioFrameAdvance( );
UpdateShockEffect();

ChangeYaw( pev->yaw_speed );

Expand Down Expand Up @@ -756,6 +757,7 @@ void CTentacle :: DieThink( void )

DispatchAnimEvents( );
StudioFrameAdvance( );
UpdateShockEffect();

ChangeYaw( 24 );

Expand Down
27 changes: 25 additions & 2 deletions dlls/monster/CTor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,28 @@ Schedule_t slSummonAttack[] =
},
};

// uninterruptable melee attack
Task_t tlSlamAttack[] =
{
{ TASK_STOP_MOVING, 0 },
{ TASK_MELEE_ATTACK1, (float)0 },
};

Schedule_t slSlamAttack[] =
{
{
tlSlamAttack,
ARRAYSIZE(tlSlamAttack),
0,
0,
"TOR_SLAM_ATTACK"
},
};

DEFINE_CUSTOM_SCHEDULES(CTor)
{
slSummonAttack
slSummonAttack,
slSlamAttack
};

IMPLEMENT_CUSTOM_SCHEDULES(CTor, CBaseMonster)
Expand Down Expand Up @@ -303,8 +322,12 @@ Schedule_t* CTor::GetSchedule(void)
}

Schedule_t* CTor::GetScheduleOfType(int Type) {
if (Type == SCHED_MELEE_ATTACK2) {
switch (Type) {
case SCHED_MELEE_ATTACK1:
return &slSlamAttack[0];
case SCHED_MELEE_ATTACK2:
AttackSound();
break;
}

return CBaseMonster::GetScheduleOfType(Type);
Expand Down
1 change: 1 addition & 0 deletions dlls/monster/CXenTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class CXenTree : public CActAnimating
void HandleAnimEvent(MonsterEvent_t* pEvent);
void Attack(void);
int Classify(void) { return CLASS_BARNACLE; }
const char* DisplayName() { return "Xen Tree"; }

virtual int Save(CSave& save);
virtual int Restore(CRestore& restore);
Expand Down
Loading

0 comments on commit bafbf7d

Please sign in to comment.