Skip to content

Instantly share code, notes, and snippets.

@DelusionalLogic
Created July 4, 2012 20:51
Show Gist options
  • Save DelusionalLogic/3049480 to your computer and use it in GitHub Desktop.
Save DelusionalLogic/3049480 to your computer and use it in GitHub Desktop.
Auto Crit
--[[
AutoAttacker! + autoCrit 2.0 mod 1
v0.1
AutoAttacker! written by Weee
autoCrit 2.0 mod 1 written by PedobearIGER + mod by Weee
Smash "X" to win! Allows you to attack-move weakest champion in desireable range.
Hold "C" for autoCrit. On Twisted Fate hold space.
]]
--[[ Config ]]
hotkey = 88 -- hotkey for autoattacking. 88 - "xXx"
hotkeyCrit = 67 -- hotkey for autocrit. 67 - "cCc"
additionalRange = 300 -- additional range to scan around your champ (your auto-attack range + additionalrange).
--[[ Advanced Config ]]
targetFindRange = 80 -- This is a distance between targeted spell coordinates and your real target's coordinates.
-- When you cast any spell (including autoattacks) processSpellCallback gives you start and finish coordinates.
-- Starting coordinates == player coordinates or close to it.
-- Finish coordinates == your target coordinates.
-- So if you want to let the script know who is your real target - you can check the distance from x2,y2,z2 to each enemy in your game.
-- This script checks if this distance is <= targetFindRange (default: 80). If yes then that enemy is our target.
-- Knowing who is our target lets us to interrupt autoattacks with moving straigth to the target instead of moving to the cursor or to player's own XZ.
--[[ Globals ]]
holdAttack = false
enemies = {}
player = GetMyHero()
--[[ Code ]]
function altDoFile(name)
dofile(debug.getinfo(1).source:sub(debug.getinfo(1).source:find(".*\\")):sub(2)..name)end
altDoFile("libs/target_selector.lua")
ts = TargetSelector:new(TARGET_LOW_HP,player.range + additionalRange,DAMAGE_PHYSICAL)
function GetDistance2D( o1, o2 ) -- Improved GetDistance2D which detects if we're finding distance between 2D objects (x,y) or 3D objects (x,z)
local c = "z"
if o1.z == nil or o2.z == nil then c = "y" end
return math.sqrt(math.pow(o1.x - o2.x, 2) + math.pow(o1[c] - o2[c], 2))
end
function Hotkey( msg, keycode )
if keycode == hotkeyCrit then if msg == KEY_DOWN then holdAttack = true else holdAttack = false end end
if keycode == hotkey and msg == KEY_UP then
ts.range = player.range + additionalRange
ts:tick()
if ts.target ~= nil then player:Attack(ts.target) end
end
end
function SpellTrack(object, spellName, spellLevel, posStart, posEnd)
--if not string.find(string.lower(spellName), "minion") then
-- PrintChat(object.charName..", "..player.charName)
-- end
if holdAttack and object and object.charName == player.charName and string.find(string.lower(spellName), "basicattack") then
local enemyToCrit
for i, enemy in pairs(enemies) do
if enemy and not enemy.dead and enemy.visible and GetDistance2D(enemy,{x=posEnd.x,y=posEnd.y,z=posStart.z}) <= targetFindRange then
enemyToCrit = enemy
end
end
if enemyToCrit == nil then enemyToCrit = player end
player:MoveTo(enemyToCrit.x,enemyToCrit.z)
--player:HoldPosition()
if enemyToCrit ~= player then player:Attack(enemyToCrit) end
end
end
for i=1, heroManager.iCount, 1 do
local playerObj = heroManager:GetHero(i)
if playerObj and playerObj.team ~= player.team then
table.insert(enemies,playerObj)
end
end
if player.charName == "TwistedFate" then hotkeyCrit = 32 end
BoL:addMsgHandler(Hotkey)
BoL:addProcessSpellHandler(SpellTrack)
PrintChat(" >> AutoAttacker! + autoCrit")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment