Guest User

Re: FCEU emulator info display for Snake's Revenge game

a guest
Jun 5th, 2014
100
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[lua script for fceu 0.98-28 or fceux
  2. purpose: display enemy HP, bomb timers, hostage count, and body count for Snake's Revenge NES game
  3. written by Dammit 7/24/2008; last edited 8/25/2008]]
  4.  
  5. local nudge = {}
  6.   nudge.y = 0x18
  7.   nudge.x = 0x08
  8. local waitperiod = 3
  9. local incontrol = waitperiod
  10. local status = 0
  11. local bodycount = 0
  12. local underflow = 240
  13. local bomb = {}
  14. local enemy = {}
  15. for i = 0, 4 do
  16.   enemy[i] = {}
  17.   enemy[i].hpold = 0
  18. end
  19.  
  20. local function checkstatus()
  21.   for i = 0, 4 do
  22.     enemy[i].corpse = memory.readbyte(0x40c+0x1*i)
  23.     enemy[i].y = memory.readbyte(0x47a+0x1*i)
  24.     enemy[i].x = memory.readbyte(0x490+0x1*i)
  25.     enemy[i].hpnew = memory.readbyte(0x5cd+0x1*i)
  26.   end
  27.   status = memory.readbyte(0x34)
  28. end
  29.  
  30. local function hostagecount()
  31.   local hostage = memory.readbyte(0x438)
  32.   if hostage==204 or hostage==222 then
  33.     local rescues = memory.readbyte(0x6e)
  34.     gui.text(enemy[0].x-4*nudge.x,enemy[0].y-nudge.y,"HOSTAGES: "..rescues)
  35.   end
  36. end
  37.  
  38. local function bombtimer()
  39.   bomb.laid = memory.readbyte(0x42d)
  40.   bomb.x = memory.readbyte(0x485)
  41.   bomb.y = memory.readbyte(0x46f)
  42.   bomb.time = memory.readbyte(0x574)
  43. -- draw bomb time only if there's a bomb
  44.   if status==3 and bomb.laid==14 then gui.text(bomb.x,bomb.y,bomb.time) end
  45.   if status==14 and bomb.laid==8 then gui.text(bomb.x,bomb.y,bomb.time) end
  46. end
  47.  
  48. local function enemyhp()
  49.   for i = 0, 4 do
  50. -- draw HP only if the enemy is alive
  51.     if enemy[i].corpse~=0 and enemy[i].hpnew>0 then
  52. -- offset the drawn text, but only if it will stay in bounds
  53.       if enemy[i].y>=nudge.y then enemy[i].y = enemy[i].y-nudge.y end
  54.       if enemy[i].x>=nudge.y then enemy[i].x = enemy[i].x-nudge.x end
  55.       gui.text(enemy[i].x,enemy[i].y,enemy[i].hpnew)
  56.     end
  57.   end
  58. end
  59.  
  60. local function killcounter()
  61.   for i = 0, 4 do
  62.     if enemy[i].hpnew < 1 or enemy[i].hpnew > underflow then
  63.       if enemy[i].hpold > 0 and enemy[i].hpold < underflow then
  64. --inanimate objects don't count
  65.         if enemy[i].corpse ~= 96 and enemy[i].corpse ~= 102 and enemy[i].corpse ~= 226 then
  66.           bodycount = bodycount+1
  67.         end
  68.       end
  69.     end
  70.   end
  71. end
  72.  
  73. local function drawdata()
  74.   checkstatus()
  75. --draw these only during the action
  76.   if status==3 or status==14 then
  77.     enemyhp()
  78.     hostagecount()
  79.     bombtimer()
  80.   end
  81. -- don't update kills during load screens
  82.   if status == 2 or status == 13 or status == 18 then incontrol = 0 end
  83.   if incontrol >= waitperiod then
  84.     killcounter()
  85.   else incontrol = incontrol+1 end
  86.   gui.text(0,8,"BODY COUNT: "..bodycount)
  87.   for i = 0, 4 do enemy[i].hpold = enemy[i].hpnew end
  88. end
  89.  
  90. gui.transparency(1)
  91. gui.register(drawdata)
  92.  
  93. while true do
  94.   FCEU.frameadvance()
  95. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×