Advertisement
Guest User

[TFM] Unplayble

a guest
Nov 29th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.42 KB | None | 0 0
  1. --[[
  2. Developed by: Contistente#0000
  3. Unplayable version: 1.0
  4. ]]--
  5.  
  6. -- Disable standard room behaviors --
  7. for _, k in next, {"AutoShaman", "AutoNewGame", "AutoTimeLeft", "AutoScore"} do
  8.     tfm.exec["disable"..k]()
  9. end
  10.  
  11. -- Minigame data table --
  12. tfm.unplayable = {player={}, players={}, shooter={targetName="", firerate=0, firerate_timer=0, firetip=0, x=0, y=0, dx=0, dy=0, dir=0, angles={0, 0}, isFacingRight=false, canshoot=false}, round={mapCode=0, players_alive=0, started=false, difficulty={level=1, timer=0, levelup=15000}}}
  13.  
  14. -- Minigame events --
  15. function eventNewGame()
  16.     -- Reset play --
  17.     tfm.unplayable.round.mapCode = tfm.get.room.xmlMapInfo.mapCode
  18.     tfm.unplayable.round.difficulty.level = 1
  19.     tfm.unplayable.round.players_alive = 0
  20.  
  21.     for k, v in next, tfm.get.room.playerList do
  22.         if (not v.isDead) then
  23.             tfm.unplayable.round.players_alive = tfm.unplayable.round.players_alive + 1
  24.         end
  25.     end
  26.  
  27.     ui.setMapName("Unplayable   <BL>|</BL>   <G>@"..tfm.unplayable.round.mapCode.."</G>   <BL>|</BL>   <N>Difficulty Lvl: <V>"..tfm.unplayable.round.difficulty.level.."</V></N>")
  28.  
  29.     -- Set round time
  30.     tfm.exec.setGameTime(93)
  31. end
  32.  
  33. function eventLoop(elapsed, remaining)
  34.     if (tfm.unplayable.round.started) then
  35.         if (remaining <= 2000 and tfm.unplayable.round.players_alive > 0) then
  36.             for k, v in next, tfm.get.room.playerList do
  37.                 if(not v.isDead) then
  38.                     tfm.exec.giveCheese(k)
  39.                     tfm.exec.playerVictory(k)
  40.                 end
  41.             end
  42.         end
  43.    
  44.         if (remaining <= 500 or tfm.unplayable.round.players_alive == 0) then
  45.             tfm.unplayable.round.started = false
  46.             tfm.exec.newGame('#10')
  47.         else
  48.             if (tfm.unplayable.round.difficulty.timer < os.time()) then
  49.                 tfm.unplayable.round.difficulty.level = tfm.unplayable.round.difficulty.level + 1
  50.                 tfm.unplayable.round.difficulty.timer = os.time() + tfm.unplayable.round.difficulty.levelup
  51.        
  52.                 tfm.unplayable.shooter.firerate = (tfm.unplayable.round.difficulty.levelup/(tfm.unplayable.round.difficulty.level*5))
  53.                 tfm.unplayable.shooter.firetip = math.floor(tfm.unplayable.round.difficulty.levelup/(tfm.unplayable.round.difficulty.level*5.9999))
  54.        
  55.                 ui.setMapName("Unplayable   <BL>|</BL>   <G>@"..tfm.unplayable.round.mapCode.."</G>   <BL>|</BL>   <N>Difficulty Lvl: <V>"..tfm.unplayable.round.difficulty.level.."</V></N>")
  56.             end
  57.      
  58.             if (tfm.unplayable.shooter.firerate_timer - tfm.unplayable.shooter.firetip < os.time() and tfm.unplayable.shooter.targetName == "") then
  59.                 local alives, troll = {}
  60.                 for k, v in next, tfm.get.room.playerList do if(not v.isDead) then alives[#alives+1] = k end end
  61.                 local targetName = alives[math.random(#alives)]
  62.                 local target = tfm.get.room.playerList[targetName]
  63.                 local troll = (tfm.unplayable.round.difficulty.level >= 5 and math.random(1,100) > 80)
  64.                 if (not target) then return false end
  65.        
  66.                 if (not troll) then
  67.                     tfm.unplayable.shooter.targetName = targetName
  68.                 else
  69.                     tfm.unplayable.shooter.firerate_timer = os.time() + (tfm.unplayable.shooter.firerate/2)
  70.                 end
  71.        
  72.                 tfm.unplayable.shooter.x = target.x
  73.                 tfm.unplayable.shooter.y = target.y
  74.        
  75.                 tfm.unplayable.shooter.dir = math.random(1, 9)
  76.                
  77.                 tfm.unplayable.shooter.dx = (tfm.unplayable.shooter.dir ~= 3 and math.random(80,180) or math.random(-10,10))
  78.                 tfm.unplayable.shooter.dy = (tfm.unplayable.shooter.dir ~= 3 and math.random(-20,20) or -math.random(80,250))
  79.        
  80.                 tfm.unplayable.shooter.isFacingRight = target.isFacingRight
  81.        
  82.                 if (tfm.unplayable.round.difficulty.level > 2 and math.random(1,100) < 40) then
  83.                     tfm.unplayable.shooter.isFacingRight = not target.isFacingRight
  84.                 end
  85.                
  86.                 tfm.unplayable.shooter.angles[1] = (tfm.unplayable.shooter.dir ~= 3 and (tfm.unplayable.shooter.isFacingRight and math.random(260,275) or math.random(80,95)) or math.random(175,185))
  87.                 tfm.unplayable.shooter.angles[2] = ((tfm.unplayable.shooter.angles[1] >= 80 and tfm.unplayable.shooter.angles[1] <= 95)or(tfm.unplayable.shooter.angles[1] >= 175 and tfm.unplayable.shooter.angles[1] <= 185)or(tfm.unplayable.shooter.angles[1] >= 260 and tfm.unplayable.shooter.angles[1] <= 275)) and (tfm.unplayable.shooter.angles[1] - 180) or tfm.unplayable.shooter.angles[1]
  88.                
  89.                 tfm.exec.addShamanObject(0, (tfm.unplayable.shooter.x + (tfm.unplayable.shooter.isFacingRight and tfm.unplayable.shooter.dx or -tfm.unplayable.shooter.dx) + math.random(-4,4)), (tfm.unplayable.shooter.dir ~= 3 and (tfm.unplayable.shooter.y + (tfm.unplayable.shooter.isFacingRight and tfm.unplayable.shooter.dy or -tfm.unplayable.shooter.dy)) or (tfm.unplayable.shooter.y + tfm.unplayable.shooter.dy)), tfm.unplayable.shooter.angles[2])
  90.             elseif (tfm.unplayable.shooter.firerate_timer < os.time()) then
  91.                 tfm.exec.addShamanObject(17, (tfm.unplayable.shooter.isFacingRight and tfm.unplayable.shooter.x + tfm.unplayable.shooter.dx or tfm.unplayable.shooter.x - tfm.unplayable.shooter.dx), (tfm.unplayable.shooter.y + tfm.unplayable.shooter.dy), tfm.unplayable.shooter.angles[1])
  92.                 tfm.unplayable.shooter.firerate_timer = os.time() + tfm.unplayable.shooter.firerate
  93.                 tfm.unplayable.shooter.targetName = ""
  94.             end
  95.         end
  96.     elseif (elapsed > 3000) then
  97.         tfm.unplayable.shooter.firerate = (tfm.unplayable.round.difficulty.levelup/(tfm.unplayable.round.difficulty.level*5))
  98.         tfm.unplayable.shooter.firetip = math.floor(tfm.unplayable.round.difficulty.levelup/(tfm.unplayable.round.difficulty.level*5.9999))
  99.  
  100.         tfm.unplayable.shooter.firerate_timer = os.time() + tfm.unplayable.shooter.firerate
  101.    
  102.         tfm.unplayable.round.difficulty.timer = os.time() + tfm.unplayable.round.difficulty.levelup
  103.         tfm.unplayable.round.started = true
  104.     end
  105. end
  106.  
  107. function eventPlayerDied(name)
  108.     tfm.unplayable.round.players_alive = tfm.unplayable.round.players_alive - 1
  109. end
  110.  
  111. function eventNewPlayer(name)
  112.     tfm.unplayable.players[#tfm.unplayable.players+1] = name
  113. end
  114.  
  115. function eventPlayerLeft(name)
  116.   local index
  117.   for k, v in next, tfm.unplayable.players do
  118.     if (v == name) then index = k end
  119.   end
  120.   tfm.unplayable.players[index] = nil
  121. end
  122.  
  123. -- Start up --
  124. table.foreach(tfm.get.room.playerList, eventNewPlayer)
  125. tfm.exec.newGame('#10')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement