initial commit of zombie hunting zones
This commit is contained in:
parent
923d46635e
commit
f4c458260e
@ -550,7 +550,7 @@ public void CreateZonePoints(float point[8][3])
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action DrawZone(int client, float array[8][3], int beamsprite, int halosprite, color[4], float life)
|
||||
public Action DrawZone(int client, float array[8][3], int beamsprite, int halosprite, int color[4], float life)
|
||||
{
|
||||
//shavit
|
||||
static int pairs[][] =
|
||||
@ -635,7 +635,7 @@ public int Keychecker()
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose: Writing to File
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void writetofile(float[3] startpos, float[3] endpos, char[] zones, int client, int state)
|
||||
public void writetofile(float startpos[3], float endpos[3], char[] zones, int client, int state)
|
||||
{
|
||||
char l_cEntryCount[MAXZONES];
|
||||
char l_cTransfer[MAXZONES];
|
||||
@ -924,7 +924,7 @@ public void CreateZones(float f_min[3], float f_max[3], char[] sZoneName, int zo
|
||||
* 1 - only a player can trigger this by touch, makes it so a NPC cannot fire a trigger_multiple
|
||||
* 2 - Won't fire unless triggering ent's view angles are within 45 degrees of trigger's angles (in addition to any other conditions), so if you want the player to only be able to fire the entity at a 90 degree angle you would do ",angles,0 90 0," into your spawnstring.
|
||||
* 4 - Won't fire unless player is in it and pressing use button (in addition to any other conditions), you must make a bounding box,(max\mins) for this to work.
|
||||
* 8 - Won't fire unless player/NPC is in it and pressing fire button, you must make a bounding box,(max\mins) for this to work.
|
||||
* 8 - Wont fire unless player/NPC is in it and pressing fire button, you must make a bounding box,(max\mins) for this to work.
|
||||
* 16 - only non-player NPCs can trigger this by touch
|
||||
* 128 - Start off, has to be activated by a target_activate to be touchable/usable
|
||||
* 256 - multiple players can trigger the entity at the same time
|
||||
@ -980,7 +980,7 @@ public void CreateZones(float f_min[3], float f_max[3], char[] sZoneName, int zo
|
||||
public void OnStartTouch(int entindex, int other)
|
||||
{
|
||||
char l_cZoneName[MAXZONES];
|
||||
if (IsValidClient(other) && IsPlayerAlive(other))
|
||||
if (IsValidClient1(other) && IsPlayerAlive(other))
|
||||
{
|
||||
GetEntPropString(entindex, Prop_Data, "m_iName", l_cZoneName, sizeof(l_cZoneName));
|
||||
//forward
|
||||
@ -996,7 +996,7 @@ public void OnStartTouch(int entindex, int other)
|
||||
public void OnEndTouch(int entindex, int other)
|
||||
{
|
||||
char l_cZoneName[MAXZONES];
|
||||
if (IsValidClient(other) && IsPlayerAlive(other))
|
||||
if (IsValidClient1(other) && IsPlayerAlive(other))
|
||||
{
|
||||
GetEntPropString(entindex, Prop_Data, "m_iName", l_cZoneName, sizeof(l_cZoneName));
|
||||
//forward
|
||||
@ -1015,6 +1015,13 @@ stock int IsValidClient(int client, bool nobots = true)
|
||||
return false;
|
||||
return IsClientInGame(client);
|
||||
}
|
||||
|
||||
stock int IsValidClient1(int client, bool nobots = true)
|
||||
{
|
||||
if (client <= 0 || client > MaxClients || !IsClientConnected(client))
|
||||
return false;
|
||||
return IsClientInGame(client);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -1049,4 +1056,4 @@ stock void ReplaceStrings(char[] str, char[] strReplace)
|
||||
ReplaceString(l_cstrFix, sizeof(l_cstrFix), strReplace, "");
|
||||
TrimString(l_cstrFix);
|
||||
Format(str, sizeof(l_cstrFix), l_cstrFix);
|
||||
}
|
||||
}
|
||||
|
40
zombie_hunting_respawn/unloze_zones/zm_cbble_b3.zones.txt
Normal file
40
zombie_hunting_respawn/unloze_zones/zm_cbble_b3.zones.txt
Normal file
@ -0,0 +1,40 @@
|
||||
"Zones"
|
||||
{
|
||||
"1"
|
||||
{
|
||||
"name" "UNASSIGNED_NAME_1"
|
||||
"cordinate_a" "-1442.968750 573.031250 16.031250"
|
||||
"cordinate_b" "-1139.582764 1231.968750 254.403992"
|
||||
}
|
||||
"2"
|
||||
{
|
||||
"name" "UNASSIGNED_NAME_2"
|
||||
"cordinate_a" "-955.031250 -751.968750 -265.968750"
|
||||
"cordinate_b" "-2388.968750 548.546021 379.967194"
|
||||
}
|
||||
"3"
|
||||
{
|
||||
"name" "UNASSIGNED_NAME_3"
|
||||
"cordinate_a" "-275.031250 -1286.968750 64.031250"
|
||||
"cordinate_b" "-936.968750 -408.660126 307.531372"
|
||||
}
|
||||
"4"
|
||||
{
|
||||
"name" "UNASSIGNED_NAME_4"
|
||||
"cordinate_a" "-238.968750 -1468.968750 64.031250"
|
||||
"cordinate_b" "641.547546 383.968719 435.103333"
|
||||
}
|
||||
"5"
|
||||
{
|
||||
"name" "UNASSIGNED_NAME_5"
|
||||
"cordinate_a" "305.968750 404.031250 64.031250"
|
||||
"cordinate_b" "-2.968750 980.378174 316.667664"
|
||||
}
|
||||
"6"
|
||||
{
|
||||
"name" "UNASSIGNED_NAME_6"
|
||||
"cordinate_a" "-1103.968750 1721.984375 21.677704"
|
||||
"cordinate_b" "531.590942 991.031250 432.144958"
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,46 @@
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
#include <zombiereloaded>
|
||||
#include <unloze_zones>
|
||||
#include <cstrike>
|
||||
#include <PlayerRankings>
|
||||
#include <hlstatsx_loghelper>
|
||||
#define MAXZONES 66
|
||||
#define ZONENAMELENGTH 256
|
||||
int g_bBlockRespawn[MAXPLAYERS+1];
|
||||
char g_cZones[MAXZONES][ZONENAMELENGTH];
|
||||
int g_cZones_CT_count[MAXZONES];
|
||||
int g_cZones_ZM_count[MAXZONES];
|
||||
int g_client_in_zone[MAXPLAYERS + 1];
|
||||
int g_iCT_Damage_in_zone[MAXPLAYERS + 1];
|
||||
int g_iZone_fought_or_ct_controlled[MAXZONES];
|
||||
int g_iLast_Client_In_Zone[MAXPLAYERS + 1];
|
||||
int ping_ents[MAXPLAYERS + 1];
|
||||
|
||||
//spawning the markers
|
||||
float ping_coorindates[MAXZONES][3];
|
||||
int zone_pings[MAXZONES];
|
||||
|
||||
static char g_cConfigZones[PLATFORM_MAX_PATH];
|
||||
int g_zoneCount = 0;
|
||||
int client_target[MAXPLAYERS + 1];
|
||||
float g_fStartPos[MAXZONES][3];
|
||||
float g_fEndPos[MAXZONES][3];
|
||||
ConVar g_hRespawnTreshold;
|
||||
ConVar g_hHealthRegenZM;
|
||||
ConVar g_hHealthRegenAmount;
|
||||
ConVar g_hZMSpeedBuff;
|
||||
Handle hText;
|
||||
Handle g_hZMZoneTimer = null;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "zh stop zm respawn",
|
||||
name = "zombie hunting plugin",
|
||||
author = "jenz",
|
||||
description = "Disables respawning on zombie hunting maps after some deaths",
|
||||
version = "1.0.0",
|
||||
description = "Disables respawning on zombie hunting maps after some deaths, adds zoning",
|
||||
version = "2.0.0",
|
||||
url = "www.unloze.com"
|
||||
};
|
||||
|
||||
@ -21,12 +49,52 @@ public Plugin myinfo =
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnPluginStart()
|
||||
{
|
||||
g_hRespawnTreshold = CreateConVar("zh_respawn_count", "5.0", "zombie hunting respawn count", 0, true, 0.0, true, 100.0);
|
||||
for (int client; client < MaxClients; client++)
|
||||
g_bBlockRespawn[client] = 0;
|
||||
|
||||
HookEvent("round_start", OnRoundStart);
|
||||
HookEvent("player_death", OnClientDeath);
|
||||
OnMapStart();
|
||||
g_hRespawnTreshold = CreateConVar("zh_respawn_count", "5.0", "zombie hunting respawn count", 0, true, 0.0, true, 100.0);
|
||||
g_hHealthRegenZM = CreateConVar("zh_regenMaxHealth", "2000", "zombie hunting zombie max health for regen", 0, true, 0.0, true, 5000.0);
|
||||
g_hHealthRegenAmount = CreateConVar("zh_regenAmount", "100", "zombie hunting zombie max health for regen", 0, true, 0.0, true, 5000.0);
|
||||
g_hZMSpeedBuff = CreateConVar("zh_speedbuff", "1.2", "zombie hunting zombie speed buff in zm zone", 0, true, 0.0, true, 5000.0);
|
||||
for (int client; client < MaxClients; client++)
|
||||
g_bBlockRespawn[client] = 0;
|
||||
|
||||
ReadZoneFile();
|
||||
|
||||
HookEvent("round_start", OnRoundStart);
|
||||
HookEvent("round_end", OnRoundEnd, EventHookMode_Pre);
|
||||
HookEvent("player_death", OnClientDeath);
|
||||
hText = CreateHudSynchronizer();
|
||||
|
||||
//timer for ZM zone benefits
|
||||
g_hZMZoneTimer = CreateTimer(5.0, give_zm_zone_boosts, _, TIMER_REPEAT);
|
||||
}
|
||||
|
||||
public Action give_zm_zone_boosts(Handle hTimer)
|
||||
{
|
||||
for (int client; client < MaxClients; client++)
|
||||
{
|
||||
if (IsValidClient(client) && IsPlayerAlive(client) && GetClientTeam(client) == CS_TEAM_T)
|
||||
{
|
||||
int index = g_client_in_zone[client];
|
||||
//the player is zm, inside a zone and the zone has no humans present, so its a zm zone where he should get extra healed
|
||||
if (index != -1 && g_cZones_CT_count[index] == 0)
|
||||
{
|
||||
//giving zm inside of zm controlled zone extra health regeneration
|
||||
int client_health = GetEntData(client, FindDataMapInfo(client, "m_iHealth"));
|
||||
if (client_health < g_hHealthRegenZM.IntValue)
|
||||
{
|
||||
SetEntProp(client, Prop_Send, "m_iHealth", client_health + g_hHealthRegenAmount.IntValue, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public void OnPluginEnd()
|
||||
{
|
||||
CloseHandle(hText);
|
||||
if (g_hZMZoneTimer != null)
|
||||
delete g_hZMZoneTimer;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -34,17 +102,89 @@ public void OnPluginStart()
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
g_iCT_Damage_in_zone[client] = 0;
|
||||
client_target[client] = 0;
|
||||
g_client_in_zone[client] = -1;
|
||||
adjust_clients(); //calling GetClientTeam inside adjust_clients complaints that client already disconnected.
|
||||
g_bBlockRespawn[client] = 0;
|
||||
}
|
||||
|
||||
public void adjust_clients()
|
||||
{
|
||||
for (int i = 0; i < MAXZONES; i++)
|
||||
{
|
||||
g_cZones_CT_count[i] = 0;
|
||||
g_cZones_ZM_count[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i <= g_zoneCount; i++)
|
||||
{
|
||||
for (int client; client < MaxClients; client++)
|
||||
{
|
||||
if (IsValidClient(client) && IsPlayerAlive(client) && g_client_in_zone[client] == i)
|
||||
{
|
||||
if (GetClientTeam(client) == CS_TEAM_CT)
|
||||
{
|
||||
g_cZones_CT_count[i]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_cZones_ZM_count[i]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
UpdateMarkers();
|
||||
}
|
||||
|
||||
public void OnRoundEnd(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
bool found_alive_zm = false;
|
||||
for (int client = 0; client < MaxClients; client++)
|
||||
{
|
||||
if (IsValidClient(client) && GetClientTeam(client) == CS_TEAM_T && IsPlayerAlive(client))
|
||||
{
|
||||
found_alive_zm = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_alive_zm)
|
||||
{
|
||||
for (int client = 0; client < MaxClients; client++)
|
||||
{
|
||||
if (IsValidClient(client) && GetClientTeam(client) == CS_TEAM_CT)
|
||||
{
|
||||
ForcePlayerSuicide(client);
|
||||
}
|
||||
}
|
||||
PrintToChatAll("Humans failed!");
|
||||
PrintToChatAll("Humans failed!");
|
||||
PrintToChatAll("Humans failed!");
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
for (int client; client < MaxClients; client++)
|
||||
g_bBlockRespawn[client] = 0;
|
||||
for (int client = 0; client < MaxClients; client++)
|
||||
{
|
||||
g_bBlockRespawn[client] = 0;
|
||||
if (IsValidClient(client))
|
||||
{
|
||||
g_iCT_Damage_in_zone[client] = 0;
|
||||
}
|
||||
g_client_in_zone[client] = -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAXZONES; i++)
|
||||
{
|
||||
g_cZones_CT_count[i] = 0;
|
||||
g_cZones_ZM_count[i] = 0;
|
||||
g_iZone_fought_or_ct_controlled[i] = -1;
|
||||
g_iLast_Client_In_Zone[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -53,12 +193,32 @@ public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
int victim = GetClientOfUserId(hEvent.GetInt("userid"));
|
||||
if (g_bBlockRespawn[victim] > g_hRespawnTreshold.FloatValue)
|
||||
g_client_in_zone[victim] = -1;
|
||||
adjust_clients();
|
||||
SetEntityRenderColor(victim, 255, 255, 255, 255);
|
||||
//resetting speed to default althought its only needed for ZM to be enforced
|
||||
SetEntPropFloat(victim, Prop_Data, "m_flLaggedMovementValue", 1.0);
|
||||
if (g_bBlockRespawn[victim] > g_hRespawnTreshold.IntValue)
|
||||
return;
|
||||
PrintToChat(victim, "\x04[ZR]\x01 You have %f respawns left for this round.", g_hRespawnTreshold.FloatValue - g_bBlockRespawn[victim]);
|
||||
PrintToChat(victim, "\x04[ZR]\x01 You have %i respawns left for this round.", g_hRespawnTreshold.IntValue - g_bBlockRespawn[victim]);
|
||||
g_bBlockRespawn[victim]++;
|
||||
}
|
||||
|
||||
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
|
||||
{
|
||||
int index = g_client_in_zone[client];
|
||||
if (index != -1)
|
||||
{
|
||||
//client got infected inside a specific zone, reduce human count inside that specific zone by 1
|
||||
if (g_cZones_CT_count[index] > 0)
|
||||
{
|
||||
g_cZones_CT_count[index]--;
|
||||
}
|
||||
g_cZones_ZM_count[index]++;
|
||||
UpdateMarkers();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -70,7 +230,7 @@ stock bool IsValidClient(int client)
|
||||
return false;
|
||||
}
|
||||
|
||||
public float get_power_distance(int target_player, float [3]pos)
|
||||
public float get_power_distance(int target_player, float pos[3])
|
||||
{
|
||||
float vec[3];
|
||||
GetClientAbsOrigin(target_player, vec);
|
||||
@ -79,7 +239,7 @@ public float get_power_distance(int target_player, float [3]pos)
|
||||
|
||||
public Action ZR_OnClientRespawn(&client, &ZR_RespawnCondition:condition)
|
||||
{
|
||||
if (g_bBlockRespawn[client] > g_hRespawnTreshold.FloatValue)
|
||||
if (g_bBlockRespawn[client] > g_hRespawnTreshold.IntValue)
|
||||
return Plugin_Handled;
|
||||
|
||||
//teleport player to team members with farthest distance to enemy just.
|
||||
@ -100,7 +260,7 @@ public Action ZR_OnClientRespawn(&client, &ZR_RespawnCondition:condition)
|
||||
float nearestdistance = -1.0;
|
||||
int nearest = -1;
|
||||
for (int j = 1; j <= MaxClients; j++)
|
||||
if (IsValidClient(j) && IsPlayerAlive(j) && GetClientTeam(i) != GetClientTeam(j) && GetClientTeam(i) == 3)
|
||||
if (IsValidClient(j) && IsPlayerAlive(j) && GetClientTeam(i) != GetClientTeam(j) && GetClientTeam(i) == CS_TEAM_CT)
|
||||
{
|
||||
float pos[3];
|
||||
GetEntPropVector(i, Prop_Send, "m_vecOrigin", pos);
|
||||
@ -150,7 +310,9 @@ public bool TraceRayHitOnlyEnt(int entityhit, int mask, any data) {
|
||||
|
||||
public void OnClientPostAdminCheck(int client)
|
||||
{
|
||||
g_iCT_Damage_in_zone[client] = 0;
|
||||
client_target[client] = 0;
|
||||
g_client_in_zone[client] = -1;
|
||||
}
|
||||
|
||||
public Action tp_client(Handle timer, int client)
|
||||
@ -163,4 +325,433 @@ public Action tp_client(Handle timer, int client)
|
||||
PrintToChat(client, "Respawned you at player: %N", client_target[client]);
|
||||
client_target[client] = 0;
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public void unloze_zoneLeave(int client, char[] zone)
|
||||
{
|
||||
int index = g_client_in_zone[client];
|
||||
g_client_in_zone[client] = -1;
|
||||
g_iCT_Damage_in_zone[client] = 0;
|
||||
if (GetClientTeam(client) == CS_TEAM_CT)
|
||||
{
|
||||
if (g_cZones_CT_count[index] > 0)
|
||||
{
|
||||
g_cZones_CT_count[index]--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_cZones_ZM_count[index] > 0)
|
||||
{
|
||||
g_cZones_ZM_count[index]--;
|
||||
}
|
||||
}
|
||||
SetEntityRenderColor(client, 255, 255, 255, 255);
|
||||
//resetting speed to default althought its only needed for ZM to be enforced
|
||||
SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 1.0);
|
||||
UpdateMarkers();
|
||||
}
|
||||
|
||||
public void unloze_zoneCreated()
|
||||
{
|
||||
ReadZoneFile();
|
||||
}
|
||||
|
||||
public Action retry_zoneEntry(Handle timer, DataPack data)
|
||||
{
|
||||
ResetPack(data);
|
||||
char zone[256];
|
||||
data.ReadString(zone, sizeof(zone));
|
||||
int client_serial = data.ReadCell();
|
||||
delete data;
|
||||
|
||||
int client;
|
||||
if ((client = GetClientFromSerial(client_serial)) != 0)
|
||||
{
|
||||
//by the time its recalled should the player have left the previous zone already
|
||||
unloze_zoneEntry(client, zone);
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public void unloze_zoneEntry(int client, char[] zone)
|
||||
{
|
||||
int index = -1;
|
||||
//unfortunately it can happen that a zone is entered before the current one is left, which can lead to -1 index
|
||||
//when leaving the zone again.
|
||||
//example: Enter new zone before old is left -> leave old zone -> index is -1 -> leave current zone -> leave forward is called before entering new zone is called ->
|
||||
//tries to do -- on a array index where the index is -1
|
||||
if (g_client_in_zone[client] != -1)
|
||||
{
|
||||
//the previous zone has to be left before we recognize the client entering the new zone
|
||||
//only special cases are roundstart/respawning
|
||||
DataPack hDataPack = new DataPack();
|
||||
hDataPack.WriteString(zone);
|
||||
hDataPack.WriteCell(GetClientSerial(client));
|
||||
CreateTimer(1.0, retry_zoneEntry, hDataPack);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < g_zoneCount; i++)
|
||||
{
|
||||
if (StrEqual(g_cZones[i], zone))
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_client_in_zone[client] = index;
|
||||
|
||||
g_iCT_Damage_in_zone[client] = PlayerRankings_GetClientDamage(client);
|
||||
if (GetClientTeam(client) == CS_TEAM_CT)
|
||||
{
|
||||
g_cZones_CT_count[index]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_cZones_ZM_count[index]++;
|
||||
}
|
||||
g_iLast_Client_In_Zone[index] = client;
|
||||
display_hud_text(index, client);
|
||||
UpdateMarkers();
|
||||
}
|
||||
|
||||
public void handle_pings(int i, int pingtype)
|
||||
{
|
||||
for (int j = zone_pings[i]; j < zone_pings[i + 1]; j++)
|
||||
{
|
||||
//the ping is atm not the skull, will be changed to skull.
|
||||
RemovePing(j);
|
||||
SpawnPing(pingtype, ping_coorindates[j], j);
|
||||
for (int client = 0; client < MaxClients; client++)
|
||||
{
|
||||
if (IsValidClient(client) && g_client_in_zone[client] == i)
|
||||
{
|
||||
display_hud_text(i, client);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void display_hud_text(int index, int client)
|
||||
{
|
||||
if (hText != INVALID_HANDLE)
|
||||
{
|
||||
char msg[256];
|
||||
if (g_cZones_CT_count[index] > 0 && g_cZones_ZM_count[index] > 0)
|
||||
{
|
||||
Format(msg, sizeof(msg), "Fought over zone");
|
||||
SetHudTextParams(0.35, 0.85, 2.5, 255, 255, 255, 85);
|
||||
ShowSyncHudText(client, hText, msg);
|
||||
}
|
||||
else if (g_cZones_CT_count[index] > 0)
|
||||
{
|
||||
Format(msg, sizeof(msg), "Human controlled zone");
|
||||
SetHudTextParams(0.35, 0.85, 2.5, 0, 0, 255, 85);
|
||||
ShowSyncHudText(client, hText, msg);
|
||||
SetEntityRenderColor(client, 0, 0, 255, 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
Format(msg, sizeof(msg), "Zombie controlled zone");
|
||||
SetHudTextParams(0.35, 0.85, 2.5, 255, 0, 0, 85);
|
||||
ShowSyncHudText(client, hText, msg);
|
||||
SetEntityRenderColor(client, 255, 0, 0, 255);
|
||||
SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", g_hZMSpeedBuff.FloatValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose: Reads from file
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action ReadZoneFile()
|
||||
{
|
||||
int i_zoneTemp;
|
||||
char l_cMapName[MAXZONES];
|
||||
GetCurrentMap(l_cMapName, sizeof(l_cMapName));
|
||||
Handle l_hZoneFile = INVALID_HANDLE;
|
||||
char l_cLine[ZONENAMELENGTH];
|
||||
char sPart[4][32];
|
||||
BuildPath(Path_SM, g_cConfigZones, sizeof(g_cConfigZones), "configs/unloze_zones/%s.zones.txt", l_cMapName);
|
||||
l_hZoneFile = OpenFile(g_cConfigZones, "r");
|
||||
if (l_hZoneFile == INVALID_HANDLE)
|
||||
{
|
||||
Handle kv = CreateKeyValues("Zones");
|
||||
KeyValuesToFile(kv, g_cConfigZones);
|
||||
CloseHandle(kv);
|
||||
delete l_hZoneFile;
|
||||
return Plugin_Handled;
|
||||
}
|
||||
while (!IsEndOfFile(l_hZoneFile) && ReadFileLine(l_hZoneFile, l_cLine, sizeof(l_cLine)))
|
||||
{
|
||||
if (StrContains(l_cLine, "name", false) > -1)
|
||||
{
|
||||
ReplaceStrings(l_cLine, "name");
|
||||
Format(g_cZones[i_zoneTemp], sizeof(g_cZones), l_cLine);
|
||||
}
|
||||
if (StrContains(l_cLine, "cordinate_a", false) >= 0)
|
||||
{
|
||||
ReplaceString(l_cLine, sizeof(l_cLine), "\"", "", true);
|
||||
ReplaceString(l_cLine, sizeof(l_cLine), "cordinate_a", "", true);
|
||||
ExplodeString(l_cLine, " ", sPart, 4, 32);
|
||||
g_fStartPos[i_zoneTemp][0] = StringToFloat(sPart[0]);//reading first vector
|
||||
g_fStartPos[i_zoneTemp][1] = StringToFloat(sPart[1]);//reading second vector
|
||||
g_fStartPos[i_zoneTemp][2] = StringToFloat(sPart[2]);//reading third vector
|
||||
}
|
||||
if (StrContains(l_cLine, "cordinate_b", false) >= 0)
|
||||
{
|
||||
ReplaceString(l_cLine, sizeof(l_cLine), "\"", "", true);
|
||||
ReplaceString(l_cLine, sizeof(l_cLine), "cordinate_b", "", true);
|
||||
ExplodeString(l_cLine, " ", sPart, 4, 32);
|
||||
g_fEndPos[i_zoneTemp][0] = StringToFloat(sPart[0]);
|
||||
g_fEndPos[i_zoneTemp][1] = StringToFloat(sPart[1]);
|
||||
g_fEndPos[i_zoneTemp][2] = StringToFloat(sPart[2]);
|
||||
i_zoneTemp++;
|
||||
}
|
||||
}
|
||||
g_zoneCount = i_zoneTemp;
|
||||
delete l_hZoneFile;
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
{
|
||||
//resetting coordinates and setup.
|
||||
for (int i = 0; i < MAXZONES; i++)
|
||||
{
|
||||
ping_coorindates[i][0] = 0.0;
|
||||
ping_coorindates[i][1] = 0.0;
|
||||
ping_coorindates[i][2] = 0.0;
|
||||
zone_pings[i] = 0;
|
||||
}
|
||||
|
||||
char g_cMapname[ZONENAMELENGTH];
|
||||
GetCurrentMap(g_cMapname, sizeof(g_cMapname));
|
||||
if (StrEqual(g_cMapname, "zm_cbble_b3", false))
|
||||
{
|
||||
ping_coorindates[0][0] = -1321.18;
|
||||
ping_coorindates[0][1] = 635.93;
|
||||
ping_coorindates[0][2] = 15.00;
|
||||
ping_coorindates[1][0] = -1228.51;
|
||||
ping_coorindates[1][1] = 1097.70;
|
||||
ping_coorindates[1][2] = 15.00;
|
||||
zone_pings[1] = 2; //first zone thats iterated.
|
||||
|
||||
ping_coorindates[2][0] = -1313.29;
|
||||
ping_coorindates[2][1] = 481.83;
|
||||
ping_coorindates[2][2] = 15.00;
|
||||
ping_coorindates[3][0] = -1026.88;
|
||||
ping_coorindates[3][1] = -543.23;
|
||||
ping_coorindates[3][2] = 15.00 + 48.0; //higher terrain.
|
||||
zone_pings[2] = 4; //second zone thats iterated, and so on and so on.
|
||||
|
||||
ping_coorindates[4][0] = -857.17;
|
||||
ping_coorindates[4][1] = -549.33;
|
||||
ping_coorindates[4][2] = 15.00 + 48.0;
|
||||
ping_coorindates[5][0] = -319.23;
|
||||
ping_coorindates[5][1] = -1091.23;
|
||||
ping_coorindates[5][2] = 15.00 + 48.0; //higher terrain.
|
||||
zone_pings[3] = 6;
|
||||
|
||||
ping_coorindates[6][0] = -178.41;
|
||||
ping_coorindates[6][1] = -1096.69;
|
||||
ping_coorindates[6][2] = 15.00 + 48.0;
|
||||
ping_coorindates[7][0] = 135.89;
|
||||
ping_coorindates[7][1] = 262.61;
|
||||
ping_coorindates[7][2] = 15.00 + 48.0; //higher terrain.
|
||||
zone_pings[4] = 8;
|
||||
|
||||
ping_coorindates[8][0] = 149.52;
|
||||
ping_coorindates[8][1] = 477.08;
|
||||
ping_coorindates[8][2] = 15.00 + 48.0;
|
||||
ping_coorindates[9][0] = 144.99;
|
||||
ping_coorindates[9][1] = 927.54;
|
||||
ping_coorindates[9][2] = 15.00 + 48.0; //higher terrain.
|
||||
zone_pings[5] = 10;
|
||||
|
||||
ping_coorindates[10][0] = 146.94;
|
||||
ping_coorindates[10][1] = 1083.88;
|
||||
ping_coorindates[10][2] = 15.00 + 48.0;
|
||||
ping_coorindates[11][0] = -1074.73;
|
||||
ping_coorindates[11][1] = 1087.19;
|
||||
ping_coorindates[11][2] = 15.00;
|
||||
zone_pings[6] = 12;
|
||||
}
|
||||
else if (StrEqual(g_cMapname, "cs_office", false))
|
||||
{
|
||||
//not the actual values atm
|
||||
ping_coorindates[0][0] = -1097.99;
|
||||
ping_coorindates[0][1] = 1095.98;
|
||||
ping_coorindates[0][2] = 90.03;
|
||||
ping_coorindates[1][0] = -1158.51;
|
||||
ping_coorindates[1][1] = 1097.70;
|
||||
ping_coorindates[1][2] = 90.03;
|
||||
|
||||
ping_coorindates[2][0] = -1316.23;
|
||||
ping_coorindates[2][1] = 586.25;
|
||||
ping_coorindates[2][2] = 90.03;
|
||||
ping_coorindates[3][0] = -1323.59;
|
||||
ping_coorindates[3][1] = 475.53;
|
||||
ping_coorindates[3][2] = 90.03;
|
||||
}
|
||||
}
|
||||
|
||||
stock void ReplaceStrings(char[] str, char[] strReplace)
|
||||
{
|
||||
char l_cstrFix[MAXZONES];
|
||||
Format(l_cstrFix, sizeof(l_cstrFix), str);
|
||||
ReplaceString(l_cstrFix, sizeof(l_cstrFix), "\"", "");
|
||||
ReplaceString(l_cstrFix, sizeof(l_cstrFix), strReplace, "");
|
||||
TrimString(l_cstrFix);
|
||||
Format(str, sizeof(l_cstrFix), l_cstrFix);
|
||||
}
|
||||
|
||||
public void SpawnPing(int skin, float pos[3], int index)
|
||||
{
|
||||
int Ent = CreateEntityByName("prop_dynamic");
|
||||
SetEntityModel(Ent, "models/unloze/unloze_ping.mdl");
|
||||
DispatchKeyValue(Ent, "modelscale", "1.5");
|
||||
|
||||
if (skin == 1) //fought over (skull)
|
||||
SetVariantString("1");
|
||||
else if (skin == 2) //CT controlled (moon)
|
||||
SetVariantString("2");
|
||||
else if (skin == 3) //ZM controlled (cross)
|
||||
SetVariantString("3");
|
||||
|
||||
AcceptEntityInput(Ent, "Skin");
|
||||
DispatchSpawn(Ent);
|
||||
TeleportEntity(Ent, pos, NULL_VECTOR, NULL_VECTOR);
|
||||
ping_ents[index] = Ent;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void RemovePing(int index)
|
||||
{
|
||||
if (ping_ents[index] != -1 && IsValidEdict(ping_ents[index]))
|
||||
{
|
||||
char m_szClassname[64];
|
||||
GetEdictClassname(ping_ents[index], m_szClassname, sizeof(m_szClassname));
|
||||
if (strcmp("prop_dynamic", m_szClassname)==0)
|
||||
{
|
||||
AcceptEntityInput(ping_ents[index], "Kill");
|
||||
}
|
||||
}
|
||||
ping_ents[index] = -1;
|
||||
}
|
||||
|
||||
public void UpdateMarkers()
|
||||
{
|
||||
//this only works because of knowing that order of ping coordinates match with zone order.
|
||||
for (int i = 0; i <= g_zoneCount; i++)
|
||||
{
|
||||
//PrintToChatAll("g_cZones_CT_count[i]: %i", g_cZones_CT_count[i]);
|
||||
//PrintToChatAll("g_cZones_ZM_count[i]: %i", g_cZones_ZM_count[i]);
|
||||
if (g_cZones_CT_count[i] > 0 && g_cZones_ZM_count[i] > 0)
|
||||
{
|
||||
//both humans and ZM in zone.
|
||||
if (g_iZone_fought_or_ct_controlled[i] != 1)
|
||||
{
|
||||
handle_pings(i, 1);
|
||||
g_iZone_fought_or_ct_controlled[i] = 1; //indicating zone is fought over
|
||||
}
|
||||
}
|
||||
else if (g_cZones_CT_count[i] > 0)
|
||||
{
|
||||
//only humans in zone
|
||||
//the zone just went from white (humans and zm in zone) to blue (only humans now in zone)
|
||||
if (g_iZone_fought_or_ct_controlled[i] != 2)
|
||||
{
|
||||
g_iZone_fought_or_ct_controlled[i] = 2;
|
||||
reward_ct_zone_points(i);
|
||||
handle_pings(i, 2);
|
||||
}
|
||||
}
|
||||
else if (g_cZones_ZM_count[i] > 0)
|
||||
{
|
||||
if (g_iZone_fought_or_ct_controlled[i] != 3)
|
||||
{
|
||||
g_iZone_fought_or_ct_controlled[i] = 3;
|
||||
//zm controlled zone
|
||||
handle_pings(i, 3);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_iLast_Client_In_Zone[i] != 0)
|
||||
{
|
||||
int last_client_in_zone = g_iLast_Client_In_Zone[i];
|
||||
if (IsValidClient(last_client_in_zone) && IsPlayerAlive(last_client_in_zone) && GetClientTeam(last_client_in_zone) == CS_TEAM_CT)
|
||||
{
|
||||
//last guy was a CT
|
||||
g_iZone_fought_or_ct_controlled[i] = 2;
|
||||
handle_pings(i, 2);
|
||||
}
|
||||
else if (IsValidClient(last_client_in_zone) && IsPlayerAlive(last_client_in_zone) && GetClientTeam(last_client_in_zone) == CS_TEAM_T)
|
||||
{
|
||||
//last guy was a ZM
|
||||
g_iZone_fought_or_ct_controlled[i] = 3;
|
||||
handle_pings(i, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
//the client who was last here might have left or went spectate.
|
||||
handle_pings(i, 1);
|
||||
g_iZone_fought_or_ct_controlled[i] = 1; //indicating zone is fought over
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//no client was in the zone in this round yet. setting it to the skull ping.
|
||||
handle_pings(i, 1);
|
||||
g_iZone_fought_or_ct_controlled[i] = 1; //indicating zone is fought over
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void reward_ct_zone_points(int i)
|
||||
{
|
||||
for (int j = 0; j < MaxClients; j++)
|
||||
{
|
||||
//is validclient, is ct, is alive, is inside the zone that just changed from fought to CT controlled
|
||||
if (IsValidClient(j) && GetClientTeam(j) == CS_TEAM_CT && IsPlayerAlive(j) && g_client_in_zone[j] == i)
|
||||
{
|
||||
int damage_done_inside_fought_zone = PlayerRankings_GetClientDamage(j) - g_iCT_Damage_in_zone[j];
|
||||
g_iCT_Damage_in_zone[j] = PlayerRankings_GetClientDamage(j);
|
||||
//so uh, lets say the zone becomes CT, then fought over again, then CT again without the guy ever leaving it.
|
||||
//this should ensure it only counts for what the guy did in damage since the takeover
|
||||
if (damage_done_inside_fought_zone > 0)
|
||||
{
|
||||
// Damage 0-1000 inside Zone
|
||||
if (damage_done_inside_fought_zone < 1000)
|
||||
{
|
||||
LH_LogPlayerEvent(j, "triggered", "zh_h_zone_take_over_1", false);
|
||||
}
|
||||
else if (damage_done_inside_fought_zone < 3000)
|
||||
{
|
||||
LH_LogPlayerEvent(j, "triggered", "zh_h_zone_take_over_2", false);
|
||||
}
|
||||
else if (damage_done_inside_fought_zone < 6000)
|
||||
{
|
||||
LH_LogPlayerEvent(j, "triggered", "zh_h_zone_take_over_3", false);
|
||||
}
|
||||
else if (damage_done_inside_fought_zone < 9000)
|
||||
{
|
||||
LH_LogPlayerEvent(j, "triggered", "zh_h_zone_take_over_4", false);
|
||||
}
|
||||
else if (damage_done_inside_fought_zone < 15000)
|
||||
{
|
||||
LH_LogPlayerEvent(j, "triggered", "zh_h_zone_take_over_5", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LH_LogPlayerEvent(j, "triggered", "zh_h_zone_take_over_6", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user