Skip to content

Commit 3443c95

Browse files
committed
.
1 parent 4533882 commit 3443c95

6 files changed

+109
-31
lines changed

l4d2_BotHaymakers.sp

+17
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public Plugin:myinfo =
1515

1616
int iHaymakerChanceFactor;
1717
ConVar hHaymakerChanceFactor;
18+
int g_iSpawnStuck[MAXPLAYERS+1];
1819

1920
public OnPluginStart()
2021
{
@@ -30,6 +31,17 @@ public OnPluginStart()
3031

3132
AutoExecConfig(true, "l4d2_BotHaymakers");
3233

34+
HookEvent("player_spawn", Event_PlayerSpawn);
35+
HookEvent("player_first_spawn", Event_PlayerSpawn);
36+
}
37+
38+
public void Event_PlayerSpawn(Event event, const char[] eventName, bool dontBroadcast)
39+
{
40+
int client = GetClientOfUserId(event.GetInt("userid"));
41+
if(!client || !IsClientInGame(client) || !IsFakeClient(client) || GetClientTeam(client) != 3 || GetEntProp(client, Prop_Send, "m_zombieClass") != 8)
42+
return;
43+
44+
g_iSpawnStuck[client] = 5;
3345
}
3446

3547
public Action:OnPlayerRunCmd(client, &buttons)
@@ -47,6 +59,11 @@ public Action:OnPlayerRunCmd(client, &buttons)
4759
}
4860
}
4961
}
62+
if(g_iSpawnStuck[client] > 0)
63+
{
64+
g_iSpawnStuck[client] -= 1;
65+
buttons |= IN_ATTACK2;
66+
}
5067
}
5168

5269
return Plugin_Continue;

l4d2_connect_hint.sp

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
#include <geoip>
55
#include <geoipcity>
66

7-
#define PLUGIN_VERSION "0.1"
7+
#define PLUGIN_VERSION "0.2"
88
#include "modules/l4d2ps.sp"
99

10+
#define SOUND_CONNECT "buttons/bell1.wav"
11+
#define SOUND_DISCONNECT "buttons/button4.wav"
12+
1013
public Plugin myinfo =
1114
{
1215
name = "玩家加入提示",
@@ -184,6 +187,8 @@ public void OnMapStart()
184187
PrecacheGameModeList();
185188
// g_szOriginalHostName[0] = EOS;
186189
LoadHostName();
190+
PrecacheSound(SOUND_CONNECT);
191+
PrecacheSound(SOUND_DISCONNECT);
187192
}
188193

189194
public Action Event_PlayerConnectClientPre(Event event, const char[] eventName, bool dontBroadcast)
@@ -292,7 +297,10 @@ public void Event_PlayerConnect(Event event, const char[] eventName, bool dontBr
292297
}
293298

294299
if(buffer[0] != EOS)
300+
{
295301
PrintToChatAll(buffer);
302+
EmitSoundToAll(SOUND_CONNECT);
303+
}
296304
}
297305

298306
public Action Event_PlayerDisconnectPre(Event event, const char[] eventName, bool dontBroadcast)
@@ -390,7 +398,10 @@ public void Event_PlayerDisconnect(Event event, const char[] eventName, bool don
390398
}
391399

392400
if(buffer[0] != EOS)
401+
{
393402
PrintToChatAll(buffer);
403+
EmitSoundToAll(SOUND_DISCONNECT);
404+
}
394405
}
395406

396407
public void Event_PlayerTeam(Event event, const char[] eventName, bool dontBroadcast)

l4d2_dlc2_levelup.sp

+17-10
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#define SOUND_LEVELUP "ui/bigreward.wav"
3939
#define SOUND_AMMO "items/itempickup.wav"
4040
#define SOUND_CROW "ambient/animal/crow_2.wav"
41+
#define SOUND_EXPLOSIVE "weapons/hegrenade/explode5.wav"
42+
#define SOUND_GIFT "ui/gift_drop.wav"
4143

