Advertisement
Zephiles

Cheat Engine TTYD PAL Table Script

Jun 17th, 2017
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.08 KB | None | 0 0
  1. --New entries are entered in the DTimer section near the bottom of the script
  2.  
  3. function cycleFullCompact() --Compact menu stuff 1
  4.   local state = not(compactmenuitem.Caption == 'Compact View Mode')
  5.   compactmenuitem.Caption = state and 'Compact View Mode' or 'Full View Mode'
  6.   getMainForm().Splitter1.Visible = state
  7.   getMainForm().Panel4.Visible = state
  8.   getMainForm().Panel5.Visible = state
  9. end
  10.  
  11. function addCompactMenu() --Compact menu stuff 2
  12.   if compactmenualreadyexists then return end
  13.   local parent = getMainForm().Menu.Items
  14.   compactmenuitem = createMenuItem(parent); parent.add(compactmenuitem)
  15.   compactmenuitem.Caption = 'Compact View Mode'
  16.   compactmenuitem.OnClick = cycleFullCompact
  17.   compactmenualreadyexists = 'yes'
  18. end
  19.  
  20. function newTimer(tempTI) --Create new timer -> newTimer(Timer interval in milliseconds)
  21.   local Timer = createTimer(nil, false)
  22.   Timer.Interval = tempTI
  23.   Timer.Enabled = true
  24.   return Timer
  25. end
  26.  
  27. function BitwiseAnd(w) --Change Pointer to Offset -> BitwiseAnd(Address)
  28.   w = ((w & 0xFF) << 24) | ((w & 0xFF00) << 8) | ((w & 0xFF0000) >> 8 ) | (w >> 24) --Change Little Endian to Big Endian
  29.   return w & 0x1FFFFFF
  30. end
  31.  
  32. function GetAddress(adr, AO, steps) --GetAddress(Address Offset, Additional Offset, Number of Steps)
  33.   local bit = 0
  34.   local s = 0
  35.   if StartAddress and (StartAddress ~= 0x1) then
  36.     adr = readInteger(StartAddress + adr)
  37.     if adr and (adr > 0x1) then
  38.       while s < (steps - 1) do
  39.         if adr and (adr > 0x1) then
  40.           bit = BitwiseAnd(adr)
  41.           adr = readInteger(StartAddress + bit + AO)
  42.         else
  43.           adr = 0x1
  44.         end
  45.       s = s + 1
  46.       end
  47.       if adr > 0x1 then
  48.         bit = BitwiseAnd(adr)
  49.         adr = StartAddress + bit
  50.       else
  51.         adr = 0x1
  52.       end
  53.     else
  54.       adr = 0x1
  55.     end
  56.   else
  57.     adr = 0x1
  58.   end
  59.   return adr
  60. end
  61.  
  62. function WriteSymbol(tempstring, value) --Register symbol -> WriteSymbol(Script Name, Address to write)
  63.   unregisterSymbol(tempstring)
  64.   registerSymbol(tempstring, value)
  65. end
  66.  
  67. function MakeNewEntry(tempSN, tempAdr, tempAdiOff, tempSteps) --Most important function single address -> MakeNewEntry(Script name, Address offset, Number of Steps)
  68.   local address = GetAddress(tempAdr, tempAdiOff, tempSteps)
  69.   WriteSymbol(tempSN, address)
  70.   Symbols[SC] = tempSN
  71.   SC = SC + 1
  72. end
  73.  
  74. function MakeNewEntryArray(tempSN, tempAdr, tempAddiOffOne, tempAddiOffTwo, tempAddToAdr, tempArySize, tempSteps) --Multiple addresses -> MakeNewEntryArray(Script name, Address offset, Additional offset one, Additional offset two, Offset to add to address each time, Amount of addresses to make, Number of Steps)
  75.   for i=1,tempArySize do
  76.     MakeNewEntry(tempSN .. i, tempAdr, tempAddiOffOne, tempSteps)
  77.     tempAdr = tempAdr + tempAddToAdr
  78.     tempAddiOffOne = tempAddiOffOne + tempAddiOffTwo
  79.   end
  80. end
  81.  
  82. if not CM then --Add compact menu and open Dolphin in Cheat Engine it not open already
  83.   addCompactMenu()
  84.  
  85.   --Open Dolphin in Cheat Engine if it's not already (Note: Makes script execution slightly slower)
  86.   if (getOpenedProcessID() ~= getProcessIDFromProcessName('Dolphin.exe')) and getProcessIDFromProcessName('Dolphin.exe') then
  87.     openProcess('Dolphin.exe')
  88.   end
  89.  
  90.   CM = 1
  91. end
  92.  
  93. --Calculate and set start of RAM
  94. if CalculateStart then --Destroy timer if it exists
  95.   object_destroy(CalculateStart)
  96.   CalculateStart = nil
  97. end
  98. CalculateStart = newTimer(5000) --Runs every 5 second(s)
  99. CalculateStart.OnTimer = function(timer)
  100.   if (not StartAddress) or (readString(StartAddress) ~= "G8MP01") or (not Start) then
  101.  
  102.     --Dolphin 5.0-3981+
  103.     StartAddress = readPointer("[[[[THREADSTACK0-0x228]+0xB8]+0x220]+0x280]+0x60") --Normal
  104.     if (StartAddress == nil) or (readString(StartAddress) ~= "G8MP01") then
  105.       StartAddress = readPointer("[[[[THREADSTACK0-0x9E0]+0x28]+0x268]+0x6B0]+0x50") --Debug
  106.     end
  107.    
  108.     if (StartAddress == nil) or (readString(StartAddress) ~= "G8MP01") then
  109.       if readInteger(0x7FFF0000) and (readString(0x7FFF0000) == "G8MP01") then
  110.         StartAddress = 0x7FFF0000
  111.       elseif readInteger(0x2580000000) and (readString(0x2580000000) == "G8MP01") then
  112.         StartAddress = 0x2580000000
  113.       elseif readInteger(0x180040000) and (readString(0x180040000) == "G8MP01") then
  114.         StartAddress = 0x180040000
  115.       elseif readInteger(0x180020000) and (readString(0x180020000) == "G8MP01") then
  116.         StartAddress = 0x180020000
  117.       elseif readInteger(0x1802C0000) and (readString(0x1802C0000) == "G8MP01") then
  118.         StartAddress = 0x1802C0000
  119.       else
  120.         StartAddress = nil
  121.       end
  122.     end
  123.    
  124.     if StartAddress ~= nil then
  125.       WriteSymbol("Start", StartAddress)
  126.     end
  127.    
  128.   end
  129. end
  130.  
  131. getMainForm().setCaption("TTYD PAL Table Version 1.851")
  132.  
  133. if SetTableData then --Destroy timer if it exists
  134.   object_destroy(SetTableData)
  135.   SetTableData = nil
  136. end
  137. if TD then --Destroy TD if it exists
  138.   object_destroy(TD)
  139.   TD = nil
  140. end
  141. SetTableData = newTimer(5000) --Runs every 5 second(s)
  142. SetTableData.OnTimer = function(timer)
  143.   if (StartAddress ~= nil) and ((not TD) or (tempStartAddress and (tempStartAddress ~= StartAddress))) then
  144.     getMainForm().fromAddress.text = string.format("%X",StartAddress)
  145.     getMainForm().toAddress.text = string.format("%X",StartAddress+0x1800000)
  146.     tempStartAddress = StartAddress
  147.     TD = 1
  148.   end
  149. end
  150.  
  151. if messageDialog("Do you want to run the additional Lua scripts for Dynamic Addresses?", mtConfirmation, mbYes, mbNo) == mrYes then
  152.   Input = "Y"
  153. else
  154.   Input = "N"
  155. end
  156.  
  157. if Input == "Y" then
  158.   if (not CG) or (CG == 0) then --Adjust Garbage Collection to be aggressive and fast enough to work properly
  159.     collectgarbage("setpause",120)
  160.     collectgarbage("setstepmul",400)
  161.     CG = 1
  162.   end
  163.  
  164.   if not Symbols then
  165.     Symbols = {}
  166.   end
  167.  
  168.   SC = 1
  169.  
  170.   if DTimer then --Destroy timer if it exists
  171.     object_destroy(DTimer)
  172.     DTimer = nil
  173.   end
  174.   DTimer = newTimer(1) --Runs every 1 millisecond(s)
  175.   DTimer.OnTimer = function(timer)
  176.     --MakeNewEntry(Script name, Address offset, Number of Steps)
  177.     --MakeNewEntryArray(Script name, Address offset, Additional offset one, Additional offset two, Offset to add to address each time, --Amount of addresses to make, Number of Steps)
  178.     MakeNewEntryArray("EnemyHPInScript", 0x42B4B0, 0x24, 0x4, 0x0, 10, 2)
  179.     MakeNewEntryArray("CurrentTextboxScript", 0x85BC28, 0x0, 0x0, 0x48, 7, 3)
  180.     MakeNewEntry("BattleAddressesScript", 0x42B4B0, 0x0, 1)
  181.     --MakeNewEntry("MenuCurserTextboxScript", 0xB72F5C, 0x0, 1)
  182.     --MakeNewEntry("CameraPointerScript", 0x3D5448, 0x0, 1)
  183.     --MakeNewEntry("FirstStrikeTextDisplayScript", 0xB408A8, 0x0, 1)
  184.     --Additional entries go here
  185.  
  186.     SC = 1
  187.   end
  188.  
  189. else
  190.   if DTimer then --Destroy timer if it exists
  191.     object_destroy(DTimer)
  192.     DTimer = nil
  193.   end
  194.  
  195.   if Symbols then --Register symbols with address 0x1
  196.     for i=1,#Symbols do
  197.       WriteSymbol(Symbols[i], 0x1)
  198.     end
  199.   end
  200.  
  201.   if CG and (CG == 1) then --Reset Garbage Collection to default values
  202.     collectgarbage("setpause",200)
  203.     collectgarbage("setstepmul",200)
  204.     CG = 0
  205.   end
  206. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement