Ejemplo n.º 1
0
void CUICharacterInfo::Update()
{
	inherited::Update();

	if ( hasOwner() && ( m_bForceUpdate ||(Device.dwFrame%50 == 0) )  )
	{
		m_bForceUpdate = false;

		CSE_ALifeTraderAbstract* T = detail::object_exists_in_alife_registry(m_ownerID) ?
									 ch_info_get_from_id(m_ownerID) : NULL;
		if (NULL==T){
			m_ownerID = u16(-1);
			return;
		}
		else
		{
			UpdateRelation();
		}

		if ( m_icons[eIcon] )
		{
			CSE_ALifeCreatureAbstract*		pCreature = smart_cast<CSE_ALifeCreatureAbstract*>(T);
			if ( pCreature && !pCreature->g_Alive() )
			{
				m_icons[eIcon]->SetTextureColor(color_argb(255,255,160,160));
			}
		}
	}
}
Ejemplo n.º 2
0
bool  se_obj_is_alive(CSE_ALifeObject *O)
{
	CSE_ALifeCreatureAbstract *cr = smart_cast<CSE_ALifeCreatureAbstract *> (O);
	if (cr)
		return cr->g_Alive();
	else
		return  false;
}
Ejemplo n.º 3
0
bool CRelationMapLocation::Update()
{
	if (false==inherited::Update() ) return false;
	
	bool bAlive = true;

	m_last_relation = ALife::eRelationTypeFriend;

	if(m_owner_se_object)
	{
		CSE_ALifeTraderAbstract*	pEnt = NULL;
		CSE_ALifeTraderAbstract*	pAct = NULL;
		pEnt = smart_cast<CSE_ALifeTraderAbstract*>(m_owner_se_object);
		pAct = smart_cast<CSE_ALifeTraderAbstract*>(ai().alife().objects().object(m_pInvOwnerActorID,true));
		if(!pEnt || !pAct)	
			return false;

		m_last_relation =  RELATION_REGISTRY().GetRelationType(pEnt, pAct);
		CSE_ALifeCreatureAbstract*		pCreature = smart_cast<CSE_ALifeCreatureAbstract*>(m_owner_se_object);
		if(pCreature) //maybe trader ?
			bAlive = pCreature->g_Alive		();
	}else
	{
		CInventoryOwner*			pEnt = NULL;
		CInventoryOwner*			pAct = NULL;

		pEnt = smart_cast<CInventoryOwner*>(Level().Objects.net_Find(m_objectID));
		pAct = smart_cast<CInventoryOwner*>(Level().Objects.net_Find(m_pInvOwnerActorID));
		if(!pEnt || !pAct)	
			return false;

		m_last_relation =  RELATION_REGISTRY().GetRelationType(pEnt, pAct);
		CEntityAlive* pEntAlive = smart_cast<CEntityAlive*>(pEnt);
		if(pEntAlive)
			bAlive = !!pEntAlive->g_Alive		();
	}
	shared_str sname;

	if(bAlive==false)
		sname = "deadbody_location";
	else
		sname = RELATION_REGISTRY().GetSpotName(m_last_relation);

	if(m_curr_spot_name != sname){
		LoadSpot(*sname, true);
		m_curr_spot_name = sname;
	}
// update visibility
	bool vis_res = true;
	if(m_last_relation==ALife::eRelationTypeEnemy || m_last_relation==ALife::eRelationTypeWorstEnemy)
	{
		CObject* _object_ = Level().Objects.net_Find(m_objectID);
		if(_object_)
		{
			CEntityAlive* ea = smart_cast<CEntityAlive*>(_object_);
			if(ea&&!ea->g_Alive()) 
				vis_res =  true;	
			else
			{
				const CGameObject* pObj = smart_cast<const CGameObject*>(_object_);
				CActor* pAct = smart_cast<CActor*>(Level().Objects.net_Find(m_pInvOwnerActorID));
				CHelmet* helm = smart_cast<CHelmet*>(pAct->inventory().ItemFromSlot(HELMET_SLOT));
				if(helm && helm->m_fShowNearestEnemiesDistance)
				{
					if(pAct->Position().distance_to(pObj->Position()) < helm->m_fShowNearestEnemiesDistance)
						vis_res = true;
					else
						vis_res = Actor()->memory().visual().visible_now(pObj);
				}
				else
					vis_res = Actor()->memory().visual().visible_now(pObj);
			}
		}
		else
			vis_res = false;
	}

	if(bAlive==false)
	{
		CObject* _object_ = Level().Objects.net_Find(m_objectID);
		if(_object_)
		{
			const CGameObject* pObj = smart_cast<const CGameObject*>(_object_);
			CActor* pAct = smart_cast<CActor*>(Level().Objects.net_Find(m_pInvOwnerActorID));
			if(/*pAct->Position().distance_to_sqr(pObj->Position()) < 100.0F && */abs(pObj->Position().y-pAct->Position().y)<3.0f)
				vis_res = true;
			else
				vis_res = false;
		}
		else
			vis_res = false;
	}
	
	if(m_b_visible==false && vis_res==true)
		m_minimap_spot->ResetXformAnimation();

	m_b_visible = vis_res;	

	if(m_b_visible)
	{
		m_b_minimap_visible		= true;
		m_b_levelmap_visible	= true;

		if (Level().MapManager().GetMapLocationsForObject(m_objectID, find_locations_res) )
		{
			xr_vector<CMapLocation*>::iterator it = find_locations_res.begin();
			xr_vector<CMapLocation*>::iterator it_e = find_locations_res.end();
			for(;it!=it_e;++it)
			{
				CMapLocation* ml = (*it);
				if(ml==this)
					continue;

				m_b_minimap_visible	= m_b_minimap_visible && (ml->MiniMapSpot()==NULL);
				m_b_levelmap_visible= m_b_levelmap_visible && (ml->LevelMapSpot()==NULL);
			}
			
		}

	}

	return true;
}