ReGameDLL_CS/regamedll/dlls/tutor_cs_tutor.cpp

2849 lines
68 KiB
C++
Raw Normal View History

2015-06-30 12:46:07 +03:00
#include "precompiled.h"
const char *CCSTutor::m_TutorIdentifierList[] =
2015-06-30 12:46:07 +03:00
{
"YOU_FIRED_A_SHOT",
"YOU_SHOULD_RELOAD",
"YOU_ARE_OUT_OF_AMMO",
"YOU_KILLED_A_TEAMMATE",
"YOU_KILLED_PLAYER",
"YOU_KILLED_PLAYER_ONE_LEFT",
"YOU_KILLED_LAST_ENEMY",
"YOU_KILLED_PLAYER_HEADSHOT",
"YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT",
"YOU_KILLED_LAST_ENEMY_HEADSHOT",
"YOU_DIED",
"YOU_DIED_HEADSHOT",
"YOU_FELL_TO_YOUR_DEATH",
"YOU_WERE_JUST_HURT",
"YOU_ARE_BLIND_FROM_FLASHBANG",
"YOU_ATTACKED_TEAMMATE",
"BUY_TIME_BEGIN",
"BOMB_PLANTED_T",
"BOMB_PLANTED_CT",
"TEAMMATE_KILLED",
"TEAMMATE_KILLED_ONE_LEFT",
"LAST_TEAMMATE_KILLED",
"ENEMY_KILLED",
"ENEMY_KILLED_ONE_LEFT",
"LAST_ENEMY_KILLED",
"YOU_SPAWNED",
"YOU_SEE_FRIEND",
"YOU_SEE_ENEMY",
"YOU_SEE_FRIEND_CORPSE",
"YOU_SEE_ENEMY_CORPSE",
"YOU_SEE_LOOSE_BOMB_T",
"YOU_SEE_LOOSE_BOMB_CT",
"YOU_SEE_BOMB_CARRIER_T",
"YOU_SEE_BOMB_CARRIER_CT",
"YOU_SEE_PLANTED_BOMB_T",
"YOU_SEE_PLANTED_BOMB_CT",
"YOU_ARE_BOMB_CARRIER",
"YOU_SEE_LOOSE_WEAPON",
"YOU_SEE_LOOSE_DEFUSER",
"YOU_SEE_BOMBSITE_T",
"YOU_SEE_BOMBSITE_CT",
"YOU_SEE_BOMBSITE_T_BOMB",
"YOU_SEE_HOSTAGE_T",
"YOU_SEE_HOSTAGE_CT",
"YOU_SEE_HOSTAGE_CT_EXAMINE",
"YOU_USED_HOSTAGE_MORE_LEFT",
"YOU_USED_HOSTAGE_NO_MORE_LEFT",
"ALL_HOSTAGES_FOLLOWING_T",
"ALL_HOSTAGES_FOLLOWING_CT",
"HOSTAGE_RESCUED_T",
"HOSTAGE_RESCUED_CT",
"YOU_RESCUED_HOSTAGE",
"YOU_ARE_IN_BOMBSITE_T",
"YOU_ARE_IN_BOMBSITE_CT",
"YOU_ARE_IN_BOMBSITE_T_BOMB",
"ALL_HOSTAGES_RESCUED_T",
"ALL_HOSTAGES_RESCUED_CT",
"YOU_DAMAGED_HOSTAGE",
"YOU_KILLED_HOSTAGE",
"ALL_HOSTAGES_DEAD",
"YOU_HAVE_BEEN_SHOT_AT",
"TIME_RUNNING_OUT_DE_T",
"TIME_RUNNING_OUT_DE_CT",
"TIME_RUNNING_OUT_CS_T",
"TIME_RUNNING_OUT_CS_CT",
"DEFUSING_WITHOUT_KIT",
"BOMB_DEFUSED_T",
"BOMB_DEFUSED_CT",
"YOU_DEFUSED_BOMB",
"BOMB_EXPLODED_T",
"BOMB_EXPLODED_CT",
"ROUND_START_DE_T",
"ROUND_START_DE_CT",
"ROUND_START_CS_T",
"ROUND_START_CS_CT",
"ROUND_OVER",
"ROUND_DRAW",
"CT_WIN",
"T_WIN",
"DEATH_CAMERA_START",
"RADIO_COVER_ME",
"RADIO_YOU_TAKE_THE_POINT",
"RADIO_HOLD_THIS_POSITION",
"RADIO_REGROUP_TEAM",
"RADIO_FOLLOW_ME",
"RADIO_TAKING_FIRE",
"RADIO_GO_GO_GO",
"RADIO_TEAM_FALL_BACK",
"RADIO_STICK_TOGETHER_TEAM",
"RADIO_GET_IN_POSITION_AND_WAIT",
"RADIO_STORM_THE_FRONT",
"RADIO_REPORT_IN_TEAM",
"RADIO_AFFIRMATIVE",
"RADIO_ENEMY_SPOTTED",
"RADIO_NEED_BACKUP",
"RADIO_SECTOR_CLEAR",
"RADIO_IN_POSITION",
"RADIO_REPORTING_IN",
"RADIO_GET_OUT_OF_THERE",
"RADIO_NEGATIVE",
"RADIO_ENEMY_DOWN",
"BUY_NEED_PRIMARY",
"BUY_NEED_PRIMARY_AMMO",
"BUY_NEED_SECONDARY_AMMO",
"BUY_NEED_ARMOR",
"BUY_NEED_DEFUSE_KIT",
"BUY_NEED_GRENADE",
"CAREER_TASK_DONE_MORE_LEFT",
"CAREER_TASK_DONE_ONE_LEFT",
"CAREER_TASK_DONE_ALL_DONE",
"HINT_BEGIN",
"HINT_1",
"HINT_2",
"HINT_3",
"HINT_4",
"HINT_5",
"HINT_10",
"HINT_11",
"HINT_12",
"HINT_13",
"HINT_14",
"HINT_15",
"HINT_20",
"HINT_21",
"HINT_22",
"HINT_23",
"HINT_24",
"HINT_25",
"HINT_26",
"HINT_30",
"HINT_31",
"HINT_32",
"HINT_33",
"HINT_34",
"HINT_40",
"HINT_50",
"HINT_51",
"HINT_52",
"HINT_53",
"HINT_60",
"HINT_61",
"HINT_70",
"HINT_71",
"HINT_72",
"HINT_73",
"HINT_END",
"INGAME_HINT_BEGIN",
"INGAME_HINT_1",
"INGAME_HINT_2",
"INGAME_HINT_3"
};
CCSTutor::CCSTutor()
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
m_stateSystem = new CCSTutorStateSystem;
m_nextViewableCheckTime = 0;
m_currentlyShownMessageID = TUTOR_NUM_MESSAGES;
2017-10-12 17:50:56 +03:00
m_currentMessageEvent = nullptr;
2015-08-20 13:35:01 +03:00
m_messageTypeMask = TUTORMESSAGETYPE_ALL;
2017-10-12 17:50:56 +03:00
m_lastScenarioEvent = nullptr;
2015-08-20 13:35:01 +03:00
m_haveSpawned = false;
m_lastHintShown = HINT_BEGIN;
m_lastInGameHintShown = INGAME_HINT_BEGIN;
ReadTutorMessageFile();
ApplyPersistentDecay();
ResetPlayerDeathInfo();
2015-06-30 12:46:07 +03:00
}
CCSTutor::~CCSTutor()
2015-06-30 12:46:07 +03:00
{
if (m_stateSystem)
2015-08-20 13:35:01 +03:00
{
delete m_stateSystem;
2017-10-12 17:50:56 +03:00
m_stateSystem = nullptr;
2015-08-20 13:35:01 +03:00
}
if (m_currentMessageEvent)
2015-08-20 13:35:01 +03:00
{
DeleteEvent(m_currentMessageEvent);
2017-10-12 17:50:56 +03:00
m_currentMessageEvent = nullptr;
2015-08-20 13:35:01 +03:00
}
if (m_lastScenarioEvent)
2015-08-20 13:35:01 +03:00
{
DeleteEvent(m_lastScenarioEvent);
2017-10-12 17:50:56 +03:00
m_lastScenarioEvent = nullptr;
2015-08-20 13:35:01 +03:00
}
ClearCurrentEvent();
ClearEventList();
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void ParseMessageParameters(char *&messageData, TutorMessage *ret)
{
char *token;
while (true)
{
2017-10-12 17:50:56 +03:00
messageData = SharedParse((char *)messageData);
token = SharedGetToken();
2015-08-20 13:35:01 +03:00
if (!messageData || !Q_stricmp(token, "End"))
{
break;
}
if (!Q_stricmp(token, "String"))
{
2017-10-12 17:50:56 +03:00
messageData = SharedParse((char *)messageData);
ret->m_text = Q_strdup(SharedGetToken());
2015-08-20 13:35:01 +03:00
}
else if (!Q_stricmp(token, "Duration"))
{
2017-10-12 17:50:56 +03:00
messageData = SharedParse((char *)messageData);
ret->m_duration = Q_atoi(SharedGetToken());
2015-08-20 13:35:01 +03:00
}
else if (!Q_stricmp(token, "Priority"))
{
2017-10-12 17:50:56 +03:00
messageData = SharedParse((char *)messageData);
ret->m_priority = Q_atoi(SharedGetToken());
2015-08-20 13:35:01 +03:00
}
else if (!Q_stricmp(token, "KeepOld"))
{
2017-10-12 17:50:56 +03:00
messageData = SharedParse((char *)messageData);
token = SharedGetToken();
2015-08-20 13:35:01 +03:00
if (!Q_stricmp(token, "true"))
{
ret->m_keepOld = TUTORMESSAGEKEEPOLDTYPE_KEEP_OLD;
}
else if (!Q_stricmp(token, "updatecontent"))
{
ret->m_keepOld = TUTORMESSAGEKEEPOLDTYPE_UPDATE_CONTENT;
}
else
{
ret->m_keepOld = TUTORMESSAGEKEEPOLDTYPE_DONT_KEEP_OLD;
}
}
else if (!Q_stricmp(token, "Class"))
{
2017-10-12 17:50:56 +03:00
messageData = SharedParse((char *)messageData);
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
if (!Q_stricmp(SharedGetToken(), "Examine"))
2015-08-20 13:35:01 +03:00
{
ret->m_class = TUTORMESSAGECLASS_EXAMINE;
}
else
{
ret->m_class = TUTORMESSAGECLASS_NORMAL;
}
}
else if (!Q_stricmp(token, "Decay"))
{
2017-10-12 17:50:56 +03:00
messageData = SharedParse((char *)messageData);
ret->m_decay = Q_atoi(SharedGetToken());
2015-08-20 13:35:01 +03:00
}
else if (!Q_stricmp(token, "Type"))
{
2017-10-12 17:50:56 +03:00
messageData = SharedParse((char *)messageData);
token = SharedGetToken();
2015-08-20 13:35:01 +03:00
if (!Q_stricmp(token, "FriendDeath"))
{
ret->m_type = TUTORMESSAGETYPE_FRIEND_DEATH;
}
else if (!Q_stricmp(token, "EnemyDeath"))
{
ret->m_type = TUTORMESSAGETYPE_ENEMY_DEATH;
}
else if (!Q_stricmp(token, "Scenario"))
{
ret->m_type = TUTORMESSAGETYPE_SCENARIO;
}
else if (!Q_stricmp(token, "Buy"))
{
ret->m_type = TUTORMESSAGETYPE_BUY;
}
else if (!Q_stricmp(token, "Career"))
{
ret->m_type = TUTORMESSAGETYPE_CAREER;
}
else if (!Q_stricmp(token, "Hint"))
{
ret->m_type = TUTORMESSAGETYPE_HINT;
}
else if (!Q_stricmp(token, "InGameHint"))
{
ret->m_type = TUTORMESSAGETYPE_INGAME_HINT;
}
else if (!Q_stricmp(token, "EndGame"))
{
ret->m_type = TUTORMESSAGETYPE_END_GAME;
}
else
{
ret->m_type = TUTORMESSAGETYPE_DEFAULT;
}
}
else if (!Q_stricmp(token, "Lifetime"))
{
2017-10-12 17:50:56 +03:00
messageData = SharedParse((char *)messageData);
ret->m_lifetime = Q_atoi(SharedGetToken());
2015-08-20 13:35:01 +03:00
}
else if (!Q_stricmp(token, "DuplicateID"))
{
2017-10-12 17:50:56 +03:00
messageData = SharedParse((char *)messageData);
ret->m_duplicateID = Q_atoi(SharedGetToken());
2015-08-20 13:35:01 +03:00
}
else if (!Q_stricmp(token, "Interrupt"))
{
2017-10-12 17:50:56 +03:00
messageData = SharedParse((char *)messageData);
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
if (!Q_stricmp(SharedGetToken(), "Now"))
2015-08-20 13:35:01 +03:00
{
ret->m_interruptFlag = TUTORMESSAGEINTERRUPTFLAG_NOW_DAMMIT;
}
else
{
ret->m_interruptFlag = TUTORMESSAGEINTERRUPTFLAG_DEFAULT;
}
}
else if (!Q_stricmp(token, "MinDisplayTimeOverride"))
{
2017-10-12 17:50:56 +03:00
messageData = SharedParse((char *)messageData);
ret->m_minDisplayTimeOverride = Q_atof(SharedGetToken());
2015-08-20 13:35:01 +03:00
}
else if (!Q_stricmp(token, "MinRepeatInterval"))
{
2017-10-12 17:50:56 +03:00
messageData = SharedParse((char *)messageData);
ret->m_minRepeatInterval = Q_atof(SharedGetToken());
2015-08-20 13:35:01 +03:00
}
}
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
TutorMessage *ConstructTutorMessage(char *&messageData, TutorMessage *defaults)
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
TutorMessage *msg = new TutorMessage;
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
msg->m_text = nullptr;
msg->m_duplicateID = defaults->m_duplicateID;
msg->m_keepOld = defaults->m_keepOld;
msg->m_duration = defaults->m_duration;
msg->m_priority = defaults->m_priority;
msg->m_class = defaults->m_class;
msg->m_type = defaults->m_type;
msg->m_decay = defaults->m_decay;
msg->m_lifetime = defaults->m_lifetime;
msg->m_interruptFlag = defaults->m_interruptFlag;
msg->m_minDisplayTimeOverride = defaults->m_minDisplayTimeOverride;
msg->m_minRepeatInterval = defaults->m_minRepeatInterval;
msg->m_examineStartTime = -1.0f;
msg->m_timesShown = 0;
msg->m_lastCloseTime = 0;
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
ParseMessageParameters(messageData, msg);
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
return msg;
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void ReadDefaultValues(char *&messageData, TutorMessage *defaults)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
ParseMessageParameters(messageData, defaults);
2015-06-30 12:46:07 +03:00
}
void CCSTutor::ReadTutorMessageFile()
2015-08-20 13:35:01 +03:00
{
int messageFileLen = 0;
char *messageFile;
char *messageData;
TutorMessage defaultMessage;
messageFile = messageData = (char *)LOAD_FILE_FOR_ME("tutordata.txt", &messageFileLen);
if (!messageFile)
{
2017-10-12 17:50:56 +03:00
if (AreRunningCZero())
2015-08-20 13:35:01 +03:00
{
CONSOLE_ECHO("Warning: Cannot access tutor message file tutordata.txt\n");
}
return;
}
defaultMessage.m_duplicateID = 0;
defaultMessage.m_keepOld = TUTORMESSAGEKEEPOLDTYPE_DONT_KEEP_OLD;
defaultMessage.m_duration = 1;
defaultMessage.m_priority = 0;
defaultMessage.m_class = TUTORMESSAGECLASS_NORMAL;
defaultMessage.m_type = TUTORMESSAGETYPE_DEFAULT;
defaultMessage.m_decay = 10;
defaultMessage.m_lifetime = 10;
defaultMessage.m_interruptFlag = TUTORMESSAGEINTERRUPTFLAG_DEFAULT;
defaultMessage.m_minDisplayTimeOverride = 0;
defaultMessage.m_minRepeatInterval = 0;
2015-09-16 23:19:21 +03:00
while (true)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
messageData = SharedParse(messageData);
2015-08-20 13:35:01 +03:00
if (!messageData)
break;
2017-10-12 17:50:56 +03:00
char *token = SharedGetToken();
2015-08-20 13:35:01 +03:00
if (!Q_stricmp(token, "TutorMessage"))
{
2017-10-12 17:50:56 +03:00
messageData = SharedParse(messageData);
token = SharedGetToken();
2015-08-20 13:35:01 +03:00
std::string identifier = token;
TutorMessage *tm = ConstructTutorMessage(messageData, &defaultMessage);
m_messageMap[identifier] = tm;
}
else if (!Q_stricmp(token, "Defaults"))
{
ReadDefaultValues(messageData, &defaultMessage);
}
}
FREE_FILE(messageFile);
2015-06-30 12:46:07 +03:00
}
void CCSTutor::ApplyPersistentDecay()
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
for (TutorMessageID mid = YOU_FIRED_A_SHOT; mid < TUTOR_NUM_MESSAGES; mid++)
{
TutorMessage *definition = GetTutorMessageDefinition(mid);
if (definition)
2015-08-20 13:35:01 +03:00
{
int timesShown = GET_TIMES_TUTOR_MESSAGE_SHOWN(mid);
if (timesShown != -1)
{
definition->m_timesShown = timesShown;
}
}
}
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
bool CCSTutor::HasCurrentWindowBeenActiveLongEnough(float time)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
return (m_currentlyShownMessageID < 0 || m_currentlyShownMessageID >= TUTOR_NUM_MESSAGES || time > m_currentlyShownMessageMinimumCloseTime);
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
bool CCSTutor::ShouldShowMessageEvent(TutorMessageEvent *event, float time)
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
if (!event)
2015-08-20 13:35:01 +03:00
return false;
TutorMessage *message = GetTutorMessageDefinition(event->GetID());
2017-10-12 17:50:56 +03:00
if (!message)
2015-08-20 13:35:01 +03:00
return false;
if (message->m_class == TUTORMESSAGECLASS_NORMAL)
{
if (message->m_decay)
{
if (message->m_timesShown >= message->m_decay)
return false;
}
}
if (!(m_messageTypeMask & message->m_type) || (time - message->m_lastCloseTime < message->m_minRepeatInterval))
return false;
if (HasCurrentWindowBeenActiveLongEnough(time))
return true;
if (message->m_interruptFlag != TUTORMESSAGEINTERRUPTFLAG_NOW_DAMMIT)
return false;
TutorMessage *current = GetTutorMessageDefinition(m_currentlyShownMessageID);
2017-10-12 17:50:56 +03:00
if (!current || (DoMessagesHaveSameID(event->GetID(), m_currentlyShownMessageID) && current->m_keepOld != TUTORMESSAGEKEEPOLDTYPE_DONT_KEEP_OLD))
2015-08-20 13:35:01 +03:00
return false;
if (message->m_priority > current->m_priority
|| message->m_priority == current->m_priority
|| m_currentMessageEvent->GetTimeActive(time) < event->GetTimeActive(time))
{
return true;
}
return false;
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void CCSTutor::CheckForInterruptingMessageEvent(float time)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
bool newEvent = false;
TutorMessageEvent *event = m_eventList;
TutorMessage *oldMessage = GetTutorMessageDefinition(m_currentlyShownMessageID);
TutorMessageEvent *oldEvent = m_currentMessageEvent;
while (event)
2015-08-20 13:35:01 +03:00
{
if (ShouldShowMessageEvent(event, time))
{
newEvent = true;
ShowTutorMessage(event);
}
event = event->GetNext();
}
if (!newEvent)
{
return;
}
if (oldEvent)
2015-08-20 13:35:01 +03:00
{
ProcessShownDeathsForEvent(event);
DeleteEvent(oldEvent);
}
CloseCurrentWindow();
if (oldMessage)
2015-08-20 13:35:01 +03:00
{
oldMessage->m_lastCloseTime = time;
}
DeleteEventFromEventList(m_currentMessageEvent);
ConstructMessageAndDisplay();
2015-06-30 12:46:07 +03:00
}
void CCSTutor::TutorThink(float time)
2015-08-20 13:35:01 +03:00
{
if (m_nextViewableCheckTime <= time)
{
CheckForBombViewable();
CheckForLooseWeaponViewable();
CheckForLooseDefuserViewable();
CheckForTimeRunningOut();
CheckForBombsiteViewable();
CheckForHostageViewable();
CheckExamineMessages(time);
CheckHintMessages(time);
CheckInGameHintMessages(time);
CheckForNeedToReload(true);
if (m_haveSpawned && CanLocalPlayerBuyStuff())
{
m_messageTypeMask = TUTORMESSAGETYPE_BUY;
CreateAndAddEventToList(BUY_TIME_BEGIN);
m_haveSpawned = false;
}
if (CanLocalPlayerBuyStuff() && m_messageTypeMask == TUTORMESSAGETYPE_BUY)
{
CheckBuyZoneMessages();
}
else
{
if (!CanLocalPlayerBuyStuff() && m_messageTypeMask == TUTORMESSAGETYPE_BUY)
{
OnEvent(EVENT_PLAYER_LEFT_BUY_ZONE);
}
}
m_nextViewableCheckTime = cv_tutor_viewable_check_interval.value + time;
}
CheckForInactiveEvents(time);
CheckForWindowClose(time);
CheckForContentUpdate();
CheckForInterruptingMessageEvent(time);
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void CCSTutor::CheckForWindowClose(float time)
2015-06-30 12:46:07 +03:00
{
if (m_currentlyShownMessageID < 0 || m_currentlyShownMessageID >= TUTOR_NUM_MESSAGES || time <= m_currentlyShownMessageCloseTime)
2015-08-20 13:35:01 +03:00
return;
TutorMessageEvent *event = GetTutorMessageUpdateEvent();
2017-10-12 17:50:56 +03:00
if (!event)
2015-08-20 13:35:01 +03:00
{
ClearCurrentEvent();
return;
}
UpdateCurrentMessage(event);
DeleteEventFromEventList(event);
2015-06-30 12:46:07 +03:00
}
void CCSTutor::CheckForContentUpdate()
2015-06-30 12:46:07 +03:00
{
if (m_currentlyShownMessageID < 0 || m_currentlyShownMessageID >= TUTOR_NUM_MESSAGES)
2015-08-20 13:35:01 +03:00
return;
TutorMessage *definition = GetTutorMessageDefinition(m_currentlyShownMessageID);
2017-10-12 17:50:56 +03:00
if (!definition || definition->m_keepOld != TUTORMESSAGEKEEPOLDTYPE_UPDATE_CONTENT)
2015-08-20 13:35:01 +03:00
return;
TutorMessageEvent *event = GetTutorMessageUpdateEvent();
if (event)
2015-08-20 13:35:01 +03:00
{
UpdateCurrentMessage(event);
DeleteEventFromEventList(event);
}
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void CCSTutor::ClearCurrentEvent(bool closeWindow, bool processDeathsForEvent)
{
TutorMessage *oldMessage = GetTutorMessageDefinition(m_currentlyShownMessageID);
if (oldMessage)
2015-08-20 13:35:01 +03:00
{
oldMessage->m_lastCloseTime = gpGlobals->time;
}
if (processDeathsForEvent)
{
ProcessShownDeathsForEvent(m_currentMessageEvent);
}
if (closeWindow)
{
CloseCurrentWindow();
}
m_currentlyShownMessageID = TUTOR_NUM_MESSAGES;
m_currentlyShownMessageCloseTime = 0;
m_currentlyShownMessageMinimumCloseTime = 0;
if (m_currentMessageEvent)
2015-08-20 13:35:01 +03:00
{
DeleteEvent(m_currentMessageEvent);
2017-10-12 17:50:56 +03:00
m_currentMessageEvent = nullptr;
2015-08-20 13:35:01 +03:00
}
}
2015-06-30 12:46:07 +03:00
2015-08-20 13:35:01 +03:00
void CCSTutor::ProcessShownDeathsForEvent(TutorMessageEvent *event)
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
if (!event)
2015-08-20 13:35:01 +03:00
return;
2017-10-12 17:50:56 +03:00
for (auto& info : m_playerDeathInfo)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (info.m_event == event) {
info.m_hasBeenShown = true;
info.m_event = nullptr;
2015-08-20 13:35:01 +03:00
}
}
2015-06-30 12:46:07 +03:00
}
TutorMessageEvent *CCSTutor::GetTutorMessageUpdateEvent()
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
TutorMessage *definition = GetTutorMessageDefinition(m_currentlyShownMessageID);
2017-10-12 17:50:56 +03:00
if (!definition || definition->m_keepOld == TUTORMESSAGEKEEPOLDTYPE_DONT_KEEP_OLD)
return nullptr;
2015-08-20 13:35:01 +03:00
for (TutorMessageEvent *event = m_eventList; event; event = event->GetNext())
2015-08-20 13:35:01 +03:00
{
if (DoMessagesHaveSameID(event->GetID(), m_currentlyShownMessageID))
{
return event;
}
}
2017-10-12 17:50:56 +03:00
return nullptr;
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
bool CCSTutor::GetDuplicateMessagesFromEventList(TutorMessageEvent *&event1, TutorMessageEvent *&event2)
2015-06-30 12:46:07 +03:00
{
for (event1 = m_eventList; event1; event1 = event1->GetNext())
2015-08-20 13:35:01 +03:00
{
for (event2 = event1->GetNext(); event2; event2 = event2->GetNext())
2015-08-20 13:35:01 +03:00
{
if (DoMessagesHaveSameID(event1->GetID(), event2->GetID()))
{
return true;
}
}
}
return false;
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void CCSTutor::CheckForInactiveEvents(float time)
{
TutorMessageEvent *event = m_eventList;
while (event)
2015-08-20 13:35:01 +03:00
{
if (!event->IsActive(time))
{
TutorMessageEvent *temp = event->GetNext();
DeleteEventFromEventList(event);
DeleteEvent(event);
event = temp;
}
else
event = event->GetNext();
}
2017-10-12 17:50:56 +03:00
TutorMessageEvent *event1 = nullptr;
TutorMessageEvent *event2 = nullptr;
2015-08-20 13:35:01 +03:00
if (GetDuplicateMessagesFromEventList(event1, event2))
2015-08-20 13:35:01 +03:00
{
if (event1->GetTimeActive(time) < event2->GetTimeActive(time))
{
TransferDeathEvents(event2, event1);
DeleteEventFromEventList(event2);
DeleteEvent(event2);
}
else
{
TransferDeathEvents(event1, event2);
DeleteEventFromEventList(event1);
DeleteEvent(event1);
}
}
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void CCSTutor::CancelEvent(TutorMessageID mid)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
if (m_currentlyShownMessageID == mid)
ClearCurrentEvent();
TutorMessageEvent *event = m_eventList;
while (event)
2015-08-20 13:35:01 +03:00
{
TutorMessageEvent *temp = event->GetNext();
if (event->GetID() == mid)
{
DeleteEventFromEventList(event);
DeleteEvent(event);
}
event = temp;
}
if (m_lastScenarioEvent && m_lastScenarioEvent->GetID() == mid)
2015-08-20 13:35:01 +03:00
{
DeleteEvent(m_lastScenarioEvent);
2017-10-12 17:50:56 +03:00
m_lastScenarioEvent = nullptr;
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
NOXREF void CCSTutor::LookupHotKey(TutorMessageID mid, int paramNum, wchar_t *buf, int buflen)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
#ifdef _WIN32
_snwprintf(buf, buflen - 1, L"KEY%d", paramNum);
#endif
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
TutorMessageEvent *CCSTutor::CreateTutorMessageEvent(TutorMessageID mid, CBaseEntity *pEntity, CBaseEntity *pOther)
2015-08-20 13:35:01 +03:00
{
char enemyList[2048];
char teammateList[2048];
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return nullptr;
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
TutorMessage *message = GetTutorMessageDefinition(mid);
if (!message)
return nullptr;
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
TutorMessageEvent *event = new TutorMessageEvent
2015-08-20 13:35:01 +03:00
(
mid,
message->m_duplicateID,
gpGlobals->time,
message->m_lifetime,
message->m_priority
);
2017-10-12 17:50:56 +03:00
switch (mid)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case YOU_KILLED_PLAYER_ONE_LEFT:
case YOU_KILLED_LAST_ENEMY:
case YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT:
case YOU_KILLED_LAST_ENEMY_HEADSHOT:
case ENEMY_KILLED_ONE_LEFT:
case LAST_ENEMY_KILLED:
{
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case CT:
ConstructRecentDeathsList(TERRORIST, enemyList, sizeof(enemyList), event);
event->AddParameter(enemyList);
break;
case TERRORIST:
ConstructRecentDeathsList(CT, teammateList, sizeof(teammateList), event);
event->AddParameter(teammateList);
2015-08-20 13:35:01 +03:00
break;
}
2017-10-12 17:50:56 +03:00
break;
}
case YOU_KILLED_PLAYER:
case YOU_KILLED_PLAYER_HEADSHOT:
case ENEMY_KILLED:
{
int numT, numCT;
char numTStr[16], numCTStr[16];
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
GetNumPlayersAliveOnTeams(numT, numCT);
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
Q_snprintf(numTStr, sizeof(numTStr), "%i", numT);
Q_snprintf(numCTStr, sizeof(numCTStr), "%i", numCT);
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case CT:
event->AddParameter(numCTStr);
ConstructRecentDeathsList(TERRORIST, enemyList, sizeof(enemyList), event);
2015-08-20 13:35:01 +03:00
event->AddParameter(enemyList);
break;
2017-10-12 17:50:56 +03:00
case TERRORIST:
event->AddParameter(numTStr);
ConstructRecentDeathsList(CT, teammateList, sizeof(teammateList), event);
event->AddParameter(teammateList);
break;
}
break;
}
case CAREER_TASK_DONE_MORE_LEFT:
{
char numLeftStr[16];
int numtasks = 0;
if (TheCareerTasks)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
numtasks = TheCareerTasks->GetNumRemainingTasks();
}
Q_sprintf(numLeftStr, "%d", numtasks);
event->AddParameter(numLeftStr);
break;
}
case YOU_KILLED_A_TEAMMATE:
case TEAMMATE_KILLED_ONE_LEFT:
case LAST_TEAMMATE_KILLED:
ConstructRecentDeathsList(pLocalPlayer->m_iTeam, enemyList, sizeof(enemyList), event);
event->AddParameter(enemyList);
break;
case TEAMMATE_KILLED:
{
int numT;
int numCT;
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
char numTStr[16];
char numCTStr[16];
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
GetNumPlayersAliveOnTeams(numT, numCT);
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
if (pLocalPlayer->IsAlive())
{
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case CT: numCT--; break;
case TERRORIST: numT--; break;
2015-08-20 13:35:01 +03:00
}
2017-10-12 17:50:56 +03:00
}
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
Q_snprintf(numTStr, sizeof(numTStr), "%i", numT);
Q_snprintf(numCTStr, sizeof(numCTStr), "%i", numCT);
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
switch (pLocalPlayer->m_iTeam)
{
case CT:
event->AddParameter(numCTStr);
break;
case TERRORIST:
event->AddParameter(numTStr);
2015-08-20 13:35:01 +03:00
break;
}
2017-10-12 17:50:56 +03:00
ConstructRecentDeathsList(pLocalPlayer->m_iTeam, teammateList, sizeof(teammateList), event);
event->AddParameter(teammateList);
break;
}
2015-08-20 13:35:01 +03:00
}
return event;
}
void CCSTutor::AddToEventList(TutorMessageEvent *event)
{
if (event)
2015-08-20 13:35:01 +03:00
{
event->SetNext(m_eventList);
m_eventList = event;
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::CreateAndAddEventToList(TutorMessageID mid, CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
auto event = CreateTutorMessageEvent(mid, pEntity, pOther);
if (event)
2015-08-20 13:35:01 +03:00
{
auto message = GetTutorMessageDefinition(mid);
if (message && message->m_type == TUTORMESSAGETYPE_SCENARIO)
2015-08-20 13:35:01 +03:00
{
if (m_lastScenarioEvent)
2015-08-20 13:35:01 +03:00
{
DeleteEvent(m_lastScenarioEvent);
2017-10-12 17:50:56 +03:00
m_lastScenarioEvent = nullptr;
2015-08-20 13:35:01 +03:00
}
2017-11-22 20:27:55 +03:00
m_lastScenarioEvent = CreateTutorMessageEvent(mid, pEntity, pOther);
2015-08-20 13:35:01 +03:00
}
AddToEventList(event);
}
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void CCSTutor::DeleteEventFromEventList(TutorMessageEvent *event)
{
2017-10-12 17:50:56 +03:00
if (!event)
2015-08-20 13:35:01 +03:00
return;
TutorMessageEvent *temp = m_eventList;
if (temp != event)
{
if (temp)
2015-08-20 13:35:01 +03:00
{
while (event != temp->GetNext())
{
temp = temp->GetNext();
2017-10-12 17:50:56 +03:00
if (!temp)
2015-08-20 13:35:01 +03:00
{
return;
}
}
if (temp && temp->GetNext() == event)
2015-08-20 13:35:01 +03:00
{
temp->SetNext(temp->GetNext()->GetNext());
}
}
}
else
2017-10-12 17:50:56 +03:00
{
2015-08-20 13:35:01 +03:00
m_eventList = m_eventList->GetNext();
2017-10-12 17:50:56 +03:00
}
2015-06-30 12:46:07 +03:00
}
void CCSTutor::ClearEventList()
2015-06-30 12:46:07 +03:00
{
while (m_eventList)
2015-08-20 13:35:01 +03:00
{
TutorMessageEvent *temp = m_eventList;
m_eventList = m_eventList->GetNext();
DeleteEvent(temp);
}
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void CCSTutor::DeleteEvent(TutorMessageEvent *event)
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
for (auto& info : m_playerDeathInfo)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (info.m_event == event) {
info.m_event = nullptr;
2015-08-20 13:35:01 +03:00
}
}
delete event;
2015-06-30 12:46:07 +03:00
}
void CCSTutor::PurgeMessages()
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
ClearCurrentEvent();
ClearEventList();
2015-06-30 12:46:07 +03:00
if (m_lastScenarioEvent)
2015-08-20 13:35:01 +03:00
{
DeleteEvent(m_lastScenarioEvent);
2017-10-12 17:50:56 +03:00
m_lastScenarioEvent = nullptr;
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
void CCSTutor::ComputeDisplayTimesForMessage()
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
TutorMessage *message = GetTutorMessageDefinition(m_currentlyShownMessageID);
2017-10-12 17:50:56 +03:00
if (!message)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
m_currentlyShownMessageCloseTime = gpGlobals->time;
2015-08-20 13:35:01 +03:00
return;
}
2017-10-12 17:50:56 +03:00
m_currentlyShownMessageCloseTime = message->m_duration + gpGlobals->time;
2015-08-20 13:35:01 +03:00
m_currentlyShownMessageMinimumCloseTime = cv_tutor_message_minimum_display_time.value;
int stringLength = GET_LOCALIZED_STRING_LENGTH(message->m_text);
float minShowTime = stringLength * cv_tutor_message_character_display_time_coefficient.value;
if (minShowTime > m_currentlyShownMessageMinimumCloseTime)
{
m_currentlyShownMessageMinimumCloseTime = minShowTime;
}
if (message->m_minDisplayTimeOverride <= m_currentlyShownMessageMinimumCloseTime)
{
message->m_minDisplayTimeOverride = m_currentlyShownMessageMinimumCloseTime;
}
2017-10-12 17:50:56 +03:00
m_currentlyShownMessageMinimumCloseTime = message->m_minDisplayTimeOverride + gpGlobals->time;
2015-08-20 13:35:01 +03:00
if (m_currentlyShownMessageMinimumCloseTime > m_currentlyShownMessageCloseTime)
{
m_currentlyShownMessageCloseTime = m_currentlyShownMessageMinimumCloseTime;
}
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
NOXREF bool CCSTutor::ShouldUpdateCurrentMessage(TutorMessageID messageID)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
if (DoMessagesHaveSameID(messageID, m_currentlyShownMessageID))
{
TutorMessage *definition = GetTutorMessageDefinition(messageID);
if (definition && definition->m_keepOld != TUTORMESSAGEKEEPOLDTYPE_DONT_KEEP_OLD)
2015-08-20 13:35:01 +03:00
{
return true;
}
}
return false;
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void CCSTutor::UpdateCurrentMessage(TutorMessageEvent *event)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
TransferDeathEvents(m_currentMessageEvent, event);
if (m_currentMessageEvent)
2015-08-20 13:35:01 +03:00
{
DeleteEvent(m_currentMessageEvent);
2017-10-12 17:50:56 +03:00
m_currentMessageEvent = nullptr;
2015-08-20 13:35:01 +03:00
}
m_currentlyShownMessageID = (TutorMessageID)event->GetID();
m_currentMessageEvent = event;
TutorMessage *definition = GetTutorMessageDefinition(event->GetID());
if (definition)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (pLocalPlayer)
2015-08-20 13:35:01 +03:00
{
m_currentlyShownMessageCloseTime = definition->m_duration + gpGlobals->time;
if (definition->m_keepOld == TUTORMESSAGEKEEPOLDTYPE_UPDATE_CONTENT)
{
CloseCurrentWindow();
2017-10-12 17:50:56 +03:00
DisplayMessageToPlayer(pLocalPlayer, event->GetID(), definition->m_text, event);
2015-08-20 13:35:01 +03:00
}
}
}
2015-06-30 12:46:07 +03:00
}
void CCSTutor::ShowTutorMessage(TutorMessageEvent *event)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
TutorMessageID mid = static_cast<TutorMessageID>(event->GetID());
if (mid < 0 || mid >= TUTOR_NUM_MESSAGES)
return;
TutorMessage *message = GetTutorMessageDefinition(mid);
if (message)
2015-08-20 13:35:01 +03:00
{
m_currentlyShownMessageID = mid;
m_currentMessageEvent = event;
m_currentlyShownMessageCloseTime = 0;
m_currentlyShownMessageMinimumCloseTime = 0;
}
2015-06-30 12:46:07 +03:00
}
void CCSTutor::ConstructMessageAndDisplay()
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (pLocalPlayer && !pLocalPlayer->IsBot())
2015-08-20 13:35:01 +03:00
{
TutorMessageID mid = static_cast<TutorMessageID>(m_currentMessageEvent->GetID());
if (mid < 0 || mid >= TUTOR_NUM_MESSAGES)
return;
TutorMessage *message = GetTutorMessageDefinition(mid);
if (message)
2015-08-20 13:35:01 +03:00
{
message->m_timesShown++;
ComputeDisplayTimesForMessage();
2017-10-12 17:50:56 +03:00
DisplayMessageToPlayer(pLocalPlayer, mid, message->m_text, m_currentMessageEvent);
2015-08-20 13:35:01 +03:00
}
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::CallEventHandler(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
2015-08-20 13:35:01 +03:00
{
switch (event)
{
case EVENT_WEAPON_FIRED:
2017-11-22 20:27:55 +03:00
HandleWeaponFired(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_WEAPON_FIRED_ON_EMPTY:
2017-11-22 20:27:55 +03:00
HandleWeaponFiredOnEmpty(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_WEAPON_RELOADED:
2017-11-22 20:27:55 +03:00
HandleWeaponReloaded(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_BEING_SHOT_AT:
2017-11-22 20:27:55 +03:00
HandleBeingShotAt(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_PLAYER_BLINDED_BY_FLASHBANG:
2017-11-22 20:27:55 +03:00
HandlePlayerBlindedByFlashbang(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_PLAYER_DIED:
2017-11-22 20:27:55 +03:00
HandlePlayerDied(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_PLAYER_TOOK_DAMAGE:
2017-11-22 20:27:55 +03:00
HandlePlayerTookDamage(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_HOSTAGE_DAMAGED:
2017-11-22 20:27:55 +03:00
HandleHostageDamaged(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_HOSTAGE_KILLED:
2017-11-22 20:27:55 +03:00
HandleHostageKilled(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_BOMB_PLANTED:
2017-11-22 20:27:55 +03:00
HandleBombPlanted(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_BOMB_DEFUSING:
2017-11-22 20:27:55 +03:00
HandleBombDefusing(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_BOMB_DEFUSED:
2017-11-22 20:27:55 +03:00
HandleBombDefused(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_BOMB_EXPLODED:
2017-11-22 20:27:55 +03:00
HandleBombExploded(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_HOSTAGE_USED:
2017-11-22 20:27:55 +03:00
HandleHostageUsed(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_HOSTAGE_RESCUED:
2017-11-22 20:27:55 +03:00
HandleHostageRescued(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_ALL_HOSTAGES_RESCUED:
2017-11-22 20:27:55 +03:00
HandleAllHostagesRescued(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_TERRORISTS_WIN:
2017-11-22 20:27:55 +03:00
HandleTWin(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_CTS_WIN:
2017-11-22 20:27:55 +03:00
HandleCTWin(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_ROUND_DRAW:
2017-11-22 20:27:55 +03:00
HandleRoundDraw(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_ROUND_START:
2017-11-22 20:27:55 +03:00
HandleRoundStart(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_PLAYER_SPAWNED:
2017-11-22 20:27:55 +03:00
HandlePlayerSpawned(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_PLAYER_LEFT_BUY_ZONE:
2017-11-22 20:27:55 +03:00
HandlePlayerLeftBuyZone(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_DEATH_CAMERA_START:
2017-11-22 20:27:55 +03:00
HandleDeathCameraStart(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_TUTOR_BUY_MENU_OPENNED:
2017-11-22 20:27:55 +03:00
HandleBuyMenuOpenned(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_TUTOR_AUTOBUY:
2017-11-22 20:27:55 +03:00
HandleAutoBuy(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_TUTOR_NOT_BUYING_ANYTHING:
2017-11-22 20:27:55 +03:00
HandleNotBuyingAnything(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_TUTOR_NEED_TO_BUY_PRIMARY_WEAPON:
2017-11-22 20:27:55 +03:00
HandleNeedToBuyPrimaryWeapon(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_TUTOR_NEED_TO_BUY_PRIMARY_AMMO:
2017-11-22 20:27:55 +03:00
HandleNeedToBuyPrimaryAmmo(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_TUTOR_NEED_TO_BUY_SECONDARY_AMMO:
2017-11-22 20:27:55 +03:00
HandleNeedToBuySecondaryAmmo(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_TUTOR_NEED_TO_BUY_ARMOR:
2017-11-22 20:27:55 +03:00
HandleNeedToBuyArmor(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_TUTOR_NEED_TO_BUY_DEFUSE_KIT:
2017-11-22 20:27:55 +03:00
HandleNeedToBuyDefuseKit(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_TUTOR_NEED_TO_BUY_GRENADE:
2017-11-22 20:27:55 +03:00
HandleNeedToBuyGrenade(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_CAREER_TASK_DONE:
2017-11-22 20:27:55 +03:00
HandleCareerTaskDone(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_COVER_ME:
2017-11-22 20:27:55 +03:00
HandleRadioCoverMe(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_YOU_TAKE_THE_POINT:
2017-11-22 20:27:55 +03:00
HandleRadioYouTakeThePoint(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_HOLD_THIS_POSITION:
2017-11-22 20:27:55 +03:00
HandleRadioHoldThisPosition(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_REGROUP_TEAM:
2017-11-22 20:27:55 +03:00
HandleRadioRegroupTeam(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_FOLLOW_ME:
2017-11-22 20:27:55 +03:00
HandleRadioFollowMe(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_TAKING_FIRE:
2017-11-22 20:27:55 +03:00
HandleRadioTakingFire(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_GO_GO_GO:
2017-11-22 20:27:55 +03:00
HandleRadioGoGoGo(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_TEAM_FALL_BACK:
2017-11-22 20:27:55 +03:00
HandleRadioTeamFallBack(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_STICK_TOGETHER_TEAM:
2017-11-22 20:27:55 +03:00
HandleRadioStickTogetherTeam(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_GET_IN_POSITION_AND_WAIT:
2017-11-22 20:27:55 +03:00
HandleRadioGetInPositionAndWait(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_STORM_THE_FRONT:
2017-11-22 20:27:55 +03:00
HandleRadioStormTheFront(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_REPORT_IN_TEAM:
2017-11-22 20:27:55 +03:00
HandleRadioReportInTeam(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_AFFIRMATIVE:
2017-11-22 20:27:55 +03:00
HandleRadioAffirmative(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_ENEMY_SPOTTED:
2017-11-22 20:27:55 +03:00
HandleRadioEnemySpotted(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_NEED_BACKUP:
2017-11-22 20:27:55 +03:00
HandleRadioNeedBackup(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_SECTOR_CLEAR:
2017-11-22 20:27:55 +03:00
HandleRadioSectorClear(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_IN_POSITION:
2017-11-22 20:27:55 +03:00
HandleRadioInPosition(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_REPORTING_IN:
2017-11-22 20:27:55 +03:00
HandleRadioReportingIn(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_GET_OUT_OF_THERE:
2017-11-22 20:27:55 +03:00
HandleRadioGetOutOfThere(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_NEGATIVE:
2017-11-22 20:27:55 +03:00
HandleRadioNegative(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
case EVENT_RADIO_ENEMY_DOWN:
2017-11-22 20:27:55 +03:00
HandleRadioEnemyDown(pEntity, pOther);
2015-08-20 13:35:01 +03:00
break;
default:
break;
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleWeaponFired(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer || !pLocalPlayer->IsAlive())
return;
2017-11-22 20:27:55 +03:00
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
2017-10-12 17:50:56 +03:00
if (pPlayer && pPlayer == pLocalPlayer)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CheckForNeedToReload();
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleWeaponFiredOnEmpty(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return;
2017-11-22 20:27:55 +03:00
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
2017-10-12 17:50:56 +03:00
if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayerWeapon *pCurrentWeapon = static_cast<CBasePlayerWeapon *>(pPlayer->m_pActiveItem);
if (pCurrentWeapon && pPlayer->m_rgAmmo[pCurrentWeapon->m_iPrimaryAmmoType] <= 0)
2015-08-20 13:35:01 +03:00
{
TutorMessage *message = GetTutorMessageDefinition(YOU_ARE_OUT_OF_AMMO);
if (message)
2015-08-20 13:35:01 +03:00
{
message->m_lastCloseTime = 0;
2015-08-20 13:35:01 +03:00
}
CreateAndAddEventToList(YOU_ARE_OUT_OF_AMMO);
2015-08-20 13:35:01 +03:00
}
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleWeaponReloaded(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
2017-10-12 17:50:56 +03:00
if (pPlayer && pPlayer->IsPlayer() && pPlayer == UTIL_GetLocalPlayer())
2015-08-20 13:35:01 +03:00
{
CancelEvent(YOU_SHOULD_RELOAD);
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandlePlayerDied(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
2015-08-20 13:35:01 +03:00
return;
2017-11-22 20:27:55 +03:00
CBasePlayer *pVictim = static_cast<CBasePlayer *>(pEntity);
CBasePlayer *pAttacker = static_cast<CBasePlayer *>(pOther);
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
if (pVictim && !pVictim->IsPlayer())
{
pVictim = nullptr;
}
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
if (pAttacker && !pAttacker->IsPlayer())
{
pAttacker = nullptr;
}
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
if (pVictim == pLocalPlayer && !pAttacker)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (pLocalPlayer->m_bKilledByBomb)
2015-08-20 13:35:01 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(YOU_DIED, pEntity, pOther);
2015-08-20 13:35:01 +03:00
}
else
{
CreateAndAddEventToList(YOU_FELL_TO_YOUR_DEATH);
}
}
2017-10-12 17:50:56 +03:00
if (!pVictim || !pAttacker)
2015-08-20 13:35:01 +03:00
return;
2017-10-12 17:50:56 +03:00
if (pVictim == pAttacker && pVictim == pLocalPlayer)
2015-08-20 13:35:01 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(YOU_DIED, pEntity, pOther);
2015-08-20 13:35:01 +03:00
return;
}
int numT, numCT;
GetNumPlayersAliveOnTeams(numT, numCT);
2017-10-12 17:50:56 +03:00
if (pAttacker == pLocalPlayer)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (pVictim->m_iTeam == pAttacker->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(YOU_KILLED_A_TEAMMATE, pEntity, pOther);
2015-08-20 13:35:01 +03:00
return;
}
2017-10-12 17:50:56 +03:00
if (pVictim->m_bHeadshotKilled)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
switch (pAttacker->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case CT:
{
switch (numT)
2015-08-20 13:35:01 +03:00
{
2017-11-22 20:27:55 +03:00
case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY_HEADSHOT, pEntity, pOther); break;
case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT, pEntity, pOther); break;
default: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT, pEntity, pOther); break;
2015-08-20 13:35:01 +03:00
}
2017-10-12 17:50:56 +03:00
break;
}
case TERRORIST:
{
switch (numCT)
2015-08-20 13:35:01 +03:00
{
2017-11-22 20:27:55 +03:00
case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY_HEADSHOT, pEntity, pOther); break;
case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT, pEntity, pOther); break;
default: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT, pEntity, pOther); break;
2015-08-20 13:35:01 +03:00
}
2017-10-12 17:50:56 +03:00
break;
}
2015-08-20 13:35:01 +03:00
}
}
else
{
2017-10-12 17:50:56 +03:00
switch (pAttacker->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case CT:
{
switch (numT)
2015-08-20 13:35:01 +03:00
{
2017-11-22 20:27:55 +03:00
case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY, pEntity, pOther); break;
case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_ONE_LEFT, pEntity, pOther); break;
default: CreateAndAddEventToList(YOU_KILLED_PLAYER, pEntity, pOther); break;
2015-08-20 13:35:01 +03:00
}
2017-10-12 17:50:56 +03:00
break;
}
case TERRORIST:
{
switch (numCT)
2015-08-20 13:35:01 +03:00
{
2017-11-22 20:27:55 +03:00
case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY, pEntity, pOther); break;
case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_ONE_LEFT, pEntity, pOther); break;
default: CreateAndAddEventToList(YOU_KILLED_PLAYER, pEntity, pOther); break;
2015-08-20 13:35:01 +03:00
}
2017-10-12 17:50:56 +03:00
break;
}
2015-08-20 13:35:01 +03:00
}
}
}
2017-10-12 17:50:56 +03:00
else if (pVictim == pLocalPlayer)
2015-08-20 13:35:01 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(pVictim->m_bHeadshotKilled ? YOU_DIED_HEADSHOT : YOU_DIED, pEntity, pOther);
2015-08-20 13:35:01 +03:00
}
2017-10-12 17:50:56 +03:00
else if (pVictim->m_iTeam == pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
switch (pVictim->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case CT:
{
if (pLocalPlayer->IsAlive())
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (numCT == 1)
2015-08-20 13:35:01 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(LAST_TEAMMATE_KILLED, pEntity, pOther);
2017-10-12 17:50:56 +03:00
}
else if (numCT == 2)
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, pEntity, pOther);
2015-08-20 13:35:01 +03:00
}
else
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(TEAMMATE_KILLED, pEntity, pOther);
2015-08-20 13:35:01 +03:00
}
}
2017-10-12 17:50:56 +03:00
else
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (numCT == 1)
2015-08-20 13:35:01 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, pEntity, pOther);
2015-08-20 13:35:01 +03:00
}
2017-10-12 17:50:56 +03:00
else if (numCT > 1)
2015-08-20 13:35:01 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(TEAMMATE_KILLED, pEntity, pOther);
2015-08-20 13:35:01 +03:00
}
}
2017-10-12 17:50:56 +03:00
break;
2015-08-20 13:35:01 +03:00
}
2017-10-12 17:50:56 +03:00
case TERRORIST:
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (pLocalPlayer->IsAlive())
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (numT == 1)
2015-08-20 13:35:01 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(LAST_TEAMMATE_KILLED, pEntity, pOther);
2017-10-12 17:50:56 +03:00
}
else if (numT == 2)
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, pEntity, pOther);
2017-10-12 17:50:56 +03:00
}
else
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(TEAMMATE_KILLED, pEntity, pOther);
2015-08-20 13:35:01 +03:00
}
}
2017-10-12 17:50:56 +03:00
else
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (numT == 1)
2015-08-20 13:35:01 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, pEntity, pOther);
2017-10-12 17:50:56 +03:00
}
else if (numT > 1)
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(TEAMMATE_KILLED, pEntity, pOther);
2015-08-20 13:35:01 +03:00
}
}
2017-10-12 17:50:56 +03:00
break;
}
}
}
else
{
switch (pLocalPlayer->m_iTeam)
{
case CT:
{
switch (numT)
{
2017-11-22 20:27:55 +03:00
case 0: CreateAndAddEventToList(LAST_ENEMY_KILLED, pEntity, pOther); break;
case 1: CreateAndAddEventToList(ENEMY_KILLED_ONE_LEFT, pEntity, pOther); break;
default: CreateAndAddEventToList(ENEMY_KILLED, pEntity, pOther); break;
2017-10-12 17:50:56 +03:00
}
break;
}
case TERRORIST:
{
switch (numCT)
{
2017-11-22 20:27:55 +03:00
case 0: CreateAndAddEventToList(LAST_ENEMY_KILLED, pEntity, pOther); break;
case 1: CreateAndAddEventToList(ENEMY_KILLED_ONE_LEFT, pEntity, pOther); break;
default: CreateAndAddEventToList(ENEMY_KILLED, pEntity, pOther); break;
2017-10-12 17:50:56 +03:00
}
break;
}
2015-08-20 13:35:01 +03:00
}
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandlePlayerTookDamage(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return;
2015-08-20 13:35:01 +03:00
2017-11-22 20:27:55 +03:00
CBasePlayer *pVictim = static_cast<CBasePlayer *>(pEntity);
CBasePlayer *pAttacker = static_cast<CBasePlayer *>(pOther);
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
if (pVictim && !pVictim->IsPlayer())
{
2017-10-12 17:50:56 +03:00
pVictim = nullptr;
}
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
if (pAttacker && !pAttacker->IsPlayer())
{
2017-10-12 17:50:56 +03:00
pAttacker = nullptr;
}
2017-10-12 17:50:56 +03:00
if (pVictim && pVictim == pLocalPlayer)
{
CreateAndAddEventToList(YOU_WERE_JUST_HURT);
}
2017-10-12 17:50:56 +03:00
else if (pAttacker && pVictim && pAttacker == pLocalPlayer && pVictim->m_iTeam == pLocalPlayer->m_iTeam)
{
CreateAndAddEventToList(YOU_ATTACKED_TEAMMATE);
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandlePlayerBlindedByFlashbang(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return;
2015-08-20 13:35:01 +03:00
2017-11-22 20:27:55 +03:00
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
2017-10-12 17:50:56 +03:00
if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer)
{
CreateAndAddEventToList(YOU_ARE_BLIND_FROM_FLASHBANG);
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandlePlayerSpawned(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
2017-10-12 17:50:56 +03:00
if (!pPlayer || !pPlayer->IsPlayer() || pPlayer != UTIL_GetLocalPlayer())
return;
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
m_haveSpawned = true;
m_lastInGameHintShown = INGAME_HINT_BEGIN;
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(YOU_SPAWNED, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
NOXREF void CCSTutor::HandleClientCorpseSpawned(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
2017-10-12 17:50:56 +03:00
if (!pPlayer || !pPlayer->IsPlayer())
2015-08-20 13:35:01 +03:00
return;
ClientCorpseStruct *corpse = new ClientCorpseStruct;
2017-10-12 17:50:56 +03:00
corpse->m_position = pPlayer->pev->origin;
corpse->m_team = pPlayer->m_iTeam;
2015-08-20 13:35:01 +03:00
m_clientCorpseList.push_back(corpse);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleBuyMenuOpenned(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
if (m_currentlyShownMessageID == BUY_TIME_BEGIN)
{
ClearCurrentEvent();
CheckBuyZoneMessages();
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleAutoBuy(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
if (m_currentlyShownMessageID == BUY_TIME_BEGIN)
{
ClearCurrentEvent();
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
NOXREF void CCSTutor::HandleBuyTimeStart(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
;
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandlePlayerLeftBuyZone(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
m_messageTypeMask = (TUTORMESSAGETYPE_DEFAULT | TUTORMESSAGETYPE_FRIEND_DEATH | TUTORMESSAGETYPE_ENEMY_DEATH | TUTORMESSAGETYPE_SCENARIO | TUTORMESSAGETYPE_CAREER | TUTORMESSAGETYPE_INGAME_HINT | TUTORMESSAGETYPE_END_GAME);
ClearEventList();
ClearCurrentEvent();
if (m_lastScenarioEvent)
2015-08-20 13:35:01 +03:00
{
m_lastScenarioEvent->SetActivationTime(gpGlobals->time);
AddToEventList(m_lastScenarioEvent);
2017-10-12 17:50:56 +03:00
m_lastScenarioEvent = nullptr;
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleBombPlanted(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
2015-08-20 13:35:01 +03:00
return;
2017-10-12 17:50:56 +03:00
if (pLocalPlayer->IsAlive() && pLocalPlayer->m_iTeam == CT)
2015-08-20 13:35:01 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(BOMB_PLANTED_CT, pEntity, pOther);
2015-08-20 13:35:01 +03:00
}
else
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(BOMB_PLANTED_T, pEntity, pOther);
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleBombDefused(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return;
2015-08-20 13:35:01 +03:00
2017-11-22 20:27:55 +03:00
CBasePlayer *pDefuser = static_cast<CBasePlayer *>(pEntity);
2017-10-12 17:50:56 +03:00
if (pDefuser && pDefuser->IsPlayer() && pDefuser == pLocalPlayer)
{
CreateAndAddEventToList(YOU_DEFUSED_BOMB);
2017-10-12 17:50:56 +03:00
return;
}
2017-10-12 17:50:56 +03:00
switch (pLocalPlayer->m_iTeam)
{
2017-10-12 17:50:56 +03:00
case CT: CreateAndAddEventToList(BOMB_DEFUSED_CT); break;
case TERRORIST: CreateAndAddEventToList(BOMB_DEFUSED_T); break;
default: CreateAndAddEventToList(ROUND_OVER); break;
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleBombDefusing(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return;
2015-08-20 13:35:01 +03:00
2017-11-22 20:27:55 +03:00
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
2017-10-12 17:50:56 +03:00
if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer && !pPlayer->m_bHasDefuser)
{
CreateAndAddEventToList(DEFUSING_WITHOUT_KIT);
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleBombExploded(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return;
2017-10-12 17:50:56 +03:00
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case CT: CreateAndAddEventToList(BOMB_EXPLODED_CT); break;
case TERRORIST: CreateAndAddEventToList(BOMB_EXPLODED_T); break;
default: break;
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRoundStart(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
2015-08-20 13:35:01 +03:00
m_roundStartTime = gpGlobals->time;
2017-10-12 17:50:56 +03:00
if (!pLocalPlayer)
return;
if (IsBombMap())
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
case CT:
CreateAndAddEventToList(ROUND_START_DE_CT);
break;
case TERRORIST:
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (pLocalPlayer->m_bHasC4)
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(YOU_ARE_BOMB_CARRIER, pEntity, pOther);
else
CreateAndAddEventToList(ROUND_START_DE_T);
break;
}
2015-08-20 13:35:01 +03:00
}
}
else if (IsHostageMap())
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case CT: CreateAndAddEventToList(ROUND_START_CS_CT); break;
case TERRORIST: CreateAndAddEventToList(ROUND_START_CS_T); break;
2015-08-20 13:35:01 +03:00
}
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleBeingShotAt(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return;
2015-08-20 13:35:01 +03:00
2017-11-22 20:27:55 +03:00
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
2017-10-12 17:50:56 +03:00
if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer && pLocalPlayer->IsAlive())
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(YOU_HAVE_BEEN_SHOT_AT, pEntity, pOther);
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleHostageUsed(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return;
2017-11-22 20:27:55 +03:00
CBasePlayer *pActivator = static_cast<CBasePlayer *>(pEntity);
2017-10-12 17:50:56 +03:00
if (pActivator && pActivator->IsPlayer())
2015-08-20 13:35:01 +03:00
{
bool unusedHostages = !CheckForAllHostagesFollowingSomeone();
2017-10-12 17:50:56 +03:00
if (pActivator == pLocalPlayer)
{
CreateAndAddEventToList(unusedHostages ? YOU_USED_HOSTAGE_MORE_LEFT : YOU_USED_HOSTAGE_NO_MORE_LEFT);
}
else if (!unusedHostages)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case CT: CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_CT); break;
case TERRORIST: CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_T); break;
2015-08-20 13:35:01 +03:00
}
}
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleHostageRescued(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return;
2017-11-22 20:27:55 +03:00
CBasePlayer *pRescuer = static_cast<CBasePlayer *>(pEntity);
2017-10-12 17:50:56 +03:00
if (pRescuer && pRescuer->IsPlayer())
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case CT: CreateAndAddEventToList((pLocalPlayer == pRescuer) ? YOU_RESCUED_HOSTAGE : HOSTAGE_RESCUED_CT); break;
case TERRORIST: CreateAndAddEventToList(HOSTAGE_RESCUED_T); break;
2015-08-20 13:35:01 +03:00
}
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleAllHostagesRescued(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return;
2017-10-12 17:50:56 +03:00
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case CT: CreateAndAddEventToList(ALL_HOSTAGES_RESCUED_CT); break;
case TERRORIST: CreateAndAddEventToList(ALL_HOSTAGES_RESCUED_T); break;
}
}
2015-08-20 13:35:01 +03:00
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleHostageDamaged(CBaseEntity *pEntity, CBaseEntity *pOther)
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return;
2017-11-22 20:27:55 +03:00
CBasePlayer *pAttacker = static_cast<CBasePlayer *>(pOther);
if (pEntity && pAttacker && pAttacker->IsPlayer() && pLocalPlayer == pAttacker)
{
CreateAndAddEventToList(YOU_DAMAGED_HOSTAGE);
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleHostageKilled(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return;
2015-08-20 13:35:01 +03:00
CheckForAllHostagesDead();
2015-08-20 13:35:01 +03:00
2017-11-22 20:27:55 +03:00
CBasePlayer *pAttacker = static_cast<CBasePlayer *>(pOther);
if (pEntity && pAttacker && pAttacker->IsPlayer())
{
bool unusedHostages = CheckForAllHostagesFollowingSomeone();
2017-10-12 17:50:56 +03:00
if (pLocalPlayer == pAttacker)
{
CreateAndAddEventToList(YOU_KILLED_HOSTAGE);
}
2015-08-20 13:35:01 +03:00
if (unusedHostages)
{
2017-10-12 17:50:56 +03:00
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case CT: CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_CT); break;
case TERRORIST: CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_T); break;
2015-08-20 13:35:01 +03:00
}
}
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRoundDraw(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
if (CSGameRules()->m_iTotalRoundsPlayed)
2015-08-20 13:35:01 +03:00
{
CreateAndAddEventToList(ROUND_DRAW);
}
ResetPlayerDeathInfo();
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleCTWin(CBaseEntity *entith, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
CreateAndAddEventToList(CT_WIN);
ResetPlayerDeathInfo();
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleTWin(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
CreateAndAddEventToList(T_WIN);
ResetPlayerDeathInfo();
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleDeathCameraStart(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return;
2015-08-20 13:35:01 +03:00
2017-11-22 20:27:55 +03:00
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
2017-10-12 17:50:56 +03:00
if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer)
{
m_messageTypeMask = (TUTORMESSAGETYPE_FRIEND_DEATH | TUTORMESSAGETYPE_ENEMY_DEATH | TUTORMESSAGETYPE_HINT | TUTORMESSAGETYPE_END_GAME);
CreateAndAddEventToList(DEATH_CAMERA_START);
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioCoverMe(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_COVER_ME, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioYouTakeThePoint(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_YOU_TAKE_THE_POINT, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioHoldThisPosition(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_HOLD_THIS_POSITION, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioRegroupTeam(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_REGROUP_TEAM, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioFollowMe(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_FOLLOW_ME, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioTakingFire(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_TAKING_FIRE, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioGoGoGo(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_GO_GO_GO, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioTeamFallBack(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_TEAM_FALL_BACK, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioStickTogetherTeam(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_STICK_TOGETHER_TEAM, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioGetInPositionAndWait(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_GET_IN_POSITION_AND_WAIT, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioStormTheFront(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_STORM_THE_FRONT, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioReportInTeam(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_REPORT_IN_TEAM, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioAffirmative(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_AFFIRMATIVE, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioEnemySpotted(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_ENEMY_SPOTTED, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioNeedBackup(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_NEED_BACKUP, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioSectorClear(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_SECTOR_CLEAR, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioInPosition(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_IN_POSITION, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioReportingIn(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_REPORTING_IN, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioGetOutOfThere(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_GET_OUT_OF_THERE, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioNegative(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_NEGATIVE, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleRadioEnemyDown(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(RADIO_ENEMY_DOWN, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleNotBuyingAnything(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(BUY_TIME_BEGIN, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleNeedToBuyPrimaryWeapon(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(BUY_NEED_PRIMARY, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleNeedToBuyPrimaryAmmo(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(BUY_NEED_PRIMARY_AMMO, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleNeedToBuySecondaryAmmo(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(BUY_NEED_SECONDARY_AMMO, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleNeedToBuyArmor(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(BUY_NEED_ARMOR, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleNeedToBuyDefuseKit(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(BUY_NEED_DEFUSE_KIT, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleNeedToBuyGrenade(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2017-11-22 20:27:55 +03:00
CreateAndAddEventToList(BUY_NEED_GRENADE, pEntity, pOther);
2015-06-30 12:46:07 +03:00
}
2017-11-22 20:27:55 +03:00
void CCSTutor::HandleCareerTaskDone(CBaseEntity *pEntity, CBaseEntity *pOther)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
int numTasksRemaining = 0;
if (TheCareerTasks && (numTasksRemaining = TheCareerTasks->GetNumRemainingTasks()) > 0)
2015-08-20 13:35:01 +03:00
CreateAndAddEventToList((numTasksRemaining == 1) ? CAREER_TASK_DONE_ONE_LEFT : CAREER_TASK_DONE_MORE_LEFT);
else
CreateAndAddEventToList(CAREER_TASK_DONE_ALL_DONE);
2015-06-30 12:46:07 +03:00
}
void CCSTutor::HandleShotFired(Vector source, Vector target)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return;
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
float d1, d, angle, flFiringLineDistanceToPlayer;
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
d1 = (source - pLocalPlayer->pev->origin).Length();
2015-08-20 13:35:01 +03:00
if (d1 > 32.0f)
{
d = (target - source).Length();
angle = d1 / d;
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
flFiringLineDistanceToPlayer = Q_sin(Q_acos(angle)) * d1;
2017-10-12 17:50:56 +03:00
if (flFiringLineDistanceToPlayer <= 3000.0f)
{
2017-10-12 17:50:56 +03:00
OnEvent(EVENT_BEING_SHOT_AT, pLocalPlayer);
2015-08-20 13:35:01 +03:00
}
}
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void CCSTutor::GetNumPlayersAliveOnTeams(int &numT, int &numCT)
2015-06-30 12:46:07 +03:00
{
numT = numCT = 0;
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
for (int i = 1; i <= gpGlobals->maxClients; i++)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!pPlayer || !pPlayer->IsAlive())
2015-08-20 13:35:01 +03:00
continue;
2017-10-12 17:50:56 +03:00
switch (pPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case CT: numCT++; break;
case TERRORIST: numT++; break;
2015-08-20 13:35:01 +03:00
}
}
2015-06-30 12:46:07 +03:00
}
void CCSTutor::CheckForLooseWeaponViewable()
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
return;
2015-08-20 13:35:01 +03:00
TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_LOOSE_WEAPON);
if (message && message->m_class == TUTORMESSAGECLASS_EXAMINE)
return;
2017-10-12 17:50:56 +03:00
CBaseEntity *weapon = nullptr;
while ((weapon = UTIL_FindEntityByClassname(weapon, "weaponbox")))
{
2017-10-12 17:50:56 +03:00
if (IsEntityInViewOfPlayer(weapon, pLocalPlayer))
2015-08-20 13:35:01 +03:00
{
CreateAndAddEventToList(YOU_SEE_LOOSE_WEAPON);
break;
2015-08-20 13:35:01 +03:00
}
}
2015-06-30 12:46:07 +03:00
}
void CCSTutor::CheckForLooseDefuserViewable()
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer || pLocalPlayer->m_iTeam != CT)
return;
2015-08-20 13:35:01 +03:00
TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_LOOSE_DEFUSER);
if (message && message->m_class == TUTORMESSAGECLASS_EXAMINE)
return;
2017-10-12 17:50:56 +03:00
CBaseEntity *pDefuser = nullptr;
while ((pDefuser = UTIL_FindEntityByClassname(pDefuser, "item_thighpack")))
{
2017-10-12 17:50:56 +03:00
if (IsEntityInViewOfPlayer(pDefuser, pLocalPlayer))
2015-08-20 13:35:01 +03:00
{
CreateAndAddEventToList(YOU_SEE_LOOSE_DEFUSER);
break;
2015-08-20 13:35:01 +03:00
}
}
2015-06-30 12:46:07 +03:00
}
void CCSTutor::CheckForBombViewable()
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
2015-08-20 13:35:01 +03:00
return;
2017-10-12 17:50:56 +03:00
CGrenade *pBomb = (CGrenade *)UTIL_FindEntityByClassname(nullptr, "grenade");
if (pBomb && pBomb->m_bIsC4 && IsEntityInViewOfPlayer(pBomb, pLocalPlayer))
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
TutorMessageID mid = TUTOR_NUM_MESSAGES;
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case CT:
{
mid = YOU_SEE_PLANTED_BOMB_CT;
break;
}
case TERRORIST:
{
mid = YOU_SEE_PLANTED_BOMB_T;
break;
}
}
if (mid != TUTOR_NUM_MESSAGES)
{
TutorMessage *message = GetTutorMessageDefinition(mid);
if (!message || message->m_class != TUTORMESSAGECLASS_EXAMINE)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CreateAndAddEventToList(mid);
2015-08-20 13:35:01 +03:00
}
}
}
else
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pBombCarrier = nullptr;
for (int i = 1; i <= gpGlobals->maxClients; i++)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (pPlayer && pPlayer->m_bHasC4)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
pBombCarrier = pPlayer;
2015-08-20 13:35:01 +03:00
break;
}
}
2017-10-12 17:50:56 +03:00
CBaseEntity *pC4 = UTIL_FindEntityByClassname(nullptr, "weapon_c4");
if (pC4 && IsEntityInViewOfPlayer(pC4, pLocalPlayer))
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (pBombCarrier)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (pBombCarrier != pLocalPlayer)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
case CT:
{
TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_BOMB_CARRIER_CT);
if (!message || message->m_class != TUTORMESSAGECLASS_EXAMINE)
2015-08-20 13:35:01 +03:00
{
CreateAndAddEventToList(YOU_SEE_BOMB_CARRIER_CT);
2015-08-20 13:35:01 +03:00
}
break;
}
case TERRORIST:
{
TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_BOMB_CARRIER_T);
if (!message || message->m_class != TUTORMESSAGECLASS_EXAMINE)
2015-08-20 13:35:01 +03:00
{
CreateAndAddEventToList(YOU_SEE_BOMB_CARRIER_T);
2015-08-20 13:35:01 +03:00
}
break;
}
2015-08-20 13:35:01 +03:00
}
}
}
else
{
2017-10-12 17:50:56 +03:00
TutorMessageID mid = TUTOR_NUM_MESSAGES;
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
case CT:
{
mid = YOU_SEE_LOOSE_BOMB_CT;
break;
}
case TERRORIST:
{
mid = YOU_SEE_LOOSE_BOMB_T;
break;
}
}
if (mid != TUTOR_NUM_MESSAGES)
{
TutorMessage *message = GetTutorMessageDefinition(mid);
if (!message || message->m_class != TUTORMESSAGECLASS_EXAMINE)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CreateAndAddEventToList(mid);
2015-08-20 13:35:01 +03:00
}
}
}
}
}
2015-06-30 12:46:07 +03:00
}
void CCSTutor::CheckForBombsiteViewable()
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
2015-08-20 13:35:01 +03:00
return;
TutorMessageID mid = CheckForInBombZone();
2017-10-12 17:50:56 +03:00
if (mid != TUTOR_NUM_MESSAGES)
{
CreateAndAddEventToList(mid);
return;
}
switch (pLocalPlayer->m_iTeam)
{
case CT:
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
mid = YOU_SEE_BOMBSITE_CT;
break;
}
case TERRORIST:
{
if (pLocalPlayer->m_bHasC4)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
mid = YOU_SEE_BOMBSITE_T_BOMB;
2015-08-20 13:35:01 +03:00
}
2017-10-12 17:50:56 +03:00
else if (!TheCSBots() || !TheCSBots()->IsBombPlanted())
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
mid = YOU_SEE_BOMBSITE_T;
}
break;
}
}
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
TutorMessage *definition = GetTutorMessageDefinition(mid);
if (!definition || definition->m_class != TUTORMESSAGECLASS_EXAMINE)
{
if (IsBombPlantedInBombZone("func_bomb_target")
|| IsBombPlantedInBombZone("info_bomb_target"))
{
CreateAndAddEventToList(mid);
return;
2015-08-20 13:35:01 +03:00
}
}
2015-06-30 12:46:07 +03:00
}
TutorMessageID CCSTutor::CheckForInBombZone()
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (pLocalPlayer && pLocalPlayer->m_iTeam == CT)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (IsBombPlantedInBombZone("func_bomb_target")
|| IsBombPlantedInBombZone("info_bomb_target"))
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
return YOU_SEE_PLANTED_BOMB_CT;
2015-08-20 13:35:01 +03:00
}
2017-10-12 17:50:56 +03:00
}
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
return TUTOR_NUM_MESSAGES;
}
bool CCSTutor::IsBombPlantedInBombsite(CBaseEntity *bombTarget)
{
CGrenade *pBomb = nullptr;
2017-11-22 20:27:55 +03:00
while ((pBomb = UTIL_FindEntityByClassname(pBomb, "grenade")))
2017-10-12 17:50:56 +03:00
{
if (pBomb->m_bIsC4 && IsEntityInBombsite(pBomb, bombTarget))
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
return true;
2015-08-20 13:35:01 +03:00
}
}
2017-10-12 17:50:56 +03:00
return false;
2015-06-30 12:46:07 +03:00
}
2017-10-12 17:50:56 +03:00
bool CCSTutor::IsBombPlantedInBombZone(const char *pszBombZone)
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
CBaseEntity *bombSite = nullptr;
while ((bombSite = UTIL_FindEntityByClassname(bombSite, pszBombZone)))
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (IsBombPlantedInBombsite(bombSite))
2015-08-20 13:35:01 +03:00
{
return true;
}
}
return false;
2015-06-30 12:46:07 +03:00
}
void CCSTutor::CheckForHostageViewable()
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
2015-08-20 13:35:01 +03:00
return;
2017-10-12 17:50:56 +03:00
CBaseEntity *pHostageEntity = nullptr;
while ((pHostageEntity = UTIL_FindEntityByClassname(pHostageEntity, "hostage_entity")))
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
bool bValidHostage = false;
CHostage *pHostage = static_cast<CHostage *>(pHostageEntity);
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
if (pHostage->IsAlive())
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (!pHostage->IsFollowingSomeone())
{
bValidHostage = true;
}
2015-08-20 13:35:01 +03:00
}
2017-10-12 17:50:56 +03:00
if (bValidHostage && IsEntityInViewOfPlayer(pHostage, pLocalPlayer))
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
TutorMessageID mid = TUTOR_NUM_MESSAGES;
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
case CT:
{
2017-10-12 17:50:56 +03:00
mid = YOU_SEE_HOSTAGE_CT;
break;
}
case TERRORIST:
{
2017-10-12 17:50:56 +03:00
mid = YOU_SEE_HOSTAGE_T;
break;
}
2015-08-20 13:35:01 +03:00
}
2017-10-12 17:50:56 +03:00
if (mid != TUTOR_NUM_MESSAGES)
{
TutorMessage *message = GetTutorMessageDefinition(mid);
if (!message || message->m_class != TUTORMESSAGECLASS_EXAMINE)
{
CreateAndAddEventToList(mid);
}
}
break;
2015-08-20 13:35:01 +03:00
}
}
2015-06-30 12:46:07 +03:00
}
void CCSTutor::CheckForTimeRunningOut()
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer || CSGameRules()->IsFreezePeriod() || CSGameRules()->GetRoundRemainingTime() > 30.0f)
2015-08-20 13:35:01 +03:00
return;
if (IsBombMap())
{
2017-10-12 17:50:56 +03:00
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
case CT:
CreateAndAddEventToList(TIME_RUNNING_OUT_DE_CT);
break;
case TERRORIST:
CreateAndAddEventToList(TIME_RUNNING_OUT_DE_T);
break;
}
}
else if (IsHostageMap())
{
2017-10-12 17:50:56 +03:00
switch (pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
{
case CT:
CreateAndAddEventToList(TIME_RUNNING_OUT_CS_CT);
break;
case TERRORIST:
CreateAndAddEventToList(TIME_RUNNING_OUT_CS_T);
break;
}
}
2015-06-30 12:46:07 +03:00
}
void CCSTutor::CheckForAllHostagesDead()
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
bool foundLiveOne = false;
2017-10-12 17:50:56 +03:00
CHostage *pHostage = nullptr;
2015-08-20 13:35:01 +03:00
2017-11-22 20:27:55 +03:00
while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")))
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (pHostage->IsAlive())
2015-08-20 13:35:01 +03:00
{
foundLiveOne = true;
break;
}
}
if (!foundLiveOne)
{
CreateAndAddEventToList(ALL_HOSTAGES_DEAD);
}
2015-06-30 12:46:07 +03:00
}
bool CCSTutor::CheckForAllHostagesFollowingSomeone()
2015-08-20 13:35:01 +03:00
{
bool foundUnusedOne = false;
2017-10-12 17:50:56 +03:00
CHostage *pHostage = nullptr;
2015-08-20 13:35:01 +03:00
2017-11-22 20:27:55 +03:00
while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")))
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (pHostage->IsAlive())
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (!pHostage->IsFollowingSomeone())
2015-08-20 13:35:01 +03:00
{
foundUnusedOne = true;
break;
}
}
}
return foundUnusedOne ? false : true;
2015-06-30 12:46:07 +03:00
}
TutorMessage *CCSTutor::GetTutorMessageDefinition(int messageID)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
if (messageID < 0 || messageID >= TUTOR_NUM_MESSAGES)
2017-10-12 17:50:56 +03:00
return nullptr;
2015-08-20 13:35:01 +03:00
TutorMessageMapIter iter = m_messageMap.find(m_TutorIdentifierList[messageID]);
2015-08-20 13:35:01 +03:00
if (iter != m_messageMap.end())
{
return (*iter).second;
}
2017-10-12 17:50:56 +03:00
return nullptr;
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
CBaseEntity *CCSTutor::GetEntityForMessageID(int messageID, CBaseEntity *last)
{
2017-10-12 17:50:56 +03:00
CBaseEntity *pEntity = nullptr;
2015-08-20 13:35:01 +03:00
switch (messageID)
{
case YOU_SEE_FRIEND:
case YOU_SEE_ENEMY:
2017-10-12 17:50:56 +03:00
pEntity = UTIL_FindEntityByClassname(last, "player");
2015-08-20 13:35:01 +03:00
break;
case YOU_SEE_FRIEND_CORPSE:
{
// TODO: this code is noxref
// this code fucked my brain, in that pointer Vector * is passed through the CBaseEntity *
#if 1
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (pLocalPlayer)
2015-08-20 13:35:01 +03:00
{
if (m_clientCorpseList.empty())
2017-10-12 17:50:56 +03:00
return nullptr;
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
ClientCorpseStruct *lastCorpse = nullptr;
2015-08-20 13:35:01 +03:00
ClientCorpseListIter iter;
if (last)
2015-08-20 13:35:01 +03:00
{
iter = m_clientCorpseList.begin();
while (iter != m_clientCorpseList.end())
{
lastCorpse = (*iter);
if ((CBaseEntity *)lastCorpse == last)
break;
2017-10-12 17:50:56 +03:00
iter++;
2015-08-20 13:35:01 +03:00
}
while (iter != m_clientCorpseList.end())
{
ClientCorpseStruct *corpse = (*iter);
2017-10-12 17:50:56 +03:00
if (corpse->m_team == pLocalPlayer->m_iTeam)
2015-08-20 13:35:01 +03:00
return (CBaseEntity *)&corpse->m_position;
2017-10-12 17:50:56 +03:00
iter++;
2015-08-20 13:35:01 +03:00
}
2017-10-12 17:50:56 +03:00
return nullptr;
2015-08-20 13:35:01 +03:00
}
else
return (CBaseEntity *)&m_clientCorpseList.front()->m_position;
}
#endif
break;
}
case YOU_SEE_LOOSE_BOMB_T:
case YOU_SEE_LOOSE_BOMB_CT:
case YOU_SEE_BOMB_CARRIER_T:
case YOU_SEE_BOMB_CARRIER_CT:
2017-10-12 17:50:56 +03:00
pEntity = UTIL_FindEntityByClassname(last, "weapon_c4");
2015-08-20 13:35:01 +03:00
break;
case YOU_SEE_PLANTED_BOMB_T:
case YOU_SEE_PLANTED_BOMB_CT:
2017-10-12 17:50:56 +03:00
pEntity = UTIL_FindEntityByClassname(last, "grenade");
2015-08-20 13:35:01 +03:00
break;
case YOU_SEE_LOOSE_WEAPON:
2017-10-12 17:50:56 +03:00
pEntity = UTIL_FindEntityByClassname(last, "weaponbox");
2015-08-20 13:35:01 +03:00
break;
case YOU_SEE_LOOSE_DEFUSER:
2017-10-12 17:50:56 +03:00
pEntity = UTIL_FindEntityByClassname(last, "item_thighpack");
2015-08-20 13:35:01 +03:00
break;
case YOU_SEE_HOSTAGE_T:
case YOU_SEE_HOSTAGE_CT:
case YOU_SEE_HOSTAGE_CT_EXAMINE:
2017-10-12 17:50:56 +03:00
pEntity = UTIL_FindEntityByClassname(last, "hostage_entity");
2015-08-20 13:35:01 +03:00
break;
}
2017-10-12 17:50:56 +03:00
return pEntity;
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void CCSTutor::CheckHintMessages(float time)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
if (m_deadAirStartTime <= 0.0f || (time - m_deadAirStartTime <= cv_tutor_hint_interval_time.value))
return;
m_lastHintShown++;
while (true)
2015-08-20 13:35:01 +03:00
{
bool confusingHint = false;
if (IsHostageMap())
2015-08-20 13:35:01 +03:00
{
if (m_lastHintShown >= HINT_BOMB_START && m_lastHintShown <= HINT_BOMB_END)
{
confusingHint = true;
}
2015-08-20 13:35:01 +03:00
}
else if (IsBombMap())
2015-08-20 13:35:01 +03:00
{
if (m_lastHintShown >= HINT_HOSTAGE_START && m_lastHintShown <= HINT_HOSTAGE_END)
2015-08-20 13:35:01 +03:00
{
confusingHint = true;
2015-08-20 13:35:01 +03:00
}
}
if (!confusingHint)
{
break;
}
m_lastHintShown++;
if (m_lastHintShown <= HINT_BEGIN || m_lastHintShown >= HINT_END)
{
m_lastHintShown = HINT_1;
}
2015-08-20 13:35:01 +03:00
}
if (m_lastHintShown <= HINT_BEGIN || m_lastHintShown >= HINT_END)
2015-08-20 13:35:01 +03:00
{
m_lastHintShown = HINT_1;
}
TutorMessage *message = GetTutorMessageDefinition(m_lastHintShown);
if (message)
2015-08-20 13:35:01 +03:00
{
CreateAndAddEventToList(m_lastHintShown);
}
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void CCSTutor::CheckInGameHintMessages(float time)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
if (m_deadAirStartTime <= 0.0f || (time - m_deadAirStartTime <= cv_tutor_hint_interval_time.value))
return;
m_lastInGameHintShown++;
if (m_lastInGameHintShown <= INGAME_HINT_BEGIN || m_lastInGameHintShown >= INGAME_HINT_END)
return;
TutorMessage *message = GetTutorMessageDefinition(m_lastInGameHintShown);
if (message)
2015-08-20 13:35:01 +03:00
{
CreateAndAddEventToList(m_lastInGameHintShown);
}
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void CCSTutor::CheckForNeedToReload(bool isPassiveCheck)
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer || !pLocalPlayer->IsPlayer())
2015-08-20 13:35:01 +03:00
return;
2017-10-12 17:50:56 +03:00
CBasePlayerWeapon *pCurrentWeapon = static_cast<CBasePlayerWeapon *>(pLocalPlayer->m_pActiveItem);
if (!pCurrentWeapon || !pCurrentWeapon->IsWeapon())
2015-08-20 13:35:01 +03:00
return;
2017-10-12 17:50:56 +03:00
ItemInfo itemInfo;
Q_memset(&itemInfo, 0, sizeof(itemInfo));
pCurrentWeapon->GetItemInfo(&itemInfo);
2015-08-20 13:35:01 +03:00
if (itemInfo.iSlot && itemInfo.iSlot != 1)
return;
2017-10-12 17:50:56 +03:00
if (pLocalPlayer->m_rgAmmo[pCurrentWeapon->m_iPrimaryAmmoType])
2015-08-20 13:35:01 +03:00
{
if (isPassiveCheck)
{
2017-10-12 17:50:56 +03:00
if ((2 * pCurrentWeapon->m_iClip) < pCurrentWeapon->iMaxClip() && !pCurrentWeapon->m_fInReload)
2015-08-20 13:35:01 +03:00
{
CreateAndAddEventToList(YOU_SHOULD_RELOAD);
}
}
else
{
2017-10-12 17:50:56 +03:00
if ((5 * pCurrentWeapon->m_iClip) < pCurrentWeapon->iMaxClip() && !pCurrentWeapon->m_fInReload)
2015-08-20 13:35:01 +03:00
{
TutorMessage *message = GetTutorMessageDefinition(YOU_SHOULD_RELOAD);
if (message)
2015-08-20 13:35:01 +03:00
{
message->m_lastCloseTime = 0;
}
CreateAndAddEventToList(YOU_SHOULD_RELOAD);
}
else
{
TutorMessage *message = GetTutorMessageDefinition(YOU_SHOULD_RELOAD);
if (message)
2015-08-20 13:35:01 +03:00
{
message->m_lastCloseTime = gpGlobals->time;
}
}
}
}
2017-10-12 17:50:56 +03:00
else if (!pCurrentWeapon->m_iClip)
2015-08-20 13:35:01 +03:00
{
if (!isPassiveCheck)
{
TutorMessage *message = GetTutorMessageDefinition(YOU_ARE_OUT_OF_AMMO);
if (message)
2015-08-20 13:35:01 +03:00
{
message->m_lastCloseTime = 0;
}
}
CreateAndAddEventToList(YOU_ARE_OUT_OF_AMMO);
}
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void CCSTutor::CheckExamineMessages(float time)
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer)
2015-08-20 13:35:01 +03:00
return;
2017-10-12 17:50:56 +03:00
for (int i = 0; i < TUTOR_NUM_MESSAGES; i++)
2015-08-20 13:35:01 +03:00
{
TutorMessage *message = GetTutorMessageDefinition(i);
2017-10-12 17:50:56 +03:00
if (!message || message->m_class != TUTORMESSAGECLASS_EXAMINE)
2015-08-20 13:35:01 +03:00
continue;
2017-10-12 17:50:56 +03:00
CBaseEntity *pEntity = nullptr;
2015-08-20 13:35:01 +03:00
bool isPlayerLooking = false;
2017-10-12 17:50:56 +03:00
while ((pEntity = GetEntityForMessageID(i, pEntity)))
2015-08-20 13:35:01 +03:00
{
2016-01-25 20:02:57 +03:00
if (i == YOU_SEE_FRIEND_CORPSE || i == YOU_SEE_ENEMY_CORPSE)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (IsPlayerLookingAtPosition((Vector *)pEntity, pLocalPlayer))
2016-01-25 20:02:57 +03:00
{
isPlayerLooking = true;
break;
}
2015-08-20 13:35:01 +03:00
}
2016-01-25 20:02:57 +03:00
else if (i == YOU_SEE_HOSTAGE_CT_EXAMINE || i == YOU_SEE_FRIEND || i == YOU_SEE_ENEMY)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (IsPlayerLookingAtEntity(pEntity, pLocalPlayer))
2016-01-25 20:02:57 +03:00
{
isPlayerLooking = true;
break;
}
2015-08-20 13:35:01 +03:00
}
2017-10-12 17:50:56 +03:00
else if (IsPlayerLookingAtPosition(&pEntity->pev->origin, pLocalPlayer))
2015-08-20 13:35:01 +03:00
{
2016-01-25 20:02:57 +03:00
isPlayerLooking = true;
break;
2015-08-20 13:35:01 +03:00
}
}
2016-01-25 20:02:57 +03:00
if (isPlayerLooking)
2015-08-20 13:35:01 +03:00
{
2016-01-25 20:02:57 +03:00
if (message->m_examineStartTime == -1.0f)
continue;
2015-08-20 13:35:01 +03:00
2016-01-25 20:02:57 +03:00
if (time - message->m_examineStartTime <= cv_tutor_examine_time.value)
continue;
2015-08-20 13:35:01 +03:00
2016-01-25 20:02:57 +03:00
bool validEntity = false;
if (i == YOU_SEE_FRIEND)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
if (pPlayer->IsPlayer() && pPlayer->IsAlive() && pPlayer->m_iTeam == pLocalPlayer->m_iTeam)
{
2015-08-20 13:35:01 +03:00
validEntity = true;
2017-10-12 17:50:56 +03:00
}
2015-08-20 13:35:01 +03:00
}
2016-01-25 20:02:57 +03:00
else if (i == YOU_SEE_ENEMY)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEntity);
if (pPlayer->IsPlayer() && pPlayer->IsAlive() && pPlayer->m_iTeam == pLocalPlayer->m_iTeam)
2016-01-25 20:02:57 +03:00
{
2017-10-12 17:50:56 +03:00
if ((pPlayer->m_iTeam != CT || pLocalPlayer->m_iTeam == TERRORIST) && (pPlayer->m_iTeam != TERRORIST || pLocalPlayer->m_iTeam == CT))
{
2016-01-25 20:02:57 +03:00
validEntity = true;
2017-10-12 17:50:56 +03:00
}
2016-01-25 20:02:57 +03:00
}
2015-08-20 13:35:01 +03:00
}
2016-01-25 20:02:57 +03:00
else if (i == YOU_SEE_HOSTAGE_CT_EXAMINE)
{
2017-10-12 17:50:56 +03:00
CHostage *pHostage = static_cast<CHostage *>(pEntity);
if (pEntity->IsAlive())
2016-01-25 20:02:57 +03:00
{
2017-10-12 17:50:56 +03:00
if (!pHostage->IsFollowingSomeone())
{
2016-01-25 20:02:57 +03:00
validEntity = true;
2017-10-12 17:50:56 +03:00
}
2016-01-25 20:02:57 +03:00
}
}
if (validEntity)
{
2017-10-12 17:50:56 +03:00
CreateAndAddEventToList((TutorMessageID)i, pEntity);
2016-01-25 20:02:57 +03:00
}
2015-08-20 13:35:01 +03:00
}
2016-01-25 20:02:57 +03:00
else
2017-10-12 17:50:56 +03:00
{
2016-01-25 20:02:57 +03:00
message->m_examineStartTime = -1.0f;
2017-10-12 17:50:56 +03:00
}
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
bool CCSTutor::CanLocalPlayerBuyStuff()
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (pLocalPlayer)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
return pLocalPlayer->CanPlayerBuy();
2015-08-20 13:35:01 +03:00
}
return false;
2015-06-30 12:46:07 +03:00
}
void CCSTutor::CheckBuyZoneMessages()
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
if (!pLocalPlayer || m_currentlyShownMessageID == BUY_TIME_BEGIN)
2015-08-20 13:35:01 +03:00
return;
2017-10-12 17:50:56 +03:00
CBasePlayerWeapon *pPrimaryWeapon = static_cast<CBasePlayerWeapon *>(pLocalPlayer->m_rgpPlayerItems[PRIMARY_WEAPON_SLOT]);
CBasePlayerWeapon *pSecondaryWeapon = static_cast<CBasePlayerWeapon *>(pLocalPlayer->m_rgpPlayerItems[PISTOL_SLOT]);
2015-08-20 13:35:01 +03:00
2017-10-12 17:50:56 +03:00
if (pPrimaryWeapon)
2015-08-20 13:35:01 +03:00
{
2017-10-12 17:50:56 +03:00
if (pLocalPlayer->NeedsPrimaryAmmo() && pLocalPlayer->CanAffordPrimaryAmmo())
2015-08-20 13:35:01 +03:00
{
TheTutor->OnEvent(EVENT_TUTOR_NEED_TO_BUY_PRIMARY_AMMO);
return;
}
}
else
{
2017-10-12 17:50:56 +03:00
if (pLocalPlayer->CanAffordPrimary())
2015-08-20 13:35:01 +03:00
{
TheTutor->OnEvent(EVENT_TUTOR_NEED_TO_BUY_PRIMARY_WEAPON);
return;
}
}
2017-10-12 17:50:56 +03:00
if (pSecondaryWeapon && pLocalPlayer->NeedsSecondaryAmmo() && pLocalPlayer->CanAffordSecondaryAmmo())
2015-08-20 13:35:01 +03:00
{
TheTutor->OnEvent(EVENT_TUTOR_NEED_TO_BUY_SECONDARY_AMMO);
}
2017-10-12 17:50:56 +03:00
else if (pLocalPlayer->NeedsArmor() && pLocalPlayer->CanAffordArmor())
2015-08-20 13:35:01 +03:00
{
TheTutor->OnEvent(EVENT_TUTOR_NEED_TO_BUY_ARMOR);
}
2017-10-12 17:50:56 +03:00
else if (pLocalPlayer->NeedsDefuseKit() && pLocalPlayer->CanAffordDefuseKit())
2015-08-20 13:35:01 +03:00
{
TheTutor->OnEvent(EVENT_TUTOR_NEED_TO_BUY_DEFUSE_KIT);
}
2017-10-12 17:50:56 +03:00
else if (pLocalPlayer->NeedsGrenade() && pLocalPlayer->CanAffordGrenade())
2015-08-20 13:35:01 +03:00
{
TheTutor->OnEvent(EVENT_TUTOR_NEED_TO_BUY_GRENADE);
}
else
2017-10-12 17:50:56 +03:00
{
2015-08-20 13:35:01 +03:00
TheTutor->OnEvent(EVENT_TUTOR_NOT_BUYING_ANYTHING);
2017-10-12 17:50:56 +03:00
}
2015-06-30 12:46:07 +03:00
}
bool CCSTutor::IsHostageMap()
2015-06-30 12:46:07 +03:00
{
2017-10-12 17:50:56 +03:00
return UTIL_FindEntityByClassname(nullptr, "hostage_entity") != nullptr;
2015-06-30 12:46:07 +03:00
}
bool CCSTutor::IsBombMap()
2015-06-30 12:46:07 +03:00
{
return CSGameRules()->m_bMapHasBombTarget;
2015-06-30 12:46:07 +03:00
}
void CCSTutor::ResetPlayerDeathInfo()
2015-06-30 12:46:07 +03:00
{
for (auto& playerDeathInfo : m_playerDeathInfo) {
playerDeathInfo.m_hasBeenShown = false;
playerDeathInfo.m_event = nullptr;
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void CCSTutor::ConstructRecentDeathsList(TeamName team, char *buf, int buflen, TutorMessageEvent *event)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
if (!buf || !buflen)
return;
char scratch[32];
buf[0] = '\0';
2017-10-12 17:50:56 +03:00
for (int i = 1; i <= gpGlobals->maxClients; i++)
2015-08-20 13:35:01 +03:00
{
2016-05-31 17:04:51 +03:00
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
2015-08-20 13:35:01 +03:00
if (!pPlayer)
2015-08-20 13:35:01 +03:00
continue;
// ignore alive players
if (pPlayer->IsAlive())
continue;
if (pPlayer->m_iTeam != team)
continue;
Q_strcat(buf, " %n");
Q_sprintf(scratch, "%d\n", i);
Q_strcat(buf, scratch);
m_playerDeathInfo[i].m_event = event;
}
2015-06-30 12:46:07 +03:00
}
2015-08-20 13:35:01 +03:00
void CCSTutor::TransferDeathEvents(TutorMessageEvent *oldEvent, TutorMessageEvent *newEvent)
2015-06-30 12:46:07 +03:00
{
for (auto& playerDeathInfo : m_playerDeathInfo)
2015-08-20 13:35:01 +03:00
{
if (playerDeathInfo.m_event == oldEvent) {
playerDeathInfo.m_event = newEvent;
2015-08-20 13:35:01 +03:00
}
}
2015-06-30 12:46:07 +03:00
}