Implemented the new class system. Class menu missing, only default classes working.
This commit is contained in:
parent
1e99bd64f3
commit
a8704cf90c
@ -116,16 +116,8 @@ public OnMapStart()
|
||||
LoadModelData();
|
||||
LoadDownloadData();
|
||||
|
||||
// Weapon restrict
|
||||
// Forward event to modules.
|
||||
WeaponRestrictMapStart();
|
||||
|
||||
new i;
|
||||
new classindex = GetDefaultClassIndex();
|
||||
for (i = 1; i <= MAXPLAYERS; i++)
|
||||
{
|
||||
pClass[i] = classindex;
|
||||
}
|
||||
|
||||
Anticamp_Startup();
|
||||
}
|
||||
|
||||
@ -136,11 +128,6 @@ public OnMapEnd()
|
||||
|
||||
public OnConfigsExecuted()
|
||||
{
|
||||
FindMapSky();
|
||||
|
||||
LoadClassData();
|
||||
LoadAmbienceData();
|
||||
|
||||
decl String:mapconfig[PLATFORM_MAX_PATH];
|
||||
|
||||
GetCurrentMap(mapconfig, sizeof(mapconfig));
|
||||
@ -152,8 +139,17 @@ public OnConfigsExecuted()
|
||||
if (FileExists(path))
|
||||
{
|
||||
ServerCommand("exec %s", mapconfig);
|
||||
if (LogFlagCheck(LOG_CORE_EVENTS))
|
||||
{
|
||||
LogMessage("Executed map config file: %s", mapconfig);
|
||||
}
|
||||
}
|
||||
|
||||
FindMapSky();
|
||||
|
||||
ClassLoad();
|
||||
LoadClassData();
|
||||
LoadAmbienceData();
|
||||
}
|
||||
|
||||
public OnClientPutInServer(client)
|
||||
@ -167,8 +163,9 @@ public OnClientPutInServer(client)
|
||||
new bool:zhp = GetConVarBool(gCvars[CVAR_ZHP_DEFAULT]);
|
||||
dispHP[client] = zhp;
|
||||
|
||||
// Weapon restrict
|
||||
// Forward event to modules.
|
||||
WeaponRestrictClientInit(client);
|
||||
ClassClientInit(client);
|
||||
|
||||
ClientHookAttack(client);
|
||||
|
||||
@ -185,12 +182,12 @@ public OnClientPutInServer(client)
|
||||
|
||||
public OnClientDisconnect(client)
|
||||
{
|
||||
// Weapon restrict
|
||||
WeaponRestrictClientDisconnect(client);
|
||||
|
||||
ClientUnHookAttack(client);
|
||||
|
||||
PlayerLeft(client);
|
||||
|
||||
// Forward event to modules.
|
||||
WeaponRestrictClientDisconnect(client);
|
||||
ClassOnClientDisconnect(client);
|
||||
ZTeleResetClient(client);
|
||||
AmbienceStop(client);
|
||||
|
||||
@ -232,6 +229,8 @@ ZREnd()
|
||||
UnhookCvars();
|
||||
UnhookEvents();
|
||||
|
||||
// TODO: Disable all modules! Teleport, ambience, overlays, antistick, etc.
|
||||
|
||||
new maxplayers = GetMaxClients();
|
||||
for (new x = 1; x <= maxplayers; x++)
|
||||
{
|
||||
|
@ -169,22 +169,22 @@ GetDefaultClassIndex()
|
||||
}
|
||||
}
|
||||
|
||||
GetClassModel(classindex, String:model[], maxlen)
|
||||
/*GetClassModel(classindex, String:model[], maxlen)
|
||||
{
|
||||
strcopy(model, maxlen, arrayClasses[classindex][data_model]);
|
||||
}
|
||||
}*/
|
||||
|
||||
GetClassMenuDescription(classindex, String:menudescription[], maxlen)
|
||||
{
|
||||
strcopy(menudescription, maxlen, arrayClasses[classindex][data_menu_description]);
|
||||
}
|
||||
|
||||
GetClassZVision(classindex, String:zvision[], maxlen)
|
||||
/*GetClassZVision(classindex, String:zvision[], maxlen)
|
||||
{
|
||||
strcopy(zvision, maxlen, arrayClasses[classindex][data_zvision]);
|
||||
}
|
||||
}*/
|
||||
|
||||
GetClassHealth(classindex)
|
||||
/*GetClassHealth(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -193,9 +193,9 @@ GetClassHealth(classindex)
|
||||
}
|
||||
|
||||
return GetConVarInt(gCvars[CVAR_ZOMBIE_HEALTH]);
|
||||
}
|
||||
}*/
|
||||
|
||||
Float:GetClassSpeed(classindex)
|
||||
/*Float:GetClassSpeed(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -204,9 +204,9 @@ Float:GetClassSpeed(classindex)
|
||||
}
|
||||
|
||||
return GetConVarFloat(gCvars[CVAR_ZOMBIE_SPEED]);
|
||||
}
|
||||
}*/
|
||||
|
||||
Float:GetClassJumpDistance(classindex)
|
||||
/*Float:GetClassJumpDistance(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -215,9 +215,9 @@ Float:GetClassJumpDistance(classindex)
|
||||
}
|
||||
|
||||
return GetConVarFloat(gCvars[CVAR_ZOMBIE_JUMP_DISTANCE]);
|
||||
}
|
||||
}*/
|
||||
|
||||
Float:GetClassJumpHeight(classindex)
|
||||
/*Float:GetClassJumpHeight(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -226,9 +226,9 @@ Float:GetClassJumpHeight(classindex)
|
||||
}
|
||||
|
||||
return GetConVarFloat(gCvars[CVAR_ZOMBIE_JUMP_HEIGHT]);
|
||||
}
|
||||
}*/
|
||||
|
||||
Float:GetClassKnockback(classindex)
|
||||
/*Float:GetClassKnockback(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -237,9 +237,9 @@ Float:GetClassKnockback(classindex)
|
||||
}
|
||||
|
||||
return GetConVarFloat(gCvars[CVAR_ZOMBIE_KNOCKBACK]);
|
||||
}
|
||||
}*/
|
||||
|
||||
bool:GetClassNVGs(classindex)
|
||||
/*bool:GetClassNVGs(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
|
||||
@ -257,9 +257,9 @@ bool:GetClassNVGs(classindex)
|
||||
}
|
||||
|
||||
return IntToBool(GetConVarInt(gCvars[CVAR_ZOMBIE_NVGS]));
|
||||
}
|
||||
}*/
|
||||
|
||||
GetClassFOV(classindex)
|
||||
/*GetClassFOV(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -268,9 +268,9 @@ GetClassFOV(classindex)
|
||||
}
|
||||
|
||||
return GetConVarInt(gCvars[CVAR_ZOMBIE_FOV]);
|
||||
}
|
||||
}*/
|
||||
|
||||
bool:GetClassRegen(classindex)
|
||||
/*bool:GetClassRegen(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -279,9 +279,9 @@ bool:GetClassRegen(classindex)
|
||||
}
|
||||
|
||||
return GetConVarBool(gCvars[CVAR_ZOMBIE_REGEN]);
|
||||
}
|
||||
}*/
|
||||
|
||||
GetClassRegenHealth(classindex)
|
||||
/*GetClassRegenHealth(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -290,9 +290,9 @@ GetClassRegenHealth(classindex)
|
||||
}
|
||||
|
||||
return GetConVarInt(gCvars[CVAR_ZOMBIE_REGEN_HEALTH]);
|
||||
}
|
||||
}*/
|
||||
|
||||
Float:GetClassRegenInterval(classindex)
|
||||
/*Float:GetClassRegenInterval(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -301,9 +301,9 @@ Float:GetClassRegenInterval(classindex)
|
||||
}
|
||||
|
||||
return GetConVarFloat(gCvars[CVAR_ZOMBIE_REGEN_INTERVAL]);
|
||||
}
|
||||
}*/
|
||||
|
||||
bool:GetClassNapalm(classindex)
|
||||
/*bool:GetClassNapalm(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -312,9 +312,9 @@ bool:GetClassNapalm(classindex)
|
||||
}
|
||||
|
||||
return GetConVarBool(gCvars[CVAR_ZOMBIE_NAPALM]);
|
||||
}
|
||||
}*/
|
||||
|
||||
Float:GetClassNapalmTime(classindex)
|
||||
/*Float:GetClassNapalmTime(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -323,9 +323,9 @@ Float:GetClassNapalmTime(classindex)
|
||||
}
|
||||
|
||||
return GetConVarFloat(gCvars[CVAR_ZOMBIE_NAPALM_TIME]);
|
||||
}
|
||||
}*/
|
||||
|
||||
bool:GetClassNoFallDamage(classindex)
|
||||
/*bool:GetClassNoFallDamage(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -334,9 +334,9 @@ bool:GetClassNoFallDamage(classindex)
|
||||
}
|
||||
|
||||
return GetConVarBool(gCvars[CVAR_ZOMBIE_NOFALLDAMAGE]);
|
||||
}
|
||||
}*/
|
||||
|
||||
GetClassKillBonus(classindex)
|
||||
/*GetClassKillBonus(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -345,9 +345,9 @@ GetClassKillBonus(classindex)
|
||||
}
|
||||
|
||||
return GetConVarInt(gCvars[CVAR_ZOMBIE_KILL_BONUS]);
|
||||
}
|
||||
}*/
|
||||
|
||||
GetClassInfectHealth(classindex)
|
||||
/*GetClassInfectHealth(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -356,9 +356,9 @@ GetClassInfectHealth(classindex)
|
||||
}
|
||||
|
||||
return GetConVarInt(gCvars[CVAR_ZOMBIE_INFECT_HEALTH]);
|
||||
}
|
||||
}*/
|
||||
|
||||
GetClassAlphaSpawn(classindex)
|
||||
/*GetClassAlphaSpawn(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -367,9 +367,9 @@ GetClassAlphaSpawn(classindex)
|
||||
}
|
||||
|
||||
return GetConVarInt(gCvars[CVAR_ZOMBIE_ALPHA_SPAWN]);
|
||||
}
|
||||
}*/
|
||||
|
||||
GetClassAlphaDamaged(classindex)
|
||||
/*GetClassAlphaDamaged(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -378,9 +378,9 @@ GetClassAlphaDamaged(classindex)
|
||||
}
|
||||
|
||||
return GetConVarInt(gCvars[CVAR_ZOMBIE_ALPHA_DAMAGED]);
|
||||
}
|
||||
}*/
|
||||
|
||||
GetClassAlphaDamage(classindex)
|
||||
/*GetClassAlphaDamage(classindex)
|
||||
{
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
@ -389,5 +389,4 @@ GetClassAlphaDamage(classindex)
|
||||
}
|
||||
|
||||
return GetConVarInt(gCvars[CVAR_ZOMBIE_ALPHA_DAMAGE]);
|
||||
}
|
||||
|
||||
}*/
|
||||
|
@ -20,7 +20,9 @@ enum ZRSettings
|
||||
Handle:CVAR_CLASSES_SPAWN,
|
||||
Handle:CVAR_CLASSES_RANDOM,
|
||||
Handle:CVAR_CLASSES_DEFAULT,
|
||||
Handle:CVAR_CLASSES_SAVE,
|
||||
Handle:CVAR_CLASSES_DEFAULT_ZOMBIE,
|
||||
Handle:CVAR_CLASSES_DEFAULT_HUMAN,
|
||||
Handle:CVAR_CLASSES_DEFAULT_ADMIN,
|
||||
Handle:CVAR_ZOMBIE_HEALTH,
|
||||
Handle:CVAR_ZOMBIE_SPEED,
|
||||
Handle:CVAR_ZOMBIE_JUMP_DISTANCE,
|
||||
@ -98,7 +100,7 @@ new gCvars[ZRSettings];
|
||||
CreateCvars()
|
||||
{
|
||||
gCvars[CVAR_ENABLE] = CreateConVar("zr_enable", "1", "Enable zombie gameplay (0: Disable)");
|
||||
gCvars[CVAR_LOG] = CreateConVar("zr_log", "65", "Logging flags. Log messages to sourcemod logs, server console or client console. Use zr_log_flags to see a list of flags. (0: Disable)");
|
||||
gCvars[CVAR_LOG] = CreateConVar("zr_log", "331", "Logging flags. Log messages to sourcemod logs, server console or client console. Use zr_log_flags to see a list of flags. (0: Disable)");
|
||||
gCvars[CVAR_ALLOW_PLAYER_TEAM] = CreateConVar("zr_allow_player_team", "0", "This will allow the player_team event to be fired on first team join, enable when using mani model menu (0: Disable)");
|
||||
gCvars[CVAR_AMBIENCE] = CreateConVar("zr_ambience", "1", "Enable creepy ambience to be played throughout the game (0: Disable)");
|
||||
gCvars[CVAR_AMBIENCE_FILE] = CreateConVar("zr_ambience_file", "ambient/zr/zr_ambience.mp3", "Path to ambient sound file that will be played throughout the game, when zr_ambience is 1");
|
||||
@ -107,8 +109,11 @@ CreateCvars()
|
||||
gCvars[CVAR_EMITSOUNDS] = CreateConVar("zr_emitsounds", "50", "How often a zombie emits a sound, in seconds (0: Disable)");
|
||||
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_RANDOM] = CreateConVar("zr_classes_random", "0", "A random class is assigned to each player every round. Overrides zr_classes_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_DEFAULT] = CreateConVar("zr_classes_default", "classic", "Default class selected for all players when they connect, or \"random\" to select a random class. Usage zr_classes_default <class name|\"random\">");
|
||||
gCvars[CVAR_CLASSES_DEFAULT_ZOMBIE] = CreateConVar("zr_classes_default_zombie", "", "Default zombie class selected for all players when they connect. Use \"random\" to select a random class, or blank to use class config defaults.");
|
||||
gCvars[CVAR_CLASSES_DEFAULT_HUMAN] = CreateConVar("zr_classes_default_human", "", "Default human class selected for all players when they connect. Use \"random\" to select a random class, or blank to use class config defaults.");
|
||||
gCvars[CVAR_CLASSES_DEFAULT_ADMIN] = CreateConVar("zr_classes_default_admin", "", "Default admin-only class selected for admins when they connect. Use \"random\" to select a random class, or blank to use class config defaults.");
|
||||
gCvars[CVAR_ZOMBIE_HEALTH] = CreateConVar("zr_zombie_health", "5000", "The default health of a zombie");
|
||||
gCvars[CVAR_ZOMBIE_SPEED] = CreateConVar("zr_zombie_speed", "350", "How fast zombies travel (300: Default speed, 600: Double speed)");
|
||||
gCvars[CVAR_ZOMBIE_JUMP_DISTANCE] = CreateConVar("zr_zombie_jump_distance", "0.1", "How far the zombie jumps, (0: Regular jump distance)");
|
||||
|
@ -88,7 +88,7 @@ public OnTakeDamage(client, inflictor, attacker, damage, damagetype, ammotype)
|
||||
return Hacks_Continue;
|
||||
}
|
||||
|
||||
new bool:blockfalldamage = GetClassNoFallDamage(pClass[client]);
|
||||
new bool:blockfalldamage = ClassGetNoFallDamage(client);
|
||||
if (!blockfalldamage)
|
||||
{
|
||||
return Hacks_Continue;
|
||||
|
139
src/zr/event.inc
139
src/zr/event.inc
@ -129,7 +129,7 @@ public Action:PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
new team = GetEventInt(event, "team");
|
||||
|
||||
if (team == 1)
|
||||
if (team == CS_TEAM_SPECTATOR)
|
||||
{
|
||||
gZombie[index] = false;
|
||||
motherZombie[index] = false;
|
||||
@ -165,8 +165,8 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
gZombie[index] = false;
|
||||
motherZombie[index] = false;
|
||||
|
||||
// Reset FOV and overlay.
|
||||
SetPlayerFOV(index, 90);
|
||||
|
||||
ClientCommand(index, "r_screenoverlay \"\"");
|
||||
|
||||
new team = GetClientTeam(index);
|
||||
@ -182,8 +182,7 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
SetPlayerMoney(index, cash);
|
||||
}
|
||||
|
||||
ZTeleClientSpawned(index);
|
||||
|
||||
// Remove night vision.
|
||||
NightVisionOn(index, false);
|
||||
NightVision(index, false);
|
||||
|
||||
@ -241,38 +240,11 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
SetPlayerAlpha(index, 255);
|
||||
}
|
||||
|
||||
new bool:randomclass = GetConVarBool(gCvars[CVAR_CLASSES_RANDOM]);
|
||||
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
|
||||
if (classes)
|
||||
{
|
||||
new bool:showmenu = GetConVarBool(gCvars[CVAR_CLASSES_SPAWN]);
|
||||
if (showmenu && !randomclass)
|
||||
{
|
||||
ClassMenu(index);
|
||||
}
|
||||
}
|
||||
// Forward event to modules.
|
||||
ClassOnClientSpawn(index);
|
||||
ZTeleClientSpawned(index);
|
||||
|
||||
ZR_PrintToChat(index, "!zmenu reminder");
|
||||
|
||||
decl String:steamid[16];
|
||||
GetClientAuthString(index, steamid, sizeof(steamid));
|
||||
if (StrEqual(steamid, "BOT") || randomclass)
|
||||
{
|
||||
new class = GetRandomInt(0, classCount - 1);
|
||||
|
||||
Call_StartForward(hOnZClassChanged);
|
||||
Call_PushCell(index);
|
||||
Call_PushCell(pClass[index]);
|
||||
Call_PushCell(class);
|
||||
Call_Finish();
|
||||
|
||||
pClass[index] = class;
|
||||
|
||||
decl String:classname[32];
|
||||
GetClassName(class, classname, sizeof(classname));
|
||||
|
||||
ZR_PrintToChat(index, "Auto-assign", classname);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
@ -285,50 +257,63 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
decl String:weapon[32];
|
||||
GetEventString(event, "weapon", weapon, sizeof(weapon));
|
||||
|
||||
// Check if the attacker is a player.
|
||||
if (attacker != 0)
|
||||
{
|
||||
// Check if a zombie attacks a human.
|
||||
if (IsPlayerHuman(index) && IsPlayerZombie(attacker))
|
||||
{
|
||||
// Check if spawn protection is disabled and the weapon is a knife.
|
||||
if (!pProtect[index] && StrEqual(weapon, "knife"))
|
||||
{
|
||||
Zombify(index, attacker);
|
||||
}
|
||||
}
|
||||
else if (IsPlayerHuman(attacker))
|
||||
|
||||
// Check if a human attacks a zombie.
|
||||
if (IsPlayerZombie(index) && IsPlayerHuman(attacker))
|
||||
{
|
||||
new Float:knockback = GetClassKnockback(pClass[index]);
|
||||
// Get zombie knockback value.
|
||||
new Float:knockback = ClassGetKnockback(index);
|
||||
|
||||
new Float:clientloc[3];
|
||||
new Float:attackerloc[3];
|
||||
|
||||
GetClientAbsOrigin(index, clientloc);
|
||||
|
||||
if (!StrEqual(weapon, "hegrenade"))
|
||||
// Check if a grenade was thrown.
|
||||
if (StrEqual(weapon, "hegrenade"))
|
||||
{
|
||||
// Get the location of the grenade.
|
||||
FindExplodingGrenade(attackerloc);
|
||||
|
||||
// Give knockback on the victim.
|
||||
KnockBack(index, clientloc, attackerloc, knockback, dmg, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetPlayerEyePosition(attacker, attackerloc);
|
||||
|
||||
new Float:attackerang[3];
|
||||
GetPlayerEyeAngles(attacker, attackerang);
|
||||
|
||||
// Calculate victim location.
|
||||
TR_TraceRayFilter(attackerloc, attackerang, MASK_ALL, RayType_Infinite, TraceRayFilter);
|
||||
TR_GetEndPosition(clientloc);
|
||||
|
||||
KnockBack(index, clientloc, attackerloc, knockback, dmg, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
FindExplodingGrenade(attackerloc);
|
||||
|
||||
KnockBack(index, clientloc, attackerloc, knockback, dmg, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsPlayerZombie(index))
|
||||
// Check if the player is a human.
|
||||
if (IsPlayerHuman(index))
|
||||
{
|
||||
// We're done now. Nothing more to do on humans.
|
||||
return;
|
||||
}
|
||||
|
||||
// Play a random zombie hurt sound.
|
||||
if (GetRandomInt(1, 5) == 1)
|
||||
{
|
||||
decl String:sound[64];
|
||||
@ -340,28 +325,16 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
EmitSoundToAll(sound, index);
|
||||
}
|
||||
|
||||
new bool:napalm = GetClassNapalm(pClass[index]);
|
||||
if (napalm)
|
||||
// Napalm effect.
|
||||
new Float:napalm_time = ClassGetNapalmTime(index);
|
||||
if (StrEqual(weapon, "hegrenade", false) && napalm_time > 0.0)
|
||||
{
|
||||
if (StrEqual(weapon, "hegrenade", false))
|
||||
{
|
||||
new Float:napalm_time = GetClassNapalmTime(pClass[index]);
|
||||
IgniteEntity(index, napalm_time);
|
||||
}
|
||||
}
|
||||
|
||||
// Forward event to modules.
|
||||
ClassAlphaUpdate(index);
|
||||
UpdateHPDisplay(index);
|
||||
|
||||
if (GetClassRegen(pClass[index]))
|
||||
{
|
||||
if (tHandles[index][TREGEN] == INVALID_HANDLE)
|
||||
{
|
||||
new Float:interval = GetClassRegenInterval(pClass[index]);
|
||||
tHandles[index][TREGEN] = CreateTimer(interval, Regenerate, index, TIMER_REPEAT);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateAlphaDamaged(index);
|
||||
}
|
||||
|
||||
public bool:TraceRayFilter(entity, contentsMask)
|
||||
@ -403,26 +376,30 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
|
||||
|
||||
SetPlayerFOV(index, DEFAULT_FOV);
|
||||
|
||||
ExtinguishEntity(index);
|
||||
|
||||
decl String:weapon[32];
|
||||
|
||||
// Reset field of view and extinguish fire.
|
||||
SetPlayerFOV(index, DEFAULT_FOV);
|
||||
ExtinguishEntity(index);
|
||||
|
||||
// Get the weapon name.
|
||||
GetEventString(event, "weapon", weapon, sizeof(weapon));
|
||||
|
||||
// Check if the player was infected.
|
||||
if (StrEqual(weapon, "zombie_claws_of_death", false))
|
||||
{
|
||||
// Add a death count to the players score.
|
||||
if (index)
|
||||
{
|
||||
AddPlayerDeath(index, 1);
|
||||
}
|
||||
|
||||
// Give a point to the attacker.
|
||||
if (attacker)
|
||||
{
|
||||
AddPlayerScore(attacker, 1);
|
||||
|
||||
new healthgain = GetClassInfectHealth(pClass[attacker]);
|
||||
new healthgain = ClassGetHealthInfectGain(attacker);
|
||||
new health = GetClientHealth(attacker);
|
||||
|
||||
SetEntityHealth(attacker, health + healthgain);
|
||||
@ -442,12 +419,14 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
PrecacheSound(sound);
|
||||
EmitSoundToAll(sound, index);
|
||||
|
||||
// Give kill bonus.
|
||||
if (attacker)
|
||||
{
|
||||
new bonus = GetClassKillBonus(pClass[index]);
|
||||
new bonus = ClassGetKillBonus(attacker);
|
||||
AddPlayerScore(attacker, bonus);
|
||||
}
|
||||
|
||||
// Check if the player was killed by world damage.
|
||||
if (!IsClientPlayer(attacker))
|
||||
{
|
||||
gKilledByWorld[index] = true;
|
||||
@ -458,6 +437,7 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
}
|
||||
}
|
||||
|
||||
// Kill various timers.
|
||||
for (new x = 0; x < MAXTIMERS; x++)
|
||||
{
|
||||
if (tHandles[index][x] != INVALID_HANDLE)
|
||||
@ -467,6 +447,7 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
}
|
||||
}
|
||||
|
||||
// Create respawn timer if enabled.
|
||||
new bool:respawn = GetConVarBool(gCvars[CVAR_RESPAWN]);
|
||||
if (respawn)
|
||||
{
|
||||
@ -475,26 +456,18 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
}
|
||||
}
|
||||
|
||||
// Forward event to modules.
|
||||
ClassOnClientDeath(index);
|
||||
|
||||
new ZTeam:team = IsRoundOver();
|
||||
if (team == Neither)
|
||||
{
|
||||
ClientCommand(index, "r_screenoverlay \"\"");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
RoundWin(team);
|
||||
}
|
||||
|
||||
public Action:PlayerJump(Handle:event, const String:name[], bool:dontBroadcast)
|
||||
{
|
||||
new index = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
new client = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||
new Float:distance = ClassGetJumpDistance(client);
|
||||
new Float:height = ClassGetJumpHeight(client);
|
||||
|
||||
if (IsPlayerZombie(index))
|
||||
{
|
||||
new Float:distance = GetClassJumpDistance(pClass[index]);
|
||||
new Float:height = GetClassJumpHeight(pClass[index]);
|
||||
|
||||
JumpBoost(index, distance, height);
|
||||
}
|
||||
JumpBoost(client, distance, height);
|
||||
}
|
@ -116,7 +116,7 @@ LoadDownloadData()
|
||||
CloseHandle(arrayDownloads);
|
||||
}
|
||||
|
||||
ApplyZombieModel(client)
|
||||
/*ApplyZombieModel(client)
|
||||
{
|
||||
decl String:modelpath[256];
|
||||
|
||||
@ -136,4 +136,4 @@ ApplyZombieModel(client)
|
||||
Format(modelpath, sizeof(modelpath), "%s.mdl", modelpath);
|
||||
|
||||
SetPlayerModel(client, modelpath);
|
||||
}
|
||||
}*/
|
||||
|
@ -37,6 +37,8 @@ bool:ClassApplyAttributes(client, bool:improved = false)
|
||||
ClassApplyHealth(client, classindex, improved);
|
||||
ClassApplyHealthRegen(client, classindex);
|
||||
ClassApplySpeed(client, classindex);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,18 +53,18 @@ bool:ClassApplyAttributes(client, bool:improved = false)
|
||||
* ZR_CLASS_CACHE_PLAYER (default) - Player cache.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
bool:ClassApplyModel(client, classindex, cachetpye = ZR_CLASS_CACHE_PLAYER)
|
||||
bool:ClassApplyModel(client, classindex, cachetype = ZR_CLASS_CACHE_PLAYER)
|
||||
{
|
||||
decl String:modelpath[256];
|
||||
|
||||
// Get the model path from the specified cache.
|
||||
if (cachetype == ZR_CLASS_CACHE_PLAYER)
|
||||
{
|
||||
ClassGetModelPath(client, modelpath, sizeof(modelpath), cachetype)
|
||||
ClassGetModelPath(client, modelpath, sizeof(modelpath), cachetype);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClassGetModelPath(classindex, modelpath, sizeof(modelpath), cachetype)
|
||||
ClassGetModelPath(classindex, modelpath, sizeof(modelpath), cachetype);
|
||||
}
|
||||
|
||||
// Check if the user specified a random model.
|
||||
@ -99,11 +101,11 @@ bool:ClassApplyAlpha(client, classindex, cachetype = ZR_CLASS_CACHE_PLAYER)
|
||||
// Get the alpha value from the specified cache.
|
||||
if (cachetype == ZR_CLASS_CACHE_PLAYER)
|
||||
{
|
||||
alpha = ClassGetAlphaSpawn(client, cachetype);
|
||||
alpha = ClassGetAlphaInitial(client, cachetype);
|
||||
}
|
||||
else
|
||||
{
|
||||
alpha = ClassGetAlphaSpawn(classindex, cachetype);
|
||||
alpha = ClassGetAlphaInitial(classindex, cachetype);
|
||||
}
|
||||
|
||||
if (alpha < 0)
|
||||
@ -313,7 +315,7 @@ bool:ClassApplyHealthRegen(client, classindex, cachetype = ZR_CLASS_CACHE_PLAYER
|
||||
*/
|
||||
bool:ClassApplySpeed(client, classindex, cachetype = ZR_CLASS_CACHE_PLAYER)
|
||||
{
|
||||
new speed;
|
||||
new Float:speed;
|
||||
|
||||
// Get the health points from the specified cache.
|
||||
if (cachetype == ZR_CLASS_CACHE_PLAYER)
|
||||
|
@ -107,7 +107,7 @@ bool:ClassGetTeamDefault(index, cachetype = ZR_CLASS_CACHE_MODIFIED)
|
||||
}
|
||||
case ZR_CLASS_CACHE_MODIFIED:
|
||||
{
|
||||
return ClassDataCached[index][class_team_default];
|
||||
return ClassDataCache[index][class_team_default];
|
||||
}
|
||||
case ZR_CLASS_CACHE_PLAYER:
|
||||
{
|
||||
|
114
src/zr/playerclasses/classevents.inc
Normal file
114
src/zr/playerclasses/classevents.inc
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* ============================================================================
|
||||
*
|
||||
* Zombie:Reloaded
|
||||
*
|
||||
* File: classevents.inc
|
||||
* Description: Functions for handling class related events.
|
||||
* Author: Richard Helgeby
|
||||
*
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
/* ------------------------------------
|
||||
*
|
||||
* GAME EVENTS
|
||||
*
|
||||
* ------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* To be called when a client connect to the server.
|
||||
* (OnClientPutInServer)
|
||||
*/
|
||||
ClassClientInit(client)
|
||||
{
|
||||
if (!IsFakeClient(client))
|
||||
{
|
||||
// Set default class indexes on the player.
|
||||
ClassClientSetDefaultIndexes(client);
|
||||
}
|
||||
}
|
||||
|
||||
ClassOnClientDisconnect(client)
|
||||
{
|
||||
// Stop timers related to class attributes.
|
||||
ClassOverlayStop(client);
|
||||
}
|
||||
|
||||
ClassOnClientSpawn(client)
|
||||
{
|
||||
new bool:randomclass = GetConVarBool(gCvars[CVAR_CLASSES_RANDOM]);
|
||||
new bool:showmenu = GetConVarBool(gCvars[CVAR_CLASSES_SPAWN]);
|
||||
decl String:steamid[16];
|
||||
decl String:classname[64];
|
||||
|
||||
if (showmenu && !randomclass)
|
||||
{
|
||||
ClassMenu(client);
|
||||
}
|
||||
|
||||
// Assign random classes if enabled.
|
||||
GetClientAuthString(client, steamid, sizeof(steamid));
|
||||
if (StrEqual(steamid, "BOT") || randomclass)
|
||||
{
|
||||
// Old class system.
|
||||
new classindex = GetRandomInt(0, classCount - 1);
|
||||
|
||||
Call_StartForward(hOnZClassChanged);
|
||||
Call_PushCell(client);
|
||||
Call_PushCell(pClass[client]);
|
||||
Call_PushCell(classindex);
|
||||
Call_Finish();
|
||||
|
||||
pClass[client] = classindex;
|
||||
|
||||
// New class system.
|
||||
new teamid = GetClientTeam(client);
|
||||
if (zombieSpawned && teamid == CS_TEAM_T)
|
||||
{
|
||||
classindex = ClassGetRandomClass(ZR_CLASS_TEAM_ZOMBIES);
|
||||
ClassSelected[client][ZR_CLASS_TEAM_ZOMBIES] = classindex;
|
||||
ClassGetName(client, classname, sizeof(classname));
|
||||
}
|
||||
else
|
||||
{
|
||||
classindex = ClassGetRandomClass(ZR_CLASS_TEAM_HUMANS);
|
||||
ClassSelected[client][ZR_CLASS_TEAM_HUMANS] = classindex;
|
||||
ClassGetName(client, classname, sizeof(classname));
|
||||
}
|
||||
|
||||
ZR_PrintToChat(client, "Auto-assign", classname);
|
||||
}
|
||||
}
|
||||
|
||||
ClassOnClientDeath(client)
|
||||
{
|
||||
ClassHealthRegenStop(client);
|
||||
ClassOverlayStop(client);
|
||||
}
|
||||
|
||||
ClassOnClientInfected(client, bool:motherzombie = false)
|
||||
{
|
||||
new classindex = ClassGetActiveIndex(client);
|
||||
|
||||
// Update the players cache with zombie attributes.
|
||||
ClassReloadPlayerCache(client, classindex);
|
||||
|
||||
// Apply the new attributes.
|
||||
ClassApplyAttributes(client, motherzombie);
|
||||
}
|
||||
|
||||
ClassOnRoundStart()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------
|
||||
*
|
||||
* PLAYER COMMANDS
|
||||
*
|
||||
* ------------------------------------
|
||||
*/
|
||||
|
28
src/zr/playerclasses/clientalpha.inc
Normal file
28
src/zr/playerclasses/clientalpha.inc
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* ============================================================================
|
||||
*
|
||||
* Zombie:Reloaded
|
||||
*
|
||||
* File: clientalpha.inc
|
||||
* Description: Handles transparency on clients.
|
||||
* Author: Richard Helgeby
|
||||
*
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Updates the alpha value on a player.
|
||||
*/
|
||||
ClassAlphaUpdate(client)
|
||||
{
|
||||
new current_health = GetClientHealth(client);
|
||||
new max_health = ClassGetHealth(client);
|
||||
new max_damage = ClassGetAlphaDamage(client);
|
||||
|
||||
// Calculate if enough damage is done to change alpha.
|
||||
if ((max_health - current_health) > max_damage)
|
||||
{
|
||||
new alpha_damaged = ClassGetAlphaDamaged(client);
|
||||
SetPlayerAlpha(client, alpha_damaged);
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@ bool:ClientHasOverlay(client)
|
||||
return bClientHasOverlay[client];
|
||||
}
|
||||
|
||||
ClassOverlayInitialize(client, const String:overlay)
|
||||
ClassOverlayInitialize(client, const String:overlay[])
|
||||
{
|
||||
if (IsFakeClient(client))
|
||||
{
|
||||
@ -64,7 +64,7 @@ ClassOverlayStart(client)
|
||||
tOverlay[client] = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
ClientCommand(client, "r_screenoverlay \"%s\"", overlay);
|
||||
ClientCommand(client, "r_screenoverlay \"%s\"", ActiveOverlay[client]);
|
||||
bClientOverlayOn[client] = true;
|
||||
|
||||
new Float:redisplay = GetConVarFloat(gCvars[CVAR_OVERLAY_REDISPLAY]);
|
||||
|
@ -13,7 +13,7 @@
|
||||
/**
|
||||
* Validates the team requirements in a class cache and check that theres at
|
||||
* least one class for each team. Minium team requirements are zombies and
|
||||
* humans. The admin team is optinal.
|
||||
* humans. The admin team is optinal and not validated.
|
||||
*
|
||||
* @param cachetype Optional. Specifies what class cache to validate. Options:
|
||||
* ZR_CLASS_CACHE_ORIGINAL (default, unchanged class data),
|
||||
@ -35,7 +35,8 @@ bool:ClassValidateTeamRequirements(cachetype = ZR_CLASS_CACHE_ORIGINAL)
|
||||
zombieindex = ClassGetFirstClass(ZR_CLASS_TEAM_ZOMBIES, _, cachetype);
|
||||
humanindex = ClassGetFirstClass(ZR_CLASS_TEAM_HUMANS, _, cachetype);
|
||||
|
||||
if (zombieindex > -1 && humanindex > -1)
|
||||
// Validate indexes.
|
||||
if (ClassValidateIndex(zombieindex) && ClassValidateIndex(humanindex))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -43,6 +44,40 @@ bool:ClassValidateTeamRequirements(cachetype = ZR_CLASS_CACHE_ORIGINAL)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that there's a class marked as team default for each team.
|
||||
*
|
||||
* @param cachetype Optional. Specifies what class cache to validate. Options:
|
||||
* ZR_CLASS_CACHE_ORIGINAL (default, unchanged class data),
|
||||
* ZR_CLASS_CACHE_MODIFIED (modified class data).
|
||||
* @return True if validation was successful, false otherwise.
|
||||
*/
|
||||
bool:ClassValidateTeamDefaults(cachetype = ZR_CLASS_CACHE_ORIGINAL)
|
||||
{
|
||||
new zombieindex;
|
||||
new humanindex;
|
||||
|
||||
// Check if there are no classes.
|
||||
if (ClassCount == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Test if a default zombie and human class was found.
|
||||
zombieindex = ClassGetDefaultClass(ZR_CLASS_TEAM_ZOMBIES, _, cachetype);
|
||||
humanindex = ClassGetDefaultClass(ZR_CLASS_TEAM_HUMANS, _, cachetype);
|
||||
|
||||
// Validate indexes.
|
||||
if (ClassValidateIndex(zombieindex) && ClassValidateIndex(humanindex))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all the class attributes in the original class data array, to
|
||||
* check if they have invalid values. Boolean settings are not validated.
|
||||
@ -111,10 +146,12 @@ ClassValidateAttributes(classindex)
|
||||
|
||||
// Overlay path.
|
||||
decl String:overlay_path[256];
|
||||
if (strcopy(overlay_path, sizeof(overlay_path), ClassData[classindex][class_overlay_path]) != 0)
|
||||
decl String:overlay[256];
|
||||
if (strcopy(overlay_path, sizeof(overlay_path), ClassData[classindex][class_overlay_path]) > 0)
|
||||
{
|
||||
// Check if the file exists.
|
||||
if (!FileExists(overlay_path))
|
||||
Format(overlay, sizeof(overlay), "materials/%s.vmt", overlay_path);
|
||||
if (!FileExists(overlay))
|
||||
{
|
||||
flags += ZR_CLASS_ATTRIB_ERR_OVERLAY_PATH;
|
||||
}
|
||||
@ -139,14 +176,14 @@ ClassValidateAttributes(classindex)
|
||||
if (!(regen_interval >= 0.0 && regen_interval <= 900.0))
|
||||
{
|
||||
flags += ZR_CLASS_ATTRIB_ERR_HEALTH_REGEN_INTERVAL;
|
||||
}
|
||||
|
||||
// Health regen amount.
|
||||
// Health regen amount. Only validating if interval is set.
|
||||
new regen_amount = ClassData[classindex][class_health_regen_amount];
|
||||
if (!(regen_amount > 0 && regen_amount <= 65536))
|
||||
{
|
||||
flags += ZR_CLASS_ATTRIB_ERR_HEALTH_REGEN_AMOUNT;
|
||||
}
|
||||
}
|
||||
|
||||
// Health infect gain.
|
||||
new infect_gain = ClassData[classindex][class_health_infect_gain];
|
||||
@ -267,7 +304,7 @@ ClassGetIndex(const String:name[], cachetype = ZR_CLASS_CACHE_MODIFIED)
|
||||
for (new classindex = 0; classindex < ClassCount; classindex++)
|
||||
{
|
||||
// Get its name and compare it with the specified class name.
|
||||
ClassesGetName(classindex, current_name, sizeof(current_name), cachetype);
|
||||
ClassGetName(classindex, current_name, sizeof(current_name), cachetype);
|
||||
if (strcmp(name, current_name, false) == 0)
|
||||
{
|
||||
return classindex;
|
||||
@ -289,7 +326,7 @@ ClassGetActiveIndex(client)
|
||||
{
|
||||
new teamid = GetClientTeam(client);
|
||||
|
||||
if (teamid == CS_TEAM_SPECTACTOR || teamid == CS_TEAM_NONE)
|
||||
if (teamid == CS_TEAM_SPECTATOR || teamid == CS_TEAM_NONE)
|
||||
{
|
||||
// No active team.
|
||||
return -1;
|
||||
@ -297,17 +334,17 @@ ClassGetActiveIndex(client)
|
||||
|
||||
if (IsPlayerHuman(client))
|
||||
{
|
||||
teamid = ZR_TEAM_HUMANS;
|
||||
teamid = ZR_CLASS_TEAM_HUMANS;
|
||||
}
|
||||
else
|
||||
{
|
||||
teamid = ZR_TEAM_ZOMBIES;
|
||||
teamid = ZR_CLASS_TEAM_ZOMBIES;
|
||||
}
|
||||
|
||||
// TODO: How to detect that virtual admin team?
|
||||
|
||||
// Return the active class for the current team.
|
||||
return ClassActive[client][teamid];
|
||||
return ClassSelected[client][teamid];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -476,6 +513,52 @@ ClassGetFirstClass(teamfilter = -1, bool:ignoreEnabled = false, cachetype = ZR_C
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first class marked as default for the specified team.
|
||||
*
|
||||
* @param teamid The team ID.
|
||||
* @param ignoreEnabled Optional. Ignore the class's enabled attribute. Default
|
||||
* is false.
|
||||
* @param cachetype Optional. Specifies what class cache to read from.
|
||||
* Options:
|
||||
* ZR_CLASS_CACHE_ORIGINAL - Unchanced class data.
|
||||
* ZR_CLASS_CACHE_MODIFIED (default) - Changed/newest
|
||||
* class data.
|
||||
* @return The first default class index. -1 on error.
|
||||
*/
|
||||
ClassGetDefaultClass(teamid, bool:ignoreEnabled = false, cachetype = ZR_CLASS_CACHE_MODIFIED)
|
||||
{
|
||||
new Handle:classarray;
|
||||
new arraycount;
|
||||
new classindex;
|
||||
|
||||
classarray = CreateArray();
|
||||
|
||||
// Get all classes from the specified team.
|
||||
if (!ClassAddToArray(classarray, teamid, ignoreEnabled, cachetype))
|
||||
{
|
||||
// Failed to get classes.
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Loop through all classes and return the first class marked as team default.
|
||||
arraycount = GetArraySize(classarray);
|
||||
for (new i = 0; i < arraycount; i++)
|
||||
{
|
||||
// Get class index from the array.
|
||||
classindex = GetArrayCell(classarray, i);
|
||||
|
||||
// Check if the current class is marked as team default.
|
||||
if (ClassGetTeamDefault(classindex, cachetype))
|
||||
{
|
||||
// Default class found.
|
||||
return classindex;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default class index for the specified team configured to be used
|
||||
* when players join the server.
|
||||
@ -493,8 +576,6 @@ ClassGetDefaultSpawnClass(teamid, cachetype = ZR_CLASS_CACHE_MODIFIED)
|
||||
{
|
||||
decl String:classname[64];
|
||||
new classindex;
|
||||
new Handle:classarray;
|
||||
new arraycount;
|
||||
|
||||
// Get the default class name from the correct CVAR depending on teamid.
|
||||
switch (teamid)
|
||||
@ -519,13 +600,13 @@ ClassGetDefaultSpawnClass(teamid, cachetype = ZR_CLASS_CACHE_MODIFIED)
|
||||
}
|
||||
|
||||
// Check if the class name isn't empty.
|
||||
if (strlen(class_name) > 0)
|
||||
if (strlen(classname) > 0)
|
||||
{
|
||||
// Check if the user set "random" as default class.
|
||||
if (strcmp(classname, "random", false) == 0)
|
||||
{
|
||||
// Get a list of all classes with the specified team ID.
|
||||
classindex = ClassGetRandomClass(teamid, cachetype);
|
||||
classindex = ClassGetRandomClass(teamid, _, cachetype);
|
||||
|
||||
// Validate the result, in case there were errors.
|
||||
if (ClassValidateIndex(classindex))
|
||||
@ -545,7 +626,7 @@ ClassGetDefaultSpawnClass(teamid, cachetype = ZR_CLASS_CACHE_MODIFIED)
|
||||
// The user set a spesific class.
|
||||
|
||||
// Try to get the class index with the specified class name.
|
||||
classindex = ClassGetClassIndex(classname, cachetype);
|
||||
classindex = ClassGetIndex(classname, cachetype);
|
||||
|
||||
// Validate the class index and check if the team IDs match.
|
||||
if (ClassValidateIndex(classindex) && (teamid == ClassGetTeamID(classindex, cachetype)))
|
||||
@ -557,11 +638,11 @@ ClassGetDefaultSpawnClass(teamid, cachetype = ZR_CLASS_CACHE_MODIFIED)
|
||||
// The class index is invalid or the team IDs didn't match.
|
||||
// Because it's user input, we'll fall back to the first class
|
||||
// in the specified team, and log a warning.
|
||||
classindex = ClassGetFirstClass(teamid, cachetype);
|
||||
classindex = ClassGetFirstClass(teamid, _, cachetype);
|
||||
|
||||
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
|
||||
{
|
||||
ZR_LogMessageFormatted(-1, "classes", "default spawn class", "Warning: Failed to set \"%s\" as default spawn class for team %d. The class doesn't exist or the team IDs doesn't match. Falling back to the first class in the team.", _, classname, teamid);
|
||||
ZR_LogMessageFormatted(-1, "Classes", "DefaultSpawnClass", "Warning: Failed to set \"%s\" as default spawn class for team %d. The class doesn't exist or the team IDs doesn't match. Falling back to the first class in the team.", _, classname, teamid);
|
||||
}
|
||||
|
||||
// Validate the new index.
|
||||
@ -570,7 +651,7 @@ ClassGetDefaultSpawnClass(teamid, cachetype = ZR_CLASS_CACHE_MODIFIED)
|
||||
// Log a warning.
|
||||
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
|
||||
{
|
||||
ZR_LogMessageFormatted(-1, "classes", "default spawn class", "Warning: The default class name \"%s\" does not exist or matches the team ID.", _, classname);
|
||||
ZR_LogMessageFormatted(-1, "Classes", "DefaultSpawnClass", "Warning: The default class name \"%s\" does not exist or matches the team ID.", _, classname);
|
||||
}
|
||||
|
||||
return classindex;
|
||||
@ -585,7 +666,7 @@ ClassGetDefaultSpawnClass(teamid, cachetype = ZR_CLASS_CACHE_MODIFIED)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Blank class name, return a error code.
|
||||
return -1;
|
||||
// Blank class name, get the default class and return the index.
|
||||
return ClassGetDefaultClass(teamid, _, cachetype);
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@
|
||||
* Total number of classes that can be stored in each cache. A total of 32
|
||||
* classes should be enough. Too many classes will comfuse players.
|
||||
*/
|
||||
#define ZR_CLASS_MAX 31
|
||||
#define ZR_CLASS_MAX 32
|
||||
|
||||
/**
|
||||
* @section Class cache types. Specifies what data array to use.
|
||||
@ -223,24 +223,26 @@ new ClassDataCache[ZR_CLASS_MAX][ClassAttributes];
|
||||
new ClassPlayerCache[MAXPLAYERS + 1][ClassAttributes];
|
||||
|
||||
/**
|
||||
* Number of classes successfully loaded.
|
||||
* Number of classes loaded.
|
||||
*/
|
||||
new ClassCount;
|
||||
|
||||
/**
|
||||
* Stores what class that the player have selected, for each team.
|
||||
*/
|
||||
new ClassActive[MAXPLAYERS + 1][ZR_CLASS_TEAMCOUNT - 1];
|
||||
new ClassSelected[MAXPLAYERS + 1][ZR_CLASS_TEAMCOUNT];
|
||||
|
||||
#include "zr/playerclasses/filtertools"
|
||||
#include "zr/playerclasses/attributes"
|
||||
#include "zr/playerclasses/apply"
|
||||
#include "zr/playerclasses/clientoverlays"
|
||||
#include "zr/playerclasses/clientalpha"
|
||||
#include "zr/playerclasses/healthregen"
|
||||
#include "zr/playerclasses/classevents"
|
||||
|
||||
/**
|
||||
* Loads class attributes from playerclasses.txt into the ClassData array. If
|
||||
* any error occour, the plugin load will fail.
|
||||
* any error occour the plugin load will fail.
|
||||
*
|
||||
* @param classfile Optional. Specifies what file to read from. Valves key/
|
||||
* values format. The path is relative to the sourcemod
|
||||
@ -296,6 +298,7 @@ ClassLoad(const String:classfile[256] = "configs/zr/playerclasses.txt")
|
||||
/* General */
|
||||
ClassData[ClassCount][class_enabled] = bool:KvGetNum(kvClassData, "enabled", ZR_CLASS_DEFAULT_ENABLED);
|
||||
ClassData[ClassCount][class_team] = KvGetNum(kvClassData, "team", ZR_CLASS_DEFAULT_TEAM);
|
||||
ClassData[ClassCount][class_team_default] = bool:KvGetNum(kvClassData, "team_default", ZR_CLASS_DEFAULT_TEAM_DEFAULT);
|
||||
|
||||
KvGetString(kvClassData, "name", name, sizeof(name), ZR_CLASS_DEFAULT_NAME);
|
||||
strcopy(ClassData[ClassCount][class_name], 64, name);
|
||||
@ -363,6 +366,15 @@ ClassLoad(const String:classfile[256] = "configs/zr/playerclasses.txt")
|
||||
{
|
||||
SetFailState("The class configuration doesn't match the team requirements.");
|
||||
}
|
||||
|
||||
// Validate team default requirements.
|
||||
if (!ClassValidateTeamDefaults())
|
||||
{
|
||||
SetFailState("Couldn't find a default class for one or more teams. At least one class per team must be marked as default.");
|
||||
}
|
||||
|
||||
// Cache class data.
|
||||
ClassReloadDataCache();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -384,7 +396,7 @@ bool:ClassReloadDataCache()
|
||||
return false;
|
||||
}
|
||||
|
||||
for (new classindex = 0; classindex < ClassCount; clasindex++)
|
||||
for (new classindex = 0; classindex < ClassCount; classindex++)
|
||||
{
|
||||
/* General */
|
||||
ClassDataCache[classindex][class_enabled] = ClassData[classindex][class_enabled];
|
||||
@ -530,3 +542,93 @@ bool:ClassReloadPlayerCache(client, classindex, cachetype = ZR_CLASS_CACHE_MODIF
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets default class indexes for each team on all players, or a single player
|
||||
* if specified.
|
||||
*
|
||||
* @param client Optional. The client index.
|
||||
*/
|
||||
ClassClientSetDefaultIndexes(client = -1)
|
||||
{
|
||||
new classindex = GetDefaultClassIndex(); // Old class system. Not removed for backwards compatibility.
|
||||
|
||||
// Get indexes.
|
||||
new zombieindex = ClassGetDefaultSpawnClass(ZR_CLASS_TEAM_ZOMBIES);
|
||||
new humanindex = ClassGetDefaultSpawnClass(ZR_CLASS_TEAM_HUMANS);
|
||||
new adminindex = ClassGetDefaultSpawnClass(ZR_CLASS_TEAM_ADMINS);
|
||||
|
||||
// Validate zombie class index.
|
||||
if (!ClassValidateIndex(zombieindex))
|
||||
{
|
||||
// Invalid class index. Fall back to default class in class config and
|
||||
// log a warning.
|
||||
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
|
||||
{
|
||||
ZR_LogMessageFormatted(-1, "Classes", "SetDefaultIndexes", "Warning: Failed to get default zombie class, falling back to default class. Check spelling in \"zr_classes_default_zombie\".", LOG_FORMAT_TYPE_ERROR);
|
||||
}
|
||||
|
||||
// Use default class.
|
||||
zombieindex = ClassGetDefaultClass(ZR_CLASS_TEAM_ZOMBIES);
|
||||
}
|
||||
|
||||
// Validate human class index.
|
||||
if (!ClassValidateIndex(humanindex))
|
||||
{
|
||||
// Invalid class index. Fall back to default class in class config and
|
||||
// log a warning.
|
||||
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
|
||||
{
|
||||
ZR_LogMessageFormatted(-1, "Classes", "SetDefaultIndexes", "Warning: Failed to get default human class, falling back to default class. Check spelling in \"zr_classes_default_human\".", LOG_FORMAT_TYPE_ERROR);
|
||||
}
|
||||
|
||||
// Use default class.
|
||||
humanindex = ClassGetDefaultClass(ZR_CLASS_TEAM_HUMANS);
|
||||
}
|
||||
|
||||
// Validate admin class index.
|
||||
if (!ClassValidateIndex(adminindex))
|
||||
{
|
||||
// Invalid class index. Fall back to default class in class config and
|
||||
// log a warning.
|
||||
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_CLASSES))
|
||||
{
|
||||
ZR_LogMessageFormatted(-1, "Classes", "SetDefaultIndexes", "Warning: Failed to get default admin class, falling back to default class. Check spelling in \"zr_classes_default_admin\".", LOG_FORMAT_TYPE_ERROR);
|
||||
}
|
||||
|
||||
// Use default class.
|
||||
adminindex = ClassGetDefaultClass(ZR_CLASS_TEAM_ADMINS);
|
||||
}
|
||||
|
||||
// Check if a client is specified.
|
||||
if (client > 0)
|
||||
{
|
||||
// Set the old array for backwards compatibility while introducing the
|
||||
// new class system.
|
||||
pClass[client] = classindex;
|
||||
|
||||
ClassSelected[client][ZR_CLASS_TEAM_ZOMBIES] = zombieindex;
|
||||
ClassSelected[client][ZR_CLASS_TEAM_HUMANS] = humanindex;
|
||||
ClassSelected[client][ZR_CLASS_TEAM_ADMINS] = adminindex;
|
||||
|
||||
// Copy human class data to player cache.
|
||||
ClassReloadPlayerCache(client, humanindex);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No client specified. Loop through all players.
|
||||
for (new clientindex = 1; clientindex <= MAXPLAYERS; clientindex++)
|
||||
{
|
||||
// Set the old array for backwards compatibility while introducing the
|
||||
// new class system.
|
||||
pClass[clientindex] = classindex;
|
||||
|
||||
ClassSelected[clientindex][ZR_CLASS_TEAM_ZOMBIES] = zombieindex;
|
||||
ClassSelected[clientindex][ZR_CLASS_TEAM_HUMANS] = humanindex;
|
||||
ClassSelected[clientindex][ZR_CLASS_TEAM_ADMINS] = adminindex;
|
||||
|
||||
// Copy human class data to player cache.
|
||||
ClassReloadPlayerCache(client, humanindex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,15 +46,22 @@ public Action:Command_NightVision(client, argc)
|
||||
return;
|
||||
}
|
||||
|
||||
bZVisionOn[client] = !bZVisionOn[client];
|
||||
//bZVisionOn[client] = !bZVisionOn[client];
|
||||
bClientOverlayOn[client] = !bClientOverlayOn[client];
|
||||
|
||||
if (bZVisionOn[client])
|
||||
decl String:overlay[256];
|
||||
ClassGetOverlayPath(client, overlay, sizeof(overlay));
|
||||
|
||||
if (strlen(overlay) > 0)
|
||||
{
|
||||
ZVisionPreCheck(client);
|
||||
if (bClientOverlayOn[client])
|
||||
{
|
||||
ClassOverlayInitialize(client, overlay);
|
||||
}
|
||||
else
|
||||
{
|
||||
ZVisionStop(client);
|
||||
ClassOverlayStop(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,25 +170,26 @@ Zombify_Mother(client)
|
||||
gZombie[client] = true;
|
||||
motherZombie[client] = true;
|
||||
|
||||
ApplyZombieHealth(client,true);
|
||||
//ApplyZombieHealth(client,true);
|
||||
|
||||
ApplyZombieSpeed(client);
|
||||
//ApplyZombieSpeed(client);
|
||||
|
||||
CS_SwitchTeam(client, CS_TEAM_T);
|
||||
|
||||
RemoveAllPlayersWeapons(client);
|
||||
GivePlayerItem(client, "weapon_knife");
|
||||
|
||||
ApplyZombieNightVision(client);
|
||||
//ApplyZombieNightVision(client);
|
||||
|
||||
ZVisionPreCheck(client);
|
||||
//ZVisionPreCheck(client);
|
||||
|
||||
ApplyZombieFOV(client);
|
||||
//ApplyZombieFOV(client);
|
||||
|
||||
ApplyZombieModel(client);
|
||||
//ApplyZombieModel(client);
|
||||
|
||||
ApplyZombieAlpha(client);
|
||||
//ApplyZombieAlpha(client);
|
||||
|
||||
ClassOnClientInfected(client, true);
|
||||
InfectionEffects(client);
|
||||
|
||||
ztele_count[client] = 0;
|
||||
@ -249,23 +257,24 @@ Zombify(client, attacker)
|
||||
|
||||
gZombie[client] = true;
|
||||
|
||||
ApplyZombieHealth(client, false);
|
||||
//ApplyZombieHealth(client, false);
|
||||
|
||||
ApplyZombieSpeed(client);
|
||||
//ApplyZombieSpeed(client);
|
||||
|
||||
RemoveAllPlayersWeapons(client);
|
||||
GivePlayerItem(client, "weapon_knife");
|
||||
|
||||
ApplyZombieNightVision(client);
|
||||
//ApplyZombieNightVision(client);
|
||||
|
||||
ZVisionPreCheck(client);
|
||||
//ZVisionPreCheck(client);
|
||||
|
||||
ApplyZombieFOV(client);
|
||||
//ApplyZombieFOV(client);
|
||||
|
||||
ApplyZombieModel(client);
|
||||
//ApplyZombieModel(client);
|
||||
|
||||
ApplyZombieAlpha(client);
|
||||
//ApplyZombieAlpha(client);
|
||||
|
||||
ClassOnClientInfected(client);
|
||||
InfectionEffects(client);
|
||||
|
||||
ztele_count[client] = 0;
|
||||
@ -387,7 +396,7 @@ InfectionEffects(client)
|
||||
}
|
||||
}
|
||||
|
||||
ApplyZombieHealth(client, bool:mother)
|
||||
/*ApplyZombieHealth(client, bool:mother)
|
||||
{
|
||||
new health = GetClassHealth(pClass[client]);
|
||||
|
||||
@ -397,15 +406,15 @@ ApplyZombieHealth(client, bool:mother)
|
||||
}
|
||||
|
||||
SetEntityHealth(client, health);
|
||||
}
|
||||
}*/
|
||||
|
||||
ApplyZombieSpeed(client)
|
||||
/*ApplyZombieSpeed(client)
|
||||
{
|
||||
new Float:speed = GetClassSpeed(pClass[client]);
|
||||
SetPlayerSpeed(client, speed);
|
||||
}
|
||||
}*/
|
||||
|
||||
ApplyZombieNightVision(client)
|
||||
/*ApplyZombieNightVision(client)
|
||||
{
|
||||
new bool:nvgs = GetClassNVGs(pClass[client]);
|
||||
NightVision(client, nvgs);
|
||||
@ -414,19 +423,19 @@ ApplyZombieNightVision(client)
|
||||
{
|
||||
NightVisionOn(client, nvgs);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
ApplyZombieFOV(client)
|
||||
/*ApplyZombieFOV(client)
|
||||
{
|
||||
new fov = GetClassFOV(pClass[client]);
|
||||
SetPlayerFOV(client, fov);
|
||||
}
|
||||
}*/
|
||||
|
||||
ApplyZombieAlpha(client)
|
||||
/*ApplyZombieAlpha(client)
|
||||
{
|
||||
new alpha = GetClassAlphaSpawn(pClass[client]);
|
||||
SetPlayerAlpha(client, alpha);
|
||||
}
|
||||
}*/
|
||||
|
||||
KnockBack(client, const Float:clientloc[3], const Float:attackerloc[3], Float:power, dmg, bool:grenade)
|
||||
{
|
||||
@ -650,7 +659,7 @@ RemoveObjectives()
|
||||
}
|
||||
}
|
||||
|
||||
ZVisionPreCheck(client)
|
||||
/*ZVisionPreCheck(client)
|
||||
{
|
||||
if (IsFakeClient(client))
|
||||
{
|
||||
@ -671,24 +680,24 @@ ZVisionPreCheck(client)
|
||||
|
||||
ZVisionStart(client);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
ZVisionStart(client)
|
||||
/*ZVisionStart(client)
|
||||
{
|
||||
/*if (tHandles[client][TZVISION] != INVALID_HANDLE)
|
||||
{
|
||||
KillTimer(tHandles[client][TZVISION]);
|
||||
tHandles[client][TZVISION] = INVALID_HANDLE;
|
||||
}*/
|
||||
//if (tHandles[client][TZVISION] != INVALID_HANDLE)
|
||||
//{
|
||||
// KillTimer(tHandles[client][TZVISION]);
|
||||
// tHandles[client][TZVISION] = INVALID_HANDLE;
|
||||
//}
|
||||
|
||||
DisplayClientOverlay(client, ZVisionOverlay[client]);
|
||||
bZVisionOn[client] = true;
|
||||
|
||||
//new Float:redisplay = GetConVarFloat(gCvars[CVAR_ZVISION_REDISPLAY]);
|
||||
//tHandles[client][TZVISION] = CreateTimer(redisplay, ZVisionTimer, client, TIMER_REPEAT);
|
||||
}
|
||||
}*/
|
||||
|
||||
ZVisionStop(client)
|
||||
/*ZVisionStop(client)
|
||||
{
|
||||
if (tHandles[client][TZVISION] != INVALID_HANDLE)
|
||||
{
|
||||
@ -698,7 +707,7 @@ ZVisionStop(client)
|
||||
|
||||
ClientCommand(client, "r_screenoverlay \"\"");
|
||||
bZVisionOn[client] = false;
|
||||
}
|
||||
}*/
|
||||
|
||||
/*public Action:ZVisionTimer(Handle:timer, any:client)
|
||||
{
|
||||
@ -737,7 +746,7 @@ public Action:ZombieMoanTimer(Handle:timer, any:index)
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public Action:Regenerate(Handle:timer, any:index)
|
||||
/*public Action:Regenerate(Handle:timer, any:index)
|
||||
{
|
||||
if (!IsClientInGame(index) || !IsPlayerZombie(index))
|
||||
{
|
||||
@ -769,7 +778,7 @@ public Action:Regenerate(Handle:timer, any:index)
|
||||
UpdateHPDisplay(index);
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
}*/
|
||||
|
||||
UpdateHPDisplay(client)
|
||||
{
|
||||
@ -793,18 +802,6 @@ UpdateHPDisplay(client)
|
||||
ZR_HudHint(client, "Display HP", health);
|
||||
}
|
||||
|
||||
UpdateAlphaDamaged(client)
|
||||
{
|
||||
new current_health = GetClientHealth(client);
|
||||
new max_health = GetClassHealth(pClass[client]);
|
||||
new max_damage = GetClassAlphaDamage(pClass[client]);
|
||||
if (max_health - current_health > max_damage)
|
||||
{
|
||||
new alpha_damaged = GetClassAlphaDamaged(pClass[client]);
|
||||
SetPlayerAlpha(client, alpha_damaged);
|
||||
}
|
||||
}
|
||||
|
||||
public Action:ZHPTimer(Handle:timer, any:index)
|
||||
{
|
||||
if (!IsClientInGame(index))
|
||||
|
@ -63,8 +63,8 @@ new bool:motherZombie[MAXPLAYERS+1];
|
||||
new bool:gZombie[MAXPLAYERS+1];
|
||||
new bool:gBlockMotherInfect[MAXPLAYERS+1];
|
||||
new bool:bZVision[MAXPLAYERS+1];
|
||||
new bool:bZVisionOn[MAXPLAYERS+1];
|
||||
new String:ZVisionOverlay[MAXPLAYERS+1][PLATFORM_MAX_PATH];
|
||||
//new bool:bZVisionOn[MAXPLAYERS+1];
|
||||
//new String:ZVisionOverlay[MAXPLAYERS+1][PLATFORM_MAX_PATH];
|
||||
new bool:dispHP[MAXPLAYERS+1];
|
||||
new bool:pProtect[MAXPLAYERS+1];
|
||||
new bool:gKilledByWorld[MAXPLAYERS+1] = {false, ...};
|
||||
@ -211,18 +211,6 @@ bool:IsPlayerInList(client)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool:IntToBool(intval)
|
||||
{
|
||||
if (intval == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool:IsClientPlayer(client)
|
||||
{
|
||||
if (client > 0 && client <= maxclients)
|
||||
|
Loading…
Reference in New Issue
Block a user