Advertisement
Kevinkev

Passive follow fixed

Dec 27th, 2012
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.47 KB | None | 0 0
  1. --[[
  2.     Passive Follow by ivan[russia]
  3.  
  4.     !!!ALERT!!!
  5.     AUTOFOLLOW NOT TOO INTELECTUAL, PLAYERS CAN REPORT AUTOFOLLOW FOR FEED OR CHEATING OR BOTING, THEN YOU CAN GET BAN, POSIBLE BAN FOR HACKING
  6.     IN DEVELOPMENT
  7.     cmd list:
  8.    .follow start DummyNick  -- starts follow champion with nickname: DummyNick
  9.    .follow stop             -- stops follow champion
  10.    
  11.    Updated for BoL by ikita
  12. ]]
  13.  
  14. -- SETTINGS
  15. do
  16. -- you can change true to false and false to true
  17. -- false is turn off
  18. -- true is turn on
  19.  
  20. currentPlayer = 1
  21. TargetToggleKey = 116 --Toggle Target following [f5]
  22. SetupTogleKey = 117  --Key to Togle script. [ F6 - 117 ] default
  23.                      --key codes
  24.                      --http://www.indigorose.com/webhelp/ams/Program_Reference/Misc/Virtual_Key_Codes.htm
  25.  
  26. SetupFollowDistance = 500
  27. --Distance between FollowTarget and Champion in which champion starts correcting itself
  28. --Should be more then 400
  29.  
  30. SetupFollowAlly = true
  31. -- you start follow near ally when your followtarget have been diead
  32.  
  33. SetupRunAway = true
  34. -- if no ally was near when followtarget died, you run to close tower
  35.  
  36. SetupRunAwayRecall = true
  37. -- if you succesfully recall after followtarget died or recalled, you start recall
  38.  
  39. SetupFollowRecall = true
  40. -- should you recall as soon as follow target racalled
  41.  
  42. SetupAutoHold = true -- Need work
  43. -- stop autohit creeps when following target
  44. end
  45.  
  46. -- GLOBALS [Do Not Change]
  47. do
  48. SetupDebug = true
  49. switcher = true
  50. following = nil
  51. temp_following = nil
  52. stopPosition = false
  53.  
  54. --state of app enum
  55. FOLLOW = 1
  56. TEMP_FOLLOW = -33
  57. WAITING_FOLLOW_RESP = 150
  58. GOING_TO_TOWER = 666
  59.  
  60. --by default
  61. state = FOLLOW
  62.  
  63. -- spawn
  64. allySpawn = nil
  65. enemySpawn = nil
  66.  
  67. version = 1
  68. player = GetMyHero()
  69. end
  70.  
  71. recallStartTime = 0
  72. recallDetected = false
  73.  
  74. recentrecallTarget = player
  75.  
  76. -- ABSTRACTION-METHODS
  77.  
  78. --return players table
  79. function GetPlayers(team, includeDead, includeSelf)
  80.     local players = {}
  81.     for i=1, heroManager.iCount, 1 do
  82.         local member = heroManager:getHero(i)
  83.         if member ~= nil and member.valid and member.type == "obj_AI_Hero" and member.visible and member.team == team then
  84.             if member.name ~= player.name or includeSelf then
  85.                 if includeDead then
  86.                     table.insert(players,member)
  87.                 elseif member.dead == false then
  88.                     table.insert(players,member)
  89.                 end
  90.             end
  91.         end
  92.     end
  93.     if #players > 0 then
  94.         return players
  95.     else
  96.         return false
  97.     end
  98. end
  99.  
  100. --return towers table
  101. function GetTowers(team)
  102.     local towers = {}
  103.     for i=1, objManager.maxObjects, 1 do
  104.         local tower = objManager:getObject(i)
  105.         if tower ~= nil and tower.valid and tower.type == "obj_AI_Turret" and tower.visible and tower.team == team then
  106.             table.insert(towers,tower)
  107.         end
  108.     end
  109.     if #towers > 0 then
  110.         return towers
  111.     else
  112.         return false
  113.     end
  114. end
  115.  
  116. --here get close tower
  117. function GetCloseTower(hero, team)
  118.     local towers = GetTowers(team)
  119.     if #towers > 0 then
  120.         local candidate = towers[1]
  121.         for i=2, #towers, 1 do
  122.             if (towers[i].health/towers[i].maxHealth > 0.1) and  hero:GetDistance(candidate) > hero:GetDistance(towers[i]) then candidate = towers[i] end
  123.         end
  124.         return candidate
  125.     else
  126.         return false
  127.     end
  128. end
  129.  
  130. --here get close player
  131. function GetClosePlayer(hero, team)
  132.     local players = GetPlayers(team,false,false)
  133.     if #players > 0 then
  134.         local candidate = players[1]
  135.         for i=2, #players, 1 do
  136.             if hero:GetDistance(candidate) > hero:GetDistance(players[i]) then candidate = players[i] end
  137.         end
  138.         return candidate
  139.     else
  140.         return false
  141.     end
  142. end
  143.  
  144. -- return count of champs near hero
  145. function cntOfChampsNear(hero,team,distance)
  146.     local cnt = 0 -- default count of champs near HERO
  147.     local players = GetPlayers(team,false,true)
  148.     for i=1, #players, 1 do
  149.         if players[i] ~= hero and hero:GetDistance(players[i]) < distance then cnt = cnt + 1 end
  150.     end
  151.     return cnt
  152. end
  153.  
  154. -- return %hp of champs near hero
  155. function hpOfChampsNear(hero,team,distance)
  156.     local percent = 0 -- default %hp of champs near HERO
  157.     local players = GetPlayers(team,false, true)
  158.     for i=1, #players, 1 do
  159.         if players[i] ~= hero and hero:GetDistance(players[i]) < distance then percent = percent + players[i].health/players[i].maxHealth end
  160.     end
  161.     return percent
  162. end
  163.  
  164. function OnProcessSpell(object,spellProc) --for soraka + sona
  165.     if switcher == true and object.name == player.name and (spellProc.name == "SonaHymnofValorAttack" or spellProc.name == "SonaAriaofPerseveranceAttack" or spellProc.name == "SonaBasicAttack" or spellProc.name == "SonaBasicAttack2" or spellProc.name == "SonaSongofDiscordAttack" or spellProc.name == "SorakaBasicAttack" or spellProc.name == "SorakaBasicAttack2") then
  166.         Run(GetCloseTower(player,player.team))
  167.     end
  168. end
  169.  
  170. -- is recall, return true/false
  171. function isRecall(hero)
  172.     if GetTickCount() - recallStartTime > 8000 then
  173.         return false
  174.     else
  175.         if recentrecallTarget.name == hero.name then
  176.             return true
  177.         end
  178.         return false
  179.     end
  180. end
  181.  
  182. function OnCreateObj(object)
  183.     if object.name == "TeleportHomeImproved.troy" or object.name == "TeleportHome.troy" then
  184.         for i = 1, heroManager.iCount do
  185.             local target = heroManager:GetHero(i)
  186.             if GetDistance(target, object) < 100 then
  187.                 recentrecallTarget = target
  188.             end
  189.         end
  190.         recallStartTime = GetTickCount()
  191.     end
  192. end
  193.  
  194. -- turn (off - on) by SetupTogleKey
  195. function OnWndMsg(msg, keycode)
  196.     if keycode == SetupTogleKey and msg == KEY_DOWN then
  197.  
  198.         if switcher == true then
  199.  
  200.             switcher = false
  201.  
  202.             PrintChat("<font color='#FF0000'>Passive Follow >> TURNED OFF </font>")
  203.  
  204.         else
  205.  
  206.             switcher = true
  207.  
  208.             PrintChat("<font color='#00FF00'>Passive Follow >> TURNED ON </font>")
  209.  
  210.         end
  211.  
  212.     end
  213.  
  214.    
  215.  
  216.         if keycode == TargetToggleKey and msg == KEY_DOWN then
  217.  
  218.             PrintChat("<font color='#FF0000'>TARGET SWITCHED : </font>")
  219.  
  220.             players = GetPlayers(player.team, true, false)
  221.  
  222.            
  223.  
  224.             if players ~= false then
  225.                 for i=1, #players, 1 do
  226.  
  227.                 if (string.lower(players[currentPlayer].name) == string.lower(following.name)) then
  228.                     currentPlayer = currentPlayer + 1
  229.                         if currentPlayer > 4 then              
  230.                         currentPlayer = 1
  231.                         end
  232.                        
  233.                         break
  234.                 end
  235.  
  236.                
  237.  
  238.                 following = players[currentPlayer]
  239.  
  240.                         PrintChat("Passive Follow >> following summoner: "..players[currentPlayer].name)
  241.  
  242.                         carryCheck = true
  243.  
  244.                 end
  245.  
  246.                        
  247.                 end
  248.             end
  249.            
  250.  
  251.          
  252. end
  253.  
  254.  
  255. -- CHAT CALLBACK
  256. function OnSendChat(text)
  257.     if string.sub(text,1,7) == ".follow" then
  258.     BlockChat()
  259.         if string.sub(text,9,13) == "start" then
  260.             name = string.sub(text,15)
  261.             players = GetPlayers(player.team, true, false)
  262.             if players ~= false then
  263.                 for i=1, #players, 1 do
  264.                     if (string.lower(players[i].name) == string.lower(name))  then
  265.                         following = players[i]
  266.                         PrintChat("Passive Follow >> following summoner: "..players[i].name)
  267.                         carryCheck = true
  268.                         if following.dead then state = WAITING_FOLLOW_RESP else state = FOLLOW end
  269.                     end
  270.                 end
  271.                 if following == nil then PrintChat("Passive Follow >> "..name.." did not found") end
  272.             end
  273.         end
  274.         if string.sub(text,9,12) == "stop" then
  275.             following = nil
  276.             state = FOLLOW
  277.             PrintChat("Passive Follow >> terminated")
  278.         end
  279.     end
  280. end
  281.  
  282.  
  283. function toggleFollow()
  284.  
  285.    
  286.  
  287.  
  288.  
  289. end
  290.  
  291.  
  292. -- TIMER CALLBACK
  293. mytime = GetTickCount()
  294.  
  295. function OnTick()
  296.     --Identify AD carry and follow
  297.     if carryCheck == false then
  298.         for i = 1, heroManager.iCount, 1 do
  299.         local teammates = heroManager:getHero(i)
  300.         --Coordinates are for bots only
  301.             if math.sqrt((teammates.x - 12143)^2 + (teammates.z - 2190)^2) < 4500 and teammates.team == player.team and teammates.name ~= player.name then
  302.                 following = teammates
  303.                 PrintChat("Passive Follow >> following summoner: "..teammates.name)
  304.                 state = FOLLOW
  305.                 carryCheck = true
  306.             end
  307.         end
  308.        
  309.     end
  310.  
  311.     if GetTickCount() - mytime > 800 and switcher then
  312.         Brain()
  313.         mytime = GetTickCount()
  314.     end
  315.     if following ~= nil then
  316.         Status(following, 1, value)
  317.     end
  318. end
  319.  
  320. -- STATUS CALLBACK
  321. function Status(member, desc, value)
  322.     if member == following and desc == 1 then
  323.         if member.dead and state == FOLLOW then
  324.             PrintChat("Passive Follow >> "..member.name.." dead")
  325.             -- if SetupFollowAlly == true and ALLYNEAR then temporary changing follow target
  326.             if SetupFollowAlly and player:GetDistance(GetClosePlayer(player,player.team)) < SetupFollowDistance then
  327.                 temp_following = GetClosePlayer(player,player.team)
  328.                 PrintChat("Passive Follow >> "..(GetClosePlayer(player,player.team)).name.." temporary following")
  329.                 state = TEMP_FOLLOW
  330.             elseif SetupRunAway then
  331.                 state = GOING_TO_TOWER
  332.             else
  333.                 state = WAITING_FOLLOW_RESP
  334.             end
  335.         end
  336.         if member.dead == false then
  337.             if state == WAITING_FOLLOW_RESP then
  338.                 PrintChat("Passive Follow >> "..member.name.." alive")
  339.                 state = FOLLOW
  340.             end
  341.             if state == TEMP_FOLLOW then
  342.                 temp_following = nil
  343.                 PrintChat("Passive Follow >> "..member.name.." alive")
  344.                 state = FOLLOW
  345.             end
  346.             if state == GOING_TO_TOWER then
  347.                 PrintChat("Passive Follow >> "..member.name.." alive")
  348.                 state = FOLLOW
  349.             end
  350.         end
  351.     end
  352. end
  353.  
  354. -- SEMICORE
  355. -- run(follow) to target
  356. function Run(target)
  357.     if target.type == "obj_AI_Hero" then
  358.         if target:GetDistance(allySpawn) > SetupFollowDistance then
  359.             if (player:GetDistance(target) > SetupFollowDistance or player:GetDistance(target) < 275 --[[this is to stop get aoe, which are often 275 range]] or player:GetDistance(allySpawn) + 275 > target:GetDistance(allySpawn)) then
  360.                 followX = ((allySpawn.x - target.x)/(target:GetDistance(allySpawn)) * ((SetupFollowDistance - 300) / 2 + 300) + target.x + math.random(-((SetupFollowDistance-300)/3),((SetupFollowDistance-300)/3)))
  361.                 followZ = ((allySpawn.z - target.z)/(target:GetDistance(allySpawn)) * ((SetupFollowDistance - 300) / 2 + 300) + target.z + math.random(-((SetupFollowDistance-300)/3),((SetupFollowDistance-300)/3)))
  362.                 player:MoveTo(followX, followZ)
  363.             else
  364.                 player:HoldPosition()
  365.             end
  366.         elseif SetupFollowRecall and player:GetDistance(allySpawn) > (SetupFollowDistance * 3) then
  367.             state = GOING_TO_TOWER
  368.         end
  369.     end
  370.     if target.type == "obj_AI_Turret" then
  371.         if player:GetDistance(target) > 300 then
  372.             player:MoveTo(target.x + math.random(-150,150), target.z + math.random(-150,150))
  373.         elseif SetupRunAwayRecall then
  374.             CastSpell(RECALL)
  375.             if following.dead == true then
  376.                 state = WAITING_FOLLOW_RESP
  377.             else
  378.                 state = FOLLOW
  379.             end
  380.         end
  381.     end
  382. end
  383.  
  384. -- CORE
  385. function Brain()
  386.     if following ~= nil and player.dead == false and isRecall(player) == false then
  387.         if state == FOLLOW then
  388.             Run(following)
  389.         end
  390.         if state == TEMP_FOLLOW and temp_following ~= nil then Run(temp_following) end
  391.         if state == GOING_TO_TOWER then Run(GetCloseTower(player,player.team)) end
  392.        
  393.     end
  394. end
  395.  
  396. -- AT LOADING OF SCRIPT
  397.  
  398.     -- here checking timer
  399. function OnLoad()
  400.     PrintChat("Passive Follow >> v"..tostring(version).." LOADED")
  401.     carryCheck = false
  402.     -- numerate spawn
  403.     for i=1, objManager.maxObjects, 1 do
  404.         local candidate = objManager:getObject(i)
  405.         if candidate ~= nil and candidate.valid and candidate.type == "obj_SpawnPoint" then
  406.             if candidate.x < 3000 then
  407.                 if player.team == TEAM_BLUE then allySpawn = candidate else enemySpawn = candidate end
  408.             else
  409.                 if player.team == TEAM_BLUE then enemySpawn = candidate else allySpawn = candidate end
  410.             end
  411.         end
  412.     end
  413.     -- fix user settings
  414.     if SetupFollowDistance < 400 then SetupFollowDistance = 400 end
  415.     -- count towers
  416. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement