mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-07 02:18:26 +00:00
add angle diff to Shavit_GetReplayButtons
This commit is contained in:
parent
435a23f065
commit
ec3e4d2d84
@ -534,6 +534,12 @@ stock int GetSpectatorTarget(int client, int fallback = -1)
|
||||
return target;
|
||||
}
|
||||
|
||||
stock float GetAngleDiff(float current, float previous)
|
||||
{
|
||||
float diff = current - previous;
|
||||
return diff - 360.0 * RoundToFloor((diff + 180.0) / 360.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before shavit-core processes the client's usercmd.
|
||||
* Before this is called, safety checks (fake/dead clients) happen.
|
||||
@ -1558,9 +1564,11 @@ native int Shavit_GetReplayStarter(int ent);
|
||||
* Really, this is only useful for things like replay props.
|
||||
*
|
||||
* @param ent Replay entity.
|
||||
* @param anglediff The angle difference between the previous and current y angles.
|
||||
*
|
||||
* @return buttons
|
||||
*/
|
||||
native int Shavit_GetReplayButtons(int ent);
|
||||
native int Shavit_GetReplayButtons(int ent, float& anglediff);
|
||||
|
||||
/**
|
||||
* Retrieves a replay's frame count.
|
||||
|
||||
@ -392,9 +392,7 @@ void MakeAngleDiff(int client, float newAngle)
|
||||
{
|
||||
gF_PreviousAngle[client] = gF_Angle[client];
|
||||
gF_Angle[client] = newAngle;
|
||||
|
||||
float fAngleDiff = newAngle - gF_PreviousAngle[client];
|
||||
gF_AngleDiff[client] = fAngleDiff - 360.0 * RoundToFloor((fAngleDiff + 180.0) / 360.0);
|
||||
gF_AngleDiff[client] = GetAngleDiff(newAngle, gF_PreviousAngle[client]);
|
||||
}
|
||||
|
||||
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style)
|
||||
@ -1590,7 +1588,19 @@ void UpdateKeyOverlay(int client, Panel panel, bool &draw)
|
||||
return;
|
||||
}
|
||||
|
||||
int buttons = IsValidClient(target) ? gI_Buttons[target] : Shavit_GetReplayButtons(target);
|
||||
float fAngleDiff;
|
||||
int buttons;
|
||||
|
||||
if (IsValidClient(target))
|
||||
{
|
||||
fAngleDiff = gF_AngleDiff[target];
|
||||
buttons = gI_Buttons[target];
|
||||
}
|
||||
else
|
||||
{
|
||||
buttons = Shavit_GetReplayButtons(target, fAngleDiff);
|
||||
}
|
||||
|
||||
int style = (gB_Replay && Shavit_IsReplayEntity(target))? Shavit_GetReplayBotStyle(target):Shavit_GetBhopStyle(target);
|
||||
|
||||
if(!(0 <= style < gI_Styles))
|
||||
@ -1607,8 +1617,6 @@ void UpdateKeyOverlay(int client, Panel panel, bool &draw)
|
||||
FormatEx(sPanelLine, 64, " %d%s%d\n", gI_ScrollCount[target], (gI_ScrollCount[target] > 9)? " ":" ", gI_LastScrollCount[target]);
|
||||
}
|
||||
|
||||
float fAngleDiff = IsValidClient(target) ? gF_AngleDiff[target] : 0.0;
|
||||
|
||||
Format(sPanelLine, 128, "%s[%s] [%s]\n%s %s %s\n%s %s %s\n %s %s", sPanelLine,
|
||||
(buttons & IN_JUMP) > 0? "J":"ー", (buttons & IN_DUCK) > 0? "C":"ー",
|
||||
(fAngleDiff > 0) ? "←":" ", (buttons & IN_FORWARD) > 0 ? "W":"ー", (fAngleDiff < 0) ? "→":"",
|
||||
@ -1656,8 +1664,18 @@ void UpdateCenterKeys(int client)
|
||||
return;
|
||||
}
|
||||
|
||||
int buttons = IsValidClient(target) ? gI_Buttons[target] : Shavit_GetReplayButtons(target);
|
||||
float fAngleDiff = IsValidClient(target) ? gF_AngleDiff[target] : 0.0;
|
||||
float fAngleDiff;
|
||||
int buttons;
|
||||
|
||||
if (IsValidClient(target))
|
||||
{
|
||||
fAngleDiff = gF_AngleDiff[target];
|
||||
buttons = gI_Buttons[target];
|
||||
}
|
||||
else
|
||||
{
|
||||
buttons = Shavit_GetReplayButtons(target, fAngleDiff);
|
||||
}
|
||||
|
||||
char sCenterText[80];
|
||||
FormatEx(sCenterText, sizeof(sCenterText), " %s %s\n%s %s %s\n%s %s %s\n %s %s",
|
||||
|
||||
@ -1264,7 +1264,11 @@ public int Native_GetReplayButtons(Handle handler, int numParams)
|
||||
}
|
||||
|
||||
frame_t aFrame;
|
||||
gA_BotInfo[bot].aCache.aFrames.GetArray(gA_BotInfo[bot].iTick ? gA_BotInfo[bot].iTick-1 : 0, aFrame, 6);
|
||||
float prevAngle = aFrame.ang[1];
|
||||
gA_BotInfo[bot].aCache.aFrames.GetArray(gA_BotInfo[bot].iTick, aFrame, 6);
|
||||
|
||||
SetNativeCellRef(2, GetAngleDiff(aFrame.ang[1], prevAngle));
|
||||
return aFrame.buttons;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user