Absolutely perfect +showhookcoll

This commit is contained in:
def 2014-01-27 05:06:23 +01:00
parent 8ec5aa46c5
commit 3e5bcb0213
4 changed files with 50 additions and 26 deletions

View file

@ -548,27 +548,56 @@ void CPlayers::RenderPlayer(
if (Player.m_PlayerFlags&PLAYERFLAG_AIM)
{
vec2 ExDirection = Direction;
if (pPlayerInfo->m_Local)
ExDirection = normalize(vec2(m_pClient->m_pControls->m_InputData.m_TargetX, m_pClient->m_pControls->m_InputData.m_TargetY));
Graphics()->TextureSet(-1);
vec2 initPos = Position + ExDirection * 42.0f;
vec2 initPos = Position;
vec2 finishPos = initPos + ExDirection * (m_pClient->m_Tuning.m_HookLength-42.0f);
Graphics()->LinesBegin();
Graphics()->SetColor(1.00f, 0.0f, 0.0f, 1.00f);
float PhysSize = 28.0f;
Graphics()->SetColor(1.00f, 0.0f, 0.0f, 1.00f);
if (Collision()->IntersectLine(initPos, finishPos, &finishPos, 0x0, true))
{
vec2 finishPosPost = finishPos;
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);
}
vec2 OldPos = initPos + ExDirection * PhysSize * 1.5f;;
vec2 NewPos = OldPos;
if (m_pClient->IntersectCharacter(initPos, finishPos, 2.2f, finishPos) != -1)
Graphics()->SetColor(1.0f, 1.0f, 0.0f, 1.0f);
bool doBreak = false;
do {
OldPos = NewPos;
NewPos = OldPos + ExDirection * m_pClient->m_Tuning.m_HookFireSpeed;
if (distance(Position, NewPos) > m_pClient->m_Tuning.m_HookLength)
{
NewPos = initPos + normalize(NewPos-initPos) * m_pClient->m_Tuning.m_HookLength;
doBreak = true;
}
if (m_pClient->IntersectCharacter(OldPos, NewPos, finishPos) != -1)
{
Graphics()->SetColor(1.0f, 1.0f, 0.0f, 1.0f);
break;
}
int teleNr = 0;
if (!doBreak && Collision()->IntersectLineTeleHook(OldPos, NewPos, &finishPos, 0x0, &teleNr, true))
{
vec2 finishPosPost = finishPos;
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);
break;
}
NewPos.x = round(NewPos.x);
NewPos.y = round(NewPos.y);
ExDirection.x = round(ExDirection.x*256.0f) / 256.0f;
ExDirection.y = round(ExDirection.y*256.0f) / 256.0f;
} while (!doBreak);
IGraphics::CLineItem LineItem(Position.x, Position.y, finishPos.x, finishPos.y);
Graphics()->LinesDraw(&LineItem, 1);

View file

@ -1281,13 +1281,10 @@ IGameClient *CreateGameClient()
return &g_GameClient;
}
//H-Client
// TODO: should be more general
int CGameClient::IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2& NewPos)
int CGameClient::IntersectCharacter(vec2 HookPos, vec2 NewPos, vec2& NewPos2)
{
// Find other players
static const int ProximityRadius = 28;
float ClosestLen = distance(Pos0, Pos1) * 100.0f;
float PhysSize = 28.0f;
float Distance = 0.0f;
int ClosestID = -1;
for (int i=0; i<MAX_CLIENTS; i++)
@ -1301,16 +1298,14 @@ int CGameClient::IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2& Ne
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)
vec2 ClosestPoint = closest_point_on_line(HookPos, NewPos, Position);
if(distance(Position, ClosestPoint) < PhysSize+2.0f)
{
Len = distance(Pos0, IntersectPos);
if(Len < ClosestLen)
if(ClosestID == -1 || distance(HookPos, Position) < Distance)
{
NewPos = IntersectPos;
ClosestLen = Len;
NewPos2 = ClosestPoint;
ClosestID = i;
Distance = distance(HookPos, Position);
}
}
}

View file

@ -259,7 +259,7 @@ public:
class CGhost *m_pGhost;
class CTeamsCore m_Teams;
int IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, vec2& NewPos);
int IntersectCharacter(vec2 Pos0, vec2 Pos1, vec2& NewPos);
private:

View file

@ -333,7 +333,7 @@ void CCharacterCore::Tick(bool UseInput)
int Num = (*m_pTeleOuts)[teleNr-1].size();
m_HookPos = (*m_pTeleOuts)[teleNr-1][(!Num)?Num:rand() % Num]+TargetDirection*PhysSize*1.5f;
m_HookDir = TargetDirection;
m_HookTeleBase = m_HookPos;
m_HookTeleBase = m_HookPos;
}
else
{