Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.04 KB | None | 0 0
  1. local version = "1.284"
  2.  
  3. require 'VPrediction'
  4. --[[
  5. UnifiedSoraka by VictorGrego
  6.  
  7. Features:
  8. - Auto Level Abilities
  9. - Auto Starcall (Q)
  10. - Auto Heal (W)
  11. - Auto Equinox (E)
  12. - Auto Ult [M]
  13. - Avoid hitting enemy under turret
  14. - Auto Buy items
  15.  
  16. Changelog:
  17. --]]
  18.  
  19. -- Champion Check
  20. if myHero.charName ~= "Soraka" then return end
  21.  
  22. shopList = {
  23. 3301,-- coin
  24. 3340,--ward trinket
  25. 1004,1004,--Faerie Charm
  26. 3028,
  27. --1028,--Ruby Crystal
  28. --2049,--Sighstone
  29. 3096,--Nomad Medallion
  30. 3114,--Forbidden Idol
  31. 3069,--Talisman of Ascension
  32. 1001,--Boots
  33. 3108,--Fiendish Codex
  34. 3174,--Athene's Unholy Grail
  35. --2045,--Ruby Sighstone
  36. 1028,--Ruby Crystal
  37. 1057,--Negatron Cloak
  38. 3105,--Aegis of Legion
  39. 3158,--Ionian Boots
  40. 1011,--Giants Belt
  41. 3190,--Locket of Iron Solari
  42. 3143,--Randuins
  43. 3275,--Homeguard
  44. 1058,--Large Rod
  45. 3089--Rabadon
  46. }
  47.  
  48. nextbuyIndex = 1
  49. lastBuy = 0
  50.  
  51. buyDelay = 100 --default 100
  52.  
  53. --UPDATE SETTINGS
  54. local AutoUpdate = true
  55. local SELF = SCRIPT_PATH..GetCurrentEnv().FILE_NAME
  56. local URL = "https://raw.githubusercontent.com/victorgrego/Bol/master/UnifiedSoraka.lua?"..math.random(100)
  57. local UPDATE_TMP_FILE = LIB_PATH.."UNSTmp.txt"
  58. local versionmessage = "<font color=\"#81BEF7\" >Changelog: Added autobuy option and changed build to spam skills</font>"
  59.  
  60. function Update()
  61. DownloadFile(URL, UPDATE_TMP_FILE, UpdateCallback)
  62. end
  63.  
  64. function UpdateCallback()
  65. file = io.open(UPDATE_TMP_FILE, "rb")
  66. if file ~= nil then
  67. content = file:read("*all")
  68. file:close()
  69. os.remove(UPDATE_TMP_FILE)
  70. if content then
  71. tmp, sstart = string.find(content, "local version = \"")
  72. if sstart then
  73. send, tmp = string.find(content, "\"", sstart+1)
  74. end
  75. if send then
  76. Version = tonumber(string.sub(content, sstart+1, send-1))
  77. end
  78. if (Version ~= nil) and (Version > tonumber(version)) and content:find("--EOS--") then
  79. file = io.open(SELF, "w")
  80. if file then
  81. file:write(content)
  82. file:flush()
  83. file:close()
  84. PrintChat("<font color=\"#81BEF7\" >UnifiedSoraka:</font> <font color=\"#00FF00\">Successfully updated to: v"..Version..". Please reload the script with F9.</font>")
  85. else
  86. PrintChat("<font color=\"#81BEF7\" >UnifiedSoraka:</font> <font color=\"#FF0000\">Error updating to new version (v"..Version..")</font>")
  87. end
  88. elseif (Version ~= nil) and (Version == tonumber(version)) then
  89. PrintChat("<font color=\"#81BEF7\" >UnifiedSoraka:</font> <font color=\"#00FF00\">No updates found, latest version: v"..Version.." </font>")
  90. end
  91. end
  92. end
  93. end
  94. -- Constants (do not change)
  95. local GLOBAL_RANGE = 0
  96. local NO_RESOURCE = 0
  97. local DEFAULT_STARCALL_MODE = 3
  98. local DEFAULT_STARCALL_MIN_MANA = 300 --Starcall will not be cast if mana is below this level
  99. local DEFAULT_NUM_HIT_MINIONS = 3 -- number of minions that need to be hit by starcall before its cast
  100. local DEFAULT_HEAL_MODE = 2
  101. local DEFAULT_HEAL_THRESHOLD = 75 -- for healMode 3, default 75 (75%)
  102. local DEFAULT_INFUSE_MODE = 2
  103. local DEFAULT_MIN_ALLY_SILENCE = 70 -- percentage of mana nearby ally lolshould have before soraka uses silence
  104. local DEFAULT_ULT_MODE = 2
  105. local DEFAULT_ULT_THRESHOLD = 35 --percentage of hp soraka/ally/team must be at or missing for ult, eg 10 (10%)
  106. local DEFAULT_DENY_THRESHOLD = 75
  107. local DEFAULT_STEAL_THRESHOLD = 60
  108. local MAX_PLAYER_AA_RANGE = 850
  109. local HEAL_DISTANCE = 700
  110. local HL_slot = nil
  111. local CL_slot = nil
  112. local DEFAULT_MANA_CLARITY = 50
  113.  
  114. -- Recall Check
  115. local isRecalling = false
  116. local RECALL_DELAY = 0.5
  117.  
  118. -- Auto Level
  119. local levelSequence = {_W,_E,_Q,_W,_W,_R,_W,_E,_W,_E,_R,_E,_E,_Q,_Q,_R,_Q,_Q}
  120.  
  121. --Target Selector
  122. ts = TargetSelector(TARGET_LOW_HP, 1000, DAMAGE_MAGIC, true)
  123.  
  124. -- Auto Heal (W) - Soraka heals the nearest injured ally champion
  125. local RAW_HEAL_AMOUNT = {110, 140, 170, 200, 230}
  126. local RAW_HEAL_RATIO = 0.6
  127. local HEAL_RANGE = 450
  128. local HEAL_MIN_HP = 0.05
  129.  
  130. --Auto StarCall (Q)
  131. local STARCALL_RANGE = 950
  132.  
  133. local EQUINOX_RANGE = 925
  134.  
  135. --[[ ultMode notes:
  136. 1 = ult when Soraka is low/about to die, under ultThreshold% of hp [selfish ult]
  137. 2 = ult when ally is low/about to die, under ultThreshold% of hp [lane partner ult]
  138. 3 = ult when total missing health of entire team exceeds ultThreshold (ie 50% of entire team health is missing)
  139. -]]
  140.  
  141. --[[ Main Functions ]]--
  142.  
  143. -- Soraka performs starcall to help push/farm a lane or harrass enemy champions (or both)
  144. function doSorakaStarcall()
  145.  
  146. if not ts.target then return end
  147. local pos, info, hitchance
  148. local pro = false;
  149.  
  150. --[[if VIP_USER then
  151. pos, info = Prodiction.GetPrediction(ts.target, STARCALL_RANGE, nil, 0.25, 125, nil)
  152. pro = true
  153. else]]
  154. pos, hitchance = VP:GetPredictedPos(ts.target, 0.25, 2000, player, true)
  155. --end
  156.  
  157. if config.autoStarcall.starcallTowerDive == false and UnderTurret(player, true) == true and info ~= nil and (info.hitchance ~=0 or hitchance ~= 0) then return end
  158.  
  159. --if pro and pos and info.hitchance ~= 0 then
  160. -- CastSpell(_Q, pos.x, pos.z)
  161. if hitchance ~= 0 then
  162. CastSpell(_Q, pos.x, pos.z)
  163. end
  164. end
  165.  
  166. -- Soraka Heals the nearby most injured ally or herself, assumes heal is ready to be used
  167. function doSorakaHeal()
  168. -- Find ally champion to heal
  169. local ally = GetPlayer(player.team, false, false, player, HEAL_RANGE, "health")
  170. --if ally ~= nil then PrintChat("Ally Champion: "..ally.name) end
  171. -- If no eligible ally, return
  172.  
  173. -- Heal ally
  174. if ally ~= nil and (ally.health/ally.maxHealth) < config.autoHeal.healThreshold/100 then
  175. CastSpell(_W, ally)
  176. end
  177. end
  178.  
  179. -- Soraka uses ultimate based on user preference
  180. function doSorakaUlt()
  181. -- Ult based on ultMode
  182. if config.autoUlt.ultMode == 1 then
  183. if (player.health/player.maxHealth) < (config.autoUlt.ultThreshold / 100) then
  184. CastSpell(_R)
  185. end
  186. elseif config.autoUlt.ultMode == 2 then
  187. -- Find nearby ally champion (your lane partner usually) that is fatally injured
  188.  
  189. local ally = GetPlayer(player.team, false, true, nil, GLOBAL_RANGE, "health")
  190.  
  191. -- Use ult if suitable ally found
  192. if ally ~= nil and (ally.health/ally.maxHealth) < (config.autoUlt.ultThreshold / 100) then
  193. CastSpell(_R)
  194. end
  195. elseif config.autoUlt.ultMode == 3 then
  196. --find total hp of team as a percentage, ie team had 40% of their max hp
  197. local totalMissingHP = 0
  198. local counter = 0
  199.  
  200. for i=1, heroManager.iCount do
  201. local hero = heroManager:GetHero(i)
  202.  
  203. if hero ~= nil and hero.type == "AIHeroClient" and hero.team == player.team and hero.dead == false then --checks for ally and that person is not dead
  204. totalMissingHP = totalMissingHP + (hero.health/hero.maxHealth)
  205. counter = counter + 1
  206. end
  207. end
  208.  
  209. totalMissingHP = totalMissingHP / counter
  210.  
  211. if totalMissingHP < (config.autoUlt.ultThreshold / 100) then
  212. CastSpell(_R)
  213. end
  214. end
  215. end
  216.  
  217. -- Soraka Infuses the most mana deprived ally donating them mana
  218. function doSorakaEquinox()
  219.  
  220. if not ts.target then return end
  221. local pos, info, hitchance
  222. local pro = false;
  223.  
  224. pos, hitchance = VP:GetPredictedPos(ts.target, 0.25, 2000, player, true)
  225.  
  226. if config.autoStarcall.starcallTowerDive == false and UnderTurret(player, true) == true and (info.hitchance ~=0 or hitchance ~= 0) then return end
  227.  
  228. if hitchance ~= 0 then
  229. CastSpell(_E, pos.x, pos.z)
  230. end
  231. end
  232.  
  233. --[[ Helper Functions ]]--
  234.  
  235.  
  236. --[[ Helper Functions ]]--
  237. -- Return player based on their resource or stat
  238. function GetPlayer(team, includeDead, includeSelf, distanceTo, distanceAmount, resource)
  239. local target = nil
  240.  
  241. for i=1, heroManager.iCount do
  242. local member = heroManager:GetHero(i)
  243.  
  244. if member ~= nil and member.type == "AIHeroClient" and member.team == team and (member.dead ~= true or includeDead) then
  245. if member.charName ~= player.charName or includeSelf then
  246. if distanceAmount == GLOBAL_RANGE or member:GetDistance(distanceTo) <= distanceAmount then
  247. if target == nil then target = member end
  248.  
  249. if resource == "health" then --least health
  250. if member.health < target.health then target = member end
  251. elseif resource == "mana" then --least mana
  252. if member.mana < target.mana then target = member end
  253. elseif resource == "AD" then --highest AD
  254. if member.totalDamage > target.totalDamage then target = member end
  255. elseif resource == NO_RESOURCE then
  256. return member -- as any member is eligible
  257. end
  258. end
  259. end
  260. end
  261. end
  262.  
  263. return target
  264. end
  265.  
  266. function buy()
  267. if InFountain() or player.dead then
  268. -- Item purchases
  269. if GetTickCount() > lastBuy + buyDelay then
  270. if GetInventorySlotItem(shopList[nextbuyIndex]) ~= nil then
  271. --Last Buy successful
  272. nextbuyIndex = nextbuyIndex + 1
  273. else
  274. --Last Buy unsuccessful (buy again)
  275. --[[local p = CLoLPacket(0x82)
  276. p.dwArg1 = 1
  277. p.dwArg2 = 0
  278. p:EncodeF(myHero.networkID)
  279. p:Encode4(shopList[nextbuyIndex])
  280. SendPacket(p)
  281. lastBuy = GetTickCount()]]
  282. lastBuy = GetTickCount()
  283. BuyItem(shopList[nextbuyIndex])
  284. end
  285. end
  286. end
  287. end
  288.  
  289. --draws Menu
  290. function drawMenu()
  291. -- Config Menu
  292. config = scriptConfig("UnifiedSoraka", "UnifiedSoraka")
  293.  
  294. config:addParam("enableScript", "Enable Script", SCRIPT_PARAM_ONOFF, true)
  295. config:addParam("autoBuy", "Auto Buy Items", SCRIPT_PARAM_ONOFF, true)
  296. config:addParam("autoLevel", "Auto Level", SCRIPT_PARAM_ONOFF, true)
  297.  
  298. config:addSubMenu("Auto Heal", "autoHeal")
  299. config:addSubMenu("Auto Starcall", "autoStarcall")
  300. config:addSubMenu("Auto Equinox", "autoEquinox")
  301. config:addSubMenu("Auto Ult", "autoUlt")
  302. config:addSubMenu("Farming", "autoFarm")
  303.  
  304. config.autoFarm:addParam("doFarm", "Allow minion attack", SCRIPT_PARAM_ONOFF, false)
  305.  
  306. config.autoHeal:addParam("enabled", "Enable", SCRIPT_PARAM_ONOFF, true)
  307. config.autoHeal:addParam("healThreshold", "Heal Threshold (%)", SCRIPT_PARAM_SLICE, DEFAULT_HEAL_THRESHOLD, 0, 100, 0)
  308. config.autoHeal:addParam("healMinMana", "Starcall Minimum Mana (%)", SCRIPT_PARAM_SLICE, DEFAULT_STARCALL_MIN_MANA, 0, 100, 0)
  309. config.autoHeal:addParam("sorakaThreshold", "Soraka HP Threshold (%)", SCRIPT_PARAM_SLICE, DEFAULT_HEAL_THRESHOLD, 5, 100, 0)
  310.  
  311. config.autoStarcall:addParam("enabled", "Enable", SCRIPT_PARAM_ONOFF, true)
  312. config.autoStarcall:addParam("starcallTowerDive", "Starcall Under Towers", SCRIPT_PARAM_ONOFF, false)
  313. config.autoStarcall:addParam("starcallMinMana", "Starcall Minimum Mana", SCRIPT_PARAM_SLICE, DEFAULT_STARCALL_MIN_MANA, 0, 100, 0)
  314.  
  315. config.autoEquinox:addParam("enabled", "Enable", SCRIPT_PARAM_ONOFF, true)
  316. config.autoEquinox:addParam("equinoxMinMana", "Equinox Min Mana", SCRIPT_PARAM_SLICE, DEFAULT_STARCALL_MIN_MANA, 0, 100, 0)
  317. config.autoEquinox:addParam("equinoxTowerDive", "Equinox Under Towers", SCRIPT_PARAM_ONOFF, false)
  318.  
  319. config.autoUlt:addParam("enabled", "Enable", SCRIPT_PARAM_ONOFF, true)
  320. config.autoUlt:addParam("ultMode", "Ultimate Mode", SCRIPT_PARAM_LIST, DEFAULT_ULT_MODE, { "Selfish", "Lane Partner", "Entire Team" })
  321. config.autoUlt:addParam("ultThreshold", "Ult Threshold (%)", SCRIPT_PARAM_SLICE, DEFAULT_ULT_THRESHOLD, 0, 100, 0)
  322. end
  323.  
  324. function OnProcessSpell(unit,spell)
  325. if not config.autoFarm.doFarm and unit.name == player.name and spell.name:lower():find("attack") ~= nil then
  326. if(spell.target.name:lower():find("minion")~=nil) then player:HoldPosition() end
  327. end
  328. end
  329.  
  330. -- obCreatObj
  331. function OnCreateObj(obj)
  332. -- Check if player is recalling and set isrecalling
  333. if obj.name:find("TeleportHome") then
  334. if GetDistance(player, obj) <= 70 then
  335. isRecalling = true
  336. end
  337. end
  338. end
  339.  
  340. -- OnDeleteObj
  341. function OnDeleteObj(obj)
  342. if obj.name:find("TeleportHome") then
  343. -- Set isRecalling off after short delay to prevent using abilities once at base
  344. DelayAction(function() isRecalling = false end, RECALL_DELAY)
  345. end
  346. end
  347.  
  348. --[[ OnTick ]]--
  349. function OnTick()
  350. -- Check if script should be run
  351. --if not config.enableScript then return end
  352. ts:update()
  353. --if(ts.target) then print(ts.target.charName) end
  354. -- Auto Level
  355. if config.autoLevel and player.level > GetHeroLeveled() then
  356. LevelSpell(levelSequence[GetHeroLeveled() + 1])
  357. end
  358.  
  359. -- Recall Check
  360. if (isRecalling) then
  361. return -- Don't perform recall canceling actions
  362. end
  363.  
  364. -- Auto Ult (R)
  365. if config.autoUlt.enabled and player:CanUseSpell(_R) == READY then
  366. doSorakaUlt()
  367. end
  368.  
  369. if config.autoBuy then buy() end
  370.  
  371. -- Only perform following tasks if not in fountain
  372. if not InFountain() then
  373. -- Auto Heal and Deny Farm (W)
  374. if player:CanUseSpell(_W) == READY and config.autoHeal.enabled and (player.mana/player.maxMana) > config.autoHeal.healMinMana / 100 and player.health/player.maxHealth > config.autoHeal.sorakaThreshold/100 then
  375. doSorakaHeal()
  376. end
  377.  
  378. --Auto Equinox (E)
  379. if player:CanUseSpell(_E) == READY and config.autoEquinox.enabled and player.mana/player.maxMana > config.autoEquinox.equinoxMinMana/100 then
  380. doSorakaEquinox()
  381. end
  382.  
  383. -- Auto StarCall (Q)
  384. if config.autoStarcall.enabled and player:CanUseSpell(_Q) == READY and player.mana/player.maxMana > config.autoStarcall.starcallMinMana/100 then
  385. doSorakaStarcall()
  386. end
  387. end
  388. end
  389.  
  390. function OnLoad()
  391. player = GetMyHero()
  392. drawMenu()
  393. startingTime = GetTickCount()
  394.  
  395. VP = VPrediction()
  396.  
  397. if AutoUpdate then
  398. Update()
  399. end
  400. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement