Moved napalm into its own module, added cvar to enable the thrown grenade to be lit on fire.

This commit is contained in:
Greyscale 2009-04-17 10:20:04 +02:00
parent 23242cdc9d
commit 4d35037e41
4 changed files with 68 additions and 62 deletions

View File

@ -55,6 +55,9 @@
// Respawn // Respawn
#include "zr/respawn" #include "zr/respawn"
// Napalm
#include "zr/napalm"
// ZHP // ZHP
#include "zr/zhp" #include "zr/zhp"

View File

@ -18,6 +18,7 @@ enum ZRSettings
Handle:CVAR_SOUNDEFFECTS_MOAN, Handle:CVAR_SOUNDEFFECTS_MOAN,
Handle:CVAR_SOUNDEFFECTS_GROAN, Handle:CVAR_SOUNDEFFECTS_GROAN,
Handle:CVAR_SOUNDEFFECTS_DEATH, Handle:CVAR_SOUNDEFFECTS_DEATH,
Handle:CVAR_NAPALM_IGNITEGRENADE,
Handle:CVAR_CLASSES, Handle:CVAR_CLASSES,
Handle:CVAR_CLASSES_SPAWN, Handle:CVAR_CLASSES_SPAWN,
Handle:CVAR_CLASSES_RANDOM, Handle:CVAR_CLASSES_RANDOM,
@ -107,7 +108,8 @@ CreateCvars()
gCvars[CVAR_AMBIENTSOUNDS_VOLUME] = CreateConVar("zr_ambientsounds_volume", "1.0", "Volume of ambient sounds when zr_ambience is 1 (0.0: Unhearable, 1.0: Max volume)"); gCvars[CVAR_AMBIENTSOUNDS_VOLUME] = CreateConVar("zr_ambientsounds_volume", "1.0", "Volume of ambient sounds when zr_ambience is 1 (0.0: Unhearable, 1.0: Max volume)");
gCvars[CVAR_SOUNDEFFECTS_MOAN] = CreateConVar("zr_soundeffects_moan", "50", "How often, in seconds, a zombie moans (0: Disable)"); gCvars[CVAR_SOUNDEFFECTS_MOAN] = CreateConVar("zr_soundeffects_moan", "50", "How often, in seconds, a zombie moans (0: Disable)");
gCvars[CVAR_SOUNDEFFECTS_GROAN] = CreateConVar("zr_soundeffects_groan", "5", "Chance factor a zombie will groan when shot (Lower: More often, 0: Disable)"); gCvars[CVAR_SOUNDEFFECTS_GROAN] = CreateConVar("zr_soundeffects_groan", "5", "Chance factor a zombie will groan when shot (Lower: More often, 0: Disable)");
gCvars[CVAR_SOUNDEFFECTS_DEATH] = CreateConVar("zr_soundeffects_death", "1", "Zombie will emit a death sound when killed 0: Disable)"); gCvars[CVAR_SOUNDEFFECTS_DEATH] = CreateConVar("zr_soundeffects_death", "1", "Zombie will emit a death sound when killed (0: Disable)");
gCvars[CVAR_NAPALM_IGNITEGRENADE] = CreateConVar("zr_napalm_ignitegrenade", "1", "Ignites all thrown grenades. (0: Disable)");
gCvars[CVAR_CLASSES] = CreateConVar("zr_classes", "1", "Enable zombie classes"); gCvars[CVAR_CLASSES] = CreateConVar("zr_classes", "1", "Enable zombie classes");
gCvars[CVAR_CLASSES_SPAWN] = CreateConVar("zr_classes_spawn", "0", "Classmenu is re-displayed every spawn (0: Disable)"); gCvars[CVAR_CLASSES_SPAWN] = CreateConVar("zr_classes_spawn", "0", "Classmenu is re-displayed every spawn (0: Disable)");
gCvars[CVAR_CLASSES_RANDOM] = CreateConVar("zr_classes_random", "0", "A random class is assigned to each player every round. Overrides zr_classes_spawn and default classes. (0: Disable)"); gCvars[CVAR_CLASSES_RANDOM] = CreateConVar("zr_classes_random", "0", "A random class is assigned to each player every round. Overrides zr_classes_spawn and default classes. (0: Disable)");

View File

@ -16,6 +16,7 @@ HookEvents()
HookEvent("player_hurt", PlayerHurt); HookEvent("player_hurt", PlayerHurt);
HookEvent("player_death", PlayerDeath); HookEvent("player_death", PlayerDeath);
HookEvent("player_jump", PlayerJump); HookEvent("player_jump", PlayerJump);
HookEvent("weapon_fire", WeaponFire);
} }
UnhookEvents() UnhookEvents()
@ -28,6 +29,7 @@ UnhookEvents()
UnhookEvent("player_hurt", PlayerHurt); UnhookEvent("player_hurt", PlayerHurt);
UnhookEvent("player_death", PlayerDeath); UnhookEvent("player_death", PlayerDeath);
UnhookEvent("player_jump", PlayerJump); UnhookEvent("player_jump", PlayerJump);
UnhookEvent("weapon_fire", WeaponFire);
} }
public Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast) public Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
@ -231,22 +233,12 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
} }
} }
// Check if the player is a zombie.
if (IsPlayerZombie(index))
{
// Napalm effect.
new Float:napalm_time = ClassGetNapalmTime(index);
if (StrEqual(weapon, "hegrenade", false) && napalm_time > 0.0)
{
IgniteEntity(index, napalm_time);
}
}
// Forward event to modules. // Forward event to modules.
ClassAlphaUpdate(index); ClassAlphaUpdate(index);
SEffectsOnClientHurt(index); SEffectsOnClientHurt(index);
KnockbackOnClientHurt(index, attacker, weapon, hitgroup, dmg_health); KnockbackOnClientHurt(index, attacker, weapon, hitgroup, dmg_health);
ZHPOnPlayerHurt(index); NapalmOnClientHurt(index, weapon);
ZHPOnClientHurt(index);
} }
public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
@ -328,3 +320,12 @@ public Action:PlayerJump(Handle:event, const String:name[], bool:dontBroadcast)
JumpBoost(client, distance, height); JumpBoost(client, distance, height);
} }
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);
}

View File

@ -71,6 +71,55 @@ ZHPOnClientDeath(client)
tZHP[client] = INVALID_HANDLE; tZHP[client] = INVALID_HANDLE;
} }
/**
* Player has been infected.
*
* @param client The client index.
*/
ZHPOnClientInfected(client)
{
// If ZHP is disabled, then stop.
new bool:zhp = GetConVarBool(gCvars[CVAR_ZHP]);
if (!zhp)
{
return;
}
// Update HP display.
ZHPUpdateHUD(client);
// If timer is currently running, kill it.
if (tZHP[client] != INVALID_HANDLE)
{
KillTimer(tZHP[client]);
}
// Start repeating timer to update display.
tZHP[client] = CreateTimer(5.0, ZHPTimer, client, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
}
/**
* Client has been hurt.
*
* @param client The client index.
*/
ZHPOnClientHurt(client)
{
// Update HP display.
ZHPUpdateHUD(client);
}
/**
* Zombie has gained health for infecting a player.
*
* @param client The client index.
*/
ZHPOnHealthInfectGain(client)
{
// Update HP display.
ZHPUpdateHUD(client);
}
/** /**
* Toggle ZHP on a client. * Toggle ZHP on a client.
* *
@ -107,55 +156,6 @@ ZHPToggle(client)
pZHP[client] = !pZHP[client]; pZHP[client] = !pZHP[client];
} }
/**
* Player has been infected.
*
* @param client The client index.
*/
ZHPOnClientInfected(client)
{
// If ZHP is disabled, then stop.
new bool:zhp = GetConVarBool(gCvars[CVAR_ZHP]);
if (!zhp)
{
return;
}
// Update HP display.
ZHPUpdateHUD(client);
// If timer is currently running, kill it.
if (tZHP[client] != INVALID_HANDLE)
{
KillTimer(tZHP[client]);
}
// Start repeating timer to update display.
tZHP[client] = CreateTimer(5.0, ZHPTimer, client, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
}
/**
* Player has been hurt.
*
* @param client The client index.
*/
ZHPOnPlayerHurt(client)
{
// Update HP display.
ZHPUpdateHUD(client);
}
/**
* Zombie has gained health for infecting a player.
*
* @param client The client index.
*/
ZHPOnHealthInfectGain(client)
{
// Update HP display.
ZHPUpdateHUD(client);
}
/** /**
* Update HP display for a player. * Update HP display for a player.
* *