Skip to content

Commit

Permalink
Remove useless parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
M60TM committed Jul 19, 2023
1 parent e795f76 commit 317af40
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 49 deletions.
41 changes: 19 additions & 22 deletions scripting/include/tf2_sentryfirebullet.inc
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,28 @@ enum // FireBulletsFlags_t
/**
* Called before CBaseEntity::FireBullets().
*
* @param sentry
* @param builder
* @param shots
* @param src
* @param dirShooting
* @param spread Spread of bullet fire.
* @param distance
* @param ammoType
* @param tracerFreq
* @param damage
* @param playerDamage Damage to be used instead of m_flDamage if we hit a player.
* @param flags See FireBulletsFlags_t.
* @param damageForceScale
* @param attacker
* @param additionalIgnoreEnt
* @param primaryAttack
* @param useServerRandomSeed
* @param sentry Sentry entity index.
* @param builder Sentry builder index.
* @param shots Number of bullets.
* @param src Start point of bullet fire.
* @param dirShooting Direction of bullet fire.
* @param spread Spread of bullet fire.
* @param distance Distance of bullet's max reach.
* @param tracerFreq Tracer Frequency. Set to 0, no bullet tracer.
* @param damage Damage of per bullet.
* @param playerDamage Damage to be used instead of m_flDamage if we hit a player.
* @param flags See FireBulletsFlags_t.
* @param damageForceScale Damage's force scale. But it doesn't seem to affect alive player?
* @param attacker Attacker index. Unless it's a special situation, it is builder. If builder isn't valid, it is sentry.
* @param ignoreEnt Define target who bullet will ignore. Default value is -1(none).
*
* @return Plugin_Stop or Plugin_Handled to block shooting bullet.
* Plugin_Changed to change parameters.
* Plugin_Continue is nothing happen.
* @return Plugin_Stop or Plugin_Handled to block shooting bullet.
* Plugin_Changed to change parameters.
* Plugin_Continue is nothing happen.
*/
forward Action TF2_SentryFireBullet(int sentry, int builder, int &shots, const float src[3], const float dirShooting[3], float spread[3], float &distance, int &ammoType, int &tracerFreq, float &damage, int &playerDamage, int &flags, float &damageForceScale, int &attacker, int &ignoreEnt, bool &primaryAttack, bool &useServerRandomSeed);
forward Action TF2_SentryFireBullet(int sentry, int builder, int &shots, float src[3], const float dirShooting[3], float spread[3], float &distance, int &tracerFreq, float &damage, int &playerDamage, int &flags, float &damageForceScale, int &attacker, int &ignoreEnt);

forward void TF2_SentryFireBulletPost(int sentry, int builder, int shots, const float src[3], const float dirShooting[3], const float spread[3], float distance, int ammoType, int tracerFreq, float damage, int playerDamage, int flags, float damageForceScale, int attacker, int ignoreEnt, bool primaryAttack, bool useServerRandomSeed);
forward void TF2_SentryFireBulletPost(int sentry, int builder, int shots, const float src[3], const float dirShooting[3], const float spread[3], float distance, int tracerFreq, float damage, int playerDamage, int flags, float damageForceScale, int attacker, int ignoreEnt);

