Skip to content

Commit

Permalink
Add more menu features
Browse files Browse the repository at this point in the history
  • Loading branch information
TheIndra55 committed Feb 11, 2024
1 parent 0916b4d commit 3a1a057
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/game/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,16 @@ int OBTABLE_GetObjectID(char* name)
auto addr = GET_ADDRESS(0x462590, 0x4660C0, 0x5BF770);

return Hooking::CallReturn<int>(addr, name);
}

void LOAD_ObjectFileName(char* name, char* object, char* extension)
{
return LOAD_UnitFileName(name, object, extension);
}

void LOAD_UnitFileName(char* name, char* unit, char* extension)
{
auto addr = GET_ADDRESS(0x45C730, 0x45F650, 0x477970);

return Hooking::Call(addr, name, unit, extension);
}
5 changes: 4 additions & 1 deletion src/game/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,7 @@ class Game
void GAMELOOP_RequestLevelChangeByName(char* name, GameTracker* gameTracker, int doneType);

void PLAYER_DebugSwitchPlayerCharacter();
int OBTABLE_GetObjectID(char* name);
int OBTABLE_GetObjectID(char* name);

void LOAD_ObjectFileName(char* name, char* object, char* extension);
void LOAD_UnitFileName(char* name, char* unit, char* extension);
9 changes: 9 additions & 0 deletions src/game/Player.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "Game.h"
#include "util/Hooking.h"

void IncrHealth(float amount)
{
auto addr = GET_ADDRESS(0x576CA0, 0x5715E0, 0x000000);

Hooking::Call(addr, amount);
}
36 changes: 36 additions & 0 deletions src/game/Player.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma once

struct TuneData;

struct GeneralAttributes
{
float height;
float crouchHeight;
float ankleUpperOffset;
float ankleLowerOffset;
float ankleLength;
float mass;
float leftFootLockHipLimitMin;
float leftFootLockHipLimitMax;
float rightFootLockHipLimitMin;
float rightFootLockHipLimitMax;
};

struct OldRazielData
{
char pad1[116];

float HealthInitial;
float LowHealth;
};

struct PlayerProp
{
unsigned int playerVersion;

TuneData* tuneData;
GeneralAttributes general;
OldRazielData oldData;
};

void IncrHealth(float amount);
15 changes: 15 additions & 0 deletions src/modules/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ void InstanceModule::OnMenu()
{
ImGui::MenuItem("Instances", nullptr, &m_show);

#ifdef TR8
if (ImGui::MenuItem("Unhide all"))
{
UnhideAll();
}
#endif

ImGui::EndMenu();
}
}
Expand Down Expand Up @@ -219,6 +226,14 @@ void InstanceModule::SkewTo(Instance* instance)
player->position = instance->position;
}

void InstanceModule::UnhideAll()
{
Instances::Iterate([](Instance* instance)
{
INSTANCE_Post(instance, 7, 0);
});
}

std::string InstanceModule::GetBinary(int value)
{
std::string binary;
Expand Down
1 change: 1 addition & 0 deletions src/modules/Instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class InstanceModule : public Module

void DrawInstance();
void SkewTo(Instance* instance);
void UnhideAll();

std::string GetBinary(int value);

Expand Down
17 changes: 14 additions & 3 deletions src/modules/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "render/Font.h"
#include "level/Event.h"
#include "input/Input.h"
#include "game/Player.h"

void MainMenu::OnDraw()
{
Expand All @@ -30,9 +31,20 @@ void MainMenu::OnDraw()
BirthObject(object);
}

#ifndef TR8
// Player
if (ImGui::CollapsingHeader("Player"))
{
// Fill 'er up
if (ImGui::Button("Fill 'er up"))
{
auto player = Game::GetPlayerInstance();
auto data = (PlayerProp*)player->data;

// TODO fill up ammo
IncrHealth(data->oldData.HealthInitial);
}

// Switch outfit
static char outfit[64] = "";
ImGui::InputText("Outfit", outfit, sizeof(outfit));
Expand All @@ -49,7 +61,6 @@ void MainMenu::OnDraw()
SwitchPlayerCharacter();
}

#ifndef TR8
// Player flags
auto flags = (unsigned int*)GET_ADDRESS(0x1075B88, 0x7C7C78, 0x000000);

Expand All @@ -65,8 +76,8 @@ void MainMenu::OnDraw()
*flags &= ~0x80;
}
}
#endif
}
#endif

// Time
if (ImGui::CollapsingHeader("Time"))
Expand All @@ -81,8 +92,8 @@ void MainMenu::OnDraw()
}
}

// Save
#ifndef TR8
// Save
if (ImGui::CollapsingHeader("Save"))
{
static int var = 0;
Expand Down

0 comments on commit 3a1a057

Please sign in to comment.