Skip to content

Commit

Permalink
fixes on a mouse
Browse files Browse the repository at this point in the history
added readme notes to clear up possible confusion
added message that only appears in debug builds to prevent myself from shipping debug binaries again
fixed beer i owed ya being small for no reason and removed hardcoded x55 scale limit
added d1_trainstation_03 to map list for Player Teleport
fixed talker npcs giving way to player like how alyx would
remove random weapon can no longer apply if you only have a single weapon. removed its has weapon context tag since it now does a more robust check
  • Loading branch information
Pinsplash committed May 30, 2023
1 parent 1395df2 commit 7852d90
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 39 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ It should work now. If it doesn't, 'Script Log' button in OBS might have useful

To remove Twitch integration, you can simply clear out the mod's launch options and select twitch-integration.py in OBS and then click the minus button.

Voting will not work if a map is not loaded. Menu background maps count. If no map loads upon opening the mod, please open an issue for it even if a closed one already exists, or contact Pinsplash in any other way.

## Tips
* If issues arise while playing, try `chaos_restart` in the console. This should set everything back to normal and restart the map.
* If you become physically stuck in something, the game will try to get you out of it the next time an effect starts. You can also use the console command `getunstuck`.
* To modify things about Chaos like effect duration and probability, edit `hl2chaos/cfg/autoexec.cfg`.
* Effect groups can be changed in `groups.cfg`.
* To modify things about Chaos like effect duration and probability, edit `hl2chaos/cfg/autoexec.cfg`. Restart the game for changes to take effect. Effect groups can be changed in `groups.cfg`.
* Want a specific effect? Use `chaos_test_effect` followed by a number. You can get any effect's number through `chaos_print`.
* Any CFG files you change must have their change reflected in the same file in all three mods if you wish for the change to apply in all of them. You can simply copy the file into the other two mod folders and replace the old version.
* Saving often will help you progress faster.
Expand Down
30 changes: 15 additions & 15 deletions sp/src/game/server/ai_basenpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,21 @@ enum Interruptability_t
//-------------------------------------
// Spawn flags
//-------------------------------------
#define SF_NPC_WAIT_TILL_SEEN ( 1 << 0 ) // spawnflag that makes npcs wait until player can see them before attacking.
#define SF_NPC_GAG ( 1 << 1 ) // no idle noises from this npc
#define SF_NPC_FALL_TO_GROUND ( 1 << 2 ) // used my NPC_Maker
#define SF_NPC_DROP_HEALTHKIT ( 1 << 3 ) // Drop a healthkit upon death
#define SF_NPC_START_EFFICIENT ( 1 << 4 ) // Set into efficiency mode from spawn
// ( 1 << 5 )
// ( 1 << 6 )
#define SF_NPC_WAIT_FOR_SCRIPT ( 1 << 7 ) // spawnflag that makes npcs wait to check for attacking until the script is done or they've been attacked
#define SF_NPC_LONG_RANGE ( 1 << 8 ) // makes npcs look far and relaxes weapon range limit
#define SF_NPC_FADE_CORPSE ( 1 << 9 ) // Fade out corpse after death
#define SF_NPC_ALWAYSTHINK ( 1 << 10 ) // Simulate even when player isn't in PVS.
#define SF_NPC_TEMPLATE ( 1 << 11 ) // This NPC will be used as a template by an npc_maker -- do not spawn.
#define SF_NPC_ALTCOLLISION ( 1 << 12 )
#define SF_NPC_NO_WEAPON_DROP ( 1 << 13 ) // This NPC will not actually drop a weapon that can be picked up
#define SF_NPC_NO_PLAYER_PUSHAWAY ( 1 << 14 )
#define SF_NPC_WAIT_TILL_SEEN ( 1 << 0 ) // spawnflag that makes npcs wait until player can see them before attacking.//1
#define SF_NPC_GAG ( 1 << 1 ) // no idle noises from this npc//2
#define SF_NPC_FALL_TO_GROUND ( 1 << 2 ) // used my NPC_Maker//4
#define SF_NPC_DROP_HEALTHKIT ( 1 << 3 ) // Drop a healthkit upon death//8
#define SF_NPC_START_EFFICIENT ( 1 << 4 ) // Set into efficiency mode from spawn//16
// ( 1 << 5 )//32
// ( 1 << 6 )//64
#define SF_NPC_WAIT_FOR_SCRIPT ( 1 << 7 ) // spawnflag that makes npcs wait to check for attacking until the script is done or they've been attacked//128
#define SF_NPC_LONG_RANGE ( 1 << 8 ) // makes npcs look far and relaxes weapon range limit //256
#define SF_NPC_FADE_CORPSE ( 1 << 9 ) // Fade out corpse after death//512
#define SF_NPC_ALWAYSTHINK ( 1 << 10 ) // Simulate even when player isn't in PVS.//1024
#define SF_NPC_TEMPLATE ( 1 << 11 ) // This NPC will be used as a template by an npc_maker -- do not spawn.//2048
#define SF_NPC_ALTCOLLISION ( 1 << 12 )//4096
#define SF_NPC_NO_WEAPON_DROP ( 1 << 13 ) // This NPC will not actually drop a weapon that can be picked up//8192
#define SF_NPC_NO_PLAYER_PUSHAWAY ( 1 << 14 ) //16384
// ( 1 << 15 )
// !! Flags above ( 1 << 15 ) are reserved for NPC sub-classes

