Advertisement
RaYRoDTV

Add currency

Sep 13th, 2022
802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.28 KB | None | 0 0
  1. // =============================================================
  2.  
  3. // For Precompiled Headers
  4. #include <pch_Hack.h>
  5.  
  6. // For Hooking operations
  7. #include "Hooking.h"
  8.  
  9. // For Hardcoded Functions
  10. #include "ExeFunctions.h"
  11.  
  12. // For Accessing Base Addresses
  13. #include "BaseAddresses.h"
  14.  
  15. // For Accessing Hacks
  16. #include "MemoryHacks.h"
  17.  
  18. // =============================================================
  19.  
  20. namespace MemoryHacks {
  21.  
  22.     namespace {
  23.  
  24.         // using Directives
  25.         using namespace Multiverse::Hook;                             //  For Hooking operations
  26.         using namespace Multiverse::Api::Utils;                      //   For Generic Utils
  27.         using namespace Multiverse::Api::Memory::Utils;             //    For Generic Memory Utils
  28.         using namespace MemoryHacks;                               //     For Accessing Memory Hacks
  29.         using libMBIN::NMS::GameComponents::GcAudioWwiseEvents;   //      For AkEventEnum
  30.  
  31.         // --------------------------------
  32.  
  33.         // Description & Credits goes here:
  34.         void GenerateCreditsFile() {
  35.  
  36.             // Generate file once
  37.             if (static OneShot generateOnce; generateOnce) {
  38.  
  39.                 /// Generate description & credits file
  40.                 std::string filepath{ "..\\RaYRoD's Multiverse\\Hack Credits\\Add Currency.txt" };
  41.                 std::string description{ "A 'Template' for creating No Man's Sky game hacks with the Multiverse API. \n\n"
  42.                 "- Press Ctrl + Numpad Plus to add 1000 currency to your inventory." };
  43.                 std::string author{ "RaYRoD TV#7679" };
  44.                 Dependencies::CreateTxtAbout(filepath, description, author);
  45.             }
  46.         }
  47.  
  48.         // Your code goes here:
  49.         void ExecuteHack() {
  50.  
  51.             // Define Base Address & Relative Offsets
  52.             auto baseAddr{ BaseAddr::PlayerStateData };
  53.  
  54.             auto Units{ baseAddr + 0x1DC };
  55.             auto Nanites{ baseAddr + 0x1E0 };
  56.             auto QuickSilver{ baseAddr + 0x1E4 };
  57.  
  58.             // --------------------------------
  59.  
  60.               // Adds 1000 currency when user presses hotkey
  61.  
  62.             if (GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_ADD) & 1) {
  63.  
  64.                 if (Units)
  65.                     *(int*)Units += 1000;
  66.  
  67.                 if (Nanites)
  68.                     *(int*)Nanites += 1000;
  69.  
  70.                 if (QuickSilver)
  71.                     *(int*)QuickSilver += 1000;
  72.  
  73.                 // Trigger Audio Event
  74.                 ExeFunc::AudioWwiseEvent((int)GcAudioWwiseEvents::AkEventEnum::UI_UNITS_RECEIVED);
  75.                 ExeFunc::AudioWwiseEvent((int)GcAudioWwiseEvents::AkEventEnum::NOTIFY_UNITS_RECEIVED);
  76.  
  77.                 // Prints To Console:
  78.                 printf("1000 Units have been added! \n");
  79.                 printf("1000 Nanites have been added! \n");
  80.                 printf("1000 Quicksilver have been added! \n");
  81.             }
  82.         }
  83.     }
  84.  
  85.     void MemoryHacks::AddCurrency() {
  86.  
  87.         // Generate Credits File
  88.         GenerateCreditsFile();
  89.  
  90.         // Execute Hack if condition(s) are met
  91.         if (MVHookConditions::isProfileSelected && BaseAddr::PlayerStateData) {
  92.             ExecuteHack();
  93.         }
  94.     }
  95.  
  96.     // =============================================================
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement