Basic radar implementation! It shows player positions and height - also
adjusted obituaries to be colored after the team colors.
This commit is contained in:
parent
be938177a4
commit
a14e514ca2
9 changed files with 104 additions and 15 deletions
|
@ -63,15 +63,3 @@ float spr_flash2[4] = {
|
|||
48 / 256, // size x
|
||||
32 / 256 // size y
|
||||
};
|
||||
|
||||
string
|
||||
HUD_GetChatColorHEX(float fTeam)
|
||||
{
|
||||
if (fTeam == TEAM_CT) {
|
||||
return "^x7AC";
|
||||
} else if (fTeam == TEAM_T) {
|
||||
return "^xC33";
|
||||
} else {
|
||||
return "^xCCC";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -676,6 +676,7 @@ HUD_Draw(void)
|
|||
HUD_DrawZones();
|
||||
HUD_DrawProgress();
|
||||
HUD_DrawFlashlight();
|
||||
Radar_Draw();
|
||||
Damage_Draw();
|
||||
}
|
||||
|
||||
|
|
|
@ -141,4 +141,6 @@ ClientGame_RendererRestart(string rstr)
|
|||
FX_Spark_Init();
|
||||
FX_Impact_Init();
|
||||
FX_Smokenade_Init();
|
||||
|
||||
Radar_Init();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ defs.h
|
|||
../../../src/gs-entbase/shared.src
|
||||
../shared/include.src
|
||||
|
||||
radar.qc
|
||||
nightvision.qc
|
||||
draw.qc
|
||||
textmenu.qc
|
||||
|
|
83
src/client/radar.qc
Normal file
83
src/client/radar.qc
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2021 Marco Hladik <marco@icculus.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define CSRADAR_DISTANCE 1024
|
||||
|
||||
var string g_cs_radar;
|
||||
|
||||
void
|
||||
Radar_Init(void)
|
||||
{
|
||||
g_cs_radar = spriteframe("sprites/radar640.spr", 0, 0.0f);
|
||||
}
|
||||
|
||||
void
|
||||
Radar_Draw(void)
|
||||
{
|
||||
drawpic(g_hudmins, g_cs_radar, [128,128], [1,1,1], 0.25f, DRAWFLAG_ADDITIVE);
|
||||
|
||||
for (entity a = world; (a = find(a, ::classname, "player"));) {
|
||||
vector color;
|
||||
vector own_pos = pSeat->m_vecPredictedOrigin;
|
||||
vector difference = (a.origin - own_pos);
|
||||
|
||||
/* don't draw when we're exceeding the view radius */
|
||||
if (vlen(difference) > CSRADAR_DISTANCE)
|
||||
continue;
|
||||
|
||||
/* this is perhaps a bit too aggressive, so fix this and uncomment */
|
||||
#if 0
|
||||
/* test if we can actually see the player */
|
||||
traceline(a.origin, own_pos + pSeat->m_ePlayer.view_ofs, MOVE_NORMAL, pSeat->m_ePlayer);
|
||||
if (trace_ent != a) {
|
||||
traceline(a.origin + [0,0,a.maxs[2]], own_pos + pSeat->m_ePlayer.view_ofs, MOVE_OTHERONLY, pSeat->m_ePlayer);
|
||||
if (trace_ent != a) {
|
||||
traceline(a.origin + [0,0,a.mins[2]], own_pos + pSeat->m_ePlayer.view_ofs, MOVE_OTHERONLY, pSeat->m_ePlayer);
|
||||
if (trace_ent != a) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
vector matrix;
|
||||
float ht;
|
||||
makevectors([0,input_angles[1] - 90, 0]);
|
||||
matrix[0] = dotproduct(difference, v_forward);
|
||||
matrix[1] = dotproduct(difference, v_right);
|
||||
matrix[2] = 0;
|
||||
|
||||
/* we need to fit 1024 in-game units into the 64px radar image */
|
||||
vector apos = g_hudmins + [62,62] + (matrix * (64/CSRADAR_DISTANCE));
|
||||
|
||||
if (getplayerkeyfloat(a.entnum-1, "*team") == TEAM_CT)
|
||||
color = [115, 155, 205] / 255;
|
||||
else
|
||||
color = [190, 52, 57] / 255;
|
||||
|
||||
drawfill(apos, [4,4], color, 1.0f, DRAWFLAG_NORMAL);
|
||||
|
||||
/* do the line indicating the height of the player relative to us */
|
||||
ht = fabs(difference[2] * (64 / CSRADAR_DISTANCE));
|
||||
|
||||
if (difference[2] > 0)
|
||||
drawfill(apos + [1,0], [2,ht], color, 1.0f, DRAWFLAG_NORMAL);
|
||||
else if (difference[2] < 0)
|
||||
drawfill(apos + [1,-ht], [2,ht], color, 1.0f, DRAWFLAG_NORMAL);
|
||||
|
||||
//drawpic(apos, "fade_modulate", [4,4], color, 1.0f, 0);
|
||||
}
|
||||
}
|
|
@ -38,10 +38,12 @@ CSMultiplayerRules::PlayerDeath(base_player pl)
|
|||
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
||||
WriteByte(MSG_MULTICAST, EV_OBITUARY);
|
||||
if (g_dmg_eAttacker.netname)
|
||||
WriteString(MSG_MULTICAST, g_dmg_eAttacker.netname);
|
||||
WriteString(MSG_MULTICAST, strcat(HUD_GetChatColorHEX(g_dmg_eAttacker.team), g_dmg_eAttacker.netname));
|
||||
else
|
||||
WriteString(MSG_MULTICAST, g_dmg_eAttacker.classname);
|
||||
WriteString(MSG_MULTICAST, pl.netname);
|
||||
|
||||
WriteString(MSG_MULTICAST, strcat(HUD_GetChatColorHEX(pl.team), pl.netname));
|
||||
|
||||
WriteByte(MSG_MULTICAST, g_dmg_iWeapon);
|
||||
WriteByte(MSG_MULTICAST, 0);
|
||||
msg_entity = world;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
../../../src/server/defs.h
|
||||
../../../src/gs-entbase/server.src
|
||||
../../../src/gs-entbase/shared.src
|
||||
../shared/defs.h
|
||||
|
||||
defs.h
|
||||
../shared/include.src
|
||||
|
|
|
@ -32,3 +32,15 @@ enum
|
|||
STAT_GAMETIME,
|
||||
STAT_GAMESTATE
|
||||
};
|
||||
|
||||
string
|
||||
HUD_GetChatColorHEX(float fTeam)
|
||||
{
|
||||
if (fTeam == TEAM_CT) {
|
||||
return "^x7AC";
|
||||
} else if (fTeam == TEAM_T) {
|
||||
return "^xC33";
|
||||
} else {
|
||||
return "^xCCC";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#includelist
|
||||
defs.h
|
||||
flags.h
|
||||
player.h
|
||||
../../../valve/src/shared/weapon_common.h
|
||||
|
|
Loading…
Reference in a new issue