Advertisement
Guest User

Gargoyles Genesis TAS HUD script

a guest
Sep 12th, 2011
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.98 KB | None | 0 0
  1. -- initialization code (if any) goes here
  2.  
  3. gens.registerafter( function()
  4.  
  5.   -- draw code
  6.  
  7.   local spritesenabled
  8.   local actorsenabled
  9.  
  10.   local playerx, playery
  11.   local actorcount
  12.   local actorindex
  13.   local actormemory
  14.   local actorx, actory
  15.   local actorwidth, actorheight
  16.   local actorscreenx, actorscreeny
  17.   local actorspritedata
  18.   local actorhealth
  19.   local actoralive
  20.   local camerax, cameray
  21.   local boxcolor
  22.   local boxopacity
  23.   local bordercolor
  24.  
  25.   -- enable/disable features
  26.  
  27.   spritesenabled = 1
  28.   actorsenabled = 1
  29.  
  30.   -- init
  31.  
  32.   actorcount = 64  -- memory.readbyte(0xFF3FFB)
  33.   camerax = memory.readword(0xFF010C)
  34.   cameray = memory.readword(0xFF010E)
  35.   playerx = memory.readword(0xFF0106)
  36.   playery = memory.readword(0xFF0108)
  37.  
  38.   -- exit if not valid actor count (title screen, etc)
  39.  
  40.   if (actorcount == 255) then
  41.     return 0
  42.   end
  43.  
  44.  
  45.   actorindex = 0
  46.  
  47.   -- hitbox total
  48.  
  49.   actorcount = 200
  50.  
  51.   -- draw hitboxes
  52.  
  53.   while (actorindex < actorcount and actorsenabled == 1) do
  54.     actormemory = 0xFF0E72 + (actorindex * 8)
  55.     actorx = memory.readword(actormemory + 0x00)
  56.     actory = memory.readword(actormemory + 0x02)
  57.  
  58.     if (actorindex == 124) then
  59.       -- player
  60.       boxcolor = 0x00FF0044
  61.       bordercolor = 0x00FF0088
  62.     elseif (actorindex == 126) then
  63.       -- player attack
  64.       boxcolor = 0x00000000
  65.       bordercolor = 0xFFFFFFFF
  66.     elseif (actorindex > 126) then
  67.       -- projectiles, stuff that hurts
  68.       boxcolor = 0x00000088
  69.       bordercolor = 0xFF0000FF
  70.     else
  71.       boxcolor = 0xFF00FF33
  72.       bordercolor = 0xFF00FF55
  73.     end
  74.  
  75.  
  76.     if (actorx < 0x7FFF and actory < 0x7FFF) then
  77.       actorwidth = memory.readword(actormemory + 0x04) - actorx
  78.       actorheight = memory.readword(actormemory + 0x06) - actory
  79.       actorscreenx = actorx - (camerax + 16)
  80.       actorscreeny = actory - (cameray + 16)
  81.  
  82.       gui.box(actorscreenx, actorscreeny, actorscreenx + actorwidth, actorscreeny + actorheight, boxcolor, bordercolor)
  83.  
  84.       if (actorscreenx >= 0) and (actorscreenx < 320) and (actorscreeny >= 0) and (actorscreeny < 224) then
  85.         -- gui.text(actorscreenx, (actorscreeny+actorheight)-6, actorindex, 0xFFFF00CC,0x000000CC)
  86.       end
  87.     end
  88.  
  89.     actorindex = actorindex + 1
  90.   end
  91.  
  92.   actorindex = 0
  93.  
  94.   -- box color
  95.  
  96.   boxcolor = 0xFFFFFF00
  97.  
  98.   -- hitbox opacity
  99.  
  100.   boxopacity = 96
  101.  
  102.   -- draw actor info
  103.  
  104.   while (actorindex < actorcount and spritesenabled == 1) do
  105.  
  106.     -- actor data offset
  107.  
  108.     actormemory = 0xFF1076 + (actorindex * 128)
  109.  
  110.     -- get actor sprite data
  111.  
  112.     actorspritedata = memory.readdword(actormemory + 0x38)
  113.  
  114.     -- get actor dimensions
  115.  
  116.     -- actorwidth = -memory.readwordsigned(actorspritedata+2)
  117.     -- actorheight = -memory.readwordsigned(actorspritedata+4)
  118.  
  119.     -- get actor coords
  120.  
  121.     actorx = memory.readword(actormemory + 0x00)
  122.     actory = memory.readword(actormemory + 0x02)
  123.     actorscreenx = (actorx - (camerax + 16)) -- + (actorwidth/2)
  124.     actorscreeny = actory - (cameray + 16)
  125.     actorhealth = memory.readword(actormemory + 0x50)
  126.     actoralive = (memory.readword(actormemory + 0x5E) > 0) or (memory.readword(actormemory + 0x22) > 0) or (memory.readword(actormemory + 0x48) > 0)
  127.  
  128.     -- only draw text if actor is on screen
  129.     if (actorscreenx >= 0) and (actorscreenx < 320) and (actorscreeny >= 0) and (actorscreeny < 224) and (actoralive) then
  130.  
  131.       if (actorhealth > 0) then
  132.         gui.text((actorx-camerax)-16, (actory-cameray)-24, actorhealth, 0x00FFFFFF, clear)
  133.       end
  134.     end
  135.  
  136.     -- post
  137.  
  138.     actorindex = actorindex + 1
  139.   end
  140.  
  141.  
  142.   -- useful info
  143.   gui.text(145,203,"HP  " .. memory.readword(0xFF2CC6), 0xFFFF00FF, clear)
  144.   gui.text(145,209,"IV  " .. memory.readword(0xFF16D2), 0xFFFF00FF, clear)
  145.   gui.text(145,215,"RUN " .. memory.readbyte(0xFF1699), 0xFFFF00FF, clear)
  146.   gui.text(10,0,"XY  " .. playerx .. ", " .. playery, 0xFFFFFFFF, clear)
  147.   return 0
  148.  
  149. end)
  150.  
  151. gens.registerexit( function()
  152.   -- cleanup code (if any) goes here
  153. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement