Skip to content

Commit

Permalink
Updated plugins. (#411)
Browse files Browse the repository at this point in the history
1) Fix the build of plugins for the latest version of the sourcemod (fixed errors and warnings).
2) Updated syntax in some plugins.
3) Added latest version of 'left4dhooks'.
4) 'l4d2_tank_damage_cvars' fixed broken functionality related to cvar 'vs_tank_pound_damage' (apparently this code never worked).
5) 'l4d2_sniper_bodyshot' code optimization.
6) Added smac include for plugin build
l4d2_user_commands'.
7) Removed conversions to another datatype in many plugins due to enum.
8) Removed unnecessary checks in some plugins.
9) Changed l4d2util includes. Since we only use enum as constants, the enumeration names have been removed. the name made it clear to the compiler that we were using our own datatype, so we had to convert it to another datatype to avoid the warnings.
10)
  • Loading branch information
A1mDev authored Nov 6, 2021
1 parent ae4ac2d commit c048ca7
Show file tree
Hide file tree
Showing 119 changed files with 6,642 additions and 3,450 deletions.
972 changes: 715 additions & 257 deletions addons/sourcemod/gamedata/left4dhooks.l4d2.txt

Large diffs are not rendered by default.

Binary file modified addons/sourcemod/plugins/anticheat/l4d2_user_commands.smx
Binary file not shown.
Binary file modified addons/sourcemod/plugins/left4dhooks.smx
Binary file not shown.
Binary file modified addons/sourcemod/plugins/optional/l4d2_playstats.smx
Binary file not shown.
Binary file modified addons/sourcemod/plugins/optional/l4d2_sniper_bodyshot.smx
Binary file not shown.
Binary file modified addons/sourcemod/plugins/optional/l4d2_sniper_precache.smx
Binary file not shown.
Binary file modified addons/sourcemod/plugins/optional/l4d2_tank_damage_cvars.smx
Binary file not shown.
Binary file modified addons/sourcemod/plugins/optional/survivor_mvp.smx
Binary file not shown.
6 changes: 3 additions & 3 deletions addons/sourcemod/scripting/1v1.sp
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ public void Event_PlayerHurt(Event hEvent, const char[] sEventName, bool bDontBr
}

int iAttacker = GetClientOfUserId(hEvent.GetInt("attacker"));
if (!IsClientAndInGame(iAttacker) || GetClientTeam(iAttacker) != view_as<int>(L4D2Team_Infected)) {
if (!IsClientAndInGame(iAttacker) || GetClientTeam(iAttacker) != L4D2Team_Infected) {
return;
}

int iZclass = GetEntProp(iAttacker, Prop_Send, "m_zombieClass");

if (iZclass < view_as<int>(L4D2Infected_Smoker) || iZclass > view_as<int>(L4D2Infected_Charger)) {
if (iZclass < L4D2Infected_Smoker || iZclass > L4D2Infected_Charger) {
return;
}

int iVictim = GetClientOfUserId(hEvent.GetInt("userid"));
if (!IsClientAndInGame(iVictim) || GetClientTeam(iVictim) != view_as<int>(L4D2Team_Survivor)) {
if (!IsClientAndInGame(iVictim) || GetClientTeam(iVictim) != L4D2Team_Survivor) {
return;
}

Expand Down
12 changes: 6 additions & 6 deletions addons/sourcemod/scripting/TickrateFixes.sp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define ENTITY_MAX_NAME 64

//Tracking
enum DoorsTypeTracked
enum /*DoorsTypeTracked*/
{
DoorsTypeTracked_None = -1,
DoorsTypeTracked_Prop_Door_Rotating = 0,
Expand All @@ -48,7 +48,7 @@ static const char g_szDoors_Type_Tracked[][MAX_NAME_LENGTH] =
#if SOURCEMOD_V_MINOR > 9
enum struct DoorsData
{
DoorsTypeTracked DoorsData_Type;
int DoorsData_Type;
float DoorsData_Speed;
bool DoorsData_ForceClose;
}
Expand All @@ -59,7 +59,7 @@ DoorsData
#else
enum DoorsData
{
DoorsTypeTracked:DoorsData_Type,
DoorsData_Type,
Float:DoorsData_Speed,
bool:DoorsData_ForceClose
};
Expand Down Expand Up @@ -175,7 +175,7 @@ public void Hook_DoorSpawnPost(int iEntity)
// Save Original Settings.
for (int i = 0; i < sizeof(g_szDoors_Type_Tracked); i++) {
if (strcmp(sClassName, g_szDoors_Type_Tracked[i], false) == 0) {
Door_GetSettings(iEntity, view_as<DoorsTypeTracked>(i));
Door_GetSettings(iEntity, i);
}
}

Expand Down Expand Up @@ -343,14 +343,14 @@ void Door_GetSettingsAll()

for (int i = 0;i < sizeof(g_szDoors_Type_Tracked); i++) {
while ((iEntity = FindEntityByClassname(iEntity, g_szDoors_Type_Tracked[i])) != INVALID_ENT_REFERENCE) {
Door_GetSettings(iEntity, view_as<DoorsTypeTracked>(i));
Door_GetSettings(iEntity, i);
}

iEntity = -1;
}
}

void Door_GetSettings(int iEntity, DoorsTypeTracked iDoorType)
void Door_GetSettings(int iEntity, int iDoorType)
{
#if SOURCEMOD_V_MINOR > 9
g_ddDoors[iEntity].DoorsData_Type = iDoorType;
Expand Down
2 changes: 2 additions & 0 deletions addons/sourcemod/scripting/aitankgank.sp
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ public Action Timed_CheckAndKill(Handle hTimer, any iNewTank)
if (IsFakeClient(iNewTank) && IsPlayerAlive(iNewTank)) {
ForcePlayerSuicide(iNewTank);
}

return Plugin_Stop;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

//Author - A1m`

stock bool L4D2Util_IsValidClient(int client)
stock bool IsValidClientIndex(int client)
{
return (client > 0 && client <= MaxClients);
}
Expand Down
10 changes: 5 additions & 5 deletions addons/sourcemod/scripting/botpopstop.sp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <sourcemod>
#include <sdktools>
#define L4D2UTIL_STOCKS_ONLY
#define L4D2UTIL_STOCKS_ONLY 1
#include <l4d2util>

#define USE_GIVEPLAYERITEM 0 // Works correctly only in the latest version of sourcemod 1.11 (GivePlayerItem sourcemod native)
Expand Down Expand Up @@ -58,10 +58,10 @@ public void Event_WeaponFire(Event hEvent, const char[] sEventName, bool bDontBr
int iWeaponArrayIndex = -1;

switch (iWeaponId) {
case view_as<int>(WEPID_PAIN_PILLS): {
case WEPID_PAIN_PILLS: {
iWeaponArrayIndex = ePILL_INDEX;
}
case view_as<int>(WEPID_ADRENALINE): {
case WEPID_ADRENALINE: {
iWeaponArrayIndex = eADREN_INDEX;
}
default: {
Expand All @@ -71,7 +71,7 @@ public void Event_WeaponFire(Event hEvent, const char[] sEventName, bool bDontBr

g_iBotUsedCount[iClient][iWeaponArrayIndex]++;

int iEntity = GetPlayerWeaponSlot(iClient, view_as<int>(L4D2WeaponSlot_LightHealthItem));
int iEntity = GetPlayerWeaponSlot(iClient, L4D2WeaponSlot_LightHealthItem);
RemovePlayerItem(iClient, iEntity);

#if SOURCEMOD_V_MINOR > 8
Expand All @@ -95,7 +95,7 @@ public void Event_PlayerJoined(Event hEvent, const char[] sEventName, bool bDont

void RestoreItems(int iClient, int iLeavingBot)
{
int iCurrentWeapon = GetPlayerWeaponSlot(iClient, view_as<int>(L4D2WeaponSlot_LightHealthItem));
int iCurrentWeapon = GetPlayerWeaponSlot(iClient, L4D2WeaponSlot_LightHealthItem);

for (int j = 0; j < eITEM_SIZE; j++) {
if (g_iBotUsedCount[iLeavingBot][j] < 1) {
Expand Down
50 changes: 24 additions & 26 deletions addons/sourcemod/scripting/caster_assister.sp
Original file line number Diff line number Diff line change
Expand Up @@ -162,37 +162,35 @@ public Action:SetVerticalIncrement_Cmd(client, args)

public Action:OnPlayerRunCmd(client, &buttons)
{
if (IsValidClient(client) && GetClientTeam(client) == 1)
{
if (buttons & IN_USE)
{
MoveUp(client, verticalIncrement[client]);
}
else if (buttons & IN_RELOAD)
{
MoveUp(client, -verticalIncrement[client]);
}
}
if (IsValidClient(client) && GetClientTeam(client) == 1)
{
if (buttons & IN_USE)
{
MoveUp(client, verticalIncrement[client]);
}
else if (buttons & IN_RELOAD)
{
MoveUp(client, -verticalIncrement[client]);
}
}

return Plugin_Continue;
}

public bool IsSpeedValid(float speed)
bool IsSpeedValid(float speed)
{
return speed >= 0 && speed <= MAX_SPEED;
return (speed >= 0 && speed <= MAX_SPEED);
}

stock MoveUp(client, Float:distance)
void MoveUp(int client, float distance)
{
decl Float:origin[3];
GetClientAbsOrigin(client, origin);
origin[2] += distance;
TeleportEntity(client, origin, NULL_VECTOR, NULL_VECTOR);
float origin[3];
GetClientAbsOrigin(client, origin);
origin[2] += distance;
TeleportEntity(client, origin, NULL_VECTOR, NULL_VECTOR);
}

stock bool:IsValidClient(client)
{
if (client <= 0 || client > MaxClients || !IsClientConnected(client))
{
return false;
}
return IsClientInGame(client);
}
bool IsValidClient(int client)
{
return (client > 0 && client <= MaxClients && IsClientInGame(client));
}
10 changes: 10 additions & 0 deletions addons/sourcemod/scripting/caster_system.sp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
{
CreateNative("IsClientCaster", Native_IsClientCaster);
CreateNative("IsIDCaster", Native_IsIDCaster);

RegPluginLibrary("caster_system");
return APLRes_Success;
}

public void OnPluginStart()
Expand Down Expand Up @@ -169,6 +171,8 @@ public Action Timer_ReconnectCasters(Handle timer, ArrayList aList)
int client = GetClientOfUserId(aList.Get(i));
if (client > 0) ReconnectClient(client);
}

return Plugin_Stop;
}

public Action L4D2_OnClientDisableAddons(const char[] SteamID)
Expand All @@ -194,6 +198,8 @@ public Action CasterCheck(Handle timer, int userid)
CPrintToChat(client, "%t", "CasterCheck2");
ChangeClientTeam(client, L4D2Team_Spectator);
}

return Plugin_Stop;
}

// ========================
Expand Down Expand Up @@ -312,6 +318,8 @@ public Action NotCasting_Cmd(int client, int args)
public Action Reconnect(Handle timer, int client)
{
if (IsClientConnected(client)) ReconnectClient(client);

return Plugin_Stop;
}

public Action ResetCaster_Cmd(int client, int args)
Expand Down Expand Up @@ -497,4 +505,6 @@ public Action Timer_KickSpecs(Handle timer)

KickClient(i, "%t", "KickSpecsReason");
}

return Plugin_Stop;
}
30 changes: 17 additions & 13 deletions addons/sourcemod/scripting/code_patcher.sp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public Action CodePatchListCommand(int args)

if (iSize == 0) {
PrintToServer("No patches applied");
return;
return Plugin_Handled;
}

for (int i = 0; i < iSize; ++i) {
Expand All @@ -98,13 +98,15 @@ public Action CodePatchListCommand(int args)

PrintToServer("%d. %s\t0x%x: %s", i+1, name, addr, formattedBytes);
}

return Plugin_Handled;
}

public Action CodePatchPatchCommand(int args)
{
if (GetCmdArgs() != 1) {
PrintToServer("syntax: codepatch_patch <patch_name>");
return;
return Plugin_Handled;
}

char name[MAX_PATCH_NAME_LENGTH + 1];
Expand All @@ -114,7 +116,7 @@ public Action CodePatchPatchCommand(int args)

if (patchId != -1) {
PrintToServer("Patch '%s' is already loaded", name);
return;
return Plugin_Handled;
}

char key[MAX_PATCH_NAME_LENGTH + 32];
Expand All @@ -123,52 +125,52 @@ public Action CodePatchPatchCommand(int args)
Format(key, sizeof(key), "%s_signature", name);
if (!GameConfGetKeyValue(hGameConfig, key, value, sizeof(value))) {
PrintToServer("Could not find key '%s'", key);
return;
return Plugin_Handled;
}

Address addr = GameConfGetAddress(hGameConfig, value);
if (!addr) {
PrintToServer("Could not load signature '%s'", value);
return;
return Plugin_Handled;
}

Format(key, sizeof(key), "%s_offset", name);
if (!GameConfGetKeyValue(hGameConfig, key, value, sizeof(value))) {
PrintToServer("Could not find key '%s'", key);
return;
return Plugin_Handled;
}

int offset = GameConfGetOffset(hGameConfig, value);
if (offset == -1) {
PrintToServer("Could not load offset '%s'", value);
return;
return Plugin_Handled;
}

Format(key, sizeof(key), "%s_length_%s", name, (bIsWindows) ? "windows" : "linux");
if (!GameConfGetKeyValue(hGameConfig, key, value, sizeof(value))) {
PrintToServer("Could not find key '%s'", key);
return;
return Plugin_Handled;
}

int length = StringToInt(value);

if (length < 1 || length > MAX_PATCH_SIZE) {
PrintToServer("Too %s patch bytes for '%s'", (length < 1) ? "few" : "many", name);
return;
return Plugin_Handled;
}

Format(key, sizeof(key), "%s_bytes_%s", name, (bIsWindows) ? "windows" : "linux");

if (!GameConfGetKeyValue(hGameConfig, key, value, sizeof(value))) {
PrintToServer("Could not find key '%s'", key);
return;
return Plugin_Handled;
}

char[] bytes = new char[length];

if (!ParseBytes(value, bytes, length)) {
PrintToServer("Failed to parse patch bytes for '%s'", name);
return;
return Plugin_Handled;
}

addr += view_as<Address>(offset);
Expand All @@ -179,13 +181,14 @@ public Action CodePatchPatchCommand(int args)
FormatBytes(bytes, length, formattedBytes);

PrintToServer("Applied patch '%s' [ %s] at 0x%x", name, formattedBytes, addr);
return Plugin_Handled;
}

public Action CodePatchUnpatchCommand(int args)
{
if (GetCmdArgs() != 1) {
PrintToServer("syntax: codepatch_unpatch <patch_name>");
return;
return Plugin_Handled;
}

char name[MAX_PATCH_NAME_LENGTH + 1];
Expand All @@ -195,12 +198,13 @@ public Action CodePatchUnpatchCommand(int args)

if (patchId == -1) {
PrintToServer("Patch '%s' is not loaded", name);
return;
return Plugin_Handled;
}

RevertPatch(name);

PrintToServer("Reverted patch '%s'", name);
return Plugin_Handled;
}

static int GetPackedByte(int cell, int i)
Expand Down
2 changes: 2 additions & 0 deletions addons/sourcemod/scripting/dhooks-test.sp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ public MRESReturn OnTakeDamage(int pThis, DHookReturn hReturn, DHookParam hParam
hParams.SetObjectVar(1, 48, ObjectValueType_Float, 0.0);
PrintToChat(pThis, "Pimping your hp");
}

return MRES_Ignored;
}

// int CBaseCombatCharacter::GiveAmmo(int, int, bool)
Expand Down
Loading

0 comments on commit c048ca7

Please sign in to comment.