Beispiel #1
0
DBOOL CDestructable::IsPlayerToPlayerDamageOk(HOBJECT hDamager, HOBJECT hOwner)
{
	// Sanity checks...

	if (m_hObject == hDamager) return(DTRUE);
	if (m_hObject == hOwner) return(DTRUE);


	// Check if we are playing a multiplayer game that has the right options set...

	if (!g_pBloodServerShell->IsMultiplayerTeamBasedGame()) return(DTRUE);
	if (g_pBloodServerShell->GetNetGameInfo()->m_bFriendlyFire) return(DTRUE);


	// Make sure we're a player...

	if (!IsPlayer(m_hObject)) return(DTRUE);


	// Get the attacker player for this damager or projectile...

	HOBJECT hHitter = DNULL;

	if (IsPlayer(hDamager))
	{
		hHitter = hDamager;
	}
	else if (IsPlayer(hOwner))
	{
		hHitter = hOwner;
	}

	if (!hHitter) return(DTRUE);


	// Get the player pointers...

	CPlayerObj* pVictim = (CPlayerObj*)g_pServerDE->HandleToObject(m_hObject);
	if (!pVictim) return(DTRUE);

	CPlayerObj* pDamager = (CPlayerObj*)g_pServerDE->HandleToObject(hHitter);
	if (!pDamager) return(DTRUE);


	// Check if these players are on the same team...

	if (pVictim->GetTeamID() == pDamager->GetTeamID()) return(DFALSE);


	// If we get here, it's ok to do the damage...

	return(DTRUE);
}
bool CDoomsDayMissionMgr::CanRespawn( CPlayerObj const& player ) const
{
	// Once the device starts, the other teams can't respawn.
	if( m_nActivatingTeam != INVALID_TEAM && player.GetTeamID( ) != m_nActivatingTeam )
		return false;

	return true;
}
Beispiel #3
0
LTBOOL CScanner::CanSeeObject(ObjectFilterFn ofn, HOBJECT hObject)
{
	_ASSERT(hObject);
    if (!hObject) return LTFALSE;

	if (g_pGameServerShell->GetGameType() == COOPERATIVE_ASSAULT && m_nPlayerTeamFilter && IsPlayer(hObject))
	{
		CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hObject);
		if (pPlayer->GetTeamID() != m_nPlayerTeamFilter)
			return LTFALSE;
	}


    LTVector vPos;
    g_pLTServer->GetObjectPos(hObject, &vPos);

    LTVector vDir;
	vDir = vPos - GetScanPosition();

	if (VEC_MAGSQR(vDir) >= m_fVisualRange)
	{
        return LTFALSE;
	}

	vDir.Norm();

    LTRotation rRot = GetScanRotation();

    LTVector vUp, vRight, vForward;
    g_pLTServer->GetRotationVectors(&rRot, &vUp, &vRight, &vForward);

    LTFLOAT fDp = vDir.Dot(vForward);

	if (fDp < m_fFOV)
	{
        return LTFALSE;
	}

	// See if we can see the position in question

	IntersectQuery IQuery;
	IntersectInfo IInfo;

	VEC_COPY(IQuery.m_From, GetScanPosition());
	VEC_COPY(IQuery.m_To, vPos);
	IQuery.m_Flags	  = INTERSECT_OBJECTS | IGNORE_NONSOLID;
	IQuery.m_FilterFn = ofn;

    if (g_pLTServer->IntersectSegment(&IQuery, &IInfo))
	{
		if (IInfo.m_hObject == hObject)
		{
            return LTTRUE;
		}
	}

    return LTFALSE;
}
Beispiel #4
0
uint8 GetPlayerTeamId( HOBJECT hPlayer )
{
	if (!GameModeMgr::Instance( ).m_grbUseTeams)
		return INVALID_TEAM;

	CPlayerObj *pPlayer = CPlayerObj::DynamicCast( hPlayer );
	if( !pPlayer )
		return INVALID_TEAM;

	return pPlayer->GetTeamID();
}
Beispiel #5
0
bool DoomsDayDevice::Fire( CPlayerObj& playerObj )
{
	// Make sure it's from someone on our team.
	if( playerObj.GetTeamID( ) != m_nOwningTeamID )
		return false;

	// Send a message letting the players know the device has been activated.
	CAutoMessage cMsg;
	cMsg.Writeuint8( MID_DOOMSDAY_MESSAGE );
	cMsg.Writeuint8( MID_DOOMSDAY_DEVICE_COMPLETED );
	cMsg.Writeuint8( m_nOwningTeamID );
	g_pLTServer->SendToClient( cMsg.Read(), LTNULL, MESSAGE_GUARANTEED );

	// Give the activating player a bunch of points.
	ServerGameOptions& sgo = g_pGameServerShell->GetServerGameOptions( );
	uint32 nBonus = sgo.GetDoomsday( ).m_nDeviceCompletedScore;
	playerObj.GetPlayerScore()->AddBonus( nBonus );

	if( !BeginFire( ))
		return false;

	return true;
}
LTBOOL DoVectorFilterFn(HOBJECT hObj, void *pUserData)
{
	// We're not attacking our self...

	if (SpecificObjectFilterFn(hObj, pUserData))
	{
		// CharacterHitBox objects are used for vector impacts, don't
		// impact on the character/body prop object itself....

		if (IsCharacter(hObj) || IsBody(hObj) || IsKindOf(hObj, "Intelligence"))
		{
            return LTFALSE;
		}

		// Check special character hit box cases...

		if (IsCharacterHitBox(hObj))
		{
            CCharacterHitBox *pCharHitBox = (CCharacterHitBox*) g_pLTServer->HandleToObject(hObj);
			if (pCharHitBox)
			{
				// Make sure we don't hit ourself...

				HOBJECT hUs = (HOBJECT)pUserData;

				HOBJECT hTestObj = pCharHitBox->GetModelObject();
                if (!hTestObj) return LTFALSE;

				if (hTestObj == hUs)
				{
                    return LTFALSE;
				}


				// Do special AI hitting AI case...
				if (IsAI(hUs) && IsAI(hTestObj))
				{
                    CAI *pAI = (CAI*) g_pLTServer->HandleToObject(hUs);
                    if (!pAI) return LTFALSE;

					// We can't hit guys we like, unless they're NEUTRAL

                    CCharacter* pB = (CCharacter*)g_pLTServer->HandleToObject(hTestObj);
                    if (!pB) return LTFALSE;

					CharacterClass cc = pB->GetCharacterClass();
					if (cc != NEUTRAL)
					{
						return LIKE != GetAlignement(pAI->GetCharacterClass(), cc);
					}
				}

				// Check for friendly fire
				if (g_pGameServerShell->GetGameType() == COOPERATIVE_ASSAULT && g_vtNetFriendlyFire.GetFloat() < 1.0f)
				{
					// We can't hit guys on our team unless friendly fire is turned on
					if (IsPlayer(hUs) && IsPlayer(hTestObj))
					{
                        CPlayerObj* pUs = (CPlayerObj*) g_pLTServer->HandleToObject(hUs);
                        if (!pUs) return LTFALSE;


                        CPlayerObj* pThem = (CPlayerObj*) g_pLTServer->HandleToObject(hTestObj);
                        if (!pThem) return LTFALSE;

						if (pUs->GetTeamID() == pThem->GetTeamID())
                            return LTFALSE;
					}

				}
			}
		}

        return LTTRUE;
	}

    return LTFALSE;
}
void Intelligence::DoActivate(HOBJECT hSender)
{
	// BL 10/30/00 - fix multiple photographs of items in multiplayer
	{
		if ( g_pGameServerShell->GetGameType() != SINGLE )
		{
			uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject);
			if ( !(dwFlags & FLAG_VISIBLE) )
			{
				return;
			}
		}
	}

	HOBJECT hPlayer = hSender;

	if (!hSender || !IsPlayer(hSender))
	{
		// Find the player if the sender isn't one...

		ObjArray <HOBJECT, 1> objArray;
        g_pLTServer->FindNamedObjects(DEFAULT_PLAYERNAME, objArray);

		if (!objArray.NumObjects()) return;

		hPlayer = objArray.GetObject(0);
	}

	// Increment the player's intelligence count...
    CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hPlayer);
	if (pPlayer)
	{
		if (g_pGameServerShell->GetGameType() == COOPERATIVE_ASSAULT && m_nPlayerTeamFilter)
		{
			if (pPlayer->GetTeamID() != m_nPlayerTeamFilter)
				return;
			uint8 nScore = (uint8)g_vtNetIntelScore.GetFloat();
			pPlayer->AddToScore(nScore);
			
			HCLIENT hClient = pPlayer->GetClient();
		    uint32 nPlayerID = g_pLTServer->GetClientID(hClient);

            HMESSAGEWRITE hWrite = g_pLTServer->StartMessage (LTNULL, MID_TEAM_SCORED);
            g_pLTServer->WriteToMessageDWord (hWrite, nPlayerID);
            g_pLTServer->WriteToMessageByte (hWrite, (uint8)pPlayer->GetTeamID());
            g_pLTServer->WriteToMessageByte (hWrite, nScore);
            g_pLTServer->EndMessage (hWrite);

		}


		CPlayerSummaryMgr* pPSMgr = pPlayer->GetPlayerSummaryMgr();
		if (pPSMgr)
		{
			pPSMgr->IncIntelligenceCount();
		}

		HCLIENT hClient = pPlayer->GetClient();
		if (hClient)
		{
            HMESSAGEWRITE hMessage = g_pLTServer->StartMessage(hClient, MID_PLAYER_INFOCHANGE);
            g_pLTServer->WriteToMessageByte(hMessage, IC_INTEL_PICKUP_ID);
            g_pLTServer->WriteToMessageByte(hMessage, 0);
            g_pLTServer->WriteToMessageByte(hMessage, 0);
            g_pLTServer->WriteToMessageFloat(hMessage, 0.0f);
            g_pLTServer->EndMessage(hMessage);
		}

		// Show the pop-up associated with the intelligence item, if
		// applicable...

		INTEL* pIntel = g_pIntelMgr->GetIntel(m_nIntelId);
		if (pIntel && m_bShowPopup)
		{
			char buf[255];
			sprintf(buf, "msg %s (popup %d", DEFAULT_PLAYERNAME, m_nInfoId);

			// Add the scale fx...

			for (int i=0; i < pIntel->nNumScaleFXNames; i++)
			{
				if (pIntel->szScaleFXNames[i])
				{
					strcat(buf, " ");
					strcat(buf, pIntel->szScaleFXNames[i]);
				}
			}

			strcat(buf, ")");

			if (g_pCmdMgr->IsValidCmd(buf))
			{
				g_pCmdMgr->Process(buf);
			}
		}


		// If we have a command, process it...

		if (m_hstrPickedUpCmd)
		{
            char* pCmd = g_pLTServer->GetStringData(m_hstrPickedUpCmd);

			if (pCmd && g_pCmdMgr->IsValidCmd(pCmd))
			{
				g_pCmdMgr->Process(pCmd);
			}
		}

		if (g_pGameServerShell->GetGameType() == SINGLE)
		{
			g_pLTServer->RemoveObject(m_hObject);
		}
		else
		{
			uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject);
			dwFlags &= (~FLAG_VISIBLE & ~FLAG_RAYHIT);
			g_pLTServer->SetObjectFlags(m_hObject, dwFlags);

			// Play pickup sound...

			LTVector vPos;
			g_pLTServer->GetObjectPos(m_hObject, &vPos);
			g_pServerSoundMgr->PlaySoundFromPos(vPos, INTEL_PICKUP_SOUND,
				600.0f, SOUNDPRIORITY_MISC_HIGH);
		}

	}
}