Skip to content

Commit

Permalink
feat: add reset all survivor health (#32)
Browse files Browse the repository at this point in the history
* feat: add reset all survivor health

* chore: version
  • Loading branch information
rick-yao authored Dec 12, 2024
1 parent a530dac commit be76f9d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
7 changes: 6 additions & 1 deletion l4d2_tank_draw/scripting/l4d2_tank_draw.sp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* @repository https://github.com/rick-yao/L4d2-plugin
*
* Changelog
* v2.7.0 - 2024-12-12
* - add reset all survivor health
*
* v2.6.0 - 2024-12-12
* - refactor the operation of timer, make it more robust
*
Expand Down Expand Up @@ -41,7 +44,7 @@
#include "lib/dev_menu.sp"
#include "lib/lucky_draw.sp"

#define PLUGIN_VERSION "2.6.0"
#define PLUGIN_VERSION "2.7.0"
#define PLUGIN_FLAG FCVAR_SPONLY | FCVAR_NOTIFY
#define COMMAND_FILTER COMMAND_FILTER_CONNECTED | COMMAND_FILTER_NO_BOTS

Expand Down Expand Up @@ -102,6 +105,8 @@ public void OnPluginStart()

ChanceKillSingleSurvivor = CreateConVar("l4d2_tank_draw_kill_single_survivor_chance", "10", "单人死亡概率 / Probability of killing a single survivor", FCVAR_NONE);

ChanceResetAllSurvivorHealth = CreateConVar("l4d2_tank_draw_reset_all_survivor_health_chance", "30", "重置所有人血量概率 / Probability of resetting all survivors' health", FCVAR_NONE);

ChanceNewTank = CreateConVar("l4d2_tank_draw_new_tank_chance", "30", "获得tank概率 / Probability of a tank", FCVAR_NONE);
ChanceNewWitch = CreateConVar("l4d2_tank_draw_new_witch_chance", "30", "获得witch概率 / Probability of a witch", FCVAR_NONE);

Expand Down
4 changes: 3 additions & 1 deletion l4d2_tank_draw/scripting/lib/lib.sp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ ConVar
ChanceFreezeBomb,
FreezeBombDuration,
FreezeBombCountDown,
FreezeBombRadius;
FreezeBombRadius,

ChanceResetAllSurvivorHealth;

Handle g_SingleGravityTimer[MAXPLAYERS + 1] = { INVALID_HANDLE, ... };
Handle g_WorldGravityTimer = INVALID_HANDLE;
Expand Down
19 changes: 18 additions & 1 deletion l4d2_tank_draw/scripting/lib/lucky_draw.sp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ stock Action LuckyDraw(int victim, int attacker)
int chanceTimerBomb = ChanceTimerBomb.IntValue;
int chanceDisableGlow = ChanceDisableGlow.IntValue;
int chanceFreezeBomb = ChanceFreezeBomb.IntValue;
int chanceResetAllSurvivorHealth = ChanceResetAllSurvivorHealth.IntValue;

int chanceLimitedTimeWorldMoonGravity = ChanceLimitedTimeWorldMoonGravity.IntValue;
int chanceMoonGravityOneLimitedTime = ChanceMoonGravityOneLimitedTime.IntValue;
Expand All @@ -23,7 +24,7 @@ stock Action LuckyDraw(int victim, int attacker)
int chanceClearAllSurvivorHealth = ChanceClearAllSurvivorHealth.IntValue;
int chanceReviveAllDead = ChanceReviveAllDead.IntValue;

int totalChance = chanceNoPrice + chanceNewWitch + chanceFreezeBomb + chanceTimerBomb + chanceReviveAllDead + chanceNewTank + chanceDisarmSingleSurvivor + chanceDisarmAllSurvivor + chanceDecreaseHealth + chanceClearAllSurvivorHealth + chanceIncreaseHealth + chanceInfiniteAmmo + chanceInfiniteMelee + chanceAverageHealth + chanceKillAllSurvivor + chanceKillSingleSurvivor + chanceDisableGlow;
int totalChance = chanceNoPrice + chanceResetAllSurvivorHealth + chanceNewWitch + chanceFreezeBomb + chanceTimerBomb + chanceReviveAllDead + chanceNewTank + chanceDisarmSingleSurvivor + chanceDisarmAllSurvivor + chanceDecreaseHealth + chanceClearAllSurvivorHealth + chanceIncreaseHealth + chanceInfiniteAmmo + chanceInfiniteMelee + chanceAverageHealth + chanceKillAllSurvivor + chanceKillSingleSurvivor + chanceDisableGlow;
totalChance += chanceLimitedTimeWorldMoonGravity + chanceMoonGravityOneLimitedTime + chanceWorldMoonGravityToggle + chanceIncreaseGravity;

if (totalChance == 0)
Expand Down Expand Up @@ -51,6 +52,22 @@ stock Action LuckyDraw(int victim, int attacker)
return Plugin_Continue;
}

currentChance += chanceResetAllSurvivorHealth;
if (random <= currentChance)
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsValidAliveClient(i))
{
CheatCommand(i, "give", "health");
L4D_SetTempHealth(i, 0.0);
}
}
CPrintToChatAll("%t", "TankDrawResult_ResetAllSurvivorHealth", attackerName);
PrintHintTextToAll("%t", "TankDrawResult_ResetAllSurvivorHealth_NoColor", attackerName);
return Plugin_Continue;
}

currentChance += chanceFreezeBomb;
if (random <= currentChance)
{
Expand Down
12 changes: 12 additions & 0 deletions l4d2_tank_draw/translations/l4d2_tank_draw.phrases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -599,4 +599,16 @@
"en" "[Tank Draw] Player %s's lucky draw result: A lucky Witch."
"chi" "[坦克抽奖] 玩家 %s 的幸运抽奖结果: 幸运Witch"
}

"TankDrawResult_ResetAllSurvivorHealth"
{
"en" "{yellow}[Tank Draw] {lightgreen}Player {olive}%s{lightgreen}'s lucky draw result: {olive}Reset all survivors' health."
"chi" "{yellow}[坦克抽奖] {lightgreen}玩家 {olive}%s{lightgreen} 的幸运抽奖结果:{olive} 重置所有幸存者生命值"
}

"TankDrawResult_ResetAllSurvivorHealth_NoColor"
{
"en" "[Tank Draw] Player %s's lucky draw result: Reset all survivors' health."
"chi" "[坦克抽奖] 玩家 %s 的幸运抽奖结果: 重置所有幸存者生命值"
}
}

0 comments on commit be76f9d

Please sign in to comment.