mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #2361
2361: Fix /spec hook and moving SpecTees r=def- a=edg-l Fixes https://github.com/ddnet/ddnet/issues/2360 Co-authored-by: Edgar <git@edgarluque.com>
This commit is contained in:
commit
1af1d56e24
|
@ -273,6 +273,10 @@ Objects = [
|
||||||
NetObjectEx("SpecChar", "spec-char@netobj.ddnet.tw", [
|
NetObjectEx("SpecChar", "spec-char@netobj.ddnet.tw", [
|
||||||
NetIntAny("m_X"),
|
NetIntAny("m_X"),
|
||||||
NetIntAny("m_Y"),
|
NetIntAny("m_Y"),
|
||||||
|
NetIntAny("m_HookState"),
|
||||||
|
NetIntAny("m_HookedPlayer"),
|
||||||
|
NetIntAny("m_HookX"),
|
||||||
|
NetIntAny("m_HookY"),
|
||||||
]),
|
]),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ void CGhost::OnRender()
|
||||||
|
|
||||||
Player.m_AttackTick += Client()->GameTick(g_Config.m_ClDummy) - GhostTick;
|
Player.m_AttackTick += Client()->GameTick(g_Config.m_ClDummy) - GhostTick;
|
||||||
|
|
||||||
m_pClient->m_pPlayers->RenderHook(&Prev, &Player, &pGhost->m_RenderInfo , -2, IntraTick);
|
m_pClient->m_pPlayers->RenderHook(&Prev, &Player, &pGhost->m_RenderInfo , -2, false, IntraTick);
|
||||||
m_pClient->m_pPlayers->RenderPlayer(&Prev, &Player, &pGhost->m_RenderInfo, -2, false, IntraTick);
|
m_pClient->m_pPlayers->RenderPlayer(&Prev, &Player, &pGhost->m_RenderInfo, -2, false, IntraTick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,7 @@ void CPlayers::RenderHook(
|
||||||
const CNetObj_Character *pPlayerChar,
|
const CNetObj_Character *pPlayerChar,
|
||||||
const CTeeRenderInfo *pRenderInfo,
|
const CTeeRenderInfo *pRenderInfo,
|
||||||
int ClientID,
|
int ClientID,
|
||||||
|
bool Spec,
|
||||||
float Intra
|
float Intra
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -91,8 +92,13 @@ void CPlayers::RenderHook(
|
||||||
|
|
||||||
CTeeRenderInfo RenderInfo = *pRenderInfo;
|
CTeeRenderInfo RenderInfo = *pRenderInfo;
|
||||||
|
|
||||||
|
int HookedPlayer = pPlayerChar->m_HookedPlayer;
|
||||||
|
|
||||||
|
if(Spec)
|
||||||
|
HookedPlayer = m_pClient->m_aClients[ClientID].m_SpecChar.m_HookedPlayer;
|
||||||
|
|
||||||
// don't render hooks to not active character cores
|
// don't render hooks to not active character cores
|
||||||
if(pPlayerChar->m_HookedPlayer != -1 && !m_pClient->m_Snap.m_aCharacters[pPlayerChar->m_HookedPlayer].m_Active)
|
if(HookedPlayer != -1 && !m_pClient->m_Snap.m_aCharacters[HookedPlayer].m_Active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float IntraTick = Intra;
|
float IntraTick = Intra;
|
||||||
|
@ -108,9 +114,15 @@ void CPlayers::RenderHook(
|
||||||
Position = m_pClient->m_aClients[ClientID].m_RenderPos;
|
Position = m_pClient->m_aClients[ClientID].m_RenderPos;
|
||||||
else
|
else
|
||||||
Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick);
|
Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick);
|
||||||
|
|
||||||
|
if(Spec)
|
||||||
|
{
|
||||||
|
Position.x = m_pClient->m_aClients[ClientID].m_SpecChar.m_X;
|
||||||
|
Position.y = m_pClient->m_aClients[ClientID].m_SpecChar.m_Y;
|
||||||
|
}
|
||||||
|
|
||||||
// draw hook
|
// draw hook
|
||||||
if(Prev.m_HookState>0 && Player.m_HookState>0)
|
if((Prev.m_HookState>0 && Player.m_HookState>0) || (Spec && m_pClient->m_aClients[ClientID].m_SpecChar.m_HookState>0))
|
||||||
{
|
{
|
||||||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
|
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
|
||||||
|
|
||||||
|
@ -121,10 +133,16 @@ void CPlayers::RenderHook(
|
||||||
vec2 Pos = Position;
|
vec2 Pos = Position;
|
||||||
vec2 HookPos;
|
vec2 HookPos;
|
||||||
|
|
||||||
if(in_range(pPlayerChar->m_HookedPlayer, MAX_CLIENTS-1))
|
if(in_range(HookedPlayer, MAX_CLIENTS-1))
|
||||||
HookPos = m_pClient->m_aClients[pPlayerChar->m_HookedPlayer].m_RenderPos;
|
HookPos = m_pClient->m_aClients[HookedPlayer].m_RenderPos;
|
||||||
|
else if(Spec)
|
||||||
|
{
|
||||||
|
HookPos.x = m_pClient->m_aClients[ClientID].m_SpecChar.m_HookX;
|
||||||
|
HookPos.y = m_pClient->m_aClients[ClientID].m_SpecChar.m_HookY;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
HookPos = mix(vec2(Prev.m_HookX, Prev.m_HookY), vec2(Player.m_HookX, Player.m_HookY), IntraTick);
|
HookPos = mix(vec2(Prev.m_HookX, Prev.m_HookY), vec2(Player.m_HookX, Player.m_HookY), IntraTick);
|
||||||
|
|
||||||
|
|
||||||
float d = distance(Pos, HookPos);
|
float d = distance(Pos, HookPos);
|
||||||
vec2 Dir = normalize(Pos-HookPos);
|
vec2 Dir = normalize(Pos-HookPos);
|
||||||
|
@ -132,7 +150,7 @@ void CPlayers::RenderHook(
|
||||||
Graphics()->QuadsSetRotation(GetAngle(Dir)+pi);
|
Graphics()->QuadsSetRotation(GetAngle(Dir)+pi);
|
||||||
// render head
|
// render head
|
||||||
int QuadOffset = NUM_WEAPONS * 2 + 2;
|
int QuadOffset = NUM_WEAPONS * 2 + 2;
|
||||||
if(OtherTeam)
|
if(OtherTeam || Spec)
|
||||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, g_Config.m_ClShowOthersAlpha / 100.0f);
|
Graphics()->SetColor(1.0f, 1.0f, 1.0f, g_Config.m_ClShowOthersAlpha / 100.0f);
|
||||||
Graphics()->RenderQuadContainerAsSprite(m_WeaponEmoteQuadContainerIndex, QuadOffset, HookPos.x, HookPos.y);
|
Graphics()->RenderQuadContainerAsSprite(m_WeaponEmoteQuadContainerIndex, QuadOffset, HookPos.x, HookPos.y);
|
||||||
|
|
||||||
|
@ -155,7 +173,7 @@ void CPlayers::RenderHook(
|
||||||
Graphics()->QuadsSetRotation(0);
|
Graphics()->QuadsSetRotation(0);
|
||||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
RenderHand(&RenderInfo, Position, normalize(HookPos-Pos), -pi/2, vec2(20, 0), OtherTeam ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f);
|
RenderHand(&RenderInfo, Position, normalize(HookPos-Pos), -pi/2, vec2(20, 0), (OtherTeam || Spec) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -685,7 +703,7 @@ void CPlayers::OnRender()
|
||||||
CNetObj_Character CurChar = m_pClient->m_aClients[i].m_RenderCur;
|
CNetObj_Character CurChar = m_pClient->m_aClients[i].m_RenderCur;
|
||||||
|
|
||||||
|
|
||||||
if(m_pClient->m_aClients[i].m_Spec)
|
if(m_pClient->m_aClients[i].m_Spec && !m_pClient->m_Snap.m_aCharacters[i].m_Active)
|
||||||
{
|
{
|
||||||
int Skin = m_pClient->m_pSkins->Find("x_spec");
|
int Skin = m_pClient->m_pSkins->Find("x_spec");
|
||||||
if(Skin != -1)
|
if(Skin != -1)
|
||||||
|
@ -700,7 +718,8 @@ void CPlayers::OnRender()
|
||||||
&PrevChar,
|
&PrevChar,
|
||||||
&CurChar,
|
&CurChar,
|
||||||
&m_aRenderInfo[i],
|
&m_aRenderInfo[i],
|
||||||
i
|
i,
|
||||||
|
m_pClient->m_aClients[i].m_Spec && !m_pClient->m_Snap.m_aCharacters[i].m_Active
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -710,7 +729,7 @@ void CPlayers::OnRender()
|
||||||
&CurChar,
|
&CurChar,
|
||||||
&m_aRenderInfo[i],
|
&m_aRenderInfo[i],
|
||||||
i,
|
i,
|
||||||
m_pClient->m_aClients[i].m_Spec
|
m_pClient->m_aClients[i].m_Spec && !m_pClient->m_Snap.m_aCharacters[i].m_Active
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ class CPlayers : public CComponent
|
||||||
const CNetObj_Character *pPlayerChar,
|
const CNetObj_Character *pPlayerChar,
|
||||||
const CTeeRenderInfo *pRenderInfo,
|
const CTeeRenderInfo *pRenderInfo,
|
||||||
int ClientID,
|
int ClientID,
|
||||||
|
bool Spec,
|
||||||
float Intra = 0.f
|
float Intra = 0.f
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1290,6 +1290,10 @@ void CGameClient::OnNewSnapshot()
|
||||||
|
|
||||||
m_aClients[Item.m_ID].m_SpecChar.m_X = pSpecCharData->m_X;
|
m_aClients[Item.m_ID].m_SpecChar.m_X = pSpecCharData->m_X;
|
||||||
m_aClients[Item.m_ID].m_SpecChar.m_Y = pSpecCharData->m_Y;
|
m_aClients[Item.m_ID].m_SpecChar.m_Y = pSpecCharData->m_Y;
|
||||||
|
m_aClients[Item.m_ID].m_SpecChar.m_HookState = pSpecCharData->m_HookState;
|
||||||
|
m_aClients[Item.m_ID].m_SpecChar.m_HookedPlayer = pSpecCharData->m_HookedPlayer;
|
||||||
|
m_aClients[Item.m_ID].m_SpecChar.m_HookX = pSpecCharData->m_HookX;
|
||||||
|
m_aClients[Item.m_ID].m_SpecChar.m_HookY = pSpecCharData->m_HookY;
|
||||||
}
|
}
|
||||||
else if(Item.m_Type == NETOBJTYPE_SPECTATORINFO)
|
else if(Item.m_Type == NETOBJTYPE_SPECTATORINFO)
|
||||||
{
|
{
|
||||||
|
|
|
@ -295,6 +295,10 @@ public:
|
||||||
{
|
{
|
||||||
int m_X;
|
int m_X;
|
||||||
int m_Y;
|
int m_Y;
|
||||||
|
int m_HookState;
|
||||||
|
int m_HookedPlayer;
|
||||||
|
int m_HookX;
|
||||||
|
int m_HookY;
|
||||||
} m_SpecChar;
|
} m_SpecChar;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -417,6 +417,10 @@ void CPlayer::Snap(int SnappingClient)
|
||||||
CNetObj_SpecChar *pSpecChar = static_cast<CNetObj_SpecChar *>(Server()->SnapNewItem(NETOBJTYPE_SPECCHAR, id, sizeof(CNetObj_SpecChar)));
|
CNetObj_SpecChar *pSpecChar = static_cast<CNetObj_SpecChar *>(Server()->SnapNewItem(NETOBJTYPE_SPECCHAR, id, sizeof(CNetObj_SpecChar)));
|
||||||
pSpecChar->m_X = m_pCharacter->Core()->m_Pos.x;
|
pSpecChar->m_X = m_pCharacter->Core()->m_Pos.x;
|
||||||
pSpecChar->m_Y = m_pCharacter->Core()->m_Pos.y;
|
pSpecChar->m_Y = m_pCharacter->Core()->m_Pos.y;
|
||||||
|
pSpecChar->m_HookState = m_pCharacter->Core()->m_HookState;
|
||||||
|
pSpecChar->m_HookedPlayer = m_pCharacter->Core()->m_HookedPlayer;
|
||||||
|
pSpecChar->m_HookX = m_pCharacter->Core()->m_HookPos.x;
|
||||||
|
pSpecChar->m_HookY = m_pCharacter->Core()->m_HookPos.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue