本文整理汇总了C++中CGameRules::GetTeam方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameRules::GetTeam方法的具体用法?C++ CGameRules::GetTeam怎么用?C++ CGameRules::GetTeam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameRules
的用法示例。
在下文中一共展示了CGameRules::GetTeam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnShoot
// 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;
}
}
}
示例2: AllowedToTargetPlayer
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;
}
示例3: CalculateFriendlyFireRatio
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;
}
示例4: IsFriendlyEntity
bool CHUDCrosshair::IsFriendlyEntity(IEntity *pEntity)
{
IActor *pClientActor = g_pGame->GetIGameFramework()->GetClientActor();
CGameRules *pGameRules = g_pGame->GetGameRules();
if(!pEntity || !pClientActor || !pGameRules)
return false;
// Less than 2 teams means we are in a FFA based game.
if(pGameRules->GetTeamCount() < 2)
return false;
bool bFriendly = false;
int iClientTeam = pGameRules->GetTeam(pClientActor->GetEntityId());
// First, check if entity is a player
IActor *pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pEntity->GetId());
if(pActor && pActor->IsPlayer())
{
if(iClientTeam && (pGameRules->GetTeam(pActor->GetEntityId()) == iClientTeam))
{
bFriendly = true;
}
}
else
{
// Then, check if entity is a vehicle
IVehicle *pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(pEntity->GetId());
if(pVehicle && pGameRules->GetTeam(pVehicle->GetEntityId()) == iClientTeam && pVehicle->GetStatus().passengerCount)
{
IActor *pDriver = pVehicle->GetDriver();
/*if(pDriver && pGameRules->GetTeam(pDriver->GetEntityId()) == iClientTeam)
bFriendly = true;
else
bFriendly = false;*/
bFriendly = true;
//fix for bad raycast
if(pDriver && pDriver == pClientActor)
bFriendly = false;
}
}
return bFriendly;
}
示例5: GetAreaAnnouncerTeamIndex
//---------------------------------------
//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);
}
示例6: IsFriendlyToClient
bool CHUDTagNames::IsFriendlyToClient(EntityId uiEntityId)
{
IActor *client = g_pGame->GetIGameFramework()->GetClientActor();
CGameRules *pGameRules = g_pGame->GetGameRules();
if(!client || !pGameRules)
return false;
int playerTeam = pGameRules->GetTeam(client->GetEntityId());
// if this actor is spectating, use the team of the player they are spectating instead...
if(static_cast<CActor*>(client)->GetSpectatorMode() == CActor::eASM_Follow)
{
playerTeam = pGameRules->GetTeam(static_cast<CActor*>(client)->GetSpectatorTarget());
}
// Less than 2 teams means we are in a FFA based game.
if(pGameRules->GetTeam(uiEntityId) == playerTeam && pGameRules->GetTeamCount() > 1)
return true;
return false;
}
示例7: ProcessEvent
void CDangerousRigidBody::ProcessEvent( SEntityEvent& event )
{
switch(event.event)
{
case ENTITY_EVENT_COLLISION:
{
if(m_dangerous)
{
EventPhysCollision *pCollision = (EventPhysCollision *)(event.nParam[0]);
if(pCollision->pEntity[0] && pCollision->pEntity[1])
{
IPhysicalEntity* pOtherEntityPhysics = GetEntity()->GetPhysics() != pCollision->pEntity[0] ? pCollision->pEntity[0] : pCollision->pEntity[1];
if( IEntity* pOtherEntity = gEnv->pEntitySystem->GetEntityFromPhysics(pOtherEntityPhysics) )
{
EntityId localClientId = gEnv->pGame->GetIGameFramework()->GetClientActorId();
if(pOtherEntity->GetId() == localClientId) //Handle collision locally
{
float currentTime = gEnv->pTimer->GetFrameStartTime().GetSeconds();
if(currentTime - m_lastHitTime > m_timeBetweenHits)
{
CGameRules* pGameRules = g_pGame->GetGameRules();
bool sameTeam = m_activatorTeam && (pGameRules->GetTeam(localClientId) == m_activatorTeam);
float damageDealt = !sameTeam ? m_damageDealt : g_pGameCVars->g_friendlyfireratio * m_damageDealt;
Vec3 rigidBodyPos = GetEntity()->GetWorldPos();
HitInfo hitInfo(0, localClientId, 0,
damageDealt, 0.0f, 0, 0,
sDangerousRigidBodyHitTypeId, rigidBodyPos, (pOtherEntity->GetWorldPos()-rigidBodyPos).GetNormalized(), Vec3(ZERO));
pGameRules->ClientHit(hitInfo);
m_lastHitTime = currentTime;
}
}
}
}
}
}
break;
case ENTITY_EVENT_RESET:
{
Reset();
}
break;
}
}
示例8: KillOccurred
void CServerPlayerTracker::KillOccurred(const HitInfo &hitInfo, uint16 victimChannelId, bool bExpectKillCam)
{
if(hitInfo.targetId != GetEntityId() && bExpectKillCam) //We don't expect killcams when a player kills themselves
{
SKillCamValidation& victimData = GetOrCreateVictimData(victimChannelId);
victimData.vLastKillDir = hitInfo.dir;
victimData.uKills++;
victimData.fLastKillTime = gEnv->pTimer->GetCurrTime();
}
CGameRules * pGameRules = g_pGame->GetGameRules();
CGameRules::eThreatRating threatRating = pGameRules->GetThreatRatingByTeam(pGameRules->GetTeam(hitInfo.targetId), pGameRules->GetTeam(GetEntityId()));
if(threatRating == CGameRules::eHostile)
{
m_nTotalHostileKills++;
}
}
示例9: OnRequestMissionObjectives
void CUIObjectives::OnRequestMissionObjectives( const SUIEvent& event )
{
CGameRules* pGameRules = GetGameRules();
if ( pGameRules && g_pGame->GetIGameFramework()->GetClientActor() )
{
CActor* pActor = pGameRules->GetActorByChannelId( g_pGame->GetIGameFramework()->GetClientActor()->GetChannelId() );
if ( pActor )
{
std::map< string, int > tmpList;
int teamID = pGameRules->GetTeam( pActor->GetEntityId() );
for ( TObjectiveMap::iterator it = m_ObjectiveMap.begin(); it != m_ObjectiveMap.end(); ++it )
{
CGameRules::TObjective* pObjective = pGameRules->GetObjective( teamID, it->first.c_str() );
if ( pObjective )
tmpList[ it->first ] = pObjective->status;
}
for ( std::map< string, int >::iterator it = tmpList.begin(); it != tmpList.end(); ++it )
MissionObjectiveAdded( it->first, it->second );
}
}
}
示例10: GetIcon
//------------------------------------------------------------------------
EGameRulesMissionObjectives CGameRulesKingOfTheHillObjective::GetIcon( SHoldEntityDetails *pDetails, const char **ppOutName, const char **ppOutColour )
{
SKotHEntity *pKotHEntity = static_cast<SKotHEntity*>(pDetails->m_pAdditionalData);
CRY_ASSERT(pKotHEntity);
EGameRulesMissionObjectives requestedIcon = EGRMO_Unknown;
if (!pDetails->m_id)
{
requestedIcon = EGRMO_Unknown;
}
else
{
bool iconAllowed = true;
if (!m_shouldShowIconFunc.empty())
{
IEntity *pEntity = gEnv->pEntitySystem->GetEntity(pDetails->m_id);
if (pEntity)
{
IScriptTable *pEntityScript = pEntity->GetScriptTable();
HSCRIPTFUNCTION iconCheckFunc;
if (pEntityScript != NULL && pEntityScript->GetValue(m_shouldShowIconFunc.c_str(), iconCheckFunc))
{
IScriptSystem *pScriptSystem = gEnv->pScriptSystem;
bool result = false;
if (Script::CallReturn(pScriptSystem, iconCheckFunc, pEntityScript, result))
{
if (!result)
{
requestedIcon = EGRMO_Unknown;
iconAllowed = false;
}
}
}
}
}
if (iconAllowed)
{
const char *pFriendlyColour = "#9AD5B7";
const char *pHostileColour = "#AC0000";
const char *pNeutralColour = "#666666";
CGameRules *pGameRules = g_pGame->GetGameRules();
int localTeamId = pGameRules->GetTeam(g_pGame->GetIGameFramework()->GetClientActorId());
if ( (pDetails->m_controllingTeamId == 0) )
{
requestedIcon = m_neutralIcon;
*ppOutName = m_iconTextCapture.c_str();
*ppOutColour = pNeutralColour;
}
else if( (pDetails->m_controllingTeamId == CONTESTED_TEAM_ID) )
{
requestedIcon = m_contestedIcon;
*ppOutName = m_iconTextClear.c_str();
*ppOutColour = pHostileColour;
}
else if (pDetails->m_controllingTeamId == localTeamId)
{
requestedIcon = m_friendlyIcon;
*ppOutName = m_iconTextDefend.c_str();
*ppOutColour = pFriendlyColour;
}
else
{
requestedIcon = m_hostileIcon;
*ppOutName = m_iconTextClear.c_str();
*ppOutColour = pHostileColour;
}
}
}
return requestedIcon;
}
示例11: ClSiteChangedOwner
//------------------------------------------------------------------------
void CGameRulesKingOfTheHillObjective::ClSiteChangedOwner( SHoldEntityDetails *pDetails, int oldTeamId )
{
// Site has been captured
CGameRules *pGameRules = g_pGame->GetGameRules();
EntityId clientActorId = g_pGame->GetIGameFramework()->GetClientActorId();
int localTeam = pGameRules->GetTeam(clientActorId);
SKotHEntity *pKotHEntity = static_cast<SKotHEntity*>(pDetails->m_pAdditionalData);
CRY_ASSERT(pKotHEntity);
const int ownerTeamId = pDetails->m_controllingTeamId;
if (ownerTeamId > 0)
{
ClSiteChangedOwnerAnnouncement(pDetails, clientActorId, ownerTeamId, localTeam);
if (localTeam == ownerTeamId)
{
CCCPOINT(KingOfTheHillObjective_SiteCapturedByFriendlyTeam);
if (!m_friendlyCaptureString.empty())
{
SHUDEventWrapper::GameStateNotify(m_friendlyCaptureString.c_str());
}
if (!m_gameStateFriendlyString.empty())
{
const char *localisedMessage = CHUDUtils::LocalizeString(m_gameStateFriendlyString.c_str());
SHUDEventWrapper::OnGameStatusUpdate(eGBNFLP_Good, localisedMessage);
}
}
else
{
CCCPOINT(KingOfTheHillObjective_SiteCapturedByEnemyTeam);
if (!m_enemyCaptureString.empty())
{
SHUDEventWrapper::GameStateNotify(m_enemyCaptureString.c_str());
}
if (!m_gameStateEnemyString.empty())
{
const char *localisedMessage = CHUDUtils::LocalizeString(m_gameStateEnemyString.c_str());
SHUDEventWrapper::OnGameStatusUpdate(eGBNFLP_Bad, localisedMessage);
}
}
}
else if (oldTeamId > 0)
{
if (localTeam == oldTeamId)
{
CCCPOINT(KingOfTheHillObjective_SiteLostByFriendlyTeam);
if (!m_friendlyLostString.empty())
{
SHUDEventWrapper::GameStateNotify(m_friendlyLostString.c_str());
}
}
else
{
CCCPOINT(KingOfTheHillObjective_SiteLostByEnemyTeam);
if (!m_enemyLostString.empty())
{
SHUDEventWrapper::GameStateNotify(m_enemyLostString.c_str());
}
}
if (!m_gameStateNeutralString.empty())
{
const char *localisedMessage = CHUDUtils::LocalizeString(m_gameStateNeutralString.c_str());
SHUDEventWrapper::OnGameStatusUpdate(eGBNFLP_Neutral, localisedMessage);
}
}
int currActiveIndex = -1;
for (int i = 0; i < HOLD_OBJECTIVE_MAX_ENTITIES; i ++)
{
if( !m_entities[i].m_id)
{
continue;
}
++currActiveIndex;
if( &m_entities[i] != pDetails )
{
continue;
}
CRY_TODO( 23,03,2010, "HUD: OnSiteCaptured events are being sent multiple times from multiple places. /FH");
SHUDEvent siteIsCaptured(eHUDEvent_OnSiteCaptured);
siteIsCaptured.eventIntData = currActiveIndex;
siteIsCaptured.eventIntData2 = ownerTeamId;
CHUDEventDispatcher::CallEvent(siteIsCaptured);
}
}
示例12: Update
//------------------------------------------------------------------------
void CGameRulesKingOfTheHillObjective::Update( float frameTime )
{
BaseType::Update(frameTime);
CGameRules *pGameRules = g_pGame->GetGameRules();
IGameRulesScoringModule *pScoringModule = pGameRules->GetScoringModule();
const int localTeamId = pGameRules->GetTeam(g_pGame->GetIGameFramework()->GetClientActorId());
for (int i = 0; i < HOLD_OBJECTIVE_MAX_ENTITIES; ++ i)
{
SHoldEntityDetails *pDetails = &m_entities[i];
if (!pDetails->m_id)
{
continue;
}
SKotHEntity *pKotHEntity = static_cast<SKotHEntity *>(pDetails->m_pAdditionalData);
CRY_ASSERT(pKotHEntity);
if (gEnv->bServer && pScoringModule)
{
#ifndef _RELEASE
if (g_pGameCVars->g_KingOfTheHillObjective_watchLvl)
{
IEntity *pEntity = gEnv->pEntitySystem->GetEntity(pDetails->m_id);
const char *pEntName = pEntity ? pEntity->GetName() : "<NULL>";
if (pDetails->m_controllingTeamId == CONTESTED_TEAM_ID)
{
CryWatch("KotH entity '%s' is contested", pEntName);
}
else if (pDetails->m_controllingTeamId == 0)
{
CryWatch("KotH entity '%s' has no players nearby", pEntName);
}
else
{
CryWatch("KotH entity '%s' controlled by team %i, scoreTimerLength='%.2f', timeSinceLastScore='%.2f'",
pEntName, pDetails->m_controllingTeamId, pKotHEntity->m_scoreTimerLength, pKotHEntity->m_timeSinceLastScore);
}
}
#endif
if (pKotHEntity->m_scoringTeamId)
{
const int teamIndex = pKotHEntity->m_scoringTeamId - 1;
CRY_ASSERT_MESSAGE(teamIndex >= 0 && teamIndex < NUM_TEAMS, "Update() scoringTeamId is out of range");
pKotHEntity->m_timeSinceLastScore += frameTime;
if (pKotHEntity->m_timeSinceLastScore >= pKotHEntity->m_scoreTimerLength)
{
pScoringModule->OnTeamScoringEvent(teamIndex + 1, EGRST_KingOfTheHillObjectiveHeld);
pKotHEntity->m_timeSinceLastScore = 0.f;
AwardPlayerPoints(&pDetails->m_insideEntities[teamIndex], EGRST_KingOfTheHillObjectiveHeld);
CCCPOINT_IF((pKotHEntity->m_scoringTeamId == 1), KingOfTheHillObjective_TeamMarinesScored);
CCCPOINT_IF((pKotHEntity->m_scoringTeamId == 2), KingOfTheHillObjective_TeamCellScored);
}
}
}
if (gEnv->IsClient())
{
if (m_useIcons && pKotHEntity->m_needsIconUpdate)
{
UpdateIcon(pDetails);
}
if (pGameRules->GetGameMode() == eGM_CrashSite)
{
if (pDetails->m_localPlayerIsWithinRange && pDetails->m_controllingTeamId != CONTESTED_TEAM_ID)
{
CPersistantStats::GetInstance()->IncrementClientStats(EFPS_CrashSiteHeldTime, frameTime);
}
}
if (pKotHEntity->m_bPulseEnabled)
{
pKotHEntity->m_pulseTime -= frameTime;
if (pKotHEntity->m_pulseTime < 0.f)
{
eRadiusPulseType pulseType = GetPulseType(pDetails);
const float radiusEffectScale = pKotHEntity->m_radiusEffectScale * pDetails->m_controlRadius;
RadiusEffectPulse(pDetails->m_id, pulseType, radiusEffectScale);
pKotHEntity->m_pulseTime = m_pulseTimerLength;
}
}
else
{
if (!m_shouldDoPulseEffectFunc.empty())
{
IEntity *pEntity = gEnv->pEntitySystem->GetEntity(pDetails->m_id);
if (pEntity)
{
IScriptTable *pEntityScript = pEntity->GetScriptTable();
HSCRIPTFUNCTION pulseCheckFunc;
if (pEntityScript != NULL && pEntityScript->GetValue(m_shouldDoPulseEffectFunc.c_str(), pulseCheckFunc))
{
IScriptSystem *pScriptSystem = gEnv->pScriptSystem;
bool result = false;
//.........这里部分代码省略.........
示例13: DrawTagName
void CHUDTagNames::DrawTagName(IVehicle *pVehicle)
{
CRY_ASSERT(pVehicle);
if(!pVehicle)
return;
CActor *pClientActor = static_cast<CActor *>(g_pGame->GetIGameFramework()->GetClientActor());
CGameRules *pGameRules = g_pGame->GetGameRules();
int iClientTeam = pGameRules->GetTeam(pClientActor->GetEntityId());
bool bThirdPerson = pClientActor->IsThirdPerson();
bool bDrawSeatTagNames = false;
if(pClientActor->GetSpectatorMode() == CActor::eASM_Follow)
{
IActor *pFollowedActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pClientActor->GetSpectatorTarget());
if(pFollowedActor)
bDrawSeatTagNames = (pVehicle == pFollowedActor->GetLinkedVehicle());
}
else
bDrawSeatTagNames = (pVehicle == pClientActor->GetLinkedVehicle());
if(bDrawSeatTagNames)
{
// When this is local player vehicle, we always display all passengers name above their head so that he can identify them
for(int iSeatId=1; iSeatId<=pVehicle->GetLastSeatId(); iSeatId++)
{
IVehicleSeat *pVehicleSeat = pVehicle->GetSeatById(iSeatId);
if(!pVehicleSeat)
continue;
IActor *pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pVehicleSeat->GetPassenger());
if(!pActor || (pActor == pClientActor && !bThirdPerson))
continue;
DrawTagName(pActor,true);
}
return;
}
ColorF rgbTagName = COLOR_ENEMY;
// Driver seat is always 1
IVehicleSeat *pVehicleSeat = pVehicle->GetSeatById(1);
if(!pVehicleSeat)
return;
IVehicleHelper *pVehicleHelper = pVehicleSeat->GetSitHelper();
if(!pVehicleHelper)
return;
Vec3 vWorldPos = pVehicleHelper->GetWorldTM().GetTranslation();
// Add some offset to be above the driver/pilot
vWorldPos.z += 1.2f;
AABB box;
pVehicle->GetEntity()->GetWorldBounds(box);
bool bDrawOnTop = false;
if(ProjectOnSphere(vWorldPos,box))
{
bDrawOnTop = true;
}
m_tagNamesVector.resize(0);
for(int iSeatId=1; iSeatId<=pVehicle->GetLastSeatId(); iSeatId++)
{
IVehicleSeat *pVehicleSeat = pVehicle->GetSeatById(iSeatId);
if(!pVehicleSeat)
continue;
EntityId uiEntityId = pVehicleSeat->GetPassenger();
IActor *pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(uiEntityId);
if(!pActor)
continue;
const char *szRank = GetPlayerRank(uiEntityId);
IEntity *pEntity = pActor->GetEntity();
if(!pEntity)
continue;
char szText[HUD_MAX_STRING_SIZE];
if(szRank)
{
sprintf(szText,"%s %s",szRank,pEntity->GetName());
}
else
{
sprintf(szText,"%s",pEntity->GetName());
}
if(0 == iClientTeam)
{
if(uiEntityId && IsFriendlyToClient(uiEntityId))
//.........这里部分代码省略.........
示例14: Update
void CHUDTagNames::Update()
{
CActor *pClientActor = static_cast<CActor *>(g_pGame->GetIGameFramework()->GetClientActor());
CGameRules *pGameRules = g_pGame->GetGameRules();
if(!pClientActor || !pGameRules || !gEnv->bMultiplayer)
return;
int iClientTeam = pGameRules->GetTeam(pClientActor->GetEntityId());
// Skip enemies, they need to be added only when shot
// (except in spectator mode when we display everyone)
for(int iTeam = 0; iTeam < pGameRules->GetTeamCount() + 1; ++iTeam)
{
if((iTeam == iClientTeam) || (pClientActor->GetSpectatorMode() != CActor::eASM_None))
{
int iTeamPlayerCount = pGameRules->GetTeamPlayerCount(iTeam);
for(int iPlayer=0; iPlayer<iTeamPlayerCount; iPlayer++)
{
IActor *pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pGameRules->GetTeamPlayer(iTeam,iPlayer));
if(!pActor)
continue;
// Never display the local player
if(pActor == pClientActor)
continue;
// never display other spectators
if(static_cast<CActor*>(pActor)->GetSpectatorMode() != CActor::eASM_None)
continue;
// never display the name of the player we're spectating (it's shown separately with their current health)
if(pClientActor->GetSpectatorMode() == CActor::eASM_Follow && pClientActor->GetSpectatorTarget() == pActor->GetEntityId())
continue;
DrawTagName(pActor);
}
}
}
IVehicleSystem *pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem();
if(!pVehicleSystem)
return;
IVehicleIteratorPtr pVehicleIter = pVehicleSystem->CreateVehicleIterator();
while(IVehicle *pVehicle=pVehicleIter->Next())
{
SVehicleStatus rVehicleStatus = pVehicle->GetStatus();
if(0 == rVehicleStatus.passengerCount)
continue;
// Skip enemy vehicles, they need to be added only when shot (except in spectator mode...)
bool bEnemyVehicle = true;
for(int iSeatId=1; iSeatId<=pVehicle->GetLastSeatId(); iSeatId++)
{
IVehicleSeat *pVehicleSeat = pVehicle->GetSeatById(iSeatId);
if(!pVehicleSeat)
continue;
EntityId uiEntityId = pVehicleSeat->GetPassenger();
if(0 == iClientTeam)
{
if(uiEntityId && IsFriendlyToClient(uiEntityId))
{
bEnemyVehicle = false;
}
}
else if(uiEntityId && pGameRules->GetTeam(uiEntityId) == iClientTeam)
{
bEnemyVehicle = false;
}
}
if(bEnemyVehicle && (pClientActor->GetSpectatorMode() == CActor::eASM_None)) // again, draw enemies in spectator mode
continue;
DrawTagName(pVehicle);
}
// don't need to do any of this if we're in spectator mode - all player names will have been drawn above.
if(pClientActor->GetSpectatorMode() == CActor::eASM_None)
{
for(TEnemyTagNamesList::iterator iter=m_enemyTagNamesList.begin(); iter!=m_enemyTagNamesList.end(); ++iter)
{
SEnemyTagName *pEnemyTagName = &(*iter);
if(gEnv->pTimer->GetAsyncTime().GetSeconds() >= pEnemyTagName->fSpawnTime+((float) g_pGameCVars->hud_mpNamesDuration))
{
// Note: iter=my_list.erase(iter) may not be standard/safe
TEnemyTagNamesList::iterator iterNext = iter;
++iterNext;
m_enemyTagNamesList.erase(iter);
iter = iterNext;
}
else
{
IActor *pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pEnemyTagName->uiEntityId);
if(pActor)
DrawTagName(pActor);
IVehicle *pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(pEnemyTagName->uiEntityId);
//.........这里部分代码省略.........
示例15: SvOnCollision
//.........这里部分代码省略.........
if (timeSinceKick < lowestTime)
{
// We found the kicker and the kicked
kickerId = pActor->GetEntityId();
lowestTime = timeSinceKick;
}
}
pActor = pActorIterator->Next();
}
damage = ProcessActorKickedVehicle(victimActor, victimID, kickerId, offenderID, damage, collisionHitInfo);
useDefaultCalculation = false;
}
if (useDefaultCalculation)
{
fEnergy = GetCollisionEnergy(pVictimEntity, collisionHitInfo);
if (victimVehicle || offenderIsBig)
{
damage = 0.0005f * fEnergy;
}
else
{
damage = 0.0025f * fEnergy;
}
// Apply damage multipliers
damage *= GetCollisionDamageMult(pVictimEntity, pOffenderEntity, collisionHitInfo);
if (victimActor)
{
const bool victimIsPlayer = victimActor->IsPlayer();
if (victimIsPlayer)
{
damage = AdjustPlayerCollisionDamage(pVictimEntity, pOffenderEntity, collisionHitInfo, damage);
}
}
}
if (damage >= DAMAGE_THRESHOLD_COLLISIONS)
{
HitInfo hit;
hit.damage = damage;
hit.pos = collisionHitInfo.pos;
if (collisionHitInfo.target_velocity.GetLengthSquared() > 1e-6)
hit.dir = collisionHitInfo.target_velocity.GetNormalized();
hit.radius = 0.0f;
hit.partId = collisionHitInfo.partId;
hit.targetId = victimID;
hit.weaponId = offenderID;
hit.shooterId = kickerId != 0 ? kickerId : offenderID;
hit.material = 0;
hit.type = CGameRules::EHitType::Collision;
hit.explosion = false;
CGameRules *pGameRules = g_pGame->GetGameRules();
if (pGameRules->GetTeamCount() > 1)
{
int shooterTeamId = pGameRules->GetTeam(hit.shooterId);
int targetTeamId = pGameRules->GetTeam(hit.targetId);
if (shooterTeamId && (shooterTeamId == targetTeamId))
{
damage = GetFriendlyFireDamage(damage, hit, victimActor);
}
}
if (damage >= DAMAGE_THRESHOLD_COLLISIONS)
{
IScriptTable* pVictimScript = pVictimEntity ? pVictimEntity->GetScriptTable() : NULL;
IScriptTable* pOffenderScript = pOffenderEntity ? pOffenderEntity->GetScriptTable() : NULL;
if (!pOffenderEntity && pVictimEntity)
{
pOffenderEntity = pVictimEntity;
offenderID = victimID;
}
m_entityCollisionRecords[victimID] = EntityCollisionRecord(offenderID, currentTime);
if(victimVehicle)
{
victimVehicle->OnHit(hit);
}
else if (pVictimScript)
{
FRAME_PROFILER("Call to OnHit", gEnv->pSystem, PROFILE_GAME);
if (!IsDead(victimActor, pVictimScript))
{
if (IActor* offenderDriver = offenderVehicle ? offenderVehicle->GetDriver() : NULL)
hit.shooterId = offenderDriver->GetEntityId();
DelegateServerHit(pVictimScript, hit, victimActor);
}
}
}
}
}
}