Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.01 KB | None | 0 0
  1. --40 pixels
  2. --26, 66, 106
  3. --"Graphics.loadImage(Misc.resolveFile(filename))" -Enjl, the wise one
  4.  
  5. local debugModeOn = true;
  6. local camera = Camera.get()[1]
  7. local freeCamEnabled = false;
  8. local pressedTanooki = false;
  9. local freeCameraX = 0;
  10. local freeCameraY = 0;
  11. local pose = 0;
  12. local previousPowerup = 0;
  13.  
  14. local allowedCharacters = {[CHARACTER_MARIO] = true, [CHARACTER_LUIGI] = true, [CHARACTER_TOAD] = true};
  15. local hudEnabled = false;
  16.  
  17. local ui_box1 = Graphics.loadImage(Misc.resolveFile("ui_box1.png"));
  18. local box1_position = {x = 372, y = 16};
  19. local box1_item = 0;
  20.  
  21. local ui_hearts_backdrop = Graphics.loadImage(Misc.resolveFile("ui_hearts_backdrop.png"));
  22. local ui_heart = Graphics.loadImage(Misc.resolveFile("ui_heart.png"));
  23. local ui_heart_empty = Graphics.loadImage(Misc.resolveFile("ui_heart_empty.png"));
  24. local hearts_position = {x = 372, y = 28};
  25. local hearts = player:mem(0x16, FIELD_WORD);
  26.  
  27. local ui_score = Graphics.loadImage(Misc.resolveFile("ui_stars.png"));
  28. local stars_position = {x = 50, y = 28};
  29. local score = mem(0x00B2C8E4, FIELD_DWORD);
  30. local stars = mem(0x00B251E0, FIELD_WORD);
  31.  
  32. local ui_life = Graphics.loadImage(Misc.resolveFile("ui_1up.png"));
  33. local life_position = {x = 470, y = 28};
  34. local lives = mem(0x00B2C5AC, FIELD_FLOAT);
  35. local textOffset = {x = 44, y = 10};
  36.  
  37. local ui_coins = Graphics.loadImage(Misc.resolveFile("ui_coin.png"));
  38. local coins_position = {x = 620, y = 28}
  39. local normalCoins = mem(0x00B2C5A8, FIELD_WORD);
  40.  
  41. local stargate_star1 = Graphics.loadImage(Misc.resolveFile("stargate_star1.png"));
  42. local stargate_star2 = Graphics.loadImage(Misc.resolveFile("stargate_star2.png"));
  43. local stargate_star3 = Graphics.loadImage(Misc.resolveFile("stargate_star3.png"));
  44. local stargate_star4 = Graphics.loadImage(Misc.resolveFile("stargate_star4.png"));
  45. local stargate_star5 = Graphics.loadImage(Misc.resolveFile("stargate_star5.png"));
  46. local stargate_star6 = Graphics.loadImage(Misc.resolveFile("stargate_star6.png"));
  47. local stargate_star7 = Graphics.loadImage(Misc.resolveFile("stargate_star7.png"));
  48. local stargate_star8 = Graphics.loadImage(Misc.resolveFile("stargate_star8.png"));
  49. local flash1 = Graphics.loadImage(Misc.resolveFile("flash1.png"));
  50. local flash2 = Graphics.loadImage(Misc.resolveFile("flash2.png"));
  51. local flash3 = Graphics.loadImage(Misc.resolveFile("flash3.png"));
  52. local flash4 = Graphics.loadImage(Misc.resolveFile("flash4.png"));
  53. local flash5 = Graphics.loadImage(Misc.resolveFile("flash5.png"));
  54. local flash6 = Graphics.loadImage(Misc.resolveFile("flash6.png"));
  55. local flash7 = Graphics.loadImage(Misc.resolveFile("flash7.png"));
  56. local flash8 = Graphics.loadImage(Misc.resolveFile("flash8.png"));
  57. local flash9 = Graphics.loadImage(Misc.resolveFile("flash9.png"));
  58. local flash10 = Graphics.loadImage(Misc.resolveFile("flash10.png"));
  59. local flash11 = Graphics.loadImage(Misc.resolveFile("flash11.png"));
  60. local stargate_star_x = 384;
  61. local stargate_star_y = -32;
  62. local stargate_star_cutscene_timer = 0;
  63. local stargate_star_animation_timer = 0;
  64.  
  65. --Custom Coin System
  66. local GlobalData = Data(Data.DATA_WORLD, "EpisodeData");
  67.  
  68. if GlobalData == nil then
  69.  GlobalData:set("CustomCoins", tostring(1))
  70.  GlobalData:save()
  71. end
  72.  
  73. local Coins = GlobalData:get("CustomCoins");
  74.  
  75. function onStart()
  76.  Graphics.activateHud(false)
  77.  hudEnabled = true;
  78.   if not allowedCharacters[player.character] then
  79.    player.character = CHARACTER_MARIO;
  80.   end
  81. end
  82.  
  83. function onEvent(eventname)
  84.  if eventname == "Enable Custom HUD" then
  85.   Graphics.activateHud(false)
  86.   hudEnabled = true;
  87.  end
  88.  
  89.  if eventname == "Reset HUD" then
  90.   Graphics.activateHud(true)
  91.   hudEnabled = false;
  92.  end
  93.  
  94.  if eventname == "Disable HUD" then
  95.   Graphics.activateHud(false)
  96.   hudEnabled = false;
  97.  end
  98.  
  99.  if eventname == "Star Gate Open" then
  100.   stargate_star_cutscene_timer = 1
  101.  end
  102. end
  103.  
  104.  
  105.  
  106. ---Actual HUD stuff
  107. function onDraw()
  108.  
  109.  if freeCamEnabled == true and debugModeOn == true then
  110.   Text.print("FreeCam: On", 20, 560);
  111.  end
  112.  if freeCamEnabled == false and debugModeOn == true then
  113.   Text.print("", 20, 560);
  114.  end
  115.  
  116.  if (hudEnabled == true) then
  117.  
  118. --Score & Stars
  119.   Graphics.drawImage(ui_score, stars_position.x, stars_position.y);
  120.   Text.print(tostring(mem(0x00B2C8E4, FIELD_DWORD)), 1, stars_position.x + 14, stars_position.y + 6);
  121.   Text.print(tostring(mem(0x00B251E0, FIELD_WORD)), 1, stars_position.x + 178, stars_position.y + 10);
  122.  
  123. --Lives
  124.   Graphics.drawImage(ui_life, life_position.x, life_position.y);
  125.   Text.print(tostring(mem(0x00B2C5AC, FIELD_FLOAT)), 1, life_position.x + textOffset.x, life_position.y + textOffset.y);
  126.  
  127. --Coins
  128.   Graphics.drawImage(ui_coins, coins_position.x, coins_position.y);
  129.   Text.print(Coins, 1, coins_position.x + textOffset.x, coins_position.y + textOffset.y);
  130.  
  131. --Box & Hearts
  132.   if player.character <= 2 then
  133.    Graphics.drawImage(ui_box1, box1_position.x - 22, box1_position.y);
  134.     if player.reservePowerup > 0 and player.reservePowerup ~= 34 then
  135.      Graphics.draw{type = RTYPE_IMAGE, x = box1_position.x + 12, y = box1_position.y + 12, image = Graphics.sprites.npc[player.reservePowerup].img}
  136.     end
  137.    
  138.     if player.reservePowerup == 34 then
  139.      Graphics.drawImage(Graphics.loadImage(Misc.resolveFile("powerup_leaf_middle.png")), box1_position.x + 12, box1_position.y + 12);
  140.     end
  141.   end
  142.  
  143.   if player.character == 4 then
  144.    
  145.    Graphics.drawImage(ui_hearts_backdrop, hearts_position.x - 72, hearts_position.y);
  146.    Graphics.drawImage(ui_heart_empty, hearts_position.x - 48, hearts_position.y);
  147.    Graphics.drawImage(ui_heart_empty, hearts_position.x, hearts_position.y);
  148.    Graphics.drawImage(ui_heart_empty, hearts_position.x + 48, hearts_position.y);
  149.     if player:mem(0x16, FIELD_WORD) >= 1 then
  150.      Graphics.drawImage(ui_heart, hearts_position.x - 48, hearts_position.y);
  151.       if player:mem(0x16, FIELD_WORD) >= 2 then
  152.        Graphics.drawImage(ui_heart, hearts_position.x, hearts_position.y);
  153.         if player:mem(0x16, FIELD_WORD) >= 3 then
  154.          Graphics.drawImage(ui_heart, hearts_position.x + 48, hearts_position.y);
  155.         end
  156.       end
  157.     end
  158.   end
  159.  end
  160.  
  161.  if stargate_star_cutscene_timer >= 1 and stargate_star_animation_timer >= 0 and stargate_star_animation_timer <= 10 then
  162.   Graphics.drawImage(stargate_star1, stargate_star_x, stargate_star_y);
  163.  end
  164.  if stargate_star_cutscene_timer >= 1 and stargate_star_animation_timer >= 11 and stargate_star_animation_timer <= 20 then
  165.   Graphics.drawImage(stargate_star2, stargate_star_x, stargate_star_y);
  166.  end
  167.  if stargate_star_cutscene_timer >= 1 and stargate_star_animation_timer >= 21 and stargate_star_animation_timer <= 30 then
  168.   Graphics.drawImage(stargate_star3, stargate_star_x, stargate_star_y);
  169.  end
  170.  if stargate_star_cutscene_timer >= 1 and stargate_star_animation_timer >= 31 and stargate_star_animation_timer <= 40 then
  171.   Graphics.drawImage(stargate_star4, stargate_star_x, stargate_star_y);
  172.  end
  173.  if stargate_star_cutscene_timer >= 1 and stargate_star_animation_timer >= 41 and stargate_star_animation_timer <= 50 then
  174.   Graphics.drawImage(stargate_star5, stargate_star_x, stargate_star_y);
  175.  end
  176.  if stargate_star_cutscene_timer >= 1 and stargate_star_animation_timer >= 51 and stargate_star_animation_timer <= 60 then
  177.   Graphics.drawImage(stargate_star5, stargate_star_x, stargate_star_y);
  178.  end
  179.  if stargate_star_cutscene_timer >= 1 and stargate_star_animation_timer >= 61 and stargate_star_animation_timer <= 70 then
  180.   Graphics.drawImage(stargate_star6, stargate_star_x, stargate_star_y);
  181.  end
  182.  if stargate_star_cutscene_timer >= 1 and stargate_star_animation_timer >= 71 and stargate_star_animation_timer <= 80 then
  183.   Graphics.drawImage(stargate_star7, stargate_star_x, stargate_star_y);
  184.  end
  185.  if stargate_star_cutscene_timer >= 1 and stargate_star_animation_timer >= 81 and stargate_star_animation_timer <= 90 then
  186.   Graphics.drawImage(stargate_star8, stargate_star_x, stargate_star_y);
  187.  end
  188.  
  189.  if stargate_star_cutscene_timer >= 340 and stargate_star_cutscene_timer <= 350 then
  190.   Graphics.drawImage(flash1, 0, 0);
  191.  end
  192.  if stargate_star_cutscene_timer >= 351 and stargate_star_cutscene_timer <= 360 then
  193.   Graphics.drawImage(flash2, 0, 0);
  194.  end
  195.  if stargate_star_cutscene_timer >= 361 and stargate_star_cutscene_timer <= 370 then
  196.   Graphics.drawImage(flash3, 0, 0);
  197.  end
  198.  if stargate_star_cutscene_timer >= 371 and stargate_star_cutscene_timer <= 380 then
  199.   Graphics.drawImage(flash4, 0, 0);
  200.  end
  201.  if stargate_star_cutscene_timer >= 381 and stargate_star_cutscene_timer <= 390 then
  202.   Graphics.drawImage(flash5, 0, 0);
  203.  end
  204.  if stargate_star_cutscene_timer >= 391 and stargate_star_cutscene_timer <= 400 then
  205.   Graphics.drawImage(flash6, 0, 0);
  206.  end
  207.  if stargate_star_cutscene_timer >= 401 and stargate_star_cutscene_timer <= 410 then
  208.   Graphics.drawImage(flash7, 0, 0);
  209.  end
  210.  if stargate_star_cutscene_timer >= 411 and stargate_star_cutscene_timer <= 420 then
  211.   Graphics.drawImage(flash8, 0, 0);
  212.  end
  213.  if stargate_star_cutscene_timer >= 421 and stargate_star_cutscene_timer <= 430 then
  214.   Graphics.drawImage(flash9, 0, 0);
  215.  end
  216.  if stargate_star_cutscene_timer >= 431 and stargate_star_cutscene_timer <= 440 then
  217.   Graphics.drawImage(flash10, 0, 0);
  218.  end
  219.  if stargate_star_cutscene_timer >= 441 and stargate_star_cutscene_timer <= 9999 then
  220.   Graphics.drawImage(flash11, 0, 0);
  221.  end
  222.  
  223.  if pose == 1 then
  224.   player:mem(0x114, FIELD_WORD, 48)
  225.  end
  226. end
  227.  
  228. function onTick()
  229.  if stargate_star_cutscene_timer >= 1 then
  230.   stargate_star_cutscene_timer = stargate_star_cutscene_timer + 1
  231.   stargate_star_animation_timer = stargate_star_animation_timer + 1
  232.    if stargate_star_animation_timer >= 91 then
  233.     stargate_star_animation_timer = 0
  234.    end
  235.  end
  236.  
  237.  if stargate_star_cutscene_timer >= 1 and stargate_star_cutscene_timer <= 280 then
  238.   stargate_star_y = stargate_star_y + 1
  239.  end
  240.  
  241.  if player.altRunKeyPressing == true and freeCamEnabled == false and pressedTanooki == false and debugModeOn == true and player.upKeyPressing == true then
  242.   freeCamEnabled = true
  243.   pressedTanooki = true
  244.  end
  245.  if player.altRunKeyPressing == true and freeCamEnabled == true and pressedTanooki == false and debugModeOn == true and player.upKeyPressing == true then
  246.   freeCamEnabled = false
  247.   pressedTanooki = true
  248.  end
  249.  if player.altRunKeyPressing == false then
  250.   pressedTanooki = false
  251.  end
  252.  
  253.  if player.altRunKeyPressing == true and pose == 0 and pressedTanooki == false and debugModeOn == true and player.downKeyPressing == true then
  254.   pose = 1
  255.   pressedTanooki = true
  256.  end
  257.  if player.altRunKeyPressing == true and pose == 1 and pressedTanooki == false and debugModeOn == true and player.downKeyPressing == true then
  258.   pose = 0
  259.   pressedTanooki = true
  260.  end
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  if freeCamEnabled == true then
  268.   if player.upKeyPressing == true then
  269.    freeCameraY = freeCameraY - 2
  270.    
  271.    if player.runKeyPressing == true then
  272.     freeCameraY = freeCameraY - 2
  273.    end
  274.    player.upKeyPressing = false
  275.   end
  276.  
  277.   if player.downKeyPressing == true then
  278.    freeCameraY = freeCameraY + 2
  279.    
  280.    if player.runKeyPressing == true then
  281.     freeCameraY = freeCameraY + 2
  282.    end
  283.    player.downKeyPressing = false
  284.   end
  285.  
  286.   if player.rightKeyPressing == true then
  287.    freeCameraX = freeCameraX + 2
  288.    
  289.    if player.runKeyPressing == true then
  290.     freeCameraX = freeCameraX + 2
  291.    end
  292.    player.rightKeyPressing = false
  293.   end
  294.  
  295.   if player.leftKeyPressing == true then
  296.    freeCameraX = freeCameraX - 2
  297.    
  298.     if player.runKeyPressing == true then
  299.      freeCameraX = freeCameraX - 2
  300.     end
  301.    player.leftKeyPressing = false
  302.   end
  303.  
  304.   player.dropItemKeyPressing = false
  305.   player.runKeyPressing = false
  306.   player.altJumpKeyPressing = false
  307.   player.jumpKeyPressing = false
  308.  end
  309.  
  310.  
  311.  
  312.   if player:mem(0x122, FIELD_WORD) == 0 and previousPowerup ~= player.powerup then
  313.     if previousPowerup > 2 then
  314.      player.powerup = 2
  315.     end
  316.   end
  317.   if player:mem(0x122, FIELD_WORD) == 0 then
  318.    previousPowerup = player.powerup
  319.   end
  320. end
  321.  
  322. function onCameraUpdate()
  323.  if freeCamEnabled == true then
  324.   camera.x = freeCameraX
  325.   camera.y = freeCameraY
  326.  end
  327.  if freeCamEnabled == false then
  328.   freeCameraX = camera.x
  329.   freeCameraY = camera.y
  330.  end
  331. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement