void CSE_ALifeMonsterAbstract::on_unregister () { inherited1::on_unregister(); RELATION_REGISTRY().ClearRelations (ID); brain().on_unregister (); if (m_group_id != 0xffff) ai().alife().groups().object(m_group_id).unregister_member (ID); }
int CScriptGameObject::GetAttitude (CScriptGameObject* pToWho) { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); VERIFY(pInventoryOwner); CInventoryOwner* pOthersInventoryOwner = smart_cast<CInventoryOwner*>(&pToWho->object()); VERIFY(pOthersInventoryOwner); return RELATION_REGISTRY().GetAttitude(pInventoryOwner, pOthersInventoryOwner); }
void CScriptGameObject::ChangeGoodwill(int delta_goodwill, CScriptGameObject* pWhoToSet) { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if (!pInventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"ChangeGoodwill available only for InventoryOwner"); return ; } RELATION_REGISTRY().ChangeGoodwill(pInventoryOwner->object_id(), pWhoToSet->object().ID(), delta_goodwill); }
int CScriptGameObject::GetGoodwill(CScriptGameObject* pToWho) { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if (!pInventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"GetGoodwill available only for InventoryOwner"); return 0; } return RELATION_REGISTRY().GetGoodwill(pInventoryOwner->object_id(), pToWho->object().ID()); }
void CActor::LostPdaContact (CInventoryOwner* pInvOwner) { CGameObject* GO = smart_cast<CGameObject*>(pInvOwner); if (GO) { for(int t = ALife::eRelationTypeFriend; t<ALife::eRelationTypeLast; ++t) { ALife::ERelationType tt = (ALife::ERelationType)t; Level().MapManager().RemoveMapLocation(RELATION_REGISTRY().GetSpotName(tt), GO->ID()); } Level().MapManager().RemoveMapLocation("deadbody_location", GO->ID()); }; }
void CScriptGameObject::SetCommunityGoodwill_obj( LPCSTR community, int goodwill ) { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if (!pInventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"SetCommunityGoodwill available only for InventoryOwner"); return; } CHARACTER_COMMUNITY c; c.set( community ); RELATION_REGISTRY().SetCommunityGoodwill( c.index(), pInventoryOwner->object_id(), goodwill ); }
ALife::ERelationType CAI_Stalker::tfGetRelationType (const CEntityAlive *tpEntityAlive) const { const CInventoryOwner* pOtherIO = smart_cast<const CInventoryOwner*>(tpEntityAlive); ALife::ERelationType relation = ALife::eRelationTypeDummy; if(pOtherIO && !(const_cast<CEntityAlive*>(tpEntityAlive)->cast_base_monster())) relation = RELATION_REGISTRY().GetRelationType(static_cast<const CInventoryOwner*>(this), pOtherIO); if(ALife::eRelationTypeDummy != relation) return relation; else return inherited::tfGetRelationType(tpEntityAlive); }
void CScriptGameObject::SetRelation(ALife::ERelationType relation, CScriptGameObject* pWhoToSet) { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if (!pInventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"SetRelation available only for InventoryOwner"); return ; } CInventoryOwner* pOthersInventoryOwner = smart_cast<CInventoryOwner*>(&pWhoToSet->object()); VERIFY(pOthersInventoryOwner); if (!pOthersInventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"SetRelation available only for InventoryOwner"); return ; } RELATION_REGISTRY().SetRelationType(pInventoryOwner, pOthersInventoryOwner, relation); }
void CAI_PhraseDialogManager::AnswerPhrase (DIALOG_SHARED_PTR& phrase_dialog) { CInventoryOwner* pInvOwner = smart_cast<CInventoryOwner*>(this); THROW (pInvOwner); CGameObject* pOthersGO = smart_cast<CGameObject*>(phrase_dialog->OurPartner(this)); THROW (pOthersGO); CInventoryOwner* pOthersIO = smart_cast<CInventoryOwner*>(pOthersGO); THROW (pOthersIO); if(!phrase_dialog->IsFinished()) { CHARACTER_GOODWILL attitude = RELATION_REGISTRY().GetAttitude(pOthersIO, pInvOwner); xr_vector<int> phrases; CHARACTER_GOODWILL phrase_goodwill = NO_GOODWILL; //если не найдем более подход¤ещей выводим фразу //последнюю из списка (самую грубую) int phrase_num = phrase_dialog->PhraseList().size()-1; for(u32 i=0; i<phrase_dialog->PhraseList().size(); ++i) { phrase_goodwill = phrase_dialog->PhraseList()[phrase_num]->GoodwillLevel(); if(attitude >= phrase_goodwill) { phrase_num = i; break; } } for(u32 i=0; i<phrase_dialog->PhraseList().size(); i++) { if(phrase_goodwill == phrase_dialog->PhraseList()[phrase_num]->GoodwillLevel()) phrases.push_back(i); } phrase_num = phrases[Random.randI(0, phrases.size())]; shared_str phrase_id = phrase_dialog->PhraseList()[phrase_num]->GetID(); CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame()); pGameSP->TalkMenu->AddAnswer (phrase_dialog->GetPhraseText(phrase_id), pInvOwner->Name()); CPhraseDialogManager::SayPhrase(phrase_dialog, phrase_id); } }
void CActor::LostPdaContact (CInventoryOwner* pInvOwner) { CGameObject* GO = smart_cast<CGameObject*>(pInvOwner); if (GO){ for(int t = ALife::eRelationTypeFriend; t<ALife::eRelationTypeLast; ++t){ ALife::ERelationType tt = (ALife::ERelationType)t; Level().MapManager().RemoveMapLocation(RELATION_REGISTRY().GetSpotName(tt), GO->ID()); } Level().MapManager().RemoveMapLocation("deadbody_location", GO->ID()); }; if( HUD().GetUI() ){ CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame()); if(pGameSP){ pGameSP->PdaMenu->PdaContentsChanged (pda_section::contacts); } } }
void CUIActorInfoWnd::FillReputationDetails(CUIXml* xml, LPCSTR path) { XML_NODE* _list_node = xml->NavigateToNode ("relation_communities_list",0); int cnt = xml->GetNodesNum ("relation_communities_list",0,"r"); CHARACTER_COMMUNITY comm; CHARACTER_REPUTATION rep_actor, rep_neutral; rep_actor.set (Actor()->Reputation()); rep_neutral.set (NEUTAL_REPUTATION); CHARACTER_GOODWILL d_neutral = CHARACTER_REPUTATION::relation(rep_actor.index(), rep_neutral.index()); string64 buff; for(int i=0;i<cnt;++i) { CUIActorStaticticDetail* itm = xr_new<CUIActorStaticticDetail>(); itm->Init (xml, path, 0); comm.set (xml->Read(_list_node,"r",i,"unknown_community")); itm->m_text1->SetTextST (*(comm.id())); CHARACTER_GOODWILL gw = RELATION_REGISTRY().GetCommunityGoodwill(comm.index(), Actor()->ID()); gw += CHARACTER_COMMUNITY::relation(Actor()->Community(),comm.index()); gw += d_neutral; itm->m_text2->SetTextST (InventoryUtilities::GetGoodwillAsText(gw)); itm->m_text2->SetTextColor (InventoryUtilities::GetGoodwillColor(gw)); sprintf_s (buff,"%d", gw); itm->m_text3->SetTextST (buff); UIDetailList->AddWindow (itm, true); } }
void CHUDTarget::Render() { VERIFY (g_bRendering); CObject* O = Level().CurrentEntity(); if (0==O) return; CEntity* E = smart_cast<CEntity*>(O); if (0==E) return; Fvector p1 = Device.vCameraPosition; Fvector dir = Device.vCameraDirection; // Render cursor u32 C = C_DEFAULT; FVF::TL PT; Fvector p2; p2.mad (p1,dir,RQ.range); PT.transform (p2,Device.mFullTransform); float di_size = C_SIZE/powf(PT.p.w,.2f); CGameFont* F = HUD().Font().pFontGraffiti19Russian; F->SetAligment (CGameFont::alCenter); F->OutSetI (0.f,0.05f); if (psHUD_Flags.test(HUD_CROSSHAIR_DIST)){ F->SetColor (C); F->OutNext ("%4.1f",RQ.range); } if (psHUD_Flags.test(HUD_INFO)){ if (RQ.O){ CEntityAlive* E = smart_cast<CEntityAlive*> (RQ.O); CEntityAlive* pCurEnt = smart_cast<CEntityAlive*> (Level().CurrentEntity()); PIItem l_pI = smart_cast<PIItem> (RQ.O); if (IsGameTypeSingle()) { CInventoryOwner* our_inv_owner = smart_cast<CInventoryOwner*>(pCurEnt); if (E && E->g_Alive() && !E->cast_base_monster()) { //. CInventoryOwner* our_inv_owner = smart_cast<CInventoryOwner*>(pCurEnt); CInventoryOwner* others_inv_owner = smart_cast<CInventoryOwner*>(E); if(our_inv_owner && others_inv_owner){ switch(RELATION_REGISTRY().GetRelationType(others_inv_owner, our_inv_owner)) { case ALife::eRelationTypeEnemy: C = C_ON_ENEMY; break; case ALife::eRelationTypeNeutral: C = C_ON_NEUTRAL; break; case ALife::eRelationTypeFriend: C = C_ON_FRIEND; break; } if (fuzzyShowInfo>0.5f){ CStringTable strtbl ; F->SetColor (subst_alpha(C,u8(iFloor(255.f*(fuzzyShowInfo-0.5f)*2.f)))); F->OutNext ("%s", *strtbl.translate(others_inv_owner->Name()) ); F->OutNext ("%s", *strtbl.translate(others_inv_owner->CharacterInfo().Community().id()) ); } } fuzzyShowInfo += SHOW_INFO_SPEED*Device.fTimeDelta; } else if (l_pI && our_inv_owner && RQ.range < 2.0f*our_inv_owner->inventory().GetTakeDist()) { if (fuzzyShowInfo>0.5f){ F->SetColor (subst_alpha(C,u8(iFloor(255.f*(fuzzyShowInfo-0.5f)*2.f)))); F->OutNext ("%s",l_pI->Name/*Complex*/()); } fuzzyShowInfo += SHOW_INFO_SPEED*Device.fTimeDelta; } } else { if (E && (E->GetfHealth()>0)) { if (pCurEnt && GameID() == GAME_SINGLE){ if (GameID() == GAME_DEATHMATCH) C = C_ON_ENEMY; else{ if (E->g_Team() != pCurEnt->g_Team()) C = C_ON_ENEMY; else C = C_ON_FRIEND; }; if (RQ.range >= recon_mindist() && RQ.range <= recon_maxdist()){ float ddist = (RQ.range - recon_mindist())/(recon_maxdist() - recon_mindist()); float dspeed = recon_minspeed() + (recon_maxspeed() - recon_minspeed())*ddist; fuzzyShowInfo += Device.fTimeDelta/dspeed; }else{ if (RQ.range < recon_mindist()) fuzzyShowInfo += recon_minspeed()*Device.fTimeDelta; else fuzzyShowInfo = 0; }; if (fuzzyShowInfo>0.5f){ clamp(fuzzyShowInfo,0.f,1.f); int alpha_C = iFloor(255.f*(fuzzyShowInfo-0.5f)*2.f); u8 alpha_b = u8(alpha_C & 0x00ff); F->SetColor (subst_alpha(C,alpha_b)); F->OutNext ("%s",*RQ.O->cName()); } } }; }; }else{ fuzzyShowInfo -= HIDE_INFO_SPEED*Device.fTimeDelta; } clamp(fuzzyShowInfo,0.f,1.f); } //отрендерить кружочек или крестик if(!m_bShowCrosshair){ // actual rendering u32 vOffset; FVF::TL* pv = (FVF::TL*)RCache.Vertex.Lock(4,hGeom.stride(),vOffset); float size_x = float(Device.dwWidth) * di_size; float size_y = float(Device.dwHeight) * di_size; size_y = size_x; float w_2 = Device.fWidth_2; float h_2 = Device.fHeight_2; // Convert to screen coords float cx = (PT.p.x+1)*w_2; float cy = (PT.p.y+1)*h_2; pv->set (cx - size_x, cy + size_y, C, 0, 1); ++pv; pv->set (cx - size_x, cy - size_y, C, 0, 0); ++pv; pv->set (cx + size_x, cy + size_y, C, 1, 1); ++pv; pv->set (cx + size_x, cy - size_y, C, 1, 0); ++pv; // unlock VB and Render it as triangle LIST RCache.Vertex.Unlock(4,hGeom.stride()); RCache.set_Shader (hShader); RCache.set_Geometry (hGeom); RCache.Render (D3DPT_TRIANGLELIST,vOffset,0,4,0,2); }else{ //отрендерить прицел HUDCrosshair.cross_color = C; HUDCrosshair.OnRender (); } }
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; }