Ejemplo n.º 1
0
bool SecurityCamera::OnTrigger(HOBJECT hSender, const CParsedMsg &cMsg)
{
	static CParsedMsg::CToken s_cTok_Off(s_szOff);
	static CParsedMsg::CToken s_cTok_Reset(s_szReset);
	static CParsedMsg::CToken s_cTok_Gadget(s_szGadget);
	static CParsedMsg::CToken s_cTok_Tripped(s_szTripped);

	if (cMsg.GetArg(0) == s_cTok_Off)
	{
		SetState(eStateOff);
	}
	else if (cMsg.GetArg(0) == s_cTok_Reset)
	{
		SetState(eStateReset);
	}
	else if (cMsg.GetArg(0) == s_cTok_Gadget)
	{
		HandleGadgetMsg(cMsg);
	}
	else if (cMsg.GetArg(0) == s_cTok_Tripped)
	{
		m_bTripped = LTTRUE;
		SetLightColor(eRed);
		SetState(eStateOff);
	}
	else
		return CScanner::OnTrigger(hSender, cMsg);

	return true;
}
uint32 Intelligence::ObjectMessageFn(HOBJECT hSender, uint32 messageID, HMESSAGEREAD hRead)
{
    if (!g_pLTServer) return 0;

	switch(messageID)
	{
		case MID_TRIGGER:
		{
			const char* szMsg = (const char*)g_pLTServer->ReadFromMessageDWord(hRead);

			// ConParse does not destroy szMsg, so this is safe
			ConParse parse;
			parse.Init((char*)szMsg);

            while (g_pLTServer->Common()->Parse(&parse) == LT_OK)
			{
				if (parse.m_nArgs > 0 && parse.m_Args[0])
				{
					if (_stricmp(parse.m_Args[0], s_szActivate) == 0)
					{
						if (!m_bPhotoOnly)
						{
							DoActivate(hSender);
						}
					}
					else if (_stricmp(parse.m_Args[0], s_szGadget) == 0)
					{
						if (m_bPhotoOnly)
						{
							HandleGadgetMsg(hSender, parse);
						}
					}
					else if (_stricmp(parse.m_Args[0], s_szRespawn) == 0)
					{
						SetNextUpdate( m_fRespawnDelay / g_IntelRespawnScale.GetFloat(1.0f));
					}
				}
			}
		}
		break;

		default : break;
	}

	return Prop::ObjectMessageFn(hSender, messageID, hRead);
}
Ejemplo n.º 3
0
uint32 Lock::ObjectMessageFn(HOBJECT hSender, uint32 messageID, HMESSAGEREAD hRead)
{
    if (!g_pLTServer) return 0;

	switch(messageID)
	{
		case MID_TRIGGER:
		{
            ILTCommon* pCommon = g_pLTServer->Common();
			if (!pCommon) return 0;

			const char *szMsg = (const char*)g_pLTServer->ReadFromMessageDWord(hRead);

			// ConParse does not destroy szMsg, so this is safe
			ConParse parse;
			parse.Init((char*)szMsg);

			while (pCommon->Parse(&parse) == LT_OK)
			{
				if (parse.m_nArgs > 0 && parse.m_Args[0])
				{
					if (_stricmp(parse.m_Args[0], s_szGadget) == 0)
					{
						HandleGadgetMsg(hSender, parse);
					}
				}
			}
		}
		break;

		case MID_DAMAGE:
		{
			if (m_bUnlocked) break;

            uint32 dwRet = 0;

			DamageStruct damage;
			damage.InitFromMessage(hRead);

            LTBOOL bProcessDamage = m_bShootable;

			if (!bProcessDamage)
			{
				if (m_bWeldable)
				{
					bProcessDamage = (damage.eType == DT_GADGET_WELDER);
				}
				else if (m_bLightable)
				{
					bProcessDamage = (damage.eType == DT_GADGET_LIGHTER);
				}
				else
				{
					bProcessDamage = (damage.eType == DT_GADGET_LOCK_PICK);
				}
			}

			if (bProcessDamage)
			{
				dwRet = Prop::ObjectMessageFn(hSender, messageID, hRead);

				if (m_damage.IsDead())
				{
					SetupUnlockState();
				}
			}

			return dwRet;
		}
		break;

		default : break;
	}

	return Prop::ObjectMessageFn(hSender, messageID, hRead);
}
Ejemplo n.º 4
0
uint32 SecurityCamera::ObjectMessageFn(HOBJECT hSender, uint32 messageID, HMESSAGEREAD hRead)
{
    if (!g_pLTServer) return 0;

	switch(messageID)
	{
		case MID_TRIGGER:
		{
            ILTCommon* pCommon = g_pLTServer->Common();
			if (!pCommon) return 0;

			const char *szMsg = (const char*)g_pLTServer->ReadFromMessageDWord(hRead);

			// ConParse does not destroy szMsg, so this is safe
			ConParse parse;
			parse.Init((char*)szMsg);

			while (pCommon->Parse(&parse) == LT_OK)
			{
				if (parse.m_nArgs > 0 && parse.m_Args[0])
				{
					if (_stricmp(parse.m_Args[0], s_szOff) == 0)
					{
						SetState(eStateOff);
					}
					else if (_stricmp(parse.m_Args[0], s_szReset) == 0)
					{
						SetState(eStateReset);
					}
					else if (_stricmp(parse.m_Args[0], s_szGadget) == 0)
					{
						HandleGadgetMsg(parse);
					}
					else if (_stricmp(parse.m_Args[0], s_szTripped) == 0)
					{
						m_bTripped = LTTRUE;

						// Make sure the camera is set to use the red light...

						char buf[128];
						g_pServerButeMgr->GetSecurityCameraString(
							"RedLight", buf, ARRAY_LEN(buf));

						g_pLTServer->SetObjectFilenames(m_hLight, buf, "");

						SetState(eStateOff);
					}
				}
			}
		}
		break;

		case MID_DAMAGE:
		{
			// Let our damage aggregate process the message first...

            uint32 dwRet = CScanner::ObjectMessageFn(hSender, messageID, hRead);

			// Check to see if we have been destroyed

			if (m_damage.IsDead())
			{
				SetState(eStateDestroyed);
			}
			return dwRet;
		}
		break;

		default : break;
	}

	return CScanner::ObjectMessageFn(hSender, messageID, hRead);
}