//------------------------------------------------------------------------ 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); } } 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((!IsSilencerAttached()) && fDist2<sqr(SAFE_GAMEAUDIO_BATTLESTATUS_FUNC_RET(GetBattleRange()))) SAFE_GAMEAUDIO_BATTLESTATUS_FUNC(TickBattleStatus(1.0f)); } } }
void CWeapon::UpdateHUDAddonsVisibility() {//actor only if(!GetHUDmode()) return; //. return; if(ScopeAttachable()) { HudItemData()->set_bone_visible(wpn_scope, IsScopeAttached() ); } if(m_eScopeStatus==ALife::eAddonDisabled ) { HudItemData()->set_bone_visible(wpn_scope, FALSE, TRUE ); }else if(m_eScopeStatus==ALife::eAddonPermanent) HudItemData()->set_bone_visible(wpn_scope, TRUE, TRUE ); if(SilencerAttachable()) { HudItemData()->set_bone_visible(wpn_silencer, IsSilencerAttached()); } if(m_eSilencerStatus==ALife::eAddonDisabled ) { HudItemData()->set_bone_visible(wpn_silencer, FALSE, TRUE); } else if(m_eSilencerStatus==ALife::eAddonPermanent) HudItemData()->set_bone_visible(wpn_silencer, TRUE, TRUE); if(GrenadeLauncherAttachable()) { HudItemData()->set_bone_visible(wpn_grenade_launcher, IsGrenadeLauncherAttached()); } if(m_eGrenadeLauncherStatus==ALife::eAddonDisabled ) { HudItemData()->set_bone_visible(wpn_grenade_launcher, FALSE, TRUE); }else if(m_eGrenadeLauncherStatus==ALife::eAddonPermanent) HudItemData()->set_bone_visible(wpn_grenade_launcher, TRUE, TRUE); }
float CWeapon::Weight() const { float res = CInventoryItemObject::Weight(); if(IsGrenadeLauncherAttached()&&GetGrenadeLauncherName().size()){ res += pSettings->r_float(GetGrenadeLauncherName(),"inv_weight"); } if(IsScopeAttached()&&m_scopes.size()){ res += pSettings->r_float(GetScopeName(),"inv_weight"); } if(IsSilencerAttached()&&GetSilencerName().size()){ res += pSettings->r_float(GetSilencerName(),"inv_weight"); } if(iAmmoElapsed) { float w = pSettings->r_float(m_ammoTypes[m_ammoType].c_str(),"inv_weight"); float bs = pSettings->r_float(m_ammoTypes[m_ammoType].c_str(),"box_size"); res += w*(iAmmoElapsed/bs); } return res; }
u32 CWeapon::Cost() const { u32 res = CInventoryItem::Cost(); if(IsGrenadeLauncherAttached()&&GetGrenadeLauncherName().size()){ res += pSettings->r_u32(GetGrenadeLauncherName(),"cost"); } if(IsScopeAttached()&&m_scopes.size()){ res += pSettings->r_u32(GetScopeName(),"cost"); } if(IsSilencerAttached()&&GetSilencerName().size()){ res += pSettings->r_u32(GetSilencerName(),"cost"); } if(iAmmoElapsed) { float w = pSettings->r_float(m_ammoTypes[m_ammoType].c_str(),"cost"); float bs = pSettings->r_float(m_ammoTypes[m_ammoType].c_str(),"box_size"); res += iFloor(w*(iAmmoElapsed/bs)); } return res; }
void CWeapon::UpdateAddonsVisibility() { IKinematics* pWeaponVisual = smart_cast<IKinematics*>(Visual()); R_ASSERT(pWeaponVisual); u16 bone_id; UpdateHUDAddonsVisibility (); pWeaponVisual->CalculateBones_Invalidate (); bone_id = pWeaponVisual->LL_BoneID (wpn_scope); if(ScopeAttachable()) { if(IsScopeAttached()) { if(!pWeaponVisual->LL_GetBoneVisible (bone_id)) pWeaponVisual->LL_SetBoneVisible (bone_id,TRUE,TRUE); }else{ if(pWeaponVisual->LL_GetBoneVisible (bone_id)) pWeaponVisual->LL_SetBoneVisible (bone_id,FALSE,TRUE); } } if(m_eScopeStatus==ALife::eAddonDisabled && bone_id!=BI_NONE && pWeaponVisual->LL_GetBoneVisible(bone_id) ) { pWeaponVisual->LL_SetBoneVisible (bone_id,FALSE,TRUE); // Log("scope", pWeaponVisual->LL_GetBoneVisible (bone_id)); } bone_id = pWeaponVisual->LL_BoneID (wpn_silencer); if(SilencerAttachable()) { if(IsSilencerAttached()){ if(!pWeaponVisual->LL_GetBoneVisible (bone_id)) pWeaponVisual->LL_SetBoneVisible (bone_id,TRUE,TRUE); }else{ if( pWeaponVisual->LL_GetBoneVisible (bone_id)) pWeaponVisual->LL_SetBoneVisible (bone_id,FALSE,TRUE); } } if(m_eSilencerStatus==ALife::eAddonDisabled && bone_id!=BI_NONE && pWeaponVisual->LL_GetBoneVisible(bone_id) ) { pWeaponVisual->LL_SetBoneVisible (bone_id,FALSE,TRUE); // Log("silencer", pWeaponVisual->LL_GetBoneVisible (bone_id)); } bone_id = pWeaponVisual->LL_BoneID (wpn_grenade_launcher); if(GrenadeLauncherAttachable()) { if(IsGrenadeLauncherAttached()) { if(!pWeaponVisual->LL_GetBoneVisible (bone_id)) pWeaponVisual->LL_SetBoneVisible (bone_id,TRUE,TRUE); }else{ if(pWeaponVisual->LL_GetBoneVisible (bone_id)) pWeaponVisual->LL_SetBoneVisible (bone_id,FALSE,TRUE); } } if(m_eGrenadeLauncherStatus==ALife::eAddonDisabled && bone_id!=BI_NONE && pWeaponVisual->LL_GetBoneVisible(bone_id) ) { pWeaponVisual->LL_SetBoneVisible (bone_id,FALSE,TRUE); // Log("gl", pWeaponVisual->LL_GetBoneVisible (bone_id)); } pWeaponVisual->CalculateBones_Invalidate (); pWeaponVisual->CalculateBones (TRUE); }
void CWeaponMagazined::InitAddons() { ////////////////////////////////////////////////////////////////////////// // Прицел m_fIronSightZoomFactor = READ_IF_EXISTS(pSettings, r_float, cNameSect(), "ironsight_zoom_factor", 50.0f); if (IsScopeAttached()) { if (m_eScopeStatus == ALife::eAddonAttachable) { m_sScopeName = pSettings->r_string(cNameSect(), "scope_name"); m_iScopeX = pSettings->r_s32(cNameSect(), "scope_x"); m_iScopeY = pSettings->r_s32(cNameSect(), "scope_y"); shared_str scope_tex_name; scope_tex_name = pSettings->r_string(*m_sScopeName, "scope_texture"); m_fScopeZoomFactor = pSettings->r_float(*m_sScopeName, "scope_zoom_factor"); if (m_UIScope) xr_delete(m_UIScope); m_UIScope = xr_new<CUIStaticItem>(); // m_UIScope->Init(*scope_tex_name, "hud\\default", 0, 0, alNone); m_UIScope->Init(*scope_tex_name, "hud\\scopes", 0, 0, alNone); // KD: special shader that account screen resolution } else if (m_eScopeStatus == ALife::eAddonPermanent) { m_fScopeZoomFactor = pSettings->r_float(cNameSect(), "scope_zoom_factor"); shared_str scope_tex_name; scope_tex_name = pSettings->r_string(cNameSect(), "scope_texture"); if (m_UIScope) xr_delete(m_UIScope); m_UIScope = xr_new<CUIStaticItem>(); // m_UIScope->Init(*scope_tex_name, "hud\\default", 0, 0, alNone); m_UIScope->Init(*scope_tex_name, "hud\\scopes", 0, 0, alNone); // KD: special shader that account screen resolution } } else { if (m_UIScope) xr_delete(m_UIScope); if (IsZoomEnabled()) m_fIronSightZoomFactor = pSettings->r_float(cNameSect(), "scope_zoom_factor"); } if (IsSilencerAttached() && SilencerAttachable()) { m_sFlameParticlesCurrent = m_sSilencerFlameParticles; m_sSmokeParticlesCurrent = m_sSilencerSmokeParticles; m_pSndShotCurrent = &sndSilencerShot; //сила выстрела LoadFireParams(*cNameSect(), ""); //подсветка от выстрела LoadLights(*cNameSect(), "silencer_"); ApplySilencerKoeffs(); } else { m_sFlameParticlesCurrent = m_sFlameParticles; m_sSmokeParticlesCurrent = m_sSmokeParticles; m_pSndShotCurrent = &sndShot; //сила выстрела LoadFireParams(*cNameSect(), ""); //подсветка от выстрела LoadLights(*cNameSect(), ""); } inherited::InitAddons(); }
//------------------------------------------------------------------------ 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)); } } }