bandaid fix: make zm hp scale

This commit is contained in:
neon 2019-03-17 14:36:21 +01:00
parent df52c16f25
commit 9a2e8b4eb7

View File

@ -3,7 +3,7 @@
* Zombie Riot * Zombie Riot
* File: zombiedata.inc * File: zombiedata.inc
* Author: Greyscale * Author: Greyscale
* ==================== * ====================
*/ */
enum ZRiot_ZombieData enum ZRiot_ZombieData
@ -34,9 +34,9 @@ new zCount;
FileLinesToArray(Handle:array, const Handle:file) FileLinesToArray(Handle:array, const Handle:file)
{ {
ClearArray(array); ClearArray(array);
decl String:line[128]; decl String:line[128];
while(!IsEndOfFile(file) && ReadFileLine(file, line, sizeof(line))) while(!IsEndOfFile(file) && ReadFileLine(file, line, sizeof(line)))
{ {
if (StrContains(line, ";") == -1) if (StrContains(line, ";") == -1)
@ -46,7 +46,7 @@ FileLinesToArray(Handle:array, const Handle:file)
SplitString(line, "//", line, sizeof(line)); SplitString(line, "//", line, sizeof(line));
} }
TrimString(line); TrimString(line);
if (!StrEqual(line, "", false)) if (!StrEqual(line, "", false))
{ {
PushArrayString(array, line); PushArrayString(array, line);
@ -54,66 +54,66 @@ FileLinesToArray(Handle:array, const Handle:file)
} }
} }
} }
LoadZombieData(bool:defaultconfig) LoadZombieData(bool:defaultconfig)
{ {
decl String:path[PLATFORM_MAX_PATH]; decl String:path[PLATFORM_MAX_PATH];
Format(path, sizeof(path), "%s/zombies.txt", gMapConfig); Format(path, sizeof(path), "%s/zombies.txt", gMapConfig);
if (!defaultconfig && !FileExists(path)) if (!defaultconfig && !FileExists(path))
{ {
return; return;
} }
if (kvZombies != INVALID_HANDLE) if (kvZombies != INVALID_HANDLE)
{ {
CloseHandle(kvZombies); CloseHandle(kvZombies);
} }
kvZombies = CreateKeyValues("zombies"); kvZombies = CreateKeyValues("zombies");
if (!FileToKeyValues(kvZombies, path)) if (!FileToKeyValues(kvZombies, path))
{ {
SetFailState("\"%s\" failed to load", path); SetFailState("\"%s\" failed to load", path);
} }
KvRewind(kvZombies); KvRewind(kvZombies);
if (!KvGotoFirstSubKey(kvZombies)) if (!KvGotoFirstSubKey(kvZombies))
{ {
SetFailState("No zombie data defined in \"%s\"", path); SetFailState("No zombie data defined in \"%s\"", path);
} }
decl String:name[64]; decl String:name[64];
decl String:type[32]; decl String:type[32];
decl String:model[256]; decl String:model[256];
decl String:zvision[256]; decl String:zvision[256];
zCount = 0; zCount = 0;
do do
{ {
KvGetSectionName(kvZombies, name, sizeof(name)); KvGetSectionName(kvZombies, name, sizeof(name));
strcopy(arrayZombies[zCount][data_name], 32, name); strcopy(arrayZombies[zCount][data_name], 32, name);
KvGetString(kvZombies, "type", type, sizeof(type)); KvGetString(kvZombies, "type", type, sizeof(type));
arrayZombies[zCount][data_override_required] = (StrEqual(type, "override_required", false)); arrayZombies[zCount][data_override_required] = (StrEqual(type, "override_required", false));
KvGetString(kvZombies, "model", model, sizeof(model)); KvGetString(kvZombies, "model", model, sizeof(model));
strcopy(arrayZombies[zCount][data_model], 256, model); strcopy(arrayZombies[zCount][data_model], 256, model);
KvGetString(kvZombies, "zvision", zvision, sizeof(zvision)); KvGetString(kvZombies, "zvision", zvision, sizeof(zvision));
strcopy(arrayZombies[zCount][data_zvision], 256, zvision); strcopy(arrayZombies[zCount][data_zvision], 256, zvision);
arrayZombies[zCount][data_health] = KvGetNum(kvZombies, "health", 500); arrayZombies[zCount][data_health] = KvGetNum(kvZombies, "health", 500);
arrayZombies[zCount][data_speed] = KvGetFloat(kvZombies, "speed", 300.0); arrayZombies[zCount][data_speed] = KvGetFloat(kvZombies, "speed", 300.0);
arrayZombies[zCount][data_gravity] = KvGetFloat(kvZombies, "gravity", 1.0); arrayZombies[zCount][data_gravity] = KvGetFloat(kvZombies, "gravity", 1.0);
arrayZombies[zCount][data_jump] = KvGetFloat(kvZombies, "jump", 1.0); arrayZombies[zCount][data_jump] = KvGetFloat(kvZombies, "jump", 1.0);
arrayZombies[zCount][data_fov] = KvGetNum(kvZombies, "fov", 90); arrayZombies[zCount][data_fov] = KvGetNum(kvZombies, "fov", 90);
zCount++; zCount++;
} while (KvGotoNextKey(kvZombies)); } while (KvGotoNextKey(kvZombies));
} }
@ -122,31 +122,31 @@ LoadModelData()
{ {
decl String:path[PLATFORM_MAX_PATH]; decl String:path[PLATFORM_MAX_PATH];
BuildPath(Path_SM, path, sizeof(path), "configs/zriot/models.txt"); BuildPath(Path_SM, path, sizeof(path), "configs/zriot/models.txt");
new Handle:fileModels = OpenFile(path, "r"); new Handle:fileModels = OpenFile(path, "r");
if (fileModels == INVALID_HANDLE) if (fileModels == INVALID_HANDLE)
{ {
SetFailState("\"%s\" missing from server", path); SetFailState("\"%s\" missing from server", path);
} }
if (adtModels != INVALID_HANDLE) if (adtModels != INVALID_HANDLE)
{ {
CloseHandle(adtModels); CloseHandle(adtModels);
} }
adtModels = CreateArray(256, 0); adtModels = CreateArray(256, 0);
FileLinesToArray(adtModels, fileModels); FileLinesToArray(adtModels, fileModels);
if (!GetArraySize(adtModels)) if (!GetArraySize(adtModels))
{ {
SetFailState("No models listed in models.txt, please add some models then restart"); SetFailState("No models listed in models.txt, please add some models then restart");
} }
decl String:model[256]; decl String:model[256];
decl String:modelpath[256]; decl String:modelpath[256];
new modelsize = GetArraySize(adtModels); new modelsize = GetArraySize(adtModels);
for (new x = 0; x < modelsize; x++) for (new x = 0; x < modelsize; x++)
{ {
@ -154,14 +154,14 @@ LoadModelData()
{ {
GetArrayString(adtModels, x, model, sizeof(model)); GetArrayString(adtModels, x, model, sizeof(model));
Format(modelpath, sizeof(modelpath), "%s%s", model, modelSuffix[y]); Format(modelpath, sizeof(modelpath), "%s%s", model, modelSuffix[y]);
if (FileExists(modelpath)) if (FileExists(modelpath))
{ {
AddFileToDownloadsTable(modelpath); AddFileToDownloadsTable(modelpath);
} }
} }
} }
CloseHandle(fileModels); CloseHandle(fileModels);
} }
@ -169,20 +169,20 @@ LoadDownloadData()
{ {
decl String:path[PLATFORM_MAX_PATH]; decl String:path[PLATFORM_MAX_PATH];
BuildPath(Path_SM, path, sizeof(path), "configs/zriot/downloads.txt"); BuildPath(Path_SM, path, sizeof(path), "configs/zriot/downloads.txt");
new Handle:fileDownloads = OpenFile(path, "r"); new Handle:fileDownloads = OpenFile(path, "r");
if (fileDownloads == INVALID_HANDLE) if (fileDownloads == INVALID_HANDLE)
{ {
SetFailState("\"%s\" missing from server", path); SetFailState("\"%s\" missing from server", path);
} }
new Handle:arrayDownloads = CreateArray(256, 0); new Handle:arrayDownloads = CreateArray(256, 0);
FileLinesToArray(arrayDownloads, fileDownloads); FileLinesToArray(arrayDownloads, fileDownloads);
decl String:file[256]; decl String:file[256];
new downloadsize = GetArraySize(arrayDownloads); new downloadsize = GetArraySize(arrayDownloads);
for (new x = 0; x < downloadsize; x++) for (new x = 0; x < downloadsize; x++)
{ {
@ -196,7 +196,7 @@ LoadDownloadData()
ZRiot_LogMessage("File load failed", file); ZRiot_LogMessage("File load failed", file);
} }
} }
CloseHandle(fileDownloads); CloseHandle(fileDownloads);
CloseHandle(arrayDownloads); CloseHandle(arrayDownloads);
} }
@ -210,7 +210,7 @@ FindZombieIDByName(const String:name[])
return x; return x;
} }
} }
return -1; return -1;
} }
@ -220,7 +220,7 @@ bool:IsValidZombieID(zombieid)
{ {
return true; return true;
} }
return false; return false;
} }
@ -230,7 +230,7 @@ bool:IsOverrideRequired(zombieid)
{ {
return arrayZombies[zombieid][data_override_required]; return arrayZombies[zombieid][data_override_required];
} }
return false; return false;
} }
@ -240,7 +240,7 @@ ApplyZombieModel(client, zombieid)
{ {
decl String:model[256]; decl String:model[256];
strcopy(model, sizeof(model), arrayZombies[zombieid][data_model]); strcopy(model, sizeof(model), arrayZombies[zombieid][data_model]);
PrecacheModel(model); PrecacheModel(model);
SetEntityModel(client, model); SetEntityModel(client, model);
} }
@ -258,7 +258,21 @@ ApplyZombieHealth(client, zombieid)
{ {
if (IsValidZombieID(zombieid)) if (IsValidZombieID(zombieid))
{ {
SetEntityHealth(client, arrayZombies[zombieid][data_health]); new iCount = 0;
for (new i = 1; i <= MaxClients; i++)
{
if (IsValidClient(i) && (GetClientTeam(i) == 3) && IsPlayerAlive(i))
{
iCount++;
}
}
if (iCount == 0)
{
iCount++;
}
SetEntityHealth(client, arrayZombies[zombieid][data_health]*iCount);
} }
} }
@ -284,7 +298,7 @@ Float:GetZombieJump(zombieid)
{ {
return arrayZombies[zombieid][data_jump]; return arrayZombies[zombieid][data_jump];
} }
return 0.0; return 0.0;
} }
@ -294,4 +308,17 @@ ApplyZombieFOV(client, zombieid)
{ {
SetPlayerFOV(client, arrayZombies[zombieid][data_fov]); SetPlayerFOV(client, arrayZombies[zombieid][data_fov]);
} }
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
int:IsValidClient(client, nobots = true)
{
if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
{
return false;
}
return IsClientInGame(client);
} }