Advertisement
HenryEx

BG3 CE Command Dumper

Sep 19th, 2023
4,911
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.53 KB | Source Code | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <CheatTable>
  3.   <CheatEntries>
  4.     <CheatEntry>
  5.       <ID>9999</ID>
  6.       <Description>"Dump Commands List"</Description>
  7.       <LastState/>
  8.       <VariableType>Auto Assembler Script</VariableType>
  9.       <AssemblerScript>[ENABLE]
  10. {$lua}
  11. if syntaxcheck then return end
  12. local commands = readPointer("cmdList")
  13. if not commands or commands == 0 then
  14.   print("please load a saved game first")
  15.   assert(false,"can't activate yet")
  16.   return
  17. end
  18. local size = readInteger(commands + 0x2C)
  19. if size &lt;= 0 then
  20.   print("please load a saved game first")
  21.   assert(false,"can't activate yet")
  22.   return
  23. elseif size &gt; 3000 then
  24.   size = 3000 -- just in case
  25. end
  26. commands = readPointer(commands + 0x20)
  27. if not commands or commands == 0 then
  28.   print("please load a saved game first")
  29.   assert(false,"can't activate yet")
  30.   return
  31. end
  32.  
  33. local paramtypes = {
  34.   "int",
  35.   nil,
  36.   "float",
  37.   "strVar",
  38.   "strObj",
  39.   "strChar",
  40.   "strItem"
  41. }
  42. local COMMAND_LIST = "Index;Command Name\n"
  43. --local COMMAND_LIST2 = "Index;Table Address;Cmd Address;Name;# of Arguments\n"
  44. for i = 1, size do
  45.   local addr = readPointer(commands)
  46.   if addr and addr ~= 0 then
  47.     local name = readPointer(addr + 0x08)
  48.     if name and name ~= 0 then
  49.       name = readString(name, 256, false)
  50.       if type(name) == "string" then
  51.         local self = readPointer(addr + 0x40)
  52.         local faddr = readPointer(addr + 0x48)
  53.         local numParam = readInteger(addr + 0x18)
  54.         local argtable = readPointer(addr + 0x10)
  55.         local cmdargs = ""
  56.         for j = 1, numParam do
  57.           local argcur = (j - 1) * 0x10 + argtable
  58.           local argname = readPointer(argcur)
  59.           local argtype = readInteger(argcur + 0x08)
  60.           local isResult = readInteger(argcur + 0x0C)
  61.           argtype = paramtypes[argtype] or "type"..tostring(argtype)
  62.           if isResult ~= 1 then cmdargs = cmdargs.."-&gt; " end
  63.           cmdargs = cmdargs..argtype.." "..readString(argname, 256, false)
  64.           if j ~= numParam then cmdargs = cmdargs..", " end
  65.         end
  66.         COMMAND_LIST = COMMAND_LIST..string.format("%d;%s ( %s )\n", i, name, cmdargs)
  67. --        COMMAND_LIST2 = COMMAND_LIST2..string.format("%d;%X;%X;%s;%d\n", i, commands, addr, name, numParam)
  68.       end
  69.     end
  70.   end
  71.   commands = commands + 0x08
  72. end
  73.  
  74. --print(COMMAND_LIST)
  75.  
  76. local file = io.output('bg3_commandslist.csv')
  77. io.write(COMMAND_LIST)
  78. io.close(file)
  79.  
  80. {$asm}
  81. [DISABLE]
  82.  
  83. </AssemblerScript>
  84.     </CheatEntry>
  85.   </CheatEntries>
  86. </CheatTable>
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement