Skip to content

Commit

Permalink
feat: add option to disable clear buff when mission_lost
Browse files Browse the repository at this point in the history
  • Loading branch information
rick-yao committed Jan 1, 2025
1 parent 22783ce commit 979169d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
21 changes: 21 additions & 0 deletions l4d2_tank_draw/scripting/l4d2_tank_draw.sp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ public void OnPluginStart()
DrugLuckySurvivorChance = CreateConVar("l4d2_tank_draw_drug_lucky_survivor_chance", "0", "幸运玩家中毒概率 \nProbability of drug luck drawer.", FCVAR_NONE);
DrugLuckySurvivorDuration = CreateConVar("l4d2_tank_draw_drug_lucky_survivor_duration", "30", "幸运玩家中毒秒数 \nDuration of drug luck drawer.", FCVAR_NONE);

ClearBuffIfMissionLost = CreateConVar("l4d2_tank_draw_clear_buff_if_mission_lost", "0", "关卡失败时清除buff[1=是|0=否] \nClear buff if mission lost[1=yes|0=no].", FCVAR_NONE);
HookConVarChange(ClearBuffIfMissionLost, ConVarChanged);

AutoExecConfig(true, "l4d2_tank_draw");

PrintToServer("[Tank Draw] Plugin loaded");
Expand All @@ -158,6 +161,8 @@ public void OnPluginStart()
HookEvent("map_transition", Event_RoundEnd, EventHookMode_Pre);
HookEvent("finale_win", Event_RoundEnd, EventHookMode_Pre);

SetConVar();

if (L4D2TankDrawDebugMode.IntValue == 1)
{
PrintToServer("调试菜单打开 / debug menu on");
Expand Down Expand Up @@ -349,5 +354,21 @@ public Action Event_Lost(Event event, const char[] name, bool dontBroadcast)

KillAllSingleGravityTimer();

if (g_iClearBuffIfMissionLost == 1)
{
ResetAllTimer();
ResetAllValue();
}

return Plugin_Continue;
}

void ConVarChanged(Handle convar, const char[] oldValue, const char[] newValue)
{
SetConVar();
}

void SetConVar()
{
g_iClearBuffIfMissionLost = ClearBuffIfMissionLost.IntValue;
}
5 changes: 4 additions & 1 deletion l4d2_tank_draw/scripting/lib/lib.sp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
int g_iClearBuffIfMissionLost;

// built-in convar
ConVar
g_hInfiniteAmmo,
Expand Down Expand Up @@ -61,7 +63,8 @@ ConVar
DrugAllSurvivorChance,
DrugAllSurvivorDuration,
DrugLuckySurvivorChance,
DrugLuckySurvivorDuration;
DrugLuckySurvivorDuration,
ClearBuffIfMissionLost;

Handle g_SingleGravityTimer[MAXPLAYERS + 1];
Handle g_WorldGravityTimer;
Expand Down

0 comments on commit 979169d

Please sign in to comment.