bool
astPlayerShip::CollisionCallback( const colEvent &event )
{
	if ( event.colFlags & ColFlag_Enemy )
	{
		if ( !m_spawnInvulnerable )
			SetDestroyed();
		return true;
	}

	return false;
}
int RPG_DestructibleEntity::TakeDamage( const int damageAmount, const hkvVec3& impactVelocity /*= hkvVec3(0,0,0)*/ )
{
  CreateEffect(DEFX_TakeHit);
  if(damageAmount >= m_health)
  {
    SetDestroyed();
    return m_health;
  }
  else
  {
    m_health -= damageAmount;
    return damageAmount;
  }
}
uint32 ScaleSprite::ObjectMessageFn(HOBJECT hSender, uint32 messageID, HMESSAGEREAD hRead)
{
	switch(messageID)
	{
 		case MID_TRIGGER:
		{
			const char* szMsg = (const char*)g_pLTServer->ReadFromMessageDWord(hRead);

			if (stricmp(szMsg, "DESTROY") == 0)
			{
				SetDestroyed();
			}
			else if (stricmp(szMsg, "DAMAGE") == 0)
			{
				SetDamaged();
			}
			else if (stricmp(szMsg, "ON") == 0)
			{
				if (m_hObject)
				{
                    uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject);
                    g_pLTServer->SetObjectFlags(m_hObject, dwFlags | FLAG_VISIBLE);

                    uint32 dwUsrFlags = g_pLTServer->GetObjectUserFlags(m_hObject);
                    g_pLTServer->SetObjectUserFlags(m_hObject, dwUsrFlags | USRFLG_VISIBLE);
				}
			}
			else if (stricmp(szMsg, "OFF") == 0)
			{
				if (m_hObject)
				{
                    uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject);
                    g_pLTServer->SetObjectFlags(m_hObject, dwFlags & ~FLAG_VISIBLE);

                    uint32 dwUsrFlags = g_pLTServer->GetObjectUserFlags(m_hObject);
                    g_pLTServer->SetObjectUserFlags(m_hObject, dwUsrFlags & ~USRFLG_VISIBLE);
				}
			}
		}
		default : break;
	}

	return GameBase::ObjectMessageFn (hSender, messageID, hRead);
}
Esempio n. 4
0
bool ScaleSprite::OnTrigger(HOBJECT hSender, const CParsedMsg &cMsg)
{
	static CParsedMsg::CToken s_cTok_Destroy("DESTROY");
	static CParsedMsg::CToken s_cTok_Damage("DAMAGE");
	static CParsedMsg::CToken s_cTok_On("ON");
	static CParsedMsg::CToken s_cTok_Off("OFF");

	if (cMsg.GetArg(0) == s_cTok_Destroy)
	{
		SetDestroyed();
	}
	else if (cMsg.GetArg(0) == s_cTok_Damage)
	{
		SetDamaged();
	}
	else if (cMsg.GetArg(0) == s_cTok_On)
	{
		if (m_hObject)
		{
			g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE);

			g_pCommonLT->SetObjectFlags(m_hObject, OFT_User, USRFLG_VISIBLE, USRFLG_VISIBLE);
		}
	}
	else if (cMsg.GetArg(0) == s_cTok_Off)
	{
		if (m_hObject)
		{
			g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, 0, FLAG_VISIBLE);

			g_pCommonLT->SetObjectFlags(m_hObject, OFT_User, 0, USRFLG_VISIBLE);
		}
	}
	else
		return GameBase::OnTrigger(hSender, cMsg);

	return true;
}