re3-wiiu/src/Radar.cpp

529 lines
18 KiB
C++
Raw Normal View History

#include "common.h"
#include "patcher.h"
#include "Radar.h"
2019-06-15 01:34:19 +02:00
#include "Camera.h"
#include "Hud.h"
#include "World.h"
#include "Frontend.h"
#include "General.h"
#include "Vehicle.h"
#include "Pools.h"
#include "Script.h"
2019-06-20 21:34:39 +02:00
#include "TxdStore.h"
WRAPPER void CRadar::ClearBlipForEntity(eBlipType type, int32 id) { EAXJMP(0x4A56C0); }
2019-06-15 01:34:19 +02:00
WRAPPER void CRadar::Draw3dMarkers() { EAXJMP(0x4A4C70); }
WRAPPER float CRadar::LimitRadarPoint(CVector2D *point) { EAXJMP(0x4A4F30); }
WRAPPER void CRadar::ShowRadarTrace(float x, float y, uint32 size, uint32 red, uint32 green, uint32 blue, uint32 alpha) { EAXJMP(0x4A5870); }
2019-06-20 21:34:39 +02:00
WRAPPER void CRadar::StreamRadarSections(int x, int y) { EAXJMP(0x4A6100); }
WRAPPER int CRadar::ClipRadarPoly(CVector2D *out, CVector2D *in) { EAXJMP(0x4A64A0); }
WRAPPER void CRadar::TransformRealWorldToTexCoordSpace(CVector2D *out, CVector2D *in, int x, int y) { EAXJMP(0x4A5530); }
2019-06-21 11:27:53 +02:00
WRAPPER void CRadar::TransformRadarPointToRealWorldSpace(CVector2D *out, CVector2D *in) { EAXJMP(0x4A5300); }
2019-06-15 01:34:19 +02:00
2019-06-17 00:16:38 +02:00
float &CRadar::m_RadarRange = *(float*)0x8E281C;
2019-06-15 01:34:19 +02:00
CVector2D &CRadar::vec2DRadarOrigin = *(CVector2D*)0x6299B8;
CBlip *CRadar::ms_RadarTrace = (CBlip*)0x6ED5E0;
2019-06-20 11:20:52 +02:00
float CRadar::cachedSin;
float CRadar::cachedCos;
2019-06-20 21:34:39 +02:00
int *gRadarTxdIds = (int*)0x6299C0;
CSprite2d *CRadar::AsukaSprite = (CSprite2d*)0x8F1A40;
CSprite2d *CRadar::BombSprite = (CSprite2d*)0x8F5FB4;
CSprite2d *CRadar::CatSprite = (CSprite2d*)0x885B24;
CSprite2d *CRadar::CentreSprite = (CSprite2d*)0x8F6268;
CSprite2d *CRadar::CopcarSprite = (CSprite2d*)0x8F1A2C;
CSprite2d *CRadar::DonSprite = (CSprite2d*)0x8F2BE0;
CSprite2d *CRadar::EightSprite = (CSprite2d*)0x8F2BCC;
CSprite2d *CRadar::ElSprite = (CSprite2d*)0x8F1B80;
CSprite2d *CRadar::IceSprite = (CSprite2d*)0x9415FC;
CSprite2d *CRadar::JoeySprite = (CSprite2d*)0x8F2C00;
CSprite2d *CRadar::KenjiSprite = (CSprite2d*)0x8F2C68;
CSprite2d *CRadar::LizSprite = (CSprite2d*)0x8F5830;
CSprite2d *CRadar::LuigiSprite = (CSprite2d*)0x8F1A3C;
CSprite2d *CRadar::NorthSprite = (CSprite2d*)0x8F6274;
CSprite2d *CRadar::RaySprite = (CSprite2d*)0x8E2A7C;
CSprite2d *CRadar::SalSprite = (CSprite2d*)0x8F29EC;
CSprite2d *CRadar::SaveSprite = (CSprite2d*)0x8F5F74;
CSprite2d *CRadar::SpraySprite = (CSprite2d*)0x94307C;
CSprite2d *CRadar::TonySprite = (CSprite2d*)0x885B58;
CSprite2d *CRadar::WeaponSprite = (CSprite2d*)0x941534;
CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = {
NULL,
AsukaSprite,
BombSprite,
CatSprite,
CentreSprite,
CopcarSprite,
DonSprite,
EightSprite,
ElSprite,
IceSprite,
JoeySprite,
KenjiSprite,
LizSprite,
LuigiSprite,
NorthSprite,
RaySprite,
SalSprite,
SaveSprite,
SpraySprite,
TonySprite,
WeaponSprite
};
2019-06-15 01:34:19 +02:00
2019-06-20 15:18:15 +02:00
#if 0
WRAPPER void CRadar::DrawMap () { EAXJMP(0x4A4200); }
#else
void CRadar::DrawMap()
{
2019-06-15 01:34:19 +02:00
if (!TheCamera.m_WideScreenOn && CHud::m_Wants_To_Draw_Hud) {
if (FindPlayerVehicle()) {
if (FindPlayerVehicle()->GetSpeed().Magnitude() > 0.3f) {
if (FindPlayerVehicle()->GetSpeed().Magnitude() > 0.9f)
CRadar::m_RadarRange = 350.0f;
else
CRadar::m_RadarRange = (FindPlayerVehicle()->GetSpeed().Magnitude() + 0.3f) * 200.0f;
}
else
2019-06-15 01:34:19 +02:00
CRadar::m_RadarRange = 120.0f;
}
else
2019-06-15 01:34:19 +02:00
CRadar::m_RadarRange = 120.0f;
2019-06-15 01:34:19 +02:00
vec2DRadarOrigin.x = FindPlayerCentreOfWorld_NoSniperShift().x;
vec2DRadarOrigin.y = FindPlayerCentreOfWorld_NoSniperShift().y;
CRadar::DrawRadarMap();
}
}
2019-06-20 15:18:15 +02:00
#endif
2019-06-15 01:34:19 +02:00
2019-06-20 21:34:39 +02:00
#if 0
WRAPPER void CRadar::DrawRadarMask() { EAXJMP(0x4A69C0); }
#else
void CRadar::DrawRadarMask()
{
2019-06-21 11:27:53 +02:00
CVector2D vec2d[4] = {
2019-06-20 21:34:39 +02:00
CVector2D(1.0f, -1.0f),
CVector2D(1.0f, 1.0f),
CVector2D(-1.0f, 1.0f),
CVector2D(-1.0, -1.0f)
};
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
RwD3D8SetRenderState(rwRENDERSTATESTENCILFUNCTION, rwSTENCILFUNCTIONALWAYS);
CVector2D out[8];
CVector2D in;
for (int i = 0; i < 4; i++) {
in.x = vec2d[i].x;
in.y = vec2d[i].y;
CRadar::TransformRadarPointToScreenSpace(out, &in);
for (int j = 0; j < 7; j++) {
2019-06-21 11:27:53 +02:00
CRadar::cachedCos = cos(j * (PI / 2.0f / 6.0f));
CRadar::cachedSin = sin(j * (PI / 2.0f / 6.0f));
2019-06-20 21:34:39 +02:00
in.x = vec2d[i].x * cachedCos;
in.y = vec2d[i].y * cachedSin;
CRadar::TransformRadarPointToScreenSpace(&out[j + 1], &in);
};
CSprite2d::SetMaskVertices(8, (float *)out);
RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::GetVertices(), 8);
};
RwD3D8SetRenderState(rwRENDERSTATESTENCILFUNCTION, rwSTENCILFUNCTIONGREATER);
}
#endif
#if 1
WRAPPER void CRadar::DrawRadarSection(int x, int y) { EAXJMP(0x4A67E0); }
#else
void CRadar::DrawRadarSection(int x, int y)
{
}
#endif
#if 0
WRAPPER void CRadar::DrawRadarMap() { EAXJMP(0x4A6C20); }
#else
void CRadar::DrawRadarMap()
{
CRadar::DrawRadarMask();
int x = floorf((2000.0f + vec2DRadarOrigin.x) * 0.002f);
int y = round(7.0f - (2000.0f + vec2DRadarOrigin.y) * 0.002f);
CRadar::StreamRadarSections(x, y);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP);
RwRenderStateSet(rwRENDERSTATETEXTUREPERSPECTIVE, (void*)FALSE);
CRadar::DrawRadarSection(x - 1, y - 1);
CRadar::DrawRadarSection(x, y - 1);
CRadar::DrawRadarSection(x + 1, y - 1);
CRadar::DrawRadarSection(x - 1, y);
CRadar::DrawRadarSection(x, y);
CRadar::DrawRadarSection(x + 1, y);
CRadar::DrawRadarSection(x - 1, y + 1);
CRadar::DrawRadarSection(x, y + 1);
CRadar::DrawRadarSection(x + 1, y + 1);
}
#endif
2019-06-20 15:18:15 +02:00
#if 0
WRAPPER void CRadar::DrawBlips() { EAXJMP(0x4A42F0); }
#else
void CRadar::DrawBlips()
{
if (!TheCamera.m_WideScreenOn && CHud::m_Wants_To_Draw_Hud) {
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
CVector2D out;
CVector2D in = CVector2D(0.0f, 0.0f);
CRadar::TransformRadarPointToScreenSpace(&out, &in);
float angle;
2019-06-21 11:27:53 +02:00
if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN1)
angle = PI + FindPlayerHeading();
else
2019-06-21 11:27:53 +02:00
angle = FindPlayerHeading() - (PI + atan2(-TheCamera.GetForward().x, TheCamera.GetForward().y));
CRadar::DrawRotatingRadarSprite(CentreSprite, out.x, out.y, angle, 255);
CVector2D vec2d;
vec2d.x = vec2DRadarOrigin.x;
2019-06-20 21:34:39 +02:00
vec2d.y = M_SQRT2 * m_RadarRange + vec2DRadarOrigin.y;
CRadar::TransformRealWorldPointToRadarSpace(&in, &vec2d);
CRadar::LimitRadarPoint(&in);
CRadar::TransformRadarPointToScreenSpace(&out, &in);
CRadar::DrawRadarSprite(RADAR_SPRITE_NORTH, out.x, out.y, 255);
/*
DrawEntityBlip
*/
for (int i = 0; i < 32; i++) {
if (ms_RadarTrace[i].m_bInUse) {
if (ms_RadarTrace[i].m_eBlipType <= BLIP_OBJECT) {
CEntity *e = nil;
2019-06-21 11:27:53 +02:00
switch (ms_RadarTrace[i].m_eBlipType) {
case BLIP_CAR:
e = CPools::GetVehiclePool()->GetAt(ms_RadarTrace[i].m_nEntityHandle);
break;
case BLIP_CHAR:
e = CPools::GetPedPool()->GetAt(ms_RadarTrace[i].m_nEntityHandle);
break;
case BLIP_OBJECT:
e = CPools::GetObjectPool()->GetAt(ms_RadarTrace[i].m_nEntityHandle);
break;
};
if (e) {
2019-06-20 21:34:39 +02:00
if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
if (CTheScripts::DbgFlag) {
2019-06-20 21:34:39 +02:00
CRadar::ShowRadarMarker(e->GetPosition(), GetRadarTraceColour(ms_RadarTrace[i].m_nColor, ms_RadarTrace[i].m_bDim), ms_RadarTrace->m_Radius);
2019-06-20 21:34:39 +02:00
ms_RadarTrace[i].m_Radius = ms_RadarTrace[i].m_Radius - 0.1f;
if (ms_RadarTrace[i].m_Radius >= 1.0f)
ms_RadarTrace[i].m_Radius = 5.0;
}
}
2019-06-20 21:34:39 +02:00
if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BLIP_ONLY) {
2019-06-20 11:20:52 +02:00
vec2d = e->GetPosition();
CRadar::TransformRealWorldPointToRadarSpace(&in, &vec2d);
float dist = CRadar::LimitRadarPoint(&in);
int a = CRadar::CalculateBlipAlpha(dist);
CRadar::TransformRadarPointToScreenSpace(&out, &in);
2019-06-20 21:34:39 +02:00
CRGBA col = CRadar::GetRadarTraceColour(ms_RadarTrace[i].m_nColor, ms_RadarTrace[i].m_bDim);
2019-06-21 11:27:53 +02:00
if (ms_RadarTrace[i].m_IconID)
2019-06-20 21:34:39 +02:00
CRadar::DrawRadarSprite(ms_RadarTrace[i].m_IconID, out.x, out.y, a);
else
2019-06-20 21:34:39 +02:00
CRadar::ShowRadarTrace(out.x, out.y, ms_RadarTrace[i].m_wScale, col.r, col.g, col.b, 255);
}
}
}
2019-06-20 21:34:39 +02:00
/*
DrawCoordBlip
*/
if (ms_RadarTrace[i].m_eBlipType >= BLIP_COORD) {
2019-06-20 21:34:39 +02:00
if (ms_RadarTrace[i].m_eBlipType != BLIP_CONTACT_POINT || ms_RadarTrace[i].m_eBlipType == BLIP_CONTACT_POINT && DisplayThisBlip(i) || !CTheScripts::IsPlayerOnAMission()) {
if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
if (CTheScripts::DbgFlag) {
2019-06-21 11:27:53 +02:00
CRadar::ShowRadarMarker(ms_RadarTrace[i].m_vecPos, CRadar::GetRadarTraceColour(ms_RadarTrace[i].m_nColor, ms_RadarTrace[i].m_bDim), ms_RadarTrace->m_Radius);
ms_RadarTrace[i].m_Radius = ms_RadarTrace[i].m_Radius - 0.1f;
2019-06-20 21:34:39 +02:00
if (ms_RadarTrace[i].m_Radius >= 1.0f)
ms_RadarTrace[i].m_Radius = 5.0f;
}
}
2019-06-20 21:34:39 +02:00
if (ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[i].m_eBlipDisplay == BLIP_DISPLAY_BLIP_ONLY) {
CRadar::TransformRealWorldPointToRadarSpace(&in, &ms_RadarTrace[i].m_vec2DPos);
float dist = CRadar::LimitRadarPoint(&in);
int a = CRadar::CalculateBlipAlpha(dist);
CRadar::TransformRadarPointToScreenSpace(&out, &in);
2019-06-20 21:34:39 +02:00
CRGBA col = CRadar::GetRadarTraceColour(ms_RadarTrace[i].m_nColor, ms_RadarTrace[i].m_bDim);
if (CRadar::ms_RadarTrace[i].m_IconID)
2019-06-20 21:34:39 +02:00
CRadar::DrawRadarSprite(ms_RadarTrace[i].m_IconID, out.x, out.y, a);
else
2019-06-20 21:34:39 +02:00
CRadar::ShowRadarTrace(out.x, out.y, ms_RadarTrace[i].m_wScale, col.r, col.g, col.b, 255);
}
}
}
};
}
}
}
2019-06-20 15:18:15 +02:00
#endif
int CRadar::CalculateBlipAlpha(float dist)
{
if (dist <= 1.0f)
return 255;
if (dist <= 5.0f)
return (((1.0f - ((dist * 0.25f) - 0.25f)) * 255.0f) + (((dist * 0.25f) - 0.25f) * 128.0f));
return 128;
}
CRGBA CRadar::GetRadarTraceColour(uint32 color, bool bright)
{
switch (color) {
case 0:
if (bright)
return CRGBA(113, 43, 73, 255);
else
return CRGBA(127, 0, 0, 255);
case 1:
if (bright)
return CRGBA(95, 160, 106, 255);
else
return CRGBA(127, 0, 255, 255);
case 2:
if (bright)
return CRGBA(128, 167, 243, 255);
else
return CRGBA(0, 127, 255, 255);
case 3:
if (bright)
return CRGBA(225, 225, 225, 255);
else
return CRGBA(127, 127, 127, 255);
case 4:
if (bright)
return CRGBA(255, 225, 0, 255);
else
return CRGBA(127, 127, 0, 255);
case 5:
if (bright)
return CRGBA(255, 0, 255, 255);
else
return CRGBA(127, 0, 127, 255);
case 6:
if (bright)
return CRGBA(255, 255, 255, 255);
else
return CRGBA(127, 127, 255, 255);
default:
return CRGBA(0, 0, 0, 255);
}
}
void CRadar::TransformRadarPointToScreenSpace(CVector2D *out, CVector2D *in)
{
out->x = in->x * SCREEN_SCALE_X(47.0f) + SCREEN_SCALE_X(47.0f + 20.0f);
out->y = (SCREEN_SCALE_Y(76.0f)) * 0.5f + SCREEN_HEIGHT - (SCREEN_SCALE_Y(123.0f)) - in->y * (SCREEN_SCALE_Y(76.0f)) * 0.5f;
}
2019-06-20 15:18:15 +02:00
#if 0
WRAPPER void CRadar::TransformRealWorldPointToRadarSpace(CVector2D *out, CVector2D *in) { EAXJMP(0x4A50D0); }
#else
2019-06-20 11:20:52 +02:00
void CRadar::TransformRealWorldPointToRadarSpace(CVector2D *out, CVector2D *in)
{
2019-06-21 11:27:53 +02:00
if (TheCamera.Cams[TheCamera.ActiveCam].Mode != CCam::MODE_TOPDOWN1 && TheCamera.Cams[TheCamera.ActiveCam].Mode != CCam::MODE_TOPDOWNPED) {
2019-06-20 11:20:52 +02:00
if (TheCamera.GetLookDirection() != LOOKING_FORWARD) {
2019-06-21 11:27:53 +02:00
cachedSin = sin(atan2(-TheCamera.GetForward().x, TheCamera.GetForward().y));
cachedCos = cos(atan2(-TheCamera.GetForward().x, TheCamera.GetForward().y));
2019-06-20 11:20:52 +02:00
}
else {
CVector vecCamera;
2019-06-21 11:27:53 +02:00
if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FIRSTPERSON) {
2019-06-20 11:20:52 +02:00
vecCamera = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->m_matrix.m_matrix.up;
vecCamera.Normalise();
}
else
2019-06-21 11:27:53 +02:00
vecCamera = TheCamera.GetForward();
2019-06-20 11:20:52 +02:00
cachedSin = sin(atan2(-vecCamera.x, vecCamera.y));
cachedCos = cos(atan2(-vecCamera.x, vecCamera.y));
}
}
else {
cachedSin = 0.0f;
cachedCos = 1.0f;
}
float x = (in->x - vec2DRadarOrigin.x) * (1.0f / m_RadarRange);
float y = (in->y - vec2DRadarOrigin.y) * (1.0f / m_RadarRange);
out->x = cachedSin * y + cachedCos * x;
out->y = cachedCos * y - cachedSin * x;
}
2019-06-20 15:18:15 +02:00
#endif
2019-06-20 11:20:52 +02:00
2019-06-20 15:18:15 +02:00
#if 0
WRAPPER void CRadar::DrawRadarSprite(int sprite, float x, float y, int alpha) { EAXJMP(0x4A5EF0); }
#else
void CRadar::DrawRadarSprite(int sprite, float x, float y, int alpha)
{
float w = SCREEN_SCALE_X(8.0f);
float h = SCREEN_SCALE_Y(8.0f);
RadarSprites[sprite]->Draw(CRect(x - w, y - h, x + w, y + h), CRGBA(255, 255, 255, alpha));
}
2019-06-20 15:18:15 +02:00
#endif
2019-06-20 15:18:15 +02:00
#if 0
WRAPPER void CRadar::ShowRadarMarker(CVector pos, CRGBA color, float radius) { EAXJMP(0x4A59C0); }
#else
2019-06-20 11:20:52 +02:00
void CRadar::ShowRadarMarker(CVector pos, CRGBA color, float radius) {
float z2 = pos.z + (0.5f * color.color32) * TheCamera.m_matrix.m_matrix.at.z;
float y2 = (0.5f * color.color32) * TheCamera.m_matrix.m_matrix.at.y + pos.y;
float x2 = (0.5f * color.color32) * TheCamera.m_matrix.m_matrix.at.x + pos.x;
float z1 = pos.z + (1.4f * color.color32) * TheCamera.m_matrix.m_matrix.at.z;
float y1 = (1.4f * color.color32) * TheCamera.m_matrix.m_matrix.at.y + pos.y;
float x1 = (1.4f * color.color32) * TheCamera.m_matrix.m_matrix.at.x + pos.x;
CTheScripts::ScriptDebugLine3D(x1, y1, z1, x2, y2, z2, color.color32, color.color32);
z2 = pos.z - (0.5f * color.color32) * TheCamera.m_matrix.m_matrix.at.x;
y2 = pos.y - (0.5f * color.color32) * TheCamera.m_matrix.m_matrix.at.x;
x2 = pos.x - (0.5f * color.color32) * TheCamera.m_matrix.m_matrix.at.x;
z1 = pos.z - (1.4f * color.color32) * TheCamera.m_matrix.m_matrix.at.x;
y1 = pos.y - (1.4f * color.color32) * TheCamera.m_matrix.m_matrix.at.x;
x1 = pos.x - (1.4f * color.color32) * TheCamera.m_matrix.m_matrix.at.x;
CTheScripts::ScriptDebugLine3D(x1, y1, z1, x2, y2, z2, color.color32, color.color32);
z2 = (0.5f * color.color32) * TheCamera.m_matrix.m_matrix.right.x + pos.z;
y2 = (0.5f * color.color32) * TheCamera.m_matrix.m_matrix.right.x + pos.y;
x2 = (0.5f * color.color32) * TheCamera.m_matrix.m_matrix.right.x + pos.x;
z1 = (1.4f * color.color32) * TheCamera.m_matrix.m_matrix.right.x + pos.z;
y1 = (1.4f * color.color32) * TheCamera.m_matrix.m_matrix.right.x + pos.y;
x1 = (1.4f * color.color32) * TheCamera.m_matrix.m_matrix.right.x + pos.x;
CTheScripts::ScriptDebugLine3D(x1, y1, z1, x2, y2, z2, color.color32, color.color32);
z2 = pos.z - (0.5f * color.color32) * TheCamera.m_matrix.m_matrix.right.x;
y2 = pos.y - (0.5f * color.color32) * TheCamera.m_matrix.m_matrix.right.x;
x2 = pos.x - (0.5f * color.color32) * TheCamera.m_matrix.m_matrix.right.x;
z1 = pos.z - (1.4f * color.color32) * TheCamera.m_matrix.m_matrix.right.x;
y1 = pos.y - (1.4f * color.color32) * TheCamera.m_matrix.m_matrix.right.x;
x1 = pos.x - (1.4f * color.color32) * TheCamera.m_matrix.m_matrix.right.x;
CTheScripts::ScriptDebugLine3D(x1, y1, z1, x2, y2, z2, color.color32, color.color32);
}
2019-06-20 15:18:15 +02:00
#endif
2019-06-20 11:20:52 +02:00
2019-06-20 15:18:15 +02:00
#if 0
WRAPPER void CRadar::DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float angle, int alpha) { EAXJMP(0x4A5D10); }
#else
void CRadar::DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float angle, int alpha)
{
CVector curPosn[4];
CVector oldPosn[4];
curPosn[0].x = x - SCREEN_SCALE_X(5.6f);
curPosn[0].y = y + SCREEN_SCALE_Y(5.6f);
curPosn[1].x = x + SCREEN_SCALE_X(5.6f);
curPosn[1].y = y + SCREEN_SCALE_Y(5.6f);
curPosn[2].x = x - SCREEN_SCALE_X(5.6f);
curPosn[2].y = y - SCREEN_SCALE_Y(5.6f);
curPosn[3].x = x + SCREEN_SCALE_X(5.6f);
curPosn[3].y = y - SCREEN_SCALE_Y(5.6f);
for (uint32 i = 0; i < 4; i++) {
oldPosn[i] = curPosn[i];
curPosn[i].x = x + (oldPosn[i].x - x) * cosf(angle) + (oldPosn[i].y - y) * sinf(angle);
curPosn[i].y = y - (oldPosn[i].x - x) * sinf(angle) + (oldPosn[i].y - y) * cosf(angle);
}
sprite->Draw(curPosn[2].x, curPosn[2].y, curPosn[3].x, curPosn[3].y, curPosn[0].x, curPosn[0].y, curPosn[1].x, curPosn[1].y, CRGBA(255, 255, 255, alpha));
2019-06-15 01:34:19 +02:00
}
2019-06-20 15:18:15 +02:00
#endif
2019-06-15 01:34:19 +02:00
2019-06-20 21:34:39 +02:00
bool CRadar::DisplayThisBlip(int counter)
{
switch (ms_RadarTrace[counter].m_IconID) {
case RADAR_SPRITE_BOMB:
case RADAR_SPRITE_SPRAY:
case RADAR_SPRITE_WEAPON:
return true;
default:
return false;
}
}
2019-06-21 11:27:53 +02:00
#if 0
WRAPPER void CRadar::GetTextureCorners(int x, int y, CVector2D *out) { EAXJMP(0x4A61C0); };
#else
2019-06-20 21:34:39 +02:00
void CRadar::GetTextureCorners(int x, int y, CVector2D *out)
{
out[0].x = 500.0f * (x - 4);
out[0].y = 500.0f * (3 - y);
out[1].x = 500.0f * (y - 4 + 1);
out[1].y = 500.0f * (3 - y);
out[2].x = 500.0f * (y - 4 + 1);
out[2].y = 500.0f * (3 - y + 1);
out[3].x = 500.0f * (x - 4);
out[3].y = 500.0f * (3 - y + 1);
}
2019-06-21 11:27:53 +02:00
#endif
2019-06-20 21:34:39 +02:00
void CRadar::ClipRadarTileCoords(int x, int y)
{
if (x < 0)
x = 0;
if (x > 7)
x = 7;
if (y < 0)
y = 0;
if (y > 7)
y = 7;
}
2019-06-15 01:34:19 +02:00
STARTPATCHES
InjectHook(0x4A5040, CRadar::TransformRadarPointToScreenSpace, PATCH_JUMP);
ENDPATCHES