Skip to content

Commit

Permalink
Ignore damage falloff distance for rockets
Browse files Browse the repository at this point in the history
  • Loading branch information
FortyTwoFortyTwo committed Nov 13, 2023
1 parent ba3559e commit 60f1ae9
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
7 changes: 7 additions & 0 deletions addons/sourcemod/configs/vsh/vsh.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//- minicrit - Give minicrit when holding weapon
//- crit - Give crit when holding weapon
//- clip - Set given clip size on spawn
//- ignorefalloff - Whenever to ignore blast damage falloff
//
//List of calling function name
//- banner - Called when player uses banner
Expand Down Expand Up @@ -202,6 +203,11 @@

"Soldier"
{
"Primary"
{
"ignorefalloff" "1"
}

"Melee"
{
"crit" "1"
Expand Down Expand Up @@ -504,6 +510,7 @@
{
"desp" "Back Scatter: {neutral}Fires fast rockets instead of bullets"
"attrib" "280 ; 2.0 ; 2 ; 8.0 ; 103 ; 1.33"
"ignorefalloff" "1"
}

"772" //Baby Face Blaster
Expand Down
50 changes: 50 additions & 0 deletions addons/sourcemod/scripting/saxtonhale.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,8 @@ public void OnClientPutInServer(int iClient)
SDK_HookGiveNamedItem(iClient);
SDKHook(iClient, SDKHook_PreThink, Client_OnThink);
SDKHook(iClient, SDKHook_OnTakeDamageAlive, Client_OnTakeDamageAlive);
SDKHook(iClient, SDKHook_OnTakeDamage, Client_OnTakeDamage);
SDKHook(iClient, SDKHook_OnTakeDamagePost, Client_OnTakeDamagePost);
SDKHook(iClient, SDKHook_StartTouch, Client_OnStartTouch);
SDKHook(iClient, SDKHook_WeaponSwitchPost, Client_OnWeaponSwitchPost);

Expand Down Expand Up @@ -1435,6 +1437,54 @@ public Action Client_OnTakeDamageAlive(int victim, int &attacker, int &inflictor
return finalAction;
}

public Action Client_OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3], int damagecustom)
{
if (!g_bEnabled) return Plugin_Continue;
if (g_iTotalRoundPlayed <= 0) return Plugin_Continue;

if (SaxtonHale_IsValidAttack(attacker) && weapon != INVALID_ENT_REFERENCE && HasEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex"))
{
TFClassType nClass = TF2_GetPlayerClass(attacker);
int iIndex = GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
int iSlot = TF2_GetItemSlot(iIndex, nClass);

if (0 <= iSlot < sizeof(g_ConfigClass[]))
{
int iIgnoreFalloff = g_ConfigIndex.IgnoreFalloff(iIndex);
if (iIgnoreFalloff == -1)
iIgnoreFalloff = g_ConfigClass[nClass][iSlot].IgnoreFalloff();

if (iIgnoreFalloff == 1)
TF2_AddCondition(attacker, TFCond_RunePrecision, 0.05);
}
}

return Plugin_Continue;
}

public void Client_OnTakeDamagePost(int victim, int attacker, int inflictor, float damage, int damagetype, int weapon, const float damageForce[3], const float damagePosition[3], int damagecustom)
{
if (!g_bEnabled) return;
if (g_iTotalRoundPlayed <= 0) return;

if (SaxtonHale_IsValidAttack(attacker) && weapon != INVALID_ENT_REFERENCE && HasEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex"))
{
TFClassType nClass = TF2_GetPlayerClass(attacker);
int iIndex = GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
int iSlot = TF2_GetItemSlot(iIndex, nClass);

if (0 <= iSlot < sizeof(g_ConfigClass[]))
{
int iIgnoreFalloff = g_ConfigIndex.IgnoreFalloff(iIndex);
if (iIgnoreFalloff == -1)
iIgnoreFalloff = g_ConfigClass[nClass][iSlot].IgnoreFalloff();

if (iIgnoreFalloff == 1)
TF2_RemoveCondition(attacker, TFCond_RunePrecision);
}
}
}

public Action Client_OnStartTouch(int iClient, int iToucher)
{
if (!g_bEnabled) return Plugin_Continue;
Expand Down
23 changes: 23 additions & 0 deletions addons/sourcemod/scripting/vsh/config.sp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ methodmap ConfigClass < StringMap

else return -1;
}

//Return whenever to ignore damage falloff
public int IgnoreFalloff()
{
char sValue[MAXLEN_CONFIG_VALUE];
if (this.GetString("ignorefalloff", sValue, sizeof(sValue)))
return StringToInt(sValue);

else return -1;
}
};

methodmap ConfigIndex < ArrayList
Expand Down Expand Up @@ -276,6 +286,19 @@ methodmap ConfigIndex < ArrayList

else return -1;
}

//Return whenever to ignore damage falloff
public int IgnoreFalloff(int iIndex)
{
StringMap sMap = this.GetStringMap(iIndex);
if (sMap == null) return -1;

char sValue[MAXLEN_CONFIG_VALUE];
if (sMap.GetString("ignorefalloff", sValue, sizeof(sValue)))
return StringToInt(sValue);

else return -1;
}
};

methodmap ConfigConvar < StringMap
Expand Down

0 comments on commit 60f1ae9

Please sign in to comment.