Separate mp_location_area_info from chat and radar

Add fallback location message for chat
This commit is contained in:
s1lentq 2024-04-08 16:42:08 +07:00
parent 279bd6421b
commit 5117374a27
6 changed files with 41 additions and 13 deletions

View File

@ -116,7 +116,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| mp_freezetime_duck | 1 | 0 | 1 | Allow players to duck during freezetime.<br/> `0` disabled<br/>`1` enabled |
| mp_freezetime_jump | 1 | 0 | 1 | Allow players to jump during freezetime.<br/> `0` disabled<br/>`1` enabled |
| mp_defuser_allocation | 0 | 0 | 2 | Give defuser on player spawn.<br/> `0` disabled<br/>`1` Random players. <br/>`2` All players. |
| mp_location_area_info | 0 | 0 | 1 | Enable location area info.<br/> `0` disabled<br/>`1` enabled.<br/>Usually displayed in HUDs below radar or in radio chat as a prefix.<br/>`NOTE`: Navigation `maps/.nav` file required and should contain place names |
| mp_location_area_info | 0 | 0 | 3 | Enable location area info.<br/> `0` disabled<br/>`1` show location below HUD radar.<br/>`2` show location in HUD chat. `NOT RECOMMENDED!` [:speech_balloon:](## "Not all client builds are compatible")<br/>`3` both displayed. `NOT RECOMMENDED!` [:speech_balloon:](## "Not all client builds are compatible")<br/><br/>`NOTE`: Navigation `maps/.nav` file required and should contain place names<br/>`NOTE`: If option `2` or `3` is enabled, be sure to enable `mp_chat_loc_fallback 1` |
</details>
## How to install zBot for CS 1.6?

6
dist/game.cfg vendored
View File

@ -577,11 +577,13 @@ mp_freezetime_jump "1"
mp_defuser_allocation "0"
// Enable location area info
// Usually displayed in HUDs below radar or in radio chat as a prefix
// 0 - disabled (default behavior)
// 1 - enabled
// 1 - show location below HUD radar
// 2 - show location in HUD chat (NOT RECOMMENDED! Not all client builds are compatible)
// 3 - both displayed (NOT RECOMMENDED! Not all client builds are compatible)
//
// NOTE: Navigation maps/.nav file required and should contain place names
// NOTE: If option 2 or 3 is enabled, be sure to enable mp_chat_loc_fallback 1
//
// Default value: "0"
mp_location_area_info "0"

View File

@ -836,7 +836,11 @@ void Host_Say(edict_t *pEntity, BOOL teamonly)
// team only
if (teamonly)
{
if (AreRunningCZero() && (pPlayer->m_iTeam == CT || pPlayer->m_iTeam == TERRORIST))
if ((
#ifdef REGAMEDLL_ADD
location_area_info.value >= 2 ||
#endif
AreRunningCZero()) && (pPlayer->m_iTeam == CT || pPlayer->m_iTeam == TERRORIST))
{
// search the place name where is located the player
Place playerPlace = TheNavAreaGrid.GetPlace(&pPlayer->pev->origin);
@ -850,8 +854,17 @@ void Host_Say(edict_t *pEntity, BOOL teamonly)
break;
}
}
if (!placeName)
placeName = TheNavAreaGrid.IDToName(playerPlace);
}
bool bUseLocFallback = false;
#ifdef REGAMEDLL_ADD
if (chat_loc_fallback.value)
bUseLocFallback = true;
#endif
if (pPlayer->m_iTeam == CT)
{
if (bSenderDead)
@ -861,7 +874,7 @@ void Host_Say(edict_t *pEntity, BOOL teamonly)
}
else if (placeName)
{
pszFormat = "#Cstrike_Chat_CT_Loc";
pszFormat = bUseLocFallback ? "\x1(Counter-Terrorist) \x3%s1\x1 @ \x4%s3\x1 : %s2" : "#Cstrike_Chat_CT_Loc";
pszConsoleFormat = "*(Counter-Terrorist) %s @ %s : %s";
consoleUsesPlaceName = true;
}
@ -880,7 +893,7 @@ void Host_Say(edict_t *pEntity, BOOL teamonly)
}
else if (placeName)
{
pszFormat = "#Cstrike_Chat_T_Loc";
pszFormat = bUseLocFallback ? "\x1(Terrorist) \x3%s1\x1 @ \x4%s3\x1 : %s2" : "#Cstrike_Chat_T_Loc";
pszConsoleFormat = "(Terrorist) %s @ %s : %s";
consoleUsesPlaceName = true;
}

