Guest User

Untitled

a guest
Jul 19th, 2015
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 211.41 KB | None | 0 0
  1. --<<Complete bot for Meepo(Full Version), made by Moones>>
  2.  
  3. --LIBRARIES--
  4.  
  5. require("libs.ScriptConfig")
  6. require("libs.Utils")
  7. require("libs.TargetFind")
  8. require("libs.Animations")
  9. require("libs.SkillShot")
  10. require("libs.AbilityDamage")
  11. require("libs.Res")
  12. require("libs.DrawManager3D")
  13.  
  14. --END of LIBRARIES--
  15.  
  16. --INFO--
  17.  
  18. --[[
  19. +-------------------------------------------------+
  20. | |
  21. | iMeepo Script - Made by Moones |
  22. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
  23. +-------------------------------------------------+
  24.  
  25. =+=+=+=+=+=+=+=+=+ VERSION 0.818 +=+=+=+=+=+=+=+=+=+
  26.  
  27. Description:
  28. ------------
  29.  
  30. - Script which controls Meepo for you. Goal was to acomplish automatic playing through whole game, but so far human control is still needed.
  31. - Hold N to kill enemy, Hold H to run away, If you are lanning with meepo press L.
  32.  
  33. TODO:
  34. ----
  35.  
  36. - Waypoints
  37. - AUTO FOUNTAIN DIVE - ......
  38. - BEHAVIOURS IN SPECIAL SITUATIONS - detect when your meepo could be ganked etc..
  39.  
  40. ]]--
  41.  
  42. ----Version
  43. local currentVersion = 0.818
  44. local Beta = ""
  45.  
  46. --END of INFO--
  47.  
  48. --SETTINGS--
  49.  
  50. ----ScriptConfig----
  51. local config = ScriptConfig.new()
  52. config:SetParameter("ChaseKey", "F", config.TYPE_HOTKEY)
  53. config:SetParameter("RetreatKey", "H", config.TYPE_HOTKEY)
  54. config:SetParameter("HealKey", "G", config.TYPE_HOTKEY)
  55. config:SetParameter("FarmJungleKey", "B", config.TYPE_HOTKEY)
  56. config:SetParameter("AllMeeposIdle", "V", config.TYPE_HOTKEY)
  57. config:SetParameter("Debug", "P", config.TYPE_HOTKEY)
  58. config:SetParameter("Lane", "L", config.TYPE_HOTKEY)
  59. config:SetParameter("PoofBindInDota", "W", config.TYPE_HOTKEY)
  60. config:SetParameter("EarthbindBindInDota", "Q", config.TYPE_HOTKEY)
  61. config:SetParameter("StopKeyBindInDota", "S", config.TYPE_HOTKEY)
  62. config:SetParameter("AllPoofToSelected", "U", config.TYPE_HOTKEY)
  63. config:SetParameter("Meepo1", 49, config.TYPE_HOTKEY) -- 49 is Key Code for 1
  64. config:SetParameter("Meepo2", 50, config.TYPE_HOTKEY) -- 50 is Key Code for 2 for all KeyCodes go to http://www.zynox.net/forum/threads/336-KeyCodes
  65. config:SetParameter("Meepo3", 51, config.TYPE_HOTKEY) -- 3
  66. config:SetParameter("Meepo4", 52, config.TYPE_HOTKEY) -- 4
  67. config:SetParameter("Meepo5", 53, config.TYPE_HOTKEY) -- 5
  68. config:SetParameter("EnableAutoBind", true, config.TYPE_BOOL)
  69. config:SetParameter("AutoGoFarmAfterChase", true, config.TYPE_BOOL)
  70. config:SetParameter("UseBoTs", true, config.TYPE_BOOL)
  71. config:SetParameter("AutoPush", true, config.TYPE_BOOL)
  72. config:SetParameter("MinHPToFightPercent", 50, config.TYPE_NUMBER)
  73. config:SetParameter("HPPercentToGoHealWhenHoldingKey", 50, config.TYPE_NUMBER)
  74. config:SetParameter("VersionInfoPosX", 680, config.TYPE_NUMBER)
  75. config:SetParameter("VersionInfoPosY", 820, config.TYPE_NUMBER)
  76. config:SetParameter("MinimapNumbersXMove", 0, config.TYPE_NUMBER)
  77. config:Load()
  78.  
  79. -----ScriptConfig Variables----
  80. local mainkey = config.ChaseKey
  81. local retreatkey = config.RetreatKey
  82. local farmJkey = config.FarmJungleKey
  83. local debugKey = config.Debug
  84. local idleKey = config.AllMeeposIdle
  85. local laneKey = config.Lane
  86. local meepo1 = config.Meepo1
  87. local meepo2 = config.Meepo2
  88. local meepo3 = config.Meepo3
  89. local meepo4 = config.Meepo4
  90. local meepo5 = config.Meepo5
  91. local minimapMove = config.MinimapNumbersXMove
  92. local minhp = config.MinHPToFightPercent
  93. local healpercent = config.HPPercentToGoHealWhenHoldingKey
  94. local healkey = config.HealKey
  95. local stop1 = config.PoofBindInDota
  96. local stop2 = config.EarthbindBindInDota
  97. local stop3 = config.StopKeyBindInDota
  98.  
  99. -----Local Script Variables----
  100. local reg = false local myId = nil local attack = 0 local move = 0 local start = false local meepoTable = {} local meepos = nil
  101. local active = true local monitor = client.screenSize.x/1920 local DWS = {} local castingEarthbind = {0,0,0,0,0,0,0} local poofDamage = { 0, 0 }
  102. local F14 = drawMgr:CreateFont("F14","Tahoma",client.screenSize.x*0.01,600) local meepoStateSigns = {} local base = nil local allies = nil local enemies = nil
  103. local meepoNumberSigns = {} local F15 = drawMgr:CreateFont("F15","Tahoma",50*monitor,600*monitor) local entitiesForPush = {} local meepoMinimapNumberSigns = {}
  104. local F13 = drawMgr:CreateFont("F13","Tahoma",16*monitor,600*monitor) local spellDamageTable = {} local visibleCamps = {} local campSigns = {}
  105. local outdated = false local F12 = drawMgr:CreateFont("F12","Tahoma",13*monitor,600*monitor) local versionSign = drawMgr:CreateText(config.VersionInfoPosX,config.VersionInfoPosY,0x66FF33FF,"",F14)
  106. local retreat = false local retreattime = nil local mousehoverCamp = nil local closestCamp = nil local retreatStartTime = nil local lichJumpRange = 575
  107. local dodgedistance = nil local dodgeradius = nil local aoeStarttime = nil local start,vec = nil,nil local infoSign = drawMgr:CreateText(config.VersionInfoPosX,config.VersionInfoPosY+20,-1,"",F12)
  108. local retreatkeyCount = 0 local doubleclickTime = nil local EthDmg = 0 local eff = nil local ctrl = 17 local gameTime = 0 local enemyTeam = nil local meTeam = nil
  109. local me = nil local player = nil local targetlock = false local statusText = drawMgr:CreateText(10*monitor,580*monitor,99333580,"",F14) statusText.visible = false local victim = nil
  110.  
  111. ----Local Meepo States----
  112. local STATE_NONE, STATE_CHASE, STATE_FARM_JUNGLE, STATE_FARM_LANE, STATE_LANE, STATE_PUSH, STATE_HEAL, STATE_ESCAPE, STATE_POOF_OUT, STATE_MOVE, STATE_STACK = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
  113.  
  114. ----States Signs----
  115. local statesSigns = {
  116. {"Idling", -1},
  117. {"Chasing", 0x17E317FF},
  118. {"Farming and Stacking Jungle", 0x65d9f7ff},
  119. {"Farming Lane", 0x3375ffff},
  120. {"Laninng", 0xbf00bfff},
  121. {"Pushing Lane", 0xf3f00bff},
  122. {"Healing", 0xff6b00ff},
  123. {"Escaping", 0xfe86c2ff},
  124. {"Poofing Out", 0x008321ff},
  125. {"Moving", 0xa46900ff},
  126. {"Stacking", 0xa89500ff}
  127. }
  128.  
  129. ----Jungle Camps positions, Stacks Positions----
  130. local JungleCamps = {
  131. {position = Vector(-1131,-4044,127), stackPosition = Vector(-2498.94,-3517.86,128), waitPosition = Vector(-1401.69,-3791.52,128), team = 2, id = 1, farmed = false, lvlReq = 8, visible = false, visTime = 0, stacking = false},
  132. {position = Vector(-366,-2945,127), stackPosition = Vector(-534.219,-1795.27,128), waitPosition = Vector(536,-3001,256), team = 2, id = 2, farmed = false, lvlReq = 3, visible = false, visTime = 0, stacking = false},
  133. {position = Vector(1606.45,-3433.36,256), stackPosition = Vector(1325.19,-5108.22,256), waitPosition = Vector(1541.87,-4265.38,256), team = 2, id = 3, farmed = false, lvlReq = 8, visible = false, visTime = 0, stacking = false},
  134. {position = Vector(3126,-3439,256), stackPosition = Vector(4410.49,-3985,256), waitPosition = Vector(3401.5,-4233.39,256), team = 2, id = 4, farmed = false, lvlReq = 3, visible = false, visTime = 0, stacking = false},
  135. {position = Vector(3031.03,-4480.06,256), stackPosition = Vector(1368.66,-5279.04,256), waitPosition = Vector(2939.61,-5457.52,256), team = 2, id = 5, farmed = false, lvlReq = 1, visible = false, visTime = 0, stacking = false},
  136. {position = Vector(-2991,191,256), stackPosition = Vector(-3483,-1735,247), waitPosition = Vector(-2433,-356,256), team = 2, id = 6, farmed = false, lvlReq = 12, visible = false, visTime = 0, ancients = true, stacking = false},
  137. {position = Vector(1167,3295,256), stackPosition = Vector(570.86,4515.96,256), waitPosition = Vector(1011,3656,256), team = 3, id = 7, farmed = false, lvlReq = 8, visible = false, visTime = 0, stacking = false},
  138. {position = Vector(-244,3629,256), stackPosition = Vector(-1170.27,4581.59,256), waitPosition = Vector(-515,4845,256), team = 3, id = 8, farmed = false, lvlReq = 3, visible = false, visTime = 0, stacking = false},
  139. {position = Vector(-1588,2697,127), stackPosition = Vector(-1302,3689.41,136.411), waitPosition = Vector(-1491,2986,127), team = 3, id = 9, farmed = false, lvlReq = 3, visible = false, visTime = 0, stacking = false},
  140. {position = Vector(-3157.74,4475.46,256), stackPosition = Vector(-3296.1,5508.48,256), waitPosition = Vector(-3086,4924,256), team = 3, id = 10, farmed = false, lvlReq = 1, visible = false, visTime = 0, stacking = false},
  141. {position = Vector(-4382,3612,256), stackPosition = Vector(-3026.54,3819.69,132.345), waitPosition = Vector(-3995,3984,256), team = 3, id = 11, farmed = false, lvlReq = 8, visible = false, visTime = 0, stacking = false},
  142. {position = Vector(4026,-709.943,128), stackPosition = Vector(2228.46,-1046.78,128), waitPosition = Vector(3122,-1158.69,128), team = 3, id = 12, farmed = false, lvlReq = 12, visible = false, visTime = 0, ancients = true, stacking = false}
  143. }
  144.  
  145. --END of SETTINGS--
  146.  
  147. --GLOBAL CONSTANTS--
  148.  
  149. ----Key Function
  150.  
  151. function Key(msg, code)
  152. local me = me
  153. local player = player
  154. if client.chat or client.console or Animations.maxCount < 1 or not PlayingGame() or client.shopOpen or me.health < 0 then return end
  155. if msg == RBUTTON_DOWN and shop() and client.mousePosition.x < 10000 then
  156. local selection = player.selection
  157. for h, smeepo in pairs(selection) do
  158. if meepoTable[smeepo.handle] and meepoTable[smeepo.handle].state ~= STATE_LANE and meepoTable[smeepo.handle].state ~= STATE_MOVE and meepoTable[smeepo.handle].state ~= STATE_NONE then
  159. --Updating state of meepo
  160. meepoTable[smeepo.handle].state = STATE_NONE
  161. end
  162. end
  163. elseif msg == LBUTTON_DOWN and client.mouseScreenPosition.x > 300 then
  164. local me = entityList:GetMyHero()
  165. if not me then return end
  166. local targetFind = targetFind
  167. local mOver = targetFind:GetClosestToMouse(me,999999)
  168. if mOver and GetDistance2D(mOver, client.mousePosition) < 300 then
  169. victim = mOver
  170. targetlock = true
  171. return false
  172. elseif victim then
  173. victim = nil
  174. targetlock = false
  175. return false
  176. end
  177. elseif msg == KEY_UP and not IsKeyDown(ctrl) then
  178. if code == mainkey or code == healkey then
  179. return true
  180. elseif code == farmJkey then
  181. local selection = player.selection
  182. for h, smeepo in pairs(selection) do
  183. if meepoTable[smeepo.handle] then
  184. --Updating state of meepo
  185. local distance = GetDistance2D
  186. local hovc = closestCamp and distance(client.mousePosition,closestCamp.position) < 100
  187. if meepoTable[smeepo.handle].state ~= STATE_STACK and meepoTable[smeepo.handle].state ~= STATE_HEAL and meepoTable[smeepo.handle].state ~= STATE_POOF_OUT and meepoTable[smeepo.handle].state ~= STATE_ESCAPE and
  188. (meepoTable[smeepo.handle].state ~= STATE_FARM_JUNGLE or hovc) then
  189. if hovc then
  190. meepoTable[smeepo.handle].camp = closestCamp
  191. meepoTable[smeepo.handle].hoveredCamp = true
  192. else
  193. meepoTable[smeepo.handle].camp = nil
  194. meepoTable[smeepo.handle].hoveredCamp = false
  195. end
  196. meepoTable[smeepo.handle].lastcamp = nil
  197. meepoTable[smeepo.handle].state = STATE_FARM_JUNGLE
  198. elseif meepoTable[smeepo.handle].state == STATE_FARM_JUNGLE or meepoTable[smeepo.handle].state == STATE_PUSH then
  199. meepoTable[smeepo.handle].camp = nil
  200. meepoTable[smeepo.handle].lastcamp = nil
  201. meepoTable[smeepo.handle].state = STATE_STACK
  202. else
  203. meepoTable[smeepo.handle].state = STATE_NONE
  204. end
  205. end
  206. end
  207. return true
  208. elseif code == stop1 or code == stop2 or code == stop3 then
  209. local selection = player.selection
  210. for h, smeepo in pairs(selection) do
  211. if meepoTable[smeepo.handle] and meepoTable[smeepo.handle].state ~= STATE_LANE and meepoTable[smeepo.handle].state ~= STATE_MOVE and meepoTable[smeepo.handle].state ~= STATE_NONE then
  212. --Updating state of meepo
  213. meepoTable[smeepo.handle].state = STATE_NONE
  214. end
  215. end
  216. elseif code == idleKey then
  217. for h, smeepo in pairs(meepoTable) do
  218. --Updating state of meepo
  219. if meepoTable[h] then
  220. meepoTable[h].state = STATE_NONE
  221. end
  222. end
  223. return true
  224. elseif code == laneKey then
  225. local selection = player.selection
  226. for h, smeepo in pairs(selection) do
  227. if meepoTable[smeepo.handle] then
  228. --Updating state of meepo
  229. if meepoTable[smeepo.handle].state ~= STATE_POOF_OUT and meepoTable[smeepo.handle].state ~= STATE_ESCAPE and
  230. meepoTable[smeepo.handle].state ~= STATE_LANE then
  231. meepoTable[smeepo.handle].state = STATE_LANE
  232. --print("laneKey")
  233. elseif meepoTable[smeepo.handle].state == STATE_LANE then
  234. meepoTable[smeepo.handle].state = STATE_NONE
  235. end
  236. end
  237. end
  238. return true
  239. elseif code == config.AllPoofToSelected then
  240. local selection = player.selection
  241. if not selection[1] then return end
  242. local selected = selection[1]
  243. for number,meepo in pairs(meepos) do
  244. local poof = meepoTable[meepo.handle].poof
  245. meepo:CastAbility(poof,selected.position)
  246. end
  247. return true
  248. elseif code == debugKey then
  249. SetDebugState(not IsDebugActive())
  250. return true
  251. elseif config.EnableAutoBind and (code == meepo1 or code == meepo2 or code == meepo3 or code == meepo4 or code == meepo5) and meepos then
  252. for number,meepo in pairs(meepos) do
  253. if meepo.alive then
  254. local meepoUlt = meepo:GetAbility(4)
  255. local meeponumber = (meepoUlt:GetProperty( "CDOTA_Ability_Meepo_DividedWeStand", "m_nWhichDividedWeStand" ) + 1)
  256. if code == meepo1 and meeponumber == 1 then
  257. SelectUnit(meepo)
  258. return true
  259. elseif code == meepo2 and meeponumber == 2 then
  260. SelectUnit(meepo)
  261. return true
  262. elseif code == meepo3 and meeponumber == 3 then
  263. SelectUnit(meepo)
  264. return true
  265. elseif code == meepo4 and meeponumber == 4 then
  266. SelectUnit(meepo)
  267. return true
  268. elseif code == meepo5 and meeponumber == 5 then
  269. SelectUnit(meepo)
  270. return true
  271. end
  272. end
  273. end
  274. elseif code == retreatkey then
  275. if retreatkeyCount == 0 then
  276. retreatkeyCount = 1
  277. elseif retreatkeyCount == 1 then
  278. retreatkeyCount = 2
  279. for number,meepo in pairs(meepoTable) do
  280. meepoTable[number].state = STATE_ESCAPE
  281. meepoTable[number].retreat = true
  282. end
  283. end
  284. return true
  285. end
  286. end
  287. end
  288.  
  289. ----Main tick function--
  290. function Main(tick)
  291.  
  292. gameTime = client.gameTime
  293.  
  294. --VersionInfo
  295. if gameTime > 1 then
  296. versionSign.visible = false
  297. infoSign.visible = false
  298. else
  299. local up,ver,beta,info = Version()
  300. if up then
  301. if beta ~= "" then
  302. versionSign.text = "Your version of iMeepo is up-to-date! (v"..currentVersion.." "..Beta..")"
  303. else
  304. versionSign.text = "Your version of iMeepo is up-to-date! (v"..currentVersion..")"
  305. end
  306. versionSign.color = 0x66FF33FF
  307. if info then
  308. infoSign.text = info
  309. infoSign.visible = true
  310. end
  311. end
  312. if outdated then
  313. if beta ~= "" then
  314. versionSign.text = "Your version of iMeepo is OUTDATED (Yours: v"..currentVersion.." "..Beta.." Current: v"..ver.." "..beta.."), send me email to moones@email.cz to get current one!"
  315. else
  316. versionSign.text = "Your version of iMeepo is OUTDATED (Yours: v"..currentVersion.." "..Beta.." Current: v"..ver.."), send me email to moones@email.cz to get current one!"
  317. end
  318. versionSign.color = 0xFF6600FF
  319. if info then
  320. infoSign.text = info
  321. infoSign.visible = true
  322. end
  323. end
  324. versionSign.visible = true
  325. end
  326.  
  327. if not PlayingGame() or Animations.maxCount < 1 then return end
  328.  
  329. --Local function variables
  330. local me = me local ID = me.classId if ID ~= myId then Close() end local player = player
  331. local DWSMain = me:GetAbility(4)
  332. local ethereal = me:FindItem("item_ethereal_blade") if not enemyTeam then enemyTeam = me:GetEnemyTeam() end
  333. local mOver = entityList:GetMouseover() local numberOfNotVisibleEnemies = 0 if not meTeam then meTeam = me.team end
  334. local allchase = false local myHand = me.handle local dangerousPosition = nil local distance = GetDistance2D
  335. local mathmin,mathmax,mathcos,mathsin,mathceil,mathrad,mathsqrt,mathabs,mathrad,mathfloor,mathatan,mathdeg = math.min,math.max,math.cos,math.sin,math.ceil,math.rad,math.sqrt,math.abs,math.rad,math.floor,math.atan,math.deg
  336. local mousePosition = client.mousePosition local latency = client.latency local IsKeyDown = IsKeyDown local aliveenemies = 0
  337.  
  338. --Collecting Meepos
  339. if me.alive then
  340. if (DWS and not DWS[1]) or (allies and #allies < 5) or (enemies and (#enemies < 5 or not enemies[5].hero)) then
  341. DWS[1] = DWSMain.level
  342. meepos = entityList:GetEntities({type = LuaEntity.TYPE_MEEPO, team = meTeam})
  343. allies = entityList:GetEntities({type = LuaEntity.TYPE_HERO, team = meTeam, illusion=false})
  344. --Get enemies
  345. enemies = entityList:GetEntities({type = LuaEntity.TYPE_HERO, team = enemyTeam, illusion = false})
  346. --Get Bear!!
  347. local bear = entityList:GetEntities({classId = CDOTA_Unit_SpiritBear, team = enemyTeam})[1]
  348. if bear then
  349. enemies[6] = bear
  350. end
  351. collectMeepos(meepos)
  352. elseif DWS[1] < DWSMain.level then
  353. meepos = entityList:GetEntities({type = LuaEntity.TYPE_MEEPO, team = meTeam})
  354. allies = entityList:GetEntities({type = LuaEntity.TYPE_HERO, team = meTeam})
  355. collectMeepos(meepos)
  356. DWS[1] = DWSMain.level
  357. elseif not DWS[2] and me:AghanimState() then
  358. meepos = entityList:GetEntities({type = LuaEntity.TYPE_MEEPO, team = meTeam})
  359. allies = entityList:GetEntities({type = LuaEntity.TYPE_HERO, team = meTeam})
  360. collectMeepos(meepos)
  361. DWS[2] = true
  362. end
  363. end
  364.  
  365. local meepos, enemies, allies = meepos, enemies, allies
  366. local tempmeepoTable = meepoTable
  367.  
  368. if not tempmeepoTable[myHand] then return end
  369.  
  370. local myInfo = tempmeepoTable[myHand]
  371.  
  372. --Getting Poof Damage
  373. local poofDamage2 = poofDamage
  374. local poof = myInfo.poof
  375. if poof and poof.level > 0 and (not poofDamage2 or poofDamage2[2] < poof.level) then
  376. poofDamage = { AbilityDamage.GetDamage(poof), poof.level }
  377. end
  378.  
  379. --SwitchingTreads back to agility
  380. SwitchTreads(true)
  381.  
  382. --KS with ethereal
  383. if ethereal and SleepCheck("eth") then
  384. EthDmg = AbilityDamage.GetDamage(ethereal)*1.4
  385. Sleep(10000,"eth")
  386. end
  387. local EthDmg = EthDmg
  388.  
  389. ----print(me.classId)
  390. --base
  391. if not base then
  392. base = entityList:GetEntities({classId = CDOTA_Unit_Fountain,team = meTeam})[1]
  393. end
  394.  
  395. --neutrals
  396. local neutrals = entityList:GetEntities({team=LuaEntity.TEAM_NEUTRAL})
  397.  
  398. if targetlock then
  399. if victim and victim.alive then
  400. statusText.text = "LOCKED on "..client:Localize(victim.name)
  401. else
  402. targetlock = false
  403. end
  404. statusText.visible = true
  405. local sizeX = (F14:GetTextSize(statusText.text).x)/2.5
  406. statusText.x = client.mouseScreenPosition.x-sizeX
  407. statusText.y = client.mouseScreenPosition.y-client.screenSize.x*0.01
  408. else
  409. statusText.visible = false
  410. end
  411.  
  412. --creeps
  413. entitiesForPush = {}
  414.  
  415. local lanecreeps = entityList:GetEntities({classId=CDOTA_BaseNPC_Creep_Lane,visible=true})
  416. local siege = entityList:GetEntities({classId=CDOTA_BaseNPC_Creep_Siege,team=enemyTeam,visible=true})
  417. local towers = entityList:GetEntities({classId=CDOTA_BaseNPC_Tower,visible=true})
  418. local ward = entityList:GetEntities({classId=CDOTA_BaseNPC_Venomancer_PlagueWard,team=enemyTeam,visible=true})
  419. local fam = entityList:GetEntities({classId=CDOTA_Unit_VisageFamiliar,team=enemyTeam,visible=true})
  420. local spider = entityList:GetEntities({classId=CDOTA_Unit_Broodmother_Spiderling,team=enemyTeam,visible=true})
  421. local boar = entityList:GetEntities({classId=CDOTA_Unit_Hero_Beastmaster_Boar,team=enemyTeam,visible=true})
  422. local forg = entityList:GetEntities({classId=CDOTA_BaseNPC_Invoker_Forged_Spirit,team=enemyTeam,visible=true})
  423. --local build = entityList:GetEntities({classId=CDOTA_BaseNPC_Building,team=enemyTeam,visible=true})
  424. local racks = entityList:GetEntities({classId=CDOTA_BaseNPC_Barracks,team=enemyTeam,visible=true})
  425.  
  426. local alliedUnit = nil
  427. local entitiesForPushCount = 0
  428. for i = 1, #lanecreeps do local v = lanecreeps[i] if not v:IsInvul() and v.team ~= meTeam and v.alive and not v:IsAttackImmune() and v.spawned then entitiesForPushCount = entitiesForPushCount + 1 entitiesForPush[entitiesForPushCount] = v end
  429.  
  430. --Allied unit
  431. if v.team == meTeam and v.health > v.maxHealth*0.5 and (not alliedUnit or v.health > alliedUnit.health) then
  432. alliedUnit = v
  433. end
  434. end
  435. for i = 1, #siege do local v = siege[i] if not v:IsInvul() and v.team ~= meTeam and v.alive and not v:IsAttackImmune() and v.spawned then entitiesForPushCount = entitiesForPushCount + 1 entitiesForPush[entitiesForPushCount] = v end end
  436. for i = 1, #towers do local v = towers[i] if not v:IsInvul() and v.team ~= meTeam and v.alive and not v:IsAttackImmune() then entitiesForPushCount = entitiesForPushCount + 1 entitiesForPush[entitiesForPushCount] = v end end
  437. for i = 1, #ward do local v = ward[i] if not v:IsInvul() and v.team ~= meTeam and v.alive and not v:IsAttackImmune() then entitiesForPushCount = entitiesForPushCount + 1 entitiesForPush[entitiesForPushCount] = v end end
  438. for i = 1, #fam do local v = fam[i] if not v:IsInvul() and v.team ~= meTeam and v.alive and not v:IsAttackImmune() then entitiesForPushCount = entitiesForPushCount + 1 entitiesForPush[entitiesForPushCount] = v end end
  439. for i = 1, #spider do local v = spider[i] if not v:IsInvul() and v.team ~= meTeam and v.alive and not v:IsAttackImmune() then entitiesForPushCount = entitiesForPushCount + 1 entitiesForPush[entitiesForPushCount] = v end end
  440. for i = 1, #boar do local v = boar[i] if not v:IsInvul() and v.team ~= meTeam and v.alive and not v:IsAttackImmune() then entitiesForPushCount = entitiesForPushCount + 1 entitiesForPush[entitiesForPushCount] = v end end
  441. for i = 1, #forg do local v = forg[i] if not v:IsInvul() and v.team ~= meTeam and v.alive and not v:IsAttackImmune() then entitiesForPushCount = entitiesForPushCount + 1 entitiesForPush[entitiesForPushCount] = v end end
  442. for i = 1, #racks do local v = racks[i] if not v:IsInvul() and v.team ~= meTeam and v.alive and not v:IsAttackImmune() then entitiesForPushCount = entitiesForPushCount + 1 entitiesForPush[entitiesForPushCount] = v end end
  443.  
  444. local entitiesForPush = entitiesForPush
  445.  
  446. --Reseting farmed/visible/stacking state of camps
  447. local drawMgr3D = drawMgr3D
  448. local tempJungleCamps = JungleCamps
  449. for i = 1, #tempJungleCamps do
  450. local camp = tempJungleCamps[i]
  451. local block = false
  452. local farmed = true
  453. for k = 1, #neutrals do
  454. local ent = neutrals[k]
  455. if ent.health and ent.alive and ent.visible and ent.spawned and distance(ent,camp.position) < 800 then
  456. farmed = false
  457. JungleCamps[camp.id].farmed = false
  458. tempJungleCamps = JungleCamps
  459. end
  460. end
  461. for m = 1, #allies do
  462. local v = allies[m]
  463. if distance(v,camp.position) < 500 and v.alive then
  464. block = true
  465. end
  466. if farmed and distance(v,camp.position) < 300 then
  467. JungleCamps[camp.id].farmed = true
  468. tempJungleCamps = JungleCamps
  469. end
  470. if distance(v,camp.position) < 500 then
  471. JungleCamps[camp.id].visible = v.visibleToEnemy
  472. tempJungleCamps = JungleCamps
  473. end
  474. end
  475. if gameTime < 30 then
  476. JungleCamps[camp.id].farmed = true
  477. tempJungleCamps = JungleCamps
  478. end
  479. if (gameTime % 60 > 0.5 and gameTime % 60 < 2) or (gameTime > 30 and gameTime < 32) then
  480. if camp.farmed then
  481. if not block then
  482. JungleCamps[camp.id].farmed = false
  483. tempJungleCamps = JungleCamps
  484. end
  485. end
  486. if camp.stacking then
  487. JungleCamps[camp.id].stacking = false
  488. tempJungleCamps = JungleCamps
  489. end
  490. end
  491. if camp.visible then
  492. if (gameTime - camp.visTime) > 30 then
  493. JungleCamps[camp.id].visible = false
  494. tempJungleCamps = JungleCamps
  495. end
  496. end
  497. if not campSigns[camp.id] then
  498. campSigns[camp.id] = drawMgr3D:CreateText(camp.position, Vector(0,0,0), Vector2D(0,0), 0x66FF33FF, "Camp Available!", F14)
  499. else
  500. if tempJungleCamps[camp.id].farmed then
  501. campSigns[camp.id].drawObj.text = "Camp farmed!"
  502. campSigns[camp.id].drawObj.color = 0xFF6600FF
  503. elseif tempJungleCamps[camp.id].visible then
  504. campSigns[camp.id].drawObj.text = "Camp visible!"
  505. campSigns[camp.id].drawObj.color = 0xFFFF00FF
  506. else
  507. campSigns[camp.id].drawObj.text = "Camp available!"
  508. campSigns[camp.id].drawObj.color = 0x66FF33FF
  509. end
  510. end
  511. if not closestCamp or distance(mousePosition,closestCamp.position) > distance(mousePosition,camp.position) then
  512. closestCamp = camp
  513. end
  514. end
  515.  
  516. local closestCamp = closestCamp
  517. local tempmousehoverCamp = mousehoverCamp
  518. --Hovered camp
  519. if closestCamp and distance(mousePosition,closestCamp.position) < 100 then
  520. if not tempmousehoverCamp then
  521. mousehoverCamp = drawMgr3D:CreateText(closestCamp.position, Vector(0,0,0), Vector2D(0,15), -1, "Farm this CAMP? Press "..string.char(farmJkey), F14)
  522. else
  523. mousehoverCamp.pos = closestCamp.position
  524. end
  525. elseif tempmousehoverCamp then
  526. mousehoverCamp.drawObj.visible = false
  527. end
  528.  
  529. --Sorting Enemies
  530. -- if #enemies > 1 then
  531. -- table.sort(enemies, function (a,b) return a.health*(1/(1-a.dmgResist)) > b.health*(1/(1-b.dmgResist)) end)
  532. -- end
  533.  
  534. local Lich = nil
  535. local Pudge = nil
  536. local Jakiro = nil
  537. local Mirana = nil
  538. local Invoker = nil
  539. local Kunkka = nil
  540.  
  541. --Enemies loop
  542. for vNum = 1, #enemies do
  543. local enemy = enemies[vNum]
  544. if not (client.shopOpen or client.paused) and me.alive and not IsKeyDown(ctrl) then
  545.  
  546. if not enemy.visible and enemy.alive and not enemy:IsIllusion() then
  547. numberOfNotVisibleEnemies = numberOfNotVisibleEnemies + 1
  548. end
  549.  
  550. if not enemy:IsIllusion() and enemy.alive and enemy.health > 0 then
  551. if not dangerousPosition then
  552. dangerousPosition = enemy.position
  553. else
  554. dangerousPosition = dangerousPosition + enemy.position
  555. end
  556. aliveenemies = aliveenemies + 1
  557. end
  558.  
  559.  
  560. if enemy.visible and (enemy.hero or enemy.classId == CDOTA_Unit_SpiritBear) and enemy.alive and not enemy:IsIllusion() then
  561.  
  562. --Determining main enemy
  563. if not (mOver and (mOver.hero or mOver.classId == CDOTA_Unit_SpiritBear) and mOver.alive and mOver.team == enemyTeam and not mOver:IsIllusion()) then
  564. if not targetlock and ((not victim or (victim.health*(1/(1-victim.dmgResist))) > (enemy.health*(1/(1-enemy.dmgResist)))) and distance(mousePosition,enemy) < client.screenSize.x) then
  565. victim = enemy
  566. end
  567. if not targetlock and (distance(mousePosition,enemy) < 300 and (not victim or distance(mousePosition,enemy) < distance(mousePosition,victim))) then
  568. victim = enemy
  569. end
  570. end
  571.  
  572. --Ethereal KS
  573. if SleepCheck("ethereal") and ethereal and canCast(me, ethereal) and distance(me,enemy) <= ethereal.castRange+100 then
  574. local ethDmgTaken = enemy:DamageTaken(EthDmg,DAMAGE_MAGC,me)
  575. if ethDmgTaken >= enemy.health and (enemy.health > ethDmgTaken*0.5 or distance(me,enemy) > (ethereal.castRange*0.5)+50) then
  576. me:CastAbility(ethereal, enemy)
  577. Sleep(100+latency, myHand.."-casting")
  578. Sleep(200,"ethereal")
  579. end
  580. end
  581.  
  582. --Hex
  583. if SleepCheck("hex") and not enemy:IsMagicImmune() and (myInfo.state == STATE_CHASE or myInfo.state == STATE_ESCAPE or myInfo.state == STATE_HEAL) and
  584. (enemy.hero or enemy.classId == CDOTA_Unit_SpiritBear) and enemy.classId ~= CDOTA_BaseNPC_Creep_Neutral then
  585. local hex = me:FindItem("item_sheepstick")
  586. if canCast(me, hex) and chainEarthbind(me, enemy, me:GetTurnTime(enemy), meepos) and distance(me,enemy) <= hex.castRange+25 then
  587. me:CastAbility(hex,enemy)
  588. Sleep(me:GetTurnTime(enemy)*1000,myHand.."-casting")
  589. Sleep(me:GetTurnTime(enemy)*1000+500,"hex")
  590. end
  591. end
  592.  
  593. --Cast Earthbind
  594. if not enemy:IsMagicImmune() and (enemy.hero or enemy.classId == CDOTA_Unit_SpiritBear) then
  595. local closest = getClosest(enemy,1,true,nil,meepos, distance)
  596. if closest and (closest ~= me or not (myInfo.blink and canCast(me,myInfo.blink) and distance(me, enemy) > 700)) and distance(closest,enemy) < 2000 then
  597. local hand = closest.handle
  598. local info = tempmeepoTable[hand]
  599. local earthbind = info.earthbind
  600. local delay = earthbind:FindCastPoint()*1000 + latency + closest:GetTurnTime(enemy)*1000
  601. local speed = earthbind:GetSpecialData("speed", earthbind.level)
  602. local prediction = SkillShot.SkillShotXYZ(closest,enemy,delay,speed)
  603. local radius = earthbind:GetSpecialData("radius", earthbind.level)
  604.  
  605. --checking if enemy is casting
  606. local castingspell = false
  607. for i = 1, #enemy.abilities do
  608. local v = enemy.abilities[i]
  609. local cp = v:FindCastPoint()
  610. if v.abilityPhase and cp >= (distance(closest,enemy)-radius+25)/857 and Animations.getDuration(v)/1000 <= cp/3 then
  611. castingspell = true
  612. end
  613. end
  614.  
  615. if SleepCheck(hand.."-casting") and earthbind and not earthbind.abilityPhase and (((info.state ~= STATE_NONE and info.state ~= STATE_MOVE and info.state ~= STATE_LANE) and (info.state ~= STATE_FARM_JUNGLE or closest.visibleToEnemy))) then
  616. if canCast(closest,earthbind) and prediction and
  617. distance(closest, prediction) <= earthbind.castRange+(radius/2) and ((gameTime > castingEarthbind[vNum] and chainEarthbind(closest, enemy, delay/1000+distance(closest,prediction)/speed, meepos)) or enemy:IsChanneling() or castingspell) then
  618. if distance(prediction,closest) > earthbind.castRange+25 then
  619. prediction = (prediction - closest.position) * (earthbind.castRange - radius) / distance(prediction,closest) + closest.position
  620. end
  621. if distance(enemy,prediction) <= (radius/2)-50 and distance(enemy,prediction) < (radius/2)-50 then
  622. prediction = enemy.position
  623. end
  624. ----print(meepoTable[closest.handle].earthbind.castRange, distance(closest, prediction))
  625. if distance(closest, prediction) <= earthbind.castRange+25 then
  626. meepoTable[hand].prediction = {prediction,enemy.handle}
  627. tempmeepoTable = meepoTable
  628. closest:CastAbility(earthbind, prediction)
  629. castingEarthbind[vNum] = gameTime + delay/1000 + distance(closest,prediction)/speed + 1
  630. Sleep(earthbind:FindCastPoint()*1000,hand.."-casting")
  631. end
  632. end
  633. end
  634. end
  635. end
  636.  
  637. local near,dist,nearMeepo = anyMeepoisNear(enemy, 1000, nil, meepos, distance, mathcos, mathsin)
  638. local hand = nil
  639. if nearMeepo then hand = nearMeepo.handle end
  640. local info = tempmeepoTable[hand]
  641. --Escape mode
  642. if (enemy.hero or enemy.classId == CDOTA_Unit_SpiritBear) and near and nearMeepo and nearMeepo.alive and info and info.state ~= STATE_ESCAPE then
  643. --if (player.selection[1].handle ~= nearMeepo.handle or meepoTable[nearMeepo.handle].state == STATE_CHASE) then
  644. local inc = 0--IncomingDamage(enemy,false)
  645. local channel = enemy:GetChanneledAbility()
  646. local pooftaken = enemy:DamageTaken(poofDamage[1],DAMAGE_MAGC,me)
  647. if (inc >= enemy.health or enemy.health < pooftaken*getAliveNumber(false,meepos)) or (channel and (channel.name == "item_travel_boots" or channel.name == "item_tpscroll")) then
  648. if info.state ~= STATE_ESCAPE and near and distance(nearMeepo,enemy) < 400 and (info.state == STATE_FARM_JUNGLE or info.state == STATE_NONE or info.state == STATE_MOVE or info.state == STATE_CHASE or info.state == STATE_PUSH) then
  649. DebugPrint("EscapeC")
  650. allchase = enemy
  651. if SleepCheck("pingdanger") then
  652. client:Ping(Client.PING_NORMAL,enemy.position)
  653. Sleep(7000,"pingdanger")
  654. end
  655. end
  656. else
  657. local meinc = 0--IncomingDamage(nearMeepo,false)
  658. if (player.selection[1].handle ~= hand or (info.state ~= STATE_CHASE or not IsKeyDown(mainkey))) and nearMeepo.health < nearMeepo.maxHealth*(minhp/100) and enemy.health > pooftaken*getAliveNumber(false,meepos) then
  659. if near and (info.state == STATE_FARM_JUNGLE or info.state == STATE_NONE or info.state == STATE_MOVE or info.state == STATE_CHASE or info.state == STATE_PUSH) and ((nearMeepo.visibleToEnemy and 500) or (distance(nearMeepo,enemy) < enemy.attackRange and gameTime > 1200)) then
  660. DebugPrint("EscapeE")
  661. if nearMeepo.health < 300 or info.state ~= STATE_CHASE then
  662. meepoTable[hand].lastState = info.state
  663. meepoTable[hand].state = STATE_ESCAPE
  664. tempmeepoTable = meepoTable
  665. if SleepCheck("ping") then
  666. client:Ping(Client.PING_DANGER,enemy.position)
  667. Sleep(7000,"ping")
  668. end
  669. Sleep(4000,hand.."-escape")
  670. end
  671. end
  672. end
  673. end
  674. -- elseif meepoTable[nearMeepo.handle].state ~= STATE_NONE and meepoTable[nearMeepo.handle].state ~= STATE_MOVE and nearMeepo.visibleToEnemy then
  675. -- meepoTable[nearMeepo.handle].state = STATE_NONE
  676. -- end
  677. end
  678. end
  679. --Sleep(1000,enemy.handle)
  680. end
  681.  
  682. --Recognizing dangerous enemies
  683. if enemy.classId == CDOTA_Unit_Hero_Lich then
  684. Lich = enemy
  685. elseif enemy.classId == CDOTA_Unit_Hero_Pudge then
  686. Pudge = enemy
  687. elseif enemy.classId == CDOTA_Unit_Hero_Jakiro then
  688. Jakiro = enemy
  689. elseif enemy.classId == CDOTA_Unit_Hero_Invoker then
  690. Invoker = enemy
  691. elseif enemy.classId == CDOTA_Unit_Hero_Kunkka then
  692. Kunkka = enemy
  693. elseif enemy.classId == CDOTA_Unit_Hero_Mirana then
  694. Mirana = enemy
  695. end
  696.  
  697. end
  698.  
  699. if dangerousPosition then
  700. dangerousPosition = dangerousPosition/#enemies
  701. end
  702.  
  703. local cast = {}
  704.  
  705. if Invoker or Kunkka or Mirana then
  706. cast = entityList:GetEntities({classId=CDOTA_BaseNPC})
  707. end
  708.  
  709. --Lich Chain Frost
  710. local projectiles = entityList:GetProjectiles({})
  711. local chainFrost = nil
  712. if Lich then
  713. local chainfrost = Lich:GetAbility(4)
  714. if chainfrost and chainfrost.cd > 0 then
  715. for i = 1, #projectiles do
  716. local v = projectiles[i]
  717. if v.speed == 750 then
  718. chainFrost = v
  719. end
  720. end
  721. end
  722. end
  723.  
  724. --LineDodge variables
  725. local linedodge = false
  726. local linedodgeHero = nil
  727. local dodgespeed = 0
  728.  
  729. --Pudge Hook
  730. if Pudge then
  731. local hook = Pudge:GetAbility(1)
  732. if hook and hook.abilityPhase and Animations.getDuration(hook) >= 50 then
  733. linedodge = true
  734. linedodgeHero = Pudge
  735. dodgeradius = hook:GetSpecialData("hook_width",hook.level)
  736. dodgedistance = hook:GetSpecialData("hook_distance",hook.level) + dodgeradius + 50
  737. dodgespeed = hook:GetSpecialData("hook_speed",hook.level)
  738. end
  739. end
  740.  
  741. --Jakiro IcePath
  742. if Jakiro then
  743. local IcePath = Jakiro:GetAbility(2)
  744. if IcePath and IcePath.abilityPhase and Animations.getDuration(IcePath) >= 50 then
  745. linedodge = true
  746. linedodgeHero = Jakiro
  747. dodgeradius = IcePath:GetSpecialData("path_radius",IcePath.level) - 100
  748. dodgedistance = 1100 + dodgeradius + 50
  749. dodgespeed = 1000 - 100*IcePath.level
  750. end
  751. end
  752.  
  753. --Mirana arrow
  754. local arrow = nil
  755. if Mirana then
  756. arrow = FindEntity(cast,me,650,nil)
  757. if arrow then
  758. if not start then
  759. start = arrow.position
  760. end
  761. if arrow.visibleToEnemy and not vec then
  762. vec = arrow.position
  763. if distance(vec,start) < 50 then
  764. vec = nil
  765. end
  766. end
  767. if start and vec then
  768. linedodge = true
  769. dodgeradius = 10
  770. dodgespeed = 857
  771. end
  772. elseif start then
  773. start,vec = nil,nil
  774. end
  775. end
  776.  
  777. --Kunkka torrent
  778. local torrent = nil
  779. if Kunkka then
  780. torrent = FindEntity(cast,me,nil,"modifier_kunkka_torrent_thinker")
  781. if torrent then
  782. if not aoeStarttime then
  783. aoeStarttime = gameTime
  784. end
  785. elseif aoeStarttime and gameTime - aoeStarttime > 1.5 then aoeStarttime = nil
  786. end
  787. end
  788.  
  789. --Invoker Sunstrike
  790. local sunstrike = nil
  791. if Invoker then
  792. sunstrike = FindEntity(cast,me,nil,"modifier_invoker_sun_strike")
  793. if sunstrike then
  794. if not aoeStarttime then
  795. aoeStarttime = gameTime
  796. end
  797. elseif aoeStarttime and gameTime - aoeStarttime > 1.7 then aoeStarttime = nil
  798. end
  799. end
  800.  
  801. --If we are hovering someone with mouse then they are our main victim
  802. if not targetlock and mOver and (mOver.hero or mOver.classId == CDOTA_Unit_SpiritBear) and mOver.alive and mOver.team == enemyTeam and not mOver:IsIllusion() then
  803. victim = mOver
  804. end
  805.  
  806. --Retreat
  807. local lowest = nil
  808. local lowHandle = nil
  809. if IsKeyDown(retreatkey) and not client.chat and not IsKeyDown(ctrl) then
  810. lowest = getLowestHPMeepo(meepos)
  811. if lowest then
  812. lowHandle = lowest.handle
  813. meepoTable[lowHandle].state = STATE_ESCAPE
  814. meepoTable[lowHandle].retreat = true
  815. tempmeepoTable = meepoTable
  816. end
  817. retreat = true
  818. if not retreatStartTime then
  819. retreatStartTime = gameTime
  820. end
  821. elseif not retreattime and retreat then
  822. retreattime = gameTime
  823. retreatStartTime = nil
  824. elseif retreat and retreattime and gameTime - retreattime > 3 then
  825. retreat = false
  826. retreattime = nil
  827. retreatStartTime = nil
  828. end
  829.  
  830. --doubleclick Retreat
  831. if retreatkeyCount == 2 then
  832. if not doubleclickTime then
  833. doubleclickTime = gameTime
  834. elseif gameTime - doubleclickTime > 20 or ((IsKeyDown(mainkey) or IsKeyDown(healkey)) and not client.chat) then
  835. doubleclickTime = nil
  836. retreatkeyCount = 0
  837. end
  838. elseif retreatkeyCount == 1 then
  839. if not doubleclickTime then
  840. doubleclickTime = gameTime
  841. elseif gameTime - doubleclickTime > 0.5 or ((IsKeyDown(mainkey) or IsKeyDown(healkey)) and not client.chat) then
  842. doubleclickTime = nil
  843. retreatkeyCount = 0
  844. end
  845. end
  846.  
  847. --Cycling through our meepos
  848. for i = 1, #meepos do
  849. local meepo = meepos[i]
  850. local meepoHandle = meepo.handle
  851. local meepoUlt = meepo:GetAbility(4)
  852. local meeponumber = (meepoUlt:GetProperty( "CDOTA_Ability_Meepo_DividedWeStand", "m_nWhichDividedWeStand" ) + 1)
  853. local info = tempmeepoTable[meepoHandle]
  854. if not meepo:IsChanneling() and not (client.shopOpen or client.paused or IsKeyDown(ctrl)) and info then
  855.  
  856. if allchase then
  857. if info.state ~= STATE_HEAL and meepo.alive and meepo.health > (meepo.maxHealth/100)*minhp then
  858. meepoTable[meepoHandle].victim = allchase
  859. meepoTable[meepoHandle].state = STATE_CHASE
  860. else
  861. meepoTable[meepoHandle].victim = nil
  862. end
  863. tempmeepoTable = meepoTable
  864. info = tempmeepoTable[meepoHandle]
  865. end
  866. if meepo.alive then
  867.  
  868. --Earthbind cancel
  869. local earthbind = info.earthbind
  870. local EBprediction = info.prediction
  871. if earthbind.abilityPhase and EBprediction and SleepCheck(meepoHandle.."-cancel") then
  872. local enemy = entityList:GetEntity(EBprediction[2])
  873. local delay = earthbind:FindCastPoint()*1000 + latency + meepo:GetTurnTime(enemy)*1000
  874. local speed = earthbind:GetSpecialData("speed", earthbind.level)
  875. local prediction = SkillShot.SkillShotXYZ(meepo,enemy,delay,speed)
  876. local radius = earthbind:GetSpecialData("radius", earthbind.level)
  877. if prediction and distance(prediction,meepo) < earthbind.castRange+(radius/2) then
  878. if distance(prediction,meepo) > earthbind.castRange+25 then
  879. prediction = (prediction - meepo.position) * (earthbind.castRange - radius) / distance(prediction,meepo) + meepo.position
  880. end
  881. if distance(enemy,prediction) <= (radius/2)-50 and distance(enemy,prediction) < (radius/2)-50 then
  882. prediction = enemy.position
  883. end
  884. if distance(EBprediction[1],prediction) > radius+50 then
  885. meepo:Stop()
  886. meepo:CastAbility(earthbind,prediction)
  887. Sleep(delay - latency,meepoHandle.."-casting")
  888. Sleep(1000,meepoHandle.."-cancel")
  889. end
  890. end
  891. end
  892.  
  893. --Kunkka Torrent dodge
  894. if torrent and SleepCheck(meepoHandle.."torrent") and distance(meepo,torrent) <= 320 then
  895. AOEDodge(meepo, torrent.position, 320,mathfloor, mathsqrt)
  896. Sleep(1600-((gameTime-aoeStarttime)*1000)+latency,meepoHandle.."-move")
  897. Sleep(1600-((gameTime-aoeStarttime)*1000)+latency,meepoHandle.."-casting")
  898. Sleep(1600-((gameTime-aoeStarttime)*1000)+latency,meepoHandle.."-attack")
  899. Sleep(1600-((gameTime-aoeStarttime)*1000)+latency,meepoHandle.."torrent")
  900. end
  901.  
  902. --Invoker Sunstrike Dodge
  903. if sunstrike and SleepCheck(meepoHandle.."sunstrike") and distance(meepo,sunstrike) <= 270 then
  904. AOEDodge(meepo, sunstrike.position, 270,mathfloor, mathsqrt)
  905. Sleep(1600-((gameTime-aoeStarttime)*1000)+latency,meepoHandle.."-move")
  906. Sleep(1600-((gameTime-aoeStarttime)*1000)+latency,meepoHandle.."-casting")
  907. Sleep(1600-((gameTime-aoeStarttime)*1000)+latency,meepoHandle.."-attack")
  908. Sleep(1600-((gameTime-aoeStarttime)*1000)+latency,meepoHandle.."sunstrike")
  909. end
  910.  
  911. --Line dodge
  912. if linedodge and dodgedistance and dodgeradius and SleepCheck(meepoHandle.."dodge") and linedodgeHero then
  913. LineDodge(meepo, Vector(linedodgeHero.position.x + dodgedistance * mathcos(linedodgeHero.rotR), linedodgeHero.position.y + dodgedistance * mathsin(linedodgeHero.rotR), linedodgeHero.position.z), linedodgeHero.position, dodgeradius, (distance(linedodgeHero,meepo)/dodgespeed)*1000+latency,mathfloor, mathsqrt, mathabs)
  914. end
  915.  
  916. --Arrow dodge
  917. if linedodge and arrow and SleepCheck(meepoHandle.."dodge") and start then
  918. local distance2 = FindAB(start,vec,distance(meepo,start)*10,mathdeg, mathatan, mathabs, mathrad, mathcos, mathsin)
  919. --check for block
  920. if distance(meepo, start) <= (distance(start,distance2) + dodgeradius + 25) and distance(arrow,start) <= distance(meepo,start) then
  921. --dodge
  922. LineDodge(meepo, distance2, start, dodgeradius, (distance(arrow.position,meepo)/dodgespeed)*1000+latency,mathfloor, mathsqrt, mathabs)
  923. end
  924. end
  925.  
  926. --Lich Ulti Split
  927. if chainFrost and SleepCheck(meepoHandle.."chainfrost") and info.state ~= STATE_CHASE then
  928. local target = chainFrost.target
  929. if target and target ~= meepo then
  930. local dist = distance(target,meepo)
  931. if dist < lichJumpRange then
  932. local pos = target.position + ((meepo.position - target.position)*(lichJumpRange + 10)/dist)
  933. meepo:Move(pos)
  934. Sleep(50+latency,meepoHandle.."chainfrost")
  935. Sleep((distance(pos,meepo)/meepo.movespeed)*1000+latency,meepoHandle.."-move")
  936. Sleep((distance(pos,meepo)/meepo.movespeed)*1000+latency,meepoHandle.."-casting")
  937. end
  938. else
  939. FindOptimalPlaceAgainstChainFrost(meepo,distance,mathsqrt)
  940. Sleep(50+latency,meepoHandle.."chainfrost")
  941. end
  942. end
  943.  
  944. --Retreat
  945. if not IsKeyDown(ctrl) and IsKeyDown(retreatkey) and not client.chat then
  946. if retreatStartTime then
  947. if lowest and lowHandle ~= meepoHandle then
  948. if (meepo.health <= meepo.maxHealth*0.5 or (gameTime - retreatStartTime) > 3) then
  949. meepoTable[meepoHandle].state = STATE_ESCAPE
  950. meepoTable[meepoHandle].retreat = true
  951. else
  952. meepoTable[meepoHandle].state = STATE_CHASE
  953. end
  954. tempmeepoTable = meepoTable
  955. info = tempmeepoTable[meepoHandle]
  956. end
  957. end
  958. end
  959.  
  960. if info.state ~= STATE_CHASE and info.state ~= STATE_POOF_OUT and info.state ~= STATE_HEAL and info.state ~= STATE_ESCAPE and info.state ~= STATE_FARM_JUNGLE and info.state ~= STATE_PUSH and not SleepCheck(meepoHandle.."-casting") and info.poof and info.poof.abilityPhase then
  961. meepo:Stop()
  962. end
  963.  
  964. if dangerousPosition and ((info.camp and distance(dangerousPosition,info.camp.position) < 1000) or distance(meepo,dangerousPosition) < 1000) and (info.state == STATE_FARM_JUNGLE or info.state == STATE_PUSH) then
  965. meepoTable[meepoHandle].state = STATE_ESCAPE
  966. tempmeepoTable = meepoTable
  967. info = tempmeepoTable[meepoHandle]
  968. end
  969.  
  970. --HealKey
  971. if IsKeyDown(healkey) and not client.chat then
  972. if meepo.health <= meepo.maxHealth*(healpercent/100) then
  973. if not info.healPosition then
  974. meepoTable[meepoHandle].healPosition = meepo.position
  975. else
  976. meepoTable[meepoHandle].state = STATE_HEAL
  977. end
  978. tempmeepoTable = meepoTable
  979. info = tempmeepoTable[meepoHandle]
  980. elseif SleepCheck(meepoHandle.."-move") then
  981. meepo:Move(mousePosition)
  982. Sleep(500,meepoHandle.."-move")
  983. end
  984. end
  985.  
  986. --rupture
  987. if meepo:DoesHaveModifier("modifier_bloodseeker_rupture") then
  988. if meepo.activity == LuaEntityNPC.ACTIVITY_MOVE then
  989. local prev = SelectUnit(meepo)
  990. player:HoldPosition()
  991. SelectBack(prev)
  992. end
  993. local rupture = meepo:FindModifier("modifier_bloodseeker_rupture")
  994. Sleep(rupture.remainingTime*1000,meepoHandle.."-move")
  995. end
  996.  
  997. --Poof out
  998. if info.state == STATE_POOF_OUT and SleepCheck(meepoHandle.."-casting") then
  999. if info.lastState then
  1000. meepoTable[meepoHandle].state = info.lastState
  1001. meepoTable[meepoHandle].lastState = nil
  1002. else
  1003. meepoTable[meepoHandle].state = STATE_FARM_JUNGLE
  1004. end
  1005. tempmeepoTable = meepoTable
  1006. info = tempmeepoTable[meepoHandle]
  1007. end
  1008.  
  1009. --charged meepo
  1010. if meepo:DoesHaveModifier("modifier_spirit_breaker_charge_of_darkness_vision") and (info.state == STATE_FARM_JUNGLE or info.state == STATE_PUSH) then
  1011. meepoTable[meepoHandle].state = STATE_ESCAPE
  1012. tempmeepoTable = meepoTable
  1013. info = tempmeepoTable[meepoHandle]
  1014. end
  1015.  
  1016. --Escape function
  1017. if info.state == STATE_ESCAPE then
  1018. local travels = meepo:FindItem("item_travel_boots") or meepo:FindItem("item_travel_boots_2")
  1019. local tp = meepo:FindItem("item_tpscroll")
  1020. local item = nil
  1021. local poof = info.poof
  1022. meepoTable[meepoHandle].victim = nil
  1023. if info.foundCreep then
  1024. meepoTable[meepoHandle].foundCreep = false
  1025. end
  1026. if SleepCheck(meepoHandle.."-casting") then
  1027. local meepotp,time = tping(base.position,distance,meepo.handle)
  1028. if poof.level > 0 and canCast(meepo, poof) and not poof.abilityPhase then
  1029. local farrest = getFarrestMeepo(meepo,meepos,distance)
  1030. local near,dist,nearMeepo = anyMeepoisNear(base.position, 2000, meepo, meepos, distance, mathcos, mathsin)
  1031. local pos = nil
  1032. if (farrest and distance(meepo,farrest) > 1000) and distance(meepo,base) > distance(farrest,base) and not meepotp then
  1033. pos = farrest.position
  1034. elseif ((near and nearMeepo) or (meepotp and (time and time < (poof:FindCastPoint()-meepo:GetTurnTime(base.position))))) and distance(meepo,base.position) > 1000 then
  1035. pos = base.position
  1036. end
  1037. if pos then
  1038. meepo:CastAbility(poof,pos)
  1039. if pos == base.position then
  1040. meepoTable[meepoHandle].lastState = STATE_LANE
  1041. --print("escape")
  1042. elseif pos == farrest.position then
  1043. meepoTable[meepoHandle].lastState = STATE_ESCAPE
  1044. end
  1045. meepoTable[meepoHandle].state = STATE_POOF_OUT
  1046. if distance(meepo,base.position) > 50 then
  1047. meepo:Move(base.position,true)
  1048. end
  1049. Sleep(poof:FindCastPoint()*1000,meepoHandle.."-casting")
  1050. end
  1051. end
  1052. if travels then item = travels else item = tp end
  1053. if item and canCast(meepo, item) and (not meepotp or not canCast(meepo,poof)) and not IsInDanger(meepo,nil,distance,mathmin) and distance(meepo,base.position) > 2000 and SleepCheck("travels") then
  1054. meepo:CastAbility(item,base.position)
  1055. meepoTable[meepoHandle].tping = base.position
  1056. meepoTable[meepoHandle].tpTime = gameTime+(latency/1000)+meepo:GetTurnTime(base.position)
  1057. Sleep(3000,meepoHandle.."-casting")
  1058. Sleep(100,"travels")
  1059. return
  1060. end
  1061. end
  1062. if SleepCheck(meepoHandle.."-move") and not meepo:IsChanneling() then
  1063. local nearNum,nearTable = getNearVictims(meepo,distance)
  1064. local pos = nil
  1065. if nearNum > 0 then
  1066. for i = 1, #nearTable do
  1067. local v = nearTable[i]
  1068. if pos then
  1069. pos = pos + v.position
  1070. else
  1071. pos = v.position
  1072. end
  1073. end
  1074. local pos1 = pos/nearNum
  1075. pos = (meepo.position - pos1) * (distance(meepo,pos1) + 5000) / distance(meepo,pos1) + meepo.position
  1076. end
  1077. if pos and pos1 and distance(meepo,pos1) < 1200 then
  1078. meepo:Move(pos)
  1079. else
  1080. meepo:Move(base.position)
  1081. end
  1082. Sleep(750, meepoHandle.."-move")
  1083. end
  1084. tempmeepoTable = meepoTable
  1085. info = tempmeepoTable[meepoHandle]
  1086. end
  1087.  
  1088. --reseting tp position
  1089. if info.tping then
  1090. -- if not meepoTable[meepoHandle].starttp then
  1091. -- meepoTable[meepoHandle].starttp = gameTime
  1092. -- elseif gameTime - meepoTable[meepoHandle].starttp > 5 then
  1093. -- meepoTable[meepoHandle].starttp = nil
  1094. -- meepoTable[meepoHandle].tping = nil
  1095. -- end
  1096. local tp = meepo:FindItem("item_tpscroll") or meepo:FindItem("item_travel_boots") or meepo:FindItem("item_travel_boots_2")
  1097.  
  1098. local tped = (tp and (mathceil(tp.cd + 3) == mathceil(tp:GetCooldown(tp.level))))
  1099. if tped then
  1100. meepoTable[meepoHandle].tping = nil
  1101. meepoTable[meepoHandle].tpTime = nil
  1102. tempmeepoTable = meepoTable
  1103. info = tempmeepoTable[meepoHandle]
  1104. end
  1105. end
  1106.  
  1107. --Heal function
  1108. if (info.state == STATE_HEAL or (meepo.alive and (((meepo.health+(meepo.healthRegen*(distance(meepo,base)/meepo.movespeed))) < meepo.maxHealth/4.25 and
  1109. info.state ~= STATE_POOF_OUT and info.state ~= STATE_LANE and info.state ~= STATE_ESCAPE and (info.state ~= STATE_FARM_JUNGLE or
  1110. (info.camp and distance(info.camp.position,meepo) > 1000))) or meepo:DoesHaveModifier("modifier_bloodseeker_thirst_vision") or info.healPosition))) and SleepCheck(meepoHandle.."-heal") then
  1111. local incDmgM = 0--IncomingDamage(meepo,false)
  1112. --Updating state of meepo
  1113. if info.state ~= STATE_HEAL then
  1114. meepoTable[meepoHandle].lastState = info.state
  1115. meepoTable[meepoHandle].state = STATE_HEAL
  1116. meepoTable[meepoHandle].camp = nil
  1117. meepoTable[meepoHandle].lastcamp = nil
  1118. if info.foundCreep then
  1119. meepoTable[meepoHandle].foundCreep = false
  1120. end
  1121. end
  1122.  
  1123. --Giving orders to heal
  1124. local mustGoBase,items,isMe = haveHealingItems(meepo, distance)
  1125. if not info.healPosition and not mustGoBase and not IsInDanger(meepo,nil,distance,mathmin) and (not info.camp or distance(meepo,info.camp.position) > 1000) and not me:DoesHaveModifier("modifier_flask_healing") then
  1126. if isMe and (me.maxHealth - me.health) > 300 then
  1127. me:CastAbility(items[1], me)
  1128. elseif distance(me, meepo) > 200 then
  1129. meepo:Follow(me)
  1130. else
  1131. me:CastAbility(items[1], meepo)
  1132. end
  1133. else
  1134. if info.victim and info.victim.visible and distance(info.victim,meepo) < info.victim.attackRange and (incDmgM > meepo.health or meepo.health < 300) then
  1135. meepo:Move((meepo.position - info.victim.position) * (distance(meepo,info.victim) + info.victim.attackRange) / distance(meepo,info.victim) + meepo.position)
  1136. end
  1137. if not IsInDanger(meepo,nil,distance,mathmin) then
  1138. if config.UseBoTs then
  1139. useTP(meepo, meepoHandle, base.position, false, false, meepos, distance, mathcos, mathsin)
  1140. else
  1141. useTP(meepo, meepoHandle, base.position, false, true, meepos, distance, mathcos, mathsin)
  1142. end
  1143. end
  1144. if SleepCheck(meepoHandle.."-casting") and distance(meepo,base.position) > 50 then
  1145. meepo:Move(base.position)
  1146. end
  1147. end
  1148. tempmeepoTable = meepoTable
  1149. info = tempmeepoTable[meepoHandle]
  1150. Sleep(500, meepoHandle.."-heal")
  1151. end
  1152.  
  1153. if info.state == STATE_ESCAPE and distance(meepo,base.position) < 1000 then
  1154. --print("escapedToBase")
  1155. meepoTable[meepoHandle].state = STATE_LANE
  1156. meepoTable[meepoHandle].retreat = false
  1157. tempmeepoTable = meepoTable
  1158. info = tempmeepoTable[meepoHandle]
  1159. end
  1160.  
  1161. --Going farm after healed
  1162. if meepo.alive and ((info.state == STATE_HEAL and meepo.health > meepo.maxHealth/1.4) or (info.state == STATE_ESCAPE and (not dangerousPosition or distance(meepo,dangerousPosition) > 2500) and not IsInDanger(meepo,nil,distance,mathmin) and SleepCheck(meepoHandle.."-escape") and (not (IsKeyDown(retreatkey) and not client.chat) or distance(meepo,base.position) < 1000))) then
  1163.  
  1164. --HealKey
  1165. if info.healPosition then
  1166. local farrest = getFarrestMeepo(meepo,meepos,distance)
  1167. meepoTable[meepoHandle].state = STATE_LANE
  1168. --print("HealKey")
  1169. useTP(meepo, meepoHandle, farrest.position, false, true, meepos, distance, mathcos, mathsin)
  1170. meepoTable[meepoHandle].healPosition = nil
  1171. else
  1172.  
  1173. --Updating state of meepo
  1174. if info.lastState and info.lastState ~= STATE_HEAL then
  1175. if not retreat and not info.retreat then
  1176. meepoTable[meepoHandle].state = info.lastState
  1177. elseif retreatkeyCount ~= 2 then
  1178. meepoTable[meepoHandle].state = STATE_NONE
  1179. meepoTable[meepoHandle].retreat = false
  1180. end
  1181. elseif not (IsKeyDown(retreatkey) and not client.chat) then
  1182. if not retreat and not info.retreat then
  1183. meepoTable[meepoHandle].state = STATE_FARM_JUNGLE
  1184. elseif retreatkeyCount ~= 2 then
  1185. meepoTable[meepoHandle].state = STATE_NONE
  1186. meepoTable[meepoHandle].retreat = false
  1187. end
  1188. end
  1189. end
  1190. tempmeepoTable = meepoTable
  1191. info = tempmeepoTable[meepoHandle]
  1192. end
  1193.  
  1194.  
  1195. --
  1196. if not IsKeyDown(ctrl) and IsKeyDown(mainkey) and not client.chat and meepo.health < (meepo.maxHealth/100)*minhp and (info.state == STATE_LANE or info.state == STATE_NONE) then
  1197. meepoTable[meepoHandle].state = STATE_ESCAPE
  1198. tempmeepoTable = meepoTable
  1199. info = tempmeepoTable[meepoHandle]
  1200. end
  1201.  
  1202. --Chase function
  1203. if not IsKeyDown(ctrl) and ((IsKeyDown(mainkey) and not client.chat) or (info.state == STATE_CHASE and (not IsKeyDown(mainkey) or client.chat))) and meepo.health > (meepo.maxHealth/100)*minhp then
  1204. if meepo.alive and not meepo:IsStunned() and not meepo:IsRooted() and info.state ~= STATE_HEAL and
  1205. info.state ~= STATE_POOF_OUT and info.state ~= STATE_ESCAPE then
  1206. -- local victim2 = meepoTable[meepoHandle].victim
  1207. --local incDmgM = IncomingDamage(meepo,false)
  1208. --local incDmgv = IncomingDamage(victim,false)
  1209. meepoTable[meepoHandle].victim = victim
  1210.  
  1211. local near,dist,nearMeepo = anyMeepoisNear(victim, 700, meepo, meepos, distance, mathcos, mathsin)
  1212.  
  1213. if info.victim and not info.victim.visible then
  1214. if info.victimFogTime == 0 then
  1215. meepoTable[meepoHandle].victimFogTime = gameTime
  1216. elseif (gameTime - info.victimFogTime) > 5 then
  1217. meepoTable[meepoHandle].victim = nil
  1218. meepoTable[meepoHandle].victimFogTime = 0
  1219. end
  1220. end
  1221.  
  1222. local selection = player.selection
  1223. local selHand = nil
  1224. if selection[1] then selHand = selection[1].handle end
  1225. local nearR = false
  1226. local selected = nil
  1227. if (victim and victim.alive and victim.visible and (distance(meepo,victim) < 500 or near) and (victim.hero or victim.classId == CDOTA_Unit_SpiritBear)) or (IsKeyDown(mainkey) and not client.chat and victim and victim.alive and (victim.hero or victim.classId == CDOTA_Unit_SpiritBear)) then
  1228. if selection[1] then
  1229. if selection[1].classId ~= ID then selection = {meepos[1]} selHand = selection[1].handle end
  1230. if tempmeepoTable[selHand] then
  1231. if tempmeepoTable[selHand].state ~= STATE_CHASE then
  1232. meepoTable[selHand].state = STATE_CHASE
  1233. end
  1234. useTP(meepo, meepoHandle, victim.position, false, true, meepos, distance, mathcos, mathsin)
  1235. OrbWalk(meepo,meepoHandle,victim,true,meepos, distance, mathcos, mathsin,mathabs,mathrad,mathceil,mathmax)
  1236. selected = selection[1]
  1237. if distance(selected, victim) < 500 then
  1238. nearR = true
  1239. end
  1240. end
  1241. end
  1242. if victim and victim.alive and (victim.hero or victim.classId == CDOTA_Unit_SpiritBear) and victim.visible and (nearR or near or distance(meepo,victim) < 1000) then
  1243. if info.state ~= STATE_CHASE then
  1244. meepoTable[meepoHandle].state = STATE_CHASE
  1245. meepoTable[meepoHandle].camp = nil
  1246. meepoTable[meepoHandle].lastcamp = nil
  1247. meepoTable[meepoHandle].foundCreep = false
  1248. end
  1249. useTP(meepo, meepoHandle, victim.position, false, true,meepos, distance, mathcos, mathsin)
  1250. OrbWalk(meepo,meepoHandle,victim,true,meepos, distance, mathcos, mathsin,mathabs,mathrad,mathceil,mathmax)
  1251. end
  1252. elseif info.state == STATE_CHASE then
  1253. if config.AutoGoFarmAfterChase then
  1254. meepoTable[meepoHandle].state = STATE_FARM_JUNGLE
  1255. else
  1256. meepoTable[meepoHandle].state = STATE_NONE
  1257. end
  1258. meepoTable[meepoHandle].victim = nil
  1259. elseif SleepCheck(meepoHandle.."-move") and (info.state == STATE_NONE or info.state == STATE_MOVE or info.state == STATE_LANE) then
  1260. meepoTable[meepoHandle].victim = nil
  1261. meepo:Move(mousePosition)
  1262. Sleep(500,meepoHandle.."-move")
  1263. end
  1264. end
  1265. tempmeepoTable = meepoTable
  1266. info = tempmeepoTable[meepoHandle]
  1267. else
  1268. --Updating state of meepo
  1269. if tempmeepoTable[meepoHandle].state == STATE_CHASE then
  1270. if meepo.health <= (meepo.maxHealth/100)*minhp then
  1271. meepoTable[meepoHandle].state = STATE_ESCAPE
  1272. else
  1273. if config.AutoGoFarmAfterChase then
  1274. meepoTable[meepoHandle].state = STATE_FARM_JUNGLE
  1275. else
  1276. meepoTable[meepoHandle].state = STATE_NONE
  1277. end
  1278. end
  1279. meepoTable[meepoHandle].victim = nil
  1280. end
  1281. tempmeepoTable = meepoTable
  1282. end
  1283.  
  1284. --Unaggro
  1285. if tempmeepoTable[meepo.handle].state ~= STATE_LANE then
  1286. for i = 1, #projectiles do
  1287. local p = projectiles[i]
  1288. local sour = p.source
  1289. if sour and sour.classId == CDOTA_BaseNPC_Tower and p.target and p.target.handle == meepoHandle and distance(meepo,sour) <= sour.attackRange+25 then
  1290. local sourHand = sour.handle
  1291. local closest = getClosest(sour,1,false,meepo,meepos, distance)
  1292. local dmg = meepo:DamageTaken((sour.dmgMax+sour.dmgMin)/2,DAMAGE_PHYS,sour)
  1293. if closest and closest.health > meepo.health then
  1294. if SleepCheck(meepoHandle.."unaggro") and SleepCheck(sourHand) and SleepCheck(closest.handle.."unaggro") then
  1295. if alliedUnit and (dmg >= meepo.maxHealth*0.2 or meepo.health-(dmg*1.5) <= meepo.maxHealth*0.5)
  1296. and distance(closest,sour) <= sour.attackRange then
  1297. meepo:Attack(alliedUnit)
  1298. closest:Attack(sour)
  1299. Sleep((distance(meepo,p.position)/p.speed)*1000,sourHand)
  1300. Sleep(250, meepoHandle.."unaggro")
  1301. Sleep(250, closest.handle.."unaggro")
  1302. end
  1303. elseif SleepCheck(meepoHandle.."unaggro2") and SleepCheck(meepoHandle.."-casting") then
  1304. local prev = SelectUnit(meepo)
  1305. player:HoldPosition()
  1306. SelectBack(prev)
  1307. Sleep((distance(meepo,p.position)/p.speed)*1000,meepoHandle.."unaggro2")
  1308. end
  1309. else
  1310. if SleepCheck(meepoHandle.."unaggro") and SleepCheck(sourHand) then
  1311. if alliedUnit and (dmg >= meepo.maxHealth*0.2 or meepo.health-(dmg*1.5) <= meepo.maxHealth*0.5)then
  1312. meepo:Attack(alliedUnit)
  1313. Sleep((distance(meepo,p.position)/p.speed)*1000,sourHand)
  1314. Sleep(250, meepoHandle.."unaggro")
  1315. end
  1316. elseif SleepCheck(meepoHandle.."unaggro2") and SleepCheck(meepoHandle.."-casting") and meepo.activity == LuaEntityNPC.ACTIVITY_MOVE then
  1317. local prev = SelectUnit(meepo)
  1318. player:HoldPosition()
  1319. SelectBack(prev)
  1320. Sleep((distance(meepo,p.position)/p.speed)*1000,meepoHandle.."unaggro2")
  1321. end
  1322. end
  1323. end
  1324. end
  1325. end
  1326.  
  1327. --Lane Farm
  1328. if meepo.alive and tempmeepoTable[meepoHandle].state == STATE_PUSH then
  1329. local def = false
  1330. local pushEntity = nil
  1331. local pushEntities = {}
  1332. local pushEntitiesCount = 0
  1333. for i = 1, entitiesForPushCount do
  1334. local creep = entitiesForPush[i]
  1335. if creep.team ~= meTeam and creep.alive and creep.visible then
  1336. if distance(creep,meepo) <= 4000 then
  1337. if distance(creep,meepo) <= 400 then
  1338. pushEntitiesCount = pushEntitiesCount + 1
  1339. pushEntities[pushEntitiesCount] = creep
  1340. end
  1341. if not pushEntity or (creep.health < pushEntity.health and distance(creep,pushEntity) < 700) then
  1342. pushEntity = creep
  1343. end
  1344. end
  1345. end
  1346. end
  1347.  
  1348. if (not tempmeepoTable[meepoHandle].camp or ((gameTime % 60 > 0 and gameTime % 60 < 1) or tempJungleCamps[tempmeepoTable[meepoHandle].camp.id].farmed or tempJungleCamps[tempmeepoTable[meepoHandle].camp.id].visible)) then
  1349. DebugPrint("Getting Camp")
  1350. meepoTable[meepoHandle].camp = getClosestCamp(meepo,nil,nil,nil, distance)
  1351. elseif tempmeepoTable[meepoHandle].camp and SleepCheck(meepoHandle.."-camp") then
  1352. DebugPrint("Getting Camp 2")
  1353. local camp = getClosestCamp(meepo,nil,nil,nil, distance)
  1354. if camp and distance(meepo,camp.position) < distance(meepo,tempmeepoTable[meepoHandle].camp.position) then
  1355. meepoTable[meepoHandle].camp = camp
  1356. end
  1357. Sleep(3000, meepoHandle.."-camp")
  1358. end
  1359. tempmeepoTable = meepoTable
  1360. local camp = nil
  1361. if tempmeepoTable[meepoHandle].camp then
  1362. camp = tempJungleCamps[tempmeepoTable[meepoHandle].camp.id]
  1363. end
  1364.  
  1365. local en = false
  1366.  
  1367. if pushEntity then
  1368. for i = 1, #towers do
  1369. local v = towers[i]
  1370. if v.team == meTeam and distance(v,pushEntity) < 1000 then
  1371. def = true
  1372. end
  1373. if v.team ~= meTeam and distance(v,pushEntity) < 1000 and aliveenemies > 2 then
  1374. meepoTable[meepoHandle].state = STATE_FARM_JUNGLE
  1375. end
  1376. end
  1377. for i = 1, #enemies do
  1378. local e = enemies[i]
  1379. if e.alive and e.visible and distance(e,pushEntity) < 700 and not def then
  1380. en = true
  1381. end
  1382. end
  1383. end
  1384.  
  1385. if en or (not def and (numberOfNotVisibleEnemies > 1 and (dangerousPosition and distance(meepo,dangerousPosition) < 1200))) or (numberOfNotVisibleEnemies > 2 and (dangerousPosition and distance(meepo,dangerousPosition) < 2500)) or (not pushEntity or (camp and not camp.farmed and not camp.visible and not camp.stacking and distance(camp.position,meepo) < distance(pushEntity,meepo) and distance(pushEntity,meepo) > 500)) and aliveenemies > 2 then
  1386. meepoTable[meepoHandle].state = STATE_FARM_JUNGLE
  1387. end
  1388.  
  1389.  
  1390. local tp = false
  1391. if pushEntity and pushEntity.alive and not meepo:IsChanneling() then
  1392. DebugPrint("FarmJungle2")
  1393. if config.UseBoTs then
  1394. tp = useTP(meepo, meepoHandle, pushEntity.position, false, false, meepos, distance, mathcos, mathsin)
  1395. else
  1396. tp = useTP(meepo, meepoHandle, pushEntity.position, false, true, meepos, distance, mathcos, mathsin)
  1397. end
  1398.  
  1399. if distance(pushEntity,meepo) < 500 then
  1400. if pushEntity.classId == CDOTA_BaseNPC_Tower then
  1401. local tank = false
  1402. for i = 1, #lanecreeps do
  1403. local v = lanecreeps[i]
  1404. if v.team == meTeam and v.spawned and distance(v,pushEntity) < pushEntity.attackRange+100 then
  1405. tank = true
  1406. end
  1407. end
  1408. if tank then
  1409. OrbWalk(meepo, meepoHandle, pushEntity, pushEntitiesCount > 1, meepos, distance, mathcos, mathsin,mathabs,mathrad,mathceil,mathmax)
  1410. elseif distance(meepo,pushEntity) < pushEntity.attackRange+500 and SleepCheck(meepoHandle.."-move") then
  1411. local pos = (meepo.position - pushEntity.position) * (distance(meepo,pushEntity) + pushEntity.attackRange+100) / distance(meepo,pushEntity) + meepo.position
  1412. meepo:Move(pos)
  1413. Sleep(500, meepoHandle.."-move")
  1414. end
  1415. else
  1416. local poofDmg = mathceil(pushEntity:DamageTaken(poofDamage[1],DAMAGE_MAGC,meepo))
  1417. OrbWalk(meepo, meepoHandle, pushEntity, (pushEntity.health > poofDmg or pushEntitiesCount > 1), meepos, distance, mathcos, mathsin,mathabs,mathrad,mathceil,mathmax)
  1418. end
  1419. elseif SleepCheck(meepoHandle.."-move") then
  1420. meepo:Move(pushEntity.position)
  1421. Sleep(500, meepoHandle.."-move")
  1422. end
  1423. end
  1424. end
  1425.  
  1426. --Jungling
  1427. if meepo.alive and tempmeepoTable[meepoHandle].state == STATE_FARM_JUNGLE then
  1428. local push = {false,0,nil}
  1429. for i = 1, entitiesForPushCount do
  1430. local creep = entitiesForPush[i]
  1431. if creep.team ~= meTeam then
  1432. local en = false
  1433. for i = 1, #enemies do
  1434. local e = enemies[i]
  1435. if e.alive and e.visible and not e:IsIllusion() and distance(e,creep) < 700 then
  1436. en = true
  1437. end
  1438. end
  1439. if not en then
  1440. push = {true,distance(creep,meepo),creep}
  1441. end
  1442. end
  1443. end
  1444. DebugPrint("FarmJungle1")
  1445. if (not tempmeepoTable[meepoHandle].camp or (((gameTime % 60 > 0 and gameTime % 60 < 1) or (tempJungleCamps[tempmeepoTable[meepoHandle].camp.id].farmed and gameTime > 30) or tempJungleCamps[tempmeepoTable[meepoHandle].camp.id].visible) and not tempmeepoTable[meepoHandle].hoveredCamp)) then
  1446. DebugPrint("Getting Camp")
  1447. meepoTable[meepoHandle].camp = nil
  1448. meepoTable[meepoHandle].lastcamp = nil
  1449. meepoTable[meepoHandle].camp = getClosestCamp(meepo, false, numberOfNotVisibleEnemies, dangerousPosition, distance)
  1450. meepoTable[meepoHandle].hoveredCamp = false
  1451. elseif tempmeepoTable[meepoHandle].camp and SleepCheck(meepoHandle.."-camp") and not tempmeepoTable[meepoHandle].hoveredCamp then
  1452. DebugPrint("Getting Camp 2")
  1453. local camp = getClosestCamp(meepo, false, numberOfNotVisibleEnemies, dangerousPosition, distance)
  1454. if camp and (distance(meepo,camp.position) < distance(meepo,tempmeepoTable[meepoHandle].camp.position) or (camp.team ~= meTeam and numberOfNotVisibleEnemies > 2)) then
  1455. meepoTable[meepoHandle].hoveredCamp = false
  1456. meepoTable[meepoHandle].camp = camp
  1457. end
  1458. Sleep(3000, meepoHandle.."-camp")
  1459. end
  1460. tempmeepoTable = meepoTable
  1461. local camp = nil
  1462. if tempmeepoTable[meepoHandle].camp then
  1463. camp = tempJungleCamps[tempmeepoTable[meepoHandle].camp.id]
  1464. end
  1465. local creepForCurrentMeepo = nil
  1466. local creepsNearCurrentMeepo = {}
  1467. local creepsNearCurrentMeepoCount = 0
  1468. local def = false
  1469. local back = false
  1470. if push[3] then
  1471. for i = 1, #towers do
  1472. local v = towers[i]
  1473. if v.team == meTeam and distance(v,push[3]) < 2000 then
  1474. def = true
  1475. end
  1476. if v.team ~= meTeam and distance(v,push[3]) < 2000 then
  1477. back = true
  1478. end
  1479. end
  1480. end
  1481. if camp then
  1482. for i = 1, #neutrals do
  1483. local creep = neutrals[i]
  1484. if creep.spawned and distance(meepo,creep) <= 1000 and (distance(camp.position,creep) <= 650 or (creep.visible and distance(creep,camp.position) < 1200)) and creep.alive then
  1485. creepsNearCurrentMeepoCount = creepsNearCurrentMeepoCount + 1
  1486. creepsNearCurrentMeepo[creepsNearCurrentMeepoCount] = creep
  1487. if not creepForCurrentMeepo or creep.health < creepForCurrentMeepo.health then
  1488. creepForCurrentMeepo = creep
  1489. end
  1490. end
  1491. end
  1492.  
  1493. if meepo.visibleToEnemy and not tempJungleCamps[camp.id].visible and creepForCurrentMeepo and distance(meepo,camp.position) < 500 then
  1494. JungleCamps[camp.id].visible = true
  1495. JungleCamps[camp.id].visTime = gameTime
  1496. tempJungleCamps = JungleCamps
  1497. meepoTable[meepoHandle].lastcamp = camp
  1498. meepoTable[meepoHandle].camp = nil
  1499. if tempmeepoTable[meepoHandle].foundCreep then
  1500. meepoTable[meepoHandle].foundCreep = false
  1501. end
  1502. meepoTable[meepoHandle].hoveredCamp = false
  1503. camp = getClosestCamp(meepo, false, numberOfNotVisibleEnemies, dangerousPosition, distance)
  1504. end
  1505. tempmeepoTable = meepoTable
  1506. if camp then
  1507. if config.AutoPush and not tempmeepoTable[meepoHandle].hoveredCamp and ((numberOfNotVisibleEnemies < 4 or (not dangerousPosition or distance(meepo,dangerousPosition) > 2500)) or def) and (((push[1] and push[2] < distance(camp.position,meepo)) or def) or camp.farmed or camp.visible) and (not back or aliveenemies < 2) then
  1508. meepoTable[meepoHandle].state = STATE_PUSH
  1509. end
  1510. end
  1511. elseif SleepCheck(meepoHandle.."-move") then
  1512. if config.AutoPush and ((numberOfNotVisibleEnemies < 4 or (not dangerousPosition or distance(meepo,dangerousPosition) > 2500)) or def) and push[1] and (not back or aliveenemies < 2) then
  1513. meepoTable[meepoHandle].state = STATE_PUSH
  1514. end
  1515. if tempmeepoTable[meepoHandle].lastcamp and distance(meepo, tempmeepoTable[meepoHandle].lastcamp) then
  1516. meepo:Move(tempmeepoTable[meepoHandle].lastcamp.stackPosition)
  1517. Sleep(750,meepoHandle.."-move")
  1518. else
  1519. local c = getClosestPos(meepo,distance)
  1520. if distance(meepo,c.stackPosition) > 50 then
  1521. meepo:Move(c.stackPosition)
  1522. Sleep(750,meepoHandle.."-move")
  1523. end
  1524. end
  1525. end
  1526. if camp and not meepo:IsChanneling() then
  1527. DebugPrint("FarmJungle2")
  1528. local tp = nil
  1529. if distance(camp.position,meepo) > 1200 then
  1530. if config.UseBoTs then
  1531. tp = useTP(meepo, meepoHandle, camp.position, false, false, meepos, distance, mathcos, mathsin)
  1532. else
  1533. tp = useTP(meepo, meepoHandle, camp.position, false, true, meepos, distance, mathcos, mathsin)
  1534. end
  1535. end
  1536.  
  1537. if SleepCheck(meepoHandle.."stack") and (distance(meepo,camp.position) > 450 or not tempmeepoTable[meepoHandle].foundCreep) and SleepCheck(meepoHandle.."-move") and not meepo:IsChanneling() and
  1538. not tp and (not creepForCurrentMeepo or not creepForCurrentMeepo.alive) then
  1539. if tempmeepoTable[meepoHandle].foundCreep then
  1540. meepoTable[meepoHandle].foundCreep = false
  1541. end
  1542. if (tempJungleCamps[camp.id].stacking or (tempJungleCamps[camp.id].farmed and gameTime % 60 > 50)) and distance(meepo,camp.position) < 1500 then
  1543. if distance(meepo,camp.position) < 1000 then
  1544. if distance(meepo,camp.stackPosition) > 50 then
  1545. meepo:Move(camp.stackPosition)
  1546. Sleep(750,meepoHandle.."-move")
  1547. end
  1548. elseif meepo.activity == LuaEntityNPC.ACTIVITY_MOVE then
  1549. DebugPrint("HoldPos")
  1550. local prev = SelectUnit(meepo)
  1551. player:HoldPosition()
  1552. SelectBack(prev)
  1553. end
  1554. elseif not tempmeepoTable[meepoHandle].hoveredCamp or not tempJungleCamps[camp.id].farmed then
  1555. meepo:Move(camp.position)
  1556. Sleep(750,meepoHandle.."-move")
  1557. -- if creepForCurrentMeepo then
  1558. -- print(meeponumber,creepForCurrentMeepo,creepForCurrentMeepo.name,creepForCurrentMeepo.alive,tempmeepoTable[meepoHandle].foundCreep, distance(meepo,camp.position))
  1559. -- else
  1560. -- print(meeponumber,creepForCurrentMeepo,tempmeepoTable[meepoHandle].foundCreep, distance(meepo,camp.position))
  1561. -- end
  1562. elseif tempJungleCamps[camp.id].farmed and tempmeepoTable[meepoHandle].hoveredCamp then
  1563. meepo:Move(camp.stackPosition)
  1564. Sleep(750,meepoHandle.."-move")
  1565. end
  1566. end
  1567. if creepForCurrentMeepo and creepForCurrentMeepo.alive then
  1568. if (meepo.health <= mathmin(mathmax(mathceil(meepo:DamageTaken(creepForCurrentMeepo.dmgMin + creepForCurrentMeepo.dmgBonus,DAMAGE_PHYS,creepForCurrentMeepo))*(creepsNearCurrentMeepoCount)*2, meepo.maxHealth/5),meepo.maxHealth/4.25) or meepo.health < 150) and ((meepo.health <= creepForCurrentMeepo.health) or creepsNearCurrentMeepoCount > 1) then
  1569. if distance(meepo,creepForCurrentMeepo) < creepForCurrentMeepo.attackRange+100 and not IsInDanger(meepo,nil,distance,mathmin) then
  1570. local pos = (meepo.position - creepForCurrentMeepo.position) * (distance(meepo,creepForCurrentMeepo) + creepForCurrentMeepo.attackRange+100) / distance(meepo,creepForCurrentMeepo) + meepo.position
  1571. if SleepCheck(meepoHandle.."-move") then
  1572. meepo:Move(pos)
  1573. Sleep(500,meepoHandle.."-move")
  1574. end
  1575. else
  1576. if not SleepCheck(meepoHandle.."-casting") then
  1577. local prev = SelectUnit(meepo)
  1578. player:HoldPosition()
  1579. SelectBack(prev)
  1580. end
  1581. meepoTable[meepoHandle].state = STATE_HEAL
  1582. end
  1583. end
  1584. meepoTable[meepoHandle].foundCreep = true
  1585. tempmeepoTable = meepoTable
  1586. JungleCamps[camp.id].farmed = false
  1587. tempJungleCamps = JungleCamps
  1588. local stackDuration = mathmin((distance(creepForCurrentMeepo,camp.stackPosition)+(creepsNearCurrentMeepoCount*60))/mathmin(creepForCurrentMeepo.movespeed,me.movespeed), 9)
  1589. if creepForCurrentMeepo:IsRanged() and creepsNearCurrentMeepoCount <= 4 then
  1590. stackDuration = mathmin((distance(creepForCurrentMeepo,camp.stackPosition)+creepForCurrentMeepo.attackRange+(creepsNearCurrentMeepoCount*60))/mathmin(creepForCurrentMeepo.movespeed,me.movespeed), 9)
  1591. end
  1592. if SleepCheck(meepoHandle.."-moveStack") and (gameTime % 60 > (60 - stackDuration) and gameTime % 60 < 57) and (distance(creepForCurrentMeepo,meepo) < 250 or tempJungleCamps[camp.id].stacking) then
  1593. local pos = (camp.stackPosition - creepForCurrentMeepo.position) * (distance(camp.stackPosition,creepForCurrentMeepo) + creepForCurrentMeepo.attackRange) / distance(camp.stackPosition,creepForCurrentMeepo) + camp.stackPosition
  1594. meepo:Move(pos)
  1595. Sleep((distance(meepo,pos)/meepo.movespeed)*1000,meepoHandle.."-moveStack")
  1596. Sleep((60 - (gameTime % 60))*1000,meepoHandle.."stack")
  1597. JungleCamps[camp.id].stacking = true
  1598. tempJungleCamps = JungleCamps
  1599. elseif SleepCheck(meepoHandle.."stack") and not tempJungleCamps[camp.id].stacking then
  1600. local poofDmg = mathceil(creepForCurrentMeepo:DamageTaken(poofDamage[1],DAMAGE_MAGC,meepo))
  1601. if ((creepsNearCurrentMeepoCount > 3 and camp.lvlReq == 8) or (creepsNearCurrentMeepoCount > 4 and camp.lvlReq < 8 and camp.lvlReq >= 3) or (creepsNearCurrentMeepoCount > 4 and camp.lvlReq < 3)) and tempmeepoTable[meepoHandle].poof and tempmeepoTable[meepoHandle].poof.cd == 0 and meepo.mana >= tempmeepoTable[meepoHandle].poof.manacost and (tempmeepoTable[meepoHandle].poof.level == 4 or (tempmeepoTable[meepoHandle].poof.level >= 1 and camp.lvlReq < 8)) then
  1602. if tempmeepoTable[meepoHandle].poof and canCast(meepo, tempmeepoTable[meepoHandle].poof) then
  1603. local pos = camp.position
  1604. if distance(meepo,creepForCurrentMeepo.position) < distance(meepo,camp.position) then
  1605. pos = creepForCurrentMeepo.position
  1606. end
  1607. if distance(meepo,pos) > 50 then
  1608. if SleepCheck(meepoHandle.."-move") then
  1609. meepo:Move(pos)
  1610. Sleep(750,meepoHandle.."-move")
  1611. end
  1612. elseif SleepCheck(meepoHandle.."-casting") and distance(meepo,camp.position) < 200 then
  1613. meepo:CastAbility(tempmeepoTable[meepoHandle].poof,meepo.position)
  1614. Sleep(tempmeepoTable[meepoHandle].poof:FindCastPoint()*1000,meepoHandle.."-casting")
  1615. end
  1616. elseif SleepCheck(meepoHandle.."-move") then
  1617. local pos = (camp.stackPosition - creepForCurrentMeepo.position) * (distance(camp.stackPosition,creepForCurrentMeepo) + creepForCurrentMeepo.attackRange) / distance(camp.stackPosition,creepForCurrentMeepo) + camp.stackPosition
  1618. meepo:Move(pos)
  1619. Sleep(750,meepoHandle.."-move")
  1620. Sleep(mathmin((distance(meepo,camp.stackPosition)/meepo.movespeed)*1000,tempmeepoTable[meepoHandle].poof.cd*1000),meepoHandle.."-orb")
  1621. end
  1622. elseif SleepCheck(meepoHandle.."-orb") then
  1623. OrbWalk(meepo, meepoHandle, creepForCurrentMeepo, (creepForCurrentMeepo.health > poofDmg/1.2 or creepsNearCurrentMeepoCount > 1 or creepForCurrentMeepo.health > meepo.health), meepos, distance, mathcos, mathsin,mathabs,mathrad,mathceil,mathmax)
  1624. end
  1625. end
  1626. elseif ((tempmeepoTable[meepoHandle].foundCreep and distance(meepo,camp.position) < 600) or distance(meepo,camp.position) < 200) and SleepCheck("blink") then
  1627. if meepo.health < meepo.maxHealth/4.25 then
  1628. meepoTable[meepoHandle].state = STATE_HEAL
  1629. end
  1630. meepoTable[meepoHandle].lastcamp = camp
  1631. JungleCamps[camp.id].farmed = true
  1632. tempJungleCamps = JungleCamps
  1633. if not tempmeepoTable[meepoHandle].hoveredCamp then
  1634. meepoTable[meepoHandle].camp = nil
  1635. meepoTable[meepoHandle].hoveredCamp = false
  1636. elseif tempmeepoTable[meepoHandle].camp and distance(meepo, tempmeepoTable[meepoHandle].camp.stackPosition) > 100 and SleepCheck(meepoHandle.."-move") then
  1637. meepo:Move(meepoTable[meepoHandle].camp.stackPosition)
  1638. Sleep(750,meepoHandle.."-move")
  1639. end
  1640. if tempmeepoTable[meepoHandle].foundCreep then
  1641. meepoTable[meepoHandle].foundCreep = false
  1642. end
  1643. tempmeepoTable = meepoTable
  1644. end
  1645. elseif SleepCheck(meepoHandle.."-move") and not meepo:IsChanneling() and not tp then
  1646. for i = 1, #entitiesForPush do
  1647. local creep = entitiesForPush[i]
  1648. if creep.team ~= meTeam and distance(creep,meepo) <= 4000 then
  1649. local en = false
  1650. for i = 1, #enemies do
  1651. local e = enemies[i]
  1652. if e.alive and e.visible and distance(e,creep) < 700 then
  1653. en = true
  1654. end
  1655. end
  1656. local back = false
  1657. for i = 1, #towers do
  1658. local v = towers[i]
  1659. if v.team ~= meTeam and distance(v,creep) < 2000 then
  1660. back = true
  1661. end
  1662. end
  1663. if config.AutoPush and not en and (not back or aliveenemies < 2) and not tempmeepoTable[meepoHandle].hoveredCamp then
  1664. meepoTable[meepoHandle].state = STATE_PUSH
  1665. end
  1666. end
  1667. end
  1668. if not tempmeepoTable[meepoHandle].hoveredCamp then
  1669. meepoTable[meepoHandle].camp = nil
  1670. meepoTable[meepoHandle].hoveredCamp = false
  1671. end
  1672. if tempmeepoTable[meepoHandle].foundCreep then
  1673. meepoTable[meepoHandle].foundCreep = false
  1674. end
  1675. if tempmeepoTable[meepoHandle].hoveredCamp then
  1676. meepoTable[meepoHandle].lastcamp = tempmeepoTable[meepoHandle].camp
  1677. end
  1678. if tempmeepoTable[meepoHandle].lastcamp then
  1679. meepoTable[meepoHandle].camp = getClosestCamp(meepo,false, numberOfNotVisibleEnemies, dangerousPosition, distance,true)
  1680. if distance(meepo, tempmeepoTable[meepoHandle].lastcamp.stackPosition) > 100 then
  1681. meepo:Move(meepoTable[meepoHandle].lastcamp.stackPosition)
  1682. Sleep(750,meepoHandle.."-move")
  1683. end
  1684. else
  1685. meepoTable[meepoHandle].camp = getClosestCamp(meepo,false, numberOfNotVisibleEnemies, dangerousPosition, distance,true)
  1686. camp = meepoTable[meepoHandle].camp
  1687. if camp and distance(meepo, camp.stackPosition) > 100 then
  1688. meepo:Move(camp.stackPosition)
  1689. Sleep(750,meepoHandle.."-move")
  1690. end
  1691. end
  1692. tempmeepoTable = meepoTable
  1693. end
  1694. end
  1695.  
  1696. --Stacking
  1697. if meepo.alive and tempmeepoTable[meepoHandle].state == STATE_STACK then
  1698.  
  1699. if (not tempmeepoTable[meepoHandle].camp or ((gameTime % 60 > 0 and gameTime % 60 < 1) or tempJungleCamps[tempmeepoTable[meepoHandle].camp.id].farmed or tempJungleCamps[tempmeepoTable[meepoHandle].camp.id].visible)) then
  1700. DebugPrint("Getting Camp")
  1701. meepoTable[meepoHandle].camp = getClosestCamp(meepo, true, numberOfNotVisibleEnemies,nil, distance)
  1702. elseif tempmeepoTable[meepoHandle].camp and SleepCheck(meepoHandle.."-camp") then
  1703. DebugPrint("Getting Camp 2")
  1704. local camp = getClosestCamp(meepo, true, numberOfNotVisibleEnemies,nil, distance)
  1705. if camp and (distance(meepo,camp.position) < distance(meepo,tempmeepoTable[meepoHandle].camp.position) or (camp.team ~= meTeam and numberOfNotVisibleEnemies > 3)) then
  1706. meepoTable[meepoHandle].camp = camp
  1707. end
  1708. Sleep(3000, meepoHandle.."-camp")
  1709. end
  1710. local camp = nil
  1711. tempmeepoTable = meepoTable
  1712. if tempmeepoTable[meepoHandle].camp then
  1713. camp = tempJungleCamps[tempmeepoTable[meepoHandle].camp.id]
  1714. end
  1715. local creepForCurrentMeepo = nil
  1716. local creepsNearCurrentMeepo = {}
  1717. local creepsNearCurrentMeepoCount = 0
  1718. if camp then
  1719. for i = 1, #neutrals do
  1720. local creep = neutrals[i]
  1721. if creep.visible and creep.spawned and distance(creep,meepo) <= 900 and (distance(camp.position,meepo) <= 1000 or (creep.visible and distance(creep,camp.position) < 1200)) then
  1722. creepsNearCurrentMeepoCount = creepsNearCurrentMeepoCount + 1
  1723. creepsNearCurrentMeepo[creepsNearCurrentMeepoCount] = creep
  1724. if not creepForCurrentMeepo or distance(meepo, creep) > distance(meepo, creepForCurrentMeepo) then
  1725. creepForCurrentMeepo = creep
  1726. end
  1727. end
  1728. end
  1729.  
  1730. if meepo.visibleToEnemy and not tempJungleCamps[camp.id].visible and creepForCurrentMeepo then
  1731. JungleCamps[camp.id].visible = true
  1732. JungleCamps[camp.id].visTime = gameTime
  1733. tempJungleCamps = JungleCamps
  1734. meepoTable[meepoHandle].lastcamp = camp
  1735. meepoTable[meepoHandle].camp = nil
  1736. if tempmeepoTable[meepoHandle].foundCreep then
  1737. meepoTable[meepoHandle].foundCreep = false
  1738. end
  1739. camp = getClosestCamp(meepo, true, numberOfNotVisibleEnemies,nil, distance)
  1740. end
  1741. elseif SleepCheck(meepoHandle.."-move") then
  1742. if tempmeepoTable[meepoHandle].lastcamp and distance(meepo, meepoTable[meepoHandle].lastcamp.stackPosition) > 50 then
  1743. meepo:Move(meepoTable[meepoHandle].lastcamp.stackPosition)
  1744. Sleep(750,meepoHandle.."-move")
  1745. end
  1746. end
  1747. tempmeepoTable = meepoTable
  1748.  
  1749. if camp and not meepo:IsChanneling() then
  1750. DebugPrint("FarmJungle2")
  1751.  
  1752. local tp = nil
  1753. if config.UseBoTs then
  1754. tp = useTP(meepo, meepoHandle, camp.position, false, false, meepos, distance, mathcos, mathsin)
  1755. else
  1756. tp = useTP(meepo, meepoHandle, camp.position, false, true, meepos, distance, mathcos, mathsin)
  1757. end
  1758.  
  1759. local stackDuration = 0
  1760. if creepForCurrentMeepo and creepForCurrentMeepo.alive then
  1761. stackDuration = mathmin((distance(creepForCurrentMeepo,camp.stackPosition)+(creepsNearCurrentMeepoCount*45))/mathmin(creepForCurrentMeepo.movespeed,me.movespeed), 9)
  1762. if creepForCurrentMeepo:IsRanged() and creepsNearCurrentMeepoCount <= 4 then
  1763. stackDuration = mathmin((distance(creepForCurrentMeepo,camp.stackPosition)+creepForCurrentMeepo.attackRange+(creepsNearCurrentMeepoCount*45))/mathmin(creepForCurrentMeepo.movespeed,me.movespeed), 9)
  1764. end
  1765. end
  1766. local moveTime = 50 - (distance(meepo,camp.position)+50)/meepo.movespeed
  1767. if stackDuration > 0 then
  1768. moveTime = 60 - stackDuration - (distance(meepo,creepForCurrentMeepo.position)+50)/meepo.movespeed
  1769. end
  1770. if SleepCheck(meepoHandle.."stack") and SleepCheck(meepoHandle.."-move") and not meepo:IsChanneling() and
  1771. not tp then
  1772. if gameTime % 60 < moveTime then
  1773. if distance(meepo,camp.waitPosition) > 50 then
  1774. meepo:Move(camp.waitPosition)
  1775. end
  1776. elseif (not creepForCurrentMeepo or not creepForCurrentMeepo.visible) then
  1777. if distance(meepo,camp.position) > 50 then
  1778. meepo:Move(camp.position)
  1779. end
  1780. end
  1781. Sleep(750,meepoHandle.."-move")
  1782. end
  1783. if gameTime % 60 > moveTime then
  1784. if creepForCurrentMeepo and creepForCurrentMeepo.alive then
  1785. meepoTable[meepoHandle].foundCreep = true
  1786. JungleCamps[camp.id].farmed = false
  1787. tempJungleCamps = JungleCamps
  1788. if SleepCheck(meepoHandle.."-moveStack") and (gameTime % 60 > (60 - stackDuration) and gameTime % 60 < 57) and (distance(creepForCurrentMeepo,meepo) < 700 or tempJungleCamps[camp.id].stacking) then
  1789. local pos = (camp.stackPosition - creepForCurrentMeepo.position) * (distance(camp.stackPosition,creepForCurrentMeepo) + creepForCurrentMeepo.attackRange) / distance(camp.stackPosition,creepForCurrentMeepo) + camp.stackPosition
  1790. meepo:Move(pos)
  1791. Sleep((distance(meepo,pos)/meepo.movespeed)*1000,meepoHandle.."-moveStack")
  1792. Sleep((60 - (gameTime % 60))*1000,meepoHandle.."stack")
  1793. JungleCamps[camp.id].stacking = true
  1794. tempJungleCamps = JungleCamps
  1795. elseif SleepCheck(meepoHandle.."stack") and not tempJungleCamps[camp.id].stacking and SleepCheck(meepoHandle.."-attack") then
  1796. local pos = (creepForCurrentMeepo.position - meepo.position) * (distance(meepo.position,creepForCurrentMeepo) - 800) / distance(meepo.position,creepForCurrentMeepo) + creepForCurrentMeepo.position
  1797. meepo:Move(pos)
  1798. meepo:Move(camp.stackPosition,true)
  1799. Sleep(5000,meepoHandle.."-attack")
  1800. end
  1801. tempmeepoTable = meepoTable
  1802. end
  1803. end
  1804. end
  1805. end
  1806.  
  1807. --Drawings
  1808. if not meepoNumberSigns[meepoHandle] then
  1809. if meeponumber == 1 then
  1810. meepoNumberSigns[meepoHandle] = drawMgr:CreateText(-7*monitor,-90*monitor,-1,""..meeponumber,F15)
  1811. else
  1812. meepoNumberSigns[meepoHandle] = drawMgr:CreateText(-7*monitor,-80*monitor,-1,""..meeponumber,F15)
  1813. end
  1814. meepoNumberSigns[meepoHandle].visible = true
  1815. meepoNumberSigns[meepoHandle].entity = meepo
  1816. meepoNumberSigns[meepoHandle].entityPosition = Vector(0,0,meepo.healthbarOffset)
  1817. end
  1818. if not meepoNumberSigns[meepoHandle.."-num"] then
  1819. meepoNumberSigns[meepoHandle.."-num"] = drawMgr:CreateText(2,70 + 79*(meeponumber-1),-1,""..meeponumber,F15)
  1820. end
  1821. if not meepoNumberSigns[meepoHandle.."-minimap"] then
  1822. local minimap_vec = MapToMinimap(meepo.position.x,meepo.position.y)
  1823. meepoNumberSigns[meepoHandle.."-minimap"] = drawMgr:CreateText(minimap_vec.x-2+minimapMove,minimap_vec.y-5,-1,""..meeponumber,F13)
  1824. elseif SleepCheck(meepoHandle.."-minimap") then
  1825. local minimap_vec = MapToMinimap(meepo.position.x,meepo.position.y)
  1826. meepoNumberSigns[meepoHandle.."-minimap"].x, meepoNumberSigns[meepoHandle.."-minimap"].y = minimap_vec.x-2+minimapMove,minimap_vec.y-5
  1827. Sleep(Animations.maxCount*2, meepoHandle.."-minimap")
  1828. end
  1829. local sign = statesSigns[tempmeepoTable[meepoHandle].state]
  1830. if sign then
  1831. if not meepoStateSigns[meepoHandle] then
  1832. meepoStateSigns[meepoHandle] = drawMgr:CreateText(120,79*meeponumber,sign[2],""..sign[1],F14) meepoStateSigns[meepoHandle].visible = true
  1833. else
  1834. meepoStateSigns[meepoHandle].text = ""..sign[1]
  1835. if tempmeepoTable[meepoHandle].state == STATE_CHASE and tempmeepoTable[meepoHandle].victim then
  1836. meepoStateSigns[meepoHandle].text = meepoStateSigns[meepoHandle].text..": "..client:Localize(tempmeepoTable[meepoHandle].victim.name)
  1837. end
  1838. meepoStateSigns[meepoHandle].color = sign[2]
  1839. end
  1840. end
  1841.  
  1842. --Determining move and idle states
  1843. if meepo.state == STATE_NONE or meepo.state == STATE_MOVE then
  1844. if meepo.activity == LuaEntityNPC.ACTIVITY_MOVE then
  1845. meepoTable[meepoHandle].state = STATE_MOVE
  1846. elseif meepo.activity == LuaEntityNPC.ACTIVITY_IDLE then
  1847. meepoTable[meepoHandle].state = STATE_NONE
  1848. end
  1849. tempmeepoTable = meepoTable
  1850. end
  1851.  
  1852. elseif tempmeepoTable[meepoHandle] then
  1853.  
  1854. --Reseting meepo attributes when he ded
  1855. --print("reset")
  1856. meepoTable[meepoHandle].state = STATE_LANE
  1857. meepoTable[meepoHandle].victim = nil
  1858. meepoTable[meepoHandle].foundCreep = false
  1859. meepoTable[meepoHandle].camp = nil
  1860. meepoTable[meepoHandle].victimFogTime = 0
  1861. tempmeepoTable = meepoTable
  1862. end
  1863. end
  1864. end
  1865.  
  1866. if not tempmeepoTable[myHand].blink then
  1867. meepoTable[myHand].blink = me:FindItem("item_blink")
  1868. tempmeepoTable = meepoTable
  1869. end
  1870.  
  1871. --Blink
  1872. if SleepCheck("blink") and (victim and victim.visible and distance(me,victim) > 700 and distance(me,victim) < 1700 and (tempmeepoTable[myHand].state == STATE_CHASE and me.health > (me.maxHealth/3)) or
  1873. (tempmeepoTable[myHand].camp and distance(me,tempmeepoTable[myHand].camp.position) > 200 and distance(me,tempmeepoTable[myHand].camp.position) < 1200 and tempmeepoTable[myHand].state == STATE_FARM_JUNGLE)) and retreatkeyCount == 0 and not retreat then
  1874. local blink = tempmeepoTable[myHand].blink
  1875. local blinkPos = nil
  1876. if (victim and (victim.hero or victim.classId == CDOTA_Unit_SpiritBear) and victim.visible and distance(me,victim) > 700 and distance(me,victim) < 1700 and tempmeepoTable[myHand].state == STATE_CHASE) then
  1877. blinkPos = victim.position
  1878. elseif tempmeepoTable[myHand].state == STATE_FARM_JUNGLE and tempmeepoTable[myHand].camp and not tempmeepoTable[myHand].camp.farmed and not tempmeepoTable[myHand].camp.visible and not tempmeepoTable[myHand].camp.stacking then
  1879. blinkPos = tempmeepoTable[myHand].camp.position
  1880. end
  1881. if blinkPos then
  1882. if distance(me,blinkPos) > 1100 then
  1883. blinkPos = (blinkPos - me.position) * 1100 / distance(blinkPos,me) + me.position
  1884. end
  1885. meepoTable[myHand].blinkPos = blinkPos
  1886. tempmeepoTable = meepoTable
  1887. if canCast(me, blink) then
  1888. DebugPrint("blink")
  1889. me:CastAbility(blink,blinkPos)
  1890. if victim then
  1891. Sleep(me:GetTurnTime(victim)*1000,myHand.."-casting")
  1892. Sleep(me:GetTurnTime(victim)*1000+500,"blink")
  1893. else
  1894. Sleep(me:GetTurnTime(tempmeepoTable[myHand].camp.position)*1000,myHand.."-casting")
  1895. Sleep(me:GetTurnTime(tempmeepoTable[myHand].camp.position)*1000+500,"blink")
  1896. end
  1897. end
  1898. end
  1899. end
  1900. end
  1901.  
  1902. ----Better functions to collect our meepos. Currently broken in Ensage
  1903.  
  1904. -- function meepoAdd(entity)
  1905. -- --print("asd")
  1906. -- if entity.type == LuaEntity.TYPE_MEEPO and not meepoTable[entity.handle] then
  1907. -- meepoTable[entity.handle] = entity
  1908. -- end
  1909. -- end
  1910.  
  1911. -- function meepoUpdate(propertyName,entity,newData)
  1912. -- if entity.type == LuaEntity.TYPE_MEEPO then
  1913. -- meepoTable[entity.handle] = entity
  1914. -- end
  1915. -- end
  1916.  
  1917. ----Function called on Load, registers our Main tick function and ensures reseting of all variables and settings to prevent crash
  1918.  
  1919. function Load()
  1920.  
  1921. --Checking version
  1922. --download()
  1923. local up,ver,beta,info = Version()
  1924. if up then
  1925. if beta ~= "" then
  1926. versionSign.text = "Your version of iMeepo is up-to-date! (v"..currentVersion.." "..Beta..")"
  1927. else
  1928. versionSign.text = "Your version of iMeepo is up-to-date! (v"..currentVersion..")"
  1929. end
  1930. versionSign.color = 0x66FF33FF
  1931. if info then
  1932. infoSign.text = info
  1933. infoSign.visible = true
  1934. end
  1935. end
  1936. if outdated then
  1937. if beta ~= "" then
  1938. versionSign.text = "Your version of iMeepo is OUTDATED (Yours: v"..currentVersion.." "..Beta.." Current: v"..ver.." "..beta.."), send me email to moones@email.cz to get current one!"
  1939. else
  1940. versionSign.text = "Your version of iMeepo is OUTDATED (Yours: v"..currentVersion.." "..Beta.." Current: v"..ver.."), send me email to moones@email.cz to get current one!"
  1941. end
  1942. versionSign.color = 0xFF6600FF
  1943. if info then
  1944. infoSign.text = info
  1945. infoSign.visible = true
  1946. end
  1947. end
  1948. versionSign.visible = true
  1949.  
  1950. if PlayingGame() then
  1951. me = entityList:GetMyHero()
  1952. player = entityList:GetMyPlayer()
  1953. if not player or not me or me.classId ~= CDOTA_Unit_Hero_Meepo then
  1954. versionSign.visible = false
  1955. infoSign.visible = false
  1956. script:Disable()
  1957. else
  1958. reg = true start = false myId = me.classId active = true meepoTable = {} DWS = {} base = nil allies = nil enemies = nil outdated = false retreat = false
  1959. retreattime = nil castingEarthbind = {0,0,0,0,0,0,0} poofDamage = { 0, 0 } meepoStateSigns = {} entitiesForPush = {} meepoMinimapNumberSigns = {} meepoNumberSigns = {}
  1960. spellDamageTable = {} mousehoverCamp = nil closestCamp = nil retreatStartTime = nil aoeStarttime = nil start,vec = nil,nil retreatkeyCount = 0 doubleclickTime = nil
  1961. EthDmg = 0 campSigns = {} eff = nil enemyTeam = nil meTeam = nil targetlock = false victim = nil
  1962. JungleCamps = {
  1963. {position = Vector(-1131,-4044,127), stackPosition = Vector(-2498.94,-3517.86,128), waitPosition = Vector(-1401.69,-3791.52,128), team = 2, id = 1, farmed = false, lvlReq = 8, visible = false, visTime = 0, stacking = false},
  1964. {position = Vector(-366,-2945,127), stackPosition = Vector(-534.219,-1795.27,128), waitPosition = Vector(536,-3001,256), team = 2, id = 2, farmed = false, lvlReq = 3, visible = false, visTime = 0, stacking = false},
  1965. {position = Vector(1606.45,-3433.36,256), stackPosition = Vector(1325.19,-5108.22,256), waitPosition = Vector(1541.87,-4265.38,256), team = 2, id = 3, farmed = false, lvlReq = 8, visible = false, visTime = 0, stacking = false},
  1966. {position = Vector(3126,-3439,256), stackPosition = Vector(4410.49,-3985,256), waitPosition = Vector(3401.5,-4233.39,256), team = 2, id = 4, farmed = false, lvlReq = 3, visible = false, visTime = 0, stacking = false},
  1967. {position = Vector(3031.03,-4480.06,256), stackPosition = Vector(1368.66,-5279.04,256), waitPosition = Vector(2939.61,-5457.52,256), team = 2, id = 5, farmed = false, lvlReq = 1, visible = false, visTime = 0, stacking = false},
  1968. {position = Vector(-2991,191,256), stackPosition = Vector(-3483,-1735,247), waitPosition = Vector(-2433,-356,256), team = 2, id = 6, farmed = false, lvlReq = 12, visible = false, visTime = 0, ancients = true, stacking = false},
  1969. {position = Vector(1167,3295,256), stackPosition = Vector(570.86,4515.96,256), waitPosition = Vector(1011,3656,256), team = 3, id = 7, farmed = false, lvlReq = 8, visible = false, visTime = 0, stacking = false},
  1970. {position = Vector(-244,3629,256), stackPosition = Vector(-1170.27,4581.59,256), waitPosition = Vector(-515,4845,256), team = 3, id = 8, farmed = false, lvlReq = 3, visible = false, visTime = 0, stacking = false},
  1971. {position = Vector(-1588,2697,127), stackPosition = Vector(-1302,3689.41,136.411), waitPosition = Vector(-1491,2986,127), team = 3, id = 9, farmed = false, lvlReq = 3, visible = false, visTime = 0, stacking = false},
  1972. {position = Vector(-3157.74,4475.46,256), stackPosition = Vector(-3296.1,5508.48,256), waitPosition = Vector(-3086,4924,256), team = 3, id = 10, farmed = false, lvlReq = 1, visible = false, visTime = 0, stacking = false},
  1973. {position = Vector(-4382,3612,256), stackPosition = Vector(-3026.54,3819.69,132.345), waitPosition = Vector(-3995,3984,256), team = 3, id = 11, farmed = false, lvlReq = 8, visible = false, visTime = 0, stacking = false},
  1974. {position = Vector(4026,-709.943,128), stackPosition = Vector(2228.46,-1046.78,128), waitPosition = Vector(3122,-1158.69,128), team = 3, id = 12, farmed = false, lvlReq = 12, visible = false, visTime = 0, ancients = true, stacking = false}
  1975. }
  1976. script:RegisterEvent(EVENT_FRAME, Main)
  1977. -- script:RegisterEvent(EVENT_ENTITY_ADD, meepoAdd)
  1978. -- script:RegisterEvent(EVENT_ENTITY_UPDATE, meepoUpdate)
  1979. script:RegisterEvent(EVENT_KEY, Key)
  1980. script:UnregisterEvent(Load)
  1981. end
  1982. end
  1983. end
  1984.  
  1985. ----Function called on close, unregisters our Main tick function and resets everything as well
  1986.  
  1987. function Close()
  1988. start = false enemyTeam = nil meTeam = nil
  1989. myId = nil
  1990. active = true
  1991. meepoTable = {}
  1992. DWS = {}
  1993. base = nil
  1994. allies = nil
  1995. enemies = nil
  1996. castingEarthbind = {0,0,0,0,0,0,0}
  1997. poofDamage = { 0, 0 }
  1998. meepoStateSigns = {}
  1999. entitiesForPush = {}
  2000. meepoMinimapNumberSigns = {}
  2001. meepoNumberSigns = {}
  2002. spellDamageTable = {}
  2003. mousehoverCamp = nil
  2004. closestCamp = nil
  2005. outdated = false
  2006. retreat = false
  2007. retreattime = nil
  2008. retreatStartTime = nil
  2009. aoeStarttime = nil
  2010. start,vec = nil,nil
  2011. retreatkeyCount = 0
  2012. doubleclickTime = nil
  2013. me = nil
  2014. player = nil
  2015. meepos = nil
  2016. JungleCamps = {
  2017. {position = Vector(-1131,-4044,127), stackPosition = Vector(-2498.94,-3517.86,128), waitPosition = Vector(-1401.69,-3791.52,128), team = 2, id = 1, farmed = false, lvlReq = 8, visible = false, visTime = 0, stacking = false},
  2018. {position = Vector(-366,-2945,127), stackPosition = Vector(-534.219,-1795.27,128), waitPosition = Vector(536,-3001,256), team = 2, id = 2, farmed = false, lvlReq = 3, visible = false, visTime = 0, stacking = false},
  2019. {position = Vector(1606.45,-3433.36,256), stackPosition = Vector(1325.19,-5108.22,256), waitPosition = Vector(1541.87,-4265.38,256), team = 2, id = 3, farmed = false, lvlReq = 8, visible = false, visTime = 0, stacking = false},
  2020. {position = Vector(3126,-3439,256), stackPosition = Vector(4410.49,-3985,256), waitPosition = Vector(3401.5,-4233.39,256), team = 2, id = 4, farmed = false, lvlReq = 3, visible = false, visTime = 0, stacking = false},
  2021. {position = Vector(3031.03,-4480.06,256), stackPosition = Vector(1368.66,-5279.04,256), waitPosition = Vector(2939.61,-5457.52,256), team = 2, id = 5, farmed = false, lvlReq = 1, visible = false, visTime = 0, stacking = false},
  2022. {position = Vector(-2991,191,256), stackPosition = Vector(-3483,-1735,247), waitPosition = Vector(-2433,-356,256), team = 2, id = 6, farmed = false, lvlReq = 12, visible = false, visTime = 0, ancients = true, stacking = false},
  2023. {position = Vector(1167,3295,256), stackPosition = Vector(570.86,4515.96,256), waitPosition = Vector(1011,3656,256), team = 3, id = 7, farmed = false, lvlReq = 8, visible = false, visTime = 0, stacking = false},
  2024. {position = Vector(-244,3629,256), stackPosition = Vector(-1170.27,4581.59,256), waitPosition = Vector(-515,4845,256), team = 3, id = 8, farmed = false, lvlReq = 3, visible = false, visTime = 0, stacking = false},
  2025. {position = Vector(-1588,2697,127), stackPosition = Vector(-1302,3689.41,136.411), waitPosition = Vector(-1491,2986,127), team = 3, id = 9, farmed = false, lvlReq = 3, visible = false, visTime = 0, stacking = false},
  2026. {position = Vector(-3157.74,4475.46,256), stackPosition = Vector(-3296.1,5508.48,256), waitPosition = Vector(-3086,4924,256), team = 3, id = 10, farmed = false, lvlReq = 1, visible = false, visTime = 0, stacking = false},
  2027. {position = Vector(-4382,3612,256), stackPosition = Vector(-3026.54,3819.69,132.345), waitPosition = Vector(-3995,3984,256), team = 3, id = 11, farmed = false, lvlReq = 8, visible = false, visTime = 0, stacking = false},
  2028. {position = Vector(4026,-709.943,128), stackPosition = Vector(2228.46,-1046.78,128), waitPosition = Vector(3122,-1158.69,128), team = 3, id = 12, farmed = false, lvlReq = 12, visible = false, visTime = 0, ancients = true, stacking = false}
  2029. }
  2030. campSigns = {}
  2031. collectgarbage("collect")
  2032. if reg then
  2033. script:UnregisterEvent(Main)
  2034. -- script:UnregisterEvent(meepoAdd)
  2035. -- script:UnregisterEvent(meepoUpdate)
  2036. script:UnregisterEvent(Key)
  2037. script:RegisterEvent(EVENT_TICK, Load)
  2038. reg = false
  2039. end
  2040. end
  2041.  
  2042. --Registering our Load and Close functions
  2043.  
  2044. script:RegisterEvent(EVENT_CLOSE, Close)
  2045. script:RegisterEvent(EVENT_TICK, Load)
  2046.  
  2047. --END of GLOBAL CONSTANTS--
  2048.  
  2049. --FUNCTIONS--
  2050.  
  2051. ----Determining if given spell can be casted by meepo
  2052.  
  2053. function canCast(meepo, spell)
  2054. return meepo and spell and spell:CanBeCasted() and meepo:CanCast()
  2055. end
  2056.  
  2057. ----Determining if victim will get hit by Poof
  2058.  
  2059. function willHit(meepo, victim, radius, n, meepos, distance, mathcos, mathsin)
  2060. local near,dist,nearMeepo = anyMeepoisNear(victim, radius, meepo, meepos, distance, mathcos, mathsin)
  2061. return ((radius and distance(meepo, victim) <= radius+150) or (n and near and dist <= radius+150)) and
  2062. (victim:IsStunned() or victim:IsRooted() or victim.movespeed < 200 or victim.creep or victim.classId == CDOTA_BaseNPC_Creep_Neutral or
  2063. Animations.isAttacking(victim) or (n and near and nearMeepo.handle ~= meepo.handle) or
  2064. victim.activity == LuaEntityNPC.ACTIVITY_IDLE)
  2065. end
  2066.  
  2067. ----Determining when to use earthbind to ensure 100% chaining
  2068.  
  2069. function chainEarthbind(meepo, target, delay, meepos)
  2070. local chain = false
  2071. local stunned = false
  2072. local modifiers_table = {"modifier_shadow_demon_disruption", "modifier_obsidian_destroyer_astral_imprisonment_prison",
  2073. "modifier_eul_cyclone", "modifier_invoker_tornado", "modifier_bane_nightmare", "modifier_shadow_shaman_shackles",
  2074. "modifier_crystal_maiden_frostbite", "modifier_ember_spirit_searing_chains", "modifier_axe_berserkers_call",
  2075. "modifier_lone_druid_spirit_bear_entangle_effect", "modifier_meepo_earthbind", "modifier_naga_siren_ensnare",
  2076. "modifier_storm_spirit_electric_vortex_pull", "modifier_treant_overgrowth", "modifier_cyclone",
  2077. "modifier_sheepstick_debuff", "modifier_shadow_shaman_voodoo", "modifier_lion_voodoo", "modifier_brewmaster_storm_cyclone",
  2078. "modifier_puck_phase_shift"}
  2079. local modifiers = target.modifiers
  2080. local length = #modifiers_table
  2081. table.sort(modifiers, function (a,b) return a.remainingTime > b.remainingTime end)
  2082. for i = 1, #modifiers do
  2083. local m = modifiers[i]
  2084. for z = 1, length do
  2085. local k = modifiers_table[z]
  2086. if m and (m.stunDebuff or m.name == k) then
  2087. stunned = true
  2088. local remainingTime = m.remainingTime
  2089. if m.name == "modifier_eul_cyclone" then remainingTime = m.remainingTime+0.07 end
  2090. if remainingTime <= delay then
  2091. chain = true
  2092. else
  2093. chain = false
  2094. end
  2095. end
  2096. end
  2097. end
  2098. return not (stunned or target:IsStunned()) or chain
  2099. end
  2100.  
  2101. ----Collecting our meepos
  2102.  
  2103. function collectMeepos(meepos)
  2104. for i = 1, #meepos do
  2105. local meepo = meepos[i]
  2106. if meepo and meepo.alive then
  2107. local hand = meepo.handle
  2108. if not meepoTable[hand] and not meepo:IsIllusion() then
  2109. meepoTable[hand] = {}
  2110. meepoTable[hand].state = STATE_LANE
  2111. meepoTable[hand].lastState = nil
  2112. meepoTable[hand].victim = nil
  2113. meepoTable[hand].lastcamp = nil
  2114. meepoTable[hand].foundCreep = false
  2115. meepoTable[hand].camp = nil
  2116. meepoTable[hand].victimFogTime = 0
  2117. meepoTable[hand].poof = meepo:GetAbility(2)
  2118. meepoTable[hand].earthbind = meepo:GetAbility(1)
  2119. end
  2120. end
  2121. end
  2122. end
  2123.  
  2124. ----Checking if any meepo is casting Earthbind right now
  2125.  
  2126. function earthbindAnimation(meepos)
  2127. for i = 1, #meepos do
  2128. local meepo = meepos[i]
  2129. local earthbind = meepo:GetAbility(1)
  2130. if earthbind and earthbind.abilityPhase then
  2131. return true
  2132. end
  2133. end
  2134. return false
  2135. end
  2136.  
  2137. ----Checking if any meepo is farming
  2138.  
  2139. function anyMeepoIsPushing(meepos)
  2140. for i = 1, #meepos do
  2141. local meepo = meepos[i]
  2142. if meepo.state == STATE_PUSH then
  2143. return true
  2144. end
  2145. end
  2146. return false
  2147. end
  2148.  
  2149. ----Getting position where to move for meepos to attempt blocking victim
  2150.  
  2151. function getBlockPositions(victim,rotR,meepo, mathcos, mathsin)
  2152. local me = me
  2153. local rotR1,rotR2 = -rotR,(-3-rotR)
  2154. local infront = Vector(victim.position.x+me.movespeed*mathcos(rotR), victim.position.y+me.movespeed*mathsin(rotR), victim.position.z)
  2155. local behind = Vector(victim.position.x+(-me.movespeed/2)*mathcos(rotR), victim.position.y+(-me.movespeed/2)*mathsin(rotR), victim.position.z)
  2156. return Vector(infront.x+90*mathcos(rotR1), infront.y+90*mathsin(rotR1), infront.z),
  2157. Vector(infront.x+90*mathcos(rotR2), infront.y+90*mathsin(rotR2), infront.z),
  2158. Vector(behind.x+120*mathcos(rotR1), behind.y+120*mathsin(rotR1), behind.z),
  2159. Vector(behind.x+120*mathcos(rotR2), behind.y+120*mathsin(rotR2), behind.z),infront
  2160. end
  2161.  
  2162. ----Checking if victim is facing any of our meepos
  2163.  
  2164. function isFacingAnyMeepo(victim,meepos,mathabs,mathrad,mathmax)
  2165. for i = 1, #meepos do
  2166. local m = meepos[i]
  2167. if (mathmax(mathabs(FindAngleR(victim) - mathrad(FindAngleBetween(victim, m))) - 0.20, 0)) <= 0.01 then
  2168. return true
  2169. end
  2170. end
  2171. return false
  2172. end
  2173.  
  2174. ----Checking if we have any meepo near victim
  2175.  
  2176. function anyMeepoisNear(victim, range, meepo, meepos, distance, mathcos, mathsin)
  2177. local closest = nil
  2178. for i = 1, #meepos do
  2179. local m = meepos[i]
  2180. if victim then
  2181. local pos = victim
  2182. if GetType(pos) ~= "Vector" then pos = victim.position end
  2183. local mpos = m.position
  2184. local dist = distance(mpos,pos)
  2185. if not closest or dist < distance(closest,pos) then
  2186. closest = m
  2187. end
  2188. end
  2189. end
  2190. if closest then
  2191. local pos = victim
  2192. if GetType(pos) ~= "Vector" then pos = victim.position end
  2193. local mpos = closest.position
  2194. if victim.activity == LuaEntityNPC.ACTIVITY_MOVE then
  2195. pos = Vector(victim.position.x+(victim.movespeed*1.5)*mathcos(victim.rotR), victim.position.y+(victim.movespeed*1.5)*mathsin(victim.rotR), victim.position.z)
  2196. end
  2197. if closest.activity == LuaEntityNPC.ACTIVITY_MOVE then
  2198. mpos = Vector(closest.position.x+(closest.movespeed)*mathcos(closest.rotR), closest.position.y+(closest.movespeed)*mathsin(closest.rotR), closest.position.z)
  2199. end
  2200. local dist = distance(mpos,pos)
  2201. if (range and dist < range) and (not meepo or closest.handle ~= meepo.handle) then
  2202. return true,dist,closest
  2203. end
  2204. end
  2205. return false,0,nil
  2206. end
  2207.  
  2208. ----Returns lowest HP meepo
  2209.  
  2210. function getLowestHPMeepo(meepos)
  2211. local lowest = nil
  2212. for i = 1, #meepos do
  2213. local meepo = meepos[i]
  2214. if not lowest or lowest.health > meepo.health then
  2215. lowest = meepo
  2216. end
  2217. end
  2218. return lowest
  2219. end
  2220.  
  2221. ----Returns closest meepo to victim
  2222.  
  2223. function getClosest(victim, num, net, exclude, meepos, distance)
  2224. --local meepos = entityList:GetEntities({type=LuaEntity.TYPE_MEEPO, team=meTeam, alive=true})
  2225. if net or num == 1 then
  2226. local closest = nil
  2227. for i = 1, #meepos do
  2228. local meepo = meepos[i]
  2229. if not meepo:IsIllusion() and (not exclude or meepo.handle ~= exclude.handle) and meepo.alive and ((meepoTable[meepo.handle].earthbind and canCast(meepo, meepoTable[meepo.handle].earthbind)) or not net) and (not closest or (victim and distance(meepo,victim) < distance(closest,victim))) then
  2230. closest = meepo
  2231. end
  2232. end
  2233. return closest
  2234. elseif num > 1 then
  2235. --table.sort(meepos, function (a,b) return distance(a,victim) < distance(b,victim) end)
  2236. local returnTable = {}
  2237. local number = 0
  2238. for i = 1, #meepos do
  2239. local meepo = meepos[i]
  2240. number = number + 1
  2241. if meepo.alive and number <= num and not meepoTable[meepo.handle].victim then
  2242. returnTable[i] = meepo
  2243. end
  2244. end
  2245. return returnTable
  2246. else
  2247. --table.sort(meepos, function (a,b) return distance(a,victim) < distance(b,victim) end)
  2248. local returnTable = {}
  2249. for i = 1, #meepos do
  2250. local meepo = meepos[i]
  2251. if meepo.alive and not meepoTable[meepo.handle].victim then
  2252. returnTable[i] = meepo
  2253. return returnTable
  2254. end
  2255. end
  2256. end
  2257. return nil
  2258. end
  2259.  
  2260. ----Returns number of alive meepos
  2261.  
  2262. function getAliveNumber(all,meepos)
  2263. local number = 0
  2264. for i = 1, #meepos do
  2265. local meepo = meepos[i]
  2266. if meepo.alive and ((meepoTable[meepo.handle] and meepoTable[meepo.handle].state ~= STATE_HEAL) or all) then
  2267. number = number + 1
  2268. end
  2269. end
  2270. return number
  2271. end
  2272.  
  2273. ----Checks if main meepo has items for heal and is close to given meepo
  2274.  
  2275. function haveHealingItems(meepo, distance)
  2276. local me = me
  2277. local isMe = false
  2278. if meepo.handle == me.handle then
  2279. me = meepo
  2280. isMe = true
  2281. end
  2282. local salve = me:FindItem("item_flask")
  2283. local bottle = me:FindItem("item_bottle")
  2284. local items = {}
  2285. if salve then
  2286. items[#items+1] = salve
  2287. end
  2288. if bottle and bottle.charges > 0 then
  2289. items[#items+1] = bottle
  2290. end
  2291. if items[1] and (distance(me, meepo) < 1000 or isMe) then
  2292. return false, items, isMe
  2293. end
  2294. return true, nil
  2295. end
  2296.  
  2297.  
  2298. ----Checks if given meepo is in danger
  2299.  
  2300. function IsInDanger(meepo,except,distance,mathmin)
  2301. if meepo and meepo.alive then
  2302. local projs = entityList:GetProjectiles({target=meepo})
  2303. for k = 1, #projs do
  2304. local z = projs[k]
  2305. if z and z.source and z.target == meepo and (not except or z.source.handle ~= except.handle) and (distance(z,z.source) < 1000 or (z.source.dmgMin and z.source.dmgMin > meepo.health)) then
  2306. return true
  2307. end
  2308. end
  2309. for i = 1, #enemies do
  2310. local v = enemies[i]
  2311. if v.alive and v.visible and distance(meepo,v) < 700 and (not except or v.handle ~= except.handle) then
  2312. return true
  2313. end
  2314. end
  2315. local neutrals = entityList:GetEntities({classId=CDOTA_BaseNPC_Creep_Neutral,visible=true})
  2316. for i = 1, #neutrals do
  2317. local v = neutrals[i]
  2318. if distance(meepo,v) < v.attackRange+200 and v.alive and (not except or v.handle ~= except.handle) and v.activity == LuaEntityNPC.ACTIVITY_ATTACK then
  2319. return true
  2320. end
  2321. for i = 1, #v.abilities do
  2322. local k = v.abilities[i]
  2323. if distance(meepo,v) < mathmin(k.castRange+200,1000) and (not except or v.handle ~= except.handle) then
  2324. return true
  2325. end
  2326. end
  2327. end
  2328. local modifiers = {"modifier_item_urn_damage","modifier_doom_bringer_doom","modifier_axe_battle_hunger",
  2329. "modifier_queenofpain_shadow_strike","modifier_phoenix_fire_spirit_burn","modifier_venomancer_poison_nova",
  2330. "modifier_venomancer_venomous_gale","modifier_silencer_curse_of_the_silent","modifier_silencer_last_word","modifier_spirit_breaker_charge_of_darkness_vision",
  2331. "modifier_bloodseeker_thirst"}
  2332. for i = 1, #modifiers do
  2333. local v = modifiers[i]
  2334. if meepo:DoesHaveModifier(v) then
  2335. return true
  2336. end
  2337. end
  2338. end
  2339. end
  2340.  
  2341. ----Return how many meepos are farming this camp
  2342.  
  2343. function getFarmingMeeposCamp(camp,current)
  2344. if camp then
  2345. local number = 0
  2346. local tempmeepoTable = meepoTable
  2347. for meepoHandle, meepo in pairs(tempmeepoTable) do
  2348. local meepo = tempmeepoTable[meepoHandle]
  2349. if meepo.camp and meepo.camp == camp and (not current or meepo.handle ~= current.handle) then
  2350. number = number + 1
  2351. end
  2352. end
  2353. return number
  2354. end
  2355. end
  2356.  
  2357. ----Returns closest jungle camp for given meepo
  2358.  
  2359. function getClosestCamp(meepo, stack, num, pos, distance, any)
  2360. if meepo and meepo.health and meepo.alive then
  2361. local closest = nil
  2362. local tempJungleCamps = JungleCamps
  2363. for i = 1, #tempJungleCamps do
  2364. local camp = tempJungleCamps[i]
  2365. local number = getFarmingMeeposCamp(camp,meepo)
  2366. local cnumber = 0
  2367. if closest then
  2368. cnumber = getFarmingMeeposCamp(closest,meepo)
  2369. end
  2370. local reqNum = 1
  2371. if camp.ancients then
  2372. reqNum = 2
  2373. elseif meepo.level < 10 then
  2374. reqNum = 3
  2375. end
  2376. if (camp.team == meepo.team or ((not num or num < 2 or (not pos or distance(meepo,pos) > 2500)) and client.gameTime > 2400)) and ((not camp.visible and ((not stack and meepo.level >= camp.lvlReq) or (stack and camp.lvlReq == 8)) and (camp.team == meepo.team or meepo.level >= 17) and ((number < reqNum or any) and (not camp.ancients or (meepo.level >= 17 or me:AghanimState()))))) and
  2377. (not closest or distance(meepo,camp.position) < distance(meepo,closest.position) or cnumber > 2 or closest.farmed or closest.visible) and not camp.farmed and not camp.visible then
  2378.  
  2379. closest = camp
  2380. end
  2381. end
  2382. return closest
  2383. end
  2384. end
  2385.  
  2386. ----Returns closest wait position
  2387.  
  2388. function getClosestPos(meepo,distance)
  2389. if meepo and meepo.alive then
  2390. local closest = nil
  2391. local tempJungleCamps = JungleCamps
  2392. for i = 1, #tempJungleCamps do
  2393. local camp = tempJungleCamps[i]
  2394. if camp.team == meepo.team and (not closest or distance(meepo,camp.waitPosition) < distance(meepo,closest.waitPosition)) then
  2395. closest = camp
  2396. end
  2397. end
  2398. return closest
  2399. end
  2400. end
  2401.  
  2402. ----Returns farrest meepo
  2403.  
  2404. function getFarrestMeepo(meepo, meepos,distance)
  2405. if meepo and meepo.alive then
  2406. local farrest = nil
  2407. for i = 1, #meepos do
  2408. local farMeepo = meepos[i]
  2409. if farMeepo.handle ~= meepo.handle and (not farrest or (distance(farMeepo,meepo) > distance(farrest,meepo))) then
  2410. farrest = farMeepo
  2411. end
  2412. end
  2413. return farrest
  2414. end
  2415. end
  2416.  
  2417. ----Returns number of near victims
  2418.  
  2419. function getNearVictims(meepo,distance)
  2420. if meepo and meepo.alive then
  2421. local number = 0
  2422. local table = {}
  2423. for i = 1, #enemies do
  2424. local v = enemies[i]
  2425. if v.alive and v.visible and distance(v,meepo) <= 1000 then
  2426. number = number + 1
  2427. table[number] = v
  2428. end
  2429. end
  2430. return number,table
  2431. end
  2432. end
  2433.  
  2434. ----AnyMeepoTping
  2435.  
  2436. function tping(position,distance,meepoh)
  2437. local tempmeepoTable = meepoTable
  2438. for meepoHandle,meepo in pairs(tempmeepoTable) do
  2439. if tempmeepoTable[meepoHandle].tping and distance(tempmeepoTable[meepoHandle].tping, position) < 1000 and meepoHandle ~= meepoh then
  2440. if tempmeepoTable[meepoHandle].tpTime then
  2441. return true,(3 - (client.gameTime - tempmeepoTable[meepoHandle].tpTime))
  2442. end
  2443. return true
  2444. end
  2445. end
  2446. return false
  2447. end
  2448.  
  2449. ----Use TP
  2450.  
  2451. function useTP(meepo, meepoHandle, position, nopoof, notp, meepos, distance, mathcos, mathsin)
  2452. if SleepCheck(meepoHandle.."-casting") and position then
  2453. local travels = meepo:FindItem("item_travel_boots") or meepo:FindItem("item_travel_boots_2")
  2454. local tp = meepo:FindItem("item_tpscroll")
  2455. local item = nil
  2456. local tempmeepoTable = meepoTable
  2457. local poof = tempmeepoTable[meepoHandle].poof
  2458. local near,dist,nearMeepo = anyMeepoisNear(position, 5000, meepo, meepos, distance, mathcos, mathsin)
  2459. local victim = tempmeepoTable[meepoHandle].victim
  2460. if victim and (victim.hero or victim.classId == CDOTA_Unit_SpiritBear) then
  2461. near,dist,nearMeepo = anyMeepoisNear(position, 1000, meepo, meepos, distance, mathcos, mathsin)
  2462. end
  2463. local meepotp,time = tping(position,distance,meepo.handle)
  2464. if not nopoof and poof and not poof.abilityPhase and poof.level > 0 and canCast(meepo, poof) and ((near and distance(nearMeepo,meepo) > 1000 and nearMeepo ~= meepo) or (meepotp and time and time < (poof:FindCastPoint()-meepo:GetTurnTime(position)))) then
  2465. meepo:CastAbility(poof,position)
  2466. meepo:Move(position, true)
  2467. meepoTable[meepoHandle].lastState = tempmeepoTable[meepoHandle].state
  2468. meepoTable[meepoHandle].state = STATE_POOF_OUT
  2469. Sleep(poof:FindCastPoint()*1000,meepoHandle.."-casting")
  2470. return true
  2471. end
  2472. if travels then item = travels else item = tp end
  2473. if (not poof or (not poof.abilityPhase and poof.cd > 0)) and item and canCast(meepo, item) and not notp and distance(meepo,position) > 4000 and (not meepotp or (not poof or not canCast(meepo,poof))) and SleepCheck("travels") then
  2474. meepo:CastAbility(item,position)
  2475. meepo:Move(position, true)
  2476. meepoTable[meepoHandle].tping = position
  2477. meepoTable[meepoHandle].tpTime = gameTime+(client.latency/1000)+meepo:GetTurnTime(position)
  2478. Sleep(3000,meepoHandle.."-casting")
  2479. Sleep(100,"travels")
  2480. return true
  2481. end
  2482. end
  2483. end
  2484.  
  2485. function GetAttackRange(hero)
  2486. local bonus = 0
  2487. if hero.classId == CDOTA_Unit_Hero_TemplarAssassin then
  2488. local psy = hero:GetAbility(3)
  2489. psyrange = {60,120,180,240}
  2490. if psy and psy.level > 0 then
  2491. bonus = psyrange[psy.level]
  2492. end
  2493. elseif hero.classId == CDOTA_Unit_Hero_Sniper then
  2494. local aim = hero:GetAbility(3)
  2495. aimrange = {100,200,300,400}
  2496. if aim and aim.level > 0 then
  2497. bonus = aimrange[aim.level]
  2498. end
  2499. end
  2500. return hero.attackRange + bonus
  2501. end
  2502.  
  2503. ----returns damage going on meepo
  2504.  
  2505. function IncomingDamage(unit,onlymagic,lane)
  2506. if unit and unit.alive then
  2507. local result = 0
  2508. local plusdamage = 0
  2509. local type = DAMAGE_MAGC
  2510. local results = {}
  2511. local resultsMagic = {}
  2512. local enemy = enemies
  2513. local source = nil
  2514. if #enemies > 0 and unit.team == enemy[1].team then
  2515. enemy = allies
  2516. end
  2517. for i,v in pairs(enemy) do
  2518. if v.alive and v.visible then
  2519. if not onlymagic and not results[v.handle] and (Animations.isAttacking(v) or distance(unit,v) < 200) and distance(unit,v) <= GetAttackRange(v) + 50 and (mathmax(math.abs(FindAngleR(v) - math.rad(FindAngleBetween(v, unit))) - 0.20, 0)) == 0 then
  2520. local dmg = (v.dmgMax+v.dmgBonus)*(4/(Animations.getBackswingTime(v)+Animations.GetAttackTime(v)) + latency/1000)
  2521. if v.type == LuaEntity.TYPE_MEEPO then
  2522. dmg = dmg*getAliveNumber()
  2523. end
  2524. plusdamage = plusdamage + dmg
  2525. results[v.handle] = true
  2526. end
  2527. result = result + math.floor(unit:DamageTaken(plusdamage,DAMAGE_PHYS,v))
  2528. plusdamage = 0
  2529. for i,k in pairs(unit.modifiers) do
  2530. local spell = v:FindSpell(k.name:gsub("modifier_",""))
  2531. if spell then
  2532. local dmg
  2533. if not spellDamageTable[spell.handle] or spellDamageTable[spell.handle][2] ~= spell.level or spellDamageTable[spell.handle][3] ~= v.dmgMin+v.dmgBonus or spellDamageTable[spell.handle][4] ~= v.attackSpeed then
  2534. spellDamageTable[spell.handle] = { AbilityDamage.GetDamage(spell), spell.level, v.dmgMin+v.dmgBonus, v.attackSpeed }
  2535. end
  2536. dmg = spellDamageTable[spell.handle][1]
  2537. if v.type == LuaEntity.TYPE_MEEPO then
  2538. dmg = dmg*getAliveNumber()
  2539. end
  2540. if dmg and dmg > 0 and not resultsMagic[spell.handle] and not resultsMagic[k.handle] then
  2541. plusdamage = plusdamage + dmg
  2542. type = AbilityDamage.GetDmgType(spell)
  2543. resultsMagic[k.handle] = true
  2544. resultsMagic[spell.handle] = true
  2545. end
  2546. end
  2547. end
  2548. result = result + math.floor(unit:DamageTaken(plusdamage,type,v))
  2549. plusdamage = 0
  2550. for i,k in pairs(v.abilities) do
  2551. if k.level > 0 and (k.abilityPhase or (k:CanBeCasted() and k:FindCastPoint() < 0.4)) and not resultsMagic[k.handle] and distance(v,unit) <= k.castRange+100 and (((mathmax(math.abs(FindAngleR(v) - math.rad(FindAngleBetween(v, unit))) - 0.20, 0)) == 0
  2552. and (k:IsBehaviourType(LuaEntityAbility.BEHAVIOR_UNIT_TARGET) or k:IsBehaviourType(LuaEntityAbility.BEHAVIOR_POINT))) or k:IsBehaviourType(LuaEntityAbility.BEHAVIOR_NO_TARGET)) then
  2553. local dmg
  2554. if not spellDamageTable[k.handle] or spellDamageTable[k.handle][2] ~= k.level or spellDamageTable[k.handle][3] ~= v.dmgMin+v.dmgBonus or spellDamageTable[k.handle][4] ~= v.attackSpeed then
  2555. spellDamageTable[k.handle] = { AbilityDamage.GetDamage(k), k.level, v.dmgMin+v.dmgBonus, v.attackSpeed }
  2556. end
  2557. dmg = spellDamageTable[k.handle][1]
  2558. if dmg then
  2559. plusdamage = plusdamage + dmg
  2560. type = AbilityDamage.GetDmgType(k)
  2561. resultsMagic[k.handle] = true
  2562. end
  2563. end
  2564. end
  2565. result = result + math.floor(unit:DamageTaken(plusdamage,type,v))
  2566. plusdamage = 0
  2567. for i,k in pairs(v.items) do
  2568. local dmg
  2569. if not spellDamageTable[k.handle] or spellDamageTable[k.handle][2] ~= v.level or spellDamageTable[k.handle][3] ~= v.dmgMin+v.dmgBonus or spellDamageTable[k.handle][4] ~= v.attackSpeed then
  2570. spellDamageTable[k.handle] = { AbilityDamage.GetDamage(k), v.level, v.dmgMin+v.dmgBonus, v.attackSpeed }
  2571. end
  2572. dmg = spellDamageTable[k.handle][1]
  2573. if dmg and dmg > 0 and k.castRange and not resultsMagic[k.handle] and distance(v,unit) <= k.castRange+200 then
  2574. plusdamage = plusdamage + dmg
  2575. resultsMagic[k.handle] = true
  2576. end
  2577. end
  2578. result = result + math.floor(unit:DamageTaken(plusdamage,DAMAGE_MAGC,v))
  2579. plusdamage = 0
  2580. end
  2581. end
  2582. for i,k in pairs(entityList:GetProjectiles({target=unit})) do
  2583. if k.source then
  2584. -- local spell = k.source:FindSpell(k.name)
  2585. -- if spell and not resultsMagic[k.source.handle] and not resultsMagic[k.name] then
  2586. -- local dmg
  2587. -- if not spellDamageTable[spell.handle] or spellDamageTable[spell.handle][2] ~= spell.level or spellDamageTable[spell.handle][3] ~= k.source.dmgMin+k.source.dmgBonus or spellDamageTable[spell.handle][4] ~= k.source.attackSpeed then
  2588. -- spellDamageTable[spell.handle] = { AbilityDamage.GetDamage(spell), spell.level, k.source.dmgMin+k.source.dmgBonus, k.source.attackSpeed }
  2589. -- end
  2590. -- dmg = spellDamageTable[spell.handle][1]
  2591. -- if k.source.type == LuaEntity.TYPE_MEEPO then
  2592. -- dmg = dmg*getAliveNumber()
  2593. -- end
  2594. -- if dmg then
  2595. -- result = result + math.floor(unit:DamageTaken(dmg,AbilityDamage.GetDmgType(spell),k.source))
  2596. -- resultsMagic[k.source.handle] = true
  2597. -- resultsMagic[k.name] = true
  2598. -- end
  2599. if not onlymagic and k.source and not results[k.source.handle] and k.source.dmgMax then
  2600. local dmg = (k.source.dmgMax+k.source.dmgBonus)*(4/(Animations.getBackswingTime(k.source)+Animations.GetAttackTime(k.source)) + latency/1000)
  2601. if k.source.type == LuaEntity.TYPE_MEEPO then
  2602. dmg = dmg*getAliveNumber()
  2603. end
  2604. plusdamage = plusdamage + dmg
  2605. source = k.source
  2606. results[k.source.handle] = true
  2607. end
  2608. end
  2609. end
  2610. if source then
  2611. result = result + math.floor(unit:DamageTaken(plusdamage,DAMAGE_PHYS,source))
  2612. end
  2613. if result then
  2614. return result
  2615. else
  2616. return 0
  2617. end
  2618. end
  2619. end
  2620.  
  2621. ----Switching treads for mana
  2622.  
  2623. function SwitchTreads(back)
  2624. local me = me
  2625. local treads = me:FindItem("item_power_treads")
  2626. if treads and SleepCheck("treads") and me.alive and not me:IsInvisible() then
  2627. local state = treads.bootsState
  2628. if back then
  2629. if state == 1 then
  2630. me:CastAbility(treads)
  2631. Sleep(200+client.latency,"treads")
  2632. elseif state == 0 then
  2633. me:CastAbility(treads)
  2634. me:CastAbility(treads)
  2635. Sleep(200+client.latency,"treads")
  2636. end
  2637. else
  2638. if state == 2 then
  2639. me:CastAbility(treads)
  2640. me:CastAbility(treads)
  2641. Sleep(2000+client.latency,"treads")
  2642. elseif state == 0 then
  2643. me:CastAbility(treads)
  2644. Sleep(2000+client.latency,"treads")
  2645. end
  2646. end
  2647. end
  2648. end
  2649.  
  2650. ----OrbWalks on victim, uses spells and abilities
  2651.  
  2652. function OrbWalk(meepo, meepoHandle, victim, usePoof, meepos, distance, mathcos, mathsin,mathabs,mathrad,mathceil,mathmax)
  2653. local player = player
  2654. local me = me
  2655. local tempmeepoTable = meepoTable
  2656. local poof = tempmeepoTable[meepoHandle].poof
  2657. if meepo:IsChanneling() then return end
  2658. --local infront = Vector(victim.position.x+150*mathcos(victim.rotR), victim.position.y+150*mathsin(victim.rotR), victim.position.z)
  2659. local behind = Vector(meepo.position.x+(-200)*mathcos(meepo.rotR), meepo.position.y+(-200)*mathsin(meepo.rotR), meepo.position.z)
  2660. --local block = SkillShot.__CheckBlock(entitiesForPush,meepo.position,infront,100,victim)
  2661. local position = nil
  2662. if not Animations.CanMove(meepo) and victim and victim.alive then
  2663.  
  2664. --Cast Poof global
  2665. if poof and SleepCheck(meepoHandle.."-casting") and victim and victim.visible and meepo.health > meepo.maxHealth/2.5 then
  2666. local radius = poof:GetSpecialData("radius", poof.level)
  2667. local near,dist,nearMeepo = anyMeepoisNear(victim, radius, meepo, meepos, distance, mathcos, mathsin)
  2668. if near and not poof.abilityPhase and poof.level > 0 and nearMeepo ~= meepo and distance(meepo,nearMeepo) > 700 and (willHit(meepo, victim, radius, true, meepos, distance, mathcos, mathsin) or distance(meepo,victim) > radius*1.5) and distance(nearMeepo,victim) > distance(meepo,victim) then
  2669. if canCast(meepo, poof) then
  2670. SwitchTreads()
  2671. meepo:CastAbility(poof,nearMeepo.position)
  2672. meepoTable[meepoHandle].lastState = tempmeepoTable[meepoHandle].state
  2673. meepoTable[meepoHandle].state = STATE_POOF_OUT
  2674. Sleep(poof:FindCastPoint()*1000,meepoHandle.."-casting")
  2675. elseif poof.cd == 0 then
  2676. SwitchTreads()
  2677. end
  2678. end
  2679. end
  2680.  
  2681. --Cast Poof
  2682. if poof and SleepCheck(meepoHandle.."-casting") and not poof.abilityPhase and victim and victim.visible and not victim:IsMagicImmune() and victim.alive and usePoof and not victim.ancient and
  2683. victim.classId ~= CDOTA_BaseNPC_Tower and victim.classId ~= CDOTA_BaseNPC_Creep_Siege then
  2684. local hitDmg = mathceil(victim:DamageTaken((meepo.dmgMin + meepo.dmgMax)/2,DAMAGE_PHYS,meepo))
  2685. local poofDmg = mathceil(victim:DamageTaken(poofDamage[1],DAMAGE_MAGC,meepo))
  2686. local radius = poof:GetSpecialData("radius", poof.level)
  2687. local near,dist,nearMeepo = anyMeepoisNear(victim, radius, meepo, meepos, distance, mathcos, mathsin)
  2688. local near2,dist2,nearMeepo2 = anyMeepoisNear(victim, 1300, meepo, meepos, distance, mathcos, mathsin)
  2689. --print(poofDmg,hitDmg,((not chainEarthbind(meepo, victim, poof:FindCastPoint()+client.latency/1000, meepos) and victim:IsInvisible()) or not victim:IsInvisible() or victim.creep or
  2690. --victim.classId == CDOTA_BaseNPC_Creep_Neutral or victim.classId == CDOTA_BaseNPC_Creep_Lane or (not meepo:GetAbility(1) or not canCast(meepo, meepo:GetAbility(1)))), poof.level, willHit(meepo, victim, radius/2+50, false, meepos, distance, mathcos, mathsin),(not tempmeepoTable[meepoHandle].camp or (distance(meepo, tempmeepoTable[meepoHandle].camp.position) < radius+25) or tempmeepoTable[meepoHandle].state == STATE_PUSH or tempmeepoTable[meepoHandle].state == STATE_CHASE))
  2691. if poofDmg/1.5 > hitDmg and ((not chainEarthbind(meepo, victim, poof:FindCastPoint()+client.latency/1000, meepos) and victim:IsInvisible()) or not victim:IsInvisible() or victim.creep or
  2692. victim.classId == CDOTA_BaseNPC_Creep_Neutral or victim.classId == CDOTA_BaseNPC_Creep_Lane) and poof.level > 0
  2693. and willHit(meepo, victim, radius/2, false, meepos, distance, mathcos, mathsin) and (not tempmeepoTable[meepoHandle].camp or (distance(meepo, tempmeepoTable[meepoHandle].camp.position) < radius+25) or tempmeepoTable[meepoHandle].state == STATE_PUSH or tempmeepoTable[meepoHandle].state == STATE_CHASE) then
  2694. if canCast(meepo, poof) then
  2695. SwitchTreads()
  2696. if ((near and (dist and distance(meepo,victim) > dist)) or near2) and nearMeepo and distance(meepo,victim) > distance(nearMeepo,victim) then
  2697. meepo:CastAbility(poof,nearMeepo.position)
  2698. Sleep(poof:FindCastPoint()*1000,meepoHandle.."-casting")
  2699. elseif willHit(meepo, victim, radius/2, false, meepos, distance, mathcos, mathsin) then
  2700. meepo:CastAbility(poof,meepo.position)
  2701. Sleep(poof:FindCastPoint()*1000,meepoHandle.."-casting")
  2702. end
  2703. elseif poof.cd == 0 then
  2704. SwitchTreads()
  2705. end
  2706. end
  2707. end
  2708.  
  2709. --useTP(meepo, meepoHandle, victim.position, true)
  2710.  
  2711. --Attack
  2712. if SleepCheck(meepoHandle.."-attack") and SleepCheck(meepoHandle.."-casting") then
  2713. meepo:Attack(victim)
  2714. Sleep(Animations.GetAttackTime(meepo)*1000 + Animations.getBackswingTime(meepo)*1000 - meepo:GetTurnTime(behind)*1000,meepoHandle.."-attack")
  2715. end
  2716. else
  2717.  
  2718. --Block victim if there is any, or try to get in better position
  2719. if SleepCheck(meepoHandle.."-casting") and SleepCheck(meepoHandle.."-move") then
  2720. if victim and victim.alive then
  2721. local bPos1,bPos2,bPos3,bPos4,bPos = getBlockPositions(victim,victim.rotR,meepo, mathcos, mathsin)
  2722. local dist1,dist2,bDist,canblock = distance(meepo,bPos1),distance(meepo,bPos2),distance(meepo,bPos),SkillShot.__CheckBlock(entitiesForPush,meepo.position,bPos,100,victim)
  2723. and (distance(meepo,bPos) > distance(victim,bPos))
  2724. if meepo.attackSpeed < 200 and ((victim.hero or victim.classId == CDOTA_Unit_SpiritBear) or (not victim:IsRanged() and victim.classId ~= CDOTA_BaseNPC_Tower and victim.classId ~= CDOTA_BaseNPC_Creep_Lane and
  2725. victim.classId ~= CDOTA_BaseNPC_Barracks and victim.classId ~= CDOTA_BaseNPC_Building and victim.classId ~= CDOTA_BaseNPC_Creep_Siege))
  2726. and victim.visible and (victim.activity == LuaEntityNPC.ACTIVITY_MOVE or
  2727. not isFacingAnyMeepo(victim, meepos,mathabs,mathrad,mathmax)) then
  2728. if not canblock then
  2729. if dist1 < dist2 and not SkillShot.__CheckBlock(entitiesForPush,meepo.position,bPos1,100,victim) then
  2730. if tempmeepoTable[meepoHandle].state ~= STATE_FARM_JUNGLE or (tempmeepoTable[meepoHandle].camp and distance(meepo, tempmeepoTable[meepoHandle].camp.position) < distance(bPos1, tempmeepoTable[meepoHandle].camp.position)) then
  2731. meepo:Move(bPos1)
  2732. position = bPos1
  2733. else
  2734. meepo:Follow(victim)
  2735. end
  2736. elseif not SkillShot.__CheckBlock(entitiesForPush,meepo.position,bPos2,100,victim) then
  2737. if tempmeepoTable[meepoHandle].state ~= STATE_FARM_JUNGLE or (tempmeepoTable[meepoHandle].camp and distance(meepo, tempmeepoTable[meepoHandle].camp.position) < distance(bPos2, tempmeepoTable[meepoHandle].camp.position)) then
  2738. meepo:Move(bPos2)
  2739. position = bPos2
  2740. else
  2741. meepo:Follow(victim)
  2742. end
  2743. elseif dist1 < dist2 then
  2744. if tempmeepoTable[meepoHandle].state ~= STATE_FARM_JUNGLE or (tempmeepoTable[meepoHandle].camp and distance(meepo, tempmeepoTable[meepoHandle].camp.position) < distance(bPos3, tempmeepoTable[meepoHandle].camp.position)) then
  2745. meepo:Move(bPos3)
  2746. position = bPos3
  2747. else
  2748. meepo:Follow(victim)
  2749. end
  2750. else
  2751. if tempmeepoTable[meepoHandle].state ~= STATE_FARM_JUNGLE or (tempmeepoTable[meepoHandle].camp and distance(meepo, tempmeepoTable[meepoHandle].camp.position) < distance(bPos4, tempmeepoTable[meepoHandle].camp.position)) then
  2752. meepo:Move(bPos4)
  2753. position = bPos4
  2754. else
  2755. meepo:Follow(victim)
  2756. end
  2757. end
  2758. elseif tempmeepoTable[meepoHandle].state ~= STATE_FARM_JUNGLE or (tempmeepoTable[meepoHandle].camp and distance(meepo, tempmeepoTable[meepoHandle].camp.position) < distance(bPos, tempmeepoTable[meepoHandle].camp.position)) then
  2759. meepo:Move(bPos)
  2760. position = bPos
  2761. else
  2762. meepo:Follow(victim)
  2763. end
  2764. else
  2765. meepo:Follow(victim)
  2766. end
  2767. elseif player.selection[1] and meepoHandle ~= player.selection[1].handle then
  2768. meepoTable[meepoHandle].state = STATE_FARM_JUNGLE
  2769. else
  2770. meepoTable[meepoHandle].state = 10
  2771. meepo:Move(client.mousePosition)
  2772. end
  2773. Sleep(Animations.getBackswingTime(meepo)*1000,meepoHandle.."-move")
  2774. if meepoHandle == me.handle then
  2775. start = false
  2776. end
  2777. end
  2778. end
  2779. end
  2780.  
  2781. ----Shop Opened ((C) Nyan)
  2782.  
  2783. function shop()
  2784. local mx = client.mouseScreenPosition.x
  2785. local my = client.mouseScreenPosition.y
  2786. local ShopPanel = {1920-565,76,1920,80+774}
  2787. if client.shopOpen and mx >= ShopPanel[1] and mx <= ShopPanel[3] and my >= ShopPanel[2] and my <= ShopPanel[4] then
  2788. return false
  2789. end
  2790. return true
  2791. end
  2792.  
  2793.  
  2794. ----Download Version File
  2795.  
  2796. -- function download()
  2797. -- --require 'luarocks.require'
  2798. -- local http = require 'socket.http'
  2799. -- local content = http.get("https://raw.githubusercontent.com/Moones/Ensage-scripts/master/Scripts/iMeepo_Version.lua").readAll()
  2800. -- if not content then
  2801. -- error("Could not connect to website")
  2802. -- end
  2803. -- local f = fs.open(SCRIPT_PATH.."/iMeepo_Version.lua", "w")
  2804. -- f.write(content)
  2805. -- f.close()
  2806. -- end
  2807.  
  2808. ----Check Version
  2809.  
  2810. function Version()
  2811. local file = io.open(SCRIPT_PATH.."/iMeepo_Version.lua", "r")
  2812. local ver = nil
  2813. if file then
  2814. ver = file:read("*number")
  2815. file:read("*line")
  2816. beta = file:read("*line")
  2817. info = file:read("*line")
  2818. file:close()
  2819. end
  2820. if ver then
  2821. local bcheck = ""..beta
  2822. if ver == currentVersion and bcheck == Beta then
  2823. outdated = false
  2824. return true,ver,beta,info
  2825. elseif ver > currentVersion or bcheck ~= Beta then
  2826. outdated = true
  2827. return false,ver,beta,info
  2828. end
  2829. else
  2830. versionSign.text = "You didn't download version info file from Moones' repository. Please do so to keep the script updated."
  2831. versionSign.color = -1
  2832. return false
  2833. end
  2834. end
  2835.  
  2836. ----DODGING
  2837.  
  2838. ----LICH ULT SPLITTING
  2839.  
  2840. function IsOptimalPlaceAgainstChainFrost(pos,validTargets,distance)
  2841. for i = 1, #validTargets do
  2842. local v = validTargets[i]
  2843. if distance(v, pos) < lichJumpRange - 5 then
  2844. return false
  2845. end
  2846. end
  2847. return true
  2848. end
  2849.  
  2850. function FindOptimalPlaceAgainstChainFrost(meepo,distance,mathsqrt)
  2851. local validTargets = entityList:FindEntities(function (ent) return (ent.creep or ent.hero) and ent.team ~= 5 - meepo.team and (not ent.creep or ent.spawned) and not ent:IsInvul() and ent.handle ~= meepo.handle and distance(meepo,ent) < lichJumpRange*3/2 end)
  2852. ----print(#validTargets)
  2853. local move = not IsOptimalPlaceAgainstChainFrost(meepo,validTargets,distance)
  2854. if move then
  2855. local nearbyCount = 0
  2856. for i = 1, #validTargets do
  2857. local v = validTargets[i]
  2858. if distance(v,meepo) < lichJumpRange then
  2859. nearbyCount = nearbyCount + 1
  2860. end
  2861. end
  2862. if nearbyCount > 1 then
  2863. local intersections = {}
  2864. local intersectionsCount = 0
  2865. for i = 1, #validTargets do
  2866. local v = validTargets[i]
  2867. for k = 1, #validTargets do
  2868. local l = validTargets[k]
  2869. if l ~= v then
  2870. local dist = distance(l,v)
  2871. if dist < lichJumpRange then
  2872. local midpoint = (l.position + v.position) / 2
  2873. local directionVector = (v.position - l.position) / dist
  2874. local rDist = mathsqrt(lichJumpRange*lichJumpRange - (dist*dist)/4)
  2875. local rDirection = Rotate90(directionVector)
  2876. local ti = {midpoint - rDirection*rDist, midpoint + rDirection*rDist}
  2877. for a = 1, #ti do
  2878. local b = ti[a]
  2879. if IsOptimalPlaceAgainstChainFrost(b,validTargets,distance) then
  2880. intersectionsCount = intersectionsCount + 1
  2881. intersections[intersectionsCount] = b
  2882. end
  2883. end
  2884. end
  2885. end
  2886. end
  2887. end
  2888. table.sort(intersections, function (a,b) return distance(a,meepo) < distance(b,meepo) end)
  2889. for i = 1, #intersections do
  2890. local v = intersections[i]
  2891. if IsOptimalPlaceAgainstChainFrost(v,validTargets,distance) then
  2892. meepo:Move(v)
  2893. Sleep((distance(v,meepo)/meepo.movespeed)*1000+client.latency,meepo.handle.."-move")
  2894. Sleep((distance(v,meepo)/meepo.movespeed)*1000+client.latency,meepo.handle.."-casting")
  2895. return
  2896. end
  2897. end
  2898. end
  2899. end
  2900. end
  2901.  
  2902. function Rotate90(vec)
  2903. return Vector(vec.y,-1 * (vec.x),vec.z)
  2904. end
  2905.  
  2906. ----ABILITIES DODGING
  2907.  
  2908. function FindEntity(cast,me,dayvision,m1)
  2909. for i = 1, #cast do
  2910. local z = cast[i]
  2911. if z.team ~= me.team then
  2912. if (not dayvision or z.dayVision == dayvision) and (not m1 or z:DoesHaveModifier(m1)) then
  2913. return z
  2914. end
  2915. end
  2916. end
  2917. return nil
  2918. end
  2919.  
  2920. function LineDodge(meepo, pos1, pos2, radius, sleep,mathfloor, mathsqrt, mathabs)
  2921. radius = radius + 250
  2922. local calc1 = (mathfloor(mathsqrt((pos2.x-meepo.position.x)^2 + (pos2.y-meepo.position.y)^2)))
  2923. local calc2 = (mathfloor(mathsqrt((pos1.x-meepo.position.x)^2 + (pos1.y-meepo.position.y)^2)))
  2924. local calc4 = (mathfloor(mathsqrt((pos1.x-pos2.x)^2 + (pos1.y-pos2.y)^2)))
  2925. local calc3, perpendicular, k, x4, z4, dodgex, dodgey
  2926. perpendicular = (mathfloor((mathabs((pos2.x-pos1.x)*(pos1.y-meepo.position.y)-(pos1.x-meepo.position.x)*(pos2.y-pos1.y)))/(mathsqrt((pos2.x-pos1.x)^2 + (pos2.y-pos1.y)^2))))
  2927. k = ((pos2.y-pos1.y)*(meepo.position.x-pos1.x) - (pos2.x-pos1.x)*(meepo.position.y-pos1.y)) / ((pos2.y-pos1.y)^2 + (pos2.x-pos1.x)^2)
  2928. x4 = meepo.position.x - k * (pos2.y-pos1.y)
  2929. z4 = meepo.position.y + k * (pos2.x-pos1.x)
  2930. calc3 = (mathfloor(mathsqrt((x4-meepo.position.x)^2 + (z4-meepo.position.y)^2)))
  2931. dodgex = x4 + (radius/calc3)*(meepo.position.x-x4)
  2932. dodgey = z4 + (radius/calc3)*(meepo.position.y-z4)
  2933. if perpendicular < radius and calc1 < calc4 and calc2 < calc4 then
  2934. local dodgevector = Vector(dodgex,dodgey,meepo.position.z)
  2935. meepo:Move(dodgevector)
  2936. Sleep(sleep,meepo.handle.."-move")
  2937. Sleep(sleep,meepo.handle.."-casting")
  2938. Sleep(sleep,meepo.handle.."-attack")
  2939. Sleep(250,meepo.handle.."dodge")
  2940. return
  2941. end
  2942. end
  2943.  
  2944. function AOEDodge(meepo, pos1, radius,mathfloor, mathsqrt)
  2945. local calc = (mathfloor(mathsqrt((pos1.x-meepo.position.x)^2 + (pos1.y-meepo.position.y)^2)))
  2946. local dodgex, dodgey
  2947. dodgex = pos1.x + (radius/calc)*(meepo.position.x-pos1.x)
  2948. dodgey = pos1.y + (radius/calc)*(meepo.position.y-pos1.y)
  2949. if calc < radius then
  2950. local dodgevector = Vector(dodgex,dodgey,meepo.position.z)
  2951. meepo:Move(dodgevector)
  2952. return
  2953. end
  2954. end
  2955.  
  2956. function FindAB(first, second, distance,mathdeg, mathatan, mathabs, mathrad, mathcos, mathsin)
  2957. local xAngle = mathdeg(mathatan(mathabs(second.x - first.x)/mathabs(second.y - first.y)))
  2958. local retValue = nil
  2959. local retVector = Vector()
  2960. if first.x <= second.x and first.y >= second.y then
  2961. retValue = 270 + xAngle
  2962. elseif first.x >= second.x and first.y >= second.y then
  2963. retValue = (90-xAngle) + 180
  2964. elseif first.x >= second.x and first.y <= second.y then
  2965. retValue = 90+xAngle
  2966. elseif first.x <= second.x and first.y <= second.y then
  2967. retValue = 90 - xAngle
  2968. end
  2969. retVector = Vector(first.x + mathcos(mathrad(retValue))*distance,first.y + mathsin(mathrad(retValue))*distance,0)
  2970. client:GetGroundPosition(retVector)
  2971. retVector.z = retVector.z+100
  2972. return retVector
  2973. end
  2974.  
  2975. --END of FUNCTIONS--
Add Comment
Please, Sign In to add comment