Skip to content

Commit

Permalink
Merge branch 'master' into sipooltest
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasylidong committed Apr 2, 2024
2 parents 916340b + 4b796f9 commit 9a1f01f
Show file tree
Hide file tree
Showing 36 changed files with 2,279 additions and 703 deletions.
Binary file modified addons/sourcemod/plugins/extend/l4d_stats.smx
Binary file not shown.
Binary file modified addons/sourcemod/plugins/extend/rpg.smx
Binary file not shown.
Binary file not shown.
Binary file modified addons/sourcemod/plugins/funcommands.smx
Binary file not shown.
Binary file removed addons/sourcemod/plugins/optional/botpopstop.smx
Binary file not shown.
Binary file not shown.
Binary file modified addons/sourcemod/plugins/optional/l4d2_playstats.smx
Binary file not shown.
File renamed without changes.
30 changes: 10 additions & 20 deletions addons/sourcemod/scripting/extend/l4d_stats.sp
Original file line number Diff line number Diff line change
Expand Up @@ -9734,7 +9734,7 @@ public CheckSurvivorsWin()

CampaignOver = true;
//StatsPrintToChatTeam(TEAM_SURVIVORS, "\x03CampaignOver值没问题!");
StopMapTiming();
if(!StopMapTiming())return;
CurrentGamemodeID = GetCurrentGamemodeID();
// Return if gamemode is Scavenge or Survival
if (CurrentGamemodeID == GAMEMODE_SCAVENGE ||
Expand All @@ -9749,17 +9749,6 @@ public CheckSurvivorsWin()
decl String:UpdatePoints[32], String:UpdatePointsPenalty[32];
new ClientTeam, bool:NegativeScore = GetConVarBool(cvar_EnableNegativeScore);

if (!MapTimingEnabled() || MapTimingStartTime <= 0.0)
{
return;
}
new Float:TotalTime = GetEngineTime() - MapTimingStartTime;
if(TotalTime < 30.0)
{
StatsPrintToChatAll("记录时间小于30s,数据应该不对,没有分数奖励!(PS: 30s能完成的图算啥图)");
return;
}

switch (CurrentGamemodeID)
{
case GAMEMODE_VERSUS:
Expand Down Expand Up @@ -11147,11 +11136,11 @@ GetCurrentDifficulty()
else return 0;
}

public StopMapTiming()
public bool StopMapTiming()
{
if (!MapTimingEnabled() || MapTimingStartTime <= 0.0 || StatsDisabled())
{
return;
return false;
}
if(g_brpgAvailable && !L4D_RPG_GetGlobalValue(INDEX_VALID))
{
Expand All @@ -11161,7 +11150,7 @@ public StopMapTiming()
}
MapTimingStartTime = -1.0;
MapTimingBlocked = true;
return;
return false;
}
if(!IsNormalMode() && !IsThisRoundValid())
{
Expand All @@ -11171,7 +11160,7 @@ public StopMapTiming()
}
MapTimingStartTime = -1.0;
MapTimingBlocked = true;
return;
return false;
}
int mode = 0;
if(IsAnne())
Expand All @@ -11196,14 +11185,14 @@ public StopMapTiming()
StatsPrintToChatAll("启用了多人运动模式,不记录这张地图游戏时间!");
MapTimingStartTime = -1.0;
MapTimingBlocked = true;
return;
return false;
}

new Float:TotalTime = GetEngineTime() - MapTimingStartTime;
if(TotalTime < 30.0)
{
StatsPrintToChatAll("记录时间小于30s,数据应该不对,没有分数奖励!(PS: 30s能完成的图算啥图)");
return;
return false;
}

MapTimingStartTime = -1.0;
Expand Down Expand Up @@ -11242,8 +11231,8 @@ public StopMapTiming()
}

// Game ended because all of the infected team left the server... don't record the time!
if (InfectedCounter <= 0)
return;
//if (InfectedCounter <= 0)
//return;

new GameDifficulty = GetCurrentDifficulty();
if(mode > 0)
Expand Down Expand Up @@ -11291,6 +11280,7 @@ public StopMapTiming()
}

