Skip to content

Instantly share code, notes, and snippets.

@Acen
Last active July 6, 2018 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Acen/3b8305f8420c0d3ff679 to your computer and use it in GitHub Desktop.
Save Acen/3b8305f8420c0d3ff679 to your computer and use it in GitHub Desktop.
-- Acen's buff/attack macro.
--[[
Key Selection
VK Key list: https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
]]--
-- Activation/Deactivation
Key_Activate = 0xC0 -- ` (~)
-- Skills
Key_Skill1 = 0x10 -- SHIFT
Key_Skill2 = 0x11 -- CTRL
Key_Skill3 = 0x22 -- PAGE DOWN
Key_Skill4 = 0x38 -- 8
Key_Skill5 = 0x37 -- 7
Key_Skill6 = 0x36 -- 6
-- Buffs
Key_Buff1 = 0x77 -- F8
Key_Buff2 = 0x78 -- F9
Key_Buff3 = 0x79 -- F10
-- Potions
Key_HP = 0x24 -- HOME
Key_MP = 0x24 -- HOME
--[[
Cool Downs
]]--
-- Skills
CD_Skill1 = 30000 -- Drill Salvo
CD_Skill2 = 14000 -- Janguar Rampage
CD_Skill3 = 10000 -- Hunting Assistant Unit
CD_Skill4 = 7000 -- Dash 'n Slash
CD_Skill5 = 6000 -- Roar
CD_Skill6 = 5000 -- Swipe
-- Buffs
CD_Buff1 = 150000 -- Macro set 1
CD_Buff2 = 150000 -- Macro set 2
CD_Buff3 = 300000 -- Stand alone Buff 7
--[[
Skill Priority Table
]]--
priority = {
"Buff1",
"Buff2",
"Buff3",
"Skill1",
"Skill2",
"Skill3",
"Skill4",
"Skill5",
"Skill6"
}
--[[
Load time array with each item in priority table.
]]--
time = {} -- Set time variable to be a table/array for holding temporary cooldowns.
for key,value in ipairs(priority) do
time[value] = 0
end
--[[
Function Definitions
changeScriptState(int var)
- Changes activated status.
getScriptState()
- Gets current script status.
useBuff(int id)
- Uses buff, or all buffs as assigned to ID.
clearTime(string name, int timespent)
- Removes cooldowns from items not named.
]]--
function changeScriptState(var)
if(debug ~= 0) then console.println("Script Activated") end
if(var == nil) then
if (var_activated == 1) then
var_activated = 0
return 0
else
var_activated = 1
return 1
end
elseif (var == 1 and var_activated == 0) then
var_activated = 1
return 1
elseif (var == 0 and var_activated == 1) then
var_activated = 0
return 0
end
end
function getScriptState()
if (var_activated == 1) then
return 1
else
return 0
end
end
function useBuff(id) -- useBuff(int id [optional])
if(debug ~= 0) then console.println("Use Buff: " .. id) end
if(id == 1) then
maple.sendkey(Key_Buff1) -- Use Buff 1
time["Buff1"] = CD_Buff1 -- Set Cooldown
std.sleep(3000) -- Time it takes to use buffs
clearTime(3000, "Buff1") -- Remove time from every other CD except buff1.
elseif(id == 2) then
maple.sendkey(Key_Buff2) -- Use Buff 2
time["Buff2"] = CD_Buff2 -- Set Cooldown
std.sleep(3000) -- Time it takes to use buffs
clearTime(3000, "Buff2") -- Remove time from every other CD except buff2.
elseif(id == 3) then
maple.sendkey(Key_Buff3) -- Use Buff 3
time["Buff3"] = CD_Buff3 -- Set Cooldown
std.sleep(1500) -- Time it takes to use buff
clearTime(3000, "Buff3") -- Remove time from every other CD except buff3.
else
useBuff(1)
useBuff(2)
useBuff(3)
end
end
function useSkill(id) -- useSkill(int id [optional])
if(debug ~= 0) then console.println("Use Skill: " .. id) end
if(id == 1) then
maple.sendkey(Key_Skill1) -- Use Skill 1
time["Skill1"] = CD_Skill1 -- Set Cooldown
std.sleep(1500)
clearTime(1500, "Skill1")
elseif(id == 2) then
maple.sendkey(Key_Skill2) -- Use Skill 2
time["Skill2"] = CD_Skill2 -- Set Cooldown
std.sleep(1500)
clearTime(1500, "Skill2")
elseif(id == 3) then
maple.sendkey(Key_Skill3) -- Use Skill 3
time["Skill3"] = CD_Skill3 -- Set Cooldown
std.sleep(1500)
clearTime(1500, "Skill3")
elseif(id == 4) then
maple.sendkey(Key_Skill4) -- Use Skill 4
time["Skill4"] = CD_Skill4 -- Set Cooldown
std.sleep(1500)
clearTime(1500, "Skill4")
elseif(id == 5) then
maple.sendkey(Key_Skill5) -- Use Skill 5
time["Skill5"] = CD_Skill5 -- Set Cooldown
std.sleep(1500)
clearTime(1500, "Skill5")
elseif(id == 6) then
maple.sendkey(Key_Skill6) -- Use Skill 6
time["Skill6"] = CD_Skill6 -- Set Cooldown
std.sleep(1500)
clearTime(1500, "Skill6")
else
console.println('Failed to use skill -- Wrong ID : ' .. id)
end
end
function clearTime(timespent, name) -- clearTime(int timespent, string name [optional])
if(timespent ~= nil and name ~= nil) then -- if both id and timespent are set then
for key,value in spairs(time) do -- for each item in time array
if(key ~= name) then -- check if key is not name
time[key] = value - timespent -- change value minus timespent on action
end
end
elseif(timespent ~= nil) then -- if name not set, check timespent is
for key,value in spairs(time) do -- for each item in time array
time[key] = value - timespent -- change value minus timespent on action
end
end
end
function checkTime(name) -- checkTime(string name [optional])
if(name ~= nil) then -- if name is set
if(time[name] <= 0) then -- check if name in time array is then
return 1 -- return 1
else -- otherwise
return 0 -- return 0
end
else -- if name not set
for k,v in spairs(priority) do
if(time[v] <= 0) then
return v
end
end
--[[
for key,value in spairs(time) do -- for each item in time array
if(value <= 0) then -- check if value is 0 on current item in array
return key -- return name
end
end
]]--
end
end
function spairs(t, order)
local keys = {}
for k in pairs(t) do keys[#keys+1] = k end
if order then
table.sort(keys, function(a,b) return order(t, a, b) end)
else
table.sort(keys)
end
local i = 0
return function()
i = i + 1
if keys[i] then
return keys[i], t[keys[i]]
end
end
end
--[[
On launch hoopla
]]--
local debug = 0
console.alloc() -- Start console
console.println('\nWelcome to Acen\'s terrible buff & skill usage script.')
console.println('---')
console.println('Start bot = ` (~)')
console.println('KILL THE BOT ASLFJALSDFJ = hold F1')
var_activated = 0
--[[
Loop Start
]]--
while true do
if(std.getasynckeystate(0x70)) then
console.println('\n---\nScript Killed -- B-BAKA! It\'s not like I wanted to help you anyway!')
break
end
if(std.getasynckeystate(Key_Activate)) then
changeScriptState()
std.sleep(1000)
end
while(getScriptState() == 1) do
if(std.getasynckeystate(0x70)) then
break
end
for k,v in spairs(priority) do
if(checkTime(v) == 1) then
if(string.match(v, "Buff")) then
useBuff(k)
else
local id = tonumber(string.match(v, "%d+"))
useSkill(id)
end
else
local name = checkTime()
if(name ~= nil) then
if(string.match(name, "Buff")) then
useBuff(tonumber(string.match(name, "%d+")))
else
useSkill(tonumber(string.match(name, "%d+")))
end
else
std.sleep(10)
clearTime(10)
end
if(debug ~= 0) then console.println("Leaving Loop - " .. os.time()) end
break
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment