Advertisement
Guest User

Tackle

a guest
Jun 17th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.57 KB | None | 0 0
  1. local tackleSprite;
  2. local hasGenerated = false;
  3. local myCounter = 0
  4. local cooldown = 0
  5. local defs = API.load("expandedDefines")
  6. local pnpc = API.load("pnpc")
  7. local npcconfig = API.load("npcconfig")
  8. local npcManager = API.load("npcManager")
  9. local player = Player()
  10. local tableX = {}
  11. local tableY = {}
  12. local tOpacity = {}
  13. local flag = false
  14.  
  15. function onTick()
  16.  
  17. character=player:mem(0xF0, FIELD_WORD)
  18.  
  19.     if (player.powerup == PLAYER_BIG) then
  20.  
  21.         if (cooldown == 0) then --Cooldown (sempre deve ser maior que a duração do efeito!!!!! lembrar)
  22.            
  23.         if ((player.altRunKeyPressing) and (player.downKeyPressing == false) and (player.altJumpKeyPressing == false)) or (myCounter > 0) then
  24.             myCounter = myCounter + 2
  25.  
  26.             Text.print(myCounter,0,0)
  27.             --Contador de tempo
  28.  
  29.             player.speedX = player:mem(0x106, FIELD_WORD) * 8
  30.             --Velocidade horizontal
  31.  
  32.             table.insert(tableX, player.x)
  33.             table.insert(tableY, player.y)
  34.             table.insert(tOpacity, 1)
  35.  
  36.             if ((player:isGroundTouching() == false) and (character~=5)) then
  37.                 player.speedY = -6
  38.                 if (myCounter < 3) then
  39.                     playSFX("tackle-air.wav")
  40.                 end
  41.             end
  42.  
  43.             flag = true
  44.  
  45.  
  46.             if (player:isGroundTouching()) then
  47.                 if (myCounter < 3) then
  48.                     playSFX("tackle-ground.wav")
  49.                 end
  50.             end
  51.  
  52.             player.leftKeyPressing = false
  53.             player.rightKeyPressing = false
  54.             player.jumpKeyPressing = false
  55.             player.altJumpKeyPressing = false
  56.             player.runKeyPressing = false
  57.  
  58.             Defines.cheat_donthurtme = true
  59.             --Invencibilidade
  60.  
  61.             player:mem(0x156, FIELD_BOOL, false)
  62.            
  63.             --Efeitos
  64.  
  65.             for _, w in pairs(NPC.getIntersecting(player.x, player.y, player.x + player.width, player.y + player.height)) do
  66.  
  67.                 if defs.NPC_HITTABLE_MAP[w.id] then
  68.                     w:harm(HARM_TYPE_EXT_HAMMER)
  69.                     playSFX("punch.wav")
  70.                     Animation.spawn(76, w.x, w.y)
  71.                 end
  72.  
  73.             end
  74.             --Matar os brode
  75.  
  76.             if (myCounter == 40) then
  77.                 cooldown = 50
  78.                 myCounter = 0
  79.                 Defines.cheat_donthurtme = false
  80.                 flag = false
  81.                 tableX = {}
  82.                 tableY = {}
  83.                 tOpacity = {}
  84.             end
  85.  
  86.         end
  87.         --Fim da linha
  88.  
  89.         else
  90.             cooldown = cooldown - 1 --Caso cooldown seja 100 (ou o tempo definido), a função será executada
  91.         end
  92.  
  93.     end
  94.  
  95.  end
  96.  
  97.  function onDraw()
  98.     tackleSprite = Graphics.loadImageResolved("tackleS.png")
  99.  
  100.     if (flag) then
  101.  
  102.         for i = 1, #tableX, 2 do --only draw every fifth frame
  103.             Graphics.drawImageToSceneWP(tackleSprite, tableX[i], tableY[i], (tOpacity[i] - 0.1), 0)
  104.         end
  105.  
  106.         player:setCurrentSpriteIndex(1, 45, false)
  107.  
  108.     end
  109. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement