diff --git a/Couch/scripting/Couch.sp b/Couch/scripting/Couch.sp index 111ad54..9848fed 100644 --- a/Couch/scripting/Couch.sp +++ b/Couch/scripting/Couch.sp @@ -111,6 +111,9 @@ static const char g_sPistols[][] = ConVar g_cvModel; ConVar g_cvPushScale; +// The engine's own phys_pushscale. Maps change it through point_servercommand, and the engine has +// already multiplied it into the damage force by the time OnTakeDamage runs, so it is divided out. +ConVar g_cvPhysPushScale; ConVar g_cvPistolOnly; ConVar g_cvAllowUse; ConVar g_cvEffect; @@ -236,7 +239,8 @@ public void OnPluginStart() g_fwdOnCouchBroken = new GlobalForward("Couch_OnCouchBroken", ET_Ignore, Param_Cell, Param_Cell); g_cvModel = CreateConVar("sm_couch_model", COUCH_DEFAULT_MODEL, "Model used for the couch. Applies to the next spawn.", FCVAR_NOTIFY); - g_cvPushScale = CreateConVar("sm_couch_push_scale", "6.0", "Multiplier on the force bullets apply to the couch. 1.0 is the engine's own push.", FCVAR_NOTIFY, true, 0.0, true, 100.0); + g_cvPushScale = CreateConVar("sm_couch_push_scale", "6.0", "Multiplier on the force bullets apply to the couch. 1.0 is the engine's own push at phys_pushscale 1; maps changing phys_pushscale don't change the couch.", FCVAR_NOTIFY, true, 0.0, true, 100.0); + g_cvPhysPushScale = FindConVar("phys_pushscale"); g_cvPistolOnly = CreateConVar("sm_couch_pistol_only", "0", "Only pistols and knives move the couch; other guns and grenades are ignored.", FCVAR_NOTIFY, true, 0.0, true, 1.0); g_cvAllowUse = CreateConVar("sm_allow_couch_use", "1", "Players may push the couch by holding +use on it. 0 means it can only be moved by shooting it.", FCVAR_NOTIFY, true, 0.0, true, 1.0); g_cvEffect = CreateConVar("sm_couch_effect", "1", "Colour cycle and pulsing light on the couch.", FCVAR_NOTIFY, true, 0.0, true, 1.0); @@ -683,7 +687,14 @@ public Action OnCouchTakeDamage(int victim, int &attacker, int &inflictor, float Action result = Plugin_Continue; + // damageForce already carries phys_pushscale (CalculateBulletDamageForce and the melee and + // explosive variants all multiply it in), so divide it back out. At 0 the force is already zero + // and there is nothing to undo. float fScale = g_cvPushScale.FloatValue; + float fEnginePush = (g_cvPhysPushScale != null) ? g_cvPhysPushScale.FloatValue : 1.0; + if (fEnginePush > 0.0) + fScale /= fEnginePush; + if (fScale != 1.0) { ScaleVector(damageForce, fScale);