From 13dedd6c68c11a64ba040b92194a32bec71d8880 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Fri, 8 Nov 2024 00:32:04 +0800 Subject: [PATCH] [saco] Implement/match `CGame::UpdateCheckpoints()` --- saco/game/game.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++- saco/game/game.h | 3 ++- saco/game/scripting.h | 2 ++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/saco/game/game.cpp b/saco/game/game.cpp index afb85a3..19827a0 100644 --- a/saco/game/game.cpp +++ b/saco/game/game.cpp @@ -1,5 +1,6 @@ #include "../main.h" +#include "game.h" #include "util.h" #include "keystuff.h" #include "aimstuff.h" @@ -38,7 +39,7 @@ CGame::CGame() m_pGameAudio = new CAudio(); m_pGameCamera = new CCamera(); m_pGamePlayer = NULL; - field_4D = 0; + m_bCheckpointsEnabled = FALSE; m_bRaceCheckpointsEnabled = FALSE; m_dwRaceCheckpointHandle = NULL; field_61 = 0; @@ -775,6 +776,56 @@ void CGame::DisableRaceCheckpoint() //----------------------------------------------------------- +void CGame::UpdateCheckpoints() +{ + DWORD dwMarkerID; + + if(m_bCheckpointsEnabled) { + CPlayerPed *pPlayerPed = this->FindPlayerPed(); + if(pPlayerPed) { + ScriptCommand(&is_actor_near_point_3d,pPlayerPed->m_dwGTAId, + m_vecCheckpointPos.X,m_vecCheckpointPos.Y,m_vecCheckpointPos.Z, + m_vecCheckpointExtent.X,m_vecCheckpointExtent.Y,m_vecCheckpointExtent.Z,1); + if (!m_dwCheckpointMarker) + { + dwMarkerID = 0; + ScriptCommand(&create_radar_marker_without_sphere, + m_vecCheckpointPos.X, m_vecCheckpointPos.Y, m_vecCheckpointPos.Z, 0, &dwMarkerID); + ScriptCommand(&set_marker_color, dwMarkerID, 1005); + ScriptCommand(&show_on_radar, dwMarkerID, 3); + m_dwCheckpointMarker = dwMarkerID; + } + } + } + else if(m_dwCheckpointMarker) { + DisableMarker(m_dwCheckpointMarker); + m_dwCheckpointMarker = NULL; + } + + if(m_bRaceCheckpointsEnabled) { + CPlayerPed *pPlayerPed = this->FindPlayerPed(); + if(pPlayerPed) + { + if (!m_dwRaceCheckpointMarker) + { + dwMarkerID = 0; + ScriptCommand(&create_radar_marker_without_sphere, + m_vecRaceCheckpointPos.X,m_vecRaceCheckpointPos.Y,m_vecRaceCheckpointPos.Z,0,&dwMarkerID); + ScriptCommand(&set_marker_color, dwMarkerID, 1005); + ScriptCommand(&show_on_radar, dwMarkerID, 3); + m_dwRaceCheckpointMarker = dwMarkerID; + } + } + } + else if(m_dwRaceCheckpointMarker) { + DisableMarker(m_dwRaceCheckpointMarker); + DisableRaceCheckpoint(); + m_dwRaceCheckpointMarker = NULL; + } +} + +//----------------------------------------------------------- + DWORD CGame::CreateRadarMarkerIcon(int iMarkerType, float fX, float fY, float fZ, DWORD dwColor, int iStyle) { DWORD dwMarkerID=0; diff --git a/saco/game/game.h b/saco/game/game.h index 4dc0c17..289ee4d 100644 --- a/saco/game/game.h +++ b/saco/game/game.h @@ -30,7 +30,7 @@ private: DWORD m_dwRaceCheckpointHandle; VECTOR m_vecCheckpointPos; VECTOR m_vecCheckpointExtent; - int field_4D; + BOOL m_bCheckpointsEnabled; DWORD m_dwCheckpointMarker; int field_55; int field_59; @@ -83,6 +83,7 @@ public: void DrawGangZone(float* fPos, DWORD dwColor); void EnableStuntBonus(bool bEnable); + void UpdateCheckpoints(); void SetCheckpointInformation(VECTOR *pos, VECTOR *extent); void MakeRaceCheckpoint(); diff --git a/saco/game/scripting.h b/saco/game/scripting.h index 042513e..edb3f0c 100644 --- a/saco/game/scripting.h +++ b/saco/game/scripting.h @@ -56,6 +56,8 @@ const SCRIPT_COMMAND show_on_radar = { 0x0168, "ii" }; // var_marker, size const SCRIPT_COMMAND create_icon_marker_sphere = { 0x02A7, "fffiv" }; +const SCRIPT_COMMAND is_actor_near_point_3d = { 0x00FE, "iffffffi" };// var_actor, x, y, z, rx, ry, rz, b + const SCRIPT_COMMAND add_to_player_money = { 0x0109, "ii" }; // PLAYER_CHAR, money const SCRIPT_COMMAND has_car_sunk = { 0x02bf, "i" }; // CarID