From ed1dd85d6e6a7f6592c30fa18e6ebaa212f5e3d6 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Wed, 30 Sep 2015 06:49:22 +0600 Subject: [PATCH] Refactoring --- regamedll/dlls/client.cpp | 10478 ++++++------- regamedll/dlls/gamerules.h | 129 +- regamedll/dlls/multiplay_gamerules.cpp | 1603 +- regamedll/dlls/player.cpp | 18877 ++++++++++++----------- 4 files changed, 15797 insertions(+), 15290 deletions(-) diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index c53af5c1..064c4388 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -1,5198 +1,5280 @@ -#include "precompiled.h" -#include "entity_state.h" - -/* -* Globals initialization -*/ -#ifndef HOOK_GAMEDLL - -float g_flTimeLimit = 0; -float g_flResetTime = 0; -bool g_bClientPrintEnable = true; - -char *sPlayerModelFiles[] = -{ - "models/player.mdl", - "models/player/leet/leet.mdl", - "models/player/gign/gign.mdl", - "models/player/vip/vip.mdl", - "models/player/gsg9/gsg9.mdl", - "models/player/guerilla/guerilla.mdl", - "models/player/arctic/arctic.mdl", - "models/player/sas/sas.mdl", - "models/player/terror/terror.mdl", - "models/player/urban/urban.mdl", - "models/player/spetsnaz/spetsnaz.mdl", // CZ - "models/player/militia/militia.mdl" // CZ -}; - -bool g_skipCareerInitialSpawn; - -static entity_field_alias_t entity_field_alias[] = -{ - { "origin[0]", 0 }, - { "origin[1]", 0 }, - { "origin[2]", 0 }, - { "angles[0]", 0 }, - { "angles[1]", 0 }, - { "angles[2]", 0 }, -}; - -static entity_field_alias_t player_field_alias[] = -{ - { "origin[0]", 0 }, - { "origin[1]", 0 }, - { "origin[2]", 0 }, -} - -static entity_field_alias_t custom_entity_field_alias[] = -{ - { "origin[0]", 0 }, - { "origin[1]", 0 }, - { "origin[2]", 0 }, - { "angles[0]", 0 }, - { "angles[1]", 0 }, - { "angles[2]", 0 }, - { "skin", 0 }, - { "sequence", 0 }, - { "animtime", 0 }, -} - -static int g_serveractive = 0; - -#else - -float g_flTimeLimit; -float g_flResetTime; -bool g_bClientPrintEnable; - -char *sPlayerModelFiles[12]; -bool g_skipCareerInitialSpawn; - -entity_field_alias_t entity_field_alias[6]; -entity_field_alias_t player_field_alias[3]; -entity_field_alias_t custom_entity_field_alias[9]; -int g_serveractive; - -#endif // HOOK_GAMEDLL - -PLAYERPVSSTATUS g_PVSStatus[32]; -unsigned short m_usResetDecals; -unsigned short g_iShadowSprite; - -/* <47b45> ../cstrike/dlls/client.cpp:76 */ -int CMD_ARGC_(void) -{ - if (!UseBotArgs) - return CMD_ARGC(); - - int i = 0; - - while (BotArgs[i]) - i++; - - return i; -} - -/* <47b84> ../cstrike/dlls/client.cpp:90 */ -const char *CMD_ARGV_(int i) -{ - if (!UseBotArgs) - return CMD_ARGV(i); - - if (i < 4) - return BotArgs[i]; - - return NULL; -} - -/* <47eac> ../cstrike/dlls/client.cpp:180 */ -NOXREF void set_suicide_frame(entvars_t *pev) -{ - if (!FStrEq(STRING(pev->model), "models/player.mdl")) - return; - - pev->solid = SOLID_NOT; - pev->movetype = MOVETYPE_TOSS; - pev->deadflag = DEAD_DEAD; - pev->nextthink = -1; -} - -/* <47a58> ../cstrike/dlls/client.cpp:192 */ -void TeamChangeUpdate(CBasePlayer *player, int team_id) -{ - MESSAGE_BEGIN(MSG_ALL, gmsgTeamInfo); - WRITE_BYTE(player->entindex()); - switch (team_id) - { - case CT: - WRITE_STRING("CT"); - break; - case TERRORIST: - WRITE_STRING("TERRORIST"); - break; - case SPECTATOR: - WRITE_STRING("SPECTATOR"); - break; - default: - WRITE_STRING("UNASSIGNED"); - break; - } - MESSAGE_END(); - - if (team_id != UNASSIGNED) - { - player->SetScoreboardAttributes(); - } -} - -/* <4731f> ../cstrike/dlls/client.cpp:222 */ -void BlinkAccount(CBasePlayer *player, int numBlinks) -{ - MESSAGE_BEGIN(MSG_ONE, gmsgBlinkAcct, NULL, player->pev); - WRITE_BYTE(numBlinks); - MESSAGE_END(); -} - -/* <47efd> ../cstrike/dlls/client.cpp:236 */ -BOOL ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *szRejectReason) -{ - return g_pGameRules->ClientConnected(pEntity, pszName, pszAddress, szRejectReason); -} - -/* <47f5b> ../cstrike/dlls/client.cpp:255 */ -void ClientDisconnect(edict_t *pEntity) -{ - CBasePlayer *pPlayer = (CBasePlayer *)CBaseEntity::Instance(pEntity); - - if (!g_fGameOver) - { - UTIL_ClientPrintAll(HUD_PRINTNOTIFY, "#Game_disconnected", STRING(pEntity->v.netname)); - CSound *pSound = CSoundEnt::SoundPointerForIndex(CSoundEnt::ClientSoundIndex(pEntity)); - - if (pSound) - pSound->Reset(); - - pEntity->v.takedamage = DAMAGE_NO; - pEntity->v.solid = SOLID_NOT; - pEntity->v.flags = FL_DORMANT; - - if (pPlayer) - pPlayer->SetThink(NULL); - - UTIL_SetOrigin(&pEntity->v, pEntity->v.origin); - g_pGameRules->ClientDisconnected(pEntity); - } - - if (pPlayer && pPlayer->IsBot()) - { - TheBots->ClientDisconnect(pPlayer); - } -} - -/* <4c477> ../cstrike/dlls/client.cpp:306 */ -void respawn(entvars_t *pev, BOOL fCopyCorpse) -{ - if (gpGlobals->coop || gpGlobals->deathmatch) - { - CHalfLifeMultiplay *mp = g_pGameRules; - - if (mp->m_iTotalRoundsPlayed > 0) - mp->MarkSpawnSkipped(); - - CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pev); - - if (mp->IsCareer() && mp->ShouldSkipSpawn() && pPlayer->IsAlive()) - g_skipCareerInitialSpawn = true; - - pPlayer->Spawn(); - g_skipCareerInitialSpawn = false; - } - else if (pev->deadflag > DEAD_NO) - { - SERVER_COMMAND("reload\n"); - } -} - -/* <48013> ../cstrike/dlls/client.cpp:347 */ -void ClientKill(edict_t *pEntity) -{ - entvars_t *pev = &pEntity->v; - CHalfLifeMultiplay *mp = g_pGameRules; - CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance(pev); - - if (pl->IsObserver()) - return; - - if (pl->m_iJoiningState != JOINED) - return; - - if (gpGlobals->time >= pl->m_fNextSuicideTime) - { - pl->m_LastHitGroup = 0; - pl->m_fNextSuicideTime = gpGlobals->time + 1; - pEntity->v.health = 0; - pl->Killed(pev, GIB_NEVER); - - if (mp->m_pVIP == pl) - { - mp->m_iConsecutiveVIP = 10; - } - } -} - -/* <47a8a> ../cstrike/dlls/client.cpp:379 */ -void ShowMenu(CBasePlayer *pPlayer, int bitsValidSlots, int nDisplayTime, BOOL fNeedMore, char *pszText) -{ - MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pPlayer->pev); - WRITE_SHORT(bitsValidSlots); - WRITE_CHAR(nDisplayTime); - WRITE_BYTE(fNeedMore); - WRITE_STRING(pszText); - MESSAGE_END(); -} - -/* <4735f> ../cstrike/dlls/client.cpp:390 */ -void ShowVGUIMenu(CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu) -{ - if (pPlayer->m_bVGUIMenus || MenuType > VGUI_Menu_Buy_Item) - { - MESSAGE_BEGIN(MSG_ONE, gmsgVGUIMenu, NULL, pPlayer->pev); - WRITE_BYTE(MenuType); - WRITE_SHORT(BitMask); - WRITE_CHAR(-1); - WRITE_BYTE(0); - WRITE_STRING(" "); - MESSAGE_END(); - } - else - ShowMenu(pPlayer, BitMask, -1, 0, szOldMenu); -} - -/* <4c3c5> ../cstrike/dlls/client.cpp:414 */ -NOXREF int CountTeams(void) -{ - int iNumCT = 0, iNumTerrorist = 0; - CBaseEntity *pPlayer = NULL; - - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) - { - if (FNullEnt(pPlayer->edict())) - break; - - CBasePlayer *player = GetClassPtr((CBasePlayer *)pPlayer->pev); - - if (player->m_iTeam == UNASSIGNED) - continue; - - if (player->pev->flags & FL_DORMANT) - continue; - - if (player->m_iTeam == SPECTATOR) - continue; - - if (player->m_iTeam == CT) - iNumCT++; - - else if (player->m_iTeam == TERRORIST) - iNumTerrorist++; - } - - return iNumCT - iNumTerrorist; -} - -/* <4c2be> ../cstrike/dlls/client.cpp:443 */ -void ListPlayers(CBasePlayer *current) -{ - char message[120], cNumber[12]; - Q_strcpy(message, ""); - - CBaseEntity *pPlayer = NULL; - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) - { - if (FNullEnt(pPlayer->edict())) - break; - - if (pPlayer->pev->flags & FL_DORMANT) - continue; - - CBasePlayer *player = GetClassPtr((CBasePlayer *)pPlayer->pev); - int iUserID = GETPLAYERUSERID(ENT(player->pev)); - - Q_sprintf(cNumber, "%d", iUserID); - Q_strcpy(message, "\n"); - Q_strcat(message, cNumber); - Q_strcat(message, " : "); - Q_strcat(message, STRING(player->pev->netname)); - - ClientPrint(current->pev, HUD_PRINTCONSOLE, message); - } - - ClientPrint(current->pev, HUD_PRINTCONSOLE, "\n"); -} - -/* <4c200> ../cstrike/dlls/client.cpp:475 */ -int CountTeamPlayers(int iTeam) -{ - CBaseEntity *pPlayer = NULL; - int i = 0; - - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) - { - if (FNullEnt(pPlayer->edict())) - break; - - if (pPlayer->pev->flags & FL_DORMANT) - continue; - - if (GetClassPtr((CBasePlayer *)pPlayer->pev)->m_iTeam == iTeam) - i++; - } - - return i; -} - -/* <4c4ef> ../cstrike/dlls/client.cpp:494 */ -void ProcessKickVote(CBasePlayer *pVotingPlayer, CBasePlayer *pKickPlayer) -{ - CBaseEntity *pTempEntity; - CBasePlayer *pTempPlayer; - int iValidVotes; - int iVoteID; - int iVotesNeeded; - float fKickPercent; - - if (!pVotingPlayer || !pKickPlayer) - return; - - int iTeamCount = CountTeamPlayers(pVotingPlayer->m_iTeam); - - if (iTeamCount < 3) - return; - - iValidVotes = 0; - pTempEntity = NULL; - iVoteID = pVotingPlayer->m_iCurrentKickVote; - - while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player")) != NULL) - { - if (FNullEnt(pTempEntity->edict())) - break; - - pTempPlayer = GetClassPtr((CBasePlayer *)pTempEntity->pev); - - if (!pTempPlayer || pTempPlayer->m_iTeam == UNASSIGNED) - continue; - - if (pTempPlayer->m_iTeam == pVotingPlayer->m_iTeam && pTempPlayer->m_iCurrentKickVote == iVoteID) - iValidVotes++; - } - - if (kick_percent.value < 0) - CVAR_SET_STRING("mp_kickpercent", "0.0"); - - else if (kick_percent.value > 1) - CVAR_SET_STRING("mp_kickpercent", "1.0"); - - iVotesNeeded = iValidVotes; - fKickPercent = (iTeamCount * kick_percent.value + 0.5); - - if (iVotesNeeded >= (int)fKickPercent) - { - UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Game_kicked", STRING(pKickPlayer->pev->netname)); - SERVER_COMMAND(UTIL_VarArgs("kick # %d\n", iVoteID)); - pTempEntity = NULL; - - while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player")) != NULL) - { - if (FNullEnt(pTempEntity->edict())) - break; - - pTempPlayer = GetClassPtr((CBasePlayer *)pTempEntity->pev); - - if (!pTempPlayer || pTempPlayer->m_iTeam == UNASSIGNED) - continue; - - if (pTempPlayer->m_iTeam == pVotingPlayer->m_iTeam && pTempPlayer->m_iCurrentKickVote == iVoteID) - pTempPlayer->m_iCurrentKickVote = 0; - } - } -} - -/* <48298> ../cstrike/dlls/client.cpp:580 */ -TeamName SelectDefaultTeam(void) -{ - TeamName team = UNASSIGNED; - CHalfLifeMultiplay *mp = g_pGameRules; - - if (mp->m_iNumTerrorist < mp->m_iNumCT) - team = TERRORIST; - else if (mp->m_iNumTerrorist > mp->m_iNumCT) - team = CT; - - else if (mp->m_iNumCTWins > mp->m_iNumTerroristWins) - team = TERRORIST; - - else if (mp->m_iNumCTWins < mp->m_iNumTerroristWins) - team = CT; - else - team = RANDOM_LONG(0, 1) ? TERRORIST : CT; - - if (mp->TeamFull(team)) - { - if (team == TERRORIST) - team = CT; - else - team = TERRORIST; - - if (mp->TeamFull(team)) - return UNASSIGNED; - } - - return team; - -} - -/* <473a3> ../cstrike/dlls/client.cpp:638 */ -void CheckStartMoney(void) -{ - int money = (int)startmoney.value; - - if (money > 16000) - CVAR_SET_FLOAT("mp_startmoney", 16000); - else if (money < 800) - CVAR_SET_FLOAT("mp_startmoney", 800); -} - -/* <4c084> ../cstrike/dlls/client.cpp:661 */ -void ClientPutInServer(edict_t *pEntity) -{ - entvars_t *pev = &pEntity->v; - CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pev); - CHalfLifeMultiplay *mp = g_pGameRules; - - pPlayer->SetCustomDecalFrames(-1); - pPlayer->SetPrefsFromUserinfo(GET_INFO_BUFFER(pEntity)); - - if (!mp->IsMultiplayer()) - { - pPlayer->Spawn(); - return; - } - - pPlayer->m_bNotKilled = true; - pPlayer->m_iIgnoreGlobalChat = IGNOREMSG_NONE; - pPlayer->m_iTeamKills = 0; - pPlayer->m_bJustConnected = true; - pPlayer->Spawn(); - pPlayer->m_bTeamChanged = false; - pPlayer->m_iNumSpawns = 0; - - CheckStartMoney(); - - pPlayer->m_iAccount = (int)startmoney.value; - pPlayer->m_fGameHUDInitialized = FALSE; - pPlayer->m_flDisplayHistory &= ~DHF_ROUND_STARTED; - pPlayer->pev->flags |= FL_SPECTATOR; - pPlayer->pev->solid = SOLID_NOT; - pPlayer->pev->movetype = MOVETYPE_NOCLIP; - pPlayer->pev->effects = EF_NODRAW; - pPlayer->pev->effects |= EF_NOINTERP; - pPlayer->pev->takedamage = DAMAGE_NO; - pPlayer->pev->deadflag = DEAD_DEAD; - pPlayer->pev->velocity = g_vecZero; - pPlayer->pev->punchangle = g_vecZero; - pPlayer->m_iJoiningState = READINGLTEXT; - pPlayer->m_iTeam = UNASSIGNED; - pPlayer->pev->fixangle = 1; - pPlayer->m_iModelName = MODEL_URBAN; - pPlayer->m_bContextHelp = true; - pPlayer->m_bHasNightVision = false; - pPlayer->m_iHostagesKilled = 0; - pPlayer->m_iMapVote = 0; - pPlayer->m_iCurrentKickVote = 0; - pPlayer->m_fDeadTime = 0; - pPlayer->has_disconnected = false; - pPlayer->m_iMenu = Menu_OFF; - pPlayer->ClearAutoBuyData(); - pPlayer->m_rebuyString = NULL; - - SET_CLIENT_MAXSPEED(ENT(pPlayer->pev), 1); - SET_MODEL(ENT(pPlayer->pev), "models/player.mdl"); - - pPlayer->SetThink(NULL); - - CBaseEntity *Target = UTIL_FindEntityByClassname(NULL, "trigger_camera"); - pPlayer->m_pIntroCamera = Target; - - if (mp && mp->m_bMapHasCameras == MAP_HAS_CAMERAS_INIT) - { - mp->m_bMapHasCameras = (Target != NULL); - } - - if (pPlayer->m_pIntroCamera) - Target = UTIL_FindEntityByTargetname(NULL, STRING(pPlayer->m_pIntroCamera->pev->target)); - - if (pPlayer->m_pIntroCamera && Target) - { - Vector CamAngles = UTIL_VecToAngles((Target->pev->origin - pPlayer->m_pIntroCamera->pev->origin).Normalize()); - CamAngles.x = -CamAngles.x; - - UTIL_SetOrigin(pPlayer->pev, pPlayer->m_pIntroCamera->pev->origin); - - pPlayer->pev->angles = CamAngles; - pPlayer->pev->v_angle = pPlayer->pev->angles; - - pPlayer->m_fIntroCamTime = gpGlobals->time + 6; - pPlayer->pev->view_ofs = g_vecZero; - } - else - { - pPlayer->m_iTeam = CT; - - if (mp) - { - mp->GetPlayerSpawnSpot(pPlayer); - } - - pPlayer->m_iTeam = UNASSIGNED; - pPlayer->pev->v_angle = g_vecZero; - pPlayer->pev->angles = gpGlobals->v_forward; - } - - TheBots->OnEvent(EVENT_PLAYER_CHANGED_TEAM, (CBaseEntity *)pPlayer); - pPlayer->m_iJoiningState = SHOWLTEXT; - - static char sName[128]; - Q_strcpy(sName, STRING(pPlayer->pev->netname)); - - for (char *pApersand = sName; pApersand && *pApersand != '\0'; pApersand++) - { - if (*pApersand == '%') - *pApersand = ' '; - } - - UTIL_ClientPrintAll(HUD_PRINTNOTIFY, "#Game_connected", (sName[0] != '\0') ? sName : ""); -} - -/* <478f7> ../cstrike/dlls/client.cpp:792 */ -int Q_strlen_(const char *str) -{ - int count = 0; - if (str && *str) - { - while (str[count++ + 1]); - } - return count; -} - -/* <4bbff> ../cstrike/dlls/client.cpp:814 */ -void Host_Say(edict_t *pEntity, int teamonly) -{ - CBasePlayer *client; - int j; - char *p; - char text[128]; - char szTemp[256]; - const char *cpSay = "say"; - const char *cpSayTeam = "say_team"; - const char *pcmd = CMD_ARGV_(0); - bool bSenderDead = false; - - entvars_t *pev = &pEntity->v; - CBasePlayer *player = GetClassPtr((CBasePlayer *)pev); - - if (player->m_flLastTalk != 0.0f && gpGlobals->time - player->m_flLastTalk < 0.66f) - return; - - player->m_flLastTalk = gpGlobals->time; - - if (player->pev->deadflag != DEAD_NO) - bSenderDead = true; - - // We can get a raw string now, without the "say " prepended - if (CMD_ARGC_() == 0) - return; - - if (!Q_stricmp(pcmd, cpSay) || !Q_stricmp(pcmd, cpSayTeam)) - { - if (CMD_ARGC_() >= 2) - { - p = (char *)CMD_ARGS(); - } - else - { - // say with a blank message, nothing to do - return; - } - } - else // Raw text, need to prepend argv[0] - { - if (CMD_ARGC_() >= 2) - { - Q_sprintf(szTemp, "%s %s", (char *)pcmd, (char *)CMD_ARGS()); - } - else - { - // Just a one word command, use the first word...sigh - Q_sprintf(szTemp, "%s", (char *)pcmd); - } - - p = szTemp; - } - - // remove quotes if present - if (*p == '"') - { - p++; - p[Q_strlen(p) - 1] = '\0'; - } - - // make sure the text has content - if (!p || !p[0] || !Q_UnicodeValidate(p)) - { - // no character found, so say nothing - return; - } - - Q_StripUnprintableAndSpace(p); - - if (Q_strlen(p) <= 0) - return; - - const char *placeName = NULL; - char *pszFormat = NULL; - char *pszConsoleFormat = NULL; - bool consoleUsesPlaceName = false; - - if (teamonly) - { - if (player->m_iTeam == CT || player->m_iTeam == TERRORIST) - { - // search the place name where is located the player - Place playerPlace = TheNavAreaGrid.GetPlace(&player->pev->origin); - const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); - - for (BotPhraseList::const_iterator iter = placeList->begin(); iter != placeList->end(); ++iter) - { - if ((*iter)->GetID() == playerPlace) - { - placeName = (*iter)->GetName(); - break; - } - } - } - - if (player->m_iTeam == CT) - { - if (bSenderDead) - { - pszFormat = "#Cstrike_Chat_CT_Dead"; - pszConsoleFormat = "*DEAD*(Counter-Terrorist) %s : %s"; - } - else if (placeName != NULL) - { - pszFormat = "#Cstrike_Chat_CT_Loc"; - pszConsoleFormat = "*(Counter-Terrorist) %s @ %s : %s"; - consoleUsesPlaceName = true; - } - else - { - pszFormat = "#Cstrike_Chat_CT"; - pszConsoleFormat = "(Counter-Terrorist) %s : %s"; - } - } - else if (player->m_iTeam == TERRORIST) - { - if (bSenderDead) - { - pszFormat = "#Cstrike_Chat_T_Dead"; - pszConsoleFormat = "*DEAD*(Terrorist) %s : %s"; - } - else if (placeName != NULL) - { - pszFormat = "#Cstrike_Chat_T_Loc"; - pszConsoleFormat = "(Terrorist) %s @ %s : %s"; - consoleUsesPlaceName = true; - } - else - { - pszFormat = "#Cstrike_Chat_T"; - pszConsoleFormat = "(Terrorist) %s : %s"; - } - } - else - { - pszFormat = "#Cstrike_Chat_Spec"; - pszConsoleFormat = "(Spectator) %s : %s"; - } - } - else - { - if (bSenderDead) - { - if (player->m_iTeam == SPECTATOR) - { - pszFormat = "#Cstrike_Chat_AllSpec"; - pszConsoleFormat = "*SPEC* %s : %s"; - } - else - { - pszFormat = "#Cstrike_Chat_AllDead"; - pszConsoleFormat = "*DEAD* %s : %s"; - } - } - else - { - pszFormat = "#Cstrike_Chat_All"; - pszConsoleFormat = "%s : %s"; - } - } - - text[0] = '\0'; - - // -3 for /n and null terminator - j = sizeof(text) - 3 - Q_strlen(text) - Q_strlen(pszFormat); - - if (placeName != NULL) - { - j -= Q_strlen(placeName) + 1; - } - - if ((signed int)Q_strlen(p) > j) - p[j] = 0; - - for (char *pAmpersand = p; pAmpersand != NULL && *pAmpersand != '\0'; pAmpersand++) - { - if (pAmpersand[0] == '%') - { - if (pAmpersand[1] != 'l' && pAmpersand[1] != ' ' && pAmpersand[1] != '\0') - { - pAmpersand[0] = ' '; - } - } - } - - Q_strcat(text, p); - Q_strcat(text, "\n"); - - // loop through all players - // Start with the first player. - // This may return the world in single player if the client types something between levels or during spawn - // so check it, or it will infinite loop - - client = NULL; - while ((client = (CBasePlayer *)UTIL_FindEntityByClassname(client, "player")) != NULL) - { - if (FNullEnt(client->edict())) - break; - - if (!client->pev) - continue; - - if (client->edict() == pEntity) - continue; - - // Not a client ? (should never be true) - if (!client->IsNetClient()) - continue; - - // can the receiver hear the sender? or has he muted him? - if (gpGlobals->deathmatch != 0.0f && g_pGameRules->m_VoiceGameMgr.PlayerHasBlockedPlayer(client, player)) - continue; - - if (teamonly && client->m_iTeam != player->m_iTeam) - continue; - - if ((client->pev->deadflag != DEAD_NO && !bSenderDead) || (client->pev->deadflag == DEAD_NO && bSenderDead)) - { - if (!(player->pev->flags & FL_PROXY)) - continue; - } - - if ((client->m_iIgnoreGlobalChat == IGNOREMSG_ENEMY && client->m_iTeam == player->m_iTeam) - || client->m_iIgnoreGlobalChat == IGNOREMSG_NONE) - { - MESSAGE_BEGIN(MSG_ONE, gmsgSayText, NULL, client->pev); - WRITE_BYTE(ENTINDEX(pEntity)); - WRITE_STRING(pszFormat); - WRITE_STRING(""); - WRITE_STRING(text); - - if (placeName != NULL) - { - WRITE_STRING(placeName); - } - - MESSAGE_END(); - } - } - - char *fullText = p; - - // print to the sending client - MESSAGE_BEGIN(MSG_ONE, gmsgSayText, NULL, &pEntity->v); - WRITE_BYTE(ENTINDEX(pEntity)); - WRITE_STRING(pszFormat); - WRITE_STRING(""); - WRITE_STRING(text); - - if (placeName != NULL) - { - WRITE_STRING(placeName); - } - - MESSAGE_END(); - - // echo to server console - if (pszConsoleFormat) - { - if (placeName && consoleUsesPlaceName) - SERVER_PRINT(UTIL_VarArgs(pszConsoleFormat, STRING(player->pev->netname), placeName, text)); - else - SERVER_PRINT(UTIL_VarArgs(pszConsoleFormat, STRING(player->pev->netname), text)); - } - else - SERVER_PRINT(text); - - if (CVAR_GET_FLOAT("mp_logmessages") != 0) - { - const char *temp = teamonly ? "say_team" : "say"; - const char *deadText = (player->m_iTeam != SPECTATOR && bSenderDead) ? " (dead)" : ""; - - char *szTeam = GetTeam(player->m_iTeam); - - UTIL_LogPrintf - ( - "\"%s<%i><%s><%s>\" %s \"%s\"%s\n", - STRING(player->pev->netname), - GETPLAYERUSERID(player->edict()), - GETPLAYERAUTHID(player->edict()), - szTeam, - temp, - fullText, - deadText - ); - } -} - -/* <4865e> ../cstrike/dlls/client.cpp:1160 */ -void DropSecondary(CBasePlayer *pPlayer) -{ - if (pPlayer->HasShield()) - { - if (pPlayer->HasShield() && pPlayer->m_bShieldDrawn && pPlayer->m_pActiveItem != NULL) - { - ((CBasePlayerWeapon *)pPlayer->m_pActiveItem)->SecondaryAttack(); - } - - pPlayer->m_bShieldDrawn = false; - } - - CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]; - - if (pWeapon != NULL) - { - pPlayer->DropPlayerItem(STRING(pWeapon->pev->classname)); - } - -} - -/* <473db> ../cstrike/dlls/client.cpp:1182 */ -void DropPrimary(CBasePlayer *pPlayer) -{ - if (pPlayer->HasShield()) - { - pPlayer->DropShield(); - return; - } - - if (pPlayer->m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]) - { - pPlayer->DropPlayerItem(STRING(pPlayer->m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]->pev->classname)); - } -} - -/* <483a2> ../cstrike/dlls/client.cpp:1197 */ -bool CanBuyThis(CBasePlayer *pPlayer, int iWeapon) -{ - CHalfLifeMultiplay *mp = g_pGameRules; - - if (pPlayer->HasShield() && iWeapon == WEAPON_ELITE) - { - return false; - } - - if (pPlayer->HasShield() && iWeapon == WEAPON_SHIELDGUN) - { - return false; - } - - if (pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ] != NULL && pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]->m_iId == WEAPON_ELITE && iWeapon == WEAPON_SHIELDGUN) - { - return false; - } - - if (pPlayer->m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ] != NULL && pPlayer->m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]->m_iId == iWeapon) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Cstrike_Already_Own_Weapon"); - } - - return false; - } - - if (pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ] != NULL && pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]->m_iId == iWeapon) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Cstrike_Already_Own_Weapon"); - } - - return false; - } - - if (!CanBuyWeaponByMaptype(pPlayer->m_iTeam, (WeaponIdType)iWeapon, (mp->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES))) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Cannot_Buy_This"); - } - - return false; - } - - return true; -} - -/* <48696> ../cstrike/dlls/client.cpp:1247 */ -void BuyPistol(CBasePlayer *pPlayer, int iSlot) -{ - int iWeapon = 0; - int iWeaponPrice = 0; - const char *pszWeapon = NULL; - - if (!pPlayer->CanPlayerBuy(true)) - { - return; - } - - if (iSlot < 1 || iSlot > 5) - { - return; - } - - switch (iSlot) - { - case 1: - { - iWeapon = WEAPON_GLOCK18; - iWeaponPrice = GLOCK18_PRICE; - pszWeapon = "weapon_glock18"; - break; - } - case 2: - { - iWeapon = WEAPON_USP; - iWeaponPrice = USP_PRICE; - pszWeapon = "weapon_usp"; - break; - } - case 3: - { - iWeapon = WEAPON_P228; - iWeaponPrice = P228_PRICE; - pszWeapon = "weapon_p228"; - break; - } - case 4: - { - iWeapon = WEAPON_DEAGLE; - iWeaponPrice = DEAGLE_PRICE; - pszWeapon = "weapon_deagle"; - break; - } - case 5: - { - if (pPlayer->m_iTeam == CT) - { - iWeapon = WEAPON_FIVESEVEN; - iWeaponPrice = FIVESEVEN_PRICE; - pszWeapon = "weapon_fiveseven"; - } - else - { - iWeapon = WEAPON_ELITE; - iWeaponPrice = ELITE_PRICE; - pszWeapon = "weapon_elite"; - } - - break; - } - } - - if (!CanBuyThis(pPlayer, iWeapon)) - { - return; - } - - if (pPlayer->m_iAccount < iWeaponPrice) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); - BlinkAccount(pPlayer, 2); - } - - return; - } - - DropSecondary(pPlayer); - - pPlayer->GiveNamedItem(pszWeapon); - pPlayer->AddAccount(-iWeaponPrice); - - if (TheTutor) - { - TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); - } -} - -/* <487b0> ../cstrike/dlls/client.cpp:1325 */ -void BuyShotgun(CBasePlayer *pPlayer, int iSlot) -{ - int iWeapon = 0; - int iWeaponPrice = 0; - const char *pszWeapon = NULL; - - if (!pPlayer->CanPlayerBuy(true)) - { - return; - } - - if (iSlot < 1 || iSlot > 2) - { - return; - } - - switch (iSlot) - { - case 1: - { - iWeapon = WEAPON_M3; - iWeaponPrice = M3_PRICE; - pszWeapon = "weapon_m3"; - break; - } - case 2: - { - iWeapon = WEAPON_XM1014; - iWeaponPrice = XM1014_PRICE; - pszWeapon = "weapon_xm1014"; - break; - } - } - - if (!CanBuyThis(pPlayer, iWeapon)) - { - return; - } - - if (pPlayer->m_iAccount < iWeaponPrice) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); - BlinkAccount(pPlayer, 2); - } - - return; - } - - DropPrimary(pPlayer); - - pPlayer->GiveNamedItem(pszWeapon); - pPlayer->AddAccount(-iWeaponPrice); - - if (TheTutor) - { - TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); - } -} - -/* <488b5> ../cstrike/dlls/client.cpp:1378 */ -void BuySubMachineGun(CBasePlayer *pPlayer, int iSlot) -{ - int iWeapon = 0; - int iWeaponPrice = 0; - const char *pszWeapon = NULL; - - if (!pPlayer->CanPlayerBuy(true)) - { - return; - } - - if (iSlot < 1 || iSlot > 4) - { - return; - } - - switch (iSlot) - { - case 1: - { - if (pPlayer->m_iTeam == CT) - { - iWeapon = WEAPON_TMP; - iWeaponPrice = TMP_PRICE; - pszWeapon = "weapon_tmp"; - } - else - { - iWeapon = WEAPON_MAC10; - iWeaponPrice = MAC10_PRICE; - pszWeapon = "weapon_mac10"; - } - - break; - } - case 2: - { - iWeapon = WEAPON_MP5N; - iWeaponPrice = MP5NAVY_PRICE; - pszWeapon = "weapon_mp5navy"; - break; - } - case 3: - { - iWeapon = WEAPON_UMP45; - iWeaponPrice = UMP45_PRICE; - pszWeapon = "weapon_ump45"; - break; - } - case 4: - { - iWeapon = WEAPON_P90; - iWeaponPrice = P90_PRICE; - pszWeapon = "weapon_p90"; - break; - } - } - - if (!CanBuyThis(pPlayer, iWeapon)) - { - return; - } - - if (pPlayer->m_iAccount < iWeaponPrice) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); - BlinkAccount(pPlayer, 2); - } - - return; - } - - DropPrimary(pPlayer); - - pPlayer->GiveNamedItem(pszWeapon); - pPlayer->AddAccount(-iWeaponPrice); - - if (TheTutor) - { - TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); - } -} - -/* <489bb> ../cstrike/dlls/client.cpp:1450 */ -void BuyWeaponByWeaponID(CBasePlayer *pPlayer, WeaponIdType weaponID) -{ - if (!pPlayer->CanPlayerBuy(true)) - { - return; - } - - if (!CanBuyThis(pPlayer, weaponID)) - { - return; - } - - WeaponInfoStruct *info = GetWeaponInfo(weaponID); - - if (!info || !info->entityName) - { - return; - } - - if (pPlayer->m_iAccount < info->cost) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); - BlinkAccount(pPlayer, 2); - } - - return; - } - - if (IsPrimaryWeapon(weaponID)) - { - DropPrimary(pPlayer); - } - else - { - DropSecondary(pPlayer); - } - - pPlayer->GiveNamedItem(info->entityName); - pPlayer->AddAccount(-info->cost); - - if (TheTutor) - { - TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); - } -} - -/* <48adf> ../cstrike/dlls/client.cpp:1498 */ -void BuyRifle(CBasePlayer *pPlayer, int iSlot) -{ - int iWeapon = 0; - int iWeaponPrice = 0; - bool bIsCT = false; - const char *pszWeapon = NULL; - - if (!pPlayer->CanPlayerBuy(true)) - { - return; - } - - if (iSlot < 1 || iSlot > 6) - { - return; - } - - if (pPlayer->m_iTeam == CT) - bIsCT = true; - - switch (iSlot) - { - case 2: - { - if (bIsCT) - { - iWeapon = WEAPON_SCOUT; - iWeaponPrice = SCOUT_PRICE; - pszWeapon = "weapon_scout"; - } - else - { - iWeapon = WEAPON_AK47; - iWeaponPrice = AK47_PRICE; - pszWeapon = "weapon_ak47"; - } - - break; - } - case 3: - { - if (bIsCT) - { - iWeapon = WEAPON_M4A1; - iWeaponPrice = M4A1_PRICE; - pszWeapon = "weapon_m4a1"; - } - else - { - iWeapon = WEAPON_SCOUT; - iWeaponPrice = SCOUT_PRICE; - pszWeapon = "weapon_scout"; - } - - break; - } - case 4: - { - if (bIsCT) - { - iWeapon = WEAPON_AUG; - iWeaponPrice = AUG_PRICE; - pszWeapon = "weapon_aug"; - } - else - { - iWeapon = WEAPON_SG552; - iWeaponPrice = SG552_PRICE; - pszWeapon = "weapon_sg552"; - } - - break; - } - case 5: - { - if (bIsCT) - { - iWeapon = WEAPON_SG550; - iWeaponPrice = SG550_PRICE; - pszWeapon = "weapon_sg550"; - } - else - { - iWeapon = WEAPON_AWP; - iWeaponPrice = AWP_PRICE; - pszWeapon = "weapon_awp"; - } - - break; - } - case 6: - { - if (bIsCT) - { - iWeapon = WEAPON_AWP; - iWeaponPrice = AWP_PRICE; - pszWeapon = "weapon_awp"; - } - else - { - iWeapon = WEAPON_G3SG1; - iWeaponPrice = G3SG1_PRICE; - pszWeapon = "weapon_g3sg1"; - } - - break; - } - default: - { - if (bIsCT) - { - iWeapon = WEAPON_FAMAS; - iWeaponPrice = FAMAS_PRICE; - pszWeapon = "weapon_famas"; - } - else - { - iWeapon = WEAPON_GALIL; - iWeaponPrice = GALIL_PRICE; - pszWeapon = "weapon_galil"; - } - - break; - } - } - - if (!CanBuyThis(pPlayer, iWeapon)) - { - return; - } - - if (pPlayer->m_iAccount < iWeaponPrice) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); - BlinkAccount(pPlayer, 2); - } - - return; - } - - DropPrimary(pPlayer); - - pPlayer->GiveNamedItem(pszWeapon); - pPlayer->AddAccount(-iWeaponPrice); - - if (TheTutor) - { - TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); - } -} - -/* <48bf5> ../cstrike/dlls/client.cpp:1629 */ -void BuyMachineGun(CBasePlayer *pPlayer, int iSlot) -{ - int iWeapon = WEAPON_M249; - int iWeaponPrice = M249_PRICE; - const char *pszWeapon = "weapon_m249"; - - if (!pPlayer->CanPlayerBuy(true)) - { - return; - } - - if (iSlot != 1) - { - return; - } - - if (!CanBuyThis(pPlayer, iWeapon)) - { - return; - } - - if (pPlayer->m_iAccount < iWeaponPrice) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); - BlinkAccount(pPlayer, 2); - } - - return; - } - - DropPrimary(pPlayer); - - pPlayer->GiveNamedItem(pszWeapon); - pPlayer->AddAccount(-iWeaponPrice); - - if (TheTutor) - { - TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); - } -} - -/* <473f8> ../cstrike/dlls/client.cpp:1677 */ -void BuyItem(CBasePlayer *pPlayer, int iSlot) -{ - //int iItem = 0; - int iItemPrice = 0; - const char *pszItem = NULL; - - if (!pPlayer->CanPlayerBuy(true)) - return; - - if (pPlayer->m_iTeam == CT) - { - if (iSlot < 1 || iSlot > 8) - return; - } - else - { - if (iSlot < 1 || iSlot > 6) - return; - } - - int fullArmor = (pPlayer->pev->armorvalue >= 100); - int helmet = (pPlayer->m_iKevlar == ARMOR_TYPE_HELMET); - //int price; - int enoughMoney = 1; - - switch (iSlot) - { - case MENU_SLOT_ITEM_VEST: - { - if (fullArmor) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Kevlar"); - } - - return; - } - - if (pPlayer->m_iAccount >= KEVLAR_PRICE) - { - if (helmet) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Helmet_Bought_Kevlar"); - } - } - - pszItem = "item_kevlar"; - iItemPrice = KEVLAR_PRICE; - } - else - enoughMoney = 0; - - break; - } - case MENU_SLOT_ITEM_VESTHELM: - { - if (fullArmor) - { - if (helmet) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Kevlar_Helmet"); - } - - return; - } - - if (pPlayer->m_iAccount >= HELMET_PRICE) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Kevlar_Bought_Helmet"); - } - - pszItem = "item_assaultsuit"; - iItemPrice = HELMET_PRICE; - } - else - enoughMoney = 0; - - break; - } - else - { - if (helmet) - { - if (pPlayer->m_iAccount >= KEVLAR_PRICE) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Helmet_Bought_Kevlar"); - } - - pszItem = "item_assaultsuit"; - iItemPrice = KEVLAR_PRICE; - } - else - enoughMoney = 0; - } - else - { - if (pPlayer->m_iAccount >= ASSAULTSUIT_PRICE) - { - pszItem = "item_assaultsuit"; - iItemPrice = ASSAULTSUIT_PRICE; - } - else - enoughMoney = 0; - } - } - - break; - } - case MENU_SLOT_ITEM_FLASHGREN: - { - if (pPlayer->AmmoInventory(pPlayer->GetAmmoIndex("Flashbang")) >= 2) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Cannot_Carry_Anymore"); - } - - return; - } - - if (pPlayer->m_iAccount >= FLASHBANG_PRICE) - { - pszItem = "weapon_flashbang"; - iItemPrice = FLASHBANG_PRICE; - - } - else - enoughMoney = 0; - - break; - } - case MENU_SLOT_ITEM_HEGREN: - { - if (pPlayer->AmmoInventory(pPlayer->GetAmmoIndex("HEGrenade")) >= 1) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Cannot_Carry_Anymore"); - } - - return; - } - - if (pPlayer->m_iAccount >= HEGRENADE_PRICE) - { - pszItem = "weapon_hegrenade"; - iItemPrice = HEGRENADE_PRICE; - } - else - enoughMoney = 0; - - break; - } - case MENU_SLOT_ITEM_SMOKEGREN: - { - if (pPlayer->AmmoInventory(pPlayer->GetAmmoIndex("SmokeGrenade")) >= 1) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Cannot_Carry_Anymore"); - } - - return; - } - - if (pPlayer->m_iAccount >= SMOKEGRENADE_PRICE) - { - pszItem = "weapon_smokegrenade"; - iItemPrice = SMOKEGRENADE_PRICE; - } - else - enoughMoney = 0; - - break; - } - case MENU_SLOT_ITEM_NVG: - { - if (pPlayer->m_bHasNightVision) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_One"); - } - - return; - } - - if (pPlayer->m_iAccount >= NVG_PRICE) - { - if (!(pPlayer->m_flDisplayHistory & DHF_NIGHTVISION)) - { - pPlayer->HintMessage("#Hint_use_nightvision"); - pPlayer->m_flDisplayHistory |= DHF_NIGHTVISION; - } - - EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/equip_nvg.wav", VOL_NORM, ATTN_NORM); - - pPlayer->m_bHasNightVision = true; - pPlayer->AddAccount(-NVG_PRICE); - - SendItemStatus(pPlayer); - } - else - enoughMoney = 0; - - break; - } - case MENU_SLOT_ITEM_DEFUSEKIT: - { - if (pPlayer->m_iTeam != CT || !g_pGameRules->m_bMapHasBombTarget) - { - return; - } - - if (pPlayer->m_bHasDefuser) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_One"); - } - - return; - } - - if (pPlayer->m_iAccount >= DEFUSEKIT_PRICE) - { - pPlayer->m_bHasDefuser = true; - - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pPlayer->pev); - WRITE_BYTE(STATUSICON_SHOW); - WRITE_STRING("defuser"); - WRITE_BYTE(0); - WRITE_BYTE(160); - WRITE_BYTE(0); - MESSAGE_END(); - - pPlayer->pev->body = 1; - pPlayer->AddAccount(-DEFUSEKIT_PRICE); - - EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/kevlar.wav", VOL_NORM, ATTN_NORM); - SendItemStatus(pPlayer); - } - else - enoughMoney = 0; - - break; - } - case MENU_SLOT_ITEM_SHIELD: - { - if (!CanBuyThis(pPlayer, WEAPON_SHIELDGUN)) - { - return; - } - - if (pPlayer->m_iAccount >= SHIELDGUN_PRICE) - { - DropPrimary(pPlayer); - - pPlayer->GiveShield(true); - pPlayer->AddAccount(-SHIELDGUN_PRICE); - - EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM); - } - else - enoughMoney = 0; - - break; - } - } - - if (!enoughMoney) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); - BlinkAccount(pPlayer, 2); - } - - return; - } - - if (pszItem != NULL) - { - pPlayer->GiveNamedItem(pszItem); - pPlayer->AddAccount(-iItemPrice); - } - - if (TheTutor) - { - TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); - } -} - -/* <48d40> ../cstrike/dlls/client.cpp:1998 */ -void HandleMenu_ChooseAppearance(CBasePlayer *player, int slot) -{ - CHalfLifeMultiplay *mp = g_pGameRules; - int numSkins = UTIL_IsGame("czero") ? CZ_NUM_SKIN : CS_NUM_SKIN; - - struct - { - ModelName model_id; - char *model_name; - int model_name_index; - - } appearance; - - Q_memset(&appearance, 0, sizeof(appearance)); - - if (player->m_iTeam == TERRORIST) - { - if ((slot > numSkins || slot < 1) && (!TheBotProfiles->GetCustomSkin(slot) || !player->IsBot())) - { - slot = RANDOM_LONG(1, numSkins); - } - - switch (slot) - { - case 1: - appearance.model_id = MODEL_TERROR; - appearance.model_name = "terror"; - break; - case 2: - appearance.model_id = MODEL_LEET; - appearance.model_name = "leet"; - break; - case 3: - appearance.model_id = MODEL_ARCTIC; - appearance.model_name = "arctic"; - break; - case 4: - appearance.model_id = MODEL_GUERILLA; - appearance.model_name = "guerilla"; - break; - case 5: - if (UTIL_IsGame("czero")) - { - appearance.model_id = MODEL_MILITIA; - appearance.model_name = "militia"; - break; - } - default: - if (TheBotProfiles->GetCustomSkinModelname(slot) && player->IsBot()) - { - appearance.model_name = (char *)TheBotProfiles->GetCustomSkinModelname(slot); - } - else - { - appearance.model_id = MODEL_TERROR; - appearance.model_name = "terror"; - } - break; - } - - // default T model models/player/terror/terror.mdl - appearance.model_name_index = 8; - - } - else if (player->m_iTeam == CT) - { - if ((slot > numSkins || slot < 1) && (!TheBotProfiles->GetCustomSkin(slot) || !player->IsBot())) - { - slot = RANDOM_LONG(1, numSkins); - } - - switch (slot) - { - case 1: - appearance.model_id = MODEL_URBAN; - appearance.model_name = "urban"; - break; - case 2: - appearance.model_id = MODEL_GSG9; - appearance.model_name = "gsg9"; - break; - case 3: - appearance.model_id = MODEL_SAS; - appearance.model_name = "sas"; - break; - case 4: - appearance.model_id = MODEL_GIGN; - appearance.model_name = "gign"; - break; - case 5: - if (UTIL_IsGame("czero")) - { - appearance.model_id = MODEL_SPETSNAZ; - appearance.model_name = "spetsnaz"; - break; - } - default: - if (TheBotProfiles->GetCustomSkinModelname(slot) && player->IsBot()) - { - appearance.model_name = (char *)TheBotProfiles->GetCustomSkinModelname(slot); - } - else - { - appearance.model_id = MODEL_URBAN; - appearance.model_name = "urban"; - } - break; - } - - // default CT model models/player/urban/urban.mdl - appearance.model_name_index = 9; - } - - player->m_iMenu = Menu_OFF; - - if (player->m_iJoiningState != JOINED) - { - if (player->m_iJoiningState == PICKINGTEAM) - { - player->m_iJoiningState = GETINTOGAME; - - if (mp->IsCareer()) - { - if (!player->IsBot()) - { - mp->CheckWinConditions(); - } - } - } - } - else - mp->CheckWinConditions(); - - player->pev->body = 0; - player->m_iModelName = appearance.model_id; - - SET_CLIENT_KEY_VALUE(player->entindex(), GET_INFO_BUFFER(player->edict()), "model", appearance.model_name); - player->SetNewPlayerModel(sPlayerModelFiles[ appearance.model_name_index ]); - - if (mp->m_iMapHasVIPSafetyZone == MAP_VIP_SAFETYZONE_INIT) - { - if ((UTIL_FindEntityByClassname(NULL, "func_vip_safetyzone")) != NULL) - mp->m_iMapHasVIPSafetyZone = MAP_HAVE_VIP_SAFETYZONE_YES; - else - mp->m_iMapHasVIPSafetyZone = MAP_HAVE_VIP_SAFETYZONE_NO; - } - - if (mp->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) - { - if (!mp->m_pVIP && player->m_iTeam == CT) - { - player->MakeVIP(); - } - } -} - -/* <48e4b> ../cstrike/dlls/client.cpp:2214 */ -BOOL HandleMenu_ChooseTeam(CBasePlayer *player, int slot) -{ - CHalfLifeMultiplay *mp = g_pGameRules; - TeamName team = UNASSIGNED; - int oldTeam; - char *szOldTeam; - char *szNewTeam; - const char *szName; - - if (player->m_bIsVIP) - { - if (player->pev->deadflag == DEAD_NO) - { - ClientPrint(player->pev, HUD_PRINTCENTER, "#Cannot_Switch_From_VIP"); - CLIENT_COMMAND(ENT(player->pev), "slot10\n"); - - return TRUE; - } - - if (g_pGameRules->IsVIPQueueEmpty()) - { - ClientPrint(player->pev, HUD_PRINTCENTER, "#Cannot_Switch_From_VIP"); - CLIENT_COMMAND(ENT(player->pev), "slot10\n"); - - return TRUE; - } - } - - switch (slot) - { - case MENU_SLOT_TEAM_TERRORIST: - team = TERRORIST; - break; - case MENU_SLOT_TEAM_CT: - team = CT; - break; - case MENU_SLOT_TEAM_VIP: - { - if (mp->m_iMapHasVIPSafetyZone != MAP_HAVE_VIP_SAFETYZONE_YES || player->m_iTeam != CT) - { - return FALSE; - } - - mp->AddToVIPQueue(player); - CLIENT_COMMAND(ENT(player->pev), "slot10\n"); - return TRUE; - } - case MENU_SLOT_TEAM_RANDOM: - { - team = SelectDefaultTeam(); - - if (team == UNASSIGNED) - { - bool madeRoom = false; - if (cv_bot_auto_vacate.value > 0.0f && !player->IsBot()) - { - team = (RANDOM_LONG(0, 1) == 0) ? TERRORIST : CT; - - if (UTIL_KickBotFromTeam(team)) - madeRoom = true; - else - { - if (team == CT) - team = TERRORIST; - else - team = CT; - - if (UTIL_KickBotFromTeam(team)) - { - madeRoom = true; - } - } - } - - if (!madeRoom) - { - ClientPrint(player->pev, HUD_PRINTCENTER, "#All_Teams_Full"); - return FALSE; - } - } - break; - } - case MENU_SLOT_TEAM_SPECT: - { - if (!allow_spectators.value) - { - if (!(player->pev->flags & FL_PROXY)) - { - ClientPrint(player->pev, HUD_PRINTCENTER, "#Cannot_Be_Spectator"); - CLIENT_COMMAND(ENT(player->pev), "slot10\n"); - - return FALSE; - } - } - - if (player->m_iTeam == SPECTATOR) - { - return TRUE; - } - - if (!mp->IsFreezePeriod()) - { - if (player->pev->deadflag == DEAD_NO) - { - ClientPrint(player->pev, HUD_PRINTCENTER, "#Cannot_Be_Spectator"); - CLIENT_COMMAND(ENT(player->pev), "slot10\n"); - - return FALSE; - } - } - - if (player->m_iTeam != UNASSIGNED) - { - if (player->pev->deadflag == DEAD_NO) - { - ClientKill(player->edict()); - player->pev->frags++; - } - } - - player->RemoveAllItems(TRUE); - player->m_bHasC4 = false; - - if (player->m_iTeam != SPECTATOR) - { - // notify other clients of player joined to team spectator - UTIL_LogPrintf - ( - "\"%s<%i><%s><%s>\" joined team \"SPECTATOR\"\n", - STRING(player->pev->netname), - GETPLAYERUSERID(player->edict()), - GETPLAYERAUTHID(player->edict()), - GetTeam(player->m_iTeam) - ); - } - - player->m_iTeam = SPECTATOR; - player->m_iJoiningState = JOINED; - player->m_iAccount = 0; - - MESSAGE_BEGIN(MSG_ONE, gmsgMoney, NULL, player->pev); - WRITE_LONG(player->m_iAccount); - WRITE_BYTE(0); - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_BROADCAST, gmsgScoreInfo); - WRITE_BYTE(ENTINDEX(player->edict())); - WRITE_SHORT((int)player->pev->frags); - WRITE_SHORT(player->m_iDeaths); - WRITE_SHORT(0); - WRITE_SHORT(0); - MESSAGE_END(); - - player->m_pIntroCamera = NULL; - player->m_bTeamChanged = true; - - TheBots->OnEvent(EVENT_PLAYER_CHANGED_TEAM, player); - - TeamChangeUpdate(player, player->m_iTeam); - - edict_t *pentSpawnSpot = mp->GetPlayerSpawnSpot(player); - player->StartObserver(VARS(pentSpawnSpot)->origin, VARS(pentSpawnSpot)->angles); - - MESSAGE_BEGIN(MSG_ALL, gmsgSpectator); - WRITE_BYTE(ENTINDEX(player->edict())); - WRITE_BYTE(1); - MESSAGE_END(); - - if (fadetoblack.value) - { - UTIL_ScreenFade(player, Vector(0, 0, 0), 0.001, 0, 0, 0); - } - - return TRUE; - } - } - - if (mp->TeamFull(team) && (cv_bot_auto_vacate.value <= 0.0f || player->IsBot() || !UTIL_KickBotFromTeam(team))) - { - if (team == TERRORIST) - ClientPrint(player->pev, HUD_PRINTCENTER, "#Terrorists_Full"); - else - ClientPrint(player->pev, HUD_PRINTCENTER, "#CTs_Full"); - - return FALSE; - } - - if (mp->TeamStacked(team, player->m_iTeam)) - { - if (team == TERRORIST) - ClientPrint(player->pev, HUD_PRINTCENTER, "#Too_Many_Terrorists"); - else - ClientPrint(player->pev, HUD_PRINTCENTER, "#Too_Many_CTs"); - - return FALSE; - } - - if (!player->IsBot() && team != SPECTATOR) - { - int humanTeam = UNASSIGNED; - - if (!Q_stricmp(humans_join_team.string, "CT")) - { - humanTeam = CT; - } - else if (!Q_stricmp(humans_join_team.string, "T")) - { - humanTeam = TERRORIST; - } - - if (humanTeam != UNASSIGNED && team != humanTeam) - { - if (team == TERRORIST) - ClientPrint(player->pev, HUD_PRINTCENTER, "#Humans_Join_Team_CT"); - else - ClientPrint(player->pev, HUD_PRINTCENTER, "#Humans_Join_Team_T"); - - return FALSE; - } - } - - if (player->m_bTeamChanged) - { - if (player->pev->deadflag != DEAD_NO) - { - ClientPrint(player->pev, HUD_PRINTCENTER, "#Only_1_Team_Change"); - - return FALSE; - } - } - - if (player->m_iTeam == SPECTATOR && team != SPECTATOR) - { - player->m_bNotKilled = true; - player->m_iIgnoreGlobalChat = IGNOREMSG_NONE; - player->m_iTeamKills = 0; - - CheckStartMoney(); - - player->m_iAccount = (int)startmoney.value; - player->pev->solid = SOLID_NOT; - player->pev->movetype = MOVETYPE_NOCLIP; - player->pev->effects = EF_NODRAW; - player->pev->effects |= EF_NOINTERP; - player->pev->takedamage = DAMAGE_NO; - player->pev->deadflag = DEAD_DEAD; - player->pev->velocity = g_vecZero; - player->pev->punchangle = g_vecZero; - player->m_bHasNightVision = false; - player->m_iHostagesKilled = 0; - player->m_fDeadTime = 0; - player->has_disconnected = false; - player->m_iJoiningState = GETINTOGAME; - - SendItemStatus(player); - SET_CLIENT_MAXSPEED(ENT(player->pev), 1); - SET_MODEL(ENT(player->pev), "models/player.mdl"); - } - - if (!g_pGameRules->IsCareer()) - { - bool isCZero = UTIL_IsGame("czero"); - - switch (team) - { - case CT: - if (isCZero) - ShowVGUIMenu(player, VGUI_Menu_Class_CT, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6), "#CT_Select"); - else - ShowVGUIMenu(player, VGUI_Menu_Class_CT, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5), "#CT_Select"); - break; - - case TERRORIST: - if (isCZero) - ShowVGUIMenu(player, VGUI_Menu_Class_T, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6), "#Terrorist_Select"); - else - ShowVGUIMenu(player, VGUI_Menu_Class_T, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5), "#Terrorist_Select"); - break; - } - } - - player->m_iMenu = Menu_ChooseAppearance; - - if (player->pev->deadflag == DEAD_NO) - { - ClientKill(player->edict()); - } - - player->m_bTeamChanged = true; - oldTeam = player->m_iTeam; - player->m_iTeam = team; - - TheBots->OnEvent(EVENT_PLAYER_CHANGED_TEAM, player); - - TeamChangeUpdate(player, team); - - if (player->pev->netname) - { - szName = STRING(player->pev->netname); - - if (!szName[0]) - szName = ""; - } - else - szName = ""; - - szOldTeam = GetTeam(oldTeam); - szNewTeam = GetTeam(team); - - UTIL_ClientPrintAll(HUD_PRINTNOTIFY, (team == TERRORIST) ? "#Game_join_terrorist" : "#Game_join_ct", szName); - UTIL_LogPrintf - ( - "\"%s<%i><%s><%s>\" joined team \"%s\"\n", - STRING(player->pev->netname), - GETPLAYERUSERID(player->edict()), - GETPLAYERAUTHID(player->edict()), - szOldTeam, - szNewTeam - ); - - return TRUE; -} - -/* <474a0> ../cstrike/dlls/client.cpp:2553 */ -void Radio1(CBasePlayer *player, int slot) -{ - if (player->m_flRadioTime >= gpGlobals->time) - { - return; - } - - if (player->m_iRadioMessages <= 0) - { - return; - } - - player->m_iRadioMessages--; - player->m_flRadioTime = gpGlobals->time + 1.5f; - - switch (slot) - { - case 1: - player->Radio("%!MRAD_COVERME", "#Cover_me"); - break; - case 2: - player->Radio("%!MRAD_TAKEPOINT", "#You_take_the_point"); - break; - case 3: - player->Radio("%!MRAD_POSITION", "#Hold_this_position"); - break; - case 4: - player->Radio("%!MRAD_REGROUP", "#Regroup_team"); - break; - case 5: - player->Radio("%!MRAD_FOLLOWME", "#Follow_me"); - break; - case 6: - player->Radio("%!MRAD_HITASSIST", "#Taking_fire"); - break; - } - - TheBots->OnEvent((GameEventType)(EVENT_START_RADIO_1 + slot), player); -} - -/* <474ca> ../cstrike/dlls/client.cpp:2596 */ -void Radio2(CBasePlayer *player, int slot) -{ - if (player->m_flRadioTime >= gpGlobals->time) - { - return; - } - - if (player->m_iRadioMessages <= 0) - { - return; - } - - player->m_iRadioMessages--; - player->m_flRadioTime = gpGlobals->time + 1.5f; - - switch (slot) - { - case 1: - player->Radio("%!MRAD_GO", "#Go_go_go"); - break; - case 2: - player->Radio("%!MRAD_FALLBACK", "#Team_fall_back"); - break; - case 3: - player->Radio("%!MRAD_STICKTOG", "#Stick_together_team"); - break; - case 4: - player->Radio("%!MRAD_GETINPOS", "#Get_in_position_and_wait"); - break; - case 5: - player->Radio("%!MRAD_STORMFRONT", "#Storm_the_front"); - break; - case 6: - player->Radio("%!MRAD_REPORTIN", "#Report_in_team"); - break; - } - - TheBots->OnEvent((GameEventType)(EVENT_START_RADIO_2 + slot), player); -} - -/* <474f4> ../cstrike/dlls/client.cpp:2639 */ -void Radio3(CBasePlayer *player, int slot) -{ - if (player->m_flRadioTime >= gpGlobals->time) - { - return; - } - - if (player->m_iRadioMessages <= 0) - { - return; - } - - player->m_iRadioMessages--; - player->m_flRadioTime = gpGlobals->time + 1.5f; - - switch (slot) - { - case 1: - if (RANDOM_LONG(0, 1)) - player->Radio("%!MRAD_AFFIRM", "#Affirmative"); - else - player->Radio("%!MRAD_ROGER", "#Roger_that"); - - break; - case 2: - player->Radio("%!MRAD_ENEMYSPOT", "#Enemy_spotted"); - break; - case 3: - player->Radio("%!MRAD_BACKUP", "#Need_backup"); - break; - case 4: - player->Radio("%!MRAD_CLEAR", "#Sector_clear"); - break; - case 5: - player->Radio("%!MRAD_INPOS", "#In_position"); - break; - case 6: - player->Radio("%!MRAD_REPRTINGIN", "#Reporting_in"); - break; - case 7: - player->Radio("%!MRAD_BLOW", "#Get_out_of_there"); - break; - case 8: - player->Radio("%!MRAD_NEGATIVE", "#Negative"); - break; - case 9: - player->Radio("%!MRAD_ENEMYDOWN", "#Enemy_down"); - break; - } - - TheBots->OnEvent((GameEventType)(EVENT_START_RADIO_3 + slot), player); -} - -/* <49402> ../cstrike/dlls/client.cpp:2698 */ -bool BuyGunAmmo(CBasePlayer *player, CBasePlayerItem *weapon, bool bBlinkMoney) -{ - int cost; - const char *classname; - - if (!player->CanPlayerBuy(true)) - { - return false; - } - - int nAmmo = weapon->PrimaryAmmoIndex(); - if (nAmmo == -1) - { - return false; - } - - if (player->m_rgAmmo[ nAmmo ] >= weapon->iMaxAmmo1()) - { - return false; - } - - switch (weapon->m_iId) - { - case WEAPON_AWP: - cost = AMMO_338MAG_PRICE; - classname = "ammo_338magnum"; - break; - case WEAPON_SCOUT: - case WEAPON_G3SG1: - case WEAPON_AK47: - cost = AMMO_762MM_PRICE; - classname = "ammo_762nato"; - break; - case WEAPON_XM1014: - case WEAPON_M3: - cost = AMMO_BUCKSHOT_PRICE; - classname = "ammo_buckshot"; - break; - case WEAPON_MAC10: - case WEAPON_UMP45: - case WEAPON_USP: - cost = AMMO_45ACP_PRICE; - classname = "ammo_45acp"; - break; - case WEAPON_M249: - cost = AMMO_556MM_PRICE; - classname = "ammo_556natobox"; - break; - case WEAPON_FIVESEVEN: - case WEAPON_P90: - cost = AMMO_57MM_PRICE; - classname = "ammo_57mm"; - break; - case WEAPON_ELITE: - case WEAPON_GLOCK18: - case WEAPON_MP5N: - case WEAPON_TMP: - cost = AMMO_9MM_PRICE; - classname = "ammo_9mm"; - break; - case WEAPON_DEAGLE: - cost = AMMO_50AE_PRICE; - classname = "ammo_50ae"; - break; - case WEAPON_P228: - cost = AMMO_357SIG_PRICE; - classname = "ammo_357sig"; - break; - case WEAPON_AUG: - case WEAPON_SG550: - case WEAPON_GALIL: - case WEAPON_FAMAS: - case WEAPON_M4A1: - case WEAPON_SG552: - cost = AMMO_556MM_PRICE; - classname = "ammo_556nato"; - break; - default: - ALERT(at_console, "Tried to buy ammo for an unrecognized gun\n"); - return false; - } - - if (player->m_iAccount >= cost) - { - player->GiveNamedItem(classname); - player->AddAccount(-cost); - return true; - } - - if (bBlinkMoney) - { - if (g_bClientPrintEnable) - { - ClientPrint(player->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); - BlinkAccount(player, 2); - } - } - - return false; -} - -/* <4751e> ../cstrike/dlls/client.cpp:2884 */ -bool BuyAmmo(CBasePlayer *player, int nSlot, bool bBlinkMoney) -{ - if (!player->CanPlayerBuy(true)) - { - return false; - } - - if (nSlot < PRIMARY_WEAPON_SLOT || nSlot > PISTOL_SLOT) - { - return false; - } - - CBasePlayerItem *pItem = player->m_rgpPlayerItems[ nSlot ]; - - if (player->HasShield()) - { - if (player->m_rgpPlayerItems[ PISTOL_SLOT ]) - pItem = player->m_rgpPlayerItems[ PISTOL_SLOT ]; - } - - if (pItem != NULL) - { - while (BuyGunAmmo(player, pItem, bBlinkMoney)) - { - pItem = pItem->m_pNext; - - if (!pItem) - { - return true; - } - } - } - - return false; -} - -/* <4bb4a> ../cstrike/dlls/client.cpp:2933 */ -CBaseEntity *EntityFromUserID(int userID) -{ - CBaseEntity *pTempEntity = NULL; - - while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player")) != NULL) - { - if (FNullEnt(pTempEntity->edict())) - break; - - CBasePlayer *pTempPlayer = GetClassPtr((CBasePlayer *)pTempEntity->pev); - - if (pTempPlayer->m_iTeam != UNASSIGNED && userID == GETPLAYERUSERID(pTempEntity->edict())) - { - return pTempPlayer; - } - } - - return NULL; -} - -/* <4baa5> ../cstrike/dlls/client.cpp:2958 */ -NOXREF int CountPlayersInServer(void) -{ - int count = 0; - CBaseEntity *pTempEntity = NULL; - - while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player")) != NULL) - { - if (FNullEnt(pTempEntity->edict())) - break; - - CBasePlayer *pTempPlayer = GetClassPtr((CBasePlayer *)pTempEntity->pev); - - if (pTempPlayer->m_iTeam != UNASSIGNED) - { - count++; - } - } - - return count; -} - -/* <4958c> ../cstrike/dlls/client.cpp:2983 */ -BOOL HandleBuyAliasCommands(CBasePlayer *pPlayer, const char *pszCommand) -{ - BOOL bRetVal = FALSE; - //char *pszFailItem; - - WeaponIdType weaponID = WEAPON_NONE; - const char *weaponFailName = BuyAliasToWeaponID(pszCommand, weaponID); - - if (weaponID != WEAPON_NONE) - { - if (CanBuyWeaponByMaptype(pPlayer->m_iTeam, weaponID, (g_pGameRules->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES))) - { - bRetVal = TRUE; - BuyWeaponByWeaponID(pPlayer, weaponID); - } - else if (weaponFailName != NULL) - { - bRetVal = TRUE; - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Alias_Not_Avail", weaponFailName); - } - } - else - { - bRetVal = TRUE; - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Cannot_Buy_This"); - } - } - } - else - { - if (FStrEq(pszCommand, "primammo")) - { - bRetVal = TRUE; - if (BuyAmmo(pPlayer, PRIMARY_WEAPON_SLOT, true)) - { - while (BuyAmmo(pPlayer, PRIMARY_WEAPON_SLOT, false)) - ; - - if (TheTutor) - { - TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); - } - } - } - else if (FStrEq(pszCommand, "secammo")) - { - bRetVal = TRUE; - if (BuyAmmo(pPlayer, PISTOL_SLOT, true)) - { - while (BuyAmmo(pPlayer, PISTOL_SLOT, false)) - ; - - if (TheTutor) - { - TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); - } - } - } - else if (FStrEq(pszCommand, "vest")) - { - bRetVal = TRUE; - BuyItem(pPlayer, MENU_SLOT_ITEM_VEST); - } - else if (FStrEq(pszCommand, "vesthelm")) - { - bRetVal = TRUE; - BuyItem(pPlayer, MENU_SLOT_ITEM_VESTHELM); - } - else if (FStrEq(pszCommand, "flash")) - { - bRetVal = TRUE; - BuyItem(pPlayer, MENU_SLOT_ITEM_FLASHGREN); - } - else if (FStrEq(pszCommand, "hegren")) - { - bRetVal = TRUE; - BuyItem(pPlayer, MENU_SLOT_ITEM_HEGREN); - } - else if (FStrEq(pszCommand, "sgren")) - { - bRetVal = TRUE; - BuyItem(pPlayer, MENU_SLOT_ITEM_SMOKEGREN); - } - else if (FStrEq(pszCommand, "nvgs")) - { - bRetVal = TRUE; - BuyItem(pPlayer, MENU_SLOT_ITEM_NVG); - } - else if (FStrEq(pszCommand, "defuser")) - { - bRetVal = TRUE; - if (pPlayer->m_iTeam != CT) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Alias_Not_Avail", "#Bomb_Defusal_Kit"); - } - } - else - BuyItem(pPlayer, MENU_SLOT_ITEM_DEFUSEKIT); - } - else if (FStrEq(pszCommand, "shield")) - { - bRetVal = TRUE; - if (pPlayer->m_iTeam != CT) - { - if (g_bClientPrintEnable) - { - ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Alias_Not_Avail", "#TactShield_Desc"); - } - } - else - BuyItem(pPlayer, MENU_SLOT_ITEM_SHIELD); - } - } - - pPlayer->BuildRebuyStruct(); - return bRetVal; -} - -/* <49c3e> ../cstrike/dlls/client.cpp:3113 */ -BOOL HandleRadioAliasCommands(CBasePlayer *pPlayer, const char *pszCommand) -{ - BOOL bRetVal = FALSE; - - if (FStrEq(pszCommand, "coverme")) - { - bRetVal = TRUE; - Radio1(pPlayer, 1); - } - else if (FStrEq(pszCommand, "takepoint")) - { - bRetVal = TRUE; - Radio1(pPlayer, 2); - } - else if (FStrEq(pszCommand, "holdpos")) - { - bRetVal = TRUE; - Radio1(pPlayer, 3); - } - else if (FStrEq(pszCommand, "regroup")) - { - bRetVal = TRUE; - Radio1(pPlayer, 4); - } - else if (FStrEq(pszCommand, "followme")) - { - bRetVal = TRUE; - Radio1(pPlayer, 5); - } - else if (FStrEq(pszCommand, "takingfire")) - { - bRetVal = TRUE; - Radio1(pPlayer, 6); - } - else if (FStrEq(pszCommand, "go")) - { - bRetVal = TRUE; - Radio2(pPlayer, 1); - } - else if (FStrEq(pszCommand, "fallback")) - { - bRetVal = TRUE; - Radio2(pPlayer, 2); - } - else if (FStrEq(pszCommand, "sticktog")) - { - bRetVal = TRUE; - Radio2(pPlayer, 3); - } - else if (FStrEq(pszCommand, "getinpos")) - { - bRetVal = TRUE; - Radio2(pPlayer, 4); - } - else if (FStrEq(pszCommand, "stormfront")) - { - bRetVal = TRUE; - Radio2(pPlayer, 5); - } - else if (FStrEq(pszCommand, "report")) - { - bRetVal = TRUE; - Radio2(pPlayer, 6); - } - else if (FStrEq(pszCommand, "roger")) - { - bRetVal = TRUE; - Radio3(pPlayer, 1); - } - else if (FStrEq(pszCommand, "enemyspot")) - { - bRetVal = TRUE; - Radio3(pPlayer, 2); - } - else if (FStrEq(pszCommand, "needbackup")) - { - bRetVal = TRUE; - Radio3(pPlayer, 3); - } - else if (FStrEq(pszCommand, "sectorclear")) - { - bRetVal = TRUE; - Radio3(pPlayer, 4); - } - else if (FStrEq(pszCommand, "inposition")) - { - bRetVal = TRUE; - Radio3(pPlayer, 5); - } - else if (FStrEq(pszCommand, "reportingin")) - { - bRetVal = TRUE; - Radio3(pPlayer, 6); - } - else if (FStrEq(pszCommand, "getout")) - { - bRetVal = TRUE; - Radio3(pPlayer, 7); - } - else if (FStrEq(pszCommand, "negative")) - { - bRetVal = TRUE; - Radio3(pPlayer, 8); - } - else if (FStrEq(pszCommand, "enemydown")) - { - bRetVal = TRUE; - Radio3(pPlayer, 9); - } - - return bRetVal; -} - -// Use CMD_ARGV, CMD_ARGV, and CMD_ARGC to get pointers the character string command. - -/* <4c6c1> ../cstrike/dlls/client.cpp:3234 */ -void ClientCommand(edict_t *pEntity) -{ - const char *pcmd = CMD_ARGV_(0); - const char *pstr = NULL; - CHalfLifeMultiplay *mp = g_pGameRules; - - // Is the client spawned yet? - if (!pEntity->pvPrivateData) - return; - - entvars_t *pev = &pEntity->v; - CBasePlayer *player = GetClassPtr((CBasePlayer *)pev); - - if (FStrEq(pcmd, "say")) - { - if (gpGlobals->time >= player->m_flLastCommandTime[0]) - { - player->m_flLastCommandTime[0] = gpGlobals->time + 0.3f; - Host_Say(pEntity, 0); - } - } - else if (FStrEq(pcmd, "say_team")) - { - if (gpGlobals->time >= player->m_flLastCommandTime[1]) - { - player->m_flLastCommandTime[1] = gpGlobals->time + 0.3f; - Host_Say(pEntity, 1); - } - } - else if (FStrEq(pcmd, "fullupdate")) - { - if (gpGlobals->time >= player->m_flLastCommandTime[2]) - { - player->m_flLastCommandTime[2] = gpGlobals->time + 0.6f; - player->ForceClientDllUpdate(); - } - } - else if (FStrEq(pcmd, "vote")) - { - if (gpGlobals->time >= player->m_flLastCommandTime[3]) - { - player->m_flLastCommandTime[3] = gpGlobals->time + 0.3f; - - if (gpGlobals->time < player->m_flNextVoteTime) - { - ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Wait_3_Seconds"); - return; - } - - player->m_flNextVoteTime = gpGlobals->time + 3; - - if (player->m_iTeam != UNASSIGNED) - { - int iVoteID; - int iVoteFail = 0; - int iNumArgs = CMD_ARGC_(); - const char *pszArg1 = CMD_ARGV_(1); - int iVoteLength = Q_strlen(pszArg1); - - if (iNumArgs != 2 || iVoteLength <= 0 || iVoteLength > 6) - { - iVoteFail = 1; - } - - iVoteID = Q_atoi(pszArg1); - if (iVoteID <= 0) - { - iVoteFail = 1; - } - - if (iVoteFail) - { - ListPlayers(player); - ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_vote_usage"); - return; - } - - if (CountTeamPlayers(player->m_iTeam) < 3) - { - ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Cannot_Vote_With_Less_Than_Three"); - return; - } - - CBaseEntity *pKickEntity = EntityFromUserID(iVoteID); - if (pKickEntity != NULL) - { - CBasePlayer *pKickPlayer = GetClassPtr((CBasePlayer *)pKickEntity->pev); - - if (pKickPlayer->m_iTeam != player->m_iTeam) - { - ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_vote_players_on_your_team"); - return; - } - - if (pKickPlayer == player) - { - ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_vote_not_yourself"); - return; - } - - ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_vote_cast", UTIL_dtos1(iVoteID)); - player->m_iCurrentKickVote = iVoteID; - ProcessKickVote(player, pKickPlayer); - } - else - { - ListPlayers(player); - ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_vote_player_not_found", UTIL_dtos1(iVoteID)); - } - } - } - } - else if (FStrEq(pcmd, "listmaps")) - { - if (gpGlobals->time >= player->m_flLastCommandTime[5]) - { - player->m_flLastCommandTime[5] = gpGlobals->time + 0.3f; - mp->DisplayMaps(player, 0); - } - } - else if (FStrEq(pcmd, "votemap")) - { - if (gpGlobals->time >= player->m_flLastCommandTime[4]) - { - player->m_flLastCommandTime[4] = gpGlobals->time + 0.3f; - - if (gpGlobals->time < player->m_flNextVoteTime) - { - ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Wait_3_Seconds"); - return; - } - - player->m_flNextVoteTime = gpGlobals->time + 3; - - if (player->m_iTeam != UNASSIGNED) - { - if (gpGlobals->time < 180) - { - ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Cannot_Vote_Map"); - return; - } - - int iFailed = 0; - int iNumArgs = CMD_ARGC_(); - const char *pszArg1 = CMD_ARGV_(1); - int iVoteLength = Q_strlen(pszArg1); - - if (iNumArgs != 2 || iVoteLength > 5) - { - iFailed = 1; - } - - int iVoteID = Q_atoi(pszArg1); - if (iVoteID < 1 || iVoteID > MAX_VOTE_MAPS) - { - iFailed = 1; - } - - if (iVoteID > GetMapCount()) - { - iFailed = 1; - } - - if (iFailed) - { - mp->DisplayMaps(player, 0); - ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_votemap_usage"); - return; - } - - if (CountTeamPlayers(player->m_iTeam) < 2) - { - ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Cannot_Vote_Need_More_People"); - return; - } - - if (player->m_iMapVote) - { - mp->m_iMapVotes[ player->m_iMapVote ]--; - - if (mp->m_iMapVotes[player->m_iMapVote] < 0) - { - mp->m_iMapVotes[player->m_iMapVote] = 0; - } - } - - ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_voted_for_map", UTIL_dtos1(iVoteID)); - player->m_iMapVote = iVoteID; - mp->ProcessMapVote(player, iVoteID); - } - } - } - else if (FStrEq(pcmd, "timeleft")) - { - if (gpGlobals->time > player->m_iTimeCheckAllowed) - { - player->m_iTimeCheckAllowed = (int)(gpGlobals->time + 1); - - if (!timelimit.value) - { - ClientPrint(player->pev, HUD_PRINTTALK, "#Game_no_timelimit"); - return; - } - - int iTimeRemaining = (int)(g_flTimeLimit - gpGlobals->time); - - if (iTimeRemaining < 0) - iTimeRemaining = 0; - - int iMinutes = (int)(iTimeRemaining % 60); - int iSeconds = (int)(iTimeRemaining / 60); - - char secs[5]; - char *temp = UTIL_dtos2(iMinutes); - - if (iMinutes >= 10) - { - secs[0] = temp[0]; - secs[1] = temp[1]; - secs[2] = '\0'; - } - else - { - secs[0] = '0'; - secs[1] = temp[0]; - secs[2] = '\0'; - } - - ClientPrint(player->pev, HUD_PRINTTALK, "#Game_timelimit", UTIL_dtos1(iSeconds), secs); - } - } - else if (FStrEq(pcmd, "listplayers")) - { - if (gpGlobals->time >= player->m_flLastCommandTime[6]) - { - player->m_flLastCommandTime[6] = gpGlobals->time + 0.3f; - ListPlayers(player); - } - } - else if (FStrEq(pcmd, "client_buy_open")) - { - if (player->m_iMenu == Menu_OFF) - { - player->m_iMenu = Menu_ClientBuy; - } - - if (player->m_signals.GetState() & SIGNAL_BUY) - { - if (TheTutor) - { - TheTutor->OnEvent(EVENT_TUTOR_BUY_MENU_OPENNED); - } - } - else - { - MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, NULL, player->pev); - MESSAGE_END(); - } - } - else if (FStrEq(pcmd, "client_buy_close")) - { - if (player->m_iMenu == Menu_ClientBuy) - { - player->m_iMenu = Menu_OFF; - } - } - else if (FStrEq(pcmd, "menuselect")) - { - int slot = Q_atoi(CMD_ARGV_(1)); - - if (player->m_iJoiningState == JOINED || (player->m_iMenu != SPECTATOR && player->m_iMenu != TERRORIST)) - { - if (slot == 10) - { - player->m_iMenu = Menu_OFF; - } - } - - switch (player->m_iMenu) - { - case Menu_OFF: - break; - - case Menu_ChooseTeam: - { - if (!player->m_bVGUIMenus && !HandleMenu_ChooseTeam(player, slot)) - { - if (player->m_iJoiningState == JOINED) - ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_0), "#IG_Team_Select"); - else - ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5), "#Team_Select"); - - player->m_iMenu = Menu_ChooseTeam; - } - break; - } - case Menu_IGChooseTeam: - { - if (!player->m_bVGUIMenus) - { - HandleMenu_ChooseTeam(player, slot); - } - break; - } - case Menu_ChooseAppearance: - { - if (!player->m_bVGUIMenus) - { - HandleMenu_ChooseAppearance(player, slot); - } - break; - } - case Menu_Buy: - { - if (!player->m_bVGUIMenus) - { - switch (slot) - { - case VGUI_MenuSlot_Buy_Pistol: - { - if (player->m_iTeam == CT) - ShowVGUIMenu(player, VGUI_Menu_Buy_Pistol, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_0), "#CT_BuyPistol"); - else - ShowVGUIMenu(player, VGUI_Menu_Buy_Pistol, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_0), "#T_BuyPistol"); - - player->m_iMenu = Menu_BuyPistol; - break; - } - case VGUI_MenuSlot_Buy_ShotGun: - { - if (mp->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES && player->m_iTeam == TERRORIST) - ShowVGUIMenu(player, VGUI_Menu_Buy_ShotGun, MENU_KEY_0, "#AS_BuyShotgun"); - else - ShowVGUIMenu(player, VGUI_Menu_Buy_ShotGun, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_0), "#BuyShotgun"); - - player->m_iMenu = Menu_BuyShotgun; - break; - } - case VGUI_MenuSlot_Buy_SubMachineGun: - { - if (mp->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) - { - if (player->m_iTeam == CT) - ShowVGUIMenu(player, VGUI_Menu_Buy_SubMachineGun, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_0), "#AS_CT_BuySubMachineGun"); - else - ShowVGUIMenu(player, VGUI_Menu_Buy_SubMachineGun, (MENU_KEY_1 | MENU_KEY_3 | MENU_KEY_0), "#AS_T_BuySubMachineGun"); - } - else - { - if (player->m_iTeam == CT) - ShowVGUIMenu(player, VGUI_Menu_Buy_SubMachineGun, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_0), "#CT_BuySubMachineGun"); - else - ShowVGUIMenu(player, VGUI_Menu_Buy_SubMachineGun, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_0), "#T_BuySubMachineGun"); - } - - player->m_iMenu = Menu_BuySubMachineGun; - break; - } - case VGUI_MenuSlot_Buy_Rifle: - { - if (mp->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) - { - if (player->m_iTeam == CT) - ShowVGUIMenu(player, VGUI_Menu_Buy_Rifle, (MENU_KEY_1 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_0), "#AS_CT_BuyRifle"); - else - ShowVGUIMenu(player, VGUI_Menu_Buy_Rifle, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_0), "#AS_T_BuyRifle"); - } - else - { - if (player->m_iTeam == CT) - ShowVGUIMenu(player, VGUI_Menu_Buy_Rifle, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#CT_BuyRifle"); - else - ShowVGUIMenu(player, VGUI_Menu_Buy_Rifle, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#T_BuyRifle"); - } - - player->m_iMenu = Menu_BuyRifle; - break; - } - case VGUI_MenuSlot_Buy_MachineGun: - { - if (mp->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES && player->m_iTeam == TERRORIST) - ShowVGUIMenu(player, VGUI_Menu_Buy_MachineGun, MENU_KEY_0, "#AS_T_BuyMachineGun"); - else - ShowVGUIMenu(player, VGUI_Menu_Buy_MachineGun, (MENU_KEY_1 | MENU_KEY_0), "#BuyMachineGun"); - - player->m_iMenu = Menu_BuyMachineGun; - break; - } - case VGUI_MenuSlot_Buy_PrimAmmo: - { - if (player->m_signals.GetState() & SIGNAL_BUY) - { - if (BuyAmmo(player, PRIMARY_WEAPON_SLOT, true)) - { - while (BuyAmmo(player, PRIMARY_WEAPON_SLOT, false)) - ; - - if (TheTutor) - { - TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, player); - } - } - - player->BuildRebuyStruct(); - } - break; - } - case VGUI_MenuSlot_Buy_SecAmmo: - { - if (player->m_signals.GetState() & SIGNAL_BUY) - { - if (BuyAmmo(player, PISTOL_SLOT, true)) - { - while (BuyAmmo(player, PISTOL_SLOT, false)) - ; - - if (TheTutor) - { - TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, player); - } - } - - player->BuildRebuyStruct(); - } - } - case VGUI_MenuSlot_Buy_Item: - { - if (player->m_signals.GetState() & SIGNAL_BUY) - { - if (mp->m_bMapHasBombTarget) - { - if (player->m_iTeam == CT) - ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_0), "#DCT_BuyItem"); - else - ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#DT_BuyItem"); - } - else - { - if (player->m_iTeam == CT) - ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_8 | MENU_KEY_0), "#CT_BuyItem"); - else - ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#T_BuyItem"); - } - - player->m_iMenu = Menu_BuyItem; - } - break; - } - } - } - break; - } - case Menu_BuyPistol: - { - if (!player->m_bVGUIMenus) - { - BuyPistol(player, slot); - } - break; - } - case Menu_BuyShotgun: - { - if (!player->m_bVGUIMenus) - { - BuyShotgun(player, slot); - } - break; - } - case Menu_BuySubMachineGun: - { - if (!player->m_bVGUIMenus) - { - BuySubMachineGun(player, slot); - } - break; - } - case Menu_BuyRifle: - { - if (!player->m_bVGUIMenus) - { - BuyRifle(player, slot); - } - break; - } - case Menu_BuyMachineGun: - { - if (!player->m_bVGUIMenus) - { - BuyMachineGun(player, slot); - } - break; - } - case Menu_BuyItem: - { - if (!player->m_bVGUIMenus) - { - BuyItem(player, slot); - } - break; - } - case Menu_Radio1: - { - Radio1(player, slot); - break; - } - case Menu_Radio2: - { - Radio2(player, slot); - break; - } - case Menu_Radio3: - { - Radio3(player, slot); - break; - } - default: - ALERT(at_console, "ClientCommand(): Invalid menu selected\n"); - break; - } - } - else if (FStrEq(pcmd, "chooseteam")) - { - if (player->m_iMenu == Menu_ChooseAppearance) - { - return; - } - - if (player->m_bTeamChanged) - { - if (player->pev->deadflag != DEAD_NO) - { - ClientPrint(player->pev, HUD_PRINTCENTER, "#Only_1_Team_Change"); - return; - } - } - - if (!mp->IsCareer()) - { - if (mp->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES && player->m_iJoiningState == JOINED && player->m_iTeam == CT) - { - if (mp->IsFreezePeriod() || player->pev->deadflag != DEAD_NO) - ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#IG_VIP_Team_Select_Spect"); - else - ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_5 | MENU_KEY_0), "#IG_VIP_Team_Select"); - } - else - { - if (mp->IsFreezePeriod() || player->pev->deadflag != DEAD_NO) - ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#IG_Team_Select_Spect"); - else - ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_0), "#IG_Team_Select"); - } - - player->m_iMenu = Menu_ChooseTeam; - } - } - else if (FStrEq(pcmd, "showbriefing")) - { - if (player->m_iMenu == Menu_OFF) - { - if (g_szMapBriefingText[0] != '\0') - { - if (player->m_iTeam != UNASSIGNED && !(player->m_afPhysicsFlags & PFLAG_OBSERVER)) - { - player->MenuPrint(g_szMapBriefingText); - player->m_bMissionBriefing = true; - } - } - } - } - else if (FStrEq(pcmd, "ignoremsg")) - { - if (player->m_iIgnoreGlobalChat == IGNOREMSG_NONE) - { - player->m_iIgnoreGlobalChat = IGNOREMSG_ENEMY; - ClientPrint(player->pev, HUD_PRINTCENTER, "#Ignore_Broadcast_Messages"); - } - else if (player->m_iIgnoreGlobalChat == IGNOREMSG_ENEMY) - { - player->m_iIgnoreGlobalChat = IGNOREMSG_TEAM; - ClientPrint(player->pev, HUD_PRINTCENTER, "#Ignore_Broadcast_Team_Messages"); - } - else if (player->m_iIgnoreGlobalChat == IGNOREMSG_TEAM) - { - player->m_iIgnoreGlobalChat = IGNOREMSG_NONE; - ClientPrint(player->pev, HUD_PRINTCENTER, "#Accept_All_Messages"); - } - } - else if (FStrEq(pcmd, "ignorerad")) - { - player->m_bIgnoreRadio = !player->m_bIgnoreRadio; - ClientPrint(player->pev, HUD_PRINTCENTER, player->m_bIgnoreRadio ? "#Ignore_Radio" : "#Accept_Radio"); - } - else if (FStrEq(pcmd, "become_vip")) - { - if (player->m_iJoiningState != JOINED || player->m_iTeam != CT) - { - ClientPrint(player->pev, HUD_PRINTCENTER, "#Command_Not_Available"); - return; - } - - mp->AddToVIPQueue(player); - } - else if (FStrEq(pcmd, "spectate") && (player->pev->flags & FL_PROXY)) // always allow proxies to become a spectator - { - // clients wants to become a spectator - HandleMenu_ChooseTeam(player, MENU_SLOT_TEAM_SPECT); - } - else if (FStrEq(pcmd, "specmode")) - { - // new spectator mode - int mode = Q_atoi(CMD_ARGV_(1)); - - if (player->IsObserver() && player->CanSwitchObserverModes()) - player->Observer_SetMode(mode); - else - player->m_iObserverLastMode = mode; - - if (mode == OBS_CHASE_FREE) - { - MESSAGE_BEGIN(MSG_ONE, gmsgADStop, NULL, player->pev); - MESSAGE_END(); - } - } - else if (FStrEq(pcmd, "spec_set_ad")) - { - float val = Q_atof(CMD_ARGV_(1)); - player->SetObserverAutoDirector(val > 0.0f); - } - else if (FStrEq(pcmd, "follownext")) - { - // follow next player - int arg = Q_atoi(CMD_ARGV_(1)); - - if (player->IsObserver() && player->CanSwitchObserverModes()) - { - player->Observer_FindNextPlayer(arg != 0); - } - } - else if (FStrEq(pcmd, "follow")) - { - if (player->IsObserver() && player->CanSwitchObserverModes()) - { - player->Observer_FindNextPlayer(false, CMD_ARGV_(1)); - } - } - else - { - if (mp->ClientCommand_DeadOrAlive(GetClassPtr((CBasePlayer *)pev), pcmd)) - return; - - if (TheBots->ClientCommand(GetClassPtr((CBasePlayer *)pev), pcmd)) - return; - - if (FStrEq(pcmd, "mp_debug")) - { - UTIL_SetDprintfFlags(CMD_ARGV_(1)); - } - else if (FStrEq(pcmd, "jointeam")) - { - if (player->m_iMenu == Menu_ChooseAppearance) - { - ClientPrint(player->pev, HUD_PRINTCENTER, "#Command_Not_Available"); - return; - } - - int slot = Q_atoi(CMD_ARGV_(1)); - if (HandleMenu_ChooseTeam(player, slot)) - { - if (slot == MENU_SLOT_TEAM_VIP || slot == MENU_SLOT_TEAM_SPECT || player->m_bIsVIP) - { - player->m_iMenu = Menu_OFF; - } - else - player->m_iMenu = Menu_ChooseAppearance; - } - else - { - if (player->m_iJoiningState == JOINED) - ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_0), "#IG_Team_Select"); - else - ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5), "#Team_Select"); - - player->m_iMenu = Menu_ChooseTeam; - } - } - else if (FStrEq(pcmd, "joinclass")) - { - int slot = Q_atoi(CMD_ARGV_(1)); - - if (player->m_iMenu != Menu_ChooseAppearance) - { - ClientPrint(player->pev, HUD_PRINTCENTER, "#Command_Not_Available"); - return; - } - - HandleMenu_ChooseAppearance(player, slot); - } - else if (player->pev->deadflag == DEAD_NO) - { - if (FStrEq(pcmd, "nightvision")) - { - if (gpGlobals->time >= player->m_flLastCommandTime[7]) - { - player->m_flLastCommandTime[7] = gpGlobals->time + 0.3f; - - if (!player->m_bHasNightVision) - return; - - if (player->m_bNightVisionOn) - { - EMIT_SOUND(ENT(player->pev), CHAN_ITEM, "items/nvg_off.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); - - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, player->pev); - WRITE_BYTE(0); // disable nightvision - MESSAGE_END(); - - player->m_bNightVisionOn = false; - - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *pObserver = (CBasePlayer *)UTIL_PlayerByIndex(i); - - if (pObserver && pObserver->IsObservingPlayer(player)) - { - EMIT_SOUND(ENT(pObserver->pev), CHAN_ITEM, "items/nvg_off.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); - - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); - WRITE_BYTE(0); // disable nightvision - MESSAGE_END(); - - pObserver->m_bNightVisionOn = false; - } - } - } - else - { - EMIT_SOUND(ENT(player->pev), CHAN_ITEM, "items/nvg_on.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); - - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, player->pev); - WRITE_BYTE(1); // enable nightvision - MESSAGE_END(); - - player->m_bNightVisionOn = true; - - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *pObserver = (CBasePlayer *)UTIL_PlayerByIndex(i); - - if (pObserver && pObserver->IsObservingPlayer(player)) - { - EMIT_SOUND(ENT(pObserver->pev), CHAN_ITEM, "items/nvg_on.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); - - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); - WRITE_BYTE(1); // enable nightvision - MESSAGE_END(); - - pObserver->m_bNightVisionOn = true; - } - } - } - } - } - else if (FStrEq(pcmd, "radio1")) - { - ShowMenu(player, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), -1, FALSE, "#RadioA"); - player->m_iMenu = Menu_Radio1; - } - else if (FStrEq(pcmd, "radio2")) - { - ShowMenu(player, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), -1, FALSE, "#RadioB"); - player->m_iMenu = Menu_Radio2; - return; - } - else if (FStrEq(pcmd, "radio3")) - { - ShowMenu(player, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_9 | MENU_KEY_0), -1, FALSE, "#RadioC"); - player->m_iMenu = Menu_Radio3; - } - else if (FStrEq(pcmd, "drop")) - { - // player is dropping an item. - if (player->HasShield()) - { - if (player->m_pActiveItem && player->m_pActiveItem->m_iId == WEAPON_C4) - { - player->DropPlayerItem("weapon_c4"); - } - else - player->DropShield(); - } - else - player->DropPlayerItem(CMD_ARGV_(1)); - } - else if (FStrEq(pcmd, "fov")) - { -#if 0 - if (g_flWeaponCheat && CMD_ARGC() > 1) - GetClassPtr((CBasePlayer *)pev)->m_iFOV = Q_atoi(CMD_ARGV(1)); - else - CLIENT_PRINTF(pEntity, print_console, UTIL_VarArgs("\"fov\" is \"%d\"\n", (int)GetClassPtr((CBasePlayer *)pev)->m_iFOV)); -#endif - } - else if (FStrEq(pcmd, "use")) - { - GetClassPtr((CBasePlayer *)pev)->SelectItem(CMD_ARGV_(1)); - } - else if (((pstr = Q_strstr(pcmd, "weapon_")) != NULL) && (pstr == pcmd)) - { - GetClassPtr((CBasePlayer *)pev)->SelectItem(pcmd); - } - else if (FStrEq(pcmd, "lastinv")) - { - GetClassPtr((CBasePlayer *)pev)->SelectLastItem(); - } - else if (FStrEq(pcmd, "buyammo1")) - { - if (player->m_signals.GetState() & SIGNAL_BUY) - { - BuyAmmo(player, PRIMARY_WEAPON_SLOT, true); - player->BuildRebuyStruct(); - if (TheTutor) - { - TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, player); - } - } - } - else if (FStrEq(pcmd, "buyammo2")) - { - if (player->m_signals.GetState() & SIGNAL_BUY) - { - BuyAmmo(player, PISTOL_SLOT, true); - player->BuildRebuyStruct(); - if (TheTutor) - { - TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, player); - } - } - } - else if (FStrEq(pcmd, "buyequip")) - { - if (player->m_signals.GetState() & SIGNAL_BUY) - { - if (mp->m_bMapHasBombTarget) - { - if (player->m_iTeam == CT) - ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_0), "#DCT_BuyItem"); - else - ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#DT_BuyItem"); - } - else - { - if (player->m_iTeam == CT) - ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_8 | MENU_KEY_0), "#CT_BuyItem"); - else - ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#T_BuyItem"); - } - - player->m_iMenu = Menu_BuyItem; - } - } - else if (FStrEq(pcmd, "buy")) - { - if (player->m_signals.GetState() & SIGNAL_BUY) - { - ShowVGUIMenu(player, VGUI_Menu_Buy, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_0), "#Buy"); - player->m_iMenu = Menu_Buy; - - if (TheBots) - { - TheBots->OnEvent(EVENT_TUTOR_BUY_MENU_OPENNED); - } - } - } - else if (FStrEq(pcmd, "cl_setautobuy")) - { - player->ClearAutoBuyData(); - - for (int i = 1; i < CMD_ARGC_(); i++) - { - player->AddAutoBuyData(CMD_ARGV_(i)); - } - - bool oldval = g_bClientPrintEnable; - g_bClientPrintEnable = false; - player->AutoBuy(); - g_bClientPrintEnable = oldval; - } - else if (FStrEq(pcmd, "cl_setrebuy")) - { - if (CMD_ARGC_() == 2) - { - player->InitRebuyData(CMD_ARGV_(1)); - - bool oldval = g_bClientPrintEnable; - g_bClientPrintEnable = false; - player->Rebuy(); - g_bClientPrintEnable = oldval; - } - } - else if (FStrEq(pcmd, "cl_autobuy")) - { - if (player->m_signals.GetState() & SIGNAL_BUY) - { - bool oldval = g_bClientPrintEnable; - g_bClientPrintEnable = false; - player->AutoBuy(); - g_bClientPrintEnable = oldval; - } - } - else if (FStrEq(pcmd, "cl_rebuy")) - { - if (player->m_signals.GetState() & SIGNAL_BUY) - { - bool oldval = g_bClientPrintEnable; - g_bClientPrintEnable = false; - player->Rebuy(); - g_bClientPrintEnable = oldval; - } - } - else if (FStrEq(pcmd, "smartradio")) - { - player->SmartRadio(); - } - else - { - if (HandleBuyAliasCommands(player, pcmd)) - return; - - if (HandleRadioAliasCommands(player, pcmd)) - return; - - if (!g_pGameRules->ClientCommand(GetClassPtr((CBasePlayer *)pev), pcmd)) - { - // tell the user they entered an unknown command - char command[128]; - - // check the length of the command (prevents crash) - // max total length is 192 ...and we're adding a string below ("Unknown command: %s\n") - Q_strncpy(command, pcmd, sizeof(command) - 1); - command[sizeof(command) - 1] = '\0'; - - // tell the user they entered an unknown command - ClientPrint(&pEntity->v, HUD_PRINTCONSOLE, "#Game_unknown_command", command); - } - } - } - } -} - -/* <4b959> ../cstrike/dlls/client.cpp:4282 */ -void ClientUserInfoChanged(edict_t *pEntity, char *infobuffer) -{ - // Is the client spawned yet? - if (!pEntity->pvPrivateData) - { - return; - } - - CBasePlayer *pPlayer = (CBasePlayer *)CBaseEntity::Instance(pEntity); - - char *szBufferName = GET_KEY_VALUE(infobuffer, "name"); - int iClientIndex = pPlayer->entindex(); - - // msg everyone if someone changes their name, and it isn't the first time (changing no name to current name) - if (pEntity->v.netname && STRING(pEntity->v.netname)[0] != '\0' && !FStrEq(STRING(pEntity->v.netname), szBufferName)) - { - char szName[32]; - Q_snprintf(szName, sizeof(szName), "%s", szBufferName); - - // First parse the name and remove any %'s - for (char *pPct = szName; pPct != NULL && *pPct != '\0'; pPct++) - { - // Replace it with a space - if (*pPct == '%' || *pPct == '&') - *pPct = ' '; - } - - if (szName[0] == '#') - szName[0] = '*'; - - if (pPlayer->pev->deadflag != DEAD_NO) - { - pPlayer->m_bHasChangedName = true; - Q_snprintf(pPlayer->m_szNewName, sizeof(pPlayer->m_szNewName), "%s", szName); - ClientPrint(pPlayer->pev, HUD_PRINTTALK, "#Name_change_at_respawn"); - SET_CLIENT_KEY_VALUE(iClientIndex, infobuffer, "name", (char *)STRING(pEntity->v.netname)); - } - else - { - // Set the name - SET_CLIENT_KEY_VALUE(iClientIndex, infobuffer, "name", szName); - - MESSAGE_BEGIN(MSG_BROADCAST, gmsgSayText); - WRITE_BYTE(iClientIndex); - WRITE_STRING("#Cstrike_Name_Change"); - WRITE_STRING(STRING(pEntity->v.netname)); - WRITE_STRING(szName); - MESSAGE_END(); - - UTIL_LogPrintf - ( - "\"%s<%i><%s><%s>\" changed name to \"%s\"\n", - STRING(pEntity->v.netname), - GETPLAYERUSERID(pEntity), - GETPLAYERAUTHID(pEntity), - GetTeam(pPlayer->m_iTeam), - szName - ); - } - } - - g_pGameRules->ClientUserInfoChanged(GetClassPtr((CBasePlayer *)&pEntity->v), infobuffer); -} - -/* <4a378> ../cstrike/dlls/client.cpp:4362 */ -void ServerDeactivate(void) -{ - // It's possible that the engine will call this function more times than is necessary - // Therefore, only run it one time for each call to ServerActivate - if (g_serveractive != 1) - { - return; - } - - g_serveractive = 0; - - // Peform any shutdown operations here... - g_pGameRules->ServerDeactivate(); - CLocalNav::Reset(); - TheBots->ServerDeactivate(); - - if (g_pHostages) - { - g_pHostages->ServerDeactivate(); - } -} - -/* <4a392> ../cstrike/dlls/client.cpp:4400 */ -void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax) -{ - int i; - CBaseEntity *pClass; - - // Every call to ServerActivate should be matched by a call to ServerDeactivate - g_serveractive = 1; - EmptyEntityHashTable(); - - // Clients have not been initialized yet - for (i = 0; i < edictCount; i++) - { - edict_t *pEdict = &pEdictList[i]; - - if (pEdict->free) - continue; - - // Clients aren't necessarily initialized until ClientPutInServer() - if (i < clientMax || !pEdict->pvPrivateData) - continue; - - pClass = CBaseEntity::Instance(pEdict); - - // Activate this entity if it's got a class & isn't dormant - if (pClass && !(pClass->pev->flags & FL_DORMANT)) - { - AddEntityHashValue(&pEdict->v, STRING(pEdict->v.classname), CLASSNAME); - pClass->Activate(); - } - else - ALERT(at_console, "Can't instance %s\n", STRING(pEdict->v.classname)); - } - - // Link user messages here to make sure first client can get them... - LinkUserMessages(); - WriteSigonMessages(); - - if (g_pGameRules) - { - g_pGameRules->CheckMapConditions(); - } - - TheBots->ServerActivate(); - - if (g_pHostages) - { - g_pHostages->ServerActivate(); - } -} - -/* <4a404> ../cstrike/dlls/client.cpp:4459 */ -void PlayerPreThink(edict_t *pEntity) -{ - entvars_t *pev = &pEntity->v; - CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE(pEntity); - - if (pPlayer) - { - pPlayer->PreThink(); - } -} - -/* <4a47c> ../cstrike/dlls/client.cpp:4475 */ -void PlayerPostThink(edict_t *pEntity) -{ - entvars_t *pev = &pEntity->v; - CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE(pEntity); - - if (pPlayer) - { - pPlayer->PostThink(); - } -} - -/* <4a4f4> ../cstrike/dlls/client.cpp:4486 */ -void ParmsNewLevel(void) -{ - ; -} - -/* <4a50d> ../cstrike/dlls/client.cpp:4491 */ -void ParmsChangeLevel(void) -{ - // retrieve the pointer to the save data - SAVERESTOREDATA *pSaveData = (SAVERESTOREDATA *)gpGlobals->pSaveData; - - if (pSaveData) - { - pSaveData->connectionCount = BuildChangeList(pSaveData->levelList, MAX_LEVEL_CONNECTIONS); - } -} - -/* <4a548> ../cstrike/dlls/client.cpp:4504 */ -void StartFrame(void) -{ - if (g_pGameRules != NULL) - { - g_pGameRules->Think(); - } - - if (g_fGameOver) - return; - - CLocalNav::Think(); - - static cvar_t *skill = NULL; - if (!skill) - { - skill = CVAR_GET_POINTER("skill"); - } - - gpGlobals->teamplay = 1.0f; - - if (skill != NULL) - g_iSkillLevel = (int)skill->value; - - else - g_iSkillLevel = 0; - - TheBots->StartFrame(); - - if (TheTutor) - { - TheTutor->StartFrame(gpGlobals->time); - } - - ++g_ulFrameCount; -} - -/* <4a581> ../cstrike/dlls/client.cpp:4534 */ -void ClientPrecache(void) -{ - int i; - bool isCZero = UTIL_IsGame("czero"); - - PRECACHE_SOUND("weapons/dryfire_pistol.wav"); - PRECACHE_SOUND("weapons/dryfire_rifle.wav"); - PRECACHE_SOUND("player/pl_shot1.wav"); - PRECACHE_SOUND("player/pl_die1.wav"); - PRECACHE_SOUND("player/headshot1.wav"); - PRECACHE_SOUND("player/headshot2.wav"); - PRECACHE_SOUND("player/headshot3.wav"); - PRECACHE_SOUND("player/bhit_flesh-1.wav"); - PRECACHE_SOUND("player/bhit_flesh-2.wav"); - PRECACHE_SOUND("player/bhit_flesh-3.wav"); - PRECACHE_SOUND("player/bhit_kevlar-1.wav"); - PRECACHE_SOUND("player/bhit_helmet-1.wav"); - PRECACHE_SOUND("player/die1.wav"); - PRECACHE_SOUND("player/die2.wav"); - PRECACHE_SOUND("player/die3.wav"); - PRECACHE_SOUND("player/death6.wav"); - PRECACHE_SOUND("radio/locknload.wav"); - PRECACHE_SOUND("radio/letsgo.wav"); - PRECACHE_SOUND("radio/moveout.wav"); - PRECACHE_SOUND("radio/com_go.wav"); - PRECACHE_SOUND("radio/rescued.wav"); - PRECACHE_SOUND("radio/rounddraw.wav"); - PRECACHE_SOUND("items/kevlar.wav"); - PRECACHE_SOUND("items/ammopickup2.wav"); - PRECACHE_SOUND("items/nvg_on.wav"); - PRECACHE_SOUND("items/nvg_off.wav"); - PRECACHE_SOUND("items/equip_nvg.wav"); - PRECACHE_SOUND("weapons/c4_beep1.wav"); - PRECACHE_SOUND("weapons/c4_beep2.wav"); - PRECACHE_SOUND("weapons/c4_beep3.wav"); - PRECACHE_SOUND("weapons/c4_beep4.wav"); - PRECACHE_SOUND("weapons/c4_beep5.wav"); - PRECACHE_SOUND("weapons/c4_explode1.wav"); - PRECACHE_SOUND("weapons/c4_plant.wav"); - PRECACHE_SOUND("weapons/c4_disarm.wav"); - PRECACHE_SOUND("weapons/c4_disarmed.wav"); - PRECACHE_SOUND("weapons/explode3.wav"); - PRECACHE_SOUND("weapons/explode4.wav"); - PRECACHE_SOUND("weapons/explode5.wav"); - PRECACHE_SOUND("player/sprayer.wav"); - PRECACHE_SOUND("player/pl_fallpain2.wav"); - PRECACHE_SOUND("player/pl_fallpain3.wav"); - PRECACHE_SOUND("player/pl_snow1.wav"); - PRECACHE_SOUND("player/pl_snow2.wav"); - PRECACHE_SOUND("player/pl_snow3.wav"); - PRECACHE_SOUND("player/pl_snow4.wav"); - PRECACHE_SOUND("player/pl_snow5.wav"); - PRECACHE_SOUND("player/pl_snow6.wav"); - PRECACHE_SOUND("player/pl_step1.wav"); - PRECACHE_SOUND("player/pl_step2.wav"); - PRECACHE_SOUND("player/pl_step3.wav"); - PRECACHE_SOUND("player/pl_step4.wav"); - PRECACHE_SOUND("common/npc_step1.wav"); - PRECACHE_SOUND("common/npc_step2.wav"); - PRECACHE_SOUND("common/npc_step3.wav"); - PRECACHE_SOUND("common/npc_step4.wav"); - PRECACHE_SOUND("player/pl_metal1.wav"); - PRECACHE_SOUND("player/pl_metal2.wav"); - PRECACHE_SOUND("player/pl_metal3.wav"); - PRECACHE_SOUND("player/pl_metal4.wav"); - PRECACHE_SOUND("player/pl_dirt1.wav"); - PRECACHE_SOUND("player/pl_dirt2.wav"); - PRECACHE_SOUND("player/pl_dirt3.wav"); - PRECACHE_SOUND("player/pl_dirt4.wav"); - PRECACHE_SOUND("player/pl_duct1.wav"); - PRECACHE_SOUND("player/pl_duct2.wav"); - PRECACHE_SOUND("player/pl_duct3.wav"); - PRECACHE_SOUND("player/pl_duct4.wav"); - PRECACHE_SOUND("player/pl_grate1.wav"); - PRECACHE_SOUND("player/pl_grate2.wav"); - PRECACHE_SOUND("player/pl_grate3.wav"); - PRECACHE_SOUND("player/pl_grate4.wav"); - PRECACHE_SOUND("player/pl_slosh1.wav"); - PRECACHE_SOUND("player/pl_slosh2.wav"); - PRECACHE_SOUND("player/pl_slosh3.wav"); - PRECACHE_SOUND("player/pl_slosh4.wav"); - PRECACHE_SOUND("player/pl_tile1.wav"); - PRECACHE_SOUND("player/pl_tile2.wav"); - PRECACHE_SOUND("player/pl_tile3.wav"); - PRECACHE_SOUND("player/pl_tile4.wav"); - PRECACHE_SOUND("player/pl_tile5.wav"); - PRECACHE_SOUND("player/pl_swim1.wav"); - PRECACHE_SOUND("player/pl_swim2.wav"); - PRECACHE_SOUND("player/pl_swim3.wav"); - PRECACHE_SOUND("player/pl_swim4.wav"); - PRECACHE_SOUND("player/pl_ladder1.wav"); - PRECACHE_SOUND("player/pl_ladder2.wav"); - PRECACHE_SOUND("player/pl_ladder3.wav"); - PRECACHE_SOUND("player/pl_ladder4.wav"); - PRECACHE_SOUND("player/pl_wade1.wav"); - PRECACHE_SOUND("player/pl_wade2.wav"); - PRECACHE_SOUND("player/pl_wade3.wav"); - PRECACHE_SOUND("player/pl_wade4.wav"); - PRECACHE_SOUND("debris/wood1.wav"); - PRECACHE_SOUND("debris/wood2.wav"); - PRECACHE_SOUND("debris/wood3.wav"); - PRECACHE_SOUND("plats/train_use1.wav"); - PRECACHE_SOUND("plats/vehicle_ignition.wav"); - PRECACHE_SOUND("buttons/spark5.wav"); - PRECACHE_SOUND("buttons/spark6.wav"); - PRECACHE_SOUND("debris/glass1.wav"); - PRECACHE_SOUND("debris/glass2.wav"); - PRECACHE_SOUND("debris/glass3.wav"); - PRECACHE_SOUND("items/flashlight1.wav"); - PRECACHE_SOUND("items/flashlight1.wav"); - PRECACHE_SOUND("common/bodysplat.wav"); - PRECACHE_SOUND("player/pl_pain2.wav"); - PRECACHE_SOUND("player/pl_pain4.wav"); - PRECACHE_SOUND("player/pl_pain5.wav"); - PRECACHE_SOUND("player/pl_pain6.wav"); - PRECACHE_SOUND("player/pl_pain7.wav"); - - int numPlayerModels; - if (isCZero) - numPlayerModels = ARRAYSIZE(sPlayerModelFiles); - else - numPlayerModels = ARRAYSIZE(sPlayerModelFiles) - 2; - - for (i = 0; i < numPlayerModels; i++) - PRECACHE_MODEL(sPlayerModelFiles[i]); - - for (i = FirstCustomSkin; i <= LastCustomSkin; i++) - { - const char *fname = TheBotProfiles->GetCustomSkinFname(i); - - if (!fname) - break; - - PRECACHE_MODEL((char *)fname); - } - - PRECACHE_MODEL("models/p_ak47.mdl"); - PRECACHE_MODEL("models/p_aug.mdl"); - PRECACHE_MODEL("models/p_awp.mdl"); - PRECACHE_MODEL("models/p_c4.mdl"); - PRECACHE_MODEL("models/w_c4.mdl"); - PRECACHE_MODEL("models/p_deagle.mdl"); - PRECACHE_MODEL("models/shield/p_shield_deagle.mdl"); - PRECACHE_MODEL("models/p_flashbang.mdl"); - PRECACHE_MODEL("models/shield/p_shield_flashbang.mdl"); - PRECACHE_MODEL("models/p_hegrenade.mdl"); - PRECACHE_MODEL("models/shield/p_shield_hegrenade.mdl"); - PRECACHE_MODEL("models/p_glock18.mdl"); - PRECACHE_MODEL("models/shield/p_shield_glock18.mdl"); - PRECACHE_MODEL("models/p_p228.mdl"); - PRECACHE_MODEL("models/shield/p_shield_p228.mdl"); - PRECACHE_MODEL("models/p_smokegrenade.mdl"); - PRECACHE_MODEL("models/shield/p_shield_smokegrenade.mdl"); - PRECACHE_MODEL("models/p_usp.mdl"); - PRECACHE_MODEL("models/shield/p_shield_usp.mdl"); - PRECACHE_MODEL("models/p_fiveseven.mdl"); - PRECACHE_MODEL("models/shield/p_shield_fiveseven.mdl"); - PRECACHE_MODEL("models/p_knife.mdl"); - PRECACHE_MODEL("models/shield/p_shield_knife.mdl"); - PRECACHE_MODEL("models/w_flashbang.mdl"); - PRECACHE_MODEL("models/w_hegrenade.mdl"); - PRECACHE_MODEL("models/p_sg550.mdl"); - PRECACHE_MODEL("models/p_g3sg1.mdl"); - PRECACHE_MODEL("models/p_m249.mdl"); - PRECACHE_MODEL("models/p_m3.mdl"); - PRECACHE_MODEL("models/p_m4a1.mdl"); - PRECACHE_MODEL("models/p_mac10.mdl"); - PRECACHE_MODEL("models/p_mp5.mdl"); - PRECACHE_MODEL("models/p_ump45.mdl"); - PRECACHE_MODEL("models/p_p90.mdl"); - PRECACHE_MODEL("models/p_scout.mdl"); - PRECACHE_MODEL("models/p_sg552.mdl"); - PRECACHE_MODEL("models/w_smokegrenade.mdl"); - PRECACHE_MODEL("models/p_tmp.mdl"); - PRECACHE_MODEL("models/p_elite.mdl"); - PRECACHE_MODEL("models/p_xm1014.mdl"); - PRECACHE_MODEL("models/p_galil.mdl"); - PRECACHE_MODEL("models/p_famas.mdl"); - PRECACHE_MODEL("models/p_shield.mdl"); - PRECACHE_MODEL("models/w_shield.mdl"); - - Vector temp = g_vecZero; - Vector vMin = Vector(-38, -24, -41); - Vector vMax = Vector(38, 24, 41); - - for (i = 0; i < numPlayerModels; i++) - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, sPlayerModelFiles[i]); - - for (i = FirstCustomSkin; i <= LastCustomSkin; i++) - { - const char *fname = TheBotProfiles->GetCustomSkinFname(i); - - if (!fname) - break; - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds_if_avail, (float *)&vMin, (float *)&vMax, fname); - } - - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke1.spr"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke2.spr"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke3.spr"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke4.spr"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/fast_wallpuff1.spr"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/smokepuff.spr"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/gas_puff_01.spr"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc.tga"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc_nw.tga"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc_ne.tga"); - ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc_sw.tga"); - - if (isCZero) - { - vMin = Vector(-13, -6, -22); - vMax = Vector(13, 6, 22); - } - else - { - vMin = Vector(-12, -6, -22); - vMax = Vector(12, 6, 22); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_deagle.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_p228.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_elite.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_usp.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_fiveseven.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_glock18.mdl"); - - if (isCZero) - { - vMin = Vector(-26, -19, -21); - vMax = Vector(26, 23, 21); - } - else - { - vMin = Vector(-25, -19, -21); - vMax = Vector(25, 23, 21); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_xm1014.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_m3.mdl"); - - if (isCZero) - { - vMin = Vector(-23, -9, -20); - vMax = Vector(23, 17, 20); - } - else - { - vMin = Vector(-23, -8, -20); - vMax = Vector(23, 8, 20); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_mac10.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_mp5.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_ump45.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_tmp.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_p90.mdl"); - - if (isCZero) - { - vMin = Vector(-38, -33, -22); - vMax = Vector(38, 15, 35); - } - else - { - vMin = Vector(-31, -8, -21); - vMax = Vector(31, 12, 31); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_ak47.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_aug.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_awp.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_g3sg1.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_sg550.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_m4a1.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_scout.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_sg552.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_famas.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_galil.mdl"); - - if (isCZero) - { - vMin = Vector(-30, -10, -20); - vMax = Vector(30, 11, 20); - } - else - { - vMin = Vector(-24, -10, -20); - vMax = Vector(25, 10, 20); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_m249.mdl"); - - vMin = Vector(-7, -7, -15); - vMax = Vector(7, 7, 15); - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_c4.mdl"); - - vMin = Vector(-4, -8, -3); - vMax = Vector(3, 7, 3); - - if (isCZero) - { - vMin = Vector(-17, -8, -3); - vMax = Vector(17, 7, 3); - } - else - { - vMin = Vector(-4, -8, -3); - vMax = Vector(3, 7, 3); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_c4.mdl"); - - if (isCZero) - { - vMin = Vector(-7, -3, -18); - vMax = Vector(7, 2, 18); - } - else - { - vMin = Vector(-7, -2, -18); - vMax = Vector(7, 2, 18); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_flashbang.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_hegrenade.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_smokegrenade.mdl"); - - if (isCZero) - vMin = Vector(-5, -5, -7); - else - vMin = Vector(-5, -5, -5); - - vMax = Vector(5, 5, 14); - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_flashbang.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_hegrenade.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_smokegrenade.mdl"); - - vMin = Vector(-7, -11, -18); - vMax = Vector(7, 6, 18); - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_knife.mdl"); - - if (isCZero) - { - vMin = Vector(-21, -25, -54); - vMax = Vector(21, 23, 24); - } - else - { - vMin = Vector(-16, -8, -54); - vMax = Vector(16, 6, 24); - } - - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_deagle.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_fiveseven.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_flashbang.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_glock18.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_hegrenade.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_knife.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_p228.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_smokegrenade.mdl"); - ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_usp.mdl"); - - PRECACHE_SOUND("common/wpn_hudoff.wav"); - PRECACHE_SOUND("common/wpn_hudon.wav"); - PRECACHE_SOUND("common/wpn_moveselect.wav"); - PRECACHE_SOUND("common/wpn_select.wav"); - PRECACHE_SOUND("common/wpn_denyselect.wav"); - PRECACHE_SOUND("player/geiger6.wav"); - PRECACHE_SOUND("player/geiger5.wav"); - PRECACHE_SOUND("player/geiger4.wav"); - PRECACHE_SOUND("player/geiger3.wav"); - PRECACHE_SOUND("player/geiger2.wav"); - PRECACHE_SOUND("player/geiger1.wav"); - - if (giPrecacheGrunt) - UTIL_PrecacheOther("enemy_terrorist"); - - g_iShadowSprite = PRECACHE_MODEL("sprites/shadow_circle.spr"); - - PRECACHE_MODEL("sprites/wall_puff1.spr"); - PRECACHE_MODEL("sprites/wall_puff2.spr"); - PRECACHE_MODEL("sprites/wall_puff3.spr"); - PRECACHE_MODEL("sprites/wall_puff4.spr"); - PRECACHE_MODEL("sprites/black_smoke1.spr"); - PRECACHE_MODEL("sprites/black_smoke2.spr"); - PRECACHE_MODEL("sprites/black_smoke3.spr"); - PRECACHE_MODEL("sprites/black_smoke4.spr"); - PRECACHE_MODEL("sprites/fast_wallpuff1.spr"); - PRECACHE_MODEL("sprites/pistol_smoke1.spr"); - PRECACHE_MODEL("sprites/pistol_smoke2.spr"); - PRECACHE_MODEL("sprites/rifle_smoke1.spr"); - PRECACHE_MODEL("sprites/rifle_smoke2.spr"); - PRECACHE_MODEL("sprites/rifle_smoke3.spr"); - PRECACHE_GENERIC("sprites/scope_arc.tga"); - PRECACHE_GENERIC("sprites/scope_arc_nw.tga"); - PRECACHE_GENERIC("sprites/scope_arc_ne.tga"); - PRECACHE_GENERIC("sprites/scope_arc_sw.tga"); - - m_usResetDecals = g_engfuncs.pfnPrecacheEvent(1, "events/decal_reset.sc"); -} - -/* <4a6e5> ../cstrike/dlls/client.cpp:4996 */ -const char *GetGameDescription(void) -{ - if (UTIL_IsGame("czero")) - return "Condition Zero"; - - return "Counter-Strike"; -} - -/* <4a703> ../cstrike/dlls/client.cpp:5022 */ -void Sys_Error(const char *error_string) -{ - ; -} - -/* <4a731> ../cstrike/dlls/client.cpp:5039 */ -void PlayerCustomization(edict_t *pEntity, customization_t *pCust) -{ - CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE(pEntity); - - if (!pPlayer) - { - ALERT(at_console, "PlayerCustomization: Couldn't get player!\n"); - return; - } - - if (!pCust) - { - ALERT(at_console, "PlayerCustomization: NULL customization!\n"); - return; - } - - switch (pCust->resource.type) - { - case t_decal: - pPlayer->SetCustomDecalFrames(pCust->nUserData2); - break; - case t_sound: - case t_skin: - case t_model: - break; - default: - ALERT(at_console, "PlayerCustomization: Unknown customization type!\n"); - break; - } -} - -/* <4a7b9> ../cstrike/dlls/client.cpp:5079 */ -void SpectatorConnect(edict_t *pEntity) -{ - CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE(pEntity); - - if (pPlayer) - { - pPlayer->SpectatorConnect(); - } -} - -/* <4a83d> ../cstrike/dlls/client.cpp:5095 */ -void SpectatorDisconnect(edict_t *pEntity) -{ - CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE(pEntity); - - if (pPlayer) - { - pPlayer->SpectatorDisconnect(); - } -} - -/* <4a8b5> ../cstrike/dlls/client.cpp:5111 */ -void SpectatorThink(edict_t *pEntity) -{ - CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE(pEntity); - - if (pPlayer) - { - pPlayer->SpectatorThink(); - } -} - -/* <4a92d> ../cstrike/dlls/client.cpp:5160 */ -void SetupVisibility(edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas) -{ - edict_t *pView = pClient; - - // Find the client's PVS - if (pViewEntity) - { - pView = pViewEntity; - } - - if (pClient->v.flags & FL_PROXY) - { - *pvs = NULL; // the spectator proxy sees - *pas = NULL; // and hears everything - return; - } - - CBasePlayer *pPlayer = reinterpret_cast(CBasePlayer::Instance(pClient)); - - if (pPlayer->pev->iuser2 && pPlayer->m_hObserverTarget) - { - if (pPlayer->m_afPhysicsFlags & PFLAG_OBSERVER) - { - pView = pPlayer->m_hObserverTarget->edict(); - UTIL_SetOrigin(pPlayer->pev, pPlayer->m_hObserverTarget->pev->origin); - } - } - - Vector org = pView->v.origin + pView->v.view_ofs; - - if (pView->v.flags & FL_DUCKING) - { - org = org + (VEC_HULL_MIN - VEC_DUCK_HULL_MIN); - } - - *pvs = ENGINE_SET_PVS((float *)&org); - *pas = ENGINE_SET_PAS((float *)&org); -} - -/* <4aa75> ../cstrike/dlls/client.cpp:5226 */ -void ResetPlayerPVS(edict_t *client, int clientnum) -{ - PLAYERPVSSTATUS *pvs = &g_PVSStatus[clientnum]; - - Q_memset(pvs, 0, sizeof(*pvs)); - pvs->headnode = client->headnode; - pvs->num_leafs = client->num_leafs; - Q_memcpy(pvs->leafnums, client->leafnums, sizeof(pvs->leafnums)); -} - -/* <4aae8> ../cstrike/dlls/client.cpp:5240 */ -bool CheckPlayerPVSLeafChanged(edict_t *client, int clientnum) -{ - PLAYERPVSSTATUS *pvs = &g_PVSStatus[clientnum]; - if (pvs->headnode != client->headnode || pvs->num_leafs != client->num_leafs) - return true; - - for (int i = 0; i < pvs->num_leafs; i++) - { - if (client->leafnums[i] != pvs->leafnums[i]) - return true; - } - return false; -} - -/* <475e3> ../cstrike/dlls/client.cpp:5263 */ -void MarkEntityInPVS(int clientnum, int entitynum, float time, bool inpvs) -{ - PLAYERPVSSTATUS *pvs; - ENTITYPVSSTATUS *es; - - pvs = &g_PVSStatus[clientnum]; - es = &pvs->m_Status[entitynum]; - - if (inpvs) - es->m_fTimeEnteredPVS = time; - else - es->m_fTimeEnteredPVS = 0; -} - -/* <47581> ../cstrike/dlls/client.cpp:5275 */ -bool CheckEntityRecentlyInPVS(int clientnum, int entitynum, float currenttime) -{ - PLAYERPVSSTATUS *pvs; - ENTITYPVSSTATUS *es; - - pvs = &g_PVSStatus[clientnum]; - es = &pvs->m_Status[entitynum]; - - if (es->m_fTimeEnteredPVS && es->m_fTimeEnteredPVS + 1.0f >= currenttime) - { - return true; - } - - return false; -} - -/* <4ac57> ../cstrike/dlls/client.cpp:5312 */ -int AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet) -{ - if ((ent->v.effects & EF_NODRAW) == EF_NODRAW && ent != host) - return 0; - - if (!ent->v.modelindex || !STRING(ent->v.model)) - return 0; - - if ((ent->v.flags & FL_SPECTATOR) == FL_SPECTATOR && ent != host) - return 0; - - int i; - int hostnum = ENTINDEX(host) - 1; - - if (CheckPlayerPVSLeafChanged(host, hostnum)) - ResetPlayerPVS(host, hostnum); - - if (ent != host) - { - if (!CheckEntityRecentlyInPVS(hostnum, e, gpGlobals->time)) - { - if (!ENGINE_CHECK_VISIBILITY(ent, pSet)) - { - MarkEntityInPVS(hostnum, e, 0, false); - return 0; - } - - MarkEntityInPVS(hostnum, e, gpGlobals->time, true); - } - } - - if ((ent->v.flags & FL_SKIPLOCALHOST) == FL_SKIPLOCALHOST && (hostflags & 1) && ent->v.owner == host) - return 0; - - if (host->v.groupinfo) - { - UTIL_SetGroupTrace(host->v.groupinfo, GROUP_OP_AND); - - if (ent->v.groupinfo) - { - if (g_groupop == GROUP_OP_AND) - { - if (!(ent->v.groupinfo & host->v.groupinfo)) - return 0; - } - else if (g_groupop == GROUP_OP_NAND) - { - if (ent->v.groupinfo & host->v.groupinfo) - return 0; - } - } - - UTIL_UnsetGroupTrace(); - } - - Q_memset(state, 0, sizeof(*state)); - - state->number = e; - state->entityType = ENTITY_NORMAL; - - if (ent->v.flags & FL_CUSTOMENTITY) - state->entityType = ENTITY_BEAM; - - state->animtime = (int)(1000.0 * ent->v.animtime) / 1000.0; - - Q_memcpy(state->origin, ent->v.origin, sizeof(float) * 3); - Q_memcpy(state->angles, ent->v.angles, sizeof(float) * 3); - Q_memcpy(state->mins, ent->v.mins, sizeof(float) * 3); - Q_memcpy(state->maxs, ent->v.maxs, sizeof(float) * 3); - Q_memcpy(state->startpos, ent->v.startpos, sizeof(float) * 3); - Q_memcpy(state->endpos, ent->v.endpos, sizeof(float) * 3); - - state->impacttime = ent->v.impacttime; - state->starttime = ent->v.starttime; - state->modelindex = ent->v.modelindex; - state->frame = ent->v.frame; - state->skin = ent->v.skin; - state->effects = ent->v.effects; - - if (!player && ent->v.animtime && !ent->v.velocity.x && !ent->v.velocity.y && !ent->v.velocity.z) - state->eflags |= EFLAG_SLERP; - - state->scale = ent->v.scale; - state->solid = ent->v.solid; - state->colormap = ent->v.colormap; - state->movetype = ent->v.movetype; - state->sequence = ent->v.sequence; - state->framerate = ent->v.framerate; - state->body = ent->v.body; - - for (i = 0; i < 4; i++) - state->controller[i] = ent->v.controller[i]; - - for (i = 0; i < 2; i++) - state->blending[i] = ent->v.blending[i]; - - state->rendermode = ent->v.rendermode; - state->renderamt = (int)ent->v.renderamt; - state->renderfx = ent->v.renderfx; - state->rendercolor.r = (byte)ent->v.rendercolor.x; - state->rendercolor.g = (byte)ent->v.rendercolor.y; - state->rendercolor.b = (byte)ent->v.rendercolor.z; - - state->aiment = 0; - - if (ent->v.aiment) - state->aiment = ENTINDEX(ent->v.aiment); - - state->owner = 0; - if (ent->v.owner) - { - int owner = ENTINDEX(ent->v.owner); - - if (owner >= 1 && owner <= gpGlobals->maxClients) - state->owner = owner; - } - - if (player) - { - Q_memcpy(state->basevelocity, ent->v.basevelocity, sizeof(float) * 3); - - state->weaponmodel = MODEL_INDEX(STRING(ent->v.weaponmodel)); - state->gaitsequence = ent->v.gaitsequence; - - state->spectator = (ent->v.flags & FL_SPECTATOR) ? TRUE : FALSE; - state->friction = ent->v.friction; - state->gravity = ent->v.gravity; - state->usehull = (ent->v.flags & FL_DUCKING) ? 1 : 0; - state->health = (int)ent->v.health; - } - else - state->playerclass = ent->v.playerclass; - - state->iuser4 = ent->v.iuser4; - return 1; -} - -// Creates baselines used for network encoding, especially for player data since players are not spawned until connect time. - -/* <4aef3> ../cstrike/dlls/client.cpp:5516 */ -void CreateBaseline(int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, Vector player_mins, Vector player_maxs) -{ - baseline->origin = entity->v.origin; - baseline->angles = entity->v.angles; - - baseline->frame = entity->v.frame; - baseline->skin = (short)entity->v.skin; - - // render information - baseline->rendermode = (byte)entity->v.rendermode; - baseline->renderamt = (byte)entity->v.renderamt; - baseline->rendercolor.r = (byte)entity->v.rendercolor.x; - baseline->rendercolor.g = (byte)entity->v.rendercolor.y; - baseline->rendercolor.b = (byte)entity->v.rendercolor.z; - baseline->renderfx = (byte)entity->v.renderfx; - - if (player) - { - baseline->mins = player_mins; - baseline->maxs = player_maxs; - - baseline->colormap = eindex; - baseline->modelindex = playermodelindex; - baseline->friction = 1.0; - baseline->movetype = MOVETYPE_WALK; - - baseline->solid = SOLID_SLIDEBOX; - baseline->scale = entity->v.scale; - baseline->framerate = 1.0; - baseline->gravity = 1.0; - } - else - { - baseline->mins = entity->v.mins; - baseline->maxs = entity->v.maxs; - - baseline->colormap = 0; - baseline->modelindex = entity->v.modelindex; - baseline->movetype = entity->v.movetype; - - baseline->scale = entity->v.scale; - baseline->solid = entity->v.solid; - baseline->framerate = entity->v.framerate; - baseline->gravity = entity->v.gravity; - } -} - -/* <47d8a> ../cstrike/dlls/client.cpp:5586 */ -void Entity_FieldInit(struct delta_s *pFields) -{ - entity_field_alias[ FIELD_ORIGIN0 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ORIGIN0 ].name); - entity_field_alias[ FIELD_ORIGIN1 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ORIGIN1 ].name); - entity_field_alias[ FIELD_ORIGIN2 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ORIGIN2 ].name); - entity_field_alias[ FIELD_ANGLES0 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ANGLES0 ].name); - entity_field_alias[ FIELD_ANGLES1 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ANGLES1 ].name); - entity_field_alias[ FIELD_ANGLES2 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ANGLES2 ].name); -} - -// Callback for sending entity_state_t info over network. - -/* <47da7> ../cstrike/dlls/client.cpp:5604 */ -void Entity_Encode(struct delta_s *pFields, const unsigned char *from, const unsigned char *to) -{ - entity_state_t *f, *t; - int localplayer = 0; - static int initialized = 0; - - if (!initialized) - { - Entity_FieldInit(pFields); - initialized = 1; - } - - f = (entity_state_t *)from; - t = (entity_state_t *)to; - - // Never send origin to local player, it's sent with more resolution in clientdata_t structure - localplayer = (t->number - 1) == ENGINE_CURRENT_PLAYER(); - - if (localplayer) - { - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); - } - if (t->impacttime != 0 && t->starttime != 0) - { - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); - - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ANGLES0 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ANGLES1 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ANGLES2 ].field); - } - if (t->movetype == MOVETYPE_FOLLOW && t->aiment != 0) - { - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); - } - else if (t->aiment != f->aiment) - { - DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); - DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); - DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); - } -} - -/* <47cb4> ../cstrike/dlls/client.cpp:5662 */ -void Player_FieldInit(struct delta_s *pFields) -{ - player_field_alias[ FIELD_ORIGIN0 ].field = DELTA_FINDFIELD(pFields, player_field_alias[ FIELD_ORIGIN0 ].name); - player_field_alias[ FIELD_ORIGIN1 ].field = DELTA_FINDFIELD(pFields, player_field_alias[ FIELD_ORIGIN1 ].name); - player_field_alias[ FIELD_ORIGIN2 ].field = DELTA_FINDFIELD(pFields, player_field_alias[ FIELD_ORIGIN2 ].name); -} - -// Callback for sending entity_state_t for players info over network. - -/* <47cd1> ../cstrike/dlls/client.cpp:5676 */ -void Player_Encode(struct delta_s *pFields, const unsigned char *from, const unsigned char *to) -{ - entity_state_t *f, *t; - int localplayer = 0; - - static int initialized = 0; - if (!initialized) - { - Player_FieldInit(pFields); - initialized = 1; - } - - f = (entity_state_t *)from; - t = (entity_state_t *)to; - - // Never send origin to local player, it's sent with more resolution in clientdata_t structure - localplayer = (t->number - 1) == ENGINE_CURRENT_PLAYER(); - - if (localplayer) - { - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); - } - if (t->movetype == MOVETYPE_FOLLOW && t->aiment != 0) - { - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); - DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); - } - else if (t->aiment != f->aiment) - { - DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); - DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); - DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); - } -} - -/* <4afc4> ../cstrike/dlls/client.cpp:5738 */ -void Custom_Entity_FieldInit(delta_s *pFields) -{ - custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].name); - custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].name); - custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].name); - custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].name); - custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].name); - custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].name); - custom_entity_field_alias[ CUSTOMFIELD_SKIN ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_SKIN ].name); - custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].name); - custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].name); -} - -// Callback for sending entity_state_t info ( for custom entities ) over network. - -/* <4aff3> ../cstrike/dlls/client.cpp:5759 */ -void Custom_Encode(struct delta_s *pFields, const unsigned char *from, const unsigned char *to) -{ - entity_state_t *f, *t; - int beamType; - static int initialized = 0; - - if (!initialized) - { - Custom_Entity_FieldInit(pFields); - initialized = 1; - } - - f = (entity_state_t *)from; - t = (entity_state_t *)to; - - beamType = t->rendermode & 0x0F; - - if (beamType != BEAM_POINTS) - { - if (beamType != BEAM_ENTPOINT) - { - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].field); - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].field); - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].field); - } - - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].field); - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].field); - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].field); - } - - if (beamType != BEAM_ENTS && beamType != BEAM_ENTPOINT) - { - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_SKIN ].field); - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].field); - } - - // animtime is compared by rounding first - // see if we really shouldn't actually send it - - if ((int)f->animtime == (int)t->animtime) - { - DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].field); - } -} - -/* <4b08a> ../cstrike/dlls/client.cpp:5811 */ -void RegisterEncoders(void) -{ - DELTA_ADDENCODER("Entity_Encode", Entity_Encode); - DELTA_ADDENCODER("Custom_Encode", Custom_Encode); - DELTA_ADDENCODER("Player_Encode", Player_Encode); -} - -/* <4b0a4> ../cstrike/dlls/client.cpp:5818 */ -int GetWeaponData(edict_s *player, struct weapon_data_s *info) -{ - entvars_t *pev = &player->v; - CBasePlayer *pl = reinterpret_cast(CBasePlayer::Instance(pev)); - - Q_memset(info, 0, sizeof(weapon_data_t) * MAX_WEAPONS); - - if (!pl) - { - return 1; - } - - for (int i = 0; i < MAX_ITEM_TYPES; i++) - { - CBasePlayerItem *pPlayerItem = pl->m_rgpPlayerItems[i]; - - while (pPlayerItem != NULL) - { - CBasePlayerWeapon *gun = reinterpret_cast(pPlayerItem->GetWeaponPtr()); - - if (gun && gun->UseDecrement()) - { - ItemInfo II; - Q_memset(&II, 0, sizeof(II)); - gun->GetItemInfo(&II); - - if (II.iId >= 0 && II.iId < MAX_WEAPONS) - { - weapon_data_t *item = &info[II.iId]; - - item->m_iId = II.iId; - item->m_iClip = gun->m_iClip; - item->m_flTimeWeaponIdle = Q_max(gun->m_flTimeWeaponIdle, -0.001f); - item->m_flNextPrimaryAttack = Q_max(gun->m_flNextPrimaryAttack, -0.001f); - item->m_flNextSecondaryAttack = Q_max(gun->m_flNextSecondaryAttack, -0.001f); - item->m_flNextReload = Q_max(gun->m_flNextReload, -0.001f); - item->m_fInReload = gun->m_fInReload; - item->m_fInSpecialReload = gun->m_fInSpecialReload; - item->m_fInZoom = gun->m_iShotsFired; - item->m_fAimedDamage = gun->m_flLastFire; - item->m_iWeaponState = gun->m_iWeaponState; - item->fuser2 = gun->m_flStartThrow; - item->fuser3 = gun->m_flReleaseThrow; - item->iuser1 = gun->m_iSwing; - } - } - - pPlayerItem = pPlayerItem->m_pNext; - } - } - - return 1; -} - -/* <4b1fd> ../cstrike/dlls/client.cpp:5889 */ -void UpdateClientData(const struct edict_s *ent, int sendweapons, struct clientdata_s *cd) -{ - if (!ent || !ent->pvPrivateData) - { - return; - } - - entvars_t *pevOrg = NULL; - entvars_t *pev = (entvars_t *)&ent->v; - CBasePlayer *pl = reinterpret_cast(CBasePlayer::Instance(pev)); - - if (pl->pev->iuser1 == OBS_IN_EYE && pl->m_hObserverTarget) - { - pevOrg = pev; - pev = pl->m_hObserverTarget->pev; - pl = reinterpret_cast(CBasePlayer::Instance(pev)); - } - - cd->flags = pev->flags; - cd->health = pev->health; - cd->viewmodel = MODEL_INDEX(STRING(pev->viewmodel)); - cd->waterlevel = pev->waterlevel; - cd->watertype = pev->watertype; - cd->weapons = pev->weapons; - cd->origin = pev->origin; - cd->velocity = pev->velocity; - cd->view_ofs = pev->view_ofs; - cd->punchangle = pev->punchangle; - cd->bInDuck = pev->bInDuck; - cd->flTimeStepSound = pev->flTimeStepSound; - cd->flDuckTime = pev->flDuckTime; - cd->flSwimTime = pev->flSwimTime; - cd->waterjumptime = (int)pev->teleport_time; - - Q_strcpy(cd->physinfo, ENGINE_GETPHYSINFO(ent)); - - cd->maxspeed = pev->maxspeed; - cd->fov = pev->fov; - cd->weaponanim = pev->weaponanim; - cd->pushmsec = pev->pushmsec; - - if (pevOrg) - { - cd->iuser1 = pevOrg->iuser1; - cd->iuser2 = pevOrg->iuser2; - cd->iuser3 = pevOrg->iuser3; - } - else - { - cd->iuser1 = pev->iuser1; - cd->iuser2 = pev->iuser2; - cd->iuser3 = pev->iuser3; - } - - cd->fuser1 = pev->fuser1; - cd->fuser3 = pev->fuser3; - cd->fuser2 = pev->fuser2; - - if (sendweapons && pl != NULL) - { - cd->ammo_shells = pl->ammo_buckshot; - cd->ammo_nails = pl->ammo_9mm; - cd->ammo_cells = pl->ammo_556nato; - cd->ammo_rockets = pl->ammo_556natobox; - cd->vuser2.x = pl->ammo_762nato; - cd->vuser2.y = pl->ammo_45acp; - cd->vuser2.z = pl->ammo_50ae; - cd->vuser3.x = pl->ammo_338mag; - cd->vuser3.y = pl->ammo_57mm; - cd->vuser3.z = pl->ammo_357sig; - cd->m_flNextAttack = pl->m_flNextAttack; - - int iUser3 = 0; - if (pl->m_bCanShoot && !pl->m_bIsDefusing) - iUser3 |= DATA_IUSER3_CANSHOOT; - - if (g_pGameRules->IsFreezePeriod()) - iUser3 |= DATA_IUSER3_FREEZETIMEOVER; - else - iUser3 &= ~DATA_IUSER3_FREEZETIMEOVER; - - if (pl->m_signals.GetState() & SIGNAL_BOMB) - iUser3 |= DATA_IUSER3_INBOMBZONE; - else - iUser3 &= ~DATA_IUSER3_INBOMBZONE; - - if (pl->HasShield()) - iUser3 |= DATA_IUSER3_HOLDINGSHIELD; - else - iUser3 &= ~DATA_IUSER3_HOLDINGSHIELD; - - if (!pl->pev->iuser1 && !pevOrg) - cd->iuser3 = iUser3; - - if (pl->m_pActiveItem != NULL) - { - ItemInfo II; - Q_memset(&II, 0, sizeof(II)); - - CBasePlayerWeapon *gun = reinterpret_cast(pl->m_pActiveItem->GetWeaponPtr()); - - if (gun != NULL && gun->UseDecrement() && gun->GetItemInfo(&II)) - { - cd->m_iId = II.iId; - - if ((unsigned int)gun->m_iPrimaryAmmoType < MAX_AMMO_TYPES) - { - cd->vuser4.x = gun->m_iPrimaryAmmoType; - cd->vuser4.y = pl->m_rgAmmo[ gun->m_iPrimaryAmmoType ]; - } - else - { - cd->vuser4.x = -1.0; - cd->vuser4.y = 0; - } - } - } - } -} - -/* <4b3ee> ../cstrike/dlls/client.cpp:6050 */ -void CmdStart(const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed) -{ - entvars_t *pev = (entvars_t *)&player->v; - CBasePlayer *pl = reinterpret_cast(CBasePlayer::Instance(pev)); - - if (!pl) - { - return; - } - - if (pl->pev->groupinfo) - { - UTIL_SetGroupTrace(pl->pev->groupinfo, GROUP_OP_AND); - } - - pl->random_seed = random_seed; -} - -/* <4b4eb> ../cstrike/dlls/client.cpp:6074 */ -void CmdEnd(const edict_t *player) -{ - entvars_t *pev = (entvars_t *)&player->v; - CBasePlayer *pl = reinterpret_cast(CBasePlayer::Instance(pev)); - - if (!pl) - return; - - if (pl->pev->groupinfo) - UTIL_UnsetGroupTrace(); - - if (pev->flags & FL_DUCKING) - UTIL_SetSize(pev, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX); -} - -/* <4b644> ../cstrike/dlls/client.cpp:6101 */ -int ConnectionlessPacket(const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size) -{ - // Parse stuff from args - int max_buffer_size = *response_buffer_size; - - // Zero it out since we aren't going to respond. - // If we wanted to response, we'd write data into response_buffer - *response_buffer_size = 0; - - // Since we don't listen for anything here, just respond that it's a bogus message - // If we didn't reject the message, we'd return 1 for success instead. - return 0; -} - -/* <4b6c2> ../cstrike/dlls/client.cpp:6122 */ -int GetHullBounds(int hullnumber, float *mins, float *maxs) -{ - return hullnumber < 3; -} - -// Create pseudo-baselines for items that aren't placed in the map at spawn time, but which are likely -// to be created during play ( e.g., grenades, ammo packs, projectiles, corpses, etc. ) - -/* <4b733> ../cstrike/dlls/client.cpp:6156 */ -void CreateInstancedBaselines(void) -{ - int iret = 0; - entity_state_t state; - - Q_memset(&state, 0, sizeof(state)); - - // Create any additional baselines here for things like grendates, etc. - // iret = ENGINE_INSTANCE_BASELINE(pc->pev->classname, &state); - - // Destroy objects. - // UTIL_Remove(pc); -} - -/* <4b77c> ../cstrike/dlls/client.cpp:6179 */ -int InconsistentFile(const edict_t *player, const char *filename, char *disconnect_message) -{ - // Server doesn't care? - if (CVAR_GET_FLOAT("mp_consistency") != 1) - return 0; - - // Default behavior is to kick the player - Q_sprintf(disconnect_message, "Server is enforcing file consistency for %s\n", filename); - - // Kick now with specified disconnect message. - return 1; -} - -// The game .dll should return 1 if lag compensation should be allowed ( could also just set -// the sv_unlag cvar. -// Most games right now should return 0, until client-side weapon prediction code is written -// and tested for them ( note you can predict weapons, but not do lag compensation, too, -// if you want. - -/* <4b7cf> ../cstrike/dlls/client.cpp:6204 */ -int AllowLagCompensation(void) -{ - return 1; -} +#include "precompiled.h" +#include "entity_state.h" + +/* +* Globals initialization +*/ +#ifndef HOOK_GAMEDLL + +float g_flTimeLimit = 0; +float g_flResetTime = 0; +bool g_bClientPrintEnable = true; + +char *sPlayerModelFiles[] = +{ + "models/player.mdl", + "models/player/leet/leet.mdl", + "models/player/gign/gign.mdl", + "models/player/vip/vip.mdl", + "models/player/gsg9/gsg9.mdl", + "models/player/guerilla/guerilla.mdl", + "models/player/arctic/arctic.mdl", + "models/player/sas/sas.mdl", + "models/player/terror/terror.mdl", + "models/player/urban/urban.mdl", + "models/player/spetsnaz/spetsnaz.mdl", // CZ + "models/player/militia/militia.mdl" // CZ +}; + +bool g_skipCareerInitialSpawn; + +static entity_field_alias_t entity_field_alias[] = +{ + { "origin[0]", 0 }, + { "origin[1]", 0 }, + { "origin[2]", 0 }, + { "angles[0]", 0 }, + { "angles[1]", 0 }, + { "angles[2]", 0 }, +}; + +static entity_field_alias_t player_field_alias[] = +{ + { "origin[0]", 0 }, + { "origin[1]", 0 }, + { "origin[2]", 0 }, +} + +static entity_field_alias_t custom_entity_field_alias[] = +{ + { "origin[0]", 0 }, + { "origin[1]", 0 }, + { "origin[2]", 0 }, + { "angles[0]", 0 }, + { "angles[1]", 0 }, + { "angles[2]", 0 }, + { "skin", 0 }, + { "sequence", 0 }, + { "animtime", 0 }, +} + +static int g_serveractive = 0; + +#else + +float g_flTimeLimit; +float g_flResetTime; +bool g_bClientPrintEnable; + +char *sPlayerModelFiles[12]; +bool g_skipCareerInitialSpawn; + +entity_field_alias_t entity_field_alias[6]; +entity_field_alias_t player_field_alias[3]; +entity_field_alias_t custom_entity_field_alias[9]; +int g_serveractive; + +#endif // HOOK_GAMEDLL + +PLAYERPVSSTATUS g_PVSStatus[32]; +unsigned short m_usResetDecals; +unsigned short g_iShadowSprite; + +/* <47b45> ../cstrike/dlls/client.cpp:76 */ +int CMD_ARGC_(void) +{ + if (!UseBotArgs) + return CMD_ARGC(); + + int i = 0; + + while (BotArgs[i]) + i++; + + return i; +} + +/* <47b84> ../cstrike/dlls/client.cpp:90 */ +const char *CMD_ARGV_(int i) +{ + if (!UseBotArgs) + return CMD_ARGV(i); + + if (i < 4) + return BotArgs[i]; + + return NULL; +} + +/* <47eac> ../cstrike/dlls/client.cpp:180 */ +NOXREF void set_suicide_frame(entvars_t *pev) +{ + if (!FStrEq(STRING(pev->model), "models/player.mdl")) + return; + + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_TOSS; + pev->deadflag = DEAD_DEAD; + pev->nextthink = -1; +} + +/* <47a58> ../cstrike/dlls/client.cpp:192 */ +void TeamChangeUpdate(CBasePlayer *player, int team_id) +{ + MESSAGE_BEGIN(MSG_ALL, gmsgTeamInfo); + WRITE_BYTE(player->entindex()); + switch (team_id) + { + case CT: + WRITE_STRING("CT"); + break; + case TERRORIST: + WRITE_STRING("TERRORIST"); + break; + case SPECTATOR: + WRITE_STRING("SPECTATOR"); + break; + default: + WRITE_STRING("UNASSIGNED"); + break; + } + MESSAGE_END(); + + if (team_id != UNASSIGNED) + { + player->SetScoreboardAttributes(); + } +} + +/* <4731f> ../cstrike/dlls/client.cpp:222 */ +void BlinkAccount(CBasePlayer *player, int numBlinks) +{ + MESSAGE_BEGIN(MSG_ONE, gmsgBlinkAcct, NULL, player->pev); + WRITE_BYTE(numBlinks); + MESSAGE_END(); +} + +/* <47efd> ../cstrike/dlls/client.cpp:236 */ +BOOL ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *szRejectReason) +{ + return g_pGameRules->ClientConnected(pEntity, pszName, pszAddress, szRejectReason); +} + +/* <47f5b> ../cstrike/dlls/client.cpp:255 */ +void ClientDisconnect(edict_t *pEntity) +{ + CBasePlayer *pPlayer = (CBasePlayer *)CBaseEntity::Instance(pEntity); + + if (!g_fGameOver) + { + UTIL_ClientPrintAll(HUD_PRINTNOTIFY, "#Game_disconnected", STRING(pEntity->v.netname)); + CSound *pSound = CSoundEnt::SoundPointerForIndex(CSoundEnt::ClientSoundIndex(pEntity)); + + if (pSound) + pSound->Reset(); + + pEntity->v.takedamage = DAMAGE_NO; + pEntity->v.solid = SOLID_NOT; + pEntity->v.flags = FL_DORMANT; + + if (pPlayer) + pPlayer->SetThink(NULL); + + UTIL_SetOrigin(&pEntity->v, pEntity->v.origin); + g_pGameRules->ClientDisconnected(pEntity); + } + + if (pPlayer && pPlayer->IsBot()) + { + TheBots->ClientDisconnect(pPlayer); + } +} + +/* <4c477> ../cstrike/dlls/client.cpp:306 */ +void respawn(entvars_t *pev, BOOL fCopyCorpse) +{ + if (gpGlobals->coop || gpGlobals->deathmatch) + { + CHalfLifeMultiplay *mp = g_pGameRules; + + if (mp->m_iTotalRoundsPlayed > 0) + mp->MarkSpawnSkipped(); + + CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pev); + + if (mp->IsCareer() && mp->ShouldSkipSpawn() && pPlayer->IsAlive()) + g_skipCareerInitialSpawn = true; + + pPlayer->Spawn(); + g_skipCareerInitialSpawn = false; + } + else if (pev->deadflag > DEAD_NO) + { + SERVER_COMMAND("reload\n"); + } +} + +// Suicide... + +/* <48013> ../cstrike/dlls/client.cpp:347 */ +void ClientKill(edict_t *pEntity) +{ + entvars_t *pev = &pEntity->v; + CHalfLifeMultiplay *mp = g_pGameRules; + CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance(pev); + + if (pl->IsObserver()) + return; + + if (pl->m_iJoiningState != JOINED) + return; + + // prevent suiciding too often + if (pl->m_fNextSuicideTime > gpGlobals->time) + return; + + pl->m_LastHitGroup = 0; + + // don't let them suicide for 5 seconds after suiciding + pl->m_fNextSuicideTime = gpGlobals->time + 1; + + // have the player kill themself + pEntity->v.health = 0; + pl->Killed(pev, GIB_NEVER); + + if (mp->m_pVIP == pl) + { + mp->m_iConsecutiveVIP = 10; + } +} + +/* <47a8a> ../cstrike/dlls/client.cpp:379 */ +void ShowMenu(CBasePlayer *pPlayer, int bitsValidSlots, int nDisplayTime, BOOL fNeedMore, char *pszText) +{ + MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pPlayer->pev); + WRITE_SHORT(bitsValidSlots); + WRITE_CHAR(nDisplayTime); + WRITE_BYTE(fNeedMore); + WRITE_STRING(pszText); + MESSAGE_END(); +} + +/* <4735f> ../cstrike/dlls/client.cpp:390 */ +void ShowVGUIMenu(CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu) +{ + if (pPlayer->m_bVGUIMenus || MenuType > VGUI_Menu_Buy_Item) + { + MESSAGE_BEGIN(MSG_ONE, gmsgVGUIMenu, NULL, pPlayer->pev); + WRITE_BYTE(MenuType); + WRITE_SHORT(BitMask); + WRITE_CHAR(-1); + WRITE_BYTE(0); + WRITE_STRING(" "); + MESSAGE_END(); + } + else + ShowMenu(pPlayer, BitMask, -1, 0, szOldMenu); +} + +/* <4c3c5> ../cstrike/dlls/client.cpp:414 */ +NOXREF int CountTeams(void) +{ + int iNumCT = 0, iNumTerrorist = 0; + CBaseEntity *pPlayer = NULL; + + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + { + if (FNullEnt(pPlayer->edict())) + break; + + CBasePlayer *player = GetClassPtr((CBasePlayer *)pPlayer->pev); + + if (player->m_iTeam == UNASSIGNED) + continue; + + if (player->pev->flags & FL_DORMANT) + continue; + + if (player->m_iTeam == SPECTATOR) + continue; + + if (player->m_iTeam == CT) + iNumCT++; + + else if (player->m_iTeam == TERRORIST) + iNumTerrorist++; + } + + return iNumCT - iNumTerrorist; +} + +/* <4c2be> ../cstrike/dlls/client.cpp:443 */ +void ListPlayers(CBasePlayer *current) +{ + char message[120], cNumber[12]; + Q_strcpy(message, ""); + + CBaseEntity *pPlayer = NULL; + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + { + if (FNullEnt(pPlayer->edict())) + break; + + if (pPlayer->pev->flags & FL_DORMANT) + continue; + + CBasePlayer *player = GetClassPtr((CBasePlayer *)pPlayer->pev); + int iUserID = GETPLAYERUSERID(ENT(player->pev)); + + Q_sprintf(cNumber, "%d", iUserID); + Q_strcpy(message, "\n"); + Q_strcat(message, cNumber); + Q_strcat(message, " : "); + Q_strcat(message, STRING(player->pev->netname)); + + ClientPrint(current->pev, HUD_PRINTCONSOLE, message); + } + + ClientPrint(current->pev, HUD_PRINTCONSOLE, "\n"); +} + +/* <4c200> ../cstrike/dlls/client.cpp:475 */ +int CountTeamPlayers(int iTeam) +{ + CBaseEntity *pPlayer = NULL; + int i = 0; + + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + { + if (FNullEnt(pPlayer->edict())) + break; + + if (pPlayer->pev->flags & FL_DORMANT) + continue; + + if (GetClassPtr((CBasePlayer *)pPlayer->pev)->m_iTeam == iTeam) + i++; + } + + return i; +} + +/* <4c4ef> ../cstrike/dlls/client.cpp:494 */ +void ProcessKickVote(CBasePlayer *pVotingPlayer, CBasePlayer *pKickPlayer) +{ + CBaseEntity *pTempEntity; + CBasePlayer *pTempPlayer; + int iValidVotes; + int iVoteID; + int iVotesNeeded; + float fKickPercent; + + if (!pVotingPlayer || !pKickPlayer) + return; + + int iTeamCount = CountTeamPlayers(pVotingPlayer->m_iTeam); + + if (iTeamCount < 3) + return; + + iValidVotes = 0; + pTempEntity = NULL; + iVoteID = pVotingPlayer->m_iCurrentKickVote; + + while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player")) != NULL) + { + if (FNullEnt(pTempEntity->edict())) + break; + + pTempPlayer = GetClassPtr((CBasePlayer *)pTempEntity->pev); + + if (!pTempPlayer || pTempPlayer->m_iTeam == UNASSIGNED) + continue; + + if (pTempPlayer->m_iTeam == pVotingPlayer->m_iTeam && pTempPlayer->m_iCurrentKickVote == iVoteID) + iValidVotes++; + } + + if (kick_percent.value < 0) + CVAR_SET_STRING("mp_kickpercent", "0.0"); + + else if (kick_percent.value > 1) + CVAR_SET_STRING("mp_kickpercent", "1.0"); + + iVotesNeeded = iValidVotes; + fKickPercent = (iTeamCount * kick_percent.value + 0.5); + + if (iVotesNeeded >= (int)fKickPercent) + { + UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Game_kicked", STRING(pKickPlayer->pev->netname)); + SERVER_COMMAND(UTIL_VarArgs("kick # %d\n", iVoteID)); + pTempEntity = NULL; + + while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player")) != NULL) + { + if (FNullEnt(pTempEntity->edict())) + break; + + pTempPlayer = GetClassPtr((CBasePlayer *)pTempEntity->pev); + + if (!pTempPlayer || pTempPlayer->m_iTeam == UNASSIGNED) + continue; + + if (pTempPlayer->m_iTeam == pVotingPlayer->m_iTeam && pTempPlayer->m_iCurrentKickVote == iVoteID) + pTempPlayer->m_iCurrentKickVote = 0; + } + } +} + +/* <48298> ../cstrike/dlls/client.cpp:580 */ +TeamName SelectDefaultTeam(void) +{ + TeamName team = UNASSIGNED; + CHalfLifeMultiplay *mp = g_pGameRules; + + if (mp->m_iNumTerrorist < mp->m_iNumCT) + { + team = TERRORIST; + } + else if (mp->m_iNumTerrorist > mp->m_iNumCT) + { + team = CT; + } + // Choose the team that's losing + else if (mp->m_iNumTerroristWins < mp->m_iNumCTWins) + { + team = TERRORIST; + } + else if (mp->m_iNumCTWins < mp->m_iNumTerroristWins) + { + team = CT; + } + else + { + // Teams and scores are equal, pick a random team + if (RANDOM_LONG(0, 1) == 0) + { + team = CT; + } + else + { + team = TERRORIST; + } + } + + if (mp->TeamFull(team)) + { + // Pick the opposite team + if (team == TERRORIST) + { + team = CT; + } + else + { + team = TERRORIST; + } + + // No choices left + if (mp->TeamFull(team)) + { + return UNASSIGNED; + } + } + + return team; + +} + +/* <473a3> ../cstrike/dlls/client.cpp:638 */ +void CheckStartMoney(void) +{ + int money = (int)startmoney.value; + + if (money > 16000) + CVAR_SET_FLOAT("mp_startmoney", 16000); + else if (money < 800) + CVAR_SET_FLOAT("mp_startmoney", 800); +} + +/* <4c084> ../cstrike/dlls/client.cpp:661 */ +void ClientPutInServer(edict_t *pEntity) +{ + entvars_t *pev = &pEntity->v; + CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pev); + CHalfLifeMultiplay *mp = g_pGameRules; + + pPlayer->SetCustomDecalFrames(-1); + pPlayer->SetPrefsFromUserinfo(GET_INFO_BUFFER(pEntity)); + + if (!mp->IsMultiplayer()) + { + pPlayer->Spawn(); + return; + } + + pPlayer->m_bNotKilled = true; + pPlayer->m_iIgnoreGlobalChat = IGNOREMSG_NONE; + pPlayer->m_iTeamKills = 0; + pPlayer->m_bJustConnected = true; + pPlayer->Spawn(); + pPlayer->m_bTeamChanged = false; + pPlayer->m_iNumSpawns = 0; + + CheckStartMoney(); + + pPlayer->m_iAccount = (int)startmoney.value; + pPlayer->m_fGameHUDInitialized = FALSE; + pPlayer->m_flDisplayHistory &= ~DHF_ROUND_STARTED; + pPlayer->pev->flags |= FL_SPECTATOR; + pPlayer->pev->solid = SOLID_NOT; + pPlayer->pev->movetype = MOVETYPE_NOCLIP; + pPlayer->pev->effects = EF_NODRAW; + pPlayer->pev->effects |= EF_NOINTERP; + pPlayer->pev->takedamage = DAMAGE_NO; + pPlayer->pev->deadflag = DEAD_DEAD; + pPlayer->pev->velocity = g_vecZero; + pPlayer->pev->punchangle = g_vecZero; + pPlayer->m_iJoiningState = READINGLTEXT; + pPlayer->m_iTeam = UNASSIGNED; + pPlayer->pev->fixangle = 1; + pPlayer->m_iModelName = MODEL_URBAN; + pPlayer->m_bContextHelp = true; + pPlayer->m_bHasNightVision = false; + pPlayer->m_iHostagesKilled = 0; + pPlayer->m_iMapVote = 0; + pPlayer->m_iCurrentKickVote = 0; + pPlayer->m_fDeadTime = 0; + pPlayer->has_disconnected = false; + pPlayer->m_iMenu = Menu_OFF; + pPlayer->ClearAutoBuyData(); + pPlayer->m_rebuyString = NULL; + + SET_CLIENT_MAXSPEED(ENT(pPlayer->pev), 1); + SET_MODEL(ENT(pPlayer->pev), "models/player.mdl"); + + pPlayer->SetThink(NULL); + + CBaseEntity *Target = UTIL_FindEntityByClassname(NULL, "trigger_camera"); + pPlayer->m_pIntroCamera = Target; + + if (mp && mp->m_bMapHasCameras == MAP_HAS_CAMERAS_INIT) + { + mp->m_bMapHasCameras = (Target != NULL); + } + + if (pPlayer->m_pIntroCamera) + Target = UTIL_FindEntityByTargetname(NULL, STRING(pPlayer->m_pIntroCamera->pev->target)); + + if (pPlayer->m_pIntroCamera && Target) + { + Vector CamAngles = UTIL_VecToAngles((Target->pev->origin - pPlayer->m_pIntroCamera->pev->origin).Normalize()); + CamAngles.x = -CamAngles.x; + + UTIL_SetOrigin(pPlayer->pev, pPlayer->m_pIntroCamera->pev->origin); + + pPlayer->pev->angles = CamAngles; + pPlayer->pev->v_angle = pPlayer->pev->angles; + + pPlayer->m_fIntroCamTime = gpGlobals->time + 6; + pPlayer->pev->view_ofs = g_vecZero; + } + else + { + pPlayer->m_iTeam = CT; + + if (mp) + { + mp->GetPlayerSpawnSpot(pPlayer); + } + + pPlayer->m_iTeam = UNASSIGNED; + pPlayer->pev->v_angle = g_vecZero; + pPlayer->pev->angles = gpGlobals->v_forward; + } + + TheBots->OnEvent(EVENT_PLAYER_CHANGED_TEAM, (CBaseEntity *)pPlayer); + pPlayer->m_iJoiningState = SHOWLTEXT; + + static char sName[128]; + Q_strcpy(sName, STRING(pPlayer->pev->netname)); + + for (char *pApersand = sName; pApersand && *pApersand != '\0'; pApersand++) + { + if (*pApersand == '%') + *pApersand = ' '; + } + + UTIL_ClientPrintAll(HUD_PRINTNOTIFY, "#Game_connected", (sName[0] != '\0') ? sName : ""); +} + +/* <478f7> ../cstrike/dlls/client.cpp:792 */ +int Q_strlen_(const char *str) +{ + int count = 0; + if (str && *str) + { + while (str[count++ + 1]); + } + return count; +} + +/* <4bbff> ../cstrike/dlls/client.cpp:814 */ +void Host_Say(edict_t *pEntity, int teamonly) +{ + CBasePlayer *client; + int j; + char *p; + char text[128]; + char szTemp[256]; + const char *cpSay = "say"; + const char *cpSayTeam = "say_team"; + const char *pcmd = CMD_ARGV_(0); + bool bSenderDead = false; + + entvars_t *pev = &pEntity->v; + CBasePlayer *player = GetClassPtr((CBasePlayer *)pev); + + if (player->m_flLastTalk != 0.0f && gpGlobals->time - player->m_flLastTalk < 0.66f) + return; + + player->m_flLastTalk = gpGlobals->time; + + if (player->pev->deadflag != DEAD_NO) + bSenderDead = true; + + // We can get a raw string now, without the "say " prepended + if (CMD_ARGC_() == 0) + return; + + if (!Q_stricmp(pcmd, cpSay) || !Q_stricmp(pcmd, cpSayTeam)) + { + if (CMD_ARGC_() >= 2) + { + p = (char *)CMD_ARGS(); + } + else + { + // say with a blank message, nothing to do + return; + } + } + else // Raw text, need to prepend argv[0] + { + if (CMD_ARGC_() >= 2) + { + Q_sprintf(szTemp, "%s %s", (char *)pcmd, (char *)CMD_ARGS()); + } + else + { + // Just a one word command, use the first word...sigh + Q_sprintf(szTemp, "%s", (char *)pcmd); + } + + p = szTemp; + } + + // remove quotes if present + if (*p == '"') + { + p++; + p[Q_strlen(p) - 1] = '\0'; + } + + // make sure the text has content + if (!p || !p[0] || !Q_UnicodeValidate(p)) + { + // no character found, so say nothing + return; + } + + Q_StripUnprintableAndSpace(p); + + if (Q_strlen(p) <= 0) + return; + + const char *placeName = NULL; + char *pszFormat = NULL; + char *pszConsoleFormat = NULL; + bool consoleUsesPlaceName = false; + + if (teamonly) + { + if (player->m_iTeam == CT || player->m_iTeam == TERRORIST) + { + // search the place name where is located the player + Place playerPlace = TheNavAreaGrid.GetPlace(&player->pev->origin); + const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); + + for (BotPhraseList::const_iterator iter = placeList->begin(); iter != placeList->end(); ++iter) + { + if ((*iter)->GetID() == playerPlace) + { + placeName = (*iter)->GetName(); + break; + } + } + } + + if (player->m_iTeam == CT) + { + if (bSenderDead) + { + pszFormat = "#Cstrike_Chat_CT_Dead"; + pszConsoleFormat = "*DEAD*(Counter-Terrorist) %s : %s"; + } + else if (placeName != NULL) + { + pszFormat = "#Cstrike_Chat_CT_Loc"; + pszConsoleFormat = "*(Counter-Terrorist) %s @ %s : %s"; + consoleUsesPlaceName = true; + } + else + { + pszFormat = "#Cstrike_Chat_CT"; + pszConsoleFormat = "(Counter-Terrorist) %s : %s"; + } + } + else if (player->m_iTeam == TERRORIST) + { + if (bSenderDead) + { + pszFormat = "#Cstrike_Chat_T_Dead"; + pszConsoleFormat = "*DEAD*(Terrorist) %s : %s"; + } + else if (placeName != NULL) + { + pszFormat = "#Cstrike_Chat_T_Loc"; + pszConsoleFormat = "(Terrorist) %s @ %s : %s"; + consoleUsesPlaceName = true; + } + else + { + pszFormat = "#Cstrike_Chat_T"; + pszConsoleFormat = "(Terrorist) %s : %s"; + } + } + else + { + pszFormat = "#Cstrike_Chat_Spec"; + pszConsoleFormat = "(Spectator) %s : %s"; + } + } + else + { + if (bSenderDead) + { + if (player->m_iTeam == SPECTATOR) + { + pszFormat = "#Cstrike_Chat_AllSpec"; + pszConsoleFormat = "*SPEC* %s : %s"; + } + else + { + pszFormat = "#Cstrike_Chat_AllDead"; + pszConsoleFormat = "*DEAD* %s : %s"; + } + } + else + { + pszFormat = "#Cstrike_Chat_All"; + pszConsoleFormat = "%s : %s"; + } + } + + text[0] = '\0'; + + // -3 for /n and null terminator + j = sizeof(text) - 3 - Q_strlen(text) - Q_strlen(pszFormat); + + if (placeName != NULL) + { + j -= Q_strlen(placeName) + 1; + } + + if ((signed int)Q_strlen(p) > j) + p[j] = 0; + + for (char *pAmpersand = p; pAmpersand != NULL && *pAmpersand != '\0'; pAmpersand++) + { + if (pAmpersand[0] == '%') + { + if (pAmpersand[1] != 'l' && pAmpersand[1] != ' ' && pAmpersand[1] != '\0') + { + pAmpersand[0] = ' '; + } + } + } + + Q_strcat(text, p); + Q_strcat(text, "\n"); + + // loop through all players + // Start with the first player. + // This may return the world in single player if the client types something between levels or during spawn + // so check it, or it will infinite loop + + client = NULL; + while ((client = (CBasePlayer *)UTIL_FindEntityByClassname(client, "player")) != NULL) + { + if (FNullEnt(client->edict())) + break; + + if (!client->pev) + continue; + + if (client->edict() == pEntity) + continue; + + // Not a client ? (should never be true) + if (!client->IsNetClient()) + continue; + + // can the receiver hear the sender? or has he muted him? + if (gpGlobals->deathmatch != 0.0f && g_pGameRules->m_VoiceGameMgr.PlayerHasBlockedPlayer(client, player)) + continue; + + if (teamonly && client->m_iTeam != player->m_iTeam) + continue; + + if ((client->pev->deadflag != DEAD_NO && !bSenderDead) || (client->pev->deadflag == DEAD_NO && bSenderDead)) + { + if (!(player->pev->flags & FL_PROXY)) + continue; + } + + if ((client->m_iIgnoreGlobalChat == IGNOREMSG_ENEMY && client->m_iTeam == player->m_iTeam) + || client->m_iIgnoreGlobalChat == IGNOREMSG_NONE) + { + MESSAGE_BEGIN(MSG_ONE, gmsgSayText, NULL, client->pev); + WRITE_BYTE(ENTINDEX(pEntity)); + WRITE_STRING(pszFormat); + WRITE_STRING(""); + WRITE_STRING(text); + + if (placeName != NULL) + { + WRITE_STRING(placeName); + } + + MESSAGE_END(); + } + } + + char *fullText = p; + + // print to the sending client + MESSAGE_BEGIN(MSG_ONE, gmsgSayText, NULL, &pEntity->v); + WRITE_BYTE(ENTINDEX(pEntity)); + WRITE_STRING(pszFormat); + WRITE_STRING(""); + WRITE_STRING(text); + + if (placeName != NULL) + { + WRITE_STRING(placeName); + } + + MESSAGE_END(); + + // echo to server console + if (pszConsoleFormat) + { + if (placeName && consoleUsesPlaceName) + SERVER_PRINT(UTIL_VarArgs(pszConsoleFormat, STRING(player->pev->netname), placeName, text)); + else + SERVER_PRINT(UTIL_VarArgs(pszConsoleFormat, STRING(player->pev->netname), text)); + } + else + SERVER_PRINT(text); + + if (CVAR_GET_FLOAT("mp_logmessages") != 0) + { + const char *temp = teamonly ? "say_team" : "say"; + const char *deadText = (player->m_iTeam != SPECTATOR && bSenderDead) ? " (dead)" : ""; + + char *szTeam = GetTeam(player->m_iTeam); + + UTIL_LogPrintf + ( + "\"%s<%i><%s><%s>\" %s \"%s\"%s\n", + STRING(player->pev->netname), + GETPLAYERUSERID(player->edict()), + GETPLAYERAUTHID(player->edict()), + szTeam, + temp, + fullText, + deadText + ); + } +} + +/* <4865e> ../cstrike/dlls/client.cpp:1160 */ +void DropSecondary(CBasePlayer *pPlayer) +{ + if (pPlayer->HasShield()) + { + if (pPlayer->HasShield() && pPlayer->m_bShieldDrawn && pPlayer->m_pActiveItem != NULL) + { + ((CBasePlayerWeapon *)pPlayer->m_pActiveItem)->SecondaryAttack(); + } + + pPlayer->m_bShieldDrawn = false; + } + + CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]; + + if (pWeapon != NULL) + { + pPlayer->DropPlayerItem(STRING(pWeapon->pev->classname)); + } + +} + +/* <473db> ../cstrike/dlls/client.cpp:1182 */ +void DropPrimary(CBasePlayer *pPlayer) +{ + if (pPlayer->HasShield()) + { + pPlayer->DropShield(); + return; + } + + if (pPlayer->m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]) + { + pPlayer->DropPlayerItem(STRING(pPlayer->m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]->pev->classname)); + } +} + +/* <483a2> ../cstrike/dlls/client.cpp:1197 */ +bool CanBuyThis(CBasePlayer *pPlayer, int iWeapon) +{ + CHalfLifeMultiplay *mp = g_pGameRules; + + if (pPlayer->HasShield() && iWeapon == WEAPON_ELITE) + { + return false; + } + + if (pPlayer->HasShield() && iWeapon == WEAPON_SHIELDGUN) + { + return false; + } + + if (pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ] != NULL && pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]->m_iId == WEAPON_ELITE && iWeapon == WEAPON_SHIELDGUN) + { + return false; + } + + if (pPlayer->m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ] != NULL && pPlayer->m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]->m_iId == iWeapon) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Cstrike_Already_Own_Weapon"); + } + + return false; + } + + if (pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ] != NULL && pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]->m_iId == iWeapon) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Cstrike_Already_Own_Weapon"); + } + + return false; + } + + if (!CanBuyWeaponByMaptype(pPlayer->m_iTeam, (WeaponIdType)iWeapon, (mp->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES))) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Cannot_Buy_This"); + } + + return false; + } + + return true; +} + +/* <48696> ../cstrike/dlls/client.cpp:1247 */ +void BuyPistol(CBasePlayer *pPlayer, int iSlot) +{ + int iWeapon = 0; + int iWeaponPrice = 0; + const char *pszWeapon = NULL; + + if (!pPlayer->CanPlayerBuy(true)) + { + return; + } + + if (iSlot < 1 || iSlot > 5) + { + return; + } + + switch (iSlot) + { + case 1: + { + iWeapon = WEAPON_GLOCK18; + iWeaponPrice = GLOCK18_PRICE; + pszWeapon = "weapon_glock18"; + break; + } + case 2: + { + iWeapon = WEAPON_USP; + iWeaponPrice = USP_PRICE; + pszWeapon = "weapon_usp"; + break; + } + case 3: + { + iWeapon = WEAPON_P228; + iWeaponPrice = P228_PRICE; + pszWeapon = "weapon_p228"; + break; + } + case 4: + { + iWeapon = WEAPON_DEAGLE; + iWeaponPrice = DEAGLE_PRICE; + pszWeapon = "weapon_deagle"; + break; + } + case 5: + { + if (pPlayer->m_iTeam == CT) + { + iWeapon = WEAPON_FIVESEVEN; + iWeaponPrice = FIVESEVEN_PRICE; + pszWeapon = "weapon_fiveseven"; + } + else + { + iWeapon = WEAPON_ELITE; + iWeaponPrice = ELITE_PRICE; + pszWeapon = "weapon_elite"; + } + + break; + } + } + + if (!CanBuyThis(pPlayer, iWeapon)) + { + return; + } + + if (pPlayer->m_iAccount < iWeaponPrice) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); + BlinkAccount(pPlayer, 2); + } + + return; + } + + DropSecondary(pPlayer); + + pPlayer->GiveNamedItem(pszWeapon); + pPlayer->AddAccount(-iWeaponPrice); + + if (TheTutor) + { + TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); + } +} + +/* <487b0> ../cstrike/dlls/client.cpp:1325 */ +void BuyShotgun(CBasePlayer *pPlayer, int iSlot) +{ + int iWeapon = 0; + int iWeaponPrice = 0; + const char *pszWeapon = NULL; + + if (!pPlayer->CanPlayerBuy(true)) + { + return; + } + + if (iSlot < 1 || iSlot > 2) + { + return; + } + + switch (iSlot) + { + case 1: + { + iWeapon = WEAPON_M3; + iWeaponPrice = M3_PRICE; + pszWeapon = "weapon_m3"; + break; + } + case 2: + { + iWeapon = WEAPON_XM1014; + iWeaponPrice = XM1014_PRICE; + pszWeapon = "weapon_xm1014"; + break; + } + } + + if (!CanBuyThis(pPlayer, iWeapon)) + { + return; + } + + if (pPlayer->m_iAccount < iWeaponPrice) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); + BlinkAccount(pPlayer, 2); + } + + return; + } + + DropPrimary(pPlayer); + + pPlayer->GiveNamedItem(pszWeapon); + pPlayer->AddAccount(-iWeaponPrice); + + if (TheTutor) + { + TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); + } +} + +/* <488b5> ../cstrike/dlls/client.cpp:1378 */ +void BuySubMachineGun(CBasePlayer *pPlayer, int iSlot) +{ + int iWeapon = 0; + int iWeaponPrice = 0; + const char *pszWeapon = NULL; + + if (!pPlayer->CanPlayerBuy(true)) + { + return; + } + + if (iSlot < 1 || iSlot > 4) + { + return; + } + + switch (iSlot) + { + case 1: + { + if (pPlayer->m_iTeam == CT) + { + iWeapon = WEAPON_TMP; + iWeaponPrice = TMP_PRICE; + pszWeapon = "weapon_tmp"; + } + else + { + iWeapon = WEAPON_MAC10; + iWeaponPrice = MAC10_PRICE; + pszWeapon = "weapon_mac10"; + } + + break; + } + case 2: + { + iWeapon = WEAPON_MP5N; + iWeaponPrice = MP5NAVY_PRICE; + pszWeapon = "weapon_mp5navy"; + break; + } + case 3: + { + iWeapon = WEAPON_UMP45; + iWeaponPrice = UMP45_PRICE; + pszWeapon = "weapon_ump45"; + break; + } + case 4: + { + iWeapon = WEAPON_P90; + iWeaponPrice = P90_PRICE; + pszWeapon = "weapon_p90"; + break; + } + } + + if (!CanBuyThis(pPlayer, iWeapon)) + { + return; + } + + if (pPlayer->m_iAccount < iWeaponPrice) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); + BlinkAccount(pPlayer, 2); + } + + return; + } + + DropPrimary(pPlayer); + + pPlayer->GiveNamedItem(pszWeapon); + pPlayer->AddAccount(-iWeaponPrice); + + if (TheTutor) + { + TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); + } +} + +/* <489bb> ../cstrike/dlls/client.cpp:1450 */ +void BuyWeaponByWeaponID(CBasePlayer *pPlayer, WeaponIdType weaponID) +{ + if (!pPlayer->CanPlayerBuy(true)) + { + return; + } + + if (!CanBuyThis(pPlayer, weaponID)) + { + return; + } + + WeaponInfoStruct *info = GetWeaponInfo(weaponID); + + if (!info || !info->entityName) + { + return; + } + + if (pPlayer->m_iAccount < info->cost) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); + BlinkAccount(pPlayer, 2); + } + + return; + } + + if (IsPrimaryWeapon(weaponID)) + { + DropPrimary(pPlayer); + } + else + { + DropSecondary(pPlayer); + } + + pPlayer->GiveNamedItem(info->entityName); + pPlayer->AddAccount(-info->cost); + + if (TheTutor) + { + TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); + } +} + +/* <48adf> ../cstrike/dlls/client.cpp:1498 */ +void BuyRifle(CBasePlayer *pPlayer, int iSlot) +{ + int iWeapon = 0; + int iWeaponPrice = 0; + bool bIsCT = false; + const char *pszWeapon = NULL; + + if (!pPlayer->CanPlayerBuy(true)) + { + return; + } + + if (iSlot < 1 || iSlot > 6) + { + return; + } + + if (pPlayer->m_iTeam == CT) + bIsCT = true; + + switch (iSlot) + { + case 2: + { + if (bIsCT) + { + iWeapon = WEAPON_SCOUT; + iWeaponPrice = SCOUT_PRICE; + pszWeapon = "weapon_scout"; + } + else + { + iWeapon = WEAPON_AK47; + iWeaponPrice = AK47_PRICE; + pszWeapon = "weapon_ak47"; + } + + break; + } + case 3: + { + if (bIsCT) + { + iWeapon = WEAPON_M4A1; + iWeaponPrice = M4A1_PRICE; + pszWeapon = "weapon_m4a1"; + } + else + { + iWeapon = WEAPON_SCOUT; + iWeaponPrice = SCOUT_PRICE; + pszWeapon = "weapon_scout"; + } + + break; + } + case 4: + { + if (bIsCT) + { + iWeapon = WEAPON_AUG; + iWeaponPrice = AUG_PRICE; + pszWeapon = "weapon_aug"; + } + else + { + iWeapon = WEAPON_SG552; + iWeaponPrice = SG552_PRICE; + pszWeapon = "weapon_sg552"; + } + + break; + } + case 5: + { + if (bIsCT) + { + iWeapon = WEAPON_SG550; + iWeaponPrice = SG550_PRICE; + pszWeapon = "weapon_sg550"; + } + else + { + iWeapon = WEAPON_AWP; + iWeaponPrice = AWP_PRICE; + pszWeapon = "weapon_awp"; + } + + break; + } + case 6: + { + if (bIsCT) + { + iWeapon = WEAPON_AWP; + iWeaponPrice = AWP_PRICE; + pszWeapon = "weapon_awp"; + } + else + { + iWeapon = WEAPON_G3SG1; + iWeaponPrice = G3SG1_PRICE; + pszWeapon = "weapon_g3sg1"; + } + + break; + } + default: + { + if (bIsCT) + { + iWeapon = WEAPON_FAMAS; + iWeaponPrice = FAMAS_PRICE; + pszWeapon = "weapon_famas"; + } + else + { + iWeapon = WEAPON_GALIL; + iWeaponPrice = GALIL_PRICE; + pszWeapon = "weapon_galil"; + } + + break; + } + } + + if (!CanBuyThis(pPlayer, iWeapon)) + { + return; + } + + if (pPlayer->m_iAccount < iWeaponPrice) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); + BlinkAccount(pPlayer, 2); + } + + return; + } + + DropPrimary(pPlayer); + + pPlayer->GiveNamedItem(pszWeapon); + pPlayer->AddAccount(-iWeaponPrice); + + if (TheTutor) + { + TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); + } +} + +/* <48bf5> ../cstrike/dlls/client.cpp:1629 */ +void BuyMachineGun(CBasePlayer *pPlayer, int iSlot) +{ + int iWeapon = WEAPON_M249; + int iWeaponPrice = M249_PRICE; + const char *pszWeapon = "weapon_m249"; + + if (!pPlayer->CanPlayerBuy(true)) + { + return; + } + + if (iSlot != 1) + { + return; + } + + if (!CanBuyThis(pPlayer, iWeapon)) + { + return; + } + + if (pPlayer->m_iAccount < iWeaponPrice) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); + BlinkAccount(pPlayer, 2); + } + + return; + } + + DropPrimary(pPlayer); + + pPlayer->GiveNamedItem(pszWeapon); + pPlayer->AddAccount(-iWeaponPrice); + + if (TheTutor) + { + TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); + } +} + +/* <473f8> ../cstrike/dlls/client.cpp:1677 */ +void BuyItem(CBasePlayer *pPlayer, int iSlot) +{ + //int iItem = 0; + int iItemPrice = 0; + const char *pszItem = NULL; + + if (!pPlayer->CanPlayerBuy(true)) + return; + + if (pPlayer->m_iTeam == CT) + { + if (iSlot < 1 || iSlot > 8) + return; + } + else + { + if (iSlot < 1 || iSlot > 6) + return; + } + + int fullArmor = (pPlayer->pev->armorvalue >= 100); + int helmet = (pPlayer->m_iKevlar == ARMOR_TYPE_HELMET); + //int price; + int enoughMoney = 1; + + switch (iSlot) + { + case MENU_SLOT_ITEM_VEST: + { + if (fullArmor) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Kevlar"); + } + + return; + } + + if (pPlayer->m_iAccount >= KEVLAR_PRICE) + { + if (helmet) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Helmet_Bought_Kevlar"); + } + } + + pszItem = "item_kevlar"; + iItemPrice = KEVLAR_PRICE; + } + else + enoughMoney = 0; + + break; + } + case MENU_SLOT_ITEM_VESTHELM: + { + if (fullArmor) + { + if (helmet) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Kevlar_Helmet"); + } + + return; + } + + if (pPlayer->m_iAccount >= HELMET_PRICE) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Kevlar_Bought_Helmet"); + } + + pszItem = "item_assaultsuit"; + iItemPrice = HELMET_PRICE; + } + else + enoughMoney = 0; + + break; + } + else + { + if (helmet) + { + if (pPlayer->m_iAccount >= KEVLAR_PRICE) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_Helmet_Bought_Kevlar"); + } + + pszItem = "item_assaultsuit"; + iItemPrice = KEVLAR_PRICE; + } + else + enoughMoney = 0; + } + else + { + if (pPlayer->m_iAccount >= ASSAULTSUIT_PRICE) + { + pszItem = "item_assaultsuit"; + iItemPrice = ASSAULTSUIT_PRICE; + } + else + enoughMoney = 0; + } + } + + break; + } + case MENU_SLOT_ITEM_FLASHGREN: + { + if (pPlayer->AmmoInventory(pPlayer->GetAmmoIndex("Flashbang")) >= 2) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Cannot_Carry_Anymore"); + } + + return; + } + + if (pPlayer->m_iAccount >= FLASHBANG_PRICE) + { + pszItem = "weapon_flashbang"; + iItemPrice = FLASHBANG_PRICE; + + } + else + enoughMoney = 0; + + break; + } + case MENU_SLOT_ITEM_HEGREN: + { + if (pPlayer->AmmoInventory(pPlayer->GetAmmoIndex("HEGrenade")) >= 1) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Cannot_Carry_Anymore"); + } + + return; + } + + if (pPlayer->m_iAccount >= HEGRENADE_PRICE) + { + pszItem = "weapon_hegrenade"; + iItemPrice = HEGRENADE_PRICE; + } + else + enoughMoney = 0; + + break; + } + case MENU_SLOT_ITEM_SMOKEGREN: + { + if (pPlayer->AmmoInventory(pPlayer->GetAmmoIndex("SmokeGrenade")) >= 1) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Cannot_Carry_Anymore"); + } + + return; + } + + if (pPlayer->m_iAccount >= SMOKEGRENADE_PRICE) + { + pszItem = "weapon_smokegrenade"; + iItemPrice = SMOKEGRENADE_PRICE; + } + else + enoughMoney = 0; + + break; + } + case MENU_SLOT_ITEM_NVG: + { + if (pPlayer->m_bHasNightVision) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_One"); + } + + return; + } + + if (pPlayer->m_iAccount >= NVG_PRICE) + { + if (!(pPlayer->m_flDisplayHistory & DHF_NIGHTVISION)) + { + pPlayer->HintMessage("#Hint_use_nightvision"); + pPlayer->m_flDisplayHistory |= DHF_NIGHTVISION; + } + + EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/equip_nvg.wav", VOL_NORM, ATTN_NORM); + + pPlayer->m_bHasNightVision = true; + pPlayer->AddAccount(-NVG_PRICE); + + SendItemStatus(pPlayer); + } + else + enoughMoney = 0; + + break; + } + case MENU_SLOT_ITEM_DEFUSEKIT: + { + if (pPlayer->m_iTeam != CT || !g_pGameRules->m_bMapHasBombTarget) + { + return; + } + + if (pPlayer->m_bHasDefuser) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Already_Have_One"); + } + + return; + } + + if (pPlayer->m_iAccount >= DEFUSEKIT_PRICE) + { + pPlayer->m_bHasDefuser = true; + + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pPlayer->pev); + WRITE_BYTE(STATUSICON_SHOW); + WRITE_STRING("defuser"); + WRITE_BYTE(0); + WRITE_BYTE(160); + WRITE_BYTE(0); + MESSAGE_END(); + + pPlayer->pev->body = 1; + pPlayer->AddAccount(-DEFUSEKIT_PRICE); + + EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/kevlar.wav", VOL_NORM, ATTN_NORM); + SendItemStatus(pPlayer); + } + else + enoughMoney = 0; + + break; + } + case MENU_SLOT_ITEM_SHIELD: + { + if (!CanBuyThis(pPlayer, WEAPON_SHIELDGUN)) + { + return; + } + + if (pPlayer->m_iAccount >= SHIELDGUN_PRICE) + { + DropPrimary(pPlayer); + + pPlayer->GiveShield(true); + pPlayer->AddAccount(-SHIELDGUN_PRICE); + + EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM); + } + else + enoughMoney = 0; + + break; + } + } + + if (!enoughMoney) + { + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); + BlinkAccount(pPlayer, 2); + } + + return; + } + + if (pszItem != NULL) + { + pPlayer->GiveNamedItem(pszItem); + pPlayer->AddAccount(-iItemPrice); + } + + if (TheTutor) + { + TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); + } +} + +/* <48d40> ../cstrike/dlls/client.cpp:1998 */ +void HandleMenu_ChooseAppearance(CBasePlayer *player, int slot) +{ + CHalfLifeMultiplay *mp = g_pGameRules; + int numSkins = UTIL_IsGame("czero") ? CZ_NUM_SKIN : CS_NUM_SKIN; + + struct + { + ModelName model_id; + char *model_name; + int model_name_index; + + } appearance; + + Q_memset(&appearance, 0, sizeof(appearance)); + + if (player->m_iTeam == TERRORIST) + { + if ((slot > numSkins || slot < 1) && (!TheBotProfiles->GetCustomSkin(slot) || !player->IsBot())) + { + slot = RANDOM_LONG(1, numSkins); + } + + switch (slot) + { + case 1: + appearance.model_id = MODEL_TERROR; + appearance.model_name = "terror"; + break; + case 2: + appearance.model_id = MODEL_LEET; + appearance.model_name = "leet"; + break; + case 3: + appearance.model_id = MODEL_ARCTIC; + appearance.model_name = "arctic"; + break; + case 4: + appearance.model_id = MODEL_GUERILLA; + appearance.model_name = "guerilla"; + break; + case 5: + if (UTIL_IsGame("czero")) + { + appearance.model_id = MODEL_MILITIA; + appearance.model_name = "militia"; + break; + } + default: + if (TheBotProfiles->GetCustomSkinModelname(slot) && player->IsBot()) + { + appearance.model_name = (char *)TheBotProfiles->GetCustomSkinModelname(slot); + } + else + { + appearance.model_id = MODEL_TERROR; + appearance.model_name = "terror"; + } + break; + } + + // default T model models/player/terror/terror.mdl + appearance.model_name_index = 8; + + } + else if (player->m_iTeam == CT) + { + if ((slot > numSkins || slot < 1) && (!TheBotProfiles->GetCustomSkin(slot) || !player->IsBot())) + { + slot = RANDOM_LONG(1, numSkins); + } + + switch (slot) + { + case 1: + appearance.model_id = MODEL_URBAN; + appearance.model_name = "urban"; + break; + case 2: + appearance.model_id = MODEL_GSG9; + appearance.model_name = "gsg9"; + break; + case 3: + appearance.model_id = MODEL_SAS; + appearance.model_name = "sas"; + break; + case 4: + appearance.model_id = MODEL_GIGN; + appearance.model_name = "gign"; + break; + case 5: + if (UTIL_IsGame("czero")) + { + appearance.model_id = MODEL_SPETSNAZ; + appearance.model_name = "spetsnaz"; + break; + } + default: + if (TheBotProfiles->GetCustomSkinModelname(slot) && player->IsBot()) + { + appearance.model_name = (char *)TheBotProfiles->GetCustomSkinModelname(slot); + } + else + { + appearance.model_id = MODEL_URBAN; + appearance.model_name = "urban"; + } + break; + } + + // default CT model models/player/urban/urban.mdl + appearance.model_name_index = 9; + } + + player->m_iMenu = Menu_OFF; + + // Reset the player's state + if (player->m_iJoiningState == JOINED) + { + mp->CheckWinConditions(); + } + else if (player->m_iJoiningState == PICKINGTEAM) + { + player->m_iJoiningState = GETINTOGAME; + + if (mp->IsCareer()) + { + if (!player->IsBot()) + { + mp->CheckWinConditions(); + } + } + } + + player->pev->body = 0; + player->m_iModelName = appearance.model_id; + + SET_CLIENT_KEY_VALUE(player->entindex(), GET_INFO_BUFFER(player->edict()), "model", appearance.model_name); + player->SetNewPlayerModel(sPlayerModelFiles[ appearance.model_name_index ]); + + if (mp->m_iMapHasVIPSafetyZone == MAP_VIP_SAFETYZONE_UNINITIALIZED) + { + if ((UTIL_FindEntityByClassname(NULL, "func_vip_safetyzone")) != NULL) + mp->m_iMapHasVIPSafetyZone = MAP_HAVE_VIP_SAFETYZONE_YES; + else + mp->m_iMapHasVIPSafetyZone = MAP_HAVE_VIP_SAFETYZONE_NO; + } + + if (mp->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) + { + if (!mp->m_pVIP && player->m_iTeam == CT) + { + player->MakeVIP(); + } + } +} + +// returns true if the selection has been handled and the player's menu +// can be closed...false if the menu should be displayed again + +/* <48e4b> ../cstrike/dlls/client.cpp:2214 */ +BOOL HandleMenu_ChooseTeam(CBasePlayer *player, int slot) +{ + CHalfLifeMultiplay *mp = g_pGameRules; + + int oldTeam; + char *szOldTeam; + char *szNewTeam; + + // If this player is a VIP, don't allow him to switch teams/appearances unless the following conditions are met : + // a) There is another TEAM_CT player who is in the queue to be a VIP + // b) This player is dead + + if (player->m_bIsVIP) + { + if (player->pev->deadflag == DEAD_NO) + { + ClientPrint(player->pev, HUD_PRINTCENTER, "#Cannot_Switch_From_VIP"); + CLIENT_COMMAND(ENT(player->pev), "slot10\n"); + + return TRUE; + } + else if (g_pGameRules->IsVIPQueueEmpty()) + { + ClientPrint(player->pev, HUD_PRINTCENTER, "#Cannot_Switch_From_VIP"); + CLIENT_COMMAND(ENT(player->pev), "slot10\n"); + + return TRUE; + } + } + + TeamName team = UNASSIGNED; + + switch (slot) + { + case MENU_SLOT_TEAM_TERRORIST: + team = TERRORIST; + break; + case MENU_SLOT_TEAM_CT: + team = CT; + break; + case MENU_SLOT_TEAM_VIP: + { + if (mp->m_iMapHasVIPSafetyZone != MAP_HAVE_VIP_SAFETYZONE_YES || player->m_iTeam != CT) + { + return FALSE; + } + + mp->AddToVIPQueue(player); + CLIENT_COMMAND(ENT(player->pev), "slot10\n"); + return TRUE; + } + case MENU_SLOT_TEAM_RANDOM: + { + // Attempt to auto-select a team + team = SelectDefaultTeam(); + + if (team == UNASSIGNED) + { + if (cv_bot_auto_vacate.value > 0.0f && !player->IsBot()) + { + team = (RANDOM_LONG(0, 1) == 0) ? TERRORIST : CT; + + if (!UTIL_KickBotFromTeam(team)) + { + // no bots on that team, try the other + team = (team == CT) ? TERRORIST : CT; + + if (!UTIL_KickBotFromTeam(team)) + { + // couldn't kick any bots, fail + team = UNASSIGNED; + } + } + } + } + + break; + } + case MENU_SLOT_TEAM_SPECT: + { + // Prevent this is the cvar is set + // spectator proxy + if (!allow_spectators.value && !(player->pev->flags & FL_PROXY)) + { + ClientPrint(player->pev, HUD_PRINTCENTER, "#Cannot_Be_Spectator"); + CLIENT_COMMAND(ENT(player->pev), "slot10\n"); + + return FALSE; + } + + // are we already a spectator? + if (player->m_iTeam == SPECTATOR) + { + return TRUE; + } + + // Only spectate if we are in the freeze period or dead. + // This is done here just in case. + if (mp->IsFreezePeriod() || player->pev->deadflag != DEAD_NO) + { + if (player->m_iTeam != UNASSIGNED && player->pev->deadflag == DEAD_NO) + { + ClientKill(player->edict()); + + // add 1 to frags to balance out the 1 subtracted for killing yourself + player->pev->frags++; + } + + player->RemoveAllItems(TRUE); + player->m_bHasC4 = false; + + if (player->m_iTeam != SPECTATOR) + { + // notify other clients of player joined to team spectator + UTIL_LogPrintf + ( + "\"%s<%i><%s><%s>\" joined team \"SPECTATOR\"\n", + STRING(player->pev->netname), + GETPLAYERUSERID(player->edict()), + GETPLAYERAUTHID(player->edict()), + GetTeam(player->m_iTeam) + ); + } + + player->m_iTeam = SPECTATOR; + player->m_iJoiningState = JOINED; + + // Reset money + player->m_iAccount = 0; + + MESSAGE_BEGIN(MSG_ONE, gmsgMoney, NULL, player->pev); + WRITE_LONG(player->m_iAccount); + WRITE_BYTE(0); + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_BROADCAST, gmsgScoreInfo); + WRITE_BYTE(ENTINDEX(player->edict())); + WRITE_SHORT((int)player->pev->frags); + WRITE_SHORT(player->m_iDeaths); + WRITE_SHORT(0); + WRITE_SHORT(0); + MESSAGE_END(); + + player->m_pIntroCamera = NULL; + player->m_bTeamChanged = true; + + TheBots->OnEvent(EVENT_PLAYER_CHANGED_TEAM, player); + + TeamChangeUpdate(player, player->m_iTeam); + + edict_t *pentSpawnSpot = mp->GetPlayerSpawnSpot(player); + player->StartObserver(VARS(pentSpawnSpot)->origin, VARS(pentSpawnSpot)->angles); + + MESSAGE_BEGIN(MSG_ALL, gmsgSpectator); + WRITE_BYTE(ENTINDEX(player->edict())); + WRITE_BYTE(1); + MESSAGE_END(); + + // do we have fadetoblack on? (need to fade their screen back in) + if (fadetoblack.value) + { + UTIL_ScreenFade(player, Vector(0, 0, 0), 0.001, 0, 0, FFADE_IN); + } + + return TRUE; + } + else + { + ClientPrint(player->pev, HUD_PRINTCENTER, "#Cannot_Be_Spectator"); + CLIENT_COMMAND(ENT(player->pev), "slot10\n"); + + return FALSE; + } + + break; + } + default: + return FALSE; + } + + // If the code gets this far, the team is not TEAM_UNASSIGNED + // Player is switching to a new team (It is possible to switch to the + // same team just to choose a new appearance) + + if (mp->TeamFull(team)) + { + // The specified team is full + // attempt to kick a bot to make room for this player + + bool madeRoom = false; + if (cv_bot_auto_vacate.value > 0 && !player->IsBot()) + { + if (UTIL_KickBotFromTeam(team)) + madeRoom = true; + } + + if (!madeRoom) + { + ClientPrint(player->pev, HUD_PRINTCENTER, (team == TERRORIST) ? "#Terrorists_Full" : "#CTs_Full"); + return FALSE; + } + } + + // players are allowed to change to their own team so they can just change their model + if (mp->TeamStacked(team, player->m_iTeam)) + { + // The specified team is full + ClientPrint(player->pev, HUD_PRINTCENTER, (team == TERRORIST) ? "#Too_Many_Terrorists" : "#Too_Many_CTs"); + return FALSE; + } + + if (team != SPECTATOR && !player->IsBot()) + { + int humanTeam = UNASSIGNED; + + if (!Q_stricmp(humans_join_team.string, "CT")) + { + humanTeam = CT; + } + else if (!Q_stricmp(humans_join_team.string, "T")) + { + humanTeam = TERRORIST; + } + + if (humanTeam != UNASSIGNED && team != humanTeam) + { + ClientPrint(player->pev, HUD_PRINTCENTER, (team == TERRORIST) ? "#Humans_Join_Team_CT" : "#Humans_Join_Team_T"); + return FALSE; + } + } + + if (player->m_bTeamChanged) + { + if (player->pev->deadflag != DEAD_NO) + { + ClientPrint(player->pev, HUD_PRINTCENTER, "#Only_1_Team_Change"); + return FALSE; + } + } + + if (player->m_iTeam == SPECTATOR && team != SPECTATOR) + { + // If they're switching into spectator, setup spectator properties.. + player->m_bNotKilled = true; + player->m_iIgnoreGlobalChat = IGNOREMSG_NONE; + player->m_iTeamKills = 0; + + CheckStartMoney(); + + // all players start with "mp_startmoney" bucks + player->m_iAccount = (int)startmoney.value; + + player->pev->solid = SOLID_NOT; + player->pev->movetype = MOVETYPE_NOCLIP; + player->pev->effects = EF_NODRAW; + player->pev->effects |= EF_NOINTERP; + player->pev->takedamage = DAMAGE_NO; + player->pev->deadflag = DEAD_DEAD; + player->pev->velocity = g_vecZero; + player->pev->punchangle = g_vecZero; + + player->m_bHasNightVision = false; + player->m_iHostagesKilled = 0; + player->m_fDeadTime = 0; + player->has_disconnected = false; + + player->m_iJoiningState = GETINTOGAME; + + SendItemStatus(player); + SET_CLIENT_MAXSPEED(ENT(player->pev), 1); + SET_MODEL(ENT(player->pev), "models/player.mdl"); + } + + if (!g_pGameRules->IsCareer()) + { + bool isCZero = UTIL_IsGame("czero"); + + switch (team) + { + case CT: + if (isCZero) + ShowVGUIMenu(player, VGUI_Menu_Class_CT, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6), "#CT_Select"); + else + ShowVGUIMenu(player, VGUI_Menu_Class_CT, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5), "#CT_Select"); + break; + + case TERRORIST: + if (isCZero) + ShowVGUIMenu(player, VGUI_Menu_Class_T, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6), "#Terrorist_Select"); + else + ShowVGUIMenu(player, VGUI_Menu_Class_T, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5), "#Terrorist_Select"); + break; + } + } + + player->m_iMenu = Menu_ChooseAppearance; + + // Show the appropriate Choose Appearance menu + // This must come before ClientKill() for CheckWinConditions() to function properly + + if (player->pev->deadflag == DEAD_NO) + { + ClientKill(player->edict()); + } + + // Switch their actual team... + player->m_bTeamChanged = true; + oldTeam = player->m_iTeam; + player->m_iTeam = team; + + TheBots->OnEvent(EVENT_PLAYER_CHANGED_TEAM, player); + + TeamChangeUpdate(player, team); + + szOldTeam = GetTeam(oldTeam); + szNewTeam = GetTeam(team); + + // Notify others that this player has joined a new team + UTIL_ClientPrintAll + ( + HUD_PRINTNOTIFY, + (team == TERRORIST) ? "#Game_join_terrorist" : "#Game_join_ct", + (STRING(player->pev->netname) && STRING(player->pev->netname)[0] != 0) ? STRING(player->pev->netname) : "" + ); + + UTIL_LogPrintf + ( + "\"%s<%i><%s><%s>\" joined team \"%s\"\n", + STRING(player->pev->netname), + GETPLAYERUSERID(player->edict()), + GETPLAYERAUTHID(player->edict()), + szOldTeam, + szNewTeam + ); + + return TRUE; +} + +/* <474a0> ../cstrike/dlls/client.cpp:2553 */ +void Radio1(CBasePlayer *player, int slot) +{ + if (player->m_flRadioTime >= gpGlobals->time) + { + return; + } + + if (player->m_iRadioMessages <= 0) + { + return; + } + + player->m_iRadioMessages--; + player->m_flRadioTime = gpGlobals->time + 1.5f; + + switch (slot) + { + case 1: + player->Radio("%!MRAD_COVERME", "#Cover_me"); + break; + case 2: + player->Radio("%!MRAD_TAKEPOINT", "#You_take_the_point"); + break; + case 3: + player->Radio("%!MRAD_POSITION", "#Hold_this_position"); + break; + case 4: + player->Radio("%!MRAD_REGROUP", "#Regroup_team"); + break; + case 5: + player->Radio("%!MRAD_FOLLOWME", "#Follow_me"); + break; + case 6: + player->Radio("%!MRAD_HITASSIST", "#Taking_fire"); + break; + } + + TheBots->OnEvent((GameEventType)(EVENT_START_RADIO_1 + slot), player); +} + +/* <474ca> ../cstrike/dlls/client.cpp:2596 */ +void Radio2(CBasePlayer *player, int slot) +{ + if (player->m_flRadioTime >= gpGlobals->time) + { + return; + } + + if (player->m_iRadioMessages <= 0) + { + return; + } + + player->m_iRadioMessages--; + player->m_flRadioTime = gpGlobals->time + 1.5f; + + switch (slot) + { + case 1: + player->Radio("%!MRAD_GO", "#Go_go_go"); + break; + case 2: + player->Radio("%!MRAD_FALLBACK", "#Team_fall_back"); + break; + case 3: + player->Radio("%!MRAD_STICKTOG", "#Stick_together_team"); + break; + case 4: + player->Radio("%!MRAD_GETINPOS", "#Get_in_position_and_wait"); + break; + case 5: + player->Radio("%!MRAD_STORMFRONT", "#Storm_the_front"); + break; + case 6: + player->Radio("%!MRAD_REPORTIN", "#Report_in_team"); + break; + } + + TheBots->OnEvent((GameEventType)(EVENT_START_RADIO_2 + slot), player); +} + +/* <474f4> ../cstrike/dlls/client.cpp:2639 */ +void Radio3(CBasePlayer *player, int slot) +{ + if (player->m_flRadioTime >= gpGlobals->time) + { + return; + } + + if (player->m_iRadioMessages <= 0) + { + return; + } + + player->m_iRadioMessages--; + player->m_flRadioTime = gpGlobals->time + 1.5f; + + switch (slot) + { + case 1: + if (RANDOM_LONG(0, 1)) + player->Radio("%!MRAD_AFFIRM", "#Affirmative"); + else + player->Radio("%!MRAD_ROGER", "#Roger_that"); + + break; + case 2: + player->Radio("%!MRAD_ENEMYSPOT", "#Enemy_spotted"); + break; + case 3: + player->Radio("%!MRAD_BACKUP", "#Need_backup"); + break; + case 4: + player->Radio("%!MRAD_CLEAR", "#Sector_clear"); + break; + case 5: + player->Radio("%!MRAD_INPOS", "#In_position"); + break; + case 6: + player->Radio("%!MRAD_REPRTINGIN", "#Reporting_in"); + break; + case 7: + player->Radio("%!MRAD_BLOW", "#Get_out_of_there"); + break; + case 8: + player->Radio("%!MRAD_NEGATIVE", "#Negative"); + break; + case 9: + player->Radio("%!MRAD_ENEMYDOWN", "#Enemy_down"); + break; + } + + TheBots->OnEvent((GameEventType)(EVENT_START_RADIO_3 + slot), player); +} + +/* <49402> ../cstrike/dlls/client.cpp:2698 */ +bool BuyGunAmmo(CBasePlayer *player, CBasePlayerItem *weapon, bool bBlinkMoney) +{ + int cost; + const char *classname; + + if (!player->CanPlayerBuy(true)) + { + return false; + } + + // Ensure that the weapon uses ammo + int nAmmo = weapon->PrimaryAmmoIndex(); + if (nAmmo == -1) + { + return false; + } + + // Can only buy if the player does not already have full ammo + if (player->m_rgAmmo[ nAmmo ] >= weapon->iMaxAmmo1()) + { + return false; + } + + switch (weapon->m_iId) + { + case WEAPON_AWP: + cost = AMMO_338MAG_PRICE; + classname = "ammo_338magnum"; + break; + case WEAPON_SCOUT: + case WEAPON_G3SG1: + case WEAPON_AK47: + cost = AMMO_762MM_PRICE; + classname = "ammo_762nato"; + break; + case WEAPON_XM1014: + case WEAPON_M3: + cost = AMMO_BUCKSHOT_PRICE; + classname = "ammo_buckshot"; + break; + case WEAPON_MAC10: + case WEAPON_UMP45: + case WEAPON_USP: + cost = AMMO_45ACP_PRICE; + classname = "ammo_45acp"; + break; + case WEAPON_M249: + cost = AMMO_556MM_PRICE; + classname = "ammo_556natobox"; + break; + case WEAPON_FIVESEVEN: + case WEAPON_P90: + cost = AMMO_57MM_PRICE; + classname = "ammo_57mm"; + break; + case WEAPON_ELITE: + case WEAPON_GLOCK18: + case WEAPON_MP5N: + case WEAPON_TMP: + cost = AMMO_9MM_PRICE; + classname = "ammo_9mm"; + break; + case WEAPON_DEAGLE: + cost = AMMO_50AE_PRICE; + classname = "ammo_50ae"; + break; + case WEAPON_P228: + cost = AMMO_357SIG_PRICE; + classname = "ammo_357sig"; + break; + case WEAPON_AUG: + case WEAPON_SG550: + case WEAPON_GALIL: + case WEAPON_FAMAS: + case WEAPON_M4A1: + case WEAPON_SG552: + cost = AMMO_556MM_PRICE; + classname = "ammo_556nato"; + break; + default: + ALERT(at_console, "Tried to buy ammo for an unrecognized gun\n"); + return false; + } + + // Purchase the ammo if the player has enough money + if (player->m_iAccount >= cost) + { + player->GiveNamedItem(classname); + player->AddAccount(-cost); + return true; + } + + if (bBlinkMoney) + { + if (g_bClientPrintEnable) + { + // Not enough money.. let the player know + ClientPrint(player->pev, HUD_PRINTCENTER, "#Not_Enough_Money"); + BlinkAccount(player, 2); + } + } + + return false; +} + +/* <4751e> ../cstrike/dlls/client.cpp:2884 */ +bool BuyAmmo(CBasePlayer *player, int nSlot, bool bBlinkMoney) +{ + if (!player->CanPlayerBuy(true)) + { + return false; + } + + if (nSlot < PRIMARY_WEAPON_SLOT || nSlot > PISTOL_SLOT) + { + return false; + } + + // Buy one ammo clip for all weapons in the given slot + // + // nSlot == 1 : Primary weapons + // nSlot == 2 : Secondary weapons + + CBasePlayerItem *pItem = player->m_rgpPlayerItems[ nSlot ]; + + if (player->HasShield()) + { + if (player->m_rgpPlayerItems[ PISTOL_SLOT ]) + pItem = player->m_rgpPlayerItems[ PISTOL_SLOT ]; + } + + if (pItem != NULL) + { + while (BuyGunAmmo(player, pItem, bBlinkMoney)) + { + pItem = pItem->m_pNext; + + if (!pItem) + { + return true; + } + } + } + + return false; +} + +/* <4bb4a> ../cstrike/dlls/client.cpp:2933 */ +CBaseEntity *EntityFromUserID(int userID) +{ + CBaseEntity *pTempEntity = NULL; + + while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player")) != NULL) + { + if (FNullEnt(pTempEntity->edict())) + break; + + CBasePlayer *pTempPlayer = GetClassPtr((CBasePlayer *)pTempEntity->pev); + + if (pTempPlayer->m_iTeam != UNASSIGNED && userID == GETPLAYERUSERID(pTempEntity->edict())) + { + return pTempPlayer; + } + } + + return NULL; +} + +/* <4baa5> ../cstrike/dlls/client.cpp:2958 */ +NOXREF int CountPlayersInServer(void) +{ + int count = 0; + CBaseEntity *pTempEntity = NULL; + + while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player")) != NULL) + { + if (FNullEnt(pTempEntity->edict())) + break; + + CBasePlayer *pTempPlayer = GetClassPtr((CBasePlayer *)pTempEntity->pev); + + if (pTempPlayer->m_iTeam != UNASSIGNED) + { + count++; + } + } + + return count; +} + +// Handles the special "buy" alias commands we're creating to accommodate the buy +// scripts players use (now that we've rearranged the buy menus and broken the scripts) +// ** Returns TRUE if we've handled the command ** + +/* <4958c> ../cstrike/dlls/client.cpp:2983 */ +BOOL HandleBuyAliasCommands(CBasePlayer *pPlayer, const char *pszCommand) +{ + // Let them buy it if it's got a weapon data string. + BOOL bRetVal = FALSE; + const char *pszFailItem = NULL; + + WeaponIdType weaponID = WEAPON_NONE; + const char *weaponFailName = BuyAliasToWeaponID(pszCommand, weaponID); + + if (weaponID != WEAPON_NONE) + { + // Ok, we have weapon info ID. + // assasination maps have a specific set of weapons that can be used in them. + if (CanBuyWeaponByMaptype(pPlayer->m_iTeam, weaponID, (g_pGameRules->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES))) + { + bRetVal = TRUE; + BuyWeaponByWeaponID(pPlayer, weaponID); + } + else if (weaponFailName != NULL) + { + bRetVal = TRUE; + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Alias_Not_Avail", weaponFailName); + } + } + else + { + bRetVal = TRUE; + if (g_bClientPrintEnable) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Cannot_Buy_This"); + } + } + } + else + { + // primary ammo + if (FStrEq(pszCommand, "primammo")) + { + bRetVal = TRUE; + + // Buy as much primary ammo as possible + // Blink money only if player doesn't have enough for the + // first clip + if (BuyAmmo(pPlayer, PRIMARY_WEAPON_SLOT, true)) + { + while (BuyAmmo(pPlayer, PRIMARY_WEAPON_SLOT, false)) + ; + + if (TheTutor != NULL) + { + TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); + } + } + } + // secondary ammo + else if (FStrEq(pszCommand, "secammo")) + { + bRetVal = TRUE; + + // Buy as much secondary ammo as possible + // Blink money only if player doesn't have enough for the + // first clip + if (BuyAmmo(pPlayer, PISTOL_SLOT, true)) + { + while (BuyAmmo(pPlayer, PISTOL_SLOT, false)) + ; + + if (TheTutor != NULL) + { + TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, pPlayer); + } + } + } + // equipment + else if (FStrEq(pszCommand, "vest")) + { + bRetVal = TRUE; + BuyItem(pPlayer, MENU_SLOT_ITEM_VEST); + } + else if (FStrEq(pszCommand, "vesthelm")) + { + bRetVal = TRUE; + BuyItem(pPlayer, MENU_SLOT_ITEM_VESTHELM); + } + else if (FStrEq(pszCommand, "flash")) + { + bRetVal = TRUE; + BuyItem(pPlayer, MENU_SLOT_ITEM_FLASHGREN); + } + else if (FStrEq(pszCommand, "hegren")) + { + bRetVal = TRUE; + BuyItem(pPlayer, MENU_SLOT_ITEM_HEGREN); + } + else if (FStrEq(pszCommand, "sgren")) + { + bRetVal = TRUE; + BuyItem(pPlayer, MENU_SLOT_ITEM_SMOKEGREN); + } + else if (FStrEq(pszCommand, "nvgs")) + { + bRetVal = TRUE; + BuyItem(pPlayer, MENU_SLOT_ITEM_NVG); + } + else if (FStrEq(pszCommand, "defuser")) + { + bRetVal = TRUE; + if (pPlayer->m_iTeam == CT) + { + BuyItem(pPlayer, MENU_SLOT_ITEM_DEFUSEKIT); + } + else + { + // fail gracefully + pszFailItem = "#Bomb_Defusal_Kit"; + } + } + else if (FStrEq(pszCommand, "shield")) + { + bRetVal = TRUE; + if (pPlayer->m_iTeam == CT) + { + BuyItem(pPlayer, MENU_SLOT_ITEM_SHIELD); + } + else + { + // fail gracefully + pszFailItem = "#TactShield_Desc"; + } + } + } + + if (g_bClientPrintEnable && pszFailItem != NULL) + { + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Alias_Not_Avail", pszFailItem); + } + + pPlayer->BuildRebuyStruct(); + return bRetVal; +} + +/* <49c3e> ../cstrike/dlls/client.cpp:3113 */ +BOOL HandleRadioAliasCommands(CBasePlayer *pPlayer, const char *pszCommand) +{ + BOOL bRetVal = FALSE; + + if (FStrEq(pszCommand, "coverme")) + { + bRetVal = TRUE; + Radio1(pPlayer, 1); + } + else if (FStrEq(pszCommand, "takepoint")) + { + bRetVal = TRUE; + Radio1(pPlayer, 2); + } + else if (FStrEq(pszCommand, "holdpos")) + { + bRetVal = TRUE; + Radio1(pPlayer, 3); + } + else if (FStrEq(pszCommand, "regroup")) + { + bRetVal = TRUE; + Radio1(pPlayer, 4); + } + else if (FStrEq(pszCommand, "followme")) + { + bRetVal = TRUE; + Radio1(pPlayer, 5); + } + else if (FStrEq(pszCommand, "takingfire")) + { + bRetVal = TRUE; + Radio1(pPlayer, 6); + } + else if (FStrEq(pszCommand, "go")) + { + bRetVal = TRUE; + Radio2(pPlayer, 1); + } + else if (FStrEq(pszCommand, "fallback")) + { + bRetVal = TRUE; + Radio2(pPlayer, 2); + } + else if (FStrEq(pszCommand, "sticktog")) + { + bRetVal = TRUE; + Radio2(pPlayer, 3); + } + else if (FStrEq(pszCommand, "getinpos")) + { + bRetVal = TRUE; + Radio2(pPlayer, 4); + } + else if (FStrEq(pszCommand, "stormfront")) + { + bRetVal = TRUE; + Radio2(pPlayer, 5); + } + else if (FStrEq(pszCommand, "report")) + { + bRetVal = TRUE; + Radio2(pPlayer, 6); + } + else if (FStrEq(pszCommand, "roger")) + { + bRetVal = TRUE; + Radio3(pPlayer, 1); + } + else if (FStrEq(pszCommand, "enemyspot")) + { + bRetVal = TRUE; + Radio3(pPlayer, 2); + } + else if (FStrEq(pszCommand, "needbackup")) + { + bRetVal = TRUE; + Radio3(pPlayer, 3); + } + else if (FStrEq(pszCommand, "sectorclear")) + { + bRetVal = TRUE; + Radio3(pPlayer, 4); + } + else if (FStrEq(pszCommand, "inposition")) + { + bRetVal = TRUE; + Radio3(pPlayer, 5); + } + else if (FStrEq(pszCommand, "reportingin")) + { + bRetVal = TRUE; + Radio3(pPlayer, 6); + } + else if (FStrEq(pszCommand, "getout")) + { + bRetVal = TRUE; + Radio3(pPlayer, 7); + } + else if (FStrEq(pszCommand, "negative")) + { + bRetVal = TRUE; + Radio3(pPlayer, 8); + } + else if (FStrEq(pszCommand, "enemydown")) + { + bRetVal = TRUE; + Radio3(pPlayer, 9); + } + + return bRetVal; +} + +// Use CMD_ARGV, CMD_ARGV, and CMD_ARGC to get pointers the character string command. + +/* <4c6c1> ../cstrike/dlls/client.cpp:3234 */ +void ClientCommand(edict_t *pEntity) +{ + const char *pcmd = CMD_ARGV_(0); + const char *pstr = NULL; + CHalfLifeMultiplay *mp = g_pGameRules; + + // Is the client spawned yet? + if (!pEntity->pvPrivateData) + return; + + entvars_t *pev = &pEntity->v; + CBasePlayer *player = GetClassPtr((CBasePlayer *)pev); + + if (FStrEq(pcmd, "say")) + { + if (gpGlobals->time >= player->m_flLastCommandTime[0]) + { + player->m_flLastCommandTime[0] = gpGlobals->time + 0.3f; + Host_Say(pEntity, 0); + } + } + else if (FStrEq(pcmd, "say_team")) + { + if (gpGlobals->time >= player->m_flLastCommandTime[1]) + { + player->m_flLastCommandTime[1] = gpGlobals->time + 0.3f; + Host_Say(pEntity, 1); + } + } + else if (FStrEq(pcmd, "fullupdate")) + { + if (gpGlobals->time >= player->m_flLastCommandTime[2]) + { + player->m_flLastCommandTime[2] = gpGlobals->time + 0.6f; + player->ForceClientDllUpdate(); + } + } + else if (FStrEq(pcmd, "vote")) + { + if (gpGlobals->time >= player->m_flLastCommandTime[3]) + { + player->m_flLastCommandTime[3] = gpGlobals->time + 0.3f; + + if (gpGlobals->time < player->m_flNextVoteTime) + { + ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Wait_3_Seconds"); + return; + } + + player->m_flNextVoteTime = gpGlobals->time + 3; + + if (player->m_iTeam != UNASSIGNED) + { + int iVoteID; + int iVoteFail = 0; + int iNumArgs = CMD_ARGC_(); + const char *pszArg1 = CMD_ARGV_(1); + int iVoteLength = Q_strlen(pszArg1); + + if (iNumArgs != 2 || iVoteLength <= 0 || iVoteLength > 6) + { + iVoteFail = 1; + } + + iVoteID = Q_atoi(pszArg1); + if (iVoteID <= 0) + { + iVoteFail = 1; + } + + if (iVoteFail) + { + ListPlayers(player); + ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_vote_usage"); + return; + } + + if (CountTeamPlayers(player->m_iTeam) < 3) + { + ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Cannot_Vote_With_Less_Than_Three"); + return; + } + + CBaseEntity *pKickEntity = EntityFromUserID(iVoteID); + if (pKickEntity != NULL) + { + CBasePlayer *pKickPlayer = GetClassPtr((CBasePlayer *)pKickEntity->pev); + + if (pKickPlayer->m_iTeam != player->m_iTeam) + { + ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_vote_players_on_your_team"); + return; + } + + if (pKickPlayer == player) + { + ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_vote_not_yourself"); + return; + } + + ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_vote_cast", UTIL_dtos1(iVoteID)); + player->m_iCurrentKickVote = iVoteID; + ProcessKickVote(player, pKickPlayer); + } + else + { + ListPlayers(player); + ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_vote_player_not_found", UTIL_dtos1(iVoteID)); + } + } + } + } + else if (FStrEq(pcmd, "listmaps")) + { + if (gpGlobals->time >= player->m_flLastCommandTime[5]) + { + player->m_flLastCommandTime[5] = gpGlobals->time + 0.3f; + mp->DisplayMaps(player, 0); + } + } + else if (FStrEq(pcmd, "votemap")) + { + if (gpGlobals->time >= player->m_flLastCommandTime[4]) + { + player->m_flLastCommandTime[4] = gpGlobals->time + 0.3f; + + if (gpGlobals->time < player->m_flNextVoteTime) + { + ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Wait_3_Seconds"); + return; + } + + player->m_flNextVoteTime = gpGlobals->time + 3; + + if (player->m_iTeam != UNASSIGNED) + { + if (gpGlobals->time < 180) + { + ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Cannot_Vote_Map"); + return; + } + + int iFailed = 0; + int iNumArgs = CMD_ARGC_(); + const char *pszArg1 = CMD_ARGV_(1); + int iVoteLength = Q_strlen(pszArg1); + + if (iNumArgs != 2 || iVoteLength > 5) + { + iFailed = 1; + } + + int iVoteID = Q_atoi(pszArg1); + if (iVoteID < 1 || iVoteID > MAX_VOTE_MAPS) + { + iFailed = 1; + } + + if (iVoteID > GetMapCount()) + { + iFailed = 1; + } + + if (iFailed) + { + mp->DisplayMaps(player, 0); + ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_votemap_usage"); + return; + } + + if (CountTeamPlayers(player->m_iTeam) < 2) + { + ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Cannot_Vote_Need_More_People"); + return; + } + + if (player->m_iMapVote) + { + mp->m_iMapVotes[ player->m_iMapVote ]--; + + if (mp->m_iMapVotes[player->m_iMapVote] < 0) + { + mp->m_iMapVotes[player->m_iMapVote] = 0; + } + } + + ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_voted_for_map", UTIL_dtos1(iVoteID)); + player->m_iMapVote = iVoteID; + mp->ProcessMapVote(player, iVoteID); + } + } + } + else if (FStrEq(pcmd, "timeleft")) + { + if (gpGlobals->time > player->m_iTimeCheckAllowed) + { + player->m_iTimeCheckAllowed = (int)(gpGlobals->time + 1); + + if (!timelimit.value) + { + ClientPrint(player->pev, HUD_PRINTTALK, "#Game_no_timelimit"); + return; + } + + int iTimeRemaining = (int)(g_flTimeLimit - gpGlobals->time); + + if (iTimeRemaining < 0) + iTimeRemaining = 0; + + int iMinutes = (int)(iTimeRemaining % 60); + int iSeconds = (int)(iTimeRemaining / 60); + + char secs[5]; + char *temp = UTIL_dtos2(iMinutes); + + if (iMinutes >= 10) + { + secs[0] = temp[0]; + secs[1] = temp[1]; + secs[2] = '\0'; + } + else + { + secs[0] = '0'; + secs[1] = temp[0]; + secs[2] = '\0'; + } + + ClientPrint(player->pev, HUD_PRINTTALK, "#Game_timelimit", UTIL_dtos1(iSeconds), secs); + } + } + else if (FStrEq(pcmd, "listplayers")) + { + if (gpGlobals->time >= player->m_flLastCommandTime[6]) + { + player->m_flLastCommandTime[6] = gpGlobals->time + 0.3f; + ListPlayers(player); + } + } + else if (FStrEq(pcmd, "client_buy_open")) + { + if (player->m_iMenu == Menu_OFF) + { + player->m_iMenu = Menu_ClientBuy; + } + + if (player->m_signals.GetState() & SIGNAL_BUY) + { + if (TheTutor) + { + TheTutor->OnEvent(EVENT_TUTOR_BUY_MENU_OPENNED); + } + } + else + { + MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, NULL, player->pev); + MESSAGE_END(); + } + } + else if (FStrEq(pcmd, "client_buy_close")) + { + if (player->m_iMenu == Menu_ClientBuy) + { + player->m_iMenu = Menu_OFF; + } + } + else if (FStrEq(pcmd, "menuselect")) + { + int slot = Q_atoi(CMD_ARGV_(1)); + + if (player->m_iJoiningState == JOINED || (player->m_iMenu != SPECTATOR && player->m_iMenu != TERRORIST)) + { + if (slot == 10) + { + player->m_iMenu = Menu_OFF; + } + } + + switch (player->m_iMenu) + { + case Menu_OFF: + break; + + case Menu_ChooseTeam: + { + if (!player->m_bVGUIMenus && !HandleMenu_ChooseTeam(player, slot)) + { + if (player->m_iJoiningState == JOINED) + ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_0), "#IG_Team_Select"); + else + ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5), "#Team_Select"); + + player->m_iMenu = Menu_ChooseTeam; + } + break; + } + case Menu_IGChooseTeam: + { + if (!player->m_bVGUIMenus) + { + HandleMenu_ChooseTeam(player, slot); + } + break; + } + case Menu_ChooseAppearance: + { + if (!player->m_bVGUIMenus) + { + HandleMenu_ChooseAppearance(player, slot); + } + break; + } + case Menu_Buy: + { + if (!player->m_bVGUIMenus) + { + switch (slot) + { + case VGUI_MenuSlot_Buy_Pistol: + { + if (player->m_iTeam == CT) + ShowVGUIMenu(player, VGUI_Menu_Buy_Pistol, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_0), "#CT_BuyPistol"); + else + ShowVGUIMenu(player, VGUI_Menu_Buy_Pistol, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_0), "#T_BuyPistol"); + + player->m_iMenu = Menu_BuyPistol; + break; + } + case VGUI_MenuSlot_Buy_ShotGun: + { + if (mp->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES && player->m_iTeam == TERRORIST) + ShowVGUIMenu(player, VGUI_Menu_Buy_ShotGun, MENU_KEY_0, "#AS_BuyShotgun"); + else + ShowVGUIMenu(player, VGUI_Menu_Buy_ShotGun, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_0), "#BuyShotgun"); + + player->m_iMenu = Menu_BuyShotgun; + break; + } + case VGUI_MenuSlot_Buy_SubMachineGun: + { + if (mp->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) + { + if (player->m_iTeam == CT) + ShowVGUIMenu(player, VGUI_Menu_Buy_SubMachineGun, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_0), "#AS_CT_BuySubMachineGun"); + else + ShowVGUIMenu(player, VGUI_Menu_Buy_SubMachineGun, (MENU_KEY_1 | MENU_KEY_3 | MENU_KEY_0), "#AS_T_BuySubMachineGun"); + } + else + { + if (player->m_iTeam == CT) + ShowVGUIMenu(player, VGUI_Menu_Buy_SubMachineGun, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_0), "#CT_BuySubMachineGun"); + else + ShowVGUIMenu(player, VGUI_Menu_Buy_SubMachineGun, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_0), "#T_BuySubMachineGun"); + } + + player->m_iMenu = Menu_BuySubMachineGun; + break; + } + case VGUI_MenuSlot_Buy_Rifle: + { + if (mp->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) + { + if (player->m_iTeam == CT) + ShowVGUIMenu(player, VGUI_Menu_Buy_Rifle, (MENU_KEY_1 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_0), "#AS_CT_BuyRifle"); + else + ShowVGUIMenu(player, VGUI_Menu_Buy_Rifle, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_0), "#AS_T_BuyRifle"); + } + else + { + if (player->m_iTeam == CT) + ShowVGUIMenu(player, VGUI_Menu_Buy_Rifle, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#CT_BuyRifle"); + else + ShowVGUIMenu(player, VGUI_Menu_Buy_Rifle, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#T_BuyRifle"); + } + + player->m_iMenu = Menu_BuyRifle; + break; + } + case VGUI_MenuSlot_Buy_MachineGun: + { + if (mp->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES && player->m_iTeam == TERRORIST) + ShowVGUIMenu(player, VGUI_Menu_Buy_MachineGun, MENU_KEY_0, "#AS_T_BuyMachineGun"); + else + ShowVGUIMenu(player, VGUI_Menu_Buy_MachineGun, (MENU_KEY_1 | MENU_KEY_0), "#BuyMachineGun"); + + player->m_iMenu = Menu_BuyMachineGun; + break; + } + case VGUI_MenuSlot_Buy_PrimAmmo: + { + if (player->m_signals.GetState() & SIGNAL_BUY) + { + if (BuyAmmo(player, PRIMARY_WEAPON_SLOT, true)) + { + while (BuyAmmo(player, PRIMARY_WEAPON_SLOT, false)) + ; + + if (TheTutor) + { + TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, player); + } + } + + player->BuildRebuyStruct(); + } + break; + } + case VGUI_MenuSlot_Buy_SecAmmo: + { + if (player->m_signals.GetState() & SIGNAL_BUY) + { + if (BuyAmmo(player, PISTOL_SLOT, true)) + { + while (BuyAmmo(player, PISTOL_SLOT, false)) + ; + + if (TheTutor) + { + TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, player); + } + } + + player->BuildRebuyStruct(); + } + } + case VGUI_MenuSlot_Buy_Item: + { + if (player->m_signals.GetState() & SIGNAL_BUY) + { + if (mp->m_bMapHasBombTarget) + { + if (player->m_iTeam == CT) + ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_0), "#DCT_BuyItem"); + else + ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#DT_BuyItem"); + } + else + { + if (player->m_iTeam == CT) + ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_8 | MENU_KEY_0), "#CT_BuyItem"); + else + ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#T_BuyItem"); + } + + player->m_iMenu = Menu_BuyItem; + } + break; + } + } + } + break; + } + case Menu_BuyPistol: + { + if (!player->m_bVGUIMenus) + { + BuyPistol(player, slot); + } + break; + } + case Menu_BuyShotgun: + { + if (!player->m_bVGUIMenus) + { + BuyShotgun(player, slot); + } + break; + } + case Menu_BuySubMachineGun: + { + if (!player->m_bVGUIMenus) + { + BuySubMachineGun(player, slot); + } + break; + } + case Menu_BuyRifle: + { + if (!player->m_bVGUIMenus) + { + BuyRifle(player, slot); + } + break; + } + case Menu_BuyMachineGun: + { + if (!player->m_bVGUIMenus) + { + BuyMachineGun(player, slot); + } + break; + } + case Menu_BuyItem: + { + if (!player->m_bVGUIMenus) + { + BuyItem(player, slot); + } + break; + } + case Menu_Radio1: + { + Radio1(player, slot); + break; + } + case Menu_Radio2: + { + Radio2(player, slot); + break; + } + case Menu_Radio3: + { + Radio3(player, slot); + break; + } + default: + ALERT(at_console, "ClientCommand(): Invalid menu selected\n"); + break; + } + } + else if (FStrEq(pcmd, "chooseteam")) + { + if (player->m_iMenu == Menu_ChooseAppearance) + { + return; + } + + if (player->m_bTeamChanged) + { + if (player->pev->deadflag != DEAD_NO) + { + ClientPrint(player->pev, HUD_PRINTCENTER, "#Only_1_Team_Change"); + return; + } + } + + if (!mp->IsCareer()) + { + if (mp->m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES && player->m_iJoiningState == JOINED && player->m_iTeam == CT) + { + if (mp->IsFreezePeriod() || player->pev->deadflag != DEAD_NO) + ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#IG_VIP_Team_Select_Spect"); + else + ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_5 | MENU_KEY_0), "#IG_VIP_Team_Select"); + } + else + { + if (mp->IsFreezePeriod() || player->pev->deadflag != DEAD_NO) + ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#IG_Team_Select_Spect"); + else + ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_0), "#IG_Team_Select"); + } + + player->m_iMenu = Menu_ChooseTeam; + } + } + else if (FStrEq(pcmd, "showbriefing")) + { + if (player->m_iMenu == Menu_OFF) + { + if (g_szMapBriefingText[0] != '\0') + { + if (player->m_iTeam != UNASSIGNED && !(player->m_afPhysicsFlags & PFLAG_OBSERVER)) + { + player->MenuPrint(g_szMapBriefingText); + player->m_bMissionBriefing = true; + } + } + } + } + else if (FStrEq(pcmd, "ignoremsg")) + { + if (player->m_iIgnoreGlobalChat == IGNOREMSG_NONE) + { + player->m_iIgnoreGlobalChat = IGNOREMSG_ENEMY; + ClientPrint(player->pev, HUD_PRINTCENTER, "#Ignore_Broadcast_Messages"); + } + else if (player->m_iIgnoreGlobalChat == IGNOREMSG_ENEMY) + { + player->m_iIgnoreGlobalChat = IGNOREMSG_TEAM; + ClientPrint(player->pev, HUD_PRINTCENTER, "#Ignore_Broadcast_Team_Messages"); + } + else if (player->m_iIgnoreGlobalChat == IGNOREMSG_TEAM) + { + player->m_iIgnoreGlobalChat = IGNOREMSG_NONE; + ClientPrint(player->pev, HUD_PRINTCENTER, "#Accept_All_Messages"); + } + } + else if (FStrEq(pcmd, "ignorerad")) + { + player->m_bIgnoreRadio = !player->m_bIgnoreRadio; + ClientPrint(player->pev, HUD_PRINTCENTER, player->m_bIgnoreRadio ? "#Ignore_Radio" : "#Accept_Radio"); + } + else if (FStrEq(pcmd, "become_vip")) + { + if (player->m_iJoiningState != JOINED || player->m_iTeam != CT) + { + ClientPrint(player->pev, HUD_PRINTCENTER, "#Command_Not_Available"); + return; + } + + mp->AddToVIPQueue(player); + } + else if (FStrEq(pcmd, "spectate") && (player->pev->flags & FL_PROXY)) // always allow proxies to become a spectator + { + // clients wants to become a spectator + HandleMenu_ChooseTeam(player, MENU_SLOT_TEAM_SPECT); + } + else if (FStrEq(pcmd, "specmode")) + { + // new spectator mode + int mode = Q_atoi(CMD_ARGV_(1)); + + if (player->IsObserver() && player->CanSwitchObserverModes()) + player->Observer_SetMode(mode); + else + player->m_iObserverLastMode = mode; + + if (mode == OBS_CHASE_FREE) + { + MESSAGE_BEGIN(MSG_ONE, gmsgADStop, NULL, player->pev); + MESSAGE_END(); + } + } + else if (FStrEq(pcmd, "spec_set_ad")) + { + float val = Q_atof(CMD_ARGV_(1)); + player->SetObserverAutoDirector(val > 0.0f); + } + else if (FStrEq(pcmd, "follownext")) + { + // follow next player + int arg = Q_atoi(CMD_ARGV_(1)); + + if (player->IsObserver() && player->CanSwitchObserverModes()) + { + player->Observer_FindNextPlayer(arg != 0); + } + } + else if (FStrEq(pcmd, "follow")) + { + if (player->IsObserver() && player->CanSwitchObserverModes()) + { + player->Observer_FindNextPlayer(false, CMD_ARGV_(1)); + } + } + else + { + if (mp->ClientCommand_DeadOrAlive(GetClassPtr((CBasePlayer *)pev), pcmd)) + return; + + if (TheBots->ClientCommand(GetClassPtr((CBasePlayer *)pev), pcmd)) + return; + + if (FStrEq(pcmd, "mp_debug")) + { + UTIL_SetDprintfFlags(CMD_ARGV_(1)); + } + else if (FStrEq(pcmd, "jointeam")) + { + if (player->m_iMenu == Menu_ChooseAppearance) + { + ClientPrint(player->pev, HUD_PRINTCENTER, "#Command_Not_Available"); + return; + } + + int slot = Q_atoi(CMD_ARGV_(1)); + if (HandleMenu_ChooseTeam(player, slot)) + { + if (slot == MENU_SLOT_TEAM_VIP || slot == MENU_SLOT_TEAM_SPECT || player->m_bIsVIP) + { + player->m_iMenu = Menu_OFF; + } + else + player->m_iMenu = Menu_ChooseAppearance; + } + else + { + if (player->m_iJoiningState == JOINED) + ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_0), "#IG_Team_Select"); + else + ShowVGUIMenu(player, VGUI_Menu_Team, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5), "#Team_Select"); + + player->m_iMenu = Menu_ChooseTeam; + } + } + else if (FStrEq(pcmd, "joinclass")) + { + int slot = Q_atoi(CMD_ARGV_(1)); + + if (player->m_iMenu != Menu_ChooseAppearance) + { + ClientPrint(player->pev, HUD_PRINTCENTER, "#Command_Not_Available"); + return; + } + + HandleMenu_ChooseAppearance(player, slot); + } + else if (player->pev->deadflag == DEAD_NO) + { + if (FStrEq(pcmd, "nightvision")) + { + if (gpGlobals->time >= player->m_flLastCommandTime[7]) + { + player->m_flLastCommandTime[7] = gpGlobals->time + 0.3f; + + if (!player->m_bHasNightVision) + return; + + if (player->m_bNightVisionOn) + { + EMIT_SOUND(ENT(player->pev), CHAN_ITEM, "items/nvg_off.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); + + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, player->pev); + WRITE_BYTE(0); // disable nightvision + MESSAGE_END(); + + player->m_bNightVisionOn = false; + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pObserver = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (pObserver && pObserver->IsObservingPlayer(player)) + { + EMIT_SOUND(ENT(pObserver->pev), CHAN_ITEM, "items/nvg_off.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); + + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); + WRITE_BYTE(0); // disable nightvision + MESSAGE_END(); + + pObserver->m_bNightVisionOn = false; + } + } + } + else + { + EMIT_SOUND(ENT(player->pev), CHAN_ITEM, "items/nvg_on.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); + + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, player->pev); + WRITE_BYTE(1); // enable nightvision + MESSAGE_END(); + + player->m_bNightVisionOn = true; + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pObserver = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (pObserver && pObserver->IsObservingPlayer(player)) + { + EMIT_SOUND(ENT(pObserver->pev), CHAN_ITEM, "items/nvg_on.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); + + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); + WRITE_BYTE(1); // enable nightvision + MESSAGE_END(); + + pObserver->m_bNightVisionOn = true; + } + } + } + } + } + else if (FStrEq(pcmd, "radio1")) + { + ShowMenu(player, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), -1, FALSE, "#RadioA"); + player->m_iMenu = Menu_Radio1; + } + else if (FStrEq(pcmd, "radio2")) + { + ShowMenu(player, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), -1, FALSE, "#RadioB"); + player->m_iMenu = Menu_Radio2; + return; + } + else if (FStrEq(pcmd, "radio3")) + { + ShowMenu(player, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_9 | MENU_KEY_0), -1, FALSE, "#RadioC"); + player->m_iMenu = Menu_Radio3; + } + else if (FStrEq(pcmd, "drop")) + { + // player is dropping an item. + if (player->HasShield()) + { + if (player->m_pActiveItem && player->m_pActiveItem->m_iId == WEAPON_C4) + { + player->DropPlayerItem("weapon_c4"); + } + else + player->DropShield(); + } + else + player->DropPlayerItem(CMD_ARGV_(1)); + } + else if (FStrEq(pcmd, "fov")) + { +#if 0 + if (g_flWeaponCheat && CMD_ARGC() > 1) + GetClassPtr((CBasePlayer *)pev)->m_iFOV = Q_atoi(CMD_ARGV(1)); + else + CLIENT_PRINTF(pEntity, print_console, UTIL_VarArgs("\"fov\" is \"%d\"\n", (int)GetClassPtr((CBasePlayer *)pev)->m_iFOV)); +#endif + } + else if (FStrEq(pcmd, "use")) + { + GetClassPtr((CBasePlayer *)pev)->SelectItem(CMD_ARGV_(1)); + } + else if (((pstr = Q_strstr(pcmd, "weapon_")) != NULL) && (pstr == pcmd)) + { + GetClassPtr((CBasePlayer *)pev)->SelectItem(pcmd); + } + else if (FStrEq(pcmd, "lastinv")) + { + GetClassPtr((CBasePlayer *)pev)->SelectLastItem(); + } + else if (FStrEq(pcmd, "buyammo1")) + { + if (player->m_signals.GetState() & SIGNAL_BUY) + { + BuyAmmo(player, PRIMARY_WEAPON_SLOT, true); + player->BuildRebuyStruct(); + if (TheTutor) + { + TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, player); + } + } + } + else if (FStrEq(pcmd, "buyammo2")) + { + if (player->m_signals.GetState() & SIGNAL_BUY) + { + BuyAmmo(player, PISTOL_SLOT, true); + player->BuildRebuyStruct(); + if (TheTutor) + { + TheTutor->OnEvent(EVENT_PLAYER_BOUGHT_SOMETHING, player); + } + } + } + else if (FStrEq(pcmd, "buyequip")) + { + if (player->m_signals.GetState() & SIGNAL_BUY) + { + if (mp->m_bMapHasBombTarget) + { + if (player->m_iTeam == CT) + ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_0), "#DCT_BuyItem"); + else + ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#DT_BuyItem"); + } + else + { + if (player->m_iTeam == CT) + ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_8 | MENU_KEY_0), "#CT_BuyItem"); + else + ShowVGUIMenu(player, VGUI_Menu_Buy_Item, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0), "#T_BuyItem"); + } + + player->m_iMenu = Menu_BuyItem; + } + } + else if (FStrEq(pcmd, "buy")) + { + if (player->m_signals.GetState() & SIGNAL_BUY) + { + ShowVGUIMenu(player, VGUI_Menu_Buy, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_0), "#Buy"); + player->m_iMenu = Menu_Buy; + + if (TheBots) + { + TheBots->OnEvent(EVENT_TUTOR_BUY_MENU_OPENNED); + } + } + } + else if (FStrEq(pcmd, "cl_setautobuy")) + { + player->ClearAutoBuyData(); + + for (int i = 1; i < CMD_ARGC_(); i++) + { + player->AddAutoBuyData(CMD_ARGV_(i)); + } + + bool oldval = g_bClientPrintEnable; + g_bClientPrintEnable = false; + player->AutoBuy(); + g_bClientPrintEnable = oldval; + } + else if (FStrEq(pcmd, "cl_setrebuy")) + { + if (CMD_ARGC_() == 2) + { + player->InitRebuyData(CMD_ARGV_(1)); + + bool oldval = g_bClientPrintEnable; + g_bClientPrintEnable = false; + player->Rebuy(); + g_bClientPrintEnable = oldval; + } + } + else if (FStrEq(pcmd, "cl_autobuy")) + { + if (player->m_signals.GetState() & SIGNAL_BUY) + { + bool oldval = g_bClientPrintEnable; + g_bClientPrintEnable = false; + player->AutoBuy(); + g_bClientPrintEnable = oldval; + } + } + else if (FStrEq(pcmd, "cl_rebuy")) + { + if (player->m_signals.GetState() & SIGNAL_BUY) + { + bool oldval = g_bClientPrintEnable; + g_bClientPrintEnable = false; + player->Rebuy(); + g_bClientPrintEnable = oldval; + } + } + else if (FStrEq(pcmd, "smartradio")) + { + player->SmartRadio(); + } + else + { + if (HandleBuyAliasCommands(player, pcmd)) + return; + + if (HandleRadioAliasCommands(player, pcmd)) + return; + + if (!g_pGameRules->ClientCommand(GetClassPtr((CBasePlayer *)pev), pcmd)) + { + // tell the user they entered an unknown command + char command[128]; + + // check the length of the command (prevents crash) + // max total length is 192 ...and we're adding a string below ("Unknown command: %s\n") + Q_strncpy(command, pcmd, sizeof(command) - 1); + command[sizeof(command) - 1] = '\0'; + + // tell the user they entered an unknown command + ClientPrint(&pEntity->v, HUD_PRINTCONSOLE, "#Game_unknown_command", command); + } + } + } + } +} + +/* <4b959> ../cstrike/dlls/client.cpp:4282 */ +void ClientUserInfoChanged(edict_t *pEntity, char *infobuffer) +{ + // Is the client spawned yet? + if (!pEntity->pvPrivateData) + { + return; + } + + CBasePlayer *pPlayer = (CBasePlayer *)CBaseEntity::Instance(pEntity); + + char *szBufferName = GET_KEY_VALUE(infobuffer, "name"); + int iClientIndex = pPlayer->entindex(); + + // msg everyone if someone changes their name, and it isn't the first time (changing no name to current name) + if (pEntity->v.netname && STRING(pEntity->v.netname)[0] != '\0' && !FStrEq(STRING(pEntity->v.netname), szBufferName)) + { + char szName[32]; + Q_snprintf(szName, sizeof(szName), "%s", szBufferName); + + // First parse the name and remove any %'s + for (char *pPct = szName; pPct != NULL && *pPct != '\0'; pPct++) + { + // Replace it with a space + if (*pPct == '%' || *pPct == '&') + *pPct = ' '; + } + + if (szName[0] == '#') + szName[0] = '*'; + + if (pPlayer->pev->deadflag != DEAD_NO) + { + pPlayer->m_bHasChangedName = true; + Q_snprintf(pPlayer->m_szNewName, sizeof(pPlayer->m_szNewName), "%s", szName); + ClientPrint(pPlayer->pev, HUD_PRINTTALK, "#Name_change_at_respawn"); + SET_CLIENT_KEY_VALUE(iClientIndex, infobuffer, "name", (char *)STRING(pEntity->v.netname)); + } + else + { + // Set the name + SET_CLIENT_KEY_VALUE(iClientIndex, infobuffer, "name", szName); + + MESSAGE_BEGIN(MSG_BROADCAST, gmsgSayText); + WRITE_BYTE(iClientIndex); + WRITE_STRING("#Cstrike_Name_Change"); + WRITE_STRING(STRING(pEntity->v.netname)); + WRITE_STRING(szName); + MESSAGE_END(); + + UTIL_LogPrintf + ( + "\"%s<%i><%s><%s>\" changed name to \"%s\"\n", + STRING(pEntity->v.netname), + GETPLAYERUSERID(pEntity), + GETPLAYERAUTHID(pEntity), + GetTeam(pPlayer->m_iTeam), + szName + ); + } + } + + g_pGameRules->ClientUserInfoChanged(GetClassPtr((CBasePlayer *)&pEntity->v), infobuffer); +} + +/* <4a378> ../cstrike/dlls/client.cpp:4362 */ +void ServerDeactivate(void) +{ + // It's possible that the engine will call this function more times than is necessary + // Therefore, only run it one time for each call to ServerActivate + if (g_serveractive != 1) + { + return; + } + + g_serveractive = 0; + + // Peform any shutdown operations here... + g_pGameRules->ServerDeactivate(); + CLocalNav::Reset(); + TheBots->ServerDeactivate(); + + if (g_pHostages) + { + g_pHostages->ServerDeactivate(); + } +} + +/* <4a392> ../cstrike/dlls/client.cpp:4400 */ +void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax) +{ + int i; + CBaseEntity *pClass; + + // Every call to ServerActivate should be matched by a call to ServerDeactivate + g_serveractive = 1; + EmptyEntityHashTable(); + + // Clients have not been initialized yet + for (i = 0; i < edictCount; i++) + { + edict_t *pEdict = &pEdictList[i]; + + if (pEdict->free) + continue; + + // Clients aren't necessarily initialized until ClientPutInServer() + if (i < clientMax || !pEdict->pvPrivateData) + continue; + + pClass = CBaseEntity::Instance(pEdict); + + // Activate this entity if it's got a class & isn't dormant + if (pClass && !(pClass->pev->flags & FL_DORMANT)) + { + AddEntityHashValue(&pEdict->v, STRING(pEdict->v.classname), CLASSNAME); + pClass->Activate(); + } + else + ALERT(at_console, "Can't instance %s\n", STRING(pEdict->v.classname)); + } + + // Link user messages here to make sure first client can get them... + LinkUserMessages(); + WriteSigonMessages(); + + if (g_pGameRules) + { + g_pGameRules->CheckMapConditions(); + } + + TheBots->ServerActivate(); + + if (g_pHostages) + { + g_pHostages->ServerActivate(); + } +} + +/* <4a404> ../cstrike/dlls/client.cpp:4459 */ +void PlayerPreThink(edict_t *pEntity) +{ + entvars_t *pev = &pEntity->v; + CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE(pEntity); + + if (pPlayer) + { + pPlayer->PreThink(); + } +} + +/* <4a47c> ../cstrike/dlls/client.cpp:4475 */ +void PlayerPostThink(edict_t *pEntity) +{ + entvars_t *pev = &pEntity->v; + CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE(pEntity); + + if (pPlayer) + { + pPlayer->PostThink(); + } +} + +/* <4a4f4> ../cstrike/dlls/client.cpp:4486 */ +void ParmsNewLevel(void) +{ + ; +} + +/* <4a50d> ../cstrike/dlls/client.cpp:4491 */ +void ParmsChangeLevel(void) +{ + // retrieve the pointer to the save data + SAVERESTOREDATA *pSaveData = (SAVERESTOREDATA *)gpGlobals->pSaveData; + + if (pSaveData) + { + pSaveData->connectionCount = BuildChangeList(pSaveData->levelList, MAX_LEVEL_CONNECTIONS); + } +} + +/* <4a548> ../cstrike/dlls/client.cpp:4504 */ +void StartFrame(void) +{ + if (g_pGameRules != NULL) + { + g_pGameRules->Think(); + } + + if (g_fGameOver) + return; + + CLocalNav::Think(); + + static cvar_t *skill = NULL; + if (!skill) + { + skill = CVAR_GET_POINTER("skill"); + } + + gpGlobals->teamplay = 1.0f; + + if (skill != NULL) + g_iSkillLevel = (int)skill->value; + + else + g_iSkillLevel = 0; + + TheBots->StartFrame(); + + if (TheTutor) + { + TheTutor->StartFrame(gpGlobals->time); + } + + ++g_ulFrameCount; +} + +/* <4a581> ../cstrike/dlls/client.cpp:4534 */ +void ClientPrecache(void) +{ + int i; + bool isCZero = UTIL_IsGame("czero"); + + PRECACHE_SOUND("weapons/dryfire_pistol.wav"); + PRECACHE_SOUND("weapons/dryfire_rifle.wav"); + PRECACHE_SOUND("player/pl_shot1.wav"); + PRECACHE_SOUND("player/pl_die1.wav"); + PRECACHE_SOUND("player/headshot1.wav"); + PRECACHE_SOUND("player/headshot2.wav"); + PRECACHE_SOUND("player/headshot3.wav"); + PRECACHE_SOUND("player/bhit_flesh-1.wav"); + PRECACHE_SOUND("player/bhit_flesh-2.wav"); + PRECACHE_SOUND("player/bhit_flesh-3.wav"); + PRECACHE_SOUND("player/bhit_kevlar-1.wav"); + PRECACHE_SOUND("player/bhit_helmet-1.wav"); + PRECACHE_SOUND("player/die1.wav"); + PRECACHE_SOUND("player/die2.wav"); + PRECACHE_SOUND("player/die3.wav"); + PRECACHE_SOUND("player/death6.wav"); + PRECACHE_SOUND("radio/locknload.wav"); + PRECACHE_SOUND("radio/letsgo.wav"); + PRECACHE_SOUND("radio/moveout.wav"); + PRECACHE_SOUND("radio/com_go.wav"); + PRECACHE_SOUND("radio/rescued.wav"); + PRECACHE_SOUND("radio/rounddraw.wav"); + PRECACHE_SOUND("items/kevlar.wav"); + PRECACHE_SOUND("items/ammopickup2.wav"); + PRECACHE_SOUND("items/nvg_on.wav"); + PRECACHE_SOUND("items/nvg_off.wav"); + PRECACHE_SOUND("items/equip_nvg.wav"); + PRECACHE_SOUND("weapons/c4_beep1.wav"); + PRECACHE_SOUND("weapons/c4_beep2.wav"); + PRECACHE_SOUND("weapons/c4_beep3.wav"); + PRECACHE_SOUND("weapons/c4_beep4.wav"); + PRECACHE_SOUND("weapons/c4_beep5.wav"); + PRECACHE_SOUND("weapons/c4_explode1.wav"); + PRECACHE_SOUND("weapons/c4_plant.wav"); + PRECACHE_SOUND("weapons/c4_disarm.wav"); + PRECACHE_SOUND("weapons/c4_disarmed.wav"); + PRECACHE_SOUND("weapons/explode3.wav"); + PRECACHE_SOUND("weapons/explode4.wav"); + PRECACHE_SOUND("weapons/explode5.wav"); + PRECACHE_SOUND("player/sprayer.wav"); + PRECACHE_SOUND("player/pl_fallpain2.wav"); + PRECACHE_SOUND("player/pl_fallpain3.wav"); + PRECACHE_SOUND("player/pl_snow1.wav"); + PRECACHE_SOUND("player/pl_snow2.wav"); + PRECACHE_SOUND("player/pl_snow3.wav"); + PRECACHE_SOUND("player/pl_snow4.wav"); + PRECACHE_SOUND("player/pl_snow5.wav"); + PRECACHE_SOUND("player/pl_snow6.wav"); + PRECACHE_SOUND("player/pl_step1.wav"); + PRECACHE_SOUND("player/pl_step2.wav"); + PRECACHE_SOUND("player/pl_step3.wav"); + PRECACHE_SOUND("player/pl_step4.wav"); + PRECACHE_SOUND("common/npc_step1.wav"); + PRECACHE_SOUND("common/npc_step2.wav"); + PRECACHE_SOUND("common/npc_step3.wav"); + PRECACHE_SOUND("common/npc_step4.wav"); + PRECACHE_SOUND("player/pl_metal1.wav"); + PRECACHE_SOUND("player/pl_metal2.wav"); + PRECACHE_SOUND("player/pl_metal3.wav"); + PRECACHE_SOUND("player/pl_metal4.wav"); + PRECACHE_SOUND("player/pl_dirt1.wav"); + PRECACHE_SOUND("player/pl_dirt2.wav"); + PRECACHE_SOUND("player/pl_dirt3.wav"); + PRECACHE_SOUND("player/pl_dirt4.wav"); + PRECACHE_SOUND("player/pl_duct1.wav"); + PRECACHE_SOUND("player/pl_duct2.wav"); + PRECACHE_SOUND("player/pl_duct3.wav"); + PRECACHE_SOUND("player/pl_duct4.wav"); + PRECACHE_SOUND("player/pl_grate1.wav"); + PRECACHE_SOUND("player/pl_grate2.wav"); + PRECACHE_SOUND("player/pl_grate3.wav"); + PRECACHE_SOUND("player/pl_grate4.wav"); + PRECACHE_SOUND("player/pl_slosh1.wav"); + PRECACHE_SOUND("player/pl_slosh2.wav"); + PRECACHE_SOUND("player/pl_slosh3.wav"); + PRECACHE_SOUND("player/pl_slosh4.wav"); + PRECACHE_SOUND("player/pl_tile1.wav"); + PRECACHE_SOUND("player/pl_tile2.wav"); + PRECACHE_SOUND("player/pl_tile3.wav"); + PRECACHE_SOUND("player/pl_tile4.wav"); + PRECACHE_SOUND("player/pl_tile5.wav"); + PRECACHE_SOUND("player/pl_swim1.wav"); + PRECACHE_SOUND("player/pl_swim2.wav"); + PRECACHE_SOUND("player/pl_swim3.wav"); + PRECACHE_SOUND("player/pl_swim4.wav"); + PRECACHE_SOUND("player/pl_ladder1.wav"); + PRECACHE_SOUND("player/pl_ladder2.wav"); + PRECACHE_SOUND("player/pl_ladder3.wav"); + PRECACHE_SOUND("player/pl_ladder4.wav"); + PRECACHE_SOUND("player/pl_wade1.wav"); + PRECACHE_SOUND("player/pl_wade2.wav"); + PRECACHE_SOUND("player/pl_wade3.wav"); + PRECACHE_SOUND("player/pl_wade4.wav"); + PRECACHE_SOUND("debris/wood1.wav"); + PRECACHE_SOUND("debris/wood2.wav"); + PRECACHE_SOUND("debris/wood3.wav"); + PRECACHE_SOUND("plats/train_use1.wav"); + PRECACHE_SOUND("plats/vehicle_ignition.wav"); + PRECACHE_SOUND("buttons/spark5.wav"); + PRECACHE_SOUND("buttons/spark6.wav"); + PRECACHE_SOUND("debris/glass1.wav"); + PRECACHE_SOUND("debris/glass2.wav"); + PRECACHE_SOUND("debris/glass3.wav"); + PRECACHE_SOUND("items/flashlight1.wav"); + PRECACHE_SOUND("items/flashlight1.wav"); + PRECACHE_SOUND("common/bodysplat.wav"); + PRECACHE_SOUND("player/pl_pain2.wav"); + PRECACHE_SOUND("player/pl_pain4.wav"); + PRECACHE_SOUND("player/pl_pain5.wav"); + PRECACHE_SOUND("player/pl_pain6.wav"); + PRECACHE_SOUND("player/pl_pain7.wav"); + + int numPlayerModels; + if (isCZero) + numPlayerModels = ARRAYSIZE(sPlayerModelFiles); + else + numPlayerModels = ARRAYSIZE(sPlayerModelFiles) - 2; + + for (i = 0; i < numPlayerModels; i++) + PRECACHE_MODEL(sPlayerModelFiles[i]); + + for (i = FirstCustomSkin; i <= LastCustomSkin; i++) + { + const char *fname = TheBotProfiles->GetCustomSkinFname(i); + + if (!fname) + break; + + PRECACHE_MODEL((char *)fname); + } + + PRECACHE_MODEL("models/p_ak47.mdl"); + PRECACHE_MODEL("models/p_aug.mdl"); + PRECACHE_MODEL("models/p_awp.mdl"); + PRECACHE_MODEL("models/p_c4.mdl"); + PRECACHE_MODEL("models/w_c4.mdl"); + PRECACHE_MODEL("models/p_deagle.mdl"); + PRECACHE_MODEL("models/shield/p_shield_deagle.mdl"); + PRECACHE_MODEL("models/p_flashbang.mdl"); + PRECACHE_MODEL("models/shield/p_shield_flashbang.mdl"); + PRECACHE_MODEL("models/p_hegrenade.mdl"); + PRECACHE_MODEL("models/shield/p_shield_hegrenade.mdl"); + PRECACHE_MODEL("models/p_glock18.mdl"); + PRECACHE_MODEL("models/shield/p_shield_glock18.mdl"); + PRECACHE_MODEL("models/p_p228.mdl"); + PRECACHE_MODEL("models/shield/p_shield_p228.mdl"); + PRECACHE_MODEL("models/p_smokegrenade.mdl"); + PRECACHE_MODEL("models/shield/p_shield_smokegrenade.mdl"); + PRECACHE_MODEL("models/p_usp.mdl"); + PRECACHE_MODEL("models/shield/p_shield_usp.mdl"); + PRECACHE_MODEL("models/p_fiveseven.mdl"); + PRECACHE_MODEL("models/shield/p_shield_fiveseven.mdl"); + PRECACHE_MODEL("models/p_knife.mdl"); + PRECACHE_MODEL("models/shield/p_shield_knife.mdl"); + PRECACHE_MODEL("models/w_flashbang.mdl"); + PRECACHE_MODEL("models/w_hegrenade.mdl"); + PRECACHE_MODEL("models/p_sg550.mdl"); + PRECACHE_MODEL("models/p_g3sg1.mdl"); + PRECACHE_MODEL("models/p_m249.mdl"); + PRECACHE_MODEL("models/p_m3.mdl"); + PRECACHE_MODEL("models/p_m4a1.mdl"); + PRECACHE_MODEL("models/p_mac10.mdl"); + PRECACHE_MODEL("models/p_mp5.mdl"); + PRECACHE_MODEL("models/p_ump45.mdl"); + PRECACHE_MODEL("models/p_p90.mdl"); + PRECACHE_MODEL("models/p_scout.mdl"); + PRECACHE_MODEL("models/p_sg552.mdl"); + PRECACHE_MODEL("models/w_smokegrenade.mdl"); + PRECACHE_MODEL("models/p_tmp.mdl"); + PRECACHE_MODEL("models/p_elite.mdl"); + PRECACHE_MODEL("models/p_xm1014.mdl"); + PRECACHE_MODEL("models/p_galil.mdl"); + PRECACHE_MODEL("models/p_famas.mdl"); + PRECACHE_MODEL("models/p_shield.mdl"); + PRECACHE_MODEL("models/w_shield.mdl"); + + Vector temp = g_vecZero; + Vector vMin = Vector(-38, -24, -41); + Vector vMax = Vector(38, 24, 41); + + for (i = 0; i < numPlayerModels; i++) + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, sPlayerModelFiles[i]); + + for (i = FirstCustomSkin; i <= LastCustomSkin; i++) + { + const char *fname = TheBotProfiles->GetCustomSkinFname(i); + + if (!fname) + break; + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds_if_avail, (float *)&vMin, (float *)&vMax, fname); + } + + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke1.spr"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke2.spr"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke3.spr"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/black_smoke4.spr"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/fast_wallpuff1.spr"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/smokepuff.spr"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/gas_puff_01.spr"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc.tga"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc_nw.tga"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc_ne.tga"); + ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc_sw.tga"); + + if (isCZero) + { + vMin = Vector(-13, -6, -22); + vMax = Vector(13, 6, 22); + } + else + { + vMin = Vector(-12, -6, -22); + vMax = Vector(12, 6, 22); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_deagle.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_p228.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_elite.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_usp.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_fiveseven.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_glock18.mdl"); + + if (isCZero) + { + vMin = Vector(-26, -19, -21); + vMax = Vector(26, 23, 21); + } + else + { + vMin = Vector(-25, -19, -21); + vMax = Vector(25, 23, 21); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_xm1014.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_m3.mdl"); + + if (isCZero) + { + vMin = Vector(-23, -9, -20); + vMax = Vector(23, 17, 20); + } + else + { + vMin = Vector(-23, -8, -20); + vMax = Vector(23, 8, 20); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_mac10.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_mp5.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_ump45.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_tmp.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_p90.mdl"); + + if (isCZero) + { + vMin = Vector(-38, -33, -22); + vMax = Vector(38, 15, 35); + } + else + { + vMin = Vector(-31, -8, -21); + vMax = Vector(31, 12, 31); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_ak47.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_aug.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_awp.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_g3sg1.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_sg550.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_m4a1.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_scout.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_sg552.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_famas.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_galil.mdl"); + + if (isCZero) + { + vMin = Vector(-30, -10, -20); + vMax = Vector(30, 11, 20); + } + else + { + vMin = Vector(-24, -10, -20); + vMax = Vector(25, 10, 20); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_m249.mdl"); + + vMin = Vector(-7, -7, -15); + vMax = Vector(7, 7, 15); + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_c4.mdl"); + + vMin = Vector(-4, -8, -3); + vMax = Vector(3, 7, 3); + + if (isCZero) + { + vMin = Vector(-17, -8, -3); + vMax = Vector(17, 7, 3); + } + else + { + vMin = Vector(-4, -8, -3); + vMax = Vector(3, 7, 3); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_c4.mdl"); + + if (isCZero) + { + vMin = Vector(-7, -3, -18); + vMax = Vector(7, 2, 18); + } + else + { + vMin = Vector(-7, -2, -18); + vMax = Vector(7, 2, 18); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_flashbang.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_hegrenade.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_smokegrenade.mdl"); + + if (isCZero) + vMin = Vector(-5, -5, -7); + else + vMin = Vector(-5, -5, -5); + + vMax = Vector(5, 5, 14); + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_flashbang.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_hegrenade.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_smokegrenade.mdl"); + + vMin = Vector(-7, -11, -18); + vMax = Vector(7, 6, 18); + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_knife.mdl"); + + if (isCZero) + { + vMin = Vector(-21, -25, -54); + vMax = Vector(21, 23, 24); + } + else + { + vMin = Vector(-16, -8, -54); + vMax = Vector(16, 6, 24); + } + + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_deagle.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_fiveseven.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_flashbang.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_glock18.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_hegrenade.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_knife.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_p228.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_smokegrenade.mdl"); + ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/shield/p_shield_usp.mdl"); + + PRECACHE_SOUND("common/wpn_hudoff.wav"); + PRECACHE_SOUND("common/wpn_hudon.wav"); + PRECACHE_SOUND("common/wpn_moveselect.wav"); + PRECACHE_SOUND("common/wpn_select.wav"); + PRECACHE_SOUND("common/wpn_denyselect.wav"); + PRECACHE_SOUND("player/geiger6.wav"); + PRECACHE_SOUND("player/geiger5.wav"); + PRECACHE_SOUND("player/geiger4.wav"); + PRECACHE_SOUND("player/geiger3.wav"); + PRECACHE_SOUND("player/geiger2.wav"); + PRECACHE_SOUND("player/geiger1.wav"); + + if (giPrecacheGrunt) + UTIL_PrecacheOther("enemy_terrorist"); + + g_iShadowSprite = PRECACHE_MODEL("sprites/shadow_circle.spr"); + + PRECACHE_MODEL("sprites/wall_puff1.spr"); + PRECACHE_MODEL("sprites/wall_puff2.spr"); + PRECACHE_MODEL("sprites/wall_puff3.spr"); + PRECACHE_MODEL("sprites/wall_puff4.spr"); + PRECACHE_MODEL("sprites/black_smoke1.spr"); + PRECACHE_MODEL("sprites/black_smoke2.spr"); + PRECACHE_MODEL("sprites/black_smoke3.spr"); + PRECACHE_MODEL("sprites/black_smoke4.spr"); + PRECACHE_MODEL("sprites/fast_wallpuff1.spr"); + PRECACHE_MODEL("sprites/pistol_smoke1.spr"); + PRECACHE_MODEL("sprites/pistol_smoke2.spr"); + PRECACHE_MODEL("sprites/rifle_smoke1.spr"); + PRECACHE_MODEL("sprites/rifle_smoke2.spr"); + PRECACHE_MODEL("sprites/rifle_smoke3.spr"); + PRECACHE_GENERIC("sprites/scope_arc.tga"); + PRECACHE_GENERIC("sprites/scope_arc_nw.tga"); + PRECACHE_GENERIC("sprites/scope_arc_ne.tga"); + PRECACHE_GENERIC("sprites/scope_arc_sw.tga"); + + m_usResetDecals = g_engfuncs.pfnPrecacheEvent(1, "events/decal_reset.sc"); +} + +/* <4a6e5> ../cstrike/dlls/client.cpp:4996 */ +const char *GetGameDescription(void) +{ + if (UTIL_IsGame("czero")) + return "Condition Zero"; + + return "Counter-Strike"; +} + +/* <4a703> ../cstrike/dlls/client.cpp:5022 */ +void Sys_Error(const char *error_string) +{ + ; +} + +/* <4a731> ../cstrike/dlls/client.cpp:5039 */ +void PlayerCustomization(edict_t *pEntity, customization_t *pCust) +{ + CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE(pEntity); + + if (!pPlayer) + { + ALERT(at_console, "PlayerCustomization: Couldn't get player!\n"); + return; + } + + if (!pCust) + { + ALERT(at_console, "PlayerCustomization: NULL customization!\n"); + return; + } + + switch (pCust->resource.type) + { + case t_decal: + pPlayer->SetCustomDecalFrames(pCust->nUserData2); + break; + case t_sound: + case t_skin: + case t_model: + break; + default: + ALERT(at_console, "PlayerCustomization: Unknown customization type!\n"); + break; + } +} + +/* <4a7b9> ../cstrike/dlls/client.cpp:5079 */ +void SpectatorConnect(edict_t *pEntity) +{ + CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE(pEntity); + + if (pPlayer) + { + pPlayer->SpectatorConnect(); + } +} + +/* <4a83d> ../cstrike/dlls/client.cpp:5095 */ +void SpectatorDisconnect(edict_t *pEntity) +{ + CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE(pEntity); + + if (pPlayer) + { + pPlayer->SpectatorDisconnect(); + } +} + +/* <4a8b5> ../cstrike/dlls/client.cpp:5111 */ +void SpectatorThink(edict_t *pEntity) +{ + CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE(pEntity); + + if (pPlayer) + { + pPlayer->SpectatorThink(); + } +} + +/* <4a92d> ../cstrike/dlls/client.cpp:5160 */ +void SetupVisibility(edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas) +{ + edict_t *pView = pClient; + + // Find the client's PVS + if (pViewEntity) + { + pView = pViewEntity; + } + + if (pClient->v.flags & FL_PROXY) + { + *pvs = NULL; // the spectator proxy sees + *pas = NULL; // and hears everything + return; + } + + CBasePlayer *pPlayer = reinterpret_cast(CBasePlayer::Instance(pClient)); + + if (pPlayer->pev->iuser2 && pPlayer->m_hObserverTarget) + { + if (pPlayer->m_afPhysicsFlags & PFLAG_OBSERVER) + { + pView = pPlayer->m_hObserverTarget->edict(); + UTIL_SetOrigin(pPlayer->pev, pPlayer->m_hObserverTarget->pev->origin); + } + } + + Vector org = pView->v.origin + pView->v.view_ofs; + + if (pView->v.flags & FL_DUCKING) + { + org = org + (VEC_HULL_MIN - VEC_DUCK_HULL_MIN); + } + + *pvs = ENGINE_SET_PVS((float *)&org); + *pas = ENGINE_SET_PAS((float *)&org); +} + +/* <4aa75> ../cstrike/dlls/client.cpp:5226 */ +void ResetPlayerPVS(edict_t *client, int clientnum) +{ + PLAYERPVSSTATUS *pvs = &g_PVSStatus[clientnum]; + + Q_memset(pvs, 0, sizeof(*pvs)); + pvs->headnode = client->headnode; + pvs->num_leafs = client->num_leafs; + Q_memcpy(pvs->leafnums, client->leafnums, sizeof(pvs->leafnums)); +} + +/* <4aae8> ../cstrike/dlls/client.cpp:5240 */ +bool CheckPlayerPVSLeafChanged(edict_t *client, int clientnum) +{ + PLAYERPVSSTATUS *pvs = &g_PVSStatus[clientnum]; + if (pvs->headnode != client->headnode || pvs->num_leafs != client->num_leafs) + return true; + + for (int i = 0; i < pvs->num_leafs; i++) + { + if (client->leafnums[i] != pvs->leafnums[i]) + return true; + } + return false; +} + +/* <475e3> ../cstrike/dlls/client.cpp:5263 */ +void MarkEntityInPVS(int clientnum, int entitynum, float time, bool inpvs) +{ + PLAYERPVSSTATUS *pvs; + ENTITYPVSSTATUS *es; + + pvs = &g_PVSStatus[clientnum]; + es = &pvs->m_Status[entitynum]; + + if (inpvs) + es->m_fTimeEnteredPVS = time; + else + es->m_fTimeEnteredPVS = 0; +} + +/* <47581> ../cstrike/dlls/client.cpp:5275 */ +bool CheckEntityRecentlyInPVS(int clientnum, int entitynum, float currenttime) +{ + PLAYERPVSSTATUS *pvs; + ENTITYPVSSTATUS *es; + + pvs = &g_PVSStatus[clientnum]; + es = &pvs->m_Status[entitynum]; + + if (es->m_fTimeEnteredPVS && es->m_fTimeEnteredPVS + 1.0f >= currenttime) + { + return true; + } + + return false; +} + +/* <4ac57> ../cstrike/dlls/client.cpp:5312 */ +int AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet) +{ + if ((ent->v.effects & EF_NODRAW) == EF_NODRAW && ent != host) + return 0; + + if (!ent->v.modelindex || !STRING(ent->v.model)) + return 0; + + if ((ent->v.flags & FL_SPECTATOR) == FL_SPECTATOR && ent != host) + return 0; + + int i; + int hostnum = ENTINDEX(host) - 1; + + if (CheckPlayerPVSLeafChanged(host, hostnum)) + ResetPlayerPVS(host, hostnum); + + if (ent != host) + { + if (!CheckEntityRecentlyInPVS(hostnum, e, gpGlobals->time)) + { + if (!ENGINE_CHECK_VISIBILITY(ent, pSet)) + { + MarkEntityInPVS(hostnum, e, 0, false); + return 0; + } + + MarkEntityInPVS(hostnum, e, gpGlobals->time, true); + } + } + + if ((ent->v.flags & FL_SKIPLOCALHOST) == FL_SKIPLOCALHOST && (hostflags & 1) && ent->v.owner == host) + return 0; + + if (host->v.groupinfo) + { + UTIL_SetGroupTrace(host->v.groupinfo, GROUP_OP_AND); + + if (ent->v.groupinfo) + { + if (g_groupop == GROUP_OP_AND) + { + if (!(ent->v.groupinfo & host->v.groupinfo)) + return 0; + } + else if (g_groupop == GROUP_OP_NAND) + { + if (ent->v.groupinfo & host->v.groupinfo) + return 0; + } + } + + UTIL_UnsetGroupTrace(); + } + + Q_memset(state, 0, sizeof(*state)); + + state->number = e; + state->entityType = ENTITY_NORMAL; + + if (ent->v.flags & FL_CUSTOMENTITY) + state->entityType = ENTITY_BEAM; + + state->animtime = (int)(1000.0 * ent->v.animtime) / 1000.0; + + Q_memcpy(state->origin, ent->v.origin, sizeof(float) * 3); + Q_memcpy(state->angles, ent->v.angles, sizeof(float) * 3); + Q_memcpy(state->mins, ent->v.mins, sizeof(float) * 3); + Q_memcpy(state->maxs, ent->v.maxs, sizeof(float) * 3); + Q_memcpy(state->startpos, ent->v.startpos, sizeof(float) * 3); + Q_memcpy(state->endpos, ent->v.endpos, sizeof(float) * 3); + + state->impacttime = ent->v.impacttime; + state->starttime = ent->v.starttime; + state->modelindex = ent->v.modelindex; + state->frame = ent->v.frame; + state->skin = ent->v.skin; + state->effects = ent->v.effects; + + if (!player && ent->v.animtime && !ent->v.velocity.x && !ent->v.velocity.y && !ent->v.velocity.z) + state->eflags |= EFLAG_SLERP; + + state->scale = ent->v.scale; + state->solid = ent->v.solid; + state->colormap = ent->v.colormap; + state->movetype = ent->v.movetype; + state->sequence = ent->v.sequence; + state->framerate = ent->v.framerate; + state->body = ent->v.body; + + for (i = 0; i < 4; i++) + state->controller[i] = ent->v.controller[i]; + + for (i = 0; i < 2; i++) + state->blending[i] = ent->v.blending[i]; + + state->rendermode = ent->v.rendermode; + state->renderamt = (int)ent->v.renderamt; + state->renderfx = ent->v.renderfx; + state->rendercolor.r = (byte)ent->v.rendercolor.x; + state->rendercolor.g = (byte)ent->v.rendercolor.y; + state->rendercolor.b = (byte)ent->v.rendercolor.z; + + state->aiment = 0; + + if (ent->v.aiment) + state->aiment = ENTINDEX(ent->v.aiment); + + state->owner = 0; + if (ent->v.owner) + { + int owner = ENTINDEX(ent->v.owner); + + if (owner >= 1 && owner <= gpGlobals->maxClients) + state->owner = owner; + } + + if (player) + { + Q_memcpy(state->basevelocity, ent->v.basevelocity, sizeof(float) * 3); + + state->weaponmodel = MODEL_INDEX(STRING(ent->v.weaponmodel)); + state->gaitsequence = ent->v.gaitsequence; + + state->spectator = (ent->v.flags & FL_SPECTATOR) ? TRUE : FALSE; + state->friction = ent->v.friction; + state->gravity = ent->v.gravity; + state->usehull = (ent->v.flags & FL_DUCKING) ? 1 : 0; + state->health = (int)ent->v.health; + } + else + state->playerclass = ent->v.playerclass; + + state->iuser4 = ent->v.iuser4; + return 1; +} + +// Creates baselines used for network encoding, especially for player data since players are not spawned until connect time. + +/* <4aef3> ../cstrike/dlls/client.cpp:5516 */ +void CreateBaseline(int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, Vector player_mins, Vector player_maxs) +{ + baseline->origin = entity->v.origin; + baseline->angles = entity->v.angles; + + baseline->frame = entity->v.frame; + baseline->skin = (short)entity->v.skin; + + // render information + baseline->rendermode = (byte)entity->v.rendermode; + baseline->renderamt = (byte)entity->v.renderamt; + baseline->rendercolor.r = (byte)entity->v.rendercolor.x; + baseline->rendercolor.g = (byte)entity->v.rendercolor.y; + baseline->rendercolor.b = (byte)entity->v.rendercolor.z; + baseline->renderfx = (byte)entity->v.renderfx; + + if (player) + { + baseline->mins = player_mins; + baseline->maxs = player_maxs; + + baseline->colormap = eindex; + baseline->modelindex = playermodelindex; + baseline->friction = 1.0; + baseline->movetype = MOVETYPE_WALK; + + baseline->solid = SOLID_SLIDEBOX; + baseline->scale = entity->v.scale; + baseline->framerate = 1.0; + baseline->gravity = 1.0; + } + else + { + baseline->mins = entity->v.mins; + baseline->maxs = entity->v.maxs; + + baseline->colormap = 0; + baseline->modelindex = entity->v.modelindex; + baseline->movetype = entity->v.movetype; + + baseline->scale = entity->v.scale; + baseline->solid = entity->v.solid; + baseline->framerate = entity->v.framerate; + baseline->gravity = entity->v.gravity; + } +} + +/* <47d8a> ../cstrike/dlls/client.cpp:5586 */ +void Entity_FieldInit(struct delta_s *pFields) +{ + entity_field_alias[ FIELD_ORIGIN0 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ORIGIN0 ].name); + entity_field_alias[ FIELD_ORIGIN1 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ORIGIN1 ].name); + entity_field_alias[ FIELD_ORIGIN2 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ORIGIN2 ].name); + entity_field_alias[ FIELD_ANGLES0 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ANGLES0 ].name); + entity_field_alias[ FIELD_ANGLES1 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ANGLES1 ].name); + entity_field_alias[ FIELD_ANGLES2 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ANGLES2 ].name); +} + +// Callback for sending entity_state_t info over network. + +/* <47da7> ../cstrike/dlls/client.cpp:5604 */ +void Entity_Encode(struct delta_s *pFields, const unsigned char *from, const unsigned char *to) +{ + entity_state_t *f, *t; + int localplayer = 0; + static int initialized = 0; + + if (!initialized) + { + Entity_FieldInit(pFields); + initialized = 1; + } + + f = (entity_state_t *)from; + t = (entity_state_t *)to; + + // Never send origin to local player, it's sent with more resolution in clientdata_t structure + localplayer = (t->number - 1) == ENGINE_CURRENT_PLAYER(); + + if (localplayer) + { + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); + } + if (t->impacttime != 0 && t->starttime != 0) + { + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); + + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ANGLES0 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ANGLES1 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ANGLES2 ].field); + } + if (t->movetype == MOVETYPE_FOLLOW && t->aiment != 0) + { + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); + } + else if (t->aiment != f->aiment) + { + DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); + DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); + DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); + } +} + +/* <47cb4> ../cstrike/dlls/client.cpp:5662 */ +void Player_FieldInit(struct delta_s *pFields) +{ + player_field_alias[ FIELD_ORIGIN0 ].field = DELTA_FINDFIELD(pFields, player_field_alias[ FIELD_ORIGIN0 ].name); + player_field_alias[ FIELD_ORIGIN1 ].field = DELTA_FINDFIELD(pFields, player_field_alias[ FIELD_ORIGIN1 ].name); + player_field_alias[ FIELD_ORIGIN2 ].field = DELTA_FINDFIELD(pFields, player_field_alias[ FIELD_ORIGIN2 ].name); +} + +// Callback for sending entity_state_t for players info over network. + +/* <47cd1> ../cstrike/dlls/client.cpp:5676 */ +void Player_Encode(struct delta_s *pFields, const unsigned char *from, const unsigned char *to) +{ + entity_state_t *f, *t; + int localplayer = 0; + + static int initialized = 0; + if (!initialized) + { + Player_FieldInit(pFields); + initialized = 1; + } + + f = (entity_state_t *)from; + t = (entity_state_t *)to; + + // Never send origin to local player, it's sent with more resolution in clientdata_t structure + localplayer = (t->number - 1) == ENGINE_CURRENT_PLAYER(); + + if (localplayer) + { + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); + } + if (t->movetype == MOVETYPE_FOLLOW && t->aiment != 0) + { + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); + DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); + } + else if (t->aiment != f->aiment) + { + DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); + DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); + DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); + } +} + +/* <4afc4> ../cstrike/dlls/client.cpp:5738 */ +void Custom_Entity_FieldInit(delta_s *pFields) +{ + custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].name); + custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].name); + custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].name); + custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].name); + custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].name); + custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].name); + custom_entity_field_alias[ CUSTOMFIELD_SKIN ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_SKIN ].name); + custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].name); + custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].name); +} + +// Callback for sending entity_state_t info ( for custom entities ) over network. + +/* <4aff3> ../cstrike/dlls/client.cpp:5759 */ +void Custom_Encode(struct delta_s *pFields, const unsigned char *from, const unsigned char *to) +{ + entity_state_t *f, *t; + int beamType; + static int initialized = 0; + + if (!initialized) + { + Custom_Entity_FieldInit(pFields); + initialized = 1; + } + + f = (entity_state_t *)from; + t = (entity_state_t *)to; + + beamType = t->rendermode & 0x0F; + + if (beamType != BEAM_POINTS) + { + if (beamType != BEAM_ENTPOINT) + { + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].field); + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].field); + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].field); + } + + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].field); + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].field); + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].field); + } + + if (beamType != BEAM_ENTS && beamType != BEAM_ENTPOINT) + { + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_SKIN ].field); + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].field); + } + + // animtime is compared by rounding first + // see if we really shouldn't actually send it + + if ((int)f->animtime == (int)t->animtime) + { + DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].field); + } +} + +/* <4b08a> ../cstrike/dlls/client.cpp:5811 */ +void RegisterEncoders(void) +{ + DELTA_ADDENCODER("Entity_Encode", Entity_Encode); + DELTA_ADDENCODER("Custom_Encode", Custom_Encode); + DELTA_ADDENCODER("Player_Encode", Player_Encode); +} + +/* <4b0a4> ../cstrike/dlls/client.cpp:5818 */ +int GetWeaponData(edict_s *player, struct weapon_data_s *info) +{ + entvars_t *pev = &player->v; + CBasePlayer *pl = reinterpret_cast(CBasePlayer::Instance(pev)); + + Q_memset(info, 0, sizeof(weapon_data_t) * MAX_WEAPONS); + + if (!pl) + { + return 1; + } + + for (int i = 0; i < MAX_ITEM_TYPES; i++) + { + CBasePlayerItem *pPlayerItem = pl->m_rgpPlayerItems[i]; + + while (pPlayerItem != NULL) + { + CBasePlayerWeapon *gun = reinterpret_cast(pPlayerItem->GetWeaponPtr()); + + if (gun && gun->UseDecrement()) + { + ItemInfo II; + Q_memset(&II, 0, sizeof(II)); + gun->GetItemInfo(&II); + + if (II.iId >= 0 && II.iId < MAX_WEAPONS) + { + weapon_data_t *item = &info[II.iId]; + + item->m_iId = II.iId; + item->m_iClip = gun->m_iClip; + item->m_flTimeWeaponIdle = Q_max(gun->m_flTimeWeaponIdle, -0.001f); + item->m_flNextPrimaryAttack = Q_max(gun->m_flNextPrimaryAttack, -0.001f); + item->m_flNextSecondaryAttack = Q_max(gun->m_flNextSecondaryAttack, -0.001f); + item->m_flNextReload = Q_max(gun->m_flNextReload, -0.001f); + item->m_fInReload = gun->m_fInReload; + item->m_fInSpecialReload = gun->m_fInSpecialReload; + item->m_fInZoom = gun->m_iShotsFired; + item->m_fAimedDamage = gun->m_flLastFire; + item->m_iWeaponState = gun->m_iWeaponState; + item->fuser2 = gun->m_flStartThrow; + item->fuser3 = gun->m_flReleaseThrow; + item->iuser1 = gun->m_iSwing; + } + } + + pPlayerItem = pPlayerItem->m_pNext; + } + } + + return 1; +} + +/* <4b1fd> ../cstrike/dlls/client.cpp:5889 */ +void UpdateClientData(const struct edict_s *ent, int sendweapons, struct clientdata_s *cd) +{ + if (!ent || !ent->pvPrivateData) + { + return; + } + + entvars_t *pevOrg = NULL; + entvars_t *pev = (entvars_t *)&ent->v; + CBasePlayer *pl = reinterpret_cast(CBasePlayer::Instance(pev)); + + if (pl->pev->iuser1 == OBS_IN_EYE && pl->m_hObserverTarget) + { + pevOrg = pev; + pev = pl->m_hObserverTarget->pev; + pl = reinterpret_cast(CBasePlayer::Instance(pev)); + } + + cd->flags = pev->flags; + cd->health = pev->health; + cd->viewmodel = MODEL_INDEX(STRING(pev->viewmodel)); + cd->waterlevel = pev->waterlevel; + cd->watertype = pev->watertype; + cd->weapons = pev->weapons; + cd->origin = pev->origin; + cd->velocity = pev->velocity; + cd->view_ofs = pev->view_ofs; + cd->punchangle = pev->punchangle; + cd->bInDuck = pev->bInDuck; + cd->flTimeStepSound = pev->flTimeStepSound; + cd->flDuckTime = pev->flDuckTime; + cd->flSwimTime = pev->flSwimTime; + cd->waterjumptime = (int)pev->teleport_time; + + Q_strcpy(cd->physinfo, ENGINE_GETPHYSINFO(ent)); + + cd->maxspeed = pev->maxspeed; + cd->fov = pev->fov; + cd->weaponanim = pev->weaponanim; + cd->pushmsec = pev->pushmsec; + + if (pevOrg) + { + cd->iuser1 = pevOrg->iuser1; + cd->iuser2 = pevOrg->iuser2; + cd->iuser3 = pevOrg->iuser3; + } + else + { + cd->iuser1 = pev->iuser1; + cd->iuser2 = pev->iuser2; + cd->iuser3 = pev->iuser3; + } + + cd->fuser1 = pev->fuser1; + cd->fuser3 = pev->fuser3; + cd->fuser2 = pev->fuser2; + + if (sendweapons && pl != NULL) + { + cd->ammo_shells = pl->ammo_buckshot; + cd->ammo_nails = pl->ammo_9mm; + cd->ammo_cells = pl->ammo_556nato; + cd->ammo_rockets = pl->ammo_556natobox; + cd->vuser2.x = pl->ammo_762nato; + cd->vuser2.y = pl->ammo_45acp; + cd->vuser2.z = pl->ammo_50ae; + cd->vuser3.x = pl->ammo_338mag; + cd->vuser3.y = pl->ammo_57mm; + cd->vuser3.z = pl->ammo_357sig; + cd->m_flNextAttack = pl->m_flNextAttack; + + int iUser3 = 0; + if (pl->m_bCanShoot && !pl->m_bIsDefusing) + iUser3 |= DATA_IUSER3_CANSHOOT; + + if (g_pGameRules->IsFreezePeriod()) + iUser3 |= DATA_IUSER3_FREEZETIMEOVER; + else + iUser3 &= ~DATA_IUSER3_FREEZETIMEOVER; + + if (pl->m_signals.GetState() & SIGNAL_BOMB) + iUser3 |= DATA_IUSER3_INBOMBZONE; + else + iUser3 &= ~DATA_IUSER3_INBOMBZONE; + + if (pl->HasShield()) + iUser3 |= DATA_IUSER3_HOLDINGSHIELD; + else + iUser3 &= ~DATA_IUSER3_HOLDINGSHIELD; + + if (!pl->pev->iuser1 && !pevOrg) + cd->iuser3 = iUser3; + + if (pl->m_pActiveItem != NULL) + { + ItemInfo II; + Q_memset(&II, 0, sizeof(II)); + + CBasePlayerWeapon *gun = reinterpret_cast(pl->m_pActiveItem->GetWeaponPtr()); + + if (gun != NULL && gun->UseDecrement() && gun->GetItemInfo(&II)) + { + cd->m_iId = II.iId; + + if ((unsigned int)gun->m_iPrimaryAmmoType < MAX_AMMO_TYPES) + { + cd->vuser4.x = gun->m_iPrimaryAmmoType; + cd->vuser4.y = pl->m_rgAmmo[ gun->m_iPrimaryAmmoType ]; + } + else + { + cd->vuser4.x = -1.0; + cd->vuser4.y = 0; + } + } + } + } +} + +/* <4b3ee> ../cstrike/dlls/client.cpp:6050 */ +void CmdStart(const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed) +{ + entvars_t *pev = (entvars_t *)&player->v; + CBasePlayer *pl = reinterpret_cast(CBasePlayer::Instance(pev)); + + if (!pl) + { + return; + } + + if (pl->pev->groupinfo) + { + UTIL_SetGroupTrace(pl->pev->groupinfo, GROUP_OP_AND); + } + + pl->random_seed = random_seed; +} + +/* <4b4eb> ../cstrike/dlls/client.cpp:6074 */ +void CmdEnd(const edict_t *player) +{ + entvars_t *pev = (entvars_t *)&player->v; + CBasePlayer *pl = reinterpret_cast(CBasePlayer::Instance(pev)); + + if (!pl) + return; + + if (pl->pev->groupinfo) + UTIL_UnsetGroupTrace(); + + if (pev->flags & FL_DUCKING) + UTIL_SetSize(pev, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX); +} + +/* <4b644> ../cstrike/dlls/client.cpp:6101 */ +int ConnectionlessPacket(const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size) +{ + // Parse stuff from args + int max_buffer_size = *response_buffer_size; + + // Zero it out since we aren't going to respond. + // If we wanted to response, we'd write data into response_buffer + *response_buffer_size = 0; + + // Since we don't listen for anything here, just respond that it's a bogus message + // If we didn't reject the message, we'd return 1 for success instead. + return 0; +} + +/* <4b6c2> ../cstrike/dlls/client.cpp:6122 */ +int GetHullBounds(int hullnumber, float *mins, float *maxs) +{ + return hullnumber < 3; +} + +// Create pseudo-baselines for items that aren't placed in the map at spawn time, but which are likely +// to be created during play ( e.g., grenades, ammo packs, projectiles, corpses, etc. ) + +/* <4b733> ../cstrike/dlls/client.cpp:6156 */ +void CreateInstancedBaselines(void) +{ + int iret = 0; + entity_state_t state; + + Q_memset(&state, 0, sizeof(state)); + + // Create any additional baselines here for things like grendates, etc. + // iret = ENGINE_INSTANCE_BASELINE(pc->pev->classname, &state); + + // Destroy objects. + // UTIL_Remove(pc); +} + +/* <4b77c> ../cstrike/dlls/client.cpp:6179 */ +int InconsistentFile(const edict_t *player, const char *filename, char *disconnect_message) +{ + // Server doesn't care? + if (CVAR_GET_FLOAT("mp_consistency") != 1) + return 0; + + // Default behavior is to kick the player + Q_sprintf(disconnect_message, "Server is enforcing file consistency for %s\n", filename); + + // Kick now with specified disconnect message. + return 1; +} + +// The game .dll should return 1 if lag compensation should be allowed ( could also just set +// the sv_unlag cvar. +// Most games right now should return 0, until client-side weapon prediction code is written +// and tested for them ( note you can predict weapons, but not do lag compensation, too, +// if you want. + +/* <4b7cf> ../cstrike/dlls/client.cpp:6204 */ +int AllowLagCompensation(void) +{ + return 1; +} diff --git a/regamedll/dlls/gamerules.h b/regamedll/dlls/gamerules.h index 89d6f1e8..6764b651 100644 --- a/regamedll/dlls/gamerules.h +++ b/regamedll/dlls/gamerules.h @@ -34,34 +34,34 @@ #include "game_shared/voice_gamemgr.h" -#define COM_TOKEN_LEN 1500 +#define COM_TOKEN_LEN 1500 -#define MAX_RULE_BUFFER 1024 -#define MAX_VOTE_MAPS 100 -#define MAX_VIP_QUEUES 5 +#define MAX_RULE_BUFFER 1024 +#define MAX_VOTE_MAPS 100 +#define MAX_VIP_QUEUES 5 -#define MAX_BOMB_RADIUS 2048 +#define MAX_BOMB_RADIUS 2048 -#define MAP_VIP_SAFETYZONE_INIT 0 // initial -#define MAP_HAVE_VIP_SAFETYZONE_YES 1 // on map have of vip safety zone -#define MAP_HAVE_VIP_SAFETYZONE_NO 2 // there is no safety zone +#define MAP_VIP_SAFETYZONE_UNINITIALIZED 0 // uninitialized +#define MAP_HAVE_VIP_SAFETYZONE_YES 1 // has VIP safety zone +#define MAP_HAVE_VIP_SAFETYZONE_NO 2 // does not have VIP safetyzone -#define MAP_HAS_CAMERAS_INIT 2 // initial -#define MAP_HAS_CAMERAS_YES 1 // on map have of camera's +#define MAP_HAS_CAMERAS_INIT 2 // initial +#define MAP_HAS_CAMERAS_YES 1 // on map have of camera's -#define ITEM_RESPAWN_TIME 30 -#define WEAPON_RESPAWN_TIME 20 -#define AMMO_RESPAWN_TIME 20 +#define ITEM_RESPAWN_TIME 30 +#define WEAPON_RESPAWN_TIME 20 +#define AMMO_RESPAWN_TIME 20 // longest the intermission can last, in seconds -#define MAX_INTERMISSION_TIME 120 +#define MAX_INTERMISSION_TIME 120 // when we are within this close to running out of entities, items // marked with the ITEM_FLAG_LIMITINWORLD will delay their respawn -#define ENTITY_INTOLERANCE 100 +#define ENTITY_INTOLERANCE 100 -#define MAX_MOTD_CHUNK 60 -#define MAX_MOTD_LENGTH 1536 // (MAX_MOTD_CHUNK * 4) +#define MAX_MOTD_CHUNK 60 +#define MAX_MOTD_LENGTH 1536 // (MAX_MOTD_CHUNK * 4) // custom enum enum @@ -72,6 +72,7 @@ enum }; // custom enum +// used for EndRoundMessage() logged messages enum ScenarionEventEndRound { ROUND_TARGET_BOMB = 1, @@ -272,6 +273,8 @@ public: } virtual BOOL FAllowMonsters(void) = 0; virtual void EndMultiplayerGame(void) {}; + + // Stuff that is shared between client and server. virtual BOOL IsFreezePeriod(void) { return IsFreezePeriod_(); @@ -489,6 +492,8 @@ public: virtual void ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer); virtual int IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled); virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor); + + // Death notices virtual void DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor); virtual BOOL CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon); virtual void PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon); @@ -525,7 +530,12 @@ public: } virtual void ServerDeactivate(void); virtual void CheckMapConditions(void); + + // Recreate all the map entities from the map data (preserving their indices), + // then remove everything else except the players. + // Also get rid of all world decals. virtual void CleanUpMap(void); + virtual void RestartRound(void); virtual void CheckWinConditions(void); virtual void RemoveGuns(void); @@ -608,6 +618,36 @@ public: #endif // HOOK_GAMEDLL public: + // Checks if it still needs players to start a round, or if it has enough players to start rounds. + // Starts a round and returns true if there are enough players. + bool NeededPlayersCheck(bool &bNeededPlayers); + + // Setup counts for m_iNumTerrorist, m_iNumCT, m_iNumSpawnableTerrorist, m_iNumSpawnableCT, etc. + void InitializePlayerCounts(int &NumAliveTerrorist, int &NumAliveCT, int &NumDeadTerrorist, int &NumDeadCT); + + // Check to see if the round is over for the various game types. Terminates the round + // and returns true if the round should end. + bool PrisonRoundEndCheck(int NumAliveTerrorist, int NumAliveCT, int NumDeadTerrorist, int NumDeadCT, bool bNeededPlayers); + bool BombRoundEndCheck(bool bNeededPlayers); + bool HostageRescueRoundEndCheck(bool bNeededPlayers); + bool VIPRoundEndCheck(bool bNeededPlayers); + + // Check to see if the teams exterminated each other. Ends the round and returns true if so. + bool TeamExterminationCheck(int NumAliveTerrorist, int NumAliveCT, int NumDeadTerrorist, int NumDeadCT, bool bNeededPlayers); + void TerminateRound(float tmDelay, int iWinStatus); + + // Check various conditions to end the map. + bool CheckGameOver(void); + bool CheckTimeLimit(void); + bool CheckMaxRounds(void); + bool CheckWinLimit(void); + + void CheckFreezePeriodExpired(void); + void CheckRoundTimeExpired(void); + + void CheckLevelInitialized(void); + void CheckRestartRound(void); + BOOL IsCareer(void); void QueueCareerRoundEndMenu(float tmDelay, int iWinStatus); void SetCareerMatchLimit(int minWins, int winDifference); @@ -633,17 +673,23 @@ public: BOOL TeamStacked(int newTeam_id, int curTeam_id); bool IsVIPQueueEmpty(void); bool AddToVIPQueue(CBasePlayer *toAdd); + + // VIP FUNCTIONS void PickNextVIP(void); void StackVIPQueue(void); void ResetCurrentVIP(void); + void BalanceTeams(void); void SwapAllPlayers(void); void UpdateTeamScores(void); void DisplayMaps(CBasePlayer *player, int iVote); void ResetAllMapVotes(void); void ProcessMapVote(CBasePlayer *player, int iVote); + + // BOMB MAP FUNCTIONS BOOL IsThereABomber(void); BOOL IsThereABomb(void); + bool IsMatchStarted(void) { return (m_fTeamCount != 0.0f || m_fCareerRoundMenuTime != 0.0f || m_fCareerMatchMenuTime != 0.0f); @@ -657,57 +703,64 @@ private: public: CVoiceGameMgr m_VoiceGameMgr; - float m_fTeamCount; + float m_fTeamCount; // m_flRestartRoundTime, the global time when the round is supposed to end, if this is not 0 float m_flCheckWinConditions; float m_fRoundCount; - int m_iRoundTime; + int m_iRoundTime; // (From mp_roundtime) - How many seconds long this round is. int m_iRoundTimeSecs; - int m_iIntroRoundTime; - float m_fIntroRoundCount; + int m_iIntroRoundTime; // (From mp_freezetime) - How many seconds long the intro round (when players are frozen) is. + float m_fIntroRoundCount; // The global time when the intro round ends and the real one starts + // wrote the original "m_flRoundTime" comment for this variable). int m_iAccountTerrorist; int m_iAccountCT; - int m_iNumTerrorist; - int m_iNumCT; + int m_iNumTerrorist; // The number of terrorists on the team (this is generated at the end of a round) + int m_iNumCT; // The number of CTs on the team (this is generated at the end of a round) int m_iNumSpawnableTerrorist; int m_iNumSpawnableCT; - int m_iSpawnPointCount_Terrorist; - int m_iSpawnPointCount_CT; + int m_iSpawnPointCount_Terrorist; // Number of Terrorist spawn points + int m_iSpawnPointCount_CT; // Number of CT spawn points int m_iHostagesRescued; int m_iHostagesTouched; - int m_iRoundWinStatus; + int m_iRoundWinStatus; // 1 == CT's won last round, 2 == Terrorists did, 3 == Draw, no winner + short m_iNumCTWins; short m_iNumTerroristWins; - bool m_bTargetBombed; - bool m_bBombDefused; + + bool m_bTargetBombed; // whether or not the bomb has been bombed + bool m_bBombDefused; // whether or not the bomb has been defused + bool m_bMapHasBombTarget; bool m_bMapHasBombZone; bool m_bMapHasBuyZone; bool m_bMapHasRescueZone; bool m_bMapHasEscapeZone; - int m_iMapHasVIPSafetyZone; + + int m_iMapHasVIPSafetyZone; // 0 = uninitialized; 1 = has VIP safety zone; 2 = DOES not have VIP safetyzone int m_bMapHasCameras; int m_iC4Timer; - int m_iC4Guy; - int m_iLoserBonus; - int m_iNumConsecutiveCTLoses; - int m_iNumConsecutiveTerroristLoses; - float m_fMaxIdlePeriod; + int m_iC4Guy; // The current Terrorist who has the C4. + int m_iLoserBonus; // the amount of money the losing team gets. This scales up as they lose more rounds in a row + int m_iNumConsecutiveCTLoses; // the number of rounds the CTs have lost in a row. + int m_iNumConsecutiveTerroristLoses; // the number of rounds the Terrorists have lost in a row. + + float m_fMaxIdlePeriod; // For the idle kick functionality. This is tha max amount of time that the player has to be idle before being kicked + int m_iLimitTeams; bool m_bLevelInitialized; bool m_bRoundTerminating; - bool m_bCompleteReset; + bool m_bCompleteReset; // Set to TRUE to have the scores reset next time round restarts float m_flRequiredEscapeRatio; int m_iNumEscapers; int m_iHaveEscaped; bool m_bCTCantBuy; - bool m_bTCantBuy; + bool m_bTCantBuy; // Who can and can't buy. float m_flBombRadius; int m_iConsecutiveVIP; int m_iTotalGunCount; int m_iTotalGrenadeCount; int m_iTotalArmourCount; - int m_iUnBalancedRounds; - int m_iNumEscapeRounds; + int m_iUnBalancedRounds; // keeps track of the # of consecutive rounds that have gone by where one team outnumbers the other team by more than 2 + int m_iNumEscapeRounds; // keeps track of the # of consecutive rounds of escape played.. Teams will be swapped after 8 rounds int m_iMapVotes[ MAX_VOTE_MAPS ]; int m_iLastPick; int m_iMaxMapTime; diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 28eeeffc..25b60b6e 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -298,7 +298,7 @@ void EndRoundMessage(const char *sentence, int event) { CHalfLifeMultiplay *mp = g_pGameRules; char *team = NULL; - const char *message = &sentence[1]; + const char *message = &(sentence[1]); int teamTriggered = 1; UTIL_ClientPrintAll(HUD_PRINTCENTER, sentence); @@ -312,6 +312,7 @@ void EndRoundMessage(const char *sentence, int event) case ROUND_HOSTAGE_NOT_RESCUED: case ROUND_VIP_NOT_ESCAPED: team = GetTeam(TERRORIST); + // tell bots the terrorists won the round TheBots->OnEvent(EVENT_TERRORISTS_WIN); break; case ROUND_VIP_ESCAPED: @@ -323,10 +324,12 @@ void EndRoundMessage(const char *sentence, int event) case ROUND_TARGET_SAVED: case ROUND_TERRORISTS_NOT_ESCAPED: team = GetTeam(CT); + // tell bots the CTs won the round TheBots->OnEvent(EVENT_CTS_WIN); break; default: teamTriggered = false; + // tell bots the round was a draw TheBots->OnEvent(EVENT_ROUND_DRAW); break; } @@ -652,92 +655,113 @@ void CHalfLifeMultiplay::UpdateTeamScores(void) /* <113aee> ../cstrike/dlls/multiplay_gamerules.cpp:747 */ void CHalfLifeMultiplay::__MAKE_VHOOK(CleanUpMap)(void) { - CBaseEntity *torestart; - CBaseEntity *toremove; - int icount; + // Recreate all the map entities from the map data (preserving their indices), + // then remove everything else except the players. - for (torestart = UTIL_FindEntityByClassname(NULL, "cycler_sprite"); - torestart != NULL; torestart = UTIL_FindEntityByClassname(torestart, "cycler_sprite")) + CBaseEntity *torestart = NULL; + CBaseEntity *toremove = NULL; + + torestart = UTIL_FindEntityByClassname(NULL, "cycler_sprite"); + while (torestart != NULL) { torestart->Restart(); + torestart = UTIL_FindEntityByClassname(torestart, "cycler_sprite"); } - for (torestart = UTIL_FindEntityByClassname(NULL, "light"); - torestart != NULL; torestart = UTIL_FindEntityByClassname(torestart, "light")) + torestart = UTIL_FindEntityByClassname(NULL, "light"); + while (torestart != NULL) { torestart->Restart(); + torestart = UTIL_FindEntityByClassname(torestart, "light"); } - for (torestart = UTIL_FindEntityByClassname(NULL, "func_breakable"); - torestart != NULL; torestart = UTIL_FindEntityByClassname(torestart, "func_breakable")) + torestart = UTIL_FindEntityByClassname(NULL, "func_breakable"); + while (torestart != NULL) { torestart->Restart(); + torestart = UTIL_FindEntityByClassname(torestart, "func_breakable"); } - for (torestart = UTIL_FindEntityByClassname(NULL, "func_door"); - torestart != NULL; torestart = UTIL_FindEntityByClassname(torestart, "func_door")) + torestart = UTIL_FindEntityByClassname(NULL, "func_door"); + while (torestart != NULL) { torestart->Restart(); + torestart = UTIL_FindEntityByClassname(torestart, "func_door"); } - for (torestart = UTIL_FindEntityByClassname(NULL, "func_water"); - torestart != NULL; torestart = UTIL_FindEntityByClassname(torestart, "func_water")) + torestart = UTIL_FindEntityByClassname(NULL, "func_water"); + while (torestart != NULL) { torestart->Restart(); + torestart = UTIL_FindEntityByClassname(torestart, "func_water"); } - for (torestart = UTIL_FindEntityByClassname(NULL, "func_door_rotating"); - torestart != NULL; torestart = UTIL_FindEntityByClassname(torestart, "func_door_rotating")) + torestart = UTIL_FindEntityByClassname(NULL, "func_door_rotating"); + while (torestart != NULL) { torestart->Restart(); + torestart = UTIL_FindEntityByClassname(torestart, "func_door_rotating"); } - for (torestart = UTIL_FindEntityByClassname(NULL, "func_tracktrain"); - torestart != NULL; torestart = UTIL_FindEntityByClassname(torestart, "func_tracktrain")) + torestart = UTIL_FindEntityByClassname(NULL, "func_tracktrain"); + while (torestart != NULL) { torestart->Restart(); + torestart = UTIL_FindEntityByClassname(torestart, "func_tracktrain"); } - for (torestart = UTIL_FindEntityByClassname(NULL, "func_vehicle"); - torestart != NULL; torestart = UTIL_FindEntityByClassname(torestart, "func_vehicle")) + torestart = UTIL_FindEntityByClassname(NULL, "func_vehicle"); + while (torestart != NULL) { torestart->Restart(); + torestart = UTIL_FindEntityByClassname(torestart, "func_vehicle"); } - for (torestart = UTIL_FindEntityByClassname(NULL, "func_train"); - torestart != NULL; torestart = UTIL_FindEntityByClassname(torestart, "func_train")) + torestart = UTIL_FindEntityByClassname(NULL, "func_train"); + while (torestart != NULL) { torestart->Restart(); + torestart = UTIL_FindEntityByClassname(torestart, "func_train"); } - for (torestart = UTIL_FindEntityByClassname(NULL, "armoury_entity"); - torestart != NULL; torestart = UTIL_FindEntityByClassname(torestart, "armoury_entity")) + torestart = UTIL_FindEntityByClassname(NULL, "armoury_entity"); + while (torestart != NULL) { torestart->Restart(); + torestart = UTIL_FindEntityByClassname(torestart, "armoury_entity"); } - for (torestart = UTIL_FindEntityByClassname(NULL, "ambient_generic"); - torestart != NULL; torestart = UTIL_FindEntityByClassname(torestart, "ambient_generic")) + torestart = UTIL_FindEntityByClassname(NULL, "ambient_generic"); + while (torestart != NULL) { torestart->Restart(); + torestart = UTIL_FindEntityByClassname(torestart, "ambient_generic"); } - for (torestart = UTIL_FindEntityByClassname(NULL, "env_sprite"); - torestart != NULL; torestart = UTIL_FindEntityByClassname(torestart, "env_sprite")) + torestart = UTIL_FindEntityByClassname(NULL, "env_sprite"); + while (torestart != NULL) { torestart->Restart(); + torestart = UTIL_FindEntityByClassname(torestart, "env_sprite"); } - for (toremove = UTIL_FindEntityByClassname(NULL, "grenade"), icount = 0; - toremove != NULL && icount < 20; toremove = UTIL_FindEntityByClassname(toremove, "grenade"), icount++) + // Remove grenades and C4 + int icount = 0; + toremove = UTIL_FindEntityByClassname(NULL, "grenade"); + while (toremove != NULL && icount < 20) { UTIL_Remove(toremove); + toremove = UTIL_FindEntityByClassname(toremove, "grenade"); + icount++; } - for (toremove = UTIL_FindEntityByClassname(NULL, "item_thighpack"); - toremove != NULL; toremove = UTIL_FindEntityByClassname(toremove, "item_thighpack")) + // Remove defuse kit + // Old code only removed 4 kits and stopped. + toremove = UTIL_FindEntityByClassname(NULL, "item_thighpack"); + while (toremove != NULL) { UTIL_Remove(toremove); + toremove = UTIL_FindEntityByClassname(toremove, "item_thighpack"); } RemoveGuns(); @@ -747,11 +771,13 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CleanUpMap)(void) /* <118585> ../cstrike/dlls/multiplay_gamerules.cpp:862 */ void CHalfLifeMultiplay::__MAKE_VHOOK(GiveC4)(void) { - int iTeamCount = m_iNumTerrorist; + int iTeamCount; int iTemp = 0; int humansPresent = 0; - ++m_iC4Guy; + iTeamCount = m_iNumTerrorist; + m_iC4Guy++; + bool giveToHumans = (cv_bot_defer_to_human.value > 0.0); if (giveToHumans) @@ -776,11 +802,13 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(GiveC4)(void) giveToHumans = false; } + // if we've looped past the last Terrorist.. then give the C4 to the first one. if (m_iC4Guy > iTeamCount) { m_iC4Guy = 1; } + // Give the C4 to the specified T player.. CBaseEntity *pPlayer = NULL; while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) { @@ -798,16 +826,18 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(GiveC4)(void) if (player->pev->deadflag != DEAD_NO || player->m_iTeam != TERRORIST || (giveToHumans && player->IsBot())) continue; - if (++iTemp == m_iC4Guy) + iTemp++; + if (iTemp == m_iC4Guy) { player->m_bHasC4 = true; player->GiveNamedItem("weapon_c4"); - player->SetBombIcon(FALSE); + player->SetBombIcon(); player->pev->body = 1; player->m_flDisplayHistory |= DHF_BOMB_RETRIEVED; player->HintMessage("#Hint_you_have_the_bomb", FALSE, TRUE); + // Log this information UTIL_LogPrintf ( "\"%s<%i><%s>\" triggered \"Spawned_With_The_Bomb\"\n", @@ -850,6 +880,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(GiveC4)(void) player->m_flDisplayHistory |= DHF_BOMB_RETRIEVED; player->HintMessage("#Hint_you_have_the_bomb", FALSE, TRUE); + // Log this information UTIL_LogPrintf ( "\"%s<%i><%s>\" triggered \"Spawned_With_The_Bomb\"\n", @@ -865,13 +896,11 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(GiveC4)(void) } /* <11541f> ../cstrike/dlls/multiplay_gamerules.cpp:981 */ -void TerminateRound(float tmDelay, int iWinStatus) +void CHalfLifeMultiplay::TerminateRound(float tmDelay, int iWinStatus) { - CHalfLifeMultiplay *mp = g_pGameRules; - - mp->m_iRoundWinStatus = iWinStatus; - mp->m_bRoundTerminating = true; - mp->m_fTeamCount = gpGlobals->time + tmDelay; + m_iRoundWinStatus = iWinStatus; + m_fTeamCount = gpGlobals->time + tmDelay; + m_bRoundTerminating = true; } /* <114a6a> ../cstrike/dlls/multiplay_gamerules.cpp:995 */ @@ -977,30 +1006,51 @@ void CHalfLifeMultiplay::QueueCareerRoundEndMenu(float tmDelay, int iWinStatus) /* <117750> ../cstrike/dlls/multiplay_gamerules.cpp:1084 */ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckWinConditions)(void) { - if (m_bFirstConnected && m_iRoundWinStatus) + // If a winner has already been determined and game of started.. then get the heck out of here + if (m_bFirstConnected && m_iRoundWinStatus != 0) { return; } - CBaseEntity *pPlayer = NULL; + // Initialize the player counts.. + int NumDeadCT, NumDeadTerrorist, NumAliveTerrorist, NumAliveCT; + InitializePlayerCounts(NumAliveTerrorist, NumAliveCT, NumDeadTerrorist, NumDeadCT); - int NumDeadCT, NumDeadTerrorist, NumAliveTerrorist, - NumAliveCT, NumSpawnableHumans, NumHumans; + // other player's check + bool bNeededPlayers = false; + if (NeededPlayersCheck(bNeededPlayers)) + return; - NumDeadCT = 0; - NumDeadTerrorist = 0; - NumAliveTerrorist = 0; - NumAliveCT = 0; - NumSpawnableHumans = 0; - NumHumans = 0; + // Assasination/VIP scenarion check + if (VIPRoundEndCheck(bNeededPlayers)) + return; - m_iNumSpawnableCT = 0; - m_iNumSpawnableTerrorist = 0; - m_iNumCT = 0; - m_iNumTerrorist = 0; + // Prison escape check + if (PrisonRoundEndCheck(NumAliveTerrorist, NumAliveCT, NumDeadTerrorist, NumDeadCT, bNeededPlayers)) + return; + + // Bomb check + if (BombRoundEndCheck(bNeededPlayers)) + return; + + // Team Extermination check + // CounterTerrorists won by virture of elimination + if (TeamExterminationCheck(NumAliveTerrorist, NumAliveCT, NumDeadTerrorist, NumDeadCT, bNeededPlayers)) + return; + + // Hostage rescue check + if (HostageRescueRoundEndCheck(bNeededPlayers)) + return; +} + +void CHalfLifeMultiplay::InitializePlayerCounts(int &NumAliveTerrorist, int &NumAliveCT, int &NumDeadTerrorist, int &NumDeadCT) +{ + NumAliveTerrorist = NumAliveCT = NumDeadCT = NumDeadTerrorist = 0; + m_iNumTerrorist = m_iNumCT = m_iNumSpawnableTerrorist = m_iNumSpawnableCT = 0; m_iHaveEscaped = 0; // initialize count dead/alive players + CBaseEntity *pPlayer = NULL; while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) { if (FNullEnt(pPlayer->edict())) @@ -1026,65 +1076,65 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckWinConditions)(void) switch (player->m_iTeam) { - case CT: + case CT: + { + m_iNumCT++; + + if (player->m_iMenu != Menu_ChooseAppearance) { - ++m_iNumCT; - - if (player->m_iMenu != Menu_ChooseAppearance) - { - m_iNumSpawnableCT++; - //player->IsBot(); - } - + m_iNumSpawnableCT++; //player->IsBot(); - if (player->pev->deadflag != DEAD_NO) - NumDeadCT++; - else - NumAliveCT++; - - break; } - case TERRORIST: + + //player->IsBot(); + if (player->pev->deadflag != DEAD_NO) + NumDeadCT++; + else + NumAliveCT++; + + break; + } + case TERRORIST: + { + m_iNumTerrorist++; + + if (player->m_iMenu != Menu_ChooseAppearance) { - ++m_iNumTerrorist; - - if (player->m_iMenu != Menu_ChooseAppearance) - { - m_iNumSpawnableTerrorist++; - //player->IsBot(); - } + m_iNumSpawnableTerrorist++; //player->IsBot(); - - if (player->pev->deadflag != DEAD_NO) - NumDeadTerrorist++; - else - NumAliveTerrorist++; - - if (player->m_bEscaped) - m_iHaveEscaped++; - - break; } - default: - break; + //player->IsBot(); + + if (player->pev->deadflag != DEAD_NO) + NumDeadTerrorist++; + else + NumAliveTerrorist++; + + // Check to see if this guy escaped. + if (player->m_bEscaped) + m_iHaveEscaped++; + + break; + } + default: + break; } } +} - BOOL bNeededPlayers = FALSE; - - NumSpawnableHumans = (m_iNumSpawnableTerrorist > 0 && m_iNumSpawnableCT > 0); - NumHumans = (m_iNumCT > 0 && m_iNumTerrorist > 0); - +bool CHalfLifeMultiplay::NeededPlayersCheck(bool &bNeededPlayers) +{ + // We needed players to start scoring + // Do we have them now? // start the game, after the players entered in game - if (!NumSpawnableHumans) + if (!m_iNumSpawnableTerrorist || !m_iNumSpawnableCT) { UTIL_ClientPrintAll(HUD_PRINTCONSOLE, "#Game_scoring"); - - bNeededPlayers = TRUE; + bNeededPlayers = true; m_bFirstConnected = false; } - if (!m_bFirstConnected && NumSpawnableHumans) + if (!m_bFirstConnected && m_iNumSpawnableTerrorist != 0 && m_iNumSpawnableCT != 0) { if (IsCareer()) { @@ -1092,12 +1142,14 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckWinConditions)(void) if (!player || !player->IsBot()) { - return; + return true; } } + // Start the round immediately when the first person joins UTIL_LogPrintf("World triggered \"Game_Commencing\"\n"); + // Make sure we are not on the FreezePeriod. m_bFreezePeriod = FALSE; m_bCompleteReset = true; @@ -1107,9 +1159,14 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckWinConditions)(void) m_bFirstConnected = true; TheBots->OnEvent(EVENT_GAME_COMMENCE); - return; + return true; } + return false; +} + +bool CHalfLifeMultiplay::VIPRoundEndCheck(bool bNeededPlayers) +{ // checks to scenario Escaped VIP on map with vip safety zones if (m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES && m_pVIP != NULL) { @@ -1121,20 +1178,20 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckWinConditions)(void) if (!bNeededPlayers) { m_iNumCTWins++; + // Update the clients team score UpdateTeamScores(); } MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR); - WRITE_BYTE(9); - WRITE_BYTE(DRC_CMD_EVENT); - WRITE_SHORT(ENTINDEX(m_pVIP->edict())); - WRITE_SHORT(0); - WRITE_LONG(DRC_FLAG_PRIO_MASK | DRC_FLAG_FINAL); + WRITE_BYTE(9); // command length in bytes + WRITE_BYTE(DRC_CMD_EVENT); // VIP rescued + WRITE_SHORT(ENTINDEX(m_pVIP->edict())); // index number of primary entity + WRITE_SHORT(0); // index number of secondary entity + WRITE_LONG(15 | DRC_FLAG_FINAL); // eventflags (priority and flags) MESSAGE_END(); EndRoundMessage("#VIP_Escaped", ROUND_VIP_ESCAPED); TheBots->OnEvent(EVENT_VIP_ESCAPED); - TerminateRound(5, WINSTATUS_CTS); if (IsCareer()) @@ -1142,10 +1199,10 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckWinConditions)(void) QueueCareerRoundEndMenu(5, WINSTATUS_CTS); } - return; + return true; } - - if (m_pVIP->pev->deadflag != DEAD_NO) + // The VIP is dead + else if (m_pVIP->pev->deadflag != DEAD_NO) { Broadcast("terwin"); m_iAccountTerrorist += REWARD_VIP_ASSASSINATED; @@ -1153,12 +1210,12 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckWinConditions)(void) if (!bNeededPlayers) { m_iNumTerroristWins++; + // Update the clients team score UpdateTeamScores(); } EndRoundMessage("#VIP_Assassinated", ROUND_VIP_ASSASSINATED); TheBots->OnEvent(EVENT_VIP_ASSASSINATED); - TerminateRound(5, WINSTATUS_TERRORISTS); if (IsCareer()) @@ -1166,10 +1223,15 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckWinConditions)(void) QueueCareerRoundEndMenu(5, WINSTATUS_TERRORISTS); } - return; + return true; } } + return false; +} + +bool CHalfLifeMultiplay::PrisonRoundEndCheck(int NumAliveTerrorist, int NumAliveCT, int NumDeadTerrorist, int NumDeadCT, bool bNeededPlayers) +{ // checks to scenario Escaped Terrorist's if (m_bMapHasEscapeZone) { @@ -1183,6 +1245,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckWinConditions)(void) if (!bNeededPlayers) { m_iNumTerroristWins++; + // Update the clients team score UpdateTeamScores(); } @@ -1194,93 +1257,23 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckWinConditions)(void) QueueCareerRoundEndMenu(5, WINSTATUS_TERRORISTS); } - return; + return true; } - - if (!NumAliveTerrorist) - { - if (m_flRequiredEscapeRatio > flEscapeRatio) - { - Broadcast("ctwin"); - m_iAccountCT += (1 - flEscapeRatio) * REWARD_CTS_PREVENT_ESCAPE; - - if (!bNeededPlayers) - { - m_iNumCTWins++; - UpdateTeamScores(); - } - - EndRoundMessage("#CTs_PreventEscape", ROUND_CTS_PREVENT_ESCAPE); - TerminateRound(5, WINSTATUS_CTS); - - if (IsCareer()) - { - QueueCareerRoundEndMenu(5, WINSTATUS_CTS); - } - - return; - } - else if (NumDeadTerrorist && m_iNumSpawnableCT > 0) - { - Broadcast("ctwin"); - m_iAccountCT += (1 - flEscapeRatio) * REWARD_ESCAPING_TERRORISTS_NEUTRALIZED; - - if (!bNeededPlayers) - { - m_iNumCTWins++; - UpdateTeamScores(); - } - - EndRoundMessage("#Escaping_Terrorists_Neutralized", ROUND_ESCAPING_TERRORISTS_NEUTRALIZED); - TerminateRound(5, WINSTATUS_CTS); - - if (IsCareer()) - { - QueueCareerRoundEndMenu(5, WINSTATUS_CTS); - } - - return; - } - } - } - - // checks to scenario bomb target saved or exploded - if (m_bMapHasBombTarget) - { - if (m_bTargetBombed) - { - Broadcast("terwin"); - m_iAccountTerrorist += REWARD_TARGET_BOMB; - - if (!bNeededPlayers) - { - m_iNumTerroristWins++; - UpdateTeamScores(); - } - - EndRoundMessage("#Target_Bombed", ROUND_TARGET_BOMB); - TerminateRound(5, WINSTATUS_TERRORISTS); - - if (IsCareer()) - { - QueueCareerRoundEndMenu(5, WINSTATUS_TERRORISTS); - } - - return; - } - else if (m_bBombDefused) + else if (NumAliveTerrorist == 0 && flEscapeRatio < m_flRequiredEscapeRatio) { Broadcast("ctwin"); - m_iAccountCT += REWARD_BOMB_DEFUSED; - m_iAccountTerrorist += REWARD_BOMB_PLANTED; + + // CTs are rewarded based on how many terrorists have escaped... + m_iAccountCT += (1 - flEscapeRatio) * REWARD_CTS_PREVENT_ESCAPE; if (!bNeededPlayers) { m_iNumCTWins++; + // Update the clients team score UpdateTeamScores(); } - EndRoundMessage("#Bomb_Defused", ROUND_BOMB_DEFUSED); + EndRoundMessage("#CTs_PreventEscape", ROUND_CTS_PREVENT_ESCAPE); TerminateRound(5, WINSTATUS_CTS); if (IsCareer()) @@ -1288,26 +1281,107 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckWinConditions)(void) QueueCareerRoundEndMenu(5, WINSTATUS_CTS); } - return; + return true; } + else if (NumAliveTerrorist == 0 && NumDeadTerrorist != 0 && m_iNumSpawnableCT > 0) + { + Broadcast("ctwin"); + + // CTs are rewarded based on how many terrorists have escaped... + m_iAccountCT += (1 - flEscapeRatio) * REWARD_ESCAPING_TERRORISTS_NEUTRALIZED; + + if (!bNeededPlayers) + { + m_iNumCTWins++; + // Update the clients team score + UpdateTeamScores(); + } + + EndRoundMessage("#Escaping_Terrorists_Neutralized", ROUND_ESCAPING_TERRORISTS_NEUTRALIZED); + TerminateRound(5, WINSTATUS_CTS); + + if (IsCareer()) + { + QueueCareerRoundEndMenu(5, WINSTATUS_CTS); + } + + return true; + } + // else return true; } - // check the round ended on expiration time - if (NumHumans && NumSpawnableHumans) + return false; +} + +bool CHalfLifeMultiplay::BombRoundEndCheck(bool bNeededPlayers) +{ + // Check to see if the bomb target was hit or the bomb defused.. if so, then let's end the round! + if (m_bTargetBombed && m_bMapHasBombTarget) + { + Broadcast("terwin"); + m_iAccountTerrorist += REWARD_TARGET_BOMB; + + if (!bNeededPlayers) + { + m_iNumTerroristWins++; + // Update the clients team score + UpdateTeamScores(); + } + + EndRoundMessage("#Target_Bombed", ROUND_TARGET_BOMB); + TerminateRound(5, WINSTATUS_TERRORISTS); + + if (IsCareer()) + { + QueueCareerRoundEndMenu(5, WINSTATUS_TERRORISTS); + } + + return true; + } + else if (m_bBombDefused && m_bMapHasBombTarget) + { + Broadcast("ctwin"); + m_iAccountCT += REWARD_BOMB_DEFUSED; + m_iAccountTerrorist += REWARD_BOMB_PLANTED; + + if (!bNeededPlayers) + { + m_iNumCTWins++; + // Update the clients team score + UpdateTeamScores(); + } + + EndRoundMessage("#Bomb_Defused", ROUND_BOMB_DEFUSED); + TerminateRound(5, WINSTATUS_CTS); + + if (IsCareer()) + { + QueueCareerRoundEndMenu(5, WINSTATUS_CTS); + } + + return true; + } + + return false; +} + +bool CHalfLifeMultiplay::TeamExterminationCheck(int NumAliveTerrorist, int NumAliveCT, int NumDeadTerrorist, int NumDeadCT, bool bNeededPlayers) +{ + if ((m_iNumCT > 0 && m_iNumSpawnableCT > 0) + && (m_iNumTerrorist > 0 && m_iNumSpawnableTerrorist > 0)) { if (!NumAliveTerrorist && NumDeadTerrorist && NumAliveCT > 0) { - CGrenade *C4 = NULL; CBaseEntity *temp = NULL; - BOOL nowin = FALSE; + bool nowin = false; while ((temp = UTIL_FindEntityByClassname(temp, "grenade")) != NULL) { - C4 = reinterpret_cast(temp); + CGrenade *C4 = reinterpret_cast(temp); if (C4->m_bIsC4 && !C4->m_bJustBlew) { - nowin = TRUE; + nowin = true; #ifdef REGAMEDLL_FIXES break; #endif // REGAMEDLL_FIXES @@ -1322,6 +1396,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckWinConditions)(void) if (!bNeededPlayers) { m_iNumCTWins++; + // Update the clients team score UpdateTeamScores(); } @@ -1333,10 +1408,13 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckWinConditions)(void) QueueCareerRoundEndMenu(5, WINSTATUS_CTS); } - return; } + + return true; } - else if (!NumAliveCT && NumDeadCT) + + // Terrorists WON + if (NumAliveCT == 0 && NumDeadCT != 0) { Broadcast("terwin"); m_iAccountTerrorist += m_bMapHasBombTarget ? REWARD_BOMB_EXPLODED : REWARD_TERRORISTS_WIN; @@ -1344,6 +1422,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckWinConditions)(void) if (!bNeededPlayers) { m_iNumTerroristWins++; + // Update the clients team score UpdateTeamScores(); } @@ -1355,65 +1434,79 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckWinConditions)(void) QueueCareerRoundEndMenu(5, WINSTATUS_TERRORISTS); } - return; + return true; } } - else if (!NumAliveCT && !NumAliveTerrorist) + else if (NumAliveCT == 0 && NumAliveTerrorist == 0) { EndRoundMessage("#Round_Draw", ROUND_END_DRAW); Broadcast("rounddraw"); TerminateRound(5, WINSTATUS_DRAW); - return; + return true; } - // check that the hostages is rescued + return false; +} +bool CHalfLifeMultiplay::HostageRescueRoundEndCheck(bool bNeededPlayers) +{ + // Check to see if 50% of the hostages have been rescued. CBaseEntity *hostage = NULL; int iHostages = 0; + + // Assume that all hostages are either rescued or dead.. bool bHostageAlive = false; while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity")) != NULL) { - ++iHostages; + iHostages++; + // We've found a live hostage. don't end the round if (hostage->pev->takedamage == DAMAGE_YES) { bHostageAlive = true; } } - if (!bHostageAlive && iHostages > 0 && m_iHostagesRescued >= (iHostages * 0.5)) + // There are no hostages alive.. check to see if the CTs have rescued atleast 50% of them. + if (!bHostageAlive && iHostages > 0) { - Broadcast("ctwin"); - m_iAccountCT += REWARD_ALL_HOSTAGES_RESCUED; - - if (!bNeededPlayers) + if (m_iHostagesRescued >= (iHostages * 0.5)) { - m_iNumCTWins++; - UpdateTeamScores(); + Broadcast("ctwin"); + m_iAccountCT += REWARD_ALL_HOSTAGES_RESCUED; + + if (!bNeededPlayers) + { + m_iNumCTWins++; + // Update the clients team score + UpdateTeamScores(); + } + + EndRoundMessage("#All_Hostages_Rescued", ROUND_ALL_HOSTAGES_RESCUED); + TheBots->OnEvent(EVENT_ALL_HOSTAGES_RESCUED); + + if (IsCareer()) + { + TheCareerTasks->HandleEvent(EVENT_ALL_HOSTAGES_RESCUED); + } + + TerminateRound(5, WINSTATUS_CTS); + if (IsCareer()) + { + QueueCareerRoundEndMenu(5, WINSTATUS_CTS); + } + + return true; } - - EndRoundMessage("#All_Hostages_Rescued", ROUND_ALL_HOSTAGES_RESCUED); - TheBots->OnEvent(EVENT_ALL_HOSTAGES_RESCUED); - - if (IsCareer()) - { - TheCareerTasks->HandleEvent(EVENT_ALL_HOSTAGES_RESCUED); - } - - TerminateRound(5, WINSTATUS_CTS); - if (IsCareer()) - { - QueueCareerRoundEndMenu(5, WINSTATUS_CTS); - } - - return; } + + return false; } /* <117336> ../cstrike/dlls/multiplay_gamerules.cpp:1499 */ -NOXREF void CHalfLifeMultiplay::SwapAllPlayers(void) +void CHalfLifeMultiplay::SwapAllPlayers(void) { CBaseEntity *pPlayer = NULL; @@ -1429,10 +1522,14 @@ NOXREF void CHalfLifeMultiplay::SwapAllPlayers(void) player->SwitchTeam(); } - int iTemp = m_iNumTerroristWins; + // Swap Team victories + int iTemp; + + iTemp = m_iNumTerroristWins; m_iNumTerroristWins = m_iNumCTWins; m_iNumCTWins = iTemp; + // Update the clients team score UpdateTeamScores(); } @@ -1442,15 +1539,18 @@ void CHalfLifeMultiplay::BalanceTeams(void) int iTeamToSwap = UNASSIGNED; int iNumToSwap; + // The ratio for teams is different for Assasination maps if (m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) { - int iDesiredNumCT; - if ((m_iNumTerrorist + m_iNumCT) % 2) + int iDesiredNumCT, iDesiredNumTerrorist; + + // uneven number of players + if ((m_iNumCT + m_iNumTerrorist) % 2 != 0) iDesiredNumCT = (int)((m_iNumCT + m_iNumTerrorist) * 0.55f) + 1; else iDesiredNumCT = (int)((m_iNumCT + m_iNumTerrorist) / 2); - int iDesiredNumTerrorist = (m_iNumTerrorist + m_iNumCT) - iDesiredNumCT; + iDesiredNumTerrorist = (m_iNumCT + m_iNumTerrorist) - iDesiredNumCT; if (m_iNumCT < iDesiredNumCT) { @@ -1469,7 +1569,7 @@ void CHalfLifeMultiplay::BalanceTeams(void) } else { - if (m_iNumTerrorist < m_iNumCT) + if (m_iNumCT > m_iNumTerrorist) { iTeamToSwap = CT; iNumToSwap = (m_iNumCT - m_iNumTerrorist) / 2; @@ -1481,22 +1581,25 @@ void CHalfLifeMultiplay::BalanceTeams(void) } else { + // Teams are even.. Get out of here. return; } } + // Don't swap more than 4 players at a time.. This is a naive method of avoiding infinite loops. if (iNumToSwap > 4) iNumToSwap = 4; - int iHighestUserID; + // last person to join the server + int iHighestUserID = 0; CBasePlayer *toSwap = NULL; - CBaseEntity *pPlayer = NULL; for (int i = 1; i <= iNumToSwap; i++) { iHighestUserID = 0; toSwap = NULL; + CBaseEntity *pPlayer = NULL; while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) { if (FNullEnt(pPlayer->edict())) @@ -1507,13 +1610,11 @@ void CHalfLifeMultiplay::BalanceTeams(void) CBasePlayer *player = GetClassPtr((CBasePlayer *)pPlayer->pev); - if (player->m_iTeam != iTeamToSwap || GETPLAYERUSERID(player->edict()) <= iHighestUserID || m_pVIP == player) + if (player->m_iTeam == iTeamToSwap && GETPLAYERUSERID(player->edict()) > iHighestUserID && m_pVIP != player) { - continue; + iHighestUserID = GETPLAYERUSERID(player->edict()); + toSwap = player; } - - iHighestUserID = GETPLAYERUSERID(player->edict()); - toSwap = player; } if (toSwap != NULL) @@ -1542,10 +1643,17 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckMapConditions)(void) m_bMapHasBombZone = false; } + // Check to see if this map has hostage rescue zones m_bMapHasRescueZone = (UTIL_FindEntityByClassname(NULL, "func_hostage_rescue") != NULL); + + // See if the map has func_buyzone entities + // Used by CBasePlayer::HandleSignals() to support maps without these entities m_bMapHasBuyZone = (UTIL_FindEntityByClassname(NULL, "func_buyzone") != NULL); + + // GOOSEMAN : See if this map has func_escapezone entities m_bMapHasEscapeZone = (UTIL_FindEntityByClassname(NULL, "func_escapezone") != NULL); + // Check to see if this map has VIP safety zones if ((UTIL_FindEntityByClassname(NULL, "func_vip_safetyzone")) != NULL) m_iMapHasVIPSafetyZone = MAP_HAVE_VIP_SAFETYZONE_YES; else @@ -1555,6 +1663,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(CheckMapConditions)(void) /* <11745e> ../cstrike/dlls/multiplay_gamerules.cpp:1676 */ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void) { + // tell bots that the round is restarting TheBots->RestartRound(); if (g_pHostages) @@ -1562,16 +1671,19 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void) g_pHostages->RestartRound(); } - ++m_iTotalRoundsPlayed; + m_iTotalRoundsPlayed++; ClearBodyQue(); - CVAR_SET_FLOAT("sv_accelerate", 5); - CVAR_SET_FLOAT("sv_friction", 4); + // Hardlock the player accelaration to 5.0 + CVAR_SET_FLOAT("sv_accelerate", 5.0); + CVAR_SET_FLOAT("sv_friction", 4.0); CVAR_SET_FLOAT("sv_stopspeed", 75); + // Tabulate the number of players on each team. m_iNumCT = CountTeamPlayers(CT); m_iNumTerrorist = CountTeamPlayers(TERRORIST); + // reset the dropped bomb on everyone's radar if (m_bMapHasBombTarget) { MESSAGE_BEGIN(MSG_ALL, gmsgBombPickup); @@ -1583,24 +1695,31 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void) g_pGameRules->m_bBombDropped = FALSE; + // reset all players health for HLTV MESSAGE_BEGIN(MSG_SPEC, gmsgHLTV); - WRITE_BYTE(0); - WRITE_BYTE(100 | DRC_FLAG_FACEPLAYER); + WRITE_BYTE(0); // 0 = all players + WRITE_BYTE(100 | DRC_FLAG_FACEPLAYER); // 100 health + msg flag MESSAGE_END(); + // reset all players FOV for HLTV MESSAGE_BEGIN(MSG_SPEC, gmsgHLTV); - WRITE_BYTE(0); - WRITE_BYTE(0); + WRITE_BYTE(0); // all players + WRITE_BYTE(0); // to default FOV value MESSAGE_END(); if (CVAR_GET_FLOAT("mp_autoteambalance") != 0.0f && m_iUnBalancedRounds >= 1) + { BalanceTeams(); + } if ((m_iNumCT - m_iNumTerrorist) >= 2 || (m_iNumTerrorist - m_iNumCT) >= 2) - ++m_iUnBalancedRounds; + { + m_iUnBalancedRounds++; + } else m_iUnBalancedRounds = 0; + // Warn the players of an impending auto-balance next round... if (CVAR_GET_FLOAT("mp_autoteambalance") != 0.0f && m_iUnBalancedRounds == 1) { UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Auto_Team_Balance_Next_Round"); @@ -1608,14 +1727,19 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void) if (m_bCompleteReset) { + // bounds check if (timelimit.value < 0) + { CVAR_SET_FLOAT("mp_timelimit", 0); + } g_flResetTime = gpGlobals->time; + // Reset timelimit if (timelimit.value) - g_flTimeLimit = gpGlobals->time + timelimit.value * 60; + g_flTimeLimit = gpGlobals->time + (timelimit.value * 60); + // Reset total # of rounds played m_iTotalRoundsPlayed = 0; m_iMaxRounds = (int)CVAR_GET_FLOAT("mp_maxrounds"); @@ -1633,12 +1757,16 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void) CVAR_SET_FLOAT("mp_winlimit", 0); } + // Reset score info m_iNumTerroristWins = 0; m_iNumCTWins = 0; m_iNumConsecutiveTerroristLoses = 0; m_iNumConsecutiveCTLoses = 0; + + // Reset team scores UpdateTeamScores(); + // Reset the player stats for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *plr = (CBasePlayer *)UTIL_PlayerByIndex(i); @@ -1657,15 +1785,17 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void) float flAutoKickIdle = CVAR_GET_FLOAT("mp_autokick_timeout"); + // set the idlekick max time (in seconds) if (flAutoKickIdle > 0) m_fMaxIdlePeriod = flAutoKickIdle; else m_fMaxIdlePeriod = (m_iRoundTime * 2); + // This makes the round timer function as the intro timer on the client side m_iRoundTimeSecs = m_iIntroRoundTime; + // Check to see if there's a mapping info paramater entity CMapInfo *mi = (CMapInfo *)UTIL_FindEntityByClassname(NULL, "info_map_parameters"); - if (mi != NULL) { switch (mi->m_iBuyingStatus) @@ -1708,21 +1838,22 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void) if (m_bMapHasEscapeZone) { m_iHaveEscaped = 0; - m_iNumEscapers = 0; + m_iNumEscapers = 0; // Will increase this later when we count how many Ts are starting - if (m_iNumEscapeRounds > 2) + if (m_iNumEscapeRounds >= 3) { SwapAllPlayers(); m_iNumEscapeRounds = 0; } - ++m_iNumEscapeRounds; + // Increment the number of rounds played... After 8 rounds, the players will do a whole sale switch.. + m_iNumEscapeRounds++; } if (m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) { PickNextVIP(); - ++m_iConsecutiveVIP; + m_iConsecutiveVIP++; } int acct_tmp = 0; @@ -1748,66 +1879,84 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void) temp->RePosition(); } - if (m_iRoundWinStatus == WINSTATUS_TERRORISTS) + // Scale up the loser bonus when teams fall into losing streaks + if (m_iRoundWinStatus == WINSTATUS_TERRORISTS) // terrorists won { + // check to see if they just broke a losing streak if (m_iNumConsecutiveTerroristLoses > 1) { + // this is the default losing bonus m_iLoserBonus = REWARD_LOSER_BONUS_MIN; } - m_iNumConsecutiveCTLoses++; - m_iNumConsecutiveTerroristLoses = 0; + m_iNumConsecutiveTerroristLoses = 0; // starting fresh + m_iNumConsecutiveCTLoses++; // increment the number of wins the CTs have had } else if (m_iRoundWinStatus == WINSTATUS_CTS) { + // check to see if they just broke a losing streak if (m_iNumConsecutiveCTLoses > 1) { + // this is the default losing bonus m_iLoserBonus = REWARD_LOSER_BONUS_MIN; } - m_iNumConsecutiveCTLoses = 0; - m_iNumConsecutiveTerroristLoses++; + m_iNumConsecutiveCTLoses = 0; // starting fresh + m_iNumConsecutiveTerroristLoses++; // increment the number of wins the Terrorists have had } - if (m_iLoserBonus < REWARD_LOSER_BONUS_MAX && (m_iNumConsecutiveTerroristLoses > 1 || m_iNumConsecutiveCTLoses > 1)) + // check if the losing team is in a losing streak & that the loser bonus hasen't maxed out. + if(m_iNumConsecutiveTerroristLoses > 1 && m_iLoserBonus < REWARD_LOSER_BONUS_MAX) { + // help out the team in the losing streak + m_iLoserBonus += REWARD_LOSER_BONUS_ADD; + } + else if(m_iNumConsecutiveCTLoses > 1 && m_iLoserBonus < REWARD_LOSER_BONUS_MAX) + { + // help out the team in the losing streak m_iLoserBonus += REWARD_LOSER_BONUS_ADD; } - if (m_iRoundWinStatus == WINSTATUS_TERRORISTS) + // assign the wining and losing bonuses + if (m_iRoundWinStatus == WINSTATUS_TERRORISTS) // terrorists won { m_iAccountTerrorist += acct_tmp; m_iAccountCT += m_iLoserBonus; } - else if (m_iRoundWinStatus == WINSTATUS_CTS) + else if (m_iRoundWinStatus == WINSTATUS_CTS) // CT Won { m_iAccountCT += acct_tmp; if (!m_bMapHasEscapeZone) { + // only give them the bonus if this isn't an escape map m_iAccountTerrorist += m_iLoserBonus; } } + // Update CT account based on number of hostages rescued m_iAccountCT += m_iHostagesRescued * REWARD_RESCUED_HOSTAGE; - m_fRoundCount = gpGlobals->time; - m_fIntroRoundCount = gpGlobals->time; + // Update individual players accounts and respawn players + // the round time stamp must be set before players are spawned + m_fIntroRoundCount = m_fRoundCount = gpGlobals->time; + + // Adrian - No cash for anyone at first rounds! ( well, only the default. ) if (m_bCompleteReset) { - m_iAccountCT = 0; - m_iAccountTerrorist = 0; + // No extra cash!. + m_iAccountTerrorist = m_iAccountCT = 0; + // We are starting fresh. So it's like no one has ever won or lost. m_iNumTerroristWins = 0; m_iNumCTWins = 0; - m_iNumConsecutiveTerroristLoses = 0; m_iNumConsecutiveCTLoses = 0; - m_iLoserBonus = REWARD_LOSER_BONUS_DEFAULT; } + // tell bots that the round is restarting CBaseEntity *pPlayer = NULL; while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) { @@ -1836,21 +1985,25 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void) } else if (player->m_iTeam == TERRORIST) { - ++m_iNumEscapers; + // Add another potential escaper to the mix! + m_iNumEscapers++; if (!player->m_bReceivesNoMoneyNextRound) { player->AddAccount(m_iAccountTerrorist); } + // If it's a prison scenario then remove the Ts guns if (m_bMapHasEscapeZone) { + // this will cause them to be reset with default weapons, armor, and items player->m_bNotKilled = false; } } if (player->m_iTeam != UNASSIGNED && player->m_iTeam != SPECTATOR) { + // drop the c4 if the player is carrying it if (player->m_bHasC4) { player->DropPlayerItem("weapon_c4"); @@ -1858,10 +2011,16 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void) player->RoundRespawn(); } + + // Gooseman : The following code fixes the HUD icon bug + // by removing the C4 and DEFUSER icons from the HUD regardless + // for EVERY player (regardless of what team they're on) } + // Respawn entities (glass, doors, etc..) CleanUpMap(); + // Give C4 to the terrorists if (m_bMapHasBombTarget) { GiveC4(); @@ -1869,19 +2028,15 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void) TheBots->OnEvent(EVENT_BUY_TIME_START); + // Reset game variables m_flIntermissionEndTime = 0; m_flIntermissionStartTime = 0; - m_fTeamCount = 0; - - m_iAccountCT = 0; - m_iAccountTerrorist = 0; - + m_fTeamCount = 0.0; + m_iAccountTerrorist = m_iAccountCT = 0; m_iHostagesRescued = 0; m_iHostagesTouched = 0; - m_iRoundWinStatus = 0; - m_bBombDefused = false; - m_bTargetBombed = false; + m_bTargetBombed = m_bBombDefused = false; m_bLevelInitialized = false; m_bCompleteReset = false; } @@ -1897,9 +2052,13 @@ BOOL CHalfLifeMultiplay::IsThereABomber(void) break; if (pPlayer->m_iTeam != CT && pPlayer->IsBombGuy()) + { + // There you are. return TRUE; + } } + // Didn't find a bomber. return FALSE; } @@ -1938,18 +2097,22 @@ BOOL CHalfLifeMultiplay::TeamFull(int team_id) { switch (team_id) { - case TERRORIST: - return (m_iNumTerrorist >= m_iSpawnPointCount_Terrorist); - case CT: - return (m_iNumCT >= m_iSpawnPointCount_CT); + case TERRORIST: + return (m_iNumTerrorist >= m_iSpawnPointCount_Terrorist); + + case CT: + return (m_iNumCT >= m_iSpawnPointCount_CT); } return FALSE; } +// checks to see if the desired team is stacked, returns true if it is + /* <114dbb> ../cstrike/dlls/multiplay_gamerules.cpp:2144 */ BOOL CHalfLifeMultiplay::TeamStacked(int newTeam_id, int curTeam_id) { + // players are allowed to change to their own team if (newTeam_id == curTeam_id) return FALSE; @@ -1958,20 +2121,16 @@ BOOL CHalfLifeMultiplay::TeamStacked(int newTeam_id, int curTeam_id) switch (newTeam_id) { - case TERRORIST: - { - if (curTeam_id != UNASSIGNED && curTeam_id != SPECTATOR) - return ((m_iNumTerrorist + 1) > (m_iNumCT + m_iLimitTeams - 1)); - else - return ((m_iNumTerrorist + 1) > (m_iNumCT + m_iLimitTeams)); - } - case CT: - { - if (curTeam_id != UNASSIGNED && curTeam_id != SPECTATOR) - return ((m_iNumCT + 1) > (m_iNumTerrorist + m_iLimitTeams - 1)); - else - return ((m_iNumCT + 1) > (m_iNumTerrorist + m_iLimitTeams)); - } + case TERRORIST: + if (curTeam_id != UNASSIGNED && curTeam_id != SPECTATOR) + return ((m_iNumTerrorist + 1) > (m_iNumCT + m_iLimitTeams - 1)); + else + return ((m_iNumTerrorist + 1) > (m_iNumCT + m_iLimitTeams)); + case CT: + if (curTeam_id != UNASSIGNED && curTeam_id != SPECTATOR) + return ((m_iNumCT + 1) > (m_iNumTerrorist + m_iLimitTeams - 1)); + else + return ((m_iNumCT + 1) > (m_iNumTerrorist + m_iLimitTeams)); } return FALSE; @@ -2007,14 +2166,14 @@ bool CHalfLifeMultiplay::IsVIPQueueEmpty(void) { CBasePlayer *toCheck = VIPQueue[i]; - if (toCheck && toCheck->m_iTeam != CT) + if (toCheck != NULL && toCheck->m_iTeam != CT) { VIPQueue[i] = NULL; } } StackVIPQueue(); - return (VIPQueue[0] == NULL && VIPQueue[1] == NULL && VIPQueue[2] == NULL && VIPQueue[3] == NULL && VIPQueue[4] == NULL); + return (VIPQueue[0] == NULL && VIPQueue[1] == NULL && VIPQueue[2] == NULL && VIPQueue[3] == NULL && VIPQueue[4] == NULL); } /* <114eea> ../cstrike/dlls/multiplay_gamerules.cpp:2257 */ @@ -2106,6 +2265,7 @@ void CHalfLifeMultiplay::PickNextVIP(void) { if (!IsVIPQueueEmpty()) { + // Remove the current VIP from his VIP status and make him a regular CT. if (m_pVIP != NULL) { ResetCurrentVIP(); @@ -2118,45 +2278,41 @@ void CHalfLifeMultiplay::PickNextVIP(void) m_pVIP = VIPQueue[i]; m_pVIP->MakeVIP(); - VIPQueue[i] = NULL; - - StackVIPQueue(); + VIPQueue[i] = NULL; // remove this player from the VIP queue + StackVIPQueue(); // and re-organize the queue m_iConsecutiveVIP = 0; - - break; + return; } } } - else if (m_iConsecutiveVIP > 2) + // If it's been the same VIP for 3 rounds already.. then randomly pick a new one + else if (m_iConsecutiveVIP >= 3) { - if (++m_iLastPick > m_iNumCT) - { + m_iLastPick++; + + if (m_iLastPick > m_iNumCT) m_iLastPick = 1; - } int iCount = 1; - CBasePlayer *pLastPlayer = NULL; + CBaseEntity *pPlayer = NULL; + CBasePlayer *player = NULL; + CBasePlayer *pLastPlayer = NULL; - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"); + + while ((pPlayer != NULL) && (!FNullEnt(pPlayer->edict()))) { - if (FNullEnt(pPlayer->edict())) - break; - - if (pPlayer->pev->flags & FL_DORMANT) - continue; - - CBasePlayer *player = GetClassPtr((CBasePlayer *)pPlayer->pev); - - if (player->m_iTeam == CT) + if (!(pPlayer->pev->flags & FL_DORMANT)) { - if (iCount == m_iLastPick) + player = GetClassPtr((CBasePlayer *)pPlayer->pev); + + if (player->m_iTeam == CT && iCount == m_iLastPick) { if (player == m_pVIP && pLastPlayer != NULL) - { player = pLastPlayer; - } + // Remove the current VIP from his VIP status and make him a regular CT. if (m_pVIP != NULL) { ResetCurrentVIP(); @@ -2164,38 +2320,41 @@ void CHalfLifeMultiplay::PickNextVIP(void) player->MakeVIP(); m_iConsecutiveVIP = 0; - break; + + return; } + else if (player->m_iTeam == CT) + iCount++; - iCount++; + if (player->m_iTeam != SPECTATOR) + pLastPlayer = player; } - if (player->m_iTeam != SPECTATOR) - { - pLastPlayer = player; - } + pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"); } } - else if (!m_pVIP) + // There is no VIP and there is no one waiting to be the VIP.. therefore just pick the first CT player we can find. + else if (m_pVIP == NULL) { CBaseEntity *pPlayer = NULL; + CBasePlayer *player = NULL; - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"); + while ((pPlayer != NULL) && (!FNullEnt(pPlayer->edict()))) { - if (FNullEnt(pPlayer->edict())) - break; - - if (pPlayer->pev->flags == FL_DORMANT) - continue; - - CBasePlayer *player = GetClassPtr((CBasePlayer *)pPlayer->pev); - - if (player->m_iTeam == CT) + if (pPlayer->pev->flags != FL_DORMANT) { - player->MakeVIP(); - m_iConsecutiveVIP = 0; - break; + player = GetClassPtr((CBasePlayer *)pPlayer->pev); + + if (player->m_iTeam == CT) + { + player->MakeVIP(); + m_iConsecutiveVIP = 0; + return; + } } + + pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"); } } } @@ -2214,8 +2373,8 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)(void) if (!m_fRoundCount) { - m_fRoundCount = gpGlobals->time; - m_fIntroRoundCount = gpGlobals->time; + // intialize the timer time stamps, this happens once only + m_fIntroRoundCount = m_fRoundCount = gpGlobals->time; } if (m_flForceCameraValue != forcecamera.value @@ -2233,69 +2392,22 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)(void) m_flFadeToBlackValue = fadetoblack.value; } - if (g_fGameOver) - { - int time = (int)CVAR_GET_FLOAT("mp_chattime"); - - if (time < 1) - CVAR_SET_STRING("mp_chattime", "1"); - - else if (time > MAX_INTERMISSION_TIME) - CVAR_SET_STRING("mp_chattime", UTIL_dtos1(MAX_INTERMISSION_TIME)); - - m_flIntermissionEndTime = m_flIntermissionStartTime + mp_chattime.value; - - if (gpGlobals->time > m_flIntermissionEndTime && !IsCareer() - && (!UTIL_HumansInGame(false) || m_iEndIntermissionButtonHit || (gpGlobals->time > m_flIntermissionStartTime + MAX_INTERMISSION_TIME))) - { - ChangeLevel(); - } - + // Check game rules + if (CheckGameOver()) return; - } - float fTimeLimit = timelimit.value; - - if (fTimeLimit < 0) - { - CVAR_SET_FLOAT("mp_timelimit", 0); - fTimeLimit = 0; - } + // have we hit the timelimit? + if (CheckTimeLimit()) + return; if (!IsCareer()) { - if (fTimeLimit != 0.0f) - { - g_flTimeLimit = g_flResetTime + fTimeLimit * 60.0f; - } - - if (fTimeLimit && g_flTimeLimit <= gpGlobals->time) - { - ALERT(at_console, "Changing maps because time limit has been met\n"); - - GoToIntermission(); + // have we hit the max rounds? + if (CheckMaxRounds()) return; - } - if (m_iMaxRounds && m_iTotalRoundsPlayed >= m_iMaxRounds) - { - ALERT(at_console, "Changing maps due to maximum rounds have been met\n"); - - GoToIntermission(); + if (CheckWinLimit()) return; - } - - if (m_iMaxRoundsWon && (m_iNumCTWins >= m_iMaxRoundsWon || m_iNumTerroristWins >= m_iMaxRoundsWon)) - { - if ((m_iNumCTWins - m_iNumTerroristWins >= m_iRoundWinDifference) - || (m_iNumTerroristWins - m_iNumCTWins >= m_iRoundWinDifference)) - { - ALERT(at_console, "Changing maps...one team has won the specified number of rounds\n"); - - GoToIntermission(); - return; - } - } } if (!IsCareer() || (m_fCareerMatchMenuTime <= 0.0 || m_fCareerMatchMenuTime >= gpGlobals->time)) @@ -2309,167 +2421,16 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)(void) MESSAGE_END(); } + // Check for the end of the round. if (IsFreezePeriod()) { - if (TimeRemaining() <= 0.0) - { - char CT_sentence[40], T_sentence[40]; - - UTIL_LogPrintf("World triggered \"Round_Start\"\n"); - m_bFreezePeriod = FALSE; - - switch (RANDOM_LONG(0, 3)) - { - case 0: - Q_strncpy(CT_sentence, "%!MRAD_MOVEOUT", sizeof(CT_sentence)); - Q_strncpy(T_sentence, "%!MRAD_MOVEOUT", sizeof(T_sentence)); - break; - case 1: - Q_strncpy(CT_sentence, "%!MRAD_LETSGO", sizeof(CT_sentence)); - Q_strncpy(T_sentence, "%!MRAD_LETSGO", sizeof(T_sentence)); - break; - case 2: - Q_strncpy(CT_sentence, "%!MRAD_LOCKNLOAD", sizeof(CT_sentence)); - Q_strncpy(T_sentence, "%!MRAD_LOCKNLOAD", sizeof(T_sentence)); - break; - case 3: - Q_strncpy(CT_sentence, "%!MRAD_GO", sizeof(CT_sentence)); - Q_strncpy(T_sentence, "%!MRAD_GO", sizeof(T_sentence)); - break; - } - - if (m_bMapHasEscapeZone) - { - Q_strncpy(CT_sentence, "%!MRAD_ELIM", sizeof(CT_sentence)); - Q_strncpy(T_sentence, "%!MRAD_GETOUT", sizeof(T_sentence)); - } - else if (m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) - { - Q_strncpy(CT_sentence, "%!MRAD_VIP", sizeof(CT_sentence)); - Q_strncpy(T_sentence, "%!MRAD_LOCKNLOAD", sizeof(T_sentence)); - } - - bool bCTPlayed, bTPlayed; - - m_iRoundTimeSecs = m_iRoundTime; - m_fRoundCount = gpGlobals->time; - - bCTPlayed = false; - bTPlayed = false; - - TheCareerTasks->HandleEvent(EVENT_ROUND_START); - - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *plr = reinterpret_cast(UTIL_PlayerByIndex(i)); - - if (!plr || plr->pev->flags == FL_DORMANT) - { - continue; - } - - if (plr->m_iJoiningState == JOINED) - { - if (plr->m_iTeam == CT && !bCTPlayed) - { - plr->Radio(CT_sentence, NULL); - bCTPlayed = true; - } - else if (plr->m_iTeam == TERRORIST && !bTPlayed) - { - plr->Radio(T_sentence, NULL); - bTPlayed = true; - } - - if (plr->m_iTeam != SPECTATOR) - { - plr->ResetMaxSpeed(); - plr->m_bCanShoot = true; - } - } - - plr->SyncRoundTimer(); - } - - TheBots->OnEvent(EVENT_ROUND_START); - TheCareerTasks->HandleEvent(EVENT_ROUND_START); - } + CheckFreezePeriodExpired(); } - else if (HasRoundTimeExpired()) + else { - //CGrenade *C4 = (CGrenade *)UTIL_FindEntityByClassname(NULL, "grenade"); - - if (m_bMapHasBombTarget) - { - Broadcast("ctwin"); - - m_iAccountCT += REWARD_TARGET_BOMB_SAVED; - m_iNumCTWins++; - - EndRoundMessage("#Target_Saved", ROUND_TARGET_SAVED); - TerminateRound(5, WINSTATUS_CTS); - - if (IsCareer()) - { - QueueCareerRoundEndMenu(5, WINSTATUS_CTS); - } - - UpdateTeamScores(); - MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(TERRORIST); - } - else if (UTIL_FindEntityByClassname(NULL, "hostage_entity")) - { - Broadcast("terwin"); - m_iAccountTerrorist += REWARD_HOSTAGE_NOT_RESCUED; - m_iNumTerroristWins++; - - EndRoundMessage("#Hostages_Not_Rescued", ROUND_HOSTAGE_NOT_RESCUED); - TerminateRound(5, WINSTATUS_TERRORISTS); - - if (IsCareer()) - { - QueueCareerRoundEndMenu(5, WINSTATUS_TERRORISTS); - } - - UpdateTeamScores(); - MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(CT); - } - else if (m_bMapHasEscapeZone) - { - Broadcast("ctwin"); - m_iNumCTWins++; - - EndRoundMessage("#Terrorists_Not_Escaped", ROUND_TERRORISTS_NOT_ESCAPED); - TerminateRound(5, WINSTATUS_CTS); - - if (IsCareer()) - { - QueueCareerRoundEndMenu(5, WINSTATUS_CTS); - } - - UpdateTeamScores(); - } - else if (m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) - { - Broadcast("terwin"); - m_iAccountTerrorist += REWARD_VIP_NOT_ESCAPED; - m_iNumTerroristWins++; - - EndRoundMessage("#VIP_Not_Escaped", ROUND_VIP_NOT_ESCAPED); - TerminateRound(5, WINSTATUS_TERRORISTS); - - if (IsCareer()) - { - QueueCareerRoundEndMenu(5, WINSTATUS_TERRORISTS); - } - - UpdateTeamScores(); - } - - m_fRoundCount = gpGlobals->time + 60.0f; + CheckRoundTimeExpired(); } -//LABEL_147: if (m_fTeamCount != 0.0f && m_fTeamCount <= gpGlobals->time) { if (!IsCareer() || !m_fCareerRoundMenuTime) @@ -2555,91 +2516,33 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)(void) m_fCareerRoundMenuTime = 0; } } -//LABEL_181: - if (TheTutor) + + if (TheTutor != NULL) { TheTutor->PurgeMessages(); } } - if (!m_bLevelInitialized) - { - m_iSpawnPointCount_Terrorist = 0; - m_iSpawnPointCount_CT = 0; - - CBaseEntity *ent = NULL; - - while ((ent = UTIL_FindEntityByClassname(ent, "info_player_deathmatch")) != NULL) - m_iSpawnPointCount_Terrorist++; - - //ent = NULL; - while ((ent = UTIL_FindEntityByClassname(ent, "info_player_start")) != NULL) - m_iSpawnPointCount_CT++; - - m_bLevelInitialized = true; - } + CheckLevelInitialized(); if (gpGlobals->time > m_tmNextPeriodicThink) { - int iRestartDelay = (int)restartround.value; - - if (!iRestartDelay) - { - iRestartDelay = sv_restart.value; - } - - if (iRestartDelay > 0) - { - if (iRestartDelay > 60) - iRestartDelay = 60; - - CHalfLifeMultiplay *mp = g_pGameRules; - UTIL_LogPrintf("World triggered \"Restart_Round_(%i_%s)\"\n", iRestartDelay, (iRestartDelay == 1) ? "second" : "seconds"); - - if (mp != NULL) - { - UTIL_LogPrintf - ( - "Team \"CT\" scored \"%i\" with \"%i\" players\n", - mp->m_iNumCTWins, - mp->m_iNumCT - ); - - UTIL_LogPrintf - ( - "Team \"TERRORIST\" scored \"%i\" with \"%i\" players\n", - mp->m_iNumTerroristWins, - mp->m_iNumTerrorist - ); - } - - UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Game_will_restart_in", UTIL_dtos1(iRestartDelay), (iRestartDelay == 1) ? "SECOND" : "SECONDS"); - UTIL_ClientPrintAll(HUD_PRINTCONSOLE, "#Game_will_restart_in_console", UTIL_dtos1(iRestartDelay), (iRestartDelay == 1) ? "SECOND" : "SECONDS"); - - m_bCompleteReset = true; - m_fTeamCount = gpGlobals->time + iRestartDelay; - - CVAR_SET_FLOAT("sv_restartround", 0); - CVAR_SET_FLOAT("sv_restart", 0); - - CareerRestart(); - } - + CheckRestartRound(); m_tmNextPeriodicThink = gpGlobals->time + 1.0f; if (g_psv_accelerate->value != 5.0f) { - CVAR_SET_FLOAT("sv_accelerate", 5); + CVAR_SET_FLOAT("sv_accelerate", 5.0); } if (g_psv_friction->value != 4.0f) { - CVAR_SET_FLOAT("sv_friction", 4); + CVAR_SET_FLOAT("sv_friction", 4.0); } if (g_psv_stopspeed->value != 75.0f) { - CVAR_SET_FLOAT("sv_stopspeed", 75); + CVAR_SET_FLOAT("sv_stopspeed", 75.0); } m_iMaxRounds = (int)maxrounds.value; @@ -2696,10 +2599,359 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)(void) } } +bool CHalfLifeMultiplay::CheckGameOver(void) +{ + // someone else quit the game already + if (g_fGameOver) + { + int time = (int)CVAR_GET_FLOAT("mp_chattime"); + + if (time < 1) + CVAR_SET_STRING("mp_chattime", "1"); + + else if (time > MAX_INTERMISSION_TIME) + CVAR_SET_STRING("mp_chattime", UTIL_dtos1(MAX_INTERMISSION_TIME)); + + // bounds check + m_flIntermissionEndTime = m_flIntermissionStartTime + mp_chattime.value; + + // check to see if we should change levels now + if (m_flIntermissionEndTime < gpGlobals->time && !IsCareer()) + { + if (!UTIL_HumansInGame(false) // if only bots, just change immediately + || m_iEndIntermissionButtonHit // check that someone has pressed a key, or the max intermission time is over + || ((m_flIntermissionStartTime + MAX_INTERMISSION_TIME) < gpGlobals->time)) + { + // intermission is over + ChangeLevel(); + } + } + + return true; + } + + return false; +} + +bool CHalfLifeMultiplay::CheckTimeLimit(void) +{ + float fTimeLimit = timelimit.value; + + if (fTimeLimit < 0) + { + CVAR_SET_FLOAT("mp_timelimit", 0); + return false; + } + + if (!IsCareer()) + { + if (fTimeLimit != 0.0f) + { + g_flTimeLimit = g_flResetTime + fTimeLimit * 60.0f; + } + + if (fTimeLimit > 0 && gpGlobals->time >= g_flTimeLimit) + { + ALERT(at_console, "Changing maps because time limit has been met\n"); + GoToIntermission(); + return true; + } + } + + return false; +} + +bool CHalfLifeMultiplay::CheckMaxRounds(void) +{ + if (m_iMaxRounds != 0 && m_iTotalRoundsPlayed >= m_iMaxRounds) + { + ALERT(at_console, "Changing maps due to maximum rounds have been met\n"); + GoToIntermission(); + return true; + } + + return false; +} + +bool CHalfLifeMultiplay::CheckWinLimit(void) +{ + // has one team won the specified number of rounds? + if (m_iMaxRoundsWon != 0 && (m_iNumCTWins >= m_iMaxRoundsWon || m_iNumTerroristWins >= m_iMaxRoundsWon)) + { + if ((m_iNumCTWins - m_iNumTerroristWins >= m_iRoundWinDifference) || (m_iNumTerroristWins - m_iNumCTWins >= m_iRoundWinDifference)) + { + ALERT(at_console, "Changing maps...one team has won the specified number of rounds\n"); + GoToIntermission(); + return true; + } + } + + return false; +} + +void CHalfLifeMultiplay::CheckFreezePeriodExpired(void) +{ + if (TimeRemaining() > 0) + return; + + // Log this information + UTIL_LogPrintf("World triggered \"Round_Start\"\n"); + + // Freeze period expired: kill the flag + m_bFreezePeriod = FALSE; + + char CT_sentence[40]; + char T_sentence[40]; + + switch (RANDOM_LONG(0, 3)) + { + case 0: + Q_strncpy(CT_sentence, "%!MRAD_MOVEOUT", sizeof(CT_sentence)); + Q_strncpy(T_sentence, "%!MRAD_MOVEOUT", sizeof(T_sentence)); + break; + case 1: + Q_strncpy(CT_sentence, "%!MRAD_LETSGO", sizeof(CT_sentence)); + Q_strncpy(T_sentence, "%!MRAD_LETSGO", sizeof(T_sentence)); + break; + case 2: + Q_strncpy(CT_sentence, "%!MRAD_LOCKNLOAD", sizeof(CT_sentence)); + Q_strncpy(T_sentence, "%!MRAD_LOCKNLOAD", sizeof(T_sentence)); + break; + default: + Q_strncpy(CT_sentence, "%!MRAD_GO", sizeof(CT_sentence)); + Q_strncpy(T_sentence, "%!MRAD_GO", sizeof(T_sentence)); + break; + } + + // More specific radio commands for the new scenarios : Prison & Assasination + if (m_bMapHasEscapeZone) + { + Q_strncpy(CT_sentence, "%!MRAD_ELIM", sizeof(CT_sentence)); + Q_strncpy(T_sentence, "%!MRAD_GETOUT", sizeof(T_sentence)); + } + else if (m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) + { + Q_strncpy(CT_sentence, "%!MRAD_VIP", sizeof(CT_sentence)); + Q_strncpy(T_sentence, "%!MRAD_LOCKNLOAD", sizeof(T_sentence)); + } + + // Reset the round time + m_fRoundCount = gpGlobals->time; + + // in seconds + m_iRoundTimeSecs = m_iRoundTime; + + bool bCTPlayed = false; + bool bTPlayed = false; + + TheCareerTasks->HandleEvent(EVENT_ROUND_START); + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *plr = reinterpret_cast(UTIL_PlayerByIndex(i)); + + if (!plr || plr->pev->flags == FL_DORMANT) + { + continue; + } + + if (plr->m_iJoiningState == JOINED) + { + if (plr->m_iTeam == CT && !bCTPlayed) + { + plr->Radio(CT_sentence, NULL); + bCTPlayed = true; + } + else if (plr->m_iTeam == TERRORIST && !bTPlayed) + { + plr->Radio(T_sentence, NULL); + bTPlayed = true; + } + + if (plr->m_iTeam != SPECTATOR) + { + plr->ResetMaxSpeed(); + plr->m_bCanShoot = true; + } + } + + plr->SyncRoundTimer(); + } + + TheBots->OnEvent(EVENT_ROUND_START); + TheCareerTasks->HandleEvent(EVENT_ROUND_START); +} + +void CHalfLifeMultiplay::CheckRoundTimeExpired(void) +{ + if (!HasRoundTimeExpired()) + return; + +#if 0 + // Round time expired + float flEndRoundTime; + + // Check to see if there's still a live C4 hanging around.. if so, wait until this C4 blows before ending the round + CGrenade *C4 = (CGrenade *)UTIL_FindEntityByClassname(NULL, "grenade"); + + if (C4 != NULL) + { + if (!C4->m_bJustBlew) + flEndRoundTime = C4->m_flC4Blow; + else + flEndRoundTime = gpGlobals->time + 5.0; + } +#endif + + // New code to get rid of round draws!! + if (m_bMapHasBombTarget) + { + Broadcast("ctwin"); + + m_iAccountCT += REWARD_TARGET_BOMB_SAVED; + m_iNumCTWins++; + + EndRoundMessage("#Target_Saved", ROUND_TARGET_SAVED); + TerminateRound(5, WINSTATUS_CTS); + + if (IsCareer()) + { + QueueCareerRoundEndMenu(5, WINSTATUS_CTS); + } + + UpdateTeamScores(); + MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(TERRORIST); + } + else if (UTIL_FindEntityByClassname(NULL, "hostage_entity") != NULL) + { + Broadcast("terwin"); + m_iAccountTerrorist += REWARD_HOSTAGE_NOT_RESCUED; + m_iNumTerroristWins++; + + EndRoundMessage("#Hostages_Not_Rescued", ROUND_HOSTAGE_NOT_RESCUED); + TerminateRound(5, WINSTATUS_TERRORISTS); + + if (IsCareer()) + { + QueueCareerRoundEndMenu(5, WINSTATUS_TERRORISTS); + } + + UpdateTeamScores(); + MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(CT); + } + else if (m_bMapHasEscapeZone) + { + Broadcast("ctwin"); + m_iNumCTWins++; + + EndRoundMessage("#Terrorists_Not_Escaped", ROUND_TERRORISTS_NOT_ESCAPED); + TerminateRound(5, WINSTATUS_CTS); + + if (IsCareer()) + { + QueueCareerRoundEndMenu(5, WINSTATUS_CTS); + } + + UpdateTeamScores(); + } + else if (m_iMapHasVIPSafetyZone == MAP_HAVE_VIP_SAFETYZONE_YES) + { + Broadcast("terwin"); + m_iAccountTerrorist += REWARD_VIP_NOT_ESCAPED; + m_iNumTerroristWins++; + + EndRoundMessage("#VIP_Not_Escaped", ROUND_VIP_NOT_ESCAPED); + TerminateRound(5, WINSTATUS_TERRORISTS); + + if (IsCareer()) + { + QueueCareerRoundEndMenu(5, WINSTATUS_TERRORISTS); + } + + UpdateTeamScores(); + } + + // This is done so that the portion of code has enough time to do it's thing. + m_fRoundCount = gpGlobals->time + 60.0f; +} + +void CHalfLifeMultiplay::CheckLevelInitialized(void) +{ + if (!m_bLevelInitialized) + { + // Count the number of spawn points for each team + // This determines the maximum number of players allowed on each + CBaseEntity *ent = NULL; + + m_iSpawnPointCount_Terrorist = 0; + m_iSpawnPointCount_CT = 0; + + while ((ent = UTIL_FindEntityByClassname(ent, "info_player_deathmatch")) != NULL) + m_iSpawnPointCount_Terrorist++; + + while ((ent = UTIL_FindEntityByClassname(ent, "info_player_start")) != NULL) + m_iSpawnPointCount_CT++; + + m_bLevelInitialized = true; + } +} + +void CHalfLifeMultiplay::CheckRestartRound(void) +{ + // Restart the round if specified by the server + int iRestartDelay = (int)restartround.value; + + if (!iRestartDelay) + { + iRestartDelay = sv_restart.value; + } + + if (iRestartDelay > 0) + { + if (iRestartDelay > 60) + iRestartDelay = 60; + + CHalfLifeMultiplay *mp = g_pGameRules; + + // log the restart + UTIL_LogPrintf("World triggered \"Restart_Round_(%i_%s)\"\n", iRestartDelay, (iRestartDelay == 1) ? "second" : "seconds"); + + if (mp != NULL) + { + UTIL_LogPrintf + ( + "Team \"CT\" scored \"%i\" with \"%i\" players\n", + mp->m_iNumCTWins, + mp->m_iNumCT + ); + + UTIL_LogPrintf + ( + "Team \"TERRORIST\" scored \"%i\" with \"%i\" players\n", + mp->m_iNumTerroristWins, + mp->m_iNumTerrorist + ); + } + + // let the players know + UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Game_will_restart_in", UTIL_dtos1(iRestartDelay), (iRestartDelay == 1) ? "SECOND" : "SECONDS"); + UTIL_ClientPrintAll(HUD_PRINTCONSOLE, "#Game_will_restart_in_console", UTIL_dtos1(iRestartDelay), (iRestartDelay == 1) ? "SECOND" : "SECONDS"); + + m_fTeamCount = gpGlobals->time + iRestartDelay; + m_bCompleteReset = true; + + CVAR_SET_FLOAT("sv_restartround", 0); + CVAR_SET_FLOAT("sv_restart", 0); + + CareerRestart(); + } +} + /* <115189> ../cstrike/dlls/multiplay_gamerules.cpp:2922 */ bool CHalfLifeMultiplay::HasRoundTimeExpired(void) { - if (TimeRemaining() > 0 || m_iRoundWinStatus) + // We haven't completed other objectives, so go for this!. + if (TimeRemaining() > 0 || m_iRoundWinStatus != 0) { return false; } @@ -2827,35 +3079,58 @@ BOOL CHalfLifeMultiplay::__MAKE_VHOOK(FShouldSwitchWeapon)(CBasePlayer *pPlayer, /* <113eec> ../cstrike/dlls/multiplay_gamerules.cpp:3071 */ BOOL CHalfLifeMultiplay::__MAKE_VHOOK(GetNextBestWeapon)(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon) { + CBasePlayerItem *pCheck; + CBasePlayerItem *pBest; // this will be used in the event that we don't find a weapon in the same category. + int iBestWeight; + int i; + if (!pCurrentWeapon->CanHolster()) - return FALSE; - - int iBestWeight = -1; - CBasePlayerItem *pBest = NULL; - - for (int i = 0; i < MAX_ITEM_TYPES; i++) { - CBasePlayerItem *pCheck = pPlayer->m_rgpPlayerItems[i]; + // can't put this gun away right now, so can't switch. + return FALSE; + } + + iBestWeight = -1; // no weapon lower than -1 can be autoswitched to + pBest = NULL; + + for (i = 0; i < MAX_ITEM_TYPES; i++) + { + pCheck = pPlayer->m_rgpPlayerItems[i]; while (pCheck != NULL) { - if (pCheck->iWeight() > iBestWeight && pCheck != pCurrentWeapon && pCheck->CanDeploy()) + // don't reselect the weapon we're trying to get rid of + if (pCheck->iWeight() > iBestWeight && pCheck != pCurrentWeapon) { - iBestWeight = pCheck->iWeight(); - pBest = pCheck; + //ALERT (at_console, "Considering %s\n", STRING(pCheck->pev->classname)); + // we keep updating the 'best' weapon just in case we can't find a weapon of the same weight + // that the player was using. This will end up leaving the player with his heaviest-weighted + // weapon. + + if (pCheck->CanDeploy()) + { + // if this weapon is useable, flag it as the best + iBestWeight = pCheck->iWeight(); + pBest = pCheck; + } } pCheck = pCheck->m_pNext; } } - if (pBest != NULL) + // if we make it here, we've checked all the weapons and found no useable + // weapon in the same catagory as the current weapon. + + // if pBest is null, we didn't find ANYTHING. Shouldn't be possible- should always + // at least get the crowbar, but ya never know. + if (pBest == NULL) { - pPlayer->SwitchWeapon(pBest); - return TRUE; + return FALSE; } - return FALSE; + pPlayer->SwitchWeapon(pBest); + return TRUE; } /* <113aa5> ../cstrike/dlls/multiplay_gamerules.cpp:3132 */ @@ -2907,7 +3182,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl) MESSAGE_END(); } - // sending just one score makes the hud scoreboard active; otherwise + // sending just one score makes the hud scoreboard active; otherwise // it is just disabled for single play MESSAGE_BEGIN(MSG_ONE, gmsgScoreInfo, NULL, pl->edict()); WRITE_BYTE(ENTINDEX(pl->edict())); @@ -2934,7 +3209,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl) // loop through all active players and send their score info to the new client for (i = 1; i <= gpGlobals->maxClients; i++) { - // FIXME: Probably don't need to cast this just to read m_iDeaths + // FIXME: Probably don't need to cast this just to read m_iDeaths CBasePlayer *plr = reinterpret_cast(UTIL_PlayerByIndex(i)); if (plr != NULL) @@ -3229,12 +3504,12 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(PlayerThink)(CBasePlayer *pPlayer) } } +// Purpose: Player has just spawned. Equip them. + /* <113bcf> ../cstrike/dlls/multiplay_gamerules.cpp:3523 */ void CHalfLifeMultiplay::__MAKE_VHOOK(PlayerSpawn)(CBasePlayer *pPlayer) { - BOOL addDefault; - CBaseEntity *pWeaponEntity = NULL; - + // This is tied to the joining state (m_iJoiningState).. add it when the joining state is there. if (pPlayer->m_bJustConnected) { return; @@ -3242,15 +3517,19 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(PlayerSpawn)(CBasePlayer *pPlayer) pPlayer->pev->weapons |= (1 << WEAPON_SUIT); - addDefault = TRUE; + bool addDefault = true; + CBaseEntity *pWeaponEntity = NULL; while ((pWeaponEntity = UTIL_FindEntityByClassname(pWeaponEntity, "game_player_equip")) != NULL) { pWeaponEntity->Touch(pPlayer); - addDefault = FALSE; + addDefault = false; } - if ((!pPlayer->m_bNotKilled && addDefault) || pPlayer->m_bIsVIP) + if (pPlayer->m_bNotKilled) + addDefault = false; + + if (addDefault || pPlayer->m_bIsVIP) { pPlayer->GiveDefaultItems(); } @@ -3261,24 +3540,35 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(PlayerSpawn)(CBasePlayer *pPlayer) /* <113d74> ../cstrike/dlls/multiplay_gamerules.cpp:3553 */ BOOL CHalfLifeMultiplay::__MAKE_VHOOK(FPlayerCanRespawn)(CBasePlayer *pPlayer) { + // Player cannot respawn twice in a round if (pPlayer->m_iNumSpawns > 0) { return FALSE; } + // Player cannot respawn until next round if more than 20 seconds in + + // Tabulate the number of players on each team. m_iNumCT = CountTeamPlayers(CT); m_iNumTerrorist = CountTeamPlayers(TERRORIST); - if (m_iNumTerrorist > 0 && m_iNumCT > 0 && (gpGlobals->time > m_fRoundCount + 20.0f)) - { - if (fadetoblack.value != 0.0f) - { - UTIL_ScreenFade(pPlayer, Vector(0, 0, 0), 3, 3, 255, (FFADE_OUT | FFADE_STAYOUT)); - } - return FALSE; + if (m_iNumTerrorist > 0 && m_iNumCT > 0) + { + // If this player just connected and fadetoblack is on, then maybe + // the server admin doesn't want him peeking around. + if (gpGlobals->time > m_fRoundCount + 20.0f) + { + if (fadetoblack.value != 0.0f) + { + UTIL_ScreenFade(pPlayer, Vector(0, 0, 0), 3, 3, 255, (FFADE_OUT | FFADE_STAYOUT)); + } + + return FALSE; + } } + // Player cannot respawn while in the Choose Appearance menu if (pPlayer->m_iMenu == Menu_ChooseAppearance) { return FALSE; @@ -3340,13 +3630,15 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvar FireTargets("game_playerdie", pVictim, pVictim, USE_TOGGLE, 0); + // Did the player kill himself? if (pVictim->pev == pKiller) { - // killed self + // Players lose a frag for killing themselves pKiller->frags -= 1; } else if (peKiller && peKiller->IsPlayer()) { + // if a player dies in a deathmatch game and the killer is a client, award the killer some points CBasePlayer *killer = GetClassPtr((CBasePlayer *)pKiller); if (killer->m_iTeam == pVictim->m_iTeam) @@ -3467,6 +3759,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(DeathNotice)(CBasePlayer *pVictim, entvars char *tau = "tau_cannon"; char *gluon = "gluon gun"; + // Is the killer a client? if (pKiller->flags & FL_CLIENT) { killer_index = ENTINDEX(ENT(pKiller)); @@ -3475,7 +3768,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(DeathNotice)(CBasePlayer *pVictim, entvars { if (pevInflictor == pKiller) { - // If the inflictor is the killer, then it must be their current weapon doing the damage + // If the inflictor is the killer, then it must be their current weapon doing the damage CBasePlayer *pPlayer = reinterpret_cast(CBaseEntity::Instance(pKiller)); if (pPlayer && pPlayer->m_pActiveItem) @@ -3485,7 +3778,8 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(DeathNotice)(CBasePlayer *pVictim, entvars } else { - killer_weapon_name = STRING(pevInflictor->classname); // it's just that easy + // it's just that easy + killer_weapon_name = STRING(pevInflictor->classname); } } } @@ -3524,6 +3818,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(DeathNotice)(CBasePlayer *pVictim, entvars else if (!Q_strcmp(killer_weapon_name, "gauss")) killer_weapon_name = tau; + // Did he kill himself? if (pVictim->pev == pKiller) { // killed self @@ -3615,7 +3910,7 @@ float CHalfLifeMultiplay::__MAKE_VHOOK(FlWeaponRespawnTime)(CBasePlayerItem *pWe } // FlWeaponRespawnTime - Returns 0 if the weapon can respawn -// now, otherwise it returns the time at which it can try +// now, otherwise it returns the time at which it can try // to spawn again. /* <114058> ../cstrike/dlls/multiplay_gamerules.cpp:3938 */ @@ -3626,7 +3921,7 @@ float CHalfLifeMultiplay::__MAKE_VHOOK(FlWeaponTryRespawn)(CBasePlayerItem *pWea if (NUMBER_OF_ENTITIES() < (gpGlobals->maxEntities - ENTITY_INTOLERANCE)) return 0; - // we're past the entity tolerance level, so delay the respawn + // we're past the entity tolerance level, so delay the respawn return FlWeaponRespawnTime(pWeapon); } @@ -4137,7 +4432,7 @@ int CountPlayers(void) { CBaseEntity *pEnt = UTIL_PlayerByIndex(i); - if (pEnt) + if (pEnt != NULL) { num = num + 1; } @@ -4509,7 +4804,7 @@ void CHalfLifeMultiplay::SendMOTDToClient(edict_t *client) MESSAGE_END(); // Send the message of the day - // read it chunk-by-chunk, and send it in parts + // read it chunk-by-chunk, and send it in parts while (pFileList && *pFileList && char_count < MAX_MOTD_LENGTH) { char chunk[MAX_MOTD_CHUNK + 1]; diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 7785bbb2..c229961a 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -1,9400 +1,9477 @@ -#include "precompiled.h" - -#define DEFINE_WEAPON(m_wpnid, m_cost, m_slotnum, m_acost)\ - { m_wpnid, m_cost, 3, m_slotnum, m_acost } - -/* -* Globals initialization -*/ -#ifndef HOOK_GAMEDLL - -int giPrecacheGrunt = 0; -int gmsgFlashlight = 0; -int gmsgFlashBattery = 0; -int gmsgResetHUD = 0; -int gmsgInitHUD = 0; -int gmsgViewMode = 0; -int gmsgShowGameTitle = 0; -int gmsgCurWeapon = 0; -int gmsgHealth = 0; -int gmsgDamage = 0; -int gmsgBattery = 0; -int gmsgTrain = 0; -int gmsgLogo = 0; -int gmsgWeaponList = 0; -int gmsgAmmoX = 0; -int gmsgDeathMsg = 0; -int gmsgScoreAttrib = 0; -int gmsgScoreInfo = 0; -int gmsgTeamInfo = 0; -int gmsgTeamScore = 0; -int gmsgGameMode = 0; -int gmsgMOTD = 0; -int gmsgServerName = 0; -int gmsgAmmoPickup = 0; -int gmsgItemPickup = 0; -int gmsgHideWeapon = 0; -int gmsgSayText = 0; -int gmsgTextMsg = 0; -int gmsgSetFOV = 0; -int gmsgShowMenu = 0; -int gmsgSendAudio = 0; -int gmsgRoundTime = 0; -int gmsgMoney = 0; -int gmsgBlinkAcct = 0; -int gmsgArmorType = 0; -int gmsgStatusValue = 0; -int gmsgStatusText = 0; -int gmsgStatusIcon = 0; -int gmsgBarTime = 0; -int gmsgReloadSound = 0; -int gmsgCrosshair = 0; -int gmsgNVGToggle = 0; -int gmsgRadar = 0; -int gmsgSpectator = 0; -int gmsgVGUIMenu = 0; -int gmsgCZCareer = 0; -int gmsgCZCareerHUD = 0; -int gmsgTaskTime = 0; -int gmsgTutorText = 0; -int gmsgTutorLine = 0; -int gmsgShadowIdx = 0; -int gmsgTutorState = 0; -int gmsgTutorClose = 0; -int gmsgAllowSpec = 0; -int gmsgBombDrop = 0; -int gmsgBombPickup = 0; -int gmsgHostagePos = 0; -int gmsgHostageK = 0; -int gmsgGeigerRange = 0; -int gmsgSendCorpse = 0; -int gmsgHLTV = 0; -int gmsgSpecHealth = 0; -int gmsgForceCam = 0; -int gmsgADStop = 0; -int gmsgReceiveW = 0; -int gmsgScenarioIcon = 0; -int gmsgBotVoice = 0; -int gmsgBuyClose = 0; -int gmsgItemStatus = 0; -int gmsgLocation = 0; -int gmsgSpecHealth2 = 0; -int gmsgBarTime2 = 0; -int gmsgBotProgress = 0; -int gmsgBrass = 0; -int gmsgFog = 0; -int gmsgShowTimer = 0; - -BOOL gInitHUD = TRUE; -cvar_t *sv_aim = NULL; - -TYPEDESCRIPTION CRevertSaved::m_SaveData[] = -{ - DEFINE_FIELD(CRevertSaved, m_messageTime, FIELD_FLOAT), - DEFINE_FIELD(CRevertSaved, m_loadTime, FIELD_FLOAT), -}; - -TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] = -{ - DEFINE_FIELD(CBasePlayer, m_flFlashLightTime, FIELD_TIME), - DEFINE_FIELD(CBasePlayer, m_iFlashBattery, FIELD_INTEGER), - DEFINE_FIELD(CBasePlayer, m_afButtonLast, FIELD_INTEGER), - DEFINE_FIELD(CBasePlayer, m_afButtonPressed, FIELD_INTEGER), - DEFINE_FIELD(CBasePlayer, m_afButtonReleased, FIELD_INTEGER), - DEFINE_ARRAY(CBasePlayer, m_rgItems, FIELD_INTEGER, MAX_ITEMS), - DEFINE_FIELD(CBasePlayer, m_afPhysicsFlags, FIELD_INTEGER), - DEFINE_FIELD(CBasePlayer, m_flTimeStepSound, FIELD_TIME), - DEFINE_FIELD(CBasePlayer, m_flTimeWeaponIdle, FIELD_TIME), - DEFINE_FIELD(CBasePlayer, m_flSwimTime, FIELD_TIME), - DEFINE_FIELD(CBasePlayer, m_flDuckTime, FIELD_TIME), - DEFINE_FIELD(CBasePlayer, m_flWallJumpTime, FIELD_TIME), - DEFINE_FIELD(CBasePlayer, m_flSuitUpdate, FIELD_TIME), - DEFINE_ARRAY(CBasePlayer, m_rgSuitPlayList, FIELD_INTEGER, CSUITPLAYLIST), - DEFINE_FIELD(CBasePlayer, m_iSuitPlayNext, FIELD_INTEGER), - DEFINE_ARRAY(CBasePlayer, m_rgiSuitNoRepeat, FIELD_INTEGER, CSUITNOREPEAT), - DEFINE_ARRAY(CBasePlayer, m_rgflSuitNoRepeatTime, FIELD_TIME, CSUITNOREPEAT), - DEFINE_FIELD(CBasePlayer, m_lastDamageAmount, FIELD_INTEGER), - DEFINE_ARRAY(CBasePlayer, m_rgpPlayerItems, FIELD_CLASSPTR, MAX_ITEM_TYPES), - DEFINE_FIELD(CBasePlayer, m_pActiveItem, FIELD_CLASSPTR), - DEFINE_FIELD(CBasePlayer, m_pLastItem, FIELD_CLASSPTR), - DEFINE_ARRAY(CBasePlayer, m_rgAmmo, FIELD_INTEGER, MAX_AMMO_SLOTS), - DEFINE_FIELD(CBasePlayer, m_idrowndmg, FIELD_INTEGER), - DEFINE_FIELD(CBasePlayer, m_idrownrestored, FIELD_INTEGER), - DEFINE_FIELD(CBasePlayer, m_tSneaking, FIELD_TIME), - DEFINE_FIELD(CBasePlayer, m_iTrain, FIELD_INTEGER), - DEFINE_FIELD(CBasePlayer, m_bitsHUDDamage, FIELD_INTEGER), - DEFINE_FIELD(CBasePlayer, m_flFallVelocity, FIELD_FLOAT), - DEFINE_FIELD(CBasePlayer, m_iTargetVolume, FIELD_INTEGER), - DEFINE_FIELD(CBasePlayer, m_iWeaponVolume, FIELD_INTEGER), - DEFINE_FIELD(CBasePlayer, m_iExtraSoundTypes, FIELD_INTEGER), - DEFINE_FIELD(CBasePlayer, m_iWeaponFlash, FIELD_INTEGER), - DEFINE_FIELD(CBasePlayer, m_fLongJump, FIELD_BOOLEAN), - DEFINE_FIELD(CBasePlayer, m_fInitHUD, FIELD_BOOLEAN), - DEFINE_FIELD(CBasePlayer, m_tbdPrev, FIELD_TIME), - DEFINE_FIELD(CBasePlayer, m_pTank, FIELD_EHANDLE), - DEFINE_FIELD(CBasePlayer, m_iHideHUD, FIELD_INTEGER), - DEFINE_FIELD(CBasePlayer, m_iFOV, FIELD_INTEGER), - DEFINE_FIELD(CBasePlayer, m_flDisplayHistory, FIELD_INTEGER), - DEFINE_FIELD(CBasePlayer, m_iJoiningState, FIELD_INTEGER), -}; - -WeaponStruct g_weaponStruct[ MAX_WEAPONS ] = -{ - { 0, 0, 0, 0, 0 }, - - { WEAPON_P228, P228_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_357SIG_PRICE }, - { WEAPON_SCOUT, SCOUT_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_762MM_PRICE }, - { WEAPON_XM1014, XM1014_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_BUCKSHOT_PRICE }, - { WEAPON_MAC10, MAC10_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_45ACP_PRICE }, - { WEAPON_AUG, AUG_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, - { WEAPON_ELITE, ELITE_PRICE, CT, AUTOBUYCLASS_SECONDARY, AMMO_9MM_PRICE }, - { WEAPON_FIVESEVEN, FIVESEVEN_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_57MM_PRICE }, - { WEAPON_UMP45, UMP45_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_45ACP_PRICE }, - { WEAPON_SG550, SG550_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, - { WEAPON_USP, USP_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_45ACP_PRICE }, - { WEAPON_GLOCK18, GLOCK18_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_9MM_PRICE }, - { WEAPON_MP5N, MP5NAVY_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_9MM_PRICE }, - { WEAPON_AWP, AWP_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_338MAG_PRICE }, - { WEAPON_M249, M249_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, - { WEAPON_M3, M3_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_BUCKSHOT_PRICE }, - { WEAPON_M4A1, M4A1_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, - { WEAPON_TMP, TMP_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_9MM_PRICE }, - { WEAPON_G3SG1, G3SG1_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_762MM_PRICE }, - { WEAPON_DEAGLE, DEAGLE_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_50AE_PRICE }, - { WEAPON_SG552, SG552_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, - { WEAPON_AK47, AK47_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_762MM_PRICE }, - { WEAPON_P90, P90_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_57MM_PRICE }, - { WEAPON_FAMAS, FAMAS_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, - { WEAPON_GALIL, GALIL_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, - // TODO: this have bug, the cost of galil $2000, but not $2250 - - { WEAPON_SHIELDGUN, SHIELDGUN_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, 0 }, - - { 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0 } -}; - -char *CDeadHEV::m_szPoses[] = -{ - "deadback", - "deadsitting", - "deadstomach", - "deadtable" -}; - -#else //HOOK_GAMEDLL - -int giPrecacheGrunt; -int gmsgWeapPickup; -int gmsgHudText; -int gmsgHudTextArgs; -int gmsgShake; -int gmsgFade; -int gmsgFlashlight; -int gmsgFlashBattery; -int gmsgResetHUD; -int gmsgInitHUD; -int gmsgViewMode; -int gmsgShowGameTitle; -int gmsgCurWeapon; -int gmsgHealth; -int gmsgDamage; -int gmsgBattery; -int gmsgTrain; -int gmsgLogo; -int gmsgWeaponList; -int gmsgAmmoX; -int gmsgDeathMsg; -int gmsgScoreAttrib; -int gmsgScoreInfo; -int gmsgTeamInfo; -int gmsgTeamScore; -int gmsgGameMode; -int gmsgMOTD; -int gmsgServerName; -int gmsgAmmoPickup; -int gmsgItemPickup; -int gmsgHideWeapon; -int gmsgSayText; -int gmsgTextMsg; -int gmsgSetFOV; -int gmsgShowMenu; -int gmsgSendAudio; -int gmsgRoundTime; -int gmsgMoney; -int gmsgBlinkAcct; -int gmsgArmorType; -int gmsgStatusValue; -int gmsgStatusText; -int gmsgStatusIcon; -int gmsgBarTime; -int gmsgReloadSound; -int gmsgCrosshair; -int gmsgNVGToggle; -int gmsgRadar; -int gmsgSpectator; -int gmsgVGUIMenu; -int gmsgCZCareer; -int gmsgCZCareerHUD; -int gmsgTaskTime; -int gmsgTutorText; -int gmsgTutorLine; -int gmsgShadowIdx; -int gmsgTutorState; -int gmsgTutorClose; -int gmsgAllowSpec; -int gmsgBombDrop; -int gmsgBombPickup; -int gmsgHostagePos; -int gmsgHostageK; -int gmsgGeigerRange; -int gmsgSendCorpse; -int gmsgHLTV; -int gmsgSpecHealth; -int gmsgForceCam; -int gmsgADStop; -int gmsgReceiveW; -int gmsgScenarioIcon; -int gmsgBotVoice; -int gmsgBuyClose; -int gmsgItemStatus; -int gmsgLocation; -int gmsgSpecHealth2; -int gmsgBarTime2; -int gmsgBotProgress; -int gmsgBrass; -int gmsgFog; -int gmsgShowTimer; - -BOOL gInitHUD; -cvar_t *sv_aim; - -TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CRevertSaved, m_SaveData)[2]; -TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CBasePlayer, m_playerSaveData)[40]; -WeaponStruct g_weaponStruct[ MAX_WEAPONS ]; -char *(*CDeadHEV::pm_szPoses)[4]; - -#endif //HOOK_GAMEDLL - -//int giPrecacheGrunt; -int gEvilImpulse101; -char g_szMapBriefingText[512]; - -entvars_t *g_pevLastInflictor; -CBaseEntity *g_pLastSpawn; -CBaseEntity *g_pLastCTSpawn; -CBaseEntity *g_pLastTerroristSpawn; - -/* <14e3fc> ../cstrike/dlls/player.cpp:5868 */ -struct ZombieSpawn -{ - CBaseEntity *entity; - CountdownTimer useableTimer; - -};/* size: 12, cachelines: 1, members: 2 */ - -ZombieSpawn zombieSpawn[256]; -int zombieSpawnCount; - -/* <15353b> ../cstrike/dlls/player.cpp:282 */ -void LinkUserMessages(void) -{ - if (gmsgCurWeapon) - return; - - gmsgCurWeapon = REG_USER_MSG("CurWeapon", 3); - gmsgGeigerRange = REG_USER_MSG("Geiger", 1); - gmsgFlashlight = REG_USER_MSG("Flashlight", 2); - gmsgFlashBattery = REG_USER_MSG("FlashBat", 1); - gmsgHealth = REG_USER_MSG("Health", 1); - gmsgDamage = REG_USER_MSG("Damage", 12); - gmsgBattery = REG_USER_MSG("Battery", 2); - gmsgTrain = REG_USER_MSG("Train", 1); - gmsgHudText = REG_USER_MSG("HudTextPro", -1); - REG_USER_MSG("HudText", -1); - gmsgSayText = REG_USER_MSG("SayText", -1); - gmsgTextMsg = REG_USER_MSG("TextMsg", -1); - gmsgWeaponList = REG_USER_MSG("WeaponList", -1); - gmsgResetHUD = REG_USER_MSG("ResetHUD", 0); - gmsgInitHUD = REG_USER_MSG("InitHUD", 0); - gmsgViewMode = REG_USER_MSG("ViewMode", 0); - gmsgShowGameTitle = REG_USER_MSG("GameTitle", 1); - gmsgDeathMsg = REG_USER_MSG("DeathMsg", -1); - gmsgScoreAttrib = REG_USER_MSG("ScoreAttrib", 2); - gmsgScoreInfo = REG_USER_MSG("ScoreInfo", 9); - gmsgTeamInfo = REG_USER_MSG("TeamInfo", -1); - gmsgTeamScore = REG_USER_MSG("TeamScore", -1); - gmsgGameMode = REG_USER_MSG("GameMode", 1); - gmsgMOTD = REG_USER_MSG("MOTD", -1); - gmsgServerName = REG_USER_MSG("ServerName", -1); - gmsgAmmoPickup = REG_USER_MSG("AmmoPickup", 2); - gmsgWeapPickup = REG_USER_MSG("WeapPickup", 1); - gmsgItemPickup = REG_USER_MSG("ItemPickup", -1); - gmsgHideWeapon = REG_USER_MSG("HideWeapon", 1); - gmsgSetFOV = REG_USER_MSG("SetFOV", 1); - gmsgShowMenu = REG_USER_MSG("ShowMenu", -1); - gmsgShake = REG_USER_MSG("ScreenShake", 6); - gmsgFade = REG_USER_MSG("ScreenFade", 10); - gmsgAmmoX = REG_USER_MSG("AmmoX", 2); - gmsgSendAudio = REG_USER_MSG("SendAudio", -1); - gmsgRoundTime = REG_USER_MSG("RoundTime", 2); - gmsgMoney = REG_USER_MSG("Money", 5); - gmsgArmorType = REG_USER_MSG("ArmorType", 1); - gmsgBlinkAcct = REG_USER_MSG("BlinkAcct", 1); - gmsgStatusValue = REG_USER_MSG("StatusValue", -1); - gmsgStatusText = REG_USER_MSG("StatusText", -1); - gmsgStatusIcon = REG_USER_MSG("StatusIcon", -1); - gmsgBarTime = REG_USER_MSG("BarTime", 2); - gmsgReloadSound = REG_USER_MSG("ReloadSound", 2); - gmsgCrosshair = REG_USER_MSG("Crosshair", 1); - gmsgNVGToggle = REG_USER_MSG("NVGToggle", 1); - gmsgRadar = REG_USER_MSG("Radar", 7); - gmsgSpectator = REG_USER_MSG("Spectator", 2); - gmsgVGUIMenu = REG_USER_MSG("VGUIMenu", -1); - gmsgTutorText = REG_USER_MSG("TutorText", -1); - gmsgTutorLine = REG_USER_MSG("TutorLine", -1); - gmsgTutorState = REG_USER_MSG("TutorState", -1); - gmsgTutorClose = REG_USER_MSG("TutorClose", -1); - gmsgAllowSpec = REG_USER_MSG("AllowSpec", 1); - gmsgBombDrop = REG_USER_MSG("BombDrop", 7); - gmsgBombPickup = REG_USER_MSG("BombPickup", 0); - gmsgSendCorpse = REG_USER_MSG("ClCorpse", -1); - gmsgHostagePos = REG_USER_MSG("HostagePos", 8); - gmsgHostageK = REG_USER_MSG("HostageK", 1); - gmsgHLTV = REG_USER_MSG("HLTV", 2); - gmsgSpecHealth = REG_USER_MSG("SpecHealth", 1); - gmsgForceCam = REG_USER_MSG("ForceCam", 3); - gmsgADStop = REG_USER_MSG("ADStop", 0); - gmsgReceiveW = REG_USER_MSG("ReceiveW", 1); - gmsgCZCareer = REG_USER_MSG("CZCareer", -1); - gmsgCZCareerHUD = REG_USER_MSG("CZCareerHUD", -1); - gmsgShadowIdx = REG_USER_MSG("ShadowIdx", 4); - gmsgTaskTime = REG_USER_MSG("TaskTime", 4); - gmsgScenarioIcon = REG_USER_MSG("Scenario", -1); - gmsgBotVoice = REG_USER_MSG("BotVoice", 2); - gmsgBuyClose = REG_USER_MSG("BuyClose", 0); - gmsgSpecHealth2 = REG_USER_MSG("SpecHealth2", 2); - gmsgBarTime2 = REG_USER_MSG("BarTime2", 4); - gmsgItemStatus = REG_USER_MSG("ItemStatus", 1); - gmsgLocation = REG_USER_MSG("Location", -1); - gmsgBotProgress = REG_USER_MSG("BotProgress", -1); - gmsgBrass = REG_USER_MSG("Brass", -1); - gmsgFog = REG_USER_MSG("Fog", 7); - gmsgShowTimer = REG_USER_MSG("ShowTimer", 0); - gmsgHudTextArgs = REG_USER_MSG("HudTextArgs", -1); -} - -/* <1535a5> ../cstrike/dlls/player.cpp:380 */ -void WriteSigonMessages(void) -{ - for (int i = 0; i < MAX_WEAPONS; i++) - { - ItemInfo &II = IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, ItemInfoArray)[i]; - - if (!II.iId) - continue; - - const char *pszName; - if (!II.pszName) - pszName = "Empty"; - else - pszName = II.pszName; - - MESSAGE_BEGIN(MSG_INIT, gmsgWeaponList); - WRITE_STRING(pszName); - WRITE_BYTE(CBasePlayer::GetAmmoIndex(II.pszAmmo1)); - WRITE_BYTE(II.iMaxAmmo1); - WRITE_BYTE(CBasePlayer::GetAmmoIndex(II.pszAmmo2)); - WRITE_BYTE(II.iMaxAmmo2); - WRITE_BYTE(II.iSlot); - WRITE_BYTE(II.iPosition); - WRITE_BYTE(II.iId); - WRITE_BYTE(II.iFlags); - MESSAGE_END(); - } -} - -/* <15f281> ../cstrike/dlls/player.cpp:425 */ -LINK_ENTITY_TO_CLASS(player, CBasePlayer); - -/* <1536a9> ../cstrike/dlls/player.cpp:429 */ -void SendItemStatus(CBasePlayer *pPlayer) -{ - int itemStatus = 0; - if (pPlayer->m_bHasNightVision) - itemStatus |= ITEM_STATUS_NIGHTVISION; - - if (pPlayer->m_bHasDefuser) - itemStatus |= ITEM_STATUS_DEFUSER; - - MESSAGE_BEGIN(MSG_ONE, gmsgItemStatus, NULL, pPlayer->pev); - WRITE_BYTE(itemStatus); - MESSAGE_END(); -} - -/* <150ed5> ../cstrike/dlls/player.cpp:438 */ -const char *GetCSModelName(int item_id) -{ - const char *modelName = NULL; - switch (item_id) - { - case WEAPON_P228: modelName = "models/w_p228.mdl"; break; - case WEAPON_SCOUT: modelName = "models/w_scout.mdl"; break; - case WEAPON_HEGRENADE: modelName = "models/w_hegrenade.mdl"; break; - case WEAPON_XM1014: modelName = "models/w_xm1014.mdl"; break; - case WEAPON_C4: modelName = "models/w_backpack.mdl"; break; - case WEAPON_MAC10: modelName = "models/w_mac10.mdl"; break; - case WEAPON_AUG: modelName = "models/w_aug.mdl"; break; - case WEAPON_SMOKEGRENADE: modelName = "models/w_smokegrenade.mdl"; break; - case WEAPON_ELITE: modelName = "models/w_elite.mdl"; break; - case WEAPON_FIVESEVEN: modelName = "models/w_fiveseven.mdl"; break; - case WEAPON_UMP45: modelName = "models/w_ump45.mdl"; break; - case WEAPON_SG550: modelName = "models/w_sg550.mdl"; break; - case WEAPON_GALIL: modelName = "models/w_galil.mdl"; break; - case WEAPON_FAMAS: modelName = "models/w_famas.mdl"; break; - case WEAPON_USP: modelName = "models/w_usp.mdl"; break; - case WEAPON_GLOCK18: modelName = "models/w_glock18.mdl"; break; - case WEAPON_AWP: modelName = "models/w_awp.mdl"; break; - case WEAPON_MP5N: modelName = "models/w_mp5.mdl"; break; - case WEAPON_M249: modelName = "models/w_m249.mdl"; break; - case WEAPON_M3: modelName = "models/w_m3.mdl"; break; - case WEAPON_M4A1: modelName = "models/w_m4a1.mdl"; break; - case WEAPON_TMP: modelName = "models/w_tmp.mdl"; break; - case WEAPON_G3SG1: modelName = "models/w_g3sg1.mdl"; break; - case WEAPON_FLASHBANG: modelName = "models/w_flashbang.mdl"; break; - case WEAPON_DEAGLE: modelName = "models/w_deagle.mdl"; break; - case WEAPON_SG552: modelName = "models/w_sg552.mdl"; break; - case WEAPON_AK47: modelName = "models/w_ak47.mdl"; break; - case WEAPON_KNIFE: modelName = "models/w_knife.mdl"; break; - case WEAPON_P90: modelName = "models/w_p90.mdl"; break; - case WEAPON_SHIELDGUN: modelName = "models/w_shield.mdl"; break; - default: - ALERT(at_console, "CBasePlayer::PackDeadPlayerItems(): Unhandled item- not creating weaponbox\n"); - } - - return modelName; -} - -/* <153737> ../cstrike/dlls/player.cpp:572 */ -void CBasePlayer::SetPlayerModel(BOOL HasC4) -{ - char *infobuffer = GET_INFO_BUFFER(edict()); - char *model; - - if (m_iTeam == CT) - { - switch (m_iModelName) - { - case MODEL_URBAN: - model = "urban"; - break; - case MODEL_GSG9: - model = "gsg9"; - break; - case MODEL_GIGN: - model = "gign"; - break; - case MODEL_SAS: - model = "sas"; - break; - case MODEL_VIP: - model = "vip"; - break; - case MODEL_SPETSNAZ: - if (UTIL_IsGame("czero")) - { - model = "spetsnaz"; - break; - } - default: - { - if (IsBot()) - { - model = (char *)TheBotProfiles->GetCustomSkinModelname(m_iModelName); - if (!model) - model = "urban"; - } - else - model = "urban"; - - break; - } - } - } - else if (m_iTeam == TERRORIST) - { - switch (m_iModelName) - { - case MODEL_TERROR: - model = "terror"; - break; - case MODEL_LEET: - model = "leet"; - break; - case MODEL_ARCTIC: - model = "arctic"; - break; - case MODEL_GUERILLA: - model = "guerilla"; - break; - case MODEL_MILITIA: - if (UTIL_IsGame("czero")) - { - model = "militia"; - break; - } - default: - { - if (IsBot()) - { - model = (char *)TheBotProfiles->GetCustomSkinModelname(m_iModelName); - if (!model) - model = "terror"; - } - else - model = "terror"; - - break; - } - } - } - else - model = "urban"; - - if (Q_strcmp(GET_KEY_VALUE(infobuffer, "model"), model)) - { - SET_CLIENT_KEY_VALUE(entindex(), infobuffer, "model", model); - } -} - -/* <15f129> ../cstrike/dlls/player.cpp:659 */ -NOXREF CBasePlayer *CBasePlayer::GetNextRadioRecipient(CBasePlayer *pStartPlayer) -{ - CBaseEntity *pEntity = (CBaseEntity *)pStartPlayer; - while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")) != NULL) - { - if (FNullEnt(pEntity->edict())) - break; - - BOOL bSend = FALSE; - CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pEntity->pev); - - if (pEntity->IsPlayer()) - { - if (pEntity->IsDormant()) - continue; - - if (pPlayer && pPlayer->m_iTeam == m_iTeam) - bSend = TRUE; - } - else if (pPlayer) - { - int iSpecMode = IsObserver(); - - if (iSpecMode != OBS_CHASE_LOCKED && iSpecMode != OBS_CHASE_FREE && iSpecMode != OBS_IN_EYE) - continue; - - if (!FNullEnt(m_hObserverTarget)) - continue; - - CBasePlayer *pTarget = (CBasePlayer *)CBaseEntity::Instance(pPlayer->m_hObserverTarget->pev); - - if (pTarget && pTarget->m_iTeam == m_iTeam) - { - bSend = TRUE; - } - } - - if (bSend) - { - return pPlayer; - } - } - - return NULL; -} - -/* <15edd2> ../cstrike/dlls/player.cpp:705 */ -void CBasePlayer::Radio(const char *msg_id, const char *msg_verbose, short pitch, bool showIcon) -{ - if (!IsPlayer()) - return; - - if (pev->deadflag != DEAD_NO && !IsBot()) - return; - - CBaseEntity *pEntity = NULL; - while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")) != NULL) - { - if (FNullEnt(pEntity->edict())) - break; - - BOOL bSend = FALSE; - CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pEntity->pev); - - if (pEntity->IsPlayer()) - { - if (pEntity->IsDormant()) - continue; - - if (pEntity && pPlayer->m_iTeam == m_iTeam) - bSend = TRUE; - } - else if (pEntity) - { - int iSpecMode = IsObserver(); - - if (iSpecMode != OBS_CHASE_LOCKED && iSpecMode != OBS_CHASE_FREE && iSpecMode != OBS_IN_EYE) - continue; - - if (!FNullEnt(m_hObserverTarget)) - continue; - - CBasePlayer *pTarget = (CBasePlayer *)CBaseEntity::Instance(pPlayer->m_hObserverTarget->pev); - - if (pTarget && pTarget->m_iTeam == m_iTeam) - bSend = TRUE; - } - - if (!bSend || pPlayer->m_bIgnoreRadio) - continue; - - MESSAGE_BEGIN(MSG_ONE, gmsgSendAudio, NULL, pEntity->pev); - WRITE_BYTE(ENTINDEX(edict())); - WRITE_STRING(msg_id); - WRITE_SHORT(pitch); - MESSAGE_END(); - - if (msg_verbose) - { - // search the place name where is located the player - const char *placeName = NULL; - Place playerPlace = TheNavAreaGrid.GetPlace(&pev->origin); - const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); - - for (BotPhraseList::const_iterator iter = placeList->begin(); iter != placeList->end(); ++iter) - { - if ((*iter)->GetID() == playerPlace) - { - placeName = (*iter)->GetName(); - break; - } - } - - if (placeName != NULL) - ClientPrint(pEntity->pev, HUD_PRINTRADIO, NumAsString(entindex()), "#Game_radio_location", STRING(pev->netname), placeName, msg_verbose); - else - ClientPrint(pEntity->pev, HUD_PRINTRADIO, NumAsString(entindex()), "#Game_radio", STRING(pev->netname), msg_verbose); - } - - if (showIcon) - { - MESSAGE_BEGIN(MSG_ONE, SVC_TEMPENTITY, NULL, pEntity->pev); - WRITE_BYTE(TE_PLAYERATTACHMENT); - WRITE_BYTE(ENTINDEX(edict())); - WRITE_COORD(35); // vertical offset - WRITE_SHORT(g_sModelIndexRadio); // model index - WRITE_SHORT(15); // life - MESSAGE_END(); - } - } -} - -/* <1537f3> ../cstrike/dlls/player.cpp:812 */ -void CBasePlayer::SmartRadio(void) -{ - ; -} - -/* <15381b> ../cstrike/dlls/player.cpp:816 */ -void CBasePlayer::Pain(int m_LastHitGroup, bool HasArmour) -{ - int temp = RANDOM_LONG(0, 2); - - if (m_LastHitGroup == HITGROUP_HEAD) - { - if (m_iKevlar == ARMOR_TYPE_HELMET) - { - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/bhit_helmet-1.wav", VOL_NORM, ATTN_NORM); - return; - } - - switch (temp) - { - case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/headshot1.wav", VOL_NORM, ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/headshot2.wav", VOL_NORM, ATTN_NORM); break; - default: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/headshot3.wav", VOL_NORM, ATTN_NORM); break; - } - } - else - { - if (m_LastHitGroup != HITGROUP_LEFTLEG && m_LastHitGroup != HITGROUP_RIGHTLEG) - { - if (HasArmour) - { - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/bhit_kevlar-1.wav", VOL_NORM, ATTN_NORM); - return; - } - } - - switch (temp) - { - case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/bhit_flesh-1.wav", VOL_NORM, ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/bhit_flesh-2.wav", VOL_NORM, ATTN_NORM); break; - default: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/bhit_flesh-3.wav", VOL_NORM, ATTN_NORM); break; - } - } -} - -/* <153b48> ../cstrike/dlls/player.cpp:864 */ -Vector VecVelocityForDamage(float flDamage) -{ - Vector vec(RANDOM_FLOAT(-100, 100), RANDOM_FLOAT(-100, 100), RANDOM_FLOAT(200, 300)); - - if (flDamage > -50.0f) - vec = vec * 0.7f; - else if (flDamage > -200.0f) - vec = vec * 2.0f; - else - vec = vec * 10.0f; - - return vec; -} - -/* <14edfb> ../cstrike/dlls/player.cpp:878 */ -int TrainSpeed(int iSpeed, int iMax) -{ - float fMax; - float fSpeed; - int iRet = 0; - - fMax = (float)iMax; - fSpeed = iSpeed / fMax; - - if (iSpeed < 0) - iRet = TRAIN_BACK; - else if (iSpeed == 0) - iRet = TRAIN_NEUTRAL; - else if (fSpeed < 0.33) - iRet = TRAIN_SLOW; - else if (fSpeed < 0.66) - iRet = TRAIN_MEDIUM; - else - iRet = TRAIN_FAST; - - return iRet; -} - -/* <153c8e> ../cstrike/dlls/player.cpp:902 */ -void CBasePlayer::DeathSound(void) -{ - // temporarily using pain sounds for death sounds - switch (RANDOM_LONG(1, 4)) - { - case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/die1.wav", VOL_NORM, ATTN_NORM); break; - case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/die2.wav", VOL_NORM, ATTN_NORM); break; - case 3: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/die3.wav", VOL_NORM, ATTN_NORM); break; - case 4: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/death6.wav", VOL_NORM, ATTN_NORM); break; - } -} - -// override takehealth -// bitsDamageType indicates type of damage healed. - -/* <151213> ../cstrike/dlls/player.cpp:937 */ -int CBasePlayer::__MAKE_VHOOK(TakeHealth)(float flHealth, int bitsDamageType) -{ - return CBaseMonster::TakeHealth(flHealth, bitsDamageType); -} - -/* <150f1c> ../cstrike/dlls/player.cpp:943 */ -Vector CBasePlayer::__MAKE_VHOOK(GetGunPosition)(void) -{ - return pev->origin + pev->view_ofs; -} - -/* <15412b> ../cstrike/dlls/player.cpp:953 */ -bool CBasePlayer::IsHittingShield(Vector &vecDirection, TraceResult *ptr) -{ - if ((m_pActiveItem && m_pActiveItem->m_iId == WEAPON_C4) || !HasShield()) - return false; - - if (ptr->iHitgroup == HITGROUP_SHIELD) - return true; - - if (m_bShieldDrawn) - UTIL_MakeVectors(pev->angles); - - return false; -} - -/* <152b58> ../cstrike/dlls/player.cpp:989 */ -void CBasePlayer::__MAKE_VHOOK(TraceAttack)(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) -{ - bool bShouldBleed = true; - bool bShouldSpark = false; - bool bHitShield = IsHittingShield(vecDir, ptr); - CBasePlayer *pAttacker = (CBasePlayer *)CBasePlayer::Instance(pevAttacker); - - if (CVAR_GET_FLOAT("mp_friendlyfire") == 0 && m_iTeam == pAttacker->m_iTeam) - bShouldBleed = false; - - if (pev->takedamage == DAMAGE_NO) - return; - - m_LastHitGroup = ptr->iHitgroup; - if (bHitShield) - { - flDamage = 0; - - if (RANDOM_LONG(0, 1)) - EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/ric_metal-1.wav", VOL_NORM, ATTN_NORM); - else - EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/ric_metal-2.wav", VOL_NORM, ATTN_NORM); - - UTIL_Sparks(ptr->vecEndPos); - - pev->punchangle.x = flDamage * RANDOM_FLOAT(-0.15, 0.15); - pev->punchangle.z = flDamage * RANDOM_FLOAT(-0.15, 0.15); - - if (pev->punchangle.x < 4) - pev->punchangle.x = -4; - - if (pev->punchangle.z < -5) - pev->punchangle.z = -5; - - else if (pev->punchangle.z > 5) - pev->punchangle.z = 5; - } - else - { - switch (ptr->iHitgroup) - { - case HITGROUP_GENERIC: - break; - - case HITGROUP_HEAD: - { - if (m_iKevlar == ARMOR_TYPE_HELMET) - { - bShouldBleed = false; - bShouldSpark = true; - } - - flDamage *= 4; - if (bShouldBleed) - { - pev->punchangle.x = flDamage * -0.5; - - if (pev->punchangle.x < -12) - pev->punchangle.x = -12; - - pev->punchangle.z = flDamage * RANDOM_FLOAT(-1, 1); - - if (pev->punchangle.z < -9) - pev->punchangle.z = -9; - - else if (pev->punchangle.z > 9) - pev->punchangle.z = 9; - } - break; - } - case HITGROUP_CHEST: - { - flDamage *= 1; - - if (m_iKevlar != ARMOR_TYPE_EMPTY) - bShouldBleed = false; - - else if (bShouldBleed) - { - pev->punchangle.x = flDamage * -0.1; - - if (pev->punchangle.x < -4) - pev->punchangle.x = -4; - } - break; - } - case HITGROUP_STOMACH: - { - flDamage = flDamage * 1.25; - - if (m_iKevlar != ARMOR_TYPE_EMPTY) - bShouldBleed = false; - - else if (bShouldBleed) - { - pev->punchangle.x = flDamage * -0.1; - - if (pev->punchangle.x < -4) - pev->punchangle.x = -4; - } - break; - } - case HITGROUP_LEFTARM: - case HITGROUP_RIGHTARM: - { - if (m_iKevlar != ARMOR_TYPE_EMPTY) - bShouldBleed = false; - - break; - } - case HITGROUP_LEFTLEG: - case HITGROUP_RIGHTLEG: - { - flDamage *= 0.75; - break; - } - } - } - - if (bShouldBleed) - { - BloodSplat(ptr->vecEndPos, vecDir, ptr->iHitgroup, flDamage * 5); - SpawnBlood(ptr->vecEndPos, BloodColor(), flDamage); // a little surface blood. - TraceBleed(flDamage, vecDir, ptr, bitsDamageType); - } - else if (ptr->iHitgroup == HITGROUP_HEAD && bShouldSpark == true) - { - MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, ptr->vecEndPos); - WRITE_BYTE(TE_STREAK_SPLASH); - WRITE_COORD(ptr->vecEndPos.x); - WRITE_COORD(ptr->vecEndPos.y); - WRITE_COORD(ptr->vecEndPos.z); - WRITE_COORD(ptr->vecPlaneNormal.x); - WRITE_COORD(ptr->vecPlaneNormal.y); - WRITE_COORD(ptr->vecPlaneNormal.z); - WRITE_BYTE(5); // color - WRITE_SHORT(22); // count - WRITE_SHORT(25); // base speed - WRITE_SHORT(65); // ramdon velocity - MESSAGE_END(); - } - - AddMultiDamage(pevAttacker, this, flDamage, bitsDamageType); -} - -/* <1541c2> ../cstrike/dlls/player.cpp:1171 */ -const char *GetWeaponName(entvars_t *pevInflictor, entvars_t *pKiller) -{ - const char *killer_weapon_name = "world"; - - if (pKiller->flags & FL_CLIENT) - { - //int killer_index = ENTINDEX(ENT(pKiller)); unused! - - if (pevInflictor) - { - if (pevInflictor == pKiller) - { - CBasePlayer *pAttacker = (CBasePlayer *)CBaseEntity::Instance(pKiller); - - if (pAttacker) - { - if (pAttacker->m_pActiveItem) - killer_weapon_name = pAttacker->m_pActiveItem->pszName(); - } - } - else - killer_weapon_name = STRING(pevInflictor->classname); - } - } - else - killer_weapon_name = STRING(pevInflictor->classname); - - if (!Q_strncmp(killer_weapon_name, "weapon_", 7)) - killer_weapon_name += 7; - - else if (!Q_strncmp(killer_weapon_name, "monster_", 8)) - killer_weapon_name += 8; - - else if (Q_strncmp(killer_weapon_name, "func_", 5)) - killer_weapon_name += 5; - - return killer_weapon_name; -} - -/* <14e061> ../cstrike/dlls/player.cpp:1214 */ -void LogAttack(CBasePlayer *pAttacker, CBasePlayer *pVictim, int teamAttack, int healthHit, int armorHit, int newHealth, int newArmor, const char *killer_weapon_name) -{ - int detail = logdetail.value; - - if (!detail) - return; - - if (!pAttacker || !pVictim) - return; - - if ((teamAttack && (detail & LOG_TEAMMATEATTACK)) || (!teamAttack && (detail & LOG_ENEMYATTACK))) - { - UTIL_LogPrintf - ( - "\"%s<%i><%s><%s>\" attacked \"%s<%i><%s><%s>\" with \"%s\" (damage \"%d\") (damage_armor \"%d\") (health \"%d\") (armor \"%d\")\n", - STRING(pAttacker->pev->netname), - GETPLAYERUSERID(pAttacker->edict()), - GETPLAYERAUTHID(pAttacker->edict()), - GetTeam(pAttacker->m_iTeam), - STRING(pVictim->pev->netname), - GETPLAYERUSERID(pVictim->edict()), - GETPLAYERAUTHID(pVictim->edict()), - GetTeam(pVictim->m_iTeam), - killer_weapon_name, - healthHit, - armorHit, - newHealth, - newArmor - ); - } -} - -// Take some damage. -// NOTE: each call to TakeDamage with bitsDamageType set to a time-based damage -// type will cause the damage time countdown to be reset. Thus the ongoing effects of poison, radiation -// etc are implemented with subsequent calls to TakeDamage using DMG_GENERIC. - -/* <15dff9> ../cstrike/dlls/player.cpp:1241 */ -int CBasePlayer::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) -{ - int fTookDamage; - float flRatio = ARMOR_RATIO; - float flBonus = ARMOR_BONUS; - //float flHealthPrev = pev->health; - int iGunType = 0; - float flShieldRatio = 0; - int teamAttack = FALSE; - int armorHit = 0; - CBasePlayer *pAttack = NULL; - CBaseEntity *pAttacker = NULL; - //CBaseEntity *attacker = NULL; // unused - - if (bitsDamageType & (DMG_EXPLOSION | DMG_BLAST | DMG_FALL)) - m_LastHitGroup = HITGROUP_GENERIC; - - else if (m_LastHitGroup == HITGROUP_SHIELD && (bitsDamageType & DMG_BULLET)) - return 0; - - if (HasShield()) - flShieldRatio = 0.2; - - if (m_bIsVIP) - flRatio *= 0.5; - - if (bitsDamageType & (DMG_EXPLOSION | DMG_BLAST)) - { - if (!IsAlive()) - { - return 0; - } - - if (bitsDamageType & DMG_EXPLOSION) - { - CBaseEntity *temp = GetClassPtr((CBaseEntity *)pevInflictor); - - if (!Q_strcmp(STRING(temp->pev->classname), "grenade")) - { - CGrenade *pGrenade = GetClassPtr((CGrenade *)pevInflictor); - - if (CVAR_GET_FLOAT("mp_friendlyfire")) - { - if (pGrenade->m_iTeam == m_iTeam) - teamAttack = TRUE; - - pAttack = reinterpret_cast(CBasePlayer::Instance(pevAttacker)); - } - else if (pGrenade->m_iTeam == m_iTeam && (&edict()->v != pevAttacker)) - { - return 0; - } - } - } - - if (!FNullEnt(ENT(pevInflictor))) - m_vBlastVector = pev->origin - pevInflictor->origin; - - if (pev->armorvalue != 0.0f && IsArmored(m_LastHitGroup)) - { - float_precision flNew = flRatio * flDamage; - float_precision flArmor = (flDamage - flNew) * flBonus; - - // Does this use more armor than we have? - if (flArmor > pev->armorvalue) - { - flNew = flDamage - pev->armorvalue; - armorHit = flArmor; - pev->armorvalue = 0; - } - else - { - int oldValue = pev->armorvalue; - - if (flArmor < 0.0) - flArmor = 1.0; - - pev->armorvalue -= flArmor; - armorHit = oldValue - pev->armorvalue; - } - - flDamage = flNew; - - if (pev->armorvalue <= 0.0) - m_iKevlar = ARMOR_TYPE_EMPTY; - - Pain(m_LastHitGroup, true); - } - else - Pain(m_LastHitGroup, false); - - m_lastDamageAmount = flDamage; - - if (pev->health > flDamage) - { - SetAnimation(PLAYER_FLINCH); - Pain(m_LastHitGroup, false); - } - else - { - if (bitsDamageType & DMG_BLAST) - m_bKilledByBomb = true; - - else if (bitsDamageType & DMG_EXPLOSION) - m_bKilledByGrenade = true; - } - - LogAttack(pAttack, this, teamAttack, (int)flDamage, armorHit, pev->health - flDamage, pev->armorvalue, GetWeaponName(pevInflictor, pevAttacker)); - fTookDamage = CBaseMonster::TakeDamage(pevInflictor, pevAttacker, (int)flDamage, bitsDamageType); - - if (fTookDamage > 0) - { - CHalfLifeMultiplay *mp = g_pGameRules; - - if (TheBots) - TheBots->OnEvent(EVENT_PLAYER_TOOK_DAMAGE, this, pAttack); - - if (mp->IsCareer()) - { - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); - - if (!pPlayer) - continue; - - bool killedByHumanPlayer = (!pPlayer->IsBot() && pPlayer->pev == pevAttacker && pPlayer->m_iTeam != m_iTeam); - - if (killedByHumanPlayer) - { - TheCareerTasks->HandleEnemyInjury(GetWeaponName(pevInflictor, pevAttacker), pPlayer->HasShield(), pPlayer); - } - } - } - } - - { - // reset damage time countdown for each type of time based damage player just sustained - for (int i = 0; i < CDMG_TIMEBASED; i++) - { - if (bitsDamageType & (DMG_PARALYZE << i)) - m_rgbTimeBasedDamage[i] = 0; - } - } - - // tell director about it - MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR); - WRITE_BYTE(9); // command length in bytes - WRITE_BYTE(DRC_CMD_EVENT); // take damage event - WRITE_SHORT(ENTINDEX(edict())); // index number of primary entity - WRITE_SHORT(ENTINDEX(ENT(pevInflictor))); // index number of secondary entity - WRITE_LONG(5); // eventflags (priority and flags) - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_SPEC, gmsgHLTV); - WRITE_BYTE(ENTINDEX(edict())); - WRITE_BYTE((int)Q_max(pev->health, 0.0f) | DRC_FLAG_FACEPLAYER); - MESSAGE_END(); - - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); - - if (!pPlayer || pPlayer->m_hObserverTarget != this) - continue; - - MESSAGE_BEGIN(MSG_ONE, gmsgSpecHealth, NULL, pPlayer->edict()); - WRITE_BYTE((int)Q_max(pev->health, 0.0f)); - MESSAGE_END(); - } - - return fTookDamage; - } - - pAttacker = CBaseEntity::Instance(pevAttacker); - - if (!g_pGameRules->FPlayerCanTakeDamage(this, pAttacker) && Q_strcmp("grenade", STRING(pevInflictor->classname))) - { - // Refuse the damage - return 0; - } - - if (bitsDamageType & DMG_BLAST && g_pGameRules->IsMultiplayer()) - { - // blasts damage armor more. - flBonus *= 2; - } - - // Already dead - if (!IsAlive()) - return 0; - - pAttacker = GetClassPtr((CBaseEntity *)pevAttacker); - - if (pAttacker->IsPlayer()) - { - pAttack = GetClassPtr((CBasePlayer *)pevAttacker); - - if (pAttack != this && pAttack->m_iTeam == m_iTeam) - { - // TODO: this->m_flDisplayHistory!! - if (!(m_flDisplayHistory & DHF_FRIEND_INJURED)) - { - m_flDisplayHistory |= DHF_FRIEND_INJURED; - pAttack->HintMessage("#Hint_try_not_to_injure_teammates"); - } - - teamAttack = TRUE; - if (gpGlobals->time > pAttack->m_flLastAttackedTeammate + 0.6) - { - CBaseEntity *pBasePlayer = NULL; - while ((pBasePlayer = UTIL_FindEntityByClassname(pBasePlayer, "player")) != NULL) - { - if (FNullEnt(pBasePlayer->edict())) - break; - - CBasePlayer *basePlayer = GetClassPtr((CBasePlayer *)pBasePlayer->pev); - - if (basePlayer->m_iTeam == m_iTeam) - { - ClientPrint(basePlayer->pev, HUD_PRINTTALK, "#Game_teammate_attack", STRING(pAttack->pev->netname)); - } - } - - pAttack->m_flLastAttackedTeammate = gpGlobals->time; - } - } - - if (pAttack->m_iTeam == m_iTeam) - flDamage *= 0.35; - - iGunType = pAttack->m_pActiveItem->m_iId; - - if (pAttack->m_pActiveItem) - { - flRatio += flShieldRatio; - switch (iGunType) - { - case WEAPON_AUG: - case WEAPON_M4A1: flRatio *= 1.4; break; - case WEAPON_AWP: flRatio *= 1.95; break; - case WEAPON_G3SG1: flRatio *= 1.65; break; - case WEAPON_SG550: flRatio *= 1.45; break; - case WEAPON_M249: flRatio *= 1.5; break; - case WEAPON_ELITE: flRatio *= 1.05; break; - case WEAPON_DEAGLE: flRatio *= 1.5; break; - case WEAPON_GLOCK18: flRatio *= 1.05; break; - case WEAPON_FIVESEVEN: - case WEAPON_P90: flRatio *= 1.5; break; - case WEAPON_MAC10: flRatio *= 0.95; break; - case WEAPON_P228: flRatio *= 1.25; break; - case WEAPON_SCOUT: - case WEAPON_KNIFE: flRatio *= 1.7; break; - case WEAPON_FAMAS: - case WEAPON_SG552: flRatio *= 1.4; break; - case WEAPON_GALIL: - case WEAPON_AK47: flRatio *= 1.55; break; - } - } - - if (!ShouldDoLargeFlinch(m_LastHitGroup, iGunType)) - { - m_flVelocityModifier = 0.5f; - - if (m_LastHitGroup == HITGROUP_HEAD) - m_bHighDamage = (flDamage > 60); - else - m_bHighDamage = (flDamage > 20); - - SetAnimation(PLAYER_FLINCH); - } - else - { - if (pev->velocity.Length() < 300) - { - Vector attack_velocity = (pev->origin - pAttack->pev->origin).Normalize() * 170; - pev->velocity = pev->velocity + attack_velocity; - - m_flVelocityModifier = 0.65f; - } - SetAnimation(PLAYER_LARGE_FLINCH); - } - } - - // keep track of amount of damage last sustained - m_lastDamageAmount = flDamage; - - // Armor - // armor doesn't protect against fall or drown damage! - if (pev->armorvalue != 0.0f && !(bitsDamageType & (DMG_DROWN | DMG_FALL)) && IsArmored(m_LastHitGroup)) - { - float_precision flNew = flRatio * flDamage; - float_precision flArmor = (flDamage - flNew) * flBonus; - - // Does this use more armor than we have? - if (flArmor > pev->armorvalue) - { - armorHit = flArmor; - flArmor = pev->armorvalue; - flArmor *= (1 / flBonus); - flNew = flDamage - flArmor; - pev->armorvalue = 0; - } - else - { - int oldValue = pev->armorvalue; - - if (flArmor < 0.0) - flArmor = 1.0; - - pev->armorvalue -= flArmor; - armorHit = oldValue - pev->armorvalue; - } - - flDamage = flNew; - - if (pev->armorvalue <= 0.0f) - m_iKevlar = ARMOR_TYPE_EMPTY; - - Pain(m_LastHitGroup, true); - } - else - Pain(m_LastHitGroup, false); - - LogAttack(pAttack, this, teamAttack, flDamage, armorHit, pev->health - flDamage, pev->armorvalue, GetWeaponName(pevInflictor, pevAttacker)); - - // this cast to INT is critical!!! If a player ends up with 0.5 health, the engine will get that - // as an int (zero) and think the player is dead! (this will incite a clientside screentilt, etc) - fTookDamage = CBaseMonster::TakeDamage(pevInflictor, pevAttacker, (int)flDamage, bitsDamageType); - - if (fTookDamage > 0) - { - CHalfLifeMultiplay *mp = g_pGameRules; - - if (TheBots) - { - TheBots->OnEvent(EVENT_PLAYER_TOOK_DAMAGE, this, pAttack); - } - - if (mp->IsCareer()) - { - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); - - if (!pPlayer) - continue; - - bool killedByHumanPlayer = (!pPlayer->IsBot() && pPlayer->pev == pevAttacker && pPlayer->m_iTeam != m_iTeam); - - if (killedByHumanPlayer) - { - TheCareerTasks->HandleEnemyInjury(GetWeaponName(pevInflictor, pevAttacker), pPlayer->HasShield(), pPlayer); - } - } - } - } - - { - // reset damage time countdown for each type of time based damage player just sustained - for (int i = 0; i < CDMG_TIMEBASED; i++) - { - if (bitsDamageType & (DMG_PARALYZE << i)) - m_rgbTimeBasedDamage[i] = 0; - } - } - - // tell director about it - MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR); - WRITE_BYTE(9); // command length in bytes - WRITE_BYTE(DRC_CMD_EVENT); // take damage event - WRITE_SHORT(ENTINDEX(edict())); // index number of primary entity - WRITE_SHORT(ENTINDEX(ENT(pevInflictor))); // index number of secondary entity - WRITE_LONG(5); // eventflags (priority and flags) - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_SPEC, gmsgHLTV); - WRITE_BYTE(ENTINDEX(edict())); - WRITE_BYTE((int)Q_max(pev->health, 0.0f) | DRC_FLAG_FACEPLAYER); - MESSAGE_END(); - - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); - - if (!pPlayer) - continue; - - if (pPlayer->m_hObserverTarget == this) - { - MESSAGE_BEGIN(MSG_ONE, gmsgSpecHealth, NULL, pPlayer->edict()); - WRITE_BYTE((int)Q_max(pev->health, 0.0f)); - MESSAGE_END(); - } - } - - // Save this so we can report it to the client - m_bitsHUDDamage = -1; - - // make sure the damage bits get resent - m_bitsDamageType |= bitsDamageType; - - return fTookDamage; -} - -/* <1516a0> ../cstrike/dlls/player.cpp:1706 */ -void packPlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo) -{ - if (pItem) - { - const char *modelName = GetCSModelName(pItem->m_iId); - if (modelName) - { - CWeaponBox *pWeaponBox = (CWeaponBox *)CBaseEntity::Create("weaponbox", pPlayer->pev->origin, pPlayer->pev->angles, ENT(pPlayer->pev)); - - pWeaponBox->pev->angles.x = 0; - pWeaponBox->pev->angles.z = 0; - - pWeaponBox->pev->velocity = pPlayer->pev->velocity * 0.75; - - pWeaponBox->SetThink(&CWeaponBox::Kill); - pWeaponBox->pev->nextthink = gpGlobals->time + 300; - pWeaponBox->PackWeapon(pItem); - - if (packAmmo) - { - pWeaponBox->PackAmmo(MAKE_STRING(IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, ItemInfoArray)[ pItem->m_iId ].pszAmmo1), pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()]); - } - SET_MODEL(ENT(pWeaponBox->pev), modelName); - } - } -} - -/* <15f739> ../cstrike/dlls/player.cpp:1756 */ -void CBasePlayer::PackDeadPlayerItems(void) -{ - bool bPackGun = (g_pGameRules->DeadPlayerWeapons(this) != GR_PLR_DROP_GUN_NO); - bool bPackAmmo = (g_pGameRules->DeadPlayerAmmo(this) != GR_PLR_DROP_AMMO_NO); - - if (bPackGun) - { - bool bShieldDropped = false; - if (HasShield()) - { - DropShield(); - bShieldDropped = true; - } - - int nBestWeight = 0; - CBasePlayerItem *pBestItem = NULL; - - for (int n = 0; n < MAX_ITEM_TYPES; n++) - { - CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[ n ]; - - while (pPlayerItem != NULL) - { - ItemInfo info; - if (pPlayerItem->iItemSlot() < KNIFE_SLOT && !bShieldDropped) - { - if (pPlayerItem->GetItemInfo(&info)) - { - if (info.iWeight > nBestWeight) - { - nBestWeight = info.iWeight; - pBestItem = pPlayerItem; - } - } - } - else if (pPlayerItem->iItemSlot() == GRENADE_SLOT && UTIL_IsGame("czero")) - packPlayerItem(this, pPlayerItem, true); - - pPlayerItem = pPlayerItem->m_pNext; - } - } - packPlayerItem(this, pBestItem, bPackAmmo); - } - RemoveAllItems(TRUE); -} - -/* <15f710> ../cstrike/dlls/player.cpp:1829 */ -void CBasePlayer::GiveDefaultItems(void) -{ - RemoveAllItems(FALSE); - m_bHasPrimary = false; - - switch (m_iTeam) - { - case CT: - GiveNamedItem("weapon_knife"); - GiveNamedItem("weapon_usp"); - GiveAmmo(m_bIsVIP ? 12 : 24, "45acp", MAX_AMMO_45ACP); - - break; - case TERRORIST: - GiveNamedItem("weapon_knife"); - GiveNamedItem("weapon_glock18"); - GiveAmmo(40, "9mm", MAX_AMMO_9MM); - - break; - } -} - -/* <15f406> ../cstrike/dlls/player.cpp:1871 */ -void CBasePlayer::RemoveAllItems(BOOL removeSuit) -{ - BOOL bKillProgBar = false; - int i; - - if (m_bHasDefuser) - { - m_bHasDefuser = false; - pev->body = 0; - - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("defuser"); - MESSAGE_END(); - - SendItemStatus(this); - bKillProgBar = true; - } - - if (m_bHasC4) - { - m_bHasC4 = false; - pev->body = 0; - - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("c4"); - MESSAGE_END(); - - bKillProgBar = true; - } - - RemoveShield(); - - if (bKillProgBar) - SetProgressBarTime(0); - - if (m_pActiveItem) - { - ResetAutoaim(); - - m_pActiveItem->Holster(); - m_pActiveItem = NULL; - } - m_pLastItem = NULL; - - for (i = 0; i < MAX_ITEM_TYPES; i++) - { - m_pActiveItem = m_rgpPlayerItems[i]; - - while (m_pActiveItem) - { - CBasePlayerItem *pPendingItem = m_pActiveItem->m_pNext; - - m_pActiveItem->Drop(); - m_pActiveItem = pPendingItem; - } - - m_rgpPlayerItems[i] = NULL; - } - - m_pActiveItem = NULL; - m_bHasPrimary = NULL; - - pev->viewmodel = 0; - pev->weaponmodel = 0; - - if (removeSuit) - pev->weapons = 0; - else - pev->weapons &= ~WEAPON_ALLWEAPONS; - - for (i = 0; i < MAX_AMMO_SLOTS; i++) - m_rgAmmo[i] = 0; - - UpdateClientData(); - - MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev); - WRITE_BYTE(0); - WRITE_BYTE(0); - WRITE_BYTE(0); - MESSAGE_END(); -} - -/* <15436c> ../cstrike/dlls/player.cpp:1962 */ -void CBasePlayer::SetBombIcon(BOOL bFlash) -{ - if (m_bHasC4) - { - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); - WRITE_BYTE(bFlash ? STATUSICON_FLASH : STATUSICON_SHOW); - WRITE_STRING("c4"); - WRITE_BYTE(0); - WRITE_BYTE(160); - WRITE_BYTE(0); - MESSAGE_END(); - } - else - { - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("c4"); - MESSAGE_END(); - } - - SetScoreboardAttributes(); -} - -/* <15f2ab> ../cstrike/dlls/player.cpp:1985 */ -void CBasePlayer::SetProgressBarTime(int time) -{ - if (time) - { - m_progressStart = gpGlobals->time; - m_progressEnd = time + gpGlobals->time; - } - else - { - m_progressStart = 0; - m_progressEnd = 0; - } - - MESSAGE_BEGIN(MSG_ONE, gmsgBarTime, NULL, pev); - WRITE_SHORT(time); - MESSAGE_END(); - - CBaseEntity *pPlayer = NULL; - int myIndex = entindex(); - - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) - { - if (FNullEnt(pPlayer->edict())) - break; - - CBasePlayer *player = GetClassPtr((CBasePlayer *)pPlayer->pev); - - if (player->IsObserver() == OBS_IN_EYE && player->pev->iuser2 == myIndex) - { - MESSAGE_BEGIN(MSG_ONE, gmsgBarTime, NULL, player->pev); - WRITE_SHORT(time); - MESSAGE_END(); - } - } -} - -/* <15dcb4> ../cstrike/dlls/player.cpp:2027 */ -void CBasePlayer::SetProgressBarTime2(int time, float timeElapsed) -{ - if (time) - { - m_progressStart = gpGlobals->time - timeElapsed; - m_progressEnd = time + gpGlobals->time - timeElapsed; - } - else - { - timeElapsed = 0; - m_progressStart = 0; - m_progressEnd = 0; - } - - short iTimeElapsed = (timeElapsed * 100.0 / (m_progressEnd - m_progressStart)); - - MESSAGE_BEGIN(MSG_ONE, gmsgBarTime2, NULL, pev); - WRITE_SHORT(time); - WRITE_SHORT(iTimeElapsed); - MESSAGE_END(); - - CBaseEntity *pPlayer = NULL; - int myIndex = entindex(); - - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) - { - if (FNullEnt(pPlayer->edict())) - break; - - CBasePlayer *player = GetClassPtr((CBasePlayer *)pPlayer->pev); - - if (player->IsObserver() == OBS_IN_EYE && player->pev->iuser2 == myIndex) - { - MESSAGE_BEGIN(MSG_ONE, gmsgBarTime, NULL, player->pev); - WRITE_SHORT(time); - WRITE_SHORT(iTimeElapsed); - MESSAGE_END(); - } - } -} - -/* <14e0e9> ../cstrike/dlls/player.cpp:2073 */ -void BuyZoneIcon_Set(CBasePlayer *player) -{ - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); - WRITE_BYTE(STATUSICON_SHOW); - WRITE_STRING("buyzone"); - WRITE_BYTE(0); - WRITE_BYTE(160); - WRITE_BYTE(0); - MESSAGE_END(); -} - -/* <14e106> ../cstrike/dlls/player.cpp:2086 */ -void BuyZoneIcon_Clear(CBasePlayer *player) -{ - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("buyzone"); - MESSAGE_END(); - - if (player->m_iMenu >= Menu_Buy) - { - if (player->m_iMenu <= Menu_BuyItem) - { - CLIENT_COMMAND(ENT(player->pev), "slot10\n"); - } - else if (player->m_iMenu == Menu_ClientBuy) - { - MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, NULL, player->pev); - MESSAGE_END(); - } - } -} - -/* <14e62c> ../cstrike/dlls/player.cpp:2115 */ -void BombTargetFlash_Set(CBasePlayer *player) -{ - if (player->m_bHasC4 && !(player->m_flDisplayHistory & DHF_IN_TARGET_ZONE)) - { - player->m_flDisplayHistory |= DHF_IN_TARGET_ZONE; - player->HintMessage("#Hint_you_are_in_targetzone", TRUE); // TODO: send also for dead the players? - } - player->SetBombIcon(TRUE); -} - -/* <14e649> ../cstrike/dlls/player.cpp:2129 */ -void BombTargetFlash_Clear(CBasePlayer *player) -{ - player->SetBombIcon(FALSE); -} - -/* <158292> ../cstrike/dlls/player.cpp:2136 */ -void RescueZoneIcon_Set(CBasePlayer *player) -{ - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); - WRITE_BYTE(STATUSICON_SHOW); - WRITE_STRING("rescue"); - WRITE_BYTE(0); - WRITE_BYTE(160); - WRITE_BYTE(0); - MESSAGE_END(); - - if (player->m_iTeam == CT && !(player->m_flDisplayHistory & DHF_IN_RESCUE_ZONE)) - { - player->m_flDisplayHistory |= DHF_IN_RESCUE_ZONE; - player->HintMessage("#Hint_hostage_rescue_zone", TRUE); // TODO: send also for dead the players? - } -} - -/* <14e666> ../cstrike/dlls/player.cpp:2156 */ -void RescueZoneIcon_Clear(CBasePlayer *player) -{ - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("rescue"); - MESSAGE_END(); - - if (player->m_iMenu >= Menu_Buy) - { - if (player->m_iMenu <= Menu_BuyItem) - { - CLIENT_COMMAND(ENT(player->pev), "slot10\n"); - } - else if (player->m_iMenu == Menu_ClientBuy) - { - MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, NULL, player->pev); - MESSAGE_END(); - } - } -} - -/* <1582af> ../cstrike/dlls/player.cpp:2185 */ -void EscapeZoneIcon_Set(CBasePlayer *player) -{ - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); - WRITE_BYTE(STATUSICON_SHOW); - WRITE_STRING("escape"); - WRITE_BYTE(0); - WRITE_BYTE(160); - WRITE_BYTE(0); - MESSAGE_END(); - - if (player->m_iTeam == CT) - { - if (!(player->m_flDisplayHistory & DHF_IN_ESCAPE_ZONE)) - { - player->m_flDisplayHistory |= DHF_IN_ESCAPE_ZONE; - player->HintMessage("#Hint_terrorist_escape_zone"); - } - } -} - -/* <14e683> ../cstrike/dlls/player.cpp:2203 */ -void EscapeZoneIcon_Clear(CBasePlayer *player) -{ - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("escape"); - MESSAGE_END(); - - if (player->m_iMenu >= Menu_Buy) - { - if (player->m_iMenu <= Menu_BuyItem) - { - CLIENT_COMMAND(player->edict(), "slot10\n"); - } - else if (player->m_iMenu == Menu_ClientBuy) - { - MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, NULL, player->pev); - MESSAGE_END(); - } - } -} - -/* <1582cc> ../cstrike/dlls/player.cpp:2231 */ -void VIP_SafetyZoneIcon_Set(CBasePlayer *player) -{ - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); - WRITE_BYTE(STATUSICON_SHOW); - WRITE_STRING("vipsafety"); - WRITE_BYTE(0); - WRITE_BYTE(160); - WRITE_BYTE(0); - MESSAGE_END(); - - if (!(player->m_flDisplayHistory & DHF_IN_VIPSAFETY_ZONE)) - { - if (player->m_iTeam == CT) - { - player->m_flDisplayHistory |= DHF_IN_VIPSAFETY_ZONE; - player->HintMessage("#Hint_ct_vip_zone", TRUE); - } - else if (player->m_iTeam == TERRORIST) - { - player->m_flDisplayHistory |= DHF_IN_VIPSAFETY_ZONE; - player->HintMessage("#Hint_terrorist_vip_zone", TRUE); - } - } -} - -/* <14e6a0> ../cstrike/dlls/player.cpp:2255 */ -void VIP_SafetyZoneIcon_Clear(CBasePlayer *player) -{ - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("vipsafety"); - MESSAGE_END(); - - if (player->m_iMenu >= Menu_Buy) - { - if (player->m_iMenu <= Menu_BuyItem) - { - CLIENT_COMMAND(player->edict(), "slot10\n"); - } - else if (player->m_iMenu == Menu_ClientBuy) - { - MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, NULL, player->pev); - MESSAGE_END(); - } - } -} - -/* <154417> ../cstrike/dlls/player.cpp:2282 */ -void CBasePlayer::SendFOV(int fov) -{ - pev->fov = (float_precision)fov; - m_iClientFOV = fov; - m_iFOV = fov; - - MESSAGE_BEGIN(MSG_ONE, gmsgSetFOV, NULL, pev); - WRITE_BYTE(fov); - MESSAGE_END(); -} - -/* <160a1a> ../cstrike/dlls/player.cpp:2300 */ -void CBasePlayer::__MAKE_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) -{ - m_canSwitchObserverModes = false; - - if (m_LastHitGroup == HITGROUP_HEAD) - m_bHeadshotKilled = true; - - CBaseEntity *pAttackerEntity = CBaseEntity::Instance(pevAttacker); - - TheBots->OnEvent(EVENT_PLAYER_DIED, this, pAttackerEntity); - - if (g_pGameRules->IsCareer()) - { - bool killerHasShield = false; - bool wasBlind = false; - - if (!IsBot()) - { - TheCareerTasks->HandleEvent(EVENT_DIE, NULL, this); - } - TheCareerTasks->HandleDeath(m_iTeam, this); - - if (!m_bKilledByBomb) - { - CBasePlayer *pAttacker = (CBasePlayer *)CBaseEntity::Instance(pevAttacker); - - if (pAttacker->HasShield()) - killerHasShield = true; - - CCSBot *pBot = reinterpret_cast(this); - if (pBot->IsBot() && pBot->IsBlind()) - { - wasBlind = true; - } - - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); - - if (!pPlayer) - continue; - - bool killedByHumanPlayer = (!pPlayer->IsBot() && pPlayer->pev == pevAttacker && pPlayer->m_iTeam != m_iTeam); - - if (killedByHumanPlayer) - { - TheCareerTasks->HandleEnemyKill(wasBlind, GetWeaponName(g_pevLastInflictor, pevAttacker), m_bHeadshotKilled, killerHasShield, this, pPlayer); - } - } - } - } - - if (!m_bKilledByBomb) - { - g_pGameRules->PlayerKilled(this, pevAttacker, g_pevLastInflictor); - } - - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pev); - WRITE_BYTE(0); - MESSAGE_END(); - - m_bNightVisionOn = false; - - for (int i = 1; i <= gpGlobals->maxClients; ++i) - { - CBasePlayer *pObserver = (CBasePlayer *)UTIL_PlayerByIndex(i); - - if (!pObserver) - continue; - - if (pObserver->IsObservingPlayer(this)) - { - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); - WRITE_BYTE(0); - MESSAGE_END(); - - pObserver->m_bNightVisionOn = false; - } - } - - if (m_pTank != NULL) - { - m_pTank->Use(this, this, USE_OFF, 0); - m_pTank = NULL; - } - - CSound *pSound = CSoundEnt::SoundPointerForIndex(CSoundEnt::ClientSoundIndex(edict())); - - if (pSound) - { - pSound->Reset(); - } - - SetAnimation(PLAYER_DIE); - - if (m_pActiveItem && m_pActiveItem->m_pPlayer) - { - switch (m_pActiveItem->m_iId) - { - case WEAPON_HEGRENADE: - { - CHEGrenade *pHEGrenade = (CHEGrenade *)m_pActiveItem; - if ((pev->button & IN_ATTACK) && m_rgAmmo[ pHEGrenade->m_iPrimaryAmmoType ]) - { - CGrenade::ShootTimed2(pev, (pev->origin + pev->view_ofs), pev->angles, 1.5, m_iTeam, pHEGrenade->m_usCreateExplosion); - } - break; - } - case WEAPON_FLASHBANG: - { - if ((pev->button & IN_ATTACK) && m_rgAmmo[ ((CBasePlayerWeapon *)m_pActiveItem)->m_iPrimaryAmmoType ]) - { - CGrenade::ShootTimed(pev, (pev->origin + pev->view_ofs), pev->angles, 1.5); - } - break; - } - case WEAPON_SMOKEGRENADE: - { - CSmokeGrenade *pSmoke = (CSmokeGrenade *)m_pActiveItem; - if ((pev->button & IN_ATTACK) && m_rgAmmo[ pSmoke->m_iPrimaryAmmoType ]) - { - CGrenade::ShootSmokeGrenade(pev, (pev->origin + pev->view_ofs), pev->angles, 1.5, pSmoke->m_usCreateSmoke); - } - break; - } - default: - break; - } - } - - pev->modelindex = m_modelIndexPlayer; - pev->deadflag = DEAD_DYING; - pev->movetype = MOVETYPE_TOSS; - pev->takedamage = DAMAGE_NO; - - pev->gamestate = 1; - m_bShieldDrawn = false; - - pev->flags &= ~FL_ONGROUND; - - if (fadetoblack.value == 0.0) - { - pev->iuser1 = OBS_CHASE_FREE; - pev->iuser2 = ENTINDEX(edict()); - pev->iuser3 = ENTINDEX(ENT(pevAttacker)); - - m_hObserverTarget = UTIL_PlayerByIndex(pev->iuser3); - - MESSAGE_BEGIN(MSG_ONE, gmsgADStop, NULL, pev); - MESSAGE_END(); - } - else - UTIL_ScreenFade(this, Vector(0, 0, 0), 3, 3, 255, (FFADE_OUT | FFADE_STAYOUT)); - - SetScoreboardAttributes(); - - if (m_iThrowDirection) - { - switch (m_iThrowDirection) - { - case THROW_FORWARD: - { - UTIL_MakeVectors(pev->angles); - - pev->velocity = gpGlobals->v_forward * RANDOM_FLOAT(100, 200); - pev->velocity.z = RANDOM_FLOAT(50, 100); - - break; - } - case THROW_BACKWARD: - { - UTIL_MakeVectors(pev->angles); - - pev->velocity = gpGlobals->v_forward * RANDOM_FLOAT(-100, -200); - pev->velocity.z = RANDOM_FLOAT(50, 100); - - break; - } - case THROW_HITVEL: - { - if (FClassnameIs(pevAttacker, "player")) - { - UTIL_MakeVectors(pevAttacker->angles); - - pev->velocity = gpGlobals->v_forward * RANDOM_FLOAT(200, 300); - pev->velocity.z = RANDOM_FLOAT(200, 300); - } - - break; - } - case THROW_BOMB: - { - pev->velocity = m_vBlastVector * (1 / m_vBlastVector.Length()) * (2300 - m_vBlastVector.Length()) * 0.25; - pev->velocity.z = (2300 - m_vBlastVector.Length()) / 2.75; - - break; - } - case THROW_GRENADE: - { - pev->velocity = m_vBlastVector * (1 / m_vBlastVector.Length()) * (500 - m_vBlastVector.Length()); - pev->velocity.z = (350 - m_vBlastVector.Length()) * 1.5; - - break; - } - case THROW_HITVEL_MINUS_AIRVEL: - { - if (FClassnameIs(pevAttacker, "player")) - { - UTIL_MakeVectors(pevAttacker->angles); - pev->velocity = gpGlobals->v_forward * RANDOM_FLOAT(200, 300); - } - - break; - } - default: - break; - } - - pev->angles.y = UTIL_VecToAngles(-pev->velocity).y; - pev->v_angle.y = pev->angles.y; - - m_iThrowDirection = THROW_NONE; - } - - SetSuitUpdate(NULL, FALSE, 0); - m_iClientHealth = 0; - - MESSAGE_BEGIN(MSG_ONE, gmsgHealth, NULL, pev); - WRITE_BYTE(m_iClientHealth); - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev); - WRITE_BYTE(0); - WRITE_BYTE(0xFF); - WRITE_BYTE(0xFF); - MESSAGE_END(); - - SendFOV(0); - - g_pGameRules->CheckWinConditions(); - m_bNotKilled = false; - - if (m_bHasC4) - { - DropPlayerItem("weapon_c4"); - SetProgressBarTime(0); - } - else if (m_bHasDefuser) - { - m_bHasDefuser = false; - pev->body = 0; - - GiveNamedItem("item_thighpack"); - - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("defuser"); - MESSAGE_END(); - - SendItemStatus(this); - } - - if (m_bIsDefusing) - { - SetProgressBarTime(0); - } - - m_bIsDefusing = false; - - BuyZoneIcon_Clear(this); - - SetThink(&CBasePlayer::PlayerDeathThink); - pev->nextthink = gpGlobals->time + 0.1; - pev->solid = SOLID_NOT; - - if (m_bPunishedForTK) - { - m_bPunishedForTK = false; - HintMessage("#Hint_cannot_play_because_tk", TRUE, TRUE); - } - - if ((pev->health < -9000 && iGib != GIB_NEVER) || iGib == GIB_ALWAYS) - { - pev->solid = SOLID_NOT; - GibMonster(); - pev->effects |= EF_NODRAW; - - g_pGameRules->CheckWinConditions(); - - return; - } - - DeathSound(); - - pev->angles.x = 0; - pev->angles.z = 0; - - if (!(m_flDisplayHistory & DHF_SPEC_DUCK)) - { - HintMessage("#Spec_Duck", TRUE, TRUE); - m_flDisplayHistory |= DHF_SPEC_DUCK; - } -} - -/* <154478> ../cstrike/dlls/player.cpp:2625 */ -BOOL CBasePlayer::IsBombGuy(void) -{ - if (!g_pGameRules->IsMultiplayer()) - return FALSE; - - return m_bHasC4; -} - -/* <1544a1> ../cstrike/dlls/player.cpp:2636 */ -void CBasePlayer::SetAnimation(PLAYER_ANIM playerAnim) -{ - int animDesired; - float speed; - char szAnim[64]; - int hopSeq; - int leapSeq; - - if (!pev->modelindex) - return; - - if ((playerAnim == PLAYER_FLINCH || playerAnim == PLAYER_LARGE_FLINCH) && HasShield()) - return; - - if (playerAnim != PLAYER_FLINCH && playerAnim != PLAYER_LARGE_FLINCH && m_flFlinchTime > gpGlobals->time && pev->health > 0.0f) - return; - - speed = pev->velocity.Length2D(); - - if (pev->flags & FL_FROZEN) - { - speed = 0; - playerAnim = PLAYER_IDLE; - } - - hopSeq = LookupActivity(ACT_HOP); - leapSeq = LookupActivity(ACT_LEAP); - - switch (playerAnim) - { - case PLAYER_JUMP: - { - if (m_Activity == ACT_SWIM || m_Activity == ACT_DIESIMPLE || m_Activity == ACT_HOVER) - m_IdealActivity = m_Activity; - else - { - m_IdealActivity = ACT_HOP; - TheBots->OnEvent(EVENT_PLAYER_JUMPED, this); - } - break; - } - case PLAYER_SUPERJUMP: - { - if (m_Activity == ACT_SWIM || m_Activity == ACT_DIESIMPLE || m_Activity == ACT_HOVER) - m_IdealActivity = m_Activity; - else - m_IdealActivity = ACT_LEAP; - break; - } - case PLAYER_DIE: - { - m_IdealActivity = ACT_DIESIMPLE; - DeathSound(); - break; - } - case PLAYER_ATTACK1: - { - if (m_Activity == ACT_SWIM || m_Activity == ACT_DIESIMPLE || m_Activity == ACT_HOVER) - m_IdealActivity = m_Activity; - else - { - m_IdealActivity = ACT_RANGE_ATTACK1; - TheBots->OnEvent(EVENT_WEAPON_FIRED, this); - } - break; - } - case PLAYER_ATTACK2: - { - if (m_Activity == ACT_SWIM || m_Activity == ACT_DIESIMPLE || m_Activity == ACT_HOVER) - m_IdealActivity = m_Activity; - else - { - m_IdealActivity = ACT_RANGE_ATTACK2; - TheBots->OnEvent(EVENT_WEAPON_FIRED, this); - } - break; - } - case PLAYER_RELOAD: - { - if (m_Activity == ACT_SWIM || m_Activity == ACT_DIESIMPLE || m_Activity == ACT_HOVER) - m_IdealActivity = m_Activity; - else - { - m_IdealActivity = ACT_RELOAD; - TheBots->OnEvent(EVENT_WEAPON_RELOADED, this); - } - break; - } - case PLAYER_IDLE: - case PLAYER_WALK: - { - if (pev->flags & FL_ONGROUND || (m_Activity != ACT_HOP && m_Activity != ACT_LEAP)) - { - if (pev->waterlevel <= 1) - m_IdealActivity = ACT_WALK; - - else if (speed == 0.0f) - m_IdealActivity = ACT_HOVER; - - else - m_IdealActivity = ACT_SWIM; - } - else - m_IdealActivity = m_Activity; - break; - } - case PLAYER_HOLDBOMB: - m_IdealActivity = ACT_HOLDBOMB; - break; - case PLAYER_FLINCH: - m_IdealActivity = ACT_FLINCH; - break; - case PLAYER_LARGE_FLINCH: - m_IdealActivity = ACT_LARGE_FLINCH; - break; - default: - break; - } - switch (m_IdealActivity) - { - case ACT_HOP: - case ACT_LEAP: - { - if (m_Activity == m_IdealActivity) - return; - - switch (m_Activity) - { - case ACT_RANGE_ATTACK1: Q_strcpy(szAnim, "ref_shoot_"); break; - case ACT_RANGE_ATTACK2: Q_strcpy(szAnim, "ref_shoot2_"); break; - case ACT_RELOAD: Q_strcpy(szAnim, "ref_reload_"); break; - default: Q_strcpy(szAnim, "ref_aim_"); break; - } - - Q_strcat(szAnim, m_szAnimExtention); - animDesired = LookupSequence(szAnim); - if (animDesired == -1) - animDesired = 0; - - if (pev->sequence != animDesired || !m_fSequenceLoops) - pev->frame = 0; - - if (!m_fSequenceLoops) - pev->effects |= EF_NOINTERP; - - if (m_IdealActivity == ACT_LEAP) - pev->gaitsequence = LookupActivity(ACT_LEAP); - else - pev->gaitsequence = LookupActivity(ACT_HOP); - - m_Activity = m_IdealActivity; - break; - } - case ACT_RANGE_ATTACK1: - { - m_flLastFired = gpGlobals->time; - - if (pev->flags & FL_DUCKING) - Q_strcpy(szAnim, "crouch_shoot_"); - else - Q_strcpy(szAnim, "ref_shoot_"); - - Q_strcat(szAnim, m_szAnimExtention); - animDesired = LookupSequence(szAnim); - if (animDesired == -1) - animDesired = 0; - - pev->sequence = animDesired; - pev->frame = 0; - - ResetSequenceInfo(); - m_Activity = m_IdealActivity; - break; - } - case ACT_RANGE_ATTACK2: - { - m_flLastFired = gpGlobals->time; - - if (pev->flags & FL_DUCKING) - Q_strcpy(szAnim, "crouch_shoot2_"); - else - Q_strcpy(szAnim, "ref_shoot2_"); - - Q_strcat(szAnim, m_szAnimExtention); - animDesired = LookupSequence(szAnim); - if (animDesired == -1) - animDesired = 0; - - pev->sequence = animDesired; - pev->frame = 0; - - ResetSequenceInfo(); - m_Activity = m_IdealActivity; - break; - } - case ACT_RELOAD: - { - if (pev->flags & FL_DUCKING) - Q_strcpy(szAnim, "crouch_reload_"); - else - Q_strcpy(szAnim, "ref_reload_"); - - Q_strcat(szAnim, m_szAnimExtention); - animDesired = LookupSequence(szAnim); - if (animDesired == -1) - animDesired = 0; - - if (pev->sequence != animDesired || !m_fSequenceLoops) - pev->frame = 0; - - if (!m_fSequenceLoops) - pev->effects |= EF_NOINTERP; - - m_Activity = m_IdealActivity; - break; - } - case ACT_HOLDBOMB: - { - if (pev->flags & FL_DUCKING) - Q_strcpy(szAnim, "crouch_aim_"); - else - Q_strcpy(szAnim, "ref_aim_"); - - Q_strcat(szAnim, m_szAnimExtention); - animDesired = LookupSequence(szAnim); - if (animDesired == -1) - animDesired = 0; - - m_Activity = m_IdealActivity; - break; - } - case ACT_WALK: - { - if ((m_Activity != ACT_RANGE_ATTACK1 || m_fSequenceFinished) - && (m_Activity != ACT_RANGE_ATTACK2 || m_fSequenceFinished) - && (m_Activity != ACT_FLINCH || m_fSequenceFinished) - && (m_Activity != ACT_LARGE_FLINCH || m_fSequenceFinished) - && (m_Activity != ACT_RELOAD || m_fSequenceFinished)) - { - if (speed <= 135.0f || m_flLastFired + 4.0 >= gpGlobals->time) - { - if (pev->flags & FL_DUCKING) - Q_strcpy(szAnim, "crouch_aim_"); - else - Q_strcpy(szAnim, "ref_aim_"); - - Q_strcat(szAnim, m_szAnimExtention); - animDesired = LookupSequence(szAnim); - if (animDesired == -1) - animDesired = 0; - - m_Activity = ACT_WALK; - } - else - { - Q_strcpy(szAnim, "run_"); - Q_strcat(szAnim, m_szAnimExtention); - animDesired = LookupSequence(szAnim); - if (animDesired == -1) - { - if (pev->flags & FL_DUCKING) - Q_strcpy(szAnim, "crouch_aim_"); - else - Q_strcpy(szAnim, "ref_aim_"); - - Q_strcat(szAnim, m_szAnimExtention); - animDesired = LookupSequence(szAnim); - if (animDesired == -1) - animDesired = 0; - - m_Activity = ACT_RUN; - pev->gaitsequence = LookupActivity(ACT_RUN); - } - else - { - m_Activity = ACT_RUN; - pev->gaitsequence = animDesired; - } - if (m_Activity == ACT_RUN) - { - //TODO: maybe away used variable 'speed'? - //if (speed > 150.0f) - if (pev->velocity.Length2D() > 150.0f) - TheBots->OnEvent(EVENT_PLAYER_FOOTSTEP, this); - } - } - } - else - animDesired = pev->sequence; - - if (speed > 135.0f) - pev->gaitsequence = LookupActivity(ACT_RUN); - else - pev->gaitsequence = LookupActivity(ACT_WALK); - break; - } - case ACT_FLINCH: - case ACT_LARGE_FLINCH: - { - m_Activity = m_IdealActivity; - -#ifndef REGAMEDLL_FIXES - // TODO: why? this condition was checked! - if ((playerAnim == PLAYER_FLINCH || playerAnim == PLAYER_LARGE_FLINCH) && HasShield()) - return; -#endif // REGAMEDLL_FIXES - - switch (m_LastHitGroup) - { - case HITGROUP_GENERIC: - { - if (RANDOM_LONG(0, 1)) - animDesired = LookupSequence("head_flinch"); - else - animDesired = LookupSequence("gut_flinch"); - break; - } - case HITGROUP_HEAD: - case HITGROUP_CHEST: - animDesired = LookupSequence("head_flinch"); - break; - case HITGROUP_SHIELD: - animDesired = 0; - break; - default: - animDesired = LookupSequence("gut_flinch"); - break; - } - - if (animDesired == -1) - animDesired = 0; - - break; - } - case ACT_DIESIMPLE: - { - if (m_Activity == m_IdealActivity) - return; - - m_Activity = m_IdealActivity; - m_flDeathThrowTime = 0; - m_iThrowDirection = THROW_NONE; - - switch (m_LastHitGroup) - { - case HITGROUP_GENERIC: - { - switch (RANDOM_LONG(0, 8)) - { - case 0: - animDesired = LookupActivity(ACT_DIE_HEADSHOT); - m_iThrowDirection = THROW_BACKWARD; - break; - case 1: - animDesired = LookupActivity(ACT_DIE_GUTSHOT); - break; - case 2: - animDesired = LookupActivity(ACT_DIE_BACKSHOT); - m_iThrowDirection = THROW_HITVEL; - break; - case 3: - animDesired = LookupActivity(ACT_DIESIMPLE); - break; - case 4: - animDesired = LookupActivity(ACT_DIEBACKWARD); - m_iThrowDirection = THROW_HITVEL; - break; - case 5: - animDesired = LookupActivity(ACT_DIEFORWARD); - m_iThrowDirection = THROW_FORWARD; - break; - case 6: - animDesired = LookupActivity(ACT_DIE_CHESTSHOT); - break; - case 7: - animDesired = LookupActivity(ACT_DIE_GUTSHOT); - break; - case 8: - animDesired = LookupActivity(ACT_DIE_HEADSHOT); - break; - default: - break; - } - break; - } - case HITGROUP_HEAD: - { - int random = RANDOM_LONG(0, 8); - m_bHeadshotKilled = true; - - if (m_bHighDamage) - ++random; - - switch (random) - { - case 1: - case 2: - m_iThrowDirection = THROW_BACKWARD; - break; - case 3: - case 4: - m_iThrowDirection = THROW_FORWARD; - break; - case 5: - case 6: - m_iThrowDirection = THROW_HITVEL; - break; - default: - m_iThrowDirection = THROW_NONE; - break; - } - - animDesired = LookupActivity(ACT_DIE_HEADSHOT); - break; - } - case HITGROUP_CHEST: - animDesired = LookupActivity(ACT_DIE_CHESTSHOT); - break; - case HITGROUP_STOMACH: - animDesired = LookupActivity(ACT_DIE_GUTSHOT); - break; - case HITGROUP_LEFTARM: - animDesired = LookupSequence("left"); - break; - case HITGROUP_RIGHTARM: - { - m_iThrowDirection = RANDOM_LONG(0, 1) ? THROW_HITVEL : THROW_HITVEL_MINUS_AIRVEL; - animDesired = LookupSequence("right"); - break; - } - default: - { - animDesired = LookupActivity(ACT_DIESIMPLE); - break; - } - } - if (pev->flags & FL_DUCKING) - { - animDesired = LookupSequence("crouch_die"); - m_iThrowDirection = THROW_BACKWARD; - } - else if (m_bKilledByBomb || m_bKilledByGrenade) - { - UTIL_MakeVectors(pev->angles); - - if (DotProduct(gpGlobals->v_forward, m_vBlastVector) > 0.0f) - animDesired = LookupSequence("left"); - - else - { - if (RANDOM_LONG(0, 1)) - animDesired = LookupSequence("crouch_die"); - else - animDesired = LookupActivity(ACT_DIE_HEADSHOT); - } - - if (m_bKilledByBomb) - m_iThrowDirection = THROW_BOMB; - - else if (m_bKilledByGrenade) - m_iThrowDirection = THROW_GRENADE; - } - - if (animDesired == -1) - animDesired = 0; - - if (pev->sequence != animDesired) - { - pev->gaitsequence = 0; - pev->sequence = animDesired; - pev->frame = 0.0f; - ResetSequenceInfo(); - } - return; - } - default: - { - if (m_Activity == m_IdealActivity) - return; - - m_Activity = m_IdealActivity; - animDesired = LookupActivity(m_IdealActivity); - - if (pev->sequence != animDesired) - { - pev->gaitsequence = 0; - pev->sequence = animDesired; - pev->frame = 0; - - ResetSequenceInfo(); - } - return; - } - } - - if (pev->gaitsequence != hopSeq && pev->gaitsequence != leapSeq) - { - if (pev->flags & FL_DUCKING) - { - if (speed != 0.0f) - pev->gaitsequence = LookupActivity(ACT_CROUCH); - else - pev->gaitsequence = LookupActivity(ACT_CROUCHIDLE); - } - else - { - if (speed > 135.0f) - { - if (m_flLastFired + 4.0f < gpGlobals->time) - { - if (m_Activity != ACT_FLINCH && m_Activity != ACT_LARGE_FLINCH) - { - Q_strcpy(szAnim, "run_"); - Q_strcat(szAnim, m_szAnimExtention); - - animDesired = LookupSequence(szAnim); - if (animDesired == -1) - { - if (pev->flags & FL_DUCKING) - Q_strcpy(szAnim, "crouch_aim_"); - else - Q_strcpy(szAnim, "ref_aim_"); - - Q_strcat(szAnim, m_szAnimExtention); - animDesired = LookupSequence(szAnim); - } - else - pev->gaitsequence = animDesired; - - m_Activity = ACT_RUN; - } - } - pev->gaitsequence = LookupActivity(ACT_RUN); - } - else - { - if (speed > 0.0f) - pev->gaitsequence = LookupActivity(ACT_WALK); - else - pev->gaitsequence = LookupActivity(ACT_IDLE); - } - } - } - if (pev->sequence != animDesired) - { - pev->sequence = animDesired; - pev->frame = 0; - - ResetSequenceInfo(); - } -} - -/* <1544f4> ../cstrike/dlls/player.cpp:3264 */ -void CBasePlayer::WaterMove(void) -{ - int air; - - if (pev->movetype == MOVETYPE_NOCLIP || pev->movetype == MOVETYPE_NONE) - return; - - if (pev->health < 0.0f) - return; - - // waterlevel 0 - not in water - // waterlevel 1 - feet in water - // waterlevel 2 - waist in water - // waterlevel 3 - head in water - - if (pev->waterlevel != 3) - { - // not underwater - - // play 'up for air' sound - if (pev->air_finished < gpGlobals->time) - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_wade1.wav", VOL_NORM, ATTN_NORM); - - else if (pev->air_finished < gpGlobals->time + 9) - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_wade2.wav", VOL_NORM, ATTN_NORM); - - pev->air_finished = gpGlobals->time + AIRTIME; - pev->dmg = 2; - - // if we took drowning damage, give it back slowly - if (m_idrowndmg > m_idrownrestored) - { - // set drowning damage bit. hack - dmg_drownrecover actually - // makes the time based damage code 'give back' health over time. - // make sure counter is cleared so we start count correctly. - - // NOTE: this actually causes the count to continue restarting - // until all drowning damage is healed. - m_rgbTimeBasedDamage[ itbd_DrownRecover ] = 0; - m_bitsDamageType |= DMG_DROWNRECOVER; - m_bitsDamageType &= ~DMG_DROWN; - - } - } - else - { - // fully under water - // stop restoring damage while underwater - m_rgbTimeBasedDamage[ itbd_DrownRecover ] = 0; - m_bitsDamageType &= ~DMG_DROWNRECOVER; - - // drown! - if (gpGlobals->time > pev->air_finished) - { - if (gpGlobals->time > pev->pain_finished) - { - // take drowning damage - pev->dmg += 1; - - if (pev->dmg > 5) - pev->dmg = 5; - - TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), pev->dmg, DMG_DROWN); - pev->pain_finished = gpGlobals->time + 1; - - // track drowning damage, give it back when - // player finally takes a breath - m_idrowndmg += pev->dmg; - } - } - else - m_bitsDamageType &= ~(DMG_DROWNRECOVER | DMG_DROWN); - } - - if (!pev->waterlevel) - { - if (pev->flags & FL_INWATER) - pev->flags &= ~FL_INWATER; - - return; - } - - // make bubbles - air = (int)(pev->air_finished - gpGlobals->time); - - if (!RANDOM_LONG(0, 0x1f) && RANDOM_LONG(0, AIRTIME - 1) >= air) - { - switch (RANDOM_LONG(0, 3)) - { - case 0: EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_swim1.wav", 0.8, ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_swim2.wav", 0.8, ATTN_NORM); break; - case 2: EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_swim3.wav", 0.8, ATTN_NORM); break; - case 3: EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_swim4.wav", 0.8, ATTN_NORM); break; - } - } - - if (pev->watertype == CONTENT_LAVA) // do damage - { - if (pev->dmgtime < gpGlobals->time) - TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), pev->waterlevel * 10, DMG_BURN); - } - else if (pev->watertype == CONTENT_SLIME) // do damage - { - pev->dmgtime = gpGlobals->time + 1; - TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), pev->waterlevel * 4, DMG_ACID); - } - if (!(pev->flags & FL_INWATER)) - { - pev->flags |= FL_INWATER; - pev->dmgtime = 0; - } -} - -/* <15493f> ../cstrike/dlls/player.cpp:3380 */ -BOOL CBasePlayer::IsOnLadder(void) -{ - return pev->movetype == MOVETYPE_FLY; -} - -/* <160720> ../cstrike/dlls/player.cpp:3387 */ -NOXREF void CBasePlayer::ThrowWeapon(char *pszItemName) -{ - for (int i = 0; i < MAX_WEAPON_SLOTS; i++) - { - CBasePlayerItem *pWeapon = m_rgpPlayerItems[i]; - - while (pWeapon != NULL) - { - if (!Q_strcmp(pszItemName, STRING(pWeapon->pev->classname))) - { - DropPlayerItem(pszItemName); - return; - } - - pWeapon = pWeapon->m_pNext; - } - } -} - -/* <154967> ../cstrike/dlls/player.cpp:3424 */ -LINK_ENTITY_TO_CLASS(weapon_shield, CWShield); - -/* <151962> ../cstrike/dlls/player.cpp:3426 */ -void CWShield::__MAKE_VHOOK(Spawn)(void) -{ - pev->movetype = MOVETYPE_TOSS; - pev->solid = SOLID_TRIGGER; - - UTIL_SetSize(pev, g_vecZero, g_vecZero); - SET_MODEL(ENT(pev), "models/w_shield.mdl"); -} - -/* <152e95> ../cstrike/dlls/player.cpp:3436 */ -void CWShield::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) -{ - if (!pOther->IsPlayer()) - return; - - CBasePlayer *pPlayer = (CBasePlayer *)pOther; - - if (pPlayer->pev->deadflag != DEAD_NO) - return; - - if (m_hEntToIgnoreTouchesFrom != NULL && pPlayer == (CBasePlayer *)((CBaseEntity *)m_hEntToIgnoreTouchesFrom)) - { - if (m_flTimeToIgnoreTouches > gpGlobals->time) - return; - - m_hEntToIgnoreTouchesFrom = NULL; - } - - if (!pPlayer->m_bHasPrimary) - { - if (pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ] != NULL && pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]->m_iId == WEAPON_ELITE) - return; - - if (pPlayer->m_pActiveItem) - { - if (!pPlayer->m_pActiveItem->CanHolster()) - return; - } - - if (!pPlayer->m_bIsVIP) - { - pPlayer->GiveShield(); - - EMIT_SOUND(edict(), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM); - UTIL_Remove(this); - - pev->nextthink = gpGlobals->time + 0.1; - } - } -} - -/* <154a43> ../cstrike/dlls/player.cpp:3480 */ -void CBasePlayer::GiveShield(bool bDeploy) -{ - m_bOwnsShield = true; - m_bHasPrimary = true; - - if (m_pActiveItem != NULL) - { - CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; - - if (bDeploy) - { - if (m_rgAmmo[ pWeapon->m_iPrimaryAmmoType ] > 0) - pWeapon->Holster(); - - if (!pWeapon->Deploy()) - pWeapon->RetireWeapon(); - } - } - - pev->gamestate = 0; -} - -/* <154a70> ../cstrike/dlls/player.cpp:3504 */ -void CBasePlayer::RemoveShield(void) -{ - if (HasShield()) - { - m_bOwnsShield = false; - m_bHasPrimary = false; - m_bShieldDrawn = false; - pev->gamestate = 1; - - UpdateShieldCrosshair(true); - } -} - -/* <154ad5> ../cstrike/dlls/player.cpp:3521 */ -void CBasePlayer::DropShield(bool bDeploy) -{ - if (!HasShield()) - return; - - if (m_pActiveItem && !m_pActiveItem->CanHolster()) - return; - - if (m_pActiveItem) - { - CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; - - if (pWeapon->m_iId == WEAPON_HEGRENADE || pWeapon->m_iId == WEAPON_FLASHBANG || pWeapon->m_iId == WEAPON_SMOKEGRENADE) - { - if (m_rgAmmo[ pWeapon->m_iPrimaryAmmoType ] <= 0) - g_pGameRules->GetNextBestWeapon(this, pWeapon); - } - } - - if (m_pActiveItem) - { - CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; - - if (pWeapon->m_flStartThrow != 0) - m_pActiveItem->Holster(); - } - - if (IsReloading()) - { - CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; - - pWeapon->m_fInReload = FALSE; - m_flNextAttack = 0; - } - - if (IsProtectedByShield() && m_pActiveItem) - ((CBasePlayerWeapon *)m_pActiveItem)->SecondaryAttack(); - - m_bShieldDrawn = false; - - RemoveShield(); - - if (m_pActiveItem && bDeploy) - m_pActiveItem->Deploy(); - - UTIL_MakeVectors(pev->angles); - - CWShield *pShield = (CWShield *)CBaseEntity::Create("weapon_shield", pev->origin + gpGlobals->v_forward * 10, pev->angles, edict()); - - pShield->pev->angles.x = 0; - pShield->pev->angles.z = 0; - - pShield->pev->velocity = gpGlobals->v_forward * 400; - - pShield->SetThink(&CBaseEntity::SUB_Remove); - pShield->pev->nextthink = gpGlobals->time + 300; - - pShield->SetCantBePickedUpByUser(this, 2.0); -} - -/* <154b15> ../cstrike/dlls/player.cpp:3588 */ -bool CBasePlayer::HasShield(void) -{ - return m_bOwnsShield; -} - -/* <1615d2> ../cstrike/dlls/player.cpp:3593 */ -NOXREF void CBasePlayer::ThrowPrimary(void) -{ - ThrowWeapon("weapon_m249"); - ThrowWeapon("weapon_g3sg1"); - ThrowWeapon("weapon_sg550"); - ThrowWeapon("weapon_awp"); - ThrowWeapon("weapon_mp5navy"); - ThrowWeapon("weapon_tmp"); - ThrowWeapon("weapon_p90"); - ThrowWeapon("weapon_ump45"); - ThrowWeapon("weapon_m4a1"); - ThrowWeapon("weapon_m3"); - ThrowWeapon("weapon_sg552"); - ThrowWeapon("weapon_scout"); - ThrowWeapon("weapon_galil"); - ThrowWeapon("weapon_famas"); - - DropShield(); -} - -/* <154b6d> ../cstrike/dlls/player.cpp:3624 */ -void CBasePlayer::AddAccount(int amount, bool bTrackChange) -{ - m_iAccount += amount; - - if (m_iAccount < 0) - m_iAccount = 0; - - else if (m_iAccount > 16000) - m_iAccount = 16000; - - MESSAGE_BEGIN(MSG_ONE, gmsgMoney, NULL, pev); - WRITE_LONG(m_iAccount); - WRITE_BYTE(bTrackChange); - MESSAGE_END(); -} - -/* <154bf8> ../cstrike/dlls/player.cpp:3640 */ -void CBasePlayer::ResetMenu(void) -{ - MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pev); - WRITE_SHORT(0); - WRITE_CHAR(0); - WRITE_BYTE(0); - WRITE_STRING(""); - MESSAGE_END(); - -#ifdef REGAMEDLL_FIXES - m_iMenu = Menu_OFF; -#endif // REGAMEDLL_FIXES - -} - -/* <154c50> ../cstrike/dlls/player.cpp:3651 */ -void CBasePlayer::SyncRoundTimer(void) -{ - float tmRemaining; - CHalfLifeMultiplay *mp = g_pGameRules; - - if (mp->IsMultiplayer()) - tmRemaining = mp->TimeRemaining(); - else - tmRemaining = 0; - - if (tmRemaining < 0) - tmRemaining = 0; - - MESSAGE_BEGIN(MSG_ONE, gmsgRoundTime, NULL, pev); - WRITE_SHORT((int)tmRemaining); - MESSAGE_END(); - - if (!mp->IsMultiplayer()) - return; - - if (mp->IsFreezePeriod() && TheTutor != NULL && !IsObserver()) - { - MESSAGE_BEGIN(MSG_ONE, gmsgBlinkAcct, NULL, pev); - WRITE_BYTE(MONEY_BLINK_AMOUNT); - MESSAGE_END(); - } - - if (mp->IsCareer()) - { - int remaining = 0; - bool shouldCountDown = false; - int fadeOutDelay = 0; - - if (tmRemaining != 0.0f) - { - remaining = TheCareerTasks->GetTaskTime() - (gpGlobals->time - mp->m_fRoundCount); - } - - if (remaining < 0) - remaining = 0; - - if (mp->IsFreezePeriod()) - remaining = -1; - - if (TheCareerTasks->GetFinishedTaskTime()) - remaining = -TheCareerTasks->GetFinishedTaskTime(); - - if (!mp->IsFreezePeriod() && !TheCareerTasks->GetFinishedTaskTime()) - { - shouldCountDown = true; - } - if (!mp->IsFreezePeriod()) - { - if (TheCareerTasks->GetFinishedTaskTime() || (TheCareerTasks->GetTaskTime() <= TheCareerTasks->GetRoundElapsedTime())) - { - fadeOutDelay = 3; - } - } - - if (!TheCareerTasks->GetFinishedTaskTime() || TheCareerTasks->GetFinishedTaskRound() == mp->m_iTotalRoundsPlayed) - { - MESSAGE_BEGIN(MSG_ONE, gmsgTaskTime, NULL, pev); - WRITE_SHORT(remaining); // remaining of time, -1 the timer is disappears - WRITE_BYTE(shouldCountDown); // timer counts down - WRITE_BYTE(fadeOutDelay); // fade in time, hide HUD timer after the expiration time - MESSAGE_END(); - } - } -} - -/* <154db6> ../cstrike/dlls/player.cpp:3711 */ -void CBasePlayer::RemoveLevelText(void) -{ - ResetMenu(); -} - -void ShowMenu2(CBasePlayer *pPlayer, int bitsValidSlots, int nDisplayTime, int fNeedMore, char *pszText) -{ - MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pPlayer->pev); - WRITE_SHORT(bitsValidSlots); - WRITE_CHAR(nDisplayTime); - WRITE_BYTE(fNeedMore); - WRITE_STRING(pszText); - MESSAGE_END(); -} - -/* <154e29> ../cstrike/dlls/player.cpp:3721 */ -void WINAPI_HOOK CBasePlayer::MenuPrint(const char *msg) -{ - const char *msg_portion = msg; - char sbuf[MAX_BUFFER_MENU_BRIEFING + 1]; - - while (Q_strlen(msg_portion) >= MAX_BUFFER_MENU_BRIEFING) - { - Q_strncpy(sbuf, msg_portion, MAX_BUFFER_MENU_BRIEFING); - sbuf[ MAX_BUFFER_MENU_BRIEFING ] = '\0'; - msg_portion += MAX_BUFFER_MENU_BRIEFING; - - MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pev); - WRITE_SHORT(0xFFFF); - WRITE_CHAR(-1); - WRITE_BYTE(1); // multipart - WRITE_STRING(sbuf); - MESSAGE_END(); - } - - MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pev); - WRITE_SHORT(0xFFFF); - WRITE_CHAR(-1); - WRITE_BYTE(0); // multipart - WRITE_STRING(msg_portion); - MESSAGE_END(); -} - -/* <154f3d> ../cstrike/dlls/player.cpp:3753 */ -void CBasePlayer::MakeVIP(void) -{ - pev->body = 0; - m_iModelName = MODEL_VIP; - - SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "vip"); - UTIL_LogPrintf("\"%s<%i><%s>\" triggered \"Became_VIP\"\n", STRING(pev->netname), GETPLAYERUSERID(edict()), GETPLAYERAUTHID(edict())); - - m_iTeam = CT; - m_bIsVIP = true; - m_bNotKilled = false; - - g_pGameRules->m_pVIP = this; - g_pGameRules->m_iConsecutiveVIP = 1; -} - -/* <154fe5> ../cstrike/dlls/player.cpp:3785 */ -void CBasePlayer::JoiningThink(void) -{ - switch (m_iJoiningState) - { - case JOINED: - { - return; - } - case SHOWLTEXT: - { - ResetMenu(); - m_iJoiningState = SHOWTEAMSELECT; - - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("defuser"); - MESSAGE_END(); - - m_bHasDefuser = false; - m_fLastMovement = gpGlobals->time; - m_bMissionBriefing = false; - - SendItemStatus(this); - break; - } - case READINGLTEXT: - { - if (m_afButtonPressed & (IN_ATTACK | IN_ATTACK2 | IN_JUMP)) - { - m_afButtonPressed &= ~(IN_ATTACK | IN_ATTACK2 | IN_JUMP); - - RemoveLevelText(); - m_iJoiningState = SHOWTEAMSELECT; - } - - break; - } - case GETINTOGAME: - { - CHalfLifeMultiplay *mp = g_pGameRules; - - m_bNotKilled = false; - m_iIgnoreGlobalChat = IGNOREMSG_NONE; - - m_iTeamKills = 0; - m_iFOV = DEFAULT_FOV; - - Q_memset(&m_rebuyStruct, 0, sizeof(m_rebuyStruct)); - - m_bIsInRebuy = false; - m_bJustConnected = false; - m_fLastMovement = gpGlobals->time; - - ResetMaxSpeed(); - m_iJoiningState = JOINED; - - if (mp->m_bMapHasEscapeZone && m_iTeam == CT) - { - m_iAccount = 0; - CheckStartMoney(); - AddAccount(startmoney.value); - } - - if (mp->FPlayerCanRespawn(this)) - { - Spawn(); - - mp->CheckWinConditions(); - - if (!mp->m_fTeamCount && mp->m_bMapHasBombTarget && !mp->IsThereABomber() && !mp->IsThereABomb()) - { - mp->GiveC4(); - } - if (m_iTeam == TERRORIST) - { - mp->m_iNumEscapers++; - } - } - else - { - pev->deadflag = DEAD_RESPAWNABLE; - - if (pev->classname) - { - RemoveEntityHashValue(pev, STRING(pev->classname), CLASSNAME); - } - - MAKE_STRING_CLASS("player", pev); - AddEntityHashValue(pev, STRING(pev->classname), CLASSNAME); - - pev->flags &= (FL_PROXY | FL_FAKECLIENT); - pev->flags |= (FL_SPECTATOR | FL_CLIENT); - - edict_t *pentSpawnSpot = mp->GetPlayerSpawnSpot(this); - StartObserver(pev->origin, VARS(pentSpawnSpot)->angles); - - mp->CheckWinConditions(); - - MESSAGE_BEGIN(MSG_ALL, gmsgTeamInfo); - WRITE_BYTE(entindex()); - switch (m_iTeam) - { - case CT: - WRITE_STRING("CT"); - break; - case TERRORIST: - WRITE_STRING("TERRORIST"); - break; - case SPECTATOR: - WRITE_STRING("SPECTATOR"); - break; - default: - WRITE_STRING("UNASSIGNED"); - break; - } - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_ALL, gmsgLocation); - WRITE_BYTE(entindex()); - WRITE_STRING(""); - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_ALL, gmsgScoreInfo); - WRITE_BYTE(ENTINDEX(edict())); - WRITE_SHORT((int)pev->frags); - WRITE_SHORT(m_iDeaths); - WRITE_SHORT(0); - WRITE_SHORT(m_iTeam); - MESSAGE_END(); - - if (!(m_flDisplayHistory & DHF_SPEC_DUCK)) - { - HintMessage("#Spec_Duck", TRUE, TRUE); - m_flDisplayHistory |= DHF_SPEC_DUCK; - } - } - - return; - } - } - - if (m_pIntroCamera && gpGlobals->time >= m_fIntroCamTime) - { - m_pIntroCamera = UTIL_FindEntityByClassname(m_pIntroCamera, "trigger_camera"); - - if (!m_pIntroCamera) - { - m_pIntroCamera = UTIL_FindEntityByClassname(NULL, "trigger_camera"); - } - - CBaseEntity *Target = UTIL_FindEntityByTargetname(NULL, STRING(m_pIntroCamera->pev->target)); - - if (Target) - { - Vector CamAngles = UTIL_VecToAngles((Target->pev->origin - m_pIntroCamera->pev->origin).Normalize()); - - CamAngles.x = -CamAngles.x; - UTIL_SetOrigin(pev, m_pIntroCamera->pev->origin); - - pev->angles = CamAngles; - pev->v_angle = pev->angles; - - pev->velocity = g_vecZero; - pev->punchangle = g_vecZero; - - pev->fixangle = 1; - pev->view_ofs = g_vecZero; - m_fIntroCamTime = gpGlobals->time + 6; - } - else - m_pIntroCamera = NULL; - } -} - -/* <16076f> ../cstrike/dlls/player.cpp:3952 */ -void CBasePlayer::Disappear(void) -{ - if (m_pTank != NULL) - { - m_pTank->Use(this, this, USE_OFF, 0); - m_pTank = NULL; - } - - CSound *pSound = CSoundEnt::SoundPointerForIndex(CSoundEnt::ClientSoundIndex(edict())); - - if (pSound) - { - pSound->Reset(); - } - - m_fSequenceFinished = TRUE; - pev->modelindex = m_modelIndexPlayer; - pev->view_ofs = Vector(0, 0, -8); - pev->deadflag = DEAD_DYING; - pev->solid = SOLID_NOT; - pev->flags &= ~FL_ONGROUND; - - SetSuitUpdate(NULL, FALSE, 0); - - m_iClientHealth = 0; - MESSAGE_BEGIN(MSG_ONE, gmsgHealth, NULL, pev); - WRITE_BYTE(m_iClientHealth); - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev); - WRITE_BYTE(0); - WRITE_BYTE(0xFF); - WRITE_BYTE(0xFF); - MESSAGE_END(); - - SendFOV(0); - - g_pGameRules->CheckWinConditions(); - m_bNotKilled = false; - - if (m_bHasC4) - { - DropPlayerItem("weapon_c4"); - SetProgressBarTime(0); - } - else if (m_bHasDefuser) - { - m_bHasDefuser = false; - pev->body = 0; - GiveNamedItem("item_thighpack"); - - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("defuser"); - MESSAGE_END(); - - SendItemStatus(this); - SetProgressBarTime(0); - } - - BuyZoneIcon_Clear(this); - - SetThink(&CBasePlayer::PlayerDeathThink); - pev->nextthink = gpGlobals->time + 0.1f; - - pev->angles.x = 0; - pev->angles.z = 0; -} - -/* <15f83d> ../cstrike/dlls/player.cpp:4039 */ -void CBasePlayer::PlayerDeathThink(void) -{ - if (m_iJoiningState != JOINED) - return; - - if (pev->flags & FL_ONGROUND) - { - float flForward = pev->velocity.Length() - 20; - - if (flForward <= 0) - pev->velocity = g_vecZero; - else - pev->velocity = flForward * pev->velocity.Normalize(); - } - - if (HasWeapons()) - { - // we drop the guns here because weapons that have an area effect and can kill their user - // will sometimes crash coming back from CBasePlayer::Killed() if they kill their owner because the - // player class sometimes is freed. It's safer to manipulate the weapons once we know - // we aren't calling into any of their code anymore through the player pointer. - PackDeadPlayerItems(); - } - - if (pev->modelindex && !m_fSequenceFinished && pev->deadflag == DEAD_DYING) - { - StudioFrameAdvance(); - return; - } - - // once we're done animating our death and we're on the ground, we want to set movetype to None so our dead body won't do collisions and stuff anymore - // this prevents a bug where the dead body would go to a player's head if he walked over it while the dead player was clicking their button to respawn - if (pev->movetype != MOVETYPE_NONE && (pev->flags & FL_ONGROUND)) - pev->movetype = MOVETYPE_NONE; - - if (pev->deadflag == DEAD_DYING) - { - m_fDeadTime = gpGlobals->time; - pev->deadflag = DEAD_DEAD; - } - - StopAnimation(); - pev->effects |= EF_NOINTERP; - - BOOL fAnyButtonDown = (pev->button & ~IN_SCORE); - - // if the player has been dead for one second longer than allowed by forcerespawn, - // forcerespawn isn't on. Send the player off to an intermission camera until they - // choose to respawn. - if (g_pGameRules->IsMultiplayer()) - { - if (gpGlobals->time > m_fDeadTime + 3.0 && !(m_afPhysicsFlags & PFLAG_OBSERVER)) - { - SpawnClientSideCorpse(); - StartDeathCam(); // go to dead camera. - } - } - - // wait for all buttons released - if (pev->deadflag == DEAD_DEAD && m_iTeam != UNASSIGNED && m_iTeam != SPECTATOR) - { - if (fAnyButtonDown) - return; - - if (g_pGameRules->FPlayerCanRespawn(this)) - { - pev->deadflag = DEAD_RESPAWNABLE; - - if (g_pGameRules->IsMultiplayer()) - g_pGameRules->CheckWinConditions(); - } - - pev->nextthink = gpGlobals->time + 0.1; - } - else if (pev->deadflag == DEAD_RESPAWNABLE) - { - respawn(pev, FALSE); - pev->button = 0; - pev->nextthink = -1; - } -} - -/* <153042> ../cstrike/dlls/player.cpp:4134 */ -void CBasePlayer::__MAKE_VHOOK(RoundRespawn)(void) -{ - m_canSwitchObserverModes = true; - - if (m_bJustKilledTeammate && CVAR_GET_FLOAT("mp_tkpunish")) - { - m_bJustKilledTeammate = false; -#ifndef REGAMEDLL_FIXES - // TODO: wtf? - CLIENT_COMMAND(edict(), "kill\n"); -#else - if (pev->health > 0.0f) - { - ClientKill(ENT(pev)); - } -#endif // REGAMEDLL_FIXES - m_bPunishedForTK = true; - } - if (m_iMenu != Menu_ChooseAppearance) - { - respawn(pev); - - pev->button = 0; - pev->nextthink = -1; - } - - if (m_pActiveItem) - { - if (m_pActiveItem->iItemSlot() == GRENADE_SLOT) - { - SwitchWeapon(m_pActiveItem); - } - } - - m_lastLocation[0] = '\0'; -} - -/* <155577> ../cstrike/dlls/player.cpp:4172 */ -void CBasePlayer::StartDeathCam(void) -{ - if (pev->view_ofs == g_vecZero) - { - // don't accept subsequent attempts to StartDeathCam() - return; - } - - StartObserver(pev->origin, pev->angles); - - if (TheBots) - { - TheBots->OnEvent(EVENT_DEATH_CAMERA_START, this); - } -} - -/* <155616> ../cstrike/dlls/player.cpp:4190 */ -void CBasePlayer::StartObserver(Vector vecPosition, Vector vecViewAngle) -{ - // clear any clientside entities attached to this player - MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, pev->origin); - WRITE_BYTE(TE_KILLPLAYERATTACHMENTS); - WRITE_BYTE(entindex()); - MESSAGE_END(); - - // Holster weapon immediately, to allow it to cleanup - if (m_pActiveItem) - m_pActiveItem->Holster(); - - if (m_pTank) - { - m_pTank->Use(this, this); - m_pTank = NULL; - } - - // clear out the suit message cache so we don't keep chattering - SetSuitUpdate(); - - // Tell Ammo Hud that the player is dead - MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev); - WRITE_BYTE(0); - WRITE_BYTE(0xFF); - WRITE_BYTE(0xFF); - MESSAGE_END(); - - // reset FOV - SendFOV(0); - - // Setup flags - m_iHideHUD = (HIDEHUD_WEAPONS | HIDEHUD_HEALTH); - m_afPhysicsFlags |= PFLAG_OBSERVER; - - pev->effects = EF_NODRAW; - pev->view_ofs = g_vecZero; - - pev->angles = pev->v_angle = vecViewAngle; - - pev->fixangle = 1; - pev->solid = SOLID_NOT; - - pev->takedamage = DAMAGE_NO; - pev->movetype = MOVETYPE_NONE; - - // Move them to the new position - UTIL_SetOrigin(pev, vecPosition); - - m_afPhysicsFlags &= ~PFLAG_DUCKING; - pev->flags &= ~FL_DUCKING; - pev->health = 1; - - m_iObserverC4State = 0; - m_bObserverHasDefuser = false; - - m_iObserverWeapon = 0; - m_flNextObserverInput = 0; - - pev->iuser1 = OBS_NONE; - - static int iFirstTime = 1; - CHalfLifeMultiplay *mp = g_pGameRules; - - if (iFirstTime && mp && mp->IsCareer() && !IsBot()) - { - Observer_SetMode(OBS_CHASE_LOCKED); - CLIENT_COMMAND(edict(), "spec_autodirector_internal 1\n"); - iFirstTime = 0; - } - else - Observer_SetMode(m_iObserverLastMode); - - ResetMaxSpeed(); - - // Tell all clients this player is now a spectator - MESSAGE_BEGIN(MSG_ALL, gmsgSpectator); - WRITE_BYTE(entindex()); - WRITE_BYTE(1); - MESSAGE_END(); -} - -/* <14d785> ../cstrike/dlls/player.cpp:4272 */ -bool CanSeeUseable(CBasePlayer *me, CBaseEntity *entity) -{ - TraceResult result; - Vector eye = me->pev->origin + me->pev->view_ofs; - - if (FClassnameIs(entity->pev, "hostage_entity")) - { - Vector chest = entity->pev->origin + Vector(0, 0, 36); - Vector head = entity->pev->origin + Vector(0, 0, 72 * 0.9); - Vector knees = entity->pev->origin + Vector(0, 0, 18); - - UTIL_TraceLine(eye, chest, ignore_monsters, ignore_glass, me->edict(), &result); - if (result.flFraction < 1.0f) - { - UTIL_TraceLine(eye, head, ignore_monsters, ignore_glass, entity->edict(), &result); - if (result.flFraction < 1.0f) - { - UTIL_TraceLine(eye, knees, ignore_monsters, ignore_glass, entity->edict(), &result); - if (result.flFraction < 1.0f) - { - return false; - } - } - } - } - - return true; -} - -/* <155815> ../cstrike/dlls/player.cpp:4307 */ -void CBasePlayer::PlayerUse(void) -{ - // Was use pressed or released? - if (!((pev->button | m_afButtonPressed | m_afButtonReleased) & IN_USE)) - return; - - // Hit Use on a train? - if (m_afButtonPressed & IN_USE) - { - if (m_pTank != NULL) - { - // Stop controlling the tank - // TODO: Send HUD Update - m_pTank->Use(this, this, USE_OFF, 0); - m_pTank = NULL; - return; - } - - if (m_afPhysicsFlags & PFLAG_ONTRAIN) - { - m_iTrain = (TRAIN_NEW | TRAIN_OFF); - m_afPhysicsFlags &= ~PFLAG_ONTRAIN; - - CBaseEntity *pTrain = Instance(pev->groundentity); - if (pTrain && pTrain->Classify() == CLASS_VEHICLE) - { - ((CFuncVehicle *)pTrain)->m_pDriver = NULL; - } - return; - } - else - { - // Start controlling the train! - CBaseEntity *pTrain = Instance(pev->groundentity); - - if (pTrain && !(pev->button & IN_JUMP) && (pev->flags & FL_ONGROUND) && (pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE) && pTrain->OnControls(pev)) - { - m_afPhysicsFlags |= PFLAG_ONTRAIN; - - m_iTrain = TrainSpeed(pTrain->pev->speed, pTrain->pev->impulse); - m_iTrain |= TRAIN_NEW; - - if (pTrain->Classify() == CLASS_VEHICLE) - { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "plats/vehicle_ignition.wav", 0.8, ATTN_NORM); - ((CFuncVehicle *)pTrain)->m_pDriver = this; - } - else - EMIT_SOUND(ENT(pev), CHAN_ITEM, "plats/train_use1.wav", 0.8, ATTN_NORM); - - return; - } - } - } - - bool useNewHostages = !TheNavAreaList.empty(); - CBaseEntity *pObject = NULL; - CBaseEntity *pClosest = NULL; - Vector vecLOS; - float flMaxDot = VIEW_FIELD_NARROW; - float flDot; - - // so we know which way we are facing - UTIL_MakeVectors(pev->v_angle); - - if (useNewHostages) - { - TraceResult result; - const float useHostageRange = 1000.0f; - - Vector vecStart = pev->origin + pev->view_ofs; - Vector vecEnd = vecStart + gpGlobals->v_forward * useHostageRange; - - UTIL_TraceLine(vecStart, vecEnd, dont_ignore_monsters, edict(), &result); - - if (result.flFraction < 1.0f) - { - CBaseEntity *hit = Instance(result.pHit); - if (hit != NULL && FClassnameIs(hit->pev, "hostage_entity") && CanSeeUseable(this, hit)) - pClosest = hit; - } - - if (!pClosest) - { - while ((pObject = UTIL_FindEntityInSphere(pObject, pev->origin, useHostageRange)) != NULL) - { - if (!FClassnameIs(pObject->pev, "hostage_entity")) - continue; - - vecLOS = VecBModelOrigin(pObject->pev) - vecStart; - vecLOS.NormalizeInPlace(); - - flDot = DotProduct(vecLOS, gpGlobals->v_forward); - - if (flDot > flMaxDot && CanSeeUseable(this, pObject)) - { - pClosest = pObject; - flMaxDot = flDot; - } - } - } - } - - if (!pClosest) - { - while ((pObject = UTIL_FindEntityInSphere(pObject, pev->origin, PLAYER_SEARCH_RADIUS)) != NULL) - { - if (pObject->ObjectCaps() & (FCAP_IMPULSE_USE | FCAP_CONTINUOUS_USE | FCAP_ONOFF_USE)) - { - // !!!PERFORMANCE- should this check be done on a per case basis AFTER we've determined that - // this object is actually usable? This dot is being done for every object within PLAYER_SEARCH_RADIUS - // when player hits the use key. How many objects can be in that area, anyway? (sjb) - vecLOS = (VecBModelOrigin(pObject->pev) - (pev->origin + pev->view_ofs)); - vecLOS.NormalizeInPlace(); - - flDot = DotProduct(vecLOS, gpGlobals->v_forward); - - // only if the item is in front of the user - if (flDot > flMaxDot) - { - flMaxDot = flDot; - pClosest = pObject; - } - } - } - } - - pObject = pClosest; - - // Found an object - if (pObject != NULL) - { - if (!useNewHostages || CanSeeUseable(this, pObject)) - { - int caps = pObject->ObjectCaps(); - - if (m_afButtonPressed & IN_USE) - EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/wpn_select.wav", 0.4, ATTN_NORM); - - if (((pev->button & IN_USE) && (caps & FCAP_CONTINUOUS_USE)) - || ((m_afButtonPressed & IN_USE) && (caps & (FCAP_IMPULSE_USE | FCAP_ONOFF_USE)))) - { - if (caps & FCAP_CONTINUOUS_USE) - m_afPhysicsFlags |= PFLAG_USING; - - pObject->Use(this, this, USE_SET, 1); - } - // UNDONE: Send different USE codes for ON/OFF. Cache last ONOFF_USE object to send 'off' if you turn away - // BUGBUG This is an "off" use - else if ((m_afButtonReleased & IN_USE) && (pObject->ObjectCaps() & FCAP_ONOFF_USE)) - { - pObject->Use(this, this, USE_SET, 0); - } - } - } - else - { - if (m_afButtonPressed & IN_USE) - EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/wpn_denyselect.wav", 0.4, ATTN_NORM); - } -} - -/* <155f41> ../cstrike/dlls/player.cpp:4486 */ -void CBasePlayer::HostageUsed(void) -{ - if (m_flDisplayHistory & DHF_HOSTAGE_USED) - return; - - if (m_iTeam == TERRORIST) - HintMessage("#Hint_use_hostage_to_stop_him"); - - else if (m_iTeam == CT) - HintMessage("#Hint_lead_hostage_to_rescue_point"); - - m_flDisplayHistory |= DHF_HOSTAGE_USED; -} - -/* <153f69> ../cstrike/dlls/player.cpp:4507 */ -void CBasePlayer::__MAKE_VHOOK(Jump)(void) -{ - if (pev->flags & FL_WATERJUMP) - return; - - if (pev->waterlevel >= 2) - { - return; - } - - // jump velocity is sqrt( height * gravity * 2) - // If this isn't the first frame pressing the jump button, break out. - if (!(m_afButtonPressed & IN_JUMP)) - { - // don't pogo stick - return; - } - - if (!(pev->flags & FL_ONGROUND) || pev->groundentity == NULL) - return; - - // many features in this function use v_forward, so makevectors now. - UTIL_MakeVectors(pev->angles); - SetAnimation(PLAYER_JUMP); - - if ((pev->flags & FL_DUCKING) || (m_afPhysicsFlags & PFLAG_DUCKING)) - { - if (m_fLongJump && (pev->button & IN_DUCK) && (gpGlobals->time - m_flDuckTime < 1.0f) && pev->velocity.Length() > 50) - { - SetAnimation(PLAYER_SUPERJUMP); - } - } - - // If you're standing on a conveyor, add it's velocity to yours (for momentum) - entvars_t *pevGround = VARS(pev->groundentity); - if (pevGround) - { - if (pevGround->flags & FL_CONVEYOR) - { - pev->velocity = pev->velocity + pev->basevelocity; - } - - if (FClassnameIs(pevGround, "func_tracktrain") - || FClassnameIs(pevGround, "func_train") - || FClassnameIs(pevGround, "func_vehicle")) - { - pev->velocity = pevGround->velocity + pev->velocity; - } - } -} - -// This is a glorious hack to find free space when you've crouched into some solid space -// Our crouching collisions do not work correctly for some reason and this is easier -// than fixing the problem :( - -/* <155fe2> ../cstrike/dlls/player.cpp:4565 */ -NOXREF void FixPlayerCrouchStuck(edict_t *pPlayer) -{ - TraceResult trace; - - // Move up as many as 18 pixels if the player is stuck. - for (int i = 0; i < 18; i++) - { - UTIL_TraceHull(pPlayer->v.origin, pPlayer->v.origin, dont_ignore_monsters, head_hull, pPlayer, &trace); - - if (trace.fStartSolid) - pPlayer->v.origin.z ++; - else - break; - } -} - -/* <153ef5> ../cstrike/dlls/player.cpp:4580 */ -void CBasePlayer::__MAKE_VHOOK(Duck)(void) -{ - if (pev->button & IN_DUCK) - SetAnimation(PLAYER_WALK); -} - -/* <150f8f> ../cstrike/dlls/player.cpp:4591 */ -int CBasePlayer::__MAKE_VHOOK(Classify)(void) -{ - return CLASS_PLAYER; -} - -/* <150fb7> ../cstrike/dlls/player.cpp:4597 */ -void CBasePlayer::__MAKE_VHOOK(AddPoints)(int score, BOOL bAllowNegativeScore) -{ - if (score < 0 && !bAllowNegativeScore) - { - if (pev->frags < 0) - return; - - if (-score > pev->frags) - score = -pev->frags; - } - - pev->frags += score; - - MESSAGE_BEGIN(MSG_BROADCAST, gmsgScoreInfo); - WRITE_BYTE(ENTINDEX(edict())); - WRITE_SHORT((int)pev->frags); - WRITE_SHORT(m_iDeaths); - WRITE_SHORT(0); - WRITE_SHORT(m_iTeam); - MESSAGE_END(); -} - -/* <15125b> ../cstrike/dlls/player.cpp:4626 */ -void CBasePlayer::__MAKE_VHOOK(AddPointsToTeam)(int score, BOOL bAllowNegativeScore) -{ - int index = entindex(); - - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); - - if (pPlayer && i != index) - { - if (g_pGameRules->PlayerRelationship(this, pPlayer) == GR_TEAMMATE) - pPlayer->AddPoints(score, bAllowNegativeScore); - } - } -} - -/* <156047> ../cstrike/dlls/player.cpp:4645 */ -bool CBasePlayer::CanPlayerBuy(bool display) -{ - CHalfLifeMultiplay *mp = g_pGameRules; - int buyTime; - - if (!mp->IsMultiplayer()) - { - return CHalfLifeTraining::PlayerCanBuy(this); - } - - if (pev->deadflag != DEAD_NO || !(m_signals.GetState() & SIGNAL_BUY)) - { - return false; - } - - buyTime = (int)(CVAR_GET_FLOAT("mp_buytime") * 60); - if (buyTime < 15) - { - buyTime = 15; - CVAR_SET_FLOAT("mp_buytime", 1 / (60 / 15)); - } - - if (gpGlobals->time - mp->m_fRoundCount > buyTime) - { - if (display) - { - ClientPrint(pev, HUD_PRINTCENTER, "#Cant_buy", UTIL_dtos1(buyTime)); - } - return false; - } - if (m_bIsVIP) - { - if (display) - { - ClientPrint(pev, HUD_PRINTCENTER, "#VIP_cant_buy"); - } - return false; - } - if (mp->m_bCTCantBuy && m_iTeam == CT) - { - if (display) - { - ClientPrint(pev, HUD_PRINTCENTER, "#CT_cant_buy"); - } - return false; - } - if (mp->m_bTCantBuy && m_iTeam == TERRORIST) - { - if (display) - { - ClientPrint(pev, HUD_PRINTCENTER, "#Terrorist_cant_buy"); - } - return false; - } - - return true; -} - -/* <15f9ac> ../cstrike/dlls/player.cpp:4717 */ -void CBasePlayer::__MAKE_VHOOK(PreThink)(void) -{ - int buttonsChanged = (pev->button ^ m_afButtonLast); - - if (pev->button != m_afButtonLast) - m_fLastMovement = gpGlobals->time; - - m_afButtonPressed = (buttonsChanged & pev->button); // The changed ones still down are "pressed" - m_afButtonReleased = (buttonsChanged & (~pev->button)); // The ones not down are "released" - - m_hintMessageQueue.Update(this); - g_pGameRules->PlayerThink(this); - - if (g_fGameOver) - { - return; - } - - if (m_iJoiningState != JOINED) - { - JoiningThink(); - } - - if (m_bMissionBriefing) - { - if (m_afButtonPressed & (IN_ATTACK | IN_ATTACK2)) - { - m_afButtonPressed &= ~(IN_ATTACK | IN_ATTACK2); - RemoveLevelText(); - m_bMissionBriefing = false; - } - } - - UTIL_MakeVectors(pev->v_angle); - ItemPreFrame(); - WaterMove(); - - if (pev->flags & FL_ONGROUND) - { - if (m_flVelocityModifier < 1.0f) - { - float_precision modvel = m_flVelocityModifier + 0.01; - - m_flVelocityModifier = modvel; - pev->velocity = pev->velocity * modvel; - } - - if (m_flVelocityModifier > 1.0f) - m_flVelocityModifier = 1; - } - - if (m_flIdleCheckTime <= (double)gpGlobals->time || m_flIdleCheckTime == 0.0f) - { - m_flIdleCheckTime = gpGlobals->time + 5.0; - - double v25 = gpGlobals->time - m_fLastMovement; - - if (v25 > g_pGameRules->m_fMaxIdlePeriod) - { - if (!IsBot() && CVAR_GET_FLOAT("mp_autokick") != 0.0f) - { - UTIL_LogPrintf("\"%s<%i><%s><%s>\" triggered \"Game_idle_kick\" (auto)\n", - STRING(pev->netname), - GETPLAYERUSERID(edict()), - GETPLAYERAUTHID(edict()), - GetTeam(m_iTeam)); - - UTIL_ClientPrintAll(HUD_PRINTCONSOLE, "#Game_idle_kick", STRING(pev->netname)); - SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(pev->netname))); - m_fLastMovement = gpGlobals->time; - } - } - } - - if (g_pGameRules && g_pGameRules->FAllowFlashlight()) - m_iHideHUD &= ~HIDEHUD_FLASHLIGHT; - else - m_iHideHUD |= HIDEHUD_FLASHLIGHT; - - // JOHN: checks if new client data (for HUD and view control) needs to be sent to the client - UpdateClientData(); - CheckTimeBasedDamage(); - CheckSuitUpdate(); - - // So the correct flags get sent to client asap. - if (m_afPhysicsFlags & PFLAG_ONTRAIN) - pev->flags |= FL_ONTRAIN; - else - pev->flags &= ~FL_ONTRAIN; - - // Observer Button Handling - if (IsObserver() && (m_afPhysicsFlags & PFLAG_OBSERVER)) - { - Observer_HandleButtons(); - Observer_CheckTarget(); - Observer_CheckProperties(); - return; - } - - if (pev->deadflag >= DEAD_DYING && pev->deadflag != DEAD_RESPAWNABLE) - { - PlayerDeathThink(); - return; - } - - CBaseEntity *pGroundEntity = Instance(pev->groundentity); - - if (pGroundEntity && pGroundEntity->Classify() == CLASS_VEHICLE) - pev->iuser4 = 1; - else - pev->iuser4 = 0; - - // Train speed control - if (m_afPhysicsFlags & PFLAG_ONTRAIN) - { - CBaseEntity *pTrain = Instance(pev->groundentity); - float vel; - - if (!pTrain) - { - TraceResult trainTrace; - // Maybe this is on the other side of a level transition - UTIL_TraceLine(pev->origin, pev->origin + Vector(0, 0, -38), ignore_monsters, ENT(pev), &trainTrace); - - // HACKHACK - Just look for the func_tracktrain classname - if (trainTrace.flFraction != 1.0f && trainTrace.pHit) - pTrain = Instance(trainTrace.pHit); - - if (!pTrain || !(pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE) || !pTrain->OnControls(pev)) - { - m_iTrain = (TRAIN_NEW | TRAIN_OFF); - m_afPhysicsFlags &= ~PFLAG_ONTRAIN; - - ((CFuncVehicle *)pTrain)->m_pDriver = NULL; - return; - } - } - else if (!(pev->flags & FL_ONGROUND) || (pTrain->pev->spawnflags & SF_TRACKTRAIN_NOCONTROL)) - { - // Turn off the train if you jump, strafe, or the train controls go dead - m_iTrain = (TRAIN_NEW | TRAIN_OFF); - m_afPhysicsFlags &= ~PFLAG_ONTRAIN; - - ((CFuncVehicle *)pTrain)->m_pDriver = NULL; - return; - } - - pev->velocity = g_vecZero; - vel = 0; - - if (pTrain->Classify() == CLASS_VEHICLE) - { - if (pev->button & IN_FORWARD) - { - vel = 1; - pTrain->Use(this, this, USE_SET, vel); - } - - if (pev->button & IN_BACK) - { - vel = -1; - pTrain->Use(this, this, USE_SET, vel); - } - - if (pev->button & IN_MOVELEFT) - { - vel = 20; - pTrain->Use(this, this, USE_SET, vel); - } - if (pev->button & IN_MOVERIGHT) - { - vel = 30; - pTrain->Use(this, this, USE_SET, vel); - } - } - else - { - if (m_afButtonPressed & IN_FORWARD) - { - vel = 1; - pTrain->Use(this, this, USE_SET, vel); - } - else if (m_afButtonPressed & IN_BACK) - { - vel = -1; - pTrain->Use(this, this, USE_SET, vel); - } - } - - if (vel) - { - m_iTrain = TrainSpeed(pTrain->pev->speed, pTrain->pev->impulse); - m_iTrain |= (TRAIN_ACTIVE | TRAIN_NEW); - } - } - else if (m_iTrain & TRAIN_ACTIVE) - { - // turn off train - m_iTrain = TRAIN_NEW; - } - - if (pev->button & IN_JUMP) - { - // If on a ladder, jump off the ladder - // else Jump - Jump(); - } - - // If trying to duck, already ducked, or in the process of ducking - if ((pev->button & IN_DUCK) || (pev->flags & FL_DUCKING) || (m_afPhysicsFlags & PFLAG_DUCKING)) - { - Duck(); - } - - if (!(pev->flags & FL_ONGROUND)) - { - m_flFallVelocity = -pev->velocity.z; - } - - // Clear out ladder pointer - m_hEnemy = NULL; - - if (m_afPhysicsFlags & PFLAG_ONBARNACLE) - { - pev->velocity = g_vecZero; - } - - if (!(m_flDisplayHistory & DHF_ROUND_STARTED) && CanPlayerBuy()) - { - HintMessage("#Hint_press_buy_to_purchase"); - m_flDisplayHistory |= DHF_ROUND_STARTED; - } - - UpdateLocation(); -} - -// If player is taking time based damage, continue doing damage to player - -// this simulates the effect of being poisoned, gassed, dosed with radiation etc - -// anything that continues to do damage even after the initial contact stops. -// Update all time based damage counters, and shut off any that are done. - -// The m_bitsDamageType bit MUST be set if any damage is to be taken. -// This routine will detect the initial on value of the m_bitsDamageType -// and init the appropriate counter. Only processes damage every second. - -/* <156096> ../cstrike/dlls/player.cpp:5146 */ -void CBasePlayer::CheckTimeBasedDamage(void) -{ - int i; - BYTE bDuration = 0; - //static float gtbdPrev = 0.0; - - if (!(m_bitsDamageType & DMG_TIMEBASED)) - return; - - if (abs((int64_t)(gpGlobals->time - m_tbdPrev)) < 2.0f) - return; - - m_tbdPrev = gpGlobals->time; - - for (i = 0; i < CDMG_TIMEBASED; i++) - { - if (m_bitsDamageType & (DMG_PARALYZE << i)) - { - switch (i) - { - case itbd_Paralyze: - // UNDONE - flag movement as half-speed - bDuration = PARALYZE_DURATION; - break; - case itbd_NerveGas: - bDuration = NERVEGAS_DURATION; - break; - case itbd_Poison: - { - TakeDamage(pev, pev, POISON_DAMAGE, DMG_GENERIC); - bDuration = POISON_DURATION; - break; - } - case itbd_DrownRecover: - { - if (m_idrowndmg > m_idrownrestored) - { - int idif = Q_min(m_idrowndmg - m_idrownrestored, 10); - TakeHealth(idif, DMG_GENERIC); - m_idrownrestored += idif; - } - - bDuration = 4; - break; - } - case itbd_Radiation: - bDuration = RADIATION_DURATION; - break; - case itbd_Acid: - bDuration = ACID_DURATION; - break; - case itbd_SlowBurn: - bDuration = SLOWBURN_DURATION; - break; - case itbd_SlowFreeze: - bDuration = SLOWFREEZE_DURATION; - break; - default: - bDuration = 0; - break; - } - - if (m_rgbTimeBasedDamage[i]) - { - // use up an antitoxin on poison or nervegas after a few seconds of damage - if ((i == itbd_NerveGas && m_rgbTimeBasedDamage[i] < NERVEGAS_DURATION) || (i == itbd_Poison && m_rgbTimeBasedDamage[i] < POISON_DURATION)) - { - if (m_rgItems[ ITEM_ANTIDOTE ]) - { - m_rgbTimeBasedDamage[i] = 0; - m_rgItems[ ITEM_ANTIDOTE ]--; - SetSuitUpdate("!HEV_HEAL4", FALSE, SUIT_REPEAT_OK); - } - } - - // decrement damage duration, detect when done. - if (!m_rgbTimeBasedDamage[i] || --m_rgbTimeBasedDamage[i] == 0) - { - m_rgbTimeBasedDamage[i] = 0; - // if we're done, clear damage bits - m_bitsDamageType &= ~(DMG_PARALYZE << i); - } - } - else - // first time taking this damage type - init damage duration - m_rgbTimeBasedDamage[i] = bDuration; - } - } -} - -/* <156112> ../cstrike/dlls/player.cpp:5312 */ -void CBasePlayer::UpdateGeigerCounter(void) -{ - if (gpGlobals->time < m_flgeigerDelay) - return; - - m_flgeigerDelay = gpGlobals->time + 0.25; - BYTE range = (byte)(m_flgeigerRange * 0.25); - - if (range != m_igeigerRangePrev) - { - m_igeigerRangePrev = range; - - MESSAGE_BEGIN(MSG_ONE, gmsgGeigerRange, NULL, pev); - WRITE_BYTE(range); - MESSAGE_END(); - } - - if (!RANDOM_LONG(0, 3)) - m_flgeigerRange = 1000.0; -} - -/* <156189> ../cstrike/dlls/player.cpp:5352 */ -void CBasePlayer::CheckSuitUpdate(void) -{ - int i; - int isentence = 0; - int isearch = m_iSuitPlayNext; - - // Ignore suit updates if no suit - if (!(pev->weapons & (1 << WEAPON_SUIT))) - return; - - // if in range of radiation source, ping geiger counter - UpdateGeigerCounter(); - - if (g_pGameRules->IsMultiplayer()) - { - // don't bother updating HEV voice in multiplayer. - return; - } - - if (gpGlobals->time >= m_flSuitUpdate && m_flSuitUpdate > 0) - { - // play a sentence off of the end of the queue - for (i = 0; i < CSUITPLAYLIST; i++) - { - if (isentence = m_rgSuitPlayList[ isearch ]) - break; - - if (++isearch == CSUITPLAYLIST) - isearch = 0; - } - - if (isentence) - { - m_rgSuitPlayList[ isearch ] = 0; - - if (isentence > 0) - { - // play sentence number - - char sentence[CBSENTENCENAME_MAX + 1]; - Q_strcpy(sentence, "!"); - Q_strcat(sentence, gszallsentencenames[isentence]); - EMIT_SOUND_SUIT(ENT(pev), sentence); - } - else - { - // play sentence group - EMIT_GROUPID_SUIT(ENT(pev), -isentence); - } - m_flSuitUpdate = gpGlobals->time + SUITUPDATETIME; - } - else - // queue is empty, don't check - m_flSuitUpdate = 0; - } -} - -/* <156201> ../cstrike/dlls/player.cpp:5414 */ -void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) -{ - ; -} - -/* <15623f> ../cstrike/dlls/player.cpp:5519 */ -void CBasePlayer::CheckPowerups(entvars_t *pev) -{ - if (pev->health > 0.0f) - pev->modelindex = m_modelIndexPlayer; -} - -/* <15626b> ../cstrike/dlls/player.cpp:5531 */ -void CBasePlayer::SetNewPlayerModel(const char *modelName) -{ - SET_MODEL(edict(), modelName); - m_modelIndexPlayer = pev->modelindex; -} - -// UpdatePlayerSound - updates the position of the player's -// reserved sound slot in the sound list. - -/* <1562a4> ../cstrike/dlls/player.cpp:5543 */ -void CBasePlayer::UpdatePlayerSound(void) -{ - int iBodyVolume; - int iVolume; - CSound *pSound; - - pSound = CSoundEnt::SoundPointerForIndex(CSoundEnt::ClientSoundIndex(edict())); - - if (!pSound) - { - ALERT(at_console, "Client lost reserved sound!\n"); - return; - } - - pSound->m_iType = bits_SOUND_NONE; - - // now calculate the best target volume for the sound. If the player's weapon - // is louder than his body/movement, use the weapon volume, else, use the body volume. - - if (pev->flags & FL_ONGROUND) - { - iBodyVolume = pev->velocity.Length(); - - // clamp the noise that can be made by the body, in case a push trigger, - // weapon recoil, or anything shoves the player abnormally fast. - if (iBodyVolume> 512) - { - iBodyVolume = 512; - } - } - else - { - iBodyVolume = 0; - } - - if (pev->button & IN_JUMP) - { - iBodyVolume += 100; - } - - // convert player move speed and actions into sound audible by monsters. - if (m_iWeaponVolume > iBodyVolume) - { - m_iTargetVolume = m_iWeaponVolume; - - // OR in the bits for COMBAT sound if the weapon is being louder than the player. - pSound->m_iType |= bits_SOUND_COMBAT; - } - else - { - m_iTargetVolume = iBodyVolume; - } - - // decay weapon volume over time so bits_SOUND_COMBAT stays set for a while - m_iWeaponVolume -= 250 * gpGlobals->frametime; - - // if target volume is greater than the player sound's current volume, we paste the new volume in - // immediately. If target is less than the current volume, current volume is not set immediately to the - // lower volume, rather works itself towards target volume over time. This gives monsters a much better chance - // to hear a sound, especially if they don't listen every frame. - iVolume = pSound->m_iVolume; - - if (m_iTargetVolume > iVolume) - { - iVolume = m_iTargetVolume; - } - else if (iVolume > m_iTargetVolume) - { - iVolume -= 250 * gpGlobals->frametime; - - if (iVolume < m_iTargetVolume) - iVolume = 0; - } - - if (m_fNoPlayerSound) - { - // debugging flag, lets players move around and shoot without monsters hearing. - iVolume = 0; - } - - if (gpGlobals->time > m_flStopExtraSoundTime) - { - // since the extra sound that a weapon emits only lasts for one client frame, we keep that sound around for a server frame or two - // after actual emission to make sure it gets heard. - m_iExtraSoundTypes = 0; - } - - if (pSound) - { - pSound->m_vecOrigin = pev->origin; - pSound->m_iVolume = iVolume; - pSound->m_iType |= (bits_SOUND_PLAYER | m_iExtraSoundTypes); - } - - // keep track of virtual muzzle flash - m_iWeaponFlash -= 256 * gpGlobals->frametime; - - if (m_iWeaponFlash < 0) - m_iWeaponFlash = 0; - - UTIL_MakeVectors(pev->angles); - gpGlobals->v_forward.z = 0; -} - -/* <15a182> ../cstrike/dlls/player.cpp:5667 */ -void CBasePlayer::__MAKE_VHOOK(PostThink)(void) -{ - // intermission or finale - if (g_fGameOver) - goto pt_end; - - if (!IsAlive()) - goto pt_end; - - // Handle Tank controlling - if (m_pTank != NULL) - { - // if they've moved too far from the gun, or selected a weapon, unuse the gun - if (m_pTank->OnControls(pev) && !pev->weaponmodel) - { - // try fire the gun - m_pTank->Use(this, this, USE_SET, 2); - } - else - { - // they've moved off the platform - m_pTank->Use(this, this, USE_OFF, 0); - m_pTank = NULL; - } - } - - // do weapon stuff - ItemPostFrame(); - - // check to see if player landed hard enough to make a sound - // falling farther than half of the maximum safe distance, but not as far a max safe distance will - // play a bootscrape sound, and no damage will be inflicted. Fallling a distance shorter than half - // of maximum safe distance will make no sound. Falling farther than max safe distance will play a - // fallpain sound, and damage will be inflicted based on how far the player fell - if ((pev->flags & FL_ONGROUND) && pev->health > 0.0f && m_flFallVelocity >= PLAYER_FALL_PUNCH_THRESHHOLD) - { - if (pev->watertype != CONTENT_WATER) - { - // after this point, we start doing damage - if (m_flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED) - { - float flFallDamage = g_pGameRules->FlPlayerFallDamage(this); - - //splat - if (flFallDamage > pev->health) - { - // note: play on item channel because we play footstep landing on body channel - EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/bodysplat.wav", VOL_NORM, ATTN_NORM); - } - if (flFallDamage > 0) - { - m_LastHitGroup = HITGROUP_GENERIC; - TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), flFallDamage, DMG_FALL); - pev->punchangle.x = 0; - TheBots->OnEvent(EVENT_PLAYER_LANDED_FROM_HEIGHT, this); - } - } - } - - if (IsAlive()) - { - SetAnimation(PLAYER_WALK); - } - } - - if (pev->flags & FL_ONGROUND) - { - if (m_flFallVelocity > 64.0f && !g_pGameRules->IsMultiplayer()) - { - CSoundEnt::InsertSound(bits_SOUND_PLAYER, pev->origin, m_flFallVelocity, 0.2); - } - m_flFallVelocity = 0; - } - - // select the proper animation for the player character - if (IsAlive()) - { - if (pev->velocity.x || pev->velocity.y) - { - if (((pev->velocity.x || pev->velocity.y) && (pev->flags & FL_ONGROUND)) || pev->waterlevel > 1) - SetAnimation(PLAYER_WALK); - } - else if (pev->gaitsequence != ACT_FLY) - SetAnimation(PLAYER_IDLE); - } - - StudioFrameAdvance(); - CheckPowerups(pev); - UpdatePlayerSound(); - -pt_end: -#ifdef CLIENT_WEAPONS - // Decay timers on weapons - // go through all of the weapons and make a list of the ones to pack - for (int i = 0; i < MAX_ITEM_TYPES; i++) - { - if (m_rgpPlayerItems[i]) - { - CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[i]; - - while (pPlayerItem != NULL) - { - CBasePlayerWeapon *gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr(); - - if (gun && gun->UseDecrement()) - { - gun->m_flNextPrimaryAttack = Q_max(gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0f); - gun->m_flNextSecondaryAttack = Q_max(gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001f); - - if (gun->m_flTimeWeaponIdle != 1000.0f) - { - gun->m_flTimeWeaponIdle = Q_max(gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001f); - } - } - - pPlayerItem = pPlayerItem->m_pNext; - } - } - } - - m_flNextAttack -= gpGlobals->frametime; - - if (m_flNextAttack < -0.001) - m_flNextAttack = -0.001; -#endif // CLIENT_WEAPONS - - // Track button info so we can detect 'pressed' and 'released' buttons next frame - m_afButtonLast = pev->button; - m_iGaitsequence = pev->gaitsequence; - - StudioProcessGait(); -} - -/* <14e39d> ../cstrike/dlls/player.cpp:5837 */ -BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot) -{ - CBaseEntity *ent = NULL; - - if (!pSpot->IsTriggered(pPlayer)) - return FALSE; - - while ((ent = UTIL_FindEntityInSphere(ent, pSpot->pev->origin, 64)) != NULL) - { - if (ent->IsPlayer() && ent != pPlayer) - return FALSE; - } - - return TRUE; -} - -/* <1563a8> ../cstrike/dlls/player.cpp:5879 */ -NOXREF void InitZombieSpawns(void) -{ - CBaseEntity *spot = NULL; - - g_pSelectedZombieSpawn = NULL; - zombieSpawnCount = 0; - - while ((spot = UTIL_FindEntityByClassname(spot, "info_player_start")) != NULL) - { - if (spot->pev->origin != Vector(0, 0, 0)) - { - zombieSpawn[ zombieSpawnCount ].entity = spot; - zombieSpawn[ zombieSpawnCount ].useableTimer.Invalidate(); - - zombieSpawnCount++; - } - } -} - -/* <14e440> ../cstrike/dlls/player.cpp:5906 */ -NOXREF CBaseEntity *FindZombieSpawn(CBaseEntity *player, bool forceSpawn) -{ - return NULL; -} - -/* <15645f> ../cstrike/dlls/player.cpp:6060 */ -edict_t *EntSelectSpawnPoint(CBaseEntity *pPlayer) -{ - CBaseEntity *pSpot; - edict_t *player = pPlayer->edict(); - - // choose a info_player_deathmatch point - if (g_pGameRules->IsCoOp()) - { - pSpot = UTIL_FindEntityByClassname(g_pLastSpawn, "info_player_coop"); - - if (!FNullEnt(pSpot)) - goto ReturnSpot; - - pSpot = UTIL_FindEntityByClassname(g_pLastSpawn, "info_player_start"); - - if (!FNullEnt(pSpot)) - goto ReturnSpot; - } - else if (g_pGameRules->IsDeathmatch() && ((CBasePlayer *)pPlayer)->m_bIsVIP) - { - pSpot = UTIL_FindEntityByClassname(NULL, "info_vip_start"); - - if (!FNullEnt(pSpot)) - goto ReturnSpot; - - goto CTSpawn; - } - else if (g_pGameRules->IsDeathmatch() && ((CBasePlayer *)pPlayer)->m_iTeam == CT) - { -CTSpawn: - pSpot = UTIL_FindEntityByClassname(g_pLastCTSpawn, "info_player_start"); - - // skip over the null point - if (FNullEnt(pSpot)) - { - pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_start"); - } - - CBaseEntity *pFirstSpot = pSpot; - - do - { - if (pSpot) - { - // check if pSpot is valid - if (IsSpawnPointValid(pPlayer, pSpot)) - { - if (pSpot->pev->origin == Vector(0, 0, 0)) - { - pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_start"); - continue; - } - - // if so, go to pSpot - goto ReturnSpot; - } - } - - // increment pSpot - pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_start"); - } - // loop if we're not back to the start - while (pSpot != pFirstSpot); - - // we haven't found a place to spawn yet, so kill any guy at the first spawn point and spawn there - if (!FNullEnt(pSpot)) - { - CBaseEntity *ent = NULL; - while ((ent = UTIL_FindEntityInSphere(ent, pSpot->pev->origin, 64)) != NULL) - { - // if ent is a client, kill em (unless they are ourselves) - if (ent->IsPlayer() && ent->edict() != player) - ent->TakeDamage(VARS(INDEXENT(0)), VARS(INDEXENT(0)), 200, DMG_GENERIC); - } - goto ReturnSpot; - } - } - else if (g_pGameRules->IsDeathmatch() && ((CBasePlayer *)pPlayer)->m_iTeam == TERRORIST) - { - pSpot = UTIL_FindEntityByClassname(g_pLastTerroristSpawn, "info_player_deathmatch"); - - // skip over the null point - if (FNullEnt(pSpot)) - pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_deathmatch"); - - CBaseEntity *pFirstSpot = pSpot; - - do - { - if (pSpot) - { - // check if pSpot is valid - if (IsSpawnPointValid(pPlayer, pSpot)) - { - if (pSpot->pev->origin == Vector(0, 0, 0)) - { - pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_deathmatch"); - continue; - } - - // if so, go to pSpot - goto ReturnSpot; - } - } - - // increment pSpot - pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_deathmatch"); - } - // loop if we're not back to the start - while (pSpot != pFirstSpot); - - // we haven't found a place to spawn yet, so kill any guy at the first spawn point and spawn there - if (!FNullEnt(pSpot)) - { - CBaseEntity *ent = NULL; - while ((ent = UTIL_FindEntityInSphere(ent, pSpot->pev->origin, 64)) != NULL) - { - // if ent is a client, kill em (unless they are ourselves) - if (ent->IsPlayer() && ent->edict() != player) - ent->TakeDamage(VARS(INDEXENT(0)), VARS(INDEXENT(0)), 200, DMG_GENERIC); - } - goto ReturnSpot; - } - } - - // If startspot is set, (re)spawn there. - if (FStringNull(gpGlobals->startspot) || !Q_strlen(STRING(gpGlobals->startspot))) - { - pSpot = UTIL_FindEntityByClassname(NULL, "info_player_deathmatch"); - - if (!FNullEnt(pSpot)) - goto ReturnSpot; - } - else - { - pSpot = UTIL_FindEntityByTargetname(NULL, STRING(gpGlobals->startspot)); - - if (!FNullEnt(pSpot)) - goto ReturnSpot; - } - -ReturnSpot: - if (FNullEnt(pSpot)) - { - ALERT(at_error, "PutClientInServer: no info_player_start on level"); - return INDEXENT(0); - } - - if (((CBasePlayer *)pPlayer)->m_iTeam == TERRORIST) - g_pLastTerroristSpawn = pSpot; - else - g_pLastCTSpawn = pSpot; - - return pSpot->edict(); -} - -/* <15331b> ../cstrike/dlls/player.cpp:6237 */ -void SetScoreAttrib(CBasePlayer *dest, CBasePlayer *src) -{ - int state = 0; - if (src->pev->deadflag != DEAD_NO) - state |= SCORE_STATUS_DEAD; - - if (src->m_bHasC4) - state |= SCORE_STATUS_BOMB; - - if (src->m_bIsVIP) - state |= SCORE_STATUS_VIP; - - if (gmsgScoreAttrib) - { - MESSAGE_BEGIN(MSG_ONE, gmsgScoreAttrib, NULL, dest->pev); - WRITE_BYTE(src->entindex()); - WRITE_BYTE(state); - MESSAGE_END(); - } -} - -/* <15fdba> ../cstrike/dlls/player.cpp:6264 */ -void CBasePlayer::__MAKE_VHOOK(Spawn)(void) -{ - int i; - - m_iGaitsequence = 0; - - m_flGaitframe = 0; - m_flGaityaw = 0; - m_flGaitMovement = 0; - m_prevgaitorigin = Vector(0, 0, 0); - m_progressStart = 0; - m_progressEnd = 0; - - if (pev->classname) - { - RemoveEntityHashValue(pev, STRING(pev->classname), CLASSNAME); - } - - MAKE_STRING_CLASS("player", pev); - AddEntityHashValue(pev, STRING(pev->classname), CLASSNAME); - - pev->health = 100; - - if (!m_bNotKilled) - { - pev->armorvalue = 0; - m_iKevlar = ARMOR_TYPE_EMPTY; - } - - pev->maxspeed = 1000; - pev->takedamage = DAMAGE_AIM; - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_WALK; - pev->max_health = pev->health; - - pev->flags &= FL_PROXY; - pev->flags |= FL_CLIENT; - pev->air_finished = gpGlobals->time + 12; - pev->dmg = 2; - pev->effects = 0; - pev->deadflag = DEAD_NO; - pev->dmg_take = 0; - pev->dmg_save = 0; - - m_bitsHUDDamage = -1; - m_bitsDamageType = 0; - m_afPhysicsFlags = 0; - m_fLongJump = FALSE; - m_iClientFOV = 0; - m_pentCurBombTarget = NULL; - - if (m_bOwnsShield) - pev->gamestate = 0; - else - pev->gamestate = 1; - - ResetStamina(); - pev->friction = 1; - pev->gravity = 1; - - SET_PHYSICS_KEY_VALUE(edict(), "slj", "0"); - SET_PHYSICS_KEY_VALUE(edict(), "hl", "1"); - m_hintMessageQueue.Reset(); - - m_flVelocityModifier = 1; - m_iLastZoom = DEFAULT_FOV; - m_flLastTalk = 0; - m_flIdleCheckTime = 0; - m_flRadioTime = 0; - m_iRadioMessages = 60; - m_bHasC4 = false; - m_bKilledByBomb = false; - m_bKilledByGrenade = false; - m_flDisplayHistory &= ~DHM_ROUND_CLEAR; - m_tmHandleSignals = 0; - m_fCamSwitch = 0; - m_iChaseTarget = 1; - m_bEscaped = false; - m_tmNextRadarUpdate = gpGlobals->time; - m_vLastOrigin = Vector(0, 0, 0); - m_iCurrentKickVote = 0; - m_flNextVoteTime = 0; - m_bJustKilledTeammate = false; - - SET_VIEW(ENT(pev), ENT(pev)); - - m_hObserverTarget = NULL; - pev->iuser1 = 0; - pev->iuser2 = 0; - pev->iuser3 = 0; - - m_flLastFired = -15; - m_bHeadshotKilled = false; - m_bReceivesNoMoneyNextRound = false; - m_bShieldDrawn = false; - - m_blindUntilTime = 0; - m_blindStartTime = 0; - m_blindHoldTime = 0; - m_blindFadeTime = 0; - m_blindAlpha = 0; - - m_canSwitchObserverModes = true; - m_lastLocation[0] = '\0'; - - m_bitsDamageType &= ~(DMG_DROWN | DMG_DROWNRECOVER); - m_rgbTimeBasedDamage[ itbd_DrownRecover ] = 0; - m_idrowndmg = 0; - m_idrownrestored = 0; - - if (m_iObserverC4State) - { - m_iObserverC4State = 0; - - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("c4"); - MESSAGE_END(); - } - - if (m_bObserverHasDefuser) - { - m_bObserverHasDefuser = false; - - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("defuser"); - MESSAGE_END(); - } - - MESSAGE_BEGIN(MSG_ONE, SVC_ROOMTYPE, NULL, pev); - WRITE_SHORT((int)CVAR_GET_FLOAT("room_type")); - MESSAGE_END(); - - if (g_pGameRules->IsFreezePeriod()) - m_bCanShoot = false; - else - m_bCanShoot = true; - - m_iNumSpawns++; - InitStatusBar(); - - for (i = 0; i < MAX_RECENT_PATH; i++) - m_vRecentPath[ i ] = Vector(0, 0, 0); - - if (m_pActiveItem != NULL && !pev->viewmodel) - { - switch (m_pActiveItem->m_iId) - { - case WEAPON_AWP: - pev->viewmodel = MAKE_STRING("models/v_awp.mdl"); - break; - case WEAPON_G3SG1: - pev->viewmodel = MAKE_STRING("models/v_g3sg1.mdl"); - break; - case WEAPON_SCOUT: - pev->viewmodel = MAKE_STRING("models/v_scout.mdl"); - break; - case WEAPON_SG550: - pev->viewmodel = MAKE_STRING("models/v_sg550.mdl"); - break; - } - } - - m_iFOV = DEFAULT_FOV; - m_flNextDecalTime = 0; - m_flTimeStepSound = 0; - m_iStepLeft = 0; - m_flFieldOfView = 0.5; - m_bloodColor = BLOOD_COLOR_RED; - m_flNextAttack = 0; - m_flgeigerDelay = gpGlobals->time + 2; - - StartSneaking(); - - m_iFlashBattery = 99; - m_flFlashLightTime = 1; - - if (m_bHasDefuser) - pev->body = 1; - else - pev->body = 0; - - if (m_bMissionBriefing) - { - RemoveLevelText(); - m_bMissionBriefing = false; - } - - m_flFallVelocity = 0; - - if (!g_skipCareerInitialSpawn) - { - g_pGameRules->GetPlayerSpawnSpot(this); - } - - if (!pev->modelindex) - { - SET_MODEL(ENT(pev), "models/player.mdl"); - m_modelIndexPlayer = pev->modelindex; - } - - pev->sequence = LookupActivity(ACT_IDLE); - - if (pev->flags & FL_DUCKING) - UTIL_SetSize(pev, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX); - else - UTIL_SetSize(pev, VEC_HULL_MIN, VEC_HULL_MAX); - - pev->view_ofs = VEC_VIEW; - Precache(); - - m_HackedGunPos = Vector(0, 32, 0); - - if (m_iPlayerSound == SOUNDLIST_EMPTY) - { - ALERT(at_console, "Couldn't alloc player sound slot!\n"); - } - - m_iHideHUD &= ~(HIDEHUD_WEAPONS | HIDEHUD_HEALTH | HIDEHUD_TIMER | HIDEHUD_MONEY); - m_fNoPlayerSound = FALSE; - m_pLastItem = NULL; - m_fWeapon = FALSE; - m_pClientActiveItem = NULL; - m_iClientBattery = -1; - m_fInitHUD = TRUE; - - if (!m_bNotKilled) - { - m_iClientHideHUD = -1; - - for (i = 0; i < MAX_AMMO_SLOTS; i++) - m_rgAmmo[i] = 0; - - m_bHasPrimary = false; - m_bHasNightVision = false; - - SendItemStatus(this); - } - else - { - for (i = 0; i < MAX_AMMO_SLOTS; i++) - m_rgAmmoLast[i] = -1; - } - - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pev); - WRITE_BYTE(0); - MESSAGE_END(); - - m_bNightVisionOn = false; - - for (i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *pObserver = (CBasePlayer *)UTIL_PlayerByIndex(i); - - if (pObserver && pObserver->IsObservingPlayer(this)) - { - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); - WRITE_BYTE(0); - MESSAGE_END(); - - pObserver->m_bNightVisionOn = false; - } - } - - m_lastx = 0; - m_lasty = 0; - - g_pGameRules->PlayerSpawn(this); - - m_bNotKilled = true; - m_bIsDefusing = false; - - SetProgressBarTime(0); - ResetMaxSpeed(); - - UTIL_SetOrigin(pev, pev->origin); - - if (m_bIsVIP) - { - m_iKevlar = ARMOR_TYPE_HELMET; - pev->armorvalue = 200; - HintMessage("#Hint_you_are_the_vip", TRUE, TRUE); - } - - SetScoreboardAttributes(); - - MESSAGE_BEGIN(MSG_ALL, gmsgTeamInfo); - WRITE_BYTE(entindex()); - switch (m_iTeam) - { - case CT: - WRITE_STRING("CT"); - break; - case TERRORIST: - WRITE_STRING("TERRORIST"); - break; - case SPECTATOR: - WRITE_STRING("SPECTATOR"); - break; - default: - WRITE_STRING("UNASSIGNED"); - break; - } - MESSAGE_END(); - - UpdateLocation(true); - - MESSAGE_BEGIN(MSG_ALL, gmsgScoreInfo); - WRITE_BYTE(ENTINDEX(edict())); - WRITE_SHORT((int)pev->frags); - WRITE_SHORT(m_iDeaths); - WRITE_SHORT(0); - WRITE_SHORT(m_iTeam); - MESSAGE_END(); - - if (m_bHasChangedName) - { - char *infobuffer = GET_INFO_BUFFER(edict()); - - if (!FStrEq(m_szNewName, GET_KEY_VALUE(infobuffer, "name"))) - { - SET_CLIENT_KEY_VALUE(entindex(), infobuffer, "name", m_szNewName); - } - - m_bHasChangedName = false; - m_szNewName[0] = '\0'; - } - - UTIL_ScreenFade(this, Vector(0, 0, 0), 0.001); - SyncRoundTimer(); - - if (TheBots) - { - TheBots->OnEvent(EVENT_PLAYER_SPAWNED, this); - } - - m_allowAutoFollowTime = false; - - sv_aim = CVAR_GET_POINTER("sv_aim"); - - for (i = 0; i < ARRAYSIZE(m_flLastCommandTime); i++) - m_flLastCommandTime[i] = -1; -} - -/* <153555> ../cstrike/dlls/player.cpp:6620 */ -void CBasePlayer::__MAKE_VHOOK(Precache)(void) -{ - // in the event that the player JUST spawned, and the level node graph - // was loaded, fix all of the node graph pointers before the game starts. - - // !!!BUGBUG - now that we have multiplayer, this needs to be moved! - if (WorldGraph.m_fGraphPresent && !WorldGraph.m_fGraphPointersSet) - { - if (!WorldGraph.FSetGraphPointers()) - { - ALERT(at_console, "**Graph pointers were not set!\n"); - } - else - { - ALERT(at_console, "**Graph Pointers Set!\n"); - } - } - - // SOUNDS / MODELS ARE PRECACHED in ClientPrecache() (game specific) - // because they need to precache before any clients have connected - - // init geiger counter vars during spawn and each time - // we cross a level transition - - m_flgeigerRange = 1000; - m_igeigerRangePrev = 1000; - m_bitsDamageType = 0; - m_bitsHUDDamage = -1; - m_iClientBattery = -1; - m_iTrain = TRAIN_NEW; - - // Make sure any necessary user messages have been registered - LinkUserMessages(); - - // won't update for 1/2 a second - m_iUpdateTime = 5; - - if (gInitHUD) - m_fInitHUD = TRUE; -} - -/* <151a77> ../cstrike/dlls/player.cpp:6671 */ -int CBasePlayer::__MAKE_VHOOK(Save)(CSave &save) -{ - if (!CBaseMonster::Save(save)) - return 0; - - return save.WriteFields("PLAYER", this, IMPLEMENT_ARRAY_CLASS(CBasePlayer, m_playerSaveData), ARRAYSIZE(IMPLEMENT_ARRAY_CLASS(CBasePlayer, m_playerSaveData))); -} - -/* <153355> ../cstrike/dlls/player.cpp:6685 */ -void CBasePlayer::SetScoreboardAttributes(CBasePlayer *destination) -{ - if (destination != NULL) - { - SetScoreAttrib(destination, this); - return; - } - - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *player = (CBasePlayer *)UTIL_PlayerByIndex(i); - - if (player && !FNullEnt(player->edict())) - SetScoreboardAttributes(player); - } -} - -/* <156e88> ../cstrike/dlls/player.cpp:6712 */ -NOXREF void CBasePlayer::RenewItems(void) -{ - ; -} - -/* <156b9b> ../cstrike/dlls/player.cpp:6718 */ -int CBasePlayer::__MAKE_VHOOK(Restore)(CRestore &restore) -{ - if (!CBaseMonster::Restore(restore)) - return 0; - - int status = restore.ReadFields("PLAYER", this, IMPLEMENT_ARRAY_CLASS(CBasePlayer, m_playerSaveData), ARRAYSIZE(IMPLEMENT_ARRAY_CLASS(CBasePlayer, m_playerSaveData))); - SAVERESTOREDATA *pSaveData = (SAVERESTOREDATA *)gpGlobals->pSaveData; - - if (!pSaveData->fUseLandmark) - { - ALERT(at_console, "No Landmark:%s\n", pSaveData->szLandmarkName); - - edict_t *pentSpawnSpot = EntSelectSpawnPoint(this); - - pev->origin = VARS(pentSpawnSpot)->origin + Vector(0, 0, 1); - pev->angles = VARS(pentSpawnSpot)->angles; - } - - pev->v_angle.z = 0; - pev->angles = pev->v_angle; - pev->fixangle = 1; - - m_bloodColor = BLOOD_COLOR_RED; - m_modelIndexPlayer = pev->modelindex; - - if (pev->flags & FL_DUCKING) - UTIL_SetSize(pev, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX); - else - UTIL_SetSize(pev, VEC_HULL_MIN, VEC_HULL_MAX); - - m_flDisplayHistory &= ~DHM_CONNECT_CLEAR; - SetScoreboardAttributes(); - - return status; -} - -/* <156eab> ../cstrike/dlls/player.cpp:6771 */ -void CBasePlayer::Reset(void) -{ - pev->frags = 0; - m_iDeaths = 0; - m_iAccount = 0; - - MESSAGE_BEGIN(MSG_ONE, gmsgMoney, NULL, pev); - WRITE_LONG(m_iAccount); - WRITE_BYTE(0); - MESSAGE_END(); - - m_bNotKilled = false; - - RemoveShield(); - CheckStartMoney(); - AddAccount(startmoney.value); - - MESSAGE_BEGIN(MSG_ALL, gmsgScoreInfo); - WRITE_BYTE(ENTINDEX(edict())); - WRITE_SHORT(0); - WRITE_SHORT(0); - WRITE_SHORT(0); - WRITE_SHORT(m_iTeam); - MESSAGE_END(); -} - -/* <157066> ../cstrike/dlls/player.cpp:6794 */ -NOXREF void CBasePlayer::SelectNextItem(int iItem) -{ - CBasePlayerItem *pItem = m_rgpPlayerItems[ iItem ]; - - if (!pItem) - { - return; - } - - if (pItem == m_pActiveItem) - { - pItem = m_pActiveItem->m_pNext; - - if (!pItem) - { - return; - } - - CBasePlayerItem *pLast = pItem; - - while (pLast->m_pNext != NULL) - pLast = pLast->m_pNext; - - pLast->m_pNext = m_pActiveItem; - m_pActiveItem->m_pNext = NULL; - m_rgpPlayerItems[ iItem ] = pItem; - } - - ResetAutoaim(); - - if (m_pActiveItem) - { - m_pActiveItem->Holster(); - } - - if (HasShield()) - { - CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; - pWeapon->m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; - m_bShieldDrawn = false; - } - - m_pLastItem = m_pActiveItem; - m_pActiveItem = pItem; - - if (m_pActiveItem) - { - UpdateShieldCrosshair(true); - - m_pActiveItem->Deploy(); - m_pActiveItem->UpdateItemInfo(); - - ResetMaxSpeed(); - } -} - -/* <15714a> ../cstrike/dlls/player.cpp:6851 */ -void CBasePlayer::SelectItem(const char *pstr) -{ - if (!pstr) - { - return; - } - - CBasePlayerItem *pItem = NULL; - - for (int i = 0; i < MAX_ITEM_TYPES; i++) - { - pItem = m_rgpPlayerItems[ i ]; - - if (pItem != NULL) - { - while (pItem != NULL) - { - if (FClassnameIs(pItem->pev, pstr)) - break; - - pItem = pItem->m_pNext; - } - - if (pItem) - { - break; - } - } - } - - if (!pItem || pItem == m_pActiveItem) - { - return; - } - - ResetAutoaim(); - - // FIX, this needs to queue them up and delay - if (m_pActiveItem) - { - m_pActiveItem->Holster(); - } - - m_pLastItem = m_pActiveItem; - m_pActiveItem = pItem; - - if (m_pActiveItem) - { - CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; - pWeapon->m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; - - m_bShieldDrawn = false; - UpdateShieldCrosshair(true); - - m_pActiveItem->Deploy(); - m_pActiveItem->UpdateItemInfo(); - - ResetMaxSpeed(); - } -} - -/* <157268> ../cstrike/dlls/player.cpp:6909 */ -void CBasePlayer::SelectLastItem(void) -{ - if (m_pActiveItem && !m_pActiveItem->CanHolster()) - return; - - if (!m_pLastItem || m_pLastItem == m_pActiveItem) - { - for (int i = 1; i < MAX_ITEMS; i++) - { - CBasePlayerItem *pItem = m_rgpPlayerItems[i]; - if (pItem && pItem != m_pActiveItem) - { - m_pLastItem = pItem; - break; - } - } - } - - if (!m_pLastItem || m_pLastItem == m_pActiveItem) - return; - - ResetAutoaim(); - - if (m_pActiveItem) - m_pActiveItem->Holster(); - - if (HasShield()) - { - CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; - - if (m_pActiveItem) - pWeapon->m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; - - m_bShieldDrawn = false; - } - - CBasePlayerItem *pTemp = m_pActiveItem; - - m_pActiveItem = m_pLastItem; - m_pLastItem = pTemp; - - m_pActiveItem->Deploy(); - m_pActiveItem->UpdateItemInfo(); - - UpdateShieldCrosshair(true); - - ResetMaxSpeed(); -} - -// HasWeapons - do I have any weapons at all? - -/* <15733a> ../cstrike/dlls/player.cpp:6967 */ -BOOL CBasePlayer::HasWeapons(void) -{ - for (int i = 0; i < MAX_ITEM_TYPES; i++) - { - if (m_rgpPlayerItems[i]) - return TRUE; - } - return FALSE; -} - -/* <157372> ../cstrike/dlls/player.cpp:6982 */ -NOXREF void CBasePlayer::SelectPrevItem(int iItem) -{ - ; -} - -/* <15106c> ../cstrike/dlls/player.cpp:6987 */ -const char *CBasePlayer::__MAKE_VHOOK(TeamID)(void) -{ - // Not fully connected yet - if (pev == NULL) - return ""; - - // return their team name - return m_szTeamName; -} - -/* <1573aa> ../cstrike/dlls/player.cpp:7010 */ -void CSprayCan::Spawn(entvars_t *pevOwner) -{ - pev->origin = pevOwner->origin + Vector(0, 0, 32); - pev->angles = pevOwner->v_angle; - pev->owner = ENT(pevOwner); - pev->frame = 0; - - pev->nextthink = gpGlobals->time + 0.1; - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/sprayer.wav", VOL_NORM, ATTN_NORM); -} - -/* <151815> ../cstrike/dlls/player.cpp:7021 */ -void CSprayCan::__MAKE_VHOOK(Think)(void) -{ - TraceResult tr; - int playernum; - int nFrames; - CBasePlayer *pPlayer; - - pPlayer = (CBasePlayer *)GET_PRIVATE(pev->owner); - - if (pPlayer) - nFrames = pPlayer->GetCustomDecalFrames(); - else - nFrames = -1; - - playernum = ENTINDEX(pev->owner); - - UTIL_MakeVectors(pev->angles); - UTIL_TraceLine(pev->origin, pev->origin + gpGlobals->v_forward * 128, ignore_monsters, pev->owner, &tr); - - // No customization present. - if (nFrames == -1) - { - UTIL_DecalTrace(&tr, DECAL_LAMBDA6); - UTIL_Remove(this); - } - else - { - UTIL_PlayerDecalTrace(&tr, playernum, pev->frame, TRUE); - - // Just painted last custom frame. - if (pev->frame++ >= (nFrames - 1)) - UTIL_Remove(this); - } - - pev->nextthink = gpGlobals->time + 0.1; -} - -/* <157481> ../cstrike/dlls/player.cpp:7064 */ -void CBloodSplat::Spawn(entvars_t *pevOwner) -{ - pev->origin = pevOwner->origin + Vector(0, 0, 32); - pev->angles = pevOwner->v_angle; - pev->owner = ENT(pevOwner); - - SetThink(&CBloodSplat::Spray); - pev->nextthink = gpGlobals->time + 0.1; -} - -/* <151758> ../cstrike/dlls/player.cpp:7074 */ -void CBloodSplat::Spray(void) -{ - TraceResult tr; - if (g_Language != LANGUAGE_GERMAN) - { - UTIL_MakeVectors(pev->angles); - UTIL_TraceLine(pev->origin, pev->origin + gpGlobals->v_forward * 128, ignore_monsters, pev->owner, &tr); - UTIL_BloodDecalTrace(&tr, BLOOD_COLOR_RED); - } - - SetThink(&CBloodSplat::SUB_Remove); - pev->nextthink = gpGlobals->time + 0.1; -} - -/* <1574d3> ../cstrike/dlls/player.cpp:7093 */ -void CBasePlayer::GiveNamedItem(const char *pszName) -{ - string_t istr = MAKE_STRING(pszName); - edict_t *pent = CREATE_NAMED_ENTITY(istr); - - if (FNullEnt(pent)) - { - ALERT(at_console, "NULL Ent in GiveNamedItem!\n"); - return; - } - - VARS(pent)->origin = pev->origin; - pent->v.spawnflags |= SF_NORESPAWN; - - DispatchSpawn(pent); - DispatchTouch(pent, ENT(pev)); -} - -/* <157568> ../cstrike/dlls/player.cpp:7114 */ -CBaseEntity *FindEntityForward(CBaseEntity *pMe) -{ - TraceResult tr; - - UTIL_MakeVectors(pMe->pev->v_angle); - UTIL_TraceLine(pMe->pev->origin + pMe->pev->view_ofs, pMe->pev->origin + pMe->pev->view_ofs + gpGlobals->v_forward * 8192, dont_ignore_monsters, pMe->edict(), &tr); - - if (tr.flFraction != 1.0 && !FNullEnt(tr.pHit)) - { - CBaseEntity *pHit = CBaseEntity::Instance(tr.pHit); - return pHit; - } - return NULL; -} - -/* <15777b> ../cstrike/dlls/player.cpp:7129 */ -BOOL CBasePlayer::FlashlightIsOn(void) -{ - return pev->effects & EF_DIMLIGHT; -} - -/* <15779e> ../cstrike/dlls/player.cpp:7135 */ -void CBasePlayer::FlashlightTurnOn(void) -{ - if (!g_pGameRules->FAllowFlashlight()) - return; - - if (pev->weapons & (1 << WEAPON_SUIT)) - { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/flashlight1.wav", VOL_NORM, ATTN_NORM); - - pev->effects |= EF_DIMLIGHT; - - MESSAGE_BEGIN(MSG_ONE, gmsgFlashlight, NULL, pev); - WRITE_BYTE(1); - WRITE_BYTE(m_iFlashBattery); - MESSAGE_END(); - - m_flFlashLightTime = gpGlobals->time + FLASH_DRAIN_TIME; - } -} - -/* <157816> ../cstrike/dlls/player.cpp:7157 */ -void CBasePlayer::FlashlightTurnOff(void) -{ - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/flashlight1.wav", VOL_NORM, ATTN_NORM); - - pev->effects &= ~EF_DIMLIGHT; - MESSAGE_BEGIN(MSG_ONE, gmsgFlashlight, NULL, pev); - WRITE_BYTE(0); - WRITE_BYTE(m_iFlashBattery); - MESSAGE_END(); - - m_flFlashLightTime = gpGlobals->time + FLASH_CHARGE_TIME; -} - -/* <158ae7> ../cstrike/dlls/player.cpp:7179 */ -void CBasePlayer::ForceClientDllUpdate(void) -{ - m_iClientHealth = -1; - m_iClientBattery = -1; - m_fWeapon = FALSE; - m_fInitHUD = TRUE; - m_iTrain |= TRAIN_NEW; - - UpdateClientData(); - HandleSignals(); -} - -/* <157f8d> ../cstrike/dlls/player.cpp:7202 */ -void CBasePlayer::__MAKE_VHOOK(ImpulseCommands)(void) -{ - TraceResult tr; - - // Handle use events - PlayerUse(); - - int iImpulse = pev->impulse; - - switch (iImpulse) - { - case 99: - { - int iOn; - - if (!gmsgLogo) - { - iOn = 1; - gmsgLogo = REG_USER_MSG("Logo", 1); - } - else - iOn = 0; - - assert(gmsgLogo > 0); - - MESSAGE_BEGIN(MSG_ONE, gmsgLogo, NULL, pev); - WRITE_BYTE(iOn); - MESSAGE_END(); - - if (!iOn) - gmsgLogo = 0; - - break; - } - case 100: - { - // temporary flashlight for level designers - if (FlashlightIsOn()) - FlashlightTurnOff(); - else - FlashlightTurnOn(); - - break; - } - case 201: - { - // paint decal - if (gpGlobals->time < m_flNextDecalTime) - { - // too early! - break; - } - - UTIL_MakeVectors(pev->v_angle); - UTIL_TraceLine(pev->origin + pev->view_ofs, pev->origin + pev->view_ofs + gpGlobals->v_forward * 128, ignore_monsters, edict(), &tr); - - if (tr.flFraction != 1.0f) - { - // line hit something, so paint a decal - m_flNextDecalTime = gpGlobals->time + CVAR_GET_FLOAT("decalfrequency"); - CSprayCan *pCan = GetClassPtr((CSprayCan *)NULL); - pCan->Spawn(pev); - } - break; - } - default: - // check all of the cheat impulse commands now - CheatImpulseCommands(iImpulse); - } - - pev->impulse = 0; -} - -/* <15786e> ../cstrike/dlls/player.cpp:7280 */ -void CBasePlayer::CheatImpulseCommands(int iImpulse) -{ - if (!g_flWeaponCheat) - return; - - CBaseEntity *pEntity; - TraceResult tr; - - switch (iImpulse) - { - case 76: - if (!giPrecacheGrunt) - { - giPrecacheGrunt = 1; - ALERT(at_console, "You must now restart to use Grunt-o-matic.\n"); - } - else - { - UTIL_MakeVectors(Vector(0, pev->v_angle.y, 0)); - Create("monster_human_grunt", pev->origin + gpGlobals->v_forward * 128, pev->angles); - } - break; - case 101: - gEvilImpulse101 = TRUE; - AddAccount(16000); - ALERT(at_console, "Crediting %s with $16000\n", STRING(pev->netname)); - break; - case 102: - CGib::SpawnRandomGibs(pev, 1, 1); - break; - case 103: - { - // What the hell are you doing? - pEntity = FindEntityForward(this); - - if (pEntity) - { - CBaseMonster *pMonster = pEntity->MyMonsterPointer(); - - if (pMonster) - pMonster->ReportAIState(); - } - break; - } - case 104: - // Dump all of the global state varaibles (and global entity names) - gGlobalState.DumpGlobals(); - break; - case 105: - { - // player makes no sound for monsters to hear. - if (m_fNoPlayerSound) - { - ALERT(at_console, "Player is audible\n"); - m_fNoPlayerSound = FALSE; - } - else - { - ALERT(at_console, "Player is silent\n"); - m_fNoPlayerSound = TRUE; - } - break; - } - case 106: - { - // Give me the classname and targetname of this entity. - pEntity = FindEntityForward(this); - - if (pEntity) - { - ALERT(at_console, "Classname: %s", STRING(pEntity->pev->classname)); - - if (!FStringNull(pEntity->pev->targetname)) - ALERT(at_console, " - Targetname: %s\n", STRING(pEntity->pev->targetname)); - else - ALERT(at_console, " - TargetName: No Targetname\n"); - - ALERT(at_console, "Model: %s\n", STRING(pEntity->pev->model)); - - if (pEntity->pev->globalname) - ALERT(at_console, "Globalname: %s\n", STRING(pEntity->pev->globalname)); - } - break; - } - case 107: - { - TraceResult tr; - edict_t *pWorld = INDEXENT(0); - - Vector start = pev->origin + pev->view_ofs; - Vector end = start + gpGlobals->v_forward * 1024; - UTIL_TraceLine(start, end, ignore_monsters, edict(), &tr); - - if (tr.pHit) - pWorld = tr.pHit; - - const char *pszTextureName = TRACE_TEXTURE(pWorld, start, end); - - if (pszTextureName) - ALERT(at_console, "Texture: %s\n", pszTextureName); - - break; - } - case 195: - // show shortest paths for entire level to nearest node - Create("node_viewer_fly", pev->origin, pev->angles); - break; - case 196: - // show shortest paths for entire level to nearest node - Create("node_viewer_large", pev->origin, pev->angles); - break; - case 197: - // show shortest paths for entire level to nearest node - Create("node_viewer_human", pev->origin, pev->angles); - break; - case 199: - // show nearest node and all connections - ALERT(at_console, "%d\n", WorldGraph.FindNearestNode(pev->origin, bits_NODE_LAND)); - WorldGraph.ShowNodeConnections(WorldGraph.FindNearestNode(pev->origin, bits_NODE_LAND)); - break; - case 202: - { - // Random blood splatter - UTIL_MakeVectors(pev->v_angle); - UTIL_TraceLine(pev->origin + pev->view_ofs, pev->origin + pev->view_ofs + gpGlobals->v_forward * 128, ignore_monsters, edict(), &tr); - - if (tr.flFraction != 1.0f) - { - // line hit something, so paint a decal - CBloodSplat *pBlood = GetClassPtr((CBloodSplat *)NULL); - pBlood->Spawn(pev); - } - break; - } - case 203: - { - // remove creature. - pEntity = FindEntityForward(this); - - if (pEntity && pEntity->pev->takedamage != DAMAGE_NO) - { - pEntity->SetThink(&CBaseEntity::SUB_Remove); - } - break; - } - case 204: - { - TraceResult tr; - Vector dir = Vector(0, 0, 1); - - UTIL_BloodDrips(pev->origin, dir, BLOOD_COLOR_RED, 2000); - - for (int r = 1; r < 4; r++) - { - float bloodRange = r * 50.0f; - - for (int i = 0; i < 50; i++) - { - dir.x = RANDOM_FLOAT(-1, 1); - dir.y = RANDOM_FLOAT(-1, 1); - dir.z = RANDOM_FLOAT(-1, 1); - - if (dir.x || dir.y || dir.z) - dir.NormalizeInPlace(); - else - dir.z = -1.0f; - - UTIL_TraceLine(EyePosition(), EyePosition() + dir * bloodRange, ignore_monsters, pev->pContainingEntity, &tr); - - if (tr.flFraction < 1.0f) - UTIL_BloodDecalTrace(&tr, BLOOD_COLOR_RED); - } - } - break; - } - } -} - -/* <158256> ../cstrike/dlls/player.cpp:7474 */ -void OLD_CheckBuyZone(CBasePlayer *player) -{ - const char *pszSpawnClass = NULL; - - if (player->m_iTeam == TERRORIST) - pszSpawnClass = "info_player_deathmatch"; - - else if (player->m_iTeam == CT) - pszSpawnClass = "info_player_start"; - - if (pszSpawnClass != NULL) - { - CBaseEntity *pSpot = NULL; - while ((pSpot = UTIL_FindEntityByClassname(pSpot, pszSpawnClass)) != NULL) - { - if ((pSpot->pev->origin - player->pev->origin).Length() < 200.0f) - player->m_signals.Signal(SIGNAL_BUY); - } - } -} - -/* <14e5a9> ../cstrike/dlls/player.cpp:7514 */ -void OLD_CheckBombTarget(CBasePlayer *player) -{ - CBaseEntity *pSpot = NULL; - while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_bomb_target")) != NULL) - { - if ((pSpot->pev->origin - player->pev->origin).Length() <= 256.0f) - player->m_signals.Signal(SIGNAL_BOMB); - } -} - -/* <14e5d5> ../cstrike/dlls/player.cpp:7532 */ -void OLD_CheckRescueZone(CBasePlayer *player) -{ - CBaseEntity *pSpot = NULL; - while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_hostage_rescue")) != NULL) - { - if ((pSpot->pev->origin - player->pev->origin).Length() <= 256.0f) - player->m_signals.Signal(SIGNAL_RESCUE); - } -} - -/* <1582e9> ../cstrike/dlls/player.cpp:7553 */ -void CBasePlayer::HandleSignals(void) -{ - CHalfLifeMultiplay *mp = g_pGameRules; - - if (mp->IsMultiplayer()) - { - if (!mp->m_bMapHasBuyZone) - OLD_CheckBuyZone(this); - - if (!mp->m_bMapHasBombZone) - OLD_CheckBombTarget(this); - - if (!mp->m_bMapHasRescueZone) - OLD_CheckRescueZone(this); - } - - int state = m_signals.GetSignal(); - int changed = m_signals.GetState() ^ state; - - m_signals.Update(); - - if (changed & SIGNAL_BUY) - { - if (state & SIGNAL_BUY) - BuyZoneIcon_Set(this); - else - BuyZoneIcon_Clear(this); - } - if (changed & SIGNAL_BOMB) - { - if (state & SIGNAL_BOMB) - BombTargetFlash_Set(this); - else - BombTargetFlash_Clear(this); - } - if (changed & SIGNAL_RESCUE) - { - if (state & SIGNAL_RESCUE) - RescueZoneIcon_Set(this); - else - RescueZoneIcon_Clear(this); - } - if (changed & SIGNAL_ESCAPE) - { - if (state & SIGNAL_ESCAPE) - EscapeZoneIcon_Set(this); - else - EscapeZoneIcon_Clear(this); - } - if (changed & SIGNAL_VIPSAFETY) - { - if (state & SIGNAL_VIPSAFETY) - VIP_SafetyZoneIcon_Set(this); - else - VIP_SafetyZoneIcon_Clear(this); - } -} - -// Add a weapon to the player (Item == Weapon == Selectable Object) - -/* <15325f> ../cstrike/dlls/player.cpp:7625 */ -BOOL CBasePlayer::__MAKE_VHOOK(AddPlayerItem)(CBasePlayerItem *pItem) -{ - CBasePlayerItem *pInsert = m_rgpPlayerItems[ pItem->iItemSlot() ]; - while (pInsert != NULL) - { - if (FClassnameIs(pInsert->pev, STRING(pItem->pev->classname))) - { - if (pItem->AddDuplicate(pInsert)) - { - g_pGameRules->PlayerGotWeapon(this, pItem); - pItem->CheckRespawn(); - - // ugly hack to update clip w/o an update clip message - pItem->UpdateItemInfo(); - - if (m_pActiveItem) - m_pActiveItem->UpdateItemInfo(); - - pItem->Kill(); - } - else if (gEvilImpulse101) - pItem->Kill(); - - return FALSE; - } - - pInsert = pInsert->m_pNext; - } - if (pItem->AddToPlayer(this)) - { - g_pGameRules->PlayerGotWeapon(this, pItem); - - if (pItem->iItemSlot() == PRIMARY_WEAPON_SLOT) - m_bHasPrimary = true; - - pItem->CheckRespawn(); - pItem->m_pNext = m_rgpPlayerItems[ pItem->iItemSlot() ]; - m_rgpPlayerItems[ pItem->iItemSlot() ] = pItem; - - if (HasShield()) - pev->gamestate = 0; - - // should we switch to this item? - if (g_pGameRules->FShouldSwitchWeapon(this, pItem)) - { - if (!m_bShieldDrawn) - { - SwitchWeapon(pItem); - } - } - - return TRUE; - } - else if (gEvilImpulse101) - { - pItem->Kill(); - } - - return FALSE; -} - -/* <1534bd> ../cstrike/dlls/player.cpp:7692 */ -BOOL CBasePlayer::__MAKE_VHOOK(RemovePlayerItem)(CBasePlayerItem *pItem) -{ - if (m_pActiveItem == pItem) - { - ResetAutoaim(); - pItem->pev->nextthink = 0; - - pItem->SetThink(NULL); - m_pActiveItem = NULL; - - pev->viewmodel = 0; - pev->weaponmodel = 0; - } - else if (m_pLastItem == pItem) - m_pLastItem = NULL; - - CBasePlayerItem *pPrev = m_rgpPlayerItems[pItem->iItemSlot()]; - if (pPrev == pItem) - { - m_rgpPlayerItems[pItem->iItemSlot()] = pItem->m_pNext; - return TRUE; - } - - while (pPrev && pPrev->m_pNext != pItem) - pPrev = pPrev->m_pNext; - - if (pPrev) - { - pPrev->m_pNext = pItem->m_pNext; - return TRUE; - } - return FALSE; -} - -// Returns the unique ID for the ammo, or -1 if error - -/* <15997b> ../cstrike/dlls/player.cpp:7731 */ -int CBasePlayer::__MAKE_VHOOK(GiveAmmo)(int iCount, char *szName, int iMax) -{ - if (pev->flags & FL_SPECTATOR) - return -1; - - if (!szName) - { - // no ammo. - return -1; - } - - if (!g_pGameRules->CanHaveAmmo(this, szName, iMax)) - { - // game rules say I can't have any more of this ammo type. - return -1; - } - - int i = GetAmmoIndex(szName); - - if (i < 0 || i >= MAX_AMMO_SLOTS) - return -1; - - int iAdd = Q_min(iCount, iMax - m_rgAmmo[i]); - if (iAdd < 1) - return i; - - m_rgAmmo[i] += iAdd; - - // make sure the ammo messages have been linked first - if (gmsgAmmoPickup) - { - // Send the message that ammo has been picked up - MESSAGE_BEGIN(MSG_ONE, gmsgAmmoPickup, NULL, pev); - WRITE_BYTE(GetAmmoIndex(szName)); // ammo ID - WRITE_BYTE(iAdd); // amount - MESSAGE_END(); - } - TabulateAmmo(); - - return i; -} - -// Called every frame by the player PreThink - -/* <158b10> ../cstrike/dlls/player.cpp:7784 */ -void CBasePlayer::ItemPreFrame(void) -{ -#ifdef CLIENT_WEAPONS - if (m_flNextAttack > 0) - return; -#else - if (gpGlobals->time < m_flNextAttack) - return; -#endif // CLIENT_WEAPONS - - if (!m_pActiveItem) - return; - - m_pActiveItem->ItemPreFrame(); -} - -// Called every frame by the player PostThink - -/* <158b33> ../cstrike/dlls/player.cpp:7805 */ -void CBasePlayer::ItemPostFrame(void) -{ - static int fInSelect = FALSE; - - // check if the player is using a tank - if (m_pTank != NULL) - return; - - if (m_pActiveItem != NULL) - { - if (HasShield() && IsReloading()) - { - if (pev->button & IN_ATTACK2) - m_flNextAttack = 0; - } - } - -#ifdef CLIENT_WEAPONS - if (m_flNextAttack > 0) -#else - if (gpGlobals->time < m_flNextAttack) -#endif // CLIENT_WEAPONS - return; - - ImpulseCommands(); - - if (m_pActiveItem != NULL) - m_pActiveItem->ItemPostFrame(); -} - -/* <158b71> ../cstrike/dlls/player.cpp:7834 */ -int CBasePlayer::AmmoInventory(int iAmmoIndex) -{ - if (iAmmoIndex == -1) - return -1; - - return m_rgAmmo[iAmmoIndex]; -} - -/* <158b9d> ../cstrike/dlls/player.cpp:7844 */ -int CBasePlayer::GetAmmoIndex(const char *psz) -{ - if (!psz) - return -1; - - for (int i = 1; i < MAX_AMMO_SLOTS; i++) - { - if (!IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, AmmoInfoArray)[ i ].pszName) - continue; - - if (!Q_stricmp(psz, IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, AmmoInfoArray)[ i ].pszName)) - return i; - } - return -1; -} - -/* <158bf7> ../cstrike/dlls/player.cpp:7865 */ -void CBasePlayer::SendAmmoUpdate(void) -{ - for (int i = 0; i < MAX_AMMO_SLOTS; i++) - { - if (m_rgAmmo[i] != m_rgAmmoLast[i]) - { - m_rgAmmoLast[i] = m_rgAmmo[i]; - - // send "Ammo" update message - MESSAGE_BEGIN(MSG_ONE, gmsgAmmoX, NULL, pev); - WRITE_BYTE(i); - WRITE_BYTE(Q_max(Q_min(m_rgAmmo[i], 254), 0)); // clamp the value to one byte - MESSAGE_END(); - } - } -} - -/* <158d4b> ../cstrike/dlls/player.cpp:7885 */ -void CBasePlayer::SendHostagePos(void) -{ - CBaseEntity *pHostage = NULL; - - while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")) != NULL) - { - MESSAGE_BEGIN(MSG_ONE, gmsgHostagePos, NULL, pev); - WRITE_BYTE(1); - WRITE_BYTE(((CHostage *)pHostage)->m_iHostageIndex); - WRITE_COORD(pHostage->pev->origin.x); - WRITE_COORD(pHostage->pev->origin.y); - WRITE_COORD(pHostage->pev->origin.z); - MESSAGE_END(); - } - - SendHostageIcons(); -} - -/* <158c66> ../cstrike/dlls/player.cpp:7908 */ -void CBasePlayer::SendHostageIcons(void) -{ - CBaseEntity *pHostage = NULL; - int numHostages = 0; - char buf[16]; - - if (!UTIL_IsGame("czero")) - return; - - while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")) != NULL) - { - if (pHostage && pHostage->pev->deadflag == DEAD_NO) - numHostages++; - } - - if (numHostages > 4) - numHostages = 4; - - Q_snprintf(buf, ARRAYSIZE(buf), "hostage%d", numHostages); - - if (numHostages) - { - MESSAGE_BEGIN(MSG_ONE, gmsgScenarioIcon, NULL, pev); - WRITE_BYTE(1); - WRITE_STRING(buf); - WRITE_BYTE(0); - MESSAGE_END(); - } - else - { - MESSAGE_BEGIN(MSG_ONE, gmsgScenarioIcon, NULL, pev); - WRITE_BYTE(0); - MESSAGE_END(); - } -} - -/* <158dc6> ../cstrike/dlls/player.cpp:7949 */ -void CBasePlayer::SendWeatherInfo(void) -{ - CBaseEntity *pPoint = UTIL_FindEntityByClassname(NULL, "env_rain"); - CBaseEntity *pPoint2 = UTIL_FindEntityByClassname(NULL, "func_rain"); - - if (pPoint != NULL || pPoint2 != NULL) - { - MESSAGE_BEGIN(MSG_ONE, gmsgReceiveW, NULL, pev); - WRITE_BYTE(1); - MESSAGE_END(); - } - else - { - pPoint = UTIL_FindEntityByClassname(NULL, "env_snow"); - pPoint2 = UTIL_FindEntityByClassname(NULL, "func_snow"); - - if (pPoint != NULL || pPoint2 != NULL) - { - MESSAGE_BEGIN(MSG_ONE, gmsgReceiveW, NULL, pev); - WRITE_BYTE(2); - MESSAGE_END(); - } - } -} - -// resends any changed player HUD info to the client. -// Called every frame by PlayerPreThink -// Also called at start of demo recording and playback by -// ForceClientDllUpdate to ensure the demo gets messages -// reflecting all of the HUD state info. - -/* <159d3c> ../cstrike/dlls/player.cpp:7963 */ -void CBasePlayer::__MAKE_VHOOK(UpdateClientData)(void) -{ - if (m_fInitHUD) - { - m_fInitHUD = FALSE; - gInitHUD = FALSE; - m_signals.Update(); - - MESSAGE_BEGIN(MSG_ONE, gmsgResetHUD, NULL, pev); - MESSAGE_END(); - - CHalfLifeMultiplay *mp = g_pGameRules; - - if (!m_fGameHUDInitialized) - { - MESSAGE_BEGIN(MSG_ONE, gmsgInitHUD, NULL, pev); - MESSAGE_END(); - - CBaseEntity *pEntity = UTIL_FindEntityByClassname(NULL, "env_fog"); - - if (pEntity) - { - CClientFog *pFog = (CClientFog *)pEntity; - - int r = pFog->pev->rendercolor[0]; - int g = pFog->pev->rendercolor[1]; - int b = pFog->pev->rendercolor[2]; - - if (r > 255) - r = 255; - - else if (r < 0) - r = 0; - - if (g > 255) - g = 255; - - else if (g < 0) - g = 0; - - if (b > 255) - b = 255; - - else if (b < 0) - b = 0; - - union - { - float f; - char b[4]; - - } density; - - density.f = pFog->m_fDensity; - - MESSAGE_BEGIN(MSG_ONE, gmsgFog, NULL, pev); - WRITE_BYTE(r); - WRITE_BYTE(g); - WRITE_BYTE(b); - WRITE_BYTE(density.b[0]); - WRITE_BYTE(density.b[1]); - WRITE_BYTE(density.b[2]); - WRITE_BYTE(density.b[3]); - MESSAGE_END(); - } - - mp->InitHUD(this); - m_fGameHUDInitialized = TRUE; - - if (mp->IsMultiplayer()) - { - FireTargets("game_playerjoin", this, this, USE_TOGGLE, 0); - } - - m_iObserverLastMode = OBS_ROAMING; - m_iObserverC4State = 0; - m_bObserverHasDefuser = false; - SetObserverAutoDirector(false); - } - - FireTargets("game_playerspawn", this, this, USE_TOGGLE, 0); - - MESSAGE_BEGIN(MSG_ONE, gmsgMoney, NULL, pev); - WRITE_LONG(m_iAccount); - WRITE_BYTE(0); - MESSAGE_END(); - - if (m_bHasDefuser) - { - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); - WRITE_BYTE(STATUSICON_SHOW); - WRITE_STRING("defuser"); - WRITE_BYTE(0); - WRITE_BYTE(160); - WRITE_BYTE(0); - MESSAGE_END(); - } - - SetBombIcon(FALSE); - SyncRoundTimer(); - SendHostagePos(); - SendWeatherInfo(); - - if (mp->IsMultiplayer()) - { - MESSAGE_BEGIN(MSG_ONE, gmsgTeamScore, NULL, pev); - WRITE_STRING(GetTeam(CT)); - WRITE_SHORT(mp->m_iNumCTWins); - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_ONE, gmsgTeamScore, NULL, pev); - WRITE_STRING(GetTeam(TERRORIST)); - WRITE_SHORT(mp->m_iNumTerroristWins); - MESSAGE_END(); - } - } - - if (m_iHideHUD != m_iClientHideHUD) - { - MESSAGE_BEGIN(MSG_ONE, gmsgHideWeapon, NULL, pev); - WRITE_BYTE(m_iHideHUD); - MESSAGE_END(); - - m_iClientHideHUD = m_iHideHUD; - } - - if (m_iFOV != m_iClientFOV) - { - // cache FOV change at end of function, so weapon updates can see that FOV has changed - - pev->fov = m_iFOV; - - MESSAGE_BEGIN(MSG_ONE, gmsgSetFOV, NULL, pev); - WRITE_BYTE(m_iFOV); - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_SPEC, gmsgHLTV); - WRITE_BYTE(ENTINDEX(edict())); - WRITE_BYTE(m_iFOV); - MESSAGE_END(); - } - - // HACKHACK -- send the message to display the game title - if (gDisplayTitle) - { - MESSAGE_BEGIN(MSG_ONE, gmsgShowGameTitle, NULL, pev); - WRITE_BYTE(0); - MESSAGE_END(); - - gDisplayTitle = FALSE; - } - - if ((int)pev->health != m_iClientHealth) - { - int iHealth = clamp(pev->health, 0, 255); - - if (pev->health > 0.0f && pev->health <= 1.0f) - iHealth = 1; - - // send "health" update message - MESSAGE_BEGIN(MSG_ONE, gmsgHealth, NULL, pev); - WRITE_BYTE(iHealth); - MESSAGE_END(); - - m_iClientHealth = (int)pev->health; - } - - if ((int)pev->armorvalue != m_iClientBattery) - { - m_iClientBattery = (int)pev->armorvalue; - - assert(gmsgBattery > 0); - - // send "armor" update message - MESSAGE_BEGIN(MSG_ONE, gmsgBattery, NULL, pev); - WRITE_SHORT((int)pev->armorvalue); - MESSAGE_END(); - } - - if (pev->dmg_take != 0.0f || pev->dmg_save != 0.0f || m_bitsHUDDamage != m_bitsDamageType) - { - // Comes from inside me if not set - Vector damageOrigin = pev->origin; - - // send "damage" message - // causes screen to flash, and pain compass to show direction of damage - edict_t *other = pev->dmg_inflictor; - - if (other) - { - CBaseEntity *pEntity = CBaseEntity::Instance(other); - - if (pEntity) - { - damageOrigin = pEntity->Center(); - } - } - - // only send down damage type that have hud art - int visibleDamageBits = m_bitsDamageType & DMG_SHOWNHUD; - - MESSAGE_BEGIN(MSG_ONE, gmsgDamage, NULL, pev); - WRITE_BYTE((int)pev->dmg_save); - WRITE_BYTE((int)pev->dmg_take); - WRITE_LONG(visibleDamageBits); - WRITE_COORD(damageOrigin.x); - WRITE_COORD(damageOrigin.y); - WRITE_COORD(damageOrigin.z); - MESSAGE_END(); - - pev->dmg_take = 0; - pev->dmg_save = 0; - m_bitsHUDDamage = m_bitsDamageType; - - // Clear off non-time-based damage indicators - m_bitsDamageType &= DMG_TIMEBASED; - } - - // Update Flashlight - if (m_flFlashLightTime && m_flFlashLightTime <= gpGlobals->time) - { - if (FlashlightIsOn()) - { - if (m_iFlashBattery) - { - m_flFlashLightTime = gpGlobals->time + FLASH_DRAIN_TIME; - m_iFlashBattery--; - - if (!m_iFlashBattery) - { - FlashlightTurnOff(); - } - } - } - else - { - if (m_iFlashBattery < 100) - { - m_flFlashLightTime = gpGlobals->time + FLASH_CHARGE_TIME; - m_iFlashBattery++; - } - else - m_flFlashLightTime = 0; - } - - MESSAGE_BEGIN(MSG_ONE, gmsgFlashBattery, NULL, pev); - WRITE_BYTE(m_iFlashBattery); - MESSAGE_END(); - } - - if (m_iTrain & TRAIN_NEW) - { - assert(gmsgTrain > 0); - - // send "train hud" update message - MESSAGE_BEGIN(MSG_ONE, gmsgTrain, NULL, pev); - WRITE_BYTE(m_iTrain & 0xF); - MESSAGE_END(); - - m_iTrain &= ~TRAIN_NEW; - } - - SendAmmoUpdate(); - - // Update all the items - for (int i = 0; i < MAX_ITEM_TYPES; i++) - { - if (m_rgpPlayerItems[i]) - { - // each item updates it's successors - m_rgpPlayerItems[i]->UpdateClientData(this); - } - } - - // Cache and client weapon change - m_pClientActiveItem = m_pActiveItem; - m_iClientFOV = m_iFOV; - - // Update Status Bar - if (m_flNextSBarUpdateTime < gpGlobals->time) - { - UpdateStatusBar(); - m_flNextSBarUpdateTime = gpGlobals->time + 0.2; - } - - if (!(m_flDisplayHistory & DHF_AMMO_EXHAUSTED)) - { - if (m_pActiveItem && m_pActiveItem->IsWeapon()) - { - CBasePlayerWeapon *w = (CBasePlayerWeapon *)m_pActiveItem; - - if (!(w->iFlags() & ITEM_FLAG_EXHAUSTIBLE)) - { - if (AmmoInventory(w->m_iPrimaryAmmoType) < 1 && w->m_iClip == 0) - { - m_flDisplayHistory |= DHF_AMMO_EXHAUSTED; - HintMessage("#Hint_out_of_ammo"); - } - } - } - } - - if (gpGlobals->time > m_tmHandleSignals) - { - m_tmHandleSignals = gpGlobals->time + 0.5f; - HandleSignals(); - } - - if (pev->deadflag == DEAD_NO && gpGlobals->time > m_tmNextRadarUpdate) - { - m_tmNextRadarUpdate = gpGlobals->time + 1.0f; - - if ((pev->origin - m_vLastOrigin).Length() >= 64) - { - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBaseEntity *pEntity = UTIL_PlayerByIndex(i); - - if (!pEntity || i == entindex()) - continue; - - CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pEntity->pev); - - if (pPlayer->pev->flags == FL_DORMANT) - continue; - - if (pPlayer->pev->deadflag != DEAD_NO) - continue; - - if (pPlayer->m_iTeam == m_iTeam) - { - MESSAGE_BEGIN(MSG_ONE, gmsgRadar, NULL, pPlayer->pev); - WRITE_BYTE(entindex()); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z); - MESSAGE_END(); - } - } - } - - m_vLastOrigin = pev->origin; - } -} - -/* <1510bc> ../cstrike/dlls/player.cpp:8330 */ -BOOL CBasePlayer::__MAKE_VHOOK(FBecomeProne)(void) -{ - m_afPhysicsFlags |= PFLAG_ONBARNACLE; - return TRUE; -} - -/* <158e8a> ../cstrike/dlls/player.cpp:8341 */ -NOXREF void CBasePlayer::BarnacleVictimBitten(entvars_t *pevBarnacle) -{ - TakeDamage(pevBarnacle, pevBarnacle, pev->armorvalue + pev->health, DMG_SLASH | DMG_ALWAYSGIB); -} - -/* <158ec3> ../cstrike/dlls/player.cpp:8350 */ -NOXREF void CBasePlayer::BarnacleVictimReleased(void) -{ - m_afPhysicsFlags &= ~PFLAG_ONBARNACLE; -} - -// return player light level plus virtual muzzle flash - -/* <1510e4> ../cstrike/dlls/player.cpp:8360 */ -int CBasePlayer::__MAKE_VHOOK(Illumination)(void) -{ - int iIllum = CBaseEntity::Illumination(); - - iIllum += m_iWeaponFlash; - - if (iIllum > 255) - return 255; - - return iIllum; -} - -/* <158eeb> ../cstrike/dlls/player.cpp:8371 */ -void CBasePlayer::EnableControl(BOOL fControl) -{ - if (!fControl) - pev->flags |= FL_FROZEN; - else - pev->flags &= ~FL_FROZEN; -} - -/* <151142> ../cstrike/dlls/player.cpp:8387 */ -void CBasePlayer::__MAKE_VHOOK(ResetMaxSpeed)(void) -{ - float speed = 240.0f; - - if (IsObserver()) - speed = 900.0f; - - else if (g_pGameRules->IsMultiplayer() && g_pGameRules->IsFreezePeriod()) - speed = 1.0f; - - else if (m_bIsVIP) - speed = 227.0f; - - else if (m_pActiveItem) - speed = m_pActiveItem->GetMaxSpeed(); - - pev->maxspeed = speed; -} - -/* <158f23> ../cstrike/dlls/player.cpp:8436 */ -bool CBasePlayer::HintMessage(const char *pMessage, BOOL bDisplayIfPlayerDead, BOOL bOverride) -{ - if (!bDisplayIfPlayerDead && !IsAlive()) - return false; - - if (bOverride || m_bShowHints) - return m_hintMessageQueue.AddMessage(pMessage, 6.0, true, NULL); - - return true; -} - -/* <1513f7> ../cstrike/dlls/player.cpp:8473 */ -Vector CBasePlayer::__MAKE_VHOOK(GetAutoaimVector)(float flDelta) -{ - Vector vecSrc; - BOOL m_fOldTargeting; - Vector angles; - - if (g_iSkillLevel == SKILL_HARD) - { - UTIL_MakeVectors(pev->v_angle + pev->punchangle); - return gpGlobals->v_forward; - } - - vecSrc = GetGunPosition(); - m_fOldTargeting = m_fOnTarget; - m_vecAutoAim = Vector(0, 0, 0); - angles = AutoaimDeflection(vecSrc, 8192, flDelta); - - if (g_pGameRules->AllowAutoTargetCrosshair()) - { - if (m_fOldTargeting != m_fOnTarget) - m_pActiveItem->UpdateItemInfo(); - } - else - m_fOnTarget = FALSE; - - if (angles.x > 180.0f) - angles.x -= 360.0f; - if (angles.x < -180.0f) - angles.x += 360.0f; - - if (angles.y > 180.0f) - angles.y -= 360.0f; - if (angles.y < -180.0f) - angles.y += 360.0f; - - if (angles.x > 25.0f) - angles.x = 25.0f; - if (angles.x < -25.0f) - angles.x = -25.0f; - - if (angles.y > 12.0f) - angles.y = 12.0f; - if (angles.y < -12.0f) - angles.y = -12.0f; - - if (g_iSkillLevel == SKILL_EASY) - m_vecAutoAim = m_vecAutoAim * 0.67f + angles * 0.33f; - else - m_vecAutoAim = angles * 0.9f; - - if (sv_aim && sv_aim->value > 0.0f) - { - if (m_vecAutoAim.x != m_lastx || m_vecAutoAim.y != m_lasty) - { - SET_CROSSHAIRANGLE(ENT(pev), -m_vecAutoAim.x, m_vecAutoAim.y); - - m_lastx = m_vecAutoAim.x; - m_lasty = m_vecAutoAim.y; - } - } - - UTIL_MakeVectors(pev->v_angle + pev->punchangle + m_vecAutoAim); - return gpGlobals->v_forward; -} - -/* <158f62> ../cstrike/dlls/player.cpp:8553 */ -Vector CBasePlayer::AutoaimDeflection(Vector &vecSrc, float flDist, float flDelta) -{ - m_fOnTarget = FALSE; - return g_vecZero; -} - -/* <158fc1> ../cstrike/dlls/player.cpp:8686 */ -void CBasePlayer::ResetAutoaim(void) -{ - if (m_vecAutoAim.x != 0.0f || m_vecAutoAim.y != 0.0f) - { - m_vecAutoAim = Vector(0, 0, 0); - SET_CROSSHAIRANGLE(ENT(pev), 0, 0); - } - m_fOnTarget = FALSE; -} - -// UNDONE: Determine real frame limit, 8 is a placeholder. -// Note: -1 means no custom frames present. - -/* <158ff6> ../cstrike/dlls/player.cpp:8704 */ -void CBasePlayer::SetCustomDecalFrames(int nFrames) -{ - if (nFrames > 0 && nFrames < 8) - m_nCustomSprayFrames = nFrames; - else - m_nCustomSprayFrames = -1; -} - -// Returns the # of custom frames this player's custom clan logo contains. - -/* <15902e> ../cstrike/dlls/player.cpp:8720 */ -int CBasePlayer::GetCustomDecalFrames(void) -{ - return m_nCustomSprayFrames; -} - -/* <151183> ../cstrike/dlls/player.cpp:8731 */ -void CBasePlayer::__MAKE_VHOOK(Blind)(float duration, float holdTime, float fadeTime, int alpha) -{ - m_blindUntilTime = gpGlobals->time + duration; - m_blindStartTime = gpGlobals->time; - - m_blindHoldTime = holdTime; - m_blindFadeTime = fadeTime; - m_blindAlpha = alpha; -} - -/* <159051> ../cstrike/dlls/player.cpp:8741 */ -void CBasePlayer::InitStatusBar(void) -{ - m_flStatusBarDisappearDelay = 0.0f; - m_SbarString0[0] = '\0'; -} - -/* <159079> ../cstrike/dlls/player.cpp:8749 */ -void CBasePlayer::UpdateStatusBar(void) -{ - int newSBarState[ SBAR_END ]; - char sbuf0[ SBAR_STRING_SIZE ]; - - Q_memset(newSBarState, 0, sizeof(newSBarState)); - Q_strcpy(sbuf0, m_SbarString0); - - // Find an ID Target - TraceResult tr; - UTIL_MakeVectors(pev->v_angle + pev->punchangle); - - Vector vecSrc = EyePosition(); - Vector vecEnd = vecSrc + (gpGlobals->v_forward * ((pev->flags & FL_SPECTATOR) != 0 ? MAX_SPECTATOR_ID_RANGE : MAX_ID_RANGE)); - - UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, edict(), &tr); - - if (tr.flFraction != 1.0f) - { - if (!FNullEnt(tr.pHit)) - { - CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); - bool isVisiblePlayer = (!TheBots->IsLineBlockedBySmoke(&pev->origin, &pEntity->pev->origin) && pEntity->Classify() == CLASS_PLAYER); - - if (gpGlobals->time >= m_blindUntilTime && isVisiblePlayer) - { - CBasePlayer *pTarget = (CBasePlayer *)pEntity; - - newSBarState[ SBAR_ID_TARGETNAME ] = ENTINDEX(pTarget->edict()); - newSBarState[ SBAR_ID_TARGETTYPE ] = (pTarget->m_iTeam == m_iTeam) ? SBAR_TARGETTYPE_TEAMMATE : SBAR_TARGETTYPE_ENEMY; - - if (pTarget->m_iTeam == m_iTeam || IsObserver()) - { - if (playerid.value != PLAYERID_MODE_OFF || IsObserver()) - Q_strcpy(sbuf0, "1 %c1: %p2\n2 %h: %i3%%"); - else - Q_strcpy(sbuf0, " "); - - newSBarState[ SBAR_ID_TARGETHEALTH ] = (int)((pEntity->pev->health / pEntity->pev->max_health) * 100); - - if (!(m_flDisplayHistory & DHF_FRIEND_SEEN) && !(pev->flags & FL_SPECTATOR)) - { - m_flDisplayHistory |= DHF_FRIEND_SEEN; - HintMessage("#Hint_spotted_a_friend"); - } - } - else if (!IsObserver()) - { - if (playerid.value != PLAYERID_MODE_TEAMONLY && playerid.value != PLAYERID_MODE_OFF) - Q_strcpy(sbuf0, "1 %c1: %p2"); - else - Q_strcpy(sbuf0, " "); - - if (!(m_flDisplayHistory & DHF_ENEMY_SEEN)) - { - m_flDisplayHistory |= DHF_ENEMY_SEEN; - HintMessage("#Hint_spotted_an_enemy"); - } - } - - m_flStatusBarDisappearDelay = gpGlobals->time + 2.0f; - } - else if (pEntity->Classify() == CLASS_HUMAN_PASSIVE) - { - if (playerid.value != PLAYERID_MODE_OFF || IsObserver()) - Q_strcpy(sbuf0, "1 %c1 %h: %i3%%"); - else - Q_strcpy(sbuf0, " "); - - newSBarState[ SBAR_ID_TARGETTYPE ] = SBAR_TARGETTYPE_HOSTAGE; - newSBarState[ SBAR_ID_TARGETHEALTH ] = (int)((pEntity->pev->health / pEntity->pev->max_health) * 100); - - if (!(m_flDisplayHistory & DHF_HOSTAGE_SEEN_FAR) && tr.flFraction > 0.1f) - { - m_flDisplayHistory |= DHF_HOSTAGE_SEEN_FAR; - - if (m_iTeam == TERRORIST) - HintMessage("#Hint_prevent_hostage_rescue", TRUE); - - else if (m_iTeam == CT) - HintMessage("#Hint_rescue_the_hostages", TRUE); - } - else if (m_iTeam == CT && !(m_flDisplayHistory & DHF_HOSTAGE_SEEN_NEAR) && tr.flFraction <= 0.1f) - { - m_flDisplayHistory |= (DHF_HOSTAGE_SEEN_NEAR | DHF_HOSTAGE_SEEN_FAR); - HintMessage("#Hint_press_use_so_hostage_will_follow"); - } - - m_flStatusBarDisappearDelay = gpGlobals->time + 2.0f; - } - } - } - else if (m_flStatusBarDisappearDelay > gpGlobals->time) - { - // hold the values for a short amount of time after viewing the object - - newSBarState[ SBAR_ID_TARGETTYPE ] = m_izSBarState[ SBAR_ID_TARGETTYPE ]; - newSBarState[ SBAR_ID_TARGETNAME ] = m_izSBarState[ SBAR_ID_TARGETNAME ]; - newSBarState[ SBAR_ID_TARGETHEALTH ] = m_izSBarState[ SBAR_ID_TARGETHEALTH ]; - } - - BOOL bForceResend = FALSE; - - if (Q_strcmp(sbuf0, m_SbarString0)) - { - MESSAGE_BEGIN(MSG_ONE, gmsgStatusText, NULL, pev); - WRITE_BYTE(0); - WRITE_STRING(sbuf0); - MESSAGE_END(); - - Q_strcpy(m_SbarString0, sbuf0); - - // make sure everything's resent - bForceResend = TRUE; - } - - // Check values and send if they don't match - for (int i = 1; i < SBAR_END; i++) - { - if (newSBarState[ i ] != m_izSBarState[ i ] || bForceResend) - { - MESSAGE_BEGIN(MSG_ONE, gmsgStatusValue, NULL, pev); - WRITE_BYTE(i); - WRITE_SHORT(newSBarState[ i ]); - MESSAGE_END(); - - m_izSBarState[ i ] = newSBarState[ i ]; - } - } -} - -/* <1603f0> ../cstrike/dlls/player.cpp:8926 */ -void CBasePlayer::DropPlayerItem(const char *pszItemName) -{ - if (!Q_strlen(pszItemName)) - { - // if this string has no length, the client didn't type a name! - // assume player wants to drop the active item. - // make the string null to make future operations in this function easier - pszItemName = NULL; - } - - if (m_bIsVIP) - { - ClientPrint(pev, HUD_PRINTCENTER, "#Weapon_Cannot_Be_Dropped"); - return; - } - else if (!pszItemName && HasShield()) - { - DropShield(); - return; - } - - for (int i = 0; i < MAX_ITEM_TYPES; i++) - { - CBasePlayerItem *pWeapon = m_rgpPlayerItems[i]; - - while (pWeapon != NULL) - { - if (pszItemName) - { - if (!Q_strcmp(pszItemName, STRING(pWeapon->pev->classname))) - break; - } - else - { - if (pWeapon == m_pActiveItem) - break; - } - - pWeapon = pWeapon->m_pNext; - } - - if (pWeapon) - { - if (!pWeapon->CanDrop()) - { - ClientPrint(pev, HUD_PRINTCENTER, "#Weapon_Cannot_Be_Dropped"); - continue; - } - - // take item off hud - pev->weapons &= ~(1 << pWeapon->m_iId); - g_pGameRules->GetNextBestWeapon(this, pWeapon); - UTIL_MakeVectors(pev->angles); - - if (pWeapon->iItemSlot() == PRIMARY_WEAPON_SLOT) - m_bHasPrimary = false; - - if (!Q_strcmp(STRING(pWeapon->pev->classname), "weapon_c4")) - { - m_bHasC4 = false; - pev->body = 0; - SetBombIcon(FALSE); - pWeapon->m_pPlayer->SetProgressBarTime(0); - - if (!g_pGameRules->m_fTeamCount) - { - UTIL_LogPrintf("\"%s<%i><%s>\" triggered \"Dropped_The_Bomb\"\n", - STRING(pev->netname), - GETPLAYERUSERID(edict()), - GETPLAYERAUTHID(edict())); - - g_pGameRules->m_bBombDropped = TRUE; - - CBaseEntity *pEntity = NULL; - - while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")) != NULL) - { - if (FNullEnt(pEntity->edict())) - break; - - if (!pEntity->IsPlayer()) - continue; - - if (pEntity->pev->flags != FL_DORMANT) - { - CBasePlayer *pOther = GetClassPtr((CBasePlayer *)pEntity->pev); - - if (pOther->pev->deadflag == DEAD_NO && pOther->m_iTeam == TERRORIST) - { - ClientPrint(pOther->pev, HUD_PRINTCENTER, "#Game_bomb_drop", STRING(pev->netname)); - - MESSAGE_BEGIN(MSG_ONE, gmsgBombDrop, NULL, pOther->pev); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z); - WRITE_BYTE(0); - MESSAGE_END(); - } - } - } - } - } - - CWeaponBox *pWeaponBox = (CWeaponBox *)Create("weaponbox", pev->origin + gpGlobals->v_forward * 10, pev->angles, edict()); - pWeaponBox->pev->angles.x = 0; - pWeaponBox->pev->angles.z = 0; - pWeaponBox->SetThink(&CWeaponBox::Kill); - pWeaponBox->pev->nextthink = gpGlobals->time + 300; - pWeaponBox->PackWeapon(pWeapon); - pWeaponBox->pev->velocity = gpGlobals->v_forward * 300 + gpGlobals->v_forward * 100; - - if (!Q_strcmp(STRING(pWeapon->pev->classname), "weapon_c4")) - { - pWeaponBox->m_bIsBomb = true; - pWeaponBox->SetThink(&CWeaponBox::BombThink); - pWeaponBox->pev->nextthink = gpGlobals->time + 1; - - TheCSBots()->SetLooseBomb(pWeaponBox); - TheCSBots()->OnEvent(EVENT_BOMB_DROPPED); - } - - if (pWeapon->iFlags() & ITEM_FLAG_EXHAUSTIBLE) - { - int iAmmoIndex = GetAmmoIndex(pWeapon->pszAmmo1()); - - if (iAmmoIndex != -1) - { - pWeaponBox->PackAmmo(MAKE_STRING(pWeapon->pszAmmo1()), m_rgAmmo[iAmmoIndex] > 0); - m_rgAmmo[iAmmoIndex] = 0; - } - } - - const char *modelname = GetCSModelName(pWeapon->m_iId); - - if (modelname != NULL) - { - SET_MODEL(ENT(pWeaponBox->pev), modelname); - } - - return; - } - } -} - -/* <1594a2> ../cstrike/dlls/player.cpp:9094 */ -BOOL CBasePlayer::HasPlayerItem(CBasePlayerItem *pCheckItem) -{ - CBasePlayerItem *pItem = m_rgpPlayerItems[ pCheckItem->iItemSlot() ]; - while (pItem != NULL) - { - if (FClassnameIs(pItem->pev, STRING(pCheckItem->pev->classname))) - return TRUE; - - pItem = pItem->m_pNext; - } - return FALSE; -} - -/* <159534> ../cstrike/dlls/player.cpp:9113 */ -BOOL CBasePlayer::HasNamedPlayerItem(const char *pszItemName) -{ - CBasePlayerItem *pItem; - int i; - - for (i = 0; i < MAX_ITEM_TYPES; i++) - { - pItem = m_rgpPlayerItems[ i ]; - - while (pItem != NULL) - { - if (!Q_strcmp(pszItemName, STRING(pItem->pev->classname))) - return TRUE; - - pItem = pItem->m_pNext; - } - } - - return FALSE; -} - -/* <1619fd> ../cstrike/dlls/player.cpp:9137 */ -void CBasePlayer::SwitchTeam(void) -{ - int oldTeam; - char *szOldTeam; - char *szNewTeam; - const char *szName; - - oldTeam = m_iTeam; - - if (m_iTeam == CT) - { - m_iTeam = TERRORIST; - - switch (m_iModelName) - { - case MODEL_URBAN: - m_iModelName = MODEL_LEET; - SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "leet"); - break; - case MODEL_GIGN: - m_iModelName = MODEL_GUERILLA; - SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "guerilla"); - break; - case MODEL_SAS: - m_iModelName = MODEL_ARCTIC; - SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "arctic"); - break; - case MODEL_SPETSNAZ: - if (UTIL_IsGame("czero")) - { - m_iModelName = MODEL_MILITIA; - SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "militia"); - break; - } - default: - if (m_iModelName == MODEL_GSG9 || !IsBot() || !TheBotProfiles->GetCustomSkinModelname(m_iModelName)) - { - m_iModelName = MODEL_TERROR; - SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "terror"); - } - break; - } - } - else if (m_iTeam == TERRORIST) - { - m_iTeam = CT; - - switch (m_iModelName) - { - case MODEL_TERROR: - m_iModelName = MODEL_GSG9; - SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "gsg9"); - break; - - case MODEL_ARCTIC: - m_iModelName = MODEL_SAS; - SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "sas"); - break; - - case MODEL_GUERILLA: - m_iModelName = MODEL_GIGN; - SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "gign"); - break; - - case MODEL_MILITIA: - if (UTIL_IsGame("czero")) - { - m_iModelName = MODEL_SPETSNAZ; - SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "spetsnaz"); - break; - } - default: - if (m_iModelName == MODEL_LEET || !IsBot() || !TheBotProfiles->GetCustomSkinModelname(m_iModelName)) - { - m_iModelName = MODEL_URBAN; - SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "urban"); - } - break; - } - } - - MESSAGE_BEGIN(MSG_ALL, gmsgTeamInfo); - WRITE_BYTE(entindex()); - switch (m_iTeam) - { - case CT: - WRITE_STRING("CT"); - break; - case TERRORIST: - WRITE_STRING("TERRORIST"); - break; - case SPECTATOR: - WRITE_STRING("SPECTATOR"); - break; - default: - WRITE_STRING("UNASSIGNED"); - break; - } - MESSAGE_END(); - - TheBots->OnEvent(EVENT_PLAYER_CHANGED_TEAM, this); - - UpdateLocation(true); - - if (m_iTeam) - { - SetScoreboardAttributes(); - } - - if (pev->netname) - { - szName = STRING(pev->netname); - - if (!szName[0]) - szName = ""; - } - else - szName = ""; - - UTIL_ClientPrintAll(HUD_PRINTNOTIFY, (m_iTeam == TERRORIST) ? "#Game_join_terrorist_auto" : "#Game_join_ct_auto", szName); - - if (m_bHasDefuser) - { - m_bHasDefuser = false; - pev->body = 0; - - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); - WRITE_BYTE(STATUSICON_HIDE); - WRITE_STRING("defuser"); - MESSAGE_END(); - - SendItemStatus(this); - SetProgressBarTime(0); - - for (int i = 0; i < MAX_ITEM_TYPES; i++) - { - m_pActiveItem = m_rgpPlayerItems[ i ]; - - if (m_pActiveItem && FClassnameIs(m_pActiveItem->pev, "item_thighpack")) - { - m_pActiveItem->Drop(); - m_rgpPlayerItems[i] = NULL; - } - } - } - - szOldTeam = GetTeam(oldTeam); - szNewTeam = GetTeam(m_iTeam); - - UTIL_LogPrintf - ( - "\"%s<%i><%s><%s>\" joined team \"%s\" (auto)\n", - STRING(pev->netname), - GETPLAYERUSERID(edict()), - GETPLAYERAUTHID(edict()), - szOldTeam, - szNewTeam - ); - - CCSBot *pBot = reinterpret_cast(this); - - if (pBot->IsBot()) - { - const BotProfile *pProfile = pBot->GetProfile(); - - if (pProfile != NULL) - { - bool kick = false; - - if (m_iTeam == CT && !pProfile->IsValidForTeam(BOT_TEAM_CT)) - kick = true; - - else if (m_iTeam == TERRORIST && !pProfile->IsValidForTeam(BOT_TEAM_T)) - kick = true; - - if (kick) - { - SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(pev->netname))); - } - } - } -} - -/* <159594> ../cstrike/dlls/player.cpp:9302 */ -void CBasePlayer::UpdateShieldCrosshair(bool draw) -{ - if (draw) - m_iHideHUD &= ~HIDEHUD_CROSSHAIR; - else - m_iHideHUD |= HIDEHUD_CROSSHAIR; -} - -/* <152fbc> ../cstrike/dlls/player.cpp:9313 */ -BOOL CBasePlayer::SwitchWeapon(CBasePlayerItem *pWeapon) -{ - if (!pWeapon->CanDeploy()) - { - return FALSE; - } - - ResetAutoaim(); - - if (m_pActiveItem) - { - m_pActiveItem->Holster(); - } - - CBasePlayerItem *pTemp = m_pActiveItem; - m_pActiveItem = pWeapon; - m_pLastItem = pTemp; - pWeapon->Deploy(); - - if (pWeapon->m_pPlayer) - { - pWeapon->m_pPlayer->ResetMaxSpeed(); - } - - if (HasShield()) - { - UpdateShieldCrosshair(true); - } - - return TRUE; -} - -/* <1595ed> ../cstrike/dlls/player.cpp:9342 */ -void CBasePlayer::TabulateAmmo(void) -{ - ammo_buckshot = AmmoInventory(GetAmmoIndex("buckshot")); - ammo_9mm = AmmoInventory(GetAmmoIndex("9mm")); - ammo_556nato = AmmoInventory(GetAmmoIndex("556Nato")); - ammo_556natobox = AmmoInventory(GetAmmoIndex("556NatoBox")); - ammo_762nato = AmmoInventory(GetAmmoIndex("762Nato")); - ammo_45acp = AmmoInventory(GetAmmoIndex("45acp")); - ammo_50ae = AmmoInventory(GetAmmoIndex("50AE")); - ammo_338mag = AmmoInventory(GetAmmoIndex("338Magnum")); - ammo_57mm = AmmoInventory(GetAmmoIndex("57mm")); - ammo_357sig = AmmoInventory(GetAmmoIndex("357SIG")); -} - -/* <1511eb> ../cstrike/dlls/player.cpp:9365 */ -int CDeadHEV::__MAKE_VHOOK(Classify)(void) -{ - return CLASS_HUMAN_MILITARY; -} - -/* <152451> ../cstrike/dlls/player.cpp:9375 */ -void CDeadHEV::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ - if (FStrEq(pkvd->szKeyName, "pose")) - { - m_iPose = Q_atoi(pkvd->szValue); - pkvd->fHandled = TRUE; - } - else - CBaseMonster::KeyValue(pkvd); -} - -/* <159a88> ../cstrike/dlls/player.cpp:9386 */ -LINK_ENTITY_TO_CLASS(monster_hevsuit_dead, CDeadHEV); - -/* <1513ce> ../cstrike/dlls/player.cpp:9391 */ -void CDeadHEV::__MAKE_VHOOK(Spawn)(void) -{ - PRECACHE_MODEL("models/player.mdl"); - SET_MODEL(ENT(pev), "models/player.mdl"); - - pev->effects = 0; - pev->yaw_speed = 8.0f; - - pev->sequence = 0; - pev->body = 1; - - m_bloodColor = BLOOD_COLOR_RED; - pev->sequence = LookupSequence(m_szPoses[ m_iPose ]); - - if (pev->sequence == -1) - { - ALERT(at_console, "Dead hevsuit with bad pose\n"); - pev->sequence = 0; - pev->effects = EF_BRIGHTFIELD; - } - - pev->health = 8; - MonsterInitDead(); -} - -/* <159b64> ../cstrike/dlls/player.cpp:9426 */ -LINK_ENTITY_TO_CLASS(player_weaponstrip, CStripWeapons); - -/* <15f62f> ../cstrike/dlls/player.cpp:9428 */ -void CStripWeapons::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ - CBasePlayer *pPlayer = NULL; - - if (pActivator && pActivator->IsPlayer()) - { - pPlayer = (CBasePlayer *)pActivator; - } - else if (!g_pGameRules->IsDeathmatch()) - { - pPlayer = (CBasePlayer *)Instance(INDEXENT(1)); - } - - if (pPlayer) - { - pPlayer->RemoveAllItems(FALSE); - } -} - -/* <159c40> ../cstrike/dlls/player.cpp:9473 */ -LINK_ENTITY_TO_CLASS(player_loadsaved, CRevertSaved); - -/* <151a24> ../cstrike/dlls/player.cpp:9481 */ -IMPLEMENT_SAVERESTORE(CRevertSaved, CPointEntity); - -/* <152540> ../cstrike/dlls/player.cpp:9483 */ -void CRevertSaved::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) -{ - if (FStrEq(pkvd->szKeyName, "duration")) - { - SetDuration(Q_atof(pkvd->szValue)); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "holdtime")) - { - SetHoldTime(Q_atof(pkvd->szValue)); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "messagetime")) - { - SetMessageTime(Q_atof(pkvd->szValue)); - pkvd->fHandled = TRUE; - } - else if (FStrEq(pkvd->szKeyName, "loadtime")) - { - SetLoadTime(Q_atof(pkvd->szValue)); - pkvd->fHandled = TRUE; - } - else - CPointEntity::KeyValue(pkvd); -} - -/* <151365> ../cstrike/dlls/player.cpp:9509 */ -void CRevertSaved::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ - UTIL_ScreenFadeAll(pev->rendercolor, Duration(), HoldTime(), (int)pev->renderamt, FFADE_OUT); - pev->nextthink = gpGlobals->time + MessageTime(); - SetThink(&CRevertSaved::MessageThink); -} - -/* <152a96> ../cstrike/dlls/player.cpp:9517 */ -void CRevertSaved::MessageThink(void) -{ - float nextThink = LoadTime() - MessageTime(); - UTIL_ShowMessageAll(STRING(pev->message)); - - if (nextThink > 0) - { - pev->nextthink = gpGlobals->time + nextThink; - SetThink(&CRevertSaved::LoadThink); - } - else - LoadThink(); -} - -/* <15198b> ../cstrike/dlls/player.cpp:9531 */ -void CRevertSaved::LoadThink(void) -{ - if (!gpGlobals->deathmatch) - SERVER_COMMAND("reload\n"); -} - -/* <15133c> ../cstrike/dlls/player.cpp:9549 */ -void CInfoIntermission::__MAKE_VHOOK(Spawn)(void) -{ - UTIL_SetOrigin(pev, pev->origin); - - pev->solid = SOLID_NOT; - pev->effects = EF_NODRAW; - pev->v_angle = g_vecZero; - pev->nextthink = gpGlobals->time + 2; -} - -/* <1530e6> ../cstrike/dlls/player.cpp:9560 */ -void CInfoIntermission::__MAKE_VHOOK(Think)(void) -{ - edict_t *pTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target)); - - if (!FNullEnt(pTarget)) - { - pev->v_angle = UTIL_VecToAngles((pTarget->v.origin - pev->origin).Normalize()); - pev->v_angle.x = -pev->v_angle.x; - } -} - -/* <159d1c> ../cstrike/dlls/player.cpp:9574 */ -LINK_ENTITY_TO_CLASS(info_intermission, CInfoIntermission); - -/* <159df8> ../cstrike/dlls/player.cpp:9586 */ -void CBasePlayer::StudioEstimateGait(void) -{ - float_precision dt; - Vector est_velocity; - - dt = gpGlobals->frametime; - - if (dt < 0) - dt = 0; - - else if (dt > 1.0) - dt = 1; - - if (dt == 0) - { - m_flGaitMovement = 0; - return; - } - - est_velocity = pev->origin - m_prevgaitorigin; - m_prevgaitorigin = pev->origin; - - m_flGaitMovement = est_velocity.Length(); - - if (dt <= 0 || m_flGaitMovement / dt < 5) - { - m_flGaitMovement = 0; - - est_velocity.x = 0; - est_velocity.y = 0; - } - - if (!est_velocity.x && !est_velocity.y) - { - float_precision flYawDiff = pev->angles.y - m_flGaityaw; - float_precision flYaw = fmod(flYawDiff, 360); - - flYawDiff = flYawDiff - (int64_t)(flYawDiff / 360) * 360; - - if (flYawDiff > 180) - flYawDiff -= 360; - - if (flYawDiff < -180) - flYawDiff += 360; - - if (flYaw < -180) - flYaw += 360; - - else if (flYaw > 180) - flYaw -= 360; - - if (flYaw > -5 && flYaw < 5) - m_flYawModifier = 0.05; - - if (flYaw < -90 || flYaw > 90) - m_flYawModifier = 3.5; - - if (dt < 0.25) - flYawDiff *= dt * m_flYawModifier; - else - flYawDiff *= dt; - - if ((float_precision)abs((int64_t)flYawDiff) < 0.1) - flYawDiff = 0; - - m_flGaityaw += flYawDiff; - m_flGaityaw -= (int64_t)(m_flGaityaw / 360) * 360; - - m_flGaitMovement = 0; - } - else - { - m_flGaityaw = (atan2((float_precision)est_velocity.y, (float_precision)est_velocity.x) * 180 / M_PI); - - if (m_flGaityaw > 180) - m_flGaityaw = 180; - - if (m_flGaityaw < -180) - m_flGaityaw = -180; - } -} - -/* <159f01> ../cstrike/dlls/player.cpp:9685 */ -void CBasePlayer::StudioPlayerBlend(int *pBlend, float *pPitch) -{ - // calc up/down pointing - float range = (float)(int64_t)(*pPitch * 3.0f); - - *pBlend = range; - - if (range <= -45.0f) - { - *pBlend = 255; - *pPitch = 0; - } - else if (range >= 45.0f) - { - *pBlend = 0; - *pPitch = 0; - } - else - { - *pBlend = (int64_t)((45.0f - range) * (255.0f / 90.0f)); - *pPitch = 0; - } -} - -/* <159f81> ../cstrike/dlls/player.cpp:9709 */ -void CBasePlayer::CalculatePitchBlend(void) -{ - int iBlend; - float temp = pev->angles.x; - - StudioPlayerBlend(&iBlend, &temp); - - pev->blending[1] = iBlend; - m_flPitch = iBlend; -} - -/* <15a007> ../cstrike/dlls/player.cpp:9720 */ -void CBasePlayer::CalculateYawBlend(void) -{ - float dt; - float maxyaw = 255.0f; - - float_precision flYaw; - float_precision blend_yaw; - - dt = gpGlobals->frametime; - - if (dt < 0.0) - dt = 0; - - else if (dt > 1.0) - dt = 1; - - StudioEstimateGait(); - - flYaw = fmod((float_precision)(pev->angles.y - m_flGaityaw), 360); - - if (flYaw < -180) - flYaw += 360; - - else if (flYaw > 180) - flYaw -= 360; - - if (m_flGaitMovement != 0.0) - { - if (flYaw > 120) - { - m_flGaityaw -= 180; - m_flGaitMovement = -m_flGaitMovement; - flYaw -= 180; - } - else if (flYaw < -120) - { - m_flGaityaw += 180; - m_flGaitMovement = -m_flGaitMovement; - flYaw += 180; - } - } - - flYaw = (flYaw / 90) * 128 + 127; - - if (flYaw > 255) - flYaw = 255; - - else if (flYaw < 0) - flYaw = 0; - - blend_yaw = maxyaw - flYaw; - - pev->blending[0] = (int64_t)blend_yaw; - m_flYaw = blend_yaw; -} - -/* <15a07b> ../cstrike/dlls/player.cpp:9776 */ -void CBasePlayer::StudioProcessGait(void) -{ - mstudioseqdesc_t *pseqdesc; - float_precision dt = gpGlobals->frametime; - - if (dt < 0.0) - dt = 0; - - else if (dt > 1.0) - dt = 1; - - CalculateYawBlend(); - CalculatePitchBlend(); - - model_t *model = (model_t *)GET_MODEL_PTR(edict()); - - if (!model) - return; - - studiohdr_t *pstudiohdr = (studiohdr_t *)model; - - pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + pev->gaitsequence; - - if (pseqdesc->linearmovement.x > 0.0f) - m_flGaitframe += (m_flGaitMovement / pseqdesc->linearmovement.x) * pseqdesc->numframes; - else - m_flGaitframe += pev->framerate * pseqdesc->fps * dt; - - m_flGaitframe -= (int)(m_flGaitframe / pseqdesc->numframes) * pseqdesc->numframes; - - if (m_flGaitframe < 0) - m_flGaitframe += pseqdesc->numframes; -} - -/* <15a444> ../cstrike/dlls/player.cpp:9821 */ -void CBasePlayer::ResetStamina(void) -{ - pev->fuser1 = 0; - pev->fuser3 = 0; - pev->fuser2 = 0; -} - -/* <15a467> ../cstrike/dlls/player.cpp:9829 */ -float_precision GetPlayerPitch(const edict_t *pEdict) -{ - entvars_t *pev = VARS((edict_t *)pEdict); - CBasePlayer *pPlayer = reinterpret_cast(CBasePlayer::Instance(pev)); - - if (!pPlayer) - return 0.0f; - - return pPlayer->m_flPitch; -} - -/* <15a530> ../cstrike/dlls/player.cpp:9846 */ -float_precision GetPlayerYaw(const edict_t *pEdict) -{ - entvars_t *pev = VARS((edict_t *)pEdict); - CBasePlayer *pPlayer = reinterpret_cast(CBasePlayer::Instance(pev)); - - if (!pPlayer) - return 0.0f; - - return pPlayer->m_flYaw; -} - -/* <15a5f9> ../cstrike/dlls/player.cpp:9863 */ -int GetPlayerGaitsequence(const edict_t *pEdict) -{ - entvars_t *pev = VARS((edict_t *)pEdict); - CBasePlayer *pPlayer = reinterpret_cast(CBasePlayer::Instance(pev)); - - if (!pPlayer) - return 1; - - return pPlayer->m_iGaitsequence; -} - -/* <15a6c2> ../cstrike/dlls/player.cpp:9880 */ -void CBasePlayer::SpawnClientSideCorpse(void) -{ - char *infobuffer = GET_INFO_BUFFER(edict()); - char *pModel = GET_KEY_VALUE(infobuffer, "model"); - - MESSAGE_BEGIN(MSG_ALL, gmsgSendCorpse); - WRITE_STRING(pModel); - WRITE_LONG(pev->origin.x * 128); - WRITE_LONG(pev->origin.y * 128); - WRITE_LONG(pev->origin.z * 128); - WRITE_COORD(pev->angles.x); - WRITE_COORD(pev->angles.y); - WRITE_COORD(pev->angles.z); - WRITE_LONG((pev->animtime - gpGlobals->time) * 100); - WRITE_BYTE(pev->sequence); - WRITE_BYTE(pev->body); - WRITE_BYTE(m_iTeam); - WRITE_BYTE(entindex()); - MESSAGE_END(); - - m_canSwitchObserverModes = true; - - if (TheTutor != NULL) - { - TheTutor->OnEvent(EVENT_CLIENT_CORPSE_SPAWNED, this); - } -} - -/* <15a7a2> ../cstrike/dlls/player.cpp:9909 */ -BOOL CBasePlayer::IsArmored(int nHitGroup) -{ - BOOL fApplyArmor = FALSE; - - if (m_iKevlar == ARMOR_TYPE_EMPTY) - return FALSE; - - switch (nHitGroup) - { - case HITGROUP_HEAD: - { - fApplyArmor = (m_iKevlar == ARMOR_TYPE_HELMET); - break; - } - case HITGROUP_GENERIC: - case HITGROUP_CHEST: - case HITGROUP_STOMACH: - case HITGROUP_LEFTARM: - case HITGROUP_RIGHTARM: - fApplyArmor = TRUE; - break; - } - - return fApplyArmor; -} - -/* <15a847> ../cstrike/dlls/player.cpp:9939 */ -BOOL CBasePlayer::ShouldDoLargeFlinch(int nHitGroup, int nGunType) -{ - if (pev->flags & FL_DUCKING) - return FALSE; - - if (nHitGroup != HITGROUP_LEFTLEG && nHitGroup != HITGROUP_RIGHTLEG) - { - switch (nGunType) - { - case WEAPON_SCOUT: - case WEAPON_AUG: - case WEAPON_SG550: - case WEAPON_GALIL: - case WEAPON_FAMAS: - case WEAPON_AWP: - case WEAPON_M3: - case WEAPON_M4A1: - case WEAPON_G3SG1: - case WEAPON_DEAGLE: - case WEAPON_SG552: - case WEAPON_AK47: - return TRUE; - } - } - - return FALSE; -} - -/* <15a87d> ../cstrike/dlls/player.cpp:9971 */ -void CBasePlayer::SetPrefsFromUserinfo(char *infobuffer) -{ - const char *pszKeyVal; - - pszKeyVal = GET_KEY_VALUE(infobuffer, "_cl_autowepswitch"); - - if (Q_strcmp(pszKeyVal, "")) - m_iAutoWepSwitch = Q_atoi(pszKeyVal); - else - m_iAutoWepSwitch = 1; - - pszKeyVal = GET_KEY_VALUE(infobuffer, "_vgui_menus"); - - if (Q_strcmp(pszKeyVal, "")) - m_bVGUIMenus = Q_atoi(pszKeyVal) != 0; - else - m_bVGUIMenus = true; - - pszKeyVal = GET_KEY_VALUE(infobuffer, "_ah"); - - if (Q_strcmp(pszKeyVal, "")) - m_bShowHints = Q_atoi(pszKeyVal) != 0; - else - m_bShowHints = true; -} - -/* <15a92a> ../cstrike/dlls/player.cpp:10013 */ -bool CBasePlayer::IsLookingAtPosition(Vector *pos, float angleTolerance) -{ - Vector to = *pos - EyePosition(); - Vector idealAngle = UTIL_VecToAngles(to); - - idealAngle.x = 360.0 - idealAngle.x; - - float deltaYaw = NormalizeAngle(idealAngle.y - pev->v_angle.y); - float deltaPitch = NormalizeAngle(idealAngle.x - pev->v_angle.x); - - return (abs(deltaYaw) < angleTolerance - && abs(deltaPitch) < angleTolerance); -} - -/* <15aa7b> ../cstrike/dlls/player.cpp:10083 */ -bool CBasePlayer::CanAffordPrimary(void) -{ - int account = m_iAccount; - - if (m_iTeam == CT) - { - WeaponStruct *temp; - for (int i = 0; i < MAX_WEAPONS; i++) - { - temp = &g_weaponStruct[ i ]; - - if ((temp->m_side & TERRORIST) && temp->m_slot == PRIMARY_WEAPON_SLOT && account >= temp->m_price) - return true; - } - } - else if (m_iTeam == TERRORIST) - { - WeaponStruct *temp; - for (int i = 0; i < MAX_WEAPONS; i++) - { - temp = &g_weaponStruct[ i ]; - - if ((temp->m_side & CT) && temp->m_slot == PRIMARY_WEAPON_SLOT && account >= temp->m_price) - return true; - } - } - - return false; -} - -/* <15ab2c> ../cstrike/dlls/player.cpp:10139 */ -bool CBasePlayer::CanAffordPrimaryAmmo(void) -{ - CBasePlayerWeapon *primary = (CBasePlayerWeapon *)&m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]; - - for (int i = 0; i < MAX_WEAPONS; i++) - { - WeaponStruct *temp = &g_weaponStruct[ i ]; - - if (temp->m_type == primary->m_iId && m_iAccount >= temp->m_ammoPrice) - return true; - } - - return false; -} - -/* <15aba0> ../cstrike/dlls/player.cpp:10169 */ -bool CBasePlayer::CanAffordSecondaryAmmo(void) -{ - CBasePlayerWeapon *secondary = (CBasePlayerWeapon *)&m_rgpPlayerItems[ PISTOL_SLOT ]; - - for (int i = 0; i < MAX_WEAPONS; i++) - { - WeaponStruct *temp = &g_weaponStruct[ i ]; - - if (temp->m_type == secondary->m_iId && m_iAccount >= temp->m_ammoPrice) - return true; - } - - return false; -} - -/* <15ac14> ../cstrike/dlls/player.cpp:10199 */ -bool CBasePlayer::CanAffordArmor(void) -{ - if (m_iKevlar == ARMOR_TYPE_KEVLAR && pev->armorvalue == 100.0f && m_iAccount >= HELMET_PRICE) - return true; - - return (m_iAccount >= KEVLAR_PRICE); -} - -/* <15ac3c> ../cstrike/dlls/player.cpp:10217 */ -bool CBasePlayer::CanAffordDefuseKit(void) -{ - return (m_iAccount >= DEFUSEKIT_PRICE); -} - -/* <15ac64> ../cstrike/dlls/player.cpp:10227 */ -bool CBasePlayer::CanAffordGrenade(void) -{ - return (m_iAccount >= FLASHBANG_PRICE); -} - -/* <15ac8c> ../cstrike/dlls/player.cpp:10247 */ -bool CBasePlayer::NeedsPrimaryAmmo(void) -{ - CBasePlayerWeapon *primary = (CBasePlayerWeapon *)&m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]; - - if (!primary || primary->m_iId == WEAPON_SHIELDGUN) - return false; - - return (m_rgAmmo[ primary->m_iPrimaryAmmoType ] < primary->iMaxAmmo1()); -} - -/* <15ace1> ../cstrike/dlls/player.cpp:10268 */ -bool CBasePlayer::NeedsSecondaryAmmo(void) -{ - CBasePlayerWeapon *secondary = (CBasePlayerWeapon *)&m_rgpPlayerItems[ PISTOL_SLOT ]; - - if (!secondary) - return false; - - return (m_rgAmmo[ secondary->m_iPrimaryAmmoType ] < secondary->iMaxAmmo1()); -} - -/* <15ad36> ../cstrike/dlls/player.cpp:10285 */ -bool CBasePlayer::NeedsArmor(void) -{ - if (m_iKevlar == ARMOR_TYPE_EMPTY) - return true; - - return (pev->armorvalue < 50.0f); -} - -/* <15ad5e> ../cstrike/dlls/player.cpp:10300 */ -bool CBasePlayer::NeedsDefuseKit(void) -{ - CHalfLifeMultiplay *mpRules = g_pGameRules; - - if (m_bHasDefuser || m_iTeam != CT) - return false; - - return (mpRules->m_bMapHasBombTarget); -} - -/* <15ad9a> ../cstrike/dlls/player.cpp:10325 */ -bool CBasePlayer::NeedsGrenade(void) -{ - int iAmmoIndex = GetAmmoIndex("HEGrenade"); - - if (iAmmoIndex > 0 && m_rgAmmo[ iAmmoIndex ]) - return false; - - iAmmoIndex = GetAmmoIndex("Flashbang"); - - if (iAmmoIndex > 0 && m_rgAmmo[ iAmmoIndex ]) - return false; - - iAmmoIndex = GetAmmoIndex("SmokeGrenade"); - - if (iAmmoIndex > 0 && m_rgAmmo[ iAmmoIndex ]) - return false; - - return true; -} - -/* <15aeab> ../cstrike/dlls/player.cpp:10381 */ -void CBasePlayer::ClientCommand(const char *cmd, const char *arg1, const char *arg2, const char *arg3) -{ - BotArgs[0] = cmd; - BotArgs[1] = arg1; - BotArgs[2] = arg2; - BotArgs[3] = arg3; - - UseBotArgs = true; - ::ClientCommand(ENT(pev)); - UseBotArgs = false; -} - -/* <15aea9> ../cstrike/dlls/player.cpp:10401 */ -const char *GetBuyStringForWeaponClass(int weaponClass) -{ - switch (weaponClass) - { - case WEAPONCLASS_PISTOL: - return "deagle elites fn57 usp glock p228 shield"; - case WEAPONCLASS_SNIPERRIFLE: - return "awp sg550 g3sg1 scout"; - case WEAPONCLASS_GRENADE: - return "hegren"; - case WEAPONCLASS_SHOTGUN: - return "xm1014 m3"; - case WEAPONCLASS_SUBMACHINEGUN: - return "p90 ump45 mp5 tmp mac10"; - case WEAPONCLASS_MACHINEGUN: - return "m249"; - case WEAPONCLASS_RIFLE: - return "sg552 aug ak47 m4a1 galil famas"; - } - - return NULL; -} - -/* <15aee9> ../cstrike/dlls/player.cpp:10454 */ -void CBasePlayer::ClearAutoBuyData(void) -{ - m_autoBuyString[0] = '\0'; -} - -/* <15af11> ../cstrike/dlls/player.cpp:10459 */ -void CBasePlayer::AddAutoBuyData(const char *str) -{ - int len = Q_strlen(m_autoBuyString); - - if (len < MAX_AUTOBUY_LENGTH - 1) - { - if (len > 0) - m_autoBuyString[ len ] = ' '; - - Q_strncat(m_autoBuyString, str, MAX_AUTOBUY_LENGTH - len); - } -} - -/* <15af66> ../cstrike/dlls/player.cpp:10478 */ -void CBasePlayer::InitRebuyData(const char *str) -{ - if (!str || Q_strlen(str) > MAX_REBUY_LENGTH) - { - return; - } - - if (m_rebuyString != NULL) - { - delete m_rebuyString; - m_rebuyString = NULL; - } - - m_rebuyString = new char[ Q_strlen(str) + 1 ]; - Q_strcpy(m_rebuyString, str); - m_rebuyString[ Q_strlen(str) ] = '\0'; -} - -/* <15be4f> ../cstrike/dlls/player.cpp:10500 */ -void CBasePlayer::AutoBuy(void) -{ - const char *c = NULL; - bool boughtPrimary = false; - bool boughtSecondary = false; - char prioritizedString[ MAX_AUTOBUY_LENGTH ]; - - c = PickFlashKillWeaponString(); - - if (c != NULL) - { - ParseAutoBuyString(c, boughtPrimary, boughtSecondary); - } - - c = PickGrenadeKillWeaponString(); - - if (c != NULL) - { - ParseAutoBuyString(c, boughtPrimary, boughtSecondary); - } - - // TODO: Reverse me - c = PickPrimaryCareerTaskWeapon(); - - if (c != NULL) - { - Q_strcpy(prioritizedString, c); - - PrioritizeAutoBuyString(prioritizedString, m_autoBuyString); - ParseAutoBuyString(prioritizedString, boughtPrimary, boughtSecondary); - } - - // TODO: Reverse me - c = PickSecondaryCareerTaskWeapon(); - - if (c != NULL) - { - Q_strcpy(prioritizedString, c); - - PrioritizeAutoBuyString(prioritizedString, m_autoBuyString); - ParseAutoBuyString(prioritizedString, boughtPrimary, boughtSecondary); - } - - ParseAutoBuyString(m_autoBuyString, boughtPrimary, boughtSecondary); - - c = PickFlashKillWeaponString(); - - if (c != NULL) - { - ParseAutoBuyString(c, boughtPrimary, boughtSecondary); - } - - if (TheTutor) - TheTutor->OnEvent(EVENT_PLAYER_LEFT_BUY_ZONE); -} - -/* <14ea4e> ../cstrike/dlls/player.cpp:10556 */ -bool IsPrimaryWeaponClass(int classId) -{ - return (classId >= WEAPONCLASS_SUBMACHINEGUN && classId <= WEAPONCLASS_SNIPERRIFLE); -} - -/* <15afbe> ../cstrike/dlls/player.cpp:10571 */ -bool IsPrimaryWeaponId(int id) -{ - int classId = WEAPONCLASS_NONE; - const char *alias = WeaponIDToAlias(id); - - if (alias) - { - classId = AliasToWeaponClass(alias); - } - - return IsPrimaryWeaponClass(classId); -} - -/* <14ea6f> ../cstrike/dlls/player.cpp:10583 */ -bool IsSecondaryWeaponClass(int classId) -{ - return (classId == WEAPONCLASS_PISTOL); -} - -/* <15b059> ../cstrike/dlls/player.cpp:10588 */ -bool IsSecondaryWeaponId(int id) -{ - int classId = WEAPONCLASS_NONE; - const char *alias = WeaponIDToAlias(id); - - if (alias) - { - classId = AliasToWeaponClass(alias); - } - - return IsSecondaryWeaponClass(classId); -} - -/* <15b0f1> ../cstrike/dlls/player.cpp:10600 */ -const char *GetWeaponAliasFromName(const char *weaponName) -{ - if (!Q_strncmp(weaponName, "weapon_", 7)) - { - weaponName += 7; - } - - return weaponName; -} - -/* <15b133> ../cstrike/dlls/player.cpp:10607 */ -bool CurrentWeaponSatisfies(CBasePlayerWeapon *pWeapon, int id, int classId) -{ - if (pWeapon == NULL) - return false; - - const char *weaponName = GetWeaponAliasFromName(pWeapon->pszName()); - - if (id && AliasToWeaponID(weaponName) == id) - return true; - - if (classId && AliasToWeaponClass(weaponName) == classId) - return true; - - return false; -} - -void (*pCBasePlayer__PickPrimaryCareerTaskWeapon)(void); - -/* <15b1eb> ../cstrike/dlls/player.cpp:10623 */ -NOBODY const char __declspec(naked) *CBasePlayer::PickPrimaryCareerTaskWeapon(void) -{ - __asm - { - jmp pCBasePlayer__PickPrimaryCareerTaskWeapon - } -// { -// intconst BufLen; // 10625 -// char buf; // 10626 -// class CBasePlayerWeapon *primary; // 10632 -// class vector > taskVector; // 10634 -// CareerTaskListIt it; // 10635 -// vector(vector > *const this); // 10634 -// { -// class CCareerTask *pTask; // 10638 -// push_back(vector > *const this, -// const value_type &__x); // 10656 -// IsPrimaryWeaponId(int id); // 10644 -// CurrentWeaponSatisfies(CBasePlayerWeapon *pWeapon, -// int id, -// int classId); // 10647 -// IsPrimaryWeaponId(int id); // 10649 -// GetBuyStringForWeaponClass(int weaponClass); // 10652 -// } -// operator++(_List_iterator *const this); // 10636 -// { -// int taskNum; // 10664 -// class CCareerTask *temp; // 10666 -// operator[](vector > *const this, -// size_type __n); // 10667 -// } -// { -// int i; // 10673 -// { -// class CCareerTask *pTask; // 10675 -// IsPrimaryWeaponId(int id); // 10676 -// GetBuyStringForWeaponClass(int weaponClass); // 10682 -// } -// size(const class vector > *const this); // 10673 -// } -// ~vector(vector > *const this, -// intconst __in_chrg); // 10634 -// } -} - -void (*pCBasePlayer__PickSecondaryCareerTaskWeapon)(void); - -/* <15b5d7> ../cstrike/dlls/player.cpp:10690 */ -NOBODY const char __declspec(naked) *CBasePlayer::PickSecondaryCareerTaskWeapon(void) -{ - __asm - { - jmp pCBasePlayer__PickSecondaryCareerTaskWeapon - } -// { -// intconst BufLen; // 10692 -// char buf; // 10693 -// class CBasePlayerWeapon *secondary; // 10699 -// class vector > taskVector; // 10701 -// CareerTaskListIt it; // 10702 -// vector(vector > *const this); // 10701 -// { -// class CCareerTask *pTask; // 10705 -// IsSecondaryWeaponId(int id); // 10711 -// CurrentWeaponSatisfies(CBasePlayerWeapon *pWeapon, -// int id, -// int classId); // 10714 -// push_back(vector > *const this, -// const value_type &__x); // 10723 -// IsSecondaryWeaponId(int id); // 10716 -// GetBuyStringForWeaponClass(int weaponClass); // 10719 -// } -// operator++(_List_iterator *const this); // 10703 -// { -// int taskNum; // 10731 -// class CCareerTask *temp; // 10733 -// operator[](vector > *const this, -// size_type __n); // 10734 -// } -// { -// int i; // 10740 -// { -// class CCareerTask *pTask; // 10742 -// IsSecondaryWeaponId(int id); // 10743 -// } -// size(const class vector > *const this); // 10740 -// } -// ~vector(vector > *const this, -// intconst __in_chrg); // 10701 -// } -} - -/* <15b9ea> ../cstrike/dlls/player.cpp:10759 */ -const char *CBasePlayer::PickFlashKillWeaponString(void) -{ - bool foundOne = false; - - for (CareerTaskListIt it = TheCareerTasks->GetTasks()->begin(); it != TheCareerTasks->GetTasks()->end(); ++it) - { - CCareerTask *pTask = (*it); - - if (!pTask->IsComplete() && !Q_strcmp(pTask->GetTaskName(), "killblind")) - { - foundOne = true; - break; - } - } - - if (foundOne) - return "flash flash"; - - return NULL; -} - -/* <15baa1> ../cstrike/dlls/player.cpp:10787 */ -const char *CBasePlayer::PickGrenadeKillWeaponString(void) -{ - bool foundOne = false; - - for (CareerTaskListIt it = TheCareerTasks->GetTasks()->begin(); it != TheCareerTasks->GetTasks()->end(); ++it) - { - CCareerTask *pTask = (*it); - - if (!pTask->IsComplete() && pTask->GetWeaponId() == WEAPON_HEGRENADE) - { - foundOne = true; - break; - } - } - - if (foundOne) - return "hegren"; - - return NULL; -} - -/* <15bb0c> ../cstrike/dlls/player.cpp:10816 */ -void CBasePlayer::PrioritizeAutoBuyString(char *autobuyString, const char *priorityString) -{ - char newString[ MAX_AUTOBUY_LENGTH ]; - int newStringPos = 0; - char priorityToken[32]; - - if (!priorityString || !autobuyString) - return; - - const char *priorityChar = priorityString; - - while (*priorityChar != '\0') - { - int i = 0; - - while (*priorityChar != '\0' && *priorityChar != ' ') - { - priorityToken[ i++ ] = *priorityChar; - priorityChar++; - } - - priorityToken[i] = 0; - - while (*priorityChar == ' ') - priorityChar++; - - if (!Q_strlen(priorityToken)) - continue; - - char *autoBuyPosition = Q_strstr(autobuyString, priorityToken); - - if (autoBuyPosition != NULL) - { - while (*autoBuyPosition != '\0' && *autoBuyPosition != ' ') - { - newString[ newStringPos ] = *autoBuyPosition; - *autoBuyPosition = ' '; - - ++newStringPos; - ++autoBuyPosition; - } - - newString[ newStringPos++ ] = ' '; - } - } - - char *autobuyPosition = autobuyString; - - while (*autobuyPosition != '\0') - { - while (*autobuyPosition == ' ') - autobuyPosition++; - - while (*autobuyPosition != '\0' && *autobuyPosition != ' ') - { - newString[ newStringPos++ ] = *autobuyPosition; - autobuyPosition++; - } - - newString[ newStringPos++ ] = ' '; - } - - newString[ newStringPos ] = 0; - Q_sprintf(autobuyString, "%s", newString); -} - -/* <15bcd5> ../cstrike/dlls/player.cpp:10899 */ -void CBasePlayer::ParseAutoBuyString(const char *string, bool &boughtPrimary, bool &boughtSecondary) -{ - char command[32]; - const char *c = string; - - if (!string || !string[0]) - return; - - while (*c) - { - int i = 0; - - while (*c && (*c != ' ') && i < sizeof(command)) - { - command[i] = *c; - ++c; - ++i; - } - - if (*c == ' ') - ++c; - - command[i] = 0; - i = 0; - - while (command[i] != 0) - { - if (command[i] == ' ') - { - command[i] = 0; - break; - } - - ++i; - } - - if (!Q_strlen(command)) - continue; - - AutoBuyInfoStruct *commandInfo = GetAutoBuyCommandInfo(command); - if (ShouldExecuteAutoBuyCommand(commandInfo, boughtPrimary, boughtSecondary)) - { - ClientCommand(commandInfo->m_command); - PostAutoBuyCommandProcessing(commandInfo, boughtPrimary, boughtSecondary); - } - } -} - -/* <15bb6b> ../cstrike/dlls/player.cpp:10957 */ -bool CBasePlayer::ShouldExecuteAutoBuyCommand(AutoBuyInfoStruct *commandInfo, bool boughtPrimary, bool boughtSecondary) -{ - if (!commandInfo) - return false; - - if (boughtPrimary && (commandInfo->m_class & AUTOBUYCLASS_PRIMARY) != 0 && !(commandInfo->m_class & AUTOBUYCLASS_AMMO)) - return false; - - if (boughtSecondary && (commandInfo->m_class & AUTOBUYCLASS_SECONDARY) != 0 && !(commandInfo->m_class & AUTOBUYCLASS_AMMO)) - return false; - - return true; -} - -/* <15bbfa> ../cstrike/dlls/player.cpp:10978 */ -AutoBuyInfoStruct *CBasePlayer::GetAutoBuyCommandInfo(const char *command) -{ - int i = 0; - AutoBuyInfoStruct *ret = NULL; - AutoBuyInfoStruct *temp = NULL; - - while (ret == NULL) - { - temp = &(g_autoBuyInfo[ i ]); - - if (!temp->m_class) - break; - - if (Q_stricmp(temp->m_command, command) == 0) - ret = temp; - - i++; - } - - return ret; -} - -/* <15bc49> ../cstrike/dlls/player.cpp:11000 */ -void CBasePlayer::PostAutoBuyCommandProcessing(AutoBuyInfoStruct *commandInfo, bool &boughtPrimary, bool &boughtSecondary) -{ - CBasePlayerWeapon *primary = (CBasePlayerWeapon *)m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]; - CBasePlayerWeapon *secondary = (CBasePlayerWeapon *)m_rgpPlayerItems[ PISTOL_SLOT ]; - - if (!commandInfo) - return; - - if (primary != NULL && !Q_stricmp(STRING(primary->pev->classname), commandInfo->m_classname)) - boughtPrimary = true; - - else if (commandInfo->m_class & AUTOBUYCLASS_SHIELD && HasShield()) - boughtPrimary = true; - - else if (secondary != NULL && !Q_stricmp(STRING(secondary->pev->classname), commandInfo->m_classname)) - boughtSecondary = true; -} - -/* <15c0b4> ../cstrike/dlls/player.cpp:11027 */ -void CBasePlayer::BuildRebuyStruct(void) -{ - int iAmmoIndex; - - if (m_bIsInRebuy) - return; - - CBasePlayerWeapon *primary = (CBasePlayerWeapon *)m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]; - CBasePlayerWeapon *secondary = (CBasePlayerWeapon *)m_rgpPlayerItems[ PISTOL_SLOT ]; - - if (primary != NULL) - { - m_rebuyStruct.m_primaryWeapon = primary->m_iId; - m_rebuyStruct.m_primaryAmmo = m_rgAmmo[ primary->m_iPrimaryAmmoType ]; - } - else - { - m_rebuyStruct.m_primaryAmmo = 0; - - if (HasShield()) - m_rebuyStruct.m_primaryWeapon = WEAPON_SHIELDGUN; - else - m_rebuyStruct.m_primaryWeapon = 0; - } - - if (secondary != NULL) - { - m_rebuyStruct.m_secondaryWeapon = secondary->m_iId; - m_rebuyStruct.m_secondaryAmmo = m_rgAmmo[ secondary->m_iPrimaryAmmoType ]; - } - else - { - m_rebuyStruct.m_secondaryWeapon = 0; - m_rebuyStruct.m_secondaryAmmo = 0; - } - - iAmmoIndex = GetAmmoIndex("HEGrenade"); - - if (iAmmoIndex != -1) - m_rebuyStruct.m_heGrenade = m_rgAmmo[ iAmmoIndex ]; - else - m_rebuyStruct.m_heGrenade = 0; - - iAmmoIndex = GetAmmoIndex("Flashbang"); - - if (iAmmoIndex != -1) - m_rebuyStruct.m_flashbang = m_rgAmmo[ iAmmoIndex ]; - else - m_rebuyStruct.m_flashbang = 0; - - iAmmoIndex = GetAmmoIndex("SmokeGrenade"); - - if (iAmmoIndex != -1) - m_rebuyStruct.m_smokeGrenade = m_rgAmmo[ iAmmoIndex ]; - else - m_rebuyStruct.m_smokeGrenade = 0; - - m_rebuyStruct.m_defuser = m_bHasDefuser; - m_rebuyStruct.m_nightVision = m_bHasNightVision; - m_rebuyStruct.m_armor = m_iKevlar; -} - -/* <15c37d> ../cstrike/dlls/player.cpp:11134 */ -void CBasePlayer::Rebuy(void) -{ - char *fileData = m_rebuyString; - char *token; - - m_bIsInRebuy = true; - - while (true) - { - fileData = MP_COM_Parse(fileData); - token = MP_COM_GetToken(); - - if (!fileData) - break; - - if (!Q_stricmp(token, "primaryWeapon")) - RebuyPrimaryWeapon(); - else if (!Q_stricmp(token, "primaryAmmo")) - RebuyPrimaryAmmo(); - else if (!Q_stricmp(token, "secondaryWeapon")) - RebuySecondaryWeapon(); - else if (!Q_stricmp(token, "secondaryAmmo")) - RebuySecondaryAmmo(); - else if (!Q_stricmp(token, "hegrenade")) - RebuyHEGrenade(); - else if (!Q_stricmp(token, "flashbang")) - RebuyFlashbang(); - else if (!Q_stricmp(token, "smokegrenade")) - RebuySmokeGrenade(); - else if (!Q_stricmp(token, "defuser")) - RebuyDefuser(); - else if (!Q_stricmp(token, "nightvision")) - RebuyNightVision(); - else if (!Q_stricmp(token, "armor")) - RebuyArmor(); - } - - m_bIsInRebuy = false; - - if (TheTutor) - TheTutor->OnEvent(EVENT_PLAYER_LEFT_BUY_ZONE); -} - -/* <15c96a> ../cstrike/dlls/player.cpp:11200 */ -NOXREF void CBasePlayer::RebuyPrimaryWeapon(void) -{ - if (!m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]) - { - if (m_rebuyStruct.m_primaryWeapon) - { - const char *alias = WeaponIDToAlias(m_rebuyStruct.m_primaryWeapon); - - if (alias != NULL) - ClientCommand(alias); - } - } -} - -/* <15c9e4> ../cstrike/dlls/player.cpp:11217 */ -NOXREF void CBasePlayer::RebuyPrimaryAmmo(void) -{ - CBasePlayerWeapon *primary = (CBasePlayerWeapon *)m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]; - - if (primary != NULL) - { - if (m_rebuyStruct.m_primaryAmmo > m_rgAmmo[ primary->m_iPrimaryAmmoType ]) - ClientCommand("primammo"); - } -} - -/* <15ca68> ../cstrike/dlls/player.cpp:11233 */ -NOXREF void CBasePlayer::RebuySecondaryWeapon(void) -{ - if (m_rebuyStruct.m_secondaryWeapon) - { - const char *alias = WeaponIDToAlias(m_rebuyStruct.m_secondaryWeapon); - - if (alias != NULL) - ClientCommand(alias); - } -} - -/* <15cae2> ../cstrike/dlls/player.cpp:11245 */ -NOXREF void CBasePlayer::RebuySecondaryAmmo(void) -{ - CBasePlayerWeapon *secondary = (CBasePlayerWeapon *)m_rgpPlayerItems[ PISTOL_SLOT ]; - - if (secondary) - { - if (m_rebuyStruct.m_secondaryAmmo > m_rgAmmo[ secondary->m_iPrimaryAmmoType ]) - ClientCommand("secammo"); - } -} - -/* <15cb66> ../cstrike/dlls/player.cpp:11259 */ -NOXREF void CBasePlayer::RebuyHEGrenade(void) -{ - int iAmmoIndex = GetAmmoIndex("HEGrenade"); - - if (iAmmoIndex == -1) - return; - - int numToBuy = m_rebuyStruct.m_heGrenade - m_rgAmmo[ iAmmoIndex ]; - - for (int i = 0; i < numToBuy; i++) - ClientCommand("hegren"); -} - -/* <15cc3f> ../cstrike/dlls/player.cpp:11279 */ -NOXREF void CBasePlayer::RebuyFlashbang(void) -{ - int iAmmoIndex = GetAmmoIndex("Flashbang"); - - if (iAmmoIndex == -1) - return; - - int numToBuy = m_rebuyStruct.m_flashbang - m_rgAmmo[ iAmmoIndex ]; - - for (int i = 0; i < numToBuy; i++) - ClientCommand("flash"); -} - -/* <15cd18> ../cstrike/dlls/player.cpp:11299 */ -NOXREF void CBasePlayer::RebuySmokeGrenade(void) -{ - int iAmmoIndex = GetAmmoIndex("SmokeGrenade"); - - if (iAmmoIndex == -1) - return; - - int numToBuy = m_rebuyStruct.m_smokeGrenade - m_rgAmmo[ iAmmoIndex ]; - - for (int i = 0; i < numToBuy; i++) - ClientCommand("sgren"); -} - -/* <15cdf1> ../cstrike/dlls/player.cpp:11319 */ -void CBasePlayer::RebuyDefuser(void) -{ - if (m_rebuyStruct.m_defuser) - { - if (!m_bHasDefuser) - ClientCommand("defuser"); - } -} - -/* <15ce59> ../cstrike/dlls/player.cpp:11330 */ -void CBasePlayer::RebuyNightVision(void) -{ - if (m_rebuyStruct.m_nightVision) - { - if (!m_bHasNightVision) - ClientCommand("nvgs"); - } -} - -/* <15cec1> ../cstrike/dlls/player.cpp:11341 */ -void CBasePlayer::RebuyArmor(void) -{ - if (m_rebuyStruct.m_armor) - { - if (m_rebuyStruct.m_armor > m_iKevlar) - { - if (m_rebuyStruct.m_armor == ARMOR_TYPE_KEVLAR) - ClientCommand("vest"); - else - ClientCommand("vesthelm"); - } - } -} - -/* <15cf7c> ../cstrike/dlls/player.cpp:11366 */ -bool CBasePlayer::IsObservingPlayer(CBasePlayer *pPlayer) -{ - if (!pPlayer || pev->flags == FL_DORMANT) - return false; - - if (FNullEnt(pPlayer)) - return false; - - return (IsObserver() == OBS_IN_EYE && pev->iuser2 == pPlayer->entindex()) != 0; -} - -/* <15d049> ../cstrike/dlls/player.cpp:11380 */ -void CBasePlayer::UpdateLocation(bool forceUpdate) -{ - if (!forceUpdate && m_flLastUpdateTime >= gpGlobals->time + 2) - return; - - const char *placeName = ""; - - if (pev->deadflag == DEAD_NO && UTIL_IsGame("czero")) - { - // search the place name where is located the player - Place playerPlace = TheNavAreaGrid.GetPlace(&pev->origin); - const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); - - for (BotPhraseList::const_iterator iter = placeList->begin(); iter != placeList->end(); ++iter) - { - if ((*iter)->GetID() == playerPlace) - { - placeName = (*iter)->GetName(); - break; - } - } - } - - if (!placeName[0] || (m_lastLocation[0] && !Q_strcmp(placeName, &m_lastLocation[1]))) - { - return; - } - - m_flLastUpdateTime = gpGlobals->time; - Q_snprintf(m_lastLocation, sizeof(m_lastLocation), "#%s", placeName); - - for (int i = 1; i <= gpGlobals->maxClients; i++) - { - CBasePlayer *player = (CBasePlayer *)UTIL_PlayerByIndex(i); - - if (!player) - continue; - - if (player->m_iTeam == m_iTeam || player->m_iTeam == SPECTATOR) - { - MESSAGE_BEGIN(MSG_ONE, gmsgLocation, NULL, player->edict()); - WRITE_BYTE(entindex()); - WRITE_STRING(m_lastLocation); - MESSAGE_END(); - } - else if (forceUpdate) - { - MESSAGE_BEGIN(MSG_ONE, gmsgLocation, NULL, player->edict()); - WRITE_BYTE(entindex()); - WRITE_STRING(""); - MESSAGE_END(); - } - } -} - -#ifdef HOOK_GAMEDLL - -void CBasePlayer::Spawn(void) -{ - Spawn_(); -} - -void CBasePlayer::Precache(void) -{ - Precache_(); -} - -int CBasePlayer::Save(CSave &save) -{ - return Save_(save); -} - -int CBasePlayer::Restore(CRestore &restore) -{ - return Restore_(restore); -} - -int CBasePlayer::Classify(void) -{ - return Classify_(); -} - -void CBasePlayer::TraceAttack(entvars_t *pevAttacker,float flDamage,Vector vecDir,TraceResult *ptr,int bitsDamageType) -{ - TraceAttack_(pevAttacker,flDamage,vecDir,ptr,bitsDamageType); -} - -int CBasePlayer::TakeDamage(entvars_t *pevInflictor,entvars_t *pevAttacker,float flDamage,int bitsDamageType) -{ - return TakeDamage_(pevInflictor,pevAttacker,flDamage,bitsDamageType); -} - -int CBasePlayer::TakeHealth(float flHealth,int bitsDamageType) -{ - return TakeHealth_(flHealth,bitsDamageType); -} - -void CBasePlayer::Killed(entvars_t *pevAttacker,int iGib) -{ - Killed_(pevAttacker,iGib); -} - -void CBasePlayer::AddPoints(int score,BOOL bAllowNegativeScore) -{ - AddPoints_(score,bAllowNegativeScore); -} - -void CBasePlayer::AddPointsToTeam(int score,BOOL bAllowNegativeScore) -{ - AddPointsToTeam_(score,bAllowNegativeScore); -} - -BOOL CBasePlayer::AddPlayerItem(CBasePlayerItem *pItem) -{ - return AddPlayerItem_(pItem); -} - -BOOL CBasePlayer::RemovePlayerItem(CBasePlayerItem *pItem) -{ - return RemovePlayerItem_(pItem); -} - -int CBasePlayer::GiveAmmo(int iAmount,char *szName,int iMax) -{ - return GiveAmmo_(iAmount,szName,iMax); -} - -const char *CBasePlayer::TeamID(void) -{ - return TeamID_(); -} - -BOOL CBasePlayer::FBecomeProne(void) -{ - return FBecomeProne_(); -} - -int CBasePlayer::Illumination(void) -{ - return Illumination_(); -} - -void CBasePlayer::ResetMaxSpeed(void) -{ - ResetMaxSpeed_(); -} - -void CBasePlayer::Jump(void) -{ - Jump_(); -} - -void CBasePlayer::Duck(void) -{ - Duck_(); -} - -void CBasePlayer::PreThink(void) -{ - PreThink_(); -} - -void CBasePlayer::PostThink(void) -{ - PostThink_(); -} - -Vector CBasePlayer::GetGunPosition(void) -{ - return GetGunPosition_(); -} - -void CBasePlayer::UpdateClientData(void) -{ - UpdateClientData_(); -} - -void CBasePlayer::ImpulseCommands(void) -{ - ImpulseCommands_(); -} - -void CBasePlayer::RoundRespawn(void) -{ - RoundRespawn_(); -} - -Vector CBasePlayer::GetAutoaimVector(float flDelta) -{ - return GetAutoaimVector_(flDelta); -} - -void CBasePlayer::Blind(float flUntilTime,float flHoldTime,float flFadeTime,int iAlpha) -{ - Blind_(flUntilTime,flHoldTime,flFadeTime,iAlpha); -} - -void CStripWeapons::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ - Use_(pActivator, pCaller, useType, value); -} - -void CRevertSaved::KeyValue(KeyValueData *pkvd) -{ - KeyValue_(pkvd); -} - -int CRevertSaved::Save(CSave &save) -{ - return Save_(save); -} - -int CRevertSaved::Restore(CRestore &restore) -{ - return Restore_(restore); -} - -void CRevertSaved::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) -{ - Use_(pActivator, pCaller, useType, value); -} - -void CDeadHEV::Spawn(void) -{ - Spawn_(); -} - -void CDeadHEV::KeyValue(KeyValueData *pkvd) -{ - KeyValue_(pkvd); -} - -int CDeadHEV::Classify(void) -{ - return Classify_(); -} - -void CSprayCan::Think(void) -{ - Think_(); -} - -void CInfoIntermission::Spawn(void) -{ - Spawn_(); -} - -void CInfoIntermission::Think(void) -{ - Think_(); -} - -void CWShield::Spawn(void) -{ - Spawn_(); -} - -void CWShield::Touch(CBaseEntity *pOther) -{ - Touch_(pOther); - -} - -#endif // HOOK_GAMEDLL +#include "precompiled.h" + +#define DEFINE_WEAPON(m_wpnid, m_cost, m_slotnum, m_acost)\ + { m_wpnid, m_cost, 3, m_slotnum, m_acost } + +/* +* Globals initialization +*/ +#ifndef HOOK_GAMEDLL + +int giPrecacheGrunt = 0; +int gmsgFlashlight = 0; +int gmsgFlashBattery = 0; +int gmsgResetHUD = 0; +int gmsgInitHUD = 0; +int gmsgViewMode = 0; +int gmsgShowGameTitle = 0; +int gmsgCurWeapon = 0; +int gmsgHealth = 0; +int gmsgDamage = 0; +int gmsgBattery = 0; +int gmsgTrain = 0; +int gmsgLogo = 0; +int gmsgWeaponList = 0; +int gmsgAmmoX = 0; +int gmsgDeathMsg = 0; +int gmsgScoreAttrib = 0; +int gmsgScoreInfo = 0; +int gmsgTeamInfo = 0; +int gmsgTeamScore = 0; +int gmsgGameMode = 0; +int gmsgMOTD = 0; +int gmsgServerName = 0; +int gmsgAmmoPickup = 0; +int gmsgItemPickup = 0; +int gmsgHideWeapon = 0; +int gmsgSayText = 0; +int gmsgTextMsg = 0; +int gmsgSetFOV = 0; +int gmsgShowMenu = 0; +int gmsgSendAudio = 0; +int gmsgRoundTime = 0; +int gmsgMoney = 0; +int gmsgBlinkAcct = 0; +int gmsgArmorType = 0; +int gmsgStatusValue = 0; +int gmsgStatusText = 0; +int gmsgStatusIcon = 0; +int gmsgBarTime = 0; +int gmsgReloadSound = 0; +int gmsgCrosshair = 0; +int gmsgNVGToggle = 0; +int gmsgRadar = 0; +int gmsgSpectator = 0; +int gmsgVGUIMenu = 0; +int gmsgCZCareer = 0; +int gmsgCZCareerHUD = 0; +int gmsgTaskTime = 0; +int gmsgTutorText = 0; +int gmsgTutorLine = 0; +int gmsgShadowIdx = 0; +int gmsgTutorState = 0; +int gmsgTutorClose = 0; +int gmsgAllowSpec = 0; +int gmsgBombDrop = 0; +int gmsgBombPickup = 0; +int gmsgHostagePos = 0; +int gmsgHostageK = 0; +int gmsgGeigerRange = 0; +int gmsgSendCorpse = 0; +int gmsgHLTV = 0; +int gmsgSpecHealth = 0; +int gmsgForceCam = 0; +int gmsgADStop = 0; +int gmsgReceiveW = 0; +int gmsgScenarioIcon = 0; +int gmsgBotVoice = 0; +int gmsgBuyClose = 0; +int gmsgItemStatus = 0; +int gmsgLocation = 0; +int gmsgSpecHealth2 = 0; +int gmsgBarTime2 = 0; +int gmsgBotProgress = 0; +int gmsgBrass = 0; +int gmsgFog = 0; +int gmsgShowTimer = 0; + +BOOL gInitHUD = TRUE; +cvar_t *sv_aim = NULL; + +TYPEDESCRIPTION CRevertSaved::m_SaveData[] = +{ + DEFINE_FIELD(CRevertSaved, m_messageTime, FIELD_FLOAT), + DEFINE_FIELD(CRevertSaved, m_loadTime, FIELD_FLOAT), +}; + +TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] = +{ + DEFINE_FIELD(CBasePlayer, m_flFlashLightTime, FIELD_TIME), + DEFINE_FIELD(CBasePlayer, m_iFlashBattery, FIELD_INTEGER), + DEFINE_FIELD(CBasePlayer, m_afButtonLast, FIELD_INTEGER), + DEFINE_FIELD(CBasePlayer, m_afButtonPressed, FIELD_INTEGER), + DEFINE_FIELD(CBasePlayer, m_afButtonReleased, FIELD_INTEGER), + DEFINE_ARRAY(CBasePlayer, m_rgItems, FIELD_INTEGER, MAX_ITEMS), + DEFINE_FIELD(CBasePlayer, m_afPhysicsFlags, FIELD_INTEGER), + DEFINE_FIELD(CBasePlayer, m_flTimeStepSound, FIELD_TIME), + DEFINE_FIELD(CBasePlayer, m_flTimeWeaponIdle, FIELD_TIME), + DEFINE_FIELD(CBasePlayer, m_flSwimTime, FIELD_TIME), + DEFINE_FIELD(CBasePlayer, m_flDuckTime, FIELD_TIME), + DEFINE_FIELD(CBasePlayer, m_flWallJumpTime, FIELD_TIME), + DEFINE_FIELD(CBasePlayer, m_flSuitUpdate, FIELD_TIME), + DEFINE_ARRAY(CBasePlayer, m_rgSuitPlayList, FIELD_INTEGER, CSUITPLAYLIST), + DEFINE_FIELD(CBasePlayer, m_iSuitPlayNext, FIELD_INTEGER), + DEFINE_ARRAY(CBasePlayer, m_rgiSuitNoRepeat, FIELD_INTEGER, CSUITNOREPEAT), + DEFINE_ARRAY(CBasePlayer, m_rgflSuitNoRepeatTime, FIELD_TIME, CSUITNOREPEAT), + DEFINE_FIELD(CBasePlayer, m_lastDamageAmount, FIELD_INTEGER), + DEFINE_ARRAY(CBasePlayer, m_rgpPlayerItems, FIELD_CLASSPTR, MAX_ITEM_TYPES), + DEFINE_FIELD(CBasePlayer, m_pActiveItem, FIELD_CLASSPTR), + DEFINE_FIELD(CBasePlayer, m_pLastItem, FIELD_CLASSPTR), + DEFINE_ARRAY(CBasePlayer, m_rgAmmo, FIELD_INTEGER, MAX_AMMO_SLOTS), + DEFINE_FIELD(CBasePlayer, m_idrowndmg, FIELD_INTEGER), + DEFINE_FIELD(CBasePlayer, m_idrownrestored, FIELD_INTEGER), + DEFINE_FIELD(CBasePlayer, m_tSneaking, FIELD_TIME), + DEFINE_FIELD(CBasePlayer, m_iTrain, FIELD_INTEGER), + DEFINE_FIELD(CBasePlayer, m_bitsHUDDamage, FIELD_INTEGER), + DEFINE_FIELD(CBasePlayer, m_flFallVelocity, FIELD_FLOAT), + DEFINE_FIELD(CBasePlayer, m_iTargetVolume, FIELD_INTEGER), + DEFINE_FIELD(CBasePlayer, m_iWeaponVolume, FIELD_INTEGER), + DEFINE_FIELD(CBasePlayer, m_iExtraSoundTypes, FIELD_INTEGER), + DEFINE_FIELD(CBasePlayer, m_iWeaponFlash, FIELD_INTEGER), + DEFINE_FIELD(CBasePlayer, m_fLongJump, FIELD_BOOLEAN), + DEFINE_FIELD(CBasePlayer, m_fInitHUD, FIELD_BOOLEAN), + DEFINE_FIELD(CBasePlayer, m_tbdPrev, FIELD_TIME), + DEFINE_FIELD(CBasePlayer, m_pTank, FIELD_EHANDLE), + DEFINE_FIELD(CBasePlayer, m_iHideHUD, FIELD_INTEGER), + DEFINE_FIELD(CBasePlayer, m_iFOV, FIELD_INTEGER), + DEFINE_FIELD(CBasePlayer, m_flDisplayHistory, FIELD_INTEGER), + DEFINE_FIELD(CBasePlayer, m_iJoiningState, FIELD_INTEGER), +}; + +WeaponStruct g_weaponStruct[ MAX_WEAPONS ] = +{ + { 0, 0, 0, 0, 0 }, + + { WEAPON_P228, P228_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_357SIG_PRICE }, + { WEAPON_SCOUT, SCOUT_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_762MM_PRICE }, + { WEAPON_XM1014, XM1014_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_BUCKSHOT_PRICE }, + { WEAPON_MAC10, MAC10_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_45ACP_PRICE }, + { WEAPON_AUG, AUG_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, + { WEAPON_ELITE, ELITE_PRICE, CT, AUTOBUYCLASS_SECONDARY, AMMO_9MM_PRICE }, + { WEAPON_FIVESEVEN, FIVESEVEN_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_57MM_PRICE }, + { WEAPON_UMP45, UMP45_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_45ACP_PRICE }, + { WEAPON_SG550, SG550_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, + { WEAPON_USP, USP_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_45ACP_PRICE }, + { WEAPON_GLOCK18, GLOCK18_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_9MM_PRICE }, + { WEAPON_MP5N, MP5NAVY_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_9MM_PRICE }, + { WEAPON_AWP, AWP_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_338MAG_PRICE }, + { WEAPON_M249, M249_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, + { WEAPON_M3, M3_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_BUCKSHOT_PRICE }, + { WEAPON_M4A1, M4A1_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, + { WEAPON_TMP, TMP_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_9MM_PRICE }, + { WEAPON_G3SG1, G3SG1_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_762MM_PRICE }, + { WEAPON_DEAGLE, DEAGLE_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_50AE_PRICE }, + { WEAPON_SG552, SG552_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, + { WEAPON_AK47, AK47_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_762MM_PRICE }, + { WEAPON_P90, P90_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_57MM_PRICE }, + { WEAPON_FAMAS, FAMAS_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, + { WEAPON_GALIL, GALIL_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, + // TODO: this have bug, the cost of galil $2000, but not $2250 + + { WEAPON_SHIELDGUN, SHIELDGUN_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, 0 }, + + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0 } +}; + +char *CDeadHEV::m_szPoses[] = +{ + "deadback", + "deadsitting", + "deadstomach", + "deadtable" +}; + +#else //HOOK_GAMEDLL + +int giPrecacheGrunt; +int gmsgWeapPickup; +int gmsgHudText; +int gmsgHudTextArgs; +int gmsgShake; +int gmsgFade; +int gmsgFlashlight; +int gmsgFlashBattery; +int gmsgResetHUD; +int gmsgInitHUD; +int gmsgViewMode; +int gmsgShowGameTitle; +int gmsgCurWeapon; +int gmsgHealth; +int gmsgDamage; +int gmsgBattery; +int gmsgTrain; +int gmsgLogo; +int gmsgWeaponList; +int gmsgAmmoX; +int gmsgDeathMsg; +int gmsgScoreAttrib; +int gmsgScoreInfo; +int gmsgTeamInfo; +int gmsgTeamScore; +int gmsgGameMode; +int gmsgMOTD; +int gmsgServerName; +int gmsgAmmoPickup; +int gmsgItemPickup; +int gmsgHideWeapon; +int gmsgSayText; +int gmsgTextMsg; +int gmsgSetFOV; +int gmsgShowMenu; +int gmsgSendAudio; +int gmsgRoundTime; +int gmsgMoney; +int gmsgBlinkAcct; +int gmsgArmorType; +int gmsgStatusValue; +int gmsgStatusText; +int gmsgStatusIcon; +int gmsgBarTime; +int gmsgReloadSound; +int gmsgCrosshair; +int gmsgNVGToggle; +int gmsgRadar; +int gmsgSpectator; +int gmsgVGUIMenu; +int gmsgCZCareer; +int gmsgCZCareerHUD; +int gmsgTaskTime; +int gmsgTutorText; +int gmsgTutorLine; +int gmsgShadowIdx; +int gmsgTutorState; +int gmsgTutorClose; +int gmsgAllowSpec; +int gmsgBombDrop; +int gmsgBombPickup; +int gmsgHostagePos; +int gmsgHostageK; +int gmsgGeigerRange; +int gmsgSendCorpse; +int gmsgHLTV; +int gmsgSpecHealth; +int gmsgForceCam; +int gmsgADStop; +int gmsgReceiveW; +int gmsgScenarioIcon; +int gmsgBotVoice; +int gmsgBuyClose; +int gmsgItemStatus; +int gmsgLocation; +int gmsgSpecHealth2; +int gmsgBarTime2; +int gmsgBotProgress; +int gmsgBrass; +int gmsgFog; +int gmsgShowTimer; + +BOOL gInitHUD; +cvar_t *sv_aim; + +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CRevertSaved, m_SaveData)[2]; +TYPEDESCRIPTION IMPLEMENT_ARRAY_CLASS(CBasePlayer, m_playerSaveData)[40]; +WeaponStruct g_weaponStruct[ MAX_WEAPONS ]; +char *(*CDeadHEV::pm_szPoses)[4]; + +#endif //HOOK_GAMEDLL + +//int giPrecacheGrunt; +int gEvilImpulse101; +char g_szMapBriefingText[512]; + +entvars_t *g_pevLastInflictor; +CBaseEntity *g_pLastSpawn; +CBaseEntity *g_pLastCTSpawn; +CBaseEntity *g_pLastTerroristSpawn; + +/* <14e3fc> ../cstrike/dlls/player.cpp:5868 */ +struct ZombieSpawn +{ + CBaseEntity *entity; + CountdownTimer useableTimer; + +};/* size: 12, cachelines: 1, members: 2 */ + +ZombieSpawn zombieSpawn[256]; +int zombieSpawnCount; + +/* <15353b> ../cstrike/dlls/player.cpp:282 */ +void LinkUserMessages(void) +{ + if (gmsgCurWeapon) + return; + + gmsgCurWeapon = REG_USER_MSG("CurWeapon", 3); + gmsgGeigerRange = REG_USER_MSG("Geiger", 1); + gmsgFlashlight = REG_USER_MSG("Flashlight", 2); + gmsgFlashBattery = REG_USER_MSG("FlashBat", 1); + gmsgHealth = REG_USER_MSG("Health", 1); + gmsgDamage = REG_USER_MSG("Damage", 12); + gmsgBattery = REG_USER_MSG("Battery", 2); + gmsgTrain = REG_USER_MSG("Train", 1); + gmsgHudText = REG_USER_MSG("HudTextPro", -1); + REG_USER_MSG("HudText", -1); + gmsgSayText = REG_USER_MSG("SayText", -1); + gmsgTextMsg = REG_USER_MSG("TextMsg", -1); + gmsgWeaponList = REG_USER_MSG("WeaponList", -1); + gmsgResetHUD = REG_USER_MSG("ResetHUD", 0); + gmsgInitHUD = REG_USER_MSG("InitHUD", 0); + gmsgViewMode = REG_USER_MSG("ViewMode", 0); + gmsgShowGameTitle = REG_USER_MSG("GameTitle", 1); + gmsgDeathMsg = REG_USER_MSG("DeathMsg", -1); + gmsgScoreAttrib = REG_USER_MSG("ScoreAttrib", 2); + gmsgScoreInfo = REG_USER_MSG("ScoreInfo", 9); + gmsgTeamInfo = REG_USER_MSG("TeamInfo", -1); + gmsgTeamScore = REG_USER_MSG("TeamScore", -1); + gmsgGameMode = REG_USER_MSG("GameMode", 1); + gmsgMOTD = REG_USER_MSG("MOTD", -1); + gmsgServerName = REG_USER_MSG("ServerName", -1); + gmsgAmmoPickup = REG_USER_MSG("AmmoPickup", 2); + gmsgWeapPickup = REG_USER_MSG("WeapPickup", 1); + gmsgItemPickup = REG_USER_MSG("ItemPickup", -1); + gmsgHideWeapon = REG_USER_MSG("HideWeapon", 1); + gmsgSetFOV = REG_USER_MSG("SetFOV", 1); + gmsgShowMenu = REG_USER_MSG("ShowMenu", -1); + gmsgShake = REG_USER_MSG("ScreenShake", 6); + gmsgFade = REG_USER_MSG("ScreenFade", 10); + gmsgAmmoX = REG_USER_MSG("AmmoX", 2); + gmsgSendAudio = REG_USER_MSG("SendAudio", -1); + gmsgRoundTime = REG_USER_MSG("RoundTime", 2); + gmsgMoney = REG_USER_MSG("Money", 5); + gmsgArmorType = REG_USER_MSG("ArmorType", 1); + gmsgBlinkAcct = REG_USER_MSG("BlinkAcct", 1); + gmsgStatusValue = REG_USER_MSG("StatusValue", -1); + gmsgStatusText = REG_USER_MSG("StatusText", -1); + gmsgStatusIcon = REG_USER_MSG("StatusIcon", -1); + gmsgBarTime = REG_USER_MSG("BarTime", 2); + gmsgReloadSound = REG_USER_MSG("ReloadSound", 2); + gmsgCrosshair = REG_USER_MSG("Crosshair", 1); + gmsgNVGToggle = REG_USER_MSG("NVGToggle", 1); + gmsgRadar = REG_USER_MSG("Radar", 7); + gmsgSpectator = REG_USER_MSG("Spectator", 2); + gmsgVGUIMenu = REG_USER_MSG("VGUIMenu", -1); + gmsgTutorText = REG_USER_MSG("TutorText", -1); + gmsgTutorLine = REG_USER_MSG("TutorLine", -1); + gmsgTutorState = REG_USER_MSG("TutorState", -1); + gmsgTutorClose = REG_USER_MSG("TutorClose", -1); + gmsgAllowSpec = REG_USER_MSG("AllowSpec", 1); + gmsgBombDrop = REG_USER_MSG("BombDrop", 7); + gmsgBombPickup = REG_USER_MSG("BombPickup", 0); + gmsgSendCorpse = REG_USER_MSG("ClCorpse", -1); + gmsgHostagePos = REG_USER_MSG("HostagePos", 8); + gmsgHostageK = REG_USER_MSG("HostageK", 1); + gmsgHLTV = REG_USER_MSG("HLTV", 2); + gmsgSpecHealth = REG_USER_MSG("SpecHealth", 1); + gmsgForceCam = REG_USER_MSG("ForceCam", 3); + gmsgADStop = REG_USER_MSG("ADStop", 0); + gmsgReceiveW = REG_USER_MSG("ReceiveW", 1); + gmsgCZCareer = REG_USER_MSG("CZCareer", -1); + gmsgCZCareerHUD = REG_USER_MSG("CZCareerHUD", -1); + gmsgShadowIdx = REG_USER_MSG("ShadowIdx", 4); + gmsgTaskTime = REG_USER_MSG("TaskTime", 4); + gmsgScenarioIcon = REG_USER_MSG("Scenario", -1); + gmsgBotVoice = REG_USER_MSG("BotVoice", 2); + gmsgBuyClose = REG_USER_MSG("BuyClose", 0); + gmsgSpecHealth2 = REG_USER_MSG("SpecHealth2", 2); + gmsgBarTime2 = REG_USER_MSG("BarTime2", 4); + gmsgItemStatus = REG_USER_MSG("ItemStatus", 1); + gmsgLocation = REG_USER_MSG("Location", -1); + gmsgBotProgress = REG_USER_MSG("BotProgress", -1); + gmsgBrass = REG_USER_MSG("Brass", -1); + gmsgFog = REG_USER_MSG("Fog", 7); + gmsgShowTimer = REG_USER_MSG("ShowTimer", 0); + gmsgHudTextArgs = REG_USER_MSG("HudTextArgs", -1); +} + +/* <1535a5> ../cstrike/dlls/player.cpp:380 */ +void WriteSigonMessages(void) +{ + for (int i = 0; i < MAX_WEAPONS; i++) + { + ItemInfo &II = IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, ItemInfoArray)[i]; + + if (!II.iId) + continue; + + const char *pszName; + if (!II.pszName) + pszName = "Empty"; + else + pszName = II.pszName; + + MESSAGE_BEGIN(MSG_INIT, gmsgWeaponList); + WRITE_STRING(pszName); + WRITE_BYTE(CBasePlayer::GetAmmoIndex(II.pszAmmo1)); + WRITE_BYTE(II.iMaxAmmo1); + WRITE_BYTE(CBasePlayer::GetAmmoIndex(II.pszAmmo2)); + WRITE_BYTE(II.iMaxAmmo2); + WRITE_BYTE(II.iSlot); + WRITE_BYTE(II.iPosition); + WRITE_BYTE(II.iId); + WRITE_BYTE(II.iFlags); + MESSAGE_END(); + } +} + +/* <15f281> ../cstrike/dlls/player.cpp:425 */ +LINK_ENTITY_TO_CLASS(player, CBasePlayer); + +/* <1536a9> ../cstrike/dlls/player.cpp:429 */ +void SendItemStatus(CBasePlayer *pPlayer) +{ + int itemStatus = 0; + if (pPlayer->m_bHasNightVision) + itemStatus |= ITEM_STATUS_NIGHTVISION; + + if (pPlayer->m_bHasDefuser) + itemStatus |= ITEM_STATUS_DEFUSER; + + MESSAGE_BEGIN(MSG_ONE, gmsgItemStatus, NULL, pPlayer->pev); + WRITE_BYTE(itemStatus); + MESSAGE_END(); +} + +/* <150ed5> ../cstrike/dlls/player.cpp:438 */ +const char *GetCSModelName(int item_id) +{ + const char *modelName = NULL; + switch (item_id) + { + case WEAPON_P228: modelName = "models/w_p228.mdl"; break; + case WEAPON_SCOUT: modelName = "models/w_scout.mdl"; break; + case WEAPON_HEGRENADE: modelName = "models/w_hegrenade.mdl"; break; + case WEAPON_XM1014: modelName = "models/w_xm1014.mdl"; break; + case WEAPON_C4: modelName = "models/w_backpack.mdl"; break; + case WEAPON_MAC10: modelName = "models/w_mac10.mdl"; break; + case WEAPON_AUG: modelName = "models/w_aug.mdl"; break; + case WEAPON_SMOKEGRENADE: modelName = "models/w_smokegrenade.mdl"; break; + case WEAPON_ELITE: modelName = "models/w_elite.mdl"; break; + case WEAPON_FIVESEVEN: modelName = "models/w_fiveseven.mdl"; break; + case WEAPON_UMP45: modelName = "models/w_ump45.mdl"; break; + case WEAPON_SG550: modelName = "models/w_sg550.mdl"; break; + case WEAPON_GALIL: modelName = "models/w_galil.mdl"; break; + case WEAPON_FAMAS: modelName = "models/w_famas.mdl"; break; + case WEAPON_USP: modelName = "models/w_usp.mdl"; break; + case WEAPON_GLOCK18: modelName = "models/w_glock18.mdl"; break; + case WEAPON_AWP: modelName = "models/w_awp.mdl"; break; + case WEAPON_MP5N: modelName = "models/w_mp5.mdl"; break; + case WEAPON_M249: modelName = "models/w_m249.mdl"; break; + case WEAPON_M3: modelName = "models/w_m3.mdl"; break; + case WEAPON_M4A1: modelName = "models/w_m4a1.mdl"; break; + case WEAPON_TMP: modelName = "models/w_tmp.mdl"; break; + case WEAPON_G3SG1: modelName = "models/w_g3sg1.mdl"; break; + case WEAPON_FLASHBANG: modelName = "models/w_flashbang.mdl"; break; + case WEAPON_DEAGLE: modelName = "models/w_deagle.mdl"; break; + case WEAPON_SG552: modelName = "models/w_sg552.mdl"; break; + case WEAPON_AK47: modelName = "models/w_ak47.mdl"; break; + case WEAPON_KNIFE: modelName = "models/w_knife.mdl"; break; + case WEAPON_P90: modelName = "models/w_p90.mdl"; break; + case WEAPON_SHIELDGUN: modelName = "models/w_shield.mdl"; break; + default: + ALERT(at_console, "CBasePlayer::PackDeadPlayerItems(): Unhandled item- not creating weaponbox\n"); + } + + return modelName; +} + +/* <153737> ../cstrike/dlls/player.cpp:572 */ +void CBasePlayer::SetPlayerModel(BOOL HasC4) +{ + char *infobuffer = GET_INFO_BUFFER(edict()); + char *model; + + if (m_iTeam == CT) + { + switch (m_iModelName) + { + case MODEL_URBAN: + model = "urban"; + break; + case MODEL_GSG9: + model = "gsg9"; + break; + case MODEL_GIGN: + model = "gign"; + break; + case MODEL_SAS: + model = "sas"; + break; + case MODEL_VIP: + model = "vip"; + break; + case MODEL_SPETSNAZ: + if (UTIL_IsGame("czero")) + { + model = "spetsnaz"; + break; + } + default: + { + if (IsBot()) + { + model = (char *)TheBotProfiles->GetCustomSkinModelname(m_iModelName); + if (!model) + model = "urban"; + } + else + model = "urban"; + + break; + } + } + } + else if (m_iTeam == TERRORIST) + { + switch (m_iModelName) + { + case MODEL_TERROR: + model = "terror"; + break; + case MODEL_LEET: + model = "leet"; + break; + case MODEL_ARCTIC: + model = "arctic"; + break; + case MODEL_GUERILLA: + model = "guerilla"; + break; + case MODEL_MILITIA: + if (UTIL_IsGame("czero")) + { + model = "militia"; + break; + } + default: + { + if (IsBot()) + { + model = (char *)TheBotProfiles->GetCustomSkinModelname(m_iModelName); + if (!model) + model = "terror"; + } + else + model = "terror"; + + break; + } + } + } + else + model = "urban"; + + if (Q_strcmp(GET_KEY_VALUE(infobuffer, "model"), model)) + { + SET_CLIENT_KEY_VALUE(entindex(), infobuffer, "model", model); + } +} + +/* <15f129> ../cstrike/dlls/player.cpp:659 */ +NOXREF CBasePlayer *CBasePlayer::GetNextRadioRecipient(CBasePlayer *pStartPlayer) +{ + CBaseEntity *pEntity = (CBaseEntity *)pStartPlayer; + while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")) != NULL) + { + if (FNullEnt(pEntity->edict())) + break; + + BOOL bSend = FALSE; + CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pEntity->pev); + + if (pEntity->IsPlayer()) + { + if (pEntity->IsDormant()) + continue; + + if (pPlayer && pPlayer->m_iTeam == m_iTeam) + bSend = TRUE; + } + else if (pPlayer) + { + int iSpecMode = IsObserver(); + + if (iSpecMode != OBS_CHASE_LOCKED && iSpecMode != OBS_CHASE_FREE && iSpecMode != OBS_IN_EYE) + continue; + + if (!FNullEnt(m_hObserverTarget)) + continue; + + CBasePlayer *pTarget = (CBasePlayer *)CBaseEntity::Instance(pPlayer->m_hObserverTarget->pev); + + if (pTarget && pTarget->m_iTeam == m_iTeam) + { + bSend = TRUE; + } + } + + if (bSend) + { + return pPlayer; + } + } + + return NULL; +} + +/* <15edd2> ../cstrike/dlls/player.cpp:705 */ +void CBasePlayer::Radio(const char *msg_id, const char *msg_verbose, short pitch, bool showIcon) +{ + // Spectators don't say radio messages. + if (!IsPlayer()) + return; + + // Neither do dead guys. + if (pev->deadflag != DEAD_NO && !IsBot()) + return; + + CBaseEntity *pEntity = NULL; + while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")) != NULL) + { + if (FNullEnt(pEntity->edict())) + break; + + BOOL bSend = FALSE; + CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pEntity->pev); + + if (pPlayer == NULL) + continue; + + // are we a regular player? (not spectator) + if (pPlayer->IsPlayer()) + { + if (pPlayer->IsDormant()) + continue; + + // is this player on our team? (even dead players hear our radio calls) + if (pPlayer->m_iTeam == m_iTeam) + bSend = TRUE; + } + // this means we're a spectator + else + { + // do this when spectator mode is in + int iSpecMode = pPlayer->IsObserver(); + + if (iSpecMode != OBS_CHASE_LOCKED && iSpecMode != OBS_CHASE_FREE && iSpecMode != OBS_IN_EYE) + continue; + + if (!FNullEnt(pPlayer->m_hObserverTarget)) + continue; + + CBasePlayer *pTarget = (CBasePlayer *)CBaseEntity::Instance(pPlayer->m_hObserverTarget->pev); + + if (pTarget && pTarget->m_iTeam == m_iTeam) + { + bSend = TRUE; + } + } + + if (bSend) + { + // ignorerad command + if (!pPlayer->m_bIgnoreRadio) + { + MESSAGE_BEGIN(MSG_ONE, gmsgSendAudio, NULL, pEntity->pev); + WRITE_BYTE(ENTINDEX(edict())); + WRITE_STRING(msg_id); + WRITE_SHORT(pitch); + MESSAGE_END(); + + // radio message icon + if (msg_verbose != NULL) + { + // search the place name where is located the player + const char *placeName = NULL; + Place playerPlace = TheNavAreaGrid.GetPlace(&pev->origin); + const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); + + for (BotPhraseList::const_iterator iter = placeList->begin(); iter != placeList->end(); ++iter) + { + if ((*iter)->GetID() == playerPlace) + { + placeName = (*iter)->GetName(); + break; + } + } + + if (placeName != NULL) + ClientPrint(pEntity->pev, HUD_PRINTRADIO, NumAsString(entindex()), "#Game_radio_location", STRING(pev->netname), placeName, msg_verbose); + else + ClientPrint(pEntity->pev, HUD_PRINTRADIO, NumAsString(entindex()), "#Game_radio", STRING(pev->netname), msg_verbose); + } + + if (showIcon) + { + // put an icon over this guys head to show that he used the radio + MESSAGE_BEGIN(MSG_ONE, SVC_TEMPENTITY, NULL, pEntity->pev); + WRITE_BYTE(TE_PLAYERATTACHMENT); + WRITE_BYTE(ENTINDEX(edict())); // byte (entity index of player) + WRITE_COORD(35); // coord (vertical offset) ( attachment origin.z = player origin.z + vertical offset) + WRITE_SHORT(g_sModelIndexRadio); // short (model index) of tempent + WRITE_SHORT(15); // short (life * 10 ) e.g. 40 = 4 seconds + MESSAGE_END(); + } + } + } + } +} + +/* <1537f3> ../cstrike/dlls/player.cpp:812 */ +void CBasePlayer::SmartRadio(void) +{ + ; +} + +/* <15381b> ../cstrike/dlls/player.cpp:816 */ +void CBasePlayer::Pain(int m_LastHitGroup, bool HasArmour) +{ + int temp = RANDOM_LONG(0, 2); + + if (m_LastHitGroup == HITGROUP_HEAD) + { + if (m_iKevlar == ARMOR_TYPE_HELMET) + { + EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/bhit_helmet-1.wav", VOL_NORM, ATTN_NORM); + return; + } + + switch (temp) + { + case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/headshot1.wav", VOL_NORM, ATTN_NORM); break; + case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/headshot2.wav", VOL_NORM, ATTN_NORM); break; + default: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/headshot3.wav", VOL_NORM, ATTN_NORM); break; + } + } + else + { + if (m_LastHitGroup != HITGROUP_LEFTLEG && m_LastHitGroup != HITGROUP_RIGHTLEG) + { + if (HasArmour) + { + EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/bhit_kevlar-1.wav", VOL_NORM, ATTN_NORM); + return; + } + } + + switch (temp) + { + case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/bhit_flesh-1.wav", VOL_NORM, ATTN_NORM); break; + case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/bhit_flesh-2.wav", VOL_NORM, ATTN_NORM); break; + default: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/bhit_flesh-3.wav", VOL_NORM, ATTN_NORM); break; + } + } +} + +/* <153b48> ../cstrike/dlls/player.cpp:864 */ +Vector VecVelocityForDamage(float flDamage) +{ + Vector vec(RANDOM_FLOAT(-100, 100), RANDOM_FLOAT(-100, 100), RANDOM_FLOAT(200, 300)); + + if (flDamage > -50.0f) + vec = vec * 0.7f; + else if (flDamage > -200.0f) + vec = vec * 2.0f; + else + vec = vec * 10.0f; + + return vec; +} + +/* <14edfb> ../cstrike/dlls/player.cpp:878 */ +int TrainSpeed(int iSpeed, int iMax) +{ + float fMax; + float fSpeed; + int iRet = 0; + + fMax = (float)iMax; + fSpeed = iSpeed / fMax; + + if (iSpeed < 0) + iRet = TRAIN_BACK; + else if (iSpeed == 0) + iRet = TRAIN_NEUTRAL; + else if (fSpeed < 0.33) + iRet = TRAIN_SLOW; + else if (fSpeed < 0.66) + iRet = TRAIN_MEDIUM; + else + iRet = TRAIN_FAST; + + return iRet; +} + +/* <153c8e> ../cstrike/dlls/player.cpp:902 */ +void CBasePlayer::DeathSound(void) +{ + // temporarily using pain sounds for death sounds + switch (RANDOM_LONG(1, 4)) + { + case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/die1.wav", VOL_NORM, ATTN_NORM); break; + case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/die2.wav", VOL_NORM, ATTN_NORM); break; + case 3: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/die3.wav", VOL_NORM, ATTN_NORM); break; + case 4: EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/death6.wav", VOL_NORM, ATTN_NORM); break; + } +} + +// override takehealth +// bitsDamageType indicates type of damage healed. + +/* <151213> ../cstrike/dlls/player.cpp:937 */ +int CBasePlayer::__MAKE_VHOOK(TakeHealth)(float flHealth, int bitsDamageType) +{ + return CBaseMonster::TakeHealth(flHealth, bitsDamageType); +} + +/* <150f1c> ../cstrike/dlls/player.cpp:943 */ +Vector CBasePlayer::__MAKE_VHOOK(GetGunPosition)(void) +{ + return pev->origin + pev->view_ofs; +} + +/* <15412b> ../cstrike/dlls/player.cpp:953 */ +bool CBasePlayer::IsHittingShield(Vector &vecDirection, TraceResult *ptr) +{ + if ((m_pActiveItem && m_pActiveItem->m_iId == WEAPON_C4) || !HasShield()) + return false; + + if (ptr->iHitgroup == HITGROUP_SHIELD) + return true; + + if (m_bShieldDrawn) + UTIL_MakeVectors(pev->angles); + + return false; +} + +/* <152b58> ../cstrike/dlls/player.cpp:989 */ +void CBasePlayer::__MAKE_VHOOK(TraceAttack)(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +{ + bool bShouldBleed = true; + bool bShouldSpark = false; + bool bHitShield = IsHittingShield(vecDir, ptr); + + CBasePlayer *pAttacker = (CBasePlayer *)CBasePlayer::Instance(pevAttacker); + + if (m_iTeam == pAttacker->m_iTeam && CVAR_GET_FLOAT("mp_friendlyfire") == 0) + bShouldBleed = false; + + if (pev->takedamage == DAMAGE_NO) + return; + + m_LastHitGroup = ptr->iHitgroup; + + if (bHitShield) + { + flDamage = 0; + bShouldBleed = false; + + if (RANDOM_LONG(0, 1)) + EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/ric_metal-1.wav", VOL_NORM, ATTN_NORM); + else + EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/ric_metal-2.wav", VOL_NORM, ATTN_NORM); + + UTIL_Sparks(ptr->vecEndPos); + + pev->punchangle.x = flDamage * RANDOM_FLOAT(-0.15, 0.15); + pev->punchangle.z = flDamage * RANDOM_FLOAT(-0.15, 0.15); + + if (pev->punchangle.x < 4) + pev->punchangle.x = -4; + + if (pev->punchangle.z < -5) + pev->punchangle.z = -5; + + else if (pev->punchangle.z > 5) + pev->punchangle.z = 5; + } + else + { + switch (ptr->iHitgroup) + { + case HITGROUP_GENERIC: + break; + + case HITGROUP_HEAD: + { + if (m_iKevlar == ARMOR_TYPE_HELMET) + { + bShouldBleed = false; + bShouldSpark = true; + } + + flDamage *= 4; + if (bShouldBleed) + { + pev->punchangle.x = flDamage * -0.5; + + if (pev->punchangle.x < -12) + pev->punchangle.x = -12; + + pev->punchangle.z = flDamage * RANDOM_FLOAT(-1, 1); + + if (pev->punchangle.z < -9) + pev->punchangle.z = -9; + + else if (pev->punchangle.z > 9) + pev->punchangle.z = 9; + } + break; + } + case HITGROUP_CHEST: + { + flDamage *= 1; + + if (m_iKevlar != ARMOR_TYPE_EMPTY) + bShouldBleed = false; + + else if (bShouldBleed) + { + pev->punchangle.x = flDamage * -0.1; + + if (pev->punchangle.x < -4) + pev->punchangle.x = -4; + } + break; + } + case HITGROUP_STOMACH: + { + flDamage *= 1.25; + + if (m_iKevlar != ARMOR_TYPE_EMPTY) + bShouldBleed = false; + + else if (bShouldBleed) + { + pev->punchangle.x = flDamage * -0.1; + + if (pev->punchangle.x < -4) + pev->punchangle.x = -4; + } + break; + } + case HITGROUP_LEFTARM: + case HITGROUP_RIGHTARM: + { + if (m_iKevlar != ARMOR_TYPE_EMPTY) + bShouldBleed = false; + + break; + } + case HITGROUP_LEFTLEG: + case HITGROUP_RIGHTLEG: + { + flDamage *= 0.75; + break; + } + } + } + + if (bShouldBleed) + { + BloodSplat(ptr->vecEndPos, vecDir, ptr->iHitgroup, flDamage * 5); + SpawnBlood(ptr->vecEndPos, BloodColor(), flDamage); // a little surface blood. + TraceBleed(flDamage, vecDir, ptr, bitsDamageType); + } + // they hit a helmet + else if (ptr->iHitgroup == HITGROUP_HEAD && bShouldSpark) + { + MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, ptr->vecEndPos); + WRITE_BYTE(TE_STREAK_SPLASH); + WRITE_COORD(ptr->vecEndPos.x); + WRITE_COORD(ptr->vecEndPos.y); + WRITE_COORD(ptr->vecEndPos.z); + WRITE_COORD(ptr->vecPlaneNormal.x); + WRITE_COORD(ptr->vecPlaneNormal.y); + WRITE_COORD(ptr->vecPlaneNormal.z); + WRITE_BYTE(5); // color + WRITE_SHORT(22); // count + WRITE_SHORT(25); // base speed + WRITE_SHORT(65); // ramdon velocity + MESSAGE_END(); + } + + AddMultiDamage(pevAttacker, this, flDamage, bitsDamageType); +} + +/* <1541c2> ../cstrike/dlls/player.cpp:1171 */ +const char *GetWeaponName(entvars_t *pevInflictor, entvars_t *pKiller) +{ + const char *killer_weapon_name = "world"; + + if (pKiller->flags & FL_CLIENT) + { + //int killer_index = ENTINDEX(ENT(pKiller)); unused! + + if (pevInflictor) + { + if (pevInflictor == pKiller) + { + CBasePlayer *pAttacker = (CBasePlayer *)CBaseEntity::Instance(pKiller); + + if (pAttacker) + { + if (pAttacker->m_pActiveItem) + killer_weapon_name = pAttacker->m_pActiveItem->pszName(); + } + } + else + killer_weapon_name = STRING(pevInflictor->classname); + } + } + else + killer_weapon_name = STRING(pevInflictor->classname); + + if (!Q_strncmp(killer_weapon_name, "weapon_", 7)) + killer_weapon_name += 7; + + else if (!Q_strncmp(killer_weapon_name, "monster_", 8)) + killer_weapon_name += 8; + + else if (Q_strncmp(killer_weapon_name, "func_", 5)) + killer_weapon_name += 5; + + return killer_weapon_name; +} + +/* <14e061> ../cstrike/dlls/player.cpp:1214 */ +void LogAttack(CBasePlayer *pAttacker, CBasePlayer *pVictim, int teamAttack, int healthHit, int armorHit, int newHealth, int newArmor, const char *killer_weapon_name) +{ + int detail = logdetail.value; + + if (!detail) + return; + + if (!pAttacker || !pVictim) + return; + + if ((teamAttack && (detail & LOG_TEAMMATEATTACK)) || (!teamAttack && (detail & LOG_ENEMYATTACK))) + { + UTIL_LogPrintf + ( + "\"%s<%i><%s><%s>\" attacked \"%s<%i><%s><%s>\" with \"%s\" (damage \"%d\") (damage_armor \"%d\") (health \"%d\") (armor \"%d\")\n", + STRING(pAttacker->pev->netname), + GETPLAYERUSERID(pAttacker->edict()), + GETPLAYERAUTHID(pAttacker->edict()), + GetTeam(pAttacker->m_iTeam), + STRING(pVictim->pev->netname), + GETPLAYERUSERID(pVictim->edict()), + GETPLAYERAUTHID(pVictim->edict()), + GetTeam(pVictim->m_iTeam), + killer_weapon_name, + healthHit, + armorHit, + newHealth, + newArmor + ); + } +} + +// Take some damage. +// NOTE: each call to TakeDamage with bitsDamageType set to a time-based damage +// type will cause the damage time countdown to be reset. Thus the ongoing effects of poison, radiation +// etc are implemented with subsequent calls to TakeDamage using DMG_GENERIC. + +/* <15dff9> ../cstrike/dlls/player.cpp:1241 */ +int CBasePlayer::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +{ + int fTookDamage; + float flRatio = ARMOR_RATIO; + float flBonus = ARMOR_BONUS; + //float flHealthPrev = pev->health; + int iGunType = 0; + float flShieldRatio = 0; + int teamAttack = FALSE; + int armorHit = 0; + CBasePlayer *pAttack = NULL; + CBaseEntity *pAttacker = NULL; + //CBaseEntity *attacker = NULL; // unused + + if (bitsDamageType & (DMG_EXPLOSION | DMG_BLAST | DMG_FALL)) + m_LastHitGroup = HITGROUP_GENERIC; + + else if (m_LastHitGroup == HITGROUP_SHIELD && (bitsDamageType & DMG_BULLET)) + return 0; + + if (HasShield()) + flShieldRatio = 0.2; + + if (m_bIsVIP) + flRatio *= 0.5; + + if (bitsDamageType & (DMG_EXPLOSION | DMG_BLAST)) + { + if (!IsAlive()) + { + return 0; + } + + if (bitsDamageType & DMG_EXPLOSION) + { + CBaseEntity *temp = GetClassPtr((CBaseEntity *)pevInflictor); + + if (!Q_strcmp(STRING(temp->pev->classname), "grenade")) + { + CGrenade *pGrenade = GetClassPtr((CGrenade *)pevInflictor); + + if (CVAR_GET_FLOAT("mp_friendlyfire")) + { + if (pGrenade->m_iTeam == m_iTeam) + teamAttack = TRUE; + + pAttack = reinterpret_cast(CBasePlayer::Instance(pevAttacker)); + } + else if (pGrenade->m_iTeam == m_iTeam && (&edict()->v != pevAttacker)) + { + return 0; + } + } + } + + if (!FNullEnt(ENT(pevInflictor))) + m_vBlastVector = pev->origin - pevInflictor->origin; + + if (pev->armorvalue != 0.0f && IsArmored(m_LastHitGroup)) + { + float_precision flNew = flRatio * flDamage; + float_precision flArmor = (flDamage - flNew) * flBonus; + + // Does this use more armor than we have? + if (flArmor > pev->armorvalue) + { + flNew = flDamage - pev->armorvalue; + armorHit = flArmor; + pev->armorvalue = 0; + } + else + { + int oldValue = pev->armorvalue; + + if (flArmor < 0.0) + flArmor = 1.0; + + pev->armorvalue -= flArmor; + armorHit = oldValue - pev->armorvalue; + } + + flDamage = flNew; + + if (pev->armorvalue <= 0.0) + m_iKevlar = ARMOR_TYPE_EMPTY; + + Pain(m_LastHitGroup, true); + } + else + Pain(m_LastHitGroup, false); + + m_lastDamageAmount = flDamage; + + if (pev->health > flDamage) + { + SetAnimation(PLAYER_FLINCH); + Pain(m_LastHitGroup, false); + } + else + { + if (bitsDamageType & DMG_BLAST) + m_bKilledByBomb = true; + + else if (bitsDamageType & DMG_EXPLOSION) + m_bKilledByGrenade = true; + } + + LogAttack(pAttack, this, teamAttack, (int)flDamage, armorHit, pev->health - flDamage, pev->armorvalue, GetWeaponName(pevInflictor, pevAttacker)); + fTookDamage = CBaseMonster::TakeDamage(pevInflictor, pevAttacker, (int)flDamage, bitsDamageType); + + if (fTookDamage > 0) + { + CHalfLifeMultiplay *mp = g_pGameRules; + + if (TheBots) + TheBots->OnEvent(EVENT_PLAYER_TOOK_DAMAGE, this, pAttack); + + if (mp->IsCareer()) + { + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (!pPlayer) + continue; + + bool killedByHumanPlayer = (!pPlayer->IsBot() && pPlayer->pev == pevAttacker && pPlayer->m_iTeam != m_iTeam); + + if (killedByHumanPlayer) + { + TheCareerTasks->HandleEnemyInjury(GetWeaponName(pevInflictor, pevAttacker), pPlayer->HasShield(), pPlayer); + } + } + } + } + + { + // reset damage time countdown for each type of time based damage player just sustained + for (int i = 0; i < CDMG_TIMEBASED; i++) + { + if (bitsDamageType & (DMG_PARALYZE << i)) + m_rgbTimeBasedDamage[i] = 0; + } + } + + // tell director about it + MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR); + WRITE_BYTE(9); // command length in bytes + WRITE_BYTE(DRC_CMD_EVENT); // take damage event + WRITE_SHORT(ENTINDEX(edict())); // index number of primary entity + WRITE_SHORT(ENTINDEX(ENT(pevInflictor))); // index number of secondary entity + WRITE_LONG(5); // eventflags (priority and flags) + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_SPEC, gmsgHLTV); + WRITE_BYTE(ENTINDEX(edict())); + WRITE_BYTE((int)Q_max(pev->health, 0.0f) | DRC_FLAG_FACEPLAYER); + MESSAGE_END(); + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (!pPlayer || pPlayer->m_hObserverTarget != this) + continue; + + MESSAGE_BEGIN(MSG_ONE, gmsgSpecHealth, NULL, pPlayer->edict()); + WRITE_BYTE((int)Q_max(pev->health, 0.0f)); + MESSAGE_END(); + } + + return fTookDamage; + } + + pAttacker = CBaseEntity::Instance(pevAttacker); + + if (!g_pGameRules->FPlayerCanTakeDamage(this, pAttacker) && Q_strcmp("grenade", STRING(pevInflictor->classname))) + { + // Refuse the damage + return 0; + } + + if (bitsDamageType & DMG_BLAST && g_pGameRules->IsMultiplayer()) + { + // blasts damage armor more. + flBonus *= 2; + } + + // Already dead + if (!IsAlive()) + return 0; + + pAttacker = GetClassPtr((CBaseEntity *)pevAttacker); + + if (pAttacker->IsPlayer()) + { + pAttack = GetClassPtr((CBasePlayer *)pevAttacker); + + if (pAttack != this && pAttack->m_iTeam == m_iTeam) + { + // TODO: this->m_flDisplayHistory!! + if (!(m_flDisplayHistory & DHF_FRIEND_INJURED)) + { + m_flDisplayHistory |= DHF_FRIEND_INJURED; + pAttack->HintMessage("#Hint_try_not_to_injure_teammates"); + } + + teamAttack = TRUE; + if (gpGlobals->time > pAttack->m_flLastAttackedTeammate + 0.6) + { + CBaseEntity *pBasePlayer = NULL; + while ((pBasePlayer = UTIL_FindEntityByClassname(pBasePlayer, "player")) != NULL) + { + if (FNullEnt(pBasePlayer->edict())) + break; + + CBasePlayer *basePlayer = GetClassPtr((CBasePlayer *)pBasePlayer->pev); + + if (basePlayer->m_iTeam == m_iTeam) + { + ClientPrint(basePlayer->pev, HUD_PRINTTALK, "#Game_teammate_attack", STRING(pAttack->pev->netname)); + } + } + + pAttack->m_flLastAttackedTeammate = gpGlobals->time; + } + } + + if (pAttack->m_iTeam == m_iTeam) + flDamage *= 0.35; + + iGunType = pAttack->m_pActiveItem->m_iId; + + if (pAttack->m_pActiveItem) + { + flRatio += flShieldRatio; + switch (iGunType) + { + case WEAPON_AUG: + case WEAPON_M4A1: flRatio *= 1.4; break; + case WEAPON_AWP: flRatio *= 1.95; break; + case WEAPON_G3SG1: flRatio *= 1.65; break; + case WEAPON_SG550: flRatio *= 1.45; break; + case WEAPON_M249: flRatio *= 1.5; break; + case WEAPON_ELITE: flRatio *= 1.05; break; + case WEAPON_DEAGLE: flRatio *= 1.5; break; + case WEAPON_GLOCK18: flRatio *= 1.05; break; + case WEAPON_FIVESEVEN: + case WEAPON_P90: flRatio *= 1.5; break; + case WEAPON_MAC10: flRatio *= 0.95; break; + case WEAPON_P228: flRatio *= 1.25; break; + case WEAPON_SCOUT: + case WEAPON_KNIFE: flRatio *= 1.7; break; + case WEAPON_FAMAS: + case WEAPON_SG552: flRatio *= 1.4; break; + case WEAPON_GALIL: + case WEAPON_AK47: flRatio *= 1.55; break; + } + } + + if (!ShouldDoLargeFlinch(m_LastHitGroup, iGunType)) + { + m_flVelocityModifier = 0.5f; + + if (m_LastHitGroup == HITGROUP_HEAD) + m_bHighDamage = (flDamage > 60); + else + m_bHighDamage = (flDamage > 20); + + SetAnimation(PLAYER_FLINCH); + } + else + { + if (pev->velocity.Length() < 300) + { + Vector attack_velocity = (pev->origin - pAttack->pev->origin).Normalize() * 170; + pev->velocity = pev->velocity + attack_velocity; + + m_flVelocityModifier = 0.65f; + } + SetAnimation(PLAYER_LARGE_FLINCH); + } + } + + // keep track of amount of damage last sustained + m_lastDamageAmount = flDamage; + + // Armor + // armor doesn't protect against fall or drown damage! + if (pev->armorvalue != 0.0f && !(bitsDamageType & (DMG_DROWN | DMG_FALL)) && IsArmored(m_LastHitGroup)) + { + float_precision flNew = flRatio * flDamage; + float_precision flArmor = (flDamage - flNew) * flBonus; + + // Does this use more armor than we have? + if (flArmor > pev->armorvalue) + { + armorHit = flArmor; + flArmor = pev->armorvalue; + flArmor *= (1 / flBonus); + flNew = flDamage - flArmor; + pev->armorvalue = 0; + } + else + { + int oldValue = pev->armorvalue; + + if (flArmor < 0.0) + flArmor = 1.0; + + pev->armorvalue -= flArmor; + armorHit = oldValue - pev->armorvalue; + } + + flDamage = flNew; + + if (pev->armorvalue <= 0.0f) + m_iKevlar = ARMOR_TYPE_EMPTY; + + Pain(m_LastHitGroup, true); + } + else + Pain(m_LastHitGroup, false); + + LogAttack(pAttack, this, teamAttack, flDamage, armorHit, pev->health - flDamage, pev->armorvalue, GetWeaponName(pevInflictor, pevAttacker)); + + // this cast to INT is critical!!! If a player ends up with 0.5 health, the engine will get that + // as an int (zero) and think the player is dead! (this will incite a clientside screentilt, etc) + fTookDamage = CBaseMonster::TakeDamage(pevInflictor, pevAttacker, (int)flDamage, bitsDamageType); + + if (fTookDamage > 0) + { + CHalfLifeMultiplay *mp = g_pGameRules; + + if (TheBots) + { + TheBots->OnEvent(EVENT_PLAYER_TOOK_DAMAGE, this, pAttack); + } + + if (mp->IsCareer()) + { + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (!pPlayer) + continue; + + bool killedByHumanPlayer = (!pPlayer->IsBot() && pPlayer->pev == pevAttacker && pPlayer->m_iTeam != m_iTeam); + + if (killedByHumanPlayer) + { + TheCareerTasks->HandleEnemyInjury(GetWeaponName(pevInflictor, pevAttacker), pPlayer->HasShield(), pPlayer); + } + } + } + } + + { + // reset damage time countdown for each type of time based damage player just sustained + for (int i = 0; i < CDMG_TIMEBASED; i++) + { + if (bitsDamageType & (DMG_PARALYZE << i)) + m_rgbTimeBasedDamage[i] = 0; + } + } + + // tell director about it + MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR); + WRITE_BYTE(9); // command length in bytes + WRITE_BYTE(DRC_CMD_EVENT); // take damage event + WRITE_SHORT(ENTINDEX(edict())); // index number of primary entity + WRITE_SHORT(ENTINDEX(ENT(pevInflictor))); // index number of secondary entity + WRITE_LONG(5); // eventflags (priority and flags) + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_SPEC, gmsgHLTV); + WRITE_BYTE(ENTINDEX(edict())); + WRITE_BYTE((int)Q_max(pev->health, 0.0f) | DRC_FLAG_FACEPLAYER); + MESSAGE_END(); + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (!pPlayer) + continue; + + if (pPlayer->m_hObserverTarget == this) + { + MESSAGE_BEGIN(MSG_ONE, gmsgSpecHealth, NULL, pPlayer->edict()); + WRITE_BYTE((int)Q_max(pev->health, 0.0f)); + MESSAGE_END(); + } + } + + // Save this so we can report it to the client + m_bitsHUDDamage = -1; + + // make sure the damage bits get resent + m_bitsDamageType |= bitsDamageType; + + return fTookDamage; +} + +/* <1516a0> ../cstrike/dlls/player.cpp:1706 */ +void packPlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo) +{ + if (pItem) + { + const char *modelName = GetCSModelName(pItem->m_iId); + if (modelName) + { + CWeaponBox *pWeaponBox = (CWeaponBox *)CBaseEntity::Create("weaponbox", pPlayer->pev->origin, pPlayer->pev->angles, ENT(pPlayer->pev)); + + pWeaponBox->pev->angles.x = 0; + pWeaponBox->pev->angles.z = 0; + + pWeaponBox->pev->velocity = pPlayer->pev->velocity * 0.75; + + pWeaponBox->SetThink(&CWeaponBox::Kill); + pWeaponBox->pev->nextthink = gpGlobals->time + 300; + pWeaponBox->PackWeapon(pItem); + + if (packAmmo) + { + pWeaponBox->PackAmmo(MAKE_STRING(IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, ItemInfoArray)[ pItem->m_iId ].pszAmmo1), pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()]); + } + SET_MODEL(ENT(pWeaponBox->pev), modelName); + } + } +} + +/* <15f739> ../cstrike/dlls/player.cpp:1756 */ +void CBasePlayer::PackDeadPlayerItems(void) +{ + bool bPackGun = (g_pGameRules->DeadPlayerWeapons(this) != GR_PLR_DROP_GUN_NO); + bool bPackAmmo = (g_pGameRules->DeadPlayerAmmo(this) != GR_PLR_DROP_AMMO_NO); + + if (bPackGun) + { + bool bShieldDropped = false; + if (HasShield()) + { + DropShield(); + bShieldDropped = true; + } + + int nBestWeight = 0; + CBasePlayerItem *pBestItem = NULL; + + for (int n = 0; n < MAX_ITEM_TYPES; n++) + { + CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[ n ]; + + while (pPlayerItem != NULL) + { + ItemInfo info; + if (pPlayerItem->iItemSlot() < KNIFE_SLOT && !bShieldDropped) + { + if (pPlayerItem->GetItemInfo(&info)) + { + if (info.iWeight > nBestWeight) + { + nBestWeight = info.iWeight; + pBestItem = pPlayerItem; + } + } + } + else if (pPlayerItem->iItemSlot() == GRENADE_SLOT && UTIL_IsGame("czero")) + packPlayerItem(this, pPlayerItem, true); + + pPlayerItem = pPlayerItem->m_pNext; + } + } + packPlayerItem(this, pBestItem, bPackAmmo); + } + RemoveAllItems(TRUE); +} + +/* <15f710> ../cstrike/dlls/player.cpp:1829 */ +void CBasePlayer::GiveDefaultItems(void) +{ + RemoveAllItems(FALSE); + m_bHasPrimary = false; + + switch (m_iTeam) + { + case CT: + GiveNamedItem("weapon_knife"); + GiveNamedItem("weapon_usp"); + GiveAmmo(m_bIsVIP ? 12 : 24, "45acp", MAX_AMMO_45ACP); + + break; + case TERRORIST: + GiveNamedItem("weapon_knife"); + GiveNamedItem("weapon_glock18"); + GiveAmmo(40, "9mm", MAX_AMMO_9MM); + + break; + } +} + +/* <15f406> ../cstrike/dlls/player.cpp:1871 */ +void CBasePlayer::RemoveAllItems(BOOL removeSuit) +{ + BOOL bKillProgBar = false; + int i; + + if (m_bHasDefuser) + { + m_bHasDefuser = false; + pev->body = 0; + + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + WRITE_BYTE(STATUSICON_HIDE); + WRITE_STRING("defuser"); + MESSAGE_END(); + + SendItemStatus(this); + bKillProgBar = true; + } + + if (m_bHasC4) + { + m_bHasC4 = false; + pev->body = 0; + + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + WRITE_BYTE(STATUSICON_HIDE); + WRITE_STRING("c4"); + MESSAGE_END(); + + bKillProgBar = true; + } + + RemoveShield(); + + if (bKillProgBar) + SetProgressBarTime(0); + + if (m_pActiveItem) + { + ResetAutoaim(); + + m_pActiveItem->Holster(); + m_pActiveItem = NULL; + } + m_pLastItem = NULL; + + for (i = 0; i < MAX_ITEM_TYPES; i++) + { + m_pActiveItem = m_rgpPlayerItems[i]; + + while (m_pActiveItem) + { + CBasePlayerItem *pPendingItem = m_pActiveItem->m_pNext; + + m_pActiveItem->Drop(); + m_pActiveItem = pPendingItem; + } + + m_rgpPlayerItems[i] = NULL; + } + + m_pActiveItem = NULL; + m_bHasPrimary = NULL; + + pev->viewmodel = 0; + pev->weaponmodel = 0; + + if (removeSuit) + pev->weapons = 0; + else + pev->weapons &= ~WEAPON_ALLWEAPONS; + + for (i = 0; i < MAX_AMMO_SLOTS; i++) + m_rgAmmo[i] = 0; + + UpdateClientData(); + + MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev); + WRITE_BYTE(0); + WRITE_BYTE(0); + WRITE_BYTE(0); + MESSAGE_END(); +} + +/* <15436c> ../cstrike/dlls/player.cpp:1962 */ +void CBasePlayer::SetBombIcon(BOOL bFlash) +{ + if (m_bHasC4) + { + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + WRITE_BYTE(bFlash ? STATUSICON_FLASH : STATUSICON_SHOW); + WRITE_STRING("c4"); + WRITE_BYTE(0); + WRITE_BYTE(160); + WRITE_BYTE(0); + MESSAGE_END(); + } + else + { + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + WRITE_BYTE(STATUSICON_HIDE); + WRITE_STRING("c4"); + MESSAGE_END(); + } + + SetScoreboardAttributes(); +} + +/* <15f2ab> ../cstrike/dlls/player.cpp:1985 */ +void CBasePlayer::SetProgressBarTime(int time) +{ + if (time) + { + m_progressStart = gpGlobals->time; + m_progressEnd = time + gpGlobals->time; + } + else + { + m_progressStart = 0; + m_progressEnd = 0; + } + + MESSAGE_BEGIN(MSG_ONE, gmsgBarTime, NULL, pev); + WRITE_SHORT(time); + MESSAGE_END(); + + CBaseEntity *pPlayer = NULL; + int myIndex = entindex(); + + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + { + if (FNullEnt(pPlayer->edict())) + break; + + CBasePlayer *player = GetClassPtr((CBasePlayer *)pPlayer->pev); + + if (player->IsObserver() == OBS_IN_EYE && player->pev->iuser2 == myIndex) + { + MESSAGE_BEGIN(MSG_ONE, gmsgBarTime, NULL, player->pev); + WRITE_SHORT(time); + MESSAGE_END(); + } + } +} + +/* <15dcb4> ../cstrike/dlls/player.cpp:2027 */ +void CBasePlayer::SetProgressBarTime2(int time, float timeElapsed) +{ + if (time) + { + m_progressStart = gpGlobals->time - timeElapsed; + m_progressEnd = time + gpGlobals->time - timeElapsed; + } + else + { + timeElapsed = 0; + m_progressStart = 0; + m_progressEnd = 0; + } + + short iTimeElapsed = (timeElapsed * 100.0 / (m_progressEnd - m_progressStart)); + + MESSAGE_BEGIN(MSG_ONE, gmsgBarTime2, NULL, pev); + WRITE_SHORT(time); + WRITE_SHORT(iTimeElapsed); + MESSAGE_END(); + + CBaseEntity *pPlayer = NULL; + int myIndex = entindex(); + + while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")) != NULL) + { + if (FNullEnt(pPlayer->edict())) + break; + + CBasePlayer *player = GetClassPtr((CBasePlayer *)pPlayer->pev); + + if (player->IsObserver() == OBS_IN_EYE && player->pev->iuser2 == myIndex) + { + MESSAGE_BEGIN(MSG_ONE, gmsgBarTime, NULL, player->pev); + WRITE_SHORT(time); + WRITE_SHORT(iTimeElapsed); + MESSAGE_END(); + } + } +} + +/* <14e0e9> ../cstrike/dlls/player.cpp:2073 */ +void BuyZoneIcon_Set(CBasePlayer *player) +{ + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); + WRITE_BYTE(STATUSICON_SHOW); + WRITE_STRING("buyzone"); + WRITE_BYTE(0); + WRITE_BYTE(160); + WRITE_BYTE(0); + MESSAGE_END(); +} + +/* <14e106> ../cstrike/dlls/player.cpp:2086 */ +void BuyZoneIcon_Clear(CBasePlayer *player) +{ + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); + WRITE_BYTE(STATUSICON_HIDE); + WRITE_STRING("buyzone"); + MESSAGE_END(); + + if (player->m_iMenu >= Menu_Buy) + { + if (player->m_iMenu <= Menu_BuyItem) + { + CLIENT_COMMAND(ENT(player->pev), "slot10\n"); + } + else if (player->m_iMenu == Menu_ClientBuy) + { + MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, NULL, player->pev); + MESSAGE_END(); + } + } +} + +/* <14e62c> ../cstrike/dlls/player.cpp:2115 */ +void BombTargetFlash_Set(CBasePlayer *player) +{ + if (player->m_bHasC4 && !(player->m_flDisplayHistory & DHF_IN_TARGET_ZONE)) + { + player->m_flDisplayHistory |= DHF_IN_TARGET_ZONE; + player->HintMessage("#Hint_you_are_in_targetzone", TRUE); // TODO: send also for dead the players? + } + player->SetBombIcon(TRUE); +} + +/* <14e649> ../cstrike/dlls/player.cpp:2129 */ +void BombTargetFlash_Clear(CBasePlayer *player) +{ + player->SetBombIcon(FALSE); +} + +/* <158292> ../cstrike/dlls/player.cpp:2136 */ +void RescueZoneIcon_Set(CBasePlayer *player) +{ + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); + WRITE_BYTE(STATUSICON_SHOW); + WRITE_STRING("rescue"); + WRITE_BYTE(0); + WRITE_BYTE(160); + WRITE_BYTE(0); + MESSAGE_END(); + + if (player->m_iTeam == CT && !(player->m_flDisplayHistory & DHF_IN_RESCUE_ZONE)) + { + player->m_flDisplayHistory |= DHF_IN_RESCUE_ZONE; + player->HintMessage("#Hint_hostage_rescue_zone", TRUE); // TODO: send also for dead the players? + } +} + +/* <14e666> ../cstrike/dlls/player.cpp:2156 */ +void RescueZoneIcon_Clear(CBasePlayer *player) +{ + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); + WRITE_BYTE(STATUSICON_HIDE); + WRITE_STRING("rescue"); + MESSAGE_END(); + + if (player->m_iMenu >= Menu_Buy) + { + if (player->m_iMenu <= Menu_BuyItem) + { + CLIENT_COMMAND(ENT(player->pev), "slot10\n"); + } + else if (player->m_iMenu == Menu_ClientBuy) + { + MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, NULL, player->pev); + MESSAGE_END(); + } + } +} + +/* <1582af> ../cstrike/dlls/player.cpp:2185 */ +void EscapeZoneIcon_Set(CBasePlayer *player) +{ + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); + WRITE_BYTE(STATUSICON_SHOW); + WRITE_STRING("escape"); + WRITE_BYTE(0); + WRITE_BYTE(160); + WRITE_BYTE(0); + MESSAGE_END(); + + if (player->m_iTeam == CT) + { + if (!(player->m_flDisplayHistory & DHF_IN_ESCAPE_ZONE)) + { + player->m_flDisplayHistory |= DHF_IN_ESCAPE_ZONE; + player->HintMessage("#Hint_terrorist_escape_zone"); + } + } +} + +/* <14e683> ../cstrike/dlls/player.cpp:2203 */ +void EscapeZoneIcon_Clear(CBasePlayer *player) +{ + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); + WRITE_BYTE(STATUSICON_HIDE); + WRITE_STRING("escape"); + MESSAGE_END(); + + if (player->m_iMenu >= Menu_Buy) + { + if (player->m_iMenu <= Menu_BuyItem) + { + CLIENT_COMMAND(player->edict(), "slot10\n"); + } + else if (player->m_iMenu == Menu_ClientBuy) + { + MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, NULL, player->pev); + MESSAGE_END(); + } + } +} + +/* <1582cc> ../cstrike/dlls/player.cpp:2231 */ +void VIP_SafetyZoneIcon_Set(CBasePlayer *player) +{ + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); + WRITE_BYTE(STATUSICON_SHOW); + WRITE_STRING("vipsafety"); + WRITE_BYTE(0); + WRITE_BYTE(160); + WRITE_BYTE(0); + MESSAGE_END(); + + if (!(player->m_flDisplayHistory & DHF_IN_VIPSAFETY_ZONE)) + { + if (player->m_iTeam == CT) + { + player->m_flDisplayHistory |= DHF_IN_VIPSAFETY_ZONE; + player->HintMessage("#Hint_ct_vip_zone", TRUE); + } + else if (player->m_iTeam == TERRORIST) + { + player->m_flDisplayHistory |= DHF_IN_VIPSAFETY_ZONE; + player->HintMessage("#Hint_terrorist_vip_zone", TRUE); + } + } +} + +/* <14e6a0> ../cstrike/dlls/player.cpp:2255 */ +void VIP_SafetyZoneIcon_Clear(CBasePlayer *player) +{ + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); + WRITE_BYTE(STATUSICON_HIDE); + WRITE_STRING("vipsafety"); + MESSAGE_END(); + + if (player->m_iMenu >= Menu_Buy) + { + if (player->m_iMenu <= Menu_BuyItem) + { + CLIENT_COMMAND(player->edict(), "slot10\n"); + } + else if (player->m_iMenu == Menu_ClientBuy) + { + MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, NULL, player->pev); + MESSAGE_END(); + } + } +} + +/* <154417> ../cstrike/dlls/player.cpp:2282 */ +void CBasePlayer::SendFOV(int fov) +{ + pev->fov = (float_precision)fov; + m_iClientFOV = fov; + m_iFOV = fov; + + MESSAGE_BEGIN(MSG_ONE, gmsgSetFOV, NULL, pev); + WRITE_BYTE(fov); + MESSAGE_END(); +} + +/* <160a1a> ../cstrike/dlls/player.cpp:2300 */ +void CBasePlayer::__MAKE_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) +{ + m_canSwitchObserverModes = false; + + if (m_LastHitGroup == HITGROUP_HEAD) + m_bHeadshotKilled = true; + + CBaseEntity *pAttackerEntity = CBaseEntity::Instance(pevAttacker); + + TheBots->OnEvent(EVENT_PLAYER_DIED, this, pAttackerEntity); + + if (g_pGameRules->IsCareer()) + { + bool killerHasShield = false; + bool wasBlind = false; + + if (!IsBot()) + { + TheCareerTasks->HandleEvent(EVENT_DIE, NULL, this); + } + TheCareerTasks->HandleDeath(m_iTeam, this); + + if (!m_bKilledByBomb) + { + CBasePlayer *pAttacker = (CBasePlayer *)CBaseEntity::Instance(pevAttacker); + + if (pAttacker->HasShield()) + killerHasShield = true; + + CCSBot *pBot = reinterpret_cast(this); + if (pBot->IsBot() && pBot->IsBlind()) + { + wasBlind = true; + } + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (!pPlayer) + continue; + + bool killedByHumanPlayer = (!pPlayer->IsBot() && pPlayer->pev == pevAttacker && pPlayer->m_iTeam != m_iTeam); + + if (killedByHumanPlayer) + { + TheCareerTasks->HandleEnemyKill(wasBlind, GetWeaponName(g_pevLastInflictor, pevAttacker), m_bHeadshotKilled, killerHasShield, this, pPlayer); + } + } + } + } + + if (!m_bKilledByBomb) + { + g_pGameRules->PlayerKilled(this, pevAttacker, g_pevLastInflictor); + } + + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pev); + WRITE_BYTE(0); + MESSAGE_END(); + + m_bNightVisionOn = false; + + for (int i = 1; i <= gpGlobals->maxClients; ++i) + { + CBasePlayer *pObserver = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (!pObserver) + continue; + + if (pObserver->IsObservingPlayer(this)) + { + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); + WRITE_BYTE(0); + MESSAGE_END(); + + pObserver->m_bNightVisionOn = false; + } + } + + if (m_pTank != NULL) + { + m_pTank->Use(this, this, USE_OFF, 0); + m_pTank = NULL; + } + + CSound *pSound = CSoundEnt::SoundPointerForIndex(CSoundEnt::ClientSoundIndex(edict())); + + if (pSound) + { + pSound->Reset(); + } + + SetAnimation(PLAYER_DIE); + + if (m_pActiveItem && m_pActiveItem->m_pPlayer) + { + switch (m_pActiveItem->m_iId) + { + case WEAPON_HEGRENADE: + { + CHEGrenade *pHEGrenade = (CHEGrenade *)m_pActiveItem; + if ((pev->button & IN_ATTACK) && m_rgAmmo[ pHEGrenade->m_iPrimaryAmmoType ]) + { + CGrenade::ShootTimed2(pev, (pev->origin + pev->view_ofs), pev->angles, 1.5, m_iTeam, pHEGrenade->m_usCreateExplosion); + } + break; + } + case WEAPON_FLASHBANG: + { + if ((pev->button & IN_ATTACK) && m_rgAmmo[ ((CBasePlayerWeapon *)m_pActiveItem)->m_iPrimaryAmmoType ]) + { + CGrenade::ShootTimed(pev, (pev->origin + pev->view_ofs), pev->angles, 1.5); + } + break; + } + case WEAPON_SMOKEGRENADE: + { + CSmokeGrenade *pSmoke = (CSmokeGrenade *)m_pActiveItem; + if ((pev->button & IN_ATTACK) && m_rgAmmo[ pSmoke->m_iPrimaryAmmoType ]) + { + CGrenade::ShootSmokeGrenade(pev, (pev->origin + pev->view_ofs), pev->angles, 1.5, pSmoke->m_usCreateSmoke); + } + break; + } + default: + break; + } + } + + pev->modelindex = m_modelIndexPlayer; + pev->deadflag = DEAD_DYING; + pev->movetype = MOVETYPE_TOSS; + pev->takedamage = DAMAGE_NO; + + pev->gamestate = 1; + m_bShieldDrawn = false; + + pev->flags &= ~FL_ONGROUND; + + if (fadetoblack.value == 0.0) + { + pev->iuser1 = OBS_CHASE_FREE; + pev->iuser2 = ENTINDEX(edict()); + pev->iuser3 = ENTINDEX(ENT(pevAttacker)); + + m_hObserverTarget = UTIL_PlayerByIndex(pev->iuser3); + + MESSAGE_BEGIN(MSG_ONE, gmsgADStop, NULL, pev); + MESSAGE_END(); + } + else + UTIL_ScreenFade(this, Vector(0, 0, 0), 3, 3, 255, (FFADE_OUT | FFADE_STAYOUT)); + + SetScoreboardAttributes(); + + if (m_iThrowDirection) + { + switch (m_iThrowDirection) + { + case THROW_FORWARD: + { + UTIL_MakeVectors(pev->angles); + + pev->velocity = gpGlobals->v_forward * RANDOM_FLOAT(100, 200); + pev->velocity.z = RANDOM_FLOAT(50, 100); + + break; + } + case THROW_BACKWARD: + { + UTIL_MakeVectors(pev->angles); + + pev->velocity = gpGlobals->v_forward * RANDOM_FLOAT(-100, -200); + pev->velocity.z = RANDOM_FLOAT(50, 100); + + break; + } + case THROW_HITVEL: + { + if (FClassnameIs(pevAttacker, "player")) + { + UTIL_MakeVectors(pevAttacker->angles); + + pev->velocity = gpGlobals->v_forward * RANDOM_FLOAT(200, 300); + pev->velocity.z = RANDOM_FLOAT(200, 300); + } + + break; + } + case THROW_BOMB: + { + pev->velocity = m_vBlastVector * (1 / m_vBlastVector.Length()) * (2300 - m_vBlastVector.Length()) * 0.25; + pev->velocity.z = (2300 - m_vBlastVector.Length()) / 2.75; + + break; + } + case THROW_GRENADE: + { + pev->velocity = m_vBlastVector * (1 / m_vBlastVector.Length()) * (500 - m_vBlastVector.Length()); + pev->velocity.z = (350 - m_vBlastVector.Length()) * 1.5; + + break; + } + case THROW_HITVEL_MINUS_AIRVEL: + { + if (FClassnameIs(pevAttacker, "player")) + { + UTIL_MakeVectors(pevAttacker->angles); + pev->velocity = gpGlobals->v_forward * RANDOM_FLOAT(200, 300); + } + + break; + } + default: + break; + } + + pev->angles.y = UTIL_VecToAngles(-pev->velocity).y; + pev->v_angle.y = pev->angles.y; + + m_iThrowDirection = THROW_NONE; + } + + SetSuitUpdate(NULL, FALSE, 0); + m_iClientHealth = 0; + + MESSAGE_BEGIN(MSG_ONE, gmsgHealth, NULL, pev); + WRITE_BYTE(m_iClientHealth); + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev); + WRITE_BYTE(0); + WRITE_BYTE(0xFF); + WRITE_BYTE(0xFF); + MESSAGE_END(); + + SendFOV(0); + + g_pGameRules->CheckWinConditions(); + m_bNotKilled = false; + + if (m_bHasC4) + { + DropPlayerItem("weapon_c4"); + SetProgressBarTime(0); + } + else if (m_bHasDefuser) + { + m_bHasDefuser = false; + pev->body = 0; + + GiveNamedItem("item_thighpack"); + + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + WRITE_BYTE(STATUSICON_HIDE); + WRITE_STRING("defuser"); + MESSAGE_END(); + + SendItemStatus(this); + } + + if (m_bIsDefusing) + { + SetProgressBarTime(0); + } + + m_bIsDefusing = false; + + BuyZoneIcon_Clear(this); + + SetThink(&CBasePlayer::PlayerDeathThink); + pev->nextthink = gpGlobals->time + 0.1; + pev->solid = SOLID_NOT; + + if (m_bPunishedForTK) + { + m_bPunishedForTK = false; + HintMessage("#Hint_cannot_play_because_tk", TRUE, TRUE); + } + + if ((pev->health < -9000 && iGib != GIB_NEVER) || iGib == GIB_ALWAYS) + { + pev->solid = SOLID_NOT; + GibMonster(); + pev->effects |= EF_NODRAW; + + g_pGameRules->CheckWinConditions(); + + return; + } + + DeathSound(); + + pev->angles.x = 0; + pev->angles.z = 0; + + if (!(m_flDisplayHistory & DHF_SPEC_DUCK)) + { + HintMessage("#Spec_Duck", TRUE, TRUE); + m_flDisplayHistory |= DHF_SPEC_DUCK; + } +} + +/* <154478> ../cstrike/dlls/player.cpp:2625 */ +BOOL CBasePlayer::IsBombGuy(void) +{ + if (!g_pGameRules->IsMultiplayer()) + return FALSE; + + return m_bHasC4; +} + +/* <1544a1> ../cstrike/dlls/player.cpp:2636 */ +void CBasePlayer::SetAnimation(PLAYER_ANIM playerAnim) +{ + int animDesired; + float speed; + char szAnim[64]; + int hopSeq; + int leapSeq; + + if (!pev->modelindex) + return; + + if ((playerAnim == PLAYER_FLINCH || playerAnim == PLAYER_LARGE_FLINCH) && HasShield()) + return; + + if (playerAnim != PLAYER_FLINCH && playerAnim != PLAYER_LARGE_FLINCH && m_flFlinchTime > gpGlobals->time && pev->health > 0.0f) + return; + + speed = pev->velocity.Length2D(); + + if (pev->flags & FL_FROZEN) + { + speed = 0; + playerAnim = PLAYER_IDLE; + } + + hopSeq = LookupActivity(ACT_HOP); + leapSeq = LookupActivity(ACT_LEAP); + + switch (playerAnim) + { + case PLAYER_JUMP: + { + if (m_Activity == ACT_SWIM || m_Activity == ACT_DIESIMPLE || m_Activity == ACT_HOVER) + m_IdealActivity = m_Activity; + else + { + m_IdealActivity = ACT_HOP; + TheBots->OnEvent(EVENT_PLAYER_JUMPED, this); + } + break; + } + case PLAYER_SUPERJUMP: + { + if (m_Activity == ACT_SWIM || m_Activity == ACT_DIESIMPLE || m_Activity == ACT_HOVER) + m_IdealActivity = m_Activity; + else + m_IdealActivity = ACT_LEAP; + break; + } + case PLAYER_DIE: + { + m_IdealActivity = ACT_DIESIMPLE; + DeathSound(); + break; + } + case PLAYER_ATTACK1: + { + if (m_Activity == ACT_SWIM || m_Activity == ACT_DIESIMPLE || m_Activity == ACT_HOVER) + m_IdealActivity = m_Activity; + else + { + m_IdealActivity = ACT_RANGE_ATTACK1; + TheBots->OnEvent(EVENT_WEAPON_FIRED, this); + } + break; + } + case PLAYER_ATTACK2: + { + if (m_Activity == ACT_SWIM || m_Activity == ACT_DIESIMPLE || m_Activity == ACT_HOVER) + m_IdealActivity = m_Activity; + else + { + m_IdealActivity = ACT_RANGE_ATTACK2; + TheBots->OnEvent(EVENT_WEAPON_FIRED, this); + } + break; + } + case PLAYER_RELOAD: + { + if (m_Activity == ACT_SWIM || m_Activity == ACT_DIESIMPLE || m_Activity == ACT_HOVER) + m_IdealActivity = m_Activity; + else + { + m_IdealActivity = ACT_RELOAD; + TheBots->OnEvent(EVENT_WEAPON_RELOADED, this); + } + break; + } + case PLAYER_IDLE: + case PLAYER_WALK: + { + if (pev->flags & FL_ONGROUND || (m_Activity != ACT_HOP && m_Activity != ACT_LEAP)) + { + if (pev->waterlevel <= 1) + m_IdealActivity = ACT_WALK; + + else if (speed == 0.0f) + m_IdealActivity = ACT_HOVER; + + else + m_IdealActivity = ACT_SWIM; + } + else + m_IdealActivity = m_Activity; + break; + } + case PLAYER_HOLDBOMB: + m_IdealActivity = ACT_HOLDBOMB; + break; + case PLAYER_FLINCH: + m_IdealActivity = ACT_FLINCH; + break; + case PLAYER_LARGE_FLINCH: + m_IdealActivity = ACT_LARGE_FLINCH; + break; + default: + break; + } + switch (m_IdealActivity) + { + case ACT_HOP: + case ACT_LEAP: + { + if (m_Activity == m_IdealActivity) + return; + + switch (m_Activity) + { + case ACT_RANGE_ATTACK1: Q_strcpy(szAnim, "ref_shoot_"); break; + case ACT_RANGE_ATTACK2: Q_strcpy(szAnim, "ref_shoot2_"); break; + case ACT_RELOAD: Q_strcpy(szAnim, "ref_reload_"); break; + default: Q_strcpy(szAnim, "ref_aim_"); break; + } + + Q_strcat(szAnim, m_szAnimExtention); + animDesired = LookupSequence(szAnim); + if (animDesired == -1) + animDesired = 0; + + if (pev->sequence != animDesired || !m_fSequenceLoops) + pev->frame = 0; + + if (!m_fSequenceLoops) + pev->effects |= EF_NOINTERP; + + if (m_IdealActivity == ACT_LEAP) + pev->gaitsequence = LookupActivity(ACT_LEAP); + else + pev->gaitsequence = LookupActivity(ACT_HOP); + + m_Activity = m_IdealActivity; + break; + } + case ACT_RANGE_ATTACK1: + { + m_flLastFired = gpGlobals->time; + + if (pev->flags & FL_DUCKING) + Q_strcpy(szAnim, "crouch_shoot_"); + else + Q_strcpy(szAnim, "ref_shoot_"); + + Q_strcat(szAnim, m_szAnimExtention); + animDesired = LookupSequence(szAnim); + if (animDesired == -1) + animDesired = 0; + + pev->sequence = animDesired; + pev->frame = 0; + + ResetSequenceInfo(); + m_Activity = m_IdealActivity; + break; + } + case ACT_RANGE_ATTACK2: + { + m_flLastFired = gpGlobals->time; + + if (pev->flags & FL_DUCKING) + Q_strcpy(szAnim, "crouch_shoot2_"); + else + Q_strcpy(szAnim, "ref_shoot2_"); + + Q_strcat(szAnim, m_szAnimExtention); + animDesired = LookupSequence(szAnim); + if (animDesired == -1) + animDesired = 0; + + pev->sequence = animDesired; + pev->frame = 0; + + ResetSequenceInfo(); + m_Activity = m_IdealActivity; + break; + } + case ACT_RELOAD: + { + if (pev->flags & FL_DUCKING) + Q_strcpy(szAnim, "crouch_reload_"); + else + Q_strcpy(szAnim, "ref_reload_"); + + Q_strcat(szAnim, m_szAnimExtention); + animDesired = LookupSequence(szAnim); + if (animDesired == -1) + animDesired = 0; + + if (pev->sequence != animDesired || !m_fSequenceLoops) + pev->frame = 0; + + if (!m_fSequenceLoops) + pev->effects |= EF_NOINTERP; + + m_Activity = m_IdealActivity; + break; + } + case ACT_HOLDBOMB: + { + if (pev->flags & FL_DUCKING) + Q_strcpy(szAnim, "crouch_aim_"); + else + Q_strcpy(szAnim, "ref_aim_"); + + Q_strcat(szAnim, m_szAnimExtention); + animDesired = LookupSequence(szAnim); + if (animDesired == -1) + animDesired = 0; + + m_Activity = m_IdealActivity; + break; + } + case ACT_WALK: + { + if ((m_Activity != ACT_RANGE_ATTACK1 || m_fSequenceFinished) + && (m_Activity != ACT_RANGE_ATTACK2 || m_fSequenceFinished) + && (m_Activity != ACT_FLINCH || m_fSequenceFinished) + && (m_Activity != ACT_LARGE_FLINCH || m_fSequenceFinished) + && (m_Activity != ACT_RELOAD || m_fSequenceFinished)) + { + if (speed <= 135.0f || m_flLastFired + 4.0 >= gpGlobals->time) + { + if (pev->flags & FL_DUCKING) + Q_strcpy(szAnim, "crouch_aim_"); + else + Q_strcpy(szAnim, "ref_aim_"); + + Q_strcat(szAnim, m_szAnimExtention); + animDesired = LookupSequence(szAnim); + if (animDesired == -1) + animDesired = 0; + + m_Activity = ACT_WALK; + } + else + { + Q_strcpy(szAnim, "run_"); + Q_strcat(szAnim, m_szAnimExtention); + animDesired = LookupSequence(szAnim); + if (animDesired == -1) + { + if (pev->flags & FL_DUCKING) + Q_strcpy(szAnim, "crouch_aim_"); + else + Q_strcpy(szAnim, "ref_aim_"); + + Q_strcat(szAnim, m_szAnimExtention); + animDesired = LookupSequence(szAnim); + if (animDesired == -1) + animDesired = 0; + + m_Activity = ACT_RUN; + pev->gaitsequence = LookupActivity(ACT_RUN); + } + else + { + m_Activity = ACT_RUN; + pev->gaitsequence = animDesired; + } + if (m_Activity == ACT_RUN) + { + //TODO: maybe away used variable 'speed'? + //if (speed > 150.0f) + if (pev->velocity.Length2D() > 150.0f) + TheBots->OnEvent(EVENT_PLAYER_FOOTSTEP, this); + } + } + } + else + animDesired = pev->sequence; + + if (speed > 135.0f) + pev->gaitsequence = LookupActivity(ACT_RUN); + else + pev->gaitsequence = LookupActivity(ACT_WALK); + break; + } + case ACT_FLINCH: + case ACT_LARGE_FLINCH: + { + m_Activity = m_IdealActivity; + +#ifndef REGAMEDLL_FIXES + // TODO: why? this condition was checked! + if ((playerAnim == PLAYER_FLINCH || playerAnim == PLAYER_LARGE_FLINCH) && HasShield()) + return; +#endif // REGAMEDLL_FIXES + + switch (m_LastHitGroup) + { + case HITGROUP_GENERIC: + { + if (RANDOM_LONG(0, 1)) + animDesired = LookupSequence("head_flinch"); + else + animDesired = LookupSequence("gut_flinch"); + break; + } + case HITGROUP_HEAD: + case HITGROUP_CHEST: + animDesired = LookupSequence("head_flinch"); + break; + case HITGROUP_SHIELD: + animDesired = 0; + break; + default: + animDesired = LookupSequence("gut_flinch"); + break; + } + + if (animDesired == -1) + animDesired = 0; + + break; + } + case ACT_DIESIMPLE: + { + if (m_Activity == m_IdealActivity) + return; + + m_Activity = m_IdealActivity; + m_flDeathThrowTime = 0; + m_iThrowDirection = THROW_NONE; + + switch (m_LastHitGroup) + { + case HITGROUP_GENERIC: + { + switch (RANDOM_LONG(0, 8)) + { + case 0: + animDesired = LookupActivity(ACT_DIE_HEADSHOT); + m_iThrowDirection = THROW_BACKWARD; + break; + case 1: + animDesired = LookupActivity(ACT_DIE_GUTSHOT); + break; + case 2: + animDesired = LookupActivity(ACT_DIE_BACKSHOT); + m_iThrowDirection = THROW_HITVEL; + break; + case 3: + animDesired = LookupActivity(ACT_DIESIMPLE); + break; + case 4: + animDesired = LookupActivity(ACT_DIEBACKWARD); + m_iThrowDirection = THROW_HITVEL; + break; + case 5: + animDesired = LookupActivity(ACT_DIEFORWARD); + m_iThrowDirection = THROW_FORWARD; + break; + case 6: + animDesired = LookupActivity(ACT_DIE_CHESTSHOT); + break; + case 7: + animDesired = LookupActivity(ACT_DIE_GUTSHOT); + break; + case 8: + animDesired = LookupActivity(ACT_DIE_HEADSHOT); + break; + default: + break; + } + break; + } + case HITGROUP_HEAD: + { + int random = RANDOM_LONG(0, 8); + m_bHeadshotKilled = true; + + if (m_bHighDamage) + ++random; + + switch (random) + { + case 1: + case 2: + m_iThrowDirection = THROW_BACKWARD; + break; + case 3: + case 4: + m_iThrowDirection = THROW_FORWARD; + break; + case 5: + case 6: + m_iThrowDirection = THROW_HITVEL; + break; + default: + m_iThrowDirection = THROW_NONE; + break; + } + + animDesired = LookupActivity(ACT_DIE_HEADSHOT); + break; + } + case HITGROUP_CHEST: + animDesired = LookupActivity(ACT_DIE_CHESTSHOT); + break; + case HITGROUP_STOMACH: + animDesired = LookupActivity(ACT_DIE_GUTSHOT); + break; + case HITGROUP_LEFTARM: + animDesired = LookupSequence("left"); + break; + case HITGROUP_RIGHTARM: + { + m_iThrowDirection = RANDOM_LONG(0, 1) ? THROW_HITVEL : THROW_HITVEL_MINUS_AIRVEL; + animDesired = LookupSequence("right"); + break; + } + default: + { + animDesired = LookupActivity(ACT_DIESIMPLE); + break; + } + } + if (pev->flags & FL_DUCKING) + { + animDesired = LookupSequence("crouch_die"); + m_iThrowDirection = THROW_BACKWARD; + } + else if (m_bKilledByBomb || m_bKilledByGrenade) + { + UTIL_MakeVectors(pev->angles); + + if (DotProduct(gpGlobals->v_forward, m_vBlastVector) > 0.0f) + animDesired = LookupSequence("left"); + + else + { + if (RANDOM_LONG(0, 1)) + animDesired = LookupSequence("crouch_die"); + else + animDesired = LookupActivity(ACT_DIE_HEADSHOT); + } + + if (m_bKilledByBomb) + m_iThrowDirection = THROW_BOMB; + + else if (m_bKilledByGrenade) + m_iThrowDirection = THROW_GRENADE; + } + + if (animDesired == -1) + animDesired = 0; + + if (pev->sequence != animDesired) + { + pev->gaitsequence = 0; + pev->sequence = animDesired; + pev->frame = 0.0f; + ResetSequenceInfo(); + } + return; + } + default: + { + if (m_Activity == m_IdealActivity) + return; + + m_Activity = m_IdealActivity; + animDesired = LookupActivity(m_IdealActivity); + + if (pev->sequence != animDesired) + { + pev->gaitsequence = 0; + pev->sequence = animDesired; + pev->frame = 0; + + ResetSequenceInfo(); + } + return; + } + } + + if (pev->gaitsequence != hopSeq && pev->gaitsequence != leapSeq) + { + if (pev->flags & FL_DUCKING) + { + if (speed != 0.0f) + pev->gaitsequence = LookupActivity(ACT_CROUCH); + else + pev->gaitsequence = LookupActivity(ACT_CROUCHIDLE); + } + else + { + if (speed > 135.0f) + { + if (m_flLastFired + 4.0f < gpGlobals->time) + { + if (m_Activity != ACT_FLINCH && m_Activity != ACT_LARGE_FLINCH) + { + Q_strcpy(szAnim, "run_"); + Q_strcat(szAnim, m_szAnimExtention); + + animDesired = LookupSequence(szAnim); + if (animDesired == -1) + { + if (pev->flags & FL_DUCKING) + Q_strcpy(szAnim, "crouch_aim_"); + else + Q_strcpy(szAnim, "ref_aim_"); + + Q_strcat(szAnim, m_szAnimExtention); + animDesired = LookupSequence(szAnim); + } + else + pev->gaitsequence = animDesired; + + m_Activity = ACT_RUN; + } + } + pev->gaitsequence = LookupActivity(ACT_RUN); + } + else + { + if (speed > 0.0f) + pev->gaitsequence = LookupActivity(ACT_WALK); + else + pev->gaitsequence = LookupActivity(ACT_IDLE); + } + } + } + if (pev->sequence != animDesired) + { + pev->sequence = animDesired; + pev->frame = 0; + + ResetSequenceInfo(); + } +} + +/* <1544f4> ../cstrike/dlls/player.cpp:3264 */ +void CBasePlayer::WaterMove(void) +{ + int air; + + if (pev->movetype == MOVETYPE_NOCLIP || pev->movetype == MOVETYPE_NONE) + return; + + if (pev->health < 0.0f) + return; + + // waterlevel 0 - not in water + // waterlevel 1 - feet in water + // waterlevel 2 - waist in water + // waterlevel 3 - head in water + + if (pev->waterlevel != 3) + { + // not underwater + + // play 'up for air' sound + if (pev->air_finished < gpGlobals->time) + EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_wade1.wav", VOL_NORM, ATTN_NORM); + + else if (pev->air_finished < gpGlobals->time + 9) + EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_wade2.wav", VOL_NORM, ATTN_NORM); + + pev->air_finished = gpGlobals->time + AIRTIME; + pev->dmg = 2; + + // if we took drowning damage, give it back slowly + if (m_idrowndmg > m_idrownrestored) + { + // set drowning damage bit. hack - dmg_drownrecover actually + // makes the time based damage code 'give back' health over time. + // make sure counter is cleared so we start count correctly. + + // NOTE: this actually causes the count to continue restarting + // until all drowning damage is healed. + m_rgbTimeBasedDamage[ itbd_DrownRecover ] = 0; + m_bitsDamageType |= DMG_DROWNRECOVER; + m_bitsDamageType &= ~DMG_DROWN; + + } + } + else + { + // fully under water + // stop restoring damage while underwater + m_rgbTimeBasedDamage[ itbd_DrownRecover ] = 0; + m_bitsDamageType &= ~DMG_DROWNRECOVER; + + // drown! + if (gpGlobals->time > pev->air_finished) + { + if (gpGlobals->time > pev->pain_finished) + { + // take drowning damage + pev->dmg += 1; + + if (pev->dmg > 5) + pev->dmg = 5; + + TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), pev->dmg, DMG_DROWN); + pev->pain_finished = gpGlobals->time + 1; + + // track drowning damage, give it back when + // player finally takes a breath + m_idrowndmg += pev->dmg; + } + } + else + m_bitsDamageType &= ~(DMG_DROWNRECOVER | DMG_DROWN); + } + + if (!pev->waterlevel) + { + if (pev->flags & FL_INWATER) + pev->flags &= ~FL_INWATER; + + return; + } + + // make bubbles + air = (int)(pev->air_finished - gpGlobals->time); + + if (!RANDOM_LONG(0, 0x1f) && RANDOM_LONG(0, AIRTIME - 1) >= air) + { + switch (RANDOM_LONG(0, 3)) + { + case 0: EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_swim1.wav", 0.8, ATTN_NORM); break; + case 1: EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_swim2.wav", 0.8, ATTN_NORM); break; + case 2: EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_swim3.wav", 0.8, ATTN_NORM); break; + case 3: EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_swim4.wav", 0.8, ATTN_NORM); break; + } + } + + if (pev->watertype == CONTENT_LAVA) // do damage + { + if (pev->dmgtime < gpGlobals->time) + TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), pev->waterlevel * 10, DMG_BURN); + } + else if (pev->watertype == CONTENT_SLIME) // do damage + { + pev->dmgtime = gpGlobals->time + 1; + TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), pev->waterlevel * 4, DMG_ACID); + } + if (!(pev->flags & FL_INWATER)) + { + pev->flags |= FL_INWATER; + pev->dmgtime = 0; + } +} + +/* <15493f> ../cstrike/dlls/player.cpp:3380 */ +BOOL CBasePlayer::IsOnLadder(void) +{ + return pev->movetype == MOVETYPE_FLY; +} + +/* <160720> ../cstrike/dlls/player.cpp:3387 */ +NOXREF void CBasePlayer::ThrowWeapon(char *pszItemName) +{ + for (int i = 0; i < MAX_WEAPON_SLOTS; i++) + { + CBasePlayerItem *pWeapon = m_rgpPlayerItems[i]; + + while (pWeapon != NULL) + { + if (!Q_strcmp(pszItemName, STRING(pWeapon->pev->classname))) + { + DropPlayerItem(pszItemName); + return; + } + + pWeapon = pWeapon->m_pNext; + } + } +} + +/* <154967> ../cstrike/dlls/player.cpp:3424 */ +LINK_ENTITY_TO_CLASS(weapon_shield, CWShield); + +/* <151962> ../cstrike/dlls/player.cpp:3426 */ +void CWShield::__MAKE_VHOOK(Spawn)(void) +{ + pev->movetype = MOVETYPE_TOSS; + pev->solid = SOLID_TRIGGER; + + UTIL_SetSize(pev, g_vecZero, g_vecZero); + SET_MODEL(ENT(pev), "models/w_shield.mdl"); +} + +/* <152e95> ../cstrike/dlls/player.cpp:3436 */ +void CWShield::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) +{ + if (!pOther->IsPlayer()) + return; + + CBasePlayer *pPlayer = (CBasePlayer *)pOther; + + if (pPlayer->pev->deadflag != DEAD_NO) + return; + + if (m_hEntToIgnoreTouchesFrom != NULL && pPlayer == (CBasePlayer *)((CBaseEntity *)m_hEntToIgnoreTouchesFrom)) + { + if (m_flTimeToIgnoreTouches > gpGlobals->time) + return; + + m_hEntToIgnoreTouchesFrom = NULL; + } + + if (!pPlayer->m_bHasPrimary) + { + if (pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ] != NULL && pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]->m_iId == WEAPON_ELITE) + return; + + if (pPlayer->m_pActiveItem) + { + if (!pPlayer->m_pActiveItem->CanHolster()) + return; + } + + if (!pPlayer->m_bIsVIP) + { + pPlayer->GiveShield(); + + EMIT_SOUND(edict(), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM); + UTIL_Remove(this); + + pev->nextthink = gpGlobals->time + 0.1; + } + } +} + +/* <154a43> ../cstrike/dlls/player.cpp:3480 */ +void CBasePlayer::GiveShield(bool bDeploy) +{ + m_bOwnsShield = true; + m_bHasPrimary = true; + + if (m_pActiveItem != NULL) + { + CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; + + if (bDeploy) + { + if (m_rgAmmo[ pWeapon->m_iPrimaryAmmoType ] > 0) + pWeapon->Holster(); + + if (!pWeapon->Deploy()) + pWeapon->RetireWeapon(); + } + } + + pev->gamestate = 0; +} + +/* <154a70> ../cstrike/dlls/player.cpp:3504 */ +void CBasePlayer::RemoveShield(void) +{ + if (HasShield()) + { + m_bOwnsShield = false; + m_bHasPrimary = false; + m_bShieldDrawn = false; + pev->gamestate = 1; + + UpdateShieldCrosshair(true); + } +} + +/* <154ad5> ../cstrike/dlls/player.cpp:3521 */ +void CBasePlayer::DropShield(bool bDeploy) +{ + if (!HasShield()) + return; + + if (m_pActiveItem && !m_pActiveItem->CanHolster()) + return; + + if (m_pActiveItem) + { + CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; + + if (pWeapon->m_iId == WEAPON_HEGRENADE || pWeapon->m_iId == WEAPON_FLASHBANG || pWeapon->m_iId == WEAPON_SMOKEGRENADE) + { + if (m_rgAmmo[ pWeapon->m_iPrimaryAmmoType ] <= 0) + g_pGameRules->GetNextBestWeapon(this, pWeapon); + } + } + + if (m_pActiveItem) + { + CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; + + if (pWeapon->m_flStartThrow != 0) + m_pActiveItem->Holster(); + } + + if (IsReloading()) + { + CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; + + pWeapon->m_fInReload = FALSE; + m_flNextAttack = 0; + } + + if (IsProtectedByShield() && m_pActiveItem) + ((CBasePlayerWeapon *)m_pActiveItem)->SecondaryAttack(); + + m_bShieldDrawn = false; + + RemoveShield(); + + if (m_pActiveItem && bDeploy) + m_pActiveItem->Deploy(); + + UTIL_MakeVectors(pev->angles); + + CWShield *pShield = (CWShield *)CBaseEntity::Create("weapon_shield", pev->origin + gpGlobals->v_forward * 10, pev->angles, edict()); + + pShield->pev->angles.x = 0; + pShield->pev->angles.z = 0; + + pShield->pev->velocity = gpGlobals->v_forward * 400; + + pShield->SetThink(&CBaseEntity::SUB_Remove); + pShield->pev->nextthink = gpGlobals->time + 300; + + pShield->SetCantBePickedUpByUser(this, 2.0); +} + +/* <154b15> ../cstrike/dlls/player.cpp:3588 */ +bool CBasePlayer::HasShield(void) +{ + return m_bOwnsShield; +} + +/* <1615d2> ../cstrike/dlls/player.cpp:3593 */ +NOXREF void CBasePlayer::ThrowPrimary(void) +{ + ThrowWeapon("weapon_m249"); + ThrowWeapon("weapon_g3sg1"); + ThrowWeapon("weapon_sg550"); + ThrowWeapon("weapon_awp"); + ThrowWeapon("weapon_mp5navy"); + ThrowWeapon("weapon_tmp"); + ThrowWeapon("weapon_p90"); + ThrowWeapon("weapon_ump45"); + ThrowWeapon("weapon_m4a1"); + ThrowWeapon("weapon_m3"); + ThrowWeapon("weapon_sg552"); + ThrowWeapon("weapon_scout"); + ThrowWeapon("weapon_galil"); + ThrowWeapon("weapon_famas"); + + DropShield(); +} + +/* <154b6d> ../cstrike/dlls/player.cpp:3624 */ +void CBasePlayer::AddAccount(int amount, bool bTrackChange) +{ + m_iAccount += amount; + + if (m_iAccount < 0) + m_iAccount = 0; + + else if (m_iAccount > 16000) + m_iAccount = 16000; + + // Send money update to HUD + MESSAGE_BEGIN(MSG_ONE, gmsgMoney, NULL, pev); + WRITE_LONG(m_iAccount); + WRITE_BYTE(bTrackChange); + MESSAGE_END(); +} + +/* <154bf8> ../cstrike/dlls/player.cpp:3640 */ +void CBasePlayer::ResetMenu(void) +{ + MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pev); + WRITE_SHORT(0); + WRITE_CHAR(0); + WRITE_BYTE(0); + WRITE_STRING(""); + MESSAGE_END(); + +#ifdef REGAMEDLL_FIXES + m_iMenu = Menu_OFF; +#endif // REGAMEDLL_FIXES + +} + +/* <154c50> ../cstrike/dlls/player.cpp:3651 */ +void CBasePlayer::SyncRoundTimer(void) +{ + float tmRemaining; + CHalfLifeMultiplay *mp = g_pGameRules; + + if (mp->IsMultiplayer()) + tmRemaining = mp->TimeRemaining(); + else + tmRemaining = 0; + + if (tmRemaining < 0) + tmRemaining = 0; + + MESSAGE_BEGIN(MSG_ONE, gmsgRoundTime, NULL, pev); + WRITE_SHORT((int)tmRemaining); + MESSAGE_END(); + + if (!mp->IsMultiplayer()) + return; + + if (mp->IsFreezePeriod() && TheTutor != NULL && !IsObserver()) + { + MESSAGE_BEGIN(MSG_ONE, gmsgBlinkAcct, NULL, pev); + WRITE_BYTE(MONEY_BLINK_AMOUNT); + MESSAGE_END(); + } + + if (mp->IsCareer()) + { + int remaining = 0; + bool shouldCountDown = false; + int fadeOutDelay = 0; + + if (tmRemaining != 0.0f) + { + remaining = TheCareerTasks->GetTaskTime() - (gpGlobals->time - mp->m_fRoundCount); + } + + if (remaining < 0) + remaining = 0; + + if (mp->IsFreezePeriod()) + remaining = -1; + + if (TheCareerTasks->GetFinishedTaskTime()) + remaining = -TheCareerTasks->GetFinishedTaskTime(); + + if (!mp->IsFreezePeriod() && !TheCareerTasks->GetFinishedTaskTime()) + { + shouldCountDown = true; + } + if (!mp->IsFreezePeriod()) + { + if (TheCareerTasks->GetFinishedTaskTime() || (TheCareerTasks->GetTaskTime() <= TheCareerTasks->GetRoundElapsedTime())) + { + fadeOutDelay = 3; + } + } + + if (!TheCareerTasks->GetFinishedTaskTime() || TheCareerTasks->GetFinishedTaskRound() == mp->m_iTotalRoundsPlayed) + { + MESSAGE_BEGIN(MSG_ONE, gmsgTaskTime, NULL, pev); + WRITE_SHORT(remaining); // remaining of time, -1 the timer is disappears + WRITE_BYTE(shouldCountDown); // timer counts down + WRITE_BYTE(fadeOutDelay); // fade in time, hide HUD timer after the expiration time + MESSAGE_END(); + } + } +} + +/* <154db6> ../cstrike/dlls/player.cpp:3711 */ +void CBasePlayer::RemoveLevelText(void) +{ + ResetMenu(); +} + +void ShowMenu2(CBasePlayer *pPlayer, int bitsValidSlots, int nDisplayTime, int fNeedMore, char *pszText) +{ + MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pPlayer->pev); + WRITE_SHORT(bitsValidSlots); + WRITE_CHAR(nDisplayTime); + WRITE_BYTE(fNeedMore); + WRITE_STRING(pszText); + MESSAGE_END(); +} + +/* <154e29> ../cstrike/dlls/player.cpp:3721 */ +void WINAPI_HOOK CBasePlayer::MenuPrint(const char *msg) +{ + const char *msg_portion = msg; + char sbuf[MAX_BUFFER_MENU_BRIEFING + 1]; + + while (Q_strlen(msg_portion) >= MAX_BUFFER_MENU_BRIEFING) + { + Q_strncpy(sbuf, msg_portion, MAX_BUFFER_MENU_BRIEFING); + sbuf[ MAX_BUFFER_MENU_BRIEFING ] = '\0'; + msg_portion += MAX_BUFFER_MENU_BRIEFING; + + MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pev); + WRITE_SHORT(0xFFFF); + WRITE_CHAR(-1); + WRITE_BYTE(1); // multipart + WRITE_STRING(sbuf); + MESSAGE_END(); + } + + MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pev); + WRITE_SHORT(0xFFFF); + WRITE_CHAR(-1); + WRITE_BYTE(0); // multipart + WRITE_STRING(msg_portion); + MESSAGE_END(); +} + +/* <154f3d> ../cstrike/dlls/player.cpp:3753 */ +void CBasePlayer::MakeVIP(void) +{ + pev->body = 0; + m_iModelName = MODEL_VIP; + + SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "vip"); + UTIL_LogPrintf("\"%s<%i><%s>\" triggered \"Became_VIP\"\n", STRING(pev->netname), GETPLAYERUSERID(edict()), GETPLAYERAUTHID(edict())); + + m_iTeam = CT; + m_bIsVIP = true; + m_bNotKilled = false; + + g_pGameRules->m_pVIP = this; + g_pGameRules->m_iConsecutiveVIP = 1; +} + +/* <154fe5> ../cstrike/dlls/player.cpp:3785 */ +void CBasePlayer::JoiningThink(void) +{ + switch (m_iJoiningState) + { + case JOINED: + { + return; + } + case SHOWLTEXT: + { + ResetMenu(); + m_iJoiningState = SHOWTEAMSELECT; + + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + WRITE_BYTE(STATUSICON_HIDE); + WRITE_STRING("defuser"); + MESSAGE_END(); + + m_bHasDefuser = false; + m_fLastMovement = gpGlobals->time; + m_bMissionBriefing = false; + + SendItemStatus(this); + break; + } + case READINGLTEXT: + { + if (m_afButtonPressed & (IN_ATTACK | IN_ATTACK2 | IN_JUMP)) + { + m_afButtonPressed &= ~(IN_ATTACK | IN_ATTACK2 | IN_JUMP); + + RemoveLevelText(); + m_iJoiningState = SHOWTEAMSELECT; + } + + break; + } + case GETINTOGAME: + { + CHalfLifeMultiplay *mp = g_pGameRules; + + m_bNotKilled = false; + m_iIgnoreGlobalChat = IGNOREMSG_NONE; + + m_iTeamKills = 0; + m_iFOV = DEFAULT_FOV; + + Q_memset(&m_rebuyStruct, 0, sizeof(m_rebuyStruct)); + + m_bIsInRebuy = false; + m_bJustConnected = false; + m_fLastMovement = gpGlobals->time; + + ResetMaxSpeed(); + m_iJoiningState = JOINED; + + if (mp->m_bMapHasEscapeZone && m_iTeam == CT) + { + m_iAccount = 0; + CheckStartMoney(); + AddAccount(startmoney.value); + } + + if (mp->FPlayerCanRespawn(this)) + { + Spawn(); + + mp->CheckWinConditions(); + + if (!mp->m_fTeamCount && mp->m_bMapHasBombTarget && !mp->IsThereABomber() && !mp->IsThereABomb()) + { + mp->GiveC4(); + } + if (m_iTeam == TERRORIST) + { + mp->m_iNumEscapers++; + } + } + else + { + pev->deadflag = DEAD_RESPAWNABLE; + + if (pev->classname) + { + RemoveEntityHashValue(pev, STRING(pev->classname), CLASSNAME); + } + + MAKE_STRING_CLASS("player", pev); + AddEntityHashValue(pev, STRING(pev->classname), CLASSNAME); + + pev->flags &= (FL_PROXY | FL_FAKECLIENT); + pev->flags |= (FL_SPECTATOR | FL_CLIENT); + + edict_t *pentSpawnSpot = mp->GetPlayerSpawnSpot(this); + StartObserver(pev->origin, VARS(pentSpawnSpot)->angles); + + mp->CheckWinConditions(); + + MESSAGE_BEGIN(MSG_ALL, gmsgTeamInfo); + WRITE_BYTE(entindex()); + switch (m_iTeam) + { + case CT: + WRITE_STRING("CT"); + break; + case TERRORIST: + WRITE_STRING("TERRORIST"); + break; + case SPECTATOR: + WRITE_STRING("SPECTATOR"); + break; + default: + WRITE_STRING("UNASSIGNED"); + break; + } + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_ALL, gmsgLocation); + WRITE_BYTE(entindex()); + WRITE_STRING(""); + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_ALL, gmsgScoreInfo); + WRITE_BYTE(ENTINDEX(edict())); + WRITE_SHORT((int)pev->frags); + WRITE_SHORT(m_iDeaths); + WRITE_SHORT(0); + WRITE_SHORT(m_iTeam); + MESSAGE_END(); + + if (!(m_flDisplayHistory & DHF_SPEC_DUCK)) + { + HintMessage("#Spec_Duck", TRUE, TRUE); + m_flDisplayHistory |= DHF_SPEC_DUCK; + } + } + + return; + } + } + + if (m_pIntroCamera && gpGlobals->time >= m_fIntroCamTime) + { + m_pIntroCamera = UTIL_FindEntityByClassname(m_pIntroCamera, "trigger_camera"); + + if (!m_pIntroCamera) + { + m_pIntroCamera = UTIL_FindEntityByClassname(NULL, "trigger_camera"); + } + + CBaseEntity *Target = UTIL_FindEntityByTargetname(NULL, STRING(m_pIntroCamera->pev->target)); + + if (Target) + { + Vector CamAngles = UTIL_VecToAngles((Target->pev->origin - m_pIntroCamera->pev->origin).Normalize()); + + CamAngles.x = -CamAngles.x; + UTIL_SetOrigin(pev, m_pIntroCamera->pev->origin); + + pev->angles = CamAngles; + pev->v_angle = pev->angles; + + pev->velocity = g_vecZero; + pev->punchangle = g_vecZero; + + pev->fixangle = 1; + pev->view_ofs = g_vecZero; + m_fIntroCamTime = gpGlobals->time + 6; + } + else + m_pIntroCamera = NULL; + } +} + +/* <16076f> ../cstrike/dlls/player.cpp:3952 */ +void CBasePlayer::Disappear(void) +{ + if (m_pTank != NULL) + { + m_pTank->Use(this, this, USE_OFF, 0); + m_pTank = NULL; + } + + CSound *pSound = CSoundEnt::SoundPointerForIndex(CSoundEnt::ClientSoundIndex(edict())); + + if (pSound) + { + pSound->Reset(); + } + + m_fSequenceFinished = TRUE; + pev->modelindex = m_modelIndexPlayer; + pev->view_ofs = Vector(0, 0, -8); + pev->deadflag = DEAD_DYING; + pev->solid = SOLID_NOT; + pev->flags &= ~FL_ONGROUND; + + SetSuitUpdate(NULL, FALSE, 0); + + m_iClientHealth = 0; + MESSAGE_BEGIN(MSG_ONE, gmsgHealth, NULL, pev); + WRITE_BYTE(m_iClientHealth); + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev); + WRITE_BYTE(0); + WRITE_BYTE(0xFF); + WRITE_BYTE(0xFF); + MESSAGE_END(); + + SendFOV(0); + + g_pGameRules->CheckWinConditions(); + m_bNotKilled = false; + + if (m_bHasC4) + { + DropPlayerItem("weapon_c4"); + SetProgressBarTime(0); + } + else if (m_bHasDefuser) + { + m_bHasDefuser = false; + pev->body = 0; + GiveNamedItem("item_thighpack"); + + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + WRITE_BYTE(STATUSICON_HIDE); + WRITE_STRING("defuser"); + MESSAGE_END(); + + SendItemStatus(this); + SetProgressBarTime(0); + } + + BuyZoneIcon_Clear(this); + + SetThink(&CBasePlayer::PlayerDeathThink); + pev->nextthink = gpGlobals->time + 0.1f; + + pev->angles.x = 0; + pev->angles.z = 0; +} + +/* <15f83d> ../cstrike/dlls/player.cpp:4039 */ +void CBasePlayer::PlayerDeathThink(void) +{ + if (m_iJoiningState != JOINED) + return; + + if (pev->flags & FL_ONGROUND) + { + float flForward = pev->velocity.Length() - 20; + + if (flForward <= 0) + pev->velocity = g_vecZero; + else + pev->velocity = flForward * pev->velocity.Normalize(); + } + + if (HasWeapons()) + { + // we drop the guns here because weapons that have an area effect and can kill their user + // will sometimes crash coming back from CBasePlayer::Killed() if they kill their owner because the + // player class sometimes is freed. It's safer to manipulate the weapons once we know + // we aren't calling into any of their code anymore through the player pointer. + PackDeadPlayerItems(); + } + + if (pev->modelindex && !m_fSequenceFinished && pev->deadflag == DEAD_DYING) + { + StudioFrameAdvance(); + return; + } + + // once we're done animating our death and we're on the ground, we want to set movetype to None so our dead body won't do collisions and stuff anymore + // this prevents a bug where the dead body would go to a player's head if he walked over it while the dead player was clicking their button to respawn + if (pev->movetype != MOVETYPE_NONE && (pev->flags & FL_ONGROUND)) + pev->movetype = MOVETYPE_NONE; + + if (pev->deadflag == DEAD_DYING) + { + m_fDeadTime = gpGlobals->time; + pev->deadflag = DEAD_DEAD; + } + + StopAnimation(); + pev->effects |= EF_NOINTERP; + + BOOL fAnyButtonDown = (pev->button & ~IN_SCORE); + + // if the player has been dead for one second longer than allowed by forcerespawn, + // forcerespawn isn't on. Send the player off to an intermission camera until they + // choose to respawn. + if (g_pGameRules->IsMultiplayer()) + { + if (gpGlobals->time > m_fDeadTime + 3.0 && !(m_afPhysicsFlags & PFLAG_OBSERVER)) + { + SpawnClientSideCorpse(); + StartDeathCam(); // go to dead camera. + } + } + + // wait for all buttons released + if (pev->deadflag == DEAD_DEAD && m_iTeam != UNASSIGNED && m_iTeam != SPECTATOR) + { + if (fAnyButtonDown) + return; + + if (g_pGameRules->FPlayerCanRespawn(this)) + { + pev->deadflag = DEAD_RESPAWNABLE; + + if (g_pGameRules->IsMultiplayer()) + g_pGameRules->CheckWinConditions(); + } + + pev->nextthink = gpGlobals->time + 0.1; + } + else if (pev->deadflag == DEAD_RESPAWNABLE) + { + respawn(pev, FALSE); + pev->button = 0; + pev->nextthink = -1; + } +} + +/* <153042> ../cstrike/dlls/player.cpp:4134 */ +void CBasePlayer::__MAKE_VHOOK(RoundRespawn)(void) +{ + m_canSwitchObserverModes = true; + + // teamkill punishment.. + if (m_bJustKilledTeammate && CVAR_GET_FLOAT("mp_tkpunish")) + { + m_bJustKilledTeammate = false; +#ifndef REGAMEDLL_FIXES + // TODO: wtf? + CLIENT_COMMAND(edict(), "kill\n"); +#else + if (pev->health > 0.0f) + { + ClientKill(ENT(pev)); + } +#endif // REGAMEDLL_FIXES + m_bPunishedForTK = true; + } + if (m_iMenu != Menu_ChooseAppearance) + { + respawn(pev); + + pev->button = 0; + pev->nextthink = -1; + } + + if (m_pActiveItem) + { + if (m_pActiveItem->iItemSlot() == GRENADE_SLOT) + { + SwitchWeapon(m_pActiveItem); + } + } + + m_lastLocation[0] = '\0'; +} + +/* <155577> ../cstrike/dlls/player.cpp:4172 */ +void CBasePlayer::StartDeathCam(void) +{ + if (pev->view_ofs == g_vecZero) + { + // don't accept subsequent attempts to StartDeathCam() + return; + } + + StartObserver(pev->origin, pev->angles); + + if (TheBots) + { + TheBots->OnEvent(EVENT_DEATH_CAMERA_START, this); + } +} + +/* <155616> ../cstrike/dlls/player.cpp:4190 */ +void CBasePlayer::StartObserver(Vector vecPosition, Vector vecViewAngle) +{ + // clear any clientside entities attached to this player + MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, pev->origin); + WRITE_BYTE(TE_KILLPLAYERATTACHMENTS); + WRITE_BYTE(entindex()); + MESSAGE_END(); + + // Holster weapon immediately, to allow it to cleanup + if (m_pActiveItem) + m_pActiveItem->Holster(); + + if (m_pTank) + { + m_pTank->Use(this, this); + m_pTank = NULL; + } + + // clear out the suit message cache so we don't keep chattering + SetSuitUpdate(); + + // Tell Ammo Hud that the player is dead + MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev); + WRITE_BYTE(0); + WRITE_BYTE(0xFF); + WRITE_BYTE(0xFF); + MESSAGE_END(); + + // reset FOV + SendFOV(0); + + // Setup flags + m_iHideHUD = (HIDEHUD_WEAPONS | HIDEHUD_HEALTH); + m_afPhysicsFlags |= PFLAG_OBSERVER; + + pev->effects = EF_NODRAW; + pev->view_ofs = g_vecZero; + + pev->angles = pev->v_angle = vecViewAngle; + + pev->fixangle = 1; + pev->solid = SOLID_NOT; + + pev->takedamage = DAMAGE_NO; + pev->movetype = MOVETYPE_NONE; + + // Move them to the new position + UTIL_SetOrigin(pev, vecPosition); + + m_afPhysicsFlags &= ~PFLAG_DUCKING; + pev->flags &= ~FL_DUCKING; + pev->health = 1; + + m_iObserverC4State = 0; + m_bObserverHasDefuser = false; + + m_iObserverWeapon = 0; + m_flNextObserverInput = 0; + + pev->iuser1 = OBS_NONE; + + static int iFirstTime = 1; + CHalfLifeMultiplay *mp = g_pGameRules; + + if (iFirstTime && mp && mp->IsCareer() && !IsBot()) + { + Observer_SetMode(OBS_CHASE_LOCKED); + CLIENT_COMMAND(edict(), "spec_autodirector_internal 1\n"); + iFirstTime = 0; + } + else + Observer_SetMode(m_iObserverLastMode); + + ResetMaxSpeed(); + + // Tell all clients this player is now a spectator + MESSAGE_BEGIN(MSG_ALL, gmsgSpectator); + WRITE_BYTE(entindex()); + WRITE_BYTE(1); + MESSAGE_END(); +} + +/* <14d785> ../cstrike/dlls/player.cpp:4272 */ +bool CanSeeUseable(CBasePlayer *me, CBaseEntity *entity) +{ + TraceResult result; + Vector eye = me->pev->origin + me->pev->view_ofs; + + if (FClassnameIs(entity->pev, "hostage_entity")) + { + Vector chest = entity->pev->origin + Vector(0, 0, 36); + Vector head = entity->pev->origin + Vector(0, 0, 72 * 0.9); + Vector knees = entity->pev->origin + Vector(0, 0, 18); + + UTIL_TraceLine(eye, chest, ignore_monsters, ignore_glass, me->edict(), &result); + if (result.flFraction < 1.0f) + { + UTIL_TraceLine(eye, head, ignore_monsters, ignore_glass, entity->edict(), &result); + if (result.flFraction < 1.0f) + { + UTIL_TraceLine(eye, knees, ignore_monsters, ignore_glass, entity->edict(), &result); + if (result.flFraction < 1.0f) + { + return false; + } + } + } + } + + return true; +} + +/* <155815> ../cstrike/dlls/player.cpp:4307 */ +void CBasePlayer::PlayerUse(void) +{ + // Was use pressed or released? + if (!((pev->button | m_afButtonPressed | m_afButtonReleased) & IN_USE)) + return; + + // Hit Use on a train? + if (m_afButtonPressed & IN_USE) + { + if (m_pTank != NULL) + { + // Stop controlling the tank + // TODO: Send HUD Update + m_pTank->Use(this, this, USE_OFF, 0); + m_pTank = NULL; + return; + } + + if (m_afPhysicsFlags & PFLAG_ONTRAIN) + { + m_iTrain = (TRAIN_NEW | TRAIN_OFF); + m_afPhysicsFlags &= ~PFLAG_ONTRAIN; + + CBaseEntity *pTrain = Instance(pev->groundentity); + if (pTrain && pTrain->Classify() == CLASS_VEHICLE) + { + ((CFuncVehicle *)pTrain)->m_pDriver = NULL; + } + return; + } + else + { + // Start controlling the train! + CBaseEntity *pTrain = Instance(pev->groundentity); + + if (pTrain && !(pev->button & IN_JUMP) && (pev->flags & FL_ONGROUND) && (pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE) && pTrain->OnControls(pev)) + { + m_afPhysicsFlags |= PFLAG_ONTRAIN; + + m_iTrain = TrainSpeed(pTrain->pev->speed, pTrain->pev->impulse); + m_iTrain |= TRAIN_NEW; + + if (pTrain->Classify() == CLASS_VEHICLE) + { + EMIT_SOUND(ENT(pev), CHAN_ITEM, "plats/vehicle_ignition.wav", 0.8, ATTN_NORM); + ((CFuncVehicle *)pTrain)->m_pDriver = this; + } + else + EMIT_SOUND(ENT(pev), CHAN_ITEM, "plats/train_use1.wav", 0.8, ATTN_NORM); + + return; + } + } + } + + bool useNewHostages = !TheNavAreaList.empty(); + CBaseEntity *pObject = NULL; + CBaseEntity *pClosest = NULL; + Vector vecLOS; + float flMaxDot = VIEW_FIELD_NARROW; + float flDot; + + // so we know which way we are facing + UTIL_MakeVectors(pev->v_angle); + + if (useNewHostages) + { + TraceResult result; + const float useHostageRange = 1000.0f; + + Vector vecStart = pev->origin + pev->view_ofs; + Vector vecEnd = vecStart + gpGlobals->v_forward * useHostageRange; + + UTIL_TraceLine(vecStart, vecEnd, dont_ignore_monsters, edict(), &result); + + if (result.flFraction < 1.0f) + { + CBaseEntity *hit = Instance(result.pHit); + if (hit != NULL && FClassnameIs(hit->pev, "hostage_entity") && CanSeeUseable(this, hit)) + pClosest = hit; + } + + if (!pClosest) + { + while ((pObject = UTIL_FindEntityInSphere(pObject, pev->origin, useHostageRange)) != NULL) + { + if (!FClassnameIs(pObject->pev, "hostage_entity")) + continue; + + vecLOS = VecBModelOrigin(pObject->pev) - vecStart; + vecLOS.NormalizeInPlace(); + + flDot = DotProduct(vecLOS, gpGlobals->v_forward); + + if (flDot > flMaxDot && CanSeeUseable(this, pObject)) + { + pClosest = pObject; + flMaxDot = flDot; + } + } + } + } + + if (!pClosest) + { + while ((pObject = UTIL_FindEntityInSphere(pObject, pev->origin, PLAYER_SEARCH_RADIUS)) != NULL) + { + if (pObject->ObjectCaps() & (FCAP_IMPULSE_USE | FCAP_CONTINUOUS_USE | FCAP_ONOFF_USE)) + { + // !!!PERFORMANCE- should this check be done on a per case basis AFTER we've determined that + // this object is actually usable? This dot is being done for every object within PLAYER_SEARCH_RADIUS + // when player hits the use key. How many objects can be in that area, anyway? (sjb) + vecLOS = (VecBModelOrigin(pObject->pev) - (pev->origin + pev->view_ofs)); + vecLOS.NormalizeInPlace(); + + flDot = DotProduct(vecLOS, gpGlobals->v_forward); + + // only if the item is in front of the user + if (flDot > flMaxDot) + { + flMaxDot = flDot; + pClosest = pObject; + } + } + } + } + + pObject = pClosest; + + // Found an object + if (pObject != NULL) + { + if (!useNewHostages || CanSeeUseable(this, pObject)) + { + int caps = pObject->ObjectCaps(); + + if (m_afButtonPressed & IN_USE) + EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/wpn_select.wav", 0.4, ATTN_NORM); + + if (((pev->button & IN_USE) && (caps & FCAP_CONTINUOUS_USE)) + || ((m_afButtonPressed & IN_USE) && (caps & (FCAP_IMPULSE_USE | FCAP_ONOFF_USE)))) + { + if (caps & FCAP_CONTINUOUS_USE) + m_afPhysicsFlags |= PFLAG_USING; + + pObject->Use(this, this, USE_SET, 1); + } + // UNDONE: Send different USE codes for ON/OFF. Cache last ONOFF_USE object to send 'off' if you turn away + // BUGBUG This is an "off" use + else if ((m_afButtonReleased & IN_USE) && (pObject->ObjectCaps() & FCAP_ONOFF_USE)) + { + pObject->Use(this, this, USE_SET, 0); + } + } + } + else + { + if (m_afButtonPressed & IN_USE) + EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/wpn_denyselect.wav", 0.4, ATTN_NORM); + } +} + +/* <155f41> ../cstrike/dlls/player.cpp:4486 */ +void CBasePlayer::HostageUsed(void) +{ + if (m_flDisplayHistory & DHF_HOSTAGE_USED) + return; + + if (m_iTeam == TERRORIST) + HintMessage("#Hint_use_hostage_to_stop_him"); + + else if (m_iTeam == CT) + HintMessage("#Hint_lead_hostage_to_rescue_point"); + + m_flDisplayHistory |= DHF_HOSTAGE_USED; +} + +/* <153f69> ../cstrike/dlls/player.cpp:4507 */ +void CBasePlayer::__MAKE_VHOOK(Jump)(void) +{ + if (pev->flags & FL_WATERJUMP) + return; + + if (pev->waterlevel >= 2) + { + return; + } + + // jump velocity is sqrt( height * gravity * 2) + // If this isn't the first frame pressing the jump button, break out. + if (!(m_afButtonPressed & IN_JUMP)) + { + // don't pogo stick + return; + } + + if (!(pev->flags & FL_ONGROUND) || pev->groundentity == NULL) + return; + + // many features in this function use v_forward, so makevectors now. + UTIL_MakeVectors(pev->angles); + SetAnimation(PLAYER_JUMP); + + if ((pev->flags & FL_DUCKING) || (m_afPhysicsFlags & PFLAG_DUCKING)) + { + if (m_fLongJump && (pev->button & IN_DUCK) && (gpGlobals->time - m_flDuckTime < 1.0f) && pev->velocity.Length() > 50) + { + SetAnimation(PLAYER_SUPERJUMP); + } + } + + // If you're standing on a conveyor, add it's velocity to yours (for momentum) + entvars_t *pevGround = VARS(pev->groundentity); + if (pevGround) + { + if (pevGround->flags & FL_CONVEYOR) + { + pev->velocity = pev->velocity + pev->basevelocity; + } + + if (FClassnameIs(pevGround, "func_tracktrain") + || FClassnameIs(pevGround, "func_train") + || FClassnameIs(pevGround, "func_vehicle")) + { + pev->velocity = pevGround->velocity + pev->velocity; + } + } +} + +// This is a glorious hack to find free space when you've crouched into some solid space +// Our crouching collisions do not work correctly for some reason and this is easier +// than fixing the problem :( + +/* <155fe2> ../cstrike/dlls/player.cpp:4565 */ +NOXREF void FixPlayerCrouchStuck(edict_t *pPlayer) +{ + TraceResult trace; + + // Move up as many as 18 pixels if the player is stuck. + for (int i = 0; i < 18; i++) + { + UTIL_TraceHull(pPlayer->v.origin, pPlayer->v.origin, dont_ignore_monsters, head_hull, pPlayer, &trace); + + if (trace.fStartSolid) + pPlayer->v.origin.z ++; + else + break; + } +} + +/* <153ef5> ../cstrike/dlls/player.cpp:4580 */ +void CBasePlayer::__MAKE_VHOOK(Duck)(void) +{ + if (pev->button & IN_DUCK) + SetAnimation(PLAYER_WALK); +} + +/* <150f8f> ../cstrike/dlls/player.cpp:4591 */ +int CBasePlayer::__MAKE_VHOOK(Classify)(void) +{ + return CLASS_PLAYER; +} + +/* <150fb7> ../cstrike/dlls/player.cpp:4597 */ +void CBasePlayer::__MAKE_VHOOK(AddPoints)(int score, BOOL bAllowNegativeScore) +{ + if (score < 0 && !bAllowNegativeScore) + { + if (pev->frags < 0) + return; + + if (-score > pev->frags) + score = -pev->frags; + } + + pev->frags += score; + + MESSAGE_BEGIN(MSG_BROADCAST, gmsgScoreInfo); + WRITE_BYTE(ENTINDEX(edict())); + WRITE_SHORT((int)pev->frags); + WRITE_SHORT(m_iDeaths); + WRITE_SHORT(0); + WRITE_SHORT(m_iTeam); + MESSAGE_END(); +} + +/* <15125b> ../cstrike/dlls/player.cpp:4626 */ +void CBasePlayer::__MAKE_VHOOK(AddPointsToTeam)(int score, BOOL bAllowNegativeScore) +{ + int index = entindex(); + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (pPlayer && i != index) + { + if (g_pGameRules->PlayerRelationship(this, pPlayer) == GR_TEAMMATE) + pPlayer->AddPoints(score, bAllowNegativeScore); + } + } +} + +/* <156047> ../cstrike/dlls/player.cpp:4645 */ +bool CBasePlayer::CanPlayerBuy(bool display) +{ + CHalfLifeMultiplay *mp = g_pGameRules; + + if (!mp->IsMultiplayer()) + { + return CHalfLifeTraining::PlayerCanBuy(this); + } + + // is the player alive? + if (pev->deadflag != DEAD_NO) + { + return false; + } + + // is the player in a buy zone? + if (!(m_signals.GetState() & SIGNAL_BUY)) + { + return false; + } + + int buyTime = (int)(CVAR_GET_FLOAT("mp_buytime") * 60); + + if (buyTime < 15) + { + buyTime = 15; + CVAR_SET_FLOAT("mp_buytime", 1 / (60 / 15)); + } + + if (gpGlobals->time - mp->m_fRoundCount > buyTime) + { + if (display) + { + ClientPrint(pev, HUD_PRINTCENTER, "#Cant_buy", UTIL_dtos1(buyTime)); + } + + return false; + } + + if (m_bIsVIP) + { + if (display) + { + ClientPrint(pev, HUD_PRINTCENTER, "#VIP_cant_buy"); + } + + return false; + } + + if (mp->m_bCTCantBuy && m_iTeam == CT) + { + if (display) + { + ClientPrint(pev, HUD_PRINTCENTER, "#CT_cant_buy"); + } + + return false; + } + + if (mp->m_bTCantBuy && m_iTeam == TERRORIST) + { + if (display) + { + ClientPrint(pev, HUD_PRINTCENTER, "#Terrorist_cant_buy"); + } + + return false; + } + + return true; +} + +/* <15f9ac> ../cstrike/dlls/player.cpp:4717 */ +void CBasePlayer::__MAKE_VHOOK(PreThink)(void) +{ + // These buttons have changed this frame + int buttonsChanged = (m_afButtonLast ^ pev->button); + + //this means the player has pressed or released a key + if (buttonsChanged) + m_fLastMovement = gpGlobals->time; + + // Debounced button codes for pressed/released + // UNDONE: Do we need auto-repeat? + m_afButtonPressed = (buttonsChanged & pev->button); // The changed ones still down are "pressed" + m_afButtonReleased = (buttonsChanged & (~pev->button)); // The ones not down are "released" + + // Hint messages should be updated even if the game is over + m_hintMessageQueue.Update(this); + g_pGameRules->PlayerThink(this); + + if (g_fGameOver) + { + // intermission or finale + return; + } + + if (m_iJoiningState != JOINED) + JoiningThink(); + + // Mission Briefing text, remove it when the player hits an important button + if (m_bMissionBriefing) + { + if (m_afButtonPressed & (IN_ATTACK | IN_ATTACK2)) + { + m_afButtonPressed &= ~(IN_ATTACK | IN_ATTACK2); + RemoveLevelText(); + m_bMissionBriefing = false; + } + } + + // is this still used? + UTIL_MakeVectors(pev->v_angle); + + ItemPreFrame(); + WaterMove(); + + if (pev->flags & FL_ONGROUND) + { + // Slow down the player based on the velocity modifier + if (m_flVelocityModifier < 1.0f) + { + float_precision modvel = m_flVelocityModifier + 0.01; + + m_flVelocityModifier = modvel; + pev->velocity = pev->velocity * modvel; + } + + if (m_flVelocityModifier > 1.0f) + m_flVelocityModifier = 1; + } + + if (m_flIdleCheckTime <= (double)gpGlobals->time || m_flIdleCheckTime == 0.0f) + { + // check every 5 seconds + m_flIdleCheckTime = gpGlobals->time + 5.0; + + float_precision flLastMove = gpGlobals->time - m_fLastMovement; + + //check if this player has been inactive for 2 rounds straight + if (flLastMove > g_pGameRules->m_fMaxIdlePeriod) + { + if (!IsBot() && CVAR_GET_FLOAT("mp_autokick") != 0.0f) + { + // Log the kick + UTIL_LogPrintf + ( + "\"%s<%i><%s><%s>\" triggered \"Game_idle_kick\" (auto)\n", + STRING(pev->netname), + GETPLAYERUSERID(edict()), + GETPLAYERAUTHID(edict()), + GetTeam(m_iTeam) + ); + + UTIL_ClientPrintAll(HUD_PRINTCONSOLE, "#Game_idle_kick", STRING(pev->netname)); + SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(pev->netname))); + m_fLastMovement = gpGlobals->time; + } + } + } + + if (g_pGameRules && g_pGameRules->FAllowFlashlight()) + m_iHideHUD &= ~HIDEHUD_FLASHLIGHT; + else + m_iHideHUD |= HIDEHUD_FLASHLIGHT; + + // JOHN: checks if new client data (for HUD and view control) needs to be sent to the client + UpdateClientData(); + + CheckTimeBasedDamage(); + CheckSuitUpdate(); + + // So the correct flags get sent to client asap. + if (m_afPhysicsFlags & PFLAG_ONTRAIN) + pev->flags |= FL_ONTRAIN; + else + pev->flags &= ~FL_ONTRAIN; + + // Observer Button Handling + if (IsObserver() && (m_afPhysicsFlags & PFLAG_OBSERVER)) + { + Observer_HandleButtons(); + Observer_CheckTarget(); + Observer_CheckProperties(); + return; + } + + if (pev->deadflag >= DEAD_DYING && pev->deadflag != DEAD_RESPAWNABLE) + { + PlayerDeathThink(); + return; + } + + // new code to determine if a player is on a train or not + CBaseEntity *pGroundEntity = Instance(pev->groundentity); + if (pGroundEntity && pGroundEntity->Classify() == CLASS_VEHICLE) + { + pev->iuser4 = 1; + } + else + { + pev->iuser4 = 0; + } + + // Train speed control + if (m_afPhysicsFlags & PFLAG_ONTRAIN) + { + CBaseEntity *pTrain = Instance(pev->groundentity); + float vel; + + if (!pTrain) + { + TraceResult trainTrace; + // Maybe this is on the other side of a level transition + UTIL_TraceLine(pev->origin, pev->origin + Vector(0, 0, -38), ignore_monsters, ENT(pev), &trainTrace); + + // HACKHACK - Just look for the func_tracktrain classname + if (trainTrace.flFraction != 1.0f && trainTrace.pHit) + pTrain = Instance(trainTrace.pHit); + + if (!pTrain || !(pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE) || !pTrain->OnControls(pev)) + { + m_afPhysicsFlags &= ~PFLAG_ONTRAIN; + m_iTrain = (TRAIN_NEW | TRAIN_OFF); + ((CFuncVehicle *)pTrain)->m_pDriver = NULL; + return; + } + } + else if (!(pev->flags & FL_ONGROUND) || (pTrain->pev->spawnflags & SF_TRACKTRAIN_NOCONTROL)) + { + // Turn off the train if you jump, strafe, or the train controls go dead + m_afPhysicsFlags &= ~PFLAG_ONTRAIN; + m_iTrain = (TRAIN_NEW | TRAIN_OFF); + ((CFuncVehicle *)pTrain)->m_pDriver = NULL; + return; + } + + pev->velocity = g_vecZero; + vel = 0; + + if (pTrain->Classify() == CLASS_VEHICLE) + { + if (pev->button & IN_FORWARD) + { + vel = 1; + pTrain->Use(this, this, USE_SET, vel); + } + + if (pev->button & IN_BACK) + { + vel = -1; + pTrain->Use(this, this, USE_SET, vel); + } + + if (pev->button & IN_MOVELEFT) + { + vel = 20; + pTrain->Use(this, this, USE_SET, vel); + } + if (pev->button & IN_MOVERIGHT) + { + vel = 30; + pTrain->Use(this, this, USE_SET, vel); + } + } + else + { + if (m_afButtonPressed & IN_FORWARD) + { + vel = 1; + pTrain->Use(this, this, USE_SET, vel); + } + else if (m_afButtonPressed & IN_BACK) + { + vel = -1; + pTrain->Use(this, this, USE_SET, vel); + } + } + + if (vel) + { + m_iTrain = TrainSpeed(pTrain->pev->speed, pTrain->pev->impulse); + m_iTrain |= (TRAIN_ACTIVE | TRAIN_NEW); + } + } + else if (m_iTrain & TRAIN_ACTIVE) + { + // turn off train + m_iTrain = TRAIN_NEW; + } + + if (pev->button & IN_JUMP) + { + // If on a ladder, jump off the ladder + // else Jump + Jump(); + } + + // If trying to duck, already ducked, or in the process of ducking + if ((pev->button & IN_DUCK) || (pev->flags & FL_DUCKING) || (m_afPhysicsFlags & PFLAG_DUCKING)) + { + Duck(); + } + + if (!(pev->flags & FL_ONGROUND)) + { + m_flFallVelocity = -pev->velocity.z; + } + + //!!!HACKHACK!!! Can't be hit by traceline when not animating? + //StudioFrameAdvance(); + + // Clear out ladder pointer + m_hEnemy = NULL; + + if (m_afPhysicsFlags & PFLAG_ONBARNACLE) + { + pev->velocity = g_vecZero; + } + + if (!(m_flDisplayHistory & DHF_ROUND_STARTED) && CanPlayerBuy(false)) + { + HintMessage("#Hint_press_buy_to_purchase", FALSE); + m_flDisplayHistory |= DHF_ROUND_STARTED; + } + + UpdateLocation(); +} + +// If player is taking time based damage, continue doing damage to player - +// this simulates the effect of being poisoned, gassed, dosed with radiation etc - +// anything that continues to do damage even after the initial contact stops. +// Update all time based damage counters, and shut off any that are done. + +// The m_bitsDamageType bit MUST be set if any damage is to be taken. +// This routine will detect the initial on value of the m_bitsDamageType +// and init the appropriate counter. Only processes damage every second. + +/* <156096> ../cstrike/dlls/player.cpp:5146 */ +void CBasePlayer::CheckTimeBasedDamage(void) +{ + int i; + BYTE bDuration = 0; + //static float gtbdPrev = 0.0; + + if (!(m_bitsDamageType & DMG_TIMEBASED)) + return; + + if (abs((int64_t)(gpGlobals->time - m_tbdPrev)) < 2.0f) + return; + + m_tbdPrev = gpGlobals->time; + + for (i = 0; i < CDMG_TIMEBASED; i++) + { + if (m_bitsDamageType & (DMG_PARALYZE << i)) + { + switch (i) + { + case itbd_Paralyze: + // UNDONE - flag movement as half-speed + bDuration = PARALYZE_DURATION; + break; + case itbd_NerveGas: + bDuration = NERVEGAS_DURATION; + break; + case itbd_Poison: + { + TakeDamage(pev, pev, POISON_DAMAGE, DMG_GENERIC); + bDuration = POISON_DURATION; + break; + } + case itbd_DrownRecover: + { + if (m_idrowndmg > m_idrownrestored) + { + int idif = Q_min(m_idrowndmg - m_idrownrestored, 10); + TakeHealth(idif, DMG_GENERIC); + m_idrownrestored += idif; + } + + bDuration = 4; + break; + } + case itbd_Radiation: + bDuration = RADIATION_DURATION; + break; + case itbd_Acid: + bDuration = ACID_DURATION; + break; + case itbd_SlowBurn: + bDuration = SLOWBURN_DURATION; + break; + case itbd_SlowFreeze: + bDuration = SLOWFREEZE_DURATION; + break; + default: + bDuration = 0; + break; + } + + if (m_rgbTimeBasedDamage[i]) + { + // use up an antitoxin on poison or nervegas after a few seconds of damage + if ((i == itbd_NerveGas && m_rgbTimeBasedDamage[i] < NERVEGAS_DURATION) || (i == itbd_Poison && m_rgbTimeBasedDamage[i] < POISON_DURATION)) + { + if (m_rgItems[ ITEM_ANTIDOTE ]) + { + m_rgbTimeBasedDamage[i] = 0; + m_rgItems[ ITEM_ANTIDOTE ]--; + SetSuitUpdate("!HEV_HEAL4", FALSE, SUIT_REPEAT_OK); + } + } + + // decrement damage duration, detect when done. + if (!m_rgbTimeBasedDamage[i] || --m_rgbTimeBasedDamage[i] == 0) + { + m_rgbTimeBasedDamage[i] = 0; + // if we're done, clear damage bits + m_bitsDamageType &= ~(DMG_PARALYZE << i); + } + } + else + // first time taking this damage type - init damage duration + m_rgbTimeBasedDamage[i] = bDuration; + } + } +} + +/* <156112> ../cstrike/dlls/player.cpp:5312 */ +void CBasePlayer::UpdateGeigerCounter(void) +{ + if (gpGlobals->time < m_flgeigerDelay) + return; + + m_flgeigerDelay = gpGlobals->time + 0.25; + BYTE range = (byte)(m_flgeigerRange * 0.25); + + if (range != m_igeigerRangePrev) + { + m_igeigerRangePrev = range; + + MESSAGE_BEGIN(MSG_ONE, gmsgGeigerRange, NULL, pev); + WRITE_BYTE(range); + MESSAGE_END(); + } + + if (!RANDOM_LONG(0, 3)) + m_flgeigerRange = 1000.0; +} + +/* <156189> ../cstrike/dlls/player.cpp:5352 */ +void CBasePlayer::CheckSuitUpdate(void) +{ + int i; + int isentence = 0; + int isearch = m_iSuitPlayNext; + + // Ignore suit updates if no suit + if (!(pev->weapons & (1 << WEAPON_SUIT))) + return; + + // if in range of radiation source, ping geiger counter + UpdateGeigerCounter(); + + if (g_pGameRules->IsMultiplayer()) + { + // don't bother updating HEV voice in multiplayer. + return; + } + + if (gpGlobals->time >= m_flSuitUpdate && m_flSuitUpdate > 0) + { + // play a sentence off of the end of the queue + for (i = 0; i < CSUITPLAYLIST; i++) + { + if (isentence = m_rgSuitPlayList[ isearch ]) + break; + + if (++isearch == CSUITPLAYLIST) + isearch = 0; + } + + if (isentence) + { + m_rgSuitPlayList[ isearch ] = 0; + + if (isentence > 0) + { + // play sentence number + + char sentence[CBSENTENCENAME_MAX + 1]; + Q_strcpy(sentence, "!"); + Q_strcat(sentence, gszallsentencenames[isentence]); + EMIT_SOUND_SUIT(ENT(pev), sentence); + } + else + { + // play sentence group + EMIT_GROUPID_SUIT(ENT(pev), -isentence); + } + m_flSuitUpdate = gpGlobals->time + SUITUPDATETIME; + } + else + // queue is empty, don't check + m_flSuitUpdate = 0; + } +} + +/* <156201> ../cstrike/dlls/player.cpp:5414 */ +void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) +{ + ; +} + +/* <15623f> ../cstrike/dlls/player.cpp:5519 */ +void CBasePlayer::CheckPowerups(entvars_t *pev) +{ + if (pev->health > 0.0f) + pev->modelindex = m_modelIndexPlayer; +} + +/* <15626b> ../cstrike/dlls/player.cpp:5531 */ +void CBasePlayer::SetNewPlayerModel(const char *modelName) +{ + SET_MODEL(edict(), modelName); + m_modelIndexPlayer = pev->modelindex; +} + +// UpdatePlayerSound - updates the position of the player's +// reserved sound slot in the sound list. + +/* <1562a4> ../cstrike/dlls/player.cpp:5543 */ +void CBasePlayer::UpdatePlayerSound(void) +{ + int iBodyVolume; + int iVolume; + CSound *pSound; + + pSound = CSoundEnt::SoundPointerForIndex(CSoundEnt::ClientSoundIndex(edict())); + + if (!pSound) + { + ALERT(at_console, "Client lost reserved sound!\n"); + return; + } + + pSound->m_iType = bits_SOUND_NONE; + + // now calculate the best target volume for the sound. If the player's weapon + // is louder than his body/movement, use the weapon volume, else, use the body volume. + + if (pev->flags & FL_ONGROUND) + { + iBodyVolume = pev->velocity.Length(); + + // clamp the noise that can be made by the body, in case a push trigger, + // weapon recoil, or anything shoves the player abnormally fast. + if (iBodyVolume> 512) + { + iBodyVolume = 512; + } + } + else + { + iBodyVolume = 0; + } + + if (pev->button & IN_JUMP) + { + iBodyVolume += 100; + } + + // convert player move speed and actions into sound audible by monsters. + if (m_iWeaponVolume > iBodyVolume) + { + m_iTargetVolume = m_iWeaponVolume; + + // OR in the bits for COMBAT sound if the weapon is being louder than the player. + pSound->m_iType |= bits_SOUND_COMBAT; + } + else + { + m_iTargetVolume = iBodyVolume; + } + + // decay weapon volume over time so bits_SOUND_COMBAT stays set for a while + m_iWeaponVolume -= 250 * gpGlobals->frametime; + + // if target volume is greater than the player sound's current volume, we paste the new volume in + // immediately. If target is less than the current volume, current volume is not set immediately to the + // lower volume, rather works itself towards target volume over time. This gives monsters a much better chance + // to hear a sound, especially if they don't listen every frame. + iVolume = pSound->m_iVolume; + + if (m_iTargetVolume > iVolume) + { + iVolume = m_iTargetVolume; + } + else if (iVolume > m_iTargetVolume) + { + iVolume -= 250 * gpGlobals->frametime; + + if (iVolume < m_iTargetVolume) + iVolume = 0; + } + + if (m_fNoPlayerSound) + { + // debugging flag, lets players move around and shoot without monsters hearing. + iVolume = 0; + } + + if (gpGlobals->time > m_flStopExtraSoundTime) + { + // since the extra sound that a weapon emits only lasts for one client frame, we keep that sound around for a server frame or two + // after actual emission to make sure it gets heard. + m_iExtraSoundTypes = 0; + } + + if (pSound) + { + pSound->m_vecOrigin = pev->origin; + pSound->m_iVolume = iVolume; + pSound->m_iType |= (bits_SOUND_PLAYER | m_iExtraSoundTypes); + } + + // keep track of virtual muzzle flash + m_iWeaponFlash -= 256 * gpGlobals->frametime; + + if (m_iWeaponFlash < 0) + m_iWeaponFlash = 0; + + UTIL_MakeVectors(pev->angles); + gpGlobals->v_forward.z = 0; +} + +/* <15a182> ../cstrike/dlls/player.cpp:5667 */ +void CBasePlayer::__MAKE_VHOOK(PostThink)(void) +{ + // intermission or finale + if (g_fGameOver) + goto pt_end; + + if (!IsAlive()) + goto pt_end; + + // Handle Tank controlling + if (m_pTank != NULL) + { + // if they've moved too far from the gun, or selected a weapon, unuse the gun + if (m_pTank->OnControls(pev) && !pev->weaponmodel) + { + // try fire the gun + m_pTank->Use(this, this, USE_SET, 2); + } + else + { + // they've moved off the platform + m_pTank->Use(this, this, USE_OFF, 0); + m_pTank = NULL; + } + } + + // do weapon stuff + ItemPostFrame(); + + // check to see if player landed hard enough to make a sound + // falling farther than half of the maximum safe distance, but not as far a max safe distance will + // play a bootscrape sound, and no damage will be inflicted. Fallling a distance shorter than half + // of maximum safe distance will make no sound. Falling farther than max safe distance will play a + // fallpain sound, and damage will be inflicted based on how far the player fell + if ((pev->flags & FL_ONGROUND) && pev->health > 0.0f && m_flFallVelocity >= PLAYER_FALL_PUNCH_THRESHHOLD) + { + if (pev->watertype != CONTENT_WATER) + { + // after this point, we start doing damage + if (m_flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED) + { + float flFallDamage = g_pGameRules->FlPlayerFallDamage(this); + + //splat + if (flFallDamage > pev->health) + { + // note: play on item channel because we play footstep landing on body channel + EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/bodysplat.wav", VOL_NORM, ATTN_NORM); + } + if (flFallDamage > 0) + { + m_LastHitGroup = HITGROUP_GENERIC; + TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), flFallDamage, DMG_FALL); + pev->punchangle.x = 0; + TheBots->OnEvent(EVENT_PLAYER_LANDED_FROM_HEIGHT, this); + } + } + } + + if (IsAlive()) + { + SetAnimation(PLAYER_WALK); + } + } + + if (pev->flags & FL_ONGROUND) + { + if (m_flFallVelocity > 64.0f && !g_pGameRules->IsMultiplayer()) + { + CSoundEnt::InsertSound(bits_SOUND_PLAYER, pev->origin, m_flFallVelocity, 0.2); + } + m_flFallVelocity = 0; + } + + // select the proper animation for the player character + if (IsAlive()) + { + if (pev->velocity.x || pev->velocity.y) + { + if (((pev->velocity.x || pev->velocity.y) && (pev->flags & FL_ONGROUND)) || pev->waterlevel > 1) + SetAnimation(PLAYER_WALK); + } + else if (pev->gaitsequence != ACT_FLY) + SetAnimation(PLAYER_IDLE); + } + + StudioFrameAdvance(); + CheckPowerups(pev); + UpdatePlayerSound(); + +pt_end: +#ifdef CLIENT_WEAPONS + // Decay timers on weapons + // go through all of the weapons and make a list of the ones to pack + for (int i = 0; i < MAX_ITEM_TYPES; i++) + { + if (m_rgpPlayerItems[i]) + { + CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[i]; + + while (pPlayerItem != NULL) + { + CBasePlayerWeapon *gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr(); + + if (gun && gun->UseDecrement()) + { + gun->m_flNextPrimaryAttack = Q_max(gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0f); + gun->m_flNextSecondaryAttack = Q_max(gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001f); + + if (gun->m_flTimeWeaponIdle != 1000.0f) + { + gun->m_flTimeWeaponIdle = Q_max(gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001f); + } + } + + pPlayerItem = pPlayerItem->m_pNext; + } + } + } + + m_flNextAttack -= gpGlobals->frametime; + + if (m_flNextAttack < -0.001) + m_flNextAttack = -0.001; +#endif // CLIENT_WEAPONS + + // Track button info so we can detect 'pressed' and 'released' buttons next frame + m_afButtonLast = pev->button; + m_iGaitsequence = pev->gaitsequence; + + StudioProcessGait(); +} + +/* <14e39d> ../cstrike/dlls/player.cpp:5837 */ +BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot) +{ + CBaseEntity *ent = NULL; + + if (!pSpot->IsTriggered(pPlayer)) + return FALSE; + + while ((ent = UTIL_FindEntityInSphere(ent, pSpot->pev->origin, 64)) != NULL) + { + if (ent->IsPlayer() && ent != pPlayer) + return FALSE; + } + + return TRUE; +} + +/* <1563a8> ../cstrike/dlls/player.cpp:5879 */ +NOXREF void InitZombieSpawns(void) +{ + CBaseEntity *spot = NULL; + + g_pSelectedZombieSpawn = NULL; + zombieSpawnCount = 0; + + while ((spot = UTIL_FindEntityByClassname(spot, "info_player_start")) != NULL) + { + if (spot->pev->origin != Vector(0, 0, 0)) + { + zombieSpawn[ zombieSpawnCount ].entity = spot; + zombieSpawn[ zombieSpawnCount ].useableTimer.Invalidate(); + + zombieSpawnCount++; + } + } +} + +/* <14e440> ../cstrike/dlls/player.cpp:5906 */ +NOXREF CBaseEntity *FindZombieSpawn(CBaseEntity *player, bool forceSpawn) +{ + return NULL; +} + +/* <15645f> ../cstrike/dlls/player.cpp:6060 */ +edict_t *EntSelectSpawnPoint(CBaseEntity *pPlayer) +{ + CBaseEntity *pSpot; + edict_t *player = pPlayer->edict(); + + // choose a info_player_deathmatch point + if (g_pGameRules->IsCoOp()) + { + pSpot = UTIL_FindEntityByClassname(g_pLastSpawn, "info_player_coop"); + + if (!FNullEnt(pSpot)) + goto ReturnSpot; + + pSpot = UTIL_FindEntityByClassname(g_pLastSpawn, "info_player_start"); + + if (!FNullEnt(pSpot)) + goto ReturnSpot; + } + else if (g_pGameRules->IsDeathmatch() && ((CBasePlayer *)pPlayer)->m_bIsVIP) + { + pSpot = UTIL_FindEntityByClassname(NULL, "info_vip_start"); + + // skip over the null point + if (!FNullEnt(pSpot)) + { + goto ReturnSpot; + } + + goto CTSpawn; + } + else if (g_pGameRules->IsDeathmatch() && ((CBasePlayer *)pPlayer)->m_iTeam == CT) + { +CTSpawn: + // Find the next spawn spot. + pSpot = UTIL_FindEntityByClassname(g_pLastCTSpawn, "info_player_start"); + + // skip over the null point + if (FNullEnt(pSpot)) + { + pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_start"); + } + + CBaseEntity *pFirstSpot = pSpot; + + do + { + if (pSpot) + { + // check if pSpot is valid + if (IsSpawnPointValid(pPlayer, pSpot)) + { + if (pSpot->pev->origin == Vector(0, 0, 0)) + { + pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_start"); + continue; + } + + // if so, go to pSpot + goto ReturnSpot; + } + } + + // increment pSpot + pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_start"); + } + // loop if we're not back to the start + while (pSpot != pFirstSpot); + + // we haven't found a place to spawn yet, so kill any guy at the first spawn point and spawn there + if (!FNullEnt(pSpot)) + { + CBaseEntity *ent = NULL; + while ((ent = UTIL_FindEntityInSphere(ent, pSpot->pev->origin, 64)) != NULL) + { + // if ent is a client, kill em (unless they are ourselves) + if (ent->IsPlayer() && ent->edict() != player) + ent->TakeDamage(VARS(INDEXENT(0)), VARS(INDEXENT(0)), 200, DMG_GENERIC); + } + + goto ReturnSpot; + } + } + // The terrorist spawn points + else if (g_pGameRules->IsDeathmatch() && ((CBasePlayer *)pPlayer)->m_iTeam == TERRORIST) + { + pSpot = UTIL_FindEntityByClassname(g_pLastTerroristSpawn, "info_player_deathmatch"); + + // skip over the null point + if (FNullEnt(pSpot)) + pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_deathmatch"); + + CBaseEntity *pFirstSpot = pSpot; + + do + { + if (pSpot) + { + // check if pSpot is valid + if (IsSpawnPointValid(pPlayer, pSpot)) + { + if (pSpot->pev->origin == Vector(0, 0, 0)) + { + pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_deathmatch"); + continue; + } + + // if so, go to pSpot + goto ReturnSpot; + } + } + + // increment pSpot + pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_deathmatch"); + } + // loop if we're not back to the start + while (pSpot != pFirstSpot); + + // we haven't found a place to spawn yet, so kill any guy at the first spawn point and spawn there + if (!FNullEnt(pSpot)) + { + CBaseEntity *ent = NULL; + while ((ent = UTIL_FindEntityInSphere(ent, pSpot->pev->origin, 64)) != NULL) + { + // if ent is a client, kill em (unless they are ourselves) + if (ent->IsPlayer() && ent->edict() != player) + ent->TakeDamage(VARS(INDEXENT(0)), VARS(INDEXENT(0)), 200, DMG_GENERIC); + } + goto ReturnSpot; + } + } + + // If startspot is set, (re)spawn there. + if (FStringNull(gpGlobals->startspot) || !Q_strlen(STRING(gpGlobals->startspot))) + { + pSpot = UTIL_FindEntityByClassname(NULL, "info_player_deathmatch"); + + if (!FNullEnt(pSpot)) + goto ReturnSpot; + } + else + { + pSpot = UTIL_FindEntityByTargetname(NULL, STRING(gpGlobals->startspot)); + + if (!FNullEnt(pSpot)) + goto ReturnSpot; + } + +ReturnSpot: + if (FNullEnt(pSpot)) + { + ALERT(at_error, "PutClientInServer: no info_player_start on level"); + return INDEXENT(0); + } + + if (((CBasePlayer *)pPlayer)->m_iTeam == TERRORIST) + g_pLastTerroristSpawn = pSpot; + else + g_pLastCTSpawn = pSpot; + + return pSpot->edict(); +} + +/* <15331b> ../cstrike/dlls/player.cpp:6237 */ +void SetScoreAttrib(CBasePlayer *dest, CBasePlayer *src) +{ + int state = 0; + if (src->pev->deadflag != DEAD_NO) + state |= SCORE_STATUS_DEAD; + + if (src->m_bHasC4) + state |= SCORE_STATUS_BOMB; + + if (src->m_bIsVIP) + state |= SCORE_STATUS_VIP; + + if (gmsgScoreAttrib) + { + MESSAGE_BEGIN(MSG_ONE, gmsgScoreAttrib, NULL, dest->pev); + WRITE_BYTE(src->entindex()); + WRITE_BYTE(state); + MESSAGE_END(); + } +} + +/* <15fdba> ../cstrike/dlls/player.cpp:6264 */ +void CBasePlayer::__MAKE_VHOOK(Spawn)(void) +{ + int i; + + m_iGaitsequence = 0; + + m_flGaitframe = 0; + m_flGaityaw = 0; + m_flGaitMovement = 0; + m_prevgaitorigin = Vector(0, 0, 0); + m_progressStart = 0; + m_progressEnd = 0; + + if (!FStringNull(pev->classname)) + { + RemoveEntityHashValue(pev, STRING(pev->classname), CLASSNAME); + } + + MAKE_STRING_CLASS("player", pev); + AddEntityHashValue(pev, STRING(pev->classname), CLASSNAME); + + pev->health = 100; + + if (!m_bNotKilled) + { + pev->armorvalue = 0; + m_iKevlar = ARMOR_TYPE_EMPTY; + } + + pev->maxspeed = 1000; + pev->takedamage = DAMAGE_AIM; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_WALK; + pev->max_health = pev->health; + + pev->flags &= FL_PROXY; + pev->flags |= FL_CLIENT; + pev->air_finished = gpGlobals->time + 12; + pev->dmg = 2; + pev->effects = 0; + pev->deadflag = DEAD_NO; + pev->dmg_take = 0; + pev->dmg_save = 0; + + m_bitsHUDDamage = -1; + m_bitsDamageType = 0; + m_afPhysicsFlags = 0; + m_fLongJump = FALSE; + m_iClientFOV = 0; + m_pentCurBombTarget = NULL; + + if (m_bOwnsShield) + pev->gamestate = 0; + else + pev->gamestate = 1; + + ResetStamina(); + pev->friction = 1; + pev->gravity = 1; + + SET_PHYSICS_KEY_VALUE(edict(), "slj", "0"); + SET_PHYSICS_KEY_VALUE(edict(), "hl", "1"); + m_hintMessageQueue.Reset(); + + m_flVelocityModifier = 1; + m_iLastZoom = DEFAULT_FOV; + m_flLastTalk = 0; + m_flIdleCheckTime = 0; + m_flRadioTime = 0; + m_iRadioMessages = 60; + m_bHasC4 = false; + m_bKilledByBomb = false; + m_bKilledByGrenade = false; + m_flDisplayHistory &= ~DHM_ROUND_CLEAR; + m_tmHandleSignals = 0; + m_fCamSwitch = 0; + m_iChaseTarget = 1; + m_bEscaped = false; + m_tmNextRadarUpdate = gpGlobals->time; + m_vLastOrigin = Vector(0, 0, 0); + m_iCurrentKickVote = 0; + m_flNextVoteTime = 0; + m_bJustKilledTeammate = false; + + SET_VIEW(ENT(pev), ENT(pev)); + + m_hObserverTarget = NULL; + pev->iuser1 = 0; + pev->iuser2 = 0; + pev->iuser3 = 0; + + m_flLastFired = -15; + m_bHeadshotKilled = false; + m_bReceivesNoMoneyNextRound = false; + m_bShieldDrawn = false; + + m_blindUntilTime = 0; + m_blindStartTime = 0; + m_blindHoldTime = 0; + m_blindFadeTime = 0; + m_blindAlpha = 0; + + m_canSwitchObserverModes = true; + m_lastLocation[0] = '\0'; + + m_bitsDamageType &= ~(DMG_DROWN | DMG_DROWNRECOVER); + m_rgbTimeBasedDamage[ itbd_DrownRecover ] = 0; + m_idrowndmg = 0; + m_idrownrestored = 0; + + if (m_iObserverC4State) + { + m_iObserverC4State = 0; + + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + WRITE_BYTE(STATUSICON_HIDE); + WRITE_STRING("c4"); + MESSAGE_END(); + } + + if (m_bObserverHasDefuser) + { + m_bObserverHasDefuser = false; + + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + WRITE_BYTE(STATUSICON_HIDE); + WRITE_STRING("defuser"); + MESSAGE_END(); + } + + MESSAGE_BEGIN(MSG_ONE, SVC_ROOMTYPE, NULL, pev); + WRITE_SHORT((int)CVAR_GET_FLOAT("room_type")); + MESSAGE_END(); + + if (g_pGameRules->IsFreezePeriod()) + m_bCanShoot = false; + else + m_bCanShoot = true; + + m_iNumSpawns++; + InitStatusBar(); + + for (i = 0; i < MAX_RECENT_PATH; i++) + m_vRecentPath[ i ] = Vector(0, 0, 0); + + if (m_pActiveItem != NULL && !pev->viewmodel) + { + switch (m_pActiveItem->m_iId) + { + case WEAPON_AWP: + pev->viewmodel = MAKE_STRING("models/v_awp.mdl"); + break; + case WEAPON_G3SG1: + pev->viewmodel = MAKE_STRING("models/v_g3sg1.mdl"); + break; + case WEAPON_SCOUT: + pev->viewmodel = MAKE_STRING("models/v_scout.mdl"); + break; + case WEAPON_SG550: + pev->viewmodel = MAKE_STRING("models/v_sg550.mdl"); + break; + } + } + + m_iFOV = DEFAULT_FOV; + m_flNextDecalTime = 0; + m_flTimeStepSound = 0; + m_iStepLeft = 0; + m_flFieldOfView = 0.5; + m_bloodColor = BLOOD_COLOR_RED; + m_flNextAttack = 0; + m_flgeigerDelay = gpGlobals->time + 2; + + StartSneaking(); + + m_iFlashBattery = 99; + m_flFlashLightTime = 1; + + if (m_bHasDefuser) + pev->body = 1; + else + pev->body = 0; + + if (m_bMissionBriefing) + { + RemoveLevelText(); + m_bMissionBriefing = false; + } + + m_flFallVelocity = 0; + + if (!g_skipCareerInitialSpawn) + { + g_pGameRules->GetPlayerSpawnSpot(this); + } + + if (!pev->modelindex) + { + SET_MODEL(ENT(pev), "models/player.mdl"); + m_modelIndexPlayer = pev->modelindex; + } + + pev->sequence = LookupActivity(ACT_IDLE); + + if (pev->flags & FL_DUCKING) + UTIL_SetSize(pev, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX); + else + UTIL_SetSize(pev, VEC_HULL_MIN, VEC_HULL_MAX); + + pev->view_ofs = VEC_VIEW; + Precache(); + + m_HackedGunPos = Vector(0, 32, 0); + + if (m_iPlayerSound == SOUNDLIST_EMPTY) + { + ALERT(at_console, "Couldn't alloc player sound slot!\n"); + } + + m_iHideHUD &= ~(HIDEHUD_WEAPONS | HIDEHUD_HEALTH | HIDEHUD_TIMER | HIDEHUD_MONEY); + m_fNoPlayerSound = FALSE; + m_pLastItem = NULL; + m_fWeapon = FALSE; + m_pClientActiveItem = NULL; + m_iClientBattery = -1; + m_fInitHUD = TRUE; + + if (!m_bNotKilled) + { + m_iClientHideHUD = -1; + + for (i = 0; i < MAX_AMMO_SLOTS; i++) + m_rgAmmo[i] = 0; + + m_bHasPrimary = false; + m_bHasNightVision = false; + + SendItemStatus(this); + } + else + { + for (i = 0; i < MAX_AMMO_SLOTS; i++) + m_rgAmmoLast[i] = -1; + } + + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pev); + WRITE_BYTE(0); + MESSAGE_END(); + + m_bNightVisionOn = false; + + for (i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pObserver = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (pObserver && pObserver->IsObservingPlayer(this)) + { + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); + WRITE_BYTE(0); + MESSAGE_END(); + + pObserver->m_bNightVisionOn = false; + } + } + + m_lastx = m_lasty = 0; + + g_pGameRules->PlayerSpawn(this); + + m_bNotKilled = true; + m_bIsDefusing = false; + + // Get rid of the progress bar... + SetProgressBarTime(0); + ResetMaxSpeed(); + + UTIL_SetOrigin(pev, pev->origin); + + if (m_bIsVIP) + { + m_iKevlar = ARMOR_TYPE_HELMET; + pev->armorvalue = 200; + HintMessage("#Hint_you_are_the_vip", TRUE, TRUE); + } + + SetScoreboardAttributes(); + + MESSAGE_BEGIN(MSG_ALL, gmsgTeamInfo); + WRITE_BYTE(entindex()); + switch (m_iTeam) + { + case CT: + WRITE_STRING("CT"); + break; + case TERRORIST: + WRITE_STRING("TERRORIST"); + break; + case SPECTATOR: + WRITE_STRING("SPECTATOR"); + break; + default: + WRITE_STRING("UNASSIGNED"); + break; + } + MESSAGE_END(); + + UpdateLocation(true); + + MESSAGE_BEGIN(MSG_ALL, gmsgScoreInfo); + WRITE_BYTE(ENTINDEX(edict())); + WRITE_SHORT((int)pev->frags); + WRITE_SHORT(m_iDeaths); + WRITE_SHORT(0); + WRITE_SHORT(m_iTeam); + MESSAGE_END(); + + if (m_bHasChangedName) + { + char *infobuffer = GET_INFO_BUFFER(edict()); + + if (!FStrEq(m_szNewName, GET_KEY_VALUE(infobuffer, "name"))) + { + SET_CLIENT_KEY_VALUE(entindex(), infobuffer, "name", m_szNewName); + } + + m_bHasChangedName = false; + m_szNewName[0] = '\0'; + } + + UTIL_ScreenFade(this, Vector(0, 0, 0), 0.001); + SyncRoundTimer(); + + if (TheBots) + { + TheBots->OnEvent(EVENT_PLAYER_SPAWNED, this); + } + + m_allowAutoFollowTime = false; + + sv_aim = CVAR_GET_POINTER("sv_aim"); + + for (i = 0; i < ARRAYSIZE(m_flLastCommandTime); i++) + m_flLastCommandTime[i] = -1; +} + +/* <153555> ../cstrike/dlls/player.cpp:6620 */ +void CBasePlayer::__MAKE_VHOOK(Precache)(void) +{ + // in the event that the player JUST spawned, and the level node graph + // was loaded, fix all of the node graph pointers before the game starts. + + // !!!BUGBUG - now that we have multiplayer, this needs to be moved! + if (WorldGraph.m_fGraphPresent && !WorldGraph.m_fGraphPointersSet) + { + if (!WorldGraph.FSetGraphPointers()) + { + ALERT(at_console, "**Graph pointers were not set!\n"); + } + else + { + ALERT(at_console, "**Graph Pointers Set!\n"); + } + } + + // SOUNDS / MODELS ARE PRECACHED in ClientPrecache() (game specific) + // because they need to precache before any clients have connected + + // init geiger counter vars during spawn and each time + // we cross a level transition + + m_flgeigerRange = 1000; + m_igeigerRangePrev = 1000; + m_bitsDamageType = 0; + m_bitsHUDDamage = -1; + m_iClientBattery = -1; + m_iTrain = TRAIN_NEW; + + // Make sure any necessary user messages have been registered + LinkUserMessages(); + + // won't update for 1/2 a second + m_iUpdateTime = 5; + + if (gInitHUD) + m_fInitHUD = TRUE; +} + +/* <151a77> ../cstrike/dlls/player.cpp:6671 */ +int CBasePlayer::__MAKE_VHOOK(Save)(CSave &save) +{ + if (!CBaseMonster::Save(save)) + return 0; + + return save.WriteFields("PLAYER", this, IMPLEMENT_ARRAY_CLASS(CBasePlayer, m_playerSaveData), ARRAYSIZE(IMPLEMENT_ARRAY_CLASS(CBasePlayer, m_playerSaveData))); +} + +/* <153355> ../cstrike/dlls/player.cpp:6685 */ +void CBasePlayer::SetScoreboardAttributes(CBasePlayer *destination) +{ + if (destination != NULL) + { + SetScoreAttrib(destination, this); + return; + } + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *player = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (player && !FNullEnt(player->edict())) + SetScoreboardAttributes(player); + } +} + +/* <156e88> ../cstrike/dlls/player.cpp:6712 */ +NOXREF void CBasePlayer::RenewItems(void) +{ + ; +} + +/* <156b9b> ../cstrike/dlls/player.cpp:6718 */ +int CBasePlayer::__MAKE_VHOOK(Restore)(CRestore &restore) +{ + if (!CBaseMonster::Restore(restore)) + return 0; + + int status = restore.ReadFields("PLAYER", this, IMPLEMENT_ARRAY_CLASS(CBasePlayer, m_playerSaveData), ARRAYSIZE(IMPLEMENT_ARRAY_CLASS(CBasePlayer, m_playerSaveData))); + SAVERESTOREDATA *pSaveData = (SAVERESTOREDATA *)gpGlobals->pSaveData; + + if (!pSaveData->fUseLandmark) + { + ALERT(at_console, "No Landmark:%s\n", pSaveData->szLandmarkName); + + edict_t *pentSpawnSpot = EntSelectSpawnPoint(this); + + pev->origin = VARS(pentSpawnSpot)->origin + Vector(0, 0, 1); + pev->angles = VARS(pentSpawnSpot)->angles; + } + + pev->v_angle.z = 0; + pev->angles = pev->v_angle; + pev->fixangle = 1; + + m_bloodColor = BLOOD_COLOR_RED; + m_modelIndexPlayer = pev->modelindex; + + if (pev->flags & FL_DUCKING) + UTIL_SetSize(pev, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX); + else + UTIL_SetSize(pev, VEC_HULL_MIN, VEC_HULL_MAX); + + m_flDisplayHistory &= ~DHM_CONNECT_CLEAR; + SetScoreboardAttributes(); + + return status; +} + +/* <156eab> ../cstrike/dlls/player.cpp:6771 */ +void CBasePlayer::Reset(void) +{ + pev->frags = 0; + m_iDeaths = 0; + m_iAccount = 0; + + MESSAGE_BEGIN(MSG_ONE, gmsgMoney, NULL, pev); + WRITE_LONG(m_iAccount); + WRITE_BYTE(0); + MESSAGE_END(); + + m_bNotKilled = false; + + RemoveShield(); + CheckStartMoney(); + AddAccount(startmoney.value); + + MESSAGE_BEGIN(MSG_ALL, gmsgScoreInfo); + WRITE_BYTE(ENTINDEX(edict())); + WRITE_SHORT(0); + WRITE_SHORT(0); + WRITE_SHORT(0); + WRITE_SHORT(m_iTeam); + MESSAGE_END(); +} + +/* <157066> ../cstrike/dlls/player.cpp:6794 */ +NOXREF void CBasePlayer::SelectNextItem(int iItem) +{ + CBasePlayerItem *pItem = m_rgpPlayerItems[ iItem ]; + + if (!pItem) + { + return; + } + + if (pItem == m_pActiveItem) + { + pItem = m_pActiveItem->m_pNext; + + if (!pItem) + { + return; + } + + CBasePlayerItem *pLast = pItem; + + while (pLast->m_pNext != NULL) + pLast = pLast->m_pNext; + + pLast->m_pNext = m_pActiveItem; + m_pActiveItem->m_pNext = NULL; + m_rgpPlayerItems[ iItem ] = pItem; + } + + ResetAutoaim(); + + if (m_pActiveItem) + { + m_pActiveItem->Holster(); + } + + if (HasShield()) + { + CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; + pWeapon->m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; + m_bShieldDrawn = false; + } + + m_pLastItem = m_pActiveItem; + m_pActiveItem = pItem; + + if (m_pActiveItem) + { + UpdateShieldCrosshair(true); + + m_pActiveItem->Deploy(); + m_pActiveItem->UpdateItemInfo(); + + ResetMaxSpeed(); + } +} + +/* <15714a> ../cstrike/dlls/player.cpp:6851 */ +void CBasePlayer::SelectItem(const char *pstr) +{ + if (!pstr) + { + return; + } + + CBasePlayerItem *pItem = NULL; + + for (int i = 0; i < MAX_ITEM_TYPES; i++) + { + pItem = m_rgpPlayerItems[ i ]; + + if (pItem != NULL) + { + while (pItem != NULL) + { + if (FClassnameIs(pItem->pev, pstr)) + break; + + pItem = pItem->m_pNext; + } + + if (pItem) + { + break; + } + } + } + + if (!pItem || pItem == m_pActiveItem) + { + return; + } + + ResetAutoaim(); + + // FIX, this needs to queue them up and delay + if (m_pActiveItem) + { + m_pActiveItem->Holster(); + } + + m_pLastItem = m_pActiveItem; + m_pActiveItem = pItem; + + if (m_pActiveItem) + { + CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; + pWeapon->m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; + + m_bShieldDrawn = false; + UpdateShieldCrosshair(true); + + m_pActiveItem->Deploy(); + m_pActiveItem->UpdateItemInfo(); + + ResetMaxSpeed(); + } +} + +/* <157268> ../cstrike/dlls/player.cpp:6909 */ +void CBasePlayer::SelectLastItem(void) +{ + if (m_pActiveItem && !m_pActiveItem->CanHolster()) + return; + + if (!m_pLastItem || m_pLastItem == m_pActiveItem) + { + for (int i = 1; i < MAX_ITEMS; i++) + { + CBasePlayerItem *pItem = m_rgpPlayerItems[i]; + if (pItem && pItem != m_pActiveItem) + { + m_pLastItem = pItem; + break; + } + } + } + + if (!m_pLastItem || m_pLastItem == m_pActiveItem) + return; + + ResetAutoaim(); + + if (m_pActiveItem) + m_pActiveItem->Holster(); + + if (HasShield()) + { + CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; + + if (m_pActiveItem) + pWeapon->m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; + + m_bShieldDrawn = false; + } + + CBasePlayerItem *pTemp = m_pActiveItem; + + m_pActiveItem = m_pLastItem; + m_pLastItem = pTemp; + + m_pActiveItem->Deploy(); + m_pActiveItem->UpdateItemInfo(); + + UpdateShieldCrosshair(true); + + ResetMaxSpeed(); +} + +// HasWeapons - do I have any weapons at all? + +/* <15733a> ../cstrike/dlls/player.cpp:6967 */ +BOOL CBasePlayer::HasWeapons(void) +{ + for (int i = 0; i < MAX_ITEM_TYPES; i++) + { + if (m_rgpPlayerItems[i]) + return TRUE; + } + return FALSE; +} + +/* <157372> ../cstrike/dlls/player.cpp:6982 */ +NOXREF void CBasePlayer::SelectPrevItem(int iItem) +{ + ; +} + +/* <15106c> ../cstrike/dlls/player.cpp:6987 */ +const char *CBasePlayer::__MAKE_VHOOK(TeamID)(void) +{ + // Not fully connected yet + if (pev == NULL) + return ""; + + // return their team name + return m_szTeamName; +} + +/* <1573aa> ../cstrike/dlls/player.cpp:7010 */ +void CSprayCan::Spawn(entvars_t *pevOwner) +{ + pev->origin = pevOwner->origin + Vector(0, 0, 32); + pev->angles = pevOwner->v_angle; + pev->owner = ENT(pevOwner); + pev->frame = 0; + + pev->nextthink = gpGlobals->time + 0.1; + EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/sprayer.wav", VOL_NORM, ATTN_NORM); +} + +/* <151815> ../cstrike/dlls/player.cpp:7021 */ +void CSprayCan::__MAKE_VHOOK(Think)(void) +{ + TraceResult tr; + int playernum; + int nFrames; + CBasePlayer *pPlayer; + + pPlayer = (CBasePlayer *)GET_PRIVATE(pev->owner); + + if (pPlayer) + nFrames = pPlayer->GetCustomDecalFrames(); + else + nFrames = -1; + + playernum = ENTINDEX(pev->owner); + + UTIL_MakeVectors(pev->angles); + UTIL_TraceLine(pev->origin, pev->origin + gpGlobals->v_forward * 128, ignore_monsters, pev->owner, &tr); + + // No customization present. + if (nFrames == -1) + { + UTIL_DecalTrace(&tr, DECAL_LAMBDA6); + UTIL_Remove(this); + } + else + { + UTIL_PlayerDecalTrace(&tr, playernum, pev->frame, TRUE); + + // Just painted last custom frame. + if (pev->frame++ >= (nFrames - 1)) + UTIL_Remove(this); + } + + pev->nextthink = gpGlobals->time + 0.1; +} + +/* <157481> ../cstrike/dlls/player.cpp:7064 */ +void CBloodSplat::Spawn(entvars_t *pevOwner) +{ + pev->origin = pevOwner->origin + Vector(0, 0, 32); + pev->angles = pevOwner->v_angle; + pev->owner = ENT(pevOwner); + + SetThink(&CBloodSplat::Spray); + pev->nextthink = gpGlobals->time + 0.1; +} + +/* <151758> ../cstrike/dlls/player.cpp:7074 */ +void CBloodSplat::Spray(void) +{ + TraceResult tr; + if (g_Language != LANGUAGE_GERMAN) + { + UTIL_MakeVectors(pev->angles); + UTIL_TraceLine(pev->origin, pev->origin + gpGlobals->v_forward * 128, ignore_monsters, pev->owner, &tr); + UTIL_BloodDecalTrace(&tr, BLOOD_COLOR_RED); + } + + SetThink(&CBloodSplat::SUB_Remove); + pev->nextthink = gpGlobals->time + 0.1; +} + +/* <1574d3> ../cstrike/dlls/player.cpp:7093 */ +void CBasePlayer::GiveNamedItem(const char *pszName) +{ + string_t istr = MAKE_STRING(pszName); + edict_t *pent = CREATE_NAMED_ENTITY(istr); + + if (FNullEnt(pent)) + { + ALERT(at_console, "NULL Ent in GiveNamedItem!\n"); + return; + } + + VARS(pent)->origin = pev->origin; + pent->v.spawnflags |= SF_NORESPAWN; + + DispatchSpawn(pent); + DispatchTouch(pent, ENT(pev)); +} + +/* <157568> ../cstrike/dlls/player.cpp:7114 */ +CBaseEntity *FindEntityForward(CBaseEntity *pMe) +{ + TraceResult tr; + + UTIL_MakeVectors(pMe->pev->v_angle); + UTIL_TraceLine(pMe->pev->origin + pMe->pev->view_ofs, pMe->pev->origin + pMe->pev->view_ofs + gpGlobals->v_forward * 8192, dont_ignore_monsters, pMe->edict(), &tr); + + if (tr.flFraction != 1.0 && !FNullEnt(tr.pHit)) + { + CBaseEntity *pHit = CBaseEntity::Instance(tr.pHit); + return pHit; + } + return NULL; +} + +/* <15777b> ../cstrike/dlls/player.cpp:7129 */ +BOOL CBasePlayer::FlashlightIsOn(void) +{ + return pev->effects & EF_DIMLIGHT; +} + +/* <15779e> ../cstrike/dlls/player.cpp:7135 */ +void CBasePlayer::FlashlightTurnOn(void) +{ + if (!g_pGameRules->FAllowFlashlight()) + return; + + if (pev->weapons & (1 << WEAPON_SUIT)) + { + EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/flashlight1.wav", VOL_NORM, ATTN_NORM); + + pev->effects |= EF_DIMLIGHT; + + MESSAGE_BEGIN(MSG_ONE, gmsgFlashlight, NULL, pev); + WRITE_BYTE(1); + WRITE_BYTE(m_iFlashBattery); + MESSAGE_END(); + + m_flFlashLightTime = gpGlobals->time + FLASH_DRAIN_TIME; + } +} + +/* <157816> ../cstrike/dlls/player.cpp:7157 */ +void CBasePlayer::FlashlightTurnOff(void) +{ + EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/flashlight1.wav", VOL_NORM, ATTN_NORM); + + pev->effects &= ~EF_DIMLIGHT; + MESSAGE_BEGIN(MSG_ONE, gmsgFlashlight, NULL, pev); + WRITE_BYTE(0); + WRITE_BYTE(m_iFlashBattery); + MESSAGE_END(); + + m_flFlashLightTime = gpGlobals->time + FLASH_CHARGE_TIME; +} + +/* <158ae7> ../cstrike/dlls/player.cpp:7179 */ +void CBasePlayer::ForceClientDllUpdate(void) +{ + m_iClientHealth = -1; + m_iClientBattery = -1; + m_fWeapon = FALSE; + m_fInitHUD = TRUE; + m_iTrain |= TRAIN_NEW; + + UpdateClientData(); + HandleSignals(); +} + +/* <157f8d> ../cstrike/dlls/player.cpp:7202 */ +void CBasePlayer::__MAKE_VHOOK(ImpulseCommands)(void) +{ + TraceResult tr; + + // Handle use events + PlayerUse(); + + int iImpulse = pev->impulse; + + switch (iImpulse) + { + case 99: + { + int iOn; + + if (!gmsgLogo) + { + iOn = 1; + gmsgLogo = REG_USER_MSG("Logo", 1); + } + else + iOn = 0; + + assert(gmsgLogo > 0); + + MESSAGE_BEGIN(MSG_ONE, gmsgLogo, NULL, pev); + WRITE_BYTE(iOn); + MESSAGE_END(); + + if (!iOn) + gmsgLogo = 0; + + break; + } + case 100: + { + // temporary flashlight for level designers + if (FlashlightIsOn()) + FlashlightTurnOff(); + else + FlashlightTurnOn(); + + break; + } + case 201: + { + // paint decal + if (gpGlobals->time < m_flNextDecalTime) + { + // too early! + break; + } + + UTIL_MakeVectors(pev->v_angle); + UTIL_TraceLine(pev->origin + pev->view_ofs, pev->origin + pev->view_ofs + gpGlobals->v_forward * 128, ignore_monsters, edict(), &tr); + + if (tr.flFraction != 1.0f) + { + // line hit something, so paint a decal + m_flNextDecalTime = gpGlobals->time + CVAR_GET_FLOAT("decalfrequency"); + CSprayCan *pCan = GetClassPtr((CSprayCan *)NULL); + pCan->Spawn(pev); + } + break; + } + default: + // check all of the cheat impulse commands now + CheatImpulseCommands(iImpulse); + } + + pev->impulse = 0; +} + +/* <15786e> ../cstrike/dlls/player.cpp:7280 */ +void CBasePlayer::CheatImpulseCommands(int iImpulse) +{ + if (!g_flWeaponCheat) + return; + + CBaseEntity *pEntity; + TraceResult tr; + + switch (iImpulse) + { + case 76: + if (!giPrecacheGrunt) + { + giPrecacheGrunt = 1; + ALERT(at_console, "You must now restart to use Grunt-o-matic.\n"); + } + else + { + UTIL_MakeVectors(Vector(0, pev->v_angle.y, 0)); + Create("monster_human_grunt", pev->origin + gpGlobals->v_forward * 128, pev->angles); + } + break; + case 101: + gEvilImpulse101 = TRUE; + AddAccount(16000); + ALERT(at_console, "Crediting %s with $16000\n", STRING(pev->netname)); + break; + case 102: + CGib::SpawnRandomGibs(pev, 1, 1); + break; + case 103: + { + // What the hell are you doing? + pEntity = FindEntityForward(this); + + if (pEntity) + { + CBaseMonster *pMonster = pEntity->MyMonsterPointer(); + + if (pMonster) + pMonster->ReportAIState(); + } + break; + } + case 104: + // Dump all of the global state varaibles (and global entity names) + gGlobalState.DumpGlobals(); + break; + case 105: + { + // player makes no sound for monsters to hear. + if (m_fNoPlayerSound) + { + ALERT(at_console, "Player is audible\n"); + m_fNoPlayerSound = FALSE; + } + else + { + ALERT(at_console, "Player is silent\n"); + m_fNoPlayerSound = TRUE; + } + break; + } + case 106: + { + // Give me the classname and targetname of this entity. + pEntity = FindEntityForward(this); + + if (pEntity) + { + ALERT(at_console, "Classname: %s", STRING(pEntity->pev->classname)); + + if (!FStringNull(pEntity->pev->targetname)) + ALERT(at_console, " - Targetname: %s\n", STRING(pEntity->pev->targetname)); + else + ALERT(at_console, " - TargetName: No Targetname\n"); + + ALERT(at_console, "Model: %s\n", STRING(pEntity->pev->model)); + + if (pEntity->pev->globalname) + ALERT(at_console, "Globalname: %s\n", STRING(pEntity->pev->globalname)); + } + break; + } + case 107: + { + TraceResult tr; + edict_t *pWorld = INDEXENT(0); + + Vector start = pev->origin + pev->view_ofs; + Vector end = start + gpGlobals->v_forward * 1024; + UTIL_TraceLine(start, end, ignore_monsters, edict(), &tr); + + if (tr.pHit) + pWorld = tr.pHit; + + const char *pszTextureName = TRACE_TEXTURE(pWorld, start, end); + + if (pszTextureName) + ALERT(at_console, "Texture: %s\n", pszTextureName); + + break; + } + case 195: + // show shortest paths for entire level to nearest node + Create("node_viewer_fly", pev->origin, pev->angles); + break; + case 196: + // show shortest paths for entire level to nearest node + Create("node_viewer_large", pev->origin, pev->angles); + break; + case 197: + // show shortest paths for entire level to nearest node + Create("node_viewer_human", pev->origin, pev->angles); + break; + case 199: + // show nearest node and all connections + ALERT(at_console, "%d\n", WorldGraph.FindNearestNode(pev->origin, bits_NODE_LAND)); + WorldGraph.ShowNodeConnections(WorldGraph.FindNearestNode(pev->origin, bits_NODE_LAND)); + break; + case 202: + { + // Random blood splatter + UTIL_MakeVectors(pev->v_angle); + UTIL_TraceLine(pev->origin + pev->view_ofs, pev->origin + pev->view_ofs + gpGlobals->v_forward * 128, ignore_monsters, edict(), &tr); + + if (tr.flFraction != 1.0f) + { + // line hit something, so paint a decal + CBloodSplat *pBlood = GetClassPtr((CBloodSplat *)NULL); + pBlood->Spawn(pev); + } + break; + } + case 203: + { + // remove creature. + pEntity = FindEntityForward(this); + + if (pEntity && pEntity->pev->takedamage != DAMAGE_NO) + { + pEntity->SetThink(&CBaseEntity::SUB_Remove); + } + break; + } + case 204: + { + TraceResult tr; + Vector dir = Vector(0, 0, 1); + + UTIL_BloodDrips(pev->origin, dir, BLOOD_COLOR_RED, 2000); + + for (int r = 1; r < 4; r++) + { + float bloodRange = r * 50.0f; + + for (int i = 0; i < 50; i++) + { + dir.x = RANDOM_FLOAT(-1, 1); + dir.y = RANDOM_FLOAT(-1, 1); + dir.z = RANDOM_FLOAT(-1, 1); + + if (dir.x || dir.y || dir.z) + dir.NormalizeInPlace(); + else + dir.z = -1.0f; + + UTIL_TraceLine(EyePosition(), EyePosition() + dir * bloodRange, ignore_monsters, pev->pContainingEntity, &tr); + + if (tr.flFraction < 1.0f) + UTIL_BloodDecalTrace(&tr, BLOOD_COLOR_RED); + } + } + break; + } + } +} + +/* <158256> ../cstrike/dlls/player.cpp:7474 */ +void OLD_CheckBuyZone(CBasePlayer *player) +{ + const char *pszSpawnClass = NULL; + + if (player->m_iTeam == TERRORIST) + pszSpawnClass = "info_player_deathmatch"; + + else if (player->m_iTeam == CT) + pszSpawnClass = "info_player_start"; + + if (pszSpawnClass != NULL) + { + CBaseEntity *pSpot = NULL; + while ((pSpot = UTIL_FindEntityByClassname(pSpot, pszSpawnClass)) != NULL) + { + if ((pSpot->pev->origin - player->pev->origin).Length() < 200.0f) + player->m_signals.Signal(SIGNAL_BUY); + } + } +} + +/* <14e5a9> ../cstrike/dlls/player.cpp:7514 */ +void OLD_CheckBombTarget(CBasePlayer *player) +{ + CBaseEntity *pSpot = NULL; + while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_bomb_target")) != NULL) + { + if ((pSpot->pev->origin - player->pev->origin).Length() <= 256.0f) + player->m_signals.Signal(SIGNAL_BOMB); + } +} + +/* <14e5d5> ../cstrike/dlls/player.cpp:7532 */ +void OLD_CheckRescueZone(CBasePlayer *player) +{ + CBaseEntity *pSpot = NULL; + while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_hostage_rescue")) != NULL) + { + if ((pSpot->pev->origin - player->pev->origin).Length() <= 256.0f) + player->m_signals.Signal(SIGNAL_RESCUE); + } +} + +/* <1582e9> ../cstrike/dlls/player.cpp:7553 */ +void CBasePlayer::HandleSignals(void) +{ + CHalfLifeMultiplay *mp = g_pGameRules; + + if (mp->IsMultiplayer()) + { + if (!mp->m_bMapHasBuyZone) + OLD_CheckBuyZone(this); + + if (!mp->m_bMapHasBombZone) + OLD_CheckBombTarget(this); + + if (!mp->m_bMapHasRescueZone) + OLD_CheckRescueZone(this); + } + + int state = m_signals.GetSignal(); + int changed = m_signals.GetState() ^ state; + + m_signals.Update(); + + if (changed & SIGNAL_BUY) + { + if (state & SIGNAL_BUY) + BuyZoneIcon_Set(this); + else + BuyZoneIcon_Clear(this); + } + if (changed & SIGNAL_BOMB) + { + if (state & SIGNAL_BOMB) + BombTargetFlash_Set(this); + else + BombTargetFlash_Clear(this); + } + if (changed & SIGNAL_RESCUE) + { + if (state & SIGNAL_RESCUE) + RescueZoneIcon_Set(this); + else + RescueZoneIcon_Clear(this); + } + if (changed & SIGNAL_ESCAPE) + { + if (state & SIGNAL_ESCAPE) + EscapeZoneIcon_Set(this); + else + EscapeZoneIcon_Clear(this); + } + if (changed & SIGNAL_VIPSAFETY) + { + if (state & SIGNAL_VIPSAFETY) + VIP_SafetyZoneIcon_Set(this); + else + VIP_SafetyZoneIcon_Clear(this); + } +} + +// Add a weapon to the player (Item == Weapon == Selectable Object) + +/* <15325f> ../cstrike/dlls/player.cpp:7625 */ +BOOL CBasePlayer::__MAKE_VHOOK(AddPlayerItem)(CBasePlayerItem *pItem) +{ + CBasePlayerItem *pInsert = m_rgpPlayerItems[ pItem->iItemSlot() ]; + while (pInsert != NULL) + { + if (FClassnameIs(pInsert->pev, STRING(pItem->pev->classname))) + { + if (pItem->AddDuplicate(pInsert)) + { + g_pGameRules->PlayerGotWeapon(this, pItem); + pItem->CheckRespawn(); + + // ugly hack to update clip w/o an update clip message + pItem->UpdateItemInfo(); + + if (m_pActiveItem) + m_pActiveItem->UpdateItemInfo(); + + pItem->Kill(); + } + else if (gEvilImpulse101) + pItem->Kill(); + + return FALSE; + } + + pInsert = pInsert->m_pNext; + } + if (pItem->AddToPlayer(this)) + { + g_pGameRules->PlayerGotWeapon(this, pItem); + + if (pItem->iItemSlot() == PRIMARY_WEAPON_SLOT) + m_bHasPrimary = true; + + pItem->CheckRespawn(); + pItem->m_pNext = m_rgpPlayerItems[ pItem->iItemSlot() ]; + m_rgpPlayerItems[ pItem->iItemSlot() ] = pItem; + + if (HasShield()) + pev->gamestate = 0; + + // should we switch to this item? + if (g_pGameRules->FShouldSwitchWeapon(this, pItem)) + { + if (!m_bShieldDrawn) + { + SwitchWeapon(pItem); + } + } + + return TRUE; + } + else if (gEvilImpulse101) + { + pItem->Kill(); + } + + return FALSE; +} + +/* <1534bd> ../cstrike/dlls/player.cpp:7692 */ +BOOL CBasePlayer::__MAKE_VHOOK(RemovePlayerItem)(CBasePlayerItem *pItem) +{ + if (m_pActiveItem == pItem) + { + ResetAutoaim(); + pItem->pev->nextthink = 0; + + pItem->SetThink(NULL); + m_pActiveItem = NULL; + + pev->viewmodel = 0; + pev->weaponmodel = 0; + } + else if (m_pLastItem == pItem) + m_pLastItem = NULL; + + CBasePlayerItem *pPrev = m_rgpPlayerItems[pItem->iItemSlot()]; + if (pPrev == pItem) + { + m_rgpPlayerItems[pItem->iItemSlot()] = pItem->m_pNext; + return TRUE; + } + + while (pPrev && pPrev->m_pNext != pItem) + pPrev = pPrev->m_pNext; + + if (pPrev) + { + pPrev->m_pNext = pItem->m_pNext; + return TRUE; + } + return FALSE; +} + +// Returns the unique ID for the ammo, or -1 if error + +/* <15997b> ../cstrike/dlls/player.cpp:7731 */ +int CBasePlayer::__MAKE_VHOOK(GiveAmmo)(int iCount, char *szName, int iMax) +{ + if (pev->flags & FL_SPECTATOR) + return -1; + + if (!szName) + { + // no ammo. + return -1; + } + + if (!g_pGameRules->CanHaveAmmo(this, szName, iMax)) + { + // game rules say I can't have any more of this ammo type. + return -1; + } + + int i = GetAmmoIndex(szName); + + if (i < 0 || i >= MAX_AMMO_SLOTS) + return -1; + + int iAdd = Q_min(iCount, iMax - m_rgAmmo[i]); + if (iAdd < 1) + return i; + + m_rgAmmo[i] += iAdd; + + // make sure the ammo messages have been linked first + if (gmsgAmmoPickup) + { + // Send the message that ammo has been picked up + MESSAGE_BEGIN(MSG_ONE, gmsgAmmoPickup, NULL, pev); + WRITE_BYTE(GetAmmoIndex(szName)); // ammo ID + WRITE_BYTE(iAdd); // amount + MESSAGE_END(); + } + TabulateAmmo(); + + return i; +} + +// Called every frame by the player PreThink + +/* <158b10> ../cstrike/dlls/player.cpp:7784 */ +void CBasePlayer::ItemPreFrame(void) +{ +#ifdef CLIENT_WEAPONS + if (m_flNextAttack > 0) + return; +#else + if (gpGlobals->time < m_flNextAttack) + return; +#endif // CLIENT_WEAPONS + + if (!m_pActiveItem) + return; + + m_pActiveItem->ItemPreFrame(); +} + +// Called every frame by the player PostThink + +/* <158b33> ../cstrike/dlls/player.cpp:7805 */ +void CBasePlayer::ItemPostFrame(void) +{ + static int fInSelect = FALSE; + + // check if the player is using a tank + if (m_pTank != NULL) + return; + + if (m_pActiveItem != NULL) + { + if (HasShield() && IsReloading()) + { + if (pev->button & IN_ATTACK2) + m_flNextAttack = 0; + } + } + +#ifdef CLIENT_WEAPONS + if (m_flNextAttack > 0) +#else + if (gpGlobals->time < m_flNextAttack) +#endif // CLIENT_WEAPONS + return; + + ImpulseCommands(); + + if (m_pActiveItem != NULL) + m_pActiveItem->ItemPostFrame(); +} + +/* <158b71> ../cstrike/dlls/player.cpp:7834 */ +int CBasePlayer::AmmoInventory(int iAmmoIndex) +{ + if (iAmmoIndex == -1) + return -1; + + return m_rgAmmo[iAmmoIndex]; +} + +/* <158b9d> ../cstrike/dlls/player.cpp:7844 */ +int CBasePlayer::GetAmmoIndex(const char *psz) +{ + if (!psz) + return -1; + + for (int i = 1; i < MAX_AMMO_SLOTS; i++) + { + if (!IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, AmmoInfoArray)[ i ].pszName) + continue; + + if (!Q_stricmp(psz, IMPLEMENT_ARRAY_CLASS(CBasePlayerItem, AmmoInfoArray)[ i ].pszName)) + return i; + } + return -1; +} + +/* <158bf7> ../cstrike/dlls/player.cpp:7865 */ +void CBasePlayer::SendAmmoUpdate(void) +{ + for (int i = 0; i < MAX_AMMO_SLOTS; i++) + { + if (m_rgAmmo[i] != m_rgAmmoLast[i]) + { + m_rgAmmoLast[i] = m_rgAmmo[i]; + + // send "Ammo" update message + MESSAGE_BEGIN(MSG_ONE, gmsgAmmoX, NULL, pev); + WRITE_BYTE(i); + WRITE_BYTE(Q_max(Q_min(m_rgAmmo[i], 254), 0)); // clamp the value to one byte + MESSAGE_END(); + } + } +} + +/* <158d4b> ../cstrike/dlls/player.cpp:7885 */ +void CBasePlayer::SendHostagePos(void) +{ + CBaseEntity *pHostage = NULL; + + while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")) != NULL) + { + MESSAGE_BEGIN(MSG_ONE, gmsgHostagePos, NULL, pev); + WRITE_BYTE(1); + WRITE_BYTE(((CHostage *)pHostage)->m_iHostageIndex); + WRITE_COORD(pHostage->pev->origin.x); + WRITE_COORD(pHostage->pev->origin.y); + WRITE_COORD(pHostage->pev->origin.z); + MESSAGE_END(); + } + + SendHostageIcons(); +} + +/* <158c66> ../cstrike/dlls/player.cpp:7908 */ +void CBasePlayer::SendHostageIcons(void) +{ + CBaseEntity *pHostage = NULL; + int numHostages = 0; + char buf[16]; + + if (!UTIL_IsGame("czero")) + return; + + while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")) != NULL) + { + if (pHostage && pHostage->pev->deadflag == DEAD_NO) + numHostages++; + } + + if (numHostages > 4) + numHostages = 4; + + Q_snprintf(buf, ARRAYSIZE(buf), "hostage%d", numHostages); + + if (numHostages) + { + MESSAGE_BEGIN(MSG_ONE, gmsgScenarioIcon, NULL, pev); + WRITE_BYTE(1); + WRITE_STRING(buf); + WRITE_BYTE(0); + MESSAGE_END(); + } + else + { + MESSAGE_BEGIN(MSG_ONE, gmsgScenarioIcon, NULL, pev); + WRITE_BYTE(0); + MESSAGE_END(); + } +} + +/* <158dc6> ../cstrike/dlls/player.cpp:7949 */ +void CBasePlayer::SendWeatherInfo(void) +{ + CBaseEntity *pPoint = UTIL_FindEntityByClassname(NULL, "env_rain"); + CBaseEntity *pPoint2 = UTIL_FindEntityByClassname(NULL, "func_rain"); + + if (pPoint != NULL || pPoint2 != NULL) + { + MESSAGE_BEGIN(MSG_ONE, gmsgReceiveW, NULL, pev); + WRITE_BYTE(1); + MESSAGE_END(); + } + else + { + pPoint = UTIL_FindEntityByClassname(NULL, "env_snow"); + pPoint2 = UTIL_FindEntityByClassname(NULL, "func_snow"); + + if (pPoint != NULL || pPoint2 != NULL) + { + MESSAGE_BEGIN(MSG_ONE, gmsgReceiveW, NULL, pev); + WRITE_BYTE(2); + MESSAGE_END(); + } + } +} + +// resends any changed player HUD info to the client. +// Called every frame by PlayerPreThink +// Also called at start of demo recording and playback by +// ForceClientDllUpdate to ensure the demo gets messages +// reflecting all of the HUD state info. + +/* <159d3c> ../cstrike/dlls/player.cpp:7963 */ +void CBasePlayer::__MAKE_VHOOK(UpdateClientData)(void) +{ + if (m_fInitHUD) + { + m_fInitHUD = FALSE; + gInitHUD = FALSE; + m_signals.Update(); + + MESSAGE_BEGIN(MSG_ONE, gmsgResetHUD, NULL, pev); + MESSAGE_END(); + + CHalfLifeMultiplay *mp = g_pGameRules; + + if (!m_fGameHUDInitialized) + { + MESSAGE_BEGIN(MSG_ONE, gmsgInitHUD, NULL, pev); + MESSAGE_END(); + + CBaseEntity *pEntity = UTIL_FindEntityByClassname(NULL, "env_fog"); + + if (pEntity) + { + CClientFog *pFog = (CClientFog *)pEntity; + + int r = pFog->pev->rendercolor[0]; + int g = pFog->pev->rendercolor[1]; + int b = pFog->pev->rendercolor[2]; + + if (r > 255) + r = 255; + + else if (r < 0) + r = 0; + + if (g > 255) + g = 255; + + else if (g < 0) + g = 0; + + if (b > 255) + b = 255; + + else if (b < 0) + b = 0; + + union + { + float f; + char b[4]; + + } density; + + density.f = pFog->m_fDensity; + + MESSAGE_BEGIN(MSG_ONE, gmsgFog, NULL, pev); + WRITE_BYTE(r); + WRITE_BYTE(g); + WRITE_BYTE(b); + WRITE_BYTE(density.b[0]); + WRITE_BYTE(density.b[1]); + WRITE_BYTE(density.b[2]); + WRITE_BYTE(density.b[3]); + MESSAGE_END(); + } + + mp->InitHUD(this); + m_fGameHUDInitialized = TRUE; + + if (mp->IsMultiplayer()) + { + FireTargets("game_playerjoin", this, this, USE_TOGGLE, 0); + } + + m_iObserverLastMode = OBS_ROAMING; + m_iObserverC4State = 0; + m_bObserverHasDefuser = false; + SetObserverAutoDirector(false); + } + + FireTargets("game_playerspawn", this, this, USE_TOGGLE, 0); + + MESSAGE_BEGIN(MSG_ONE, gmsgMoney, NULL, pev); + WRITE_LONG(m_iAccount); + WRITE_BYTE(0); + MESSAGE_END(); + + if (m_bHasDefuser) + { + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + WRITE_BYTE(STATUSICON_SHOW); + WRITE_STRING("defuser"); + WRITE_BYTE(0); + WRITE_BYTE(160); + WRITE_BYTE(0); + MESSAGE_END(); + } + + SetBombIcon(FALSE); + SyncRoundTimer(); + SendHostagePos(); + SendWeatherInfo(); + + if (mp->IsMultiplayer()) + { + MESSAGE_BEGIN(MSG_ONE, gmsgTeamScore, NULL, pev); + WRITE_STRING(GetTeam(CT)); + WRITE_SHORT(mp->m_iNumCTWins); + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_ONE, gmsgTeamScore, NULL, pev); + WRITE_STRING(GetTeam(TERRORIST)); + WRITE_SHORT(mp->m_iNumTerroristWins); + MESSAGE_END(); + } + } + + if (m_iHideHUD != m_iClientHideHUD) + { + MESSAGE_BEGIN(MSG_ONE, gmsgHideWeapon, NULL, pev); + WRITE_BYTE(m_iHideHUD); + MESSAGE_END(); + + m_iClientHideHUD = m_iHideHUD; + } + + if (m_iFOV != m_iClientFOV) + { + // cache FOV change at end of function, so weapon updates can see that FOV has changed + + pev->fov = m_iFOV; + + MESSAGE_BEGIN(MSG_ONE, gmsgSetFOV, NULL, pev); + WRITE_BYTE(m_iFOV); + MESSAGE_END(); + + MESSAGE_BEGIN(MSG_SPEC, gmsgHLTV); + WRITE_BYTE(ENTINDEX(edict())); + WRITE_BYTE(m_iFOV); + MESSAGE_END(); + } + + // HACKHACK -- send the message to display the game title + if (gDisplayTitle) + { + MESSAGE_BEGIN(MSG_ONE, gmsgShowGameTitle, NULL, pev); + WRITE_BYTE(0); + MESSAGE_END(); + + gDisplayTitle = FALSE; + } + + if ((int)pev->health != m_iClientHealth) + { + int iHealth = clamp(pev->health, 0, 255); + + if (pev->health > 0.0f && pev->health <= 1.0f) + iHealth = 1; + + // send "health" update message + MESSAGE_BEGIN(MSG_ONE, gmsgHealth, NULL, pev); + WRITE_BYTE(iHealth); + MESSAGE_END(); + + m_iClientHealth = (int)pev->health; + } + + if ((int)pev->armorvalue != m_iClientBattery) + { + m_iClientBattery = (int)pev->armorvalue; + + assert(gmsgBattery > 0); + + // send "armor" update message + MESSAGE_BEGIN(MSG_ONE, gmsgBattery, NULL, pev); + WRITE_SHORT((int)pev->armorvalue); + MESSAGE_END(); + } + + if (pev->dmg_take != 0.0f || pev->dmg_save != 0.0f || m_bitsHUDDamage != m_bitsDamageType) + { + // Comes from inside me if not set + Vector damageOrigin = pev->origin; + + // send "damage" message + // causes screen to flash, and pain compass to show direction of damage + edict_t *other = pev->dmg_inflictor; + + if (other) + { + CBaseEntity *pEntity = CBaseEntity::Instance(other); + + if (pEntity) + { + damageOrigin = pEntity->Center(); + } + } + + // only send down damage type that have hud art + int visibleDamageBits = m_bitsDamageType & DMG_SHOWNHUD; + + MESSAGE_BEGIN(MSG_ONE, gmsgDamage, NULL, pev); + WRITE_BYTE((int)pev->dmg_save); + WRITE_BYTE((int)pev->dmg_take); + WRITE_LONG(visibleDamageBits); + WRITE_COORD(damageOrigin.x); + WRITE_COORD(damageOrigin.y); + WRITE_COORD(damageOrigin.z); + MESSAGE_END(); + + pev->dmg_take = 0; + pev->dmg_save = 0; + m_bitsHUDDamage = m_bitsDamageType; + + // Clear off non-time-based damage indicators + m_bitsDamageType &= DMG_TIMEBASED; + } + + // Update Flashlight + if (m_flFlashLightTime && m_flFlashLightTime <= gpGlobals->time) + { + if (FlashlightIsOn()) + { + if (m_iFlashBattery) + { + m_flFlashLightTime = gpGlobals->time + FLASH_DRAIN_TIME; + m_iFlashBattery--; + + if (!m_iFlashBattery) + { + FlashlightTurnOff(); + } + } + } + else + { + if (m_iFlashBattery < 100) + { + m_flFlashLightTime = gpGlobals->time + FLASH_CHARGE_TIME; + m_iFlashBattery++; + } + else + m_flFlashLightTime = 0; + } + + MESSAGE_BEGIN(MSG_ONE, gmsgFlashBattery, NULL, pev); + WRITE_BYTE(m_iFlashBattery); + MESSAGE_END(); + } + + if (m_iTrain & TRAIN_NEW) + { + assert(gmsgTrain > 0); + + // send "train hud" update message + MESSAGE_BEGIN(MSG_ONE, gmsgTrain, NULL, pev); + WRITE_BYTE(m_iTrain & 0xF); + MESSAGE_END(); + + m_iTrain &= ~TRAIN_NEW; + } + + SendAmmoUpdate(); + + // Update all the items + for (int i = 0; i < MAX_ITEM_TYPES; i++) + { + if (m_rgpPlayerItems[i]) + { + // each item updates it's successors + m_rgpPlayerItems[i]->UpdateClientData(this); + } + } + + // Cache and client weapon change + m_pClientActiveItem = m_pActiveItem; + m_iClientFOV = m_iFOV; + + // Update Status Bar + if (m_flNextSBarUpdateTime < gpGlobals->time) + { + UpdateStatusBar(); + m_flNextSBarUpdateTime = gpGlobals->time + 0.2; + } + + if (!(m_flDisplayHistory & DHF_AMMO_EXHAUSTED)) + { + if (m_pActiveItem && m_pActiveItem->IsWeapon()) + { + CBasePlayerWeapon *w = (CBasePlayerWeapon *)m_pActiveItem; + + if (!(w->iFlags() & ITEM_FLAG_EXHAUSTIBLE)) + { + if (AmmoInventory(w->m_iPrimaryAmmoType) < 1 && w->m_iClip == 0) + { + m_flDisplayHistory |= DHF_AMMO_EXHAUSTED; + HintMessage("#Hint_out_of_ammo"); + } + } + } + } + + if (gpGlobals->time > m_tmHandleSignals) + { + m_tmHandleSignals = gpGlobals->time + 0.5f; + HandleSignals(); + } + + if (pev->deadflag == DEAD_NO && gpGlobals->time > m_tmNextRadarUpdate) + { + m_tmNextRadarUpdate = gpGlobals->time + 1.0f; + + if ((pev->origin - m_vLastOrigin).Length() >= 64) + { + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBaseEntity *pEntity = UTIL_PlayerByIndex(i); + + if (!pEntity || i == entindex()) + continue; + + CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pEntity->pev); + + if (pPlayer->pev->flags == FL_DORMANT) + continue; + + if (pPlayer->pev->deadflag != DEAD_NO) + continue; + + if (pPlayer->m_iTeam == m_iTeam) + { + MESSAGE_BEGIN(MSG_ONE, gmsgRadar, NULL, pPlayer->pev); + WRITE_BYTE(entindex()); + WRITE_COORD(pev->origin.x); + WRITE_COORD(pev->origin.y); + WRITE_COORD(pev->origin.z); + MESSAGE_END(); + } + } + } + + m_vLastOrigin = pev->origin; + } +} + +/* <1510bc> ../cstrike/dlls/player.cpp:8330 */ +BOOL CBasePlayer::__MAKE_VHOOK(FBecomeProne)(void) +{ + m_afPhysicsFlags |= PFLAG_ONBARNACLE; + return TRUE; +} + +/* <158e8a> ../cstrike/dlls/player.cpp:8341 */ +NOXREF void CBasePlayer::BarnacleVictimBitten(entvars_t *pevBarnacle) +{ + TakeDamage(pevBarnacle, pevBarnacle, pev->armorvalue + pev->health, DMG_SLASH | DMG_ALWAYSGIB); +} + +/* <158ec3> ../cstrike/dlls/player.cpp:8350 */ +NOXREF void CBasePlayer::BarnacleVictimReleased(void) +{ + m_afPhysicsFlags &= ~PFLAG_ONBARNACLE; +} + +// return player light level plus virtual muzzle flash + +/* <1510e4> ../cstrike/dlls/player.cpp:8360 */ +int CBasePlayer::__MAKE_VHOOK(Illumination)(void) +{ + int iIllum = CBaseEntity::Illumination(); + + iIllum += m_iWeaponFlash; + + if (iIllum > 255) + return 255; + + return iIllum; +} + +/* <158eeb> ../cstrike/dlls/player.cpp:8371 */ +void CBasePlayer::EnableControl(BOOL fControl) +{ + if (!fControl) + pev->flags |= FL_FROZEN; + else + pev->flags &= ~FL_FROZEN; +} + +/* <151142> ../cstrike/dlls/player.cpp:8387 */ +void CBasePlayer::__MAKE_VHOOK(ResetMaxSpeed)(void) +{ + float speed; + + if (IsObserver()) + { + // Player gets speed bonus in observer mode + speed = 900; + } + else if (g_pGameRules->IsMultiplayer() && g_pGameRules->IsFreezePeriod()) + { + // Player should not move during the freeze period + speed = 1; + } + // VIP is slow due to the armour he's wearing + else if (m_bIsVIP != NULL) + { + speed = 227; + } + else if (m_pActiveItem != NULL) + { + // Get player speed from selected weapon + speed = m_pActiveItem->GetMaxSpeed(); + } + else + { + // No active item, set the player's speed to default + speed = 240; + } + + pev->maxspeed = speed; +} + +/* <158f23> ../cstrike/dlls/player.cpp:8436 */ +bool CBasePlayer::HintMessage(const char *pMessage, BOOL bDisplayIfPlayerDead, BOOL bOverride) +{ + if (!bDisplayIfPlayerDead && !IsAlive()) + return false; + + if (bOverride || m_bShowHints) + return m_hintMessageQueue.AddMessage(pMessage, 6.0, true, NULL); + + return true; +} + +/* <1513f7> ../cstrike/dlls/player.cpp:8473 */ +Vector CBasePlayer::__MAKE_VHOOK(GetAutoaimVector)(float flDelta) +{ + Vector vecSrc; + BOOL m_fOldTargeting; + Vector angles; + + if (g_iSkillLevel == SKILL_HARD) + { + UTIL_MakeVectors(pev->v_angle + pev->punchangle); + return gpGlobals->v_forward; + } + + vecSrc = GetGunPosition(); + m_fOldTargeting = m_fOnTarget; + m_vecAutoAim = Vector(0, 0, 0); + angles = AutoaimDeflection(vecSrc, 8192, flDelta); + + if (g_pGameRules->AllowAutoTargetCrosshair()) + { + if (m_fOldTargeting != m_fOnTarget) + m_pActiveItem->UpdateItemInfo(); + } + else + m_fOnTarget = FALSE; + + if (angles.x > 180.0f) + angles.x -= 360.0f; + if (angles.x < -180.0f) + angles.x += 360.0f; + + if (angles.y > 180.0f) + angles.y -= 360.0f; + if (angles.y < -180.0f) + angles.y += 360.0f; + + if (angles.x > 25.0f) + angles.x = 25.0f; + if (angles.x < -25.0f) + angles.x = -25.0f; + + if (angles.y > 12.0f) + angles.y = 12.0f; + if (angles.y < -12.0f) + angles.y = -12.0f; + + if (g_iSkillLevel == SKILL_EASY) + m_vecAutoAim = m_vecAutoAim * 0.67f + angles * 0.33f; + else + m_vecAutoAim = angles * 0.9f; + + if (sv_aim && sv_aim->value > 0.0f) + { + if (m_vecAutoAim.x != m_lastx || m_vecAutoAim.y != m_lasty) + { + SET_CROSSHAIRANGLE(ENT(pev), -m_vecAutoAim.x, m_vecAutoAim.y); + + m_lastx = m_vecAutoAim.x; + m_lasty = m_vecAutoAim.y; + } + } + + UTIL_MakeVectors(pev->v_angle + pev->punchangle + m_vecAutoAim); + return gpGlobals->v_forward; +} + +/* <158f62> ../cstrike/dlls/player.cpp:8553 */ +Vector CBasePlayer::AutoaimDeflection(Vector &vecSrc, float flDist, float flDelta) +{ + m_fOnTarget = FALSE; + return g_vecZero; +} + +/* <158fc1> ../cstrike/dlls/player.cpp:8686 */ +void CBasePlayer::ResetAutoaim(void) +{ + if (m_vecAutoAim.x != 0.0f || m_vecAutoAim.y != 0.0f) + { + m_vecAutoAim = Vector(0, 0, 0); + SET_CROSSHAIRANGLE(ENT(pev), 0, 0); + } + m_fOnTarget = FALSE; +} + +// UNDONE: Determine real frame limit, 8 is a placeholder. +// Note: -1 means no custom frames present. + +/* <158ff6> ../cstrike/dlls/player.cpp:8704 */ +void CBasePlayer::SetCustomDecalFrames(int nFrames) +{ + if (nFrames > 0 && nFrames < 8) + m_nCustomSprayFrames = nFrames; + else + m_nCustomSprayFrames = -1; +} + +// Returns the # of custom frames this player's custom clan logo contains. + +/* <15902e> ../cstrike/dlls/player.cpp:8720 */ +int CBasePlayer::GetCustomDecalFrames(void) +{ + return m_nCustomSprayFrames; +} + +/* <151183> ../cstrike/dlls/player.cpp:8731 */ +void CBasePlayer::__MAKE_VHOOK(Blind)(float duration, float holdTime, float fadeTime, int alpha) +{ + m_blindUntilTime = gpGlobals->time + duration; + m_blindStartTime = gpGlobals->time; + + m_blindHoldTime = holdTime; + m_blindFadeTime = fadeTime; + m_blindAlpha = alpha; +} + +/* <159051> ../cstrike/dlls/player.cpp:8741 */ +void CBasePlayer::InitStatusBar(void) +{ + m_flStatusBarDisappearDelay = 0.0f; + m_SbarString0[0] = '\0'; +} + +/* <159079> ../cstrike/dlls/player.cpp:8749 */ +void CBasePlayer::UpdateStatusBar(void) +{ + int newSBarState[ SBAR_END ]; + char sbuf0[ SBAR_STRING_SIZE ]; + + Q_memset(newSBarState, 0, sizeof(newSBarState)); + Q_strcpy(sbuf0, m_SbarString0); + + // Find an ID Target + TraceResult tr; + UTIL_MakeVectors(pev->v_angle + pev->punchangle); + + Vector vecSrc = EyePosition(); + Vector vecEnd = vecSrc + (gpGlobals->v_forward * ((pev->flags & FL_SPECTATOR) != 0 ? MAX_SPECTATOR_ID_RANGE : MAX_ID_RANGE)); + + UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, edict(), &tr); + + if (tr.flFraction != 1.0f) + { + if (!FNullEnt(tr.pHit)) + { + CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); + bool isVisiblePlayer = (!TheBots->IsLineBlockedBySmoke(&pev->origin, &pEntity->pev->origin) && pEntity->Classify() == CLASS_PLAYER); + + if (gpGlobals->time >= m_blindUntilTime && isVisiblePlayer) + { + CBasePlayer *pTarget = (CBasePlayer *)pEntity; + + newSBarState[ SBAR_ID_TARGETNAME ] = ENTINDEX(pTarget->edict()); + newSBarState[ SBAR_ID_TARGETTYPE ] = (pTarget->m_iTeam == m_iTeam) ? SBAR_TARGETTYPE_TEAMMATE : SBAR_TARGETTYPE_ENEMY; + + if (pTarget->m_iTeam == m_iTeam || IsObserver()) + { + if (playerid.value != PLAYERID_MODE_OFF || IsObserver()) + Q_strcpy(sbuf0, "1 %c1: %p2\n2 %h: %i3%%"); + else + Q_strcpy(sbuf0, " "); + + newSBarState[ SBAR_ID_TARGETHEALTH ] = (int)((pEntity->pev->health / pEntity->pev->max_health) * 100); + + if (!(m_flDisplayHistory & DHF_FRIEND_SEEN) && !(pev->flags & FL_SPECTATOR)) + { + m_flDisplayHistory |= DHF_FRIEND_SEEN; + HintMessage("#Hint_spotted_a_friend"); + } + } + else if (!IsObserver()) + { + if (playerid.value != PLAYERID_MODE_TEAMONLY && playerid.value != PLAYERID_MODE_OFF) + Q_strcpy(sbuf0, "1 %c1: %p2"); + else + Q_strcpy(sbuf0, " "); + + if (!(m_flDisplayHistory & DHF_ENEMY_SEEN)) + { + m_flDisplayHistory |= DHF_ENEMY_SEEN; + HintMessage("#Hint_spotted_an_enemy"); + } + } + + m_flStatusBarDisappearDelay = gpGlobals->time + 2.0f; + } + else if (pEntity->Classify() == CLASS_HUMAN_PASSIVE) + { + if (playerid.value != PLAYERID_MODE_OFF || IsObserver()) + Q_strcpy(sbuf0, "1 %c1 %h: %i3%%"); + else + Q_strcpy(sbuf0, " "); + + newSBarState[ SBAR_ID_TARGETTYPE ] = SBAR_TARGETTYPE_HOSTAGE; + newSBarState[ SBAR_ID_TARGETHEALTH ] = (int)((pEntity->pev->health / pEntity->pev->max_health) * 100); + + if (!(m_flDisplayHistory & DHF_HOSTAGE_SEEN_FAR) && tr.flFraction > 0.1f) + { + m_flDisplayHistory |= DHF_HOSTAGE_SEEN_FAR; + + if (m_iTeam == TERRORIST) + HintMessage("#Hint_prevent_hostage_rescue", TRUE); + + else if (m_iTeam == CT) + HintMessage("#Hint_rescue_the_hostages", TRUE); + } + else if (m_iTeam == CT && !(m_flDisplayHistory & DHF_HOSTAGE_SEEN_NEAR) && tr.flFraction <= 0.1f) + { + m_flDisplayHistory |= (DHF_HOSTAGE_SEEN_NEAR | DHF_HOSTAGE_SEEN_FAR); + HintMessage("#Hint_press_use_so_hostage_will_follow"); + } + + m_flStatusBarDisappearDelay = gpGlobals->time + 2.0f; + } + } + } + else if (m_flStatusBarDisappearDelay > gpGlobals->time) + { + // hold the values for a short amount of time after viewing the object + + newSBarState[ SBAR_ID_TARGETTYPE ] = m_izSBarState[ SBAR_ID_TARGETTYPE ]; + newSBarState[ SBAR_ID_TARGETNAME ] = m_izSBarState[ SBAR_ID_TARGETNAME ]; + newSBarState[ SBAR_ID_TARGETHEALTH ] = m_izSBarState[ SBAR_ID_TARGETHEALTH ]; + } + + BOOL bForceResend = FALSE; + + if (Q_strcmp(sbuf0, m_SbarString0)) + { + MESSAGE_BEGIN(MSG_ONE, gmsgStatusText, NULL, pev); + WRITE_BYTE(0); + WRITE_STRING(sbuf0); + MESSAGE_END(); + + Q_strcpy(m_SbarString0, sbuf0); + + // make sure everything's resent + bForceResend = TRUE; + } + + // Check values and send if they don't match + for (int i = 1; i < SBAR_END; i++) + { + if (newSBarState[ i ] != m_izSBarState[ i ] || bForceResend) + { + MESSAGE_BEGIN(MSG_ONE, gmsgStatusValue, NULL, pev); + WRITE_BYTE(i); + WRITE_SHORT(newSBarState[ i ]); + MESSAGE_END(); + + m_izSBarState[ i ] = newSBarState[ i ]; + } + } +} + +/* <1603f0> ../cstrike/dlls/player.cpp:8926 */ +void CBasePlayer::DropPlayerItem(const char *pszItemName) +{ + if (!Q_strlen(pszItemName)) + { + // if this string has no length, the client didn't type a name! + // assume player wants to drop the active item. + // make the string null to make future operations in this function easier + pszItemName = NULL; + } + + if (m_bIsVIP) + { + ClientPrint(pev, HUD_PRINTCENTER, "#Weapon_Cannot_Be_Dropped"); + return; + } + else if (!pszItemName && HasShield()) + { + DropShield(); + return; + } + + for (int i = 0; i < MAX_ITEM_TYPES; i++) + { + CBasePlayerItem *pWeapon = m_rgpPlayerItems[i]; + + while (pWeapon != NULL) + { + if (pszItemName) + { + if (!Q_strcmp(pszItemName, STRING(pWeapon->pev->classname))) + break; + } + else + { + if (pWeapon == m_pActiveItem) + break; + } + + pWeapon = pWeapon->m_pNext; + } + + if (pWeapon) + { + if (!pWeapon->CanDrop()) + { + ClientPrint(pev, HUD_PRINTCENTER, "#Weapon_Cannot_Be_Dropped"); + continue; + } + + // take item off hud + pev->weapons &= ~(1 << pWeapon->m_iId); + g_pGameRules->GetNextBestWeapon(this, pWeapon); + UTIL_MakeVectors(pev->angles); + + if (pWeapon->iItemSlot() == PRIMARY_WEAPON_SLOT) + m_bHasPrimary = false; + + if (!Q_strcmp(STRING(pWeapon->pev->classname), "weapon_c4")) + { + m_bHasC4 = false; + pev->body = 0; + SetBombIcon(FALSE); + pWeapon->m_pPlayer->SetProgressBarTime(0); + + if (!g_pGameRules->m_fTeamCount) + { + UTIL_LogPrintf("\"%s<%i><%s>\" triggered \"Dropped_The_Bomb\"\n", + STRING(pev->netname), + GETPLAYERUSERID(edict()), + GETPLAYERAUTHID(edict())); + + g_pGameRules->m_bBombDropped = TRUE; + + CBaseEntity *pEntity = NULL; + + while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")) != NULL) + { + if (FNullEnt(pEntity->edict())) + break; + + if (!pEntity->IsPlayer()) + continue; + + if (pEntity->pev->flags != FL_DORMANT) + { + CBasePlayer *pOther = GetClassPtr((CBasePlayer *)pEntity->pev); + + if (pOther->pev->deadflag == DEAD_NO && pOther->m_iTeam == TERRORIST) + { + ClientPrint(pOther->pev, HUD_PRINTCENTER, "#Game_bomb_drop", STRING(pev->netname)); + + MESSAGE_BEGIN(MSG_ONE, gmsgBombDrop, NULL, pOther->pev); + WRITE_COORD(pev->origin.x); + WRITE_COORD(pev->origin.y); + WRITE_COORD(pev->origin.z); + WRITE_BYTE(0); + MESSAGE_END(); + } + } + } + } + } + + CWeaponBox *pWeaponBox = (CWeaponBox *)Create("weaponbox", pev->origin + gpGlobals->v_forward * 10, pev->angles, edict()); + pWeaponBox->pev->angles.x = 0; + pWeaponBox->pev->angles.z = 0; + pWeaponBox->SetThink(&CWeaponBox::Kill); + pWeaponBox->pev->nextthink = gpGlobals->time + 300; + pWeaponBox->PackWeapon(pWeapon); + pWeaponBox->pev->velocity = gpGlobals->v_forward * 300 + gpGlobals->v_forward * 100; + + if (!Q_strcmp(STRING(pWeapon->pev->classname), "weapon_c4")) + { + pWeaponBox->m_bIsBomb = true; + pWeaponBox->SetThink(&CWeaponBox::BombThink); + pWeaponBox->pev->nextthink = gpGlobals->time + 1; + + TheCSBots()->SetLooseBomb(pWeaponBox); + TheCSBots()->OnEvent(EVENT_BOMB_DROPPED); + } + + if (pWeapon->iFlags() & ITEM_FLAG_EXHAUSTIBLE) + { + int iAmmoIndex = GetAmmoIndex(pWeapon->pszAmmo1()); + + if (iAmmoIndex != -1) + { + pWeaponBox->PackAmmo(MAKE_STRING(pWeapon->pszAmmo1()), m_rgAmmo[iAmmoIndex] > 0); + m_rgAmmo[iAmmoIndex] = 0; + } + } + + const char *modelname = GetCSModelName(pWeapon->m_iId); + + if (modelname != NULL) + { + SET_MODEL(ENT(pWeaponBox->pev), modelname); + } + + return; + } + } +} + +/* <1594a2> ../cstrike/dlls/player.cpp:9094 */ +BOOL CBasePlayer::HasPlayerItem(CBasePlayerItem *pCheckItem) +{ + CBasePlayerItem *pItem = m_rgpPlayerItems[ pCheckItem->iItemSlot() ]; + while (pItem != NULL) + { + if (FClassnameIs(pItem->pev, STRING(pCheckItem->pev->classname))) + return TRUE; + + pItem = pItem->m_pNext; + } + return FALSE; +} + +/* <159534> ../cstrike/dlls/player.cpp:9113 */ +BOOL CBasePlayer::HasNamedPlayerItem(const char *pszItemName) +{ + CBasePlayerItem *pItem; + int i; + + for (i = 0; i < MAX_ITEM_TYPES; i++) + { + pItem = m_rgpPlayerItems[ i ]; + + while (pItem != NULL) + { + if (!Q_strcmp(pszItemName, STRING(pItem->pev->classname))) + return TRUE; + + pItem = pItem->m_pNext; + } + } + + return FALSE; +} + +/* <1619fd> ../cstrike/dlls/player.cpp:9137 */ +void CBasePlayer::SwitchTeam(void) +{ + int oldTeam; + char *szOldTeam; + char *szNewTeam; + const char *szName; + + oldTeam = m_iTeam; + + if (m_iTeam == CT) + { + m_iTeam = TERRORIST; + + switch (m_iModelName) + { + case MODEL_URBAN: + m_iModelName = MODEL_LEET; + SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "leet"); + break; + case MODEL_GIGN: + m_iModelName = MODEL_GUERILLA; + SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "guerilla"); + break; + case MODEL_SAS: + m_iModelName = MODEL_ARCTIC; + SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "arctic"); + break; + case MODEL_SPETSNAZ: + if (UTIL_IsGame("czero")) + { + m_iModelName = MODEL_MILITIA; + SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "militia"); + break; + } + default: + if (m_iModelName == MODEL_GSG9 || !IsBot() || !TheBotProfiles->GetCustomSkinModelname(m_iModelName)) + { + m_iModelName = MODEL_TERROR; + SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "terror"); + } + break; + } + } + else if (m_iTeam == TERRORIST) + { + m_iTeam = CT; + + switch (m_iModelName) + { + case MODEL_TERROR: + m_iModelName = MODEL_GSG9; + SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "gsg9"); + break; + + case MODEL_ARCTIC: + m_iModelName = MODEL_SAS; + SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "sas"); + break; + + case MODEL_GUERILLA: + m_iModelName = MODEL_GIGN; + SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "gign"); + break; + + case MODEL_MILITIA: + if (UTIL_IsGame("czero")) + { + m_iModelName = MODEL_SPETSNAZ; + SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "spetsnaz"); + break; + } + default: + if (m_iModelName == MODEL_LEET || !IsBot() || !TheBotProfiles->GetCustomSkinModelname(m_iModelName)) + { + m_iModelName = MODEL_URBAN; + SET_CLIENT_KEY_VALUE(entindex(), GET_INFO_BUFFER(edict()), "model", "urban"); + } + break; + } + } + + MESSAGE_BEGIN(MSG_ALL, gmsgTeamInfo); + WRITE_BYTE(entindex()); + switch (m_iTeam) + { + case CT: + WRITE_STRING("CT"); + break; + case TERRORIST: + WRITE_STRING("TERRORIST"); + break; + case SPECTATOR: + WRITE_STRING("SPECTATOR"); + break; + default: + WRITE_STRING("UNASSIGNED"); + break; + } + MESSAGE_END(); + + TheBots->OnEvent(EVENT_PLAYER_CHANGED_TEAM, this); + + UpdateLocation(true); + + if (m_iTeam) + { + SetScoreboardAttributes(); + } + + if (pev->netname) + { + szName = STRING(pev->netname); + + if (!szName[0]) + szName = ""; + } + else + szName = ""; + + UTIL_ClientPrintAll(HUD_PRINTNOTIFY, (m_iTeam == TERRORIST) ? "#Game_join_terrorist_auto" : "#Game_join_ct_auto", szName); + + if (m_bHasDefuser) + { + m_bHasDefuser = false; + pev->body = 0; + + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + WRITE_BYTE(STATUSICON_HIDE); + WRITE_STRING("defuser"); + MESSAGE_END(); + + SendItemStatus(this); + SetProgressBarTime(0); + + for (int i = 0; i < MAX_ITEM_TYPES; i++) + { + m_pActiveItem = m_rgpPlayerItems[ i ]; + + if (m_pActiveItem && FClassnameIs(m_pActiveItem->pev, "item_thighpack")) + { + m_pActiveItem->Drop(); + m_rgpPlayerItems[i] = NULL; + } + } + } + + szOldTeam = GetTeam(oldTeam); + szNewTeam = GetTeam(m_iTeam); + + UTIL_LogPrintf + ( + "\"%s<%i><%s><%s>\" joined team \"%s\" (auto)\n", + STRING(pev->netname), + GETPLAYERUSERID(edict()), + GETPLAYERAUTHID(edict()), + szOldTeam, + szNewTeam + ); + + CCSBot *pBot = reinterpret_cast(this); + + if (pBot->IsBot()) + { + const BotProfile *pProfile = pBot->GetProfile(); + + if (pProfile != NULL) + { + bool kick = false; + + if (m_iTeam == CT && !pProfile->IsValidForTeam(BOT_TEAM_CT)) + kick = true; + + else if (m_iTeam == TERRORIST && !pProfile->IsValidForTeam(BOT_TEAM_T)) + kick = true; + + if (kick) + { + SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(pev->netname))); + } + } + } +} + +/* <159594> ../cstrike/dlls/player.cpp:9302 */ +void CBasePlayer::UpdateShieldCrosshair(bool draw) +{ + if (draw) + m_iHideHUD &= ~HIDEHUD_CROSSHAIR; + else + m_iHideHUD |= HIDEHUD_CROSSHAIR; +} + +/* <152fbc> ../cstrike/dlls/player.cpp:9313 */ +BOOL CBasePlayer::SwitchWeapon(CBasePlayerItem *pWeapon) +{ + if (!pWeapon->CanDeploy()) + { + return FALSE; + } + + ResetAutoaim(); + + if (m_pActiveItem) + { + m_pActiveItem->Holster(); + } + + CBasePlayerItem *pTemp = m_pActiveItem; + m_pActiveItem = pWeapon; + m_pLastItem = pTemp; + pWeapon->Deploy(); + + if (pWeapon->m_pPlayer) + { + pWeapon->m_pPlayer->ResetMaxSpeed(); + } + + if (HasShield()) + { + UpdateShieldCrosshair(true); + } + + return TRUE; +} + +/* <1595ed> ../cstrike/dlls/player.cpp:9342 */ +void CBasePlayer::TabulateAmmo(void) +{ + ammo_buckshot = AmmoInventory(GetAmmoIndex("buckshot")); + ammo_9mm = AmmoInventory(GetAmmoIndex("9mm")); + ammo_556nato = AmmoInventory(GetAmmoIndex("556Nato")); + ammo_556natobox = AmmoInventory(GetAmmoIndex("556NatoBox")); + ammo_762nato = AmmoInventory(GetAmmoIndex("762Nato")); + ammo_45acp = AmmoInventory(GetAmmoIndex("45acp")); + ammo_50ae = AmmoInventory(GetAmmoIndex("50AE")); + ammo_338mag = AmmoInventory(GetAmmoIndex("338Magnum")); + ammo_57mm = AmmoInventory(GetAmmoIndex("57mm")); + ammo_357sig = AmmoInventory(GetAmmoIndex("357SIG")); +} + +/* <1511eb> ../cstrike/dlls/player.cpp:9365 */ +int CDeadHEV::__MAKE_VHOOK(Classify)(void) +{ + return CLASS_HUMAN_MILITARY; +} + +/* <152451> ../cstrike/dlls/player.cpp:9375 */ +void CDeadHEV::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ + if (FStrEq(pkvd->szKeyName, "pose")) + { + m_iPose = Q_atoi(pkvd->szValue); + pkvd->fHandled = TRUE; + } + else + CBaseMonster::KeyValue(pkvd); +} + +/* <159a88> ../cstrike/dlls/player.cpp:9386 */ +LINK_ENTITY_TO_CLASS(monster_hevsuit_dead, CDeadHEV); + +/* <1513ce> ../cstrike/dlls/player.cpp:9391 */ +void CDeadHEV::__MAKE_VHOOK(Spawn)(void) +{ + PRECACHE_MODEL("models/player.mdl"); + SET_MODEL(ENT(pev), "models/player.mdl"); + + pev->effects = 0; + pev->yaw_speed = 8.0f; + + pev->sequence = 0; + pev->body = 1; + + m_bloodColor = BLOOD_COLOR_RED; + pev->sequence = LookupSequence(m_szPoses[ m_iPose ]); + + if (pev->sequence == -1) + { + ALERT(at_console, "Dead hevsuit with bad pose\n"); + pev->sequence = 0; + pev->effects = EF_BRIGHTFIELD; + } + + pev->health = 8; + MonsterInitDead(); +} + +/* <159b64> ../cstrike/dlls/player.cpp:9426 */ +LINK_ENTITY_TO_CLASS(player_weaponstrip, CStripWeapons); + +/* <15f62f> ../cstrike/dlls/player.cpp:9428 */ +void CStripWeapons::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + CBasePlayer *pPlayer = NULL; + + if (pActivator && pActivator->IsPlayer()) + { + pPlayer = (CBasePlayer *)pActivator; + } + else if (!g_pGameRules->IsDeathmatch()) + { + pPlayer = (CBasePlayer *)Instance(INDEXENT(1)); + } + + if (pPlayer) + { + pPlayer->RemoveAllItems(FALSE); + } +} + +/* <159c40> ../cstrike/dlls/player.cpp:9473 */ +LINK_ENTITY_TO_CLASS(player_loadsaved, CRevertSaved); + +/* <151a24> ../cstrike/dlls/player.cpp:9481 */ +IMPLEMENT_SAVERESTORE(CRevertSaved, CPointEntity); + +/* <152540> ../cstrike/dlls/player.cpp:9483 */ +void CRevertSaved::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) +{ + if (FStrEq(pkvd->szKeyName, "duration")) + { + SetDuration(Q_atof(pkvd->szValue)); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "holdtime")) + { + SetHoldTime(Q_atof(pkvd->szValue)); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "messagetime")) + { + SetMessageTime(Q_atof(pkvd->szValue)); + pkvd->fHandled = TRUE; + } + else if (FStrEq(pkvd->szKeyName, "loadtime")) + { + SetLoadTime(Q_atof(pkvd->szValue)); + pkvd->fHandled = TRUE; + } + else + CPointEntity::KeyValue(pkvd); +} + +/* <151365> ../cstrike/dlls/player.cpp:9509 */ +void CRevertSaved::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + UTIL_ScreenFadeAll(pev->rendercolor, Duration(), HoldTime(), (int)pev->renderamt, FFADE_OUT); + pev->nextthink = gpGlobals->time + MessageTime(); + SetThink(&CRevertSaved::MessageThink); +} + +/* <152a96> ../cstrike/dlls/player.cpp:9517 */ +void CRevertSaved::MessageThink(void) +{ + float nextThink = LoadTime() - MessageTime(); + UTIL_ShowMessageAll(STRING(pev->message)); + + if (nextThink > 0) + { + pev->nextthink = gpGlobals->time + nextThink; + SetThink(&CRevertSaved::LoadThink); + } + else + LoadThink(); +} + +/* <15198b> ../cstrike/dlls/player.cpp:9531 */ +void CRevertSaved::LoadThink(void) +{ + if (!gpGlobals->deathmatch) + SERVER_COMMAND("reload\n"); +} + +/* <15133c> ../cstrike/dlls/player.cpp:9549 */ +void CInfoIntermission::__MAKE_VHOOK(Spawn)(void) +{ + UTIL_SetOrigin(pev, pev->origin); + + pev->solid = SOLID_NOT; + pev->effects = EF_NODRAW; + pev->v_angle = g_vecZero; + pev->nextthink = gpGlobals->time + 2; +} + +/* <1530e6> ../cstrike/dlls/player.cpp:9560 */ +void CInfoIntermission::__MAKE_VHOOK(Think)(void) +{ + edict_t *pTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target)); + + if (!FNullEnt(pTarget)) + { + pev->v_angle = UTIL_VecToAngles((pTarget->v.origin - pev->origin).Normalize()); + pev->v_angle.x = -pev->v_angle.x; + } +} + +/* <159d1c> ../cstrike/dlls/player.cpp:9574 */ +LINK_ENTITY_TO_CLASS(info_intermission, CInfoIntermission); + +/* <159df8> ../cstrike/dlls/player.cpp:9586 */ +void CBasePlayer::StudioEstimateGait(void) +{ + float_precision dt; + Vector est_velocity; + + dt = gpGlobals->frametime; + + if (dt < 0) + dt = 0; + + else if (dt > 1.0) + dt = 1; + + if (dt == 0) + { + m_flGaitMovement = 0; + return; + } + + est_velocity = pev->origin - m_prevgaitorigin; + m_prevgaitorigin = pev->origin; + + m_flGaitMovement = est_velocity.Length(); + + if (dt <= 0 || m_flGaitMovement / dt < 5) + { + m_flGaitMovement = 0; + + est_velocity.x = 0; + est_velocity.y = 0; + } + + if (!est_velocity.x && !est_velocity.y) + { + float_precision flYawDiff = pev->angles.y - m_flGaityaw; + float_precision flYaw = fmod(flYawDiff, 360); + + flYawDiff = flYawDiff - (int64_t)(flYawDiff / 360) * 360; + + if (flYawDiff > 180) + flYawDiff -= 360; + + if (flYawDiff < -180) + flYawDiff += 360; + + if (flYaw < -180) + flYaw += 360; + + else if (flYaw > 180) + flYaw -= 360; + + if (flYaw > -5 && flYaw < 5) + m_flYawModifier = 0.05; + + if (flYaw < -90 || flYaw > 90) + m_flYawModifier = 3.5; + + if (dt < 0.25) + flYawDiff *= dt * m_flYawModifier; + else + flYawDiff *= dt; + + if ((float_precision)abs((int64_t)flYawDiff) < 0.1) + flYawDiff = 0; + + m_flGaityaw += flYawDiff; + m_flGaityaw -= (int64_t)(m_flGaityaw / 360) * 360; + + m_flGaitMovement = 0; + } + else + { + m_flGaityaw = (atan2((float_precision)est_velocity.y, (float_precision)est_velocity.x) * 180 / M_PI); + + if (m_flGaityaw > 180) + m_flGaityaw = 180; + + if (m_flGaityaw < -180) + m_flGaityaw = -180; + } +} + +/* <159f01> ../cstrike/dlls/player.cpp:9685 */ +void CBasePlayer::StudioPlayerBlend(int *pBlend, float *pPitch) +{ + // calc up/down pointing + float range = (float)(int64_t)(*pPitch * 3.0f); + + *pBlend = range; + + if (range <= -45.0f) + { + *pBlend = 255; + *pPitch = 0; + } + else if (range >= 45.0f) + { + *pBlend = 0; + *pPitch = 0; + } + else + { + *pBlend = (int64_t)((45.0f - range) * (255.0f / 90.0f)); + *pPitch = 0; + } +} + +/* <159f81> ../cstrike/dlls/player.cpp:9709 */ +void CBasePlayer::CalculatePitchBlend(void) +{ + int iBlend; + float temp = pev->angles.x; + + StudioPlayerBlend(&iBlend, &temp); + + pev->blending[1] = iBlend; + m_flPitch = iBlend; +} + +/* <15a007> ../cstrike/dlls/player.cpp:9720 */ +void CBasePlayer::CalculateYawBlend(void) +{ + float dt; + float maxyaw = 255.0f; + + float_precision flYaw; + float_precision blend_yaw; + + dt = gpGlobals->frametime; + + if (dt < 0.0) + dt = 0; + + else if (dt > 1.0) + dt = 1; + + StudioEstimateGait(); + + flYaw = fmod((float_precision)(pev->angles.y - m_flGaityaw), 360); + + if (flYaw < -180) + flYaw += 360; + + else if (flYaw > 180) + flYaw -= 360; + + if (m_flGaitMovement != 0.0) + { + if (flYaw > 120) + { + m_flGaityaw -= 180; + m_flGaitMovement = -m_flGaitMovement; + flYaw -= 180; + } + else if (flYaw < -120) + { + m_flGaityaw += 180; + m_flGaitMovement = -m_flGaitMovement; + flYaw += 180; + } + } + + flYaw = (flYaw / 90) * 128 + 127; + + if (flYaw > 255) + flYaw = 255; + + else if (flYaw < 0) + flYaw = 0; + + blend_yaw = maxyaw - flYaw; + + pev->blending[0] = (int64_t)blend_yaw; + m_flYaw = blend_yaw; +} + +/* <15a07b> ../cstrike/dlls/player.cpp:9776 */ +void CBasePlayer::StudioProcessGait(void) +{ + mstudioseqdesc_t *pseqdesc; + float_precision dt = gpGlobals->frametime; + + if (dt < 0.0) + dt = 0; + + else if (dt > 1.0) + dt = 1; + + CalculateYawBlend(); + CalculatePitchBlend(); + + model_t *model = (model_t *)GET_MODEL_PTR(edict()); + + if (!model) + return; + + studiohdr_t *pstudiohdr = (studiohdr_t *)model; + + pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + pev->gaitsequence; + + if (pseqdesc->linearmovement.x > 0.0f) + m_flGaitframe += (m_flGaitMovement / pseqdesc->linearmovement.x) * pseqdesc->numframes; + else + m_flGaitframe += pev->framerate * pseqdesc->fps * dt; + + m_flGaitframe -= (int)(m_flGaitframe / pseqdesc->numframes) * pseqdesc->numframes; + + if (m_flGaitframe < 0) + m_flGaitframe += pseqdesc->numframes; +} + +/* <15a444> ../cstrike/dlls/player.cpp:9821 */ +void CBasePlayer::ResetStamina(void) +{ + pev->fuser1 = 0; + pev->fuser3 = 0; + pev->fuser2 = 0; +} + +/* <15a467> ../cstrike/dlls/player.cpp:9829 */ +float_precision GetPlayerPitch(const edict_t *pEdict) +{ + entvars_t *pev = VARS((edict_t *)pEdict); + CBasePlayer *pPlayer = reinterpret_cast(CBasePlayer::Instance(pev)); + + if (!pPlayer) + return 0.0f; + + return pPlayer->m_flPitch; +} + +/* <15a530> ../cstrike/dlls/player.cpp:9846 */ +float_precision GetPlayerYaw(const edict_t *pEdict) +{ + entvars_t *pev = VARS((edict_t *)pEdict); + CBasePlayer *pPlayer = reinterpret_cast(CBasePlayer::Instance(pev)); + + if (!pPlayer) + return 0.0f; + + return pPlayer->m_flYaw; +} + +/* <15a5f9> ../cstrike/dlls/player.cpp:9863 */ +int GetPlayerGaitsequence(const edict_t *pEdict) +{ + entvars_t *pev = VARS((edict_t *)pEdict); + CBasePlayer *pPlayer = reinterpret_cast(CBasePlayer::Instance(pev)); + + if (!pPlayer) + return 1; + + return pPlayer->m_iGaitsequence; +} + +/* <15a6c2> ../cstrike/dlls/player.cpp:9880 */ +void CBasePlayer::SpawnClientSideCorpse(void) +{ + char *infobuffer = GET_INFO_BUFFER(edict()); + char *pModel = GET_KEY_VALUE(infobuffer, "model"); + + MESSAGE_BEGIN(MSG_ALL, gmsgSendCorpse); + WRITE_STRING(pModel); + WRITE_LONG(pev->origin.x * 128); + WRITE_LONG(pev->origin.y * 128); + WRITE_LONG(pev->origin.z * 128); + WRITE_COORD(pev->angles.x); + WRITE_COORD(pev->angles.y); + WRITE_COORD(pev->angles.z); + WRITE_LONG((pev->animtime - gpGlobals->time) * 100); + WRITE_BYTE(pev->sequence); + WRITE_BYTE(pev->body); + WRITE_BYTE(m_iTeam); + WRITE_BYTE(entindex()); + MESSAGE_END(); + + m_canSwitchObserverModes = true; + + if (TheTutor != NULL) + { + TheTutor->OnEvent(EVENT_CLIENT_CORPSE_SPAWNED, this); + } +} + +/* <15a7a2> ../cstrike/dlls/player.cpp:9909 */ +BOOL CBasePlayer::IsArmored(int nHitGroup) +{ + BOOL fApplyArmor = FALSE; + + if (m_iKevlar == ARMOR_TYPE_EMPTY) + return FALSE; + + switch (nHitGroup) + { + case HITGROUP_HEAD: + { + fApplyArmor = (m_iKevlar == ARMOR_TYPE_HELMET); + break; + } + case HITGROUP_GENERIC: + case HITGROUP_CHEST: + case HITGROUP_STOMACH: + case HITGROUP_LEFTARM: + case HITGROUP_RIGHTARM: + fApplyArmor = TRUE; + break; + } + + return fApplyArmor; +} + +/* <15a847> ../cstrike/dlls/player.cpp:9939 */ +BOOL CBasePlayer::ShouldDoLargeFlinch(int nHitGroup, int nGunType) +{ + if (pev->flags & FL_DUCKING) + return FALSE; + + if (nHitGroup != HITGROUP_LEFTLEG && nHitGroup != HITGROUP_RIGHTLEG) + { + switch (nGunType) + { + case WEAPON_SCOUT: + case WEAPON_AUG: + case WEAPON_SG550: + case WEAPON_GALIL: + case WEAPON_FAMAS: + case WEAPON_AWP: + case WEAPON_M3: + case WEAPON_M4A1: + case WEAPON_G3SG1: + case WEAPON_DEAGLE: + case WEAPON_SG552: + case WEAPON_AK47: + return TRUE; + } + } + + return FALSE; +} + +/* <15a87d> ../cstrike/dlls/player.cpp:9971 */ +void CBasePlayer::SetPrefsFromUserinfo(char *infobuffer) +{ + const char *pszKeyVal; + + pszKeyVal = GET_KEY_VALUE(infobuffer, "_cl_autowepswitch"); + + if (Q_strcmp(pszKeyVal, "")) + m_iAutoWepSwitch = Q_atoi(pszKeyVal); + else + m_iAutoWepSwitch = 1; + + pszKeyVal = GET_KEY_VALUE(infobuffer, "_vgui_menus"); + + if (Q_strcmp(pszKeyVal, "")) + m_bVGUIMenus = Q_atoi(pszKeyVal) != 0; + else + m_bVGUIMenus = true; + + pszKeyVal = GET_KEY_VALUE(infobuffer, "_ah"); + + if (Q_strcmp(pszKeyVal, "")) + m_bShowHints = Q_atoi(pszKeyVal) != 0; + else + m_bShowHints = true; +} + +/* <15a92a> ../cstrike/dlls/player.cpp:10013 */ +bool CBasePlayer::IsLookingAtPosition(Vector *pos, float angleTolerance) +{ + Vector to = *pos - EyePosition(); + Vector idealAngle = UTIL_VecToAngles(to); + + idealAngle.x = 360.0 - idealAngle.x; + + float deltaYaw = NormalizeAngle(idealAngle.y - pev->v_angle.y); + float deltaPitch = NormalizeAngle(idealAngle.x - pev->v_angle.x); + + return (abs(deltaYaw) < angleTolerance + && abs(deltaPitch) < angleTolerance); +} + +/* <15aa7b> ../cstrike/dlls/player.cpp:10083 */ +bool CBasePlayer::CanAffordPrimary(void) +{ + int account = m_iAccount; + + if (m_iTeam == CT) + { + WeaponStruct *temp; + for (int i = 0; i < MAX_WEAPONS; i++) + { + temp = &g_weaponStruct[ i ]; + + if ((temp->m_side & TERRORIST) && temp->m_slot == PRIMARY_WEAPON_SLOT && account >= temp->m_price) + return true; + } + } + else if (m_iTeam == TERRORIST) + { + WeaponStruct *temp; + for (int i = 0; i < MAX_WEAPONS; i++) + { + temp = &g_weaponStruct[ i ]; + + if ((temp->m_side & CT) && temp->m_slot == PRIMARY_WEAPON_SLOT && account >= temp->m_price) + return true; + } + } + + return false; +} + +/* <15ab2c> ../cstrike/dlls/player.cpp:10139 */ +bool CBasePlayer::CanAffordPrimaryAmmo(void) +{ + CBasePlayerWeapon *primary = (CBasePlayerWeapon *)&m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]; + + for (int i = 0; i < MAX_WEAPONS; i++) + { + WeaponStruct *temp = &g_weaponStruct[ i ]; + + if (temp->m_type == primary->m_iId && m_iAccount >= temp->m_ammoPrice) + return true; + } + + return false; +} + +/* <15aba0> ../cstrike/dlls/player.cpp:10169 */ +bool CBasePlayer::CanAffordSecondaryAmmo(void) +{ + CBasePlayerWeapon *secondary = (CBasePlayerWeapon *)&m_rgpPlayerItems[ PISTOL_SLOT ]; + + for (int i = 0; i < MAX_WEAPONS; i++) + { + WeaponStruct *temp = &g_weaponStruct[ i ]; + + if (temp->m_type == secondary->m_iId && m_iAccount >= temp->m_ammoPrice) + return true; + } + + return false; +} + +/* <15ac14> ../cstrike/dlls/player.cpp:10199 */ +bool CBasePlayer::CanAffordArmor(void) +{ + if (m_iKevlar == ARMOR_TYPE_KEVLAR && pev->armorvalue == 100.0f && m_iAccount >= HELMET_PRICE) + return true; + + return (m_iAccount >= KEVLAR_PRICE); +} + +/* <15ac3c> ../cstrike/dlls/player.cpp:10217 */ +bool CBasePlayer::CanAffordDefuseKit(void) +{ + return (m_iAccount >= DEFUSEKIT_PRICE); +} + +/* <15ac64> ../cstrike/dlls/player.cpp:10227 */ +bool CBasePlayer::CanAffordGrenade(void) +{ + return (m_iAccount >= FLASHBANG_PRICE); +} + +/* <15ac8c> ../cstrike/dlls/player.cpp:10247 */ +bool CBasePlayer::NeedsPrimaryAmmo(void) +{ + CBasePlayerWeapon *primary = (CBasePlayerWeapon *)&m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]; + + if (!primary || primary->m_iId == WEAPON_SHIELDGUN) + return false; + + return (m_rgAmmo[ primary->m_iPrimaryAmmoType ] < primary->iMaxAmmo1()); +} + +/* <15ace1> ../cstrike/dlls/player.cpp:10268 */ +bool CBasePlayer::NeedsSecondaryAmmo(void) +{ + CBasePlayerWeapon *secondary = (CBasePlayerWeapon *)&m_rgpPlayerItems[ PISTOL_SLOT ]; + + if (!secondary) + return false; + + return (m_rgAmmo[ secondary->m_iPrimaryAmmoType ] < secondary->iMaxAmmo1()); +} + +/* <15ad36> ../cstrike/dlls/player.cpp:10285 */ +bool CBasePlayer::NeedsArmor(void) +{ + if (m_iKevlar == ARMOR_TYPE_EMPTY) + return true; + + return (pev->armorvalue < 50.0f); +} + +/* <15ad5e> ../cstrike/dlls/player.cpp:10300 */ +bool CBasePlayer::NeedsDefuseKit(void) +{ + CHalfLifeMultiplay *mpRules = g_pGameRules; + + if (m_bHasDefuser || m_iTeam != CT) + return false; + + return (mpRules->m_bMapHasBombTarget); +} + +/* <15ad9a> ../cstrike/dlls/player.cpp:10325 */ +bool CBasePlayer::NeedsGrenade(void) +{ + int iAmmoIndex = GetAmmoIndex("HEGrenade"); + + if (iAmmoIndex > 0 && m_rgAmmo[ iAmmoIndex ]) + return false; + + iAmmoIndex = GetAmmoIndex("Flashbang"); + + if (iAmmoIndex > 0 && m_rgAmmo[ iAmmoIndex ]) + return false; + + iAmmoIndex = GetAmmoIndex("SmokeGrenade"); + + if (iAmmoIndex > 0 && m_rgAmmo[ iAmmoIndex ]) + return false; + + return true; +} + +/* <15aeab> ../cstrike/dlls/player.cpp:10381 */ +void CBasePlayer::ClientCommand(const char *cmd, const char *arg1, const char *arg2, const char *arg3) +{ + BotArgs[0] = cmd; + BotArgs[1] = arg1; + BotArgs[2] = arg2; + BotArgs[3] = arg3; + + UseBotArgs = true; + ::ClientCommand(ENT(pev)); + UseBotArgs = false; +} + +/* <15aea9> ../cstrike/dlls/player.cpp:10401 */ +const char *GetBuyStringForWeaponClass(int weaponClass) +{ + switch (weaponClass) + { + case WEAPONCLASS_PISTOL: + return "deagle elites fn57 usp glock p228 shield"; + case WEAPONCLASS_SNIPERRIFLE: + return "awp sg550 g3sg1 scout"; + case WEAPONCLASS_GRENADE: + return "hegren"; + case WEAPONCLASS_SHOTGUN: + return "xm1014 m3"; + case WEAPONCLASS_SUBMACHINEGUN: + return "p90 ump45 mp5 tmp mac10"; + case WEAPONCLASS_MACHINEGUN: + return "m249"; + case WEAPONCLASS_RIFLE: + return "sg552 aug ak47 m4a1 galil famas"; + } + + return NULL; +} + +/* <15aee9> ../cstrike/dlls/player.cpp:10454 */ +void CBasePlayer::ClearAutoBuyData(void) +{ + m_autoBuyString[0] = '\0'; +} + +/* <15af11> ../cstrike/dlls/player.cpp:10459 */ +void CBasePlayer::AddAutoBuyData(const char *str) +{ + int len = Q_strlen(m_autoBuyString); + + if (len < MAX_AUTOBUY_LENGTH - 1) + { + if (len > 0) + m_autoBuyString[ len ] = ' '; + + Q_strncat(m_autoBuyString, str, MAX_AUTOBUY_LENGTH - len); + } +} + +/* <15af66> ../cstrike/dlls/player.cpp:10478 */ +void CBasePlayer::InitRebuyData(const char *str) +{ + if (!str || Q_strlen(str) > MAX_REBUY_LENGTH) + { + return; + } + + if (m_rebuyString != NULL) + { + delete m_rebuyString; + m_rebuyString = NULL; + } + + m_rebuyString = new char[ Q_strlen(str) + 1 ]; + Q_strcpy(m_rebuyString, str); + m_rebuyString[ Q_strlen(str) ] = '\0'; +} + +/* <15be4f> ../cstrike/dlls/player.cpp:10500 */ +void CBasePlayer::AutoBuy(void) +{ + const char *c = NULL; + bool boughtPrimary = false; + bool boughtSecondary = false; + char prioritizedString[ MAX_AUTOBUY_LENGTH ]; + + c = PickFlashKillWeaponString(); + + if (c != NULL) + { + ParseAutoBuyString(c, boughtPrimary, boughtSecondary); + } + + c = PickGrenadeKillWeaponString(); + + if (c != NULL) + { + ParseAutoBuyString(c, boughtPrimary, boughtSecondary); + } + + // TODO: Reverse me + c = PickPrimaryCareerTaskWeapon(); + + if (c != NULL) + { + Q_strcpy(prioritizedString, c); + + PrioritizeAutoBuyString(prioritizedString, m_autoBuyString); + ParseAutoBuyString(prioritizedString, boughtPrimary, boughtSecondary); + } + + // TODO: Reverse me + c = PickSecondaryCareerTaskWeapon(); + + if (c != NULL) + { + Q_strcpy(prioritizedString, c); + + PrioritizeAutoBuyString(prioritizedString, m_autoBuyString); + ParseAutoBuyString(prioritizedString, boughtPrimary, boughtSecondary); + } + + ParseAutoBuyString(m_autoBuyString, boughtPrimary, boughtSecondary); + + c = PickFlashKillWeaponString(); + + if (c != NULL) + { + ParseAutoBuyString(c, boughtPrimary, boughtSecondary); + } + + if (TheTutor) + TheTutor->OnEvent(EVENT_PLAYER_LEFT_BUY_ZONE); +} + +/* <14ea4e> ../cstrike/dlls/player.cpp:10556 */ +bool IsPrimaryWeaponClass(int classId) +{ + return (classId >= WEAPONCLASS_SUBMACHINEGUN && classId <= WEAPONCLASS_SNIPERRIFLE); +} + +/* <15afbe> ../cstrike/dlls/player.cpp:10571 */ +bool IsPrimaryWeaponId(int id) +{ + int classId = WEAPONCLASS_NONE; + const char *alias = WeaponIDToAlias(id); + + if (alias) + { + classId = AliasToWeaponClass(alias); + } + + return IsPrimaryWeaponClass(classId); +} + +/* <14ea6f> ../cstrike/dlls/player.cpp:10583 */ +bool IsSecondaryWeaponClass(int classId) +{ + return (classId == WEAPONCLASS_PISTOL); +} + +/* <15b059> ../cstrike/dlls/player.cpp:10588 */ +bool IsSecondaryWeaponId(int id) +{ + int classId = WEAPONCLASS_NONE; + const char *alias = WeaponIDToAlias(id); + + if (alias) + { + classId = AliasToWeaponClass(alias); + } + + return IsSecondaryWeaponClass(classId); +} + +/* <15b0f1> ../cstrike/dlls/player.cpp:10600 */ +const char *GetWeaponAliasFromName(const char *weaponName) +{ + if (!Q_strncmp(weaponName, "weapon_", 7)) + { + weaponName += 7; + } + + return weaponName; +} + +/* <15b133> ../cstrike/dlls/player.cpp:10607 */ +bool CurrentWeaponSatisfies(CBasePlayerWeapon *pWeapon, int id, int classId) +{ + if (pWeapon == NULL) + return false; + + const char *weaponName = GetWeaponAliasFromName(pWeapon->pszName()); + + if (id && AliasToWeaponID(weaponName) == id) + return true; + + if (classId && AliasToWeaponClass(weaponName) == classId) + return true; + + return false; +} + +void (*pCBasePlayer__PickPrimaryCareerTaskWeapon)(void); + +/* <15b1eb> ../cstrike/dlls/player.cpp:10623 */ +NOBODY const char __declspec(naked) *CBasePlayer::PickPrimaryCareerTaskWeapon(void) +{ + __asm + { + jmp pCBasePlayer__PickPrimaryCareerTaskWeapon + } +// { +// intconst BufLen; // 10625 +// char buf; // 10626 +// class CBasePlayerWeapon *primary; // 10632 +// class vector > taskVector; // 10634 +// CareerTaskListIt it; // 10635 +// vector(vector > *const this); // 10634 +// { +// class CCareerTask *pTask; // 10638 +// push_back(vector > *const this, +// const value_type &__x); // 10656 +// IsPrimaryWeaponId(int id); // 10644 +// CurrentWeaponSatisfies(CBasePlayerWeapon *pWeapon, +// int id, +// int classId); // 10647 +// IsPrimaryWeaponId(int id); // 10649 +// GetBuyStringForWeaponClass(int weaponClass); // 10652 +// } +// operator++(_List_iterator *const this); // 10636 +// { +// int taskNum; // 10664 +// class CCareerTask *temp; // 10666 +// operator[](vector > *const this, +// size_type __n); // 10667 +// } +// { +// int i; // 10673 +// { +// class CCareerTask *pTask; // 10675 +// IsPrimaryWeaponId(int id); // 10676 +// GetBuyStringForWeaponClass(int weaponClass); // 10682 +// } +// size(const class vector > *const this); // 10673 +// } +// ~vector(vector > *const this, +// intconst __in_chrg); // 10634 +// } +} + +void (*pCBasePlayer__PickSecondaryCareerTaskWeapon)(void); + +/* <15b5d7> ../cstrike/dlls/player.cpp:10690 */ +NOBODY const char __declspec(naked) *CBasePlayer::PickSecondaryCareerTaskWeapon(void) +{ + __asm + { + jmp pCBasePlayer__PickSecondaryCareerTaskWeapon + } +// { +// intconst BufLen; // 10692 +// char buf; // 10693 +// class CBasePlayerWeapon *secondary; // 10699 +// class vector > taskVector; // 10701 +// CareerTaskListIt it; // 10702 +// vector(vector > *const this); // 10701 +// { +// class CCareerTask *pTask; // 10705 +// IsSecondaryWeaponId(int id); // 10711 +// CurrentWeaponSatisfies(CBasePlayerWeapon *pWeapon, +// int id, +// int classId); // 10714 +// push_back(vector > *const this, +// const value_type &__x); // 10723 +// IsSecondaryWeaponId(int id); // 10716 +// GetBuyStringForWeaponClass(int weaponClass); // 10719 +// } +// operator++(_List_iterator *const this); // 10703 +// { +// int taskNum; // 10731 +// class CCareerTask *temp; // 10733 +// operator[](vector > *const this, +// size_type __n); // 10734 +// } +// { +// int i; // 10740 +// { +// class CCareerTask *pTask; // 10742 +// IsSecondaryWeaponId(int id); // 10743 +// } +// size(const class vector > *const this); // 10740 +// } +// ~vector(vector > *const this, +// intconst __in_chrg); // 10701 +// } +} + +/* <15b9ea> ../cstrike/dlls/player.cpp:10759 */ +const char *CBasePlayer::PickFlashKillWeaponString(void) +{ + bool foundOne = false; + + for (CareerTaskListIt it = TheCareerTasks->GetTasks()->begin(); it != TheCareerTasks->GetTasks()->end(); ++it) + { + CCareerTask *pTask = (*it); + + if (!pTask->IsComplete() && !Q_strcmp(pTask->GetTaskName(), "killblind")) + { + foundOne = true; + break; + } + } + + if (foundOne) + return "flash flash"; + + return NULL; +} + +/* <15baa1> ../cstrike/dlls/player.cpp:10787 */ +const char *CBasePlayer::PickGrenadeKillWeaponString(void) +{ + bool foundOne = false; + + for (CareerTaskListIt it = TheCareerTasks->GetTasks()->begin(); it != TheCareerTasks->GetTasks()->end(); ++it) + { + CCareerTask *pTask = (*it); + + if (!pTask->IsComplete() && pTask->GetWeaponId() == WEAPON_HEGRENADE) + { + foundOne = true; + break; + } + } + + if (foundOne) + return "hegren"; + + return NULL; +} + +/* <15bb0c> ../cstrike/dlls/player.cpp:10816 */ +void CBasePlayer::PrioritizeAutoBuyString(char *autobuyString, const char *priorityString) +{ + char newString[ MAX_AUTOBUY_LENGTH ]; + int newStringPos = 0; + char priorityToken[32]; + + if (!priorityString || !autobuyString) + return; + + const char *priorityChar = priorityString; + + while (*priorityChar != '\0') + { + int i = 0; + + while (*priorityChar != '\0' && *priorityChar != ' ') + { + priorityToken[ i++ ] = *priorityChar; + priorityChar++; + } + + priorityToken[i] = 0; + + while (*priorityChar == ' ') + priorityChar++; + + if (!Q_strlen(priorityToken)) + continue; + + char *autoBuyPosition = Q_strstr(autobuyString, priorityToken); + + if (autoBuyPosition != NULL) + { + while (*autoBuyPosition != '\0' && *autoBuyPosition != ' ') + { + newString[ newStringPos ] = *autoBuyPosition; + *autoBuyPosition = ' '; + + ++newStringPos; + ++autoBuyPosition; + } + + newString[ newStringPos++ ] = ' '; + } + } + + char *autobuyPosition = autobuyString; + + while (*autobuyPosition != '\0') + { + while (*autobuyPosition == ' ') + autobuyPosition++; + + while (*autobuyPosition != '\0' && *autobuyPosition != ' ') + { + newString[ newStringPos++ ] = *autobuyPosition; + autobuyPosition++; + } + + newString[ newStringPos++ ] = ' '; + } + + newString[ newStringPos ] = 0; + Q_sprintf(autobuyString, "%s", newString); +} + +/* <15bcd5> ../cstrike/dlls/player.cpp:10899 */ +void CBasePlayer::ParseAutoBuyString(const char *string, bool &boughtPrimary, bool &boughtSecondary) +{ + char command[32]; + const char *c = string; + + if (!string || !string[0]) + return; + + while (*c) + { + int i = 0; + + while (*c && (*c != ' ') && i < sizeof(command)) + { + command[i] = *c; + ++c; + ++i; + } + + if (*c == ' ') + ++c; + + command[i] = 0; + i = 0; + + while (command[i] != 0) + { + if (command[i] == ' ') + { + command[i] = 0; + break; + } + + ++i; + } + + if (!Q_strlen(command)) + continue; + + AutoBuyInfoStruct *commandInfo = GetAutoBuyCommandInfo(command); + if (ShouldExecuteAutoBuyCommand(commandInfo, boughtPrimary, boughtSecondary)) + { + ClientCommand(commandInfo->m_command); + PostAutoBuyCommandProcessing(commandInfo, boughtPrimary, boughtSecondary); + } + } +} + +/* <15bb6b> ../cstrike/dlls/player.cpp:10957 */ +bool CBasePlayer::ShouldExecuteAutoBuyCommand(AutoBuyInfoStruct *commandInfo, bool boughtPrimary, bool boughtSecondary) +{ + if (!commandInfo) + return false; + + if (boughtPrimary && (commandInfo->m_class & AUTOBUYCLASS_PRIMARY) != 0 && !(commandInfo->m_class & AUTOBUYCLASS_AMMO)) + return false; + + if (boughtSecondary && (commandInfo->m_class & AUTOBUYCLASS_SECONDARY) != 0 && !(commandInfo->m_class & AUTOBUYCLASS_AMMO)) + return false; + + return true; +} + +/* <15bbfa> ../cstrike/dlls/player.cpp:10978 */ +AutoBuyInfoStruct *CBasePlayer::GetAutoBuyCommandInfo(const char *command) +{ + int i = 0; + AutoBuyInfoStruct *ret = NULL; + AutoBuyInfoStruct *temp = NULL; + + while (ret == NULL) + { + temp = &(g_autoBuyInfo[ i ]); + + if (!temp->m_class) + break; + + if (Q_stricmp(temp->m_command, command) == 0) + ret = temp; + + i++; + } + + return ret; +} + +/* <15bc49> ../cstrike/dlls/player.cpp:11000 */ +void CBasePlayer::PostAutoBuyCommandProcessing(AutoBuyInfoStruct *commandInfo, bool &boughtPrimary, bool &boughtSecondary) +{ + CBasePlayerWeapon *primary = (CBasePlayerWeapon *)m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]; + CBasePlayerWeapon *secondary = (CBasePlayerWeapon *)m_rgpPlayerItems[ PISTOL_SLOT ]; + + if (!commandInfo) + return; + + if (primary != NULL && !Q_stricmp(STRING(primary->pev->classname), commandInfo->m_classname)) + boughtPrimary = true; + + else if (commandInfo->m_class & AUTOBUYCLASS_SHIELD && HasShield()) + boughtPrimary = true; + + else if (secondary != NULL && !Q_stricmp(STRING(secondary->pev->classname), commandInfo->m_classname)) + boughtSecondary = true; +} + +/* <15c0b4> ../cstrike/dlls/player.cpp:11027 */ +void CBasePlayer::BuildRebuyStruct(void) +{ + int iAmmoIndex; + + if (m_bIsInRebuy) + return; + + CBasePlayerWeapon *primary = (CBasePlayerWeapon *)m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]; + CBasePlayerWeapon *secondary = (CBasePlayerWeapon *)m_rgpPlayerItems[ PISTOL_SLOT ]; + + if (primary != NULL) + { + m_rebuyStruct.m_primaryWeapon = primary->m_iId; + m_rebuyStruct.m_primaryAmmo = m_rgAmmo[ primary->m_iPrimaryAmmoType ]; + } + else + { + m_rebuyStruct.m_primaryAmmo = 0; + + if (HasShield()) + m_rebuyStruct.m_primaryWeapon = WEAPON_SHIELDGUN; + else + m_rebuyStruct.m_primaryWeapon = 0; + } + + if (secondary != NULL) + { + m_rebuyStruct.m_secondaryWeapon = secondary->m_iId; + m_rebuyStruct.m_secondaryAmmo = m_rgAmmo[ secondary->m_iPrimaryAmmoType ]; + } + else + { + m_rebuyStruct.m_secondaryWeapon = 0; + m_rebuyStruct.m_secondaryAmmo = 0; + } + + iAmmoIndex = GetAmmoIndex("HEGrenade"); + + if (iAmmoIndex != -1) + m_rebuyStruct.m_heGrenade = m_rgAmmo[ iAmmoIndex ]; + else + m_rebuyStruct.m_heGrenade = 0; + + iAmmoIndex = GetAmmoIndex("Flashbang"); + + if (iAmmoIndex != -1) + m_rebuyStruct.m_flashbang = m_rgAmmo[ iAmmoIndex ]; + else + m_rebuyStruct.m_flashbang = 0; + + iAmmoIndex = GetAmmoIndex("SmokeGrenade"); + + if (iAmmoIndex != -1) + m_rebuyStruct.m_smokeGrenade = m_rgAmmo[ iAmmoIndex ]; + else + m_rebuyStruct.m_smokeGrenade = 0; + + m_rebuyStruct.m_defuser = m_bHasDefuser; + m_rebuyStruct.m_nightVision = m_bHasNightVision; + m_rebuyStruct.m_armor = m_iKevlar; +} + +/* <15c37d> ../cstrike/dlls/player.cpp:11134 */ +void CBasePlayer::Rebuy(void) +{ + char *fileData = m_rebuyString; + char *token; + + m_bIsInRebuy = true; + + while (true) + { + fileData = MP_COM_Parse(fileData); + token = MP_COM_GetToken(); + + if (!fileData) + break; + + if (!Q_stricmp(token, "primaryWeapon")) + RebuyPrimaryWeapon(); + else if (!Q_stricmp(token, "primaryAmmo")) + RebuyPrimaryAmmo(); + else if (!Q_stricmp(token, "secondaryWeapon")) + RebuySecondaryWeapon(); + else if (!Q_stricmp(token, "secondaryAmmo")) + RebuySecondaryAmmo(); + else if (!Q_stricmp(token, "hegrenade")) + RebuyHEGrenade(); + else if (!Q_stricmp(token, "flashbang")) + RebuyFlashbang(); + else if (!Q_stricmp(token, "smokegrenade")) + RebuySmokeGrenade(); + else if (!Q_stricmp(token, "defuser")) + RebuyDefuser(); + else if (!Q_stricmp(token, "nightvision")) + RebuyNightVision(); + else if (!Q_stricmp(token, "armor")) + RebuyArmor(); + } + + m_bIsInRebuy = false; + + if (TheTutor) + TheTutor->OnEvent(EVENT_PLAYER_LEFT_BUY_ZONE); +} + +/* <15c96a> ../cstrike/dlls/player.cpp:11200 */ +NOXREF void CBasePlayer::RebuyPrimaryWeapon(void) +{ + if (!m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]) + { + if (m_rebuyStruct.m_primaryWeapon) + { + const char *alias = WeaponIDToAlias(m_rebuyStruct.m_primaryWeapon); + + if (alias != NULL) + ClientCommand(alias); + } + } +} + +/* <15c9e4> ../cstrike/dlls/player.cpp:11217 */ +NOXREF void CBasePlayer::RebuyPrimaryAmmo(void) +{ + CBasePlayerWeapon *primary = (CBasePlayerWeapon *)m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]; + + if (primary != NULL) + { + if (m_rebuyStruct.m_primaryAmmo > m_rgAmmo[ primary->m_iPrimaryAmmoType ]) + ClientCommand("primammo"); + } +} + +/* <15ca68> ../cstrike/dlls/player.cpp:11233 */ +NOXREF void CBasePlayer::RebuySecondaryWeapon(void) +{ + if (m_rebuyStruct.m_secondaryWeapon) + { + const char *alias = WeaponIDToAlias(m_rebuyStruct.m_secondaryWeapon); + + if (alias != NULL) + ClientCommand(alias); + } +} + +/* <15cae2> ../cstrike/dlls/player.cpp:11245 */ +NOXREF void CBasePlayer::RebuySecondaryAmmo(void) +{ + CBasePlayerWeapon *secondary = (CBasePlayerWeapon *)m_rgpPlayerItems[ PISTOL_SLOT ]; + + if (secondary) + { + if (m_rebuyStruct.m_secondaryAmmo > m_rgAmmo[ secondary->m_iPrimaryAmmoType ]) + ClientCommand("secammo"); + } +} + +/* <15cb66> ../cstrike/dlls/player.cpp:11259 */ +NOXREF void CBasePlayer::RebuyHEGrenade(void) +{ + int iAmmoIndex = GetAmmoIndex("HEGrenade"); + + if (iAmmoIndex == -1) + return; + + int numToBuy = m_rebuyStruct.m_heGrenade - m_rgAmmo[ iAmmoIndex ]; + + for (int i = 0; i < numToBuy; i++) + ClientCommand("hegren"); +} + +/* <15cc3f> ../cstrike/dlls/player.cpp:11279 */ +NOXREF void CBasePlayer::RebuyFlashbang(void) +{ + int iAmmoIndex = GetAmmoIndex("Flashbang"); + + if (iAmmoIndex == -1) + return; + + int numToBuy = m_rebuyStruct.m_flashbang - m_rgAmmo[ iAmmoIndex ]; + + for (int i = 0; i < numToBuy; i++) + ClientCommand("flash"); +} + +/* <15cd18> ../cstrike/dlls/player.cpp:11299 */ +NOXREF void CBasePlayer::RebuySmokeGrenade(void) +{ + int iAmmoIndex = GetAmmoIndex("SmokeGrenade"); + + if (iAmmoIndex == -1) + return; + + int numToBuy = m_rebuyStruct.m_smokeGrenade - m_rgAmmo[ iAmmoIndex ]; + + for (int i = 0; i < numToBuy; i++) + ClientCommand("sgren"); +} + +/* <15cdf1> ../cstrike/dlls/player.cpp:11319 */ +void CBasePlayer::RebuyDefuser(void) +{ + if (m_rebuyStruct.m_defuser) + { + if (!m_bHasDefuser) + ClientCommand("defuser"); + } +} + +/* <15ce59> ../cstrike/dlls/player.cpp:11330 */ +void CBasePlayer::RebuyNightVision(void) +{ + if (m_rebuyStruct.m_nightVision) + { + if (!m_bHasNightVision) + ClientCommand("nvgs"); + } +} + +/* <15cec1> ../cstrike/dlls/player.cpp:11341 */ +void CBasePlayer::RebuyArmor(void) +{ + if (m_rebuyStruct.m_armor) + { + if (m_rebuyStruct.m_armor > m_iKevlar) + { + if (m_rebuyStruct.m_armor == ARMOR_TYPE_KEVLAR) + ClientCommand("vest"); + else + ClientCommand("vesthelm"); + } + } +} + +/* <15cf7c> ../cstrike/dlls/player.cpp:11366 */ +bool CBasePlayer::IsObservingPlayer(CBasePlayer *pPlayer) +{ + if (!pPlayer || pev->flags == FL_DORMANT) + return false; + + if (FNullEnt(pPlayer)) + return false; + + return (IsObserver() == OBS_IN_EYE && pev->iuser2 == pPlayer->entindex()) != 0; +} + +/* <15d049> ../cstrike/dlls/player.cpp:11380 */ +void CBasePlayer::UpdateLocation(bool forceUpdate) +{ + if (!forceUpdate && m_flLastUpdateTime >= gpGlobals->time + 2) + return; + + const char *placeName = ""; + + if (pev->deadflag == DEAD_NO && UTIL_IsGame("czero")) + { + // search the place name where is located the player + Place playerPlace = TheNavAreaGrid.GetPlace(&pev->origin); + const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); + + for (BotPhraseList::const_iterator iter = placeList->begin(); iter != placeList->end(); ++iter) + { + if ((*iter)->GetID() == playerPlace) + { + placeName = (*iter)->GetName(); + break; + } + } + } + + if (!placeName[0] || (m_lastLocation[0] && !Q_strcmp(placeName, &m_lastLocation[1]))) + { + return; + } + + m_flLastUpdateTime = gpGlobals->time; + Q_snprintf(m_lastLocation, sizeof(m_lastLocation), "#%s", placeName); + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *player = (CBasePlayer *)UTIL_PlayerByIndex(i); + + if (!player) + continue; + + if (player->m_iTeam == m_iTeam || player->m_iTeam == SPECTATOR) + { + MESSAGE_BEGIN(MSG_ONE, gmsgLocation, NULL, player->edict()); + WRITE_BYTE(entindex()); + WRITE_STRING(m_lastLocation); + MESSAGE_END(); + } + else if (forceUpdate) + { + MESSAGE_BEGIN(MSG_ONE, gmsgLocation, NULL, player->edict()); + WRITE_BYTE(entindex()); + WRITE_STRING(""); + MESSAGE_END(); + } + } +} + +#ifdef HOOK_GAMEDLL + +void CBasePlayer::Spawn(void) +{ + Spawn_(); +} + +void CBasePlayer::Precache(void) +{ + Precache_(); +} + +int CBasePlayer::Save(CSave &save) +{ + return Save_(save); +} + +int CBasePlayer::Restore(CRestore &restore) +{ + return Restore_(restore); +} + +int CBasePlayer::Classify(void) +{ + return Classify_(); +} + +void CBasePlayer::TraceAttack(entvars_t *pevAttacker,float flDamage,Vector vecDir,TraceResult *ptr,int bitsDamageType) +{ + TraceAttack_(pevAttacker,flDamage,vecDir,ptr,bitsDamageType); +} + +int CBasePlayer::TakeDamage(entvars_t *pevInflictor,entvars_t *pevAttacker,float flDamage,int bitsDamageType) +{ + return TakeDamage_(pevInflictor,pevAttacker,flDamage,bitsDamageType); +} + +int CBasePlayer::TakeHealth(float flHealth,int bitsDamageType) +{ + return TakeHealth_(flHealth,bitsDamageType); +} + +void CBasePlayer::Killed(entvars_t *pevAttacker,int iGib) +{ + Killed_(pevAttacker,iGib); +} + +void CBasePlayer::AddPoints(int score,BOOL bAllowNegativeScore) +{ + AddPoints_(score,bAllowNegativeScore); +} + +void CBasePlayer::AddPointsToTeam(int score,BOOL bAllowNegativeScore) +{ + AddPointsToTeam_(score,bAllowNegativeScore); +} + +BOOL CBasePlayer::AddPlayerItem(CBasePlayerItem *pItem) +{ + return AddPlayerItem_(pItem); +} + +BOOL CBasePlayer::RemovePlayerItem(CBasePlayerItem *pItem) +{ + return RemovePlayerItem_(pItem); +} + +int CBasePlayer::GiveAmmo(int iAmount,char *szName,int iMax) +{ + return GiveAmmo_(iAmount,szName,iMax); +} + +const char *CBasePlayer::TeamID(void) +{ + return TeamID_(); +} + +BOOL CBasePlayer::FBecomeProne(void) +{ + return FBecomeProne_(); +} + +int CBasePlayer::Illumination(void) +{ + return Illumination_(); +} + +void CBasePlayer::ResetMaxSpeed(void) +{ + ResetMaxSpeed_(); +} + +void CBasePlayer::Jump(void) +{ + Jump_(); +} + +void CBasePlayer::Duck(void) +{ + Duck_(); +} + +void CBasePlayer::PreThink(void) +{ + PreThink_(); +} + +void CBasePlayer::PostThink(void) +{ + PostThink_(); +} + +Vector CBasePlayer::GetGunPosition(void) +{ + return GetGunPosition_(); +} + +void CBasePlayer::UpdateClientData(void) +{ + UpdateClientData_(); +} + +void CBasePlayer::ImpulseCommands(void) +{ + ImpulseCommands_(); +} + +void CBasePlayer::RoundRespawn(void) +{ + RoundRespawn_(); +} + +Vector CBasePlayer::GetAutoaimVector(float flDelta) +{ + return GetAutoaimVector_(flDelta); +} + +void CBasePlayer::Blind(float flUntilTime,float flHoldTime,float flFadeTime,int iAlpha) +{ + Blind_(flUntilTime,flHoldTime,flFadeTime,iAlpha); +} + +void CStripWeapons::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + Use_(pActivator, pCaller, useType, value); +} + +void CRevertSaved::KeyValue(KeyValueData *pkvd) +{ + KeyValue_(pkvd); +} + +int CRevertSaved::Save(CSave &save) +{ + return Save_(save); +} + +int CRevertSaved::Restore(CRestore &restore) +{ + return Restore_(restore); +} + +void CRevertSaved::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +{ + Use_(pActivator, pCaller, useType, value); +} + +void CDeadHEV::Spawn(void) +{ + Spawn_(); +} + +void CDeadHEV::KeyValue(KeyValueData *pkvd) +{ + KeyValue_(pkvd); +} + +int CDeadHEV::Classify(void) +{ + return Classify_(); +} + +void CSprayCan::Think(void) +{ + Think_(); +} + +void CInfoIntermission::Spawn(void) +{ + Spawn_(); +} + +void CInfoIntermission::Think(void) +{ + Think_(); +} + +void CWShield::Spawn(void) +{ + Spawn_(); +} + +void CWShield::Touch(CBaseEntity *pOther) +{ + Touch_(pOther); + +} + +#endif // HOOK_GAMEDLL