View File

@ -179,6 +179,7 @@ cvar_t legacy_vehicle_block = { "mp_legacy_vehicle_block", "1", 0,
cvar_t dying_time = { "mp_dying_time", "3.0", 0, 3.0f, nullptr };
cvar_t defuser_allocation = { "mp_defuser_allocation", "0", 0, 0.0f, nullptr };
cvar_t location_area_info = { "mp_location_area_info", "0", 0, 0.0f, nullptr };
cvar_t chat_loc_fallback = { "mp_chat_loc_fallback", "1", 1, 0.0f, nullptr };
void GameDLL_Version_f()
{
@ -443,6 +444,7 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&freezetime_jump);
CVAR_REGISTER(&defuser_allocation);
CVAR_REGISTER(&location_area_info);
CVAR_REGISTER(&chat_loc_fallback);
// print version
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");

View File

@ -202,6 +202,7 @@ extern cvar_t freezetime_duck;
extern cvar_t freezetime_jump;
extern cvar_t defuser_allocation;
extern cvar_t location_area_info;
extern cvar_t chat_loc_fallback;
#endif

View File

@ -417,7 +417,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Radio)(const char *msg_id, const char *msg
const char *placeName = nullptr;
if ((
#ifdef REGAMEDLL_ADD
location_area_info.value ||
location_area_info.value >= 2 ||
#endif
AreRunningCZero()) && TheBotPhrases)
{
@ -432,14 +432,24 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Radio)(const char *msg_id, const char *msg
}
}
if (!placeName[0])
if (!placeName)
placeName = TheNavAreaGrid.IDToName(playerPlace);
}
if (placeName)
ClientPrint(pEntity->pev, HUD_PRINTRADIO, NumAsString(entindex()), "#Game_radio_location", STRING(pev->netname), placeName, msg_verbose);
if (placeName && placeName[0])
{
bool bUseLocFallback = false;
#ifdef REGAMEDLL_ADD
if (chat_loc_fallback.value)
bUseLocFallback = true;
#endif
ClientPrint(pEntity->pev, HUD_PRINTRADIO, NumAsString(entindex()), bUseLocFallback ? "\x3%s1\x1 @ \x4%s2\x1 (RADIO): %s3" : "#Game_radio_location", STRING(pev->netname), placeName, msg_verbose);
}
else
{
ClientPrint(pEntity->pev, HUD_PRINTRADIO, NumAsString(entindex()), "#Game_radio", STRING(pev->netname), msg_verbose);
}
}
// icon over the head for teammates
@ -10089,11 +10099,11 @@ void CBasePlayer::UpdateLocation(bool forceUpdate)
if (!forceUpdate && m_flLastUpdateTime >= gpGlobals->time + 2.0f)
return;
const char *placeName = "";
const char *placeName = nullptr;
if (pev->deadflag == DEAD_NO && (
#ifdef REGAMEDLL_ADD
location_area_info.value ||
(location_area_info.value == 1 || location_area_info.value == 3) ||
#endif
AreBotsAllowed()))
{
@ -10109,7 +10119,7 @@ void CBasePlayer::UpdateLocation(bool forceUpdate)
}
}
if (!placeName[0])
if (!placeName)
placeName = TheNavAreaGrid.IDToName(playerPlace);
}