Expand Down
2 changes: 2 additions & 0 deletions sp/src/game/server/episodic/npc_magnusson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ int CNPC_Magnusson::GetSoundInterests ( void )
//-----------------------------------------------------------------------------
void CNPC_Magnusson::Spawn()
{
if (!m_bChaosSpawned)
AddSpawnFlags(SF_NPC_NO_PLAYER_PUSHAWAY);
// Allow custom model usage (mostly for monitors)
char *szModel = (char *)STRING( GetModelName() );
if (!szModel || !*szModel)
Expand Down
77 changes: 55 additions & 22 deletions sp/src/game/server/hl2/hl2_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,9 @@ void CHL2_Player::PreThink(void)
{
if (m_bRestartHUD)
{
#ifdef DEBUG
UTIL_CenterPrintAll("DEBUG BUILD. If you're seeing this and don't know why, please tell Pinsplash.\n");
#endif
m_bRestartHUD = false;
DoChaosHUDBar();
g_flEffectThinkRem = 0;
Expand Down Expand Up @@ -5247,7 +5250,7 @@ void CHL2_Player::PopulateEffects()
CreateEffect<CEBumpy>(EFFECT_BUMPY, MAKE_STRING("Bumpy Road"), EC_BUGGY, chaos_time_bumpy.GetFloat(), chaos_prob_bumpy.GetInt());
CreateEffect<CENoBrake>(EFFECT_NO_BRAKE, MAKE_STRING("Broken Brakes"), EC_BUGGY, chaos_time_no_brake.GetFloat(), chaos_prob_no_brake.GetInt());
CreateEffect<CEForceInOutCar>(EFFECT_FORCE_INOUT_CAR, MAKE_STRING("Force In/Out Vehicle"), EC_BUGGY | EC_BOAT | EC_PLAYER_TELEPORT,-1, chaos_prob_force_inout_car.GetInt());
CreateEffect<CEWeaponRemove>(EFFECT_WEAPON_REMOVE, MAKE_STRING("Remove Random Weapon"), EC_HAS_WEAPON | EC_NEED_PHYSGUN, -1, chaos_prob_weapon_remove.GetInt());
CreateEffect<CEWeaponRemove>(EFFECT_WEAPON_REMOVE, MAKE_STRING("Remove Random Weapon"), EC_NEED_PHYSGUN, -1, chaos_prob_weapon_remove.GetInt());
CreateEffect<>(EFFECT_INTERP_NPCS, MAKE_STRING("Laggy NPCs"), EC_NONE, chaos_time_interp_npcs.GetFloat(), chaos_prob_interp_npcs.GetInt());
CreateEffect<CEPhysConvert>(EFFECT_PHYS_CONVERT, MAKE_STRING("Ran Out Of Glue"), EC_NONE, -1, chaos_prob_phys_convert.GetInt());
CreateEffect<CEIncline>(EFFECT_INCLINE, MAKE_STRING("No Climbing"), EC_NONE, chaos_time_incline.GetFloat(), chaos_prob_incline.GetInt());
Expand Down Expand Up @@ -5475,6 +5478,33 @@ bool CChaosEffect::CheckEffectContext()
if (!Q_strcmp(pMapName, "d1_trainstation_05"))
return false;

if (m_nID == EFFECT_WEAPON_REMOVE)
{
if (UTIL_GetLocalPlayer()->GetActiveWeapon() == NULL)
return false;
CBaseCombatWeapon *pWeapon = (CBaseCombatWeapon *)gEntList.FindEntityByClassname(NULL, "we*");
CBaseCombatWeapon *pWeapon1 = NULL;
CBaseCombatWeapon *pWeapon2 = NULL;
while (pWeapon && !pWeapon2)
{
if (pWeapon->GetOwner() && pWeapon->GetOwner()->IsPlayer())
{
if (pWeapon1)
{
pWeapon2 = pWeapon;
break;
}
else
{
pWeapon1 = pWeapon;
}
}
pWeapon = (CBaseCombatWeapon *)gEntList.FindEntityByClassname(pWeapon, "we*");
}
if (!pWeapon2)
return false;
}

if (m_nContext == EC_NONE)
return true;

Expand Down Expand Up @@ -5544,19 +5574,19 @@ bool CChaosEffect::CheckEffectContext()
//don't need to check map list if we would be forcing out of a car, cause we don't teleport (far) in that case, unless you did the ladder bug thing
if (!(m_nID == EFFECT_FORCE_INOUT_CAR && pPlayer->IsInAVehicle()))
{
if (!Q_strcmp(pMapName, "d1_trainstation_01") || !Q_strcmp(pMapName, "d1_trainstation_04")|| !Q_strcmp(pMapName, "d1_trainstation_05")
|| !Q_strcmp(pMapName, "d1_canals_01") || !Q_strcmp(pMapName, "d1_canals_05") || !Q_strcmp(pMapName, "d1_canals_06") || !Q_strcmp(pMapName, "d1_canals_08") || !Q_strcmp(pMapName, "d1_canals_11")
if (!Q_strcmp(pMapName, "d1_trainstation_01") || !Q_strcmp(pMapName, "d1_trainstation_03") || !Q_strcmp(pMapName, "d1_trainstation_04") || !Q_strcmp(pMapName, "d1_trainstation_05")
|| !Q_strcmp(pMapName, "d1_canals_01") || !Q_strcmp(pMapName, "d1_canals_05") || !Q_strcmp(pMapName, "d1_canals_06") || !Q_strcmp(pMapName, "d1_canals_08") || !Q_strcmp(pMapName, "d1_canals_11")
|| !Q_strcmp(pMapName, "d1_eli_01") || !Q_strcmp(pMapName, "d1_eli_02")
|| !Q_strcmp(pMapName, "d1_town_02a") || !Q_strcmp(pMapName, "d1_town_05")
|| !Q_strcmp(pMapName, "d2_coast_11")
|| !Q_strcmp(pMapName, "d2_prison_06") || !Q_strcmp(pMapName, "d2_prison_08")
|| !Q_strcmp(pMapName, "d3_c17_06b") || !Q_strcmp(pMapName, "d3_c17_07") || !Q_strcmp(pMapName, "d3_c17_10b") || !Q_strcmp(pMapName, "d3_c17_13")
|| !Q_strcmp(pMapName, "d3_c17_06b") || !Q_strcmp(pMapName, "d3_c17_07") || !Q_strcmp(pMapName, "d3_c17_10b") || !Q_strcmp(pMapName, "d3_c17_13")
|| !Q_strcmp(pMapName, "d3_citadel_03") || !Q_strcmp(pMapName, "d3_citadel_04")
|| !Q_strcmp(pMapName, "d3_breen_01")
|| !Q_strcmp(pMapName, "ep1_citadel_01") || !Q_strcmp(pMapName, "ep1_citadel_03") || !Q_strcmp(pMapName, "ep1_citadel_04")
|| !Q_strcmp(pMapName, "ep1_citadel_01") || !Q_strcmp(pMapName, "ep1_citadel_03") || !Q_strcmp(pMapName, "ep1_citadel_04")
|| !Q_strcmp(pMapName, "ep1_c17_00") || !Q_strcmp(pMapName, "ep1_c17_00a")
|| !Q_strcmp(pMapName, "ep2_outland_01") || !Q_strcmp(pMapName, "ep2_outland_03") || !Q_strcmp(pMapName, "ep2_outland_06a") || !Q_strcmp(pMapName, "ep2_outland_09")
|| !Q_strcmp(pMapName, "ep2_outland_10") || !Q_strcmp(pMapName, "ep2_outland_11") || !Q_strcmp(pMapName, "ep2_outland_11a") || !Q_strcmp(pMapName, "ep2_outland_11b") || !Q_strcmp(pMapName, "ep2_outland_12") || !Q_strcmp(pMapName, "ep2_outland_12a"))
|| !Q_strcmp(pMapName, "ep2_outland_01") || !Q_strcmp(pMapName, "ep2_outland_03") || !Q_strcmp(pMapName, "ep2_outland_06a") || !Q_strcmp(pMapName, "ep2_outland_09")
|| !Q_strcmp(pMapName, "ep2_outland_10") || !Q_strcmp(pMapName, "ep2_outland_11") || !Q_strcmp(pMapName, "ep2_outland_11a") || !Q_strcmp(pMapName, "ep2_outland_11b") || !Q_strcmp(pMapName, "ep2_outland_12") || !Q_strcmp(pMapName, "ep2_outland_12a"))
return false;//no
}
}
Expand Down Expand Up @@ -7378,22 +7408,12 @@ void CEBottle::StartEffect()
int i = 0;
//try to make bottle as big as possible with whatever space is in front of player
do {
/*
pEnt->SetModelScale(i + 1);
vecOrigin += Vector(0, 0, 9);//move bottle up a bit to account for the origin being above the ground
vecOrigin += vecForward * 0.1 * i;//move bottle away as it gets bigger, or else we'll only get to about 45x before the trace fails because it's hitting the player
Msg("i %i vecOrigin %0.1f %0.1f %0.1f\n", i, vecOrigin.x, vecOrigin.y, vecOrigin.z);
//NDebugOverlay::Cross3D(vecOrigin, 16, 0, 255, 0, true, 30);
UTIL_TraceEntity(pEnt, vecOrigin, vecOrigin, MASK_SOLID, &trace);
i++;
*/
//NDebugOverlay::Cross3D(pEnt->GetAbsOrigin(), 16, 0, 255, 0, true, 30);
pEnt->SetModelScale(i + 1);
vecLastGoodPos = pEnt->GetAbsOrigin();
pEnt->GetUnstuck(20, UF_NO_NODE_TELEPORT);//only go up to 20 units away from previous position, instead of 500, which risks the beer spawning in some other random place, which is bad, i guess
UTIL_TraceEntity(pEnt, pEnt->GetAbsOrigin(), pEnt->GetAbsOrigin(), MASK_SOLID, &trace);
//only go up to 20 units away from previous position, instead of 500, which risks the beer spawning in some other random place, which is bad, i guess
i++;
} while (trace.fraction == 1 && !trace.startsolid && i < 55 && i < chaos_beer_size_limit.GetInt());//yes this i limit actually matters, or else we will create a beer so big it hits a max coord related assert and brings the whole game to a screeching halt. what the fuck.
} while (pEnt->GetUnstuck(20, UF_NO_NODE_TELEPORT) && i < chaos_beer_size_limit.GetInt());//yes this i limit actually matters, or else we will create a beer so big it hits a max coord related assert and brings the whole game to a screeching halt. what the fuck.
if (i > 1)
pEnt->SetModelScale(i - 1);
pEnt->SetMaxHealth(100 * i);
Expand Down Expand Up @@ -8553,14 +8573,27 @@ void CEWeaponRemove::StartEffect()
if (UTIL_GetLocalPlayer()->GetActiveWeapon() == NULL)
return;
CBaseCombatWeapon *pWeapon = (CBaseCombatWeapon *)gEntList.FindEntityByClassname(NULL, "we*");
while (pWeapon)
CBaseCombatWeapon *pWeapon1 = NULL;
CBaseCombatWeapon *pWeapon2 = NULL;
while (pWeapon && !pWeapon2)
{
if (pWeapon->GetOwner() && pWeapon->GetOwner()->IsPlayer())
break;
{
if (pWeapon1)
{
pWeapon2 = pWeapon;
break;
}
else
{
pWeapon1 = pWeapon;
}
}
pWeapon = (CBaseCombatWeapon *)gEntList.FindEntityByClassname(pWeapon, "we*");
}
if (!pWeapon)
if (!pWeapon2)
return;
pWeapon = RandomInt(0, 1) ? pWeapon1 : pWeapon2;
//hide model
CBaseViewModel *vm = UTIL_GetLocalPlayer()->GetViewModel(pWeapon->m_nViewModelIndex);
if (vm && pWeapon == UTIL_GetLocalPlayer()->GetActiveWeapon())
Expand Down
2 changes: 2 additions & 0 deletions sp/src/game/server/hl2/npc_breen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ int CNPC_Breen::GetSoundInterests ( void )
//-----------------------------------------------------------------------------
void CNPC_Breen::Spawn()
{
if (!m_bChaosSpawned)
AddSpawnFlags(SF_NPC_NO_PLAYER_PUSHAWAY);
// Breen is allowed to use multiple models, because he has a torso version for monitors.
// He defaults to his normal model.
char *szModel = (char *)STRING( GetModelName() );
Expand Down
2 changes: 2 additions & 0 deletions sp/src/game/server/hl2/npc_eli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ int CNPC_Eli::GetSoundInterests ( void )
//-----------------------------------------------------------------------------
void CNPC_Eli::Spawn()
{
if (!m_bChaosSpawned)
AddSpawnFlags(SF_NPC_NO_PLAYER_PUSHAWAY);
// Eli is allowed to use multiple models, because he appears in the pod.
// He defaults to his normal model.
char *szModel = (char *)STRING( GetModelName() );
Expand Down
2 changes: 2 additions & 0 deletions sp/src/game/server/hl2/npc_fisherman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ void CNPC_Fisherman::SelectModel()
//-----------------------------------------------------------------------------
void CNPC_Fisherman::Spawn( void )
{
if (!m_bChaosSpawned)
AddSpawnFlags(SF_NPC_NO_PLAYER_PUSHAWAY);
m_iHatLayer = -1;
m_iHatState = -1;

Expand Down
2 changes: 2 additions & 0 deletions sp/src/game/server/hl2/npc_gman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ int CNPC_GMan::GetSoundInterests ( void )
//-----------------------------------------------------------------------------
void CNPC_GMan::Spawn()
{
if (!m_bChaosSpawned)
AddSpawnFlags(SF_NPC_NO_PLAYER_PUSHAWAY);
Precache();

BaseClass::Spawn();
Expand Down
2 changes: 2 additions & 0 deletions sp/src/game/server/hl2/npc_kleiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ int CNPC_Kleiner::GetSoundInterests ( void )
//-----------------------------------------------------------------------------
void CNPC_Kleiner::Spawn()
{
if (!m_bChaosSpawned)
AddSpawnFlags(SF_NPC_NO_PLAYER_PUSHAWAY);
// Allow custom model usage (mostly for monitors)
char *szModel = (char *)STRING( GetModelName() );
if (!szModel || !*szModel)
Expand Down
2 changes: 2 additions & 0 deletions sp/src/game/server/hl2/npc_mossman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ int CNPC_Mossman::GetSoundInterests ( void )
//-----------------------------------------------------------------------------
void CNPC_Mossman::Spawn()
{
if (!m_bChaosSpawned)
AddSpawnFlags(SF_NPC_NO_PLAYER_PUSHAWAY);
Precache();

BaseClass::Spawn();
Expand Down

0 comments on commit 7852d90

Please sign in to comment.