Ejemplo n.º 1
0
//-------------------------------------------------------------------------
void CGameRulesStandardState::Add3DWinningTeamMember()
{
	IActor * localActor = g_pGame->GetIGameFramework()->GetClientActor();

	if (localActor != NULL && static_cast<CActor*>(localActor)->GetSpectatorState() != CActor::eASS_SpectatorMode && !g_pGame->GetUI()->IsInMenu())
	{
		IEntity * renderModelFromEntity = NULL;

		if (m_pGameRules->GetTeamCount() > 1)
		{
			// Only way to get in here is for it to be a team game (as opposed to every-man-for-himself Instant Action)
			const int teamId = m_pGameRules->GetTeam(localActor->GetEntityId());
			assert(teamId == 1 || teamId == 2);
			const int enemyTeamId = 3 - teamId;

			const int clientTeamScore = m_pGameRules->GetTeamsScore(teamId);
			const int nonClientTeamScore = m_pGameRules->GetTeamsScore(enemyTeamId);
			bool winning = (clientTeamScore >= nonClientTeamScore);

			CryLog ("Want to add 3D model of winning team member... local player '%s' is %s", localActor->GetEntity()->GetName(), winning ? " on the winning team" : "not on the winning team");
			if (! winning)
			{
				if (m_pGameRules->GetTeamPlayerCount(enemyTeamId, false))
				{
					renderModelFromEntity = gEnv->pEntitySystem->GetEntity(m_pGameRules->GetTeamPlayer(enemyTeamId, 0));
				}
			}
		}

		if (renderModelFromEntity == NULL)
		{
			// Local entity must exist (checked at top of function) so we'll _definitely_ have a renderModelFromEntity after this
			renderModelFromEntity = localActor->GetEntity();
		}

		// Additional paranoia :)
		if (renderModelFromEntity)
		{
			CryLog ("Adding 3D model of '%s' to accompany scoreboard", renderModelFromEntity->GetName());
			INDENT_LOG_DURING_SCOPE();

			ICharacterInstance * characterInst = renderModelFromEntity->GetCharacter(0);
			if (characterInst != NULL)
			{
				CMenuRender3DModelMgr *pModelManager = new CMenuRender3DModelMgr();

				CMenuRender3DModelMgr::SSceneSettings sceneSettings;
				sceneSettings.fovScale = 0.5f;
				sceneSettings.fadeInSpeed = 0.01f;
				sceneSettings.flashEdgeFadeScale = 0.2f;
				sceneSettings.ambientLight = Vec4(0.f, 0.f, 0.f, 0.8f);
				sceneSettings.lights.resize(3);
				sceneSettings.lights[0].pos.Set(-25.f, -10.f, 30.f);
				sceneSettings.lights[0].color.Set(5.f, 6.f, 5.5f);
				sceneSettings.lights[0].specular = 4.f;
				sceneSettings.lights[0].radius = 400.f;
				sceneSettings.lights[1].pos.Set(25.f, -4.f, 30.f);
				sceneSettings.lights[1].color.Set(0.7f, 0.7f, 0.7f);
				sceneSettings.lights[1].specular = 10.f;
				sceneSettings.lights[1].radius = 400.f;
				sceneSettings.lights[2].pos.Set(60.f, 40.f, 10.f);
				sceneSettings.lights[2].color.Set(0.5f, 1.0f, 0.7f);
				sceneSettings.lights[2].specular = 10.f;
				sceneSettings.lights[2].radius = 400.f;
				pModelManager->SetSceneSettings(sceneSettings);

				const char * usePlayerModelName = characterInst->GetFilePath();

				CMenuRender3DModelMgr::SModelParams params;
				params.pFilename = usePlayerModelName;
				params.posOffset.Set(0.1f, 0.f, -0.2f);
				params.rot.Set(0.f, 0.f, 3.5f);
				params.scale = 1.35f;
				params.pName = "char";
				params.screenRect[0] = 0.f;
				params.screenRect[1] = 0.f;
				params.screenRect[2] = 0.3f;
				params.screenRect[3] = 0.8f;

				const float ANIM_SPEED_MULTIPLIER = 0.5f;
				if (m_pGameRules->GetGameMode() == eGM_Gladiator)
				{
					// In Hunter mode, force the model to be a hunter
					params.pFilename = "_ObjectsSDK/Characters/Human/sdk_player/sdk_player.cdf";
				}
				const CMenuRender3DModelMgr::TAddedModelIndex characterModelIndex = pModelManager->AddModel(params);
				pModelManager->UpdateAnim(characterModelIndex, "stand_tac_idle_nw_3p_01", ANIM_SPEED_MULTIPLIER);
			}
		}
	}
}
Ejemplo n.º 2
0
void CLipSyncProvider_TransitionQueue::FindMatchingAnim(const AudioControlId audioTriggerId, const ELipSyncMethod lipSyncMethod, ICharacterInstance &character, int* pAnimIdOut, CryCharAnimationParams* pAnimParamsOut) const
{
	CRY_ASSERT(audioTriggerId != INVALID_AUDIO_CONTROL_ID);
	CRY_ASSERT(pAnimIdOut != NULL);
	CRY_ASSERT(pAnimParamsOut != NULL);

	const char* szSoundName = ::GetSoundName(audioTriggerId);
	CRY_ASSERT(szSoundName);

	// Look for an animation matching the sound name exactly

	string               matchingAnimationName = PathUtil::GetFileName(szSoundName);
	const IAnimationSet* pAnimSet              = character.GetIAnimationSet();
	int                  nAnimId               = pAnimSet->GetAnimIDByName(matchingAnimationName.c_str());

	if (nAnimId < 0)
	{
		// First fallback: look for an animation matching the sound name without the index at the end

		int index = static_cast<int>(matchingAnimationName.length()) - 1;
		while ((index >= 0) && isdigit((unsigned char)matchingAnimationName[index]))
		{
			--index;
		}

		if ((index > 0) && (matchingAnimationName[index] == '_'))
		{
			matchingAnimationName = matchingAnimationName.Left(index);

			nAnimId = pAnimSet->GetAnimIDByName(matchingAnimationName.c_str());
		}
	}

	bool isDefaultAnim = false;

	if (nAnimId < 0)
	{
		// Second fallback: when requested use a default lip movement animation

		if (lipSyncMethod == eLSM_MatchAnimationToSoundName)
		{
			nAnimId = pAnimSet->GetAnimIDByName(m_sDefaultAnimName.c_str());
			if (nAnimId < 0)
			{
				CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "No '%s' default animation found for face '%s'. Automatic lip movement will not work.", m_sDefaultAnimName.c_str(), character.GetFilePath());
			}
			isDefaultAnim = true;
		}
	}

	*pAnimIdOut = nAnimId;
	FillCharAnimationParams(isDefaultAnim, pAnimParamsOut);
}
Ejemplo n.º 3
0
void CAICorpse::SetupFromSource( IEntity& sourceEntity, ICharacterInstance& characterInstance, const uint32 priority)
{
	// 1.- Move resources from source entity, into AICorpse
	GetEntity()->SetFlags(GetEntity()->GetFlags() | (ENTITY_FLAG_CASTSHADOW));

	sourceEntity.MoveSlot(GetEntity(), 0);

	// Moving everything from one slot into another will also clear the render proxies in the source.
	// Thus, we need to invalidate the model so that it will be properly reloaded when a non-pooled
	// entity is restored from a save-game.
	CActor* sourceActor = static_cast<CActor*>(gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(sourceEntity.GetId()));
	if (sourceActor != NULL)
	{
		sourceActor->InvalidateCurrentModelName();
	}

	// 2.- After 'MoveSlot()', characterInstance is now stored inside CAICorpse
	// It needs to be now updated from the entity system
	characterInstance.SetFlags( characterInstance.GetFlags() | CS_FLAG_UPDATE );

#if AI_CORPSES_ENABLE_SERIALIZE
	m_modelName = characterInstance.GetFilePath();
#endif

	// 3.- Search for any attached weapon and clone them
	IItemSystem* pItemSystem = g_pGame->GetIGameFramework()->GetIItemSystem();

	IAttachmentManager* pAttachmentManager = characterInstance.GetIAttachmentManager();
	const uint32 attachmentCount = (uint32)pAttachmentManager->GetAttachmentCount();
	for(uint32 i = 0; i < attachmentCount ; ++i)
	{
		IAttachment* pAttachment = pAttachmentManager->GetInterfaceByIndex(i);
		assert(pAttachment != NULL);

		IAttachmentObject* pAttachmentObject = pAttachment->GetIAttachmentObject();
		if((pAttachmentObject == NULL) || (pAttachmentObject->GetAttachmentType() != IAttachmentObject::eAttachment_Entity))
			continue;

		const EntityId attachedEntityId = static_cast<CEntityAttachment*>(pAttachmentObject)->GetEntityId();

		IItem* pItem = pItemSystem->GetItem(attachedEntityId);
		if(pItem != NULL)
		{
			if(AllowCloneAttachedItem( pItem->GetEntity()->GetClass() ))
			{
				if(m_attachedItemsInfo.size() < m_attachedItemsInfo.max_size())
				{
					AttachedItem attachedItemInfo;
					attachedItemInfo.pClass = pItem->GetEntity()->GetClass();
					attachedItemInfo.attachmentName = pAttachment->GetName();

					attachedItemInfo.id = CloneAttachedItem( attachedItemInfo, pAttachment );
					m_attachedItemsInfo.push_back(attachedItemInfo);
				}
			}
		}	
	}

	//Only accept requested priority if it has attached weapons
	m_priority = (m_attachedItemsInfo.size() > 0) ? priority : 0;

	//Force physics to sleep immediately (if not already)
	IPhysicalEntity* pCorpsePhysics = GetEntity()->GetPhysics();
	if(pCorpsePhysics != NULL)
	{
		pe_action_awake awakeAction;
		awakeAction.bAwake = 0;
		pCorpsePhysics->Action( &awakeAction );
	}
}