diff --git a/CMakeLists.txt b/CMakeLists.txt index d3e4d5a..9040703 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.8) -project("HitmanAbsolutionSDK" C CXX) +project("HitmanAbsolutionSDK" CXX) set(CMAKE_CXX_STANDARD 23) set(GAME_INSTALL_PATH "" CACHE PATH "Path of Hitman Absolution folder.") @@ -25,7 +25,9 @@ set(MODS Editor Noclip HUD + HUDPersist Camera + LevelTimer ) foreach(MOD IN LISTS MODS) diff --git a/HitmanAbsolutionSDK/include/Glacier/UI/EHUDItem.h b/HitmanAbsolutionSDK/include/Glacier/UI/EHUDItem.h index edad06f..9ec4e17 100644 --- a/HitmanAbsolutionSDK/include/Glacier/UI/EHUDItem.h +++ b/HitmanAbsolutionSDK/include/Glacier/UI/EHUDItem.h @@ -16,5 +16,15 @@ enum EHUDItem HUD_ITEM_DARE_TIMER = 11, HUD_ITEM_PROFILE_DATA = 12, HUD_ITEM_DEBUGLOG = 13, - HUD_ITEM_NUM = 14 + HUD_ITEM_SCORE_INFO_MESSAGE = 14, + HUD_ITEM_RATING_TRACKER = 15, + HUD_ITEM_UNKNOWN_1 = 16, + HUD_ITEM_TARGET_TRACKER = 17, + HUD_ITEM_UNKNOWN_2 = 18, + HUD_ITEM_UNKNOWN_3 = 19, + HUD_ITEM_HEALTH_BAR = 20, + HUD_ITEM_OBJECTIVE_MESSAGE = 21, + HUD_ITEM_ITEM_HOTBAR = 22, + HUD_ITEM_NUM = 23, + }; diff --git a/Mods/HUDPersist/CMakeLists.txt b/Mods/HUDPersist/CMakeLists.txt new file mode 100644 index 0000000..c01a599 --- /dev/null +++ b/Mods/HUDPersist/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.8) + +file(GLOB_RECURSE HEADER_FILES + CONFIGURE_DEPENDS + include/*.h +) + +file(GLOB_RECURSE SRC_FILES + CONFIGURE_DEPENDS + src/*.cpp + src/*.c +) + +add_library(HUDPersist SHARED + ${HEADER_FILES} + ${SRC_FILES} +) + +target_include_directories(HUDPersist PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/include +) + +target_link_libraries(HUDPersist PRIVATE + HitmanAbsolutionSDK +) + +install(TARGETS HUDPersist + RUNTIME DESTINATION bin/mods +) diff --git a/Mods/HUDPersist/include/HUDPersist.h b/Mods/HUDPersist/include/HUDPersist.h new file mode 100644 index 0000000..1ad9a3c --- /dev/null +++ b/Mods/HUDPersist/include/HUDPersist.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +#include + +class HUDPersist : public ModInterface +{ +public: + HUDPersist(); + ~HUDPersist(); + + void OnEngineInitialized() override; + void OnDrawMenu() override; + +private: + void OnFrameUpdate(const SGameUpdateEvent& updateEvent); + + bool isHUDPersistEnabled; +}; + +DECLARE_MOD(HUDPersist) diff --git a/Mods/HUDPersist/src/HUDPersist.cpp b/Mods/HUDPersist/src/HUDPersist.cpp new file mode 100644 index 0000000..1df4923 --- /dev/null +++ b/Mods/HUDPersist/src/HUDPersist.cpp @@ -0,0 +1,56 @@ +#include + +#include "imgui.h" + +#include "Glacier/ZGameLoopManager.h" +#include "Glacier/ZLevelManager.h" +#include "Glacier/UI/ZHUDManager.h" +#include "Glacier/UI/EHUDFadeReason.h" +#include "Glacier/Player/ZHitman5.h" + +#include "Hooks.h" +#include "HUDPersist.h" + +// Bitmask covering all HUD_ITEM_NUM elements +static constexpr unsigned int ALL_HUD_ELEMENTS = (1u << HUD_ITEM_NUM) - 1; + +HUDPersist::HUDPersist() : + isHUDPersistEnabled(true) +{ +} + +HUDPersist::~HUDPersist() +{ + const ZMemberDelegate delegate(this, &HUDPersist::OnFrameUpdate); + + GameLoopManager->UnregisterForFrameUpdate(delegate); +} + +void HUDPersist::OnEngineInitialized() +{ + const ZMemberDelegate delegate(this, &HUDPersist::OnFrameUpdate); + + GameLoopManager->RegisterForFrameUpdate(delegate, 1); +} + +void HUDPersist::OnDrawMenu() +{ + ImGui::Checkbox(ICON_MD_SELF_IMPROVEMENT " HUD Persist", &isHUDPersistEnabled); +} + +void HUDPersist::OnFrameUpdate(const SGameUpdateEvent& updateEvent) +{ + ZHitman5* hitman = LevelManager->GetHitman().GetRawPointer(); + + if (!isHUDPersistEnabled || !hitman) + { + return; + } + + for (int reason = 0; reason < HUD_FADE_REASON_NUM; ++reason) + { + HUDManager->FadeHUDElements(ALL_HUD_ELEMENTS, static_cast(reason), true, 0.0f); + } +} + +DEFINE_MOD(HUDPersist); diff --git a/Mods/LevelTimer/CMakeLists.txt b/Mods/LevelTimer/CMakeLists.txt new file mode 100644 index 0000000..5b88a45 --- /dev/null +++ b/Mods/LevelTimer/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.8) + +file(GLOB_RECURSE HEADER_FILES + CONFIGURE_DEPENDS + include/*.h +) + +file(GLOB_RECURSE SRC_FILES + CONFIGURE_DEPENDS + src/*.cpp + src/*.c +) + +add_library(LevelTimer SHARED + ${HEADER_FILES} + ${SRC_FILES} +) + +target_include_directories(LevelTimer PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/include +) + +target_link_libraries(LevelTimer PRIVATE + HitmanAbsolutionSDK +) + +install(TARGETS LevelTimer + RUNTIME DESTINATION bin/mods +) diff --git a/Mods/LevelTimer/include/LevelTimer.h b/Mods/LevelTimer/include/LevelTimer.h new file mode 100644 index 0000000..65fbfdb --- /dev/null +++ b/Mods/LevelTimer/include/LevelTimer.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include +#include + +void __fastcall ZEntitySceneContext_CreateSceneHook(ZEntitySceneContext* pThis, int edx, const ZString& sStreamingState); +void __fastcall ZEntitySceneContext_ClearSceneHook(ZEntitySceneContext* pThis, int edx, bool bFullyUnloadScene); + +class LevelTimer : public ModInterface +{ +public: + LevelTimer(); + ~LevelTimer(); + + void Initialize() override; + void OnEngineInitialized() override; + void OnDrawMenu() override; + void OnDrawUI(bool hasFocus) override; + + void OnCreateScene(ZEntitySceneContext* entitySceneContext, const ZString& streamingState); + void OnClearScene(ZEntitySceneContext* entitySceneContext, bool fullyUnloadScene); + +private: + void OnFrameUpdate(const SGameUpdateEvent& updateEvent); + + float m_elapsedSeconds; + bool isLevelTimerEnabled; +}; + +DECLARE_MOD(LevelTimer) \ No newline at end of file diff --git a/Mods/LevelTimer/src/LevelTimer.cpp b/Mods/LevelTimer/src/LevelTimer.cpp new file mode 100644 index 0000000..71c1395 --- /dev/null +++ b/Mods/LevelTimer/src/LevelTimer.cpp @@ -0,0 +1,91 @@ +#include + +#include "imgui.h" +#include "Glacier/ZGameLoopManager.h" +#include "Glacier/ZLevelManager.h" +#include "Glacier/UI/ZHUDManager.h" + +#include "Hooks.h" +#include "LevelTimer.h" + +LevelTimer::LevelTimer() : m_elapsedSeconds(0.f), isLevelTimerEnabled(true) {} + +LevelTimer::~LevelTimer() +{ + const ZMemberDelegate delegate(this, &LevelTimer::OnFrameUpdate); + GameLoopManager->UnregisterForFrameUpdate(delegate); + + Hooks::ZEntitySceneContext_CreateScene.RemoveHook(); + Hooks::ZEntitySceneContext_ClearScene.RemoveHook(); +} + +void LevelTimer::Initialize() +{ + ModInterface::Initialize(); + + Hooks::ZEntitySceneContext_CreateScene.CreateHook("ZEntitySceneContext::CreateScene", 0x4479E0, ZEntitySceneContext_CreateSceneHook); + Hooks::ZEntitySceneContext_ClearScene.CreateHook("ZEntitySceneContext::ClearScene", 0x265A80, ZEntitySceneContext_ClearSceneHook); + + Hooks::ZEntitySceneContext_CreateScene.EnableHook(); + Hooks::ZEntitySceneContext_ClearScene.EnableHook(); +} + +void LevelTimer::OnEngineInitialized() +{ + const ZMemberDelegate delegate(this, &LevelTimer::OnFrameUpdate); + GameLoopManager->RegisterForFrameUpdate(delegate, 1); +} + +void LevelTimer::OnFrameUpdate(const SGameUpdateEvent& updateEvent) +{ + m_elapsedSeconds += static_cast(updateEvent.m_GameTimeDelta.ToSeconds()); +} + +void LevelTimer::OnCreateScene(ZEntitySceneContext* entitySceneContext, const ZString& streamingState) +{ + m_elapsedSeconds = 0.f; +} + +void LevelTimer::OnClearScene(ZEntitySceneContext* entitySceneContext, bool fullyUnloadScene) +{ +} + +void LevelTimer::OnDrawMenu() +{ + ImGui::Checkbox(ICON_MD_SELF_IMPROVEMENT " Level timer", &isLevelTimerEnabled); +} + +void LevelTimer::OnDrawUI(bool hasFocus) +{ + ZHitman5* hitman = LevelManager->GetHitman().GetRawPointer(); + bool isPaused = HUDManager->IsPauseMenuActive(); + + if (!isLevelTimerEnabled || !hitman || isPaused) + { + return; + } + + int minutes = static_cast(m_elapsedSeconds) / 60; + int seconds = static_cast(m_elapsedSeconds) % 60; + + auto& io = ImGui::GetIO(); + ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.25f, io.DisplaySize.y * 0.012f), ImGuiCond_Always); + ImGui::Begin("Timer", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoBackground); + ImGui::SetWindowFontScale(3.5f); + ImGui::Text("%02d:%02d", minutes, seconds); + ImGui::End(); +} + +DEFINE_MOD(LevelTimer) + +void __fastcall ZEntitySceneContext_CreateSceneHook(ZEntitySceneContext* pThis, int edx, const ZString& sStreamingState) +{ + GetModInstance()->OnCreateScene(pThis, sStreamingState); + Hooks::ZEntitySceneContext_CreateScene.CallOriginalFunction(pThis, sStreamingState); +} + +void __fastcall ZEntitySceneContext_ClearSceneHook(ZEntitySceneContext* pThis, int edx, bool bFullyUnloadScene) +{ + GetModInstance()->OnClearScene(pThis, bFullyUnloadScene); + Hooks::ZEntitySceneContext_ClearScene.CallOriginalFunction(pThis, bFullyUnloadScene); +} \ No newline at end of file diff --git a/README.md b/README.md index eb49f97..f136d10 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # HitmanAbsolutionSDK - SDK for Hitman Absolution + +SDK for Hitman Absolution @@ -8,18 +9,22 @@ ![HMA_POST](https://github.com/user-attachments/assets/0bfcc67d-f588-4b8a-98c8-f5108a2e4bcb) ## Install + Extract the content of the `AbsolutionSDK-Release.zip` archive to `:\Program Files (x86)\Steam\steamapps\common\Hitman Absolution` image ## Usage + Open SDK menu by pressing `~` key ## Contracts Mode + To use SDK with [Hitman-5-Server](https://github.com/LennardF1989/Hitman-5-Server) add `ConsoleCmd WebServiceUrl http://localhost:40147/hm5` below `[application]` in HMA.ini \ Port should match port specified in appsettings.json for HM5.Server ## Mods + ![image](https://github.com/user-attachments/assets/9ad1b04b-90da-4f3b-9a0b-d198c1c16fd0) The SDK includes 9 mods which can be activated or deactivated at any time depending on the purpose. Some of them like Freecamera and HUD have a specific key for activation or deactivation. @@ -27,99 +32,112 @@ To enable or disable one or many mods, click on `MODS` in the SDK bar. Check and ![image](https://github.com/user-attachments/assets/01b7624f-2fcd-4357-89e0-e40d301c5ae4) ### Actors + Displays all actors and has options to equip model of actors, teleport actor to hitman, teleport hitman to actor, add weapon to inventory of actor and teleport all actors to hitman.

![image](https://github.com/user-attachments/assets/a47b3fd8-7815-4547-bdd5-908c62170ab8) ### Camera + Change FOV and toggle LUT and Vignette effects.

![image](https://github.com/user-attachments/assets/c486b511-0474-4ac9-8a03-943829a4c2ed) Before disabling LUT and FOV change ![image](https://github.com/user-attachments/assets/1ff8f9ac-bc1b-418d-9f6f-85d948a0182a) +

-After disabling LUT +After disabling LUT ![image](https://github.com/user-attachments/assets/70b34a57-b5fd-4ee0-8c96-802af886d24c) +

FOV Change ![image](https://github.com/user-attachments/assets/1cf859ee-8843-4749-a50f-d01088311e78) - ### Editor + Displays tree with entities of scene and it can be used to modify properties and trigger input/output pins.

![image](https://github.com/user-attachments/assets/efd5a54f-3060-47eb-be82-5fb6a8e6e76b) ### HUD + Toggle HUD and all HUD items.

![image](https://github.com/user-attachments/assets/40d6ec87-cab2-449b-acea-e4df94af016f) +### HUDPersist + +Prevent HUD elements from fading out when using Instinct.

+ ### Items + Displays all items and has option to teleport all items to hitman.

![image](https://github.com/user-attachments/assets/68f62784-3151-4494-b464-2aa0fa646c2d) ### Player + It has tab for cheats(god mode, invisibility, infinite ammo, refill focus), tab for equping disguise/model of specified actors, tabs for spawning specified weapon/item/prop to world/inventory and tab for spawning actor. ![image](https://github.com/user-attachments/assets/9ad3d39a-97d6-4036-85ca-bf4759850534) ### StartingOutfitAndWeaponModifier + Sets starting outfit and weapon.

![image](https://github.com/user-attachments/assets/77ae42a8-d34f-4d79-aa8a-a2632c2788a5) ### NoClip + Make player fly. ### FreeCamera + Adds support for free camera. ## Configuration ### General Settings + `Read HMA.ini` is used to re-activate the contract feature in the game.

`Patch Resources` is used for installing modified files.

`Pause On Focus Loss` will pause the game at ALT-TAB. Uncheck this is you want to switch windows without pause. Usefull option for screenshooting.

The last option will minimize the game to the task bar.

![image](https://github.com/user-attachments/assets/b9c25952-6a79-484a-815f-1d2d9e92f267) - ### Mods Configuration + Mods like `FreeCamera`, `HUD`, `NoClip` and `Player` have a configurable `.ini` file in which you can change the key bindings at wish. Files are located in `.\steamapps\common\Hitman Absolution\mod` Accepted bindigs can be found in [THIS FILE](https://github.com/user-attachments/files/18822180/keys.txt). ## Controls -|Key | Description| -| -------- | ----------- | -|**Free Camera**|| -|K | Enable/Disable Free Camera| -|B+R | Increase/Decrease Camera Speed| -|LS | Forward/Backward/Left/Right| -|RS | Pan/Tilt| -|A+LS | Roll Camera| -|Y+LS | Change FOV| -|LB | Lock Camera and Enable 47 Input| -|RT (HOLD) | Faster Camera Movements| -|LT+RS | Camera Lift Up/Down| -|A+LS (Press)| Reset Roll| -|F9 | Kill NPC| -|CTRL+F9| Teleport 47 To Camera| -|F10 | Pause/Unpause Game and Activate/Deactivate Free Camera| -|F11 | Pause/Unpause Game| -| | | -|**HUD**| | -|F8 |Enable/Disable HUD| -| | | -|**No Clip**| | -|N |Enable/Disable No Clip| -| | | -|**Player** | | -|I |Get Outfit| -|O |Get Model| -|P | Change Outfit| -|J |Teleport Hitman| - - +| Key | Description | +| --------------- | ------------------------------------------------------ | +| **Free Camera** | | +| K | Enable/Disable Free Camera | +| B+R | Increase/Decrease Camera Speed | +| LS | Forward/Backward/Left/Right | +| RS | Pan/Tilt | +| A+LS | Roll Camera | +| Y+LS | Change FOV | +| LB | Lock Camera and Enable 47 Input | +| RT (HOLD) | Faster Camera Movements | +| LT+RS | Camera Lift Up/Down | +| A+LS (Press) | Reset Roll | +| F9 | Kill NPC | +| CTRL+F9 | Teleport 47 To Camera | +| F10 | Pause/Unpause Game and Activate/Deactivate Free Camera | +| F11 | Pause/Unpause Game | +| | | +| **HUD** | | +| F8 | Enable/Disable HUD | +| | | +| **No Clip** | | +| N | Enable/Disable No Clip | +| | | +| **Player** | | +| I | Get Outfit | +| O | Get Model | +| P | Change Outfit | +| J | Teleport Hitman |