void CCinematicWeapon::StopFire() { BaseClass::StopFire(); m_fireSound.Stop( GetEntityId() ); m_stopFireTailSound.Play( GetEntityId() ); }
//------------------------------------------------------------------------ void CItem::InitClient(int channelId) { // send the differences between the current, and the initial setup for(TAccessoryMap::iterator it=m_accessories.begin(); it != m_accessories.end(); ++it) GetGameObject()->InvokeRMI(ClAttachAccessory(), RequestAttachAccessoryParams(it->first.c_str()), eRMI_ToClientChannel, channelId); IActor *pOwner=GetOwnerActor(); if(!pOwner) return; // only send the pickup message if the player is connecting // for items spawned during gameplay, CItem::PickUp is already sending the pickup message INetChannel *pNetChannel=m_pGameFramework->GetNetChannel(channelId); if(pNetChannel && pNetChannel->GetContextViewState()<eCVS_InGame) { if(!m_stats.mounted && !m_stats.used) { pOwner->GetGameObject()->InvokeRMIWithDependentObject(CActor::ClPickUp(), CActor::PickItemParams(GetEntityId(), m_stats.selected, false), eRMI_ToClientChannel, GetEntityId(), channelId); //GetOwnerActor()->GetGameObject()->InvokeRMI(CActor::ClPickUp(), // CActor::PickItemParams(GetEntityId(), m_stats.selected, false), eRMI_ToClientChannel, channelId); } } if(m_stats.mounted && m_stats.used) { pOwner->GetGameObject()->InvokeRMIWithDependentObject(CActor::ClStartUse(), CActor::ItemIdParam(GetEntityId()), eRMI_ToClientChannel, GetEntityId(), channelId); } }
void CC4Projectile::SetupUIIcon() { if(GetEntityId()) { const bool dangerous = !m_OnSameTeam || g_pGame->GetGameRules()->GetFriendlyFireRatio() > 0.f; //If the C4 can't harm us we show a C4 icon (ThreatAwareness shows enemy C4 as well) const CPlayer* pPlayer = static_cast<CPlayer*>(gEnv->pGame->GetIGameFramework()->GetClientActor()); const bool shouldShow = !dangerous; if(shouldShow && !m_isShowingUIIcon) { SHUDEvent hudEvent(eHUDEvent_OnC4Spawned); hudEvent.AddData((int)GetEntityId()); hudEvent.AddData((bool)dangerous); CHUDEventDispatcher::CallEvent(hudEvent); m_isShowingUIIcon = true; } else if(m_isShowingUIIcon && !shouldShow) { SHUDEvent hudEvent(eHUDEvent_RemoveC4Icon); hudEvent.AddData((int)GetEntityId()); CHUDEventDispatcher::CallEvent(hudEvent); m_isShowingUIIcon = false; } } }
void ConstructShape(float frameOffset) { CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), GetEntityId()); if (!cmpPosition) return; if (!cmpPosition->IsInWorld()) return; float x, z, rotY; cmpPosition->GetInterpolatedPosition2D(frameOffset, x, z, rotY); CmpPtr<ICmpFootprint> cmpFootprint(GetSimContext(), GetEntityId()); if (!cmpFootprint) { // Default (this probably shouldn't happen) - just render an arbitrary-sized circle SimRender::ConstructCircleOnGround(GetSimContext(), x, z, 2.f, m_Overlay, cmpPosition->IsFloating()); } else { ICmpFootprint::EShape shape; entity_pos_t size0, size1, height; cmpFootprint->GetShape(shape, size0, size1, height); if (shape == ICmpFootprint::SQUARE) SimRender::ConstructSquareOnGround(GetSimContext(), x, z, size0.ToFloat(), size1.ToFloat(), rotY, m_Overlay, cmpPosition->IsFloating()); else SimRender::ConstructCircleOnGround(GetSimContext(), x, z, size0.ToFloat(), m_Overlay, cmpPosition->IsFloating()); } }
virtual void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo) { switch(event) { case eFE_Initialize: m_actInfo = *pActInfo; CMiniMapInfo::GetInstance()->UpdateLevelInfo(); m_entityId = GetEntityId(pActInfo); break; case eFE_Activate: if(IsPortActive(pActInfo, eI_Trigger)) TriggerPorts(pActInfo); if(IsPortActive(pActInfo, eI_Disable)) UnRegisterEntity(); if(IsPortActive(pActInfo, eI_Enable)) { UnRegisterEntity(); m_entityId = GetEntityId(pActInfo); RegisterEntity(); } break; } }
//------------------------------------------------------------------------ void CVehicleWeapon::StartUse(EntityId userId) { if (m_ownerId && userId != m_ownerId) return; if (GetEntity()->GetParent()) { m_pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(GetEntity()->GetParent()->GetId()); assert(m_pVehicle && "Using VehicleWeapons on non-vehicles may lead to unexpected behavior."); if (m_pVehicle) { m_pPart = m_pVehicle->GetWeaponParentPart(GetEntityId()); m_pOwnerSeat = m_pVehicle->GetWeaponParentSeat(GetEntityId()); m_pSeatUser = m_pVehicle->GetSeatForPassenger(userId); } } SetOwnerId(userId); Select(true); m_stats.used = true; EnableUpdate(true, eIUS_General); RequireUpdate(eIUS_General); if (OutOfAmmo(false)) Reload(false); UseManualBlending(true); LowerWeapon(false); SendMusicLogicEvent(eMUSICLOGICEVENT_WEAPON_MOUNT); }
virtual void SetOwner(player_id_t playerID) { if (playerID == m_Owner) return; player_id_t old = m_Owner; m_Owner = playerID; CMessageOwnershipChanged msg(GetEntityId(), old, playerID); GetSimContext().GetComponentManager().PostMessage(GetEntityId(), msg); }
virtual void HandleMessage(const CMessage& msg, bool UNUSED(global)) { switch (msg.GetType()) { case MT_PositionChanged: { if (!m_Active) break; const CMessagePositionChanged& data = static_cast<const CMessagePositionChanged&> (msg); if (!data.inWorld && !m_Tag.valid()) break; // nothing needs to change CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSimContext(), SYSTEM_ENTITY); if (!cmpObstructionManager) break; // error if (data.inWorld && m_Tag.valid()) { cmpObstructionManager->MoveShape(m_Tag, data.x, data.z, data.a); } else if (data.inWorld && !m_Tag.valid()) { // Need to create a new pathfinder shape: if (m_Type == STATIC) m_Tag = cmpObstructionManager->AddStaticShape(GetEntityId(), data.x, data.z, data.a, m_Size0, m_Size1, m_Flags, m_ControlGroup, m_ControlGroup2); else m_Tag = cmpObstructionManager->AddUnitShape(GetEntityId(), data.x, data.z, m_Size0, (flags_t)(m_Flags | (m_Moving ? ICmpObstructionManager::FLAG_MOVING : 0)), m_ControlGroup); } else if (!data.inWorld && m_Tag.valid()) { cmpObstructionManager->RemoveShape(m_Tag); m_Tag = tag_t(); } break; } case MT_Destroy: { if (m_Tag.valid()) { CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSimContext(), SYSTEM_ENTITY); if (!cmpObstructionManager) break; // error cmpObstructionManager->RemoveShape(m_Tag); m_Tag = tag_t(); } break; } } }
virtual void Init(const CParamNode& paramNode) { m_PreviouslyRendered = false; m_Unit = NULL; m_Visibility = ICmpRangeManager::VIS_HIDDEN; m_R = m_G = m_B = fixed::FromInt(1); if (!GetSimContext().HasUnitManager()) return; // do nothing further if graphics are disabled // TODO: we should do some fancy animation of under-construction buildings rising from the ground, // but for now we'll just use the foundation actor and ignore the normal one if (paramNode.GetChild("Foundation").IsOk() && paramNode.GetChild("FoundationActor").IsOk()) m_ActorName = paramNode.GetChild("FoundationActor").ToString(); else m_ActorName = paramNode.GetChild("Actor").ToString(); std::set<CStr> selections; m_Unit = GetSimContext().GetUnitManager().CreateUnit(m_ActorName, GetActorSeed(), selections); if (m_Unit) { CModelAbstract& model = m_Unit->GetModel(); if (model.ToCModel()) { u32 modelFlags = 0; if (paramNode.GetChild("SilhouetteDisplay").ToBool()) modelFlags |= MODELFLAG_SILHOUETTE_DISPLAY; if (paramNode.GetChild("SilhouetteOccluder").ToBool()) modelFlags |= MODELFLAG_SILHOUETTE_OCCLUDER; CmpPtr<ICmpVision> cmpVision(GetSimContext(), GetEntityId()); if (cmpVision && cmpVision->GetAlwaysVisible()) modelFlags |= MODELFLAG_IGNORE_LOS; model.ToCModel()->AddFlagsRec(modelFlags); } // Initialize the model's selection shape descriptor. This currently relies on the component initialization order; the // Footprint component must be initialized before this component (VisualActor) to support the ability to use the footprint // shape for the selection box (instead of the default recursive bounding box). See TypeList.h for the order in // which components are initialized; if for whatever reason you need to get rid of this dependency, you can always just // initialize the selection shape descriptor on-demand. InitSelectionShapeDescriptor(model, paramNode); m_Unit->SetID(GetEntityId()); } SelectAnimation("idle", false, fixed::FromInt(1), L""); }
virtual void SetActive(bool active) { if (active && !m_Active) { m_Active = true; // Construct the obstruction shape CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); if (!cmpObstructionManager) return; // error CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle()); if (!cmpPosition) return; // error if (!cmpPosition->IsInWorld()) return; // don't need an obstruction // TODO: code duplication from message handlers CFixedVector2D pos = cmpPosition->GetPosition2D(); if (m_Type == STATIC) m_Tag = cmpObstructionManager->AddStaticShape(GetEntityId(), pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, m_Flags, m_ControlGroup, m_ControlGroup2); else if (m_Type == UNIT) m_Tag = cmpObstructionManager->AddUnitShape(GetEntityId(), pos.X, pos.Y, m_Size0, m_Clearance, (flags_t)(m_Flags | (m_Moving ? ICmpObstructionManager::FLAG_MOVING : 0)), m_ControlGroup); else AddClusterShapes(pos.X, pos.Y, cmpPosition->GetRotation().Y); } else if (!active && m_Active) { m_Active = false; // Delete the obstruction shape // TODO: code duplication from message handlers if (m_Tag.valid()) { CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); if (!cmpObstructionManager) return; // error cmpObstructionManager->RemoveShape(m_Tag); m_Tag = tag_t(); if (m_Type == CLUSTER) RemoveClusterShapes(); } } // else we didn't change the active status }
//------------------------------------------------------------------------ CClaymore::~CClaymore() { if(gEnv->bMultiplayer && gEnv->bServer) { IActor *pOwner = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(m_ownerId); if(pOwner && pOwner->IsPlayer()) { ((CPlayer*)pOwner)->RecordExplosiveDestroyed(GetEntityId(), 0); } } if(g_pGame->GetHUD()) g_pGame->GetHUD()->RecordExplosiveDestroyed(GetEntityId()); }
//------------------------------------------------------------------------ void CRock::HandleEvent(const SGameObjectEvent &event) { CProjectile::HandleEvent(event); if (event.event == eGFE_OnCollision) { if (m_destroying) return; EventPhysCollision *pCollision = reinterpret_cast<EventPhysCollision *>(event.ptr); if (!pCollision) return; IEntity *pTarget = pCollision->iForeignData[1]==PHYS_FOREIGN_ID_ENTITY ? (IEntity*)pCollision->pForeignData[1]:0; if (!pTarget || pTarget->GetId()==m_ownerId || pTarget->GetId()==GetEntityId()) return; Vec3 dir(0, 0, 0); if (pCollision->vloc[0].GetLengthSquared() > 1e-6f) dir = pCollision->vloc[0].GetNormalized(); CGameRules *pGameRules = g_pGame->GetGameRules(); HitInfo hitInfo(m_ownerId, pTarget?pTarget->GetId():0, m_weaponId, m_fmId, 0.0f, pGameRules->GetHitMaterialIdFromSurfaceId(pCollision->idmat[1]), pCollision->partid[1], pGameRules->GetHitTypeId("melee"), pCollision->pt, dir, pCollision->n); hitInfo.remote = IsRemote(); hitInfo.projectileId = GetEntityId(); if (!hitInfo.remote) hitInfo.seq=m_seq; hitInfo.damage = m_damage; if (m_weaponId) { CWeapon *pWeapon=GetWeapon(); if (pWeapon && pWeapon->GetForcedHitMaterial() != -1) hitInfo.material=pGameRules->GetHitMaterialIdFromSurfaceId(pWeapon->GetForcedHitMaterial()); } pGameRules->ClientHit(hitInfo); if(m_damage>10) m_damage =(int)(m_damage*0.5f); } }
//========================================= bool CRocketLauncher::CanPickUp(EntityId userId) const { CActor *pActor = GetActor(userId); IInventory *pInventory=GetActorInventory(pActor); if (m_sharedparams->params.pickable && m_stats.pickable && !m_stats.flying && !m_frozen &&(!m_ownerId || m_ownerId==userId) && !m_stats.selected && !GetEntity()->IsHidden()) { if (pInventory && pInventory->FindItem(GetEntityId())!=-1) return false; } else return false; uint8 uniqueId = m_pItemSystem->GetItemUniqueId(GetEntity()->GetClass()->GetName()); //Can not pick up a LAW while I have one already if(pInventory && (pInventory->GetCountOfUniqueId(uniqueId)>0)) { if(pActor->IsClient()) g_pGame->GetGameRules()->OnTextMessage(eTextMessageCenter, "@mp_CannotCarryMoreLAW"); return false; } return true; }
void CActionScope::InstallProceduralClip(const SProceduralEntry &proc, int layer, const SAnimBlend &blend, float duration) { SProcSequencer &procSeq = m_procSequencers[layer]; if (procSeq.proceduralClip) { procSeq.proceduralClip->OnExit(blend.duration); procSeq.proceduralClip.reset(); } if (proc.type != 0) { CryCreateClassInstance<IProceduralClip>(proc.typeString.c_str(), procSeq.proceduralClip); if (procSeq.proceduralClip) { const char *contextName = procSeq.proceduralClip->GetContextName(); if (contextName) { IProceduralContext *context = m_actionController.FindOrCreateProceduralContext(contextName); procSeq.proceduralClip->SetContext(context); } IEntity* pEntity = gEnv->pEntitySystem->GetEntity(GetEntityId()); // TODO: Handle invalid entity! procSeq.proceduralClip->Initialise(*pEntity, *GetCharInst(), *this, *m_pAction); procSeq.proceduralClip->INTERNAL_OnEnter(blend.duration, duration, *((SProceduralParams*)&proc.animRef)); } } }
virtual void Deserialize(const CParamNode& paramNode, IDeserializer& deserialize) { Init(paramNode); u32 oldSeed = GetActorSeed(); SerializeCommon(deserialize); // If we serialized a different seed, reload actor if (oldSeed != GetActorSeed()) ReloadActor(); fixed repeattime = m_AnimSyncRepeatTime; // save because SelectAnimation overwrites it if (m_AnimRunThreshold.IsZero()) SelectAnimation(m_AnimName, m_AnimOnce, m_AnimSpeed, m_SoundGroup); else SelectMovementAnimation(m_AnimRunThreshold); SetAnimationSyncRepeat(repeattime); if (m_Unit) { CmpPtr<ICmpOwnership> cmpOwnership(GetSimContext(), GetEntityId()); if (cmpOwnership) m_Unit->GetModel().SetPlayerID(cmpOwnership->GetOwner()); } }
void RenderSubmit(SceneCollector& collector) { // (This is only called if a > 0) collector.Submit(&m_Overlay); if (ICmpSelectable::ms_EnableDebugOverlays) { // allocate debug overlays on-demand if (!m_DebugBoundingBoxOverlay) m_DebugBoundingBoxOverlay = new SOverlayLine; if (!m_DebugSelectionBoxOverlay) m_DebugSelectionBoxOverlay = new SOverlayLine; CmpPtr<ICmpVisual> cmpVisual(GetSimContext(), GetEntityId()); if (cmpVisual) { SimRender::ConstructBoxOutline(cmpVisual->GetBounds(), *m_DebugBoundingBoxOverlay); m_DebugBoundingBoxOverlay->m_Thickness = 2; m_DebugBoundingBoxOverlay->m_Color = CColor(1.f, 0.f, 0.f, 1.f); SimRender::ConstructBoxOutline(cmpVisual->GetSelectionBox(), *m_DebugSelectionBoxOverlay); m_DebugSelectionBoxOverlay->m_Thickness = 2; m_DebugSelectionBoxOverlay->m_Color = CColor(0.f, 1.f, 0.f, 1.f); collector.Submit(m_DebugBoundingBoxOverlay); collector.Submit(m_DebugSelectionBoxOverlay); } } else { // reclaim debug overlay line memory when no longer debugging (and make sure to set to zero after deletion) if (m_DebugBoundingBoxOverlay) SAFE_DELETE(m_DebugBoundingBoxOverlay); if (m_DebugSelectionBoxOverlay) SAFE_DELETE(m_DebugSelectionBoxOverlay); } }
void CWaterPuddle::ZapEnemiesOnPuddle(int ownTeam, EntityId shooterId, EntityId weaponId, float damage, int hitTypeId, IParticleEffect* hitEffect) { IGameVolumes::VolumeInfo volumeInfo; if (!GetVolumeInfoForEntity(GetEntityId(), &volumeInfo)) return; IEntity* pEntity = GetEntity(); Matrix34 worldTM = pEntity->GetWorldTM(); float waterLevel = worldTM.GetTranslation().z + volumeInfo.volumeHeight * 0.5f; CActorManager* pActorManager = CActorManager::GetActorManager(); const int numberOfActors = pActorManager->GetNumActors(); for(int i = 0; i < numberOfActors; i++) { SActorData actorData; pActorManager->GetNthActorData(i, actorData); bool isActorAlive = (actorData.health > 0.0f); bool isActorEnemy = (actorData.teamId != ownTeam); bool isActorInsidevolume = IsActorInsideVolume(worldTM, volumeInfo, actorData.entityId); if (isActorAlive && isActorEnemy && isActorInsidevolume) ApplyHit(actorData, shooterId, weaponId, damage, hitTypeId, waterLevel, hitEffect); } }
//---------------------------------------------------------------------- void CVehicleMountedWeapon::PerformRipOff(CActor* pOwner) { IActionMapManager* pMapManager = gEnv->pGame->GetIGameFramework()->GetIActionMapManager(); assert(pMapManager); pMapManager->EnableActionMap("vehicle_general", false); IVehicle *pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(m_vehicleId); if(pVehicle) { SVehicleEventParams params; params.entityId = GetEntityId(); pVehicle->BroadcastVehicleEvent(eVE_WeaponRemoved, params); if(pOwner) { if(gEnv->bMultiplayer) { const IEntity* pVehicleEnt = pVehicle->GetEntity(); IEntity* pEntity = pOwner->GetEntity(); const Matrix34& vehWMat = pVehicleEnt->GetWorldTM(); m_previousWSpaceOffsetPosition = pEntity->GetWorldPos(); m_localRipUserOffset = vehWMat.GetInverted().TransformPoint(m_previousWSpaceOffsetPosition); } pOwner->LinkToVehicle(0); } m_previousVehicleRotation = pVehicle->GetEntity()->GetWorldRotation(); } CHeavyMountedWeapon::PerformRipOff(pOwner); }
//------------------------------------------------------------------------ void CVehicleMountedWeapon::StartUse(EntityId userId) { IVehicle *pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(m_vehicleId); if (!IsRippingOff() && pVehicle) { m_pOwnerSeat = pVehicle->GetWeaponParentSeat(GetEntityId()); m_pSeatUser = pVehicle->GetSeatForPassenger(userId); IActor* pOwner = GetOwnerActor(); if (pOwner && !pOwner->IsPlayer()) { SHUDEvent hudEvent(eHUDEvent_AddEntity); hudEvent.AddData((int)pVehicle->GetEntityId()); CHUDEventDispatcher::CallEvent(hudEvent); } ClearItemFlags(eIF_InformClientsAboutUse); } CHeavyMountedWeapon::StartUse(userId); CActor* pActor = GetOwnerActor(); if (pActor && pActor->IsPlayer()) { static_cast<CPlayer*>(pActor)->RefreshVisibilityState(); } }
virtual void Init(const CParamNode& paramNode) { m_PreviouslyRendered = false; m_Unit = NULL; m_Visibility = ICmpRangeManager::VIS_HIDDEN; m_R = m_G = m_B = fixed::FromInt(1); m_ConstructionPreview = paramNode.GetChild("ConstructionPreview").IsOk(); m_ConstructionProgress = fixed::Zero(); m_Seed = GetEntityId(); if (paramNode.GetChild("Foundation").IsOk() && paramNode.GetChild("FoundationActor").IsOk()) m_ActorName = paramNode.GetChild("FoundationActor").ToString(); else m_ActorName = paramNode.GetChild("Actor").ToString(); InitModel(paramNode); // We need to select animation even if graphics are disabled, as this modifies serialized state SelectAnimation("idle", false, fixed::FromInt(1), L""); m_NeedsInterpolation = true; m_PositionChanged = true; }
//------------------------------------------------------------------------ void CItem::RemoveEntity(bool force) { if(gEnv->IsEditor() && !force) Hide(true); else if(IsServer() || force) gEnv->pEntitySystem->RemoveEntity(GetEntityId()); }
void CReplayActor::SetTeam( int8 team, const bool isFriendly ) { m_team = team; m_isFriendly = isFriendly; // Local, because it only exists locally. g_pGame->GetGameRules()->SetTeam(team, GetEntityId(), true); }
bool CMonoActor::Init(IGameObject *pGameObject) { SetGameObject(pGameObject); if(!GetGameObject()->CaptureView(this)) return false; if (!GetGameObject()->CaptureProfileManager(this)) return false; gEnv->pGameFramework->GetIActorSystem()->AddActor(GetEntityId(), this); m_pAnimatedCharacter = static_cast<IAnimatedCharacter*>(GetGameObject()->AcquireExtension("AnimatedCharacter")); if (m_pAnimatedCharacter) GetGameObject()->EnablePhysicsEvent( true, eEPE_OnPostStepImmediate ); GetGameObject()->EnablePrePhysicsUpdate( ePPU_Always ); if(!GetGameObject()->BindToNetwork()) return false; GetEntity()->SetFlags(GetEntity()->GetFlags()|(ENTITY_FLAG_ON_RADAR|ENTITY_FLAG_CUSTOM_VIEWDIST_RATIO)); GetGameObject()->SetAspectProfile(eEA_Physics, eAP_Alive); if(IEntityRenderProxy *pProxy = (IEntityRenderProxy *)GetEntity()->GetProxy(ENTITY_PROXY_RENDER)) { if(IRenderNode *pRenderNode = pProxy->GetRenderNode()) pRenderNode->SetRndFlags(ERF_REGISTER_BY_POSITION, true); } return true; }
bool CJaw::CanPickUp(EntityId userId) const { CActor *pActor = GetActor(userId); IInventory *pInventory=GetActorInventory(pActor); if (m_sharedparams->params.pickable && m_stats.pickable && !m_stats.flying && (!m_owner.GetId() || m_owner.GetId()==userId) && !m_stats.selected && !GetEntity()->IsHidden()) { if (pInventory && pInventory->FindItem(GetEntityId())!=-1) return false; } else return false; if(GetAmmoCount(m_fm->GetAmmoType())<=0) { return false; } uint8 uniqueId = m_pItemSystem->GetItemUniqueId(GetEntity()->GetClass()->GetName()); int maxNumRockets = GetWeaponSharedParams()->ammoParams.capacityAmmo[0].count; if(pInventory && (pInventory->GetCountOfUniqueId(uniqueId)>=maxNumRockets)) { if(pActor->IsClient()) { SHUDEventWrapper::DisplayInfo(eInfo_Warning, 0.5f, "@mp_CannotCarryMoreLAW"); } return false; } return true; }
void CC4Projectile::SetParams(const SProjectileDesc& projectileDesc) { if(CGameRules* pGameRules = g_pGame->GetGameRules()) { if(projectileDesc.ownerId) //Can be 0 for late joiners { m_teamId = pGameRules->GetTeam(projectileDesc.ownerId); // if this is a team game, record which team placed this claymore... if(gEnv->bServer) { pGameRules->SetTeam(m_teamId, GetEntityId()); } if(!gEnv->IsDedicated()) { const EntityId clientId = g_pGame->GetIGameFramework()->GetClientActorId(); int localPlayerTeam = pGameRules->GetTeam( clientId ); m_OnSameTeam = m_teamId ? m_teamId == localPlayerTeam : clientId == projectileDesc.ownerId; if(gEnv->bServer) { CreateLight(); } if(gEnv->bMultiplayer) { SetupUIIcon(); } } } } CProjectile::SetParams(projectileDesc); }
virtual bool CheckFoundation(std::string className) { CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), GetEntityId()); if (cmpPosition.null()) return false; // error if (!cmpPosition->IsInWorld()) return false; // no obstruction CFixedVector2D pos = cmpPosition->GetPosition2D(); CmpPtr<ICmpPathfinder> cmpPathfinder(GetSimContext(), SYSTEM_ENTITY); if (cmpPathfinder.null()) return false; // error // Get passability class ICmpPathfinder::pass_class_t passClass = cmpPathfinder->GetPassabilityClass(className); // Ignore collisions with self, or with non-foundation-blocking obstructions SkipTagFlagsObstructionFilter filter(m_Tag, ICmpObstructionManager::FLAG_BLOCK_FOUNDATION); if (m_Type == STATIC) return cmpPathfinder->CheckBuildingPlacement(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, GetEntityId(), passClass); else return cmpPathfinder->CheckUnitPlacement(filter, pos.X, pos.Y, m_Size0, passClass); }
void CProjectile::FlashbangEffect(const SFlashbangParams *flashbang) { if(!flashbang) return; const float radius = flashbang->maxRadius; if(!gEnv->pAISystem) return; // Associate event with vehicle if the shooter is in a vehicle (tank cannon shot, etc) EntityId ownerId = m_ownerId; IActor *pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(ownerId); if(pActor && pActor->GetLinkedVehicle() && pActor->GetLinkedVehicle()->GetEntityId()) ownerId = pActor->GetLinkedVehicle()->GetEntityId(); SAIStimulus stim(AISTIM_GRENADE, AIGRENADE_FLASH_BANG, ownerId, GetEntityId(), GetEntity()->GetWorldPos(), ZERO, radius); gEnv->pAISystem->RegisterStimulus(stim); SAIStimulus stimSound(AISTIM_SOUND, AISOUND_WEAPON, ownerId, 0, GetEntity()->GetWorldPos(), ZERO, radius * 3.0f); gEnv->pAISystem->RegisterStimulus(stimSound); }
virtual std::vector<entity_id_t> GetConstructionCollisions() { std::vector<entity_id_t> ret; CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), GetEntityId()); if (cmpPosition.null()) return ret; // error if (!cmpPosition->IsInWorld()) return ret; // no obstruction CFixedVector2D pos = cmpPosition->GetPosition2D(); CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSimContext(), SYSTEM_ENTITY); if (cmpObstructionManager.null()) return ret; // error // Ignore collisions with self, or with non-construction-blocking obstructions SkipTagFlagsObstructionFilter filter(m_Tag, ICmpObstructionManager::FLAG_BLOCK_CONSTRUCTION); if (m_Type == STATIC) cmpObstructionManager->TestStaticShape(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, &ret); else cmpObstructionManager->TestUnitShape(filter, pos.X, pos.Y, m_Size0, &ret); return ret; }
//------------------------------------------------------------------------ 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; } }
EntityId CAICorpse::CloneAttachedItem( const CAICorpse::AttachedItem& attachedItem, IAttachment* pAttachment ) { stack_string clonedItemName; clonedItemName.Format("%s_%s", GetEntity()->GetName(), attachedItem.pClass->GetName() ); SEntitySpawnParams params; params.sName = clonedItemName.c_str(); params.pClass = attachedItem.pClass; // Flag as 'No Save' they will be recreated during serialization if needed params.nFlags |= (ENTITY_FLAG_NO_SAVE); IEntity *pClonedItemEntity = gEnv->pEntitySystem->SpawnEntity(params); assert (pClonedItemEntity != NULL); IItem* pClonedItem = g_pGame->GetIGameFramework()->GetIItemSystem()->GetItem(pClonedItemEntity->GetId()); assert(pClonedItem != NULL); pClonedItem->Physicalize(false, false); pClonedItem->SetOwnerId( GetEntityId() ); // Set properties table to null, since they'll not be used IScriptTable* pClonedItemEntityScript = pClonedItemEntity->GetScriptTable(); if (pClonedItemEntityScript != NULL) { pClonedItemEntity->GetScriptTable()->SetToNull("Properties"); } // Swap attachments CEntityAttachment* pEntityAttachement = new CEntityAttachment(); pEntityAttachement->SetEntityId( pClonedItemEntity->GetId() ); pAttachment->AddBinding( pEntityAttachement ); return pClonedItemEntity->GetId(); }