uint32 CDestructibleModel::ObjectMessageFn(LPBASECLASS pObject, HOBJECT hSender, ILTMessage_Read *pMsg)
{
	uint32 dwRet = CDestructible::ObjectMessageFn(pObject, hSender, pMsg);

	pMsg->SeekTo(0);
	uint32 messageID = pMsg->Readuint32();
	switch(messageID)
	{
		case MID_DAMAGE:
		{
			if (IsDead() && !m_bCreatedDebris)
			{
                ILTServer* pServerDE = BaseClass::GetServerDE();
				if (!pServerDE) break;

				SpawnItem();
				CreateDebris();
				CreateWorldModelDebris();

				if (m_bCreateExplosion)
				{
					DoExplosion();
				}

				RegisterDestroyedStimulus();

				m_bCreatedDebris = LTTRUE;

				if (m_bRemoveOnDeath)
				{
					pServerDE->RemoveObject(m_hObject);
				}
			}
		}
		break;

		case MID_TRIGGER:
		{
			const char* szMsg = (const char*)pMsg->Readuint32();

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

			while (g_pCommonLT->Parse(&parse) == LT_OK)
			{
				if (parse.m_nArgs > 0 && parse.m_Args[0])
				{
					if (!IsDead())
					{
						if (_stricmp(parse.m_Args[0], "FIRE") == 0)
						{
							char* pTargetName = parse.m_nArgs > 1 ? parse.m_Args[1] : LTNULL;
							DoExplosion(pTargetName);
						}
						else if (_stricmp(parse.m_Args[0], "HIDDEN") == 0)
						{
							// Game Base will take care of the solid and visible flags for us...

							if (parse.m_nArgs > 1 && parse.m_Args[1])
							{
								if ((_stricmp(parse.m_Args[1], "1") == 0) ||
									(_stricmp(parse.m_Args[1], "TRUE") == 0))
								{
									m_bSaveCanDamage = GetCanDamage();
									m_bSaveNeverDestroy = GetNeverDestroy();

									SetCanDamage(LTFALSE);
									SetNeverDestroy(LTTRUE);
								}
								else
								{
									if ((_stricmp(parse.m_Args[1], "0") == 0) ||
										(_stricmp(parse.m_Args[1], "FALSE") == 0))
									{
										SetCanDamage(m_bSaveCanDamage);
										SetNeverDestroy(m_bSaveNeverDestroy);
									}
								}
							}
						}

					}
				}
			}
		}
		break;

		default : break;
	}

	return dwRet;
}
Beispiel #2
0
uint32 CDestructibleModel::ObjectMessageFn(LPBASECLASS pObject, HOBJECT hSender, uint32 messageID, HMESSAGEREAD hRead)
{
	uint32 dwRet = CDestructible::ObjectMessageFn(pObject, hSender, messageID, hRead);

	switch(messageID)
	{
		case MID_DAMAGE:
		{
			if (IsDead() && !m_bCreatedDebris)
			{
                ILTServer* pServerDE = BaseClass::GetServerDE();
				if (!pServerDE) break;

				SpawnItem();
				CreateDebris();
				CreateWorldModelDebris();

				if (m_bCreateExplosion)
				{
					DoExplosion();
				}

				m_bCreatedDebris = LTTRUE;

				if (m_bRemoveOnDeath)
				{
					pServerDE->RemoveObject(m_hObject);
				}
			}
		}
		break;

		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 (!IsDead())
					{
						if (_stricmp(parse.m_Args[0], "FIRE") == 0)
						{
							char* pTargetName = parse.m_nArgs > 1 ? parse.m_Args[1] : LTNULL;
							DoExplosion(pTargetName);
						}
						else if (_stricmp(parse.m_Args[0], "HIDDEN") == 0)
						{
							uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject);

							if (parse.m_nArgs > 1 && parse.m_Args[1])
							{
								if ((_stricmp(parse.m_Args[1], "1") == 0) ||
									(_stricmp(parse.m_Args[1], "TRUE") == 0))
								{
									dwFlags = 0;

									m_bSaveCanDamage = GetCanDamage();
									m_bSaveNeverDestroy = GetNeverDestroy();

									SetCanDamage(LTFALSE);
									SetNeverDestroy(LTTRUE);
								}
								else
								{
									if ((_stricmp(parse.m_Args[1], "0") == 0) ||
										(_stricmp(parse.m_Args[1], "FALSE") == 0))
									{
										dwFlags = m_dwOriginalFlags;
										dwFlags |= FLAG_VISIBLE;

										SetCanDamage(m_bSaveCanDamage);
										SetNeverDestroy(m_bSaveNeverDestroy);
									}
								}

								g_pLTServer->SetObjectFlags(m_hObject, dwFlags);
							}
						}
					}
				}
			}
		}
		break;

		default : break;
	}

	return dwRet;
}