1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
|
--Gin Tonic v7 - No Comments, sorry :P
CT_ServeSelf = { 152, 163, 180, 195, 205, 240 }
CT_ServeOpp = { 140, 200, 240 }
CT_ServeIndex = 0
CT_Tolerance = 5
CT_Action = ""
CT_ShotDecision = 0
CT_NextGround = 9999
CT_LastTouches = 0
CT_LastHeight = 0
CT_WaitCounter = 0
CT_WaitName = ""
CT_WaitMoveTo = 0
function IsAt(position)
return (math.abs(posx()-position) <= CT_Tolerance)
end
function Wait(name, time, moveto)
if (CT_WaitName == name) then
if (CT_WaitCounter == 0) then
return false
end
end
CT_WaitCounter = time
CT_WaitName = name
CT_WaitMoveTo = moveto
return true
end
function WaitQueue()
if (CT_WaitCounter > 0) then
CT_WaitCounter = CT_WaitCounter - 1
if (CT_WaitMoveTo > 0) then
if (not IsAt(CT_WaitMoveTo)) then moveto(CT_WaitMoveTo) end
end
return true
else
return false
end
end
function ResetWait()
CT_WaitCounter = 0
CT_WaitName = ""
end
function OnOpponentServe()
if (CT_ServeIndex == 0) then
CT_ServeIndex = math.random(1,3)
end
if (not IsAt(CT_ServeOpp[CT_ServeIndex])) then moveto(CT_ServeOpp[CT_ServeIndex]) end
end
function OnServe(ballready)
if (WaitQueue()) then return end
if (CT_ServeIndex == 0) then
CT_ServeIndex = math.random(1,6)
end
if (ballready) then
if (Wait("ServeDelay",math.random(28,90),CT_ServeSelf[CT_ServeIndex]+math.random(-150, 150))) then return end
if (IsAt(CT_ServeSelf[CT_ServeIndex])) then
jump()
else
moveto(CT_ServeSelf[CT_ServeIndex])
end
else
if (posx() < 150) then
jump()
end
moveto(40)
end
end
function OnGame()
ResetWait()
CT_ServeIndex = 0
local timeJump = timeToHitHeight(380, 390, 20)
local timeGround = timeToHitHeight(200, 222, 40)
local timeBlock = timeToOppSmash(390)
local estimhx = r_estimx(timeJump)
local estimGround = r_estimx(timeGround)
local estimBlock = r_estimx(timeBlock)
local block = 0
local wallcoll = willHitWall(timeJump)
if (timeBlock ~= -1) then block = timeBlock+(estimBlock-400)/13 end
if (timeBlock == -1) then timeBlock = 9999 end
if (timeJump == -1) then estimhx = 9999 end
if (timeGround == -1) then estimGround = 210 end
if (posy() < CT_LastHeight and posy() > 150 and posy() < 330) then CT_Action = "" end
CT_LastHeight = posy()
if (CT_Action == "NetBlock") then
if ((posy() < 150) or (timeBlock < 4 and oppy() < 150) or (ballx() <= posx()) or (touches() <= 0 and bspeedx() > 10)) then
CT_Action = ""
else
jump()
moveto(400)
return
end
elseif (CT_Action == "JumpPlayFwd") then
if (posy() < 150) then
CT_Action = ""
else
if (estimhx == 9999) then estimhx = ballx()+bspeedx() end
jump()
if (posy() > 300) then
if (math.abs(bally()-posy()) < 18) then
moveto(ballx()+bspeedx())
elseif (estimhx < 200) then
if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(3,5) end
moveto(estimhx-10*CT_ShotDecision)
elseif (oppx() > 600 and oppy() < 150) then
if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(4,6) end
moveto(estimhx-10*CT_ShotDecision)
elseif (oppx() < 600 and oppy() > 180) then
moveto(estimhx-40)
else
moveto(estimhx-60)
end
else
moveto(estimhx-60)
end
return
end
elseif (CT_Action == "JumpPlayRev") then
if (posy() < 150 or touches() ~= CT_LastTouches) then
CT_Action = ""
else
if (estimhx == 9999) then estimhx = ballx()+bspeedx() end
jump()
if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(4,9) end
moveto(estimhx+5*CT_ShotDecision)
return
end
end
if (touches() ~= CT_LastTouches) then
CT_LastTouches = touches()
CT_NextGround = math.random(-20,20)
end
if (CT_Action == "") then
if ((ballx() < 400 or bspeedx() < -2) and estimGround < 400) then
if (touches() >= 2) then
moveto(estimGround+(posx()-500)/22)
elseif (math.abs(bspeedx()) > 8) then
moveto(estimGround)
else
moveto(estimGround+CT_NextGround)
end
elseif (estimhx < 600 and math.abs(bspeedx()) < 6) then
moveto(280)
elseif (estimhx > 650) then
moveto(250)
else
moveto(190)
end
end
if (posy() > 150) then return end
if (touches() > 2) then return end
if (timeBlock >= 17 and timeBlock <= 19) then
if (posx() > 210 and estimBlock > 395 and estimBlock < 640 and not wallcoll) then
jump()
moveto(400)
CT_Action = "NetBlock"
return
end
end
if (timeJump >= 17 and timeJump <= 19) then
if (bspeedx() <= 7 and estimhx >= 65 and estimhx <= 420 and posx()-estimhx <= 120 and (bspeedx() >= -7 or not wallcoll)) then
if (estimGround > 400 or bally() > 250) then
CT_Action = "JumpPlayFwd"
CT_ShotDecision = 0
jump()
end
end
if ((wallcoll or bspeedx() >= -7) and estimhx <= 250 and posx()-estimhx <= 180 and posx()-estimhx >= -120) then
if (estimGround > 400 or bally() > 250) then
if (CT_Action == "JumpPlayFwd" and (touches() >= 2 or math.random(100) > 15)) then return end
CT_Action = "JumpPlayRev"
CT_ShotDecision = 0
jump()
end
end
end
end
function timeToHitHeight(minheight, maxheight, depth)
local i = 0
for i=1, depth do
if (estimy(i) >= minheight and estimy(i) <= maxheight and estimx(i) <= 420) then
return i
end
end
return -1
end
function timeToOppSmash(height)
if (bally() < height) then return -1 end
local i = 0
for i=1, 17 do
if (estimy(i) < height) then
return i
end
end
return -1
end
function r_estimx(time)
local estim = estimx(time)
if estim < 31.5 then estim = 63-estim end
if estim > 768.5 then estim = 1537-estim end
if (bally() < 330) then
if (ballx() < 400 and estim > 400) then estim = 723-estim end
if (ballx() > 400 and estim < 400) then estim = 877-estim end
end
return estim
end
function willHitWall(time)
if (estimx(time) < 31.5) then return true end
return false
end
|