bool CActor::CanMove() { if( conditions().IsCantWalk() ) { if(mstate_wishful&mcAnyMove) { CurrentGameUI()->AddCustomStatic("cant_walk", true); } return false; }else if( conditions().IsCantWalkWeight() ) { if(mstate_wishful&mcAnyMove) { CurrentGameUI()->AddCustomStatic("cant_walk_weight", true); } return false; } if(IsTalking()) return false; else return true; }
void CUIActorMenu::Draw() { CurrentGameUI()->UIMainIngameWnd->DrawZoneMap(); CurrentGameUI()->UIMainIngameWnd->DrawMainIndicatorsForInventory(); inherited::Draw (); m_ItemInfo->Draw(); m_hint_wnd->Draw(); }
void CActor::AddGameNews (GAME_NEWS_DATA& news_data) { GAME_NEWS_VECTOR& news_vector = game_news_registry->registry().objects(); news_data.receive_time = Level().GetGameTime(); news_vector.push_back (news_data); if ( CurrentGameUI() ) { CurrentGameUI()->UIMainIngameWnd->ReceiveNews(&news_data); } }
void CLevel::IR_OnKeyboardHold(int key) { if (g_bDisableAllInput) return; #ifdef KEY_HOLD_CALLBACK /* avo: script callback */ if (g_actor) g_actor->callback(GameObject::eKeyHold)(key); /* avo: end */ #endif // KEY_HOLD_CALLBACK #ifdef DEBUG // Lain: added if ( key == DIK_UP ) { static u32 time = Device.dwTimeGlobal; if ( Device.dwTimeGlobal - time > 20 ) { if ( CBaseMonster* pBM = smart_cast<CBaseMonster*>(CurrentEntity()) ) { DBG().debug_info_up(); time = Device.dwTimeGlobal; } } } else if ( key == DIK_DOWN ) { static u32 time = Device.dwTimeGlobal; if ( Device.dwTimeGlobal - time > 20 ) { if ( CBaseMonster* pBM = smart_cast<CBaseMonster*>(CurrentEntity()) ) { DBG().debug_info_down(); time = Device.dwTimeGlobal; } } } #endif // DEBUG if (CurrentGameUI() && CurrentGameUI()->IR_UIOnKeyboardHold(key)) return; if (Device.Paused() && !Level().IsDemoPlay() #ifdef DEBUG && !psActorFlags.test(AF_NO_CLIP) #endif //DEBUG ) return; if (CURRENT_ENTITY()) { IInputReceiver* IR = smart_cast<IInputReceiver*> (smart_cast<CGameObject*>(CURRENT_ENTITY())); if (IR) IR->IR_OnKeyboardHold(get_binded_action(key)); } }
void CActor::RunTalkDialog(CInventoryOwner* talk_partner, bool disable_break) { //предложить поговорить с нами if(talk_partner->OfferTalk(this)) { StartTalk(talk_partner); if(CurrentGameUI()->TopInputReceiver()) CurrentGameUI()->TopInputReceiver()->HideDialog(); // smart_cast<CUIGameSP*>(CurrentGameUI())->StartTalk(disable_break); smart_cast<CUIGameSP*>(CurrentGameUI())->StartTalk(talk_partner->bDisableBreakDialog); } }
void CActor::OnDisableInfo(shared_str info_id) const { CInventoryOwner::OnDisableInfo(info_id); if(!CurrentGameUI()) return; //только если находимся в режиме single CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(CurrentGameUI()); if(!pGameSP) return; if(pGameSP->TalkMenu->IsShown()) pGameSP->TalkMenu->NeedUpdateQuestions(); }
bool CUISequenceSimpleItem::Stop (bool bForce) { if(!m_flags.test(etiCanBeStopped)&&!bForce) return false; if(m_UIWindow->GetParent()==m_owner->MainWnd()) //started?? m_owner->MainWnd()->DetachChild (m_UIWindow); m_sound.stop (); if(m_flags.test(etiNeedPauseOn) && !m_flags.test(etiStoredPauseState)) Device.Pause (FALSE, TRUE, FALSE, "simpleitem_stop"); if(m_flags.test(etiNeedPauseOff) && m_flags.test(etiStoredPauseState)) Device.Pause (TRUE, TRUE, FALSE, "simpleitem_stop"); if(m_flags.test(etiNeedPauseSound)) Device.Pause (FALSE, FALSE, TRUE, "simpleitem_stop"); if ( g_pGameLevel ) { CUIGameSP* ui_game_sp = smart_cast<CUIGameSP*>( CurrentGameUI() ); if ( ui_game_sp && ui_game_sp->PdaMenu().IsShown() ) { ui_game_sp->PdaMenu().HideDialog(); } } inherited::Stop (); return true; }
void CLevel::IR_OnKeyboardRelease(int key) { if (!bReady || g_bDisableAllInput ) return; if ( CurrentGameUI() && CurrentGameUI()->IR_UIOnKeyboardRelease(key)) return; if (game && game->OnKeyboardRelease(get_binded_action(key)) ) return; if (Device.Paused() #ifdef DEBUG && !psActorFlags.test(AF_NO_CLIP) #endif //DEBUG ) return; if (CURRENT_ENTITY()) { IInputReceiver* IR = smart_cast<IInputReceiver*> (smart_cast<CGameObject*>(CURRENT_ENTITY())); if (IR) IR->IR_OnKeyboardRelease (get_binded_action(key)); } }
void CActor::NewPdaContact (CInventoryOwner* pInvOwner) { if(!IsGameTypeSingle()) return; bool b_alive = !!(smart_cast<CEntityAlive*>(pInvOwner))->g_Alive(); CurrentGameUI()->UIMainIngameWnd->AnimateContacts(b_alive); Level().MapManager().AddRelationLocation ( pInvOwner ); }
void game_cl_Deathmatch::OnConnected() { inherited::OnConnected (); if (m_game_ui) { VERIFY(!g_dedicated_server); m_game_ui = smart_cast<CUIGameDM*> (CurrentGameUI()); m_game_ui->SetClGame (this); } }
void ui_actor_state_wnd::UpdateHitZone() { CUIHudStatesWnd* wnd = CurrentGameUI()->UIMainIngameWnd->get_hud_states(); //некрасиво слишком VERIFY( wnd ); if ( !wnd ) { return; } wnd->UpdateZones(); }
void CActor::ReceivePhrase (DIALOG_SHARED_PTR& phrase_dialog) { //только если находимся в режиме single CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(CurrentGameUI()); if(!pGameSP) return; if(pGameSP->TalkMenu->IsShown()) pGameSP->TalkMenu->NeedUpdateQuestions(); CPhraseDialogManager::ReceivePhrase(phrase_dialog); }
void CLevel::IR_OnKeyboardRelease(int key) { if (!bReady || g_bDisableAllInput) return; #ifdef KEY_RELEASE_CALLBACK /* avo: script callback */ if (g_actor) g_actor->callback(GameObject::eKeyRelease)(key); /* avo: end */ #endif // KEY_RELEASE_CALLBACK if (CurrentGameUI() && CurrentGameUI()->IR_UIOnKeyboardRelease(key)) return; if (game && game->OnKeyboardRelease(get_binded_action(key))) return; if (Device.Paused() #ifdef DEBUG && !psActorFlags.test(AF_NO_CLIP) #endif //DEBUG ) return; if (CURRENT_ENTITY()) { IInputReceiver* IR = smart_cast<IInputReceiver*> (smart_cast<CGameObject*>(CURRENT_ENTITY())); if (IR) IR->IR_OnKeyboardRelease(get_binded_action(key)); } }
bool CActor::OnReceiveInfo(shared_str info_id) const { if(!CInventoryOwner::OnReceiveInfo(info_id)) return false; CInfoPortion info_portion; info_portion.Load(info_id); callback(GameObject::eInventoryInfo)(lua_game_object(), *info_id); if(!CurrentGameUI()) return false; //только если находимся в режиме single CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(CurrentGameUI()); if(!pGameSP) return false; if(pGameSP->TalkMenu->IsShown()) { pGameSP->TalkMenu->NeedUpdateQuestions(); } return true; }
void CLevel::IR_OnMouseMove( int dx, int dy ) { if(g_bDisableAllInput) return; if (CurrentGameUI()->IR_UIOnMouseMove(dx,dy)) return; if (Device.Paused() && !IsDemoPlay() #ifdef DEBUG && !psActorFlags.test(AF_NO_CLIP) #endif //DEBUG ) return; if (CURRENT_ENTITY()) { IInputReceiver* IR = smart_cast<IInputReceiver*> (smart_cast<CGameObject*>(CURRENT_ENTITY())); if (IR) IR->IR_OnMouseMove (dx,dy); } }
void CUISequenceSimpleItem::Start() { m_time_start = -3.0f; inherited::Start (); m_flags.set (etiStoredPauseState, Device.Paused()); if(m_flags.test(etiNeedPauseOn) && !m_flags.test(etiStoredPauseState)) { Device.Pause (TRUE, TRUE, FALSE, "simpleitem_start"); bShowPauseString = FALSE; } if(m_flags.test(etiNeedPauseOff) && m_flags.test(etiStoredPauseState)) Device.Pause (FALSE, TRUE, FALSE, "simpleitem_start"); if(m_flags.test(etiNeedPauseSound)) Device.Pause (TRUE, FALSE, TRUE, "simpleitem_start"); if(m_desired_cursor_pos.x && m_desired_cursor_pos.y) GetUICursor().SetUICursorPosition(m_desired_cursor_pos); m_owner->MainWnd()->AttachChild (m_UIWindow); if (m_sound._handle()) m_sound.play(NULL, sm_2D); if (g_pGameLevel) { bool bShowPda = false; CUIGameSP* ui_game_sp = smart_cast<CUIGameSP*>(CurrentGameUI()); if ( !stricmp( m_pda_section, "pda_tasks" ) ) {ui_game_sp->PdaMenu().SetActiveSubdialog("eptTasks"); bShowPda = true; } else if( !stricmp( m_pda_section, "pda_ranking" ) ) {ui_game_sp->PdaMenu().SetActiveSubdialog("eptRanking"); bShowPda = true; } else if( !stricmp( m_pda_section, "pda_logs" ) ) {ui_game_sp->PdaMenu().SetActiveSubdialog("eptLogs"); bShowPda = true; } else if( !stricmp( m_pda_section, "pda_show_second_task_wnd" ) ) { ui_game_sp->PdaMenu().Show_SecondTaskWnd(true); bShowPda = true; } if ( ui_game_sp ) { if ( ( !ui_game_sp->PdaMenu().IsShown() && bShowPda ) || ( ui_game_sp->PdaMenu().IsShown() && !bShowPda ) ) { ui_game_sp->PdaMenu().HideDialog(); } } } }
void CActorCondition::UpdateBoosters() { for(u8 i=0;i<eBoostMaxCount;i++) { BOOSTER_MAP::iterator it = m_booster_influences.find((EBoostParams)i); if(it!=m_booster_influences.end()) { it->second.fBoostTime -= m_fDeltaTime/(IsGameTypeSingle()?Level().GetGameTimeFactor():1.0f); if(it->second.fBoostTime<=0.0f) { DisableBoostParameters(it->second); m_booster_influences.erase(it); } } } if(m_object == Level().CurrentViewEntity()) CurrentGameUI()->UIMainIngameWnd->UpdateBoosterIndicators(m_booster_influences); }
void CUIActorMenu::Update() { { // all mode m_last_time = Device.dwTimeGlobal; m_ActorStateInfo->UpdateActorInfo( m_pActorInvOwner ); } switch ( m_currMenuMode ) { case mmUndefined: break; case mmInventory: { // m_clock_value->TextItemControl()->SetText( InventoryUtilities::GetGameTimeAsString( InventoryUtilities::etpTimeToMinutes ).c_str() ); CurrentGameUI()->UIMainIngameWnd->UpdateZoneMap(); break; } case mmTrade: { if(m_pPartnerInvOwner->inventory().ModifyFrame() != m_trade_partner_inventory_state) InitPartnerInventoryContents (); CheckDistance (); break; } case mmUpgrade: { UpdateUpgradeItem(); CheckDistance(); break; } case mmDeadBodySearch: { CheckDistance(); break; } default: R_ASSERT(0); break; } inherited::Update(); m_ItemInfo->Update(); m_hint_wnd->Update(); }
MotionID CStalkerAnimationManager::assign_head_animation () { const ANIM_VECTOR &animations = m_data_storage->m_head_animations.A; CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(CurrentGameUI()); if (pGameSP && pGameSP->TalkMenu->IsShown()) { if (pGameSP->TalkMenu->OthersInvOwner() == m_object) { if (pGameSP->TalkMenu->playing_sound()) return (animations[1]); } } CSoundPlayer &sound = object().sound(); if (!sound.active_sound_count(true)) return (animations[0]); if (!sound.active_sound_type((u32)StalkerSpace::eStalkerSoundMaskMovingInDanger)) return (animations[1]); return (animations[0]); }
void CLevel::IR_OnMouseWheel(int direction) { if (g_bDisableAllInput) return; /* avo: script callback */ if (g_actor) g_actor->callback(GameObject::eMouseWheel)(direction); /* avo: end */ if (CurrentGameUI()->IR_UIOnMouseWheel(direction)) return; if (Device.Paused() #ifdef DEBUG && !psActorFlags.test(AF_NO_CLIP) #endif //DEBUG ) return; if (CURRENT_ENTITY()) { IInputReceiver* IR = smart_cast<IInputReceiver*> (smart_cast<CGameObject*>(CURRENT_ENTITY())); if (IR) IR->IR_OnMouseWheel(direction); } }
void CUISequenceSimpleItem::Update() { inherited::Update(); float _start = (m_time_start<0.0f)? (float(Device.dwTimeContinual)/1000.0f) : m_time_start; float gt = float(Device.dwTimeContinual)/1000.0f; SubItemVecIt _I = m_subitems.begin(); SubItemVecIt _E = m_subitems.end(); for(;_I!=_E;++_I) { SSubItem& s = *_I; bool bPlaying = (gt>(_start+s.m_start-EPS))&&(gt<(_start+s.m_start+s.m_length+EPS)); if (true==bPlaying&&(false==s.m_visible)) s.Start (); else if ((false==bPlaying)&&(true==s.m_visible)) s.Stop (); } if(g_pGameLevel && (!m_pda_section || 0 == xr_strlen(m_pda_section)) ) { CUIGameSP* ui_game_sp = smart_cast<CUIGameSP*>(CurrentGameUI()); if(ui_game_sp) { if ( ui_game_sp->PdaMenu().IsShown() || ui_game_sp->ActorMenu().IsShown() || ui_game_sp->TalkMenu->IsShown() || ui_game_sp->UIChangeLevelWnd->IsShown() || (MainMenu()->IsActive() && !m_owner->m_flags.test(CUISequencer::etsOverMainMenu) ) ) m_UIWindow->Show (false); else m_UIWindow->Show (true); } } if(m_desired_cursor_pos.x && m_desired_cursor_pos.y) GetUICursor().SetUICursorPosition(m_desired_cursor_pos); }
void game_state_accumulator::init_player(game_PlayerState* local_player) { m_local_player = local_player; init_player_accum_values (local_player); CUIMpTradeWnd* tmp_trade_wnd = NULL; game_cl_Deathmatch* tmp_dm_game = smart_cast<game_cl_Deathmatch*>(&Game()); if (tmp_dm_game) { tmp_trade_wnd = smart_cast<CUIMpTradeWnd*>(tmp_dm_game->GetBuyWnd()); } else { R_ASSERT(Game().Type() == eGameIDCaptureTheArtefact); CUIGameCTA* tmp_cta_ui = smart_cast<CUIGameCTA*>(CurrentGameUI()); VERIFY(tmp_cta_ui); tmp_trade_wnd = smart_cast<CUIMpTradeWnd*>(tmp_cta_ui->GetBuyWnd()); } R_ASSERT(tmp_trade_wnd); m_item_mngr = tmp_trade_wnd->GetItemMngr(); R_ASSERT(m_item_mngr); m_amm_groups.init (m_item_mngr); }
void CLevel::IR_OnMouseMove(int dx, int dy) { if (g_bDisableAllInput) return; #ifdef MOUSE_MOVE_CALLBACK /* avo: script callback */ if (g_actor) g_actor->callback(GameObject::eMouseMove)(dx, dy); /* avo: end */ #endif // MOUSE_MOVE_CALLBACK if (CurrentGameUI()->IR_UIOnMouseMove(dx, dy)) return; if (Device.Paused() && !IsDemoPlay() #ifdef DEBUG && !psActorFlags.test(AF_NO_CLIP) #endif //DEBUG ) return; if (CURRENT_ENTITY()) { IInputReceiver* IR = smart_cast<IInputReceiver*> (smart_cast<CGameObject*>(CURRENT_ENTITY())); if (IR) IR->IR_OnMouseMove(dx, dy); } }
void CBaseMonster::HitEntity(const CEntity *pEntity, float fDamage, float impulse, Fvector &dir, ALife::EHitType hit_type, bool draw_hit_marks) { if (!g_Alive()) return; if (!pEntity || pEntity->getDestroy()) return; if (!EnemyMan.get_enemy()) return; if (EnemyMan.get_enemy() == pEntity) { Fvector position_in_bone_space; position_in_bone_space.set(0.f,0.f,0.f); // перевод из локальных координат в мировые вектора направления импульса Fvector hit_dir; XFORM().transform_dir (hit_dir,dir); hit_dir.normalize (); CEntity *pEntityNC = const_cast<CEntity*>(pEntity); VERIFY (pEntityNC); NET_Packet l_P; SHit HS; HS.GenHeader(GE_HIT, pEntityNC->ID()); // u_EventGen (l_P,GE_HIT, pEntityNC->ID()); HS.whoID = (ID()); // l_P.w_u16 (ID()); HS.weaponID = (ID()); // l_P.w_u16 (ID()); HS.dir = (hit_dir); // l_P.w_dir (hit_dir); HS.power = (fDamage); // l_P.w_float (fDamage); HS.boneID = (smart_cast<IKinematics*>(pEntityNC->Visual())->LL_GetBoneRoot());// l_P.w_s16 (smart_cast<IKinematics*>(pEntityNC->Visual())->LL_GetBoneRoot()); HS.p_in_bone_space = (position_in_bone_space); // l_P.w_vec3 (position_in_bone_space); HS.impulse = (impulse); // l_P.w_float (impulse); HS.hit_type = hit_type; // l_P.w_u16 ( u16(ALife::eHitTypeWound) ); HS.Write_Packet(l_P); u_EventSend (l_P); if (pEntityNC == Actor() && draw_hit_marks) { START_PROFILE("BaseMonster/Animation/HitEntity"); SDrawStaticStruct* s = CurrentGameUI()->AddCustomStatic("monster_claws", false); float h1,p1; Device.vCameraDirection.getHP (h1,p1); Fvector hd = hit_dir; hd.mul (-1); float d = -h1 + hd.getH (); s->wnd()->SetHeading (d); Fvector2 wnd_pos = s->wnd()->GetWndPos(); wnd_pos.y += 400.0f*_cos(d); wnd_pos.x += 500.0f*_sin(d); s->wnd()->SetWndPos(wnd_pos); STOP_PROFILE; //SetAttackEffector (); float time_to_lock = fDamage * MAX_LOCK_TIME; clamp (time_to_lock, 0.f, MAX_LOCK_TIME); Actor()->lock_accel_for (int(time_to_lock * 1000)); ////////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////// CEffectorCam* ce = Actor()->Cameras().GetCamEffector((ECamEffectorType)effBigMonsterHit); if(!ce) { const shared_str& eff_sect = pSettings->r_string(cNameSect(), "actor_hit_effect"); if(eff_sect.c_str()) { int id = -1; Fvector cam_pos,cam_dir,cam_norm; Actor()->cam_Active()->Get (cam_pos,cam_dir,cam_norm); cam_dir.normalize_safe (); dir.normalize_safe (); float ang_diff = angle_difference (cam_dir.getH(), dir.getH()); Fvector cp; cp.crossproduct (cam_dir,dir); bool bUp =(cp.y>0.0f); Fvector cross; cross.crossproduct (cam_dir, dir); VERIFY (ang_diff>=0.0f && ang_diff<=PI); float _s1 = PI_DIV_8; float _s2 = _s1+PI_DIV_4; float _s3 = _s2+PI_DIV_4; float _s4 = _s3+PI_DIV_4; if(ang_diff<=_s1){ id = 2; }else { if(ang_diff>_s1 && ang_diff<=_s2){ id = (bUp)?5:7; }else if(ang_diff>_s2 && ang_diff<=_s3){ id = (bUp)?3:1; }else if(ang_diff>_s3 && ang_diff<=_s4){ id = (bUp)?4:6; }else if(ang_diff>_s4){ id = 0; }else{ VERIFY(0); } } string64 sect_name; xr_sprintf (sect_name,"%s_%d",eff_sect.c_str(), id); AddEffector (Actor(), effBigMonsterHit, sect_name, fDamage); } } ////////////////////////////////////////////////////////////////////////// } Morale.on_attack_success(); m_time_last_attack_success = Device.dwTimeGlobal; } }
void CActor::PickupModeUpdate_COD () { if (Level().CurrentViewEntity() != this || !g_b_COD_PickUpMode) return; if (!g_Alive() || eacFirstEye != cam_active) { CurrentGameUI()->UIMainIngameWnd->SetPickUpItem(NULL); return; }; CFrustum frustum; frustum.CreateFromMatrix (Device.mFullTransform, FRUSTUM_P_LRTB|FRUSTUM_P_FAR); ISpatialResult.clear_not_free (); g_SpatialSpace->q_frustum (ISpatialResult, 0, STYPE_COLLIDEABLE, frustum); float maxlen = 1000.0f; CInventoryItem* pNearestItem = NULL; for (u32 o_it=0; o_it<ISpatialResult.size(); o_it++) { ISpatial* spatial = ISpatialResult[o_it]; CInventoryItem* pIItem = smart_cast<CInventoryItem*> (spatial->dcast_CObject ()); if (0 == pIItem) continue; if (pIItem->object().H_Parent() != NULL) continue; if (!pIItem->CanTake()) continue; if ( smart_cast<CExplosiveRocket*>( &pIItem->object() ) ) continue; CGrenade* pGrenade = smart_cast<CGrenade*> (spatial->dcast_CObject ()); if (pGrenade && !pGrenade->Useful()) continue; CMissile* pMissile = smart_cast<CMissile*> (spatial->dcast_CObject ()); if (pMissile && !pMissile->Useful()) continue; Fvector A, B, tmp; pIItem->object().Center (A); if (A.distance_to_sqr(Position())>4) continue; tmp.sub(A, cam_Active()->vPosition); B.mad(cam_Active()->vPosition, cam_Active()->vDirection, tmp.dotproduct(cam_Active()->vDirection)); float len = B.distance_to_sqr(A); if (len > 1) continue; if (maxlen>len && !pIItem->object().getDestroy()) { maxlen = len; pNearestItem = pIItem; }; } if(pNearestItem) { CFrustum frustum; frustum.CreateFromMatrix (Device.mFullTransform,FRUSTUM_P_LRTB|FRUSTUM_P_FAR); if (!CanPickItem(frustum, Device.vCameraPosition, &pNearestItem->object())) pNearestItem = NULL; } if (pNearestItem && pNearestItem->cast_game_object()) { if (Level().m_feel_deny.is_object_denied(pNearestItem->cast_game_object())) pNearestItem = NULL; } if (pNearestItem && pNearestItem->cast_game_object()) { if(!pNearestItem->cast_game_object()->getVisible()) pNearestItem = NULL; } CurrentGameUI()->UIMainIngameWnd->SetPickUpItem(pNearestItem); if (pNearestItem && m_bPickupMode) { CUsableScriptObject* pUsableObject = smart_cast<CUsableScriptObject*>(pNearestItem); if(pUsableObject && (!m_pUsableObject)) pUsableObject->use(this); //подбирание объекта Game().SendPickUpEvent(ID(), pNearestItem->object().ID()); } };
void CActor::ActorUse() { if (m_holder) { CGameObject* GO = smart_cast<CGameObject*>(m_holder); NET_Packet P; CGameObject::u_EventGen (P, GEG_PLAYER_DETACH_HOLDER, ID()); P.w_u16 (GO->ID()); CGameObject::u_EventSend (P); return; } if(character_physics_support()->movement()->PHCapture()) character_physics_support()->movement()->PHReleaseObject(); if(m_pUsableObject && NULL==m_pObjectWeLookingAt->cast_inventory_item()) { m_pUsableObject->use(this); } if ( m_pInvBoxWeLookingAt && m_pInvBoxWeLookingAt->nonscript_usable() ) { CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(CurrentGameUI()); if ( pGameSP ) //single { if ( !m_pInvBoxWeLookingAt->closed() ) { pGameSP->StartCarBody( this, m_pInvBoxWeLookingAt ); } } return; } if(!m_pUsableObject||m_pUsableObject->nonscript_usable()) { if(m_pPersonWeLookingAt) { CEntityAlive* pEntityAliveWeLookingAt = smart_cast<CEntityAlive*>(m_pPersonWeLookingAt); VERIFY(pEntityAliveWeLookingAt); if (IsGameTypeSingle()) { if(pEntityAliveWeLookingAt->g_Alive()) { TryToTalk(); }else { //только если находимся в режиме single CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(CurrentGameUI()); if ( pGameSP ) { if ( !m_pPersonWeLookingAt->deadbody_closed_status() ) { if(pEntityAliveWeLookingAt->AlreadyDie() && pEntityAliveWeLookingAt->GetLevelDeathTime()+3000 < Device.dwTimeGlobal) // 99.9% dead pGameSP->StartCarBody(this, m_pPersonWeLookingAt ); } } } } } collide::rq_result& RQ = HUD().GetCurrentRayQuery(); CPhysicsShellHolder* object = smart_cast<CPhysicsShellHolder*>(RQ.O); u16 element = BI_NONE; if(object) element = (u16)RQ.element; if(object && Level().IR_GetKeyState(DIK_LSHIFT)) { bool b_allow = !!pSettings->line_exist("ph_capture_visuals",object->cNameVisual()); if(b_allow && !character_physics_support()->movement()->PHCapture()) { character_physics_support()->movement()->PHCaptureObject( object, element ); } } else { if (object && smart_cast<CHolderCustom*>(object)) { NET_Packet P; CGameObject::u_EventGen (P, GEG_PLAYER_ATTACH_HOLDER, ID()); P.w_u16 (object->ID()); CGameObject::u_EventSend (P); return; } } } }
void CActor::IR_OnKeyboardPress(int cmd) { if(hud_adj_mode && pInput->iGetAsyncKeyState(DIK_LSHIFT)) return; if (Remote()) return; if (IsTalking()) return; if (m_input_external_handler && !m_input_external_handler->authorized(cmd)) return; switch (cmd) { case kWPN_FIRE: { /* XEM #95 */ //if( (mstate_wishful & mcLookout) && !IsGameTypeSingle() ) return; u16 slot = inventory().GetActiveSlot(); if(inventory().ActiveItem() && (slot==INV_SLOT_3 || slot==INV_SLOT_2) ) mstate_wishful &=~mcSprint; //----------------------------- if (OnServer()) { NET_Packet P; P.w_begin(M_PLAYER_FIRE); P.w_u16(ID()); u_EventSend(P); } }break; default: { }break; } if (!g_Alive()) return; if(m_holder && kUSE != cmd) { m_holder->OnKeyboardPress (cmd); if(m_holder->allowWeapon() && inventory().Action((u16)cmd, CMD_START)) return; return; }else if(inventory().Action((u16)cmd, CMD_START)) return; #ifdef DEBUG if(psActorFlags.test(AF_NO_CLIP)) { NoClipFly(cmd); return; } #endif //DEBUG switch(cmd) { case kJUMP: { mstate_wishful |= mcJump; }break; case kSPRINT_TOGGLE: { mstate_wishful ^= mcSprint; }break; case kCROUCH: { if( psActorFlags.test(AF_CROUCH_TOGGLE) ) mstate_wishful ^= mcCrouch; }break; case kCAM_1: cam_Set (eacFirstEye); break; case kCAM_2: cam_Set (eacLookAt); break; case kCAM_3: cam_Set (eacFreeLook); break; case kNIGHT_VISION: { SwitchNightVision(); break; } case kTORCH: { SwitchTorch(); break; } case kDETECTOR: { PIItem det_active = inventory().ItemFromSlot(DETECTOR_SLOT); if(det_active) { CCustomDetector* det = smart_cast<CCustomDetector*>(det_active); det->ToggleDetector (g_player_hud->attached_item(0)!=NULL); return; } }break; /* case kFLARE:{ PIItem fl_active = inventory().ItemFromSlot(FLARE_SLOT); if(fl_active) { CFlare* fl = smart_cast<CFlare*>(fl_active); fl->DropFlare (); return ; } PIItem fli = inventory().Get(CLSID_DEVICE_FLARE, true); if(!fli) return; CFlare* fl = smart_cast<CFlare*>(fli); if(inventory().Slot(fl)) fl->ActivateFlare (); }break; */ case kUSE: ActorUse(); break; case kDROP: b_DropActivated = TRUE; f_DropPower = 0; break; case kNEXT_SLOT: { OnNextWeaponSlot(); }break; case kPREV_SLOT: { OnPrevWeaponSlot(); }break; case kQUICK_USE_1: case kQUICK_USE_2: case kQUICK_USE_3: case kQUICK_USE_4: { const shared_str& item_name = g_quick_use_slots[cmd-kQUICK_USE_1]; if(item_name.size()) { PIItem itm = inventory().GetAny(item_name.c_str()); if(itm) { if (IsGameTypeSingle()) { inventory().Eat (itm); } else { inventory().ClientEat (itm); } StaticDrawableWrapper* _s = CurrentGameUI()->AddCustomStatic("item_used", true); string1024 str; strconcat (sizeof(str),str,*CStringTable().translate("st_item_used"),": ", itm->NameItem()); _s->wnd()->TextItemControl()->SetText(str); CurrentGameUI()->GetActorMenu().m_pQuickSlot->ReloadReferences(this); } } }break; } }
void CLevel::IR_OnKeyboardPress (int key) { if(Device.dwPrecacheFrame) return; #ifdef INGAME_EDITOR if (Device.editor() && (pInput->iGetAsyncKeyState(DIK_LALT) || pInput->iGetAsyncKeyState(DIK_RALT))) return; #endif // #ifdef INGAME_EDITOR bool b_ui_exist = (!!CurrentGameUI()); EGameActions _curr = get_binded_action(key); if(_curr==kPAUSE) { #ifdef INGAME_EDITOR if (Device.editor()) return; #endif // INGAME_EDITOR if (!g_block_pause && (IsGameTypeSingle() || IsDemoPlay())) { #ifdef DEBUG if(psActorFlags.test(AF_NO_CLIP)) Device.Pause(!Device.Paused(), TRUE, TRUE, "li_pause_key_no_clip"); else #endif //DEBUG Device.Pause(!Device.Paused(), TRUE, TRUE, "li_pause_key"); } return; } if( g_bDisableAllInput ) return; switch ( _curr ) { case kSCREENSHOT: Render->Screenshot(); return; break; case kCONSOLE: Console->Show (); return; break; case kQUIT: { if(b_ui_exist && CurrentGameUI()->TopInputReceiver() ) { if(CurrentGameUI()->IR_UIOnKeyboardPress(key)) return;//special case for mp and main_menu CurrentGameUI()->TopInputReceiver()->HideDialog(); }else { Console->Execute("main_menu"); }return; }break; }; if ( !bReady || !b_ui_exist ) return; if ( b_ui_exist && CurrentGameUI()->IR_UIOnKeyboardPress(key)) return; if ( Device.Paused() && !IsDemoPlay() #ifdef DEBUG && !psActorFlags.test(AF_NO_CLIP) #endif //DEBUG ) return; if ( game && game->OnKeyboardPress(get_binded_action(key)) ) return; if(_curr == kQUICK_SAVE && IsGameTypeSingle()) { Console->Execute ("save"); return; } if(_curr == kQUICK_LOAD && IsGameTypeSingle()) { #ifdef DEBUG FS.get_path ("$game_config$")->m_Flags.set(FS_Path::flNeedRescan, TRUE); FS.get_path ("$game_scripts$")->m_Flags.set(FS_Path::flNeedRescan, TRUE); FS.rescan_pathes (); #endif // DEBUG string_path saved_game,command; strconcat (sizeof(saved_game),saved_game,Core.UserName," - ","quicksave"); if (!CSavedGameWrapper::valid_saved_game(saved_game)) return; strconcat (sizeof(command),command,"load ",saved_game); Console->Execute (command); return; } #ifndef MASTER_GOLD switch (key) { case DIK_F7: { if (GameID() != eGameIDSingle) return; FS.get_path ("$game_config$")->m_Flags.set(FS_Path::flNeedRescan, TRUE); FS.get_path ("$game_scripts$")->m_Flags.set(FS_Path::flNeedRescan, TRUE); FS.rescan_pathes (); NET_Packet net_packet; net_packet.w_begin (M_RELOAD_GAME); Send (net_packet,net_flags(TRUE)); return; } case DIK_DIVIDE: { if (!Server) break; SetGameTimeFactor (g_fTimeFactor); #ifdef DEBUG if(!m_bEnvPaused) SetEnvironmentGameTimeFactor(GetEnvironmentGameTime(), g_fTimeFactor); #else //DEBUG SetEnvironmentGameTimeFactor(GetEnvironmentGameTime(), g_fTimeFactor); #endif //DEBUG break; } case DIK_MULTIPLY: { if (!Server) break; SetGameTimeFactor (1000.f); #ifdef DEBUG if(!m_bEnvPaused) SetEnvironmentGameTimeFactor(GetEnvironmentGameTime(), 1000.f); #else //DEBUG SetEnvironmentGameTimeFactor(GetEnvironmentGameTime(), 1000.f); #endif //DEBUG break; } #ifdef DEBUG case DIK_SUBTRACT:{ if (!Server) break; if(m_bEnvPaused) SetEnvironmentGameTimeFactor(GetEnvironmentGameTime(), g_fTimeFactor); else SetEnvironmentGameTimeFactor(GetEnvironmentGameTime(), 0.00001f); m_bEnvPaused = !m_bEnvPaused; break; } #endif //DEBUG case DIK_NUMPAD5: { if (GameID()!=eGameIDSingle) { Msg("For this game type Demo Record is disabled."); /// return; }; if(!pInput->iGetAsyncKeyState(DIK_LSHIFT)) { Console->Hide (); Console->Execute("demo_record 1"); } } break; #ifdef DEBUG // Lain: added TEMP!!! case DIK_UP: { g_separate_factor /= 0.9f; break; } case DIK_DOWN: { g_separate_factor *= 0.9f; if ( g_separate_factor < 0.1f ) { g_separate_factor = 0.1f; } break; } case DIK_LEFT: { g_separate_radius *= 0.9f; if ( g_separate_radius < 0 ) { g_separate_radius = 0; } break; } case DIK_RIGHT: { g_separate_radius /= 0.9f; break; } case DIK_RETURN: { bDebug = !bDebug; return; } case DIK_BACK: if (GameID() == eGameIDSingle) DRender->NextSceneMode(); //HW.Caps.SceneMode = (HW.Caps.SceneMode+1)%3; return; case DIK_F4: { if (pInput->iGetAsyncKeyState(DIK_LALT)) break; if (pInput->iGetAsyncKeyState(DIK_RALT)) break; bool bOk = false; u32 i=0, j, n=Objects.o_count(); if (pCurrentEntity) for ( ; i<n; ++i) if (Objects.o_get_by_iterator(i) == pCurrentEntity) break; if (i < n) { j = i; bOk = false; for (++i; i <n; ++i) { CEntityAlive* tpEntityAlive = smart_cast<CEntityAlive*>(Objects.o_get_by_iterator(i)); if (tpEntityAlive) { bOk = true; break; } } if (!bOk) for (i = 0; i <j; ++i) { CEntityAlive* tpEntityAlive = smart_cast<CEntityAlive*>(Objects.o_get_by_iterator(i)); if (tpEntityAlive) { bOk = true; break; } } if (bOk) { CObject *tpObject = CurrentEntity(); CObject *__I = Objects.o_get_by_iterator(i); CObject **I = &__I; SetEntity(*I); if (tpObject != *I) { CActor* pActor = smart_cast<CActor*> (tpObject); if (pActor) pActor->inventory().Items_SetCurrentEntityHud(false); } if (tpObject) { Engine.Sheduler.Unregister (tpObject); Engine.Sheduler.Register (tpObject, TRUE); }; Engine.Sheduler.Unregister (*I); Engine.Sheduler.Register (*I, TRUE); CActor* pActor = smart_cast<CActor*> (*I); if (pActor) { pActor->inventory().Items_SetCurrentEntityHud(true); CHudItem* pHudItem = smart_cast<CHudItem*>(pActor->inventory().ActiveItem()); if (pHudItem) { pHudItem->OnStateSwitch(pHudItem->GetState()); } } } } return; } // Lain: added case DIK_F5: { if ( CBaseMonster* pBM = smart_cast<CBaseMonster*>(CurrentEntity())) { DBG().log_debug_info(); } break; } case MOUSE_1: { if (GameID() != eGameIDSingle) break; if (pInput->iGetAsyncKeyState(DIK_LALT)) { if (smart_cast<CActor*>(CurrentEntity())) try_change_current_entity (); else restore_actor (); return; } break; } /**/ #endif #ifdef DEBUG case DIK_F9:{ // if (!ai().get_alife()) // break; // const_cast<CALifeSimulatorHeader&>(ai().alife().header()).set_state(ALife::eZoneStateSurge); break; } return; // case DIK_F10:{ // ai().level_graph().set_dest_point(); // ai().level_graph().build_detail_path(); // if (!Objects.FindObjectByName("m_stalker_e0000") || !Objects.FindObjectByName("localhost/dima")) // return; // if (!m_bSynchronization) { // m_bSynchronization = true; // ai().level_graph().set_start_point(); // m_bSynchronization = false; // } // luabind::functor<void> functor; // ai().script_engine().functor("alife_test.set_switch_online",functor); // functor(0,false); // } // return; // case DIK_F11: // ai().level_graph().build_detail_path(); // if (!Objects.FindObjectByName("m_stalker_e0000") || !Objects.FindObjectByName("localhost/dima")) // return; // if (!m_bSynchronization) { // m_bSynchronization = true; // ai().level_graph().set_dest_point(); // ai().level_graph().select_cover_point(); // m_bSynchronization = false; // } // return; #endif // DEBUG } #endif // MASTER_GOLD if (bindConsoleCmds.execute(key)) return; if (CURRENT_ENTITY()) { IInputReceiver* IR = smart_cast<IInputReceiver*> (smart_cast<CGameObject*>(CURRENT_ENTITY())); if (IR) IR->IR_OnKeyboardPress(get_binded_action(key)); } #ifdef _DEBUG CObject *obj = Level().Objects.FindObjectByName("monster"); if (obj) { CBaseMonster *monster = smart_cast<CBaseMonster *>(obj); if (monster) monster->debug_on_key(key); } #endif }
void game_cl_Deathmatch::shedule_Update (u32 dt) { CStringTable st; inherited::shedule_Update(dt); if(g_dedicated_server) return; //fake if(m_game_ui) { m_game_ui->SetTimeMsgCaption (NULL); m_game_ui->SetRoundResultCaption (NULL); m_game_ui->SetSpectatorMsgCaption (NULL); m_game_ui->SetPressJumpMsgCaption (NULL); m_game_ui->SetPressBuyMsgCaption (NULL); m_game_ui->SetForceRespawnTimeCaption(NULL); m_game_ui->SetWarmUpCaption (NULL); }; // if (CurrentGameUI() && CurrentGameUI()->UIMainIngameWnd) // CurrentGameUI()->UIMainIngameWnd->ZoneCounter().SetText(""); switch (Phase()) { case GAME_PHASE_INPROGRESS: { //m_game_ui->ShowPlayersList(false); Check_Invincible_Players(); if (!m_game_ui) break; if (m_s32TimeLimit && m_cl_dwWarmUp_Time == 0) { if (Level().timeServer()<(m_start_time + m_s32TimeLimit)) { u32 lts = Level().timeServer(); u32 Rest = (m_start_time + m_s32TimeLimit) - lts; string64 S; ConvertTime2String(&S, Rest); m_game_ui->SetTimeMsgCaption(S); } else { m_game_ui->SetTimeMsgCaption("00:00:00"); } }; game_PlayerState* lookat_player = Game().lookat_player(); if(local_player && !local_player->IsSkip()) { if (m_bFirstRun) { m_bFirstRun = FALSE; if (!Level().IsDemoPlayStarted() && Level().CurrentEntity()) { VERIFY( m_game_ui ); m_bFirstRun = m_game_ui->ShowServerInfo() ? FALSE : TRUE; } GetActiveVoting(); }; if (lookat_player) { string256 MoneyStr; xr_sprintf(MoneyStr, "%d", lookat_player->money_for_round); m_game_ui->ChangeTotalMoneyIndicator(MoneyStr); } m_game_ui->SetPressJumpMsgCaption(NULL); m_game_ui->SetPressBuyMsgCaption(NULL); if (m_cl_dwWarmUp_Time > Level().timeServer()) { u32 TimeRemains = m_cl_dwWarmUp_Time - Level().timeServer(); string64 S; ConvertTime2String(&S, TimeRemains); string1024 tmpStr = ""; if (TimeRemains > 10000) strconcat(sizeof(tmpStr),tmpStr, *st.translate("mp_time2start"), " ", S); else { if (TimeRemains < 1000) strconcat(sizeof(tmpStr),tmpStr, *st.translate("mp_go"), ""); else { static u32 dwLastTimeRemains = 10; u32 dwCurTimeRemains = TimeRemains/1000; if (dwLastTimeRemains != dwCurTimeRemains) { if (dwCurTimeRemains > 0 && dwCurTimeRemains <= 5) PlaySndMessage(ID_COUNTDOWN_1 + dwCurTimeRemains - 1); } dwLastTimeRemains = dwCurTimeRemains; _itoa(dwCurTimeRemains, S, 10); strconcat(sizeof(tmpStr),tmpStr, *st.translate("mp_ready"), "...", S); } }; m_game_ui->SetWarmUpCaption(tmpStr); } if (Level().CurrentEntity() && smart_cast<CSpectator*>(Level().CurrentEntity())) { if (!(pCurBuyMenu && pCurBuyMenu->IsShown()) && !(pCurSkinMenu && pCurSkinMenu->IsShown()) && !m_game_ui->IsServerInfoShown() && (CurrentGameUI() && CurrentGameUI()->GameIndicatorsShown()) ) { if (!m_bSkinSelected) m_game_ui->SetPressJumpMsgCaption("mp_press_jump2select_skin"); else m_game_ui->SetPressJumpMsgCaption("mp_press_jump2start"); if (CanCallBuyMenu()) m_game_ui->SetPressBuyMsgCaption("mp_press_to_buy"); }; }; if (Level().CurrentControlEntity() && smart_cast<CSpectator*>(Level().CurrentControlEntity()) && (CurrentGameUI()->GameIndicatorsShown()) ) { CSpectator* pSpectator = smart_cast<CSpectator*>(Level().CurrentControlEntity()); if (pSpectator) { string1024 SpectatorStr = ""; pSpectator->GetSpectatorString(SpectatorStr); m_game_ui->SetSpectatorMsgCaption(SpectatorStr); } } u32 CurTime = Level().timeServer(); if (IsVotingEnabled() && IsVotingActive() && m_dwVoteEndTime>=CurTime) { u32 TimeLeft = m_dwVoteEndTime - Level().timeServer(); string1024 VoteTimeResStr; u32 SecsLeft = (TimeLeft % 60000) / 1000; u32 MinitsLeft = (TimeLeft - SecsLeft) / 60000; u32 NumAgreed = 0; PLAYERS_MAP_IT I; I = players.begin(); for(;I!=players.end(); ++I) { game_PlayerState* ps = I->second; if (ps->m_bCurrentVoteAgreed == 1) NumAgreed++; } xr_sprintf (VoteTimeResStr, st.translate("mp_timeleft").c_str(), MinitsLeft, SecsLeft, float(NumAgreed)/players.size()); m_game_ui->SetVoteTimeResultMsg(VoteTimeResStr); }; if ( local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD) && m_u32ForceRespawn && !local_player->testFlag(GAME_PLAYER_FLAG_SPECTATOR) ) { u32 Rest = m_u32ForceRespawn - local_player->DeathTime; string64 S; ConvertTime2String (&S, Rest); string128 FullS; xr_sprintf (FullS, "%s : %s", *st.translate("mp_time2respawn"), S); m_game_ui->SetForceRespawnTimeCaption(FullS); }; if (Level().CurrentViewEntity()) { game_PlayerState* ps = GetPlayerByGameID(Level().CurrentViewEntity()->ID()); if (ps && m_game_ui) m_game_ui->SetRank(ps->team, ps->rank); if (ps && m_game_ui) m_game_ui->SetFraglimit(ps->frags(), m_s32FragLimit); } }; }break; case GAME_PHASE_PENDING: { if (!m_game_ui) break; m_game_ui->UpdateTeamPanels(); m_game_ui->ShowPlayersList(true); }break; case GAME_PHASE_PLAYER_SCORES: { if (!m_game_ui) break; string128 resstring; xr_sprintf(resstring, st.translate("mp_player_wins").c_str(), WinnerName); m_game_ui->SetRoundResultCaption(resstring); SetScore(); m_game_ui->UpdateTeamPanels(); m_game_ui->ShowPlayersList(true); }break; }; //----------------------------------------- if (!CanCallBuyMenu()) HideBuyMenu(); if (pCurSkinMenu && pCurSkinMenu->IsShown() && !CanCallSkinMenu()) pCurSkinMenu->HideDialog(); //----------------------------------------------- //----------------------------------------------- //if (m_game_ui->m_pInventoryMenu && m_game_ui->m_pInventoryMenu->IsShown() && !CanCallInventoryMenu()) // StartStopMenu(m_game_ui->m_pInventoryMenu,true); if ( m_game_ui && m_game_ui->ActorMenu().IsShown() && !CanCallInventoryMenu() ) { m_game_ui->HideActorMenu(); } //----------------------------------------- u32 cur_game_state = Phase(); //if(m_game_ui->m_pMapDesc && m_game_ui->m_pMapDesc->IsShown() && cur_game_state!=GAME_PHASE_INPROGRESS) //{ // m_game_ui->m_pMapDesc->HideDialog(); //} if(pCurSkinMenu && pCurSkinMenu->IsShown() && cur_game_state!=GAME_PHASE_INPROGRESS) { pCurSkinMenu->HideDialog(); } }
void CUIActorMenu::SetMenuMode(EMenuMode mode) { SetCurrentItem( NULL ); m_hint_wnd->set_text( NULL ); if ( mode != m_currMenuMode ) { switch(m_currMenuMode) { case mmUndefined: break; case mmInventory: DeInitInventoryMode(); break; case mmTrade: DeInitTradeMode(); break; case mmUpgrade: DeInitUpgradeMode(); break; case mmDeadBodySearch: DeInitDeadBodySearchMode(); break; default: R_ASSERT(0); break; } CurrentGameUI()->UIMainIngameWnd->ShowZoneMap(false); m_currMenuMode = mode; switch(mode) { case mmUndefined: #ifdef DEBUG Msg("* now is Undefined mode"); #endif // #ifdef DEBUG ResetMode(); break; case mmInventory: InitInventoryMode(); #ifdef DEBUG Msg("* now is Inventory mode"); #endif // #ifdef DEBUG break; case mmTrade: InitTradeMode(); #ifdef DEBUG Msg("* now is Trade mode"); #endif // #ifdef DEBUG break; case mmUpgrade: InitUpgradeMode(); #ifdef DEBUG Msg("* now is Upgrade mode"); #endif // #ifdef DEBUG break; case mmDeadBodySearch: InitDeadBodySearchMode(); #ifdef DEBUG Msg("* now is DeadBodySearch mode"); #endif // #ifdef DEBUG break; default: R_ASSERT(0); break; } UpdateConditionProgressBars(); CurModeToScript(); }//if if ( m_pActorInvOwner ) { UpdateOutfit(); UpdateActor(); } UpdateButtonsLayout(); }