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