2008-10-04 22:59:11 +02:00
|
|
|
/**
|
|
|
|
* ====================
|
|
|
|
* Zombie:Reloaded
|
|
|
|
* File: events.inc
|
|
|
|
* Author: Greyscale
|
|
|
|
* ====================
|
|
|
|
*/
|
|
|
|
|
|
|
|
HookEvents()
|
|
|
|
{
|
|
|
|
HookEvent("round_start", RoundStart);
|
|
|
|
HookEvent("round_freeze_end", RoundFreezeEnd);
|
|
|
|
HookEvent("round_end", RoundEnd);
|
|
|
|
HookEvent("player_team", PlayerTeam, EventHookMode_Pre);
|
|
|
|
HookEvent("player_spawn", PlayerSpawn);
|
|
|
|
HookEvent("player_hurt", PlayerHurt);
|
|
|
|
HookEvent("player_death", PlayerDeath);
|
|
|
|
HookEvent("player_jump", PlayerJump);
|
2009-04-17 10:20:04 +02:00
|
|
|
HookEvent("weapon_fire", WeaponFire);
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UnhookEvents()
|
|
|
|
{
|
|
|
|
UnhookEvent("round_start", RoundStart);
|
|
|
|
UnhookEvent("round_freeze_end", RoundFreezeEnd);
|
|
|
|
UnhookEvent("round_end", RoundEnd);
|
|
|
|
UnhookEvent("player_team", PlayerTeam, EventHookMode_Pre);
|
|
|
|
UnhookEvent("player_spawn", PlayerSpawn);
|
|
|
|
UnhookEvent("player_hurt", PlayerHurt);
|
|
|
|
UnhookEvent("player_death", PlayerDeath);
|
|
|
|
UnhookEvent("player_jump", PlayerJump);
|
2009-04-17 10:20:04 +02:00
|
|
|
UnhookEvent("weapon_fire", WeaponFire);
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
|
|
|
|
{
|
|
|
|
ChangeLightStyle();
|
|
|
|
|
|
|
|
if (tInfect != INVALID_HANDLE)
|
|
|
|
{
|
2009-03-30 00:35:51 +02:00
|
|
|
KillTimer(tInfect);
|
2008-10-04 22:59:11 +02:00
|
|
|
tInfect = INVALID_HANDLE;
|
|
|
|
}
|
2009-04-18 01:44:41 +02:00
|
|
|
|
|
|
|
g_bZombieSpawned = false;
|
|
|
|
|
|
|
|
for (new x = 1; x<= MaxClients; x++)
|
|
|
|
{
|
|
|
|
if (!IsClientInGame(x))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bZombie[x] = false;
|
|
|
|
}
|
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
ZR_PrintToChat(0, "Round objective");
|
2009-04-18 01:44:41 +02:00
|
|
|
|
|
|
|
// Forward event to sub-modules.
|
|
|
|
RoundEndOnRoundStart();
|
|
|
|
SEffectsOnRoundStart();
|
|
|
|
AntiStickOnRoundStart();
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Action:RoundFreezeEnd(Handle:event, const String:name[], bool:dontBroadcast)
|
|
|
|
{
|
|
|
|
RemoveObjectives();
|
|
|
|
|
|
|
|
if (tInfect != INVALID_HANDLE)
|
|
|
|
{
|
2009-03-30 00:35:51 +02:00
|
|
|
KillTimer(tInfect);
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
|
|
|
|
2009-04-20 02:56:26 +02:00
|
|
|
new Float:min = GetConVarFloat(g_hCvarsList[CVAR_SPAWN_MIN]);
|
|
|
|
new Float:max = GetConVarFloat(g_hCvarsList[CVAR_SPAWN_MAX]);
|
2008-10-04 22:59:11 +02:00
|
|
|
new Float:randlen = GetRandomFloat(min, max);
|
|
|
|
tInfect = CreateTimer(randlen, MotherZombie, _, TIMER_FLAG_NO_MAPCHANGE);
|
2008-12-20 20:46:05 +01:00
|
|
|
|
2009-04-17 01:09:52 +02:00
|
|
|
// Forward events to modules.
|
2009-04-18 01:44:41 +02:00
|
|
|
RoundEndOnRoundFreezeEnd();
|
2008-12-20 20:46:05 +01:00
|
|
|
ZTeleEnable();
|
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Action:RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
|
|
|
|
{
|
2009-04-18 01:44:41 +02:00
|
|
|
new reason = GetEventInt(event, "reason");
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
if (tInfect != INVALID_HANDLE)
|
|
|
|
{
|
2009-03-30 00:35:51 +02:00
|
|
|
KillTimer(tInfect);
|
2008-10-04 22:59:11 +02:00
|
|
|
tInfect = INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
|
2009-04-17 12:16:44 +02:00
|
|
|
g_bZombieSpawned = false;
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2009-04-16 05:30:26 +02:00
|
|
|
for (new x = 1; x<= MaxClients; x++)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
|
|
|
if (!IsClientInGame(x))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-04-17 12:16:44 +02:00
|
|
|
bZombie[x] = false;
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// Forward event to modules.
|
|
|
|
RoundEndOnRoundEnd(reason);
|
2008-12-20 20:46:05 +01:00
|
|
|
ZTeleReset();
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Action:PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
|
|
|
|
{
|
|
|
|
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
|
|
|
new team = GetEventInt(event, "team");
|
|
|
|
|
2009-04-11 01:56:22 +02:00
|
|
|
if (team == CS_TEAM_SPECTATOR)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2009-04-17 12:16:44 +02:00
|
|
|
bZombie[index] = false;
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
|
|
|
|
{
|
|
|
|
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
|
|
|
|
2009-04-17 12:16:44 +02:00
|
|
|
bZombie[index] = false;
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2009-04-11 01:56:22 +02:00
|
|
|
// Reset FOV and overlay.
|
2008-10-04 22:59:11 +02:00
|
|
|
SetPlayerFOV(index, 90);
|
|
|
|
ClientCommand(index, "r_screenoverlay \"\"");
|
|
|
|
|
2009-04-16 22:21:32 +02:00
|
|
|
// Check if client is on a team.
|
|
|
|
if (ZRIsClientOnTeam(index))
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2009-04-20 02:56:26 +02:00
|
|
|
new bool:cashfill = GetConVarBool(g_hCvarsList[CVAR_CASHFILL]);
|
2009-04-16 22:21:32 +02:00
|
|
|
if (cashfill)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2009-04-20 02:56:26 +02:00
|
|
|
new cash = GetConVarInt(g_hCvarsList[CVAR_CASHAMOUNT]);
|
2009-04-16 22:21:32 +02:00
|
|
|
SetPlayerMoney(index, cash);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove night vision.
|
|
|
|
NightVisionOn(index, false);
|
|
|
|
NightVision(index, false);
|
|
|
|
|
2009-04-17 12:16:44 +02:00
|
|
|
if (g_bZombieSpawned)
|
2009-04-16 22:21:32 +02:00
|
|
|
{
|
|
|
|
if (ZRIsClientOnTeam(index, CS_TEAM_T))
|
|
|
|
{
|
|
|
|
CS_SwitchTeam(index, CS_TEAM_CT);
|
|
|
|
CS_RespawnPlayer(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetPlayerAlpha(index, 255);
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
2008-11-13 17:03:28 +01:00
|
|
|
}
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2009-04-11 01:56:22 +02:00
|
|
|
// Forward event to modules.
|
|
|
|
ClassOnClientSpawn(index);
|
2009-04-17 01:09:52 +02:00
|
|
|
SEffectsOnClientSpawn(index);
|
2009-04-16 22:21:32 +02:00
|
|
|
SpawnProtectOnClientSpawn(index);
|
|
|
|
RespawnOnClientSpawn(index);
|
|
|
|
ZHPOnClientSpawn(index);
|
2009-04-11 01:56:22 +02:00
|
|
|
ZTeleClientSpawned(index);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
ZR_PrintToChat(index, "!zmenu reminder");
|
|
|
|
}
|
|
|
|
|
|
|
|
public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
|
|
|
|
{
|
|
|
|
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
|
|
|
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
|
|
|
|
|
2009-04-15 03:24:02 +02:00
|
|
|
new hitgroup = GetEventInt(event, "hitgroup");
|
|
|
|
|
2009-04-14 22:05:20 +02:00
|
|
|
new dmg_health = GetEventInt(event, "dmg_health");
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
decl String:weapon[32];
|
|
|
|
GetEventString(event, "weapon", weapon, sizeof(weapon));
|
|
|
|
|
2009-04-11 01:56:22 +02:00
|
|
|
// Check if the attacker is a player.
|
2009-04-16 03:57:46 +02:00
|
|
|
if (ZRIsValidClient(attacker))
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2009-04-11 01:56:22 +02:00
|
|
|
// Check if a zombie attacks a human.
|
2008-10-04 22:59:11 +02:00
|
|
|
if (IsPlayerHuman(index) && IsPlayerZombie(attacker))
|
|
|
|
{
|
2009-04-11 01:56:22 +02:00
|
|
|
// Check if spawn protection is disabled and the weapon is a knife.
|
2009-04-16 05:30:26 +02:00
|
|
|
if (!pSpawnProtect[index] && StrEqual(weapon, "knife"))
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2009-04-16 01:18:08 +02:00
|
|
|
InfectPlayer(index, attacker);
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-04-11 01:56:22 +02:00
|
|
|
|
|
|
|
// Forward event to modules.
|
|
|
|
ClassAlphaUpdate(index);
|
2009-04-17 01:09:52 +02:00
|
|
|
SEffectsOnClientHurt(index);
|
2009-04-16 22:21:32 +02:00
|
|
|
KnockbackOnClientHurt(index, attacker, weapon, hitgroup, dmg_health);
|
2009-04-17 10:20:04 +02:00
|
|
|
NapalmOnClientHurt(index, weapon);
|
|
|
|
ZHPOnClientHurt(index);
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
|
|
|
|
{
|
|
|
|
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
|
|
|
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
|
2008-12-28 00:50:39 +01:00
|
|
|
|
2009-04-21 03:27:12 +02:00
|
|
|
// Extinguish fire.
|
2008-10-04 22:59:11 +02:00
|
|
|
ExtinguishEntity(index);
|
|
|
|
|
2009-04-11 01:56:22 +02:00
|
|
|
// Get the weapon name.
|
2009-04-16 06:06:44 +02:00
|
|
|
decl String:weapon[32];
|
2008-10-04 22:59:11 +02:00
|
|
|
GetEventString(event, "weapon", weapon, sizeof(weapon));
|
2009-04-11 01:56:22 +02:00
|
|
|
|
|
|
|
// Check if the player was infected.
|
2008-10-04 22:59:11 +02:00
|
|
|
if (StrEqual(weapon, "zombie_claws_of_death", false))
|
|
|
|
{
|
2009-04-11 01:56:22 +02:00
|
|
|
// Add a death count to the players score.
|
2009-04-16 03:57:46 +02:00
|
|
|
if (ZRIsValidClient(index))
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
|
|
|
AddPlayerDeath(index, 1);
|
|
|
|
}
|
|
|
|
|
2009-04-11 01:56:22 +02:00
|
|
|
// Give a point to the attacker.
|
2009-04-16 03:57:46 +02:00
|
|
|
if (ZRIsValidClient(attacker))
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
|
|
|
AddPlayerScore(attacker, 1);
|
|
|
|
|
2009-04-11 01:56:22 +02:00
|
|
|
new healthgain = ClassGetHealthInfectGain(attacker);
|
2008-10-04 22:59:11 +02:00
|
|
|
new health = GetClientHealth(attacker);
|
|
|
|
|
|
|
|
SetEntityHealth(attacker, health + healthgain);
|
|
|
|
|
2009-04-16 01:18:08 +02:00
|
|
|
// Forward event to modules.
|
|
|
|
ZHPOnHealthInfectGain(attacker);
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-04-21 03:27:12 +02:00
|
|
|
// Reset field of view.
|
|
|
|
SetPlayerFOV(index, DEFAULT_FOV);
|
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
if (IsPlayerZombie(index))
|
|
|
|
{
|
2009-04-11 01:56:22 +02:00
|
|
|
// Give kill bonus.
|
2009-04-16 03:57:46 +02:00
|
|
|
if (ZRIsValidClient(attacker))
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2009-04-11 01:56:22 +02:00
|
|
|
new bonus = ClassGetKillBonus(attacker);
|
2008-10-04 22:59:11 +02:00
|
|
|
AddPlayerScore(attacker, bonus);
|
|
|
|
}
|
|
|
|
}
|
2009-04-21 03:27:12 +02:00
|
|
|
|
|
|
|
// Forward event to modules.
|
|
|
|
ClassOnClientDeath(index);
|
|
|
|
SEffectsOnClientDeath(index);
|
|
|
|
SpawnProtectOnClientDeath(index);
|
|
|
|
RespawnOnClientDeath(index, attacker, weapon);
|
|
|
|
ZHPOnClientDeath(index);
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
new RoundEndOutcome:outcome;
|
|
|
|
if (RoundEndGetRoundStatus(outcome))
|
|
|
|
{
|
|
|
|
RoundEndTerminateRound(outcome);
|
|
|
|
}
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Action:PlayerJump(Handle:event, const String:name[], bool:dontBroadcast)
|
|
|
|
{
|
2009-04-11 01:56:22 +02:00
|
|
|
new client = GetClientOfUserId(GetEventInt(event, "userid"));
|
|
|
|
new Float:distance = ClassGetJumpDistance(client);
|
|
|
|
new Float:height = ClassGetJumpHeight(client);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2009-04-11 01:56:22 +02:00
|
|
|
JumpBoost(client, distance, height);
|
|
|
|
}
|
2009-04-17 10:20:04 +02:00
|
|
|
|
|
|
|
public Action:WeaponFire(Handle:event, const String:name[], bool:dontBroadcast)
|
|
|
|
{
|
|
|
|
decl String:weapon[32];
|
|
|
|
GetEventString(event, "weapon", weapon, sizeof(weapon));
|
|
|
|
|
|
|
|
// Forward event to modules.
|
|
|
|
NapalmOnWeaponFire(weapon);
|
|
|
|
}
|