Esempio n. 1
0
	virtual void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo)
	{
		switch(event)
		{
		case eFE_Activate:
			CGameRules *pGR = g_pGame->GetGameRules();

			if(!pGR)
				return;

			if(!pActInfo->pEntity)
				return;

			const bool bUseVapor = GetPortBool(pActInfo, EIP_Vapor);

			if(IsPortActive(pActInfo, EIP_Freeze))
			{
				pGR->FreezeEntity(pActInfo->pEntity->GetId(), true, bUseVapor, true);
				ActivateOutput(pActInfo, EOP_Frozen, true);
			}
			else if(IsPortActive(pActInfo, EIP_UnFreeze))
			{
				pGR->FreezeEntity(pActInfo->pEntity->GetId(), false, bUseVapor);
				ActivateOutput(pActInfo, EOP_UnFrozen, true);
			}

			break;
		}
	}
void CSetEquipmentLoadoutNode ::ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
	if(event == eFE_Activate && IsPortActive(pActInfo, 0))
	{
		if(pActInfo->pEntity)
		{

			IActor* pActor = GetInputActor( pActInfo );
			CGameRules *pGameRules = g_pGame->GetGameRules();

			if(pActor)
			{
				int packIndex = GetPortInt(pActInfo, eI_EquipLoadout);
				CEquipmentLoadout *pEquipmentLoadout = g_pGame->GetEquipmentLoadout();
				if(pEquipmentLoadout)
				{
					pEquipmentLoadout->SetSelectedPackage(packIndex);
					pGameRules->SetPendingLoadoutChange();
				}
			}

		}

	}
}
//------------------------------------------------------------------------
void CTeamVisualizationManager::ProcessTeamChangeVisualization(EntityId entityId) const
{
	if(!m_teamVisualizationPartsMap.empty())
	{
		if(entityId == g_pGame->GetClientActorId())
		{
			// If local player has changed team, refresh team materials for *all* players in game
			CGameRules* pGameRules = g_pGame->GetGameRules();
			CGameRules::TPlayers players;
			pGameRules->GetPlayers(players);

			CGameRules::TPlayers::const_iterator iter = players.begin();
			CGameRules::TPlayers::const_iterator end = players.end();
			while(iter != end)
			{
				RefreshPlayerTeamMaterial(*iter); 
				++iter;
			}
		}
		else // If remote player has changed team, just refresh that player.
		{
			RefreshPlayerTeamMaterial(entityId); 
		}
	}
}
Esempio n. 4
0
//---------------------------------------
void CMiscAnnouncer::Update(const float dt)
{
	if(!ma_enabled || !AnnouncerRequired())
		return;

#if !defined(_RELEASE)
	switch(ma_debug)
	{
		case 2:    // debug OnWeaponFiredMap
			for (TWeaponFiredMap::iterator it=m_weaponFiredMap.begin(); it != m_weaponFiredMap.end(); ++it)
			{
				SOnWeaponFired &onWeaponFired = it->second;
				CryWatch("weaponFired: weapon=%s; announce=%s; played: friend=%s; enemy=%s", onWeaponFired.m_weaponEntityClass->GetName(), onWeaponFired.m_announcementName.c_str(), onWeaponFired.m_havePlayedFriendly ? "true" : "false", onWeaponFired.m_havePlayedEnemy ? "true" : "false");
			}
			break;
		case 3:			// debug listeners
		{
			CGameRules *pGameRules = g_pGame->GetGameRules();
			for (ActorWeaponListenerMap::iterator it=m_actorWeaponListener.begin(); it != m_actorWeaponListener.end(); ++it)
			{
				CryWatch("ActorWeaponListener: Actor=%s; Weapon=%s", pGameRules->GetEntityName(it->first), pGameRules->GetEntityName(it->second));
			}
		}
	}
#endif
}
Esempio n. 5
0
void CVTOLVehicleManager::RegisterVTOLWithPathFollower(bool registerVTOL)
{
	if(!registerVTOL || !m_bRegisteredWithPathFollower)
	{
		CGameRules* pGameRules = g_pGame->GetGameRules();
		if(pGameRules)
		{
			CMPPathFollowingManager* pPathFollowingManager = pGameRules->GetMPPathFollowingManager();
			if(pPathFollowingManager)
			{
				if(registerVTOL)
				{
					if(m_classId == (uint16)-1)
					{
						g_pGame->GetIGameFramework()->GetNetworkSafeClassId(m_classId, s_VTOLClassName);
					}
					pPathFollowingManager->RegisterClassFollower(m_classId, this);
					m_bRegisteredWithPathFollower = true;
				}
				else
				{
					pPathFollowingManager->UnregisterClassFollower(m_classId);
					m_bRegisteredWithPathFollower = false;
				}
			}
		}	
	}
}
Esempio n. 6
0
void CGameAchievements::OnActionEvent(const SActionEvent& event)
{
	// assuming that we don't want to detect anything in MP.
	if(event.m_event == eAE_inGame && !gEnv->bMultiplayer)
	{
		CGameRules* pGR = g_pGame->GetGameRules();
		if(pGR)
		{
#ifdef GAME_IS_CRYSIS2
			pGR->RegisterKillListener(this);
#endif
			
			m_HMGHitType = pGR->GetHitTypeId("HMG");
			m_gaussBulletHitType = pGR->GetHitTypeId("gaussBullet");
		}

		m_lastPlayerThrownObject = 0;
		m_lastPlayerKillBulletId = 0;
		m_lastPlayerKillGrenadeId = 0;
		m_killsWithOneGrenade = 0;
	}

	// NB: by the time the eAE_unloadlevel event is sent the game
	//	rules is already null: can't unregister.
}
//---------------------------------------
void CAreaAnnouncer::Init()
{
	Reset();

	//Scan for areas
	IEntityClass* pTargetClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("AreaBox");
	CRY_ASSERT_MESSAGE(pTargetClass, "Unable to find Target class AreaBox");

	if(pTargetClass)
	{
		IEntityIt* it = gEnv->pEntitySystem->GetEntityIterator();
		while ( !it->IsEnd() )
		{
			IEntity* pEntity = it->Next();
			if(pEntity->GetClass() == pTargetClass)
			{
				//check entityName
				IEntityAreaProxy *pArea = (IEntityAreaProxy*)pEntity->GetProxy(ENTITY_PROXY_AREA);
				if (pArea)
				{
					LoadAnnouncementArea(pEntity, pEntity->GetName());
				}
			}
		}
		it->Release();
	}

	CGameRules *pGameRules = g_pGame->GetGameRules();
	pGameRules->RegisterRevivedListener(this);
}
CPlayer::EClientSoundmoods CLocalPlayerComponent::FindClientSoundmoodBestFit() const
{
	const CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem();
	if(pRecordingSystem && pRecordingSystem->IsPlayingBack())
	{
		return pRecordingSystem->IsInBulletTime() ? CPlayer::ESoundmood_KillcamSlow : CPlayer::ESoundmood_Killcam;
	}

	CGameRules* pGameRules = g_pGame->GetGameRules();
	const IGameRulesStateModule *pStateModule = pGameRules ? pGameRules->GetStateModule() : NULL;
	const IGameRulesStateModule::EGR_GameState gameState = pStateModule ? pStateModule->GetGameState() : IGameRulesStateModule::EGRS_InGame;
	if(gameState == IGameRulesStateModule::EGRS_PreGame)
	{
		return CPlayer::ESoundmood_PreGame;
	}
	else if(gameState == IGameRulesStateModule::EGRS_PostGame)
	{
		return CPlayer::ESoundmood_PostGame;
	}
	else if(m_rPlayer.GetSpectatorMode() != CActor::eASM_None)
	{
		return CPlayer::ESoundmood_Spectating;
	}
	else if(m_rPlayer.IsDead())
	{
		return CPlayer::ESoundmood_Dead;
	}
	else if(m_rPlayer.GetHealth() < g_pGameCVars->g_playerLowHealthThreshold)
	{
		return CPlayer::ESoundmood_LowHealth;
	}

	return CPlayer::ESoundmood_Alive;
}
Esempio n. 9
0
bool CGameRulesSpawningBase::CanPlayerSpawnThisRound(const EntityId playerId) const
{
	bool allowed=true;

	IActor *pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(playerId);

	if (pActor->IsPlayer())
	{
		CGameRules *pGameRules = g_pGame->GetGameRules();
		IGameRulesPlayerStatsModule *playerStats = pGameRules ? pGameRules->GetPlayerStatsModule() : NULL;

		if (playerStats)
		{
			const SGameRulesPlayerStat *stats = playerStats->GetPlayerStats(playerId);
			if (stats)
			{
				if (stats->flags & SGameRulesPlayerStat::PLYSTATFL_CANTSPAWNTHISROUND)
				{	
					allowed=false;
				}
			}
		}
	}

	CryLog("CGameRulesSpawningBase::CanPlayerSpawnThisRound() player=%s allowed=%d", pActor->GetEntity()->GetName(), allowed);
	return allowed;
}
//--------------------------------------------------------------------------------------------------
// Name: ~CGameEffectsSystem
// Desc: Destructor
//--------------------------------------------------------------------------------------------------
GameSDKCGameEffectsSystem::~GameSDKCGameEffectsSystem()
{
#if DEBUG_GAME_FX_SYSTEM
	if(gEnv->pInput)
	{
		gEnv->pInput->RemoveEventListener(this);
	}
#endif

#ifdef SOFTCODE_ENABLED
	if(gEnv->pSoftCodeMgr)
	{
		gEnv->pSoftCodeMgr->RemoveListener(GAME_FX_LIBRARY_NAME,this);
	}

	SAFE_DELETE(m_gameRenderNodeSoftCodeListener);
	SAFE_DELETE(m_gameRenderElementSoftCodeListener);
	m_softCodeTypeLibs.clear();
	m_gameRenderNodes.clear();
	m_gameRenderElements.clear();
#endif

	// Remove as game rules listener
	if(g_pGame)
	{
		CGameRules* pGameRules = g_pGame->GetGameRules();
		if(pGameRules)
		{
			pGameRules->RemoveGameRulesListener(this);
		}
	}
}//-------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------
void CVehicleDamageBehaviorBurn::Update(const float deltaTime)
{
	m_timeCounter -= deltaTime;

	if(m_timeCounter <= 0.0f)
	{
		CGameRules *pGameRules = g_pGame->GetGameRules();

		if(pGameRules && gEnv->bServer)
		{
			Vec3 worldPos;

			if(m_pHelper)
				worldPos = m_pHelper->GetWorldSpaceTranslation();
			else
				worldPos = m_pVehicle->GetEntity()->GetWorldTM().GetTranslation();

			SEntityProximityQuery query;
			query.box = AABB(worldPos-Vec3(m_radius), worldPos+Vec3(m_radius));
			gEnv->pEntitySystem->QueryProximity(query);

			IEntity *pEntity = 0;

			for(int i = 0; i < query.nCount; ++i)
			{
				if((pEntity = query.pEntities[i]) && pEntity->GetPhysics())
				{
					float damage = (pEntity->GetId() == m_pVehicle->GetEntityId()) ? m_selfDamage : m_damage;

					// SNH: need to check vertical distance here as the QueryProximity() call seems to work in 2d only
					Vec3 pos = pEntity->GetWorldPos();

					if(abs(pos.z - worldPos.z) < m_radius)
					{
						if(damage > 0.f)
						{
							HitInfo hitInfo;
							hitInfo.damage = damage;
							hitInfo.pos = worldPos;
							hitInfo.radius = m_radius;
							hitInfo.targetId = pEntity->GetId();
							hitInfo.shooterId = m_shooterId;
							hitInfo.weaponId = m_pVehicle->GetEntityId();
							hitInfo.type = pGameRules->GetHitTypeId("fire");
							pGameRules->ServerHit(hitInfo);
						}
					}
				}
			}

			if(gEnv->pAISystem)
				gEnv->pAISystem->RegisterDamageRegion(this, Sphere(worldPos, m_radius));
		}

		m_timeCounter = m_interval;
	}

	m_pVehicle->NeedsUpdate();
}
Esempio n. 12
0
	~CFlowExplosionInfoNode()
	{
		// safety unregister
		CGameRules *pGR = g_pGame->GetGameRules();

		if(pGR)
			pGR->RemoveHitListener(this);
	}
//------------------------------------------------------------------------
void CTeamVisualizationManager::RefreshPlayerTeamMaterial( const EntityId playerId ) const
{
	if(IEntity* pEntity = gEnv->pEntitySystem->GetEntity(playerId))
	{
		CGameRules* pGameRules = g_pGame->GetGameRules();
		CGameRules::eThreatRating threatRating = pGameRules->GetThreatRating(g_pGame->GetClientActorId(), playerId);
		RefreshTeamMaterial( pEntity, true, threatRating==CGameRules::eFriendly );
	}
}
//====================================================================
//	Cache an equipment pack.
//
//	In:		Lua interfacing handle.
//	In:		The name of the equipment pack (case sensitive) (NULL
//			is invalid!)
//
//	Returns:	The standard Lua return code.
//
int CScriptBind_Game::CacheEquipmentPack(IFunctionHandler* pH, const char* equipmentPackName)
{
	CGameRules *gameRules = g_pGame->GetGameRules();
	if (gameRules != NULL)
	{
		gameRules->PreCacheEquipmentPack(equipmentPackName);
	}
	return pH->EndFunction();
}
Esempio n. 15
0
//------------------------------------------------------------------------
void CProjectile::Explode(bool destroy, bool impact, const Vec3 &pos, const Vec3 &normal, const Vec3 &vel, EntityId targetId)
{
	const SExplosionParams* pExplosionParams = m_pAmmoParams->pExplosion;
	if (pExplosionParams)
	{
		Vec3 dir(0,0,1);
		if (impact && vel.len2()>0)
			dir = vel.normalized();
		else if (normal.len2()>0)
			dir = -normal;

		m_hitPoints = 0;

		// marcok: using collision pos sometimes causes explosions to have no effect. Anton advised to use entity pos
		Vec3 epos = pos.len2()>0 ? (pos - dir * 0.2f) : GetEntity()->GetWorldPos();

		CGameRules *pGameRules = g_pGame->GetGameRules();
		float minRadius = pExplosionParams->minRadius;
		float maxRadius = pExplosionParams->maxRadius;
		if (m_pAmmoParams->pFlashbang)
		{
			minRadius = m_pAmmoParams->pFlashbang->maxRadius;
			maxRadius = m_pAmmoParams->pFlashbang->maxRadius;
		}

		ExplosionInfo explosionInfo(m_ownerId, GetEntityId(), m_damage, epos, dir, minRadius, maxRadius, pExplosionParams->minPhysRadius, pExplosionParams->maxPhysRadius, 0.0f, pExplosionParams->pressure, pExplosionParams->holeSize, pGameRules->GetHitTypeId(pExplosionParams->type.c_str()));
		if(m_pAmmoParams->pFlashbang)
			explosionInfo.SetEffect(pExplosionParams->effectName, pExplosionParams->effectScale, pExplosionParams->maxblurdist, m_pAmmoParams->pFlashbang->blindAmount, m_pAmmoParams->pFlashbang->flashbangBaseTime);
		else
			explosionInfo.SetEffect(pExplosionParams->effectName, pExplosionParams->effectScale, pExplosionParams->maxblurdist);
		explosionInfo.SetEffectClass(m_pAmmoParams->pEntityClass->GetName());

		if (impact)
			explosionInfo.SetImpact(normal, vel, targetId);

		if (gEnv->bServer)
		{
			pGameRules->ServerExplosion(explosionInfo);

			// add battle dust as well
			CBattleDust* pBD = pGameRules->GetBattleDust();
			if(pBD)
				pBD->RecordEvent(eBDET_Explosion, pos, GetEntity()->GetClass());
		}
	}

	if(!gEnv->bMultiplayer)
	{
		//Single player (AI related code)is processed here, CGameRules::ClientExplosion process the effect
		if (m_pAmmoParams->pFlashbang)
			FlashbangEffect(m_pAmmoParams->pFlashbang);
	}

	if (destroy)
		Destroy();
}
//---------------------------------------
//Returns signal index of 0 (for team 0 and 1) and 1 for team 2
int CAreaAnnouncer::GetAreaAnnouncerTeamIndex(const EntityId clientId)
{
	int team = 0;
	CGameRules* pGameRules = g_pGame->GetGameRules();
	if(pGameRules)
	{
		team = pGameRules->GetTeam(clientId);
	}
	return CLAMP(team - 1, 0, AREA_ANNOUNCERS - 1);
}
Esempio n. 17
0
void SExplosionParams::PreCacheLevelResources(CItemParticleEffectCache& particleCache)
{
	particleCache.CacheParticle(effectName);
	particleCache.CacheParticle(failedEffectName);

	CGameRules *pGameRules = g_pGame->GetGameRules();
	if (pGameRules)
	{
		hitTypeId = pGameRules->GetHitTypeId(type.c_str());
	}
}
//--------------------------------------------------------------------------------------------------
// Name: GameRulesInitialise
// Desc: Game Rules initialise
//--------------------------------------------------------------------------------------------------
void GameSDKCGameEffectsSystem::GameRulesInitialise()
{
	// Add as game rules listener
	if(g_pGame)
	{
		CGameRules* pGameRules = g_pGame->GetGameRules();
		if(pGameRules)
		{
			pGameRules->AddGameRulesListener(this);
		}
	}
}//-------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------
IMPLEMENT_RMI(CWeapon, SvRequestShoot)
{
    CHECK_OWNER_REQUEST();

    bool ok=true;
    CActor *pActor=GetActorByNetChannel(pNetChannel);
    if (!pActor || pActor->IsDead())
        ok=false;

    if (ok)
    {
        m_fireCounter++;
        m_expended_ammo++;

        IActor *pLocalActor=m_pGameFramework->GetClientActor();
        bool isLocal = pLocalActor && (pLocalActor->GetChannelId() == pActor->GetChannelId());

#ifdef SERVER_CHECKS
        const float fCurrentTime = gEnv->pTimer->GetAsyncCurTime();
        const int kOldShotId = m_lastShotId;
        if(ShouldEndVerificationSample(fCurrentTime, params.shotId))
        {
            EndVerificationSample(pActor, kOldShotId);
            StartVerificationSample(fCurrentTime);
        }

        m_fLastSampleTakenTime = fCurrentTime;
        m_fSampleNumShots += 1.0f;

        CPlayer * pPlayer = static_cast<CPlayer*>(pActor);
        pPlayer->GetShotCounter()->RecordShot();
#endif

        if (!isLocal)
        {
            NetShoot(params.hit, 0, params.fireModeId);
        }

        CHANGED_NETWORK_STATE(this, ASPECT_STREAM);
    }

#ifdef SERVER_CHECKS
    CGameRules * pGameRules = static_cast<CGameRules*>(g_pGame->GetGameRules());
    if(pGameRules)	//really we should assert here. I struggle to think of a situation where someone is requesting a shot but there are no GameRules...
    {
        IGameRulesDamageHandlingModule * pDamageHandler = pGameRules->GetDamageHandlingModule();
        assert(pDamageHandler);
        pDamageHandler->RegisterShotIdentification(pActor->GetEntityId(), this, params.shotId);
    }
#endif

    return true;
}
Esempio n. 20
0
// IWeaponEventListener
//---------------------------------------
void CMiscAnnouncer::OnShoot(IWeapon *pWeapon, EntityId shooterId, EntityId ammoId, IEntityClass* pAmmoType, const Vec3 &pos, const Vec3 &dir, const Vec3 &vel)
{
	if(!ma_enabled || !AnnouncerRequired())
		return;

	CWeapon *pWeaponImpl = static_cast<CWeapon*>(pWeapon);
	IEntityClass *pWeaponEntityClass = pWeaponImpl->GetEntity()->GetClass();
	g_pGame->GetWeaponSystem()->GetWeaponAlias().UpdateClass(&pWeaponEntityClass);

	DbgLog("CMiscAnnouncer::OnShoot() pWeaponImpl=%s; shooter=%d; pAmmoType=%s", pWeaponImpl->GetEntity()->GetName(), g_pGame->GetGameRules()->GetEntityName(shooterId), pAmmoType->GetName());
	
	TWeaponFiredMap::iterator it = m_weaponFiredMap.find(pWeaponEntityClass);
	if(it != m_weaponFiredMap.end())
	{
		SOnWeaponFired &onWeaponFired = it->second;

		DbgLog("CMiscAnnouncer::OnShoot() has found the firing weaponClass in our weaponFiredMap. With announcement=%s", onWeaponFired.m_announcementName.c_str());

		// we only want to play the announcement once each game/round
		IActor *pClientActor = gEnv->pGame->GetIGameFramework()->GetClientActor();
		CGameRules *pGameRules = g_pGame->GetGameRules();
		int clientTeam = pGameRules->GetTeam(pClientActor->GetEntityId());
		int shooterTeam = pGameRules->GetTeam(shooterId);
		
		if (clientTeam == shooterTeam)
		{
			if (!onWeaponFired.m_havePlayedFriendly)
			{
				DbgLog("CMiscAnnouncer::OnShoot() we've not played this friendly annoucement already. Let's do it");
				CAnnouncer::GetInstance()->Announce(shooterId, onWeaponFired.m_announcementID, CAnnouncer::eAC_inGame);
			}
			else
			{
				DbgLog("CMiscAnnouncer::OnShoot() we've already played this friendly announcement. Not playing again");
			}
			onWeaponFired.m_havePlayedFriendly = true;
		}
		else
		{
			if (!onWeaponFired.m_havePlayedEnemy)
			{
				DbgLog("CMiscAnnouncer::OnShoot() we've not played this enemy announcement already. Let's do it");
				CAnnouncer::GetInstance()->Announce(shooterId, onWeaponFired.m_announcementID, CAnnouncer::eAC_inGame);
			}
			else
			{
				DbgLog("CMiscAnnouncer::OnShoot() we've already played this enemy announcement. Not playing again.");
			}
			onWeaponFired.m_havePlayedEnemy = true;
		}
	}
}
//------------------------------------------------------------------------
int CScriptBind_Game::OnAmmoCrateSpawned(IFunctionHandler *pH, bool providesFragGrenades)
{
	CGameRules* pGameRules = g_pGame->GetGameRules();
	if (pGameRules)
	{
		if (providesFragGrenades)
		{
			pGameRules->PreCacheItemResources("FragGrenades");
		}
	}

	return pH->EndFunction();
}
Esempio n. 22
0
	bool AllowedToTargetPlayer(const EntityId attackerId, const EntityId victimEntityId)
	{
		CGameRules *pGameRules = g_pGame->GetGameRules();
		if(pGameRules && pGameRules->IsTeamGame())
		{
			const int clientTeamId = pGameRules->GetTeam(attackerId);
			const int victimTeamId = pGameRules->GetTeam(victimEntityId);

			return (clientTeamId != victimTeamId) || (g_pGameCVars->g_friendlyfireratio > 0.0f);
		}

		return true; 
	}
//------------------------------------------------------------------------
void CGameRulesHoldObjectiveBase::CleanUpEntity(SHoldEntityDetails *pDetails)
{
	CCCPOINT(HoldObjective_CleanUpActiveCaptureEntity);

	if (pDetails->m_localPlayerIsWithinRange)
	{		
		CHUDEventDispatcher::CallEvent(SHUDEvent(eHUDEvent_OnSiteAboutToExplode));
	}

	OnRemoveHoldEntity(pDetails);

	gEnv->pEntitySystem->RemoveEntityEventListener(pDetails->m_id, ENTITY_EVENT_ENTERAREA, this);
	gEnv->pEntitySystem->RemoveEntityEventListener(pDetails->m_id, ENTITY_EVENT_LEAVEAREA, this);

	if (m_spawnPOIType == eSPT_Avoid)
	{
		IGameRulesSpawningModule *pSpawningModule = g_pGame->GetGameRules()->GetSpawningModule();
		if (pSpawningModule)
		{
			pSpawningModule->RemovePOI(pDetails->m_id);
		}
	}

	IEntity *pEntity = gEnv->pEntitySystem->GetEntity(pDetails->m_id);
	if (pEntity)
	{
		IScriptTable *pScript = pEntity->GetScriptTable();
		if (pScript != NULL && pScript->GetValueType("DeactivateCapturePoint") == svtFunction)
		{
			IScriptSystem *pScriptSystem = gEnv->pScriptSystem;
			pScriptSystem->BeginCall(pScript, "DeactivateCapturePoint");
			pScriptSystem->PushFuncParam(pScript);
			pScriptSystem->PushFuncParam(true);
			pScriptSystem->EndCall();
		}

		CGameRules *pGameRules = g_pGame->GetGameRules();
		EGameMode gamemode = pGameRules->GetGameMode();
		if (gamemode == eGM_CrashSite)
		{
			Announce("Destruct", k_announceType_CS_Destruct);
		}
	}

	pDetails->Reset();

	// Fade out effect
	m_effectData.alphaLerp.Set(1.0f,0.0f,0.0f);
}
Esempio n. 24
0
void CAntiCheatManager::OnClientDisconnect(INetChannel& rNetChannel, IActor * pActor)
{
	uint16 channelId = rNetChannel.GetLocalChannelID();

	TPlayerSessionDataMap::iterator existingData = m_PlayerSessionData.find(channelId);
	if(existingData != m_PlayerSessionData.end())
	{
		existingData->second.disconnectTime = gEnv->pTimer->GetFrameStartTime(ITimer::ETIMER_UI);

		CGameRules *pGameRules = g_pGame->GetGameRules();
		IGameRulesPlayerStatsModule *pPlayerStatsModule = pGameRules->GetPlayerStatsModule();
		pGameRules->GetActorByChannelId(channelId);
		GetPlayerStats(pPlayerStatsModule, pActor->GetEntityId(), existingData->second);
	}
}
Esempio n. 25
0
CVTOLVehicleManager::~CVTOLVehicleManager()
{
	Reset();

	RegisterVTOLWithPathFollower(false);

	SAFE_RELEASE(m_pExplosionEffect);

	CGameRules *pGameRules = g_pGame->GetGameRules();
	if (pGameRules)
	{
		pGameRules->UnRegisterModuleRMIListener(m_moduleRMIIndex);
		pGameRules->UnRegisterClientConnectionListener(this);
	}
}
Esempio n. 26
0
//---------------------------------------
void CMiscAnnouncer::Init()
{
	CryLog("CMiscAnnouncer::Init()");

	IEntityClassRegistry *pEntityClassRegistry = gEnv->pEntitySystem->GetClassRegistry();
	
	XmlNodeRef xmlData = GetISystem()->LoadXmlFromFile("Scripts/Sounds/MiscAnnouncements.xml");
	InitXML(xmlData);

	CGameRules *pGameRules = g_pGame->GetGameRules();
	pGameRules->RegisterRoundsListener(this);
	pGameRules->AddGameRulesListener(this);

	g_pGame->GetIGameFramework()->GetIItemSystem()->RegisterListener(this);
}
float CGameRulesMPDamageHandling::CalculateFriendlyFireRatio(EntityId entityId1, EntityId entityId2)
{
	CGameRules *pGameRules = m_pGameRules;
	if (entityId1 != entityId2 && pGameRules->GetTeamCount() > 1)
	{
		int team1 = pGameRules->GetTeam(entityId1);
		if( team1 ==  pGameRules->GetTeam(entityId2) )
		{
			return pGameRules->GetFriendlyFireRatio();
		}
	}

	//Not on same team so full damage
	return 1.f;
}
Esempio n. 28
0
//------------------------------------------------------------------------
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);

	}
}
SExplosionParams::SExplosionParams(const IItemParamsNode *explosion)
	: minRadius(2.5f)
	, maxRadius(5.0f)
	, minPhysRadius(2.5f)
	, maxPhysRadius(5.0f)
	, pressure(200.0f)
	, holeSize(0.0f)
	, terrainHoleSize(3.0f)
	, effectScale(1)
	, effectName(0)
	, maxblurdist(10)
	, hitTypeId(0)
	, pParticleEffect(0)
{
	const char *effect = 0;
	CItemParamReader reader(explosion);
	reader.Read("max_radius", maxRadius);
	minRadius = maxRadius * 0.8f;
	maxPhysRadius = min(maxRadius, 5.0f);
	minPhysRadius = maxPhysRadius * 0.8f;
	reader.Read("min_radius", minRadius);
	reader.Read("min_phys_radius", minPhysRadius);
	reader.Read("max_phys_radius", maxPhysRadius);
	reader.Read("pressure", pressure);
	reader.Read("hole_size", holeSize);
	reader.Read("terrain_hole_size", terrainHoleSize);
	reader.Read("effect", effect);
	reader.Read("effect_scale", effectScale);
	reader.Read("radialblurdist", maxblurdist);
	reader.Read("type", type);
	CGameRules *pGameRules = g_pGame->GetGameRules();

	if (pGameRules)
	{
		hitTypeId = pGameRules->GetHitTypeId(type.c_str());
	}

	if (effect && effect[0] && gEnv->pParticleManager)
	{
		effectName = effect;
		pParticleEffect = gEnv->pParticleManager->FindEffect(effect);

		if (pParticleEffect)
		{
			pParticleEffect->AddRef();
		}
	}
}
//------------------------------------------------------------------------
void CVehicleDamageBehaviorExplosion::OnDamageEvent(EVehicleDamageBehaviorEvent event, const SVehicleDamageBehaviorEventParams &behaviorParams)
{
	if (event == eVDBE_Repair)
	{
		return;
	}

	if (!m_exploded && behaviorParams.componentDamageRatio >= 1.0f)
	{
		CGameRules *pGameRules = g_pGame->GetGameRules();

		if (pGameRules && gEnv->bServer)
		{
			ExplosionInfo explosionInfo;
			explosionInfo.damage = m_damage;
			explosionInfo.damage += (behaviorParams.randomness) * Random(-0.25f, 0.25f) * m_damage;

			if (m_pHelper)
			{
				explosionInfo.pos = m_pHelper->GetWorldSpaceTranslation();
			}
			else if (behaviorParams.pVehicleComponent)
			{
				explosionInfo.pos = m_pVehicle->GetEntity()->GetWorldTM() * behaviorParams.pVehicleComponent->GetBounds().GetCenter();
			}
			else
			{
				explosionInfo.pos = m_pVehicle->GetEntity()->GetWorldTM().GetTranslation();
			}

			explosionInfo.radius = m_radius;
			explosionInfo.minRadius = m_minRadius;
			explosionInfo.physRadius = m_physRadius;
			explosionInfo.minPhysRadius = m_minPhysRadius;
			explosionInfo.shooterId = behaviorParams.shooterId;
			explosionInfo.weaponId = m_pVehicle->GetEntityId();
			explosionInfo.pressure = m_pressure;
			pGameRules->ServerExplosion(explosionInfo);

			if(CBattleDust *pBD = pGameRules->GetBattleDust())
			{
				pBD->RecordEvent(eBDET_VehicleExplosion, explosionInfo.pos, m_pVehicle->GetEntity()->GetClass());
			}
		}

		m_exploded = true;
	}
}