Example #1
0
void game_sv_GameState::on_death	(CSE_Abstract *e_dest, CSE_Abstract *e_src)
{
	CSE_ALifeCreatureAbstract	*creature = smart_cast<CSE_ALifeCreatureAbstract*>(e_dest);
	if (!creature)
		return;

	VERIFY						(creature->get_killer_id() == ALife::_OBJECT_ID(-1));
	creature->set_killer_id		( e_src->ID );
}
Example #2
0
BOOL CEntity::net_Spawn		(CSE_Abstract* DC)
{
	m_level_death_time		= 0;
	m_game_death_time		= 0;
	m_killer_id				= ALife::_OBJECT_ID(-1);

	CSE_Abstract				*e	= (CSE_Abstract*)(DC);
	CSE_ALifeCreatureAbstract	*E	= smart_cast<CSE_ALifeCreatureAbstract*>(e);

	// Initialize variables
	if (E) {
		SetfHealth			(E->get_health());

		R_ASSERT2(!((E->get_killer_id() != ALife::_OBJECT_ID(-1)) && g_Alive()), make_string("server entity [%s][%d] has an killer [%d] and not dead",
			E->name_replace(), E->ID, E->get_killer_id()).c_str());

		m_killer_id			= E->get_killer_id();
		if (m_killer_id == ID())
			m_killer_id		= ALife::_OBJECT_ID(-1);
	}
	else
		SetfHealth			(1.0f);

	// load damage params
	if (!E) {
		// Car or trader only!!!!
		CSE_ALifeCar		*C	= smart_cast<CSE_ALifeCar*>(e);
		CSE_ALifeTrader		*T	= smart_cast<CSE_ALifeTrader*>(e);
		CSE_ALifeHelicopter	*H	= smart_cast<CSE_ALifeHelicopter*>(e);

		R_ASSERT2			(C||T||H,"Invalid entity (no inheritance from CSE_CreatureAbstract, CSE_ALifeItemCar and CSE_ALifeTrader and CSE_ALifeHelicopter)!");
		id_Team				= id_Squad = id_Group = 0;
	}
	else {
		id_Team				= E->g_team();
		id_Squad			= E->g_squad();
		id_Group			= E->g_group();

		CSE_ALifeMonsterBase	*monster	= smart_cast<CSE_ALifeMonsterBase*>(E);
		if (monster) {
			MONSTER_COMMUNITY		monster_community;
			monster_community.set	(pSettings->r_string(*cNameSect(), "species"));

			if(monster_community.team() != 255)
				id_Team = monster_community.team();
		}
	}

	if (g_Alive() && IsGameTypeSingle()) {
		m_registered_member		= true;
		Level().seniority_holder().team(g_Team()).squad(g_Squad()).group(g_Group()).register_member(this);
		++Level().seniority_holder().team(g_Team()).squad(g_Squad()).group(g_Group()).m_dwAliveCount;
	}

	if(!g_Alive())
	{
		m_level_death_time		= Device.dwTimeGlobal;
		m_game_death_time		= E->m_game_death_time;;
	}

	if (!inherited::net_Spawn(DC))
		return				(FALSE);

//	SetfHealth			(E->fHealth);
	IKinematics* pKinematics=smart_cast<IKinematics*>(Visual());
	CInifile* ini = NULL;

	if(pKinematics) ini = pKinematics->LL_UserData();
	if (ini) {
		if (ini->section_exist("damage_section") && !use_simplified_visual())
			CDamageManager::reload(pSettings->r_string("damage_section","damage"),ini);

		CParticlesPlayer::LoadParticles(pKinematics);
	}
	return					TRUE;
}