diff --git a/scripting/randomizer.sp b/scripting/randomizer.sp index fc58cd0..e1d3281 100644 --- a/scripting/randomizer.sp +++ b/scripting/randomizer.sp @@ -343,6 +343,7 @@ bool g_bWeaponDecap[MAXPLAYERS]; Handle g_hTimerClientHud[MAXPLAYERS]; bool g_bOnTakeDamage; +bool g_bOnTakeDamageClass; int g_iGainingRageWeapon = INVALID_ENT_REFERENCE; int g_iTouchItem = INVALID_ENT_REFERENCE; int g_iTouchToucher = INVALID_ENT_REFERENCE; diff --git a/scripting/randomizer/dhook.sp b/scripting/randomizer/dhook.sp index 6ab3450..2eea3b0 100644 --- a/scripting/randomizer/dhook.sp +++ b/scripting/randomizer/dhook.sp @@ -45,6 +45,7 @@ static int g_iDHookGamerulesPre; static int g_iDHookGamerulesPost; static bool g_bDoClassSpecialSkill[MAXPLAYERS]; +static bool g_bDoClassSpecialSkillClass[MAXPLAYERS]; static bool g_bApplyBiteEffectsChocolate[MAXPLAYERS]; public void DHook_Init(GameData hGameData) @@ -461,7 +462,7 @@ public MRESReturn DHook_DoClassSpecialSkillPre(int iClient, DHookReturn hReturn) //If Engineer, pickup buildings //If Spy, cloak or uncloak - g_bDoClassSpecialSkill[iClient] = false; + g_bDoClassSpecialSkill[iClient] = true; // To stop DHook_SecondaryWeaponPost from calling this again int iActiveWeapon = GetEntPropEnt(iClient, Prop_Send, "m_hActiveWeapon"); if (iActiveWeapon == INVALID_ENT_REFERENCE) return MRES_Ignored; @@ -477,7 +478,7 @@ public MRESReturn DHook_DoClassSpecialSkillPre(int iClient, DHookReturn hReturn) int iButton = Controls_GetPassiveButtonBit(iClient, iWeapon); if (iButton > 0 && iButtons & iButton) { - g_bDoClassSpecialSkill[iClient] = true; + g_bDoClassSpecialSkillClass[iClient] = true; Controls_OnPassiveUse(iClient, iWeapon); SetClientClass(iClient, TF2_GetDefaultClassFromItem(iWeapon)); return MRES_Ignored; @@ -491,10 +492,12 @@ public MRESReturn DHook_DoClassSpecialSkillPre(int iClient, DHookReturn hReturn) public MRESReturn DHook_DoClassSpecialSkillPost(int iClient, DHookReturn hReturn) { - if (g_bDoClassSpecialSkill[iClient]) + if (g_bDoClassSpecialSkillClass[iClient]) + { RevertClientClass(iClient); + g_bDoClassSpecialSkillClass[iClient] = false; + } - g_bDoClassSpecialSkill[iClient] = true; // To stop DHook_SecondaryWeaponPost from calling this again return MRES_Ignored; } diff --git a/scripting/randomizer/event.sp b/scripting/randomizer/event.sp index c1e20ca..8d5092d 100644 --- a/scripting/randomizer/event.sp +++ b/scripting/randomizer/event.sp @@ -195,5 +195,8 @@ public void Event_WeaponJump(Event event, const char[] sName, bool bDontBroadcas { //Class check should be done by this point, revert class so pain sound can be played as actual class if (g_bOnTakeDamage) + { RevertClientClass(GetClientOfUserId(event.GetInt("userid"))); + g_bOnTakeDamageClass = false; + } } \ No newline at end of file diff --git a/scripting/randomizer/sdkhook.sp b/scripting/randomizer/sdkhook.sp index 67dba81..e848a34 100644 --- a/scripting/randomizer/sdkhook.sp +++ b/scripting/randomizer/sdkhook.sp @@ -62,6 +62,7 @@ public Action Client_OnTakeDamage(int iVictim, int &iAttacker, int &iInflictor, // IsPlayerClass not always called on linux, // and some class checks don't even use IsPlayerClass. SetClientClass(iAttacker, TF2_GetDefaultClassFromItem(iWeapon)); + g_bOnTakeDamageClass = true; Properties_LoadWeaponPropInt(iAttacker, iWeapon, "m_iDecapitations"); g_bWeaponDecap[iAttacker] = true; @@ -83,12 +84,16 @@ public void Client_OnTakeDamagePost(int iVictim, int iAttacker, int iInflictor, g_bOnTakeDamage = false; g_bFeignDeath[iVictim] = false; + if (g_bOnTakeDamageClass) + { + RevertClientClass(iAttacker); + g_bOnTakeDamageClass = false; + } + if (0 < iAttacker <= MaxClients) { if (iWeapon != INVALID_ENT_REFERENCE && HasEntProp(iWeapon, Prop_Send, "m_iItemDefinitionIndex")) { - RevertClientClass(iAttacker); - Properties_SaveWeaponPropInt(iAttacker, iWeapon, "m_iDecapitations"); g_bWeaponDecap[iAttacker] = false;