mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-07 10:28:26 +00:00
Added custom airaccelerate zones and some natives. (#797)
Shavit_GetZoneData, Shavit_GetZoneFlags, and Shavit_InsideZoneGetID
This commit is contained in:
parent
b6b78f8eab
commit
a7c743cf29
@ -134,6 +134,18 @@
|
||||
"width" "1.5"
|
||||
}
|
||||
|
||||
"Airaccelerate"
|
||||
{
|
||||
"visible" "1"
|
||||
|
||||
"red" "118"
|
||||
"green" "102"
|
||||
"blue" "173"
|
||||
|
||||
"alpha" "255"
|
||||
"width" "1.5"
|
||||
}
|
||||
|
||||
"Bonus Start"
|
||||
{
|
||||
"visible" "1"
|
||||
@ -253,5 +265,17 @@
|
||||
"alpha" "255"
|
||||
"width" "1.0"
|
||||
}
|
||||
|
||||
"Bonus Airaccelerate"
|
||||
{
|
||||
"visible" "1"
|
||||
|
||||
"red" "118"
|
||||
"green" "102"
|
||||
"blue" "173"
|
||||
|
||||
"alpha" "255"
|
||||
"width" "1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,6 +103,7 @@ enum
|
||||
Zone_CustomSpawn,
|
||||
Zone_Easybhop,
|
||||
Zone_Slide,
|
||||
Zone_Airaccelerate,
|
||||
ZONETYPES_SIZE
|
||||
};
|
||||
|
||||
@ -571,7 +572,7 @@ forward Action Shavit_OnSave(int client);
|
||||
* @param client Client index.
|
||||
* @param type Zone type.
|
||||
* @param track Zone track.
|
||||
* @param id Zone ID. 0 for native zones.
|
||||
* @param id Zone ID.
|
||||
* @param entity Zone trigger entity index.
|
||||
* @noreturn
|
||||
*/
|
||||
@ -583,7 +584,7 @@ forward void Shavit_OnEnterZone(int client, int type, int track, int id, int ent
|
||||
* @param client Client index.
|
||||
* @param type Zone type.
|
||||
* @param track Zone track.
|
||||
* @param id Zone ID. 0 for native zones.
|
||||
* @param id Zone ID.
|
||||
* @param entity Zone trigger entity index.
|
||||
* @noreturn
|
||||
*/
|
||||
@ -979,7 +980,7 @@ native float Shavit_GetTimeForRank(int style, int rank, int track);
|
||||
native bool Shavit_ZoneExists(int type, int track);
|
||||
|
||||
/**
|
||||
* Checks if a player is inside a mapzone
|
||||
* Checks if a player is inside a mapzone.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @param type Mapzone type.
|
||||
@ -988,6 +989,33 @@ native bool Shavit_ZoneExists(int type, int track);
|
||||
*/
|
||||
native bool Shavit_InsideZone(int client, int type, int track);
|
||||
|
||||
/**
|
||||
* Gets the specified zone's data.
|
||||
*
|
||||
* @param zoneid ID of the zone we query the data of.
|
||||
* @return Zone data. 0 if none is specified.
|
||||
*/
|
||||
native int Shavit_GetZoneData(int zoneid);
|
||||
|
||||
/**
|
||||
* Gets the specified zone's flags.
|
||||
*
|
||||
* @param zoneid ID of the zone we query the flags of.
|
||||
* @return Zone flags. 0 if none is specified.
|
||||
*/
|
||||
native int Shavit_GetZoneFlags(int zoneid);
|
||||
|
||||
/**
|
||||
* Checks if a player is inside a mapzone.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @param type Mapzone type.
|
||||
* @param track Mapzone track, -1 to ignore track.
|
||||
* @param zoneid Reference to variable that will hold the zone's ID.
|
||||
* @return Boolean value.
|
||||
*/
|
||||
native bool Shavit_InsideZoneGetID(int client, int type, int track, int &zoneid);
|
||||
|
||||
/**
|
||||
* Checks if a player is in the process of creating a mapzone.
|
||||
*
|
||||
@ -1485,9 +1513,12 @@ public void __pl_shavit_SetNTVOptional()
|
||||
MarkNativeAsOptional("Shavit_GetWRName");
|
||||
MarkNativeAsOptional("Shavit_GetWRRecordID");
|
||||
MarkNativeAsOptional("Shavit_GetWRTime");
|
||||
MarkNativeAsOptional("Shavit_GetZoneData");
|
||||
MarkNativeAsOptional("Shavit_GetZoneFlags");
|
||||
MarkNativeAsOptional("Shavit_HasStyleAccess");
|
||||
MarkNativeAsOptional("Shavit_HijackAngles");
|
||||
MarkNativeAsOptional("Shavit_InsideZone");
|
||||
MarkNativeAsOptional("Shavit_InsideZoneGetID");
|
||||
MarkNativeAsOptional("Shavit_IsClientCreatingZone");
|
||||
MarkNativeAsOptional("Shavit_IsKZMap");
|
||||
MarkNativeAsOptional("Shavit_IsPaused");
|
||||
|
||||
@ -147,6 +147,7 @@ char gS_DeleteMap[MAXPLAYERS+1][160];
|
||||
char gS_WipePlayerID[MAXPLAYERS+1][32];
|
||||
char gS_Verification[MAXPLAYERS+1][16];
|
||||
bool gB_CookiesRetrieved[MAXPLAYERS+1];
|
||||
float gF_ZoneAiraccelerate[MAXPLAYERS+1];
|
||||
|
||||
// flags
|
||||
int gI_StyleFlag[STYLE_LIMIT];
|
||||
@ -2557,11 +2558,37 @@ public void SQL_CreateUsersTable_Callback(Database db, DBResultSet results, cons
|
||||
Call_Finish();
|
||||
}
|
||||
|
||||
public void Shavit_OnEnterZone(int client, int type, int track, int id, int entity)
|
||||
{
|
||||
if(type == Zone_Airaccelerate)
|
||||
{
|
||||
gF_ZoneAiraccelerate[client] = float(Shavit_GetZoneData(id));
|
||||
|
||||
UpdateAiraccelerate(client, gF_ZoneAiraccelerate[client]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Shavit_OnLeaveZone(int client, int type, int track, int id, int entity)
|
||||
{
|
||||
if(type == Zone_Airaccelerate)
|
||||
{
|
||||
UpdateAiraccelerate(client, view_as<float>(gA_StyleSettings[gA_Timers[client].iStyle].fAiraccelerate));
|
||||
}
|
||||
}
|
||||
|
||||
public void PreThinkPost(int client)
|
||||
{
|
||||
if(IsPlayerAlive(client))
|
||||
{
|
||||
if(!gB_Zones || !Shavit_InsideZone(client, Zone_Airaccelerate, -1))
|
||||
{
|
||||
sv_airaccelerate.FloatValue = view_as<float>(gA_StyleSettings[gA_Timers[client].iStyle].fAiraccelerate);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
sv_airaccelerate.FloatValue = gF_ZoneAiraccelerate[client];
|
||||
}
|
||||
|
||||
if(sv_enablebunnyhopping != null)
|
||||
{
|
||||
@ -3003,6 +3030,13 @@ void StopTimer_Cheat(int client, const char[] message)
|
||||
Shavit_PrintToChat(client, "%T", "CheatTimerStop", client, gS_ChatStrings.sWarning, gS_ChatStrings.sText, message);
|
||||
}
|
||||
|
||||
void UpdateAiraccelerate(int client, float airaccelerate)
|
||||
{
|
||||
char sAiraccelerate[8];
|
||||
FloatToString(airaccelerate, sAiraccelerate, 8);
|
||||
sv_airaccelerate.ReplicateToClient(client, sAiraccelerate);
|
||||
}
|
||||
|
||||
void UpdateStyleSettings(int client)
|
||||
{
|
||||
if(sv_autobunnyhopping != null)
|
||||
@ -3015,9 +3049,7 @@ void UpdateStyleSettings(int client)
|
||||
sv_enablebunnyhopping.ReplicateToClient(client, (gA_StyleSettings[gA_Timers[client].iStyle].bEnableBunnyhopping)? "1":"0");
|
||||
}
|
||||
|
||||
char sAiraccelerate[8];
|
||||
FloatToString(gA_StyleSettings[gA_Timers[client].iStyle].fAiraccelerate, sAiraccelerate, 8);
|
||||
sv_airaccelerate.ReplicateToClient(client, sAiraccelerate);
|
||||
UpdateAiraccelerate(client, view_as<float>(gA_StyleSettings[gA_Timers[client].iStyle].fAiraccelerate));
|
||||
|
||||
SetEntityGravity(client, view_as<float>(gA_StyleSettings[gA_Timers[client].iStyle].fGravityMultiplier));
|
||||
}
|
||||
|
||||
@ -54,7 +54,8 @@ char gS_ZoneNames[][] =
|
||||
"Teleport Zone", // teleports to a defined point
|
||||
"SPAWN POINT", // << unused
|
||||
"Easybhop Zone", // forces easybhop whether if the player is in non-easy styles or if the server has different settings
|
||||
"Slide Zone" // allows players to slide, in order to fix parts like the 5th stage of bhop_arcane
|
||||
"Slide Zone", // allows players to slide, in order to fix parts like the 5th stage of bhop_arcane
|
||||
"Custom Airaccelerate" // custom sv_airaccelerate inside this
|
||||
};
|
||||
|
||||
enum struct zone_cache_t
|
||||
@ -98,6 +99,7 @@ bool gB_SnapToWall[MAXPLAYERS+1];
|
||||
bool gB_CursorTracing[MAXPLAYERS+1];
|
||||
int gI_ZoneFlags[MAXPLAYERS+1];
|
||||
int gI_ZoneData[MAXPLAYERS+1];
|
||||
bool gB_WaitingForChatInput[MAXPLAYERS+1];
|
||||
|
||||
// cache
|
||||
float gV_Point1[MAXPLAYERS+1][3];
|
||||
@ -173,7 +175,10 @@ public Plugin myinfo =
|
||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||
{
|
||||
// zone natives
|
||||
CreateNative("Shavit_GetZoneData", Native_GetZoneData);
|
||||
CreateNative("Shavit_GetZoneFlags", Native_GetZoneFlags);
|
||||
CreateNative("Shavit_InsideZone", Native_InsideZone);
|
||||
CreateNative("Shavit_InsideZoneGetID", Native_InsideZoneGetID);
|
||||
CreateNative("Shavit_IsClientCreatingZone", Native_IsClientCreatingZone);
|
||||
CreateNative("Shavit_ZoneExists", Native_ZoneExists);
|
||||
CreateNative("Shavit_Zones_DeleteMap", Native_Zones_DeleteMap);
|
||||
@ -422,11 +427,42 @@ public int Native_ZoneExists(Handle handler, int numParams)
|
||||
return (GetZoneIndex(GetNativeCell(1), GetNativeCell(2)) != -1);
|
||||
}
|
||||
|
||||
public int Native_GetZoneData(Handle handler, int numParams)
|
||||
{
|
||||
return gA_ZoneCache[GetNativeCell(1)].iZoneData;
|
||||
}
|
||||
|
||||
public int Native_GetZoneFlags(Handle handler, int numParams)
|
||||
{
|
||||
return gA_ZoneCache[GetNativeCell(1)].iZoneFlags;
|
||||
}
|
||||
|
||||
public int Native_InsideZone(Handle handler, int numParams)
|
||||
{
|
||||
return InsideZone(GetNativeCell(1), GetNativeCell(2), GetNativeCell(3));
|
||||
}
|
||||
|
||||
public int Native_InsideZoneGetID(Handle handler, int numParams)
|
||||
{
|
||||
int client = GetNativeCell(1);
|
||||
int iType = GetNativeCell(2);
|
||||
int iTrack = GetNativeCell(3);
|
||||
|
||||
for(int i = 0; i < MAX_ZONES; i++)
|
||||
{
|
||||
if(gB_InsideZoneID[client][i] &&
|
||||
gA_ZoneCache[i].iZoneType == iType &&
|
||||
(gA_ZoneCache[i].iZoneTrack == iTrack || iTrack == -1))
|
||||
{
|
||||
SetNativeCellRef(4, i);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public int Native_Zones_DeleteMap(Handle handler, int numParams)
|
||||
{
|
||||
char sMap[160];
|
||||
@ -1601,6 +1637,7 @@ void Reset(int client)
|
||||
gI_ZoneFlags[client] = 0;
|
||||
gI_ZoneData[client] = 0;
|
||||
gI_ZoneDatabaseID[client] = -1;
|
||||
gB_WaitingForChatInput[client] = false;
|
||||
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
@ -1936,6 +1973,16 @@ public int CreateZoneConfirm_Handler(Menu menu, MenuAction action, int param1, i
|
||||
UpdateTeleportZone(param1);
|
||||
}
|
||||
|
||||
else if(StrEqual(sInfo, "datafromchat"))
|
||||
{
|
||||
gI_ZoneData[param1] = 0;
|
||||
gB_WaitingForChatInput[param1] = true;
|
||||
|
||||
Shavit_PrintToChat(param1, "%T", "ZoneEnterDataChat", param1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
else if(StrEqual(sInfo, "forcerender"))
|
||||
{
|
||||
gI_ZoneFlags[param1] ^= ZF_ForceRender;
|
||||
@ -1952,6 +1999,19 @@ public int CreateZoneConfirm_Handler(Menu menu, MenuAction action, int param1, i
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Action OnClientSayCommand(int client, const char[] command, const char[] sArgs)
|
||||
{
|
||||
if(gB_WaitingForChatInput[client] && gI_MapStep[client] == 3)
|
||||
{
|
||||
gI_ZoneData[client] = StringToInt(sArgs);
|
||||
CreateEditMenu(client);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
void GetTrackName(int client, int track, char[] output, int size)
|
||||
{
|
||||
if(track < 0 || track >= TRACKS_SIZE)
|
||||
@ -2038,6 +2098,12 @@ void CreateEditMenu(int client)
|
||||
FormatEx(sMenuItem, 64, "%T", "ZoneForceRender", client, ((gI_ZoneFlags[client] & ZF_ForceRender) > 0)? 'x':' ');
|
||||
menu.AddItem("forcerender", sMenuItem);
|
||||
|
||||
if(gI_ZoneType[client] == Zone_Airaccelerate)
|
||||
{
|
||||
FormatEx(sMenuItem, 64, "%T", "ZoneSetAiraccelerate", client, gI_ZoneData[client]);
|
||||
menu.AddItem("datafromchat", sMenuItem);
|
||||
}
|
||||
|
||||
menu.ExitButton = true;
|
||||
menu.Display(client, 600);
|
||||
}
|
||||
|
||||
@ -184,6 +184,15 @@
|
||||
"#format" "{1:c}"
|
||||
"en" "[{1}] Force zone drawing"
|
||||
}
|
||||
"ZoneSetAiraccelerate"
|
||||
{
|
||||
"#format" "{1:d}"
|
||||
"en" "Airaccelerate: {1}"
|
||||
}
|
||||
"ZoneEnterDataChat"
|
||||
{
|
||||
"en" "Input your desired data in chat."
|
||||
}
|
||||
"ZoneSetNo"
|
||||
{
|
||||
"en" "No"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user