mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Add +showhookcoll from H-Client
This commit is contained in:
parent
6da8d2146c
commit
9028d77471
|
@ -1,7 +1,7 @@
|
||||||
from datatypes import *
|
from datatypes import *
|
||||||
|
|
||||||
Emotes = ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"]
|
Emotes = ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"]
|
||||||
PlayerFlags = ["PLAYING", "IN_MENU", "CHATTING", "SCOREBOARD"]
|
PlayerFlags = ["PLAYING", "IN_MENU", "CHATTING", "SCOREBOARD", "AIM"]
|
||||||
GameFlags = ["TEAMS", "FLAGS"]
|
GameFlags = ["TEAMS", "FLAGS"]
|
||||||
GameStateFlags = ["GAMEOVER", "SUDDENDEATH", "PAUSED"]
|
GameStateFlags = ["GAMEOVER", "SUDDENDEATH", "PAUSED"]
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,7 @@ void CControls::OnConsoleInit()
|
||||||
Console()->Register("+jump", "", CFGFLAG_CLIENT, ConKeyInputState, &m_InputData.m_Jump, "Jump");
|
Console()->Register("+jump", "", CFGFLAG_CLIENT, ConKeyInputState, &m_InputData.m_Jump, "Jump");
|
||||||
Console()->Register("+hook", "", CFGFLAG_CLIENT, ConKeyInputState, &m_InputData.m_Hook, "Hook");
|
Console()->Register("+hook", "", CFGFLAG_CLIENT, ConKeyInputState, &m_InputData.m_Hook, "Hook");
|
||||||
Console()->Register("+fire", "", CFGFLAG_CLIENT, ConKeyInputCounter, &m_InputData.m_Fire, "Fire");
|
Console()->Register("+fire", "", CFGFLAG_CLIENT, ConKeyInputCounter, &m_InputData.m_Fire, "Fire");
|
||||||
|
Console()->Register("+showhookcoll", "", CFGFLAG_CLIENT, ConKeyInputState, &m_ShowHookColl, "Show Hook Collision");
|
||||||
|
|
||||||
{ static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 1}; Console()->Register("+weapon1", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to hammer"); }
|
{ static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 1}; Console()->Register("+weapon1", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to hammer"); }
|
||||||
{ static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 2}; Console()->Register("+weapon2", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to gun"); }
|
{ static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 2}; Console()->Register("+weapon2", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to gun"); }
|
||||||
|
@ -125,6 +126,9 @@ int CControls::SnapInput(int *pData)
|
||||||
if(m_pClient->m_pScoreboard->Active())
|
if(m_pClient->m_pScoreboard->Active())
|
||||||
m_InputData.m_PlayerFlags |= PLAYERFLAG_SCOREBOARD;
|
m_InputData.m_PlayerFlags |= PLAYERFLAG_SCOREBOARD;
|
||||||
|
|
||||||
|
if (m_pClient->m_pControls->m_ShowHookColl)
|
||||||
|
m_InputData.m_PlayerFlags |= PLAYERFLAG_AIM;
|
||||||
|
|
||||||
if(m_LastData.m_PlayerFlags != m_InputData.m_PlayerFlags)
|
if(m_LastData.m_PlayerFlags != m_InputData.m_PlayerFlags)
|
||||||
Send = true;
|
Send = true;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ public:
|
||||||
CNetObj_PlayerInput m_LastData;
|
CNetObj_PlayerInput m_LastData;
|
||||||
int m_InputDirectionLeft;
|
int m_InputDirectionLeft;
|
||||||
int m_InputDirectionRight;
|
int m_InputDirectionRight;
|
||||||
|
bool m_ShowHookColl;
|
||||||
|
|
||||||
CControls();
|
CControls();
|
||||||
|
|
||||||
|
|
|
@ -432,6 +432,7 @@ static CKeyInfo gs_aKeys[] =
|
||||||
{ "Fire", "+fire", 0 },
|
{ "Fire", "+fire", 0 },
|
||||||
{ "Hook", "+hook", 0 },
|
{ "Hook", "+hook", 0 },
|
||||||
{ "Hammer", "+weapon1", 0 },
|
{ "Hammer", "+weapon1", 0 },
|
||||||
|
{ "Hook Collisions", "+showhookcoll", 0 },
|
||||||
{ "Pistol", "+weapon2", 0 },
|
{ "Pistol", "+weapon2", 0 },
|
||||||
{ "Shotgun", "+weapon3", 0 },
|
{ "Shotgun", "+weapon3", 0 },
|
||||||
{ "Grenade", "+weapon4", 0 },
|
{ "Grenade", "+weapon4", 0 },
|
||||||
|
|
|
@ -320,6 +320,31 @@ void CPlayers::RenderPlayer(
|
||||||
|
|
||||||
// draw gun
|
// draw gun
|
||||||
{
|
{
|
||||||
|
if (Player.m_PlayerFlags&PLAYERFLAG_AIM)
|
||||||
|
{
|
||||||
|
Graphics()->TextureSet(-1);
|
||||||
|
vec2 initPos = Position + Direction * 42.0f;
|
||||||
|
vec2 finishPos = initPos + Direction * (m_pClient->m_Tuning.m_HookLength-60.0f);
|
||||||
|
Graphics()->LinesBegin();
|
||||||
|
Graphics()->SetColor(1.00f, 0.0f, 0.0f, 1.00f);
|
||||||
|
|
||||||
|
|
||||||
|
Graphics()->SetColor(1.00f, 0.0f, 0.0f, 1.00f);
|
||||||
|
if (Collision()->IntersectLine(initPos, finishPos, &finishPos, 0x0, true))
|
||||||
|
{
|
||||||
|
vec2 finishPosPost = finishPos+Direction * 1.0f;
|
||||||
|
if (!(Collision()->GetCollisionAt(finishPosPost.x, finishPosPost.y)&CCollision::COLFLAG_NOHOOK))
|
||||||
|
Graphics()->SetColor(130.0f/255.0f, 232.0f/255.0f, 160.0f/255.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_pClient->IntersectCharacter(initPos, finishPos, 12.0f, finishPos) != -1)
|
||||||
|
Graphics()->SetColor(1.0f, 1.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
IGraphics::CLineItem LineItem(Position.x, Position.y, finishPos.x, finishPos.y);
|
||||||
|
Graphics()->LinesDraw(&LineItem, 1);
|
||||||
|
Graphics()->LinesEnd();
|
||||||
|
}
|
||||||
|
|
||||||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
|
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
|
||||||
Graphics()->QuadsBegin();
|
Graphics()->QuadsBegin();
|
||||||
Graphics()->QuadsSetRotation(State.GetAttach()->m_Angle*pi*2+Angle);
|
Graphics()->QuadsSetRotation(State.GetAttach()->m_Angle*pi*2+Angle);
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
#include <game/generated/protocol.h>
|
#include <game/generated/protocol.h>
|
||||||
#include <game/generated/client_data.h>
|
#include <game/generated/client_data.h>
|
||||||
|
|
||||||
|
#include <base/math.h>
|
||||||
|
#include <base/vmath.h>
|
||||||
|
|
||||||
#include <game/localization.h>
|
#include <game/localization.h>
|
||||||
#include <game/version.h>
|
#include <game/version.h>
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
@ -1221,3 +1224,40 @@ IGameClient *CreateGameClient()
|
||||||
{
|
{
|
||||||
return &g_GameClient;
|
return &g_GameClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//H-Client
|
||||||
|
// TODO: should be more general
|
||||||
|
int CGameClient::IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2& NewPos)
|
||||||
|
{
|
||||||
|
// Find other players
|
||||||
|
static const int ProximityRadius = 28;
|
||||||
|
float ClosestLen = distance(Pos0, Pos1) * 100.0f;
|
||||||
|
int ClosestID = -1;
|
||||||
|
|
||||||
|
for (int i=0; i<MAX_CLIENTS; i++)
|
||||||
|
{
|
||||||
|
CClientData cData = m_aClients[i];
|
||||||
|
CNetObj_Character Prev = m_Snap.m_aCharacters[i].m_Prev;
|
||||||
|
CNetObj_Character Player = m_Snap.m_aCharacters[i].m_Cur;
|
||||||
|
|
||||||
|
vec2 Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), Client()->IntraGameTick());
|
||||||
|
|
||||||
|
if (!cData.m_Active || cData.m_Team == TEAM_SPECTATORS || m_Snap.m_LocalClientID == m_Snap.m_paPlayerInfos[i]->m_ClientID)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
vec2 IntersectPos = closest_point_on_line(Pos0, Pos1, Position);
|
||||||
|
float Len = distance(Position, IntersectPos);
|
||||||
|
if(Len < ProximityRadius+Radius)
|
||||||
|
{
|
||||||
|
Len = distance(Pos0, IntersectPos);
|
||||||
|
if(Len < ClosestLen)
|
||||||
|
{
|
||||||
|
NewPos = IntersectPos;
|
||||||
|
ClosestLen = Len;
|
||||||
|
ClosestID = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ClosestID;
|
||||||
|
}
|
||||||
|
|
|
@ -256,6 +256,8 @@ public:
|
||||||
class CRaceDemo *m_pRaceDemo;
|
class CRaceDemo *m_pRaceDemo;
|
||||||
class CGhost *m_pGhost;
|
class CGhost *m_pGhost;
|
||||||
|
|
||||||
|
int IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2& NewPos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
class CTeamsCore m_Teams;
|
class CTeamsCore m_Teams;
|
||||||
|
|
Loading…
Reference in a new issue