void CActor::UpdateAvailableDialogs (CPhraseDialogManager* partner) { m_AvailableDialogs.clear(); m_CheckedDialogs.clear(); if(CInventoryOwner::m_known_info_registry->registry().objects_ptr()) { for(KNOWN_INFO_VECTOR::const_iterator it = CInventoryOwner::m_known_info_registry->registry().objects_ptr()->begin(); CInventoryOwner::m_known_info_registry->registry().objects_ptr()->end() != it; ++it) { //подгрузить кусочек информации с которым мы работаем CInfoPortion info_portion; info_portion.Load((*it).info_id); for(u32 i = 0; i<info_portion.DialogNames().size(); i++) AddAvailableDialog(*info_portion.DialogNames()[i], partner); } } //добавить актерский диалог собеседника CInventoryOwner* pInvOwnerPartner = smart_cast<CInventoryOwner*>(partner); VERIFY(pInvOwnerPartner); for(u32 i = 0; i<pInvOwnerPartner->CharacterInfo().ActorDialogs().size(); i++) AddAvailableDialog(pInvOwnerPartner->CharacterInfo().ActorDialogs()[i], partner); CPhraseDialogManager::UpdateAvailableDialogs(partner); }
bool CScriptGameObject::DisableInfoPortion(LPCSTR info_id) { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if(!pInventoryOwner) return false; pInventoryOwner->TransferInfo(info_id, false); return true; }
bool CScriptGameObject::DontHasInfo (LPCSTR info_id) { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if(!pInventoryOwner) return true; return !pInventoryOwner->HasInfo(info_id); }
void CScriptGameObject::GiveMoney(int money) { CInventoryOwner* pOurOwner = smart_cast<CInventoryOwner*>(&object()); VERIFY(pOurOwner); pOurOwner->set_money (pOurOwner->get_money() + money, true ); }
void CPda::feel_touch_new(CObject* O) { if ( CInventoryOwner* pNewContactInvOwner = smart_cast<CInventoryOwner*>(O) ) { CInventoryOwner* pOwner = smart_cast<CInventoryOwner*>( H_Parent() );VERIFY(pOwner); pOwner->NewPdaContact (pNewContactInvOwner); } }
void CWeaponMagazined::state_Fire(float dt) { VERIFY(fTimeToFire > 0.f); Fvector p1, d; p1.set(get_LastFP()); d.set(get_LastFD()); if (!H_Parent()) return; CInventoryOwner* io = smart_cast<CInventoryOwner*>(H_Parent()); if (NULL == io->inventory().ActiveItem()) { Log("current_state", GetState()); Log("next_state", GetNextState()); Log("state_time", m_dwStateTime); Log("item_sect", cNameSect().c_str()); Log("H_Parent", H_Parent()->cNameSect().c_str()); } smart_cast<CEntity*> (H_Parent())->g_fireParams(this, p1, d); if (m_iShotNum == 0) { m_vStartPos = p1; m_vStartDir = d; }; VERIFY(!m_magazine.empty()); // Msg("%d && %d && (%d || %d) && (%d || %d)", !m_magazine.empty(), fTime<=0, IsWorking(), m_bFireSingleShot, m_iQueueSize < 0, m_iShotNum < m_iQueueSize); while (!m_magazine.empty() && fTime <= 0 && (IsWorking() || m_bFireSingleShot) && (m_iQueueSize < 0 || m_iShotNum < m_iQueueSize)) { m_bFireSingleShot = false; VERIFY(fTimeToFire > 0.f); fTime += fTimeToFire; ++m_iShotNum; OnShot(); static int i = 0; if (i || m_iShotNum > m_iShootEffectorStart) { // Do Weapon Callback. (Cribbledirge) StateSwitchCallback(GameObject::eOnActorWeaponFire, GameObject::eOnNPCWeaponFire); FireTrace(p1, d); } else { FireTrace(m_vStartPos, m_vStartDir); } } if (m_iShotNum == m_iQueueSize) m_bStopedAfterQueueFired = true; UpdateSounds(); }
void CPda::feel_touch_delete(CObject* O) { if(!H_Parent()) return; if ( CInventoryOwner* pLostContactInvOwner = smart_cast<CInventoryOwner*>(O) ) { CInventoryOwner* pOwner = smart_cast<CInventoryOwner*>( H_Parent() );VERIFY(pOwner); pOwner->LostPdaContact (pLostContactInvOwner); } }
void CUIInventoryWnd::Update() { if(m_b_need_reinit) InitInventory (); CEntityAlive *pEntityAlive = smart_cast<CEntityAlive*>(Level().CurrentEntity()); if(pEntityAlive) { float v = pEntityAlive->conditions().GetHealth()*100.0f; UIProgressBarHealth.SetProgressPos (v); v = pEntityAlive->conditions().GetPsyHealth()*100.0f; UIProgressBarPsyHealth.SetProgressPos (v); v = pEntityAlive->conditions().GetRadiation()*100.0f; UIProgressBarRadiation.SetProgressPos (v); #ifdef INV_NEW_SLOTS_SYSTEM if (GameID() == GAME_SINGLE){ CActor* m_pActor = smart_cast<CActor*>(Level().CurrentViewEntity()); v =(m_pActor->conditions().GetSatiety())*100.0f; UIProgressBarSatiety.SetProgressPos (v); } #endif CInventoryOwner* pOurInvOwner = smart_cast<CInventoryOwner*>(pEntityAlive); u32 _money = 0; if (GameID() != GAME_SINGLE){ game_PlayerState* ps = Game().GetPlayerByGameID(pEntityAlive->ID()); if (ps){ UIProgressBarRank.SetProgressPos(ps->experience_D*100); _money = ps->money_for_round; } }else { _money = pOurInvOwner->get_money(); } // update money string64 sMoney; //red_virus sprintf_s (sMoney,"%d %s", _money, *CStringTable().translate("ui_st_money_regional")); UIMoneyWnd.SetText (sMoney); // update outfit parameters CCustomOutfit* outfit = smart_cast<CCustomOutfit*>(pOurInvOwner->inventory().m_slots[OUTFIT_SLOT].m_pIItem); UIOutfitInfo.Update (outfit); } UIStaticTimeString.SetText(*InventoryUtilities::GetGameTimeAsString(InventoryUtilities::etpTimeToMinutes)); CUIWindow::Update (); }
void CScriptGameObject::SetSympathy( float sympathy ) { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if (!pInventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"SetSympathy available only for InventoryOwner"); return ; } pInventoryOwner->CharacterInfo().SetSympathy( sympathy ); }
CScriptGameObject *CScriptGameObject::GetCurrentOutfit() const { CInventoryOwner *inventoryOwner = smart_cast<CInventoryOwner*>(&object()); if (!inventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"CInventoryOwner : cannot access class member GetCurrentOutfit!"); return (0); } CGameObject *current_equipment = inventoryOwner->GetCurrentOutfit() ? &inventoryOwner->GetCurrentOutfit()->object() : 0; return (current_equipment ? current_equipment->lua_game_object() : 0); }
LPCSTR CScriptGameObject::sound_voice_prefix () const { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if (!pInventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"sound_voice_prefix available only for InventoryOwner"); return NULL; } return pInventoryOwner->SpecificCharacter().sound_voice_prefix(); }
LPCSTR CScriptGameObject::CharacterCommunity () { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if (!pInventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"CharacterCommunity available only for InventoryOwner"); return NULL; } return *pInventoryOwner->CharacterInfo().Community().id(); }
int CScriptGameObject::CharacterReputation () { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if (!pInventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"CharacterReputation available only for InventoryOwner"); return 0; } return pInventoryOwner->Reputation(); }
void CScriptGameObject::ChangeCharacterReputation (int char_rep) { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if (!pInventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"ChangeCharacterReputation available only for InventoryOwner"); return ; } pInventoryOwner->ChangeReputation(char_rep); }
float CScriptGameObject::GetSympathy() { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if (!pInventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"GetSympathy available only for InventoryOwner"); return 0.0f; } return pInventoryOwner->Sympathy(); }
void CScriptGameObject::SetCharacterRank (int char_rank) { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if (!pInventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"SetCharacterRank available only for InventoryOwner"); return ; } return pInventoryOwner->SetRank(char_rank); }
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()); }
xrTime CScriptGameObject::GetInfoTime (LPCSTR info_id) { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if(!pInventoryOwner) return xrTime(0); INFO_DATA info_data; if(pInventoryOwner->GetInfo(info_id, info_data)) return xrTime(info_data.receive_time); else return xrTime(0); }
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 ); }
float CScriptGameObject::GetCurrentOutfitProtection(int hit_type) { CInventoryOwner *inventoryOwner = smart_cast<CInventoryOwner*>(&object()); if (!inventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"CInventoryOwner : cannot access class member GetCurrentOutfitProtection!"); return (0); } CGameObject *current_equipment = &inventoryOwner->GetCurrentOutfit()->object(); CCustomOutfit* o = smart_cast<CCustomOutfit*>(current_equipment); if(!o) return 0.0f; return 1.0f - o->GetDefHitTypeProtection(ALife::EHitType(hit_type)); }
LPCSTR CScriptGameObject::ProfileName () { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if (!pInventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"ProfileName available only for InventoryOwner"); return NULL; } shared_str profile_id = pInventoryOwner->CharacterInfo().Profile(); if(!profile_id || !profile_id.size() ) return NULL; else return *profile_id; }
void CScriptGameObject::SetCharacterCommunity (LPCSTR comm, int squad, int group) { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); CEntity* entity = smart_cast<CEntity*>(&object()); if (!pInventoryOwner || !entity) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"SetCharacterCommunity available only for InventoryOwner"); return; } CHARACTER_COMMUNITY community; community.set(comm); pInventoryOwner->SetCommunity(community.index()); entity->ChangeTeam(community.team(), squad, group); }
int CScriptGameObject::CharacterRank () { // rank support for monster CBaseMonster *monster = smart_cast<CBaseMonster*>(&object()); if (!monster) { CInventoryOwner* pInventoryOwner = smart_cast<CInventoryOwner*>(&object()); if (!pInventoryOwner) { ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"CharacterRank available only for InventoryOwner and BaseMonster"); return 0; } return pInventoryOwner->Rank(); } return monster->Rank(); }
void CActor::UpdateAvailableDialogs (CPhraseDialogManager* partner) { m_AvailableDialogs.clear(); m_CheckedDialogs.clear(); //добавить актерский диалог собеседника CInventoryOwner* pInvOwnerPartner = smart_cast<CInventoryOwner*>(partner); VERIFY(pInvOwnerPartner); for(u32 i = 0; i<pInvOwnerPartner->CharacterInfo().ActorDialogs().size(); i++) AddAvailableDialog(pInvOwnerPartner->CharacterInfo().ActorDialogs()[i], partner); CPhraseDialogManager::UpdateAvailableDialogs(partner); }
void CWeaponMagazined::switch2_Fire() { CInventoryOwner* io = smart_cast<CInventoryOwner*>(H_Parent()); CInventoryItem* ii = smart_cast<CInventoryItem*>(this); #ifdef DEBUG VERIFY2(io, make_string("no inventory owner, item %s", *cName())); if (ii != io->inventory().ActiveItem()) Msg("! not an active item, item %s, owner %s, active item %s", *cName(), *H_Parent()->cName(), io->inventory().ActiveItem() ? *io->inventory().ActiveItem()->object().cName() : "no_active_item"); if (!(io && (ii == io->inventory().ActiveItem()))) { CAI_Stalker *stalker = smart_cast<CAI_Stalker*>(H_Parent()); if (stalker) { stalker->planner().show(); stalker->planner().show_current_world_state(); stalker->planner().show_target_world_state(); } } #else if (!io) return; #endif // DEBUG // // VERIFY2( // io && (ii == io->inventory().ActiveItem()), // make_string( // "item[%s], parent[%s]", // *cName(), // H_Parent() ? *H_Parent()->cName() : "no_parent" // ) // ); m_bStopedAfterQueueFired = false; m_bFireSingleShot = true; m_iShotNum = 0; if ((OnClient() || Level().IsDemoPlay()) && !IsWorking()) FireStart(); /* if(SingleShotMode()) { m_bFireSingleShot = true; bWorking = false; }*/ }
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 CUIInventoryWnd::Update() { if(m_b_need_reinit) InitInventory (); CEntityAlive *pEntityAlive = smart_cast<CEntityAlive*>(Level().CurrentEntity()); if(pEntityAlive) { float v = pEntityAlive->conditions().GetHealth()*100.0f; UIProgressBarHealth.SetProgressPos (v); v = pEntityAlive->conditions().GetPsyHealth()*100.0f; UIProgressBarPsyHealth.SetProgressPos (v); v = pEntityAlive->conditions().GetRadiation()*100.0f; UIProgressBarRadiation.SetProgressPos (v); if (GameID() != GAME_SINGLE){ game_PlayerState* ps = Game().GetPlayerByGameID(pEntityAlive->ID()); if (ps) UIProgressBarRank.SetProgressPos(ps->experience_D*100); } // update money CInventoryOwner* pOurInvOwner = smart_cast<CInventoryOwner*>(pEntityAlive); string64 sMoney; sprintf (sMoney,"%d RU", pOurInvOwner->get_money()); UIMoneyWnd.SetText (sMoney); // update outfit parameters CCustomOutfit* outfit = smart_cast<CCustomOutfit*>(pOurInvOwner->inventory().m_slots[OUTFIT_SLOT].m_pIItem); UIOutfitInfo.Update (outfit); } //. UITimeWnd.Update (); UIStaticTimeString.SetText(*InventoryUtilities::GetGameTimeAsString(InventoryUtilities::etpTimeToMinutes)); CUIWindow::Update (); }
void CScriptGameObject::ForEachInventoryItems(const luabind::functor<void> &functor) { CInventoryOwner* owner = smart_cast<CInventoryOwner*>(&object()); if(!owner){ ai().script_engine().script_log (ScriptStorage::eLuaMessageTypeError,"CScriptGameObject::ForEachInventoryItems non-CInventoryOwner object !!!"); return; } CInventory* pInv = &owner->inventory(); TIItemContainer item_list; pInv->AddAvailableItems(item_list, true); TIItemContainer::iterator it; for(it = item_list.begin(); item_list.end() != it; ++it) { CGameObject* inv_go = smart_cast<CGameObject*>(*it); if( inv_go ){ functor(inv_go->lua_game_object(),this); } } }
void CScriptGameObject::MakeItemActive(CScriptGameObject* pItem) { CInventoryOwner* owner = smart_cast<CInventoryOwner*>(&object()); CInventoryItem* item = smart_cast<CInventoryItem*>(&pItem->object()); u32 slot = item->GetSlot(); CInventoryItem* item_in_slot = owner->inventory().ItemFromSlot(slot); NET_Packet P; if(item_in_slot) { CGameObject::u_EventGen (P, GEG_PLAYER_ITEM2RUCK, owner->object_id()); P.w_u16 (item_in_slot->object().ID()); CGameObject::u_EventSend (P); } CGameObject::u_EventGen (P, GEG_PLAYER_ITEM2SLOT, owner->object_id()); P.w_u16 (item->object().ID()); CGameObject::u_EventSend (P); CGameObject::u_EventGen (P, GEG_PLAYER_ACTIVATE_SLOT, owner->object_id()); P.w_u32 (slot); CGameObject::u_EventSend (P); }