Skip to content

Commit 60f1ae9

Browse files
Ignore damage falloff distance for rockets
1 parent ba3559e commit 60f1ae9

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

addons/sourcemod/configs/vsh/vsh.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//- minicrit - Give minicrit when holding weapon
77
//- crit - Give crit when holding weapon
88
//- clip - Set given clip size on spawn
9+
//- ignorefalloff - Whenever to ignore blast damage falloff
910
//
1011
//List of calling function name
1112
//- banner - Called when player uses banner
@@ -202,6 +203,11 @@
202203

203204
"Soldier"
204205
{
206+
"Primary"
207+
{
208+
"ignorefalloff" "1"
209+
}
210+
205211
"Melee"
206212
{
207213
"crit" "1"
@@ -504,6 +510,7 @@
504510
{
505511
"desp" "Back Scatter: {neutral}Fires fast rockets instead of bullets"
506512
"attrib" "280 ; 2.0 ; 2 ; 8.0 ; 103 ; 1.33"
513+
"ignorefalloff" "1"
507514
}
508515

509516
"772" //Baby Face Blaster

addons/sourcemod/scripting/saxtonhale.sp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,8 @@ public void OnClientPutInServer(int iClient)
12371237
SDK_HookGiveNamedItem(iClient);
12381238
SDKHook(iClient, SDKHook_PreThink, Client_OnThink);
12391239
SDKHook(iClient, SDKHook_OnTakeDamageAlive, Client_OnTakeDamageAlive);
1240+
SDKHook(iClient, SDKHook_OnTakeDamage, Client_OnTakeDamage);
1241+
SDKHook(iClient, SDKHook_OnTakeDamagePost, Client_OnTakeDamagePost);
12401242
SDKHook(iClient, SDKHook_StartTouch, Client_OnStartTouch);
12411243
SDKHook(iClient, SDKHook_WeaponSwitchPost, Client_OnWeaponSwitchPost);
12421244

@@ -1435,6 +1437,54 @@ public Action Client_OnTakeDamageAlive(int victim, int &attacker, int &inflictor
14351437
return finalAction;
14361438
}
14371439

1440+
public Action Client_OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3], int damagecustom)
1441+
{
1442+
if (!g_bEnabled) return Plugin_Continue;
1443+
if (g_iTotalRoundPlayed <= 0) return Plugin_Continue;
1444+
1445+
if (SaxtonHale_IsValidAttack(attacker) && weapon != INVALID_ENT_REFERENCE && HasEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex"))
1446+
{
1447+
TFClassType nClass = TF2_GetPlayerClass(attacker);
1448+
int iIndex = GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
1449+
int iSlot = TF2_GetItemSlot(iIndex, nClass);
1450+
1451+
if (0 <= iSlot < sizeof(g_ConfigClass[]))
1452+
{
1453+
int iIgnoreFalloff = g_ConfigIndex.IgnoreFalloff(iIndex);
1454+
if (iIgnoreFalloff == -1)
1455+
iIgnoreFalloff = g_ConfigClass[nClass][iSlot].IgnoreFalloff();
1456+
1457+
if (iIgnoreFalloff == 1)
1458+
TF2_AddCondition(attacker, TFCond_RunePrecision, 0.05);
1459+
}
1460+
}
1461+
1462+
return Plugin_Continue;
1463+
}
1464+
1465+
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)
1466+
{
1467+
if (!g_bEnabled) return;
1468+
if (g_iTotalRoundPlayed <= 0) return;
1469+
1470+
if (SaxtonHale_IsValidAttack(attacker) && weapon != INVALID_ENT_REFERENCE && HasEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex"))
1471+
{
1472+
TFClassType nClass = TF2_GetPlayerClass(attacker);
1473+
int iIndex = GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
1474+
int iSlot = TF2_GetItemSlot(iIndex, nClass);
1475+
1476+
if (0 <= iSlot < sizeof(g_ConfigClass[]))
1477+
{
1478+
int iIgnoreFalloff = g_ConfigIndex.IgnoreFalloff(iIndex);
1479+
if (iIgnoreFalloff == -1)
1480+
iIgnoreFalloff = g_ConfigClass[nClass][iSlot].IgnoreFalloff();
1481+
1482+
if (iIgnoreFalloff == 1)
1483+
TF2_RemoveCondition(attacker, TFCond_RunePrecision);
1484+
}
1485+
}
1486+
}
1487+
14381488
public Action Client_OnStartTouch(int iClient, int iToucher)
14391489
{
14401490
if (!g_bEnabled) return Plugin_Continue;

addons/sourcemod/scripting/vsh/config.sp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ methodmap ConfigClass < StringMap
9494

9595
else return -1;
9696
}
97+
98+
//Return whenever to ignore damage falloff
99+
public int IgnoreFalloff()
100+
{
101+
char sValue[MAXLEN_CONFIG_VALUE];
102+
if (this.GetString("ignorefalloff", sValue, sizeof(sValue)))
103+
return StringToInt(sValue);
104+
105+
else return -1;
106+
}
97107
};
98108

99109
methodmap ConfigIndex < ArrayList
@@ -276,6 +286,19 @@ methodmap ConfigIndex < ArrayList
276286

277287
else return -1;
278288
}
289+
290+
//Return whenever to ignore damage falloff
291+
public int IgnoreFalloff(int iIndex)
292+
{
293+
StringMap sMap = this.GetStringMap(iIndex);
294+
if (sMap == null) return -1;
295+
296+
char sValue[MAXLEN_CONFIG_VALUE];
297+
if (sMap.GetString("ignorefalloff", sValue, sizeof(sValue)))
298+
return StringToInt(sValue);
299+
300+
else return -1;
301+
}
279302
};
280303

281304
methodmap ConfigConvar < StringMap

0 commit comments

Comments
 (0)