Skip to content

Commit

Permalink
Add handling for func_rot_button zones
Browse files Browse the repository at this point in the history
  • Loading branch information
rtldg committed Feb 16, 2025
1 parent 94ebb97 commit 04ad339
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/include/shavit/zones.inc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ enum
enum
{
ZF_ForceRender = (1 << 0),
ZF_Hammerid = (1 << 1), // used by ZoneForm_{trigger_{multiple, teleport}, func_button} sometimes
ZF_Hammerid = (1 << 1), // used by ZoneForm_{trigger_{multiple, teleport}, func_[rot_]button} sometimes
ZF_Solid = (1 << 2), // forces the zone to physically block people...
ZF_Origin = (1 << 4), // sTarget is the entity's origin formatted as "%X %X %X"
};
Expand Down
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/shavit-zones-json.sp
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ JSONObject FillYourMom(zone_cache_t cache)
public Action Command_DumpZones(int client, int args)
{
int count = Shavit_GetZoneCount();

if (!count)
{
ReplyToCommand(client, "Map doesn't have any zones...");
Expand Down Expand Up @@ -582,7 +582,7 @@ int MenuHandler_MapInfo(Menu menu, MenuAction action, int param1, int param2)
++empties;
continue;
}

for (; empties; --empties)
arr.Push(empty);
arr.Push(obj);
Expand Down
24 changes: 22 additions & 2 deletions addons/sourcemod/scripting/shavit-zones.sp
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n
}

if (convar.BoolValue) add_prebuilts_to_cache("func_button", true);
if (convar.BoolValue) add_prebuilts_to_cache("func_rot_button", true);
}
}

Expand Down Expand Up @@ -1219,6 +1220,7 @@ public void Shavit_LoadZonesHere()
if (gCV_ClimbButtons.BoolValue)
{
add_prebuilts_to_cache("func_button", true);
add_prebuilts_to_cache("func_rot_button", true);
}
}

Expand Down Expand Up @@ -1329,6 +1331,7 @@ public void OnGameFrame()
if (search_func_button)
{
FindEntitiesToHook("func_button", ZoneForm_func_button);
FindEntitiesToHook("func_rot_button", ZoneForm_func_button);
}
}

Expand Down Expand Up @@ -3017,6 +3020,23 @@ void OpenHookMenu_List(int client, int form, int pos = 0)
list.PushArray(thing);
}

// copy & paste for func_rot_button because it's shrimple and I can't think of how to do it cleanly otherwise right now
if (form == ZoneForm_func_button)
{
while ((ent = FindEntityByClassname(ent, "func_rot_button")) != -1)
{
if (gI_EntityZone[ent] > -1) continue;

float ent_origin[3];
GetEntPropVector(ent, Prop_Send, "m_vecOrigin", ent_origin);

ent_list_thing thing;
thing.dist = GetVectorDistance(player_origin, ent_origin);
thing.ent = ent;
list.PushArray(thing);
}
}

if (!list.Length)
{
Shavit_PrintToChat(client, "No unhooked entities found");
Expand Down Expand Up @@ -3067,7 +3087,7 @@ bool TeleportFilter(int entity)
char classname[20];
GetEntityClassname(entity, classname, sizeof(classname));

if (StrEqual(classname, "trigger_teleport") || StrEqual(classname, "trigger_multiple") || StrEqual(classname, "func_button"))
if (StrEqual(classname, "trigger_teleport") || StrEqual(classname, "trigger_multiple") || StrEqual(classname, "func_button") || StrEqual("func_rot_button"))
{
//TR_ClipCurrentRayToEntity(MASK_ALL, entity);
gI_CurrentTraceEntity = entity;
Expand Down Expand Up @@ -3116,7 +3136,7 @@ public int MenuHandle_HookZone_Form(Menu menu, MenuAction action, int param1, in
char classname[32];
GetEntityClassname(ent, classname, sizeof(classname));

if (StrEqual(classname, "func_button"))
if (StrEqual(classname, "func_button") || StrEqual(classname, "func_rot_button"))
{
form = ZoneForm_func_button;
}
Expand Down

0 comments on commit 04ad339

Please sign in to comment.