コード例 #1
0
ファイル: dllmain.cpp プロジェクト: basecq/III.VC.GPS
PathLineInfo *GetPlaceInfo(PathLineInfo *info)
{
	CPlaceable *entity = NULL;
	RadarBlipIII *bestBlip = NULL;
	CVector blipPos = { 0.0f, 0.0f, 0.0f };
	float distance = 9999800001.99f;
	float newDistance = 0.0f;
	unsigned int color = 0;
	int point = 0;

	for (RadarBlipIII *blip = gRadarBlips3; blip != &gRadarBlips3[32]; blip++)
	{
		if (blip->m_bActive && blip->m_wBlipSprite == gCurrentGpsMode)
		{
			if (blip->m_dwBlipType > 0 && blip->m_dwBlipType < 4)
			{
				switch (blip->m_dwBlipType)
				{
				case BLIP_CAR: // 1
					entity = VehicleGetAt(*gVehiclePool, blip->m_dwEntityHandle);
					break;
				case BLIP_PED: // 2
					entity = PedGetAt(*gPedPool, blip->m_dwEntityHandle);
					if (entity && IS_PED_IN_CAR(entity))
						entity = GET_PED_CAR(entity);
					break;
				case BLIP_OBJECT: // 3
					entity = ObjectGetAt(*gObjectPool, blip->m_dwEntityHandle);
				}
				if (entity)
				{
					blipPos.x = entity->m_sCoords.m_sMatrix.pos.x;
					blipPos.y = entity->m_sCoords.m_sMatrix.pos.y;
					blipPos.z = entity->m_sCoords.m_sMatrix.pos.z;
				}
				else continue;
			}
			else
			{
				blipPos.x = blip->m_vecCurPos.x;
				blipPos.y = blip->m_vecCurPos.y;
				blipPos.z = blip->m_vecCurPos.z;
			}
			newDistance = GetSquaredDistanceBetweenPoints(blipPos, *GetCamPos());
			if (newDistance < distance)
			{
				distance = newDistance;
				gBlipBestPos.x = blipPos.x;
				gBlipBestPos.y = blipPos.y;
				gBlipBestPos.z = blipPos.z;
				bestBlip = blip;
			}
		}
	}
	if (bestBlip)
	{
		color = GetRadarTraceColour(bestBlip->m_dwBlipColour, bestBlip->m_bBlipBrightness);
		BYTEn(info->color, 0) = BYTEn(color, 3);
		BYTEn(info->color, 1) = BYTEn(color, 2);
		BYTEn(info->color, 2) = BYTEn(color, 1);
		BYTEn(info->color, 3) = 255;
		info->targetPoint = &gBlipBestPos;
	}
	else
	{
		info->targetPoint = NULL;
		info->color = 0;
	}
	return info;
}
コード例 #2
0
ファイル: dllmain.cpp プロジェクト: MehdiNejjar/III.VC.GPS
PathLineInfo *GetPlaceInfo(PathLineInfo *info, CVehicle *playerVeh, char mode, eLevelName level)
{
	CPlaceable *entity;
	RadarBlip *bestBlip;
	CVector blipPos;
	float distance, newDistance;
	unsigned int color;
	switch(mode)
	{
	case GPS_MODE_DEFAULT:
		entity = NULL;
		bestBlip = NULL;
		distance = 9999800001.99f;
		for(RadarBlip *blip = gRadarBlips; blip != &gRadarBlips[32]; blip++)
		{
			if(blip->m_bActive && !blip->m_wBlipSprite)
			{
				if(blip->m_dwBlipType > 0 && blip->m_dwBlipType < 4)
				{
					switch(blip->m_dwBlipType)
					{
					case BLIP_CAR: // 1
						entity = VehicleGetAt(*gVehiclePool, blip->m_dwEntityHandle);
						break;
					case BLIP_PED: // 2
						entity = PedGetAt(*gPedPool, blip->m_dwEntityHandle);
						if(entity && IS_PED_IN_CAR(entity))
							entity = GET_PED_CAR(entity);
						break;
					case BLIP_OBJECT: // 3
						entity = ObjectGetAt(*gObjectPool, blip->m_dwEntityHandle);
					}
					if(entity)
					{
						blipPos.x = entity->m_sCoords.m_sMatrix.pos.x;
						blipPos.y = entity->m_sCoords.m_sMatrix.pos.y;
						blipPos.z = entity->m_sCoords.m_sMatrix.pos.z;
					}
					else continue;
				}
				else
				{
					blipPos.x = blip->m_v3dPosn.x;
					blipPos.y = blip->m_v3dPosn.y;
					blipPos.z = blip->m_v3dPosn.z;
				}
				newDistance = GetSquaredDistanceBetweenPoints(blipPos, playerVeh->m_sCoords.m_sMatrix.pos);
				if(newDistance < distance)
				{
					distance = newDistance;
					gBlipBestPos.x = blipPos.x;
					gBlipBestPos.y = blipPos.y;
					gBlipBestPos.z = blipPos.z;
					bestBlip = blip;
				}
			}
		}
		if(bestBlip)
		{
			color = GetRadarTraceColour(bestBlip->m_dwBlipColour, bestBlip->m_bBlipBrightness);
			BYTEn(info->color, 0) = BYTEn(color, 3);
			BYTEn(info->color, 1) = BYTEn(color, 2);
			BYTEn(info->color, 2) = BYTEn(color, 1);
			BYTEn(info->color, 3) = 255;
			info->targetPoint = &gBlipBestPos;
		}
		else
		{
			info->targetPoint = NULL;
			info->color = 0;
		}
		break;
	case GPS_MODE_SAFEHOUSE:
		info->targetPoint = &gSafehousePos[level - 1];
		info->color = 0xFFB07A81;
		break;
	case GPS_MODE_PAYNSPRAY:
		info->targetPoint = &gPayNSprayPos[level - 1];
		info->color = 0xFF00C7B1;
		break;
	case GPS_MODE_AMMUNATION:
		if(level != LEVEL_SHORESIDE)
		{
			info->targetPoint = &gAmmuNationPos[level - 1];
			info->color = 0xFF613CC0;
		}
		else
		{
			info->targetPoint = NULL;
			info->color = 0;
		}
		break;
	case GPS_MODE_BOMBSHOP:
		info->targetPoint = &gBombShopPos[level - 1];
		info->color = 0xFF738C34;
		break;
	case GPS_MODE_HOSPITAL:
		info->targetPoint = &gHospitalPos[level - 1];
		info->color = 0xFFD99600;
		break;
	case GPS_MODE_POLICE:
		info->targetPoint = &gPolicePos[level - 1];
		info->color = 0xFFEFD8C8;
		break;
	case GPS_MODE_FIRESTATION:
		info->targetPoint = &gFireStationPos[level - 1];
		info->color = 0xFF0B69EB;
		break;
	default:
		info->targetPoint = NULL;
		info->color = 0;
	}
	return info;
}