void CInventory::Update() { if( OnServer() ) { if(m_iActiveSlot!=m_iNextActiveSlot) { CObject* pActor_owner = smart_cast<CObject*>(m_pOwner); if (Level().CurrentViewEntity() == pActor_owner) { if( (m_iNextActiveSlot!=NO_ACTIVE_SLOT) && ItemFromSlot(m_iNextActiveSlot) && !g_player_hud->allow_activation(ItemFromSlot(m_iNextActiveSlot)->cast_hud_item()) ) return; } if( ActiveItem() ) { CHudItem* hi = ActiveItem()->cast_hud_item(); if(!hi->IsHidden()) { if(hi->GetState()==CHUDState::eIdle && hi->GetNextState()==CHUDState::eIdle) hi->SendDeactivateItem(); UpdateDropTasks (); return; } } if (GetNextActiveSlot() != NO_ACTIVE_SLOT) { PIItem tmp_next_active = ItemFromSlot(GetNextActiveSlot()); if (tmp_next_active) { if (IsSlotBlocked(tmp_next_active)) { Activate(m_iActiveSlot); return; } else { tmp_next_active->ActivateItem(); } } } // if ( m_iActiveSlot != GetNextActiveSlot() ) { // LPCSTR const name = smart_cast<CGameObject const*>(m_pOwner)->cName().c_str(); // if ( !xr_strcmp("jup_b43_stalker_assistant_pri6695", name) ) // LogStackTrace (""); // Msg ("[%6d][%s] CInventory::Activate changing active slot from %d to next active slot %d", Device.dwTimeGlobal, name, m_iActiveSlot, GetNextActiveSlot() ); // } m_iActiveSlot = GetNextActiveSlot(); } if((GetNextActiveSlot()!=NO_ACTIVE_SLOT) && ActiveItem() && ActiveItem()->cast_hud_item()->IsHidden()) ActiveItem()->ActivateItem(); } UpdateDropTasks (); }
void CInventory::Items_SetCurrentEntityHud(bool current_entity) { TIItemContainer::iterator it; for(it = m_all.begin(); m_all.end() != it; ++it) { PIItem pIItem = *it; CHudItem* pHudItem = smart_cast<CHudItem*> (pIItem); if (pHudItem) { pHudItem->GetHUD()->Visible(current_entity); }; CWeapon* pWeapon = smart_cast<CWeapon*>(pIItem); if (pWeapon) { pWeapon->InitAddons(); pWeapon->UpdateAddonsVisibility(); } } };
// HUD void CActor::OnHUDDraw (CCustomHUD* /**hud/**/) { CHudItem* pHudItem = smart_cast<CHudItem*>(inventory().ActiveItem()); if (pHudItem && pHudItem->GetHUDmode()) // if(inventory().ActiveItem() ) { inventory().ActiveItem()->renderable_Render(); } #if 0//ndef NDEBUG if (Level().CurrentControlEntity() == this && g_ShowAnimationInfo) { string128 buf; HUD().Font().pFontStat->SetColor (0xffffffff); HUD().Font().pFontStat->OutSet (170,530); HUD().Font().pFontStat->OutNext ("Position: [%3.2f, %3.2f, %3.2f]",VPUSH(Position())); HUD().Font().pFontStat->OutNext ("Velocity: [%3.2f, %3.2f, %3.2f]",VPUSH(m_PhysicMovementControl->GetVelocity())); HUD().Font().pFontStat->OutNext ("Vel Magnitude: [%3.2f]",m_PhysicMovementControl->GetVelocityMagnitude()); HUD().Font().pFontStat->OutNext ("Vel Actual: [%3.2f]",m_PhysicMovementControl->GetVelocityActual()); switch (m_PhysicMovementControl->Environment()) { case CPHMovementControl::peOnGround: strcpy(buf,"ground"); break; case CPHMovementControl::peInAir: strcpy(buf,"air"); break; case CPHMovementControl::peAtWall: strcpy(buf,"wall"); break; } HUD().Font().pFontStat->OutNext (buf); if (IReceived != 0) { float Size = 0; Size = HUD().Font().pFontStat->GetSize(); HUD().Font().pFontStat->SetSize(Size*2); HUD().Font().pFontStat->SetColor (0xffff0000); HUD().Font().pFontStat->OutNext ("Input : [%3.2f]", ICoincidenced/IReceived * 100.0f); HUD().Font().pFontStat->SetSize(Size); }; }; #endif }
void CSpectator::FirstEye_ToPlayer(CObject* pObject) { CObject* pCurViewEntity = Level().CurrentEntity(); if (pCurViewEntity) { CActor* pOldActor = smart_cast<CActor*>(pCurViewEntity); if (pOldActor) { pOldActor->inventory().Items_SetCurrentEntityHud(false); }; if (pCurViewEntity->CLS_ID != CLSID_SPECTATOR) { Engine.Sheduler.Unregister (pCurViewEntity); Engine.Sheduler.Register (pCurViewEntity, TRUE); }; }; if (pObject) { Level().SetEntity(pObject); Engine.Sheduler.Unregister (pObject); Engine.Sheduler.Register (pObject, TRUE); CActor* pActor = smart_cast<CActor*> (pObject); if (pActor) { pActor->inventory().Items_SetCurrentEntityHud(true); CHudItem* pHudItem = smart_cast<CHudItem*>(pActor->inventory().ActiveItem()); if (pHudItem) { pHudItem->OnStateSwitch(pHudItem->GetState()); } } }; };
bool CActor::use_Holder (CHolderCustom* holder) { if(m_holder){ bool b = false; CGameObject* holderGO = smart_cast<CGameObject*>(m_holder); if(smart_cast<CCar*>(holderGO)) b = use_Vehicle(0); else if (holderGO->CLS_ID==CLSID_OBJECT_W_MOUNTED || holderGO->CLS_ID==CLSID_OBJECT_W_STATMGUN) b = use_MountedWeapon(0); if(inventory().ActiveItem()){ CHudItem* hi = smart_cast<CHudItem*>(inventory().ActiveItem()); if(hi) hi->OnAnimationEnd(hi->GetState()); } return b; }else{ bool b = false; CGameObject* holderGO = smart_cast<CGameObject*>(holder); if(smart_cast<CCar*>(holder)) b = use_Vehicle(holder); if (holderGO->CLS_ID==CLSID_OBJECT_W_MOUNTED || holderGO->CLS_ID==CLSID_OBJECT_W_STATMGUN) b = use_MountedWeapon(holder); if(b){//used succesfully // switch off torch... CAttachableItem *I = CAttachmentOwner::attachedItem(CLSID_DEVICE_TORCH); if (I){ CTorch* torch = smart_cast<CTorch*>(I); if (torch) torch->Switch(false); } } if(inventory().ActiveItem()){ CHudItem* hi = smart_cast<CHudItem*>(inventory().ActiveItem()); if(hi) hi->OnAnimationEnd(hi->GetState()); } return b; } }
void CActor::g_SetAnimation( u32 mstate_rl ) { if (!g_Alive()) { if (m_current_legs||m_current_torso){ SActorState* ST = 0; if (mstate_rl&mcCrouch) ST = &m_anims->m_crouch; else ST = &m_anims->m_normal; mstate_real = 0; m_current_legs.invalidate (); m_current_torso.invalidate (); smart_cast<CKinematicsAnimated*>(Visual())->PlayCycle(m_anims->m_dead_stop); } return; } STorsoWpn::eMovingState moving_idx = STorsoWpn::eIdle; SActorState* ST = 0; SAnimState* AS = 0; if (mstate_rl&mcCrouch) ST = &m_anims->m_crouch; else if (mstate_rl&mcClimb) ST = &m_anims->m_climb; else ST = &m_anims->m_normal; bool bAccelerated = isActorAccelerated(mstate_rl, IsZoomAimingMode()); if ( bAccelerated ){ AS = &ST->m_run; }else{ AS = &ST->m_walk; } if(mstate_rl&mcAnyMove){ if( bAccelerated ) moving_idx = STorsoWpn::eRun; else moving_idx = STorsoWpn::eWalk; } // анимации MotionID M_legs; MotionID M_torso; MotionID M_head; //если мы просто стоим на месте bool is_standing = false; // Legs if (mstate_rl&mcLanding) M_legs = ST->landing[0]; else if (mstate_rl&mcLanding2) M_legs = ST->landing[1]; else if ((mstate_rl&mcTurn)&& !(mstate_rl&mcClimb)) M_legs = ST->legs_turn; else if (mstate_rl&mcFall) M_legs = ST->jump_idle; else if (mstate_rl&mcJump) M_legs = ST->jump_begin; else if (mstate_rl&mcFwd) M_legs = AS->legs_fwd; else if (mstate_rl&mcBack) M_legs = AS->legs_back; else if (mstate_rl&mcLStrafe) M_legs = AS->legs_ls; else if (mstate_rl&mcRStrafe) M_legs = AS->legs_rs; else is_standing = true; if(mstate_rl&mcSprint){ g_SetSprintAnimation (mstate_rl,M_head,M_torso,M_legs); moving_idx = STorsoWpn::eSprint; } //--------------------------------------------------------------- if (this == Level().CurrentViewEntity()) { if ((mstate_rl&mcSprint) != (mstate_old&mcSprint)) { CHudItem* pHudItem = smart_cast<CHudItem*>(inventory().ActiveItem()); if (pHudItem) pHudItem->onMovementChanged(mcSprint); }; }; //----------------------------------------------------------------------- // Torso if(mstate_rl&mcClimb) { if (mstate_rl&mcFwd) M_torso = AS->legs_fwd; else if (mstate_rl&mcBack) M_torso = AS->legs_back; else if (mstate_rl&mcLStrafe) M_torso = AS->legs_ls; else if (mstate_rl&mcRStrafe) M_torso = AS->legs_rs; } if(!M_torso) { CInventoryItem* _i = inventory().ActiveItem(); CHudItem *H = smart_cast<CHudItem*>(_i); CWeapon *W = smart_cast<CWeapon*>(_i); CMissile *M = smart_cast<CMissile*>(_i); CArtefact *A = smart_cast<CArtefact*>(_i); if (H) { VERIFY(H->animation_slot() <= _total_anim_slots_); STorsoWpn* TW = &ST->m_torso[H->animation_slot() - 1]; if (!b_DropActivated&&!fis_zero(f_DropPower)){ M_torso = TW->drop; if (!M_torso) { Msg("! drop animation for %s", *(H->object().cName())); M_torso = ST->m_torso_idle; }; m_bAnimTorsoPlayed = TRUE; }else{ if (!m_bAnimTorsoPlayed) { if (W) { bool K =inventory().GetActiveSlot() == KNIFE_SLOT; bool R3 = W->IsTriStateReload(); if(K) { switch (W->GetState()){ case CWeapon::eIdle: M_torso = TW->moving[moving_idx]; break; case CWeapon::eFire: if(is_standing) M_torso = M_legs = M_head = TW->all_attack_0; else M_torso = TW->attack_zoom; break; case CWeapon::eFire2: if(is_standing) M_torso = M_legs = M_head = TW->all_attack_1; else M_torso = TW->fire_idle; break; case CWeapon::eJammed: case CWeapon::eReload: M_torso = TW->reload; break; case CWeapon::eShowing: M_torso = TW->draw; break; case CWeapon::eHiding: M_torso = TW->holster; break; default : M_torso = TW->moving[moving_idx]; break; } } else { switch (W->GetState()){ case CWeapon::eIdle: M_torso = W->IsZoomed()?TW->zoom:TW->moving[moving_idx]; break; case CWeapon::eFire: M_torso = W->IsZoomed()?TW->attack_zoom:TW->attack; break; case CWeapon::eFire2: M_torso = W->IsZoomed()?TW->attack_zoom:TW->attack; break; case CWeapon::eJammed: case CWeapon::eReload: if(!R3) M_torso = TW->reload; else{ CWeapon::EWeaponSubStates sub_st = W->GetReloadState(); switch (sub_st){ case CWeapon::eSubstateReloadBegin: M_torso = TW->reload; break; case CWeapon::eSubstateReloadInProcess: M_torso = TW->reload_1; break; case CWeapon::eSubstateReloadEnd: M_torso = TW->reload_2; break; default: M_torso = TW->reload; break; } }break; case CWeapon::eShowing: M_torso = TW->draw; break; case CWeapon::eHiding: M_torso = TW->holster; break; default : M_torso = TW->moving[moving_idx]; break; } } } else if (M) { if(is_standing) { switch (M->GetState()){ case MS_SHOWING : M_torso = TW->draw; break; case MS_HIDING : M_torso = TW->holster; break; case MS_IDLE_SPRINT: ; case MS_IDLE : M_torso = TW->moving[moving_idx]; break; case MS_EMPTY : M_torso = TW->zoom; break; case MS_THREATEN : M_torso = M_legs = M_head = TW->all_attack_0; break; case MS_READY : M_torso = M_legs = M_head = TW->all_attack_1; break; case MS_THROW : M_torso = M_legs = M_head = TW->all_attack_2; break; case MS_END : M_torso = M_legs = M_head = TW->all_attack_2; break; default : M_torso = TW->draw; break; } } else { switch (M->GetState()){ case MS_SHOWING : M_torso = TW->draw; break; case MS_HIDING : M_torso = TW->holster; break; case MS_IDLE_SPRINT: ; case MS_IDLE : M_torso = TW->moving[moving_idx]; break; case MS_EMPTY : M_torso = TW->moving[moving_idx]; break; case MS_THREATEN : M_torso = TW->attack_zoom; break; case MS_READY : M_torso = TW->fire_idle; break; case MS_THROW : M_torso = TW->fire_end; break; case MS_END : M_torso = TW->fire_end; break; default : M_torso = TW->draw; break; } } } else if (A){ switch(A->GetState()){ case CArtefact::eIdle : M_torso = TW->moving[moving_idx]; break; case CArtefact::eShowing : M_torso = TW->draw; break; case CArtefact::eHiding : M_torso = TW->holster; break; case CArtefact::eActivating : M_torso = TW->zoom; break; default : M_torso = TW->moving[moving_idx]; } } } } } } if (!M_legs) { if((mstate_rl&mcCrouch)&&!isActorAccelerated(mstate_rl, IsZoomAimingMode()))//!(mstate_rl&mcAccel)) { M_legs=smart_cast<CKinematicsAnimated*>(Visual())->ID_Cycle("cr_idle_1"); } else M_legs = ST->legs_idle; } if (!M_head) M_head = ST->m_head_idle; if (!M_torso){ if (m_bAnimTorsoPlayed) M_torso = m_current_torso; else M_torso = ST->m_torso_idle; } // есть анимация для всего - запустим / иначе запустим анимацию по частям if (m_current_torso!=M_torso){ if (m_bAnimTorsoPlayed) m_current_torso_blend = smart_cast<CKinematicsAnimated*> (Visual())->PlayCycle(M_torso,TRUE,AnimTorsoPlayCallBack,this); else /**/m_current_torso_blend = /**/smart_cast<CKinematicsAnimated*> (Visual())->PlayCycle(M_torso); m_current_torso=M_torso; } if(m_current_head!=M_head) { if(M_head)smart_cast<CKinematicsAnimated*>(Visual())->PlayCycle(M_head); m_current_head=M_head; } if (m_current_legs!=M_legs){ float pos = 0.f; VERIFY (!m_current_legs_blend || !fis_zero(m_current_legs_blend->timeTotal)); if ((mstate_real&mcAnyMove)&&(mstate_old&mcAnyMove)&&m_current_legs_blend) pos = fmod(m_current_legs_blend->timeCurrent,m_current_legs_blend->timeTotal)/m_current_legs_blend->timeTotal; m_current_legs_blend = smart_cast<CKinematicsAnimated*>(Visual())->PlayCycle(M_legs,TRUE,legs_play_callback,this); if ((!(mstate_old&mcAnyMove))&&(mstate_real&mcAnyMove)) pos = 0.5f*Random.randI(2); if (m_current_legs_blend) m_current_legs_blend->timeCurrent = m_current_legs_blend->timeTotal*pos; m_current_legs = M_legs; CStepManager::on_animation_start(M_legs, m_current_legs_blend); } #ifdef _DEBUG if(bDebug){ HUD().Font().pFontStat->OutSetI (0,0); HUD().Font().pFontStat->OutNext("[%s]",mov_state[moving_idx]); } #endif #ifdef _DEBUG if ((Level().CurrentControlEntity() == this) && g_ShowAnimationInfo) { string128 buf; strcpy(buf,""); if (isActorAccelerated(mstate_rl, IsZoomAimingMode())) strcat(buf,"Accel "); if (mstate_rl&mcCrouch) strcat(buf,"Crouch "); if (mstate_rl&mcFwd) strcat(buf,"Fwd "); if (mstate_rl&mcBack) strcat(buf,"Back "); if (mstate_rl&mcLStrafe) strcat(buf,"LStrafe "); if (mstate_rl&mcRStrafe) strcat(buf,"RStrafe "); if (mstate_rl&mcJump) strcat(buf,"Jump "); if (mstate_rl&mcFall) strcat(buf,"Fall "); if (mstate_rl&mcTurn) strcat(buf,"Turn "); if (mstate_rl&mcLanding) strcat(buf,"Landing "); if (mstate_rl&mcLLookout) strcat(buf,"LLookout "); if (mstate_rl&mcRLookout) strcat(buf,"RLookout "); if (m_bJumpKeyPressed) strcat(buf,"+Jumping "); HUD().Font().pFontStat->OutNext ("MSTATE: [%s]",buf); /* switch (m_PhysicMovementControl->Environment()) { case CPHMovementControl::peOnGround: strcpy(buf,"ground"); break; case CPHMovementControl::peInAir: strcpy(buf,"air"); break; case CPHMovementControl::peAtWall: strcpy(buf,"wall"); break; } HUD().Font().pFontStat->OutNext (buf); HUD().Font().pFontStat->OutNext ("Accel [%3.2f, %3.2f, %3.2f]",VPUSH(NET_SavedAccel)); HUD().Font().pFontStat->OutNext ("V [%3.2f, %3.2f, %3.2f]",VPUSH(m_PhysicMovementControl->GetVelocity())); HUD().Font().pFontStat->OutNext ("vertex ID %d",ai_location().level_vertex_id()); Game().m_WeaponUsageStatistic->Draw(); */ }; #endif if (!m_current_torso_blend) return; CKinematicsAnimated *skeleton_animated = PKinematicsAnimated(Visual()); CMotionDef *motion0 = skeleton_animated->LL_GetMotionDef(m_current_torso); VERIFY (motion0); if (!(motion0->flags & esmSyncPart)) return; if (!m_current_legs_blend) return; CMotionDef *motion1 = skeleton_animated->LL_GetMotionDef(m_current_legs); VERIFY (motion1); if (!(motion1->flags & esmSyncPart)) return; m_current_torso_blend->timeCurrent = m_current_legs_blend->timeCurrent/m_current_legs_blend->timeTotal*m_current_torso_blend->timeTotal; }
void CInventory::Activate(u16 slot, bool bForce) { if(!OnServer()) { return; } PIItem tmp_item = NULL; if (slot != NO_ACTIVE_SLOT) tmp_item = ItemFromSlot(slot); if (tmp_item && IsSlotBlocked(tmp_item) && (!bForce)) { //to restore after unblocking ... SetPrevActiveSlot(slot); return; } if (GetActiveSlot()==slot || (GetNextActiveSlot()==slot && !bForce)) { // if (m_iNextActiveSlot != slot) { // LPCSTR const name = smart_cast<CGameObject const*>(m_pOwner)->cName().c_str(); // if ( !xr_strcmp("jup_b43_stalker_assistant_pri6695", name) ) // LogStackTrace (""); // Msg ( "[%6d][%s] CInventory::Activate changing next active slot to %d", Device.dwTimeGlobal, name, slot ); // } m_iNextActiveSlot=slot; #ifdef DEBUG // Msg("--- There's no need to activate slot [%d], next active slot is [%d]", slot, m_iNextActiveSlot); #endif return; } R_ASSERT2(slot<=LastSlot(), "wrong slot number"); if (slot != NO_ACTIVE_SLOT && !m_slots[slot].CanBeActivated()) return; #ifdef DEBUG // Msg("--- Activating slot [%d], inventory owner: [%s], Frame[%d]", slot, m_pOwner->Name(), Device.dwFrame); #endif // #ifdef DEBUG //активный слот не выбран if (GetActiveSlot() == NO_ACTIVE_SLOT) { if (tmp_item) { // if ( m_iNextActiveSlot != slot) { // LPCSTR const name = smart_cast<CGameObject const*>(m_pOwner)->cName().c_str(); // if ( !xr_strcmp("jup_b43_stalker_assistant_pri6695", name) ) // LogStackTrace (""); // Msg ( "[%6d][%s] CInventory::Activate changing next active slot2 to %d", Device.dwTimeGlobal, name, slot ); // } m_iNextActiveSlot = slot; } else { if(slot==GRENADE_SLOT)//fake for grenade { PIItem gr = SameSlot(GRENADE_SLOT, NULL, true); if(gr) Slot(GRENADE_SLOT,gr); } } } //активный слот задействован else if (slot==NO_ACTIVE_SLOT || tmp_item) { PIItem active_item = ActiveItem(); if(active_item && !bForce) { CHudItem* tempItem = active_item->cast_hud_item(); R_ASSERT2(tempItem, active_item->object().cNameSect().c_str()); tempItem->SendDeactivateItem(); #ifdef DEBUG // Msg("--- Inventory owner [%s]: send deactivate item [%s]", m_pOwner->Name(), active_item->NameItem()); #endif // #ifdef DEBUG } else //in case where weapon is going to destroy { if (tmp_item) tmp_item->ActivateItem(); //! if ( m_iActiveSlot != slot ) { //! LPCSTR const name = smart_cast<CGameObject const*>(m_pOwner)->cName().c_str(); // if ( !xr_strcmp("jup_b43_stalker_assistant_pri6695", name) ) // LogStackTrace (""); //! Msg ("[%6d][%s] CInventory::Activate changing active slot from %d to %d", Device.dwTimeGlobal, name, m_iActiveSlot, slot ); //! } m_iActiveSlot = slot; } // if ( m_iNextActiveSlot != slot ) { // LPCSTR const name = smart_cast<CGameObject const*>(m_pOwner)->cName().c_str(); // if ( !xr_strcmp("jup_b43_stalker_assistant_pri6695", name) && !slot ) // LogStackTrace (""); // Msg ( "[%6d][%s] CInventory::Activate changing next active slot3 to %d", Device.dwTimeGlobal, name, slot ); // } m_iNextActiveSlot = slot; } }
void CActor::shedule_Update (u32 DT) { setSVU(OnServer()); //установить режим показа HUD для текущего активного слота CHudItem* pHudItem = smart_cast<CHudItem*>(inventory().ActiveItem()); if(pHudItem && !pHudItem->object().getDestroy()) pHudItem->SetHUDmode(HUDview()); //обновление инвентаря UpdateInventoryOwner (DT); if (GameID() == GAME_SINGLE) GameTaskManager().UpdateTasks (); if(m_holder || !getEnabled() || !Ready()) { m_sDefaultObjAction = NULL; inherited::shedule_Update (DT); /* if (OnServer()) { Check_Weapon_ShowHideState(); }; */ return; } // clamp (DT,0u,100u); float dt = float(DT)/1000.f; // Check controls, create accel, prelimitary setup "mstate_real" //----------- for E3 ----------------------------- // if (Local() && (OnClient() || Level().CurrentEntity()==this)) if (Level().CurrentControlEntity() == this && (!Level().IsDemoPlay() || Level().IsServerDemo())) //------------------------------------------------ { g_cl_CheckControls (mstate_wishful,NET_SavedAccel,NET_Jump,dt); { /* if (mstate_real & mcJump) { NET_Packet P; u_EventGen(P, GE_ACTOR_JUMPING, ID()); P.w_sdir(NET_SavedAccel); P.w_float(NET_Jump); u_EventSend(P); } */ } g_cl_Orientate (mstate_real,dt); g_Orientate (mstate_real,dt); g_Physics (NET_SavedAccel,NET_Jump,dt); g_cl_ValidateMState (dt,mstate_wishful); g_SetAnimation (mstate_real); // Check for game-contacts Fvector C; float R; //m_PhysicMovementControl->GetBoundingSphere (C,R); Center(C); R=Radius(); feel_touch_update (C,R); // Dropping if (b_DropActivated) { f_DropPower += dt*0.1f; clamp (f_DropPower,0.f,1.f); } else { f_DropPower = 0.f; } if (!Level().IsDemoPlay()) { //----------------------------------------------------- mstate_wishful &=~mcAccel; mstate_wishful &=~mcLStrafe; mstate_wishful &=~mcRStrafe; mstate_wishful &=~mcLLookout; mstate_wishful &=~mcRLookout; mstate_wishful &=~mcFwd; mstate_wishful &=~mcBack; extern bool g_bAutoClearCrouch; if (g_bAutoClearCrouch) mstate_wishful &=~mcCrouch; //----------------------------------------------------- } } else { make_Interpolation(); if (NET.size()) { // NET_SavedAccel = NET_Last.p_accel; // mstate_real = mstate_wishful = NET_Last.mstate; g_sv_Orientate (mstate_real,dt ); g_Orientate (mstate_real,dt ); g_Physics (NET_SavedAccel,NET_Jump,dt ); if (!m_bInInterpolation) g_cl_ValidateMState (dt,mstate_wishful); g_SetAnimation (mstate_real); if (NET_Last.mstate & mcCrouch) { if (isActorAccelerated(mstate_real, IsZoomAimingMode())) character_physics_support()->movement()->ActivateBox(1, true); else character_physics_support()->movement()->ActivateBox(2, true); } else character_physics_support()->movement()->ActivateBox(0, true); } mstate_old = mstate_real; } if (this == Level().CurrentViewEntity()) { UpdateMotionIcon (mstate_real); }; NET_Jump = 0; inherited::shedule_Update (DT); //эффектор включаемый при ходьбе if (!pCamBobbing) { pCamBobbing = xr_new<CEffectorBobbing> (); Cameras().AddCamEffector (pCamBobbing); } pCamBobbing->SetState (mstate_real, conditions().IsLimping(), IsZoomAimingMode()); //звук тяжелого дыхания при уталости и хромании if(this==Level().CurrentControlEntity() && !g_pGamePersistent->bDedicatedServer ) { if(conditions().IsLimping() && g_Alive()){ if(!m_HeavyBreathSnd._feedback()){ m_HeavyBreathSnd.play_at_pos(this, Fvector().set(0,ACTOR_HEIGHT,0), sm_Looped | sm_2D); }else{ m_HeavyBreathSnd.set_position(Fvector().set(0,ACTOR_HEIGHT,0)); } }else if(m_HeavyBreathSnd._feedback()){ m_HeavyBreathSnd.stop (); } float bs = conditions().BleedingSpeed(); if(bs>0.6f) { Fvector snd_pos; snd_pos.set(0,ACTOR_HEIGHT,0); if(!m_BloodSnd._feedback()) m_BloodSnd.play_at_pos(this, snd_pos, sm_Looped | sm_2D); else m_BloodSnd.set_position(snd_pos); float v = bs+0.25f; m_BloodSnd.set_volume (v); }else{ if(m_BloodSnd._feedback()) m_BloodSnd.stop(); } } //если в режиме HUD, то сама модель актера не рисуется if(!character_physics_support()->IsRemoved()) setVisible (!HUDview ()); //что актер видит перед собой collide::rq_result& RQ = HUD().GetCurrentRayQuery(); if(!input_external_handler_installed() && RQ.O && RQ.range<inventory().GetTakeDist()) { m_pObjectWeLookingAt = smart_cast<CGameObject*>(RQ.O); CGameObject *game_object = smart_cast<CGameObject*>(RQ.O); m_pUsableObject = smart_cast<CUsableScriptObject*>(game_object); m_pInvBoxWeLookingAt = smart_cast<CInventoryBox*>(game_object); inventory().m_pTarget = smart_cast<PIItem>(game_object); m_pPersonWeLookingAt = smart_cast<CInventoryOwner*>(game_object); m_pVehicleWeLookingAt = smart_cast<CHolderCustom*>(game_object); CEntityAlive* pEntityAlive = smart_cast<CEntityAlive*>(game_object); if (GameID() == GAME_SINGLE ) { if (m_pUsableObject && m_pUsableObject->tip_text()) { m_sDefaultObjAction = CStringTable().translate( m_pUsableObject->tip_text() ); } else { if (m_pPersonWeLookingAt && pEntityAlive->g_Alive()) m_sDefaultObjAction = m_sCharacterUseAction; else if (pEntityAlive && !pEntityAlive->g_Alive()) { bool b_allow_drag = !!pSettings->line_exist("ph_capture_visuals",pEntityAlive->cNameVisual()); if(b_allow_drag) m_sDefaultObjAction = m_sDeadCharacterUseOrDragAction; else m_sDefaultObjAction = m_sDeadCharacterUseAction; }else if (m_pVehicleWeLookingAt) m_sDefaultObjAction = m_sCarCharacterUseAction; else if (inventory().m_pTarget && inventory().m_pTarget->CanTake() ) m_sDefaultObjAction = m_sInventoryItemUseAction; //. else if (m_pInvBoxWeLookingAt) //. m_sDefaultObjAction = m_sInventoryBoxUseAction; else m_sDefaultObjAction = NULL; } } } else { inventory().m_pTarget = NULL; m_pPersonWeLookingAt = NULL; m_sDefaultObjAction = NULL; m_pUsableObject = NULL; m_pObjectWeLookingAt = NULL; m_pVehicleWeLookingAt = NULL; m_pInvBoxWeLookingAt = NULL; } // UpdateSleep (); //для свойст артефактов, находящихся на поясе UpdateArtefactsOnBelt (); m_pPhysics_support->in_shedule_Update (DT); Check_for_AutoPickUp (); };
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 CLevel::IR_OnKeyboardPress (int key) { bool b_ui_exist = (pHUD && pHUD->GetUI()); if (!g_bDisableAllInput) { if (auto ui = HUD().GetUI()) { if (ui->UIMainIngameWnd) { ui->UIMainIngameWnd->HudAdjustMode(key); // Real Wolf. 07.09.2014. } } /************************************************** added by Ray Twitty (aka Shadows) START **************************************************/ // Колбек на нажатие клавиши if (g_actor) Actor()->callback(GameObject::eOnKeyPress)(key); /*************************************************** added by Ray Twitty (aka Shadows) END ***************************************************/ } EGameActions _curr = get_binded_action(key); switch ( _curr ) { case kSCREENSHOT: Render->Screenshot(); return; break; case kCONSOLE: Console->Show (); return; break; case kQUIT: { if(b_ui_exist && HUD().GetUI()->MainInputReceiver() ){ if(HUD().GetUI()->MainInputReceiver()->IR_OnKeyboardPress(key)) return;//special case for mp and main_menu HUD().GetUI()->StartStopMenu( HUD().GetUI()->MainInputReceiver(), true); }else Console->Execute ("main_menu"); return; }break; case kPAUSE: if(!g_block_pause) { if ( IsGameTypeSingle() ) { Device.Pause(!Device.Paused(), TRUE, TRUE, "li_pause_key"); } } return; break; }; if( g_bDisableAllInput ) return; if ( !b_ui_exist ) return; if ( b_ui_exist && pHUD->GetUI()->IR_OnKeyboardPress(key)) return; if( Device.Paused() ) return; if ( game && Game().IR_OnKeyboardPress(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_NUMPAD5: { if (GameID() != GAME_SINGLE) { Msg("For this game type Demo Record is disabled."); /// return; }; Console->Hide (); Console->Execute("demo_record 1"); } break; #endif // MASTER_GOLD #ifdef DEBUG case DIK_RETURN: bDebug = !bDebug; return; case DIK_BACK: if (GameID() == GAME_SINGLE) 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; } case MOUSE_1: { if (GameID() != GAME_SINGLE) break; if (pInput->iGetAsyncKeyState(DIK_LALT)) { if (CurrentEntity()->CLS_ID == CLSID_OBJECT_ACTOR) try_change_current_entity (); else restore_actor (); return; } break; } /**/ case DIK_DIVIDE: if( OnServer() ){ // float NewTimeFactor = pSettings->r_float("alife","time_factor"); if (GameID() == GAME_SINGLE) Server->game->SetGameTimeFactor(g_fTimeFactor); else { Server->game->SetEnvironmentGameTimeFactor(g_fTimeFactor); Server->game->SetGameTimeFactor(g_fTimeFactor); }; } break; case DIK_MULTIPLY: if( OnServer() ){ float NewTimeFactor = 1000.f; if (GameID() == GAME_SINGLE) Server->game->SetGameTimeFactor(NewTimeFactor); else { Server->game->SetEnvironmentGameTimeFactor(NewTimeFactor); // Server->game->SetGameTimeFactor(NewTimeFactor); }; } break; #endif #ifdef DEBUG case DIK_F9:{ // if (!ai().get_alife()) // break; // const_cast<CALifeSimulatorHeader&>(ai().alife().header()).set_state(ALife::eZoneStateSurge); if (GameID() != GAME_SINGLE) { extern INT g_sv_SendUpdate; g_sv_SendUpdate = 1; }; 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 #ifndef MASTER_GOLD } #endif // MASTER_GOLD if (bindConsoleCmds.execute(key)) return; if( b_ui_exist && HUD().GetUI()->MainInputReceiver() )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 }