2010-05-29 07:25:38 +00:00
|
|
|
#include <engine/graphics.h>
|
|
|
|
#include <engine/textrender.h>
|
|
|
|
#include <game/generated/protocol.h>
|
|
|
|
#include <game/generated/client_data.h>
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/client/gameclient.h>
|
|
|
|
#include <game/client/animstate.h>
|
|
|
|
#include "killmessages.h"
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CKillMessages::OnReset()
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_KillmsgCurrent = 0;
|
|
|
|
for(int i = 0; i < MAX_KILLMSGS; i++)
|
|
|
|
m_aKillmsgs[i].m_Tick = -100000;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CKillMessages::OnMessage(int MsgType, void *pRawMsg)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(MsgType == NETMSGTYPE_SV_KILLMSG)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CNetMsg_Sv_KillMsg *pMsg = (CNetMsg_Sv_KillMsg *)pRawMsg;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
// unpack messages
|
2010-05-29 07:25:38 +00:00
|
|
|
CKillMsg Kill;
|
|
|
|
Kill.m_Killer = pMsg->m_Killer;
|
|
|
|
Kill.m_Victim = pMsg->m_Victim;
|
|
|
|
Kill.m_Weapon = pMsg->m_Weapon;
|
|
|
|
Kill.m_ModeSpecial = pMsg->m_ModeSpecial;
|
|
|
|
Kill.m_Tick = Client()->GameTick();
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
// add the message
|
2010-05-29 07:25:38 +00:00
|
|
|
m_KillmsgCurrent = (m_KillmsgCurrent+1)%MAX_KILLMSGS;
|
|
|
|
m_aKillmsgs[m_KillmsgCurrent] = Kill;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CKillMessages::OnRender()
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
float Width = 400*3.0f*Graphics()->ScreenAspect();
|
|
|
|
float Height = 400*3.0f;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->MapScreen(0, 0, Width*1.5f, Height*1.5f);
|
|
|
|
float StartX = Width*1.5f-10.0f;
|
2008-08-27 15:48:50 +00:00
|
|
|
float y = 20.0f;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
for(int i = 0; i < MAX_KILLMSGS; i++)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int r = (m_KillmsgCurrent+i+1)%MAX_KILLMSGS;
|
|
|
|
if(Client()->GameTick() > m_aKillmsgs[r].m_Tick+50*10)
|
2008-08-27 15:48:50 +00:00
|
|
|
continue;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
float FontSize = 36.0f;
|
|
|
|
float KillerNameW = TextRender()->TextWidth(0, FontSize, m_pClient->m_aClients[m_aKillmsgs[r].m_Killer].m_aName, -1);
|
|
|
|
float VictimNameW = TextRender()->TextWidth(0, FontSize, m_pClient->m_aClients[m_aKillmsgs[r].m_Victim].m_aName, -1);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
float x = StartX;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
// render victim name
|
2010-05-29 07:25:38 +00:00
|
|
|
x -= VictimNameW;
|
|
|
|
TextRender()->Text(0, x, y, FontSize, m_pClient->m_aClients[m_aKillmsgs[r].m_Victim].m_aName, -1);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
// render victim tee
|
|
|
|
x -= 24.0f;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_Flags&GAMEFLAG_FLAGS)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_aKillmsgs[r].m_ModeSpecial&1)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->BlendNormal();
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsBegin();
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_pClient->m_aClients[m_aKillmsgs[r].m_Victim].m_Team == 0) RenderTools()->SelectSprite(SPRITE_FLAG_BLUE);
|
|
|
|
else RenderTools()->SelectSprite(SPRITE_FLAG_RED);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
float Size = 56.0f;
|
|
|
|
IGraphics::CQuadItem QuadItem(x, y-16, Size/2, Size);
|
|
|
|
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
RenderTools()->RenderTee(CAnimState::GetIdle(), &m_pClient->m_aClients[m_aKillmsgs[r].m_Victim].m_RenderInfo, EMOTE_PAIN, vec2(-1,0), vec2(x, y+28));
|
2008-08-27 15:48:50 +00:00
|
|
|
x -= 32.0f;
|
|
|
|
|
|
|
|
// render weapon
|
|
|
|
x -= 44.0f;
|
2010-05-29 07:25:38 +00:00
|
|
|
if (m_aKillmsgs[r].m_Weapon >= 0)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsBegin();
|
2010-05-29 07:25:38 +00:00
|
|
|
RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[m_aKillmsgs[r].m_Weapon].m_pSpriteBody);
|
|
|
|
RenderTools()->DrawSprite(x, y+28, 96);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
x -= 52.0f;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_aKillmsgs[r].m_Victim != m_aKillmsgs[r].m_Killer)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_Flags&GAMEFLAG_FLAGS)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_aKillmsgs[r].m_ModeSpecial&2)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->BlendNormal();
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsBegin();
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_pClient->m_aClients[m_aKillmsgs[r].m_Killer].m_Team == 0) RenderTools()->SelectSprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X);
|
|
|
|
else RenderTools()->SelectSprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
float Size = 56.0f;
|
|
|
|
IGraphics::CQuadItem QuadItem(x-56, y-16, Size/2, Size);
|
|
|
|
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// render killer tee
|
|
|
|
x -= 24.0f;
|
2010-05-29 07:25:38 +00:00
|
|
|
RenderTools()->RenderTee(CAnimState::GetIdle(), &m_pClient->m_aClients[m_aKillmsgs[r].m_Killer].m_RenderInfo, EMOTE_ANGRY, vec2(1,0), vec2(x, y+28));
|
2008-08-27 15:48:50 +00:00
|
|
|
x -= 32.0f;
|
|
|
|
|
|
|
|
// render killer name
|
2010-05-29 07:25:38 +00:00
|
|
|
x -= KillerNameW;
|
|
|
|
TextRender()->Text(0, x, y, FontSize, m_pClient->m_aClients[m_aKillmsgs[r].m_Killer].m_aName, -1);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
y += 44;
|
|
|
|
}
|
|
|
|
}
|