mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Add antiping_grenade
This commit is contained in:
parent
40569651fb
commit
9f45368225
|
@ -98,31 +98,23 @@ void CItems::RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID)
|
||||||
|
|
||||||
IGraphics::CQuadItem QuadItem(Pos.x, Pos.y, 32, 32);
|
IGraphics::CQuadItem QuadItem(Pos.x, Pos.y, 32, 32);
|
||||||
|
|
||||||
if (g_Config.m_ClAntiPing)
|
if (g_Config.m_ClAntiPingGrenade)
|
||||||
{
|
{
|
||||||
static int Average_Offset = -1;
|
// Draw shadows of grenades
|
||||||
static float Offset_Count = 0;
|
bool LocalPlayerInGame = m_pClient->m_aClients[m_pClient->m_Snap.m_pLocalInfo->m_ClientID].m_Team != -1;
|
||||||
static float Offset_Sum = 0;
|
static float Offset = 1;
|
||||||
|
Offset = mix(Offset, (float)(Client()->PredGameTick() - Client()->GameTick()), 0.05);
|
||||||
|
|
||||||
// Calculate average prediction offset, because client_predtick() gets varial values :(((
|
if(LocalPlayerInGame && !m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)
|
||||||
// Must be there is a normal way to realize it, but I'm too lazy to find it. ^)
|
|
||||||
if (Average_Offset == -1)
|
|
||||||
{
|
{
|
||||||
int Offset = Client()->PredGameTick() - Client()->GameTick();
|
// Draw shadow only if grenade directed to local player
|
||||||
Offset_Sum += Offset;
|
CNetObj_CharacterCore& CurChar = m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_pLocalInfo->m_ClientID].m_Cur;
|
||||||
Offset_Count++;
|
CNetObj_CharacterCore& PrevChar = m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_pLocalInfo->m_ClientID].m_Prev;
|
||||||
|
vec2 ServerPos = mix(vec2(PrevChar.m_X, PrevChar.m_Y), vec2(CurChar.m_X, CurChar.m_Y), Client()->IntraGameTick());
|
||||||
|
|
||||||
if (Offset_Count >= 100)
|
int PredictedTick = Client()->PrevGameTick() + Offset;
|
||||||
{
|
|
||||||
Average_Offset = round(Offset_Sum / Offset_Count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int PredictedTick = Client()->PrevGameTick() + Average_Offset;
|
|
||||||
float PredictedCt = (PredictedTick - pCurrent->m_StartTick)/(float)SERVER_TICK_SPEED + Client()->GameTickTime();
|
float PredictedCt = (PredictedTick - pCurrent->m_StartTick)/(float)SERVER_TICK_SPEED + Client()->GameTickTime();
|
||||||
|
|
||||||
if (PredictedCt >= 0)
|
|
||||||
{
|
|
||||||
int shadow_type = pCurrent->m_Type;
|
int shadow_type = pCurrent->m_Type;
|
||||||
RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[clamp(shadow_type, 0, NUM_WEAPONS-1)].m_pSpriteProj);
|
RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[clamp(shadow_type, 0, NUM_WEAPONS-1)].m_pSpriteProj);
|
||||||
|
|
||||||
|
|
|
@ -1084,11 +1084,17 @@ void CMenus::RenderSettingsDDRace(CUIRect MainView)
|
||||||
}
|
}
|
||||||
|
|
||||||
MainView.HSplitTop(20.0f, &Button, &MainView);
|
MainView.HSplitTop(20.0f, &Button, &MainView);
|
||||||
if(DoButton_CheckBox(&g_Config.m_ClAntiPing, Localize("AntiPing (predict grenades and other players)"), g_Config.m_ClAntiPing, &Button))
|
if(DoButton_CheckBox(&g_Config.m_ClAntiPing, Localize("AntiPing (predict other players)"), g_Config.m_ClAntiPing, &Button))
|
||||||
{
|
{
|
||||||
g_Config.m_ClAntiPing ^= 1;
|
g_Config.m_ClAntiPing ^= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MainView.HSplitTop(20.0f, &Button, &MainView);
|
||||||
|
if(DoButton_CheckBox(&g_Config.m_ClAntiPingGrenade, Localize("AntiPing (predict grenades)"), g_Config.m_ClAntiPingGrenade, &Button))
|
||||||
|
{
|
||||||
|
g_Config.m_ClAntiPingGrenade ^= 1;
|
||||||
|
}
|
||||||
|
|
||||||
CUIRect aRects[2];
|
CUIRect aRects[2];
|
||||||
CUIRect Label;
|
CUIRect Label;
|
||||||
MainView.HSplitTop(5.0f, 0, &MainView);
|
MainView.HSplitTop(5.0f, 0, &MainView);
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
|
|
||||||
// client
|
// client
|
||||||
MACRO_CONFIG_INT(ClPredict, cl_predict, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict client movements")
|
MACRO_CONFIG_INT(ClPredict, cl_predict, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict client movements")
|
||||||
MACRO_CONFIG_INT(ClAntiPing, cl_antiping, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (predict other players' movements")
|
MACRO_CONFIG_INT(ClAntiPing, cl_antiping, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (predict other players' movements)")
|
||||||
|
MACRO_CONFIG_INT(ClAntiPingGrenade, cl_antiping_grenade, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (predict grenades)")
|
||||||
MACRO_CONFIG_INT(ClNameplates, cl_nameplates, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show name plates")
|
MACRO_CONFIG_INT(ClNameplates, cl_nameplates, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show name plates")
|
||||||
MACRO_CONFIG_INT(ClNameplatesAlways, cl_nameplates_always, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Always show name plates disregarding of distance")
|
MACRO_CONFIG_INT(ClNameplatesAlways, cl_nameplates_always, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Always show name plates disregarding of distance")
|
||||||
MACRO_CONFIG_INT(ClNameplatesTeamcolors, cl_nameplates_teamcolors, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Use team colors for name plates")
|
MACRO_CONFIG_INT(ClNameplatesTeamcolors, cl_nameplates_teamcolors, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Use team colors for name plates")
|
||||||
|
|
Loading…
Reference in a new issue