Add radio test and burst all tires test to vehicle menu.

Add testing table to vehicle menu.
Put audio ids into its own enum.
This commit is contained in:
kelson8 2024-06-18 13:56:47 -04:00
parent 5539829046
commit 0a05a87dd4
Signed by: kelson8
GPG Key ID: 3D738D9DD7239E13
8 changed files with 322 additions and 121 deletions

4
src/enums/audio_ids.cpp Normal file
View File

@ -0,0 +1,4 @@
#include "pch.h"
#include "audio_ids.h"
// Idk if this file is needed.

27
src/enums/audio_ids.h Normal file
View File

@ -0,0 +1,27 @@
#pragma once
class AudioIds {
public:
// https://sampwiki.blast.hk/wiki/SoundID
// This isn't a complete list, just a couple of these that I put together.
enum eSoundIds {
BLANK_SOUND = 0,
CRASH_SOUND = 1009,
GARAGE_DOOR_OPENING = 1035,
SELECTION_SOUND = 1058,
METALLIC_FENCE_RATTLE1 = 1100,
METALLIC_FENCE_RATTLE2 = 1101,
SPRAY_CAN = 1134,
CRASH1_SOUND = 1140,
CRASH2_SOUND = 1141,
THROW_SATCHEL_SOUND = 1145,
CAR_HORN = 1147,
BLIP_SOUND = 1149,
EXPLOSION_SOUND = 1159,
HANGER_DOORS = 1165,
DRIVING_SCHOOL_RESULTS_MUSIC = 1183,
BIKE_BOAT_SCHOOL_RESULTS_MUSIC = 1183,
FLIGHT_SCHOOL_RESULTS_MUSIC = 1187,
};
};

View File