4244
#define g_flSoH_rate 0.4
4345
#define ZC_SMOKER 1
@@ -838,7 +840,7 @@ public OnPluginStart()
838840
g_pCvarSaveStats = CreateConVar("lv_save_stats", "0", "保存奖励计数(进度)", FCVAR_NONE, true, 0.0, true, 1.0);
839841
g_pCvarEquipment = CreateConVar("lv_enable_eq", "1", "是否开启装备功能", FCVAR_NONE, true, 0.0, true, 1.0);
840842
g_pCvarSurvivorBot = CreateConVar("lv_survivor_bot", "0", "为生还者机器人生存随机属性.0=禁用.1/2/4/8/16=技能.32/64/128/256=装备.262144=怒气技(或许)\n512/1024/2048/4096=满级装备.8192/16384/32768/65536/131702=满级技能.524288=怒气技(必然)", FCVAR_NONE, true, 0.0, true, 2.0);
841-
g_pCvarInfectedBot = CreateConVar("lv_infected_bot", "0", "为感染者机器人生存随机属性.0=禁用.1=启用.2=启用+满级", FCVAR_NONE, true, 0.0, true, 2.0);
843+
g_pCvarInfectedBot = CreateConVar("lv_infected_bot", "0", "为感染者机器人生存随机属性.0=禁用.1/2/4/8/16=技能.32/64/128/256=装备.262144=怒气技(或许)\n512/1024/2048/4096=满级装备.8192/16384/32768/65536/131702=满级技能.524288=怒气技(必然)", FCVAR_NONE, true, 0.0, true, 2.0);
842844
g_CvarSoundLevel = CreateConVar("lv_sound_level", "items/suitchargeok1.wav", "天赋技能选单声音文件途径");
843845
cv_particle = CreateConVar("lv_portals_particle", "electrical_arc_01_system", "存读点特效", FCVAR_NONE);
844846
cv_sndPortalERROR = CreateConVar("lv_portals_sounderror","buttons/blip2.wav", "存点声音文件途径", FCVAR_NONE);
@@ -1517,7 +1519,7 @@ public OnMapStart()
15171519

15181520
GetConVarString(g_CvarSoundLevel, g_soundLevel, sizeof(g_soundLevel));
15191521
PrecacheSound(g_soundLevel, true);
1520-
PrecacheSound("ui/gift_drop.wav", true);
1522+
PrecacheSound(SOUND_GIFT, true);
15211523

15221524
for(int i = 0; i < sizeof(g_sndShoveInfected); ++i)
15231525
PrecacheSound(g_sndShoveInfected[i], true);
@@ -1560,6 +1562,8 @@ public OnMapStart()
15601562
PrecacheSound(SOUND_LEVELUP);
15611563
PrecacheSound(SOUND_AMMO);
15621564
PrecacheSound(SOUND_CROW);
1565+
PrecacheSound(SOUND_EXPLOSIVE);
1566+
PrecacheSound(SOUND_GIFT);
15631567

15641568
PrecacheModel( STAR_1_MDL );
15651569
PrecacheModel( STAR_2_MDL );
@@ -1585,7 +1589,7 @@ public OnMapStart()
15851589
{
15861590
// Initialization(i);
15871591
ClientSaveToFileLoad(i, g_pCvarSaveStats.BoolValue);
1588-
g_bFirstLoaded[i] = true;
1592+
// g_bFirstLoaded[i] = true;
15891593

15901594
if(IsValidAliveClient(i))
15911595
RegPlayerHook(i, false);
@@ -8219,7 +8223,7 @@ void DropItem( int client, const char[] Model )
82198223
AcceptEntityInput(entity, "AddOutput", client, entity);
82208224
AcceptEntityInput(entity, "FireUser1", client, entity);
82218225

8222-
EmitAmbientSound("ui/gift_drop.wav", vecPos, entity, SNDLEVEL_CAR);
8226+
EmitAmbientSound(SOUND_GIFT, vecPos, entity, SNDLEVEL_CAR);
82238227
}
82248228
}
82258229

