Advertisement
Guest User

terranigma_dmg_graph.lua

a guest
Jun 27th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.01 KB | None | 0 0
  1. local xpos = 0
  2. local ypos = 233-28
  3.  
  4. local timerOffset = 64
  5. local baseColor   = 0x808080FF
  6. local activeColor = 0x00FF00FF
  7.  
  8. local hidden = false
  9.  
  10. local function my_display()
  11.  
  12.   if hidden then
  13.     return
  14.   end
  15.  
  16.   gui.box(xpos,ypos-9,xpos+26,ypos-1,0x000000ff)
  17.   gui.text(xpos+2,ypos-8,"Damage")
  18.  
  19.   gui.box(xpos,ypos,xpos+255,ypos+18,0x000000c0)
  20.   gui.line(xpos+1+timerOffset,ypos+1,xpos+1+timerOffset,ypos+17,0xFF0000FF)
  21.  
  22.   local timer = AND(memory.readword(0x7e0042)-timerOffset,0x1ff)
  23.   local graphy = ypos+9
  24.  
  25.   for i = 0,253 do
  26.  
  27.     local modSign
  28.     if(AND(timer+i,0x100)==0) then
  29.       modSign = 1
  30.     else
  31.      modSign = -1
  32.     end
  33.  
  34.     local colorRatio = math.min(i/timerOffset,1)
  35.     local mixedColor
  36.  
  37.     if(i>timerOffset) then
  38.       mixedColor = baseColor
  39.     else
  40.       local mixedColorComponent = 0
  41.       mixedColor = 0
  42.       for n=0,3 do
  43.         mixedColorComponent = (1-colorRatio)*AND(baseColor/math.pow(0x100,n),0xff)  +  
  44.                               (colorRatio)*AND(activeColor/math.pow(0x100,n),0xff)
  45.  
  46.         mixedColor = mixedColor + AND(math.min(mixedColorComponent,0xff),0xff)*math.pow(0x100,n)
  47.       end
  48.     end
  49.  
  50.     local graphx = xpos+i+1
  51.     local amp = 4+AND(timer+i,0x4)
  52.  
  53.     if(AND(timer+i,0x8)==0) then
  54.       gui.pixel(graphx,graphy,mixedColor)
  55.  
  56.     elseif(AND(timer+i,0xf)==0x8 or AND(timer+i,0xf)==0xf) then
  57.       gui.line(graphx,graphy,graphx,graphy-modSign*amp,mixedColor)
  58.  
  59.     elseif(AND(timer+i,0xf)==0xc) then
  60.       gui.line(graphx,graphy-modSign*4,graphx,graphy-modSign*8,mixedColor)
  61.  
  62.     else
  63.       gui.pixel(graphx,graphy-modSign*amp,mixedColor)
  64.     end
  65.   end
  66.  
  67. end
  68.  
  69. -- Hook the display function to the GUI update
  70. local on_gui_update_old = gui.register()
  71. local function on_gui_update_new()
  72.   if on_gui_update_old then
  73.     on_gui_update_old()
  74.   end
  75.   my_display()
  76. end
  77. gui.register(on_gui_update_new)
  78.  
  79. -- Public functions
  80. dmg_graph = {}
  81.  
  82. function dmg_graph.show()
  83.   hidden = false
  84. end
  85.  
  86. function dmg_graph.hide()
  87.   hidden = true
  88. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement