Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 55.65 KB | None | 0 0
  1. --<<Naga auto farm/stack/creepwave cut>>
  2.  
  3. --[[ Naga Farm script by Moones ]]--
  4.  
  5. require("libs.ScriptConfig")
  6. require("libs.Utils")
  7. require("libs.EasyHUD")
  8.  
  9. local currentVersion = 0.3
  10. local Beta = ""
  11.  
  12. local config = ScriptConfig.new()
  13. config:SetParameter("StackKey", "F", config.TYPE_HOTKEY)
  14. config:SetParameter("FarmJungleKey", "I", config.TYPE_HOTKEY)
  15. config:SetParameter("CreepCutKey", "U", config.TYPE_HOTKEY)
  16. config:SetParameter("AutoModeKey", "D", config.TYPE_HOTKEY)
  17. config:SetParameter("ComboScriptKey", "G", config.TYPE_HOTKEY)
  18. config:SetParameter("OpenMenu", "M", config.TYPE_HOTKEY)
  19. config:SetParameter("VersionInfoPosX", 670, config.TYPE_NUMBER)
  20. config:SetParameter("VersionInfoPosY", 750, config.TYPE_NUMBER)
  21. config:Load()
  22.  
  23. local player,me,JungleCamps,enemyTeam,meTeam,reg,stack,myId,Q,E,ERadius,cut,farm,auto,HUD,autoE,enemyjungle,radiance,octa,manta,travels
  24. local topLaneData = {} local midLaneData = {} local botLaneData = {} local dataSaved = false local dataUpdated = false local buttons = {}
  25. local creepwaves = {{position = Vector(0,0,0), visible = false, cutted = nil, dead = false, id = 1},
  26. {position = Vector(0,0,0), visible = false, cutted = nil, dead = false, id = 2},
  27. {position = Vector(0,0,0), visible = false, cutted = nil, dead = false, id = 3},
  28. {position = Vector(0,0,0), visible = false, cutted = nil, dead = false, id = 4},
  29. {position = Vector(0,0,0), visible = false, cutted = nil, dead = false, id = 5},
  30. {position = Vector(0,0,0), visible = false, cutted = nil, dead = false, id = 6}}
  31.  
  32. local F14 = drawMgr:CreateFont("F14","Tahoma",13,800)
  33. local versionSign = drawMgr:CreateText(client.screenSize.x*config.VersionInfoPosX/1000,client.screenSize.y*config.VersionInfoPosY/1000,0x66FF33FF,"",F14)
  34. local F12 = drawMgr:CreateFont("F12","Tahoma",12,800)
  35. local infoSign = drawMgr:CreateText(client.screenSize.x*config.VersionInfoPosX/1000,(client.screenSize.y*config.VersionInfoPosY/1000)+20,-1,"",F12)
  36. local victims = {}
  37.  
  38. function Key(msg,code)
  39. if client.chat or client.console or not PlayingGame() then return end
  40. if msg == KEY_UP then
  41. if code == config.StackKey then
  42. stack = not stack
  43. if stack then
  44. buttons[1].obj.color = 0x05999990
  45. buttons[2].obj.color = 0x60615FFF
  46. buttons[3].obj.color = 0x60615FFF
  47. buttons[4].obj.color = 0x60615FFF
  48. else
  49. buttons[1].obj.color = 0x60615FFF
  50. end
  51. elseif code == config.CreepCutKey then
  52. cut = not cut
  53. if cut then
  54. buttons[4].obj.color = 0x05999990
  55. buttons[2].obj.color = 0x60615FFF
  56. buttons[3].obj.color = 0x60615FFF
  57. buttons[1].obj.color = 0x60615FFF
  58. else
  59. buttons[4].obj.color = 0x60615FFF
  60. end
  61. elseif code == config.FarmJungleKey then
  62. farm = not farm
  63. if farm then
  64. buttons[2].obj.color = 0x60615FFF
  65. buttons[1].obj.color = 0x60615FFF
  66. buttons[4].obj.color = 0x60615FFF
  67. buttons[3].obj.color = 0x05999990
  68. else
  69. buttons[3].obj.color = 0x60615FFF
  70. end
  71. elseif code == config.AutoModeKey then
  72. auto = not auto
  73. if auto then
  74. buttons[2].obj.color = 0x05999990
  75. buttons[1].obj.color = 0x60615FFF
  76. buttons[3].obj.color = 0x60615FFF
  77. buttons[4].obj.color = 0x60615FFF
  78. else
  79. buttons[2].obj.color = 0x60615FFF
  80. end
  81. elseif code == config.OpenMenu and HUD then
  82. HUD:Open()
  83. end
  84. end
  85. end
  86.  
  87. function buttonClick(b1,b2,t)
  88. if b1.color == 0x60615FFF then
  89. b1.color = 0x05999990
  90. else
  91. b1.color = 0x60615FFF
  92. end
  93. if t.text == "Stack" then
  94. stack = not stack
  95. buttons[2].obj.color = 0x60615FFF
  96. buttons[3].obj.color = 0x60615FFF
  97. buttons[4].obj.color = 0x60615FFF
  98. elseif t.text == "AutoMode" then
  99. auto = not auto
  100. buttons[1].obj.color = 0x60615FFF
  101. buttons[3].obj.color = 0x60615FFF
  102. buttons[4].obj.color = 0x60615FFF
  103. elseif t.text == "Farm Jungle" then
  104. farm = not farm
  105. buttons[2].obj.color = 0x60615FFF
  106. buttons[1].obj.color = 0x60615FFF
  107. buttons[4].obj.color = 0x60615FFF
  108. elseif t.text == "Cut Creepwaves" then
  109. cut = not cut
  110. buttons[2].obj.color = 0x60615FFF
  111. buttons[3].obj.color = 0x60615FFF
  112. buttons[1].obj.color = 0x60615FFF
  113. end
  114. end
  115.  
  116. function Main()
  117.  
  118. --VersionInfo
  119. if client.gameTime > 1 then
  120. versionSign.visible = false
  121. infoSign.visible = false
  122. else
  123. local up,ver,beta,info = Version()
  124. if up then
  125. if beta ~= "" then
  126. versionSign.text = "Your version of Naga Farm Script is up-to-date! (v"..currentVersion.." "..Beta..")"
  127. else
  128. versionSign.text = "Your version of Naga Farm Script is up-to-date! (v"..currentVersion..")"
  129. end
  130. versionSign.color = 0x66FF33FF
  131. if info then
  132. infoSign.text = info
  133. infoSign.visible = true
  134. end
  135. end
  136. if outdated then
  137. if beta ~= "" then
  138. versionSign.text = "Your version of Naga Farm is OUTDATED (Yours: v"..currentVersion.." "..Beta.." Current: v"..ver.." "..beta..")"
  139. else
  140. versionSign.text = "Your version of Naga Farm is OUTDATED (Yours: v"..currentVersion.." "..Beta.." Current: v"..ver..")"
  141. end
  142. versionSign.color = 0xFF6600FF
  143. if info then
  144. infoSign.text = info
  145. infoSign.visible = true
  146. end
  147. end
  148. versionSign.visible = true
  149. end
  150.  
  151. if not PlayingGame() or client.paused or IsKeyDown(config.ComboScriptKey) or IsKeyDown(17) or not me or client.shopOpen then if not me then me = entityList:GetMyHero() end return end
  152. local me = me local ID = me.classId if ID ~= myId then Close() end local player = player
  153. 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
  154. if not enemyTeam then enemyTeam = me:GetEnemyTeam() end if not meTeam then meTeam = me.team end local GetDistance2D = GetDistance2D
  155. local gameTime = client.gameTime
  156. if not octa then octa = me:FindItem("item_octarine_core") end
  157. local illusions = entityList:GetEntities({type=LuaEntity.TYPE_HERO,classId=CDOTA_Unit_Hero_Naga_Siren,team=meTeam,visible=true,illusion=true,alive=true})
  158. if not radiance then radiance = me:FindItem("item_radiance") end
  159.  
  160. --GUI
  161. if not HUD then
  162. local hudW = client.screenSize.x*0.0072+400
  163. local hudH = 45
  164. HUD = EasyHUD.new(client.screenSize.x*0.39,client.screenSize.y*0.75,hudW,hudH,"Naga Script Menu",05000000,94563580,true,true)
  165. buttons[1] = {} buttons[2] = {} buttons[3] = {} buttons[4] = {} buttons[5] = {} buttons[6] = {}
  166. buttons[1].id, buttons[1].obj = HUD:AddButton(HUD.w*0.02,HUD.h*0.25,50,25,0x60615FFF,"Stack",buttonClick)
  167. buttons[2].id, buttons[2].obj = HUD:AddButton(HUD.w*0.02+52,HUD.h*0.25,60,25,0x60615FFF,"AutoMode",buttonClick)
  168. buttons[3].id, buttons[3].obj = HUD:AddButton(HUD.w*0.02+114,HUD.h*0.25,70,25,0x60615FFF,"Farm Jungle",buttonClick)
  169. buttons[4].id, buttons[4].obj = HUD:AddButton(HUD.w*0.02+186,HUD.h*0.25,90,25,0x60615FFF,"Cut Creepwaves",buttonClick)
  170. buttons[5].id, buttons[5].obj = HUD:AddCheckbox(HUD.w*0.02+280,HUD.h*0.18,15,15,"Enable auto E",nil,autoE);
  171. buttons[6].id, buttons[6].obj = HUD:AddCheckbox(HUD.w*0.02+280,HUD.h*0.18+15,15,15,"Farm enemy jungle",nil,enemyjungle);
  172. else
  173. autoE = HUD:IsChecked(buttons[5].id+1)
  174. enemyjungle = HUD:IsChecked(buttons[6].id+1)
  175. cut = buttons[4].obj.color == 0x05999990
  176. farm = buttons[3].obj.color == 0x05999990
  177. auto = buttons[2].obj.color == 0x05999990
  178. stack = buttons[1].obj.color == 0x05999990
  179. end
  180.  
  181. local neutrals = entityList:GetEntities({team=LuaEntity.TEAM_NEUTRAL,alive=true,visible=true})
  182. local allies = entityList:GetEntities({type = LuaEntity.TYPE_HERO, team = meTeam, alive=true})
  183. local enemies = entityList:GetEntities({type = LuaEntity.TYPE_HERO, team = enemyTeam, alive=true, visible = true})
  184. local lanecreeps = entityList:GetEntities({classId = CDOTA_BaseNPC_Creep_Lane,visible = true,alive = true})
  185.  
  186. --After 7:30 min mark creeps on offlanes/hardlanes dont change their movespeed
  187. if gameTime > 450 and gameTime < 451 and not dataUpdated then
  188. local team = "Dire"
  189. if meTeam == LuaEntity.TEAM_DIRE then team = "Radiant" end
  190. local topLanedata = io.open(SCRIPT_PATH.."/CreepsPathData/"..team.."TopLane2.txt", "r")
  191. if topLanedata then
  192. local count = 0
  193. topLaneData = {}
  194. while true do
  195. local time, posX, posY, posZ = topLanedata:read("*number", "*number", "*number", "*number")
  196. if not time or not posX or not posY or not posZ then break end
  197. count = count + 1
  198. topLaneData[count] = {time, Vector(posX, posY, posZ)}
  199. end
  200. topLanedata:close()
  201. else
  202. print("Please download CreepsPathData in order to use this script!")
  203. script:Disable()
  204. end
  205. local botLanedata = io.open(SCRIPT_PATH.."/CreepsPathData/"..team.."BotLane2.txt", "r")
  206. botLaneData = {}
  207. if botLanedata then
  208. local count = 0
  209. while true do
  210. local time, posX, posY, posZ = botLanedata:read("*number", "*number", "*number", "*number")
  211. if not time or not posX or not posY or not posZ then dataUpdated = true break end
  212. count = count + 1
  213. botLaneData[count] = {time, Vector(posX, posY, posZ)}
  214. end
  215. botLanedata:close()
  216. end
  217. end
  218.  
  219. if gameTime > 0 and SleepCheck("pred") then
  220. Sleep(500,"pred")
  221. local seconds = gameTime % 60
  222. local seconds2 = (gameTime + 30) % 60
  223.  
  224. if seconds < 1 then
  225. creepwaves[1].visible = true
  226. creepwaves[3].visible = true
  227. creepwaves[5].visible = true
  228. creepwaves[1].dead = false
  229. creepwaves[3].dead = false
  230. creepwaves[5].dead = false
  231. end
  232. if seconds2 < 1 then
  233. creepwaves[2].visible = true
  234. creepwaves[4].visible = true
  235. creepwaves[6].visible = true
  236. creepwaves[2].dead = false
  237. creepwaves[4].dead = false
  238. creepwaves[6].dead = false
  239. end
  240.  
  241. seconds = (gameTime + 1) % 60
  242. seconds2 = (gameTime + 31) % 60
  243.  
  244. local topLaneData,midLaneData,botLaneData = topLaneData,midLaneData,botLaneData
  245.  
  246. --Update position
  247. if dataSaved then
  248. local position, position2 = nil, nil
  249. for i = 1, #topLaneData do
  250. local data = topLaneData[i]
  251. local time, pos = data[1], data[2]
  252. if time <= seconds and creepwaves[1].visible then
  253. position = pos
  254. end
  255. if time <= seconds2 and creepwaves[2].visible then
  256. position2 = pos
  257. end
  258. end
  259. if position then
  260. creepwaves[1].position = position
  261. end
  262. if position2 then
  263. creepwaves[2].position = position2
  264. end
  265. position, position2 = nil, nil
  266. for i = 1, #midLaneData do
  267. local data = midLaneData[i]
  268. local time, pos = data[1], data[2]
  269. if time <= seconds and creepwaves[3].visible then
  270. position = pos
  271. end
  272. if time <= seconds2 and creepwaves[4].visible then
  273. position2 = pos
  274. end
  275. end
  276. if position then
  277. creepwaves[3].position = position
  278. end
  279. if position2 then
  280. creepwaves[4].position = position2
  281. end
  282. position, position2 = nil, nil
  283. for i = 1, #botLaneData do
  284. local data = botLaneData[i]
  285. local time, pos = data[1], data[2]
  286. if time <= seconds and creepwaves[5].visible then
  287. position = pos
  288. end
  289. if time <= seconds2 and creepwaves[6].visible then
  290. position2 = pos
  291. end
  292. end
  293. if position then
  294. creepwaves[5].position = position
  295. end
  296. if position2 then
  297. creepwaves[6].position = position2
  298. end
  299. end
  300. end
  301.  
  302. local illusionCount = #illusions
  303. local creepCount = #lanecreeps
  304. if SleepCheck("asd") then
  305. for z = 1, 6 do
  306. local wave = creepwaves[z]
  307. local closestCreep = nil
  308. for i = 1, creepCount do
  309. local v = lanecreeps[i]
  310. if v.spawned and wave.position ~= Vector(0,0,0) then
  311. if GetDistance2D(wave.position,v) < 500 then
  312. creepwaves[z].visible = false
  313. creepwaves[z].position = v.position
  314. end
  315. if GetDistance2D(v,wave.position) < 700 and (not closestCreep or GetDistance2D(wave.position,creep) < GetDistance2D(closestCreep,wave.position)) then
  316. closestCreep = v.position
  317. end
  318. end
  319. end
  320. if not creepwaves[z].visible and not closestCreep then
  321. creepwaves[z].dead = true
  322. end
  323. if (not octa and math.floor(Q.cd) == 10) or illusionCount <= 0 then
  324. creepwaves[z].cutted = nil
  325. elseif octa and Q.cd == 0 then
  326. creepwaves[z].cutted = nil
  327. end
  328. end
  329. end
  330.  
  331. local tempJungleCamps = JungleCamps
  332. local neutralsCount = #neutrals
  333. local alliescount = #allies
  334. if SleepCheck("asd") then
  335. Sleep(200,"asd")
  336. for i = 1, #tempJungleCamps do
  337. local camp = tempJungleCamps[i]
  338. local block = false
  339. local farmed = true
  340. for k = 1, neutralsCount do
  341. local ent = neutrals[k]
  342. if ent.health and ent.alive and ent.spawned and GetDistance2D(ent,camp.position) < 800 then
  343. farmed = false
  344. JungleCamps[camp.id].farmed = false
  345. tempJungleCamps = JungleCamps
  346. end
  347. end
  348. for m = 1, alliescount do
  349. local v = allies[m]
  350. if GetDistance2D(v,camp.position) < 500 and v.alive then
  351. block = true
  352. end
  353. if farmed and GetDistance2D(v,camp.position) < 500 then
  354. JungleCamps[camp.id].farmed = true
  355. tempJungleCamps = JungleCamps
  356. end
  357. if GetDistance2D(v,camp.position) < 300 then
  358. JungleCamps[camp.id].visible = v.visibleToEnemy
  359. tempJungleCamps = JungleCamps
  360. end
  361. end
  362. if gameTime < 30 then
  363. JungleCamps[camp.id].farmed = true
  364. tempJungleCamps = JungleCamps
  365. end
  366. if (gameTime % 60 > 0.5 and gameTime % 60 < 2) or (gameTime > 30 and gameTime < 32) then
  367. if camp.farmed then
  368. if not block then
  369. JungleCamps[camp.id].farmed = false
  370. tempJungleCamps = JungleCamps
  371. end
  372. end
  373. if camp.stacking then
  374. JungleCamps[camp.id].stacking = false
  375. tempJungleCamps = JungleCamps
  376. end
  377. end
  378. if camp.visible then
  379. if (gameTime - camp.visTime) > 30 then
  380. JungleCamps[camp.id].visible = false
  381. tempJungleCamps = JungleCamps
  382. end
  383. end
  384.  
  385. if (not octa and math.floor(Q.cd) == 10) or illusionCount <= 0 then
  386. JungleCamps[camp.id].stacked = nil
  387. elseif octa and Q.cd == 0 then
  388. JungleCamps[camp.id].stacked = nil
  389. end
  390. end
  391. end
  392.  
  393.  
  394. if (not octa and math.floor(Q.cd) == 10) or illusionCount <= 0 then
  395. victims = {}
  396. elseif octa and Q.cd == 0 then
  397. victims = {}
  398. end
  399.  
  400. local enemycount = #enemies
  401. local table = {}
  402. local projectiles = entityList:GetProjectiles({})
  403. local projectilCount = #projectiles
  404. local movespeed = me.movespeed
  405. if not travels then travels = me:FindItem("item_travel_boots") or me:FindItem("item_travel_boots_2")
  406. else movespeed = movespeed + 100 end
  407. if not manta then manta = me:FindItem("item_manta")
  408. else movespeed = movespeed + movespeed*0.1 end
  409.  
  410. for i = 1, illusionCount do
  411. local illusion = illusions[i]
  412. local modif = illusion:FindModifier("modifier_illusion")
  413. if illusion.controllable and modif then
  414. local time = modif.remainingTime - 5
  415. local hand = illusion.handle
  416. local closestCreep = nil
  417. local closestNeutral = nil
  418. local closestallyCreep = nil
  419. local closeEnemy = nil
  420. if auto or cut or farm then
  421. for z = 1, creepCount do
  422. local creep = lanecreeps[z]
  423. if creep.spawned and creep.team ~= meTeam then
  424. if creep.visible and creep.classId ~= CDOTA_BaseNPC_Creep_Siege and GetDistance2D(illusion,creep) < 500 and (not table[i] or table[i] == true) then
  425. table[i] = GetDistance2D(illusion,creep) <= ERadius
  426. end
  427. if not closestCreep or GetDistance2D(illusion,closestCreep) > GetDistance2D(illusion,creep) then
  428. closestCreep = creep
  429. end
  430. elseif creep.team == meTeam then
  431. if not closestallyCreep or GetDistance2D(illusion,closestallyCreep) > GetDistance2D(illusion,creep) then
  432. closestallyCreep = creep
  433. end
  434. end
  435. end
  436. end
  437. if auto or farm or stack then
  438. for z = 1, neutralsCount do
  439. local creep = neutrals[z]
  440. if creep.spawned and creep.alive and not creep.ancient then
  441. if creep.visible and not creep.ancient and GetDistance2D(illusion,creep) < 500 and (not table[i] or table[i] == true) then
  442. table[i] = GetDistance2D(illusion,creep) <= ERadius
  443. end
  444. if not closestNeutral or GetDistance2D(illusion,closestNeutral) > GetDistance2D(illusion,creep) then
  445. closestNeutral = creep
  446. end
  447. end
  448. end
  449. end
  450. if radiance and auto and (not victims[i] or not victims[i].alive) then
  451. for z = 1, enemycount do
  452. local enemy = enemies[z]
  453. if enemy.visible and enemy.alive and GetDistance2D(illusion,enemy) < 500 and (not table[i] or table[i] == true) then
  454. table[i] = GetDistance2D(illusion,enemy) <= ERadius
  455. end
  456. if GetDistance2D(illusion,enemy) < 700 and (not closeEnemy or GetDistance2D(illusion,closeEnemy) > GetDistance2D(illusion,enemy)) then
  457. closeEnemy = enemy
  458. end
  459. end
  460. end
  461. if victims[i] and victims[i].alive and GetDistance2D(illusion,victims[i]) < 700 then closeEnemy = victims[i] else victims[i] = nil end
  462. if auto then
  463. local closestWave = getClosestWave(illusion)
  464. local camp = getClosestCamp(illusion)
  465. if camp and ((camp.stacked and camp.stacked ~= hand) or camp.farmed) then camp = getClosestCamp(illusion) end
  466. if closestWave and ((closestWave.cutted and closestWave.cutted ~= hand) or closestWave.dead) then closestWave = getClosestWave(illusion) end
  467. if SleepCheck(hand.."attack") then
  468. if closeEnemy and closeEnemy.health < illusion.maxHealth then
  469. victims[i] = closeEnemy
  470. illusion:Attack(closeEnemy)
  471. Sleep(500,hand.."attack")
  472. elseif closestWave and illusion.acitivty ~= LuaEntityNPC.ACTIVITY_ATTACK and GetDistance2D(illusion,closestWave.position)/movespeed < time and (not camp or GetDistance2D(closestWave.position,illusion) < GetDistance2D(camp.position,illusion)+1000) and not closestWave.dead and (not closestWave.cutted or closestWave.cutted == hand) then
  473. creepwaves[closestWave.id].cutted = hand
  474. if GetDistance2D(illusion,closestWave.position) > 500 then
  475. illusion:Move(closestWave.position)
  476. illusion:AttackMove(closestWave.position,true)
  477. else
  478. illusion:AttackMove(closestWave.position)
  479. end
  480. Sleep(1000,hand.."attack")
  481. Sleep(client.latency+illusion:GetTurnTime(closestWave.position)*1000,hand.."latency")
  482. elseif (illusion.activity == LuaEntityNPC.ACTIVITY_IDLE or illusion.activity == LuaEntityNPC.ACTIVITY_IDLE1) and illusion.recentDamage == 0 and camp and GetDistance2D(illusion,camp.position)/movespeed < time and not camp.farmed and (not camp.stacked or camp.stacked == hand) then
  483. JungleCamps[camp.id].stacked = hand
  484. if not closestNeutral and SleepCheck(hand.."move") and GetDistance2D(camp.position,illusion) > 500 then
  485. illusion:Move(camp.position)
  486. illusion:AttackMove(camp.position,true)
  487. Sleep(1000,hand.."move")
  488. end
  489. if closestNeutral and SleepCheck(hand.."attack") and GetDistance2D(closestNeutral,camp.position) < 500 then
  490. illusion:Attack(closestNeutral)
  491. illusion:AttackMove(closestNeutral.position,true)
  492. Sleep(1000,hand.."attack")
  493. end
  494. elseif (illusion.activity == LuaEntityNPC.ACTIVITY_IDLE or illusion.activity == LuaEntityNPC.ACTIVITY_IDLE1) and illusion.recentDamage == 0 and closestNeutral and GetDistance2D(closestNeutral,illusion) < 500 then
  495. illusion:Attack(closestNeutral)
  496. illusion:AttackMove(closestNeutral.position,true)
  497. Sleep(1000,hand.."attack")
  498. elseif (illusion.activity == LuaEntityNPC.ACTIVITY_IDLE or illusion.activity == LuaEntityNPC.ACTIVITY_IDLE1) and illusion.recentDamage == 0 and closestCreep then
  499. illusion:Attack(closestCreep)
  500. illusion:AttackMove(closestCreep.position,true)
  501. Sleep(1000,hand.."attack")
  502. Sleep(client.latency+illusion:GetTurnTime(closestCreep.position)*1000,hand.."latency")
  503. elseif (illusion.activity == LuaEntityNPC.ACTIVITY_IDLE or illusion.activity == LuaEntityNPC.ACTIVITY_IDLE1) and illusion.recentDamage == 0 and closestNeutral then
  504. illusion:Attack(closestNeutral)
  505. illusion:AttackMove(closestNeutral.position,true)
  506. Sleep(1000,hand.."attack")
  507. Sleep(client.latency+illusion:GetTurnTime(closestNeutral.position)*1000,hand.."latency")
  508. end
  509. end
  510. elseif cut then
  511. local closestWave = getClosestWave(illusion)
  512. if closestWave and ((closestWave.cutted and closestWave.cutted ~= hand) or closestWave.dead) then closestWave = getClosestWave(illusion) end
  513. if (SleepCheck(hand.."attack") or (illusion.activity == LuaEntityNPC.ACTIVITY_IDLE and SleepCheck(hand.."latency") and (not closestWave or GetDistance2D(closestWave.position,illusion) > 500) and (not closestCreep or GetDistance2D(closestCreep,illusion) > 500))) and illusion.activity ~= LuaEntityNPC.ACTIVITY_ATTACK then
  514. if closestWave and GetDistance2D(illusion,closestWave.position)/movespeed < time then
  515. creepwaves[closestWave.id].cutted = hand
  516. if GetDistance2D(illusion,closestWave.position) > 1000 then
  517. illusion:Move(closestWave.position)
  518. illusion:AttackMove(closestWave.position,true)
  519. else
  520. illusion:AttackMove(closestWave.position)
  521. end
  522. Sleep(1000,hand.."attack")
  523. Sleep(client.latency+illusion:GetTurnTime(closestWave.position)*1000,hand.."latency")
  524. elseif closestCreep then
  525. illusion:Attack(closestCreep)
  526. illusion:AttackMove(closestCreep.position,true)
  527. Sleep(1000,hand.."attack")
  528. Sleep(client.latency+illusion:GetTurnTime(closestCreep.position)*1000,hand.."latency")
  529. end
  530. end
  531. elseif farm and (illusion.activity == LuaEntityNPC.ACTIVITY_IDLE or illusion.activity == LuaEntityNPC.ACTIVITY_IDLE1) and illusion.recentDamage == 0 then
  532. --if not closestCreep then closestCreep = closestNeutral end
  533. local selected = illusion
  534. local camp = getClosestCamp(selected)
  535. if not camp or ((camp.stacked and camp.stacked ~= hand) or camp.farmed or (not enemyjungle and camp.team ~= meTeam)) then camp = getClosestCamp(selected) end
  536. if not camp then camp = getClosestCamp(selected,false,true) end
  537. if camp and not camp.farmed and (not camp.stacked or camp.stacked == hand) and GetDistance2D(illusion,camp.position)/movespeed < time then
  538. JungleCamps[camp.id].stacked = hand
  539. if not closestNeutral and SleepCheck(hand.."move") and GetDistance2D(camp.position,illusion) > 500 then
  540. illusion:Move(camp.position)
  541. illusion:AttackMove(camp.position,true)
  542. Sleep(1000,hand.."move")
  543. end
  544. if closestNeutral and SleepCheck(hand.."attack") and GetDistance2D(closestNeutral,camp.position) < 500 then
  545. illusion:Attack(closestNeutral)
  546. illusion:AttackMove(closestNeutral.position,true)
  547. Sleep(1000,hand.."attack")
  548. end
  549. elseif closestNeutral and SleepCheck(hand.."attack") and GetDistance2D(closestNeutral,illusion) < 500 then
  550. illusion:Attack(closestNeutral)
  551. illusion:AttackMove(closestNeutral.position,true)
  552. Sleep(1000,hand.."attack")
  553. elseif closestCreep and SleepCheck(hand.."attack") then
  554. illusion:Attack(closestCreep)
  555. illusion:AttackMove(closestCreep.position,true)
  556. Sleep(1000,hand.."attack")
  557. Sleep(client.latency+illusion:GetTurnTime(closestCreep)*1000,hand.."latency")
  558. end
  559. elseif stack then
  560. --Stacking
  561. local selected = illusion
  562. local camp = getClosestCamp(selected,true)
  563. local creepsnear = {}
  564. local creepscount = 0
  565. if not camp or ((camp.stacked and camp.stacked ~= hand) or camp.farmed or camp.team ~= meTeam) then camp = getClosestCamp(selected,true) end
  566. if camp and (not camp.stacked or camp.stacked == hand) and not camp.farmed and camp.team == meTeam then
  567. JungleCamps[camp.id].stacked = hand
  568. for i = 1, neutralsCount do
  569. local creep = neutrals[i]
  570. if creep.visible and creep.spawned and GetDistance2D(creep,selected) <= 1200 and creep.visible and GetDistance2D(creep,camp.position) < 300 then
  571. creepscount = creepscount + 1
  572. creepsnear[creepscount] = creep
  573. end
  574. end
  575. local stackDuration = 0
  576. local moveTime = nil
  577. if closestNeutral and GetDistance2D(closestNeutral,camp.position) > 500 then closestNeutral = nil end
  578. if closestNeutral and closestNeutral.alive then
  579. stackDuration = mathmin((GetDistance2D(closestNeutral,camp.stackPosition)+(creepscount*45))/mathmin(closestNeutral.movespeed,movespeed), 9)
  580. if closestNeutral:IsRanged() and creepscount <= 4 then
  581. stackDuration = mathmin((GetDistance2D(closestNeutral,camp.stackPosition)+closestNeutral.attackRange+(creepscount*45))/mathmin(closestNeutral.movespeed,movespeed), 9)
  582. end
  583. moveTime = 50 - (GetDistance2D(selected,camp.position)+50)/movespeed
  584. if stackDuration > 0 then
  585. moveTime = 60 - stackDuration - (GetDistance2D(selected,closestNeutral.position)+50)/movespeed
  586. end
  587. end
  588. if SleepCheck(hand.."stack") and SleepCheck(hand.."-move") then
  589. if not moveTime or gameTime % 60 < moveTime then
  590. if GetDistance2D(selected,camp.waitPosition) > 50 then
  591. selected:Move(camp.waitPosition)
  592. end
  593. elseif (not closestNeutral or not closestNeutral.visible) then
  594. if GetDistance2D(selected,camp.position) > 50 then
  595. selected:Move(camp.position)
  596. end
  597. end
  598. Sleep(1000,hand.."-move")
  599. end
  600. if moveTime and gameTime % 60 > moveTime then
  601. if closestNeutral and closestNeutral.alive then
  602. if SleepCheck(hand.."-moveStack") and (gameTime % 60 > (60 - stackDuration) and gameTime % 60 < 57) and GetDistance2D(closestNeutral,selected) < 1000 then
  603. local pos = (camp.stackPosition - closestNeutral.position) * (GetDistance2D(camp.stackPosition,closestNeutral) + 500) / GetDistance2D(camp.stackPosition,closestNeutral) + camp.stackPosition
  604. selected:Move(pos)
  605. Sleep((GetDistance2D(selected,pos)/movespeed)*1000,hand.."-moveStack")
  606. Sleep((60 - (gameTime % 60))*1000,hand.."stack")
  607. elseif SleepCheck(hand.."stack") and SleepCheck(hand.."-attack") then
  608. local pos = (closestNeutral.position - selected.position) * (-200) / GetDistance2D(selected,closestNeutral) + closestNeutral.position
  609. local pos2 = (camp.stackPosition - closestNeutral.position) * (GetDistance2D(camp.stackPosition,closestNeutral) + 500) / GetDistance2D(camp.stackPosition,closestNeutral) + camp.stackPosition
  610. selected:Move(pos)
  611. selected:Move(pos2,true)
  612. Sleep(((GetDistance2D(pos,camp.stackPosition)+GetDistance2D(pos,illusion))/movespeed)*1000+client.latency,hand.."-attack")
  613. --Sleep(((GetDistance2D(pos,camp.stackPosition)+GetDistance2D(pos,illusion))/movespeed)*1000+client.latency,hand.."stack")
  614. --Sleep(((GetDistance2D(pos,camp.stackPosition)+GetDistance2D(pos,illusion))/movespeed)*1000+client.latency,hand.."-moveStack")
  615. end
  616. end
  617. end
  618. end
  619. end
  620. if auto or cut or farm then
  621. --Unaggro
  622. for i = 1, projectilCount do
  623. local p = projectiles[i]
  624. local sour = p.source
  625. if sour and sour.classId == CDOTA_BaseNPC_Tower and p.target and p.target == illusion and GetDistance2D(illusion,sour) <= sour.attackRange+25 then
  626. local sourHand = sour.handle
  627. local dmg = illusion:DamageTaken((sour.dmgMax+sour.dmgMin)/2,DAMAGE_PHYS,sour)
  628. if SleepCheck(hand.."unaggro") and SleepCheck(sourHand) then
  629. if closestallyCreep and GetDistance2D(closestallyCreep,sour) <= sour.attackRange+25 then
  630. illusion:Attack(closestallyCreep)
  631. Sleep((GetDistance2D(illusion,p.position)/p.speed)*1000,sourHand)
  632. Sleep(250, hand.."unaggro")
  633. end
  634. elseif SleepCheck(hand.."unaggro2") and SleepCheck(hand.."-casting") and illusion.activity == LuaEntityNPC.ACTIVITY_MOVE then
  635. local prev = SelectUnit(illusion)
  636. player:HoldPosition()
  637. SelectBack(prev)
  638. Sleep((GetDistance2D(illusion,p.position)/p.speed)*1000,hand.."unaggro2")
  639. end
  640. end
  641. end
  642. end
  643. end
  644. end
  645. local useE = 0
  646. local useanyway = false
  647. local tablecount = #table
  648. for i = 1, tablecount do
  649. local data = table[i]
  650. if data == true then useE = useE + 1 end
  651. if not octa and Q.cd < 12 and data == true then useanyway = true break
  652. elseif octa and Q.cd < 2 and data == true then useanyway = true break end
  653. end
  654.  
  655. if SleepCheck("fuck") then
  656. --print(autoE,useE, illusionCount,tablecount)
  657. Sleep(1000,"fuck")
  658. end
  659.  
  660. if not me:IsChanneling() and not me:IsInvisible() and not stack and autoE and useE == illusionCount and useE > 0 and SleepCheck("E") and E:CanBeCasted() and me:CanCast() then
  661. me:CastAbility(E) Sleep(200,"E")
  662. end
  663. end
  664.  
  665. function getClosestCamp(ilu,stack,any)
  666. local closest = nil
  667. local tempJungleCamps = JungleCamps
  668. for i = 1, #tempJungleCamps do
  669. local camp = tempJungleCamps[i]
  670. if (not closest or GetDistance2D(ilu.position,camp.position) < GetDistance2D(ilu.position,closest.position)) and (not camp.stacked or any) and not camp.farmed and not camp.ancients and (not stack or camp.team == ilu.team) and (not stack or (enemyjungle or camp.team == ilu.team)) then
  671. closest = camp
  672. end
  673. if camp.stacked and camp.stacked == ilu.handle and (not stack or camp.team == ilu.team) and (not stack or (enemyjungle or camp.team == ilu.team)) then
  674. closest = camp
  675. break
  676. end
  677. end
  678. return closest
  679. end
  680.  
  681. function getClosestWave(ilu)
  682. local creepwaves = creepwaves
  683. local closest = nil
  684. for i = 1, 6 do
  685. local wave = creepwaves[i]
  686. if (not closest or GetDistance2D(wave.position,ilu) < GetDistance2D(closest.position,ilu)) and not wave.cutted and not wave.dead and wave.position ~= Vector(0,0,0) then
  687. closest = wave
  688. end
  689. if wave.cutted and wave.cutted == ilu.handle then
  690. closest = wave
  691. break
  692. end
  693. end
  694. return closest
  695. end
  696.  
  697. ----Check Version
  698. function Version()
  699. local file = io.open(SCRIPT_PATH.."/NagaFarm_Version.lua", "r")
  700. local ver = nil
  701. if file then
  702. ver = file:read("*number")
  703. file:read("*line")
  704. beta = file:read("*line")
  705. info = file:read("*line")
  706. file:close()
  707. end
  708. if ver then
  709. local bcheck = ""..beta
  710. if ver == currentVersion and bcheck == Beta then
  711. outdated = false
  712. return true,ver,beta,info
  713. elseif ver > currentVersion or bcheck ~= Beta then
  714. outdated = true
  715. return false,ver,beta,info
  716. end
  717. else
  718. versionSign.text = "You didn't download version info file from Moones' repository. Please do so to keep the script updated."
  719. versionSign.color = -1
  720. return false
  721. end
  722. end
  723.  
  724. function Load()
  725.  
  726. --VersionInfo
  727. local up,ver,beta,info = Version()
  728. if up then
  729. if beta ~= "" then
  730. versionSign.text = "Your version of Naga Farm Script is up-to-date! (v"..currentVersion.." "..Beta..")"
  731. else
  732. versionSign.text = "Your version of Naga Farm Script is up-to-date! (v"..currentVersion..")"
  733. end
  734. versionSign.color = 0x66FF33FF
  735. if info then
  736. infoSign.text = info
  737. infoSign.visible = true
  738. end
  739. end
  740. if outdated then
  741. if beta ~= "" then
  742. versionSign.text = "Your version of Naga Farm Script is OUTDATED (Yours: v"..currentVersion.." "..Beta.." Current: v"..ver.." "..beta.."), send me email to moones@email.cz to get current one!"
  743. else
  744. versionSign.text = "Your version of Naga Farm Script is OUTDATED (Yours: v"..currentVersion.." "..Beta.." Current: v"..ver.."), send me email to moones@email.cz to get current one!"
  745. end
  746. versionSign.color = 0xFF6600FF
  747. if info then
  748. infoSign.text = info
  749. infoSign.visible = true
  750. end
  751. end
  752. versionSign.visible = true
  753.  
  754. if PlayingGame() then
  755. me = entityList:GetMyHero()
  756. player = entityList:GetMyPlayer()
  757. if not player or not me or me.classId ~= CDOTA_Unit_Hero_Naga_Siren then
  758. versionSign.visible = false
  759. infoSign.visible = false
  760. script:Disable()
  761. else
  762. Q,E = me:GetAbility(1), me:GetAbility(3)
  763. ERadius = E:GetSpecialData("radius")-50
  764. topLaneData = {} midLaneData = {} botLaneData = {} dataUpdated = false
  765. cut,stack,farm,auto,autoE,enemyjungle,radiance,octa,manta,travels = false,false,false,false,true,true,nil,nil,nil,nil
  766. topLaneData = {}
  767. midLaneData = {}
  768. botLaneData = {}
  769. victims = {}
  770. dataSaved = false
  771. local team = "Dire"
  772. if me.team == LuaEntity.TEAM_DIRE then team = "Radiant" end
  773. if not dataSaved then
  774. local topLanedata = io.open(SCRIPT_PATH.."/CreepsPathData/"..team.."TopLane.txt", "r")
  775. if topLanedata then
  776. local count = 0
  777. while true do
  778. local time, posX, posY, posZ = topLanedata:read("*number", "*number", "*number", "*number")
  779. if not time or not posX or not posY or not posZ then break end
  780. count = count + 1
  781. topLaneData[count] = {time, Vector(posX, posY, posZ)}
  782. end
  783. topLanedata:close()
  784. else
  785. print("Please download CreepsPathData in order to use this script!")
  786. script:Disable()
  787. end
  788. local midLanedata = io.open(SCRIPT_PATH.."/CreepsPathData/"..team.."MidLane.txt", "r")
  789. if midLanedata then
  790. local count = 0
  791. while true do
  792. local time, posX, posY, posZ = midLanedata:read("*number", "*number", "*number", "*number")
  793. if not time or not posX or not posY or not posZ then break end
  794. count = count + 1
  795. midLaneData[count] = {time, Vector(posX, posY, posZ)}
  796. end
  797. midLanedata:close()
  798. end
  799. local botLanedata = io.open(SCRIPT_PATH.."/CreepsPathData/"..team.."BotLane.txt", "r")
  800. if botLanedata then
  801. local count = 0
  802. while true do
  803. local time, posX, posY, posZ = botLanedata:read("*number", "*number", "*number", "*number")
  804. if not time or not posX or not posY or not posZ then dataSaved = true break end
  805. count = count + 1
  806. botLaneData[count] = {time, Vector(posX, posY, posZ)}
  807. end
  808. botLanedata:close()
  809. end
  810. end
  811.  
  812. creepwaves[1].visible = false
  813. creepwaves[3].visible = false
  814. creepwaves[5].visible = false
  815. creepwaves[2].visible = false
  816. creepwaves[4].visible = false
  817. creepwaves[6].visible = false
  818.  
  819. if HUD and (HUD:IsClosed() or HUD:IsMinimized()) then
  820. HUD:Open()
  821. end
  822.  
  823. JungleCamps = {
  824. {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, stacked = nil},
  825. {position = Vector(-366,-2945,127), stackPosition = Vector(-534.219,-1795.27,128), waitPosition = Vector(-408,-2731,127), team = 2, id = 2, farmed = false, lvlReq = 3, visible = false, visTime = 0, stacking = false, stacked = nil},
  826. {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, stacked = nil},
  827. {position = Vector(3126,-3439,256), stackPosition = Vector(4410.49,-3985,256), waitPosition = Vector(3231,-3807,256), team = 2, id = 4, farmed = false, lvlReq = 3, visible = false, visTime = 0, stacking = false, stacked = nil},
  828. {position = Vector(3031.03,-4480.06,256), stackPosition = Vector(1368.66,-5279.04,256), waitPosition = Vector(3030,-4975,256), team = 2, id = 5, farmed = false, lvlReq = 1, visible = false, visTime = 0, stacking = false, stacked = nil},
  829. {position = Vector(-2991,191,256), stackPosition = Vector(-3351,-1798,205), waitPosition = Vector(-2684,-23,256), team = 2, id = 6, farmed = false, lvlReq = 12, visible = false, visTime = 0, ancients = true, stacking = false, stacked = nil},
  830. {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, stacked = nil},
  831. {position = Vector(-244,3629,256), stackPosition = Vector(-1170.27,4581.59,256), waitPosition = Vector(-523,4041,256), team = 3, id = 8, farmed = false, lvlReq = 3, visible = false, visTime = 0, stacking = false, stacked = nil},
  832. {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, stacked = nil},
  833. {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, stacked = nil},
  834. {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, stacked = nil},
  835. {position = Vector(4026,-709.943,128), stackPosition = Vector(2636,-1017,127), waitPosition = Vector(3583,-736,127), team = 3, id = 12, farmed = false, lvlReq = 12, visible = false, visTime = 0, ancients = true, stacking = false, stacked = nil}
  836. }
  837. reg = true
  838. myId = me.classId
  839. script:RegisterEvent(EVENT_FRAME, Main)
  840. script:RegisterEvent(EVENT_KEY, Key)
  841. script:UnregisterEvent(Load)
  842. end
  843. end
  844. end
  845.  
  846. function Close()
  847. if reg then
  848. player,me,JungleCamps,enemyTeam,meTeam,reg,stack = nil,nil,{},nil,nil,false,false
  849. if HUD then
  850. HUD:Close()
  851. end
  852. script:UnregisterEvent(Main)
  853. script:UnregisterEvent(Key)
  854. script:RegisterEvent(EVENT_TICK, Load)
  855. reg = false
  856. end
  857. end
  858.  
  859. script:RegisterEvent(EVENT_CLOSE, Close)
  860. script:RegisterEvent(EVENT_TICK, Load)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement