|  | 
    Barebones Summoner Gearswap
 
    
        
        
        
            
            
                
			
			By Aeyela 2015-09-24 08:13:30			
			
						
                     
                 GitHub: Thanks to Elizabet for hosting this on GitHub
People have been having issues with Mote's SMN Gearswap recently. After lengthy conversations on the topic as well as going through his files, I believe the files themselves are to blame. Several people, evidently myself included, have not had issues with custom SMN Lua files. As a result, and due to several requests, I've decided to post my Lua to provide a viable alternative to Mote's. I make no elaborate claims that this is better (or worse, for that matter), I'm sharing purely so people can try it for themselves.
 
I give my personal guarantee that everything worked 100% at the time of posting, tested numerous times with Abyssea Revitalizers.
 
The inline comments should assist you in setting this up. You'll find it's much simpler than most SMN Luas. With no disrespect meant to people who have helped people out with Gear Swap, I find SMN Luas in particular to be way more complicated than they need to be, often containing dozens of lines of superfluous code.
What this Lua is: What this Lua is not:SimpleDoes not rely on lengthy includes or libraries, which will make it easier to trouble shoot should part of it not be working correctly at some pointCut and paste ready. I've even taken the liberty of not adding gear so you can type yours in quicker
 ComplicatedNirvana ready. I don't and will never own a Nirvana so Aftermaths are moot to me. If enough people want this, I'm happy to add it thoughThe best of the bestest all others suck etc, judge for yourself
 
With that said, here we go. This comes in two files: firstly, global.lua, which contains a list of blood pacts and what not, as well as a couple of my own functions that I use in all my Lua files (like auto style lock, macro books, etc.) The second file is the lua file itself that you'll need to add your equipment to. Be sure to remove blank lines when you're done (ie, hands="".)
 
You can put the global.lua file contents at the start of your SMN.lua file if you prefer, that way you have no includes.
Global.lua: SMN.Lua:Code  function set_macros(sheet,book)
	if book then 
		send_command('@input /macro book '..tostring(book)..';wait .1;input /macro set '..tostring(sheet))
		return
	end
	send_command('@input /macro set '..tostring(sheet))
end
function set_style(sheet)
	send_command('@input /lockstyleset '..sheet)
