diff --git a/resource/common/locale/English.toml b/resource/common/locale/English.toml index 26ac767..c9cbf8c 100644 --- a/resource/common/locale/English.toml +++ b/resource/common/locale/English.toml @@ -79,8 +79,8 @@ Makes the game more challanging to play. Lowers armour, health, stamina etc.""" Hour = "Hour" Hurricane = "Hurricane" -KeepStuff = "Keep stuff" -KeepStuffText = "Keep stuff after arrest/death" +KeepStuff = "Keep weapons" +KeepStuffText = "Keep weapons after arrest/death" KeyAction = "Action" KeyCombo = "Combination" MaxVehSkills = "Max vehicle skills" diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 6df4539..b6f5a0e 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -108,7 +108,6 @@ void MenuThread(void* param) if (Updater::IsUpdateAvailable()) { - Updater::GetUpdateVersion(); Log::Print("New update available: %s", Updater::GetUpdateVersion().c_str()); } diff --git a/src/pages/animation.cpp b/src/pages/animation.cpp index cdd80f3..21f8c92 100644 --- a/src/pages/animation.cpp +++ b/src/pages/animation.cpp @@ -297,8 +297,23 @@ void Animation::Init() // // nop (3x) patch::SetRaw(0x404950, (void*)"\xC3\x90\x90\x90", 4); - MH_CreateHook((void*)0x40D6E0, NEW_CStreaming_RemoveModel, (void**)&OLD_CStreaming_RemoveModel); - MH_EnableHook((void*)0x40D6E0); + // Fix crash at 0x4019EA + static bool hookInjected = false; + Events::initGameEvent.before += []() + { + if (hookInjected) + { + MH_DisableHook((void*)0x40D6E0); + } + }; + + Events::initGameEvent.after += []() + { + MH_CreateHook((void*)0x40D6E0, NEW_CStreaming_RemoveModel, (void**)&OLD_CStreaming_RemoveModel); + MH_EnableHook((void*)0x40D6E0); + hookInjected = true; + }; + #endif } diff --git a/src/pages/game.cpp b/src/pages/game.cpp index eb205bd..9809cb6 100644 --- a/src/pages/game.cpp +++ b/src/pages/game.cpp @@ -349,11 +349,6 @@ void Game::ShowPage() patch::Set(0x6C2759, 0, true); } } - if (Widget::Checkbox(TEXT("Game.KeepStuff"), &m_bKeepStuff, TEXT("Game.KeepStuffText"))) - { - Command(m_bKeepStuff); - Command(m_bKeepStuff); - } Widget::Checkbox(TEXT("Game.Screenshot"), &m_bScreenShot, std::format("{} {}", TEXT("Game.ScreenshotTip"), quickSceenShot.GetNameString()).c_str()); diff --git a/src/pages/game.h b/src/pages/game.h index f15cc06..2b1bb9e 100644 --- a/src/pages/game.h +++ b/src/pages/game.h @@ -24,7 +24,6 @@ private: static inline bool m_bSolidWater; // walk on water hack static inline bool m_bNoWaterPhysics; static inline bool m_bScreenShot; - static inline bool m_bKeepStuff; static inline ResourceStore m_StatData{ "stats", eResourceType::TYPE_TEXT }; #endif diff --git a/src/pages/player.cpp b/src/pages/player.cpp index c660463..45b05fa 100644 --- a/src/pages/player.cpp +++ b/src/pages/player.cpp @@ -221,11 +221,11 @@ void Player::Init() player->m_nFlags.bFireProof = 1; player->m_nFlags.bMeleeProof = 1; #else - player->m_nFlags.bBulletProof = m_bGodMode; - player->m_nFlags.bCollisionProof = m_bGodMode; - player->m_nFlags.bExplosionProof = m_bGodMode; - player->m_nFlags.bFireProof = m_bGodMode; - player->m_nFlags.bMeleeProof = m_bGodMode; + player->m_nFlags.bBulletProof = 1; + player->m_nFlags.bCollisionProof = 1; + player->m_nFlags.bExplosionProof = 1; + player->m_nFlags.bFireProof = 1; + player->m_nFlags.bMeleeProof = 1; #endif } @@ -270,11 +270,11 @@ void Player::Init() player->m_nFlags.bFireProof = 0; player->m_nFlags.bMeleeProof = 0; #else - player->m_nFlags.bBulletProof = m_bGodMode; - player->m_nFlags.bCollisionProof = m_bGodMode; - player->m_nFlags.bExplosionProof = m_bGodMode; - player->m_nFlags.bFireProof = m_bGodMode; - player->m_nFlags.bMeleeProof = m_bGodMode; + player->m_nFlags.bBulletProof = 0; + player->m_nFlags.bCollisionProof = 0; + player->m_nFlags.bExplosionProof = 0; + player->m_nFlags.bFireProof = 0; + player->m_nFlags.bMeleeProof = 0; #endif m_bGodMode = false; } @@ -558,7 +558,40 @@ void Player::ShowPage() patch::SetRaw(0x42C3B2, (void*)"\x0F\xB6\x05\xFB\x0A\xA1", 6); } } +#endif + if (Widget::Checkbox(TEXT("Game.KeepStuff"), &m_bKeepStuff, TEXT("Game.KeepStuffText"))) + { +#ifdef GTASA + Command(m_bKeepStuff); + Command(m_bKeepStuff); +#elif GTAVC + if (m_bKeepStuff) + { + patch::Nop(0x42C184, 5); + patch::Nop(0x42C068, 5); + patch::Nop(0x42BC7B, 5); + } + else + { + patch::SetRaw(0x42C184, (void*)"\xE8\xB7\x35\x0D\x00", 5); + patch::SetRaw(0x42C068, (void*)"\xE8\xD3\x36\x0D\x00", 5); + patch::SetRaw(0x42BC7B, (void*)"\xE8\xC0\x3A\x0D\x00", 5); + } +#elif GTA3 + if (m_bKeepStuff) + { + patch::Nop(0x421507, 7); + patch::Nop(0x421724, 7); + patch::Nop(0x4217F8, 8); + } + else + { + patch::SetRaw(0x421507, (void*)"\x8B\x0B\xE8\x62\xE6\x0A\x00", 7); + patch::SetRaw(0x421724, (void*)"\x8B\x0B\xE8\x45\xE4\x0A\x00", 7); + patch::SetRaw(0x4217F8, (void*)"\x83\xC4\x14\xE8\x73\xE3\x0A\x00", 8); + } #endif + } ImGui::NextColumn(); #ifdef GTASA diff --git a/src/pages/player.h b/src/pages/player.h index f10e3f4..4538baf 100644 --- a/src/pages/player.h +++ b/src/pages/player.h @@ -12,6 +12,7 @@ private: static inline bool m_bEnabled = false; static inline CVector m_fPos; }; + static inline bool m_bKeepStuff; static inline bool m_bFreezeWantedLevel; #ifdef GTAVC diff --git a/src/pages/teleport.cpp b/src/pages/teleport.cpp index 8823239..9e27538 100644 --- a/src/pages/teleport.cpp +++ b/src/pages/teleport.cpp @@ -5,12 +5,13 @@ #include "utils/util.h" #ifdef GTASA -// FlA -tRadarTrace* CRadar::ms_RadarTrace = reinterpret_cast(patch::GetPointer(0x5838B0 + 2)); +// FLA +tRadarTrace* ms_RadarTrace = reinterpret_cast(patch::GetPointer(0x5838B0 + 2)); +static int maxSprites = *(uint*)0x5D5870; void Teleport::FetchRadarSpriteData() { - static int maxSprites = *(uint*)0x5D5870; + uint timer = CTimer::m_snTimeInMilliseconds; static uint lastUpdated = timer; @@ -23,8 +24,8 @@ void Teleport::FetchRadarSpriteData() m_locData.m_pData->RemoveTable("Radar"); for (int i = 0; i != maxSprites; ++i) { - CVector pos = CRadar::ms_RadarTrace[i].m_vecPos; - std::string sprite = std::to_string(CRadar::ms_RadarTrace[i].m_nRadarSprite); + CVector pos = ms_RadarTrace[i].m_vecPos; + std::string sprite = std::to_string(ms_RadarTrace[i].m_nRadarSprite); std::string keyName = m_SpriteData.Get(sprite.c_str(), "Unknown"); keyName += ", " + Util::GetLocationName(&pos); std::string key = "Radar." + keyName; @@ -39,6 +40,8 @@ bool Teleport::IsQuickTeleportActive() return m_bQuickTeleport; } + + void Teleport::Init() { m_bTeleportMarker = gConfig.Get("Features.TeleportMarker", false); @@ -61,31 +64,54 @@ void Teleport::Init() { map.m_pTexture = gTextureList.FindRwTextureByName("map"); } - float height = screen::GetScreenHeight(); - float width = screen::GetScreenWidth(); - float size = width * height / width; // keep aspect ratio - float left = (width-size) / 2; + ImVec2 screenSz = ImVec2(screen::GetScreenWidth(), screen::GetScreenHeight()); + float size = screenSz.x * screenSz.y / screenSz.x; // keep aspect ratio + float left = (screenSz.x-size) / 2; float right = left+size; - map.Draw(CRect(left, 0.0f, right, height), CRGBA(255, 255, 255, 200)); - - if (ImGui::IsMouseClicked(0)) + map.Draw(CRect(left, 0.0f, right, screenSz.y), CRGBA(255, 255, 255, 200)); + + // draw sprites on map + static float sz = SCREEN_MULTIPLIER(12.5f); + for (int i = 0; i != maxSprites; ++i) + { + tRadarTrace &trace = ms_RadarTrace[i]; + + if (trace.m_nRadarSprite != RADAR_SPRITE_NONE) + { + CSprite2d &sprite = CRadar::RadarBlipSprites[LOWORD(trace.m_nRadarSprite)]; + ImVec2 pos = ImVec2(trace.m_vecPos.x, trace.m_vecPos.y); + pos = Util::ConvertMapToScreen(pos, m_fMapSize, screenSz); + sprite.Draw(CRect(pos.x-sz, pos.y-sz, pos.x+sz, pos.y+sz), CRGBA(255, 255, 255, 200)); + } + } + // create player sprite + CSprite2d &sprite = CRadar::RadarBlipSprites[RADAR_SPRITE_CENTRE]; + CPlayerPed *pPlayer = FindPlayerPed(); + CVector coord = pPlayer->GetPosition(); + ImVec2 pos = Util::ConvertMapToScreen(ImVec2(coord.x, coord.y), m_fMapSize, screenSz); + sprite.Draw(CRect(pos.x-sz, pos.y-sz, pos.x+sz, pos.y+sz), CRGBA(255, 255, 255, 200)); + + if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) { - // Convert screen space to image space ImVec2 pos = ImGui::GetMousePos(); if (pos.x > left && pos.x < right) { - pos.x -= left; - pos.x -= size/2; - pos.y -= size/2; - - // Convert image space to map space - pos.x = pos.x / size * m_fMapSize.x; - pos.y = pos.y / size * m_fMapSize.y; - pos.y *= -1; - + pos = Util::ConvertScreenToMap(pos, m_fMapSize, screenSz); WarpPlayer(CVector(pos.x, pos.y, 0.0f)); } } + + if (ImGui::IsMouseClicked(ImGuiMouseButton_Right)) + { + ImVec2 pos = ImGui::GetMousePos(); + if (pos.x > left && pos.x < right) + { + pos = Util::ConvertScreenToMap(pos, m_fMapSize, screenSz); + tRadarTrace *trace = &ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)]; + trace->m_vecPos = CVector(pos.x, pos.y, 0.0f); + // trace->m_nRadarSprite = RADAR_SPRITE_WAYPOINT; + } + } } #endif }; @@ -102,7 +128,7 @@ void Teleport::WarpPlayer(CVector pos, int interiorID) if (Type == eTeleportType::Marker) { - tRadarTrace targetBlip = CRadar::ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)]; + tRadarTrace targetBlip = ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)]; if (targetBlip.m_nRadarSprite != RADAR_SPRITE_WAYPOINT) { Util::SetMessage(TEXT("Teleport.TargetBlipText")); diff --git a/src/pages/vehicle.cpp b/src/pages/vehicle.cpp index 5fc15f0..ca8a9eb 100644 --- a/src/pages/vehicle.cpp +++ b/src/pages/vehicle.cpp @@ -89,6 +89,7 @@ void Vehicle::Init() pVeh->m_nPhysicalFlags.bFireProof = true; pVeh->m_nPhysicalFlags.bCollisionProof = true; pVeh->m_nPhysicalFlags.bMeleeProof = true; + pVeh->m_nVehicleFlags.bTyresDontBurst = true; pVeh->m_nVehicleFlags.bCanBeDamaged = true; #elif GTAVC pVeh->m_nFlags.bBulletProof = true; @@ -97,12 +98,19 @@ void Vehicle::Init() pVeh->m_nFlags.bCollisionProof = true; pVeh->m_nFlags.bMeleeProof = true; pVeh->m_nFlags.bImmuneToNonPlayerDamage = true; + + // no tyre burst + patch::SetRaw(0x609F30, (void*)"\xC2\x08\x00", 3); + patch::SetRaw(0x5886A0, (void*)"\xC2\x08\x00", 3); #else pVeh->m_nFlags.bBulletProof = true; pVeh->m_nFlags.bExplosionProof = true; pVeh->m_nFlags.bFireProof = true; pVeh->m_nFlags.bCollisionProof = true; pVeh->m_nFlags.bMeleeProof = true; + + // no tyre burst + patch::SetRaw(0x53C0E0, (void*)"\xC2\x04\x00", 3); #endif } @@ -682,6 +690,7 @@ void Vehicle::ShowPage() pVeh->m_nPhysicalFlags.bFireProof = false; pVeh->m_nPhysicalFlags.bCollisionProof = false; pVeh->m_nPhysicalFlags.bMeleeProof = false; + pVeh->m_nVehicleFlags.bTyresDontBurst = false; pVeh->m_nVehicleFlags.bCanBeDamaged = false; #elif GTAVC pVeh->m_nFlags.bBulletProof = false; @@ -690,12 +699,19 @@ void Vehicle::ShowPage() pVeh->m_nFlags.bCollisionProof = false; pVeh->m_nFlags.bMeleeProof = false; pVeh->m_nFlags.bImmuneToNonPlayerDamage = false; + + // restore tyre burst + patch::SetRaw(0x609F30, (void*)"\x53\x56\x57", 3); + patch::SetRaw(0x5886A0, (void*)"\x53\x56\x55", 3); #else pVeh->m_nFlags.bBulletProof = false; pVeh->m_nFlags.bExplosionProof = false; pVeh->m_nFlags.bFireProof = false; pVeh->m_nFlags.bCollisionProof = false; pVeh->m_nFlags.bMeleeProof = false; + + // restore tyre burst + patch::SetRaw(0x53C0E0, (void*)"\x53\x56\x55", 3); #endif } } diff --git a/src/utils/util.cpp b/src/utils/util.cpp index 10204da..bf869fe 100644 --- a/src/utils/util.cpp +++ b/src/utils/util.cpp @@ -3,6 +3,40 @@ #include #include "util.h" +ImVec2 Util::ConvertScreenToMap(ImVec2 pos, ImVec2 mapSz, ImVec2 screenSz) +{ + float size = screenSz.x * screenSz.y / screenSz.x; + float left = (screenSz.x-size) / 2; + + pos.x -= left; + pos.x -= size/2; + pos.y -= size/2; + + // Convert image space to map space + pos.x = pos.x / size * mapSz.x; + pos.y = pos.y / size * mapSz.y; + pos.y *= -1; + + return pos; +} + +ImVec2 Util::ConvertMapToScreen(ImVec2 pos, ImVec2 mapSz, ImVec2 screenSz) +{ + float size = screenSz.x * screenSz.y / screenSz.x; + float left = (screenSz.x-size) / 2; + + // Convert map space to screen space + pos.x = pos.x / mapSz.x * size; + pos.y = pos.y / mapSz.y * size; + pos.y *= -1; + + pos.x += left; + pos.x += size/2; + pos.y += size/2; + + return pos; +} + void Util::SetMessage(const char *message, bool b1, bool b2, bool b3) { #if GTASA diff --git a/src/utils/util.h b/src/utils/util.h index 57f17c0..41ed185 100644 --- a/src/utils/util.h +++ b/src/utils/util.h @@ -23,6 +23,9 @@ public: static void ClearCharTasksVehCheck(CPed* ped); static bool IsOnMission(); #endif + + static ImVec2 ConvertScreenToMap(ImVec2 pos, ImVec2 mapSz, ImVec2 screenSz); + static ImVec2 ConvertMapToScreen(ImVec2 pos, ImVec2 mapSz, ImVec2 screenSz); static void UnFlipVehicle(CVehicle *pVeh); static void FixVehicle(CVehicle *pVeh); static CPed* GetClosestPed();