mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 09:33:20 +00:00
Update hide and seek
This commit is contained in:
parent
04670575be
commit
f6b51ee495
5 changed files with 222 additions and 79 deletions
|
@ -41,7 +41,7 @@ public Action Command_HideAndSeek(int client, int args) {
|
|||
}
|
||||
Cleanup();
|
||||
SetupEntities(isNavBlockersEnabled, isPropsEnabled, isPortalsEnabled);
|
||||
ReplyToCommand(client, "Set the current set to \"%s\"", currentSet);
|
||||
PrintToChatAll("[H&S] Map set has been changed to \"%s\"", currentSet);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
}
|
||||
|
@ -216,9 +216,19 @@ public Action Command_HideAndSeek(int client, int args) {
|
|||
}
|
||||
if(IsBotsEnabled()) ReplyToCommand(client, "Bots are enabled");
|
||||
else ReplyToCommand(client, "Bots are disabled");
|
||||
} else if(StrEqual(subcmd, "peek")) {
|
||||
SetPeekCamTarget(client);
|
||||
SetPeekCamActive(client, !IsPeekCamActive(client));
|
||||
} else if(StrEqual(subcmd, "peekfix")) {
|
||||
if(seekerCam == INVALID_ENT_REFERENCE) {
|
||||
SetPeekCamTarget(client);
|
||||
}
|
||||
|
||||
for(int i = 1; i <= MaxClients; i++) {
|
||||
if(IsClientConnected(i) && IsClientInGame(i)) {
|
||||
SetPeekCamActive(client, false);
|
||||
SetPeekCamActive(client, false);
|
||||
}
|
||||
}
|
||||
AcceptEntityInput(seekerCam, "Kill");
|
||||
ReplyToCommand(client, "Killing active camera");
|
||||
} else if(StrEqual(subcmd, "seeker")) {
|
||||
if(args == 2) {
|
||||
char arg1[32];
|
||||
|
@ -240,8 +250,7 @@ public Action Command_HideAndSeek(int client, int args) {
|
|||
ReplyToTargetError(client, target_count);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
SetSlasher(target_list[0]);
|
||||
SetSlasher(target_list[0], true);
|
||||
ReplyToCommand(client, "Set the current seeker to %N", target_list[0]);
|
||||
} else {
|
||||
ReplyToCommand(client, "The current seeker is: %N", GetSlasher());
|
||||
|
@ -264,17 +273,24 @@ public Action Command_HideAndSeek(int client, int args) {
|
|||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
ReplyToCommand(client, " - Hide & Seek Commands -");
|
||||
ReplyToCommand(client, "toggle <blockers/props/all>: Toggles all specified");
|
||||
ReplyToCommand(client, "set [new set]: Change the prop set or view current");
|
||||
ReplyToCommand(client, "clear <props/blockers/all>: Clear all specified");
|
||||
ReplyToCommand(client, "settime [seconds]: Sets the time override for the map");
|
||||
ReplyToCommand(client, "settick [tick]: Sets the current tick timer value");
|
||||
ReplyToCommand(client, "setspawn: Sets the temporary spawnpoint for the map");
|
||||
ReplyToCommand(client, " === [ Hide & Seek Commands ] ===");
|
||||
if(GetUserAdmin(client) != INVALID_ADMIN_ID) {
|
||||
ReplyToCommand(client, "- Dev Commands -");
|
||||
ReplyToCommand(client, "r/reload [force]: Reloads map config from file");
|
||||
ReplyToCommand(client, "toggle <blockers/props/all>: Toggles all specified entities");
|
||||
ReplyToCommand(client, "clear <props/blockers/all>: Clear all specified");
|
||||
ReplyToCommand(client, "settime [seconds]: Sets the time override for the map");
|
||||
ReplyToCommand(client, "settick [tick]: Sets the current tick timer value");
|
||||
ReplyToCommand(client, "- Admin Commands -");
|
||||
ReplyToCommand(client, "set [new set]: Change the prop set or view current");
|
||||
ReplyToCommand(client, "setspawn: Sets the temporary spawnpoint for the map");
|
||||
ReplyToCommand(client, "bots [toggle, [value]]: View if bots are enabled, or turn them on");
|
||||
ReplyToCommand(client, "peekfix - Clear peek camera from all players");
|
||||
ReplyToCommand(client, "seeker [new seeker]: Get the active seeker, or set a new one.");
|
||||
ReplyToCommand(client, "sm_cvar hs_peekcam <0/2> - Turn the peek camera on or off");
|
||||
ReplyToCommand(client, "- User Commands -");
|
||||
}
|
||||
ReplyToCommand(client, "stuck: Teleports you to spawn to unstuck yourself");
|
||||
ReplyToCommand(client, "bots [toggle, [value]]: View if bots are enabled, or turn them on");
|
||||
ReplyToCommand(client, "seeker [new seeker]: Get the active seeker, or set a new one.");
|
||||
ReplyToCommand(client, "peek - debug cmd");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,18 +33,22 @@ bool ReloadMapDB() {
|
|||
}
|
||||
|
||||
|
||||
|
||||
bool LoadConfigForMap(const char[] map) {
|
||||
kv.Rewind();
|
||||
if (kv.JumpToKey(map)) {
|
||||
PrintToServer("[H&S] Loading config data for set %s on %s", currentSet, map);
|
||||
MapConfig config;
|
||||
config.entities = new ArrayList(sizeof(EntityConfig));
|
||||
config.inputs = new ArrayList(ByteCountToCells(64));
|
||||
validSets.Clear();
|
||||
|
||||
static char buffer[64];
|
||||
if(StrEqual(currentSet, "default") && kv.GetString("defaultset", buffer, sizeof(buffer))) {
|
||||
strcopy(currentSet, sizeof(currentSet), buffer);
|
||||
}
|
||||
PrintToServer("[H&S] Loading config data for set %s on %s", currentSet, map);
|
||||
|
||||
if(kv.JumpToKey("ents")) {
|
||||
kv.GotoFirstSubKey();
|
||||
char entSet[16];
|
||||
do {
|
||||
EntityConfig entCfg;
|
||||
kv.GetVector("origin", entCfg.origin, NULL_VECTOR);
|
||||
|
@ -55,17 +59,16 @@ bool LoadConfigForMap(const char[] map) {
|
|||
Format(entCfg.model, sizeof(entCfg.model), "models/%s", entCfg.model);
|
||||
kv.GetVector("scale", entCfg.scale, DEFAULT_SCALE);
|
||||
kv.GetVector("offset", entCfg.offset, NULL_VECTOR);
|
||||
kv.GetString("set", entSet, sizeof(entSet), "default");
|
||||
if(validSets.FindString(entSet) == -1) {
|
||||
validSets.PushString(entSet);
|
||||
kv.GetString("set", buffer, sizeof(buffer), "default");
|
||||
if(validSets.FindString(buffer) == -1) {
|
||||
validSets.PushString(buffer);
|
||||
}
|
||||
char debug_str[64];
|
||||
if(StrEqual(entSet, "default") || StrEqual(currentSet, entSet, false)) {
|
||||
if(StrEqual(buffer, "default") || StrEqual(currentSet, buffer, false)) {
|
||||
|
||||
config.entities.PushArray(entCfg);
|
||||
} else {
|
||||
kv.GetSectionName(debug_str, sizeof(debug_str));
|
||||
PrintToServer("Skipping %s", debug_str);
|
||||
kv.GetSectionName(buffer, sizeof(buffer));
|
||||
PrintToServer("Skipping %s", buffer);
|
||||
}
|
||||
} while (kv.GotoNextKey());
|
||||
// JumpToKey and GotoFirstSubKey both traverse, i guess, go back
|
||||
|
@ -74,7 +77,6 @@ bool LoadConfigForMap(const char[] map) {
|
|||
}
|
||||
if(kv.JumpToKey("inputs")) {
|
||||
kv.GotoFirstSubKey(false);
|
||||
static char buffer[64];
|
||||
do {
|
||||
kv.GetSectionName(buffer, sizeof(buffer));
|
||||
config.inputs.PushString(buffer);
|
||||
|
@ -110,6 +112,18 @@ bool LoadConfigForMap(const char[] map) {
|
|||
kv.GetString("buttons", buf, sizeof(buf));
|
||||
config.pressButtons = !StrEqual(buf, "no");
|
||||
mapTime = kv.GetNum("maptime", 0);
|
||||
if(kv.JumpToKey("inputs")) {
|
||||
kv.GotoFirstSubKey(false);
|
||||
do {
|
||||
kv.GetSectionName(buffer, sizeof(buffer));
|
||||
config.inputs.PushString(buffer);
|
||||
|
||||
kv.GetString(NULL_STRING, buffer, sizeof(buffer));
|
||||
config.inputs.PushString(buffer);
|
||||
} while (kv.GotoNextKey(false));
|
||||
kv.GoBack();
|
||||
kv.GoBack();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -164,4 +178,23 @@ bool LoadConfigForMap(const char[] map) {
|
|||
PrintToServer("[H&S] No map config exists for %s", map);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int COLOR_GREY[4] = { 194, 197, 204, 255 };
|
||||
int COLOR_GREEN[4] = { 0, 128, 0, 255 };
|
||||
|
||||
void ShowBeacon(int target, float radius = 100.0) {
|
||||
float vec[3];
|
||||
GetClientAbsOrigin(target, vec);
|
||||
vec[2] += 10;
|
||||
|
||||
if (g_BeamSprite > -1 && g_HaloSprite > -1) {
|
||||
TE_SetupBeamRingPoint(vec, 10.0, radius, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, COLOR_GREY, 10, 0);
|
||||
TE_SendToAll();
|
||||
TE_SetupBeamRingPoint(vec, 10.0, radius, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, COLOR_GREEN, 10, 0);
|
||||
TE_SendToAll();
|
||||
}
|
||||
|
||||
GetClientEyePosition(target, vec);
|
||||
EmitAmbientSound("buttons/button17.wav", vec, target, SNDLEVEL_RAIDSIREN);
|
||||
}
|
|
@ -60,7 +60,10 @@ int FindSlasher() {
|
|||
return -1;
|
||||
}
|
||||
|
||||
void SetSlasher(int client) {
|
||||
void SetSlasher(int client, bool ignoreBalance = false) {
|
||||
if(ignoreBalance) {
|
||||
ignoreSeekerBalance = true;
|
||||
}
|
||||
GameState state = GetState();
|
||||
char buf[128];
|
||||
for(int i = 1; i <= MaxClients; i++) {
|
||||
|
@ -198,7 +201,21 @@ void SetParent(int child, int parent) {
|
|||
AcceptEntityInput(child, "SetParent", parent);
|
||||
}
|
||||
|
||||
void SetPeekCamTarget(int target, int src = 0) {
|
||||
void SetParentAttachment(int child, const char[] attachment, bool withOffset = false) {
|
||||
SetVariantString(attachment);
|
||||
if(withOffset)
|
||||
AcceptEntityInput(child, "SetParentAttachmentMaintainOffset");
|
||||
else
|
||||
AcceptEntityInput(child, "SetParentAttachment");
|
||||
}
|
||||
|
||||
void ClearParent(int child) {
|
||||
AcceptEntityInput(child, "ClearParent");
|
||||
}
|
||||
|
||||
static float EMPTY_ANG[3] = { 0.0, 0.0, 0.0 };
|
||||
|
||||
void SetPeekCamTarget(int target, bool showFPOV = false) {
|
||||
if(seekerCam == INVALID_ENT_REFERENCE || !IsValidEntity(seekerCam)) {
|
||||
seekerCam = CreateEntityByName("point_viewcontrol_survivor");
|
||||
DispatchKeyValue(seekerCam, "targetname", "hscam");
|
||||
|
@ -206,24 +223,19 @@ void SetPeekCamTarget(int target, int src = 0) {
|
|||
for(int i = 0; i <= MaxClients; i++) {
|
||||
isViewingCam[i] = false;
|
||||
}
|
||||
PrintToServer("created new peek cam %d", seekerCam);
|
||||
}
|
||||
|
||||
AcceptEntityInput(seekerCam, "ClearParent");
|
||||
AcceptEntityInput(seekerCam, "Disable");
|
||||
|
||||
float pos[3], endPos[3], ang[3];
|
||||
GetClientEyePosition(target, pos);
|
||||
GetClientEyeAngles(target, ang);
|
||||
if(src) {
|
||||
pos[2] += 20.0;
|
||||
if(showFPOV) {
|
||||
TeleportEntity(seekerCam, pos, ang, NULL_VECTOR);
|
||||
// SetParent(seekerCam, src);
|
||||
SetParent(seekerCam, target);
|
||||
SetParentAttachment(seekerCam, "primary", false);
|
||||
} else {
|
||||
/*GetHorizontalPositionFromClient(target, -20.0, endPos);
|
||||
endPos[2] += 80.0;
|
||||
TeleportEntity(seekerCam, endPos, ang, NULL_VECTOR);
|
||||
SetParent(seekerCam, target);*/
|
||||
|
||||
TR_TraceRayFilter(pos, ang, CONTENTS_PLAYERCLIP | MASK_SOLID | MASK_VISIBLE, RayType_Infinite, Filter_IgnoreAll);
|
||||
if(TR_DidHit()) {
|
||||
TR_GetEndPosition(endPos);
|
||||
|
@ -237,13 +249,27 @@ void SetPeekCamTarget(int target, int src = 0) {
|
|||
ang[0] = RadToDeg(ArcTangent(deltaC / GetVectorDistance(endPos, pos, false) ));
|
||||
ang[1] = RadToDeg(ArcTangent2(deltaA, deltaB));
|
||||
|
||||
// pos[2] += 50.0;
|
||||
// GetAnglesLookAt(seekerCam, target, ang);
|
||||
TeleportEntity(seekerCam, endPos, ang, NULL_VECTOR);
|
||||
// SetParent(seekerCam, target);*/
|
||||
}
|
||||
}
|
||||
|
||||
bool IsPeekCamActive(int client) {
|
||||
return isViewingCam[client];
|
||||
}
|
||||
|
||||
// int GetClientsInRange(const float origin[3], ClientRangeType rangeType, int[] clients, int size)
|
||||
void SetPeekCamActive(int client, bool active) {
|
||||
if(seekerCam != INVALID_ENT_REFERENCE) {
|
||||
AcceptEntityInput(seekerCam, "Enable", client); // Need to always activate before deactivating to fix a semi-common bug
|
||||
if(!active)
|
||||
AcceptEntityInput(seekerCam, "Disable", client);
|
||||
} else {
|
||||
PrintToServer("WARN: SetPeekCamActive(%d, %b) when seekerCam invalid", client, active);
|
||||
}
|
||||
isViewingCam[client] = active;
|
||||
}
|
||||
|
||||
|
||||
stock void GetAnglesLookAt(int iClient, int iTarget, float fFinalPos[3]) {
|
||||
static float fTargetPos[3];
|
||||
static float fTargetAngles[3];
|
||||
|
@ -279,21 +305,4 @@ stock void GetViewVector(float fVecAngle[3], float fOutPut[3])
|
|||
|
||||
bool Filter_IgnoreAll(int entity, int mask) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsPeekCamActive(int client) {
|
||||
return isViewingCam[client];
|
||||
}
|
||||
|
||||
// int GetClientsInRange(const float origin[3], ClientRangeType rangeType, int[] clients, int size)
|
||||
void SetPeekCamActive(int client, bool active) {
|
||||
if(seekerCam != INVALID_ENT_REFERENCE) {
|
||||
if(active)
|
||||
AcceptEntityInput(seekerCam, "Enable", client);
|
||||
else
|
||||
AcceptEntityInput(seekerCam, "Disable", client);
|
||||
} else {
|
||||
PrintToServer("warn: SetPeekCamActive(%d, %b) when seekerCam invalid", client, active);
|
||||
}
|
||||
isViewingCam[client] = active;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue