mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-06 18:08:26 +00:00
Godmode fix for DMG_CRUSH and point_hurt (#1188)
* godmod fix for DMG_CRUSH and point_hurt * Added the "shavit_misc_godmode 4" option * fix error about `default` case not being last. `default` can be removed too since the convar has min/max limits --------- Co-authored-by: rtldg <55846624+rtldg@users.noreply.github.com>
This commit is contained in:
parent
4bbef8aa61
commit
ca60971410
@ -261,7 +261,7 @@ public void OnPluginStart()
|
||||
RegConsoleCmd("sm_adverts", Command_PrintAdverts, "Prints all the adverts to your chat");
|
||||
|
||||
// cvars and stuff
|
||||
gCV_GodMode = new Convar("shavit_misc_godmode", "3", "Enable godmode for players?\n0 - Disabled\n1 - Only prevent fall/world damage.\n2 - Only prevent damage from other players.\n3 - Full godmode.", 0, true, 0.0, true, 3.0);
|
||||
gCV_GodMode = new Convar("shavit_misc_godmode", "3", "Enable godmode for players?\n0 - Disabled\n1 - Only prevent fall/world damage.\n2 - Only prevent damage from other players.\n3 - Full godmode.\n4 - Prevent fall/world/entity damage (all except damage from other players).", 0, true, 0.0, true, 4.0);
|
||||
gCV_PreSpeed = new Convar("shavit_misc_prespeed", "2", "Stop prespeeding in the start zone?\n0 - Disabled, fully allow prespeeding.\n1 - Limit relatively to prestrafelimit.\n2 - Block bunnyhopping in startzone.\n3 - Limit to prestrafelimit and block bunnyhopping.\n4 - Limit to prestrafelimit but allow prespeeding. Combine with shavit_core_nozaxisspeed 1 for SourceCode timer's behavior.\n5 - Limit horizontal speed to prestrafe but allow prespeeding.", 0, true, 0.0, true, 5.0);
|
||||
gCV_HideTeamChanges = new Convar("shavit_misc_hideteamchanges", "1", "Hide team changes in chat?\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0);
|
||||
gCV_RespawnOnTeam = new Convar("shavit_misc_respawnonteam", "1", "Respawn whenever a player joins a team?\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0);
|
||||
@ -1484,35 +1484,54 @@ void ClearViewPunch(int victim)
|
||||
}
|
||||
}
|
||||
|
||||
public Action OnTakeDamage(int victim, int& attacker)
|
||||
public Action OnTakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype, int& weapon, float damageForce[3], float damagePosition[3])
|
||||
{
|
||||
bool bBlockDamage;
|
||||
|
||||
switch(gCV_GodMode.IntValue)
|
||||
{
|
||||
case 0:
|
||||
case 0: // don't block damage
|
||||
{
|
||||
bBlockDamage = false;
|
||||
}
|
||||
case 1:
|
||||
case 1: // block world/fall damage
|
||||
{
|
||||
// 0 - world/fall damage
|
||||
if(attacker == 0)
|
||||
if (attacker == 0)
|
||||
{
|
||||
bBlockDamage = true;
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
case 2: // block player-dealt damage
|
||||
{
|
||||
if(IsValidClient(attacker))
|
||||
char sClassname[12];
|
||||
if (IsValidClient(attacker) &&
|
||||
( !IsValidEntity(inflictor) || !GetEntityClassname(inflictor, sClassname, sizeof(sClassname)) || !StrEqual(sClassname, "point_hurt") ) // This line ignores damage dealt by point_hurt (see https://developer.valvesoftware.com/wiki/Point_hurt)
|
||||
)
|
||||
{
|
||||
bBlockDamage = true;
|
||||
}
|
||||
}
|
||||
default:
|
||||
case 3: // full godmode, blocks all damage
|
||||
{
|
||||
bBlockDamage = true;
|
||||
}
|
||||
case 4: // block world/fall/entity damage (all damage except damage from other players)
|
||||
{
|
||||
// 0 - world/fall damage
|
||||
if (attacker == 0 || attacker > MaxClients) // (attacker > MaxClients) for DMG_CRUSH, by moving/falling objects for example (with cs_enable_player_physics_box 1)
|
||||
{
|
||||
bBlockDamage = true;
|
||||
}
|
||||
else if (inflictor != attacker && IsValidEntity(inflictor)) // handles damage dealt by point_hurt (see https://developer.valvesoftware.com/wiki/Point_hurt)
|
||||
{
|
||||
char sClassname[12];
|
||||
if (GetEntityClassname(inflictor, sClassname, sizeof(sClassname)) && StrEqual(sClassname, "point_hurt"))
|
||||
{
|
||||
bBlockDamage = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gB_Hide[victim] || bBlockDamage || IsFakeClient(victim))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user