Most likely I am doing it wrong, below is the code. Can anyone spot something?
NB: It works when I invoke the method using the mono dissect GUI and use the address I get from `readQword(body + inventoryOffset)`
Code: Select all
LaunchMonoDataCollector()
debugInstanceLookup = true
-- member offsets for RoR2.CharacterBody
local bodyOffset = 0x30
local inventoryOffset = 0x70
function getBody()
local charBody = mono_findClass('RoR2', 'CharacterBody')
local charController = mono_findClass('RoR2', 'PlayerCharacterMasterController')
print(("found controller at %x"):format(charController))
local maybeControllerEntities = mono_class_findInstancesOfClassListOnly('RoR2', charController)
local maybeBodyEntities = mono_class_findInstancesOfClassListOnly('RoR2', charBody)
for k,v in ipairs(maybeControllerEntities) do
local body = readQword(v + bodyOffset)
for x,maybeBody in ipairs(maybeBodyEntities) do
if(body == maybeBody) then -- controller body matches the body entity. that's a bingo
print(("found body at %x"):format(body))
return body
end
end
end
end
local body = getBody()
local inventory = readQword(body + inventoryOffset)
print(("Inventory %x"):format(inventory))
-- local giveItem = mono_class_findMethod(inventory, 'GiveItem')
local giveRandomItems = mono_class_findMethod(inventory, 'GiveRandomItems')
mono_invoke_method('', giveRandomItems, inventory, {{type=int, value=10}})
For example `GiveItem` exists twice in the `Inventory` objects. One expects an item and the other an item index.
Last question, how to get the function signatures in LUA via the monopipe? Thanks!
PS: Not sure whether this is even a good idea how to get the address I need or if I am overcomplicating things. Please feel free to let me know if I should do things differently, cheers.