bool CMPTutorial::CheckVehicles(const CPlayer* pPlayer) { FUNCTION_PROFILER(GetISystem(), PROFILE_GAME); bool showPrompt = false; if(!pPlayer) return showPrompt; IVehicle* pVehicle = pPlayer->GetLinkedVehicle(); if(m_wasInVehicle && !pVehicle) { // got out of vehicle. Move HUD box back to normal place. SAFE_HUD_FUNC(SetTutorialTextPosition(2)); m_wasInVehicle = false; return showPrompt; } if(pVehicle && !m_wasInVehicle) { // just got in. Move HUD box up so it doesn't overlap vehicle hud. SAFE_HUD_FUNC(SetTutorialTextPosition(1)); m_wasInVehicle = true; // generic 'boarding a vehicle' message TriggerEvent(eTE_BoardVehicle); } return showPrompt; }
//------------------------------------------------------------------------ void CProjectile::SetTracked(bool tracked) { if (m_tracked!=tracked) { if (tracked) { SAFE_HUD_FUNC(AddTrackedProjectile(GetEntityId())); } else { SAFE_HUD_FUNC(RemoveTrackedProjectile(GetEntityId())); } m_tracked=tracked; } }
void execute(CItem *item) { SAFE_HUD_FUNC(WeaponAccessoriesInterface(true)); _pWeapon->PlayLayer(g_pItemStrings->modify_layer, eIPAF_Default|eIPAF_NoBlend, false); _pWeapon->m_transitioning = false; gEnv->p3DEngine->SetPostEffectParam("Dof_BlurAmount", 1.0f); _pWeapon->m_dofSpeed=0.0f; }
//------------------------------------------------------------------------ void CGameRules::ClientHit(const HitInfo &hitInfo) { FUNCTION_PROFILER(GetISystem(), PROFILE_GAME); IActor *pClientActor = g_pGame->GetIGameFramework()->GetClientActor(); IEntity *pTarget = m_pEntitySystem->GetEntity(hitInfo.targetId); IEntity *pShooter = m_pEntitySystem->GetEntity(hitInfo.shooterId); IVehicle *pVehicle = g_pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(hitInfo.targetId); IActor *pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(hitInfo.targetId); bool dead = pActor?(pActor->GetHealth()<=0):false; if((pClientActor && pClientActor->GetEntity()==pShooter) && pTarget && (pVehicle || pActor) && !dead) { SAFE_HUD_FUNC(GetCrosshair()->CrosshairHit()); SAFE_HUD_FUNC(GetTagNames()->AddEnemyTagName(pActor?pActor->GetEntityId():pVehicle->GetEntityId())); } if(pActor == pClientActor) if (gEnv->pInput) gEnv->pInput->ForceFeedbackEvent( SFFOutputEvent(eDI_XI, eFF_Rumble_Basic, 0.5f * hitInfo.damage * 0.01f, hitInfo.damage * 0.02f, 0.0f)); /* if (gEnv->pAISystem && !gEnv->bMultiplayer) { static int htMelee = GetHitTypeId("melee"); if (pShooter && hitInfo.type != htMelee) { ISurfaceType *pSurfaceType = GetHitMaterial(hitInfo.material); const ISurfaceType::SSurfaceTypeAIParams* pParams = pSurfaceType ? pSurfaceType->GetAIParams() : 0; const float radius = pParams ? pParams->fImpactRadius : 5.0f; gEnv->pAISystem->BulletHitEvent(hitInfo.pos, radius, pShooter->GetAI()); } }*/ CreateScriptHitInfo(m_scriptHitInfo, hitInfo); CallScript(m_clientStateScript, "OnHit", m_scriptHitInfo); bool backface = hitInfo.dir.Dot(hitInfo.normal)>0; if (!hitInfo.remote && hitInfo.targetId && !backface) { if (!gEnv->bServer) GetGameObject()->InvokeRMI(SvRequestHit(), hitInfo, eRMI_ToServer); else ServerHit(hitInfo); } }
//------------------------------------------------------------------------- bool CWeapon::OnActionModify(EntityId actorId, const ActionId& actionId, int activationMode, float value) { COffHand * offHandWeapon = NULL; bool isOffHandSelected = false; GetOffHandInfo(this,isOffHandSelected,&offHandWeapon); if (!IsBusy() && !isOffHandSelected) { if (m_fm) m_fm->StopFire(); if(m_zm && m_zm->IsZoomed()) m_zm->StopZoom(); if(m_weaponRaised) RaiseWeapon(false,true); if (m_modifying && !m_transitioning) { StopLayer(g_pItemStrings->modify_layer, eIPAF_Default, false); PlayAction(g_pItemStrings->leave_modify, 0); m_dofSpeed = -1.0f/((float)GetCurrentAnimationTime(eIGS_FirstPerson)/1000.0f); m_dofValue = 1.0f; m_focusValue = -1.0f; GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<ScheduleLayer_Leave>::Create(this), false); m_transitioning = true; SAFE_HUD_FUNC(WeaponAccessoriesInterface(false)); m_modifying = false; GetGameObject()->InvokeRMI(CItem::SvRequestLeaveModify(), CItem::EmptyParams(), eRMI_ToServer); } else if (!m_modifying && !m_transitioning) { gEnv->p3DEngine->SetPostEffectParam("Dof_Active", 1.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusRange", -1.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMin", 0.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMax", 5.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusLimit", 20.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_UseMask", 0.0f); PlayAction(g_pItemStrings->enter_modify, 0, false, eIPAF_Default | eIPAF_RepeatLastFrame); m_dofSpeed = 1.0f/((float)GetCurrentAnimationTime(eIGS_FirstPerson)/1000.0f); m_dofValue = 0.0f; m_transitioning = true; GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<ScheduleLayer_Enter>::Create(this), false); m_modifying = true; GetGameObject()->InvokeRMI(CItem::SvRequestEnterModify(), CItem::EmptyParams(), eRMI_ToServer); } } return true; }
//------------------------------------------------------------------------ int CScriptBind_Actor::RenderScore(IFunctionHandler *pH, ScriptHandle player, int kills, int deaths, int ping) { CActor *pActor = (CActor*)(m_pGameFW->GetClientActor()); if(!pActor) return pH->EndFunction(); SAFE_HUD_FUNC(AddToScoreBoard((EntityId)player.n, kills, deaths, ping)); return pH->EndFunction(); }
//------------------------------------------------------------------------ int CScriptBind_Actor::ResetScores(IFunctionHandler *pH) { CActor *pActor = (CActor*)(m_pGameFW->GetClientActor()); if(!pActor) return pH->EndFunction(); SAFE_HUD_FUNC(ResetScoreBoard()); return pH->EndFunction(); }
//------------------------------------------------------------------------ int CScriptBind_Actor::AddInventoryAmmo(IFunctionHandler *pH, const char *ammo, int amount) { CActor * pActor = GetActor(pH); if (!pActor) return pH->EndFunction(); IInventory *pInventory=pActor->GetInventory(); if (!pInventory) return pH->EndFunction(); IEntityClass* pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(ammo); assert(pClass); int capacity = pInventory->GetAmmoCapacity(pClass); int current = pInventory->GetAmmoCount(pClass); if((!gEnv->pSystem->IsEditor()) && (amount > capacity)) { if(pActor->IsClient()) SAFE_HUD_FUNC(DisplayFlashMessage("@ammo_maxed_out", 2, ColorF(1.0f, 0,0), true, (string("@")+pClass->GetName()).c_str())); //If still there's some place, full inventory to maximum... if(current<capacity) { pInventory->SetAmmoCount(pClass,capacity); if(pActor->IsClient() && capacity - current > 0) { /*char buffer[5]; itoa(capacity - current, buffer, 10); SAFE_HUD_FUNC(DisplayFlashMessage("@grab_ammo", 3, Col_Wheat, true, (string("@")+pClass->GetName()).c_str(), buffer));*/ if(g_pGame->GetHUD()) g_pGame->GetHUD()->DisplayAmmoPickup(pClass->GetName(), capacity - current); } if (gEnv->bServer) pActor->GetGameObject()->InvokeRMI(CActor::ClAddAmmo(), CActor::AmmoParams(ammo, amount), eRMI_ToRemoteClients); } } else { pInventory->SetAmmoCount(pClass, amount); if(pActor->IsClient() && amount - current > 0) { /*char buffer[5]; itoa(amount - current, buffer, 10); SAFE_HUD_FUNC(DisplayFlashMessage("@grab_ammo", 3, Col_Wheat, true, (string("@")+pClass->GetName()).c_str(), buffer));*/ if(g_pGame->GetHUD()) g_pGame->GetHUD()->DisplayAmmoPickup(pClass->GetName(), amount - current); } if (gEnv->bServer) pActor->GetGameObject()->InvokeRMI(CActor::ClAddAmmo(), CActor::AmmoParams(ammo, amount), eRMI_ToRemoteClients); } return pH->EndFunction(); }
//------------------------------------------------------------------------ void CScan::StartFire() { if (!m_pWeapon->IsBusy()) { if(m_pWeapon->GetOwnerActor()) { // add the flash animation part here IEntity *pEntity = m_pWeapon->GetEntity(); if(pEntity) { IEntityRenderProxy* pRenderProxy((IEntityRenderProxy*)pEntity->GetProxy(ENTITY_PROXY_RENDER)); if (pRenderProxy) { IMaterial* pMtl(pRenderProxy->GetRenderMaterial(0)); if (pMtl) { pMtl = pMtl->GetSafeSubMtl(2); if (pMtl) { const SShaderItem& shaderItem(pMtl->GetShaderItem()); if (shaderItem.m_pShaderResources && shaderItem.m_pShaderResources->GetTexture(0)) { SEfResTexture* pTex(shaderItem.m_pShaderResources->GetTexture(0)); if (pTex->m_Sampler.m_pDynTexSource) { IFlashPlayer* pFlashPlayer(0); IDynTextureSource::EDynTextureSource type(IDynTextureSource::DTS_I_FLASHPLAYER); pTex->m_Sampler.m_pDynTexSource->GetDynTextureSource((void*&)pFlashPlayer, type); if (pFlashPlayer && type == IDynTextureSource::DTS_I_FLASHPLAYER) { pFlashPlayer->Invoke0("startScan"); } } } } } } } SAFE_HUD_FUNC(SetRadarScanningEffect(true)); m_scanning=true; m_delayTimer=m_scanparams.delay; m_durationTimer=m_scanparams.duration; m_tagEntitiesDelay=m_scanparams.tagDelay; m_pWeapon->SetBusy(true); } m_pWeapon->PlayAction(m_scanactions.spin_up, 0, false, CItem::eIPAF_Default|CItem::eIPAF_CleanBlending); m_pWeapon->RequestStartFire(); m_pWeapon->RequireUpdate(eIUS_FireMode); } }
//------------------------------------------------------------------------ IMPLEMENT_RMI(CGameRules, ClDamageIndicator) { Vec3 dir(ZERO); bool vehicle=false; if (IEntity *pEntity=gEnv->pEntitySystem->GetEntity(params.shooterId)) { if (IActor *pLocal=m_pGameFramework->GetClientActor()) { dir=(pLocal->GetEntity()->GetWorldPos()-pEntity->GetWorldPos()); dir.NormalizeSafe(); vehicle=(pLocal->GetLinkedVehicle()!=0); } } SAFE_HUD_FUNC(IndicateDamage(params.weaponId, dir, vehicle)); SAFE_HUD_FUNC(ShowTargettingAI(params.shooterId)); return true; }
//------------------------------------------------------------------------ void CScan::StopFire() { if (!m_scanning) return; IEntity *pEntity = m_pWeapon->GetEntity(); if(pEntity) { IEntityRenderProxy* pRenderProxy((IEntityRenderProxy*)pEntity->GetProxy(ENTITY_PROXY_RENDER)); if (pRenderProxy) { IMaterial* pMtl(pRenderProxy->GetRenderMaterial(0)); if (pMtl) { pMtl = pMtl->GetSafeSubMtl(2); if (pMtl) { const SShaderItem& shaderItem(pMtl->GetShaderItem()); if (shaderItem.m_pShaderResources && shaderItem.m_pShaderResources->GetTexture(0)) { SEfResTexture* pTex(shaderItem.m_pShaderResources->GetTexture(0)); if (pTex->m_Sampler.m_pDynTexSource) { IFlashPlayer* pFlashPlayer(0); IDynTextureSource::EDynTextureSource type(IDynTextureSource::DTS_I_FLASHPLAYER); pTex->m_Sampler.m_pDynTexSource->GetDynTextureSource((void*&)pFlashPlayer, type); if (pFlashPlayer && type == IDynTextureSource::DTS_I_FLASHPLAYER) { pFlashPlayer->Invoke0("cancelScan"); } } } } } } } SAFE_HUD_FUNC(SetRadarScanningEffect(false)); m_pWeapon->PlayAction(m_scanactions.spin_down, 0, false, CItem::eIPAF_Default|CItem::eIPAF_CleanBlending); m_scanning=false; m_pWeapon->SetBusy(false); m_pWeapon->RequestStopFire(); if (m_scanLoopId != INVALID_SOUNDID) { m_pWeapon->StopSound(m_scanLoopId); m_scanLoopId = INVALID_SOUNDID; } }
void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo ) { switch (event) { case eFE_Initialize: m_actInfo = *pActInfo; SAFE_HUD_FUNC(RegisterListener(this)); break; case eFE_Activate: { } break; } }
//------------------------------------------------------------------------ IMPLEMENT_RMI(CGameRules, ClTaggedEntity) { if (!params.entityId) return true; //SAFE_HUD_FUNC(GetRadar()->AddTaggedEntity(params.entityId)); //we have no tagging anymore, just temp and non-temp adding SAFE_HUD_FUNC(GetRadar()->AddEntityToRadar(params.entityId)); SEntityEvent scriptEvent( ENTITY_EVENT_SCRIPT_EVENT ); scriptEvent.nParam[0] = (INT_PTR)"OnGPSTagged"; scriptEvent.nParam[1] = IEntityClass::EVT_BOOL; bool bValue = true; scriptEvent.nParam[2] = (INT_PTR)&bValue; IEntity *pEntity = gEnv->pEntitySystem->GetEntity(params.entityId); if (pEntity) pEntity->SendEvent( scriptEvent ); return true; }
IMPLEMENT_RMI(CGameRules, ClVotingStatus) { SAFE_HUD_FUNC(SetVotingState(params.state,params.timeout,params.entityId,params.description)); return true; }
//------------------------------------------------------------------------ IMPLEMENT_RMI(CGameRules, ClHitIndicator) { SAFE_HUD_FUNC(IndicateHit(false, NULL,params.success)); return true; }
//----------------------------------------------------------------------------------------------------- bool COptionsManager::HandleFSCommand(const char *szCommand,const char *szArgs) { if(!m_pPlayerProfileManager) return false; const char* user = m_pPlayerProfileManager->GetCurrentUser(); IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(user); if(!pProfile) return false; if(!stricmp(szCommand, "SaveProfile")) { UpdateToProfile(); SaveProfile(); return true; } if(!stricmp(szCommand, "RestoreDefaultProfile")) { if(szArgs && szArgs[0]) ResetDefaults(szArgs); else ResetDefaults(NULL); return true; } if(!stricmp(szCommand, "UpdateCVars")) { UpdateFlashOptions(); return true; } if(!stricmp(szCommand, "hud_showAllObjectives")) { if(szArgs) { SAFE_HUD_FUNC(SetShowAllOnScreenObjectives(atoi(szArgs)?true:false)); } } else if(!stricmp(szCommand,"hud_colorLine")) { SetCrysisProfileColor(szArgs); } else if(gEnv->bMultiplayer && !stricmp(szCommand,"g_psTutorial_Enabled")) { if(atoi(szArgs)==1) { gEnv->pConsole->ExecuteString("g_psTutorial_Reset"); } } std::map<string,SOptionEntry>::iterator it = m_profileOptions.find(szCommand); if(it!=m_profileOptions.end()) { ICVar *pCVAR = gEnv->pConsole->GetCVar(szCommand); if(pCVAR) { if(pCVAR->GetType()==1) //int { int value = atoi(szArgs); pCVAR->Set(value); } else if(pCVAR->GetType()==2) //float { float value = atof(szArgs); pCVAR->Set(value); } else if(pCVAR->GetType()==3) //string pCVAR->Set(szArgs); return true; // it's a CVAR, we are done! } } //else //does this map to an options function? even if it is inside m_profileOptions, but not a console variable (e.g. pb_client), we want to see if it's a registered command { TOpFuncMapIt iter = m_opFuncMap.find(szCommand); if(iter!=m_opFuncMap.end()) { (this->*(iter->second))(szArgs); return true; } } return false; }
void CMPTutorial::Update() { FUNCTION_PROFILER(GetISystem(), PROFILE_GAME); if(!m_enabled && g_pGameCVars->g_PSTutorial_Enabled) EnableTutorialMode(true); else if(m_enabled && !g_pGameCVars->g_PSTutorial_Enabled) EnableTutorialMode(false); m_currentEvent.m_msgDisplayTime -= gEnv->pTimer->GetFrameTime(); if(!m_enabled) { if(m_currentEvent.m_msgDisplayTime < 0.0f && m_currentEvent.m_msgRemovalCondition != eMRC_None) { m_currentEvent.m_msgRemovalCondition = eMRC_None; SAFE_HUD_FUNC(ShowTutorialText(NULL,1)); } } // update the text... must be done even if not enabled, to ensure the 'you may reenable...' // message is shown correctly. if(m_currentEvent.m_numChunks > 0) { // calculate how far through the current sound we are CTimeValue now = gEnv->pTimer->GetFrameStartTime(); float soundTimer = now.GetMilliSeconds() - m_currentEvent.m_soundStartTime; assert(soundTimer >= 0); float soundPercent = 1.0f; if(m_currentEvent.m_soundLength == 0.0f && m_currentEvent.m_pCurrentSound.get()) { m_currentEvent.m_soundLength = m_currentEvent.m_pCurrentSound->GetLengthMs(); } if(m_currentEvent.m_soundLength > 0.0f) { soundPercent = soundTimer / m_currentEvent.m_soundLength; } for(int i=m_currentEvent.m_numChunks-1; i > m_currentEvent.m_currentChunk; --i) { if(m_currentEvent.m_chunks[i].m_startPercent <= soundPercent) { m_currentEvent.m_currentChunk = i; int pos = 2; // 2=bottom, 1=middle IActor *pClientActor = g_pGame->GetIGameFramework()->GetClientActor(); if(pClientActor && pClientActor->GetLinkedVehicle()) { pos = 1; } SAFE_HUD_FUNC(ShowTutorialText(m_currentEvent.m_chunks[i].m_text, pos)); break; } } } if(!m_enabled) return; CPlayer* pPlayer = static_cast<CPlayer*>(g_pGame->GetIGameFramework()->GetClientActor()); if(!pPlayer) return; // don't start until game begins if(pPlayer->GetSpectatorMode() != 0 || g_pGame->GetGameRules()->GetCurrentStateId() != 3) return; if(!m_initialised) { m_initialised = true; if(g_pGame->GetHUD()) { // register as a HUD listener g_pGame->GetHUD()->RegisterListener(this); } // go through entity list and pull out the factories. IEntityItPtr pIt = gEnv->pEntitySystem->GetEntityIterator(); while (!pIt->IsEnd()) { if (IEntity * pEnt = pIt->Next()) { if(pEnt->GetClass() == m_pHQClass) { m_baseList.push_back(pEnt->GetId()); //CryLog("Adding HQ %d to list: %d", pEnt->GetId(), m_baseList.size()); } else if(pEnt->GetClass() == m_pAlienEnergyPointClass) { m_alienEnergyPointList.push_back(pEnt->GetId()); //CryLog("Adding AEP %d to list: %d", pEnt->GetId(), m_alienEnergyPointList.size()); } else if(pEnt->GetClass() == m_pSpawnGroupClass) { m_spawnGroupList.push_back(pEnt->GetId()); //CryLog("Adding spawngroup %d to list: %d", pEnt->GetId(), m_spawnGroupList.size()); } else if(pEnt->GetClass() == m_pFactoryClass) { m_factoryList.push_back(pEnt->GetId()); //CryLog("Adding Factory %d to list: %d", pEnt->GetId(), m_factoryList.size()); } } } } // first the briefing events. These are shown in order. bool showPrompt = CheckBriefingEvents(pPlayer); // player has been killed if(pPlayer->GetHealth() <= 0) { showPrompt = TriggerEvent(eTE_Killed); } else if(!showPrompt) { // check each event type here. Which might take a while. // entering a neutral factory // enter prototype factory // enter hostile factory // find alien crash m_entityCheckTimer -= gEnv->pTimer->GetFrameTime(); if(m_entityCheckTimer < 0.0f) { CheckNearbyEntities(pPlayer); m_entityCheckTimer = ENTITY_CHECK_TIME; } // board vehicle and vehicle tutorials CheckVehicles(pPlayer); // player has been wounded if(pPlayer->GetHealth() < pPlayer->GetMaxHealth()) TriggerEvent(eTE_Wounded); // bases m_baseCheckTimer -= gEnv->pTimer->GetFrameTime(); if(m_baseCheckTimer < 0.0f) { CheckBases(pPlayer); m_baseCheckTimer = ENTITY_CHECK_TIME; } } bool promptShown = false; for(int i=0; i<eTE_NumEvents; ++i) { if(m_events[i].m_status == eMS_Waiting) { if(m_currentEvent.m_msgDisplayTime < -MESSAGE_GAP_TIME) { ShowMessage(m_events[i]); } promptShown = true; break; } } if(!promptShown && (m_currentEvent.m_msgRemovalCondition == eMRC_Time) && (m_currentEvent.m_msgDisplayTime < 0.0f)) { HideMessage(); } }
void CHUDCommon::HUD(ICVar *pVar) { SAFE_HUD_FUNC(Show(pVar->GetIVal()!=0)); }
~CFlowNode_WeaponAccessoryChanged() { SAFE_HUD_FUNC(UnRegisterListener(this)); }
//------------------------------------------------------------------------ IMPLEMENT_RMI(CGameRules, ClTempRadarEntity) { SAFE_HUD_FUNC(GetRadar()->AddEntityTemporarily(params.entityId, 15.0f)); return true; }
//------------------------------------------------------------------------ IMPLEMENT_RMI(CGameRules, ClForbiddenAreaWarning) { SAFE_HUD_FUNC(ShowKillAreaWarning(params.active, params.timer)); return true; }
//------------------------------------------- void CGameRules::ProcessClientExplosionScreenFX(const ExplosionInfo &explosionInfo) { IActor *pClientActor = g_pGame->GetIGameFramework()->GetClientActor(); if (pClientActor) { //Distance float dist = (pClientActor->GetEntity()->GetWorldPos() - explosionInfo.pos).len(); //Is the explosion in Player's FOV (let's suppose the FOV a bit higher, like 80) CActor *pActor = (CActor *)pClientActor; SMovementState state; if (IMovementController *pMV = pActor->GetMovementController()) { pMV->GetMovementState(state); } Vec3 eyeToExplosion = explosionInfo.pos - state.eyePosition; eyeToExplosion.Normalize(); bool inFOV = (state.eyeDirection.Dot(eyeToExplosion) > 0.68f); // if in a vehicle eyeDirection is wrong if(pActor && pActor->GetLinkedVehicle()) { Vec3 eyeDir = static_cast<CPlayer*>(pActor)->GetVehicleViewDir(); inFOV = (eyeDir.Dot(eyeToExplosion) > 0.68f); } //All explosions have radial blur (default 30m radius, to make Sean happy =)) float maxBlurDistance = (explosionInfo.maxblurdistance>0.0f)?explosionInfo.maxblurdistance:30.0f; if (maxBlurDistance>0.0f && g_pGameCVars->g_radialBlur>0.0f && m_explosionScreenFX && explosionInfo.radius>0.5f) { if (inFOV && dist < maxBlurDistance) { ray_hit hit; int col = gEnv->pPhysicalWorld->RayWorldIntersection(explosionInfo.pos , -eyeToExplosion*dist, ent_static | ent_terrain, rwi_stop_at_pierceable|rwi_colltype_any, &hit, 1); //If there was no obstacle between flashbang grenade and player if(!col) { float blurRadius = (-1.0f/maxBlurDistance)*dist + 1.0f; gEnv->p3DEngine->SetPostEffectParam("FilterRadialBlurring_Radius", blurRadius); gEnv->p3DEngine->SetPostEffectParam("FilterRadialBlurring_Amount", 1.0f); //CActor *pActor = (CActor *)pClientActor; if (pActor->GetScreenEffects() != 0) { CPostProcessEffect *pBlur = new CPostProcessEffect(pClientActor->GetEntityId(),"FilterRadialBlurring_Amount", 0.0f); CLinearBlend *pLinear = new CLinearBlend(1.0f); pActor->GetScreenEffects()->StartBlend(pBlur, pLinear, 1.0f, 98); pActor->GetScreenEffects()->SetUpdateCoords("FilterRadialBlurring_ScreenPosX","FilterRadialBlurring_ScreenPosY", explosionInfo.pos); } float distAmp = 1.0f - (dist / maxBlurDistance); if (gEnv->pInput) gEnv->pInput->ForceFeedbackEvent( SFFOutputEvent(eDI_XI, eFF_Rumble_Basic, 0.5f, distAmp*3.0f, 0.0f)); } } } //Flashbang effect if(dist<explosionInfo.radius && inFOV && (!strcmp(explosionInfo.effect_class,"flashbang") || !strcmp(explosionInfo.effect_class,"FlashbangAI"))) { ray_hit hit; int col = gEnv->pPhysicalWorld->RayWorldIntersection(explosionInfo.pos , -eyeToExplosion*dist, ent_static | ent_terrain, rwi_stop_at_pierceable|rwi_colltype_any, &hit, 1); //If there was no obstacle between flashbang grenade and player if(!col) { float power = explosionInfo.flashbangScale; power *= max(0.0f, 1 - (dist/explosionInfo.radius)); float lookingAt = (eyeToExplosion.Dot(state.eyeDirection.normalize()) + 1)*0.5f; power *= lookingAt; SAFE_SOUNDMOODS_FUNC(AddSoundMood(SOUNDMOOD_EXPLOSION,MIN(power*40.0f,100.0f))); gEnv->p3DEngine->SetPostEffectParam("Flashbang_Time", 1.0f + (power * 4)); gEnv->p3DEngine->SetPostEffectParam("FlashBang_BlindAmount",explosionInfo.blindAmount); gEnv->p3DEngine->SetPostEffectParam("Flashbang_DifractionAmount", (power * 2)); gEnv->p3DEngine->SetPostEffectParam("Flashbang_Active", 1); } } else if(inFOV && (dist < explosionInfo.radius)) { if (explosionInfo.damage>10.0f || explosionInfo.pressure>100.0f) { //Add some angular impulse to the client actor depending on distance, direction... float dt = (1.0f - dist/explosionInfo.radius); dt = dt * dt; float angleZ = g_PI*0.15f*dt; float angleX = g_PI*0.15f*dt; pActor->AddAngularImpulse(Ang3(Random(-angleX*0.5f,angleX),0.0f,Random(-angleZ,angleZ)),0.0f,dt*2.0f); } } float fDist2=(pClientActor->GetEntity()->GetWorldPos()-explosionInfo.pos).len2(); if (fDist2<250.0f*250.0f) { SAFE_HUD_FUNC(ShowSoundOnRadar(explosionInfo.pos, explosionInfo.hole_size)); if (fDist2<sqr(SAFE_HUD_FUNC_RET(GetBattleRange()))) SAFE_HUD_FUNC(TickBattleStatus(1.0f)); } } }
//------------------------------------------------------------------------ void CWeapon::OnShoot(EntityId shooterId, EntityId ammoId, IEntityClass* pAmmoType, const Vec3 &pos, const Vec3 &dir, const Vec3&vel) { BROADCAST_WEAPON_EVENT(OnShoot, (this, shooterId, ammoId, pAmmoType, pos, dir, vel)); //FIXME:quick temporary solution CActor *pActor = static_cast<CActor*> (g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(shooterId)); if (pActor) pActor->HandleEvent(SGameObjectEvent(eCGE_OnShoot,eGOEF_ToExtensions)); IActor *pClientActor=m_pGameFramework->GetClientActor(); if (pActor && pActor->GetActorClass() == CPlayer::GetActorClassType() && IsServer()) { if (pActor == pClientActor) { if (IAIObject *pAIObject=pActor->GetEntity()->GetAI()) gEnv->pAISystem->SendSignal(SIGNALFILTER_LEADER, 1, "OnEnableFire", pAIObject, 0); } CPlayer *pPlayer=static_cast<CPlayer *>(pActor); CNanoSuit *pSuit=pPlayer->GetNanoSuit(); if(m_fm && strcmp(m_fm->GetType(), "Repair")) { if(pSuit) { if (pSuit->GetMode() == NANOMODE_STRENGTH && !IsMounted()) pSuit->SetSuitEnergy(pSuit->GetSuitEnergy()-g_pGameCVars->g_suitRecoilEnergyCost); else if(pSuit->GetMode() == NANOMODE_CLOAK) pSuit->SetSuitEnergy(0.0f); } } if (gEnv->bServer && pSuit && pSuit->IsInvulnerable()) pSuit->SetInvulnerability(false); } if (pClientActor && m_fm && strcmp(m_fm->GetType(), "Thrown")) { // inform the HUDRadar about the sound event Vec3 vPlayerPos=pClientActor->GetEntity()->GetWorldPos(); float fDist2=(vPlayerPos-pos).len2(); if (fDist2<250.0f*250.0f) { //if (pClientActor->GetEntityId() != shooterId) // pHUD->ShowSoundOnRadar(pos); if(gEnv->bMultiplayer) { CGameRules *pGameRules = g_pGame->GetGameRules(); if(pGameRules->GetTeamCount() < 2 || (pGameRules->GetTeam(shooterId) != pGameRules->GetTeam(pClientActor->GetEntityId()))) { //Small workaround for patch2... IFireMode* pFM = GetFireMode(GetCurrentFireMode()); bool grenade = pFM?(pFM->GetAmmoType()==CItem::sScarGrenadeClass):false; //~... if (!IsSilencerAttached() || grenade) { SAFE_HUD_FUNC(GetRadar()->AddEntityTemporarily(shooterId, 5.0f)); } else if(fDist2<5.0f*5.0f) { //Silencer attached SAFE_HUD_FUNC(GetRadar()->AddEntityTemporarily(shooterId, 5.0f)); } } } if ((!IsSilencerAttached()) && fDist2<sqr(SAFE_HUD_FUNC_RET(GetBattleRange()))) SAFE_HUD_FUNC(TickBattleStatus(1.0f)); } } }
//------------------------------------------------------------------------ IMPLEMENT_RMI(CGameRules, ClHitIndicator) { SAFE_HUD_FUNC(IndicateHit()); return true; }
//------------------------------------------------------------------------ IMPLEMENT_RMI(CGameRules, ClResetObjectives) { SAFE_HUD_FUNC(GetMissionObjectiveSystem().DeactivateObjectives(false)); return true; }