-------------------------------------------------------------------------------- -- main.lua is part of ZS Shaiya Bot. -- -- ZS Shaiya Bot is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- ZS Shaiya Bot is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with ZS Shaiya Bot. If not, see . -- -- Copyright © 2008 Joshua Langley -------------------------------------------------------------------------------- --g_script_dir = "scripts/zs_shaiya/" g_script_dir = getExecutionPath() .. "/" include("lib/utils.lua") --include("lib/stack.lua") include("constants.lua") --include("classes/fsm.lua") include("classes/avatar_class.lua") include("classes/avatar.lua") include("classes/avatar_actions.lua") include("classes/rgb.lua") include("classes/gui.lua") include("classes/shortcut.lua") include("classes/shortcuts/skill.lua") include("classes/shortcuts/potion.lua") include("classes/hook.lua") include("classes/xml_data.lua") include("functions.lua") g_cfg = nil g_window = nil g_proc = nil g_skills = nil g_install_path = nil function main_interval() write_logs() g_avatar:refresh() if (g_avatar.status == USER_DIED) then --macro_running = false --force_close() return end g_avatar:add_fighting_time(g_cfg.main_interval) g_avatar:check_use_potions() end function macro_init() debug_message("macro_init()") g_cfg = Xml_data:loadConfig(g_xml_file_config) g_skills = Xml_data:loadSkills(g_xml_file_skills) if (args[2] == "vm") then g_install_path = g_cfg.install_path_vm else g_install_path = g_cfg.install_path end g_game_cfg = load_config(g_install_path) g_interface = "INTERFACE_" .. g_game_cfg.VIDEO.SIZE_X .. "X" .. g_game_cfg.VIDEO.SIZE_Y if (g_interface == "INTERFACE_800X600" or g_interface == "INTERFACE_1024X768" or g_interface == "INTERFACE_1280X1024") then debug_message("interface=" .. g_interface) else error("Interface not supported: " .. g_interface .. ", please use a native resolution.") end g_window = init_window(g_cfg.window_name) g_proc = init_process() --init_window() init_process() init_hdc() --attach(get_win()) setPriority(priority.high) keyboardSetDelay(g_cfg.key_delay) -- seed random number generator --debug_message(os.time()) --math.randomseed(os.time()) g_gui = Gui() g_avatar = Avatar() if (g_avatar == AVATAR_ERROR_LOADING) then debug_message(error_init) macro_running = false end l_char_file = g_script_dir .. "char/" .. g_avatar.name .. ".lua" if (exists(l_char_file)) then print("custom character lua file provided.") dofile(l_char_file) end g_avatar_data = Xml_data:loadChar(g_script_dir .. "char/" .. g_avatar.name .. ".xml") if(g_avatar.name == "") then debug_message(error_init) return end --g_avi_class = Avatar_class() g_avatar:set_options(g_avatar_data.options) g_avatar:set_shortcuts(g_avatar_data.shortcuts) g_avatar:set_class(g_avi_class) end ------------------------------------------------- -- FUNCTION MAIN ------------------------------------------------- function main() registerTimer("main_interval", g_cfg.main_interval, main_interval) g_avatar:refresh() init_hdc() math.randomseed(os.time()) while(macro_running) do if (bot_status) then Avatar_class:idle_period() if (g_avatar:cycle_target()) then if (g_avatar.status ~= USER_UNDER_ATTACK) then g_avatar:fight_start() end if (g_avatar:fight_target()) then g_avatar:pickup_items() g_avatar:check_use_rest() end end g_avatar:check_died() end end unregisterTimer("main_interval") end macro_init() startMacro(main)