add sprites in quick teleport, [iii|vc] keep weapons

This commit is contained in:
Grinch_ 2022-08-09 02:09:37 +06:00
parent fe67e21eeb
commit a3ad7146ec
11 changed files with 165 additions and 44 deletions

View File

@ -79,8 +79,8 @@ Makes the game more challanging to play.
Lowers armour, health, stamina etc.""" Lowers armour, health, stamina etc."""
Hour = "Hour" Hour = "Hour"
Hurricane = "Hurricane" Hurricane = "Hurricane"
KeepStuff = "Keep stuff" KeepStuff = "Keep weapons"
KeepStuffText = "Keep stuff after arrest/death" KeepStuffText = "Keep weapons after arrest/death"
KeyAction = "Action" KeyAction = "Action"
KeyCombo = "Combination" KeyCombo = "Combination"
MaxVehSkills = "Max vehicle skills" MaxVehSkills = "Max vehicle skills"

View File

@ -108,7 +108,6 @@ void MenuThread(void* param)
if (Updater::IsUpdateAvailable()) if (Updater::IsUpdateAvailable())
{ {
Updater::GetUpdateVersion();
Log::Print<eLogLevel::Info>("New update available: %s", Updater::GetUpdateVersion().c_str()); Log::Print<eLogLevel::Info>("New update available: %s", Updater::GetUpdateVersion().c_str());
} }

View File

@ -297,8 +297,23 @@ void Animation::Init()
// // nop (3x) // // nop (3x)
patch::SetRaw(0x404950, (void*)"\xC3\x90\x90\x90", 4); patch::SetRaw(0x404950, (void*)"\xC3\x90\x90\x90", 4);
MH_CreateHook((void*)0x40D6E0, NEW_CStreaming_RemoveModel, (void**)&OLD_CStreaming_RemoveModel); // Fix crash at 0x4019EA
MH_EnableHook((void*)0x40D6E0); 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 #endif
} }

View File

@ -349,11 +349,6 @@ void Game::ShowPage()
patch::Set<uint8_t>(0x6C2759, 0, true); patch::Set<uint8_t>(0x6C2759, 0, true);
} }
} }
if (Widget::Checkbox(TEXT("Game.KeepStuff"), &m_bKeepStuff, TEXT("Game.KeepStuffText")))
{
Command<Commands::SWITCH_ARREST_PENALTIES>(m_bKeepStuff);
Command<Commands::SWITCH_DEATH_PENALTIES>(m_bKeepStuff);
}
Widget::Checkbox(TEXT("Game.Screenshot"), &m_bScreenShot, Widget::Checkbox(TEXT("Game.Screenshot"), &m_bScreenShot,
std::format("{} {}", TEXT("Game.ScreenshotTip"), std::format("{} {}", TEXT("Game.ScreenshotTip"),
quickSceenShot.GetNameString()).c_str()); quickSceenShot.GetNameString()).c_str());

View File

@ -24,7 +24,6 @@ private:
static inline bool m_bSolidWater; // walk on water hack static inline bool m_bSolidWater; // walk on water hack
static inline bool m_bNoWaterPhysics; static inline bool m_bNoWaterPhysics;
static inline bool m_bScreenShot; static inline bool m_bScreenShot;
static inline bool m_bKeepStuff;
static inline ResourceStore m_StatData{ "stats", eResourceType::TYPE_TEXT }; static inline ResourceStore m_StatData{ "stats", eResourceType::TYPE_TEXT };
#endif #endif

View File

@ -221,11 +221,11 @@ void Player::Init()
player->m_nFlags.bFireProof = 1; player->m_nFlags.bFireProof = 1;
player->m_nFlags.bMeleeProof = 1; player->m_nFlags.bMeleeProof = 1;
#else #else
player->m_nFlags.bBulletProof = m_bGodMode; player->m_nFlags.bBulletProof = 1;
player->m_nFlags.bCollisionProof = m_bGodMode; player->m_nFlags.bCollisionProof = 1;
player->m_nFlags.bExplosionProof = m_bGodMode; player->m_nFlags.bExplosionProof = 1;
player->m_nFlags.bFireProof = m_bGodMode; player->m_nFlags.bFireProof = 1;
player->m_nFlags.bMeleeProof = m_bGodMode; player->m_nFlags.bMeleeProof = 1;
#endif #endif
} }
@ -270,11 +270,11 @@ void Player::Init()
player->m_nFlags.bFireProof = 0; player->m_nFlags.bFireProof = 0;
player->m_nFlags.bMeleeProof = 0; player->m_nFlags.bMeleeProof = 0;
#else #else
player->m_nFlags.bBulletProof = m_bGodMode; player->m_nFlags.bBulletProof = 0;
player->m_nFlags.bCollisionProof = m_bGodMode; player->m_nFlags.bCollisionProof = 0;
player->m_nFlags.bExplosionProof = m_bGodMode; player->m_nFlags.bExplosionProof = 0;
player->m_nFlags.bFireProof = m_bGodMode; player->m_nFlags.bFireProof = 0;
player->m_nFlags.bMeleeProof = m_bGodMode; player->m_nFlags.bMeleeProof = 0;
#endif #endif
m_bGodMode = false; m_bGodMode = false;
} }
@ -558,7 +558,40 @@ void Player::ShowPage()
patch::SetRaw(0x42C3B2, (void*)"\x0F\xB6\x05\xFB\x0A\xA1", 6); 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<Commands::SWITCH_ARREST_PENALTIES>(m_bKeepStuff);
Command<Commands::SWITCH_DEATH_PENALTIES>(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 #endif
}
ImGui::NextColumn(); ImGui::NextColumn();
#ifdef GTASA #ifdef GTASA

