Code:
--[[
Copyright (c) 2014, Diego Vogogna
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of <addon name> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <your name> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]
_addon.name = 'assistme'
_addon.version = '0.1b'
_addon.author = 'Arshesney (Bahamut)'
_addon.commands = {'assistme'}
require('tables')
require('strings')
config = require('config')
defaults = T{}
defaults.verbose = false
defaults.assist = false
defaults.petassist = true
defaults.follow = false
settings = config.load(defaults)
statuses = {[0]='Idle',[1]='Engaged',[2]='Resting',[3]='Dead',[4]='Zoning'}
pet_command = {['BST']='Fight',['SMN']='Assault',['PUP']='Deploy'}
function initialize()
local player = windower.ffxi.get_player()
if not player then
windower.send_command('@wait 5;lua i '.._addon.name..' initialize')
else
print('AssistMe: CTRL+f follow, ALT+f toggle auto-follow, //assistme help for options.')
windower.send_command('bind ^f send @others /follow '..player.name)
windower.send_command('bind !f '.._addon.name..' follow')
end
end
windower.register_event('load', 'login', initialize)
windower.register_event('logout', 'unload', function()
windower.send_command('unbind ^f')
windower.send_command('unbind !f')
end)
windower.register_event('status change',function(new, old)
local player = windower.ffxi.get_player()
local pet = windower.ffxi.get_mob_by_target('pet')
local new_status = statuses[new]
local old_status = statuses[old]
verbose('status: '..new)
if new_status == 'Engaged' then
--verbose('Entering combat: petassist '..tostring(settings.petassist)..', petcommand '..pet_command[player.main_job])
if settings.petassist and pet and pet_command[player.main_job] then
verbose('Found a pet, sending attack command')
windower.send_command('@wait 1.5; input /ja '..pet_command[player.main_job]..' <t>')
end
if settings.assist then
verbose('Auto assits is true, sending assit and attack command to other instances')
verbose('send @others /assist '..player.name..'; wait 1.5; /attack')
windower.send_command('send @others /assist '..player.name..'; wait 1.5; send @others /a')
end
elseif new_status == 'Idle' and old_status == 'Engaged' and settings.follow then
verbose('Finished combat, sending follow')
windower.send_command('@wait 2.5; send @others /follow '..player.name)
end
end)
windower.register_event('addon command',function(...)
local params = (...)
if params:lower() == 'verbose' or params:lower() == 'debug' then
settings.verbose = not settings.verbose
windower.add_to_chat(121,'AssistMe verbose: '..tostring(settings.verbose))
elseif params:lower() == 'assist' then
settings.assist = not settings.assist
windower.add_to_chat(121,'Assist in combat is now: '..tostring(settings.assist))
elseif params:lower() == 'petassist' then
settings.petassist = not settings.petassist
windower.add_to_chat(121,'Pet auto attack is now: '..tostring(settings.petassist))
elseif params:lower() == 'follow' then
settings.follow = not settings.follow
windower.add_to_chat(121,'Auto-follow is now: '..tostring(settings.follow))
elseif params:lower() == 'show' then
windower.add_to_chat(121,'AssistMe status - Pet: '..tostring(settings.petassist)..', Follow: '..tostring(settings.follow)..', Assist: '..tostring(settings.assist))
elseif params:lower() == 'save' then
settings:save()
windower.add_to_chat(121,_addon.name..' settings saved')
elseif params:lower() == 'help' then
print(' ::: '.._addon.name..' ('.._addon.version..') :::')
print('Commands: ')
print('help --- this text')
print('assist --- toggle engage and attack target (default false)')
print('petassist --- toggle engage and attack target for current pet (default true)')
print('follow --- toggle auto follow (deafult false)')
print('show --- show current settings')
print('save --- save current settings')
end
end)
function verbose(message)
if settings.verbose then
windower.add_to_chat(104,'AssistMe [DEBUG]: '..message)
end
end