end
bp_physical=S{'Punch','Rock Throw','Barracuda Dive','Claw','Axe Kick','Shock Strike','Camisado','Regal Scratch','Poison Nails','Moonlit Charge','Crescent Fang','Rock Buster','Tail Whip','Double Punch','Megalith Throw','Double Slap','Eclipse Bite','Mountain Buster','Spinning Dive','Predator Claws','Rush','Chaotic Strike','Crag Throw','Volt Strike'}bp_hybrid=S{'Burning Strike','Flaming Crush'}bp_magical=S{'Inferno','Earthen Fury','Tidal Wave','Aerial Blast','Diamond Dust','Judgment Bolt','Searing Light','Howling Moon','Ruinous Omen','Fire II','Stone II','Water II','Aero II','Blizzard II','Thunder II','Thunderspark','Somnolence','Meteorite','Fire IV','Stone IV','Water IV','Aero IV','Blizzard IV','Thunder IV','Nether Blast','Meteor Strike','Geocrush','Grand Fall','Wind Blade','Heavenly Strike','Thunderstorm','Level ? Holy','Holy Mist','Lunar Bay','Night Terror','Conflag Strike'}bp_debuff=S{'Lunar Cry','Mewing Lullaby','Nightmare','Lunar Roar','Slowga','Ultimate Terror','Sleepga','Eerie Eye','Tidal Roar','Diamond Storm','Shock Squall','Pavor Nocturnus'}bp_buff=S{'Shining Ruby','Frost Armor','Rolling Thunder','Crimson Howl','Lightning Armor','Ecliptic Growl','Hastega','Noctoshield','Ecliptic Howl','Dream Shroud','Earthen Armor','Fleet Wind','Inferno Howl','Soothing Ruby','Heavenward Howl','Soothing Current','Hastega II','Crystal Blessing'}bp_other=S{'Healing Ruby','Raise II','Aerial Armor','Reraise II','Whispering Wind','Glittering Ruby','Earthen Ward','Spring Water','Healing Ruby II'} AvatarList=S{'Shiva','Ramuh','Garuda','Leviathan','Diabolos','Titan','Fenrir','Ifrit','Carbuncle','Fire Spirit','Air Spirit','Ice Spirit','Thunder Spirit','Light Spirit','Dark Spirit','Earth Spirit','Water Spirit','Cait Sith','Alexander','Odin','Atomos'}spirit_element={Fire='Fire Spirit',Earth='Earth Spirit',Water='Water Spirit',Wind='Air Spirit',Ice='Ice Spirit',Lightning='Thunder Spirit',Light='Light Spirit',Dark='Dark Spirit'}spirit_conflict={Fire='Ice',Earth='Lightning',Water='Fire',Wind='Earth',Ice='Wind',Lightning='Water',Light='Dark',Dark='Light'}Code  include('global.lua') -- Just a collection of functions that I use in all my GearSwaps. See below (after this code block)
set_macros(1,2) -- Sheet, Book
function get_sets()
	-- My formatting is very easy to follow. All sets that pertain to my character doing things are under 'me'.
	-- All sets that are equipped to faciliate my avatar's behaviour or abilities are under 'avatar', eg, Perpetuation, Blood Pacts, etc
	
	sets.me = {}
	sets.avatar = {}
	
	-- Your idle set when you DON'T have an avatar out
	sets.me.idle = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-- Your MP Recovered Whilst Resting Set
	sets.me.resting = {	
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-----------------------
	-- Perpetuation Related
	-----------------------
	
	-- Avatar's Out --	
	-- This is the base for all perpetuation scenarios, as seen below
	sets.avatar.perp = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	-- The following sets base off of perpetuation, so you can consider them idle sets.
	-- Set the relevant gear, bearing in mind it will overwrite the perpetuation item for that slot!
	
	-- When we want our avatar to stay alive
	sets.avatar.tank = set_combine(sets.avatar.perp,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- When we want our avatar to shred
	sets.avatar.melee = set_combine(sets.avatar.perp,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- When we want our avatar to hit
	sets.avatar.acc = set_combine(sets.avatar.perp,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- When Avatar's Favori s active
	sets.avatar.favor = set_combine(sets.avatar.perp,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	----------------------------
	-- Summoning Skill Related
	-- Including all blood pacts
	----------------------------
	
	-- + Summoning Magic. This is a base set for max skill and blood pacts and we'll overwrite later as and when we need to
	sets.avatar.skill = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-------------------------
	-- Individual Blood Pacts
	-------------------------
	
	-- Physical damage
	sets.avatar.atk = set_combine(sets.avatar.skill,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Magic Attack
	sets.avatar.mab = set_combine(sets.avatar.skill,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	-- Hybrid
	sets.avatar.hybrid = set_combine(sets.avatar.skill,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Magic Accuracy
	sets.avatar.macc = set_combine(sets.avatar.skill,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Buffs
	sets.avatar.buff = set_combine(sets.avatar.skill,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Other
	sets.avatar.other = set_combine(sets.avatar.skill,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Combat Related Sets
	
	-- Melee
	-- The melee set combines with perpetuation, because we don't want to be losing all our MP whilst we swing our Staff
	-- Anything you equip here will overwrite the perpetuation/refresh in that slot.
	sets.me.melee = set_combine(sets.avatar.perp,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Shattersoul. Weapon Skills do not work off perpetuation as it only stays equipped for a moment
	sets.me["Shattersoul"] = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	sets.me["Garland of Bliss"] = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-- Feel free to add new weapon skills, make sure you spell it the same as in game. These are the only two I ever use though
	---------------
	-- Casting Sets
	---------------
	
	sets.precast = {}
	sets.midcast = {}
	sets.aftercast = {}
	
	----------
	-- Precast
	----------
	
	-- Generic Casting Set that all others take off of. Here you should add all your fast cast	
	sets.precast.casting = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}	
	
	-- Summoning Magic Cast time - gear
	sets.precast.summoning = set_combine(sets.precast.casting,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Enhancing Magic, eg. Siegal Sash, etc
	sets.precast.enhancing = set_combine(sets.precast.casting,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	-- Stoneskin casting time -, works off of enhancing -
	sets.precast.stoneskin = set_combine(sets.precast.enhancing,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Curing Precast, Cure Spell Casting time -
	sets.precast.cure = set_combine(sets.precast.casting,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	---------------------
	-- Ability Precasting
	---------------------
	
	-- Blood Pact Ability Delay
	sets.precast.bp = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-- Mana Cede
	sets.precast["Mana Cede"] = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-- Astral Flow	
	sets.precast["Astral Flow"] = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-- Elemental Siphon, eg, Tatsumaki Thingies, Esper Stone, etc
	sets.precast.siphon = set_combine(sets.avatar.skill,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	----------
	-- Midcast
	----------
	
	-- We handle the damage and etc. in Pet Midcast later
	
	-- Whatever you want to equip mid-cast as a catch all for all spells, and we'll overwrite later for individual spells
	sets.midcast.casting = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-- Enhancing
	sets.midcast.enhancing = set_combine(sets.midcast.casting,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Stoneskin
	sets.midcast.stoneskin = set_combine(sets.midcast.enhancing,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Cure Potency
	sets.midcast.cure = set_combine(sets.midcast.casting,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	------------
	-- Aftercast
	------------
	
	-- I don't use aftercast sets, as we handle what to equip later depending on conditions using a function, eg, do we have an avatar out?
end
function precast(spell)
	-- Don't swap if we're in the middle of something or our pet's doing something
	-- Stops macro spam from interfering with an action GS is already handling
    if midaction() or pet_midaction() then
        return
    end
	
	-- If we're doing a blood pact, equip our delay set IF Apogee or Astral Conduit are not active
    if (spell.type == 'BloodPactRage' or spell.type == 'BloodPactWard') and not (buffactive['Astral Conduit'] or buffactive['Apogee']) then
	
        equip(sets.precast.bp)
		
    elseif spell.type == 'SummonerPact' then
	
		-- This chunk of code handles Elemental Siphon. It will look at the current day and weather and cancel the spell to summon
		-- the right elemental. Your elemental siphon macro should summon a Dark Spirit to trigger this check
		
		-- These use the included lists in global.lua to determine the right spirit to summon
			
        if spell.name == 'Dark Spirit' then
            if world.weather_element == 'Dark' then
			
				-- Dark Weather is active, lets the spell go ahead and equips summoning precast
                equip(sets.precast.summoning)
				
			elseif world.weather_element ~= 'None' and spirit_conflict[world.day_element] ~= world.weather_element then
			
				-- It's not dark weather but there is some weather up, cancels dark and summons the right spirit
                cancel_spell()
                send_command('input /ma "%s" <me>':format(spirit_element[world.weather_element]))
				equip(sets.precast.summoning)
				
            elseif world.day_element == 'Dark' then
			
				-- It's darksday so allow the dark spirit to go ahead and equip summoning
                equip(sets.precast.summoning)
				
            else
			
				-- There is no weather up and it's not darksday, so summon the current day's spirit
                cancel_spell()				
                send_command('input /ma "%s" <me>':format(spirit_element[world.day_element]))
				equip(sets.precast.summoning)
				
            end
		else
		
			-- We're not summoning Dark Spirit, so we don't want to Siphon, which means we're summoning an avatar
			equip(sets.precast.summoning)
			
		end
		
	-- Moving on to other types of magic
	elseif spell.type == 'WhiteMagic' or spell.type == 'BlackMagic' then
	
		-- Stoneskin Precast
        if spell.name == 'Stoneskin' then
		
            windower.ffxi.cancel_buff(37)--[[Cancels stoneskin, not delayed incase you get a Quick Cast]]
            equip(sets.precast.stoneskin)
			
		-- Cure Precast
        elseif spell.name:match('Cure') or spell.name:match('Cura') then
		
            equip(sets.precast.cure)
			
		-- Enhancing Magic
        elseif spell.skill == 'Enhancing Magic' then
		
            equip(sets.precast.enhancing)
			
            if spell.name == 'Sneak' then
                windower.ffxi.cancel_buff(71)--[[Cancels Sneak]]
            end
        else
		
			-- For everything else we go with max fastcast
            equip(sets.precast.casting)
			
        end
		
	-- Summoner Abilities
	-- We use a catch all here, if the set exists for an ability, use it
	-- This way we don't need to write a load of different code for different abilities, just make a set
	
	elseif sets.precast[spell.name] then
        equip(sets.precast[spell.name])
    end
	
end
function midcast(spell)
	-- If our pet is doing something, prevents us swapping equipment too early
    if pet_midaction() then
        return
    end
	
	-- No need to annotate all this, it's fairly logical. Just equips the relevant sets for the relevant magic
	if spell.type == 'WhiteMagic' or spell.type == 'BlackMagic' then
        if spell.name == 'Stoneskin' then
            equip(sets.midcast.stoneskin)
        elseif spell.name:match('Cure') or spell.name:match('Cura') then
            equip(sets.midcast.cure)
        elseif spell.skill == 'Enhancing Magic' then
            equip(sets.midcast.enhancing)
			if spell.name:match('Protect') or spell.name:match('Shell') then
				equip({rring="Sheltered Ring"})
            end
        else
            equip(sets.midcast.casting)
        end
    elseif spell.name == 'Elemental Siphon' then
	
		-- Siphon Set
        equip(sets.precast.siphon)
		
		-- Checks if pet matches weather
        if pet.element == world.weather_element then
            equip(sets.precast.siphon,{main="Chatoyant Staff"--[[Take advantage of the weather boost]]})
		end
		
	-- And our catch all, if a set exists for this spell use it
	elseif sets.midcast[spell.name] then
		equip(sets.midcast[spell.name])
		
	-- Remember those WS Sets we defined? :)
	elseif sets.me[spell.name] then
		equip(sets.me[spell.name])
	end
end
function aftercast(spell)
	-- If our pet's doing something, Stop!
    if pet_midaction() then
        return
    end	
	
	-- If not a blood pact or summon
	if spell and (not spell.type or not string.find(spell.type,'BloodPact') and not AvatarList:contains(spell.name) or spell.interrupted) then
	
		-- Then initiate idle function to check which set should be equipped
		idle(pet)
		
	end
end
function pet_midcast(spell)
	-- Our pet is doing something
    if (spell.type == 'BloodPactRage' or spell.type == 'BloodPactWard') then
	
		-- We're going to check the lists in global.lua for matches and equip the relevant sets
		
		if bp_physical:contains(spell.name) then
		
            equip(sets.avatar.atk)
			
        elseif bp_hybrid:contains(spell.name) then
		
            equip(sets.avatar.hybrid)
			if pet.name == 'Ifrit' then
				equip({rring="Fervor Ring"})--[[Change rring to lring if you put Evoker's on your right hand]]
			end
			
        elseif bp_magical:contains(spell.name) then
		
			equip(sets.avatar.mab)
			if pet.name == 'Ifrit' then
				equip({rring="Fervor Ring"})--[[Change rring to lring if you put Evoker's on your right hand]]
			end
		elseif bp_debuff:contains(spell.name) then
		
            equip(sets.avatar.macc)
			
        elseif bp_buff:contains(spell.name) then
		
            equip(sets.avatar.buff)
			
        elseif bp_other:contains(spell.name) then
		
            equip(sets.avatar.other)
			
        elseif spell.name == 'Perfect Defense' then
		
			equip(sets.avatar.skill)
			
		else
		
			equip(sets.avatar.skill)
			
		end
	end	
end
function pet_aftercast(spell)
	
	-- Pet aftercast is simply a check for whether Conduit and Apogee are up, and then a call to our aftercast function
	-- We have a variable called autobp that we set to true or false with commands to auto repeat BPs for us
    if (buffactive['Apogee'] or buffactive['Astral Conduit']) and autobp then
        send_command('input /pet "%s" <t>':format(spell.name))
		return
	end
	
	idle(pet)
	
end
function idle(pet)
	-- This function is called after every action, and handles which set to equip depending on what we're doing
	-- We check if we're meleeing because we don't want to idle in melee gear when we're only engaged for trusts
	
	if favor then
	
		-- Avatar's favor takes priority!
		equip(sets.avatar.favor)
		
	elseif meleeing and player.status=='Engaged' then
	
		-- We're both engaged and meleeing
		equip(sets.me.melee)
		
	elseif pet.isvalid then
		
		-- We have a pet out but we're not meleeing, set the right idle set
		equip(sets.avatar[mode])
	else
	
		-- We're not meleeing and we have no pet out
		equip(sets.me.idle)
		
	end
end
function status_change(new,old)
    if new == 'Engaged' then
	
		-- If we engage check our meleeing status
		idle(pet)
		
	elseif new=='Resting' then
	
		-- We're resting
        equip(sets.me.resting)
	else
		idle(pet)
	end
end
function pet_change(pet,gain)
	-- When we summon or release an avatar
    idle(pet)
end
function self_command(command)
	local commandArgs = command
	
	-- This command takes //gs c avatar mode, where mode is what you want, eg, tank, acc, melee, etc
    if #commandArgs:split(' ') >= 2 then
        commandArgs = T(commandArgs:split(' '))
		if commandArgs[1] == 'avatar' then
			if commandArgs[2] then
				mode = tostring(commandArgs[2])
				equip(sets.avatar[mode])
				windower.add_to_chat(8,'----- Avatar set to '..mode..' mode! -----')
			end
		elseif commandArgs[1] == 'toggle' then
			if commandArgs[2] == 'auto' then
			
				-- //gs c toggle auto will toggle auto blood pacts on and off. Auto blood pact will make your GS repeat BPs under Apogee or Conduit
				-- And by repeat I mean repeat. If Conduit is up, it will SPAM the BP until Conduit is down
				if autobp then
					autobp = false
					windower.add_to_chat(8,'----- Auto BP mode Disabled -----')
				else
					autobp = true
					windower.add_to_chat(8,'----- Auto BP mode Enabled -----')
				end
			elseif commandArgs[2] == 'melee' then
			
				-- //gs c toggle melee will toggle melee mode on and off.
				-- This basically locks the slots that will cause you to lose TP if changing them,
				-- As well as equip your melee set if you're engaged
				if meleeing then
					meleeing = false
					enable('main','sub','ranged')
					windower.add_to_chat(8,'----- Weapons Unlocked, WILL LOSE TP -----')
					idle(pet)
				else
					meleeing=true
					disable('main','sub','ranged')
					windower.add_to_chat(8,'----- Weapons Locked, WILL NOT LOSE TP -----')
					idle(pet)
				end
				
			elseif commandArgs[2] == 'favor' then
					
				-- //gs c toggle favor will toggle Favor mode on and off.
				-- It won't automatically toggle, as some people like having favor active without the gear swaps for maximum effectiveness
				-- You need to toggle prioritisation yourself
				if favor then
					favor = false
					windower.add_to_chat(8,"----- Avatar's Favor Mode OFF -----")
				else
					favor = true
					windower.add_to_chat(8,"----- Avatar's Favor Mode ON -----")
				end
				
			end
		end
	end
end
-- Required variables and their initial value
meleeing = false
autobp = false
favor = false
mode = "perp"
Here's a run down on commands:
//gs c avatar [mode] 
Replace [mode] with either: perp, tank, melee, acc to set your avatar's idling equipment to a particular setup. Perp is for maximum perp- and refresh, tank for tanking, melee for doing maximum physical damage and acc for accuracy.
//gs c toggle melee 
This will toggle your character between melee mode. Initially set to false, enabling this will idle to your melee set when engaged as well as disable slots that changing items in would remove TP. With this turned off being engaged will not equip your melee gear, so you can stay engaged for the purposes of trusts whilst keeping your relevant perpetuation gear on.
//gs c toggle auto 
Initially turned off, using this command will toggle auto blood pacts on Apogee and Conduit. By auto I literally mean auto. Using a blood pact with this on will use it again instantly if you have Apogee or Conduit up. If you have Conduit up, your character will spam abilities until you either toggle this off or Conduit drops.
//gs c toggle favor 
Initially turned off, this command will toggle your character into favor prioritisation mode. This means that, with this on, Avatar's Favor set will override other idle sets, including melee. Using Avatar's Favor will not  toggle this automatically. One particular problem with lots of Luas is this assumption is made, and most end users don't know how to disable it.
 
There are times and places we want maximum Favor power, and they are quite limited. You be the judge and set this yourself when you want it.
 
--
 
If you have any questions or problems, please reply and I'll try and help.                                             
            
            
                
			
			By Elizabet 2015-09-24 08:21:10			
			
						
                     
                 Here's my version  based off the above by Aeyela.
Features: 
All the nifty things in the OP. 
Includes all the bug fixes found in the thread previously. 
Keybind and support for cycling through avatar modes with 1 key. 
Keybind for toggling autoBP 
Keybind for toggling melee weapon lock 
Avatar-agnostic Blood Pacts handling. (need the shortcuts add-on)
 
Now on github: https://github.com/Tunaliz/Liz_Gearswaps 
            
            
                
			
			By Elizabet 2015-09-24 11:11:38			
			
						
                     
                 After playing with it. It does works flawlessly. 
However, I managed to break it! 
 
In self_command() function under the part you handle toggle for favor I added: Code  
-- Handles executing blood pacts in a generic, avatar-agnostic way.		
elseif commandArgs[1]:lower() == 'pact' then
handle_pacts(commandArgs)
        end
So when I was using a vanilla macro all was good... then once I was calling the handle_pacts function spamming the //gs c pact macro.. it was not working... as in it had the same problem I had before.
 
Funny thing is, I tried swapping the actual handle_pacts function code in the self_command() function it self. And now its back to working flawlessly...
 
I think the issue all this time was just that. Functions within within the self_command function might just not be reliable enough.
 
Thanks for the base lua! Now I am back to having something that works all the time yet I can still cast my BP using a macro with the following: 
to cast the lvl 70 blood pact of which ever avatar I happen to have summoned.                                     
            
            
                
			
			By Aeyela 2015-09-24 11:28:15			
			
						
                     
                 Where is the handle_pacts function you're trying to call? It's not in either of the files I posted so without including its source file it won't work - unless it's a native GS function which, looking through the documentation, it's doesn't seem like it. If it's a remnant of Mote's you'll either need to transfer the applicable function over or stop using it.
 I'd encourage you to just directly use /pet "Whatever" <t> as your macros, rather than adding a handler for it, or indeed using console commands. The Lua is tailored to work for any blood pact you put in and use the relevant gear sets, both for delay and effectiveness. This self command way of blood pacting is the over complication I'm trying to avoid. :)
 
            
            
                
			
			By Elizabet 2015-09-24 11:39:53			
			
						
                     
                 I had the handle_pacts function just under the self_command function in the SMN.lua file. It's not mote's stuff.
 I added that part in because I want to find exactly where the issue is. And the only way I found using your lua as a base, that wasn't working was, when I was calling a function within the self_command.
 
 However, removing that function but making it a part of the actual self_command function fixed the issue. Which leads me to believe that the issue is not with the function's code itself (since the same code works when its part of the self_command function), nor because a BP was trigerred in a non vanilla way... But that functions within functions might be a risky business when it comes to the self_commands...
 
 In the end, I'm not sure yet if I'll keep with console macros or vanilla macros... The difference is about 7 pages of macro space saved haha. But I am glad it's finally working properly.
 
            
            
                
			
			By Aeyela 2015-09-24 11:45:26			
			
						
                     
                 I had the handle_pacts function just under the self_command function in the SMN.lua file. It's not mote's stuff.
 I added that part in because I want to find exactly where the issue is. And the only way I found using your lua as a base, that wasn't working was, when I was calling a function within the self_command.
 
 However, removing that function but making it a part of the actual self_command function fixed the issue. Which leads me to believe that the issue is not with the function's code itself (since the same code works when its part of the self_command function), nor because a BP was trigerred in a non vanilla way... But that functions within functions might be a risky business.
 
 In the end, I'm not sure yet if I'll keep with console macros or vanilla macros... The difference is about 7 pages of macro space saved haha. But I am glad it's finally working properly.
One way of getting around this is to combine macros. Now that you have no reason to have gear sets or swaps in macros (as the Lua does it for you) you can merge them all into one macro. I'll concede that 6 lines is not enough for everything, but for my general use it's good enough. I don't often use Summoner in anything that requires me not to just destroy things.
 
For example, you could make Control + 1 an 'Attack' macro that goes as follows:
 
/pet "Flaming Crush" <me> 
/pet "Volt Strike" <me> 
/pet "Spinning Dive" <me> 
/pet "Predator Claws" <me> 
/ etc...
 
Pressing the macro will insert every one into your log at once, with only the currently active pet obviously activating a blood pact. This way you can throw lots of pet's moves onto one macro and still benefit from Gear Swapping, since it'll handle it on a blood pact by blood pact basis, rather than macros.                                     
            
            
                
			
			By Draylo 2015-09-26 13:29:41			
			
						
                     
                 Did anyone ever find out what happened to Mote lol                                     
            
                
                     Leviathan.Alvar
                                                    
                                                                            
                                Server: Leviathan Game: FFXI 
                
			
			By Leviathan.Alvar 2015-09-26 15:25:10			
			
						
                     
                 Did anyone ever find out what happened to Mote lolFFXIV :o                                     
            
            
                
			
			By Aeyela 2015-09-26 15:43:20			
			
						
                     
                 
Hey, whoa, don't say that around here. You trying to start a rumble?!                                     
            
                
                     Leviathan.Alvar
                                                    
                                                                            
                                Server: Leviathan Game: FFXI 
                
			
			By Leviathan.Alvar 2015-09-26 16:04:35			
			
						
                     
                 
Hey, whoa, don't say that around here. You trying to start a rumble?!FFXI > FFXIV all day bby.                                             
                    [+]
                                              
            
                
                    
                    
                    
                                                            
                                                    
                                                                            
                                Server: Bahamut Game: FFXI Posts: 879 
                
			
			By Bahamut.Seekerstar 2015-09-27 00:10:24			
			
						
                     
                 I'm trying to get this to work, and I'm getting an error: cannot find include file, global.lua.
 Whatever that is. :P
 
 
 I did manage to put my gear in the appropriate locations, I assume, and I think I know how to differentiate augmented gear now. I just need to clear this error.
 
            
            
                
			
			By Elizabet 2015-09-27 01:25:10			
			
						
                     
                 Bahamut.Seekerstar said: »I'm trying to get this to work, and I'm getting an error: cannot find include file, global.lua.
 Whatever that is. :P
 
 
 I did manage to put my gear in the appropriate locations, I assume, and I think I know how to differentiate augmented gear now. I just need to clear this error.
Check the OP, there is 2 files you need, the SMN.lua and the Global.lua both are in the OP each in a spoiler tag.                                     
            
                
                    
                    
                    
                                                            
                                                    
                                                                            
                                Server: Bahamut Game: FFXI Posts: 879 
                
			
			By Bahamut.Seekerstar 2015-09-27 01:36:09			
			
						
                     
                 Do I put the global file separately into data? 
Sorry, I have like no idea what I'm doing.
 
I also keep getting yuck errors at about line 74 or so and I don't know why.
 Code  function set_macros(sheet,book)
    if book then 
        send_command('@input /macro book '..tostring(book)..';wait .1;input /macro set '..tostring(sheet))
        return
    end
    send_command('@input /macro set '..tostring(sheet))
end
 
function set_style(sheet)
    send_command('@input /lockstyleset '..sheet)
end
 
bp_physical=S{'Punch','Rock Throw','Barracuda Dive','Claw','Axe Kick','Shock Strike','Camisado','Regal Scratch','Poison Nails','Moonlit Charge','Crescent Fang','Rock Buster','Tail Whip','Double Punch','Megalith Throw','Double Slap','Eclipse Bite','Mountain Buster','Spinning Dive','Predator Claws','Rush','Chaotic Strike','Crag Throw','Volt Strike'}bp_hybrid=S{'Burning Strike','Flaming Crush'}bp_magical=S{'Inferno','Earthen Fury','Tidal Wave','Aerial Blast','Diamond Dust','Judgment Bolt','Searing Light','Howling Moon','Ruinous Omen','Fire II','Stone II','Water II','Aero II','Blizzard II','Thunder II','Thunderspark','Somnolence','Meteorite','Fire IV','Stone IV','Water IV','Aero IV','Blizzard IV','Thunder IV','Nether Blast','Meteor Strike','Geocrush','Grand Fall','Wind Blade','Heavenly Strike','Thunderstorm','Level ? Holy','Holy Mist','Lunar Bay','Night Terror','Conflagration Strike'}bp_debuff=S{'Lunar Cry','Mewing Lullaby','Nightmare','Lunar Roar','Slowga','Ultimate Terror','Sleepga','Eerie Eye','Tidal Roar','Diamond Storm','Shock Squall','Pavor Nocturnus'}bp_buff=S{'Shining Ruby','Frost Armor','Rolling Thunder','Crimson Howl','Lightning Armor','Ecliptic Growl','Hastega','Noctoshield','Ecliptic Howl','Dream Shroud','Earthen Armor','Fleet Wind','Inferno Howl','Soothing Ruby','Heavenward Howl','Soothing Current','Hastega II','Crystal Blessing'}bp_other=S{'Healing Ruby','Raise II','Aerial Armor','Reraise II','Whispering Wind','Glittering Ruby','Earthen Ward','Spring Water','Healing Ruby II'} AvatarList=S{'Shiva','Ramuh','Garuda','Leviathan','Diabolos','Titan','Fenrir','Ifrit','Carbuncle','Fire Spirit','Air Spirit','Ice Spirit','Thunder Spirit','Light Spirit','Dark Spirit','Earth Spirit','Water Spirit','Cait Sith','Alexander','Odin','Atomos'}spirit_element={Fire='Fire Spirit',Earth='Earth Spirit',Water='Water Spirit',Wind='Air Spirit',Ice='Ice Spirit',Lightning='Thunder Spirit',Light='Light Spirit',Dark='Dark Spirit'}spirit_conflict={Fire='Ice',Earth='Lightning',Water='Fire',Wind='Earth',Ice='Wind',Lightning='Water',Light='Dark',Dark='Light'}
include('global.lua') -- Just a collection of functions that I use in all my GearSwaps. See below (after this code block)
 
set_macros(1,2) -- Sheet, Book
 
function get_sets()
 
    -- My formatting is very easy to follow. All sets that pertain to my character doing things are under 'me'.
    -- All sets that are equipped to faciliate my avatar's behaviour or abilities are under 'avatar', eg, Perpetuation, Blood Pacts, etc
     
    sets.me = {}
    sets.avatar = {}
     
    -- Your idle set when you DON'T have an avatar out
    sets.me.idle = {
        main="Gridarvor",
        sub="Vox Grip",
        ammo="Seraphicaller",
        head="Convoker's Horn +1",
        neck="Caller's Pendant",
        lear="Caller's Earring",
        rear="Moonshade Earring",
        body="Shomonjijoe +1",
        hands="Asteria Mitts",
        lring="Fervor Ring",
        rring="Evoker's Ring",
        back="Cheviot Cape",
        waist="Lucidity Sash",
        legs="Assiduity Pants",
        feet="Convoker's Pigaches +1"
    }
     
    -- Your MP Recovered Whilst Resting Set
    sets.me.resting = { 
        main="Bolelabunga",
        sub="Genbu's Shield",
        ammo="Seraphicaller",
        head="Beckoner's Horn +1",
        neck="Twilight Torque",
        lear="Moonshade Earring",
        rear="Ethereal Earring",
        body="Shomonjijoe +1",
        hands="Asteria Mitts",
        lring="Defending Ring",
        rring="Dark Ring",
        back="Cheviot Cape",
        waist="Flax Sash",
        legs="Assiduity Pants",
        feet="Herald's Gaiters"
    }
     
    -----------------------
    -- Perpetuation Related
    -----------------------
     
    -- Avatar's Out --  
    -- This is the base for all perpetuation scenarios, as seen below
    sets.avatar.perp = {
        main="Gridarvor",
        sub="Vox Grip",
        ammo="Seraphicaller",
        head="Beckoner's Horn +1",
        neck="Caller's Pendant",
        lear="Handler's Earring",
        rear="Rimeice Earring",
        body="Beckoner's Doublet +1",
        hands="Asteria Mitts",
        lring="Evoker's Ring",
        rring="Thurundaut Ring",
        back= {name="Conveyance Cape", augments={'Summoning Magic Skill +5', 'Blood Pact Damage +4', 'Pet: Enmity +12'}}
        waist="Moepapa Stone",
        legs="Assiduity Pants",
        feet="Beckoner's Pigaches"
		
    }
 
    -- The following sets base off of perpetuation, so you can consider them idle sets.
    -- Set the relevant gear, bearing in mind it will overwrite the perpetuation item for that slot!
     
    -- When we want our avatar to stay alive
    sets.avatar.tank = set_combine(sets.avatar.perp,{
        main= {name="Espiritus", augments={'Summoning Magic Skill +15', 'Pet: Magic Accuracy +30', 'Pet: Damage Taken -4%'}}
        sub="Vox Grip",
        ammo="Seraphicaller",
        head="Helios Band",
        neck="Caller's Pendant",
        lear="Handler's Earring",
        rear="Rimeice Earring",
        body="Shomonjijoe +1",
        hands="Glyphic Bracers +1",
        lring="Evoker's Ring",
        rring="Thurundaut Ring",
        back= {name="Conveyance Cape", augments={'Summoning Magic Skill +5', 'Blood Pact Damage +4', 'Pet: Enmity +12'}}
        waist="Moepapa Stone",
        legs="Psycloth Lappas",
        feet="Convoker's Pigaches +1"
    })
     
    -- When we want our avatar to shred
    sets.avatar.melee = set_combine(sets.avatar.perp,{
        main="Gridarvor",
        sub="Vox Grip",
        ammo="Seraphicaller",
        head="Helios Band",
        neck="Caller's Pendant",
        lear="Domesticator's Earring",
        rear="Rimeice Earring",
        body="Glyphic Doublet +1",
        hands="Regimen Mittens",
        lring="Evoker's Ring",
        rring="Thurundaut Ring",
        back= {name="Conveyance Cape", augments={'Summoning Magic Skill +5', 'Blood Pact Damage +4', 'Pet: Enmity +12'}}
        waist="Moepapa Stone",
        legs="Enticer's Pants",
        feet="Psycloth Boots"
    })
     
    -- When we want our avatar to hit
    sets.avatar.acc = set_combine(sets.avatar.perp,{
        main="Gridarvor",
        sub="Vox Grip",
        ammo="Seraphicaller",
        head="Convoker's Horn +1",
        neck="Caller's Pendant",
        lear="Summoning Earring",
        rear="Andoaa Earring",
        body="Glyphic Doublet +1",
        hands="Glyphic Bracers +1",
        lring="Thurundaut Ring",
        rring="Evoker's Ring",
        back= {name="Conveyance Cape", augments={'Summoning Magic Skill +5', 'Blood Pact Damage +4', 'Pet: Enmity +12'}}
        waist="Lucidity Sash",
        legs="Enticer's Pants",
		})
     
    -- When Avatar's Favori s active
    sets.avatar.favor = set_combine(sets.avatar.perp,{
        main="Gridarvor",
        sub="Vox Grip",
        ammo="Seraphicaller",
        head="Beckoner's Horn +1",
        neck="Caller's Pendant",
        lear="Summoning Earring",
        rear="Andoaa Earring",
        body="Beckoner's Doublet +1",
        hands="Asteria Mitts",
        lring="Evoker's Ring",
        rring="Fervor Ring",
        back= {name="Conveyance Cape", augments={'Summoning Magic Skill +5', 'Blood Pact Damage +4', 'Pet: Enmity +12'}}
        waist="Lucidity Sash",
        legs="Beckoner's Spats +1",
        feet="Beckoner's Pigaches"
    })
     
    ----------------------------
    -- Summoning Skill Related
    -- Including all blood pacts
    ----------------------------
     
    -- + Summoning Magic. This is a base set for max skill and blood pacts and we'll overwrite later as and when we need to
    sets.avatar.skill = {
        main= {name="Espiritus", augments={'Summoning Magic Skill +15', 'Pet: Magic Accuracy +30', 'Pet: Damage Taken -4%'}}
        sub="Vox Grip",
        ammo="Seraphicaller",
        head="Convoker's Horn +1",
        neck="Caller's Pendant",
        lear="Summoning Earring",
        rear="Andoaa Earring",
        body="Beckoner's Doublet +1",
        hands="Lammasu Mitts",
        lring="Evoker's Ring",
        rring="Fervor Ring",
        back= {name="Conveyance Cape", augments={'Summoning Magic Skill +5', 'Blood Pact Damage +4', 'Pet: Enmity +12'}}
        waist="Lucidity Sash",
        legs="Beckoner's Spats +1",
        feet="Nashira Crackows"
    }
     
    -------------------------
    -- Individual Blood Pacts
    -------------------------
     
    -- Physical damage
    sets.avatar.atk = set_combine(sets.avatar.skill,{
        main="Gridarvor",
        sub="Vox Grip",
        ammo="Seraphicaller",
        head="Psycloth Tiara",
        neck="Sacrifice Torque",
        lear="Rimeice Earring",
        rear="Gelos Earring",
        body="Convoker's Doublet +1",
        hands="Apogee Mitts",
        lring="Thurundaut Ring",
        rring="Evoker's Ring",
        back= {name="Conveyance Cape", augments={'Summoning Magic Skill +5', 'Blood Pact Damage +4', 'Pet: Enmity +12'}}
        waist="Mujin Obi",
        legs="Enticer's Pants",
        feet="Glyphic Pigaches +1"
    })
     
    -- Magic Attack
    sets.avatar.mab = set_combine(sets.avatar.skill,{
        main={name="Espiritus", augments={'MP +50', 'Pet: "Magic Attack Bonus" +20', 'Pet: Magic Accuracy +20'}}
        sub="Vox Grip",
        ammo="Seraphicaller",
        head="Psycloth Tiara",
        neck="Eidolon Pendant +1",
        lear="Gelos Earring",
        rear="Andoaa Earring",
        body="Shomonjijoe +1",
        hands="Apogee Mitts",
        lring="Thurundaut Ring",
        rring="Evoker's Ring",
        back= {name="Conveyance Cape", augments={'Summoning Magic Skill +5', 'Blood Pact Damage +4', 'Pet: Enmity +12'}}
        waist="Caller's Sash",
        legs="Helios Spats",
        feet="Hagondes Sabots +1"
    })
 
    -- Hybrid
    sets.avatar.hybrid = set_combine(sets.avatar.skill,{
        main= {name="Espiritus", augments={'MP +50', 'Pet: "Magic Attack Bonus" +20', 'Pet: Magic Accuracy +20'}}
        sub="Vox Grip",
        ammo="Seraphicaller",
        head="Psycloth Tiara",
        neck="Eidolon Pendant +1",
        lear="Gelos Earring",
        rear="Rimeice Earring",
        body="Shomonjijoe +1",
        hands="Asteria Mitts",
        lring="Fervor Ring",
        rring="Thurundaut Ring",
        back= {name="Conveyance Cape", augments={'Summoning Magic Skill +5', 'Blood Pact Damage +4', 'Pet: Enmity +12'}}
        waist="Caller's Sash",
        legs="Apogee Slacks",
        feet="Psycloth Boots"
    })
     
    -- Magic Accuracy
    sets.avatar.macc = set_combine(sets.avatar.skill,{
        main= {name="Espiritus", augments={'Summoning Magic Skill +15', 'Pet: Magic Accuracy +30', 'Pet: Damage Taken -4%'}}
        sub="Vox Grip",
        ammo="Seraphicaller",
        head="Convoker's Horn +1",
        neck="Caller's Pendant",
        lear="Andoaa Earring",
        rear="Summoning Earring",
        body="Beckoner's Doublet +1",
        hands="Lammasu Mitts",
        lring="Fervor Ring",
        rring="Evoker's Ring",
        back= {name="Conveyance Cape", augments={'Summoning Magic Skill +5', 'Blood Pact Damage +4', 'Pet: Enmity +12'}}
        waist="Lucidity Sash",
        legs="Enticer's Pants",
        feet="Beckoner's Pigaches"
    })
     
    -- Buffs
    sets.avatar.buff = set_combine(sets.avatar.skill,{
        main= {name="Espiritus", augments={'Summoning Magic Skill +15', 'Pet: Magic Accuracy +30', 'Pet: Damage Taken -4%'}}
        sub="Vox Grip",
        ammo="Seraphicaller",
        head="Convoker's Horn +1",
        neck="Caller's Pendant",
        lear="Andoaa Earring",
        rear="Summoning Earring",
        body="Beckoner's Doublet +1",
        hands="Lammasu Mitts",
        lring="Fervor Ring",
        rring="Evoker's Ring",
        back= 
		{name="Conveyance Cape", augments={'Summoning Magic Skill +5', 'Blood Pact Damage +4', 'Pet: Enmity +12'}}
        waist="Lucidity Sash",
        legs="Enticer's Pants",
        feet="Beckoner's Pigaches"
    })
     
     
    -- Combat Related Sets
     
    -- Melee
    -- The melee set combines with perpetuation, because we don't want to be losing all our MP whilst we swing our Staff
    -- Anything you equip here will overwrite the perpetuation/refresh in that slot.
    sets.me.melee = set_combine(sets.avatar.perp,{
        main="Gridarvor",
        sub="Vox Grip",
        ammo="Seraphicaller",
        head="Convoker's Horn +1",
        neck="Asperity Necklace",
        lear="Zennaroi Earring",
        rear="Steelflash Earring",
        body="Beckoner's Doublet +1",
        hands="Asteria Mitts",
        lring="Ramuh Ring +1",
        rring="Rajas Ring",
        back= {name="Conveyance Cape", augments={'Summoning Magic Skill +5', 'Blood Pact Damage +4', 'Pet: Enmity +12'}}
        waist="Chaac Belt",
        legs="Enticer's Pants",
        feet="Beckoner's Pigaches"
    })
     
    ---------------
    -- Casting Sets
    ---------------
     
    sets.precast = {}
    sets.midcast = {}
    sets.aftercast = {}
     
    ----------
    -- Precast
    ----------
     
    -- Generic Casting Set that all others take off of. Here you should add all your fast cast  
    sets.precast.casting = {
        main="Gridarvor",
        sub="Vox Grip",
        ammo="Sapience Orb",
        head="Natirah Hat",
        neck="Twilight Torque",
        lear="Loquacious Earring",
        rear="Eabani Earring",
        body="Anhur Robe",
        hands="Asteria Mitts",
        lring="Prolix Ring",
        rring="Defending Ring",
        back="Swith Cape",
        waist="Sailfi Belt",
        legs="Lengo Trousers",
        feet="Regal Pumps"
    }   
     
    ---------------------
    -- Ability Precasting
    ---------------------
     
    -- Blood Pact Ability Delay
    sets.precast.bp = {
        main= "{name="Espiritus", augments={'Summoning Magic Skill +15', 'Pet: Magic Accuracy +30', 'Pet: Damage Taken -4%'}}
        sub="Vox Grip",
        ammo="Seraphicaller",
        head="Convoker's Horn +1",
        neck="Caller's Pendant",
        lear="Caller's Earring",
        rear="Summoning Earring",
        body="Glyphic Doublet +1",
        hands="Glyphic Bracers +1",
        lring="Evoker's Ring",
        rring="Thurundaut Ring",
        back= {name="Conveyance Cape", augments={'Summoning Magic Skill +2', 'Blood Pact Damage +3', 'Blood Pact Ability Delay II -2', 'Pet: Enmity +14'}}
        waist="Lucidity Sash",
        legs="Glyphic Spats +1",
        feet="Glyphic Pigaches +1"
    }
     
    -- Mana Cede
    sets.precast["Mana Cede"] = {
        hands="Beckoner's Bracers",
    }
     
    -- Astral Flow  
    sets.precast["Astral Flow"] = {
        head="Glyphic Horn +1",
     
    }
     
    -- Elemental Siphon, eg, Tatsumaki Thingies, Esper Stone, etc
	
    sets.precast["Elemental Siphon"] = {
        main="Keraunos",
        sub="Vox Grip",
        ammo="Esper Stone",
        head="Telchine Cap",
        neck="Caller's Pendant",
        lear="Andoaa Earring",
        rear="Summoning Earring",
        body="Telchine Chasuble",
        hands="Telchine Gloves",
        lring="Fervor Ring",
        rring="Evoker's Ring",
        back= {name="Conveyance Cape", augments={'Summoning Magic Skill +5', 'Blood Pact Damage +4', 'Pet: Enmity +12'}}
        waist="Lucidity Sash",
        legs="Telchine Braconi",
        feet="Beckoner's Pigaches"
		
    }
     
    ----------
    -- Midcast
    ----------
     
    -- We handle the damage and etc. in Pet Midcast later
     
    -- Whatever you want to equip mid-cast as a catch all for all spells, and we'll overwrite later for individual spells
    sets.midcast.casting = {
        main= {name="Espiritus", augments={'Summoning Magic Skill +15', 'Pet: Magic Accuracy +30', 'Pet: Damage Taken -4%'}}
        sub="Vox Grip",
        ammo="Seraphicaller",
        head="Psycloth Tiara",
        neck="Sacrifice Torque",
        lear="Andoaa Earring",
        rear="Gelos Earring",
        body="Convoker's Doublet +1",
        hands="Apogee Mitts",
        lring="Fervor Ring",
        rring="Thurundaut Ring",
        back= 
		{name="Conveyance Cape", augments={'Summoning Magic Skill +5', 'Blood Pact Damage +4', 'Pet: Enmity +12'}}
        waist="Mujin Obi",
        legs="Apogee Slacks",
        feet="Glyphic Pigaches +1"
    }
     
    ------------
    -- Aftercast
    ------------
     
    -- I don't use aftercast sets, as we handle what to equip later depending on conditions using a function, eg, do we have an avatar out?
 
end
 
function precast(spell)
 
    -- Don't swap if we're in the middle of something or our pet's doing something
    -- Stops macro spam from interfering with an action GS is already handling
    if midaction() or pet_midaction() then
        return
    end
     
    -- If we're doing a blood pact, equip our delay set IF Apogee or Astral Conduit are not active
    if (spell.type == 'BloodPactRage' or spell.type == 'BloodPactWard') and not (buffactive['Astral Conduit'] or buffactive['Apogee']) then
     
        equip(sets.precast.bp)
         
    elseif spell.type == 'SummonerPact' then
     
        -- This chunk of code handles Elemental Siphon. It will look at the current day and weather and cancel the spell to summon
        -- the right elemental. Your elemental siphon macro should summon a Dark Spirit to trigger this check
         
        -- These use the included lists in global.lua to determine the right spirit to summon
             
        if spell.name == 'Dark Spirit' then
            if world.weather_element == 'Dark' then
             
                -- Dark Weather is active, lets the spell go ahead and equips summoning precast
                equip(sets.precast.summoning)
                 
            elseif world.weather_element ~= 'None' and spirit_conflict[world.day_element] ~= world.weather_element then
             
                -- It's not dark weather but there is some weather up, cancels dark and summons the right spirit
                cancel_spell()
                send_command('input /ma "%s" <me>':format(spirit_element[world.weather_element]))
                equip(sets.precast.summoning)
                 
            elseif world.day_element == 'Dark' then
             
                -- It's darksday so allow the dark spirit to go ahead and equip summoning
                equip(sets.precast.summoning)
                 
            else
             
                -- There is no weather up and it's not darksday, so summon the current day's spirit
                cancel_spell()              
                send_command('input /ma "%s" <me>':format(spirit_element[world.day_element]))
                equip(sets.precast.summoning)
                 
            end
        else
         
            -- We're not summoning Dark Spirit, so we don't want to Siphon, which means we're summoning an avatar
            equip(sets.precast.summoning)
             
        end
         
    -- Moving on to other types of magic
    elseif spell.type == 'WhiteMagic' or spell.type == 'BlackMagic' then
     
        -- Stoneskin Precast
        if spell.name == 'Stoneskin' then
         
            windower.ffxi.cancel_buff(37)--[[Cancels stoneskin, not delayed incase you get a Quick Cast]]
            equip(sets.precast.stoneskin)
             
        -- Cure Precast
        elseif spell.name:match('Cure') or spell.name:match('Cura') then
         
            equip(sets.precast.cure)
             
        -- Enhancing Magic
        elseif spell.skill == 'Enhancing Magic' then
         
            equip(sets.precast.enhancing)
             
            if spell.name == 'Sneak' then
                windower.ffxi.cancel_buff(71)--[[Cancels Sneak]]
            end
        else
         
            -- For everything else we go with max fastcast
            equip(sets.precast.casting)
             
        end
         
    -- Summoner Abilities
    -- We use a catch all here, if the set exists for an ability, use it
    -- This way we don't need to write a load of different code for different abilities, just make a set
     
    elseif sets.precast[spell.name] then
        equip(sets.precast[spell.name])
    end
     
end
 
function midcast(spell)
 
    -- If our pet is doing something, prevents us swapping equipment too early
    if pet_midaction() then
        return
    end
     
    -- No need to annotate all this, it's fairly logical. Just equips the relevant sets for the relevant magic
    if spell.type == 'WhiteMagic' or spell.type == 'BlackMagic' then
        if spell.name == 'Stoneskin' then
            equip(sets.midcast.stoneskin)
        elseif spell.name:match('Cure') or spell.name:match('Cura') then
            equip(sets.midcast.cure)
        elseif spell.skill == 'Enhancing Magic' then
            equip(sets.midcast.enhancing)
            if spell.name:match('Protect') or spell.name:match('Shell') then
                equip({rring="Sheltered Ring"})
            end
        else
            equip(sets.midcast.casting)
        end
    elseif spell.name == 'Elemental Siphon' then
     
        -- Siphon Set
        equip(sets.midcast.siphon)
         
        -- Checks if pet matches weather
        if pet.element == world.weather_element then
            equip(sets.midcast.siphon,{main="Chatoyant Staff"--[[Take advantage of the weather boost]]})
        end
         
    -- And our catch all, if a set exists for this spell use it
    elseif sets.midcast[spell.name] then
        equip(sets.midcast[spell.name])
         
    -- Remember those WS Sets we defined? :)
    elseif sets.me[spell.name] then
        equip(sets.me[spell.name])
    end
end
 
function aftercast(spell)
 
    -- If our pet's doing something, Stop!
    if pet_midaction() then
        return
    end 
     
    -- If not a blood pact or summon
    if spell and (not spell.type or not string.find(spell.type,'BloodPact') and not AvatarList:contains(spell.name) or spell.interrupted) then
     
        -- Then initiate idle function to check which set should be equipped
        idle(pet)
         
    end
end
 
function pet_midcast(spell)
 
    -- Our pet is doing something
    if spell.type=='BloodPactRage' then
     
        -- We're going to check the lists in global.lua for matches and equip the relevant sets
         
        if bp_physical:contains(spell.name) then
         
            equip(sets.avatar.atk)
             
        elseif bp_hybrid:contains(spell.name) then
         
            equip(sets.avatar.hybrid)
            if pet.name == 'Ifrit' then
                equip({rring="Fervor Ring"})--[[Change rring to lring if you put Evoker's on your right hand]]
            end
             
        elseif bp_magical:contains(spell.name) then
         
            equip(sets.avatar.mab)
            if pet.name == 'Ifrit' then
                equip({rring="Fervor Ring"})--[[Change rring to lring if you put Evoker's on your right hand]]
            end
 
        elseif bp_debuff:contains(spell.name) then
         
            equip(sets.avatar.macc)
             
        elseif bp_buff:contains(spell.name) then
         
            equip(sets.avatar.buff)
             
        elseif bp_other:contains(spell.name) then
         
            equip(sets.avatar.other)
             
        elseif spell.name == 'Perfect Defense' then
         
            equip(sets.avatar.skill)
             
        else
         
            equip(sets.avatar.skill)
             
        end
    end 
end
 
function pet_aftercast(spell)
     
    -- Pet aftercast is simply a check for whether Conduit and Apogee are up, and then a call to our aftercast function
    -- We have a variable called autobp that we set to true or false with commands to auto repeat BPs for us
    if (buffactive['Apogee'] or buffactive['Astral Conduit']) and autobp then
        send_command('input /pet "%s" <t>':format(spell.name))
        return
    end
     
    idle(pet)
     
end
 
function idle(pet)
 
    -- This function is called after every action, and handles which set to equip depending on what we're doing
    -- We check if we're meleeing because we don't want to idle in melee gear when we're only engaged for trusts
     
    if meleeing and player.status=='Engaged' then
     
        -- We're both engaged and meleeing
        equip(sets.me.melee)
         
    elseif pet.isvalid then
         
        -- We have a pet out but we're not meleeing, set the right idle set
        equip(sets.avatar[mode])
 
    else
     
        -- We're not meleeing and we have no pet out
        equip(sets.me.idle)
         
    end
end
 
function status_change(new,old)
    if new == 'Engaged' then
     
        -- If we engage check our meleeing status
        idle(pet)
         
    elseif new=='Resting' then
     
        -- We're resting
        equip(sets.me.resting)
    end
end
 
function pet_change(pet,gain)
 
    -- When we summon or release an avatar
    idle(pet)
 
end
 
 
function self_command(command)
 
    local commandArgs = command
     
    -- This command takes //gs c avatar mode, where mode is what you want, eg, tank, acc, melee, etc
    if #commandArgs:split(' ') >= 2 then
        commandArgs = T(commandArgs:split(' '))
        if commandArgs[1] == 'avatar' then
            if commandArgs[2] then
                mode = tostring(commandArgs[2])
                equip(sets.avatar[mode])
                windower.add_to_chat(8,'----- Avatar set to '..mode..' mode! -----')
            end
        elseif commandArgs[1] == 'toggle' then
            if commandArgs[2] == 'auto' then
             
                -- //gs c toggle auto will toggle auto blood pacts on and off. Auto blood pact will make your GS repeat BPs under Apogee or Conduit
                -- And by repeat I mean repeat. If Conduit is up, it will SPAM the BP until Conduit is down
                if autobp then
                    autobp = false
                    windower.add_to_chat(8,'----- Auto BP mode Disabled -----')
                else
                    autobp = true
                    windower.add_to_chat(8,'----- Auto BP mode Enabled -----')
                end
            elseif commandArgs[2] == 'melee' then
             
                -- //gs c toggle melee will toggle melee mode on and off.
                -- This basically locks the slots that will cause you to lose TP if changing them,
                -- As well as equip your melee set if you're engaged
 
                if meleeing then
                    meleeing = false
                    enable('main','sub','ranged')
                    windower.add_to_chat(8,'----- Weapons Unlocked, WILL LOSE TP -----')
                    idle(pet)
                else
                    meleeing=true
                    disable('main','sub','ranged')
                    windower.add_to_chat(8,'----- Weapons Locked, WILL NOT LOSE TP -----')
                    idle(pet)
                end
                 
            elseif commandArgs[2] == 'favor' then
                     
                -- //gs c toggle favor will toggle Favor mode on and off.
                -- It won't automatically toggle, as some people like having favor active without the gear swaps for maximum effectiveness
                -- You need to toggle prioritisation yourself
                if favor then
                    favor = false
                    windower.add_to_chat(8,"----- Avatar's Favor Mode OFF -----")
                else
                    favor = true
                    windower.add_to_chat(8,"----- Avatar's Favor Mode ON -----")
                end
                 
            end
        end
    end
end
 
-- Required variables and their initial value
meleeing = false
autobp = false
favor = false
mode = "perp" 
            
            
                
			
			By Elizabet 2015-09-27 01:57:00			
			
						
                     
                 Bahamut.Seekerstar said: »Do I put the global file separately into data?
 Sorry, I have like no idea what I'm doing.
 
 I also keep getting yuck errors at about line 74 or so and I don't know why.
Since you put the global (which was a separate file) directly into your SMN.lua (that works too..) you just need to remove this line:
 Code  include('global.lua') -- Just a collection of functions that I use in all my GearSwaps. See below (after this code block)
 
            
                
                    
                    
                    
                                                            
                                                    
                                                                            
                                Server: Bahamut Game: FFXI Posts: 879 
                
			
			By Bahamut.Seekerstar 2015-09-27 02:11:14			
			
						
                     
                 Thank you. Now to figure out why the errors crop up... something about line 82, wanting another "}" to close something, but I looked and tried putting a few in there.
 I feel dumb, lol.
 
            
            
                
			
			By Elizabet 2015-09-27 04:29:05			
			
						
                     
                 Probably something you messed up when entering your own sets :)                                     
            
            
                
			
			By Aeyela 2015-09-27 04:36:43			
			
						
                     
                 On line 82, you need a comma after your augmented capes Code  back= {name="Conveyance Cape", augments={'Summoning Magic Skill +5', 'Blood Pact Damage +4', 'Pet: Enmity +12'}}, 
            
                
                     Ragnarok.Boq
                                                    
                                                                            
                                Server: Ragnarok Game: FFXI Posts: 31 
                
			
			By Ragnarok.Boq 2015-09-28 06:59:53			
			
						
                     
                 This is extremely appreciated, Aeyela. I've been using Mote's, and had trouble troubleshooting it due to not fully understanding its contents. Thanks!                                     
            
            
                
			
			By Zubis 2015-09-28 12:54:35			
			
						
                     
                 This a great Gearswap. I didn't think anything was wrong with Motes, but I switched to this and I'm noticing a 20% increase in damage at least on rapid Blood Pacts.                                     
            
                
                    
                    
                    
                                                            
                                                    
                                                                            
                                Server: Siren Game: FFXI Posts: 228 
                
			
			By Siren.Noxzema 2015-09-30 01:05:35			
			
						
                     
                 I've been a long time user of Motes, but this seems good so far. I just have a couple quick questions/comments, I spent a few hours playing around/ failing at google, with no luck yet. 
 Is there any way of making keybinds like mote had set up? It would be nice to just cycle through avatar modes vs a separate macro for each.
 
 Also, how about adding different sets for melee? I'm not sure how to go about adding more sets with it being a toggle here.
 
 And, finally, how do you change the priority of Favor? Unless I broke mine somehow, toggling doesn't seem to make a difference, it just maintains my perp set.
 
 Btw you have "Conflag Strike" listed as "Conflagration Strike".
 
 Thanks for this though, I especially like the auto bp function, Idk how many times I've used a couple Punches when spamming FC because my cursor decides to go to the top of the menu lol...
 
            
            
                
			
			By Elizabet 2015-09-30 01:26:45			
			
						
                     
                 How do you change the priority of Favor? Unless I broke mine somehow, toggling doesn't seem to make a difference, it just maintains my perp set.
If you're having Beckoner's Horn in your Perp set, they are in essence the same thing.
 
If for example, in your perp set (or avatar tank mode set) your helm is a Selenian -10% DT... Then the toggle will make sure your Beckoner's Horn is there to priorise the favor bonus.
 Is there any way of making keybinds like mote had set up? It would be nice to just cycle through avatar modes vs a separate macro for each.
Right now, his lua doesn't cycle for avatar modes, that can be changed of course.
 
look for this part: Code  
        if commandArgs[1] == 'avatar' then
            if commandArgs[2] then
                mode = tostring(commandArgs[2])
                equip(sets.avatar[mode])
                windower.add_to_chat(8,'----- Avatar set to '..mode..' mode! -----')
            end
        elseif commandArgs[1] == 'toggle' then
Replace with:  Code  
        if commandArgs[1] == 'avatar' then
            if commandArgs[2] then
                mode = tostring(commandArgs[2])
                if mode == 'mode' then
                    if savedMode == 'perp' then
                       mode = 'tank'
                       savedMode = 'tank'
                    elseif savedMode == 'tank' then
                       mode = 'melee'
                       savedMode = 'melee'
                    elseif savedMode == 'melee' then
                       mode = 'acc'
                       savedMode = 'acc'
                    elseif savedMode == 'acc' then
                       mode = 'perp'
                       savedMode = 'perp'
                    end
                end    
                equip(sets.avatar[mode])
                windower.add_to_chat(8,'----- Avatar set to '..mode..' mode! -----')
            end
        elseif commandArgs[1] == 'toggle' then
Then at the end of the file Code  
-- Required variables and their initial value
meleeing = false
autobp = false
favor = false
mode = "perp"
Add in under mode = "perp": 
then at the very top of the file as first line put this:
 Code  
windower.send_command('bind f9 gs c avatar mode')
Now f9 should cycle your avatar modes.
 
Hopefully that works.. EDIT: Tested on my end and it works flawlessly.                                     
            
            
                
			
			By Aeyela 2015-09-30 03:22:54			
			
						
                     
                 And, finally, how do you change the priority of Favor? Unless I broke mine somehow, toggling doesn't seem to make a difference, it just maintains my perp set.
I actually seem to have missed that out of the function that changes you to idle gear after every action. I've changed the OP, and here it is below too. Just replace the current idle function with this one. Thanks for noticing this!
 Code  function idle(pet)
	-- This function is called after every action, and handles which set to equip depending on what we're doing
	-- We check if we're meleeing because we don't want to idle in melee gear when we're only engaged for trusts
	
	if favor then
	
		-- Avatar's favor takes priority!
		equip(sets.me.favor)
		
	elseif meleeing and player.status=='Engaged' then
	
		-- We're both engaged and meleeing
		equip(sets.me.melee)
		
	elseif pet.isvalid then
		
		-- We have a pet out but we're not meleeing, set the right idle set
		equip(sets.avatar[mode])
	else
	
		-- We're not meleeing and we have no pet out
		equip(sets.me.idle)
		
	end
endBtw you have "Conflag Strike" listed as "Conflagration Strike".
And it weirdly still works, but I've changed it anyway. Cheers!                                     
            
                
                    
                    
                    
                                                            
                                                    
                                                                            
                                Server: Siren Game: FFXI Posts: 228 
                
			
			By Siren.Noxzema 2015-09-30 08:46:48			
			
						
                     
                 Thanks for the quick responses, I'll give it a shot after work today. It's odd that Conflagration was working for you, was 95% sure it put my skill set on.                                     
            
                
                    
                    
                    
                                                            
                                                    
                                                                            
                                Server: Siren Game: FFXI Posts: 228 
                
			
			By Siren.Noxzema 2015-09-30 18:46:37			
			
						
                     
                 You have sets.avatar.favor in the gearset section, but it's calling for sets.me.favor in the function section. Fixed that and it all works perfectly. thanks again for the help.
 
 Edit: Also, you're missing Impact from the BP list.
 
            
            
                
			
			By jopa 2015-09-30 20:32:38			
			
						
                     
                 You need to change line 821 to Code  if (spell.type == 'BloodPactRage' or spell.type == 'BloodPactWard') thenin order for ward sets to work.                                             
                    [+]
                                              
            
            
                
			
			By Aeyela 2015-10-01 03:52:39			
			
						
                     
                 You need to change line 821 to Code  if (spell.type == 'BloodPactRage' or spell.type == 'BloodPactWard') thenin order for ward sets to work.
It works fine as it is. Are you having issues with it?                                     
            
            
                
			
			By jopa 2015-10-01 08:20:35			
			
						
                     
                 I was until I changed it to that.                                     
            
            
                
			
			By Aeyela 2015-10-01 17:00:32			
			
						
                     
                 I had a play with this this evening and indeed, you are right. That line should be changed. It took me awhile to replicate this issue but then I realised why. The sets inherit from the .skill set, which is what the Lua was equipping when no specified set was found for that specific Ward. As my gear is incredibly gimp compared to most people here I was not noticing, even with showswaps enabled, that it wasn't equipping the wards set. 
Thanks for bringing this to my attention. I've changed the OP and I highly encourage anyone using this to change the following line in pet_midcast:
 Code  if spell.type=='BloodPactRage' then
To Jopa's fix:
 Code  if (spell.type == 'BloodPactRage' or spell.type == 'BloodPactWard') then
As this will guarantee that your correct sets equip for all pact types, rather than inheriting the base skill set.                                     
            
                
                    
                    
                    
                                                            
                                                    
                                                                            
                                Server: Siren Game: FFXI Posts: 228 
                
			
			By Siren.Noxzema 2015-10-03 18:53:57			
			
						
                     
                 Running well so far, except ran into another issue. When I'm in melee mode, I noticed that it won't return to the original set that I had on.i.e it'll keep my BP rage, ws set etc on after I use it, instead of swapping back to my melee set, even after disengaging.
 
    
    
        
        GitHub: Thanks to Elizabet for hosting this on GitHub
People have been having issues with Mote's SMN Gearswap recently. After lengthy conversations on the topic as well as going through his files, I believe the files themselves are to blame. Several people, evidently myself included, have not had issues with custom SMN Lua files. As a result, and due to several requests, I've decided to post my Lua to provide a viable alternative to Mote's. I make no elaborate claims that this is better (or worse, for that matter), I'm sharing purely so people can try it for themselves.
 
I give my personal guarantee that everything worked 100% at the time of posting, tested numerous times with Abyssea Revitalizers.
 
The inline comments should assist you in setting this up. You'll find it's much simpler than most SMN Luas. With no disrespect meant to people who have helped people out with Gear Swap, I find SMN Luas in particular to be way more complicated than they need to be, often containing dozens of lines of superfluous code.
What this Lua is: What this Lua is not:SimpleDoes not rely on lengthy includes or libraries, which will make it easier to trouble shoot should part of it not be working correctly at some pointCut and paste ready. I've even taken the liberty of not adding gear so you can type yours in quicker
 ComplicatedNirvana ready. I don't and will never own a Nirvana so Aftermaths are moot to me. If enough people want this, I'm happy to add it thoughThe best of the bestest all others suck etc, judge for yourself
 
With that said, here we go. This comes in two files: firstly, global.lua, which contains a list of blood pacts and what not, as well as a couple of my own functions that I use in all my Lua files (like auto style lock, macro books, etc.) The second file is the lua file itself that you'll need to add your equipment to. Be sure to remove blank lines when you're done (ie, hands="".)
 
You can put the global.lua file contents at the start of your SMN.lua file if you prefer, that way you have no includes.
Global.lua: SMN.Lua:Code  function set_macros(sheet,book)
	if book then 
		send_command('@input /macro book '..tostring(book)..';wait .1;input /macro set '..tostring(sheet))
		return
	end
	send_command('@input /macro set '..tostring(sheet))
end
function set_style(sheet)
	send_command('@input /lockstyleset '..sheet)
end
bp_physical=S{'Punch','Rock Throw','Barracuda Dive','Claw','Axe Kick','Shock Strike','Camisado','Regal Scratch','Poison Nails','Moonlit Charge','Crescent Fang','Rock Buster','Tail Whip','Double Punch','Megalith Throw','Double Slap','Eclipse Bite','Mountain Buster','Spinning Dive','Predator Claws','Rush','Chaotic Strike','Crag Throw','Volt Strike'}bp_hybrid=S{'Burning Strike','Flaming Crush'}bp_magical=S{'Inferno','Earthen Fury','Tidal Wave','Aerial Blast','Diamond Dust','Judgment Bolt','Searing Light','Howling Moon','Ruinous Omen','Fire II','Stone II','Water II','Aero II','Blizzard II','Thunder II','Thunderspark','Somnolence','Meteorite','Fire IV','Stone IV','Water IV','Aero IV','Blizzard IV','Thunder IV','Nether Blast','Meteor Strike','Geocrush','Grand Fall','Wind Blade','Heavenly Strike','Thunderstorm','Level ? Holy','Holy Mist','Lunar Bay','Night Terror','Conflag Strike'}bp_debuff=S{'Lunar Cry','Mewing Lullaby','Nightmare','Lunar Roar','Slowga','Ultimate Terror','Sleepga','Eerie Eye','Tidal Roar','Diamond Storm','Shock Squall','Pavor Nocturnus'}bp_buff=S{'Shining Ruby','Frost Armor','Rolling Thunder','Crimson Howl','Lightning Armor','Ecliptic Growl','Hastega','Noctoshield','Ecliptic Howl','Dream Shroud','Earthen Armor','Fleet Wind','Inferno Howl','Soothing Ruby','Heavenward Howl','Soothing Current','Hastega II','Crystal Blessing'}bp_other=S{'Healing Ruby','Raise II','Aerial Armor','Reraise II','Whispering Wind','Glittering Ruby','Earthen Ward','Spring Water','Healing Ruby II'} AvatarList=S{'Shiva','Ramuh','Garuda','Leviathan','Diabolos','Titan','Fenrir','Ifrit','Carbuncle','Fire Spirit','Air Spirit','Ice Spirit','Thunder Spirit','Light Spirit','Dark Spirit','Earth Spirit','Water Spirit','Cait Sith','Alexander','Odin','Atomos'}spirit_element={Fire='Fire Spirit',Earth='Earth Spirit',Water='Water Spirit',Wind='Air Spirit',Ice='Ice Spirit',Lightning='Thunder Spirit',Light='Light Spirit',Dark='Dark Spirit'}spirit_conflict={Fire='Ice',Earth='Lightning',Water='Fire',Wind='Earth',Ice='Wind',Lightning='Water',Light='Dark',Dark='Light'}Code  include('global.lua') -- Just a collection of functions that I use in all my GearSwaps. See below (after this code block)
set_macros(1,2) -- Sheet, Book
function get_sets()
	-- My formatting is very easy to follow. All sets that pertain to my character doing things are under 'me'.
	-- All sets that are equipped to faciliate my avatar's behaviour or abilities are under 'avatar', eg, Perpetuation, Blood Pacts, etc
	
	sets.me = {}
	sets.avatar = {}
	
	-- Your idle set when you DON'T have an avatar out
	sets.me.idle = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-- Your MP Recovered Whilst Resting Set
	sets.me.resting = {	
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-----------------------
	-- Perpetuation Related
	-----------------------
	
	-- Avatar's Out --	
	-- This is the base for all perpetuation scenarios, as seen below
	sets.avatar.perp = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	-- The following sets base off of perpetuation, so you can consider them idle sets.
	-- Set the relevant gear, bearing in mind it will overwrite the perpetuation item for that slot!
	
	-- When we want our avatar to stay alive
	sets.avatar.tank = set_combine(sets.avatar.perp,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- When we want our avatar to shred
	sets.avatar.melee = set_combine(sets.avatar.perp,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- When we want our avatar to hit
	sets.avatar.acc = set_combine(sets.avatar.perp,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- When Avatar's Favori s active
	sets.avatar.favor = set_combine(sets.avatar.perp,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	----------------------------
	-- Summoning Skill Related
	-- Including all blood pacts
	----------------------------
	
	-- + Summoning Magic. This is a base set for max skill and blood pacts and we'll overwrite later as and when we need to
	sets.avatar.skill = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-------------------------
	-- Individual Blood Pacts
	-------------------------
	
	-- Physical damage
	sets.avatar.atk = set_combine(sets.avatar.skill,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Magic Attack
	sets.avatar.mab = set_combine(sets.avatar.skill,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	-- Hybrid
	sets.avatar.hybrid = set_combine(sets.avatar.skill,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Magic Accuracy
	sets.avatar.macc = set_combine(sets.avatar.skill,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Buffs
	sets.avatar.buff = set_combine(sets.avatar.skill,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Other
	sets.avatar.other = set_combine(sets.avatar.skill,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Combat Related Sets
	
	-- Melee
	-- The melee set combines with perpetuation, because we don't want to be losing all our MP whilst we swing our Staff
	-- Anything you equip here will overwrite the perpetuation/refresh in that slot.
	sets.me.melee = set_combine(sets.avatar.perp,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Shattersoul. Weapon Skills do not work off perpetuation as it only stays equipped for a moment
	sets.me["Shattersoul"] = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	sets.me["Garland of Bliss"] = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-- Feel free to add new weapon skills, make sure you spell it the same as in game. These are the only two I ever use though
	---------------
	-- Casting Sets
	---------------
	
	sets.precast = {}
	sets.midcast = {}
	sets.aftercast = {}
	
	----------
	-- Precast
	----------
	
	-- Generic Casting Set that all others take off of. Here you should add all your fast cast	
	sets.precast.casting = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}	
	
	-- Summoning Magic Cast time - gear
	sets.precast.summoning = set_combine(sets.precast.casting,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Enhancing Magic, eg. Siegal Sash, etc
	sets.precast.enhancing = set_combine(sets.precast.casting,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	-- Stoneskin casting time -, works off of enhancing -
	sets.precast.stoneskin = set_combine(sets.precast.enhancing,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Curing Precast, Cure Spell Casting time -
	sets.precast.cure = set_combine(sets.precast.casting,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	---------------------
	-- Ability Precasting
	---------------------
	
	-- Blood Pact Ability Delay
	sets.precast.bp = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-- Mana Cede
	sets.precast["Mana Cede"] = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-- Astral Flow	
	sets.precast["Astral Flow"] = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-- Elemental Siphon, eg, Tatsumaki Thingies, Esper Stone, etc
	sets.precast.siphon = set_combine(sets.avatar.skill,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	----------
	-- Midcast
	----------
	
	-- We handle the damage and etc. in Pet Midcast later
	
	-- Whatever you want to equip mid-cast as a catch all for all spells, and we'll overwrite later for individual spells
	sets.midcast.casting = {
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	}
	
	-- Enhancing
	sets.midcast.enhancing = set_combine(sets.midcast.casting,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Stoneskin
	sets.midcast.stoneskin = set_combine(sets.midcast.enhancing,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	-- Cure Potency
	sets.midcast.cure = set_combine(sets.midcast.casting,{
		main="",
		sub="",
		ranged="",
		ammo="",
		head="",
		neck="",
		lear="",
		rear="",
		body="",
		hands="",
		lring="",
		rring="",
		back="",
		waist="",
		legs="",
		feet=""
	})
	
	------------
	-- Aftercast
	------------
	
	-- I don't use aftercast sets, as we handle what to equip later depending on conditions using a function, eg, do we have an avatar out?
end
function precast(spell)
	-- Don't swap if we're in the middle of something or our pet's doing something
	-- Stops macro spam from interfering with an action GS is already handling
    if midaction() or pet_midaction() then
        return
    end
	
	-- If we're doing a blood pact, equip our delay set IF Apogee or Astral Conduit are not active
    if (spell.type == 'BloodPactRage' or spell.type == 'BloodPactWard') and not (buffactive['Astral Conduit'] or buffactive['Apogee']) then
	
        equip(sets.precast.bp)
		
    elseif spell.type == 'SummonerPact' then
	
		-- This chunk of code handles Elemental Siphon. It will look at the current day and weather and cancel the spell to summon
		-- the right elemental. Your elemental siphon macro should summon a Dark Spirit to trigger this check
		
		-- These use the included lists in global.lua to determine the right spirit to summon
			
        if spell.name == 'Dark Spirit' then
            if world.weather_element == 'Dark' then
			
				-- Dark Weather is active, lets the spell go ahead and equips summoning precast
                equip(sets.precast.summoning)
				
			elseif world.weather_element ~= 'None' and spirit_conflict[world.day_element] ~= world.weather_element then
			
				-- It's not dark weather but there is some weather up, cancels dark and summons the right spirit
                cancel_spell()
                send_command('input /ma "%s" <me>':format(spirit_element[world.weather_element]))
				equip(sets.precast.summoning)
				
            elseif world.day_element == 'Dark' then
			
				-- It's darksday so allow the dark spirit to go ahead and equip summoning
                equip(sets.precast.summoning)
				
            else
			
				-- There is no weather up and it's not darksday, so summon the current day's spirit
                cancel_spell()				
                send_command('input /ma "%s" <me>':format(spirit_element[world.day_element]))
				equip(sets.precast.summoning)
				
            end
		else
		
			-- We're not summoning Dark Spirit, so we don't want to Siphon, which means we're summoning an avatar
			equip(sets.precast.summoning)
			
		end
		
	-- Moving on to other types of magic
	elseif spell.type == 'WhiteMagic' or spell.type == 'BlackMagic' then
	
		-- Stoneskin Precast
        if spell.name == 'Stoneskin' then
		
            windower.ffxi.cancel_buff(37)--[[Cancels stoneskin, not delayed incase you get a Quick Cast]]
            equip(sets.precast.stoneskin)
			
		-- Cure Precast
        elseif spell.name:match('Cure') or spell.name:match('Cura') then
		
            equip(sets.precast.cure)
			
		-- Enhancing Magic
        elseif spell.skill == 'Enhancing Magic' then
		
            equip(sets.precast.enhancing)
			
            if spell.name == 'Sneak' then
                windower.ffxi.cancel_buff(71)--[[Cancels Sneak]]
            end
        else
		
			-- For everything else we go with max fastcast
            equip(sets.precast.casting)
			
        end
		
	-- Summoner Abilities
	-- We use a catch all here, if the set exists for an ability, use it
	-- This way we don't need to write a load of different code for different abilities, just make a set
	
	elseif sets.precast[spell.name] then
        equip(sets.precast[spell.name])
    end
	
end
function midcast(spell)
	-- If our pet is doing something, prevents us swapping equipment too early
    if pet_midaction() then
        return
    end
	
	-- No need to annotate all this, it's fairly logical. Just equips the relevant sets for the relevant magic
	if spell.type == 'WhiteMagic' or spell.type == 'BlackMagic' then
        if spell.name == 'Stoneskin' then
            equip(sets.midcast.stoneskin)
        elseif spell.name:match('Cure') or spell.name:match('Cura') then
            equip(sets.midcast.cure)
        elseif spell.skill == 'Enhancing Magic' then
            equip(sets.midcast.enhancing)
			if spell.name:match('Protect') or spell.name:match('Shell') then
				equip({rring="Sheltered Ring"})
            end
        else
            equip(sets.midcast.casting)
        end
    elseif spell.name == 'Elemental Siphon' then
	
		-- Siphon Set
        equip(sets.precast.siphon)
		
		-- Checks if pet matches weather
        if pet.element == world.weather_element then
            equip(sets.precast.siphon,{main="Chatoyant Staff"--[[Take advantage of the weather boost]]})
		end
		
	-- And our catch all, if a set exists for this spell use it
	elseif sets.midcast[spell.name] then
		equip(sets.midcast[spell.name])
		
	-- Remember those WS Sets we defined? :)
	elseif sets.me[spell.name] then
		equip(sets.me[spell.name])
	end
end
function aftercast(spell)
	-- If our pet's doing something, Stop!
    if pet_midaction() then
        return
    end	
	
	-- If not a blood pact or summon
	if spell and (not spell.type or not string.find(spell.type,'BloodPact') and not AvatarList:contains(spell.name) or spell.interrupted) then
	
		-- Then initiate idle function to check which set should be equipped
		idle(pet)
		
	end
end
function pet_midcast(spell)
	-- Our pet is doing something
    if (spell.type == 'BloodPactRage' or spell.type == 'BloodPactWard') then
	
		-- We're going to check the lists in global.lua for matches and equip the relevant sets
		
		if bp_physical:contains(spell.name) then
		
            equip(sets.avatar.atk)
			
        elseif bp_hybrid:contains(spell.name) then
		
            equip(sets.avatar.hybrid)
			if pet.name == 'Ifrit' then
				equip({rring="Fervor Ring"})--[[Change rring to lring if you put Evoker's on your right hand]]
			end
			
        elseif bp_magical:contains(spell.name) then
		
			equip(sets.avatar.mab)
			if pet.name == 'Ifrit' then
				equip({rring="Fervor Ring"})--[[Change rring to lring if you put Evoker's on your right hand]]
			end
		elseif bp_debuff:contains(spell.name) then
		
            equip(sets.avatar.macc)
			
        elseif bp_buff:contains(spell.name) then
		
            equip(sets.avatar.buff)
			
        elseif bp_other:contains(spell.name) then
		
            equip(sets.avatar.other)
			
        elseif spell.name == 'Perfect Defense' then
		
			equip(sets.avatar.skill)
			
		else
		
			equip(sets.avatar.skill)
			
		end
	end	
end
function pet_aftercast(spell)
	
	-- Pet aftercast is simply a check for whether Conduit and Apogee are up, and then a call to our aftercast function
	-- We have a variable called autobp that we set to true or false with commands to auto repeat BPs for us
    if (buffactive['Apogee'] or buffactive['Astral Conduit']) and autobp then
        send_command('input /pet "%s" <t>':format(spell.name))
		return
	end
	
	idle(pet)
	
end
function idle(pet)
	-- This function is called after every action, and handles which set to equip depending on what we're doing
	-- We check if we're meleeing because we don't want to idle in melee gear when we're only engaged for trusts
	
	if favor then
	
		-- Avatar's favor takes priority!
		equip(sets.avatar.favor)
		
	elseif meleeing and player.status=='Engaged' then
	
		-- We're both engaged and meleeing
		equip(sets.me.melee)
		
	elseif pet.isvalid then
		
		-- We have a pet out but we're not meleeing, set the right idle set
		equip(sets.avatar[mode])
	else
	
		-- We're not meleeing and we have no pet out
		equip(sets.me.idle)
		
	end
end
function status_change(new,old)
    if new == 'Engaged' then
	
		-- If we engage check our meleeing status
		idle(pet)
		
	elseif new=='Resting' then
	
		-- We're resting
        equip(sets.me.resting)
	else
		idle(pet)
	end
end
function pet_change(pet,gain)
	-- When we summon or release an avatar
    idle(pet)
end
function self_command(command)
	local commandArgs = command
	
	-- This command takes //gs c avatar mode, where mode is what you want, eg, tank, acc, melee, etc
    if #commandArgs:split(' ') >= 2 then
        commandArgs = T(commandArgs:split(' '))
		if commandArgs[1] == 'avatar' then
			if commandArgs[2] then
				mode = tostring(commandArgs[2])
				equip(sets.avatar[mode])
				windower.add_to_chat(8,'----- Avatar set to '..mode..' mode! -----')
			end
		elseif commandArgs[1] == 'toggle' then
			if commandArgs[2] == 'auto' then
			
				-- //gs c toggle auto will toggle auto blood pacts on and off. Auto blood pact will make your GS repeat BPs under Apogee or Conduit
				-- And by repeat I mean repeat. If Conduit is up, it will SPAM the BP until Conduit is down
				if autobp then
					autobp = false
					windower.add_to_chat(8,'----- Auto BP mode Disabled -----')
				else
					autobp = true
					windower.add_to_chat(8,'----- Auto BP mode Enabled -----')
				end
			elseif commandArgs[2] == 'melee' then
			
				-- //gs c toggle melee will toggle melee mode on and off.
				-- This basically locks the slots that will cause you to lose TP if changing them,
				-- As well as equip your melee set if you're engaged
				if meleeing then
					meleeing = false
					enable('main','sub','ranged')
					windower.add_to_chat(8,'----- Weapons Unlocked, WILL LOSE TP -----')
					idle(pet)
				else
					meleeing=true
					disable('main','sub','ranged')
					windower.add_to_chat(8,'----- Weapons Locked, WILL NOT LOSE TP -----')
					idle(pet)
				end
				
			elseif commandArgs[2] == 'favor' then
					
				-- //gs c toggle favor will toggle Favor mode on and off.
				-- It won't automatically toggle, as some people like having favor active without the gear swaps for maximum effectiveness
				-- You need to toggle prioritisation yourself
				if favor then
					favor = false
					windower.add_to_chat(8,"----- Avatar's Favor Mode OFF -----")
				else
					favor = true
					windower.add_to_chat(8,"----- Avatar's Favor Mode ON -----")
				end
				
			end
		end
	end
end
-- Required variables and their initial value
meleeing = false
autobp = false
favor = false
mode = "perp"
Here's a run down on commands:
//gs c avatar [mode] 
Replace [mode] with either: perp, tank, melee, acc to set your avatar's idling equipment to a particular setup. Perp is for maximum perp- and refresh, tank for tanking, melee for doing maximum physical damage and acc for accuracy.
//gs c toggle melee 
This will toggle your character between melee mode. Initially set to false, enabling this will idle to your melee set when engaged as well as disable slots that changing items in would remove TP. With this turned off being engaged will not equip your melee gear, so you can stay engaged for the purposes of trusts whilst keeping your relevant perpetuation gear on.
//gs c toggle auto 
Initially turned off, using this command will toggle auto blood pacts on Apogee and Conduit. By auto I literally mean auto. Using a blood pact with this on will use it again instantly if you have Apogee or Conduit up. If you have Conduit up, your character will spam abilities until you either toggle this off or Conduit drops.
//gs c toggle favor 
Initially turned off, this command will toggle your character into favor prioritisation mode. This means that, with this on, Avatar's Favor set will override other idle sets, including melee. Using Avatar's Favor will not  toggle this automatically. One particular problem with lots of Luas is this assumption is made, and most end users don't know how to disable it.
 
There are times and places we want maximum Favor power, and they are quite limited. You be the judge and set this yourself when you want it.
 
--
 
If you have any questions or problems, please reply and I'll try and help. |  |