View File

@ -12,6 +12,7 @@ private:
static inline bool m_bEnabled = false; static inline bool m_bEnabled = false;
static inline CVector m_fPos; static inline CVector m_fPos;
}; };
static inline bool m_bKeepStuff;
static inline bool m_bFreezeWantedLevel; static inline bool m_bFreezeWantedLevel;
#ifdef GTAVC #ifdef GTAVC

View File

@ -5,12 +5,13 @@
#include "utils/util.h" #include "utils/util.h"
#ifdef GTASA #ifdef GTASA
// FlA // FLA
tRadarTrace* CRadar::ms_RadarTrace = reinterpret_cast<tRadarTrace*>(patch::GetPointer(0x5838B0 + 2)); tRadarTrace* ms_RadarTrace = reinterpret_cast<tRadarTrace*>(patch::GetPointer(0x5838B0 + 2));
static int maxSprites = *(uint*)0x5D5870;
void Teleport::FetchRadarSpriteData() void Teleport::FetchRadarSpriteData()
{ {
static int maxSprites = *(uint*)0x5D5870;
uint timer = CTimer::m_snTimeInMilliseconds; uint timer = CTimer::m_snTimeInMilliseconds;
static uint lastUpdated = timer; static uint lastUpdated = timer;
@ -23,8 +24,8 @@ void Teleport::FetchRadarSpriteData()
m_locData.m_pData->RemoveTable("Radar"); m_locData.m_pData->RemoveTable("Radar");
for (int i = 0; i != maxSprites; ++i) for (int i = 0; i != maxSprites; ++i)
{ {
CVector pos = CRadar::ms_RadarTrace[i].m_vecPos; CVector pos = ms_RadarTrace[i].m_vecPos;
std::string sprite = std::to_string(CRadar::ms_RadarTrace[i].m_nRadarSprite); std::string sprite = std::to_string(ms_RadarTrace[i].m_nRadarSprite);
std::string keyName = m_SpriteData.Get<std::string>(sprite.c_str(), "Unknown"); std::string keyName = m_SpriteData.Get<std::string>(sprite.c_str(), "Unknown");
keyName += ", " + Util::GetLocationName(&pos); keyName += ", " + Util::GetLocationName(&pos);
std::string key = "Radar." + keyName; std::string key = "Radar." + keyName;
@ -39,6 +40,8 @@ bool Teleport::IsQuickTeleportActive()
return m_bQuickTeleport; return m_bQuickTeleport;
} }
void Teleport::Init() void Teleport::Init()
{ {
m_bTeleportMarker = gConfig.Get("Features.TeleportMarker", false); m_bTeleportMarker = gConfig.Get("Features.TeleportMarker", false);
@ -61,31 +64,54 @@ void Teleport::Init()
{ {
map.m_pTexture = gTextureList.FindRwTextureByName("map"); map.m_pTexture = gTextureList.FindRwTextureByName("map");
} }
float height = screen::GetScreenHeight(); ImVec2 screenSz = ImVec2(screen::GetScreenWidth(), screen::GetScreenHeight());
float width = screen::GetScreenWidth(); float size = screenSz.x * screenSz.y / screenSz.x; // keep aspect ratio
float size = width * height / width; // keep aspect ratio float left = (screenSz.x-size) / 2;
float left = (width-size) / 2;
float right = left+size; float right = left+size;
map.Draw(CRect(left, 0.0f, right, height), CRGBA(255, 255, 255, 200)); map.Draw(CRect(left, 0.0f, right, screenSz.y), CRGBA(255, 255, 255, 200));
if (ImGui::IsMouseClicked(0)) // 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(); ImVec2 pos = ImGui::GetMousePos();
if (pos.x > left && pos.x < right) if (pos.x > left && pos.x < right)
{ {
pos.x -= left; pos = Util::ConvertScreenToMap(pos, m_fMapSize, screenSz);
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;
WarpPlayer<eTeleportType::MapPosition>(CVector(pos.x, pos.y, 0.0f)); WarpPlayer<eTeleportType::MapPosition>(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 #endif
}; };
@ -102,7 +128,7 @@ void Teleport::WarpPlayer(CVector pos, int interiorID)
if (Type == eTeleportType::Marker) 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) if (targetBlip.m_nRadarSprite != RADAR_SPRITE_WAYPOINT)
{ {
Util::SetMessage(TEXT("Teleport.TargetBlipText")); Util::SetMessage(TEXT("Teleport.TargetBlipText"));

View File

@ -89,6 +89,7 @@ void Vehicle::Init()
pVeh->m_nPhysicalFlags.bFireProof = true; pVeh->m_nPhysicalFlags.bFireProof = true;
pVeh->m_nPhysicalFlags.bCollisionProof = true; pVeh->m_nPhysicalFlags.bCollisionProof = true;
pVeh->m_nPhysicalFlags.bMeleeProof = true; pVeh->m_nPhysicalFlags.bMeleeProof = true;
pVeh->m_nVehicleFlags.bTyresDontBurst = true;
pVeh->m_nVehicleFlags.bCanBeDamaged = true; pVeh->m_nVehicleFlags.bCanBeDamaged = true;
#elif GTAVC #elif GTAVC
pVeh->m_nFlags.bBulletProof = true; pVeh->m_nFlags.bBulletProof = true;
@ -97,12 +98,19 @@ void Vehicle::Init()
pVeh->m_nFlags.bCollisionProof = true; pVeh->m_nFlags.bCollisionProof = true;
pVeh->m_nFlags.bMeleeProof = true; pVeh->m_nFlags.bMeleeProof = true;
pVeh->m_nFlags.bImmuneToNonPlayerDamage = 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 #else
pVeh->m_nFlags.bBulletProof = true; pVeh->m_nFlags.bBulletProof = true;
pVeh->m_nFlags.bExplosionProof = true; pVeh->m_nFlags.bExplosionProof = true;
pVeh->m_nFlags.bFireProof = true; pVeh->m_nFlags.bFireProof = true;
pVeh->m_nFlags.bCollisionProof = true; pVeh->m_nFlags.bCollisionProof = true;
pVeh->m_nFlags.bMeleeProof = true; pVeh->m_nFlags.bMeleeProof = true;
// no tyre burst
patch::SetRaw(0x53C0E0, (void*)"\xC2\x04\x00", 3);
#endif #endif
} }
@ -682,6 +690,7 @@ void Vehicle::ShowPage()
pVeh->m_nPhysicalFlags.bFireProof = false; pVeh->m_nPhysicalFlags.bFireProof = false;
pVeh->m_nPhysicalFlags.bCollisionProof = false; pVeh->m_nPhysicalFlags.bCollisionProof = false;
pVeh->m_nPhysicalFlags.bMeleeProof = false; pVeh->m_nPhysicalFlags.bMeleeProof = false;
pVeh->m_nVehicleFlags.bTyresDontBurst = false;
pVeh->m_nVehicleFlags.bCanBeDamaged = false; pVeh->m_nVehicleFlags.bCanBeDamaged = false;
#elif GTAVC #elif GTAVC
pVeh->m_nFlags.bBulletProof = false; pVeh->m_nFlags.bBulletProof = false;
@ -690,12 +699,19 @@ void Vehicle::ShowPage()
pVeh->m_nFlags.bCollisionProof = false; pVeh->m_nFlags.bCollisionProof = false;
pVeh->m_nFlags.bMeleeProof = false; pVeh->m_nFlags.bMeleeProof = false;
pVeh->m_nFlags.bImmuneToNonPlayerDamage = 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 #else
pVeh->m_nFlags.bBulletProof = false; pVeh->m_nFlags.bBulletProof = false;
pVeh->m_nFlags.bExplosionProof = false; pVeh->m_nFlags.bExplosionProof = false;
pVeh->m_nFlags.bFireProof = false; pVeh->m_nFlags.bFireProof = false;
pVeh->m_nFlags.bCollisionProof = false; pVeh->m_nFlags.bCollisionProof = false;
pVeh->m_nFlags.bMeleeProof = false; pVeh->m_nFlags.bMeleeProof = false;
// restore tyre burst
patch::SetRaw(0x53C0E0, (void*)"\x53\x56\x55", 3);
#endif #endif
} }
} }

View File

@ -3,6 +3,40 @@
#include <psapi.h> #include <psapi.h>
#include "util.h" #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) void Util::SetMessage(const char *message, bool b1, bool b2, bool b3)
{ {
#if GTASA #if GTASA

View File

@ -23,6 +23,9 @@ public:
static void ClearCharTasksVehCheck(CPed* ped); static void ClearCharTasksVehCheck(CPed* ped);
static bool IsOnMission(); static bool IsOnMission();
#endif #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 UnFlipVehicle(CVehicle *pVeh);
static void FixVehicle(CVehicle *pVeh); static void FixVehicle(CVehicle *pVeh);
static CPed* GetClosestPed(); static CPed* GetClosestPed();