Soristl

Get Ball Function

Dec 5th, 2021
517
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getBall(name, x, y)
  2.     if ballObject.Spawn then
  3.         if ballObject.owner == "" then
  4.             local ballX1 = (tfm.get.room.objectList[ballObject.id].x - tfm.get.room.objectList[ballObject.id].vx) - 50
  5.             local ballX2 = (tfm.get.room.objectList[ballObject.id].x + tfm.get.room.objectList[ballObject.id].vx) + 50
  6.             local ballY1 = (tfm.get.room.objectList[ballObject.id].y - tfm.get.room.objectList[ballObject.id].vy) - 60
  7.             local ballY2 = (tfm.get.room.objectList[ballObject.id].y + tfm.get.room.objectList[ballObject.id].vy) + 60
  8.             if x >= ballX1 and x <= ballX2 and y >= ballY1 and y <= ballY2 then
  9.                 tfm.exec.removePhysicObject(1)
  10.                 ballObject.verifyCoords = false
  11.                 ballObject.Spawn = false
  12.                 canCatchBall()
  13.                 tfm.exec.removeObject(ballObject.id)
  14.                 idImage = tfm.exec.addImage("175aa78bb80.png", "$"..name, -45, -125, nil)
  15.                 ballObject.owner = name
  16.                 system.bindMouse(name, true)
  17.                 playersActions[name].canCatch = true
  18.                 showImageBallWithPlayer(name)
  19.                 eventKeyBoardControl(name, true)
  20.             end
  21.         elseif ballObject.owner ~= "" and playerTeam[ballObject.owner].team ~= playerTeam[name].team then
  22.             local ballX1 = (tfm.get.room.playerList[ballObject.owner].x - tfm.get.room.playerList[ballObject.owner].vx) - distanceToCatch.x - playerDirection.x1
  23.             local ballX2 = (tfm.get.room.playerList[ballObject.owner].x + tfm.get.room.playerList[ballObject.owner].vx) + distanceToCatch.x + playerDirection.x2
  24.             local ballY1 = (tfm.get.room.playerList[ballObject.owner].y - tfm.get.room.playerList[ballObject.owner].vy) - distanceToCatch.y
  25.             local ballY2 = (tfm.get.room.playerList[ballObject.owner].y + tfm.get.room.playerList[ballObject.owner].vy) + distanceToCatch.y
  26.             if x >= ballX1 and x <= ballX2 and y >= ballY1 and y <= ballY2 then
  27.                 removeTimer("powerShoot")
  28.                 gameStats.powerShootEvent = false
  29.                 ui.removeTextArea(999)
  30.                 ui.removeTextArea(1000)
  31.                 ui.removeTextArea(1001)
  32.                 ballObject.verifyCoords = false
  33.                 ballObject.Spawn = false
  34.                 forceIndex = 0
  35.                 canCatchBall()
  36.                 tfm.exec.removeImage(idImage)
  37.                 tfm.exec.removeImage(ballObject.ID_image)
  38.                 delayCatchEVT(ballObject.owner)
  39.                 system.bindMouse(ballObject.owner, false)
  40.                 eventKeyBoardControl(ballObject.owner, false)
  41.                 idImage = tfm.exec.addImage("175aa78bb80.png", "$"..name, -45, -125, nil)
  42.                 ballObject.owner = name
  43.                 playersActions[name].canCatch = true
  44.                 showImageBallWithPlayer(name)
  45.                 system.bindMouse(ballObject.owner, true)
  46.                 eventKeyBoardControl(ballObject.owner, true)
  47.             end
  48.         end
  49.     end
  50. end
RAW Paste Data