Skip to content

Commit

Permalink
added; removeItem, removeWeapon
Browse files Browse the repository at this point in the history
  • Loading branch information
Asiern committed Feb 4, 2021
1 parent 2bdf400 commit 5ed5a0d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ You can find all the used IDs and offsets [here](https://docs.google.com/spreads
- `IgnoreUpgradeMaterials` - enables or disables Ignore Upgrade Materials
- `setGameSpeed` - sets game speed
- `addItem` - Adds a specific quantity of items to the inventory (See item IDs at [Memory Reference](#memory-reference))
- `removeItem` -Removes item from memory (See item IDs at [Memory Reference](#memory-reference))
- `addWeapon` - Adds a weapon to the inventory (See weapon IDs at [Memory Reference](#memory-reference))
- `removeWeapon` - removes a weapon from the inventory (See weapon IDs at [Memory Reference](#memory-reference))
- `setHUDOpacity` - sets the opacity of the HUD
- `setColor` - sets RGBColor combination
47 changes: 47 additions & 0 deletions Source/ConsoleApplication1/NierHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,31 @@ bool NieRHook::addItem(int ID, int number)
CloseHandle(pHandle);
}

bool NieRHook::removeItem(int ID)
{
HANDLE pHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, this->_pID);
uintptr_t Address = this->_baseAddress + 0x197C4C4;
unsigned int currentID;
int emptySlotID = 0xffffffff;
if (!this->_hooked)
{
//Not hooked return
return false;
}
while (Address <= this->_baseAddress + 0x197CE18)
{
ReadProcessMemory(pHandle, (LPVOID)Address, &currentID, sizeof(currentID), NULL);
if (ID == currentID) //Item found
{
//Remove item from memory //Item found on memory
WriteProcessMemory(pHandle, (LPVOID)(Address), &emptySlotID, sizeof(emptySlotID), NULL); //Set level
return true;
}
Address += 0xC; //Go to the next slot
}
return false;
}

/*
Add weapon to memory by ID
returns: true if successful and false if not
Expand Down Expand Up @@ -361,6 +386,28 @@ bool NieRHook::addWeapon(int ID, int level)
CloseHandle(pHandle);
}

bool NieRHook::removeWeapon(int ID)
{
HANDLE pHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, this->_pID);
uintptr_t Address = this->_baseAddress + 0x197DCC4;
uintptr_t emptySlotID = 0xffffffff;
unsigned int currentID;
if (!this->_hooked)
{
return false; //Return if not hooked
}
while (Address <= this->_baseAddress + 0x197DFBC)
{
ReadProcessMemory(pHandle, (LPVOID)Address, &currentID, sizeof(currentID), NULL);
if (ID == currentID)
{ //Weapon found on memory
WriteProcessMemory(pHandle, (LPVOID)(Address), &emptySlotID, sizeof(emptySlotID), NULL); //Set level
return true;
}
Address += 0x14; //Go to the next slot
}
}

void NieRHook::setHUDOpacity(float opacity)
{
HANDLE pHandle = OpenProcess(PROCESS_ALL_ACCESS, NULL, this->_pID);
Expand Down
2 changes: 2 additions & 0 deletions Source/ConsoleApplication1/NierHook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ class NieRHook

//Inventory
bool addItem(int ID, int number);
bool removeItem(int ID);
bool addWeapon(int ID, int level);
bool removeWeapon(int ID);

//Misc
void setHUDOpacity(float opacity);
Expand Down

0 comments on commit 5ed5a0d

Please sign in to comment.