ClearTrie(MapTimingSurvivors);
return true;
}

GetThisModeBestTime(int UseBuy=0)
Expand Down
5 changes: 4 additions & 1 deletion addons/sourcemod/scripting/extend/rpg.sp
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,10 @@ public void OnClientPostAdminCheck(int client)
{
if(!IsValidClient(client) || IsFakeClient(client))
return;
player[client].ClientFirstBuy = false;
if(IsStart)
player[client].ClientFirstBuy = false;
else
player[client].ClientFirstBuy = true;
player[client].ClientRecoil = 1;
player[client].CanBuy=true;
player[client].ClientPoints = 500;
Expand Down
22 changes: 22 additions & 0 deletions addons/sourcemod/scripting/include/readyup.inc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,28 @@ forward void OnRoundIsLivePre();
*/
forward void OnRoundIsLive();

/**
* Called when the live countdown has been cancelled
*
* @param client The client index.
* @param sDisruptReason The reason why cancel the live countdown
*/
forward void OnReadyCountdownCancelled(int client, char sDisruptReason);

/**
* Called when client is ready
*
* @param client The client index.
*/
forward void OnPlayerReady(int client);

/**
* Called when client is unready
*
* @param client The client index.
*/
forward void OnPlayerUnready(int client);

/**
* Returns the index of a item in the footer array.
* Does not have to be exact. The footer only needs to contain the input, does not need to match.
Expand Down
77 changes: 77 additions & 0 deletions addons/sourcemod/scripting/l4d2_block_bot_pills.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <left4dhooks>
#include <actions>
#include <colors>

bool g_bExtensionActions;

ConVar g_cvDebugModeEnabled;

public Plugin myinfo =
{
name = "[L4D2] Block Bot Pills",
author = "B[R]UTUS",
description = "Prohibits the use of pills to bots",
version = "1.0.1",
url = "https://github.com/SirPlease/L4D2-Competitive-Rework"
}

public void OnPluginStart()
{
// ====================
// Validate extensions
// ====================
g_bExtensionActions = LibraryExists("actionslib");

if (!g_bExtensionActions)
SetFailState("\n==========\nMissing required extensions: \"Actions\".\nRead installation instructions again.\n==========");

g_cvDebugModeEnabled = CreateConVar("l4d2_bbp_debug_enabled", "0", "Is debug mode enabled?");

HookEvent("player_bot_replace", playerBotReplace_Event);
}

public void playerBotReplace_Event(Event hEvent, char[] sEventName, bool dontBroadcast)
{
int bot = GetClientOfUserId(hEvent.GetInt("bot"));

if (bot < 1 || bot > MaxClients)
return;

char sWeapon[64];
GetClientWeapon(bot, sWeapon, sizeof(sWeapon));

if (strcmp(sWeapon[7], "pain_pills") == 0)
{
AcceptEntityInput(GetPlayerWeaponSlot(bot, 4), "Kill");

int newPills = CreateEntityByName("weapon_pain_pills");
DispatchSpawn(newPills);
EquipPlayerWeapon(bot, newPills);

if (g_cvDebugModeEnabled.BoolValue)
CPrintToChatAll("{green}[{default}Bot Block Pills{green}]{default}: Prevented accidental pills take by %N", bot);
}
}

// ====================================================================================================
// ACTIONS EXTENSION
// ====================================================================================================
public void OnActionCreated(BehaviorAction action, int actor, const char[] name)
{
/* Hooking take pills action (when bot wants to take pills) */
if (strcmp(name, "SurvivorTakePills") == 0)
action.OnStart = OnSelfActionPills;
}

public Action OnSelfActionPills(BehaviorAction action, int actor, BehaviorAction priorAction, ActionResult result)
{
if (g_cvDebugModeEnabled.BoolValue)
CPrintToChatAll("{green}[{default}Bot Block Pills{green}]{default}: Bot {blue}%N{default} wants to use pain pills. Blocking this action...", actor);

result.type = DONE;
return Plugin_Changed;
}
Loading

0 comments on commit 9a1f01f

Please sign in to comment.