Skip to content

Commit

Permalink
Separate mp_location_area_info from chat and radar
Browse files Browse the repository at this point in the history
Add fallback location message for chat
  • Loading branch information
s1lentq committed Apr 8, 2024
1 parent 279bd64 commit 5117374
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
6 changes: 4 additions & 2 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
19 changes: 16 additions & 3 deletions regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 17 additions & 7 deletions regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
Expand Down Expand Up @@ -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()))
{
Expand All @@ -10109,7 +10119,7 @@ void CBasePlayer::UpdateLocation(bool forceUpdate)
}
}

if (!placeName[0])
if (!placeName)
placeName = TheNavAreaGrid.IDToName(playerPlace);
}

Expand Down

0 comments on commit 5117374

Please sign in to comment.