Advertisement
Guest User

Challenger Karthus

a guest
Jan 28th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.40 KB | None | 0 0
  1. if myHero.charName ~= "Karthus" then return end
  2.  
  3. require "VPrediction"
  4. require "SOW"
  5.  
  6. function OnLoad()
  7. PrintChat(">> Challenger Karthus loaded")
  8. InitiateVariables()
  9. CreateMenu()
  10. end
  11.  
  12. function OnTick()
  13. OnTickChecks()
  14. Combo()
  15. Harass()
  16. end
  17.  
  18. function OnDraw()
  19. DrawCircles()
  20. DrawComboKiller()
  21. end
  22.  
  23. function OnProcessSpell(unit, spell)
  24. if unit.isMe and spell.name == "KarthusDefileSoundDummy2" then
  25. lastEActivation = os.clock()
  26. end
  27. end
  28.  
  29. function InitiateVariables()
  30. --menu
  31. menu = nil
  32. --skills
  33. ignite = nil
  34. flash = nil
  35. qReady = false
  36. wReady = false
  37. eReady = false
  38. rReady = false
  39. igniteReady = false
  40. flashReady = false
  41.  
  42. qRange = 900
  43. qWidth = 100
  44. qDelay = 0.7
  45. qSpeed = math.huge
  46. wRange = 1000
  47. wWidth = 450
  48. wDelay = 0.5
  49. wSpeed = math.huge
  50. eRange = 475
  51.  
  52. lastEActivation = 0
  53.  
  54. igniteRange = 600
  55. flashRange = 400
  56. --prediction
  57. VP = VPrediction(true)
  58. --orbwalker
  59. NSOW = SOW(VP)
  60. --targets
  61. target = nil
  62. flashTarget = nil
  63. targetRange = qRange
  64. --target selector
  65. enemyCharNameList = {}
  66. enemyList = {}
  67. enemyPriorityList = {}
  68. enemyNum = 0
  69. GetEnemys()
  70. --summoners
  71. GetSummoners()
  72. end
  73.  
  74. function CreateMenu()
  75. menu = scriptConfig("Challenger Karthus", "Challenger Karthus")
  76. menu:addSubMenu("Main","main")
  77. menu.main:addParam("combo", "Combo", SCRIPT_PARAM_ONKEYDOWN, false, 32)
  78. menu.main:addParam("useW", "Use W", SCRIPT_PARAM_ONKEYTOGGLE, false, 77)
  79. menu.main:addParam("harass", "Harass Enemy", SCRIPT_PARAM_ONKEYTOGGLE, false, 86)
  80. menu.main:addParam("priority5", "Attack Priority 5", SCRIPT_PARAM_ONKEYTOGGLE, false, 72)
  81. menu:addSubMenu("Draw","draw")
  82. menu.draw:addParam("drawCircles", "Draw Circles", SCRIPT_PARAM_ONOFF, true)
  83. menu.draw:addParam("drawComboKiller", "Draw Combo Killer", SCRIPT_PARAM_ONOFF, true)
  84. menu:addSubMenu("Target Selector","targetSelector")
  85. for i = 1, enemyNum do
  86. menu.targetSelector:addParam("enemy" .. i, enemyCharNameList[i], SCRIPT_PARAM_SLICE, 0, 0, 5, 0)
  87. end
  88. menu:addSubMenu("Orb Walking", "orbWalking")
  89. NSOW:LoadToMenu(menu.orbWalking)
  90. menu.main:permaShow("harass")
  91. menu.main:permaShow("priority5")
  92. end
  93.  
  94. function OnTickChecks()
  95. qReady = myHero:CanUseSpell(_Q) == READY
  96. wReady = myHero:CanUseSpell(_W) == READY
  97. eReady = myHero:CanUseSpell(_E) == READY
  98. rReady = myHero:CanUseSpell(_R) == READY
  99. flashReady = flash and myHero:CanUseSpell(flash) == READY
  100. igniteReady = ignite and myHero:CanUseSpell(ignite) == READY
  101. target = GetBestTarget(targetRange)
  102. flashTarget = GetBestTarget(flashRange + wRange + 500)
  103. enemyPriorityList[1] = menu.targetSelector.enemy1
  104. enemyPriorityList[2] = menu.targetSelector.enemy2
  105. enemyPriorityList[3] = menu.targetSelector.enemy3
  106. enemyPriorityList[4] = menu.targetSelector.enemy4
  107. enemyPriorityList[5] = menu.targetSelector.enemy5
  108. end
  109.  
  110.  
  111.  
  112.  
  113. --noch machen
  114. function Combo()
  115. rKillable()
  116. if menu.main.combo and ValidTargetA(target) then
  117. Cast("Q", target)
  118. Cast("W", target)
  119. Cast("E")
  120. end
  121. end
  122.  
  123. function Harass()
  124. if menu.main.harass and ValidTargetA(target) then
  125. Cast("Q", target)
  126. end
  127. end
  128.  
  129. function Cast(spell, target)
  130. if spell == "Q" then
  131. if qReady and GetDistance(target) <= qRange then
  132. local castPosition, hitChance, position = VP:GetCircularCastPosition(target, qDelay, qWidth, qRange)
  133. if hitChance >= 2 then
  134. CastSpell(_Q, castPosition.x, castPosition.z)
  135. end
  136. end
  137. elseif spell == "W" then
  138. if wReady and GetDistance(target) <= wRange and menu.main.useW then
  139. local castPosition, hitChance, position = VP:GetLineCastPosition(target, wDelay, wWidth, wRange)
  140. if hitChance >= 2 then
  141. CastSpell(_W, castPosition.x, castPosition.z)
  142. end
  143. end
  144. elseif spell == "E" then
  145. if eReady and lastEActivation == 0 and EnemysInRange(eRange) > 0 then
  146. CastSpell(_E)
  147. end
  148. if eReady and lastEActivation ~= 0 and os.clock()-lastEActivation > 2 and EnemysInRange(eRange) == 0 then
  149. CastSpell(_E)
  150. lastEActivation = 0
  151. end
  152. elseif spell == "R" then
  153. if rReady then
  154. CastSpell(_R)
  155. end
  156. elseif spell == "IGNITE" then
  157. if igniteReady and GetDistance(target) <= igniteRange then
  158. CastSpell(ignite, target)
  159. end
  160. end
  161. end
  162.  
  163. function DrawComboKiller()
  164. if menu.draw.drawComboKiller then
  165. for _, enemy in pairs(GetEnemyHeroes()) do
  166. if enemy and ValidTargetA(enemy) then
  167. local position = GetHPBarPos2(enemy)
  168. DrawText(tostring(math.floor(100 * (2 * getDmg("Q", enemy, myHero) + getDmg("R", enemy, myHero)) / enemy.health + 0.5)), 15, position.x, position.y, ARGB(255, 0, 255, 0))
  169. end
  170. end
  171. end
  172. end
  173.  
  174. function DrawCircles()
  175. if menu.draw.drawCircles then
  176. if flashTarget ~= nil and ValidTargetA(flashTarget) then
  177. DrawCircle2(flashTarget.x, flashTarget.y, flashTarget.z, 100, ARGB(255,255,0,0))
  178. end
  179. DrawCircle2(myHero.x, myHero.y, myHero.z, qRange, ARGB(255, 125, 0, 225))
  180. DrawCircle2(myHero.x, myHero.y, myHero.z, wRange + flashRange, ARGB(255, 125, 0, 225))
  181. end
  182. end
  183.  
  184. function GetBestTarget(range)
  185. local lessToKill = 100
  186. local lessToKilli = 0
  187. local toKill = 0
  188. local damageToHero = 0
  189. local targetArg = nil
  190. for priority = 0, 4 do
  191. if targetArg ~= nil then
  192. break
  193. end
  194. for i = 1, enemyNum do
  195. if enemyPriorityList[i] == priority and ValidTargetA(enemyList[i], range) then
  196. damageToHero = myHero:CalcMagicDamage(enemyList[i], 200)
  197. toKill = enemyList[i].health / damageToHero
  198. if ((toKill < lessToKill) or (lessToKilli == 0)) then
  199. lessToKill = toKill
  200. lessToKilli = i
  201. targetArg = enemyList[i]
  202. end
  203. end
  204. end
  205. end
  206. lessToKill = 1
  207. for _, enemy in ipairs(GetEnemyHeroes()) do
  208. if ValidTargetA(enemy, range) then
  209. toKill = (getDmg("Q", enemy, myHero)) / enemy.health
  210. if toKill > lessToKill then
  211. lessToKill = toKill
  212. targetArg = enemy
  213. end
  214. end
  215. end
  216. if targetArg == nil and menu.main.priority5 then
  217. lessToKill = 100
  218. lessToKilli = 0
  219. for i, enemy in ipairs(GetEnemyHeroes()) do
  220. if ValidTargetA(enemy, range) then
  221. damageToHero = myHero:CalcMagicDamage(enemy, 200)
  222. toKill = enemy.health / damageToHero
  223. if ((toKill < lessToKill) or (lessToKilli == 0)) then
  224. lessToKill = toKill
  225. lessToKilli = i
  226. targetArg = enemy
  227. end
  228. end
  229. end
  230. end
  231. return targetArg
  232. end
  233. --noch machen
  234.  
  235. function GetSummoners()
  236. if string.lower(myHero:GetSpellData(SUMMONER_1).name) == "summonerdot" then
  237. ignite = SUMMONER_1
  238. elseif string.lower(myHero:GetSpellData(SUMMONER_2).name) == "summonerdot" then
  239. ignite = SUMMONER_2
  240. else
  241. ignite = nil
  242. end
  243. if string.lower(myHero:GetSpellData(SUMMONER_1).name) == "summonerflash" then
  244. flash = SUMMONER_1
  245. elseif string.lower(myHero:GetSpellData(SUMMONER_2).name) == "summonerflash" then
  246. flash = SUMMONER_2
  247. else
  248. flash = nil
  249. end
  250. end
  251.  
  252. function GetEnemys()
  253. local i = 1
  254. for j = 1, heroManager.iCount do
  255. local obj = heroManager:getHero(j)
  256. if obj ~= nil and obj.team ~= myHero.team then
  257. enemyCharNameList[i] = obj.charName
  258. enemyList[i] = obj
  259. enemyNum = i
  260. i = i + 1
  261. end
  262. end
  263. return i
  264. end
  265.  
  266. function EnemysInRange(range)
  267. local i = 0
  268. for j = 1, heroManager.iCount do
  269. local obj = heroManager:getHero(j)
  270. if ValidTargetA(obj, range) then
  271. i = i + 1
  272. end
  273. end
  274. return i
  275. end
  276.  
  277. function rKillable()
  278. for j = 1, heroManager.iCount do
  279. local obj = heroManager:getHero(j)
  280. if obj ~= nil then
  281. local rDmg = 0
  282. if rReady then
  283. rDmg = getDmg("R", obj, myHero)
  284. end
  285. if ValidTargetA(obj) and rDmg + 1 > obj.health then
  286. print("ULLLLLLLLLLLLLLLLLLLLLLLLLLLLTTTTTTTTTTTT")
  287. print("ULLLLLLLLLLLLLLLLLLLLLLLLLLLLTTTTTTTTTTTT")
  288. print("ULLLLLLLLLLLLLLLLLLLLLLLLLLLLTTTTTTTTTTTT")
  289. print("ULLLLLLLLLLLLLLLLLLLLLLLLLLLLTTTTTTTTTTTT")
  290. print("ULLLLLLLLLLLLLLLLLLLLLLLLLLLLTTTTTTTTTTTT")
  291. end
  292. end
  293. end
  294. end
  295. function ValidTargetA(target, range)
  296. if target ~= nil and target.type == myHero.type and target.team ~= myHero.team and not target.dead and target.health > 0 then
  297. if range ~= nil and GetDistance(target) <= range then
  298. return true
  299. elseif range ~= nil then
  300. return false
  301. end
  302. return true
  303. else
  304. return false
  305. end
  306. end
  307.  
  308. function GetHPBarPos2(enemy)
  309. local barPos = WorldToScreen(D3DXVECTOR3(enemy.x, enemy.y, enemy.z))
  310. local pos = { x = barPos.x - 35, y = barPos.y - 50 }
  311. return pos
  312. end
  313.  
  314. -- copied functions
  315. -- barasia, vadash, viseversa
  316. function DrawCircleNextLvl(x, y, z, radius, width, color, chordlength)
  317. radius = radius or 300
  318. quality = math.max(8,math.floor(180/math.deg((math.asin((chordlength/(2*radius)))))))
  319. quality = 2 * math.pi / quality
  320. radius = radius*.92
  321. local points = {}
  322. for theta = 0, 2 * math.pi + quality, quality do
  323. local c = WorldToScreen(D3DXVECTOR3(x + radius * math.cos(theta), y, z - radius * math.sin(theta)))
  324. points[#points + 1] = D3DXVECTOR2(c.x, c.y)
  325. end
  326. DrawLines2(points, width or 1, color or 4294967295)
  327. end
  328.  
  329. function DrawCircle2(x, y, z, radius, color)
  330. local vPos1 = Vector(x, y, z)
  331. local vPos2 = Vector(cameraPos.x, cameraPos.y, cameraPos.z)
  332. local tPos = vPos1 - (vPos1 - vPos2):normalized() * radius
  333. local sPos = WorldToScreen(D3DXVECTOR3(tPos.x, tPos.y, tPos.z))
  334. if OnScreen({ x = sPos.x, y = sPos.y }, { x = sPos.x, y = sPos.y }) then
  335. DrawCircleNextLvl(x, y, z, radius, 1, color, 75)
  336. end
  337. end
  338.  
  339. -- zikkah
  340. function GetHPBarPos(enemy)
  341. enemy.barData = GetEnemyBarData()
  342. local barPos = GetUnitHPBarPos(enemy)
  343. local barPosOffset = GetUnitHPBarOffset(enemy)
  344. local barOffset = { x = enemy.barData.PercentageOffset.x, y = enemy.barData.PercentageOffset.y }
  345. local barPosPercentageOffset = { x = enemy.barData.PercentageOffset.x, y = enemy.barData.PercentageOffset.y }
  346. local BarPosOffsetX = 171
  347. local BarPosOffsetY = 46
  348. local CorrectionY = 0
  349. local StartHpPos = 31
  350. barPos.x = barPos.x + (barPosOffset.x - 0.5 + barPosPercentageOffset.x) * BarPosOffsetX + StartHpPos
  351. barPos.y = barPos.y + (barPosOffset.y - 0.5 + barPosPercentageOffset.y) * BarPosOffsetY + CorrectionY
  352. local StartPos = Vector(barPos.x , barPos.y, 0)
  353. local EndPos = Vector(barPos.x + 108 , barPos.y , 0)
  354. return Vector(StartPos.x, StartPos.y, 0), Vector(EndPos.x, EndPos.y, 0)
  355. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement