Example #1
0
DDWORD OpheliaREV::EngineMessageFn(DDWORD messageID, void *pData, DFLOAT fData)
{
	switch(messageID)
	{
		case MID_PRECREATE:
		{
			// Need to call base class to have the object name read in before
			// we set the skin/filename...

			DDWORD dwRet = AI_Mgr::EngineMessageFn(messageID, pData, fData);

			ObjectCreateStruct* pStruct = (ObjectCreateStruct*)pData;
			if (pStruct)
			{
				_mbscpy((unsigned char*)pStruct->m_Filename, (const unsigned char*)"Models\\Characters\\ophelia.abc");
				_mbscpy((unsigned char*)pStruct->m_SkinName, (const unsigned char*)"Skins\\Characters\\ophrev.dtx");
			}

			return dwRet;
		}
		break;
        
		case MID_INITIALUPDATE:
		{
			FirstUpdate();
		}
		break;

		default : break;
	}


	return AI_Mgr::EngineMessageFn(messageID, pData, fData);
}
void RotatingWorldModel::Update()
{
	// Handle the first update
	if (m_bFirstUpdate)
		FirstUpdate();

    LTFLOAT fUpdateDelta = RWM_UPDATE_DELTA;

	switch (m_eState)
	{
		case RWM_SPINUP:
			UpdateSpinUp();
		break;

		case RWM_SPINDOWN:
			UpdateSpinDown();
		break;

		case RWM_OFF:
			fUpdateDelta = 0.0f;
		break;

		case RWM_NORMAL:
		default:
			UpdateNormalRotation();
		break;
	}

	SetNextUpdate(fUpdateDelta);
}
Example #3
0
void FireFX::Setup(HOBJECT hLinkObject, DFLOAT fBurnTime)
{
	m_hLinkObject = hLinkObject;
	m_fBurnTime = fBurnTime;
    
	FirstUpdate();
}
Example #4
0
bool CScreenPreload::UpdateInterfaceSFX()
{
	if( m_bFirstUpdate )
	{
		m_bFirstUpdate = false;
		FirstUpdate( );
	}


	if (!CBaseScreen::UpdateInterfaceSFX())
		return false;

	ChainFXList::iterator iter = m_Chains.begin();
	bool bAnyActive = false;
	while (iter != m_Chains.end() && !bAnyActive)
	{
		CChainedFX *pChain = (*iter);
		pChain->Update();
		
		bAnyActive = !pChain->IsIntroDone();
		iter++;
	}

	bAnyActive = bAnyActive || !UpdateCDKeyValidation( );

	if (!bAnyActive )
	{
		bool bSuccess = true;
		if (m_bWaitingToExit)
			bSuccess = g_pMissionMgr->FinishExitLevel( );
		else
			bSuccess = g_pMissionMgr->FinishStartGame( );

		if (!bSuccess)
		{
			if (IsMultiplayerGame())
				g_pInterfaceMgr->ConnectionFailed(g_pClientMultiplayerMgr->GetLastConnectionResult());
			else
				g_pInterfaceMgr->LoadFailed();
		}
	}

	return bAnyActive;
}
Example #5
0
void CTargetMgr::Update()
{
	
	// Do any necessary initialization...

	if (m_bFirstUpdate)
	{
		FirstUpdate();
		m_bFirstUpdate = false;
	}


	if (m_hLockedTarget && m_hTarget == m_hLockedTarget)
	{
		//are we disabling a GadgetTarget?
		if (g_pPlayerMgr->IsDisabling())
		{
			SetGadgetTarget( true );
			return;
		}

		//are we searching something?
		if (g_pPlayerMgr->IsSearching())
		{
			m_bSearchTarget = true;
			SetTargetStringID(IDS_TARGET_SEARCHING);
			
			float fDistAway = 10000.0f;
			CheckForIntersect(fDistAway);
			
			return;
		}
	}

	g_pPlayerStats->UpdateMaxProgress( 0 );
	g_pPlayerStats->UpdateProgress( 0 );
	g_pHUDMgr->QueueUpdate( kHUDProgressBar );


	// If we currently have a target, see if it is a body and if so remove the
	// glow flag (it may be set again below)...
	if (m_hTarget)
	{
		CBodyFX* pBody = g_pGameClientShell->GetSFXMgr()->GetBodyFX(m_hTarget);
		if (pBody) 
		{
			g_pCommonLT->SetObjectFlags(m_hTarget, OFT_User, 0, USRFLG_GLOW);
		}
	}


	// Start fresh
	ClearTargetInfo();


	//see what we've looking at
	float fDistAway = 10000.0f;
	CheckForIntersect(fDistAway);
	if (!m_hTarget) 
	{
		//nothing to see here
		return;
	}

	m_fTargetRange = fDistAway;

	//if its a body's hitbox, check the body instead
	CBodyFX* pBody = g_pGameClientShell->GetSFXMgr()->GetBodyFromHitBox(m_hTarget);
	if (pBody)
	{
		m_hTarget = pBody->GetServerObj();
		m_ActivationData.m_hTarget = m_hTarget;
		if (!m_hTarget) return;
	}

	//if its a Character's hitbox and it is searchable, check the Character instead
	CCharacterFX* pCharacter = g_pGameClientShell->GetSFXMgr()->GetCharacterFromHitBox(m_hTarget);
	if (pCharacter)
	{
		m_hTarget = pCharacter->GetServerObj();
		m_ActivationData.m_hTarget = m_hTarget;
		if (!m_hTarget) return;
	}



	uint32 dwUserFlags = 0;
    g_pCommonLT->GetObjectFlags(m_hTarget, OFT_User, dwUserFlags);

	// If we're on a vehicle (or if we are dead) all we care about is other players in a multiplayer game...
	// Some vehicles (like the PlayerLure) let you activate, so we'll just check if the
	// vehicle will let us show a crosshair to see if we're on a "true" vehicle or not...

	// It would be great if we didn't have to do all these checks, but such is life...

	bool bPlayersOnly = g_pPlayerMgr->IsPlayerDead() || (g_pPlayerMgr->GetMoveMgr()->GetVehicleMgr()->CanShowCrosshair() ? false : true);


	if (!bPlayersOnly)
	{
		//special case handling for bodies
		if (pBody || pCharacter)
		{
			bool bCanSearch = !!(dwUserFlags & USRFLG_CAN_SEARCH);
			if (pBody)
			{
				if (fDistAway <= g_vtActivationDistance.GetFloat())
				{
					// Make target glow, so it stands out more...
					g_pCommonLT->SetObjectFlags(m_hTarget, OFT_User, USRFLG_GLOW, USRFLG_GLOW);
				}
				
				if (pBody->CanBeRevived() && fDistAway <= g_vtReviveDistance.GetFloat() && IsRevivePlayerGameType( ))
				{
					// Get the client information of the body and us.
					uint32 nId = pBody->GetClientId();
					CClientInfoMgr* pCIMgr = g_pInterfaceMgr->GetClientInfoMgr();
					CLIENT_INFO* pCI = pCIMgr->GetClientByID(nId);
					CLIENT_INFO *pLocalCI = g_pInterfaceMgr->GetClientInfoMgr()->GetLocalClient();

					// Only allow us to revive people on the same team.  For non-team games,
					// the teamid will be set to the same invalid value anyway.
					if( pCI && pLocalCI )
					{
						if (pCI->nTeamID == pLocalCI->nTeamID)
						{
							m_nString = 0;
							FormatString(IDS_TARGET_REVIVE, m_szString, ARRAY_LEN(m_szString), pCI->sName.c_str());

							LTVector vObjPos, vDims;
							g_pLTClient->GetObjectPos(pBody->GetServerObj(), &vObjPos);
							g_pPhysicsLT->GetObjectDims(pBody->GetServerObj(), &vDims);

							// Players are non-solid to each other so you can revive right on top of them.
							m_bCanActivate = true;  //!CheckForCharacters(vObjPos, vDims, pBody->GetClientId());
							m_bMoveTarget = true;
							m_ActivationData.m_nType = MID_ACTIVATE_REVIVE;
						}
						else
						{
							m_nString = 0;
							m_bCanActivate = false;
							m_bMoveTarget = false;
							LTStrCpy(m_szString, pCI->sName.c_str(), ARRAY_LEN(m_szString));

						}

						return;
					}

				}
				else
				{
					m_bMoveTarget = (pBody->CanBeCarried() && g_pPlayerMgr->CanDropCarriedObject());
				}

			}
			else if (pCharacter)
			{
				if( (pCharacter->m_cs.eCrosshairCharacterClass != BAD) && (pCharacter->CanWake()) && (pCharacter->IsUnconscious() || (pCharacter->Slipped() && !pCharacter->m_cs.bIsPlayer)) ) 
				{
					SetTargetStringID( IDS_TARGET_WAKEUP );
					
					m_bCanActivate	= true;
					m_bMoveTarget	= g_pPlayerMgr->CanDropCarriedObject() && pCharacter->CanBeCarried();

					m_ActivationData.m_nType = MID_ACTIVATE_WAKEUP;
					return;
				}

				m_bMoveTarget = g_pPlayerMgr->CanDropCarriedObject() && pCharacter->CanBeCarried();
			}
			else
			{
				m_bMoveTarget = false;
			}

			if (bCanSearch && fDistAway <= g_vtActivationDistance.GetFloat())
			{
				// we can search this body
				m_bSearchTarget = true;
				m_ActivationData.m_nType = MID_ACTIVATE_SEARCH;
				SetTargetStringID(IDS_TARGET_SEARCH);

				uint8 nProgress = g_pPlayerMgr->GetSearcher()->GetMaxProgress();
				g_pPlayerStats->UpdateMaxProgress( nProgress );
				g_pPlayerStats->UpdateProgress( nProgress );
				g_pHUDMgr->QueueUpdate( kHUDProgressBar );

				return;
			}
			else if (pBody)
			{
				return;
			}

		}
		else
		{
			float fGadgetDistance = g_vtActivationDistance.GetFloat();
			if( dwUserFlags & USRFLG_GADGET_CAMERA )
			{
				fGadgetDistance = g_vtCamZoom1MaxDist.GetFloat();
			}

			// is this a gadget target
			if (IsGadgetActivatable(m_hTarget) && (fDistAway <= fGadgetDistance))
			{
				// looks like we can use a gadget on it...
				SetGadgetTarget( false );
				return;
			}
		}
	}

	//are we aiming at a person?
	if (dwUserFlags & USRFLG_CHARACTER)
	{
		CCharacterFX* const pFX = (CCharacterFX*)g_pGameClientShell->GetSFXMgr()->FindSpecialFX(SFX_CHARACTER_ID, m_hTarget);

		// All we care about if we're on a vehicle (or if we are dead) is the Multiplayer check below...

		if (!bPlayersOnly)
		{
			//display debug info if we have any 
			if( pFX && pFX->GetInfoString() && *pFX->GetInfoString() )
			{
				SAFE_STRCPY(m_szDebugString,pFX->GetInfoString());			
			}
			else
			{
				m_szDebugString[0] = NULL;
			}

			// is this a person we can talk to?
			if (dwUserFlags & USRFLG_CAN_ACTIVATE)
			{
				if (fDistAway <= g_vtActivationDistance.GetFloat())
				{
					SetTargetStringID(IDS_TARGET_TALK);
					return;
				}
			}
		}

		// This is the only thing we care about if we're dead or on a vehicle...(we care
		// if we're off a vehicle too)

		if (IsMultiplayerGame() && pFX && pFX->m_cs.bIsPlayer )
		{
			uint32 nId = pFX->m_cs.nClientID;
			CClientInfoMgr* pCIMgr = g_pInterfaceMgr->GetClientInfoMgr();
			CLIENT_INFO* pCI = pCIMgr->GetClientByID(nId);

			if (pCI)
			{
				m_nString = 0;
				SAFE_STRCPY(m_szString,pCI->sName.c_str());

				if (IsTeamGameType())
				{
					m_nTargetTeam = pCI->nTeamID;
				}
			}
			return;
		}
	
		// All we care about if we're dead or on a vehicle is the Multiplayer check above...

		if (!bPlayersOnly)
		{
			if( (fDistAway <= g_vtTargetDistance.GetFloat()) && pFX )
			{
				// If a nameid was specified for the model display the name...

				uint16 nNameId = g_pModelButeMgr->GetModelNameId( pFX->m_cs.eModelId );
				if( nNameId != (uint16)-1 )
				{
					if( nNameId > 0 )
					{
						SetTargetStringID( nNameId );
						return;
					}

					// warn the player if we are pointing at a friend...
					if( pFX->m_cs.eCrosshairCharacterClass != BAD )
					{
						SetTargetStringID( IDS_TARGET_INNOCENT );
						return;
					}
				}
			}
		}
	}

	// All we care about if we're dead or on a vehicle is the above Multiplayer check...
	if (bPlayersOnly)
	{
		// Didn't see another player in Multiplayer, so we have no target...
		ClearTargetInfo();
		return;
	}


	//is this a searchable object?
	if (dwUserFlags & USRFLG_CAN_SEARCH && (fDistAway <= g_vtActivationDistance.GetFloat()))
	{
		m_bSearchTarget = true;
		m_ActivationData.m_nType = MID_ACTIVATE_SEARCH;
		SetTargetStringID(IDS_TARGET_SEARCH);
		
		uint8 nProgress = g_pPlayerMgr->GetSearcher()->GetMaxProgress();
		g_pPlayerStats->UpdateMaxProgress( nProgress );
		g_pPlayerStats->UpdateProgress( nProgress );
		g_pHUDMgr->QueueUpdate( kHUDProgressBar );

		return;

	}
	
	// See if this object is part of the activate object list with it's own string ID's...

	if( fDistAway <= g_vtActivationDistance.GetFloat() )
	{
		CActivateObjectHandler *pActivateObj = LTNULL;
		CActivateObjectHandler::ActivateObjList::const_iterator iter = CActivateObjectHandler::GetActivateObjectList().begin();
		while( iter != CActivateObjectHandler::GetActivateObjectList().end() )
		{
			pActivateObj = *iter;
			
			if( pActivateObj->GetHOBJECT() == m_hTarget )
			{
				ACTIVATETYPE *pType = g_pActivateTypeMgr->GetActivateType( pActivateObj->m_nId );
				if( pType )
				{
					// Set whether or not it's disabled and set the string based on the state...

					m_bCanActivate = !pActivateObj->m_bDisabled;
					uint32 dwStringID = pType->dwStateID[pActivateObj->m_eState];
					
					if( dwStringID != (uint32)-1 )
					{
						SetTargetStringID( dwStringID );
					}

					return;
				}
			}

			++iter;
		}
	}

	//can we pick up or activate it?
	if (dwUserFlags & USRFLG_CAN_ACTIVATE && (fDistAway <= g_vtActivationDistance.GetFloat()))
	{
		//special case for bombs to defuse
		CGadgetTargetFX* const pGTFX = (CGadgetTargetFX*)g_pGameClientShell->GetSFXMgr()->FindSpecialFX(SFX_GADGETTARGET_ID, m_hTarget);
		if (pGTFX)
		{
			GadgetTargetType eGadgetType = pGTFX->GetType();
			if (eBombable == eGadgetType)
			{
				// Can only defuse a bomb that doesn't belong to your team...
				
				if( IsTeamGameType() )
				{
					CLIENT_INFO *pLocalCI = g_pInterfaceMgr->GetClientInfoMgr()->GetLocalClient();
					if( !pLocalCI )
						return;

					if( pGTFX->GetTeamID() != INVALID_TEAM )
					{
						if( pLocalCI->nTeamID == pGTFX->GetTeamID() )
						{
							m_bCanActivate = false;
						}
					}
				}

				SetTargetStringID(IDS_TARGET_DEFUSE);
				return;
			}
		}

		CPickupItemFX* const pFX = (CPickupItemFX*)g_pGameClientShell->GetSFXMgr()->FindSpecialFX(SFX_PICKUPITEM_ID, m_hTarget);

		// If this is a pickupitem, then display any team association it has.
		if( IsTeamGameType() && pFX )
		{
			m_nTargetTeam = pFX->GetTeamId( );
		}
		
		// If we're looking at a pickup, use the take string, otherwise it's just something to interact with.
		SetTargetStringID(pFX ? IDS_TARGET_TAKE : IDS_TARGET_USE);
		return;
	}

	// Are we looking at a doomsday piece...
	
	CDoomsdayPieceFX *pDDPiece = dynamic_cast<CDoomsdayPieceFX*>(g_pGameClientShell->GetSFXMgr()->FindSpecialFX( SFX_DOOMSDAYPIECE_ID, m_hTarget ));
	if( pDDPiece && (fDistAway <= g_vtActivationDistance.GetFloat()) )
	{
		m_bCanActivate = false;
		m_bMoveTarget = true;
	}
}
Example #6
0
void CTargetMgr::Update()
{
	// Do any necessary initialization...

	if (m_bFirstUpdate)
	{
		FirstUpdate();
		m_bFirstUpdate = false;
	}

	g_pPlayerStats->UpdateMaxProgress( 0 );
	g_pPlayerStats->UpdateProgress( 0 );

	// Start fresh
	ClearTargetInfo();

	//see what we've looking at
	float fDistAway = kMaxDistance;
	CheckForIntersect(fDistAway);
	m_fTargetRange = fDistAway;

	if (!m_hTarget) 
	{
		//nothing to see here
		SpecialMoveMgr::Instance().HandleLookedAt(NULL);
		return;
	}

	// If its a Character's hitbox, check the Character instead...
	CCharacterFX* pCharacter = g_pGameClientShell->GetSFXMgr()->GetCharacterFromHitBox(m_hTarget);
	if (pCharacter)
	{
		m_hTarget = pCharacter->GetServerObj();
		m_ActivationData.m_hTarget = m_hTarget;
		if (!m_hTarget) return;
	}

	CLadderFX *pLadder = g_pGameClientShell->GetSFXMgr()->GetLadderFX(m_hTarget);
	if (pLadder && LadderMgr::Instance().CanReachLadder(pLadder))
	{
		m_ActivationData.m_hTarget = m_hTarget;
		m_ActivationData.m_nType = MID_ACTIVATE_LADDER;
		return;
	}

	CTurretFX *pTurret = g_pGameClientShell->GetSFXMgr( )->GetTurretFX( m_hTarget );
	if( pTurret && pTurret->CanActivate( ))
	{
		m_ActivationData.m_hTarget = m_hTarget;
		m_ActivationData.m_nType = MID_ACTIVATE_TURRET;
		return;
	}

	CSpecialMoveFX *pSpecialMove = g_pGameClientShell->GetSFXMgr()->GetSpecialMoveFX(m_hTarget);
	if (pSpecialMove)
	{
		SpecialMoveMgr::Instance().HandleLookedAt(pSpecialMove);
		if (SpecialMoveMgr::Instance().CanReach(pSpecialMove))
		{
			m_ActivationData.m_hTarget = m_hTarget;
			m_ActivationData.m_nType = MID_ACTIVATE_SPECIALMOVE;
			return;
		}
	}
	else
	{
		SpecialMoveMgr::Instance().HandleLookedAt(NULL);
	}

	if( m_ActivationData.m_hActivateSnd )
	{
		m_ActivationData.m_nType = MID_ACTIVATE_SURFACESND;
	}

	CClientWeapon* pCurrentWeapon = g_pPlayerMgr->GetClientWeaponMgr()->GetCurrentClientWeapon();

	uint32 dwUserFlags = 0;
	g_pCommonLT->GetObjectFlags(m_hTarget, OFT_User, dwUserFlags);

	// is this a person we can talk to?
	if(( !(dwUserFlags & USRFLG_CAN_ACTIVATE) && m_ActivationData.m_nType != MID_ACTIVATE_SURFACESND ) || (fDistAway > g_vtActivationDistance.GetFloat()) )
	{
		m_ActivationData.m_hTarget = NULL;
	}


	// If we're on a vehicle (or if we are dead) all we care about is other players in a multiplayer game...
	// Some vehicles (like the PlayerLure) let you activate, so we'll just check if the
	// vehicle will let us show a crosshair to see if we're on a "true" vehicle or not...

	// It would be great if we didn't have to do all these checks, but such is life...

	bool bPlayersOnly = !g_pPlayerMgr->IsPlayerAlive() || (g_pPlayerMgr->GetMoveMgr()->GetVehicleMgr()->CanShowCrosshair() ? false : true);

	//are we aiming at a person?
	if (dwUserFlags & USRFLG_CHARACTER)
	{
		CCharacterFX* const pFX = (CCharacterFX*)g_pGameClientShell->GetSFXMgr()->FindSpecialFX(SFX_CHARACTER_ID, m_hTarget);

		// All we care about if we're on a vehicle (or if we are dead) is the Multiplayer check below...

		if (!bPlayersOnly)
		{
			//display debug info if we have any 
			if( pFX && pFX->GetInfoString() && *pFX->GetInfoString() )
			{
				g_pHUDDebug->SetTargetDebugString(pFX->GetInfoString());
			}
			else
			{
				g_pHUDDebug->SetTargetDebugString(L"");
			}

			// is this a person we can talk to?
			if (dwUserFlags & USRFLG_CAN_ACTIVATE)
			{
				if (fDistAway <= g_vtActivationDistance.GetFloat())
				{
					// SetTargetStringID(IDS_TARGET_TALK);
					return;
				}
			}
		}

		// This is the only thing we care about if we're dead or on a vehicle...(we care
		// if we're off a vehicle too)

		if (IsMultiplayerGameClient() && pFX && pFX->m_cs.bIsPlayer )
		{
			uint32 nId = pFX->m_cs.nClientID;
			CClientInfoMgr* pCIMgr = g_pInterfaceMgr->GetClientInfoMgr();
			CLIENT_INFO* pCI = pCIMgr->GetClientByID(nId);

			if (pCI)
			{
				m_szStringID = NULL;
				LTStrCpy(m_wszString, pCI->sName.c_str(), LTARRAYSIZE(m_wszString));

				if (GameModeMgr::Instance( ).m_grbUseTeams)
				{
					m_nTargetTeam = pCI->nTeamID;
				}
			}
			return;
		}

		// All we care about if we're dead or on a vehicle is the Multiplayer check above...

		if (!bPlayersOnly)
		{
			if(pFX)
			{
				if (fDistAway <= g_vtTargetDistance.GetFloat()) 
				{
					// If a nameid was specified for the model display the name...
					const char* szNameId = g_pModelsDB->GetModelNameId( pFX->m_cs.hModel );
					if( szNameId && (szNameId[0] != '\0') )
					{
						//SetTargetStringID( nNameId );
						return;
					}
				}
			}
		}
	}

	// See if this object is part of the activate object list with it's own string ID's...
	if( fDistAway <= g_vtActivationDistance.GetFloat() )
	{
		const CActivateObjectHandler *pActivateObj = CActivateObjectHandler::FindActivateObject( m_hTarget );
		if( pActivateObj )
		{
			// See whether or not it's disabled
			m_bCanActivate = !pActivateObj->m_bDisabled;

			// Fetch the proper string from the database depending on the state...
			HRECORD hRecord = DATABASE_CATEGORY( Activate ).GetRecordByIndex( pActivateObj->m_nId );
			HATTRIBUTE hStates = DATABASE_CATEGORY( Activate ).GETRECORDSTRUCT( hRecord, States );
			const char* pszStringID = DATABASE_CATEGORY( Activate ).GETSTRUCTATTRIB( States, hStates, pActivateObj->m_eState, HudText );
			if( !LTStrEmpty( pszStringID ) )
			{
				SetTargetStringID( pszStringID );
			}
			return;
		}
	}


	// All we care about if we're dead or on a vehicle is the above Multiplayer check...
	if (bPlayersOnly)
	{
		// Didn't see another player in Multiplayer, so we have no target...
		ClearTargetInfo();
		return;
	}

}
Example #7
0
DBOOL FireFX::Update(DVector* pMovement)
{
	CServerDE* pServerDE = BaseClass::GetServerDE();
	if (!pServerDE || !m_hObject) return DFALSE;

	pServerDE->SetNextUpdate(m_hObject, (DFLOAT)0.01);

    // Increase the Fire Index
    m_nFireIndex++;
    if (m_nFireIndex >= MAXFIRES)        m_nFireIndex = 0;
    
    // If First Update then look for the object to attach to...
    // and Add Light...
    //
	if (m_bFirstUpdate == DTRUE)
	{
		FirstUpdate();
	}
    else
    {
        if (m_hLinkObject)
        {
        
        	DFLOAT fTime = pServerDE->GetTime();
            
            //
            // Send Damage to LinkObject!!!
            //                  
            
            // Check for Object Dead
            if (m_bDead == DTRUE)
            {
                // Move the Smoke Up
            	if (m_hSmokeTrail[m_nFireIndex])
            	{
		            DVector vPos;
                    pServerDE->GetObjectPos(m_hSmokeTrail[m_nFireIndex], &vPos);
                    
                	vPos.y = vPos.y + 2;
		            pServerDE->SetObjectPos(m_hSmokeTrail[m_nFireIndex], &vPos);
            	}
                
                // Keep Smoke around longer 
            	if (fTime > m_fLastTime + 5.0f)
                {
                    for (int x=0; x<MAXFIRES; x++)
                    {
                       	if (m_hSmokeTrail[x])
						{
							pServerDE->RemoveObject(m_hSmokeTrail[x]);
							m_hSmokeTrail[x] = DNULL;
						}
                    }
                                
                    if (m_hLight)   pServerDE->RemoveObject( m_hLight );
                    pServerDE->RemoveObject( m_hObject );
                }
                return DTRUE;
                
            }
            else
            {
                if (m_hLinkObject)
                {
    	            if(pServerDE->IsKindOf(pServerDE->GetObjectClass(m_hLinkObject), pServerDE->GetClass("CBaseCharacter"))) 
                    {
                        CBaseCharacter *pLinkObject = (CBaseCharacter*)pServerDE->HandleToObject(m_hLinkObject);
                        // Check to see if the Linked object is dead
                	    if(pLinkObject->IsDead() )
    	                {
                            for (int x=0; x<MAXFIRES; x++)
                            {
                            	if (m_hSprite[x])
								{
									pServerDE->RemoveObject(m_hSprite[x]);
									m_hSprite[x] = DNULL;
								}
                            }           
                            
                            m_bDead = DTRUE;
        	                m_fLastTime = pServerDE->GetTime();
                        
                            return DTRUE;
                        }
                    }        
                }
            }
            
            
            DRotation rRot;
            DVector m_vUp, m_vRight, m_vForward;
            DVector vPos, vTemp, vDir, vDims;

// Need to build a table of Sprites and There Positions...
// Then Update Each position???
//
            int x = m_nFireIndex;
            
            {
            	// Remove everything if we're done.
            	if (fTime > m_fStartTime[x] + m_fDuration[x])
        	    {
            
        	        m_fStartTime[x] = pServerDE->GetTime();
            
    		        if (m_hSprite[x]) 
					{
						g_pServerDE->RemoveObject(m_hSprite[x]);
						m_hSprite[x] = DNULL;
					}
    		        if (m_hSmokeTrail[x])
					{
						g_pServerDE->RemoveObject(m_hSmokeTrail[x]);
						m_hSmokeTrail[x] = DNULL;
					}
                
                    // Add Flame
                    VEC_INIT(m_vUp);
            	    VEC_INIT(m_vRight);
                	VEC_INIT(m_vForward);

                    if (!m_hLinkObject) return DFALSE;
            	    pServerDE->GetObjectRotation(m_hLinkObject, &rRot);
                	pServerDE->GetRotationVectors(&rRot, &m_vUp, &m_vRight, &m_vForward);    

                    if (!m_hLinkObject) return DFALSE;
             	    pServerDE->GetObjectDims(m_hLinkObject, &vDims);
                	pServerDE->GetObjectPos(m_hLinkObject, &vPos);
                    
                    // Need to use the Dims of the Object to set these!!!
					VEC_MULSCALAR(vDims, vDims, 0.8f);
                    DFLOAT m_fForwardOffset = pServerDE->Random(-vDims.x, vDims.x);
                    DFLOAT m_fUpOffset = pServerDE->Random(-vDims.y, vDims.y/2.0f);
                    DFLOAT m_fRightOffset = pServerDE->Random(-vDims.z, vDims.z);
    
    	            VEC_MULSCALAR(vTemp, m_vForward, m_fForwardOffset);
        	        VEC_ADD(vPos, vPos, vTemp);
    
                    // vPos is a point in front of you.
                    // vDir is a point in front of you, but down
        	        VEC_COPY(vDir, vPos);
                	vDir.y = vDir.y - m_fUpOffset;
                	vDir.x = vDir.x - m_fRightOffset;
					vDir.z = vDir.z - m_fForwardOffset;
                
            	    VEC_COPY(vPos, vDir);

                    ObjectCreateStruct theStruct;
                    INIT_OBJECTCREATESTRUCT(theStruct);

                    theStruct.m_Flags = FLAG_VISIBLE;
                    theStruct.m_ObjectType = OT_SPRITE; 
					VEC_COPY(theStruct.m_Pos, vPos);

        			theStruct.m_SkinName[0] = '\0';
	        		theStruct.m_NextUpdate = 0.0f;
		        	_mbscpy((unsigned char*)theStruct.m_Filename, (const unsigned char*)"Sprites\\gibflame.spr");
				    VEC_COPY(theStruct.m_Scale, m_vScale)

                    HCLASS hClass = pServerDE->GetClass("BaseClass");
        
                    if (hClass)
                    {
                	    LPBASECLASS	pSprite = pServerDE->CreateObject(hClass, &theStruct);
                        m_hSprite[x] = pSprite->m_hObject;

                        if (!m_hLinkObject) return DFALSE;

						DVector vVel;
						pServerDE->GetVelocity(m_hLinkObject, &vVel);
						pServerDE->SetVelocity(pSprite->m_hObject, &vVel);

                    }        
                    

                    // Add Smoke
/*                    {
                    	ObjectCreateStruct theStruct;
                    	INIT_OBJECTCREATESTRUCT(theStruct);

                        pServerDE->GetObjectPos(m_hSprite[x], &vPos);
                       	vPos.y = vPos.y + 5;
                        
                        VEC_COPY(theStruct.m_Pos, vPos);
                    	HCLASS hClass = pServerDE->GetClass("CClientSmokeTrail");

                    	CClientSmokeTrail* pTrail = DNULL;

                    	if (hClass)
                    	{
		                    pTrail = (CClientSmokeTrail*)pServerDE->CreateObject(hClass, &theStruct);
                    	}
    
    	                if (pTrail)
                    	{
		                    DVector vVel;
                            if (!m_hLinkObject) return DFALSE;
        	    	        pServerDE->GetVelocity(m_hLinkObject, &vVel);
        		            pTrail->Setup(vVel, DFALSE);
                	    	m_hSmokeTrail[x] = pTrail->m_hObject;
                    	}
                    }            */

               	}
                
            	if (m_hSmokeTrail[x])
            	{
		            DVector vPos;
                
                    // Move the Smoke Up
                    if (m_hSprite[x])   pServerDE->GetObjectPos(m_hSprite[x], &vPos);
                    else                pServerDE->GetObjectPos(m_hSmokeTrail[x], &vPos);
                    
                	vPos.y = vPos.y + 5;
                
		            pServerDE->SetObjectPos(m_hSmokeTrail[x], &vPos);
	
            	}
            }
            
            
            if (m_hLight)
            {
                    DFLOAT fRed, fGreen, fBlue, fAlpha;
		            DVector vPos;
                    
                    
                    if (!m_hLinkObject) return DFALSE;
                    pServerDE->GetObjectPos(m_hLinkObject, &vPos);
    		        pServerDE->SetObjectPos(m_hLight, &vPos);
                    
                    if (!m_hLinkObject) return DFALSE;
                    pServerDE->GetObjectColor(m_hLinkObject, &fRed, &fGreen, &fBlue, &fAlpha);
                    pServerDE->SetObjectColor(m_hLinkObject, (fRed+0.3f), fGreen, fBlue, fAlpha);
            }    
        }            
        else
        {
            // Lost the Link, Remove Fire.
//            BPrint("Lost Link, Remove Fire...");
            
            for (int x=0; x<MAXFIRES; x++)
            {
               	if (m_hSprite[x])
				{
					pServerDE->RemoveObject(m_hSprite[x]);
					m_hSprite[x] = DNULL;
				}
               	if (m_hSmokeTrail[x])
				{
					pServerDE->RemoveObject(m_hSmokeTrail[x]);
					m_hSmokeTrail[x] = DNULL;
				}
            }
                        
            if (m_hLight)   pServerDE->RemoveObject( m_hLight );
            pServerDE->RemoveObject( m_hObject );
            
            return DFALSE;
        }
     }


	return DTRUE;
}
Example #8
0
void Controller::Update()
{
    uint32 i;
	FadeState *pState;
	float curTime, t;

	if(m_bFirstUpdate)
	{
		FirstUpdate();
        m_bFirstUpdate = LTFALSE;
	}

	if(m_State == CState_Fade)
	{
		// Find out if we're even interpolating.
        curTime = g_pLTServer->GetTime();
		if(curTime > (m_fStartTime + m_fDuration))
		{

			for(i=0; i < MAX_CONTROLLER_TARGETS; i++)
			{
				pState = &m_Fades[i];

				if(!pState->m_hTarget)
					continue;

				InterpolateValue(pState, 1.0f);
			}

			return;
		}

		t = (curTime - m_fStartTime) / m_fDuration;
		t = GetWaveFn(m_WaveType)(t); // Apply wave function.

		for(i=0; i < MAX_CONTROLLER_TARGETS; i++)
		{
			pState = &m_Fades[i];

			if(!pState->m_hTarget)
				continue;

			InterpolateValue(pState, t);
		}

		Activate();
	}
	else if(m_State == CState_Flicker)
	{
        if(g_pLTServer->GetTime() > m_fNextFlickerTime)
		{
			// Send the message.
			for(i=0; i < MAX_CONTROLLER_TARGETS; i++)
			{
				pState = &m_Fades[i];

				if(!pState->m_hTarget)
					continue;

                SendTriggerMsgToObject(this, pState->m_hTarget, LTFALSE, m_FlickerMsg);
			}

			// Go again?
			if(m_FlickerCounter != FLICKER_FOREVER)
				--m_FlickerCounter;

			if(m_FlickerCounter == 0)
				HandleOffCommand(CParsedMsg());

            m_fNextFlickerTime = g_pLTServer->GetTime() + GetRandom(m_fIntervalMin, m_fIntervalMax);
		}

		Activate();
	}
	else
	{
		Deactivate();
	}
}