HenryEx icon

BG3 CE Command Dumper

HenryEx | PRO | 09/19/23 02:47:09 PM UTC | 0 ⭐ | 5732 👁️ | Never ⏰ | []
Lua |

2.53 KB

|

Source Code

|

0 👍

/

0 👎

<?xml version="1.0" encoding="utf-8"?>
<CheatTable>
  <CheatEntries>
    <CheatEntry>
      <ID>9999</ID>
      <Description>"Dump Commands List"</Description>
      <LastState/>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
{$lua}
if syntaxcheck then return end
local commands = readPointer("cmdList")
if not commands or commands == 0 then
  print("please load a saved game first")
  assert(false,"can't activate yet")
  return
end
local size = readInteger(commands + 0x2C)
if size &lt;= 0 then
  print("please load a saved game first")
  assert(false,"can't activate yet")
  return
elseif size &gt; 3000 then
  size = 3000 -- just in case
end
commands = readPointer(commands + 0x20)
if not commands or commands == 0 then
  print("please load a saved game first")
  assert(false,"can't activate yet")
  return
end
 
local paramtypes = {
  "int",
  nil,
  "float",
  "strVar",
  "strObj",
  "strChar",
  "strItem"
}
local COMMAND_LIST = "Index;Command Name\n"
--local COMMAND_LIST2 = "Index;Table Address;Cmd Address;Name;# of Arguments\n"
for i = 1, size do
  local addr = readPointer(commands)
  if addr and addr ~= 0 then
    local name = readPointer(addr + 0x08)
    if name and name ~= 0 then
      name = readString(name, 256, false)
      if type(name) == "string" then
        local self = readPointer(addr + 0x40)
        local faddr = readPointer(addr + 0x48)
        local numParam = readInteger(addr + 0x18)
        local argtable = readPointer(addr + 0x10)
        local cmdargs = ""
        for j = 1, numParam do
          local argcur = (j - 1) * 0x10 + argtable
          local argname = readPointer(argcur)
          local argtype = readInteger(argcur + 0x08)
          local isResult = readInteger(argcur + 0x0C)
          argtype = paramtypes[argtype] or "type"..tostring(argtype)
          if isResult ~= 1 then cmdargs = cmdargs.."-&gt; " end
          cmdargs = cmdargs..argtype.." "..readString(argname, 256, false)
          if j ~= numParam then cmdargs = cmdargs..", " end
        end
        COMMAND_LIST = COMMAND_LIST..string.format("%d;%s ( %s )\n", i, name, cmdargs)
--        COMMAND_LIST2 = COMMAND_LIST2..string.format("%d;%X;%X;%s;%d\n", i, commands, addr, name, numParam)
      end
    end
  end
  commands = commands + 0x08
end
 
--print(COMMAND_LIST)
 
local file = io.output('bg3_commandslist.csv')
io.write(COMMAND_LIST)
io.close(file)
 
{$asm}
[DISABLE]
 
</AssemblerScript>
    </CheatEntry>
  </CheatEntries>
</CheatTable>
 

Comments