@ -13,6 +13,9 @@ static void CoronasMenu()
// } // }
} }
/// <summary>
/// Main code for MarkersTestMenu
/// </summary>
void MarkersTestPage::MarkersTestMenu() void MarkersTestPage::MarkersTestMenu()
{ {
#ifdef _TEST #ifdef _TEST

View File

@ -9,12 +9,18 @@
#endif #endif
// My code // My code
#include "player_functions.h" #include "functions/player_functions.h"
#include "../enums/audio_ids.h"
// Incomplete. // Incomplete.
// https://library.sannybuilder.com/#/sa/default/0672 // https://library.sannybuilder.com/#/sa/default/0672
//Command<Commands::TASK_DESTROY_CAR>(pPed); //Command<Commands::TASK_DESTROY_CAR>(pPed);
// This might be fun to mess with if I can figure out how to use the stats
//player->m_pStats;
// Try to mess with the values in this enum and play sounds: eAudioEvents
PedTestPage::PedTestPage() PedTestPage::PedTestPage()
{ {
@ -23,36 +29,17 @@ PedTestPage::PedTestPage()
bool playerCanDrown = true; bool playerCanDrown = true;
// https://sampwiki.blast.hk/wiki/SoundID
enum soundIds {
BLANK_SOUND = 0,
CRASH_SOUND = 1009,
GARAGE_DOOR_OPENING = 1035,
SELECTION_SOUND = 1058,
METALLIC_FENCE_RATTLE1 = 1100,
METALLIC_FENCE_RATTLE2 = 1101,
SPRAY_CAN = 1134,
CRASH1_SOUND = 1140,
CRASH2_SOUND = 1141,
THROW_SATCHEL_SOUND = 1145,
CAR_HORN = 1147,
BLIP_SOUND = 1149,
EXPLOSION_SOUND = 1159,
HANGER_DOORS = 1165,
DRIVING_SCHOOL_RESULTS_MUSIC = 1183,
BIKE_BOAT_SCHOOL_RESULTS_MUSIC = 1183,
FLIGHT_SCHOOL_RESULTS_MUSIC = 1187,
};
//static std::vector<int> soundIds = { //static std::vector<int> soundIds = {
AudioIds* audioIds = new AudioIds();
static std::vector<std::string> soundIds = { static std::vector<std::string> soundIds = {
std::to_string(BLANK_SOUND), std::to_string(CRASH_SOUND), std::to_string(GARAGE_DOOR_OPENING), std::to_string(AudioIds::BLANK_SOUND), std::to_string(AudioIds::CRASH_SOUND), std::to_string(AudioIds::GARAGE_DOOR_OPENING),
std::to_string(SELECTION_SOUND), std::to_string(METALLIC_FENCE_RATTLE1), std::to_string(AudioIds::SELECTION_SOUND), std::to_string(AudioIds::METALLIC_FENCE_RATTLE1),
std::to_string(METALLIC_FENCE_RATTLE2), std::to_string(SPRAY_CAN), std::to_string(AudioIds::METALLIC_FENCE_RATTLE2), std::to_string(AudioIds::SPRAY_CAN),
std::to_string(CRASH1_SOUND), std::to_string(CRASH2_SOUND), std::to_string(THROW_SATCHEL_SOUND), std::to_string(CAR_HORN), std::to_string(AudioIds::CRASH1_SOUND), std::to_string(AudioIds::CRASH2_SOUND), std::to_string(AudioIds::THROW_SATCHEL_SOUND), std::to_string(AudioIds::CAR_HORN),
std::to_string(BLIP_SOUND), std::to_string(EXPLOSION_SOUND), std::to_string(AudioIds::BLIP_SOUND), std::to_string(AudioIds::EXPLOSION_SOUND),
std::to_string(HANGER_DOORS), std::to_string(DRIVING_SCHOOL_RESULTS_MUSIC), std::to_string(AudioIds::HANGER_DOORS), std::to_string(AudioIds::DRIVING_SCHOOL_RESULTS_MUSIC),
std::to_string(BIKE_BOAT_SCHOOL_RESULTS_MUSIC), std::to_string(FLIGHT_SCHOOL_RESULTS_MUSIC) std::to_string(AudioIds::BIKE_BOAT_SCHOOL_RESULTS_MUSIC), std::to_string(AudioIds::FLIGHT_SCHOOL_RESULTS_MUSIC)
}; };
//static std::vector<int> soundIds = { //static std::vector<int> soundIds = {
@ -109,7 +96,7 @@ static void BombMenu()
// https://library.sannybuilder.com/#/sa/default/018C // https://library.sannybuilder.com/#/sa/default/018C
// These might work: https://sampwiki.blast.hk/wiki/SoundID // These might work: https://sampwiki.blast.hk/wiki/SoundID
//Command<Commands::ADD_ONE_OFF_SOUND>(playerPos.x, playerPos.y, playerPos.z, 1159); //Command<Commands::ADD_ONE_OFF_SOUND>(playerPos.x, playerPos.y, playerPos.z, 1159);
Command<Commands::ADD_ONE_OFF_SOUND>(playerPos.x, playerPos.y, playerPos.z, EXPLOSION_SOUND); Command<Commands::ADD_ONE_OFF_SOUND>(playerPos.x, playerPos.y, playerPos.z, AudioIds::EXPLOSION_SOUND);
// This does about the same as above with a bit more code. // This does about the same as above with a bit more code.
//CExplosion::AddExplosion(FindPlayerPed(), FindPlayerPed(), EXPLOSION_CAR, playerPos, 1000, 1, 1.0f, true); //CExplosion::AddExplosion(FindPlayerPed(), FindPlayerPed(), EXPLOSION_CAR, playerPos, 1000, 1, 1.0f, true);
@ -117,6 +104,14 @@ static void BombMenu()
#endif //GTASA #endif //GTASA
} }
static void TestSoundMenu()
{
// GTA SA specific sounds.
#ifdef GTASA
#endif //GTASA
}
// New // New
#define _TEST #define _TEST
@ -293,6 +288,10 @@ static void SpawnRandomPed()
CStreaming::LoadAllRequestedModels(false); // Whatever this does. CStreaming::LoadAllRequestedModels(false); // Whatever this does.
CPed* ped = new CCivilianPed(CPopulation::IsFemale(modelID) ? PED_TYPE_CIVFEMALE : PED_TYPE_CIVMALE, modelID); CPed* ped = new CCivilianPed(CPopulation::IsFemale(modelID) ? PED_TYPE_CIVFEMALE : PED_TYPE_CIVMALE, modelID);
// New
// Idk how this one works
//ped->m_pIntelligence
if (ped) if (ped)
{ {
// Is this getting the offset for the coordinates? // Is this getting the offset for the coordinates?
@ -316,76 +315,27 @@ static void SpawnPedMenu()
#endif //GTASA #endif //GTASA
// TODO Remove this later.
/// <summary>
/// Area check test.
/// This seems to work.
/// </summary>
static void AreaCheckTest()
{
CPlayerPed* player = FindPlayerPed();
int hplayer = CPools::GetPedRef(player);
CVector playerPos = player->GetPosition();
// TODO Setup some random coords for this
CVector testLocationArea1 = CVector(2, 2, 2);
CVector testLocationArea2 = CVector(20, 20, 20);
// https://library.sannybuilder.com/#/sa/default/00A4
//Command<Commands::IS_CHAR_IN_AREA_3D>(hplayer,
// testLocationArea1.x, testLocationArea1.y, testLocationArea1.z,
// testLocationArea2.x, testLocationArea2.y, testLocationArea2.z, true);
// Will this work?
if (Command<Commands::IS_CHAR_IN_AREA_3D>(hplayer,
testLocationArea1.x, testLocationArea1.y, testLocationArea1.z,
testLocationArea2.x, testLocationArea2.y, testLocationArea2.z, true)) {
Util::SetMessage("You are in the zone!");
}
else
{
Util::SetMessage("You are not in the zone!");
}
}
// TODO Remove this later.
/// <summary>
/// Working on a new method for this.
/// Kill the player when the enter this area, fires off with an event below.
/// Returns true if the player is in the specified coords.
/// </summary>
static bool IsPlayerInArea()
{
CPlayerPed* player = FindPlayerPed();
int hplayer = CPools::GetPedRef(player);
CVector playerPos = player->GetPosition();
// TODO Setup some random coords for this
CVector testLocationArea1 = CVector(2, 2, 2);
CVector testLocationArea2 = CVector(20, 20, 20);
// https://library.sannybuilder.com/#/sa/default/00A4
// This seems to work fine.
if (Command<Commands::IS_CHAR_IN_AREA_3D>(hplayer,
testLocationArea1.x, testLocationArea1.y, testLocationArea1.z,
testLocationArea2.x, testLocationArea2.y, testLocationArea2.z, false)) {
return true;
}
else
{
return false;
}
}
// TODO Make this use the function I have defined in the PlayerFunctions class.
static void AreaCheckTestMenu() static void AreaCheckTestMenu()
{ {
CVector testLocationArea1 = CVector(2, 2, 2);
CVector testLocationArea2 = CVector(20, 20, 20);
ImGui::Text("Area Check testing."); ImGui::Text("Area Check testing.");
if (ImGui::Button("Check Area #1")) { if (ImGui::Button("Check Area #1")) {
AreaCheckTest(); bool isPlayerInArea = PlayerFunctions::IsPlayerInArea(testLocationArea1.x, testLocationArea1.y, testLocationArea1.z,
testLocationArea2.x, testLocationArea2.y, testLocationArea2.z);
if (isPlayerInArea)
{
Util::SetMessage("You are in the zone.");
}
else
{
Util::SetMessage("You are not in the zone.");
}
//AreaCheckTest();
} }
} }
@ -504,22 +454,8 @@ void PedTestPage::PlayerTestMenu()
//Events::gameProcessEvent += [this]() //Events::gameProcessEvent += [this]()
{ {
// Well this just spams the text and doesn't stop the noises when in the area. // Well this just spams the text and doesn't stop the noises when in the area.
#ifdef _TEST // Moved KillPlayer and other chaos mode functions into player_functions.cpp.
// This seems to work for killing the player in the area. // Moved the event into cheatmenu.cpp.
if (IsPlayerInArea()) {
//KillPlayer();
//PlayerFunctions::KillPlayer();
//Util::SetMessage("Welcome to the circle");
//AreaCheckTest();
}
else
{
//Util::SetMessage("You will now die!");
}
#endif //_TEST1
}; };
SuicideMenu(); SuicideMenu();

View File

@ -1,7 +1,11 @@
#include "pch.h" #include "pch.h"
#include "test_teleport.h" #include "test_teleport.h"
// Incomplete
/// <summary>
/// Main code for TestTeleportMenu
/// </summary>
/// Incomplete
void TeleportTestPage::TestTeleportMenu() void TeleportTestPage::TestTeleportMenu()
{ {

View File

@ -1,5 +1,20 @@
#include "pch.h" #include "pch.h"
// My code
#include "test_vehicle.h" #include "test_vehicle.h"
#include "functions/vehicle_functions.h"
#include "functions/player_functions.h"
#ifdef GTASA
// Radio Test
#include "CAERadioTrackManager.h"
#include "CAudioEngine.h"
// I can disable the radio and change its type using this
#include "CAEVehicleAudioEntity.h"
#include "CBmx.h"
#endif //GTASA
//void TestPage::VehicleTest() { //void TestPage::VehicleTest() {
// // These are neat, the BY_GAME defines seem to have everything in this order: SA, VC, 3. // // These are neat, the BY_GAME defines seem to have everything in this order: SA, VC, 3.
@ -44,6 +59,11 @@ bool bFlyingCars = false;
bool bSearchLight = false; bool bSearchLight = false;
bool bVehGodMode = false; bool bVehGodMode = false;
VehicleTestPage::VehicleTestPage()
{
}
static void BlowUpAllCarsMenu() static void BlowUpAllCarsMenu()
{ {
#ifdef GTASA #ifdef GTASA
@ -56,13 +76,16 @@ static void BlowUpAllCarsMenu()
CCheat::BlowUpCarsCheat(); CCheat::BlowUpCarsCheat();
Util::SetMessage("All cars have been exterminated!"); Util::SetMessage("All cars have been exterminated!");
}
}
#else #else
Util::SetMessage("Only works for SA!"); Util::SetMessage("Only works for SA!");
} }
#endif //GTASA #endif //GTASA
}
}
static void SearchLightMenu() static void SearchLightMenu()
{ {
@ -119,8 +142,6 @@ static void CloseDoorsMenu()
// Works for closing the doors, not the trunk or hood though. // Works for closing the doors, not the trunk or hood though.
if (ImGui::Button("Close doors")) if (ImGui::Button("Close doors"))
{ {
int hplayer = CPools::GetPedRef(player); int hplayer = CPools::GetPedRef(player);
CVehicle* pVeh = nullptr; CVehicle* pVeh = nullptr;
@ -132,8 +153,10 @@ static void CloseDoorsMenu()
Command<Commands::CLOSE_ALL_CAR_DOORS>(hVeh); Command<Commands::CLOSE_ALL_CAR_DOORS>(hVeh);
} }
} }
#endif //GTASA
} }
#endif
static void LockDoorsMenu() static void LockDoorsMenu()
{ {
@ -142,8 +165,6 @@ static void LockDoorsMenu()
// This works for locking the car doors. // This works for locking the car doors.
if (ImGui::Button("Lock doors")) if (ImGui::Button("Lock doors"))
{ {
int hplayer = CPools::GetPedRef(player); int hplayer = CPools::GetPedRef(player);
CVehicle* pVeh = nullptr; CVehicle* pVeh = nullptr;
@ -176,8 +197,10 @@ static void LockDoorsMenu()
} }
} }
#endif //GTASA #endif //GTASA
} }
static void FlyingCarsMenu() static void FlyingCarsMenu()
{ {
// This works // This works
@ -264,16 +287,20 @@ static void IsCarInWaterMenu()
CVehicle* pVeh = nullptr; CVehicle* pVeh = nullptr;
bool bInVehicle = Command<Commands::IS_CHAR_IN_ANY_CAR>(hplayer); bool bInVehicle = Command<Commands::IS_CHAR_IN_ANY_CAR>(hplayer);
// TODO Possibly Move this into a vehicle_functions file.
// First we check if the player is in a vehicle
if (bInVehicle) { if (bInVehicle) {
CVehicle* pVeh = player->m_pVehicle; CVehicle* pVeh = player->m_pVehicle;
int hVeh = CPools::GetVehicleRef(pVeh); int hVeh = CPools::GetVehicleRef(pVeh);
// https://library.sannybuilder.com/#/sa/default/04D8 // https://library.sannybuilder.com/#/sa/default/04D8
bool isCarInWater = Command<Commands::IS_CAR_IN_WATER>(hVeh); bool isCarInWater = Command<Commands::IS_CAR_IN_WATER>(hVeh);
// If the car is not in water
if (!isCarInWater) if (!isCarInWater)
{ {
Util::SetMessage("Your car is dry."); Util::SetMessage("Your car is dry.");
} }
// If the car is in water
else else
{ {
Util::SetMessage("Your car is in the water."); Util::SetMessage("Your car is in the water.");
@ -284,9 +311,193 @@ static void IsCarInWaterMenu()
Util::SetMessage("You are not in a car!"); Util::SetMessage("You are not in a car!");
} }
} }
#endif //GTASA
} }
// Incomplete.
static void RadioTest() {
#ifdef GTASA
CAEVehicleAudioEntity* cAEVehicleAudioEntity = new CAEVehicleAudioEntity();
CAudioEngine* cAudioEngine = new CAudioEngine();
#endif //GTASA #endif //GTASA
ImGui::Separator();
ImGui::Text("Radio Test");
bool toggleRadio = true;
if (ImGui::Checkbox("Toggle Radio", &toggleRadio)) {
if (!toggleRadio) {
// Idk how I would set these values
//eRadioType(RADIO_DISABLED);
//eRadioType == RADIO_DISABLED;
//cAudioEngine->;
//cAEVehicleAudioEntity.
// Disable the radio
}
else
{
// Enable the radio
}
}
}
#define _TEST
void BurstAllTiresMenu()
{
CPlayerPed* player = FindPlayerPed();
if (ImGui::Button("Pop car tires")) {
int hplayer = CPools::GetPedRef(player);
CVehicle* pVeh = nullptr;
bool bInVehicle = Command<Commands::IS_CHAR_IN_ANY_CAR>(hplayer);
//// First we check if the player is in a vehicle
if(bInVehicle)
{
//CVehicle* pVeh = player->m_pVehicle;
// I've never used this before
// https://github.com/DK22Pac/plugin-sdk/blob/master/examples/OpenDoorExample/Main.cpp#L69
CVehicle* pVehTest = FindPlayerVehicle(0, false);
//int hVeh = CPools::GetVehicleRef(pVeh);
#define _SWITCH_TEST
#ifdef _SWITCH_TEST
eVehicleType vehicleType;
// Check if the player is in a vehicle.
if (pVehTest) {
int hVehTest = CPools::GetVehicleRef(pVehTest);
// I didn't know it was possible to use switch on an enum, this can be useful to cut down on a lot of duplicate code.
// Well this doesn't seem to work right, it always prints "Your car no longer has tires.
// https://stackoverflow.com/questions/3019153/how-do-i-use-an-enum-value-in-a-switch-statement-in-c
// I'm not doing this right, it only ever says "Your car no longer has tires" even in a bike or boat.
// Also says the same for other vehicles too.
// https://github.com/DK22Pac/plugin-sdk/blob/master/examples/CreateCar/Main.cpp#L41
//switch (reinterpret_cast<CVehicleModelInfo*>(CModelInfo::ms_modelInfoPtrs[hVehTest])->m_nVehicleType) {
// This seems to crash it.
switch (pVeh->m_nVehicleClass) {
case VEHICLE_AUTOMOBILE:
Command<Commands::BURST_CAR_TYRE>(hVehTest, 0);
Command<Commands::BURST_CAR_TYRE>(hVehTest, 1);
Command<Commands::BURST_CAR_TYRE>(hVehTest, 2);
Command<Commands::BURST_CAR_TYRE>(hVehTest, 3);
Util::SetMessage("Your car no longer has tires!");
break;
case VEHICLE_BIKE:
Command<Commands::BURST_CAR_TYRE>(hVehTest, 1);
Command<Commands::BURST_CAR_TYRE>(hVehTest, 2);
Util::SetMessage("Your bike no longer has tires!");
break;
case VEHICLE_BMX:
Command<Commands::BURST_CAR_TYRE>(hVehTest, 1);
Command<Commands::BURST_CAR_TYRE>(hVehTest, 2);
Util::SetMessage("Your bike no longer has tires!");
break;
default:
Util::SetMessage("Only works for cars and bikes!");
break;
}
//switch (vehicleType) {
}
#else
// This works
// TODO Setup for loop for this and check if the car is a motorcycle
if (pVehTest && pVehTest->m_nVehicleClass == VEHICLE_AUTOMOBILE)
{
int hVehTest = CPools::GetVehicleRef(pVehTest);
// https://github.com/DK22Pac/plugin-sdk/blob/master/examples/OpenDoorExample/Main.cpp#L71
CAutomobile* autoMobile = reinterpret_cast<CAutomobile*>(pVehTest);
// TODO Set this to where it detects if the vehicle has 4 tires or not.
Command<Commands::BURST_CAR_TYRE>(hVehTest, 1);
Command<Commands::BURST_CAR_TYRE>(hVehTest, 2);
Command<Commands::BURST_CAR_TYRE>(hVehTest, 3);
Command<Commands::BURST_CAR_TYRE>(hVehTest, 4);
}
#endif //_SWITCH_TEST
}
}
}
/// <summary>
/// Quick test for checking if the VehicleFunctions class is working properly, it seems to be working fine.
/// </summary>
void CarCheckTestMenu()
{
VehicleFunctions* vehicleFunctions = new VehicleFunctions();
// Table test
// This adds a border for it. ImGuiTableFlags_Borders
// The flag I have set below removes the borders for the tables.
if(ImGui::BeginTable("VehicleTable", 4, ImGuiTableFlags_NoBordersInBody))
{
// 1
ImGui::TableNextColumn();
if (ImGui::Button("In vehicle?"))
{
// Only shows the "In a car" message if the player is in a vehicle
VehicleFunctions::PlayerInCarMsg();
}
// 2
ImGui::TableNextColumn();
if (ImGui::Button("Car in water?"))
{
if (PlayerFunctions::IsPlayerInVehicle())
{
if (VehicleFunctions::IsCarInWater())
{
Util::SetMessage("Your car is in the water.");
}
else
{
Util::SetMessage("Your car is dry");
}
}
else
{
Util::SetMessage("You are not in a car!");
}
}
// 3
ImGui::TableNextColumn();
if (ImGui::Button("Test1"))
{
Util::SetMessage("Not implemented!");
}
// 4
ImGui::TableNextColumn();
if (ImGui::Button("Test2"))
{
Util::SetMessage("Not implemented!");
}
ImGui::EndTable();
// Fix columns being broken
ImGui::Columns(1);
}
}
/// <summary>
/// Main code for VehicleTestMenu
/// </summary>
void VehicleTestPage::VehicleTestMenu() { void VehicleTestPage::VehicleTestMenu() {
//#ifdef GTASA //#ifdef GTASA
// CPlayerPed* player = FindPlayerPed(); // CPlayerPed* player = FindPlayerPed();
@ -304,6 +515,8 @@ void VehicleTestPage::VehicleTestMenu() {
// } // }
//#endif //GTASA //#endif //GTASA
// These should be ordered in whatever order they are specified here.
// Most of these are private to this file, they can be put into the header file to be made public if needed for other classes.
BlowUpAllCarsMenu(); BlowUpAllCarsMenu();
SearchLightMenu(); SearchLightMenu();
BlowUpVehicleMenu(); BlowUpVehicleMenu();
@ -313,6 +526,14 @@ void VehicleTestPage::VehicleTestMenu() {
InvincibleCarsMenu(); InvincibleCarsMenu();
IsCarInWaterMenu(); IsCarInWaterMenu();
// New
#ifdef _TEST
BurstAllTiresMenu();
ImGui::Separator();
CarCheckTestMenu();
#endif //_TEST
} }

View File

@ -4,9 +4,9 @@
class VehicleTestPage class VehicleTestPage
{ {
private: private:
VehicleTestPage();
VehicleTestPage(const VehicleTestPage&);
void Draw(); void Draw();
public: public:
VehicleTestPage();
VehicleTestPage(const VehicleTestPage&);
static void VehicleTestMenu(); static void VehicleTestMenu();
}; };

View File

@ -129,6 +129,9 @@ static void RemoveCheckpointMenu()
/// <summary>
/// Create corona menu (Creates a corona at the specified coords)
/// </summary>
void CreateCoronaTestMenu() void CreateCoronaTestMenu()
{ {
@ -169,6 +172,9 @@ void CreateCoronaTestMenu()
#endif //_TEST #endif //_TEST
} }
/// <summary>
/// Remove corona menu
/// </summary>
static void RemoveCoronaTestMenu() static void RemoveCoronaTestMenu()
{ {