mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-04-03 16:29:01 +03:00
Add new CVars mp_playerid_showhealth & mp_playerid_field (#1046)
* Add new CVars playerid_showhealth & mp_playerid_field
This commit is contained in:
parent
b44b09d07b
commit
b10f23e1e9
@ -128,6 +128,8 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
|
||||
| mp_jump_height | 45 | 0.0 | - | Player jump height. |
|
||||
| bot_excellent_morale | 0 | 0 | 1 | Bots always have great morale regardless of defeat or victory. |
|
||||
| mp_randomspawn | 0 | 0 | 1 | Random player spawns<br/>`0` disabled <br/>`1` enabled<br/>`NOTE`: Navigation `maps/.nav` file required |
|
||||
| mp_playerid_showhealth | 1 | 0 | 2 | Player ID display mode.<br/>`0` don't show health<br/>`1` show health for teammates only (default CS behaviour)<br/>`2` show health for all players |
|
||||
| mp_playerid_field | 3 | 0 | 3 | Player ID field display mode.<br/>`0` don't show additional information<br/>`1` show team name<br/>`2` show health percentage<br/>`3` show both team name and health percentage |
|
||||
|
||||
</details>
|
||||
|
||||
|
19
dist/game.cfg
vendored
19
dist/game.cfg
vendored
@ -648,3 +648,22 @@ bot_excellent_morale "0"
|
||||
//
|
||||
// Default value: "0"
|
||||
mp_randomspawn "0"
|
||||
|
||||
// Player ID display mode
|
||||
//
|
||||
// 0 - don't show health (default behaviour)
|
||||
// 1 - show health for teammates only (default CS behaviour)
|
||||
// 2 - show health for all players
|
||||
//
|
||||
// Default value: "1"
|
||||
mp_playerid_showhealth "1"
|
||||
|
||||
// Player ID field display mode
|
||||
//
|
||||
// 0 - don't show additional information
|
||||
// 1 - show team name
|
||||
// 2 - show health percentage
|
||||
// 3 - show both team name and health percentage
|
||||
//
|
||||
// Default value: "3"
|
||||
mp_playerid_field "3"
|
||||
|
@ -193,6 +193,9 @@ cvar_t votemap_min_time = { "mp_votemap_min_time", "180", 0, 180.0f, null
|
||||
cvar_t logkills = { "mp_logkills", "1", FCVAR_SERVER, 0.0f, nullptr };
|
||||
cvar_t randomspawn = { "mp_randomspawn", "0", FCVAR_SERVER, 0.0f, nullptr };
|
||||
|
||||
cvar_t playerid_showhealth = { "mp_playerid_showhealth", "1", 0, 1.0f, nullptr };
|
||||
cvar_t playerid_field = { "mp_playerid_field", "3", 0, 3.0f, nullptr };
|
||||
|
||||
void GameDLL_Version_f()
|
||||
{
|
||||
if (Q_stricmp(CMD_ARGV(1), "version") != 0)
|
||||
@ -472,6 +475,9 @@ void EXT_FUNC GameDLLInit()
|
||||
CVAR_REGISTER(&cv_hostage_ai_enable);
|
||||
CVAR_REGISTER(&logkills);
|
||||
|
||||
CVAR_REGISTER(&playerid_showhealth);
|
||||
CVAR_REGISTER(&playerid_field);
|
||||
|
||||
// print version
|
||||
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");
|
||||
|
||||
|
@ -212,6 +212,8 @@ extern cvar_t vote_flags;
|
||||
extern cvar_t votemap_min_time;
|
||||
extern cvar_t logkills;
|
||||
extern cvar_t randomspawn;
|
||||
extern cvar_t playerid_showhealth;
|
||||
extern cvar_t playerid_field;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -115,6 +115,57 @@ void CBasePlayer::SendItemStatus()
|
||||
MESSAGE_END();
|
||||
}
|
||||
|
||||
#ifdef REGAMEDLL_ADD
|
||||
|
||||
enum PlayerIdShowHealth
|
||||
{
|
||||
PLAYERID_HIDE = 0, // Don't show health
|
||||
PLAYERID_TEAMMATES = 1, // Show health for teammates only (default CS)
|
||||
PLAYERID_ALL = 2 // Show health for all players
|
||||
};
|
||||
|
||||
enum PlayerIdField
|
||||
{
|
||||
PLAYERID_FIELD_NONE = 0, // No extra info
|
||||
PLAYERID_FIELD_TEAM = 1, // Show team name
|
||||
PLAYERID_FIELD_HEALTH = 2, // Show health percentage
|
||||
PLAYERID_FIELD_BOTH = 3 // Show both team name and health
|
||||
};
|
||||
|
||||
inline const char *GetPlayerIdString(bool sameTeam)
|
||||
{
|
||||
int showHealth = static_cast<int>(playerid_showhealth.value);
|
||||
int fieldType = static_cast<int>(playerid_field.value);
|
||||
|
||||
// Don't show health
|
||||
if (showHealth == PLAYERID_HIDE)
|
||||
{
|
||||
return (fieldType == PLAYERID_FIELD_NONE) ? "1 %p2" : "1 %c1: %p2";
|
||||
}
|
||||
|
||||
// Health only for teammates
|
||||
if (showHealth == PLAYERID_TEAMMATES && !sameTeam)
|
||||
{
|
||||
switch (fieldType)
|
||||
{
|
||||
case PLAYERID_FIELD_TEAM: return "1 %c1: %p2";
|
||||
case PLAYERID_FIELD_HEALTH: return "1 %p2";
|
||||
case PLAYERID_FIELD_BOTH: return "1 %c1: %p2";
|
||||
default: return "1 %p2";
|
||||
}
|
||||
}
|
||||
|
||||
// Show health to everyone
|
||||
switch (fieldType)
|
||||
{
|
||||
case PLAYERID_FIELD_TEAM: return "1 %c1: %p2\n2 : %i3%%";
|
||||
case PLAYERID_FIELD_HEALTH: return "1 %p2\n2 %h: %i3%%";
|
||||
case PLAYERID_FIELD_BOTH: return "1 %c1: %p2\n2 %h: %i3%%";
|
||||
default: return "1 %p2\n2 : %i3%%";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *GetCSModelName(int item_id)
|
||||
{
|
||||
const char *modelName = nullptr;
|
||||
@ -8149,11 +8200,19 @@ void CBasePlayer::UpdateStatusBar()
|
||||
if (sameTeam || GetObserverMode() != OBS_NONE)
|
||||
{
|
||||
if (playerid.value != PLAYERID_MODE_OFF || GetObserverMode() != OBS_NONE)
|
||||
#ifndef REGAMEDLL_ADD
|
||||
Q_strlcpy(sbuf0, "1 %c1: %p2\n2 %h: %i3%%");
|
||||
#else
|
||||
Q_strlcpy(sbuf0, GetPlayerIdString(sameTeam));
|
||||
#endif
|
||||
else
|
||||
Q_strlcpy(sbuf0, " ");
|
||||
|
||||
newSBarState[SBAR_ID_TARGETHEALTH] = int((pEntity->pev->health / pEntity->pev->max_health) * 100);
|
||||
#ifdef REGAMEDLL_ADD
|
||||
if (static_cast<int>(playerid_showhealth.value) != PLAYERID_FIELD_NONE)
|
||||
#endif
|
||||
{
|
||||
newSBarState[SBAR_ID_TARGETHEALTH] = int((pEntity->pev->health / pEntity->pev->max_health) * 100);
|
||||
}
|
||||
|
||||
if (!(m_flDisplayHistory & DHF_FRIEND_SEEN) && !(pev->flags & FL_SPECTATOR))
|
||||
{
|
||||
@ -8164,10 +8223,18 @@ void CBasePlayer::UpdateStatusBar()
|
||||
else if (GetObserverMode() == OBS_NONE)
|
||||
{
|
||||
if (playerid.value != PLAYERID_MODE_TEAMONLY && playerid.value != PLAYERID_MODE_OFF)
|
||||
#ifndef REGAMEDLL_ADD
|
||||
Q_strlcpy(sbuf0, "1 %c1: %p2");
|
||||
#else
|
||||
Q_strlcpy(sbuf0, GetPlayerIdString(sameTeam));
|
||||
#endif
|
||||
else
|
||||
Q_strlcpy(sbuf0, " ");
|
||||
|
||||
#ifdef REGAMEDLL_ADD
|
||||
if (static_cast<int>(playerid_showhealth.value) == PLAYERID_ALL)
|
||||
newSBarState[SBAR_ID_TARGETHEALTH] = int((pEntity->pev->health / pEntity->pev->max_health) * 100);
|
||||
#endif
|
||||
if (!(m_flDisplayHistory & DHF_ENEMY_SEEN))
|
||||
{
|
||||
m_flDisplayHistory |= DHF_ENEMY_SEEN;
|
||||
|
Loading…
x
Reference in New Issue
Block a user