コード例 #1
0
void CProjectile::ImpactDamageObject(HOBJECT hDamager, HOBJECT hObj)
{
	DamageStruct damage;

	damage.hDamager = hDamager;
	damage.vDir		= m_vDir;

	// Do Instant damage...

	if (m_fInstDamage > 0.0f)
	{
		damage.eType	= m_eInstDamageType;
		damage.fDamage	= m_fInstDamage;

		damage.DoDamage(this, hObj);
	}

	// Do Progressive damage...(if the progressive damage is supposed to
	// happen over time, it will be done in the explosion object)....

	if (m_fProgDamage > 0.0f && m_pAmmoData->fProgDamageLifetime <= 0.0f)
	{
		damage.eType	 = m_eProgDamageType;
		damage.fDamage	 = m_fProgDamage;
		damage.fDuration = m_pAmmoData->fProgDamageDuration;

		damage.DoDamage(this, hObj);
	}



	// Update player summary info...

	CPlayerObj* pPlayer;
	if (IsPlayer(hDamager) && IsCharacter(hObj) && IsAccuracyType(m_eInstDamageType))
	{
        CCharacter* pChar = (CCharacter*) g_pLTServer->HandleToObject(hObj);
        pPlayer = (CPlayerObj*) g_pLTServer->HandleToObject(hDamager);
		if (pPlayer)
		{
			ModelNode eModelNode = pChar->GetModelNodeLastHit();

			if (eModelNode != eModelNodeInvalid)
			{
				HitLocation eLoc = g_pModelButeMgr->GetSkeletonNodeLocation(pChar->GetModelSkeleton(),eModelNode);
				pPlayer->GetPlayerSummaryMgr()->IncNumHits(eLoc);
			}
			else
			{
				pPlayer->GetPlayerSummaryMgr()->IncNumHits(HL_UNKNOWN);
			}
		}
	}

	if (IsPlayer(hObj))
	{
        pPlayer = (CPlayerObj*) g_pLTServer->HandleToObject(hObj);
		if (pPlayer)
		{
			pPlayer->GetPlayerSummaryMgr()->IncNumTimesHit();
		}
	}
}
コード例 #2
0
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);
		}

	}
}