diff --git a/src/enums/audio_ids.cpp b/src/enums/audio_ids.cpp new file mode 100644 index 0000000..8376712 --- /dev/null +++ b/src/enums/audio_ids.cpp @@ -0,0 +1,4 @@ +#include "pch.h" +#include "audio_ids.h" + +// Idk if this file is needed. \ No newline at end of file diff --git a/src/enums/audio_ids.h b/src/enums/audio_ids.h new file mode 100644 index 0000000..35fb388 --- /dev/null +++ b/src/enums/audio_ids.h @@ -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, + }; + +}; diff --git a/src/test/test_markers.cpp b/src/test/test_markers.cpp index db8acf3..6fc4e5a 100644 --- a/src/test/test_markers.cpp +++ b/src/test/test_markers.cpp @@ -13,6 +13,9 @@ static void CoronasMenu() // } } +/// +/// Main code for MarkersTestMenu +/// void MarkersTestPage::MarkersTestMenu() { #ifdef _TEST diff --git a/src/test/test_ped.cpp b/src/test/test_ped.cpp index bb9de62..023666c 100644 --- a/src/test/test_ped.cpp +++ b/src/test/test_ped.cpp @@ -9,12 +9,18 @@ #endif // My code -#include "player_functions.h" +#include "functions/player_functions.h" +#include "../enums/audio_ids.h" // Incomplete. // https://library.sannybuilder.com/#/sa/default/0672 //Command(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() { @@ -23,36 +29,17 @@ PedTestPage::PedTestPage() 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 soundIds = { +AudioIds* audioIds = new AudioIds(); + static std::vector soundIds = { - std::to_string(BLANK_SOUND), std::to_string(CRASH_SOUND), std::to_string(GARAGE_DOOR_OPENING), - std::to_string(SELECTION_SOUND), std::to_string(METALLIC_FENCE_RATTLE1), - std::to_string(METALLIC_FENCE_RATTLE2), std::to_string(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(BLIP_SOUND), std::to_string(EXPLOSION_SOUND), - std::to_string(HANGER_DOORS), std::to_string(DRIVING_SCHOOL_RESULTS_MUSIC), - std::to_string(BIKE_BOAT_SCHOOL_RESULTS_MUSIC), std::to_string(FLIGHT_SCHOOL_RESULTS_MUSIC) + std::to_string(AudioIds::BLANK_SOUND), std::to_string(AudioIds::CRASH_SOUND), std::to_string(AudioIds::GARAGE_DOOR_OPENING), + std::to_string(AudioIds::SELECTION_SOUND), std::to_string(AudioIds::METALLIC_FENCE_RATTLE1), + std::to_string(AudioIds::METALLIC_FENCE_RATTLE2), std::to_string(AudioIds::SPRAY_CAN), + 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(AudioIds::BLIP_SOUND), std::to_string(AudioIds::EXPLOSION_SOUND), + std::to_string(AudioIds::HANGER_DOORS), std::to_string(AudioIds::DRIVING_SCHOOL_RESULTS_MUSIC), + std::to_string(AudioIds::BIKE_BOAT_SCHOOL_RESULTS_MUSIC), std::to_string(AudioIds::FLIGHT_SCHOOL_RESULTS_MUSIC) }; //static std::vector soundIds = { @@ -109,7 +96,7 @@ static void BombMenu() // https://library.sannybuilder.com/#/sa/default/018C // These might work: https://sampwiki.blast.hk/wiki/SoundID //Command(playerPos.x, playerPos.y, playerPos.z, 1159); - Command(playerPos.x, playerPos.y, playerPos.z, EXPLOSION_SOUND); + Command(playerPos.x, playerPos.y, playerPos.z, AudioIds::EXPLOSION_SOUND); // This does about the same as above with a bit more code. //CExplosion::AddExplosion(FindPlayerPed(), FindPlayerPed(), EXPLOSION_CAR, playerPos, 1000, 1, 1.0f, true); @@ -117,6 +104,14 @@ static void BombMenu() #endif //GTASA } +static void TestSoundMenu() +{ + // GTA SA specific sounds. +#ifdef GTASA + +#endif //GTASA +} + // New #define _TEST @@ -293,6 +288,10 @@ static void SpawnRandomPed() CStreaming::LoadAllRequestedModels(false); // Whatever this does. 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) { // Is this getting the offset for the coordinates? @@ -316,76 +315,27 @@ static void SpawnPedMenu() #endif //GTASA -// TODO Remove this later. -/// -/// Area check test. -/// This seems to work. -/// -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(hplayer, - // testLocationArea1.x, testLocationArea1.y, testLocationArea1.z, - // testLocationArea2.x, testLocationArea2.y, testLocationArea2.z, true); - - // Will this work? - if (Command(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. -/// -/// 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. -/// -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(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() { + CVector testLocationArea1 = CVector(2, 2, 2); + CVector testLocationArea2 = CVector(20, 20, 20); + ImGui::Text("Area Check testing."); 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]() { // Well this just spams the text and doesn't stop the noises when in the area. -#ifdef _TEST - // This seems to work for killing the player in the area. - if (IsPlayerInArea()) { - - //KillPlayer(); - //PlayerFunctions::KillPlayer(); - //Util::SetMessage("Welcome to the circle"); - //AreaCheckTest(); - } - else - { - - //Util::SetMessage("You will now die!"); - } - -#endif //_TEST1 + // Moved KillPlayer and other chaos mode functions into player_functions.cpp. + // Moved the event into cheatmenu.cpp. }; SuicideMenu(); diff --git a/src/test/test_teleport.cpp b/src/test/test_teleport.cpp index e996f60..8cbadfd 100644 --- a/src/test/test_teleport.cpp +++ b/src/test/test_teleport.cpp @@ -1,7 +1,11 @@ #include "pch.h" #include "test_teleport.h" -// Incomplete + +/// +/// Main code for TestTeleportMenu +/// +/// Incomplete void TeleportTestPage::TestTeleportMenu() { diff --git a/src/test/test_vehicle.cpp b/src/test/test_vehicle.cpp index 0ba98db..46835cc 100644 --- a/src/test/test_vehicle.cpp +++ b/src/test/test_vehicle.cpp @@ -1,5 +1,20 @@ #include "pch.h" +// My code #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() { // // 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 bVehGodMode = false; +VehicleTestPage::VehicleTestPage() +{ + +} + static void BlowUpAllCarsMenu() { #ifdef GTASA @@ -56,13 +76,16 @@ static void BlowUpAllCarsMenu() CCheat::BlowUpCarsCheat(); Util::SetMessage("All cars have been exterminated!"); + } +} #else Util::SetMessage("Only works for SA!"); } #endif //GTASA - } -} + + + static void SearchLightMenu() { @@ -119,8 +142,6 @@ static void CloseDoorsMenu() // Works for closing the doors, not the trunk or hood though. if (ImGui::Button("Close doors")) { - - int hplayer = CPools::GetPedRef(player); CVehicle* pVeh = nullptr; @@ -132,8 +153,10 @@ static void CloseDoorsMenu() Command(hVeh); } } +#endif //GTASA } -#endif + + static void LockDoorsMenu() { @@ -142,8 +165,6 @@ static void LockDoorsMenu() // This works for locking the car doors. if (ImGui::Button("Lock doors")) { - - int hplayer = CPools::GetPedRef(player); CVehicle* pVeh = nullptr; @@ -176,8 +197,10 @@ static void LockDoorsMenu() } } #endif //GTASA + } + static void FlyingCarsMenu() { // This works @@ -264,16 +287,20 @@ static void IsCarInWaterMenu() CVehicle* pVeh = nullptr; bool bInVehicle = Command(hplayer); + // TODO Possibly Move this into a vehicle_functions file. + // First we check if the player is in a vehicle if (bInVehicle) { CVehicle* pVeh = player->m_pVehicle; int hVeh = CPools::GetVehicleRef(pVeh); // https://library.sannybuilder.com/#/sa/default/04D8 bool isCarInWater = Command(hVeh); - + + // If the car is not in water if (!isCarInWater) { Util::SetMessage("Your car is dry."); } + // If the car is in water else { Util::SetMessage("Your car is in the water."); @@ -284,9 +311,193 @@ static void IsCarInWaterMenu() 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 + 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(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(CModelInfo::ms_modelInfoPtrs[hVehTest])->m_nVehicleType) { + // This seems to crash it. + switch (pVeh->m_nVehicleClass) { + + case VEHICLE_AUTOMOBILE: + Command(hVehTest, 0); + Command(hVehTest, 1); + Command(hVehTest, 2); + Command(hVehTest, 3); + Util::SetMessage("Your car no longer has tires!"); + break; + case VEHICLE_BIKE: + Command(hVehTest, 1); + Command(hVehTest, 2); + Util::SetMessage("Your bike no longer has tires!"); + + break; + case VEHICLE_BMX: + Command(hVehTest, 1); + Command(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(pVehTest); + + // TODO Set this to where it detects if the vehicle has 4 tires or not. + Command(hVehTest, 1); + Command(hVehTest, 2); + Command(hVehTest, 3); + Command(hVehTest, 4); + } +#endif //_SWITCH_TEST + } + } +} + +/// +/// Quick test for checking if the VehicleFunctions class is working properly, it seems to be working fine. +/// +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); + } +} + +/// +/// Main code for VehicleTestMenu +/// void VehicleTestPage::VehicleTestMenu() { //#ifdef GTASA // CPlayerPed* player = FindPlayerPed(); @@ -304,6 +515,8 @@ void VehicleTestPage::VehicleTestMenu() { // } //#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(); SearchLightMenu(); BlowUpVehicleMenu(); @@ -313,6 +526,14 @@ void VehicleTestPage::VehicleTestMenu() { InvincibleCarsMenu(); IsCarInWaterMenu(); + // New +#ifdef _TEST + BurstAllTiresMenu(); + + ImGui::Separator(); + CarCheckTestMenu(); +#endif //_TEST + } diff --git a/src/test/test_vehicle.h b/src/test/test_vehicle.h index 6a33f83..5918295 100644 --- a/src/test/test_vehicle.h +++ b/src/test/test_vehicle.h @@ -4,9 +4,9 @@ class VehicleTestPage { private: - VehicleTestPage(); - VehicleTestPage(const VehicleTestPage&); void Draw(); public: + VehicleTestPage(); + VehicleTestPage(const VehicleTestPage&); static void VehicleTestMenu(); }; diff --git a/src/test/test_world.cpp b/src/test/test_world.cpp index ab51201..dbd3415 100644 --- a/src/test/test_world.cpp +++ b/src/test/test_world.cpp @@ -129,6 +129,9 @@ static void RemoveCheckpointMenu() +/// +/// Create corona menu (Creates a corona at the specified coords) +/// void CreateCoronaTestMenu() { @@ -169,6 +172,9 @@ void CreateCoronaTestMenu() #endif //_TEST } +/// +/// Remove corona menu +/// static void RemoveCoronaTestMenu() {