| @@ -243,6 +243,15 @@ function love.load() | |||||
| end | end | ||||
| ) | ) | ||||
| ) | ) | ||||
| table.insert( | |||||
| difbuttons, | |||||
| newButton( | |||||
| "Smart", | |||||
| function() | |||||
| hardmanager("smart") | |||||
| end | |||||
| ) | |||||
| ) | |||||
| table.insert( | table.insert( | ||||
| settings, | settings, | ||||
| newButton( | newButton( | ||||
| @@ -493,6 +502,15 @@ function love.load() | |||||
| end | end | ||||
| ) | ) | ||||
| ) | ) | ||||
| table.insert( | |||||
| difbuttons, | |||||
| newButton( | |||||
| "ballCount", | |||||
| function() | |||||
| speedSetter("ballz") | |||||
| end | |||||
| ) | |||||
| ) | |||||
| table.insert( | table.insert( | ||||
| playerCountButtons, | playerCountButtons, | ||||
| newButton( | newButton( | ||||
| @@ -687,6 +705,7 @@ function hardmanager(diff) | |||||
| AI_SPEED = ballSet / 10 | AI_SPEED = ballSet / 10 | ||||
| AI_STRIKEMOD = 100 | AI_STRIKEMOD = 100 | ||||
| AI_NUKEMOD = 1000 | AI_NUKEMOD = 1000 | ||||
| AI_LEVEL = 350 | |||||
| difficultyl = 200 | difficultyl = 200 | ||||
| selecting = 0 | selecting = 0 | ||||
| gameState = "1serve" | gameState = "1serve" | ||||
| @@ -717,6 +736,19 @@ function hardmanager(diff) | |||||
| gameState = "1serve" | gameState = "1serve" | ||||
| globalState = "base" | globalState = "base" | ||||
| end | end | ||||
| if (diff == "smart") then | |||||
| INDIC[3] = ">" | |||||
| AI_SPEED = ballSpeed * 1.1 + 50 | |||||
| AI_SPEED = AI_SPEED / 10 | |||||
| AI_LEVEL = 1500 | |||||
| AI_NUKEMOD = 200 | |||||
| AI_STRIKEMOD = 20 | |||||
| selecting = 0 | |||||
| difficultyl = 350 | |||||
| AGAINST_AI = 1 | |||||
| gameState = "1serve" | |||||
| globalState = "base" | |||||
| end | |||||
| if (diff == "practice") then | if (diff == "practice") then | ||||
| INDIC[3] = ">" | INDIC[3] = ">" | ||||
| AI_SPEED = ballSpeed * 500 + 50 | AI_SPEED = ballSpeed * 500 + 50 | ||||
| @@ -26,7 +26,7 @@ function musicController(orders, toggling) | |||||
| sounds['gayTheme2']:setLooping(true) | sounds['gayTheme2']:setLooping(true) | ||||
| sounds['gayTheme2']:setVolume(0.5) | sounds['gayTheme2']:setVolume(0.5) | ||||
| sounds['gayTheme2']:play() | sounds['gayTheme2']:play() | ||||
| elseif gameState == 'play' and player1score > ptw-4 or player2score > ptw-4 and areanuclear == 0 then | |||||
| elseif gameState == 'play' and player1score > ptw-5 or player2score > ptw-5 and areanuclear == 0 then | |||||
| print(ptw-4) | print(ptw-4) | ||||
| sounds['gayTheme']:stop() | sounds['gayTheme']:stop() | ||||
| sounds['gayTheme2']:stop() | sounds['gayTheme2']:stop() | ||||
| @@ -0,0 +1,139 @@ | |||||
| function AI(target, ballCnt, diff) | |||||
| currentTarget = evaluateClosestBall(target); | |||||
| print("CLOSEST TARGET IS " .. currentTarget) | |||||
| if diff < 1200 then | |||||
| print ("Normal targeting ".. currentTarget .. " " .. target.x - ball[currentTarget].x .. " " .. ball[currentTarget].y - target.y) | |||||
| if (ball[currentTarget].y - target.y >= target.height and target.x - ball[currentTarget].x < diff) then | |||||
| target.dy = AI_SPEED | |||||
| elseif (target.y - ball[currentTarget].y >= -target.height/2 and target.x - ball[currentTarget].x < diff) then | |||||
| target.dy = -AI_SPEED | |||||
| else | |||||
| target.dy = 0 | |||||
| end | |||||
| else | |||||
| print("Complex targeting") | |||||
| neededTarget = predictBall(ball[currentTarget], target.x) | |||||
| if neededTarget ~= -1 then | |||||
| print("Calculated target = " .. neededTarget) | |||||
| if (target.y - neededTarget >= -target.height/2) then | |||||
| target.dy = -AI_SPEED | |||||
| elseif (neededTarget - target.y >= target.height*0.9) then | |||||
| target.dy = AI_SPEED | |||||
| else | |||||
| target.dy = 0 | |||||
| end | |||||
| end | |||||
| end | |||||
| if | |||||
| difficultyl == 350 and player2reverbav == true and VIRTUAL_WIDTH - ball[currentTarget].x < 90 and | |||||
| math.abs(ball[currentTarget].y - targe.y) > 150 | |||||
| then | |||||
| sounds["time"]:play() | |||||
| player2reverbav = false | |||||
| timeIsSlow2 = true | |||||
| originalPaddle = paddle_SPEED | |||||
| originalSpeed = ballSpeed | |||||
| player2reverbav = 0 | |||||
| potentialnuke2 = 0 | |||||
| potentialstrike2 = 0 | |||||
| end | |||||
| if (player2nukescore > AI_STRIKEMOD and striken == 0) then | |||||
| player2striken = 1 | |||||
| elseif (player2nukescore > AI_NUKEMOD and striken == 1) then | |||||
| if (areanuclear == 1) then | |||||
| maxspeed = maxspeed + 50 | |||||
| end | |||||
| sounds["nuke"]:play() | |||||
| potentialstrike2 = 0 | |||||
| areanuclear = 1 | |||||
| ballSpeed = ballSpeed * 2 | |||||
| if (synctype == 0) then | |||||
| paddle_SPEED = paddle_SPEED * 2 | |||||
| end | |||||
| if (synctype == 1) then | |||||
| paddle_SPEED = ballSpeed / 10 | |||||
| end | |||||
| if (synctype == 0) then | |||||
| AI_SPEED = AI_SPEED * 2.2 | |||||
| end | |||||
| if (synctype == 1) then | |||||
| AI_SPEED = ballSpeed * 1.1 / 10 | |||||
| end | |||||
| player2nukescore = 0 | |||||
| player2reverbav = 0 | |||||
| potentialnuke2 = 0 | |||||
| end | |||||
| end | |||||
| function evaluateClosestBall(target) | |||||
| local ans = 0 | |||||
| local min = 99999; | |||||
| for i = 1, maxBalls do | |||||
| if math.abs(target.x - ball[i].x ) < min then | |||||
| min = math.abs(target.x - ball[i].x) | |||||
| ans = i | |||||
| end | |||||
| end | |||||
| return ans | |||||
| end | |||||
| function predictBall(target, px) | |||||
| print("BALLSTATS:" .. target.x .. " " .. target.y) | |||||
| if VIRTUAL_WIDTH - target.x < AI_SPEED then | |||||
| return target.y | |||||
| elseif target.dx > 0 then | |||||
| local ans = recursiveCalculations(px, target.x, target.y, target.dx, target.dy, 1) | |||||
| return ans | |||||
| else | |||||
| print("GO TO CENTER!!") | |||||
| return VIRTUAL_HEIGHT/2 | |||||
| end | |||||
| end | |||||
| function recursiveCalculations(px, ex, ey, edx, edy, ifspecial) | |||||
| if (edy > 0) then | |||||
| print ("normal" .. ex .." " .. ey .. " " .. edx .. " " .. edy) | |||||
| local time = (VIRTUAL_HEIGHT-ey) / (ballSpeed * edy) | |||||
| local distance = (ballSpeed * edx) * time | |||||
| print(distance .. " " .. edx .. " " .. time .. " " .. (px-ex)) | |||||
| if distance > (px - ex) then | |||||
| local anstime = (px - ex) / (ballSpeed * edx) | |||||
| local bonus = (ballSpeed * edy) * anstime | |||||
| print("results: " .. bonus .. " " .. edx .. " " .. anstime .. " " .. (px-ex)) | |||||
| -- if (ifspecial == 0) then | |||||
| return ey + bonus | |||||
| -- else | |||||
| -- return -1 | |||||
| --end | |||||
| else | |||||
| local emulatedx = ex + distance | |||||
| local emulatedy = VIRTUAL_HEIGHT | |||||
| return recursiveCalculations(px, emulatedx, emulatedy, edx, -edy, 0) | |||||
| end | |||||
| elseif edy == 0 then | |||||
| return ey | |||||
| else | |||||
| print ("inverse" .. ex .." " .. ey .. " " .. edx .. " " .. edy) | |||||
| local time = (ey) / math.abs((ballSpeed * edy)) | |||||
| local distance = (ballSpeed * edx) * time | |||||
| print(distance .. " " .. edx .. " " .. time .. " " .. (px-ex)) | |||||
| --print("Why th efuck ") | |||||
| if distance > (px - ex) then | |||||
| local anstime = (px - ex) / (ballSpeed * edx) | |||||
| local bonus = (ballSpeed * edy) * anstime | |||||
| print("results: " .. bonus .. " " .. edx .. " " .. anstime .. " " .. (px-ex)) | |||||
| -- if (ifspecial == 0) then | |||||
| return ey + bonus | |||||
| -- else | |||||
| -- return -1 | |||||
| -- end | |||||
| else | |||||
| local emulatedx = ex + distance | |||||
| local emulatedy = 0 | |||||
| -- print("results: " .. bonus .. " " .. edx .. " " .. anstime .. " " .. (VIRTUAL_WIDTH-ex)) | |||||
| return recursiveCalculations(px, emulatedx, emulatedy, edx, -edy, 0) | |||||
| end | |||||
| end | |||||
| end | |||||
| @@ -15,55 +15,7 @@ function basegame(dt) | |||||
| serveBot() | serveBot() | ||||
| if gameState == 'play' then | if gameState == 'play' then | ||||
| if (AGAINST_AI == 1) then | if (AGAINST_AI == 1) then | ||||
| for i = 1, maxBalls do | |||||
| if (ball[i].y - player2.y >= 50 and player2.x - ball[i].x < AI_LEVEL) then | |||||
| player2.dy = AI_SPEED | |||||
| elseif (player2.y - ball[i].y >= -20 and player2.x - ball[i].x < AI_LEVEL) then | |||||
| player2.dy = -AI_SPEED | |||||
| else | |||||
| player2.dy = 0 | |||||
| end | |||||
| if | |||||
| difficultyl == 350 and player2reverbav == true and VIRTUAL_WIDTH - ball[i].x < 90 and | |||||
| math.abs(ball[i].y - player2.y) > 150 | |||||
| then | |||||
| sounds["time"]:play() | |||||
| player2reverbav = false | |||||
| timeIsSlow2 = true | |||||
| originalPaddle = paddle_SPEED | |||||
| originalSpeed = ballSpeed | |||||
| player2reverbav = 0 | |||||
| potentialnuke2 = 0 | |||||
| potentialstrike2 = 0 | |||||
| end | |||||
| if (player2nukescore > AI_STRIKEMOD and striken == 0) then | |||||
| player2striken = 1 | |||||
| elseif (player2nukescore > AI_NUKEMOD and striken == 1) then | |||||
| if (areanuclear == 1) then | |||||
| maxspeed = maxspeed + 50 | |||||
| end | |||||
| sounds["nuke"]:play() | |||||
| potentialstrike2 = 0 | |||||
| areanuclear = 1 | |||||
| ballSpeed = ballSpeed * 2 | |||||
| if (synctype == 0) then | |||||
| paddle_SPEED = paddle_SPEED * 2 | |||||
| end | |||||
| if (synctype == 1) then | |||||
| paddle_SPEED = ballSpeed / 10 | |||||
| end | |||||
| if (synctype == 0) then | |||||
| AI_SPEED = AI_SPEED * 2.2 | |||||
| end | |||||
| if (synctype == 1) then | |||||
| AI_SPEED = ballSpeed * 1.1 / 10 | |||||
| end | |||||
| player2nukescore = 0 | |||||
| player2reverbav = 0 | |||||
| potentialnuke2 = 0 | |||||
| end | |||||
| end | |||||
| AI(player2, maxBalls, AI_LEVEL) | |||||
| end | end | ||||
| if (love.keyboard.isDown(p1control.up)) then | if (love.keyboard.isDown(p1control.up)) then | ||||
| player1.dy = (paddle_SPEED + p1bonus) * -1 | player1.dy = (paddle_SPEED + p1bonus) * -1 | ||||
| @@ -392,7 +344,7 @@ end | |||||
| function debugCheck(dt) | function debugCheck(dt) | ||||
| if (gameState == "menu") then | if (gameState == "menu") then | ||||
| updateTEXT = "0.7.2 Chalkboard Update" | |||||
| updateTEXT = "0.7.4 Chalkboard Update" | |||||
| end | end | ||||
| dangerChecker() | dangerChecker() | ||||
| elapsed = elapsed + dt | elapsed = elapsed + dt | ||||
| @@ -11,5 +11,6 @@ require 'animator' | |||||
| require 'src/baseGame' | require 'src/baseGame' | ||||
| require 'src/constantvars' | require 'src/constantvars' | ||||
| require 'src/menus' | require 'src/menus' | ||||
| require 'src/AI' | |||||
| require 'src/reverseGame' | require 'src/reverseGame' | ||||
| serialize = require 'ser' | serialize = require 'ser' | ||||