[saco] Implement/match CGame::UpdateCheckpoints()

This commit is contained in:
RD42 2024-11-08 00:32:04 +08:00
parent 24f318de7a
commit 13dedd6c68
3 changed files with 56 additions and 2 deletions

View File

@ -1,5 +1,6 @@
#include "../main.h" #include "../main.h"
#include "game.h"
#include "util.h" #include "util.h"
#include "keystuff.h" #include "keystuff.h"
#include "aimstuff.h" #include "aimstuff.h"
@ -38,7 +39,7 @@ CGame::CGame()
m_pGameAudio = new CAudio(); m_pGameAudio = new CAudio();
m_pGameCamera = new CCamera(); m_pGameCamera = new CCamera();
m_pGamePlayer = NULL; m_pGamePlayer = NULL;
field_4D = 0; m_bCheckpointsEnabled = FALSE;
m_bRaceCheckpointsEnabled = FALSE; m_bRaceCheckpointsEnabled = FALSE;
m_dwRaceCheckpointHandle = NULL; m_dwRaceCheckpointHandle = NULL;
field_61 = 0; 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 CGame::CreateRadarMarkerIcon(int iMarkerType, float fX, float fY, float fZ, DWORD dwColor, int iStyle)
{ {
DWORD dwMarkerID=0; DWORD dwMarkerID=0;

View File

@ -30,7 +30,7 @@ private:
DWORD m_dwRaceCheckpointHandle; DWORD m_dwRaceCheckpointHandle;
VECTOR m_vecCheckpointPos; VECTOR m_vecCheckpointPos;
VECTOR m_vecCheckpointExtent; VECTOR m_vecCheckpointExtent;
int field_4D; BOOL m_bCheckpointsEnabled;
DWORD m_dwCheckpointMarker; DWORD m_dwCheckpointMarker;
int field_55; int field_55;
int field_59; int field_59;
@ -83,6 +83,7 @@ public:
void DrawGangZone(float* fPos, DWORD dwColor); void DrawGangZone(float* fPos, DWORD dwColor);
void EnableStuntBonus(bool bEnable); void EnableStuntBonus(bool bEnable);
void UpdateCheckpoints();
void SetCheckpointInformation(VECTOR *pos, VECTOR *extent); void SetCheckpointInformation(VECTOR *pos, VECTOR *extent);
void MakeRaceCheckpoint(); void MakeRaceCheckpoint();

View File

@ -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 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 add_to_player_money = { 0x0109, "ii" }; // PLAYER_CHAR, money
const SCRIPT_COMMAND has_car_sunk = { 0x02bf, "i" }; // CarID const SCRIPT_COMMAND has_car_sunk = { 0x02bf, "i" }; // CarID