//=========================================================
//=========================================================
void C_GameInstructor::DumpOpenOpportunities()
{
	ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "GAME INSTRUCTOR: " );
	ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Open lessons...\n" );
 
	for ( int i = m_OpenOpportunities.Count() - 1; i >= 0; --i )
	{
		CBaseLesson *pLesson = m_OpenOpportunities[ i ];
		CBaseLesson *pRootLesson = pLesson->GetRoot();
 
		Color color;
 
		if ( pLesson->IsInstructing() )
		{
			// Green
			color = CBaseLesson::m_rgbaVerboseOpen;
		}
		else if ( pRootLesson->IsLearned() && pLesson->GetPriority() >= m_iCurrentPriority )
		{
			// Yellow
			color = CBaseLesson::m_rgbaVerboseSuccess;
		}
		else
		{
			// Red
			color = CBaseLesson::m_rgbaVerboseClose;
		}
 
		ConColorMsg( color, "\t%s\n", pLesson->GetName() );
	}
}
//=========================================================
// Apaga al instructor
//=========================================================
void C_GameInstructor::Shutdown()
{
	if ( gameinstructor_verbose.GetInt() > 0 )
	{
		ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Shutting down...\n" );
	}
 
	CloseAllOpenOpportunities();
	WriteSaveData();
 
	// Removemos todas las lecciones.
	for ( int i = 0; i < m_Lessons.Count(); ++i )
	{
		if ( m_Lessons[ i ] )
		{
			m_Lessons[ i ]->StopListeningForAllEvents();
			delete m_Lessons[ i ];
			m_Lessons[ i ] = NULL;
		}
	}
 
	m_Lessons.RemoveAll();
	m_LessonGroupConVarToggles.RemoveAll();
 
	// Paramos de escuchar eventos.
	StopListeningForAllEvents();
}
void ExternalExtensionsPlugin::Unload(void) {
	PRINT_TAG();
	ConColorMsg(Color(255, 255, 0, 255), "Unloading plugin...\n");

	g_ModuleManager->UnloadAllModules();

	ConVar_Unregister();
	Interfaces::Unload();

	PRINT_TAG();
	ConColorMsg(Color(0, 255, 0, 255), "Finished unloading!\n");
}
Esempio n. 4
0
void LibMgr::FindInfo(Library lib)
{
	DynLibInfo dlinfo;
	memset(&dlinfo, 0x00, sizeof(dlinfo));
	assert(g_MemUtils.GetLibraryInfo(GetPtr(lib), dlinfo));
	
	LibInfo lib_info((uintptr_t)dlinfo.baseAddress, (uintptr_t)dlinfo.memorySize);
	
#if defined _LINUX
	g_MemUtils.ForEachSection(s_LibHandles[lib], [&](const Elf32_Shdr *shdr, const char *name){
		SegInfo seg_info(shdr->sh_addr, shdr->sh_size);
		seg_info.m_LibBaseAddr = lib_info.BaseAddr();
		
		auto it = segnames_plat.find(name);
		if (it != segnames_plat.end()) {
			ConColorMsg(Color(0x00, 0xff, 0x00, 0xff), "Library %s: segment '%s' found: %s\n",
				Lib_ToString(lib), name, Seg_ToString((*it).second));
			auto result = lib_info.m_SegmentsByType.insert(std::make_pair((*it).second, seg_info));
			assert(result.second);
		} else {
			ConColorMsg(Color(0xff, 0x00, 0x00, 0xff), "Library %s: segment '%s' not found!\n",
				Lib_ToString(lib), name);
		}
		
		auto result = lib_info.m_SegmentsByName.insert(std::make_pair(name, seg_info));
		assert(result.second);
	});
#elif defined _WINDOWS
	g_MemUtils.ForEachSection(s_LibHandles[lib], [&](const IMAGE_SECTION_HEADER *pSectHdr){
		SegInfo seg_info(pSectHdr->VirtualAddress, pSectHdr->Misc.VirtualSize);
		seg_info.m_LibBaseAddr = lib_info.BaseAddr();
		
		auto name = (const char *)pSectHdr->Name;
		
		auto it = segnames_plat.find(name);
		if (it != segnames_plat.end()) {
			auto result = lib_info.m_SegmentsByType.insert(std::make_pair((*it).second, seg_info));
			assert(result.second);
		}
		
		auto result = lib_info.m_SegmentsByName.insert(std::make_pair(name, seg_info));
		assert(result.second);
	});
#endif
	
	auto result = s_LibInfos.insert(std::make_pair(lib, lib_info));
	assert(result.second);
	
	DevMsg("Library %-34s [ %08x %08x ]\n", libnames.at(lib), lib_info.AddrBegin(), lib_info.AddrEnd());
	for (const auto& pair : lib_info.m_SegmentsByName) {
		DevMsg("  %-40s [ %08x %08x ]\n", pair.first.c_str(), pair.second.AddrBegin(), pair.second.AddrEnd());
	}
}
//=========================================================
//=========================================================
void C_GameInstructor::DefineLesson( CBaseLesson *pLesson )
{
	if ( gameinstructor_verbose.GetInt() > 0 )
	{
		ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Lesson " );
		ConColorMsg( CBaseLesson::m_rgbaVerboseName, "\"%s\" ", pLesson->GetName() );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "defined.\n" );
	}
 
	m_Lessons.AddToTail( pLesson );
}
//=========================================================
//=========================================================
void C_GameInstructor::ResetDisplaysAndSuccesses()
{
	if ( gameinstructor_verbose.GetInt() > 0 )
	{
		ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Reset all lesson display and success counts.\n" );
	}
 
	for ( int i = 0; i < m_Lessons.Count(); ++i )
	{
		m_Lessons[ i ]->ResetDisplaysAndSuccesses();
	}
 
	m_bDirtySaveData = false;
}
Esempio n. 7
0
DLL_EXPORT void MONOFUNC(dbg_colormsg)( Color *pColor, char *fmt )
{
	if( pColor == NULL )
		return;

	ConColorMsg( *pColor, fmt );
}
//=========================================================
// Inicializa al Instructor
//=========================================================
bool C_GameInstructor::Init()
{
//	if ( &GetGameInstructor() == this )
	//	return true;
 
	// Instructor desactivado, no inicializar.
	if ( !gameinstructor_enable.GetBool() || sv_gameinstructor_disable.GetBool() )
		return true;
 
	if ( gameinstructor_verbose.GetInt() > 0 )
	{
		ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Initialization...\n" );
	}
 
	m_bNoDraw					= false;
	m_bHiddenDueToOtherElements = false;
 
	m_iCurrentPriority			= 0;
	m_hLastSpectatedPlayer		= NULL;
	m_bSpectatedPlayerChanged	= false;
 
	m_szPreviousStartSound[0]	= '\0';
	m_fNextStartSoundTime		= 0;
 
	ReadLessonsFromFile( GAMEINSTRUCTOR_MOD_SCRIPT_FILE );
	ReadLessonsFromFile( GAMEINSTRUCTOR_SCRIPT_FILE );
 
	InitLessonPrerequisites();
	ReadSaveData();
 
	ListenForGameEvent("gameinstructor_draw");
	ListenForGameEvent("gameinstructor_nodraw");
 
	ListenForGameEvent("round_end");
	ListenForGameEvent("round_start");
	ListenForGameEvent("player_death");
	ListenForGameEvent("player_team");
	ListenForGameEvent("player_disconnect");
	ListenForGameEvent("map_transition");
	ListenForGameEvent("game_newmap");
	ListenForGameEvent("set_instructor_group_enabled");
 
	EvaluateLessonsForGameRules();
	return true;
}
//=========================================================
//=========================================================
void C_GameInstructor::MarkSucceeded(const char *pchLessonName)
{
	CBaseLesson *pLesson = GetLesson_Internal(pchLessonName);
 
	if ( !pLesson )
		return;
 
	if ( gameinstructor_verbose.GetInt() > 0 )
	{
		ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Lesson " );
		ConColorMsg( CBaseLesson::m_rgbaVerboseSuccess, "\"%s\" ", pLesson->GetName() );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "marked as succeeded.\n" );
	}
 
	if ( pLesson->IncSuccessCount() )
		m_bDirtySaveData = true;
}
//=========================================================
//=========================================================
bool C_GameInstructor::UpdateActiveLesson( CBaseLesson *pLesson, const CBaseLesson *pRootLesson )
{
	VPROF_BUDGET( "C_GameInstructor::UpdateActiveLesson", "GameInstructor" );
 
	bool bIsOpen = pLesson->IsInstructing();
 
	if ( !bIsOpen && !pRootLesson->IsLearned() )
	{
		pLesson->SetStartTime();
		pLesson->Start();
 
		// Check to see if it successfully started
		bIsOpen = ( pLesson->IsOpenOpportunity() && pLesson->ShouldDisplay() );
 
		if ( bIsOpen )
		{
			// Lesson hasn't been started and hasn't been learned
			if ( gameinstructor_verbose.GetInt() > 0 )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "GAME INSTRUCTOR: " );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Started lesson " );
				ConColorMsg( CBaseLesson::m_rgbaVerboseOpen, "\"%s\"", pLesson->GetName() );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ".\n" );
			}
		}
		else
		{
			pLesson->Stop();
			pLesson->ResetStartTime();
		}
	}
 
	if ( bIsOpen )
	{
		// Update the running lesson
		pLesson->Update();
		return true;
	}
	else
	{
		pLesson->UpdateInactive();
		return false;
	}
}
Esempio n. 11
0
	DETOUR_DECL_MEMBER(void, CTFBotProxy_C1)
	{
		static uintptr_t prev = 0x00000000;
		
		uintptr_t diff = Max((uintptr_t)this, prev) - Min((uintptr_t)this, prev);
		ConColorMsg(Color(0x00, 0xff, 0xff, 0xff), "CTFBotProxy constructed @ 0x%08x (diff: 0x%08x)\n", (uintptr_t)this, diff);
		prev = (uintptr_t)this;
		
		DETOUR_MEMBER_CALL(CTFBotProxy_C1)();
	}
//=========================================================
//=========================================================
void C_GameInstructor::CloseOpportunity( CBaseLesson *pLesson )
{
	UpdateInactiveLesson( pLesson );
 
	if ( pLesson->WasDisplayed() )
		MarkDisplayed( pLesson->GetName() );
 
	if ( gameinstructor_verbose.GetInt() > 0 )
	{
		ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "GAME INSTRUCTOR: " );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Opportunity " );
		ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\"%s\" ", pLesson->GetName() );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "closed for reason: " );
		ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "%s\n", pLesson->GetCloseReason() );
	}
 
	pLesson->StopListeningForAllEvents();
 
	m_OpenOpportunities.FindAndRemove( pLesson );
	delete pLesson;
}
//=========================================================
//=========================================================
void C_GameInstructor::UpdateInactiveLesson( CBaseLesson *pLesson )
{
	VPROF_BUDGET( "C_GameInstructor::UpdateInactiveLesson", "GameInstructor" );
 
	if ( pLesson->IsInstructing() )
	{
		// Lesson hasn't been stopped
		if ( gameinstructor_verbose.GetInt() > 0 )
		{
			ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "GAME INSTRUCTOR: " );
			ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Stopped lesson " );
			ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\"%s\"", pLesson->GetName() );
			ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ".\n" );
		}
 
		pLesson->Stop();
		pLesson->ResetStartTime();
	}
 
	pLesson->UpdateInactive();
}
Esempio n. 14
0
	DETOUR_DECL_MEMBER(bool, IServerGameDLL_LevelInit, const char *pMapName, const char *pMapEntities, const char *pOldLevel, const char *pLandmarkName, bool loadGame, bool background)
	{
		ConColorMsg(Color(0xff, 0x00, 0xff, 0xff), "DETOUR for IServerGameDLL::LevelInit\n");
		
		for (const uint8_t *c = reinterpret_cast<const uint8_t *>(pMapEntities); *c != '\0'; ++c) {
			if (*c >= 0x80 && *c <= 0xff) {
				Msg("- Detected character %02x @ pMapEntities+0x%x\n", (int)(*c), (uintptr_t)c - (uintptr_t)pMapEntities);
			}
		}
		
		return DETOUR_MEMBER_CALL(IServerGameDLL_LevelInit)(pMapName, pMapEntities, pOldLevel, pLandmarkName, loadGame, background);
	}
Esempio n. 15
0
	DETOUR_DECL_MEMBER(void, CEventQueue_ServiceEvents)
	{
		auto queue = reinterpret_cast<CEventQueue *>(this);
		
		if (queue->m_Events.m_pNext != nullptr) {
			ConColorMsg(Color(0xff, 0xff, 0x00, 0xff),
				"[%10.6f] CEventQueue::ServiceEvents DUMP:\n",
				engine->GetServerTime());
			
			for (EventQueuePrioritizedEvent_t *pe = queue->m_Events.m_pNext; pe != nullptr; pe = pe->m_pNext) {
				ConColorMsg(Color(0xff, 0xff, 0x00, 0xff),
					"[t: %10.6f] [target: '%s' '%s'] [param: '%s'] [activator: '%s'] [caller: '%s']\n",
					pe->m_flFireTime,
					STRING(pe->m_iTarget),
					STRING(pe->m_iTargetInput),
					pe->m_VariantValue.String(),
					(pe->m_pActivator != nullptr ? STRING(pe->m_pActivator->GetEntityName()) : "none"),
					(pe->m_pCaller    != nullptr ? STRING(pe->m_pCaller   ->GetEntityName()) : "none"));
			}
		}
		
		DETOUR_MEMBER_CALL(CEventQueue_ServiceEvents)();
	}
bool ExternalExtensionsPlugin::Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory) {
	PRINT_TAG();
	ConColorMsg(Color(0, 255, 255, 255), "version %s | a Forward Command Post project (http://fwdcp.net)\n", PLUGIN_VERSION);

	PRINT_TAG();
	ConColorMsg(Color(255, 255, 0, 255), "Loading plugin...\n");

	Interfaces::Load(interfaceFactory, gameServerFactory);

	g_GameThreadHelper = new GameThreadHelper();
	g_WebSockets = new WebSockets();

	g_ModuleManager = new ModuleManager();

	g_ModuleManager->LoadModule<Console>("Console");
	g_ModuleManager->LoadModule<GameInfo>("Game Info");

	ConVar_Register();

	PRINT_TAG();
	ConColorMsg(Color(0, 255, 0, 255), "Finished loading!\n");

	return true;
}
Esempio n. 17
0
	DETOUR_DECL_MEMBER(void, CEventQueue_AddEvent, EventQueuePrioritizedEvent_t *pe)
	{
		auto queue = reinterpret_cast<CEventQueue *>(this);
		
		ConColorMsg(Color(0x00, 0xff, 0x00, 0xff),
			"[%10.6f] AddEvent: [t: %10.6f] [target: '%s' '%s'] [param: '%s'] [activator: '%s'] [caller: '%s']\n",
			engine->GetServerTime(),
			pe->m_flFireTime,
			STRING(pe->m_iTarget),
			STRING(pe->m_iTargetInput),
			pe->m_VariantValue.String(),
			(pe->m_pActivator != nullptr ? STRING(pe->m_pActivator->GetEntityName()) : "none"),
			(pe->m_pCaller    != nullptr ? STRING(pe->m_pCaller   ->GetEntityName()) : "none"));
		
		DETOUR_MEMBER_CALL(CEventQueue_AddEvent)(pe);
	}
Esempio n. 18
0
//ConColorMsg - todo: when we add the c++ objects take colors instead
int l_concolormsg(lua_State* ls)
{
	//const int iTop		= lua_gettop(ls);

	int r = luaL_checkinteger(ls, 1);
	int g = luaL_checkinteger(ls, 2);
	int b = luaL_checkinteger(ls, 3);

	const char* streng = lua_tostring(ls, 4);

	const Color randomcol = Color(r, g, b, 255);

	ConColorMsg(randomcol, "%s\n", streng);

	return 1;
}
Esempio n. 19
0
bool CAddr_Sym_Regex::FindAddrLinux(uintptr_t& addr) const
{
	float t1 = Plat_FloatTime();
	auto results = LibMgr::FindSymRegex(this->GetLibrary(), this->GetSymbol());
	float t2 = Plat_FloatTime();
	ConColorMsg(Color(0xff, 0x00, 0xff, 0xff), "Regex lookup for \"%s\" \"%s\": %.3f ms\n",
		this->GetName(), this->GetSymbol(), (t2 - t1) * 1000.0f);
	
	bool success      = std::get<0>(results);
	std::string& name = std::get<1>(results);
	void *sym_addr    = std::get<2>(results);
	
	if (!success || sym_addr == nullptr) {
		return false;
	}
	
	addr = (uintptr_t)sym_addr;
	return true;
}
	void Restore( IRestore *pRestore, bool createPlayers )
	{
		if ( m_fDoLoad )
		{
			pRestore->StartBlock();
 
			size_t	DataLength;
 
			pRestore->ReadData((char*)&DataLength,sizeof(size_t),0);
 
			char*	Data	=	new char[DataLength];
 
			pRestore->ReadData((char*)Data,(int)DataLength,DataLength);
 
			Color ConsoleColor(100,255,100,255);
			ConColorMsg(ConsoleColor,Data);
 
			delete[] Data;
 
			pRestore->EndBlock();
		}
	}
Esempio n. 21
0
int Init(lua_State *L) {

	if ( !Lua()->IsClient() )
		Lua()->Error( "gmcl_usermessages can only be loaded on the client!" );

	CreateInterfaceFn ClientFactory = Sys_GetFactory( CLIENT_LIB );
	if ( !ClientFactory )
		Lua()->Error( "gmcl_usermessages: Error getting " CLIENT_LIB " factory." );

	g_BaseClientDLL = ( IBaseClientDLL* )ClientFactory( CLIENT_DLL_INTERFACE_VERSION, NULL );
	if ( !g_BaseClientDLL )
		Lua()->Error( "gmcl_usermessages: Error getting IBaseClientDLL interface.\n" );
	
	HOOKVFUNC( g_BaseClientDLL, 36, origDispatchUserMessage, newDispatchUserMessage );
	
	Color Blue( 0, 162, 232, 255 );
	Color White( 255, 255, 255, 255 );

	ConColorMsg( Blue, "gmcl_usermessages" );
	ConColorMsg( White, ": Loaded!\n" );

	/*
	Lua()->NewGlobalTable("usermessages");
		ILuaObject *usermessages = Lua()->GetGlobal("usermessages");
		usermessages->SetMember( "Lookup", LookupUserMessage );
		usermessages->SetMember( "GetSize", GetUserMessageSize );
		usermessages->SetMember( "GetName", GetUserMessageName );
		usermessages->SetMember( "IsValidIndex", IsValidIndex );
	usermessages->UnReference();
	*/

	ILuaObject *metaT = Lua()->GetMetaTable( CBITREAD_NAME, CBITREAD_ID );
		metaT->SetMember( "GetSize", GetSize );
		metaT->SetMember( "GetDebugName", GetDebugName );
		metaT->SetMember( "GetNumBitsLeft", GetNumBitsLeft );
		metaT->SetMember( "GetNumBitsRead", GetNumBitsRead );
		metaT->SetMember( "GetNumBytesLeft", GetNumBytesLeft );
		metaT->SetMember( "IsOverflowed", IsOverflowed );
		metaT->SetMember( "PeekUBitLong", PeekUBitLong );
		metaT->SetMember( "ReadAndAllocateString", ReadAndAllocateString );
		metaT->SetMember( "ReadBitAngle", ReadBitAngle );
		metaT->SetMember( "ReadBitAngles", ReadBitAngles );
		metaT->SetMember( "ReadBitCoord", ReadBitCoord );
		metaT->SetMember( "ReadBitCoordMP", ReadBitCoordMP );
		metaT->SetMember( "ReadBitFloat", ReadBitFloat );
		metaT->SetMember( "ReadBitNormal", ReadBitNormal );
		metaT->SetMember( "ReadBitVec3Coord", ReadBitVec3Coord );
		metaT->SetMember( "ReadBitVec3Normal", ReadBitVec3Normal );
		metaT->SetMember( "ReadByte", ReadByte );
		metaT->SetMember( "ReadChar", ReadChar );
		metaT->SetMember( "ReadFloat", ReadFloat );
		metaT->SetMember( "ReadLong", ReadLong );
		metaT->SetMember( "ReadOneBit", ReadOneBit );
		metaT->SetMember( "ReadSBitLong", ReadSBitLong );
		metaT->SetMember( "ReadShort", ReadShort );
		metaT->SetMember( "ReadString", ReadString );
		metaT->SetMember( "ReadUBitLong", ReadUBitLong );
		metaT->SetMember( "ReadUBitVar", ReadUBitVar );
		metaT->SetMember( "ReadWord", ReadWord );
		metaT->SetMember( "Seek", Seek );
		metaT->SetMember( "SeekRelative", SeekRelative );
		metaT->SetMember( "SetDebugName", SetDebugName );
		metaT->SetMember( "SetOverflowFlag", SetOverflowFlag );
		metaT->SetMember( "Tell", Tell );
		metaT->SetMember( "TotalBytesAvailable", TotalBytesAvailable );

		metaT->SetMember( "__tostring", __tostring );
		metaT->SetMember( "__eq", __eq );
		metaT->SetMember( "__index", metaT );
	metaT->UnReference();

	return 0;
}
Esempio n. 22
0
bool CScriptedIconLesson::Mod_ProcessElementAction( int iAction, bool bNot, const char *pchVarName, EHANDLE &hVar, const CGameInstructorSymbol *pchParamName, float fParam, C_BaseEntity *pParam, const char *pchParam, bool &bModHandled )
{
	// Assume we're going to handle the action
	bModHandled = true;

	C_BaseEntity *pVar = hVar.Get();

	switch ( iAction )
	{
		case LESSON_ACTION_IS_ALLOWED_ITEM:
		{
			C_ASW_Marine *pMarine = NULL;

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( pPlayer )
			{
				pMarine = dynamic_cast< C_ASW_Marine* >( pPlayer->GetMarine() );
			}

			if ( !pMarine )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->AllowedToPickup( [%s] )", pchParamName->String(), pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Marine returned NULL!\n" );
				}

				return false;
			}

			bool bIsAllowed = false;

			C_ASW_Pickup *pPickup = dynamic_cast< C_ASW_Pickup * >( pParam );
			if ( !pPickup )
			{
				C_ASW_Weapon *pWeapon = dynamic_cast< C_ASW_Weapon * >( pParam );

				if ( !pWeapon )
				{
					if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
					{
						ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->AllowedToPickup( [%s] )", pchParamName->String(), pchVarName );
						ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
						ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
						ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tParam handle as ASW_Weapon and ASW_Pickup returned NULL!\n" );
					}

					return false;
				}
				else
				{
					bIsAllowed = pWeapon->AllowedToPickup( pMarine );
				}
			}
			else
			{
				bIsAllowed = pPickup->AllowedToPickup( pMarine );
			}

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->AllowedToPickup( [%s] )", pchParamName->String(), pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bIsAllowed ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bIsAllowed ) : ( bIsAllowed );
		}

		case LESSON_ACTION_ITEM_WILL_SWAP:
		{
			C_ASW_Marine *pMarine = NULL;

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( pPlayer )
			{
				pMarine = dynamic_cast< C_ASW_Marine* >( pPlayer->GetMarine() );
			}

			if ( !pMarine )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->WillSwap( [%s] )", pchParamName->String(), pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Marine returned NULL!\n" );
				}

				return false;
			}

			bool bWillSwap = false;

			C_ASW_Pickup_Weapon *pPickup = dynamic_cast< C_ASW_Pickup_Weapon * >( pParam );
			if ( !pPickup )
			{
				C_ASW_Weapon *pWeapon = dynamic_cast< C_ASW_Weapon * >( pParam );

				if ( !pWeapon )
				{
					if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
					{
						ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->WillSwap( [%s] )", pchParamName->String(), pchVarName );
						ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
						ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
						ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tParam handle as ASW_Weapon and ASW_Pickup returned NULL!\n" );
					}

					return false;
				}
				else
				{
					int nSlot = pMarine->GetWeaponPositionForPickup( pWeapon->GetClassname() );
					bWillSwap = ( pMarine->GetASWWeapon( nSlot ) != NULL );
				}
			}
			else
			{
				int nSlot = pMarine->GetWeaponPositionForPickup( pPickup->GetWeaponClass() );
				bWillSwap = ( pMarine->GetASWWeapon( nSlot ) != NULL );
			}

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->WillSwap( [%s] )", pchParamName->String(), pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bWillSwap ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bWillSwap ) : ( bWillSwap );
		}

		case LESSON_ACTION_CAN_HACK:
		{
			C_ASW_Marine *pMarine = NULL;

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( pPlayer )
			{
				pMarine = dynamic_cast< C_ASW_Marine* >( pPlayer->GetMarine() );
			}

			if ( !pMarine )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->CanHack()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Marine returned NULL!\n" );
				}

				return false;
			}

			bool bCanHack = pMarine->GetMarineProfile()->CanHack();

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->AllowedToPickup()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bCanHack ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bCanHack ) : ( bCanHack );
		}

		case LESSON_ACTION_CAN_OFFHAND:
		{
			C_ASW_Weapon *pWeapon = dynamic_cast< C_ASW_Weapon* >( pVar );
			if ( !pWeapon )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->CanOffhand()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Weapon returned NULL!\n" );
				}

				return false;
			}

			bool bCanOffhand = pWeapon->GetWeaponInfo()->m_bOffhandActivate;

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->CanOffhand()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bCanOffhand ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bCanOffhand ) : ( bCanOffhand );
		}

		case LESSON_ACTION_HAS_SECONDARY:
		{
			C_ASW_Weapon *pWeapon = dynamic_cast< C_ASW_Weapon* >( pVar );
			if ( !pWeapon )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HasSecondary()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Weapon returned NULL!\n" );
				}

				return false;
			}

			bool bHasSecondary = pWeapon->UsesSecondaryAmmo();

			if ( bHasSecondary )
			{
				bHasSecondary = !( ( pWeapon->UsesClipsForAmmo2() && pWeapon->m_iClip2 <= 0 ) ||
								   ( !pWeapon->UsesClipsForAmmo2() && pWeapon->GetOwner() && pWeapon->GetOwner()->GetAmmoCount( pWeapon->m_iSecondaryAmmoType ) <= 0 ) );
			}

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HasSecondary()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bHasSecondary ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bHasSecondary ) : ( bHasSecondary );
		}

		case LESSON_ACTION_HAS_SECONDARY_EXPLOSIVES:
		{
			C_ASW_Marine *pMarine = NULL;

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( pPlayer )
			{
				pMarine = dynamic_cast< C_ASW_Marine* >( pPlayer->GetMarine() );
			}

			if ( !pMarine )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HasAnySecondary()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Marine returned NULL!\n" );
				}

				return false;
			}

			bool bHasAnySecondary = false;

			for ( int i = 0; i < ASW_MAX_EQUIP_SLOTS; ++i )
			{
				C_ASW_Weapon *pWeapon = static_cast< C_ASW_Weapon* >( pMarine->GetWeapon( i ) );
				if ( pWeapon && pWeapon->HasSecondaryExplosive() )
				{
					if ( !( ( pWeapon->UsesClipsForAmmo2() && pWeapon->m_iClip2 <= 0 ) || 
							( !pWeapon->UsesClipsForAmmo2() && pWeapon->GetOwner() && pWeapon->GetOwner()->GetAmmoCount( pWeapon->m_iSecondaryAmmoType ) <= 0 ) ) )
					{
						bHasAnySecondary = true;
						break;
					}
				}
			}

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HasAnySecondary()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bHasAnySecondary ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bHasAnySecondary ) : ( bHasAnySecondary );
		}

		case LESSON_ACTION_GET_MARINE:
		{
			int iTemp = static_cast<int>( fParam );

			if ( iTemp <= 0 || iTemp > 2 )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[entityINVALID] = [%s]->GetMarine()\n", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tParam selecting string is out of range!\n" );
				}

				return false;
			}

			CHandle<C_BaseEntity> *pHandle;

			char const *pchParamNameTemp = NULL;

			if ( iTemp == 2 )
			{
				pHandle = &m_hEntity2;
				pchParamNameTemp = "entity2";
			}
			else
			{
				pHandle = &m_hEntity1;
				pchParamNameTemp = "entity1";
			}

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( !pPlayer )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s] = [%s]->GetMarine()", pchParamNameTemp, pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "...\n" );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Player returned NULL!\n" );
				}

				return false;
			}

			C_ASW_Marine *pMarine = dynamic_cast< C_ASW_Marine* >( pPlayer->GetMarine() );

			pHandle->Set( pMarine );

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s] = [%s]->GetMarine()\n", pchParamNameTemp, pchVarName );
			}

			return true;
		}

		case LESSON_ACTION_IS_BOT:
		{
			C_ASW_Marine *pMarine = dynamic_cast< C_ASW_Marine* >( pVar );

			if ( !pMarine )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t![%s]->IsInhabited()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Marine returned NULL!\n" );
				}

				return false;
			}

			bool bIsBot = !pMarine->IsInhabited();

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t![%s]->IsInhabited()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bIsBot ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bIsBot ) : ( bIsBot );
		}

		case LESSON_ACTION_WEAPON_HAS_SPARE:
		{
			C_ASW_Marine *pMarine = NULL;

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( pPlayer )
			{
				pMarine = dynamic_cast< C_ASW_Marine* >( pPlayer->GetMarine() );
			}

			if ( !pMarine )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HasSpareWeapon()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Marine returned NULL!\n" );
				}

				return false;
			}

			int nOffensiveWeaponCount = 0;

			for ( int i = 0; i < ASW_MAX_EQUIP_SLOTS; ++i )
			{
				C_ASW_Weapon *pWeapon = static_cast< C_ASW_Weapon* >( pMarine->GetWeapon( i ) );
				if ( pWeapon && pWeapon->IsOffensiveWeapon() )
				{
					if ( !( ( pWeapon->UsesClipsForAmmo1() && pWeapon->m_iClip1 <= 0 ) || 
						 ( !pWeapon->UsesClipsForAmmo1() && pWeapon->GetOwner() && pWeapon->GetOwner()->GetAmmoCount( pWeapon->m_iPrimaryAmmoType ) <= 0 ) ) )
					{
						nOffensiveWeaponCount++;
					}
				}
			}

			bool bHasSpare = ( nOffensiveWeaponCount > 1 );

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HasSpareWeapon()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bHasSpare ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bHasSpare ) : ( bHasSpare );
		}

		case LESSON_ACTION_WEAPON_IS_OFFENSIVE:
		{
			C_ASW_Marine *pMarine = NULL;

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( pPlayer )
			{
				pMarine = dynamic_cast< C_ASW_Marine* >( pPlayer->GetMarine() );
			}

			if ( !pMarine )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->WeaponIsOffensive()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Marine returned NULL!\n" );
				}

				return false;
			}

			bool bIsOffensive = false;

			C_ASW_Weapon *pWeapon = pMarine->GetActiveASWWeapon();
			if ( pWeapon && pWeapon->IsOffensiveWeapon() )
			{
				if ( !( ( pWeapon->UsesClipsForAmmo1() && pWeapon->m_iClip1 <= 0 ) || 
					( !pWeapon->UsesClipsForAmmo1() && pWeapon->GetOwner() && pWeapon->GetOwner()->GetAmmoCount( pWeapon->m_iPrimaryAmmoType ) <= 0 ) ) )
				{
					bIsOffensive = true;
				}
			}

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->WeaponIsOffensive()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bIsOffensive ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bIsOffensive ) : ( bIsOffensive );
		}

		case LESSON_ACTION_WEAPON_LOCAL_HOTBAR_SLOT:
		{
			CASW_Hud_Master *pHUDMaster = GET_HUDELEMENT( CASW_Hud_Master );
			if ( pHUDMaster )
			{
				m_fOutput = pHUDMaster->GetHotBarSlot( pchParam );

				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\tm_fOutput = GET_HUDELEMENT( CASW_Hud_Squad_Hotbar )->GetHotBarSlot( [%s] ", pchParamName->String() );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "\"%s\"", pchParam );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ")\n" );
				}
			}

			return true;
		}

		case LESSON_ACTION_OWNS_HOTBAR_SLOT:
		{
			int iTemp = static_cast<int>( fParam );

			C_ASW_Player *pPlayer = dynamic_cast< C_ASW_Player* >( pVar );
			if ( !pPlayer )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\tGET_HUDELEMENT( CASW_Hud_Squad_Hotbar )->OwnsHotBarSlot( [%s] ", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "..." );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ", [%s] ", pchParamName->String() );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "\"%i\" ", iTemp );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ") " );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Player returned NULL!\n" );
				}

				return false;
			}

			bool bOwnsHotBarSlot = false;

			CASW_Hud_Master *pHUDMaster = GET_HUDELEMENT( CASW_Hud_Master );
			if ( pHUDMaster )
			{
				bOwnsHotBarSlot = pHUDMaster->OwnsHotBarSlot( pPlayer, iTemp );

				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\tGET_HUDELEMENT( CASW_Hud_Squad_Hotbar )->OwnsHotBarSlot( [%s], [%s] ", pchVarName, pchParamName->String() );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "\"%i\" ", iTemp );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ") " );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bOwnsHotBarSlot ? "true" : "false" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
				}
			}

			return ( bNot ) ? ( !bOwnsHotBarSlot ) : ( bOwnsHotBarSlot );
		}

		case LESSON_ACTION_SENTRY_WANTS_DISMANTLE:
		{
			C_ASW_Sentry_Base *pSentry = dynamic_cast< C_ASW_Sentry_Base* >( pVar );
			if ( !pSentry )
			{
				if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
				{
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->WantsDismantle()", pchVarName );
					ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
					ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
					ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\tVar handle as ASW_Sentry_Base returned NULL!\n" );
				}

				return false;
			}

			bool bWantsDismantle = pSentry->WantsDismantle();

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->WantsDismantle()", pchVarName );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bWantsDismantle ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bWantsDismantle ) : ( bWantsDismantle );
		}

		case LESSON_ACTION_IS_TUTORIAL:
		{
			bool bIsTutorial = ASWGameRules()->IsTutorialMap();

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\tASWGameRules()->IsTutorialMap()" );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bIsTutorial ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bIsTutorial ) : ( bIsTutorial );
		}

		case LESSON_ACTION_IS_SINGLEPLAYER:
		{
			bool bIsSingleplayer = ASWGameRules()->IsOfflineGame();

			if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\tASWGameRules()->IsOfflineGame()" );
				ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%s ", ( bIsSingleplayer ? "true" : "false" ) );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( "== false\n" ) : ( "== true\n" ) );
			}

			return ( bNot ) ? ( !bIsSingleplayer ) : ( bIsSingleplayer );
		}

		default:
			// Didn't handle this action
			bModHandled = false;
			break;
	}

	return false;
}
//=========================================================
//=========================================================
bool C_GameInstructor::OpenOpportunity( CBaseLesson *pLesson )
{
	// Get the root lesson
	CBaseLesson *pRootLesson = pLesson->GetRoot();
 
	if ( !pRootLesson )
	{
		if ( gameinstructor_verbose.GetInt() > 0 )
		{
			ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
			ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Opportunity " );
			ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\"%s\" ", pLesson->GetName() );
			ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "NOT opened (because root lesson could not be found).\n" );
		}
 
		delete pLesson;
		return false;
	}
 
	C_BasePlayer *pLocalPlayer = GetLocalPlayer();
 
	if ( !pRootLesson->CanOpenWhenDead() && ( !pLocalPlayer || !pLocalPlayer->IsAlive() ) )
	{
		// If the player is dead don't allow lessons that can't be opened when dead
		if ( gameinstructor_verbose.GetInt() > 0 )
		{
			ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
			ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Opportunity " );
			ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\"%s\" ", pLesson->GetName() );
			ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "NOT opened (because player is dead and can_open_when_dead not set).\n" );
		}
 
		delete pLesson;
		return false;
	}
 
	if ( !pRootLesson->PrerequisitesHaveBeenMet() )
	{
		// If the prereqs haven't been met, don't open it
		if ( gameinstructor_verbose.GetInt() > 0 )
		{
			ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
			ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Opportunity " );
			ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\"%s\" ", pLesson->GetName() );
			ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "NOT opened (because prereqs haven't been met).\n" );
		}
 
		delete pLesson;
		return false;
	}
 
	if ( pRootLesson->InstanceType() == LESSON_INSTANCE_FIXED_REPLACE )
	{
		CBaseLesson *pLessonToReplace = NULL;
		CBaseLesson *pLastReplacableLesson = NULL;
 
		int iInstanceCount = 0;
 
		// Check how many are already open
		for ( int i = m_OpenOpportunities.Count() - 1; i >= 0; --i )
		{
			CBaseLesson *pOpenOpportunity = m_OpenOpportunities[ i ];
 
			if ( pOpenOpportunity->GetNameSymbol() == pLesson->GetNameSymbol() && 
				 pOpenOpportunity->GetReplaceKeySymbol() == pLesson->GetReplaceKeySymbol() )
			{
				iInstanceCount++;
 
				if ( pRootLesson->ShouldReplaceOnlyWhenStopped() )
				{
					if ( !pOpenOpportunity->IsInstructing() )
					{
						pLastReplacableLesson = pOpenOpportunity;
					}
				}
				else
				{
					pLastReplacableLesson = pOpenOpportunity;
				}
 
				if ( iInstanceCount >= pRootLesson->GetFixedInstancesMax() )
				{
					pLessonToReplace = pLastReplacableLesson;
					break;
				}
			}
		}
 
		if ( pLessonToReplace )
		{
			// Take the place of the previous instance
			if ( gameinstructor_verbose.GetInt() > 0 )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "GAME INSTRUCTOR: " );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Opportunity " );
				ConColorMsg( CBaseLesson::m_rgbaVerboseOpen, "\"%s\" ", pLesson->GetName() );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "replacing open lesson of same type.\n" );
			}
 
			pLesson->TakePlaceOf( pLessonToReplace );
			CloseOpportunity( pLessonToReplace );
		}
		else if ( iInstanceCount >= pRootLesson->GetFixedInstancesMax() )
		{
			// Don't add another lesson of this type
			if ( gameinstructor_verbose.GetInt() > 0 )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "GAME INSTRUCTOR: " );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Opportunity " );
				ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "\"%s\" ", pLesson->GetName() );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "NOT opened (there is too many started lessons of this type).\n" );
			}
 
			delete pLesson;
			return false;
		}
	}
 
	if ( gameinstructor_verbose.GetInt() > 0 )
	{
		ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "GAME INSTRUCTOR: " );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Opportunity " );
		ConColorMsg( CBaseLesson::m_rgbaVerboseOpen, "\"%s\" ", pLesson->GetName() );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "opened.\n" );
	}
 
	m_OpenOpportunities.AddToTail( pLesson );
 
	return true;
}
Esempio n. 24
0
static int luasrc_ConColorMsg (lua_State *L) {
  ConColorMsg(*(Color *)luaL_checkcolor(L, 1), luaL_checkstring(L, 2));
  return 0;
}
Esempio n. 25
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ConVar_PrintDescription( const ConCommandBase *pVar )
{
	bool bMin, bMax;
	float fMin, fMax;
	const char *pStr;

	assert( pVar );

	Color clr;
	clr.SetColor( 255, 100, 100, 255 );

	if ( !pVar->IsCommand() )
	{
		ConVar *var = ( ConVar * )pVar;
		const ConVar_ServerBounded *pBounded = dynamic_cast<const ConVar_ServerBounded*>( var );

		bMin = var->GetMin( fMin );
		bMax = var->GetMax( fMax );

		const char *value = NULL;
		char tempVal[ 32 ];

		if ( pBounded || var->IsFlagSet( FCVAR_NEVER_AS_STRING ) )
		{
			value = tempVal;
			
			int intVal = pBounded ? pBounded->GetInt() : var->GetInt();
			float floatVal = pBounded ? pBounded->GetFloat() : var->GetFloat();

			if ( fabs( (float)intVal - floatVal ) < 0.000001 )
			{
				Q_snprintf( tempVal, sizeof( tempVal ), "%d", intVal );
			}
			else
			{
				Q_snprintf( tempVal, sizeof( tempVal ), "%f", floatVal );
			}
		}
		else
		{
			value = var->GetString();
		}

		if ( value )
		{
			ConColorMsg( clr, "\"%s\" = \"%s\"", var->GetName(), value );

			if ( stricmp( value, var->GetDefault() ) )
			{
				ConMsg( " ( def. \"%s\" )", var->GetDefault() );
			}
		}

		if ( bMin )
		{
			ConMsg( " min. %f", fMin );
		}
		if ( bMax )
		{
			ConMsg( " max. %f", fMax );
		}

		ConMsg( "\n" );

		// Handled virtualized cvars.
		if ( pBounded && fabs( pBounded->GetFloat() - var->GetFloat() ) > 0.0001f )
		{
			ConColorMsg( clr, "** NOTE: The real value is %.3f but the server has temporarily restricted it to %.3f **\n",
				var->GetFloat(), pBounded->GetFloat() );
		}
	}
	else
	{
		ConCommand *var = ( ConCommand * )pVar;

		ConColorMsg( clr, "\"%s\"\n", var->GetName() );
	}

	ConVar_PrintFlags( pVar );

	pStr = pVar->GetHelpText();
	if ( pStr && pStr[0] )
	{
		ConMsg( " - %s\n", pStr );
	}
}
//=========================================================
//=========================================================
void C_GameInstructor::Update( float frametime )
{
	VPROF_BUDGET( "C_GameInstructor::Update", "GameInstructor" );
 
	UpdateHiddenByOtherElements();
 
	// Instructor desactivado.
	if ( !gameinstructor_enable.GetBool() || m_bNoDraw || m_bHiddenDueToOtherElements )
		return;
 
	if ( gameinstructor_find_errors.GetBool() )
	{
		FindErrors();
		gameinstructor_find_errors.SetValue(0);
	}
 
	if ( IsConsole() )
	{
		// On X360 we want to save when they're not connected
		// They aren't in game
		if ( !engine->IsInGame() )
			WriteSaveData();
		else
		{
			const char *levelName = engine->GetLevelName();
 
			// The are in game, but it's a background map
			if ( levelName && levelName[0] && engine->IsLevelMainMenuBackground() )
				WriteSaveData();
		}
	}
 
	if ( m_bSpectatedPlayerChanged )
	{
		// Safe spot to clean out stale lessons if spectator changed
		if ( gameinstructor_verbose.GetInt() > 0 )
		{
			ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
			ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Spectated player changed...\n" );
		}
 
		CloseAllOpenOpportunities();
		m_bSpectatedPlayerChanged = false;
	}
 
	// Loop through all the lesson roots and reset their active status
	for ( int i = m_OpenOpportunities.Count() - 1; i >= 0; --i )
	{
		CBaseLesson *pLesson		= m_OpenOpportunities[ i ];
		CBaseLesson *pRootLesson	= pLesson->GetRoot();
 
		if ( pRootLesson->InstanceType() == LESSON_INSTANCE_SINGLE_ACTIVE )
			pRootLesson->SetInstanceActive(false);
	}
 
	int iCurrentPriority = 0;
 
	// Loop through all the open lessons
	for ( int i = m_OpenOpportunities.Count() - 1; i >= 0; --i )
	{
		CBaseLesson *pLesson = m_OpenOpportunities[ i ];
 
		// This opportunity has closed
		if ( !pLesson->IsOpenOpportunity() || pLesson->IsTimedOut() )
		{
			CloseOpportunity( pLesson );
			continue;
		}
 
		// Lesson should be displayed, so it can affect priority
		CBaseLesson *pRootLesson	= pLesson->GetRoot();
		bool bShouldDisplay			= pLesson->ShouldDisplay();
		bool bIsLocked				= pLesson->IsLocked();
 
		if ( ( bShouldDisplay || bIsLocked ) && 
			 ( pLesson->GetPriority() >= m_iCurrentPriority || pLesson->NoPriority() || bIsLocked ) && 
			 ( pRootLesson && ( pRootLesson->InstanceType() != LESSON_INSTANCE_SINGLE_ACTIVE || !pRootLesson->IsInstanceActive() ) ) )
		{
			// Lesson is at the highest priority level, isn't violating instance rules, and has met all the prerequisites
			if ( UpdateActiveLesson( pLesson, pRootLesson ) || pRootLesson->IsLearned() )
			{
				// Lesson is active
				if ( pLesson->IsVisible() || pRootLesson->IsLearned() )
				{
					pRootLesson->SetInstanceActive( true );
 
					// This active or learned lesson has the highest priority so far
					if ( iCurrentPriority < pLesson->GetPriority() && !pLesson->NoPriority() )
						iCurrentPriority = pLesson->GetPriority();
				}
			}
			else
			{
				// On second thought, this shouldn't have been displayed
				bShouldDisplay = false;
			}
		}
		else
		{
			// Lesson shouldn't be displayed right now
			UpdateInactiveLesson( pLesson );
		}
	}
 
	// Set the priority for next frame
	if ( gameinstructor_verbose.GetInt() > 1 && m_iCurrentPriority != iCurrentPriority )
	{
		ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Priority changed from " );
		ConColorMsg( CBaseLesson::m_rgbaVerboseClose, "%i ", m_iCurrentPriority );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "to " );
		ConColorMsg( CBaseLesson::m_rgbaVerboseOpen, "%i", iCurrentPriority );
		ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ".\n" );
	}
 
	m_iCurrentPriority = iCurrentPriority;
}
//=========================================================
//=========================================================
void C_GameInstructor::FireGameEvent( IGameEvent *event )
{
	VPROF_BUDGET( "C_GameInstructor::FireGameEvent", "GameInstructor" );
	const char *name = event->GetName();
 
	if ( Q_strcmp( name, "gameinstructor_draw" ) == 0 )
	{
		if ( m_bNoDraw )
		{
			if ( gameinstructor_verbose.GetInt() > 0 )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Set to draw...\n" );
			}
 
			m_bNoDraw = false;
		}
	}
	else if ( Q_strcmp( name, "gameinstructor_nodraw" ) == 0 )
	{
		if ( !m_bNoDraw )
		{
			if ( gameinstructor_verbose.GetInt() > 0 )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Set to not draw...\n" );
			}
 
			m_bNoDraw = true;
			StopAllLessons();
		}
	}
	else if ( Q_strcmp( name, "round_end" ) == 0 )
	{
		if ( gameinstructor_verbose.GetInt() > 0 )
		{
			ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
			ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Round ended...\n" );
		}
 
		CloseAllOpenOpportunities();
 
		if ( IsPC() )
		{
			// Good place to backup our counts
			WriteSaveData();
		}
	}
	else if ( Q_strcmp( name, "round_start" ) == 0 )
	{
		if ( gameinstructor_verbose.GetInt() > 0 )
		{
			ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
			ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Round started...\n" );
		}
 
		CloseAllOpenOpportunities();
 
		EvaluateLessonsForGameRules();
	}
	else if ( Q_strcmp( name, "player_death" ) == 0 )
	{
		#if !defined(NO_STEAM) && defined(USE_CEG)
				Steamworks_TestSecret(); 
				Steamworks_SelfCheck(); 
		#endif
 
		C_BasePlayer *pLocalPlayer = GetLocalPlayer();
 
		if ( pLocalPlayer && pLocalPlayer == UTIL_PlayerByUserId( event->GetInt( "userid" ) ) )
		{
			if ( gameinstructor_verbose.GetInt() > 0 )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Local player died...\n" );
			}
 
			for ( int i = m_OpenOpportunities.Count() - 1; i >= 0; --i )
			{
				CBaseLesson *pLesson		= m_OpenOpportunities[ i ];
				CBaseLesson *pRootLesson	= pLesson->GetRoot();
 
				if ( !pRootLesson->CanOpenWhenDead() )
					CloseOpportunity( pLesson );
			}
		}
	}
	else if ( Q_strcmp( name, "player_team" ) == 0 )
	{
		C_BasePlayer *pLocalPlayer = GetLocalPlayer();
 
		if ( pLocalPlayer && pLocalPlayer == UTIL_PlayerByUserId( event->GetInt( "userid" ) ) && 
			 ( event->GetInt( "team" ) != event->GetInt( "oldteam" ) || event->GetBool( "disconnect" ) ) )
		{
			if ( gameinstructor_verbose.GetInt() > 0 )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Local player changed team (or disconnected)...\n" );
			}
 
			CloseAllOpenOpportunities();
		}
 
		EvaluateLessonsForGameRules();
	}
	else if ( Q_strcmp( name, "player_disconnect" ) == 0 )
	{
		C_BasePlayer *pLocalPlayer = GetLocalPlayer();
		if ( pLocalPlayer && pLocalPlayer == UTIL_PlayerByUserId( event->GetInt( "userid" ) ) )
		{
			if ( gameinstructor_verbose.GetInt() > 0 )
			{
				ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
				ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Local player disconnected...\n" );
			}
 
			CloseAllOpenOpportunities();
		}
	}
	else if ( Q_strcmp( name, "map_transition" ) == 0 )
	{
		if ( gameinstructor_verbose.GetInt() > 0 )
		{
			ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
			ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "Map transition...\n" );
		}
 
		CloseAllOpenOpportunities();
 
		if ( m_bNoDraw )
		{
			if ( gameinstructor_verbose.GetInt() > 0 )
			{
				ConColorMsg( Color( 255, 128, 64, 255 ), "[INSTRUCTOR]: " );
				ConColorMsg( Color( 64, 128, 255, 255 ), "Set to draw...\n" );
			}
 
			m_bNoDraw = false;
		}
 
		if ( IsPC() )
		{
			// Good place to backup our counts
			WriteSaveData();
		}
	}
	else if ( Q_strcmp( name, "game_newmap" ) == 0 )
	{
		if ( gameinstructor_verbose.GetInt() > 0 )
		{
			ConColorMsg( CBaseLesson::m_rgbaVerboseHeader, "[INSTRUCTOR]: " );
			ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "New map...\n" );
		}
 
		CloseAllOpenOpportunities();
 
		if ( m_bNoDraw )
		{
			if ( gameinstructor_verbose.GetInt() > 0 )
			{
				ConColorMsg( Color( 255, 128, 64, 255 ), "[INSTRUCTOR]: " );
				ConColorMsg( Color( 64, 128, 255, 255 ), "Set to draw...\n" );
			}
 
			m_bNoDraw = false;
		}
 
		if ( IsPC() )
		{
			// Good place to backup our counts
			WriteSaveData();
		}
	}
 
	else if ( Q_strcmp( name, "set_instructor_group_enabled" ) == 0 )
	{
		const char *pszGroup	= event->GetString( "group" );
		bool bEnabled			= event->GetInt( "enabled" ) != 0;
 
		if ( pszGroup && pszGroup[0] )
			SetLessonGroupEnabled(pszGroup, bEnabled);
	}
}
Esempio n. 28
0
	DETOUR_DECL_STATIC(string_t, AllocPooledString, const char *pszValue)
	{
		ConColorMsg(Color(0xff, 0xff, 0x00, 0xff), "AllocPooledString(%s)\n", pszValue);
		return DETOUR_STATIC_CALL(AllocPooledString)(pszValue);
	}