@@ -9676,6 +9680,7 @@ public void Event_PlayerSpawn(Event event, const char[] eventName, bool dontBroa
96769680
bool sur = (StrEqual(eventName, "player_first_spawn", false) && IsPlayerHaveEffect(client, 35));
96779681
bool full = (si || sur || (g_Cvarhppack.BoolValue && !g_bIsGamePlaying));
96789682
RegPlayerHook(client, full);
9683+
g_bFirstLoaded[client] = false;
96799684

96809685
if(g_clSkill_1[client] & SKL_1_Armor)
96819686
{
@@ -11287,7 +11292,7 @@ void RegPlayerHook(int client, bool fullHealth = false)
1128711292
}
1128811293
else if(g_bFirstLoaded[client])
1128911294
{
11290-
g_bFirstLoaded[client] = false;
11295+
// g_bFirstLoaded[client] = false;
1129111296
int hl = GetEntProp(client, Prop_Data, "m_iHealth");
1129211297
if(hl > maxHealth)
1129311298
SetEntProp(client, Prop_Data, "m_iHealth", maxHealth);
@@ -12204,7 +12209,7 @@ public void PlayerHook_OnReloadStopped(int client, int weapon)
1220412209
g_iReloadWeaponEntity[client] = INVALID_ENT_REFERENCE;
1220512210
g_iReloadWeaponClip[client] = 0;
1220612211
g_iReloadWeaponOldClip[client] = 0;
12207-
12212+
1220812213
/*
1220912214
if(IsValidClient(client))
1221012215
PrintToChat(client, "停止换子弹");
@@ -12963,7 +12968,8 @@ stock bool IsSurvivorThirdPerson(int iClient)
1296312968
return true;
1296412969
if(GetEntPropEnt(iClient, Prop_Send, "m_hScriptUseTarget") > 0)
1296512970
return true;
12966-
if(GetEntPropFloat(iClient, Prop_Send, "m_staggerTimer", 1) > -1.0)
12971+
// if(GetEntPropFloat(iClient, Prop_Send, "m_staggerTimer", 1) > -1.0)
12972+
if(IsStaggering(iClient) || IsGettingUp(iClient))
1296712973
return true;
1296812974
switch(GetEntProp(iClient, Prop_Send, "m_iCurrentUseAction"))
1296912975
{
@@ -13067,9 +13073,10 @@ stock bool IsInfectedThirdPerson(int iClient)
1306713073
{
1306813074
if(GetEntPropFloat(iClient, Prop_Send, "m_TimeForceExternalView") > GetGameTime())
1306913075
return true;
13070-
if(GetEntPropFloat(iClient, Prop_Send, "m_staggerTimer", 1) > -1.0)
13076+
// if(GetEntPropFloat(iClient, Prop_Send, "m_staggerTimer", 1) > -1.0)
13077+
if(IsStaggering(iClient) || IsGettingUp(iClient))
1307113078
return true;
13072-
13079+
1307313080
switch(GetEntProp(iClient, Prop_Send, "m_zombieClass"))
1307413081
{
1307513082
case 1://smoker
@@ -16259,7 +16266,7 @@ stock void CreateExplosion(int attacker = -1, float damage, float origin[3], flo
1625916266

1626016267
AcceptEntityInput(entity, "Explode", -1, entity);
1626116268
// EmitSoundToAll("weapons/hegrenade/explode5.wav", entity, SNDCHAN_WEAPON, SNDLEVEL_SCREAMING, SND_NOFLAGS, SNDVOL_NORMAL, 100, _, origin, NULL_VECTOR, false, 0.0);
16262-
EmitAmbientSound("weapons/hegrenade/explode5.wav", origin, entity, SNDLEVEL_SCREAMING);
16269+
EmitAmbientSound(SOUND_EXPLOSIVE, origin, entity, SNDLEVEL_SCREAMING);
1626316270

1626416271
SetVariantString("OnUser1 !self:Kill::1:1");
1626516272
AcceptEntityInput(entity, "AddOutput", attacker, entity);

l4d2_fake_server.sp

+3-1
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,10 @@ public void OnEntityDestroyed(int entity)
279279

280280
public void EntityHook_ThinkPost(int entity)
281281
{
282+
int maxClients = MaxClients > 32 ? 32 : MaxClients;
283+
282284
// 数组上限就是这么大
283-
for(int i = 1; i <= 32; ++i)
285+
for(int i = 1; i <= maxClients; ++i)
284286
{
285287
if(!IsClientInGame(i))
286288
continue;

l4d2_stats.sp

+45-4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ new g_iShotsDealt[MAXPLAYERS + 1][MAXPLAYERS + 1]; // Victim - Attacker, co
5353

5454
new bool: g_bShotCounted[MAXPLAYERS + 1][MAXPLAYERS +1]; // Victim - Attacker, used by playerhurt and weaponfired
5555

56+
new Handle:g_hPounceTimer[MAXPLAYERS + 1];
57+
5658
public OnPluginStart()
5759
{
5860
HookEvent("round_start", Event_RoundStart);
@@ -140,6 +142,10 @@ public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
140142
BoomerKillTime = 0.0;
141143
}
142144
g_iAlarmCarClient = 0;
145+
146+
for(int i = 1; i <= MaxClients; ++i)
147+
if(g_hPounceTimer[i])
148+
delete g_hPounceTimer[i];
143149
}
144150

145151
public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
@@ -159,12 +165,16 @@ public Event_AbilityUse(Handle:event, const String:name[], bool:dontBroadcast)
159165
new client = GetClientOfUserId(GetEventInt(event, "userid"));
160166

161167
if(!IsClientInGame(client) || !IsInfected(client)) return;
168+
169+
if(g_hPounceTimer[client])
170+
delete g_hPounceTimer[client];
171+
162172
new zombieclass = GetEntProp(client, Prop_Send, "m_zombieClass");
163173

164174
if (zombieclass == ZC_HUNTER || zombieclass == ZC_JOCKEY)
165175
{
166176
g_bIsPouncing[client] = true;
167-
CreateTimer(0.5, Timer_GroundedCheck, GetClientUserId(client), TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
177+
g_hPounceTimer[client] = CreateTimer(0.5, Timer_GroundedCheck, GetClientUserId(client), TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
168178
}
169179
}
170180

@@ -175,28 +185,37 @@ public Event_LungePounce(Handle:event, const String:name[], bool:dontBroadcast)
175185

176186
new zombieclass = GetEntProp(attacker, Prop_Send, "m_zombieClass");
177187

178-
if (zombieclass == ZC_HUNTER || zombieclass == ZC_JOCKEY) g_bIsPouncing[attacker] = false;
188+
if (zombieclass == ZC_HUNTER || zombieclass == ZC_JOCKEY)
189+
{
190+
g_bIsPouncing[attacker] = false;
191+
if(g_hPounceTimer[attacker])
192+
delete g_hPounceTimer[attacker];
193+
}
179194
}
180195

181196
public Event_PlayerJump(Handle:event, const String:name[], bool:dontBroadcast)
182197
{
183198
new client = GetClientOfUserId(GetEventInt(event, "userid"));
184199
if(!IsClientInGame(client) || !IsInfected(client)) return;
185200

201+
if(g_hPounceTimer[client])
202+
delete g_hPounceTimer[client];
203+
186204
new zombieclass = GetEntProp(client, Prop_Send, "m_zombieClass");
187205
if(zombieclass == ZC_JOCKEY && !g_bIsPouncing[client])
188206
{
189207
g_bIsPouncing[client] = true;
190-
CreateTimer(0.5, Timer_GroundedCheck, GetClientUserId(client), TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
208+
g_hPounceTimer[client] = CreateTimer(0.5, Timer_GroundedCheck, GetClientUserId(client), TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
191209
}
192210
}
193211

194212
public Action:Timer_GroundedCheck(Handle:timer, any:userid)
195213
{
196214
new client = GetClientOfUserId(userid);
197-
if (!IsClientInGame(client) || !IsPlayerAlive(client) || IsGrounded(client))
215+
if (client <= 0 || !IsClientInGame(client) || !IsPlayerAlive(client) || IsGrounded(client))
198216
{
199217
g_bIsPouncing[client] = false;
218+
g_hPounceTimer[client] = null;
200219
KillTimer(timer);
201220
}
202221
}
@@ -450,10 +469,26 @@ public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
450469
}
451470
}
452471
}
472+
if(zombieclass == ZC_HUNTER || zombieclass == ZC_JOCKEY)
473+
{
474+
g_bIsPouncing[victim] = false;
475+
if(g_hPounceTimer[victim])
476+
delete g_hPounceTimer[victim];
477+
}
453478
}
454479
if (IsInfected(victim)) ClearDamage(victim);
455480
}
456481

482+
public OnClientDisconnect_Post(int client)
483+
{
484+
if(client <= 0 || client > MaxClients)
485+
return;
486+
487+
g_bIsPouncing[client] = false;
488+
if(g_hPounceTimer[client])
489+
delete g_hPounceTimer[client];
490+
}
491+
457492
public Action:Timer_BoomerKilledCheck(Handle:timer)
458493
{
459494
BoomerKillTime = BoomerKillTime - 0.2;
@@ -527,6 +562,8 @@ public Event_PlayerShoved(Handle:event, const String:name[], bool:dontBroadcast)
527562
else if(zombieclass == ZC_HUNTER || zombieclass == ZC_JOCKEY)
528563
{
529564
g_bIsPouncing[victim] = false;
565+
if(g_hPounceTimer[victim])
566+
delete g_hPounceTimer[victim];
530567
}
531568
}
532569

@@ -617,6 +654,10 @@ ClearMapStats()
617654
ClearDamage(i);
618655
}
619656
g_iAlarmCarClient = 0;
657+
658+
for(int i = 1; i <= MaxClients; ++i)
659+
if(g_hPounceTimer[i])
660+
delete g_hPounceTimer[i];
620661
}
621662

622663
ClearDamage(client)

0 commit comments

Comments
 (0)