public SharedPlugin __pl_tf2_sentryfirebullet = {
name = "tf2_sentryfirebullet",
Expand Down
38 changes: 11 additions & 27 deletions scripting/tf2_sentryfirebullet.sp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

#include <classdefs/firebulletsinfo_t.sp>

GlobalForward g_FwdSentryFireBulletPre;
GlobalForward g_FwdSentryFireBulletPost;
static GlobalForward g_FwdSentryFireBulletPre;
static GlobalForward g_FwdSentryFireBulletPost;

DynamicHook g_DHookSentryFireBullet;
static DynamicHook g_DHookSentryFireBullet;

/*
enum struct FireBullets_t
Expand All @@ -41,11 +41,11 @@ enum struct FireBullets_t

public Plugin myinfo =
{
name = "[TF2] Sentry Fire Bullet",
author = "Sandy and AzulFlamaWallon",
name = "[TF2] Sentry Fire Bullet",
author = "Sandy and AzulFlamaWallon",
description = "Hook Sentry's Bullet Fire.",
version = "1.0.0",
url = "https://github.com/M60TM/TF2-Sentry-Fire-Bullet"
version = "1.0.0",
url = "https://github.com/M60TM/TF2-Sentry-FireBullet"
};

public APLRes AskPluginLoad2(Handle hPlugin, bool late, char[] error, int maxlen) {
Expand All @@ -70,9 +70,9 @@ public void OnPluginStart(){

delete data;

g_FwdSentryFireBulletPre = CreateGlobalForward("TF2_SentryFireBullet", ET_Hook, Param_Cell, Param_Cell, Param_CellByRef, Param_Array, Param_Array, Param_Array, Param_FloatByRef, Param_CellByRef, Param_CellByRef, Param_FloatByRef, Param_CellByRef, Param_CellByRef, Param_FloatByRef, Param_CellByRef, Param_CellByRef, Param_CellByRef, Param_CellByRef);
g_FwdSentryFireBulletPre = new GlobalForward("TF2_SentryFireBullet", ET_Hook, Param_Cell, Param_Cell, Param_CellByRef, Param_Array, Param_Array, Param_Array, Param_FloatByRef, Param_CellByRef, Param_FloatByRef, Param_CellByRef, Param_CellByRef, Param_FloatByRef, Param_CellByRef, Param_CellByRef);

g_FwdSentryFireBulletPost = CreateGlobalForward("TF2_SentryFireBulletPost", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_Array, Param_Array, Param_Array, Param_Float, Param_Cell, Param_Cell, Param_Float, Param_Cell, Param_Cell, Param_Float, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
g_FwdSentryFireBulletPost = new GlobalForward("TF2_SentryFireBulletPost", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_Array, Param_Array, Param_Array, Param_Float, Param_Cell, Param_Float, Param_Cell, Param_Cell, Param_Float, Param_Cell, Param_Cell);
}

public void OnEntityCreated(int entity, const char[] classname){
Expand Down Expand Up @@ -133,7 +133,6 @@ bool CallFireBulletsInfoForward(GlobalForward fwd, int sentry, int builder, Fire
info.GetVecSpread(spread);

float distance = info.m_flDistance;
int ammoType = info.m_iAmmoType;
int tracerFreq = info.m_iTracerFreq;
float damage = info.m_flDamage;
int playerDamage = info.m_iPlayerDamage;
Expand All @@ -143,27 +142,21 @@ bool CallFireBulletsInfoForward(GlobalForward fwd, int sentry, int builder, Fire
int attacker = (info.m_pAttacker == Address_Null) ? -1 : GetEntityFromAddress(info.m_pAttacker);
int ignoreEnt = (info.m_pAdditionalIgnoreEnt == Address_Null) ? -1 : GetEntityFromAddress(info.m_pAdditionalIgnoreEnt);

bool primaryAttack = info.m_bPrimaryAttack;
bool useServerRandomSeed = info.m_bUseServerRandomSeed;

Call_StartForward(fwd);
Call_PushCell(sentry);
Call_PushCell(builder);
Call_PushCellRef(shots);
Call_PushArray(src, 3);
Call_PushArrayEx(src, 3, SM_PARAM_COPYBACK);
Call_PushArray(dirShooting, 3);
Call_PushArrayEx(spread, 3, SM_PARAM_COPYBACK);
Call_PushFloatRef(distance);
Call_PushCellRef(ammoType);
Call_PushCellRef(tracerFreq);
Call_PushFloatRef(damage);
Call_PushCellRef(playerDamage);
Call_PushCellRef(flags);
Call_PushFloatRef(damageForceScale);
Call_PushCellRef(attacker);
Call_PushCellRef(ignoreEnt);
Call_PushCellRef(primaryAttack);
Call_PushCellRef(useServerRandomSeed);

Action result;
Call_Finish(result);
Expand All @@ -179,6 +172,7 @@ bool CallFireBulletsInfoForward(GlobalForward fwd, int sentry, int builder, Fire
{
info.m_iShots = shots;

info.SetVecSrc(src);
info.SetVecSpread(spread);

info.m_flDistance = distance;
Expand All @@ -192,9 +186,6 @@ bool CallFireBulletsInfoForward(GlobalForward fwd, int sentry, int builder, Fire
info.m_pAttacker = IsValidEntity(attacker) ? GetEntityAddress(attacker) : Address_Null;
info.m_pAdditionalIgnoreEnt = IsValidEntity(ignoreEnt) ? GetEntityAddress(ignoreEnt) : Address_Null;

info.m_bPrimaryAttack = primaryAttack;
info.m_bUseServerRandomSeed = useServerRandomSeed;

supercede = false;
}
case Plugin_Continue:
Expand All @@ -215,7 +206,6 @@ void CallFireBulletsInfoPostForward(GlobalForward fwd, int sentry, int builder,
info.GetVecSpread(spread);

float distance = info.m_flDistance;
int ammoType = info.m_iAmmoType;
int tracerFreq = info.m_iTracerFreq;
float damage = info.m_flDamage;
int playerDamage = info.m_iPlayerDamage;
Expand All @@ -225,9 +215,6 @@ void CallFireBulletsInfoPostForward(GlobalForward fwd, int sentry, int builder,
int attacker = (info.m_pAttacker == Address_Null) ? -1 : GetEntityFromAddress(info.m_pAttacker);
int ignoreEnt = (info.m_pAdditionalIgnoreEnt == Address_Null) ? -1 : GetEntityFromAddress(info.m_pAdditionalIgnoreEnt);

bool primaryAttack = info.m_bPrimaryAttack;
bool useServerRandomSeed = info.m_bUseServerRandomSeed;

Call_StartForward(fwd);
Call_PushCell(sentry);
Call_PushCell(builder);
Expand All @@ -236,16 +223,13 @@ void CallFireBulletsInfoPostForward(GlobalForward fwd, int sentry, int builder,
Call_PushArray(dirShooting, 3);
Call_PushArray(spread, 3);
Call_PushFloat(distance);
Call_PushCell(ammoType);
Call_PushCell(tracerFreq);
Call_PushFloat(damage);
Call_PushCell(playerDamage);
Call_PushCell(flags);
Call_PushFloat(damageForceScale);
Call_PushCell(attacker);
Call_PushCell(ignoreEnt);
Call_PushCell(primaryAttack);
Call_PushCell(useServerRandomSeed);
Call_Finish();
}

Expand Down

0 comments on commit 317af40

Please sign in to comment.