Fuepepe FFXI Gearswap backup

Since I never want to rewrite these again if my HDD dies…

RNG

function get_sets()
                AccIndex = 1
                AccArray = {"LowACC","MidACC","HighACC","Fodder"}
                IdleIndex = 1
                IdleArray = {'Movement', 'Regen','Town'}                -- Default Idle Set Is Movement --
                PreshotIndex = 1
                PreshotArray = {'Any','RDM'}
                Armor = 'None'
                autoRAmode = 0
                target_distance = 5 -- Set Default Distance Here --
                send_command('input /macro book 7;wait .1;input /macro set 1') -- Change Default Macro Book Here --
                send_command('bind ^` gs c flur') --flurry toggle--
                send_command('bind ^- gs c acc') --accuracy toggle--
                send_command('bind ^= gs c pdt') --PDT toggle--
                send_command('bind != gs c mdt') --MDT toggle--
                send_command('bind !- gs c auto') --Gearset update toggle--
                ranged_ws = S{
                                "Hot Shot","Split Shot","Sniper Shot","Slug Shot","Blast Shot","Heavy Shot","Detonator",
                                "Numbing Shot","Last Stand","Coronach","Trueflight","Wildfire","Flaming Arrow",
                                "Piercing Arrow","Dulling Arrow","Sidewinder","Blast Arrow","Arching Arrow",
                                "Empyreal Arrow","Refulgent Arrow","Apex Arrow","Jishnu's Radiance","Namas Arrow"}

                -- Idle/Town Sets --
                sets.Idle = {}
                sets.Idle.Regen = {
                                head="Mummu Bonnet +2",neck="Bathy Choker +1",
                                body="Mummu Jacket +2",hands="Meg. Gloves +2",ring1="Stormsoul Ring",ring2="Hajduk Ring +1",ear1="Infused Earring",ear2="Genmei earring",
                                back="Belenus's Cape",waist="Kwahu Kachina Belt",legs="Mummu Kecks +2",feet="Meg. Jam. +2"}
                sets.Idle.Movement = set_combine(sets.Idle.Regen,{feet="Fajin Boots"})
                sets.Idle.Town = {
                                main="",
                                sub="",
                                range="",
                                ammo="",
                                head="Orion Beret +3",
                                body="Orion Jerkin +2",
                                hands="Orion Bracers +2",
                                legs="Adhemar Kecks +1",
                                feet="Meg. Jam. +2",
                                neck="Iskur Gorget",
                                waist="Kwahu Kachina Belt",
                                left_ear="Dedition Earring",
                                right_ear="Telos Earring",
                                left_ring="Weatherspoon Ring",
                                right_ring="Dingir Ring",
                                back="Belenus's Cape"}

                sets.Gastraphetes = {main={ name="Malevolence", augments={'INT+9','Mag. Acc.+10','"Mag.Atk.Bns."+9','"Fast Cast"+4',}},sub={ name="Malevolence", augments={'INT+3','Mag. Acc.+5','"Mag.Atk.Bns."+7',}},range="Gastraphetes",ammo="Quelling Bolt"}

                sets.Fomalhaut = {main="Perun +1",sub="Nusku Shield",range="Fomalhaut",ammo="Chrono Bullet"}

                sets.FailNot = {main="Kustawi +1",sub="Nusku Shield",range="Fail-Not",ammo="Chrono Arrow"}

                sets.Annihilator = {main="Perun +1",sub="Nusku Shield",range="Annihilator",ammo="Eradicating Bullet"}

                sets.Gandiva = {main="Oneiros Knife",sub="Nusku Shield",range="Gandiva",ammo="Chrono Arrow"}

                sets.Armageddon = {main="Perun +1",sub="Nusku Shield",range="Armageddon",ammo="Chrono Bullet"}

                sets.Yoichinoyumi = {main="Kustawi +1",sub="Nusku Shield",range="Yoichinoyumi",ammo="Artemis's Arrow"}

                sets.Closeup = {main="Kustawi +1",sub="Ternion Dagger +1"}

                -- Preshot --
                sets.Preshot = {}

                sets.Preshot['Fail-Not'] = {
                                head={ name="Taeon Chapeau", augments={'"Snapshot"+5','"Snapshot"+5',}},
                                body={ name="Taeon Tabard", augments={'"Snapshot"+5','"Snapshot"+5',}},hands="Carmine Fin. Ga. +1",back={ name="Belenus's Cape", augments={'"Snapshot"+10',}},waist="Impulse Belt",legs="Adhemar Kecks",feet="Meg. Jam. +2"}

                sets.Preshot['Fail-Not'].Any = set_combine(sets.Preshot['Fail-Not'],{body="Amini Caban +1",waist="Yemaya Belt"})

                sets.Preshot['Fail-Not'].RDM = set_combine(sets.Preshot['Fail-Not'].Any,{head="Orion Beret +3",waist="Impulse Belt",feet="Pursuer's Gaiters"})

                sets.Preshot.Yoichinoyumi = {
                                head={ name="Taeon Chapeau", augments={'"Snapshot"+5','"Snapshot"+5',}},
                                body={ name="Taeon Tabard", augments={'"Snapshot"+5','"Snapshot"+5',}},hands="Carmine Fin. Ga. +1",back={ name="Belenus's Cape", augments={'"Snapshot"+10',}},waist="Impulse Belt",legs="Adhemar Kecks",feet="Meg. Jam. +2"}

                sets.Preshot.Yoichinoyumi.Any = set_combine(sets.Preshot.Yoichinoyumi,{body="Amini Caban +1",waist="Yemaya Belt"})

                sets.Preshot.Yoichinoyumi.RDM = set_combine(sets.Preshot.Yoichinoyumi.Any,{head="Orion Beret +3",waist="Impulse Belt",feet="Pursuer's Gaiters"})

                sets.Preshot.Fomalhaut = {
                                head={ name="Taeon Chapeau", augments={'"Snapshot"+5','"Snapshot"+5',}},
                                body={ name="Taeon Tabard", augments={'"Snapshot"+5','"Snapshot"+5',}},hands="Carmine Fin. Ga. +1",back={ name="Belenus's Cape", augments={'"Snapshot"+10',}},waist="Impulse Belt",legs="Adhemar Kecks",feet="Meg. Jam. +2"}

                sets.Preshot.Fomalhaut.Any = set_combine(sets.Preshot.Fomalhaut,{body="Amini Caban +1",waist="Yemaya Belt"})

                sets.Preshot.Fomalhaut.RDM = set_combine(sets.Preshot.Fomalhaut.Any,{head="Orion Beret +3",waist="Impulse Belt",feet="Pursuer's Gaiters"})

                sets.Preshot.Armageddon = {
                                ammo="Eradicating Bullet", head="Sylvan Gapette +2",
                                body="Amini Caban +1",hands="Carmine Fin. Ga. +1",back={ name="Belenus's Cape", augments={'"Snapshot"+10',}},waist="Impulse Belt",legs="Adhemar Kecks",feet="Meg. Jam. +2"}

                sets.Preshot.Armageddon.Any = set_combine(sets.Preshot.Armageddon,{body="Amini Caban +1",head="Orion Beret +3"})

                sets.Preshot.Armageddon.RDM = set_combine(sets.Preshot.Armageddon.Any,{head="Orion Beret +3",body="Amini Caban +1",hands="Carmine Fin. Ga. +1",waist="Impulse Belt",legs="Adhemar Kecks",feet="Pursuer's Gaiters",
                back={ name="Belenus's Cape", augments={'"Snapshot"+10',}}})

                sets.Preshot.Gastraphetes = {
                                head={ name="Taeon Chapeau", augments={'"Snapshot"+5','"Snapshot"+5',}},
                                body="Amini Caban +1",hands="Carmine Fin. Ga. +1",back={ name="Belenus's Cape", augments={'"Snapshot"+10',}},waist="Impulse Belt",legs="Adhemar Kecks",feet="Meg. Jam. +2"}

                sets.Preshot.Gastraphetes.Any = set_combine(sets.Preshot.Gastraphetes,{head="Orion Beret +3"})

                sets.Preshot.Gastraphetes.RDM = set_combine(sets.Preshot.Gastraphetes.Any,{waist="Yemaya Belt",feet="Pursuer's Gaiters"})

                sets.Preshot.Annihilator = {
                                ammo="Eradicating Bullet", head="Sylvan Gapette +2",
                                body="Amini Caban +1",hands="Carmine Fin. Ga. +1",back={ name="Belenus's Cape", augments={'"Snapshot"+10',}},waist="Impulse Belt",legs="Adhemar Kecks",feet="Meg. Jam. +2"}

                sets.Preshot.Annihilator.Any = set_combine(sets.Preshot.Annihilator,{body="Amini Caban +1",head="Orion Beret +3"})

                sets.Preshot.Annihilator.RDM = set_combine(sets.Preshot.Annihilator.Any,{head="Orion Beret +3",body="Amini Caban +1",hands="Carmine Fin. Ga. +1",waist="Impulse Belt",legs="Adhemar Kecks",feet="Pursuer's Gaiters",
                back={ name="Belenus's Cape", augments={'"Snapshot"+10',}}})

                sets.Preshot.Gandiva = {
                                head={ name="Taeon Chapeau", augments={'"Snapshot"+5','"Snapshot"+5',}},
                                body={ name="Taeon Tabard", augments={'"Snapshot"+5','"Snapshot"+5',}},hands="Carmine Fin. Ga. +1",back={ name="Belenus's Cape", augments={'"Snapshot"+10',}},waist="Impulse Belt",legs="Adhemar Kecks",feet="Meg. Jam. +2"}

                sets.Preshot.Gandiva.Any = set_combine(sets.Preshot.Gandiva,{body="Amini Caban +1",waist="Yemaya Belt"})

                sets.Preshot.Gandiva.RDM = set_combine(sets.Preshot.Gandiva.Any,{head="Orion Beret +3",waist="Impulse Belt",feet="Pursuer's Gaiters"})

                -- Shooting Base Set --
                sets.Midshot = {range="",ammo="",
                                head="Arcadian Beret +1",neck="Ocachi Gorget",ear1="Volley Earring",ear2="Brutal Earring",
                                body="Mummu Jacket +2",hands="Meg. Gloves +2",ring1="Rajas Ring",ring2="Hajduk Ring +1",
                                    back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','"Store TP"+10',}},waist="Kwahu Kachina Belt",legs="Adhemar Kecks",feet="Meg. Jam. +2"}

                sets.Midshot.MidACC = set_combine(sets.Midshot,{
                                ear1="Enervating Earring"})

                sets.Midshot.HighACC = set_combine(sets.Midshot.MidACC,{
                                head="Orion Beret +3",neck="Peacock Charm",ring1="Hajduk Ring",feet="Orion Socks +2"})
                sets.Midshot.Fodder = set_combine(sets.Midshot,{body="Arc. Jerkin +1",ear1="Dedition Earring"})

                -- Fail-Not Sets --
                sets.Midshot.FailNot = {
                                range="Fail-Not",ammo="Chrono Arrow",
                                head="Arcadian Beret +1",neck="Iskur Gorget",ear1="Dedition Earring",ear2="Telos Earring",
                                body="Orion Jerkin +3",hands="Amini Glove. +1",ring1="Ilabrat Ring",ring2="Dingir Ring",
                                back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','"Store TP"+10',}},waist="Kwahu Kachina Belt",legs="Adhemar Kecks +1",feet={ name="Herculean Boots", augments={'Rng.Acc.+24 Rng.Atk.+24','"Subtle Blow"+10','STR+6','Rng.Acc.+2','Rng.Atk.+15',}}}

                sets.Midshot.FailNot.MidACC = set_combine(sets.Midshot.FailNot,{
                                ear1="Enervating Earring"})

                sets.Midshot.FailNot.HighACC = set_combine(sets.Midshot.FailNot.MidACC,{
                                head="Orion Beret +3",ring1="Regal Ring",ring2="Cacoethic Ring +1"})
                sets.Midshot.FailNot.Fodder = set_combine(sets.Midshot.FailNot,{body="Arc. Jerkin +1",ear1="Dedition Earring"})

                -- Yoichinoyumi Sets --
                sets.Midshot.Yoichinoyumi = {
                                range="Yoichinoyumi",ammo="Artemis's Arrow",
                                head="Arcadian Beret +1",neck="Iskur Gorget",ear1="Dedition Earring",ear2="Telos Earring",
                                body="Orion Jerkin +3",hands="Amini Glove. +1",ring1="Ilabrat Ring",ring2="Dingir Ring",
                                back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','"Store TP"+10',}},waist="Kwahu Kachina Belt",legs="Adhemar Kecks +1",feet="Adhe. Gamashes +1"}

                sets.Midshot.Yoichinoyumi.MidACC = set_combine(sets.Midshot.Yoichinoyumi,{
                                ear1="Enervating Earring"})

                sets.Midshot.Yoichinoyumi.HighACC = set_combine(sets.Midshot.Yoichinoyumi.MidACC,{
                                head="Orion Beret +3",ring1="Regal Ring",ring2="Cacoethic Ring +1"})
                sets.Midshot.Yoichinoyumi.Fodder = set_combine(sets.Midshot.Yoichinoyumi,{body="Arc. Jerkin +1"})

                -- Fomalhaut Sets --
                sets.Midshot.Fomalhaut = {
                                range="Fomalhaut",ammo="Chrono Bullet",head="Arcadian Beret +1",neck="Iskur Gorget",ear1="Dedition Earring",ear2="Telos Earring",body="Orion Jerkin +3",hands="Adhemar wristbands",ring1="Ilabrat Ring",ring2="Regal Ring",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','"Store TP"+10',}},waist="Kwahu Kachina Belt",legs="Adhemar Kecks +1",feet="Adhe. Gamashes +1"}

                sets.Midshot.Fomalhaut.MidACC = set_combine(sets.Midshot.Fomalhaut,{
                                ear1="Enervating Earring"})

                sets.Midshot.Fomalhaut.HighACC = set_combine(sets.Midshot.Fomalhaut.MidACC,{
                                head="Orion Beret +3",feet="Orion Socks +3",ring1="Cacoethic Ring +1"})
                sets.Midshot.Fomalhaut.Fodder = set_combine(sets.Midshot.Fomalhaut,{body="Arc. Jerkin +1",ear1="Dedition Earring"})

                -- Gastraphetes Sets --
                sets.Midshot.Gastraphetes = {
                                range="Gastraphetes",head="Arcadian Beret +1",neck="Iskur Gorget",ear1="Dedition Earring",ear2="Telos Earring",body="Orion Jerkin +3",hands="Adhemar wristbands",ring1="Ilabrat Ring",ring2="Regal Ring",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','"Store TP"+10',}},waist="Kwahu Kachina Belt",legs="Adhemar Kecks +1",feet="Adhe. Gamashes +1"}

                sets.Midshot.Gastraphetes.MidACC = set_combine(sets.Midshot.Gastraphetes,{
                                ear1="Enervating Earring"})

                sets.Midshot.Gastraphetes.HighACC = set_combine(sets.Midshot.Gastraphetes.MidACC,{
                                head="Orion Beret +3",feet="Orion Socks +3",ring1="Cacoethic Ring +1"})
                sets.Midshot.Gastraphetes.Fodder = set_combine(sets.Midshot.Gastraphetes,{body="Arc. Jerkin +1",ear1="Dedition Earring"})

                -- Annihilator Sets --
                sets.Midshot.Annihilator = {range="Annihilator",ammo="Eradicating Bullet",head="Arcadian Beret +1",neck="Ocachi Gorget",ear1="Volley Earring",ear2="Sherida Earring",
                                body="Mummu Jacket +2",hands="Meg. Gloves +2",ring1="Rajas Ring",ring2="Apate Ring",
                                    back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','"Store TP"+10',}},waist="Kwahu Kachina Belt",legs="Adhemar Kecks",feet="Meg. Jam. +2"}

                sets.Midshot.Annihilator.MidACC = set_combine(sets.Midshot.Annihilator,{ear1="Enervating Earring"})

                sets.Midshot.Annihilator.HighACC = set_combine(sets.Midshot.Annihilator.MidACC,{
                head="Orion Beret +3",neck="Peacock Charm",ring1="Hajduk Ring",ring2="Hajduk Ring +1",feet="Orion Socks +2"})

                sets.Midshot.Annihilator.Fodder = set_combine(sets.Midshot.Annihilator,{body="Arc. Jerkin +1"})

                -- Gandiva Sets --
                sets.Midshot.Gandiva = {range="Gandiva",head="Arcadian Beret +1",neck="Iskur Gorget",ear1="Dedition Earring",ear2="Telos Earring",body="Orion Jerkin +3",hands="Amini Glove. +1",ring1="Ilabrat Ring",ring2="Regal Ring",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','"Store TP"+10',}},waist="Kwahu Kachina Belt",legs="Adhemar Kecks +1",feet="Adhe. Gamashes +1"}

                sets.Midshot.Gandiva.MidACC = {head="Meghanada Visor +2",neck="Iskur Gorget",ear1="Enervating Earring",ear2="Telos Earring",body="Mummu Jacket +2",hands="Kobo Kote",ring1="Begrudging Ring",ring2="Mummu Ring",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','Crit.hit rate+10',}},waist="Kwahu Kachina Belt",legs="Adhemar Kecks +1",feet="Adhe. Gamashes +1"}

                sets.Midshot.Gandiva.HighACC = set_combine(sets.Midshot.Gandiva,{head="Orion Beret +3",feet="Orion Socks +3",ring1="Cacoethic Ring +1"})

                sets.Midshot.Gandiva.Fodder = set_combine(sets.Midshot.Gandiva,{body="Arc. Jerkin +1"})

                -- Armageddon Sets --
                sets.Midshot.Armageddon = { range="Armageddon",ammo="Eradicating Bullet",head="Arcadian Beret +1",neck="Ocachi Gorget",ear1="Volley Earring",ear2="Sherida Earring",
                                body="Mummu Jacket +2",hands="Meg. Gloves +2",ring1="Rajas Ring",ring2="Apate Ring",
                                    back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','"Store TP"+10',}},waist="Kwahu Kachina Belt",legs="Adhemar Kecks",feet="Meg. Jam. +2"}

                sets.Midshot.Armageddon.MidACC =  {}

                sets.Midshot.Armageddon.HighACC = set_combine(sets.Midshot.Armageddon.MidACC,{
                head="Orion Beret +3",neck="Peacock Charm",ring1="Hajduk Ring",ring2="Hajduk Ring +1",feet="Orion Socks +2"})

                sets.Midshot.Armageddon.Fodder = set_combine(sets.Midshot.Armageddon,{body="Arc. Jerkin +1"})                

                -- Barrage Base Set --
                Barrage = {
                                head="Orion Beret +3",body="Mummu Jacket +2",hands="Orion Bracers +2",neck="Peacock Charm",
                                legs="Adhemar Kecks",feet="Orion Socks +2",ear1="Volley Earring",ear2="Sherida Earring",waist="Kwahu Kachina Belt",ring1="Hajduk Ring",ring2="Hajduk Ring +1",
                                back={ name="Belenus's Cape", augments={'AGI+27','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','Weapon skill damage +10%',}}}

                -- Fail-Not Barrage Sets --
                sets.Midshot.FailNot.Barrage = set_combine(sets.Midshot.FailNot, {
                                head="Orion Beret +3",body="Orion Jerkin +3",hands="Orion Bracers +3",neck="Iskur Gorget",legs="Adhemar Kecks +1",ring1="Dingir Ring"})

                sets.Midshot.FailNot.MidACC.Barrage = set_combine(sets.Midshot.FailNot.MidACC, {
                                head="Orion Beret +3",body="Orion Jerkin +3",hands="Orion Bracers +3",ring2="Cacoethic Ring +1",ring1="Dingir Ring",
                                legs="Adhemar Kecks +1",feet="Orion Socks +3"})

                sets.Midshot.FailNot.HighACC.Barrage = set_combine(sets.Midshot.FailNot.HighACC, {
                                head="Orion Beret +3",body="Orion Jerkin +3",hands="Orion Bracers +3",ring1="Regal Ring",ring2="Cacoethic Ring +1",
                                legs="Adhemar Kecks +1",feet="Orion Socks +3"})
                sets.Midshot.FailNot.Fodder.Barrage = sets.Midshot.FailNot.Barrage

                -- Yoichinoyumi Barrage Sets --
                sets.Midshot.Yoichinoyumi.Barrage = set_combine(sets.Midshot.Yoichinoyumi, {
                                head="Orion Beret +3",body="Orion Jerkin +3",hands="Orion Bracers +3",neck="Iskur Gorget",legs="Adhemar Kecks +1",ring1="Dingir Ring"})

                sets.Midshot.Yoichinoyumi.MidACC.Barrage = set_combine(sets.Midshot.Yoichinoyumi.MidACC, {
                                head="Orion Beret +3",body="Orion Jerkin +3",hands="Orion Bracers +3",ring2="Cacoethic Ring +1",ring1="Dingir Ring",
                                legs="Adhemar Kecks +1",feet="Orion Socks +3"})

                sets.Midshot.Yoichinoyumi.HighACC.Barrage = set_combine(sets.Midshot.Yoichinoyumi.HighACC, {
                                head="Orion Beret +3",body="Orion Jerkin +3",hands="Orion Bracers +3",ring1="Regal Ring",ring2="Cacoethic Ring +1",
                                legs="Adhemar Kecks +1",feet="Orion Socks +3"})
                sets.Midshot.Yoichinoyumi.Fodder.Barrage = sets.Midshot.Yoichinoyumi.Barrage

                -- Fomalhaut Barrage Sets --
                sets.Midshot.Fomalhaut.Barrage = set_combine(sets.Midshot.Fomalhaut, {
                                head="Orion Beret +3",body="Orion Jerkin +3",hands="Orion Bracers +3",neck="Iskur Gorget",legs="Adhemar Kecks +1",ring1="Dingir Ring"})

                sets.Midshot.Fomalhaut.MidACC.Barrage = set_combine(sets.Midshot.Fomalhaut.MidACC,{
                                head="Orion Beret +3",body="Orion Jerkin +3",hands="Orion Bracers +3",ring2="Cacoethic Ring +1",ring1="Dingir Ring",
                                legs="Adhemar Kecks +1",feet="Orion Socks +3"})

                sets.Midshot.Fomalhaut.HighACC.Barrage = set_combine(sets.Midshot.Fomalhaut.HighACC,{
                                head="Orion Beret +3",body="Orion Jerkin +3",hands="Orion Bracers +3",ring1="Regal Ring",ring2="Cacoethic Ring +1",
                                legs="Adhemar Kecks +1",feet="Orion Socks +3"})
                sets.Midshot.Fomalhaut.Fodder.Barrage = sets.Midshot.Fomalhaut.Barrage

                -- Armageddon Barrage Sets --
                sets.Midshot.Armageddon.Barrage = set_combine(sets.Midshot.Armageddon, {
                                })

                sets.Midshot.Armageddon.MidACC.Barrage = set_combine(sets.Midshot.Armageddon,{
                            })

                sets.Midshot.Armageddon.HighACC.Barrage = set_combine(sets.Midshot.Armageddon.HighACC,{
                             })
--                sets.Midshot.Armageddon.Fodder.Barrage = sets.Midshot.Armageddon.Barrage

                -- Gastraphetes Barrage Sets --
                sets.Midshot.Gastraphetes.Barrage = set_combine(sets.Midshot.Gastraphetes, {
                                head="Orion Beret +3",body="Orion Jerkin +3",hands="Orion Bracers +3",neck="Iskur Gorget",legs="Adhemar Kecks +1",ring1="Dingir Ring"})

                sets.Midshot.Gastraphetes.MidACC.Barrage = set_combine(sets.Midshot.Gastraphetes.MidACC,{
                                head="Orion Beret +3",body="Orion Jerkin +3",hands="Orion Bracers +3",ring2="Cacoethic Ring +1",ring1="Dingir Ring",
                                legs="Adhemar Kecks +1",feet="Orion Socks +3"})

                sets.Midshot.Gastraphetes.HighACC.Barrage = set_combine(sets.Midshot.Gastraphetes.HighACC,{
                                head="Orion Beret +3",body="Orion Jerkin +3",hands="Orion Bracers +3",ring1="Regal Ring",ring2="Cacoethic Ring +1",
                                legs="Adhemar Kecks +1",feet="Orion Socks +3"})
                sets.Midshot.Gastraphetes.Fodder.Barrage = sets.Midshot.Gastraphetes.Barrage

               -- Annihilator Barrage Sets --
               sets.Midshot.Annihilator.Barrage = set_combine(sets.Midshot.Annihilator,{})

               sets.Midshot.Annihilator.MidACC.Barrage = set_combine(sets.Midshot.Annihilator.MidACC,{
                               })

               sets.Midshot.Annihilator.HighACC.Barrage = set_combine(sets.Midshot.Annihilator.HighACC,{
                                })

               sets.Midshot.Annihilator.Fodder.Barrage = sets.Midshot.Annihilator.Barrage
               --Gandiva Barrage Sets --
               sets.Midshot.Gandiva.Barrage = set_combine(sets.Midshot.Gandiva, {
                                head="Orion Beret +3",body="Orion Jerkin +3",hands="Orion Bracers +3",neck="Iskur Gorget",legs="Adhemar Kecks +1",ring1="Dingir Ring"})

               sets.Midshot.Gandiva.MidACC.Barrage = set_combine(sets.Midshot.Gandiva,{
                                head="Orion Beret +3",body="Orion Jerkin +3",hands="Orion Bracers +3",ring2="Cacoethic Ring +1",ring1="Dingir Ring",
                                legs="Adhemar Kecks +1",feet="Orion Socks +3"})

               sets.Midshot.Gandiva.HighACC.Barrage = set_combine(sets.Midshot.Gandiva.HighACC,{
                                head="Orion Beret +3",body="Orion Jerkin +3",hands="Orion Bracers +3",ring1="Regal Ring",ring2="Cacoethic Ring +1",
                                legs="Adhemar Kecks +1",feet="Orion Socks +3"})

               sets.Midshot.Gandiva.Fodder.Barrage = sets.Midshot.Gandiva.Barrage

               -- Doubleshot Sets --
               sets.Doubleshot = {head="Oshosi Mask",body="Oshoshi Vest",hands="Oshoshi Gloves",legs="Oshosi Trousers",feet="Oshosi Leggings"}

               -- Fail-Not Doubleshot Sets --
               sets.Midshot.FailNot.Doubleshot = set_combine(sets.Midshot.FailNot,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.FailNot.MidACC.Doubleshot = set_combine(sets.Midshot.FailNot.MidACC,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.FailNot.HighACC.Doubleshot = set_combine(sets.Midshot.FailNot.HighACC,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.FailNot.Fodder.Doubleshot = set_combine(sets.Midshot.FailNot,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               -- Yoichinoyumi Doubleshot Sets --
               sets.Midshot.Yoichinoyumi.Doubleshot = set_combine(sets.Midshot.Yoichinoyumi,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Yoichinoyumi.MidACC.Doubleshot = set_combine(sets.Midshot.Yoichinoyumi.MidACC,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Yoichinoyumi.HighACC.Doubleshot = set_combine(sets.Midshot.Yoichinoyumi.HighACC,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Yoichinoyumi.Fodder.Doubleshot = set_combine(sets.Midshot.Yoichinoyumi.Fodder,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               -- Fomalhaut Doubleshot Sets --
               sets.Midshot.Fomalhaut.Doubleshot = set_combine(sets.Midshot.Fomalhaut,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Fomalhaut.MidACC.Doubleshot = set_combine(sets.Midshot.Fomalhaut.MidACC,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Fomalhaut.HighACC.Doubleshot = set_combine(sets.Midshot.Fomalhaut.HighACC,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Fomalhaut.Fodder.Doubleshot = sets.Midshot.Fomalhaut.Doubleshot

               -- Armageddon Doubleshot Sets --
               sets.Midshot.Armageddon.Doubleshot = set_combine(sets.Midshot.Armageddon,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Armageddon.MidACC.Doubleshot = set_combine(sets.Midshot.Armageddon.MidACC,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Armageddon.HighACC.Doubleshot = set_combine(sets.Midshot.Armageddon.HighACC,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

--               sets.Midshot.Armageddon.Fodder.Doubleshot = sets.Midshot.Armageddon.Doubleshot

               --Gastraphetes Doubleshot Sets--
               sets.Midshot.Gastraphetes.Doubleshot = set_combine(sets.Midshot.Gastraphetes,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Gastraphetes.MidACC.Doubleshot = set_combine(sets.Midshot.Gastraphetes.MidACC,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Gastraphetes.HighACC.Doubleshot = set_combine(sets.Midshot.Gastraphetes.HighACC,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Gastraphetes.Fodder.Doubleshot = sets.Midshot.Gastraphetes.Doubleshot

               --Annihilator Doubleshot Sets--
               sets.Midshot.Annihilator.Doubleshot = set_combine(sets.Midshot.Annihilator,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Annihilator.MidACC.Doubleshot = set_combine(sets.Midshot.Annihilator.MidACC,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Annihilator.HighACC.Doubleshot = set_combine(sets.Midshot.Annihilator.HighACC,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Annihilator.Fodder.Doubleshot = sets.Midshot.Annihilator.Doubleshot

               --Gandiva Doubleshot Sets--
               sets.Midshot.Gandiva.Doubleshot = set_combine(sets.Midshot.Gandiva,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Gandiva.MidACC.Doubleshot = set_combine(sets.Midshot.Gandiva.MidACC,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Gandiva.HighACC.Doubleshot = set_combine(sets.Midshot.Gandiva.HighACC,{head="Oshosi Mask",legs="Oshosi Trousers",feet="Oshosi Leggings"})

               sets.Midshot.Gandiva.Fodder.Doubleshot = sets.Midshot.Gandiva.Doubleshot

               --Gandiva Aftermath Set--

               sets.Midshot.Gandiva.AM = set_combine(sets.Midshot.Gandiva,{head="Meghanada Visor +2",ear1="Enervating Earring",body="Mummu Jacket +2",hands="Kobo Kote",ring1="Begrudging Ring",ring2="Mummu Ring",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','Crit.hit rate+10',}},waist="Kwahu Kachina Belt",legs="Adhemar Kecks +1",feet="Adhe. Gamashes +1"})

               --Camouflage Sets--
               sets.Midshot.Camouflage = {}

               sets.Midshot.FailNot.Camouflage = {head="Meghanada Visor +2",neck="Iskur Gorget",ear1="Enervating Earring",body="Meghanada Cuirie +2",hands="Kobo Kote",ring1="Begrudging Ring",ring2="Mummu Ring",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','Crit.hit rate+10',}},waist="Kwahu Kachina Belt",legs="Darraigner's Brais",feet="Thereoid Greaves"}

               sets.Midshot.Yoichinoyumi.Camouflage = {head="Meghanada Visor +2",neck="Iskur Gorget",ear1="Enervating Earring",body="Meghanada Cuirie +2",hands="Kobo Kote",ring1="Begrudging Ring",ring2="Mummu Ring",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','Crit.hit rate+10',}},waist="Kwahu Kachina Belt",legs="Darraigner's Brais",feet="Thereoid Greaves"}

               sets.Midshot.Fomalhaut.Camouflage = {head="Meghanada Visor +2",neck="Iskur Gorget",ear1="Enervating Earring",body="Meghanada Cuirie +2",hands="Kobo Kote",ring1="Begrudging Ring",ring2="Mummu Ring",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','Crit.hit rate+10',}},waist="Kwahu Kachina Belt",legs="Darraigner's Brais",feet="Thereoid Greaves"}

               sets.Midshot.Armageddon.Camouflage = {head="Mummu Bonnet +2",body="Mummu Jacket +2",hands="Mummu Wrists +1",waist="Kwahu Kachina Belt",legs="Mummu Kecks +2",feet="Mummu Gamashes +1"}

               sets.Midshot.Annihilator.Camouflage = {head="Mummu Bonnet +2",body="Mummu Jacket +2",hands="Mummu Wrists +1",waist="Kwahu Kachina Belt",legs="Mummu Kecks +2",feet="Mummu Gamashes +1"}

               sets.Midshot.Gastraphetes.Camouflage = {head="Meghanada Visor +2",neck="Iskur Gorget",ear1="Enervating Earring",body="Meghanada Cuirie +2",hands="Kobo Kote",ring1="Begrudging Ring",ring2="Mummu Ring",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','Crit.hit rate+10',}},waist="Kwahu Kachina Belt",legs="Darraigner's Brais",feet="Thereoid Greaves"}

               sets.Midshot.Gandiva.Camouflage = {head="Meghanada Visor +2",neck="Iskur Gorget",ear1="Enervating Earring",body="Meghanada Cuirie +2",hands="Kobo Kote",ring1="Begrudging Ring",ring2="Mummu Ring",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','Crit.hit rate+10',}},waist="Kwahu Kachina Belt",legs="Darraigner's Brais",feet="Thereoid Greaves"}

                -- PDT/MDT Sets --
                sets.PDT = {
                                head="Meghanada Visor +2",body="Meg. Cuirie +2",hands="Meg. Gloves +2",ring1="Patricius Ring",ring2="Defending Ring",back="Moonbeam Cape",legs="Carmine Cuisses +1",waist="Flume Belt +1",feet="Meg. Jam. +2",neck="Loricate Torque +1"}

                sets.MDT = {
                                head="Dampening Tam",neck="Loricate Torque +1",body="Orion Jerkin +3",hands="Floral Gauntlets",ring1="Fortified Ring",ring2="Defending Ring",legs="Gyve trousers",feet="Oshosi Leggings",waist="Flax Sash",back="Moonbeam Cape",ear1="Etiolation Earring",ear2="Static Earring"}

                -- Melee Sets --
                sets.Melee = {
                                head="Mummu Bonnet +2",neck="Anu Torque",ear1="Brutal Earring",ear2="Suppanomimi",body="Mummu Jacket +2",hands="Mummu Wrists +1",ring1="Mummu Ring",ring2="Rajas Ring",back="Bleating Mantle",waist="Windbuffet Belt +1",legs="Mummu Kecks +2",feet="Mummu Gamash. +2"}

                sets.Melee.MidACC = set_combine(sets.Melee,{})

                sets.Melee.HighACC = set_combine(sets.Melee.MidACC,{feet="Meg. Jam. +2"})

                sets.Melee.Fodder = set_combine(sets.Melee,{})

                -- WS Base Set --
                sets.WS = {}

                -- WS Sets --
                -- Apex Arrow --
                sets.WS['Apex Arrow'] = set_combine(sets.WS,{
                                head="Orion Beret +3",neck="Fotia Gorget",body={ name="Herculean Vest", augments={'Rng.Acc.+26','Weapon skill damage +3%','AGI+15',}},hands="Meg. Gloves +2",ring1="Dingir Ring",ring2="Ilabrat Ring",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','AGI+10','Weapon skill damage +10%',}},waist="Fotia Belt",legs={ name="Herculean Trousers", augments={'Weapon skill damage +3%','AGI+10','Rng.Acc.+11','Rng.Atk.+12',}},feet={ name="Herculean Boots", augments={'Rng.Atk.+10','Weapon skill damage +4%','AGI+9','Rng.Acc.+2',}}})

                sets.WS['Apex Arrow'].MidACC = set_combine(sets.WS["Apex Arrow"],{
                                ring2="Cacoethic Ring +1"})

                sets.WS['Apex Arrow'].HighACC = set_combine(sets.WS["Apex Arrow"].MidACC,{
                                body="Orion Jerkin +3"})

                sets.WS['Apex Arrow'].Fodder = sets.WS['Apex Arrow']

                -- Namas Arrow Sets --
                sets.WS['Namas Arrow'] = set_combine(sets.WS,{
                                head="Orion Beret +3",neck="Fotia Gorget",body={ name="Herculean Vest", augments={'Rng.Acc.+26','Weapon skill damage +3%','AGI+15',}},hands="Meg. Gloves +2",ring1="Regal Ring",ring2="Ilabrat Ring",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','AGI+10','Weapon skill damage +10%',}},waist="Fotia Belt",legs={ name="Herculean Trousers", augments={'Weapon skill damage +3%','AGI+10','Rng.Acc.+11','Rng.Atk.+12',}},feet={ name="Herculean Boots", augments={'Rng.Atk.+10','Weapon skill damage +4%','AGI+9','Rng.Acc.+2',}}})

                sets.WS['Namas Arrow'].MidACC = set_combine(sets.WS["Namas Arrow"],{
                                ring2="Cacoethic Ring +1"})

                sets.WS['Namas Arrow'].HighACC = set_combine(sets.WS["Namas Arrow"].MidACC,{
                                body="Orion Jerkin +3"})

                sets.WS['Namas Arrow'].Fodder = sets.WS['Namas Arrow']

                -- Jishnu's Radiance --
                sets.WS["Jishnu's Radiance"] = set_combine(sets.WS, {
                                head="Adhemar Bonnet",neck="Fotia Gorget",ear1="Sherida Earring",ear2="Moonshade Earring",body="Meg. Cuirie +2",hands="Kobo Kote",ring1="Begrudging Ring",ring2="Ilabrat Ring",back={ name="Belenus's Cape", augments={'DEX+20','Rng.Acc.+20 Rng.Atk.+20','Crit.hit rate+10',}},waist="Fotia Belt",legs="Darraigner's Brais",feet="Thereoid greaves"})

                sets.WS["Jishnu's Radiance"].MidACC = set_combine(sets.WS    ["Jishnu's Radiance"],{
                                feet="Mummu Gamash. +2",
                                ear1="Telos Earring"})
                sets.WS["Jishnu's Radiance"].HighACC = set_combine(sets.WS["Jishnu's Radiance"].MidACC,{
                                })

                sets.WS["Jishnu's Radiance"].Fodder = sets.WS["Jishnu's Radiance"]

                -- Last Stand --
                sets.WS['Last Stand'] = set_combine(sets.WS, {
                                ammo="Eradicating Bullet",head="Orion Beret +3",neck="Fotia Gorget",ear1="Ishvara Earring",ear2="Moonshade Earring",body="Mummu Jacket +2",hands="Meg. Gloves +2",ring1="Stormsoul Ring",ring2="Regal Ring",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','AGI+10','Weapon skill damage +10%',}},waist="Fotia Belt",legs={ name="Herculean Trousers", augments={'AGI+8','Rng.Acc.+13','Rng.Atk.+28','Weapon skill damage +5%'}},feet="Orion Socks +2"})

                sets.WS['Last Stand'].MidACC = set_combine(sets.WS["Last Stand"],{
                                })

                sets.WS['Last Stand'].HighACC = set_combine(sets.WS["Last Stand"].MidACC,{
                                head="Orion Beret +3",legs="Mummu Kecks +2",feet="Meg. Jam. +2"})

                sets.WS['Last Stand'].Fodder = sets.WS['Last Stand']

                --Coronach--
                sets.WS['Coronach'] = set_combine(sets.WS['Last Stand'], {})

                sets.WS['Coronach'].MidACC = set_combine(sets.WS['Last Stand'].MidACC, {})

                sets.WS['Coronach'].HighACC = set_combine(sets.WS['Last Stand'].HighACC, {})

                -- Trueflight --
                sets.WS['Trueflight'] = {
                    ammo="Devastating Bullet",
                    head="Orion Beret +3",
                    body="Samnuha Coat",
                    hands="Carmine Fin. Ga. +1",
                    legs={ name="Herculean Trousers", augments={'Mag. Acc.+19 "Mag.Atk.Bns."+19','VIT+2','Mag. Acc.+13','"Mag.Atk.Bns."+10',}},
                    feet={ name="Herculean Boots", augments={'STR+6','"Mag.Atk.Bns."+21','Accuracy+6 Attack+6','Mag. Acc.+15 "Mag.Atk.Bns."+15',}},
                    neck="Fotia Gorget",
                    waist="Fotia Belt",
                    left_ear="Ishvara Earring",
                    right_ear="Friomisi Earring",
                    left_ring="Weatherspoon Ring",
                    right_ring="Regal Ring",
                    back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','AGI+10','Weapon skill damage +10%',}}}

                sets.WS['Trueflight'].MidACC = set_combine(sets.WS["Trueflight"],{
                                neck="Sanctity Necklace",ear1="Digni. Earring"})

                sets.WS['Trueflight'].HighACC = set_combine(sets.WS["Trueflight"].MidACC,{
                                head="Carmine Mask +1"})

                sets.WS['Trueflight'].Fodder = sets.WS['Trueflight']

                -- Wildfire --
                sets.WS['Wildfire'] = set_combine(sets.WS["Trueflight"],{head="Orion Beret +3",ring1="Ilabrat Ring",ear2="Novio earring",hands="Meg. Gloves +2"})

                sets.WS['Wildfire'].MidACC = set_combine(sets.WS["Trueflight"].MidACC,{head="Orion Beret +3",ring1="Ilabrat Ring",ear2="Novio earring",hands="Meg. Gloves +2"})

                sets.WS['Wildfire'].HighACC = set_combine(sets.WS["Trueflight"].HighACC,{ring1="Ilabrat Ring",ear2="Novio earring",hands="Meg. Gloves +2"})

                sets.WS['Wildfire'].Fodder = sets.WS['Wildfire']

                sets.WS['Hot Shot'] = set_combine(sets.WS["Trueflight"],{neck="Fotia Gorget",waist="Fotia Belt"})

                sets.WS['Hot Shot'].MidACC = set_combine(sets.WS['Hot Shot'],{legs="Adhemar Kecks +1"})

                sets.WS['Hot Shot'].HighACC = set_combine(sets.WS['Hot Shot'].MidACC,{ear2="Telos Earring"})

                sets.WS['Hot Shot'].Fodder = sets.WS['Hot Shot']

                -- Dagger Weapon Skills --

                sets.WS['Exenterator'] = {
                            head="Adhemar Bonnet",neck="Fotia Gorget",ear1="Zennaroi Earring",ear2="Digni. Earring",body="Meg. Cuirie +2",hands="Mummu Wrists +1",ring1="Ilabrat Ring",ring2="Regal Ring",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','AGI+10','Weapon skill damage +10%',}},waist="Fotia Belt",legs="Jokushu Haidate",feet="Thereoid Greaves"}

                sets.WS['Evisceration'] = sets.WS['Exenterator']

                sets.WS['Aeolian Edge'] = sets.WS['Trueflight']

                -- JA Sets --
                sets.JA = {}
                sets.JA.Shadowbind = {
                                head="Orion Beret +3",neck="Iskur Gorget",ear1="Enervating Earring",ear2="Telos Earring",body="Orion Jerkin +3",hands="Orion Bracers +2",ring1="Regal Ring",ring2="Cacoethic Ring +1",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','"Store TP"+10',}},waist="Yemaya Belt",legs="Adhemar Kecks +1",feet="Meg. Jam. +2"}

                sets.JA.Scavenge = {feet="Orion Socks +2"}

                sets.JA.Camouflage = {body="Orion Jerkin +2"}

                sets.JA.Sharpshot = {legs="Orion Braccae +2"}

                sets.JA["Bounty Shot"] = {hands="Amini Glovelettes +1",waist="Chaac Belt"}

                sets.JA["Double Shot"] = {head="Sylvan Gapette +2"}

                sets.JA["Eagle Eye Shot"] = {
                                head="Orion Beret +3",neck="Iskur Gorget",ear1="Enervating Earring",ear2="Telos Earring",body="Orion Jerkin +3",hands="Orion Bracers +3",ring1="Ilabrat Ring",ring2="Dingir Ring",back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','Rng.Acc.+10','"Store TP"+10',}},waist="Yemaya Belt",legs="Arcadian Braccae",feet={ name="Herculean Boots", augments={'Rng.Acc.+24 Rng.Atk.+24','"Subtle Blow"+10','STR+6','Rng.Acc.+2','Rng.Atk.+15',}}}

                sets.JA["Barrage"] = set_combine(sets.Midshot, 
                                {body="Orion Jerkin +3",hands="Orion Bracers +2",neck="Iskur Gorget",legs="Adhemar Kecks +1",feet="Adhe. Gamashes +1",ring1="Regal Ring",ring2="Cacoethic Ring +1"})

                -- Waltz Set --
                sets.Waltz = {head="Mummu Bonnet +2",body="Passion Jacket",}

                sets.Precast = {}
                -- Fastcast Set --
                sets.Precast.FastCast = {
                                head="Carmine Mask +1",neck="Baetyl Pendant",ear1="Loquac. Earring",ear2="Etiolation earring",body="Dread Jupon",hands="Leyline Gloves",ring1="Weather. Ring",ring2="Defending Ring",waist="Rumination Sash",legs="Carmine Cuisses +1",feet="Carmine Greaves +1"}

                -- Utsusemi Precast Set --
                sets.Precast.Utsusemi = set_combine(sets.Precast.FastCast,{body="Passion Jacket",neck="Magoraga Beads"})

                sets.Midcast = {}

                -- Magic Haste Set --
                sets.Midcast.Haste = set_combine(sets.PDT,{})
        end

        function pretarget(spell,action)
                if (spell.type:endswith('Magic') or spell.type == "Ninjutsu") and buffactive.silence then -- Auto Use Echo Drops If You Are Silenced --
                        cancel_spell()
                        send_command('input /item "Echo Drops" <me>')
                elseif spell.english == "Berserk" and buffactive.Berserk then -- Change Berserk To Aggressor If Berserk Is On --
                        cancel_spell()
                        send_command('Aggressor')
                elseif spell.english == "Seigan" and buffactive.Seigan then -- Change Seigan To Third Eye If Seigan Is On --
                        cancel_spell()
                        send_command('ThirdEye')
                elseif spell.english == "Meditate" and player.tp > 290 then -- Cancel Meditate If TP Is Above 290 --
                        cancel_spell()
                        add_to_chat(123, spell.name .. ' Canceled: ['..player.tp..' TP]')
                elseif (spell.english == 'Ranged' and spell.target.distance > 24.9) or (player.status == 'Engaged' and ((ranged_ws:contains(spell.english) and spell.target.distance > 16+target_distance) or (spell.type == "WeaponSkill" and not ranged_ws:contains(spell.english) and spell.target.distance > target_distance))) then -- Cancel Ranged Attack or WS If You Are Out Of Range --
                        cancel_spell()
                        add_to_chat(123, spell.name..' Canceled: [Out of Range]')
                        return
                end
        end

        function precast(spell,action)
                if spell.english == 'Ranged' then
                    equipSet = sets.Preshot

                if buffactive['Flurry'] then

                if PreshotArray[PreshotIndex] == 'RDM' then
                if  equipSet[player.equipment.range].RDM then 
                    equipSet =  equipSet[player.equipment.range].RDM
                end
        else
                if  equipSet[player.equipment.range].Any then 
                    equipSet =  equipSet[player.equipment.range].Any
        end
        end
        else
                if  equipSet[player.equipment.range] then 
                    equipSet =  equipSet[player.equipment.range]
        end

        end

                    equip(equipSet)

                elseif spell.type == "WeaponSkill" then
                                    equipSet = sets.WS
                                if equipSet[spell.english] then
                                        equipSet = equipSet[spell.english]
                                end
                                if equipSet[AccArray[AccIndex]] then
                                        equipSet = equipSet[AccArray[AccIndex]]
                                end
                                if player.tp > 2249     or buffactive.Sekkanoki then
                                        if spell.english == "Last Stand" then -- Equip Telos Earring When You Have 3000 TP or Sekkanoki For Last Stand --
                                                equipSet = set_combine(equipSet,{ear2="Telos Earring"})
                                        elseif spell.english == "Jishnu's Radiance" then -- Equip Telos Earring When You Have 3000 TP or Sekkanoki For Jishnu's Radiance --
                                                equipSet = set_combine(equipSet,{ear2="Telos Earring"})
                                        elseif spell.english == "Trueflight" then --Equip Ishvara Earring When you have 3000 TP or Sekkanoki for Trueflight --
                                                equipSet = set_combine(equipSet,{ear2="Ishvara Earring"})
                                        end
                                end
                                equip(equipSet)

                elseif spell.type=="JobAbility" then
                        if sets.JA[spell.english] then
                                equip(sets.JA[spell.english])
                        end
                elseif spell.type:endswith('Magic') or spell.type == "Ninjutsu" then
                        if string.find(spell.english,'Utsusemi') then
                                if buffactive['Copy Image (3)'] or buffactive['Copy Image (4)'] then
                                        cancel_spell()
                                        add_to_chat(123, spell.name .. ' Canceled: [3+ Images]')
                                        return
                                else
                                        equip(sets.Precast.Utsusemi)
                                end
                        else    
                                equip(sets.Precast.FastCast)
                        end
                elseif spell.type == "Waltz" then
                        equip(sets.Waltz)
                elseif spell.english == 'Spectral Jig' and buffactive.Sneak then
                        cast_delay(0.2)
                        send_command('cancel Sneak')
                end
        end

        function midcast(spell,action)
                if spell.english == 'Ranged' then
                        equipSet = sets.Midshot
                        if equipSet[player.equipment.range] then
                                equipSet = equipSet[player.equipment.range]
                        end
                        if equipSet[AccArray[AccIndex]] then
                                equipSet = equipSet[AccArray[AccIndex]]
                        end

                        if buffactive.Barrage and equipSet["Barrage"] then
                                equipSet = equipSet["Barrage"]
                        end
                        if buffactive['Double Shot'] and equipSet["Doubleshot"] then
                                equipSet = equipSet["Doubleshot"]
                        end
                        if buffactive['Camouflage'] and equipSet["Camouflage"] then
                                equipSet = equipSet["Camouflage"]
                        end

                        equip(equipSet)

                elseif spell.type:endswith('Magic') or spell.type == "Ninjutsu" then
                        if string.find(spell.english,'Utsusemi') then
                                if spell.english == 'Utsusemi: Ichi' and (buffactive['Copy Image'] or buffactive['Copy Image (2)']) then
                                        send_command('@wait 1.7;cancel Copy Image*')
                                end
                                equip(sets.Midcast.Haste)
                        elseif spell.english == 'Monomi: Ichi' then
                                if buffactive['Sneak'] then
                                        send_command('@wait 1.7;cancel sneak')
                                end
                                equip(sets.Midcast.Haste)
                        else
                                equip(sets.Midcast.Haste)
                        end
                end
                        if spell.english == "Trueflight" and (buffactive['Aurorastorm']) then
                        add_to_chat(125,'weather mode') 
                        equip({waist="Hachirin-no-Obi"})

                end
                        if spell.english == "Wildfire" and (buffactive['Firestorm']) then
                        add_to_chat(125,'weather mode')
                        equip({waist="Hachirin-no-Obi"})
                end

    end

        function aftercast(spell,action)
                if spell.english == 'Ranged' and autoRAmode==1 then
                        autoRA()
                elseif spell.type == "WeaponSkill" and not spell.interrupted then
                        send_command('wait 0.2;gs c TP')
                else
                        status_change(player.status)
                end
        end

        function status_change(new,old)
                if Armor == 'PDT' then
                        equip(sets.PDT)
                elseif Armor == 'MDT' then
                        equip(sets.MDT)
                elseif new == 'Engaged' then
                        equipSet = sets.Melee
                        if equipSet[AccArray[AccIndex]] then
                                equipSet = equipSet[AccArray[AccIndex]]
                        end
                        equip(equipSet)
                else
                        equip(sets.Idle[IdleArray[IdleIndex]])
                end
        end

        -- In Game: //gs c (command), Macro: /console gs c (command), Bind: gs c (command) --
        function self_command(command)
                if command == 'acc' then -- Accuracy Level Toggle --
                        AccIndex = (AccIndex % #AccArray) + 1
                        add_to_chat(158,'Accuracy Level: ' .. AccArray[AccIndex])
                        status_change(player.status)
                elseif command == 'flur' then -- Flurry Level Toggle --
                        PreshotIndex = (PreshotIndex % #PreshotArray) + 1
                        add_to_chat(158,'Flurry Level: ' ..PreshotArray[PreshotIndex])
                        status_change(player.status)
                elseif command == 'auto' then -- Auto Update Gear Toggle --
                        status_change(player.status)
                        add_to_chat(158,'Auto Update Gear')
                elseif command == 'pdt' then -- PDT Toggle --
                        if Armor == 'PDT' then
                                Armor = 'None'
                                add_to_chat(123,'PDT Set: [Unlocked]')
                        else
                                Armor = 'PDT'
                                add_to_chat(158,'PDT Set: [Locked]')
                        end
                        status_change(player.status)
                elseif command == 'mdt' then -- MDT Toggle --
                        if Armor == 'MDT' then
                                Armor = 'None'
                                add_to_chat(123,'MDT Set: [Unlocked]')
                        else
                                Armor = 'MDT'
                                add_to_chat(158,'MDT Set: [Locked]')
                        end
                        status_change(player.status)
                elseif command == 'C8' then -- Distance Toggle --
                        if player.target.distance then
                                target_distance = math.floor(player.target.distance*10)/10
                                add_to_chat(158,'Distance: '..target_distance)
                        else
                                add_to_chat(123,'No Target Selected')
                        end
                elseif command == 'C6' then -- Idle Toggle --
                        IdleIndex = (IdleIndex % #IdleArray) + 1
                        add_to_chat(158,'Idle Set: ' .. IdleArray[IdleIndex])
                        status_change(player.status)
                elseif command == 'AutoRA' then -- Auto Ranged Attack Toggle. *Don't Rely On This. It Isn't As Fast As Shooting Manually. It Is Mainly For AFK or When You Dualbox* --
                        if autoRAmode == 0 then
                                autoRAmode = 1
                                add_to_chat(158,'AutoRA Mode: [ON]')
                        else
                                autoRAmode = 0
                                add_to_chat(123,'AutoRA Mode: [OFF]')
                        end
                elseif command == 'TP' then
                        add_to_chat(158,'TP Return: ['..tostring(player.tp)..']')
                elseif command:match('^SC%d$') then
                        send_command('//' .. sc_map[command])
                end
        end

        function autoRA()
                send_command('@wait 2.5; input /ra <t>')
        end

SMN Gearset

-- Setup your Key Bindings here:  
    windower.send_command('bind f7 gs c toggle mb')
    windower.send_command('bind f9 gs c avatar mode')
    windower.send_command('bind f10 gs c toggle auto')
    windower.send_command('bind f12 gs c toggle melee')

-- Setup your Gear Sets below:
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 = {}        -- leave this empty
    sets.avatar = {}    -- leave this empty

    -- Your idle set when you DON'T have an avatar out
    sets.me.idle = {
        main="Nirvana",
 --       sub="Vox Grip",
        ranged="",
        ammo="Sancus Sachet +1",
        head="Convoker's Horn +2",
        neck="Caller's Pendant",
        lear="Handler's Earring +1",
        rear="Enmerkar Earring",
        body="Beckoner's Doublet +1",
        hands="Glyphic Bracers +1",
        lring="Evoker's Ring",
        rring="Karieyh Ring",
        back={ name="Campestres's Cape", augments={'Pet: Acc.+20 Pet: R.Acc.+20 Pet: Atk.+20 Pet: R.Atk.+20','Pet: "Regen"+10',}},
        waist="Klouskap Sash",
        legs="Convoker's Spats +2",
        feet="Herald's Gaiters"
    }

    -- Your MP Recovered Whilst Resting Set
    sets.me.resting = { 
        main="Nirvana",
 --       sub="Vox Grip",
        ranged="",
        ammo="",
        head="Yigit Turban",
        neck="Eidolon Pendant +1",
        lear="Moonshade Earring",
        rear="Magnetic Earring",
        body="Yigit Gomlek",
        hands="",
        lring="",
        rring="",
        back="",
        waist="",
        legs="Yigit Seraweels",
        feet="Numerist Pumps"
    }

    -----------------------
    -- Perpetuation Related
    -----------------------

    -- Avatar's Out --  
    -- This is the base for all perpetuation scenarios, as seen below
    sets.avatar.perp = {
        main="Nirvana",
  --      sub="Vox Grip",
        ranged="",
        ammo="Sancus Sachet +1",
        head="Beckoner's Horn +1",
        neck="Caller's Pendant",
        lear="Handler's Earring +1",
        rear="Enmerkar Earring",
        body="Beckoner's Doublet +1",
        hands="Beckoner's Bracers +1",
        lring="Evoker's Ring",
        rring="Karieyh Ring",
    back={ name="Campestres's Cape", augments={'Pet: Acc.+20 Pet: R.Acc.+20 Pet: Atk.+20 Pet: R.Atk.+20','Accuracy+20 Attack+20','Pet: Accuracy+10 Pet: Rng. Acc.+10','Pet: "Regen"+10',}},
        waist="Klouskap Sash",
        legs="Convoker's Spats +2",
        feet="Convoker's Pigaches +2"
    }

    -- 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!
    sets.avatar["Carbuncle"] = {hands="Asteria Mitts +1"}
    sets.avatar["Cait Sith"] = {hands="Lamassu Mitts +1"}
    -- When we want our avatar to stay alive
    sets.avatar.tank = set_combine(sets.avatar.perp,{
        main="",
        sub="",
        ranged="",
        ammo="",
        head="Selenian Cap",
        neck="Caller's Pendant",
        lear="Enmerkar Earring",
        rear="Handler's Earring +1",
        body="Beckoner's Doublet +1",
        hands="Baayami Cuffs",
        lring="Evoker's Ring",
        rring="Karieyh Ring",
back={ name="Campestres's Cape", augments={'Pet: Acc.+20 Pet: R.Acc.+20 Pet: Atk.+20 Pet: R.Atk.+20','Accuracy+20 Attack+20','Pet: Accuracy+10 Pet: Rng. Acc.+10','Pet: "Regen"+10',}},
        waist="Klouskap Sash",
        legs="Apogee Slacks",
        feet="Apogee Pumps"
    })

    -- 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="Nirvana",
  --      sub="Vox Grip",
        ranged="",
        ammo="Sancus Sachet +1",
        head="Beckoner's Horn +1",
        neck="Caller's Pendant",
        lear="Moonshade Earring",
        rear="Enmerkar Earring",
        body="Beckoner's Doublet +1",
        hands="Beckoner's Bracers +1",
        lring="Evoker's Ring",
        rring="Karieyh Ring",
    back={ name="Campestres's Cape", augments={'Pet: Acc.+20 Pet: R.Acc.+20 Pet: Atk.+20 Pet: R.Atk.+20','Accuracy+20 Attack+20','Pet: Accuracy+10 Pet: Rng. Acc.+10','Pet: "Regen"+10',}},
        waist="Klouskap Sash",
        legs="Convoker's Spats +2",
        feet="Apogee Pumps"
    })

    ----------------------------
    -- 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="Vox Grip",
        ranged="",
        ammo="Sancus Sachet +1",
        head="Baayami Hat",
        neck="Caller's Pendant",
        lear="Smn. Earring",
        rear="Andoaa Earring",
        body="Beckoner's Doublet +1",
        hands="Baayami Cuffs",
        lring="Evoker's Ring",
        rring="Fervor Ring",
        back="Conveyance Cape",
        waist="Lucidity Sash",
        legs="Baayami Slops",
        feet="Baayami Sabots"
    }

    -------------------------
    -- Individual Blood Pacts
    -------------------------

    -- Physical damage
    sets.avatar.atk = set_combine(sets.avatar.skill,{
        main="Nirvana",
        sub="Elan Strap",
        ranged="",
        ammo="Sancus Sachet +1",
        head="Convoker's Horn +2",
        neck="Shulmanu Collar",
        lear="Gelos Earring",
        rear="Enmerkar Earring",
        body="Convoker's Doublet +2",
    hands="Convoker's Bracers +2",
        lring="Varar Ring",
        rring="Varar Ring",
    back={ name="Campestres's Cape", augments={'Pet: Acc.+20 Pet: R.Acc.+20 Pet: Atk.+20 Pet: R.Atk.+20','Accuracy+20 Attack+20','Pet: Accuracy+10 Pet: Rng. Acc.+10','Pet: "Regen"+10',}},
        waist="Incarnation Sash",
        legs="Convoker's Spats +2",
        feet="Convoker's Pigaches +2"
    })
    sets.avatar.pacc = set_combine(sets.avatar.atk,{
        main="Nirvana",
        sub="Elan Strap",
        ranged="",
        ammo="Sancus Sachet +1",
        head="Convoker's Horn +2",
        neck="Shulmanu Collar",
        lear="Gelos Earring",
        rear="Enmerkar Earring",
        body="Convoker's Doublet +2",
        hands="Convoker's Bracers +2",
        lring="Evoker's Ring",
        rring="Varar Ring",
    back={ name="Campestres's Cape", augments={'Pet: Acc.+20 Pet: R.Acc.+20 Pet: Atk.+20 Pet: R.Atk.+20','Accuracy+20 Attack+20','Pet: Accuracy+10 Pet: Rng. Acc.+10','Pet: "Regen"+10',}},
        waist="Incarnation Sash",
        legs="Convoker's Spats +2",
        feet="Convoker's Pigaches +2"
    })

    -- Magic Attack
    sets.avatar.mab = set_combine(sets.avatar.skill,{
        main="Espiritus",
        sub="Elan Strap",
        ranged="",
        ammo="Sancus Sachet +1",
        head="Apogee Crown",
        neck="Eidolon Pendant +1",
        lear="Gelos Earring",
        rear="Enmerkar Earring",
        body="Convoker's Doublet +2",
    hands={ name="Merlinic Dastanas", augments={'Pet: Mag. Acc.+21 Pet: "Mag.Atk.Bns."+21','"Blood Boon"+2','Pet: Mag. Acc.+12','Pet: "Mag.Atk.Bns."+11',}},
        lring="Varar Ring",
        rring="Varar Ring",
    back={ name="Campestres's Cape", augments={'Pet: M.Acc.+20 Pet: M.Dmg.+20','Pet: Magic Damage+10',}},
        waist="Jaq'ij Sash",
        legs="Apogee Slacks",
        feet="Apogee Pumps"
    })
    sets.avatar.mb = set_combine(sets.avatar.mab,{hands="Glyphic Bracers +1", head="Convoker's Horn +2", legs="Convoker's Spats +2", Feet="Convoker's Pigaches +2"})
    -- Hybrid
    sets.avatar.hybrid = set_combine(sets.avatar.skill,{
        main="Nirvana",
        sub="Elan Strap",
        ranged="",
        ammo="Sancus Sachet +1",
        head="Convoker's Horn +2",
        neck="Shulmanu Collar",
        lear="Gelos Earring",
        rear="Enmerkar Earring",
        body="Convoker's Doublet +2",
    hands="Convoker's Bracers +2",
        lring="Varar Ring",
        rring="Varar Ring",
    back={ name="Campestres's Cape", augments={'Pet: Acc.+20 Pet: R.Acc.+20 Pet: Atk.+20 Pet: R.Atk.+20','Accuracy+20 Attack+20','Pet: Accuracy+10 Pet: Rng. Acc.+10','Pet: "Regen"+10',}},
        waist="Klouskap Sash",
        legs="Convoker's Spats +2",
        feet="Convoker's Pigaches +2"
    })

    -- Magic Accuracy
    sets.avatar.macc = set_combine(sets.avatar.skill,{
        main="Nirvana",
        sub="Elan Strap",
        ranged="",
        ammo="Sancus Sachet +1",
        head="Convoker's Horn +2",
        neck="Shulmanu Collar",
        lear="Gelos Earring",
        rear="Enmerkar Earring",
        body="Convoker's Doublet +2",
    hands="Convoker's Bracers +2",
        lring="Varar Ring",
        rring="Varar Ring",
    back={ name="Campestres's Cape", augments={'Pet: Acc.+20 Pet: R.Acc.+20 Pet: Atk.+20 Pet: R.Atk.+20','Accuracy+20 Attack+20','Pet: Accuracy+10 Pet: Rng. Acc.+10','Pet: "Regen"+10',}},
        waist="Klouskap Sash",
        legs="Convoker's Spats +2",
        feet="Convoker's Pigaches +2"
    })

    -- 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="Nirvana",
--        sub="Vox Grip",
        ranged="",
        ammo="Sancus Sachet +1",
        head="Beckoner's Horn +1",
        neck="Shulmanu Collar",
        lear="Moonshade Earring",
        rear="Magnetic Earring",
        body="Beckoner's Doublet +1",
        hands="Beckoner's Bracers +1",
        lring="Evoker's Ring",
        rring="Fervor Ring",
    back={ name="Campestres's Cape", augments={'Pet: Acc.+20 Pet: R.Acc.+20 Pet: Atk.+20 Pet: R.Atk.+20','Accuracy+20 Attack+20','Pet: Accuracy+10 Pet: Rng. Acc.+10','Pet: "Regen"+10',}},
  --      back="Mecistopins Mantle",
        waist="Klouskap Sash",
        legs="Convoker's Spats +2",
        feet="Convoker's Pigaches +2"
    })

    -- 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="Fotia Gorget",
        lear="",
        rear="",
        body="",
        hands="",
        lring="",
        rring="",
        back="",
        waist="Fotia Belt",
        legs="",
        feet=""
    }
    sets.me["Garland of Bliss"] = {
        main="",
        sub="",
        ranged="",
        ammo="",
        head="",
        neck="Fotia Gorget",
        lear="",
        rear="",
        body="",
        hands="",
        lring="",
        rring="Karieyh Ring",
        back="",
        waist="Fotia Belt",
        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="Amalric Coif",
        neck="",
        lear="Loquac. Earring",
        rear="",
        body="",
        hands="",
        lring="",
        rring="",
        back="",
        waist="",
        legs="",
        feet="Regal Pumps +1"
    }   

    -- Summoning Magic Cast time - gear
    sets.precast.summoning = set_combine(sets.precast.casting,{
        main="",
        sub="",
        ranged="",
        ammo="",
        head="Amalric Coif",
        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="Amalric Coif",
        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="Amalric Coif",
        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="Amalric Coif",
        neck="",
        lear="",
        rear="",
        body="",
        hands="",
        lring="",
        rring="",
        back="",
        waist="",
        legs="",
        feet=""
    })

    ---------------------
    -- Ability Precasting
    ---------------------

    -- Blood Pact Ability Delay -5 Gift
    sets.precast.bp = {
        main="Nirvana",
--        sub="Vox Grip",
        ranged="",
        ammo="Sancus Sachet +1", -- BP II -7
        head="Beckoner's Horn +1", -- Favor +2
        neck="Caller's Pendant",
        lear="Smn. Earring",
        rear="Andoaa Earring",
        body="Glyphic Doublet +1", -- BP II -2
        hands="Glyphic Bracers +1", -- BP I -6
        lring="Evoker's Ring",
        rring="Fervor Ring",
        back="Tiresias' Cape", -- BP I -3
        waist="Lucidity Sash",
        legs="Glyphic Spats +1", -- BP I -6
        feet="Glyphic Pigaches +1" -- BP II -1
    }

    -- Mana Cede
    sets.precast["Mana Cede"] = {
        main="",
        sub="",
        ranged="",
        ammo="",
        head="",
        neck="",
        lear="",
        rear="",
        body="",
        hands="Beckoner's Bracers +1",
        lring="",
        rring="",
        back="",
        waist="",
        legs="",
        feet=""
    }

    -- Astral Flow  
    sets.precast["Astral Flow"] = {
        main="",
        sub="",
        ranged="",
        ammo="",
        head="Glyphic Horn +1",
        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="Amalric Coif",
        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="Amalric Coif",
        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=""
    })
    -- Elemental Siphon, eg, Tatsumaki Thingies, Esper Stone, etc
    sets.midcast.siphon = set_combine(sets.avatar.skill,{
        main="Nirvana",
  --      sub="Vox Grip",
        ranged="",
        ammo="Sancus Sachet +1",
        head="Baayami Hat",
        neck="Caller's Pendant",
        lear="Smn. Earring",
        rear="Andoaa Earring",
        body="Beckoner's Doublet +1",
        hands="Baayami Cuffs",
        lring="Evoker's Ring",
        rring="Zodiac Ring",
        back="Conveyance Cape",
        waist="Lucidity Sash",
        legs="Beckoner's Spats +1",
        feet="Beckoner's Pigaches +1"
    })

    -- 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

SMN Core don't edit this shit

 include('SMN_Gearsets.lua')
 -- Blood Pacts Groupings:    
--[[
     Put: /console gs c pact [PactType] as your macro

        PactType can be one of:
            cure
            curaga
            buffOffense
            buffDefense
            buffSpecial
            debuff1
            debuff2
            sleep
            nuke2
            nuke4
            bp70
            bp75 (merits and lvl 75-80 pacts)
            bp99
            astralflow
--]]

    pacts = {}
    pacts.cure = {['Carbuncle']='Healing Ruby'}
    pacts.curaga = {['Carbuncle']='Healing Ruby II', ['Garuda']='Whispering Wind', ['Leviathan']='Spring Water'}
    pacts.buffoffense = {['Carbuncle']='Glittering Ruby', ['Ifrit']='Crimson Howl', ['Garuda']='Hastega II', ['Ramuh']='Rolling Thunder',
        ['Fenrir']='Ecliptic Growl', ['Shiva']='Crystal Blessing'}
    pacts.buffdefense = {['Carbuncle']='Shining Ruby', ['Shiva']='Frost Armor', ['Garuda']='Aerial Armor', ['Titan']='Earthen Ward',
        ['Ramuh']='Lightning Armor', ['Fenrir']='Ecliptic Howl', ['Diabolos']='Noctoshield', ['Cait Sith']='Reraise II'}
    pacts.buffspecial = {['Ifrit']=' <staff_and_grip Howl', ['Garuda']='Fleet Wind', ['Titan']='Earthen Armor', ['Diabolos']='Dream Shroud',
        ['Carbuncle']='Soothing Ruby', ['Fenrir']='Heavenward Howl', ['Cait Sith']='Raise II'}
    pacts.debuff1 = {['Shiva']='Diamond Storm', ['Ramuh']='Shock Squall', ['Leviathan']='Tidal Roar', ['Fenrir']='Lunar Cry',
        ['Diabolos']='Pavor Nocturnus', ['Cait Sith']='Eerie Eye'}
    pacts.debuff2 = {['Shiva']='Sleepga', ['Leviathan']='Slowga', ['Fenrir']='Lunar Roar', ['Diabolos']='Somnolence', ['Ramuh']='Thunderspark'}
    pacts.sleep = {['Shiva']='Sleepga', ['Diabolos']='Nightmare', ['Cait Sith']='Mewing Lullaby'}
    pacts.nuke2 = {['Ifrit']='Fire II', ['Shiva']='Blizzard II', ['Garuda']='Aero II', ['Titan']='Stone II',
        ['Ramuh']='Thunder II', ['Leviathan']='Water II'}
    pacts.nuke4 = {['Ifrit']='Fire IV', ['Shiva']='Blizzard IV', ['Garuda']='Aero IV', ['Titan']='Stone IV',
        ['Ramuh']='Thunder IV', ['Leviathan']='Water IV'}
    pacts.bp70 = {['Ifrit']='Flaming Crush', ['Shiva']='Rush', ['Garuda']='Predator Claws', ['Titan']='Mountain Buster',
        ['Ramuh']='Chaotic Strike', ['Leviathan']='Spinning Dive', ['Carbuncle']='Meteorite', ['Fenrir']='Eclipse Bite',
        ['Diabolos']='Nether Blast',['Cait Sith']='Regal Gash'}
    pacts.bp75 = {['Ifrit']='Meteor Strike', ['Shiva']='Heavenly Strike', ['Garuda']='Wind Blade', ['Titan']='Geocrush',
        ['Ramuh']='Thunderstorm', ['Leviathan']='Grand Fall', ['Carbuncle']='Holy Mist', ['Fenrir']='Lunar Bay',
        ['Diabolos']='Night Terror', ['Cait Sith']='Level ? Holy'}
    pacts.bp99 = {['Ifrit']='Conflag Strike', ['Ramuh']='Volt Strike', ['Titan']='Crag Throw', ['Fenrir']='Impact', ['Diabolos']='Blindside'}
    pacts.astralflow = {['Ifrit']='Inferno', ['Shiva']='Diamond Dust', ['Garuda']='Aerial Blast', ['Titan']='Earthen Fury',
        ['Ramuh']='Judgment Bolt', ['Leviathan']='Tidal Wave', ['Carbuncle']='Searing Light', ['Fenrir']='Howling Moon',
        ['Diabolos']='Ruinous Omen', ['Cait Sith']="Altana's Favor"}

--        

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', 'Zantetsuken'}

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'}

-- Set Macros for your SMN's macro page, book.
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
set_macros(1,10) -- Sheet, Book

-- Required variables and  their initial value
meleeing = false
autobp = false
favor = false
mBurst = false
macc = false
mode = "perp"
savedMode = "perp"

 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 buffactive['Astral Conduit'] 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' or spell.name == AvatarList:contains(spell.name) 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 == '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)

    -- 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') or spell.name:match('Regen')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 is doing something, prevents us swapping equipment too early
    if midaction() or pet_midaction() then
        return
    end
    if buffactive['Astral Conduit'] 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
            if mode == 'acc' then
                equip(sets.avatar.pacc)        
            else
                equip(sets.avatar.atk)
            end
        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

            if mode == 'acc' then
                equip(sets.avatar.macc)
            elseif mBurst then
                equip(sets.avatar.mb)            
            else
                equip(sets.avatar.mab)
            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
        if pet.name == 'Carbuncle' or pet.name == 'Cait Sith' then
            equip(sets.avatar[pet.name])
        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)
    -- Add to Chat rules for buffs with variable values.
    buffs_to_chat(spell)
    if (spell.english=="Heavenward Howl") then
        if (world.moon_pct>89) then
                add_to_chat(104,"[Heavenward Howl] Moon Phase Full moon - Endrain 15%")
        elseif (world.moon_pct>73) then
                add_to_chat(104,"[Heavenward Howl] Moon phase 74~90% {Endrain 12%")
        elseif (world.moon_pct>56) then
                add_to_chat(104,"[Heavenward Howl] Moon phase 57~73% {Endrain 8%}")
        elseif (world.moon_pct>39) then
                add_to_chat(104,"[Heavenward Howl] Moon phase 40~56% {First Quarter Moon - Endrain 5% | Last Quarter - moon Enaspir 1%}" )
        elseif (world.moon_pct>24) then
                add_to_chat(104,"[Heavenward Howl] Moon phase 25~39% {Enaspir 2%}")
        elseif (world.moon_pct>9) then
                add_to_chat(104,"[Heavenward Howl] Moon phase 10~24% {Enaspir 4%}")
        else
                add_to_chat(104,"[Heavenward Howl] Moon Phase New Moon - Enaspir 5%")
        end     
    end 
end

function buffs_to_chat(spell)
    -- Add to Chat rules for buffs with variable values
    -- table of tables: spell = T{ "stat_a", "stat_b", step}
    buff_chat_values = {
        ['Ecliptic Howl'] = T{"Accuracy","Evasion",4},
        ['Ecliptic Growl'] = T{"STR/DEX/VIT","INT/MND/CHR/AGI",1},
        ['Lunar Cry'] = T{"Enemy Acc Down","Enemy Eva Down",1},
    }
    if buff_chat_values[spell.english] then
        -- calc value of stat_a: 1 + (the moon phase value * step value)
        local val_a = 1 + (Moon() * buff_chat_values[spell.english][3])
        -- calc value of stat_b: (2 - (6 * step value)) - val_a
        local val_b = (2 + (6 * buff_chat_values[spell.english][3])) - val_a
        -- concatenate all that together
        add_to_chat(104,"["..spell.english.."] "..buff_chat_values[spell.english][1].." "..tostring(val_a).." - "..buff_chat_values[spell.english][2].." "..tostring(val_b))
    -- Dream Shroud is based on time not moon phase
    elseif (spell.english=="Dream Shroud") then
        -- get the hour in 24h format
        local hour24 = math.floor(world.time/60)
        if hour24 < 13 then
            add_to_chat(104,"[Dream Shroud] MAB "..tostring(13-hour24).." - MDB "..tostring(hour24+1))
        else
            add_to_chat(104,"[Dream Shroud] MAB "..tostring(1+(hour24-12)).." - MDB "..tostring(13-(hour24-12)))
        end
    end
end

function Moon()
    -- Assume bonus to effects is symmetrical around New Moon or Full Moon
    -- Actually Phase 0/11 in 12 phase Full Cycle
    -- Originally written for Artemis' Medal
    -- See http://www.ffxiah.com/screenshots/51600
    if world.moon == "New Moon" then
        return 0
    -- Check for Waxing Moon
    elseif world.moon == "Waxing Crescent" then
        -- If %MOONPCT < 24% we know it's Early, rather than Late
        if world.moon_pct < 24 then
            return 1
        else
            return 2
        end
    elseif world.moon == "First Quarter Moon" then
        return 3
    elseif world.moon == "Waxing Gibbous" then
        -- If %MOONPCT < 74% we know it's Early, rather than Late
        if world.moon_pct < 74 then
            return 4
        else
            return 5
        end
    elseif world.moon == "Full Moon" then
        return 6
    -- Check for Waning Moon
    elseif world.moon == "Waning Gibbous" then
        -- If %MOONPCT > 76% we know it's Early, rather than Late
        if world.moon_pct > 76 then
            -- Actually Phase 7 in Full Cycle
            return 5
        else
            -- Actually Phase 8 in Full Cycle
            return 4
        end    
    elseif world.moon == "Last Quarter Moon" then
        -- Actually Phase 9 in Full Cycle
        return 3
    elseif world.moon == "Waning Gibbous" then
        -- If %MOONPCT > 26% we know it's Early, rather than Late
        if world.moon_pct > 26 then
            -- Actually Phase 10 in Full Cycle
            return 2
        else
            -- Actually Phase 11 in Full Cycle
            return 1
        end
    end
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 and pet.isvalid 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.name == 'Alexander' then       
        -- We have a pet out but we're not meleeing, set the right idle set
        equip(sets.avatar.skill)    
    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
    -- If we have cait or carbie  we switch to hands.
    if pet.name == 'Carbuncle' or pet.name == 'Cait Sith' then
            equip(sets.avatar[pet.name])
    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)
    windower.add_to_chat(8,'----- Avatar set to '..mode..' mode! -----')
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' and pet.isvalid 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
            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
            elseif commandArgs[2] == 'mb' then

                -- //gs c toggle mb will toggle mb mode on and off.
                -- You need to toggle prioritisation yourself
                if mBurst then
                    mBurst = false
                    windower.add_to_chat(8,"----- Avatar's MACC Mode OFF -----")
                else
                    mBurst = true
                    windower.add_to_chat(8,"----- Avatar's MACC Mode ON -----")
                end
            end
        -- Handles executing blood pacts in a generic, avatar-agnostic way.
        -- //gs c pact [pacttype]
        elseif commandArgs[1]:lower() == 'pact' then
            if not pet.isvalid then
                    windower.add_to_chat(122,'No avatar currently available. Returning to default macro set.')
                    set_macros(1,2)
                return
            end

            if not commandArgs[2] then
                windower.add_to_chat(123,'No pact type given.')
                return
            end

            local pact = commandArgs[2]:lower()

            if not pacts[pact] then
                windower.add_to_chat(123,'Unknown pact type: '..tostring(pact))
                return
            end

            if pacts[pact][pet.name] then
                if pact == 'astralflow' and not buffactive['astral flow'] then
                    windower.add_to_chat(122,'Cannot use Astral Flow pacts at this time.')
                    return
                end

                -- Leave out target; let Shortcuts auto-determine it.
                send_command('@input /pet "'..pacts[pact][pet.name]..'"')
            else
                windower.add_to_chat(122,pet.name..' does not have a pact of type ['..pact..'].')
            end
        end
    end
end

GEO box

-------------------------------------------------------------------------------------------------------------------
-- Setup functions for this job.  Generally should not be modified.
-------------------------------------------------------------------------------------------------------------------

-- Initialization function for this job file.
function get_sets()
    mote_include_version = 2

    -- Load and initialize the include file.
    include('Mote-Include.lua')
    include('organizer-lib')
end

-- Setup vars that are user-independent.  state.Buff vars initialized here will automatically be tracked.
function job_setup()
    indi_timer = ''
    indi_duration = 180
    absorbs = S{'Absorb-STR', 'Absorb-DEX', 'Absorb-VIT', 'Absorb-AGI', 'Absorb-INT', 'Absorb-MND', 'Absorb-CHR', 'Absorb-Attri', 'Absorb-ACC', 'Absorb-TP'}
    state.CapacityMode = M(false, 'Capacity Point Mantle')
end

-------------------------------------------------------------------------------------------------------------------
-- User setup functions for this job.  Recommend that these be overridden in a sidecar file.
-------------------------------------------------------------------------------------------------------------------

-- Setup vars that are user-dependent.  Can override this function in a sidecar file.
function user_setup()
    state.Buff.Poison = buffactive['Poison'] or false

    state.OffenseMode:options('None', 'Normal', 'Melee')
    state.CastingMode:options('Normal', 'Resistant')
    state.IdleMode:options('Normal', 'PDT', 'Melee')

    gear.default.weaponskill_waist = "Windbuffet Belt +1"

    geo_sub_weapons = S{"Nehushtan", "Bolelabunga"}

    select_default_macro_book()
    send_command('bind != gs c toggle CapacityMode')
end

function file_unload()
    send_command('unbind !=')
end

-- Define sets and vars used by this job file.
function init_gear_sets()

    lowTierNukes = S{'Stone', 'Water', 'Aero', 'Fire', 'Blizzard', 'Thunder',
        'Stone II', 'Water II', 'Aero II', 'Fire II', 'Blizzard II', 'Thunder II',
        'Stone III', 'Water III', 'Aero III', 'Fire III', 'Blizzard III', 'Thunder III',
        'Stone IV', 'Water IV', 'Aero IV', 'Fire IV', 'Blizzard IV', 'Thunder IV',
        'Stonega', 'Waterga', 'Aeroga', 'Firaga', 'Blizzaga', 'Thundaga', 
        'Stonera', 'Watera', 'Aerora', 'Fira', 'Blizzara', 'Thundara',
        'Stonega II', 'Waterga II', 'Aeroga II', 'Firaga II', 'Blizzaga II', 'Thundaga II'}
    --------------------------------------
    -- Precast sets
    --------------------------------------

    -- Precast sets to enhance JAs
    sets.precast.JA.Bolster = {body="Bagua Tunic +1"}
    sets.precast.JA['Life Cycle'] = {head="Azimuth Hood", body="Geomancy Tunic +1", back="Nantosuelta's Cape"}
    sets.precast.JA['Full Circle'] = {hands="Bagua Mitaines"}
    sets.precast.JA['Radial Arcana'] = {feet="Bagua Sandals"}

    sets.CapacityMantle  = { back="Mecistopins Mantle" }

    sets.Organizer = {
        main="Nehushtan", 
    }

    -- Fast cast sets for spells

    sets.precast.FC = {
    feet="Merlinic Crackows",
    legs="Geomancy Pants +2",
    body="Mallquis Saio",
    hands="Bagua Mitaines",
    head="Mallquis Chapeau",
    back="Lifestream Cape",
    ring1="Weatherspoon Ring",
    }

    sets.precast.FC.Cure = set_combine(sets.precast.FC, {

    })

    sets.precast.FC['Elemental Magic'] = set_combine(sets.precast.FC, {
        neck="Stoicheion Medal",
        hands="Bagua Mitaines",
    })

    -- Weaponskill sets
    -- Default set for any weaponskill that isn't any more specifically defined
    sets.precast.WS = {

    }

    sets.precast.WS['Flash Nova'] = {

    }

    sets.precast.WS['Starlight'] = {ear2="Moonshade Earring"}

    sets.precast.WS['Moonlight'] = {ear2="Moonshade Earring"}

    --------------------------------------
    -- Midcast sets
    --------------------------------------

    -- Base fast recast for spells
    sets.midcast.FastRecast = {
        ear2="Loquacious Earring",
        neck="Incanter's Torque",
        body="Azimuth Coat +1", -- 3%
        hands="Amalric Gages", 
        ring1="Prolix Ring",
        back="Lifestream Cape",
        waist="Witful Belt", -- 4%
        legs="Geomancy Pants +1", -- 5%
        ring1="Weatherspoon Ring",
    }
    sets.midcast.Trust =  {
         head="Azimuth hood",
         hands="Amalric Gages", 
         body="Azimuth Coat +1",
         legs="Azimuth Tights",
         feet="Helios Boots",
         ring1="Weatherspoon Ring",
    }
     sets.midcast["Apururu (UC)"] = set_combine(sets.midcast.Trust, {
         body="Apururu Unity shirt",
     })

    sets.midcast.Geomancy = {
        main="Grioavolr",
        sub="Giuoco Grip",
        range="Dunna", 
        head="Azimuth Hood", -- 10
        neck="Incanter's Torque", -- 10
        ear1="Gwati Earring",
        hands="Geomancy Mitaines +2", -- 17
        body="Bagua Tunic +1", -- 12
        back="Lifestream Cape", -- 9
        legs="Geomancy Pants",
        feet="Umbani Boots"
    }

    sets.midcast.Geomancy.Indi = set_combine(sets.midcast.Geomancy, {
        legs="Bagua Pants",
        feet="Azimuth Gaiters",
        back="Nantosuelta's Cape", -- 9
    })

    sets.midcast.Cure = set_combine(sets.midcast.FastRecast, {
        main="Grioavolr",
        neck="Incanter's Torque",
        hands="Telchine Gloves",
        back="Solemnity Cape",
        legs="Telchine Braconi"
    })

    sets.midcast.Curaga = sets.midcast.Cure

    --sets.midcast.Protectra = {ring1="Sheltered Ring"}

    --sets.midcast.Shellra = {ring1="Sheltered Ring"}

    sets.midcast.HighTierNuke = {
        main="Grioavolr",
        sub="Niobid Strap",
        --sub="Wizzan Grip",
        --ammo="Witchstone",
        head="Ea Hat",
        neck="Eddy Necklace",
        ear1="Friomisi Earring",
        ear2="Crematio Earring",
        body="Azimuth Coat +1",
        hands="Amalric Gages", 
        ring1="Shiva Ring",
        ring2="Resonance Ring",
        back="Toro Cape",
        waist="Refoccilation Stone", 
        legs="Merlinic Shalwar",
        feet="Helios Boots"
    }

    sets.midcast.HighTierNuke.Resistant = set_combine(sets.midcast.HighTierNuke, {
        head="Welkin Crown",
        ear1="Friomisi Earring",
        ear2="Gwati Earring", 
        hands="Amalric Gages", 
        back="Refraction Cape",
        legs="Merlinic Shalwar",
        feet="Helios Boots"
        --feet="Bokwus Boots"
    })
    --sets.midcast['Elemental Magic'].Mindmelter = set_combine(sets.midcast.HighTierNuke, {
    --    main="Mindmelter"
    --})

    sets.precast.JA['Concentric Pulse'] = sets.midcast.HightTierNuke

    sets.midcast.LowTierNuke = set_combine(sets.midcast.HighTierNuke, {
        sub="Giuoco Grip",
        ear2="Crematio Earring",
        body="Witching Robe",
        feet="Umbani Boots"
    })

    sets.midcast.LowTierNuke.Resistant = set_combine(sets.midcast.LowTierNuke, {
        head="Welkin Crown",
        ear1="Friomisi Earring",
        ear2="Gwati Earring", 
        hands="Amalric Gages", 
        legs="Merlinic Shalwar",
        ring1="Sangoma Ring",
        ring2="Resonance Ring",
        back="Refraction Cape",
        feet="Helios Boots"
    })

    sets.midcast.Macc = { 
        main="Nehustan",
        sub="Niobid Strap", 
        ammo="Plumose Sachet",
        head="Geomancy Galero +2",
        neck="Spider Torque", 
        ear1="Lifestorm Earring", 
        ear2="Psystorm Earring",
        body="Geomancy Tunic +2",
        hands="Geomancy Mitaines +2",
        ring1="Stikini Ring", 
        ring2="Stikini Ring",
        back="Lifestream Cape",
        legs="Geomancy Pants +2",
        waist="Yamabuki-no-obi", 
        feet="Geomancy Sandals +2"
    }
    sets.midcast.Absorb = set_combine(sets.midcast.Macc, {
        head="Bagua Galero",
        neck="Incanter's Torque", 
        ear1="Gwati Earring",
        ring1="Evanescence Ring",
        ring2="Excelsis Ring",
        body="Geomancy tunic +1",
        legs="Azimuth Tights +1",
    })

    sets.midcast.Aspir = set_combine(sets.midcast.Macc, { 
        head="Bagua Galero",
        neck="Incanter's Torque", 
        ear1="Gwati Earring",
        ear2="Hirudinea Earring",
        ring1="Evanescence Ring",
        ring2="Excelsis Ring",
        body="Geomancy tunic +1",
        legs="Azimuth Tights +1",
    })
    sets.midcast.Drain = sets.midcast.Aspir
    sets.midcast.Stun = sets.midcast.Macc

    sets.midcast['Enfeebling Magic'] = set_combine(sets.midcast.Macc, {

    })
    sets.midcast.ElementalEnfeeble = set_combine(sets.midcast.Macc, {
        waist="Casso Sash",
        back="Lifestream Cape",
        ring1="Shiva Ring",
        ring2="Globidonta Ring",
        feet="Bagua Sandals"
    })

    sets.midcast['Enhancing Magic'] = sets.midcast.FastRecast
        --sub="Fulcio Grip", 
        --neck="Colossus's Torque", 
        --body="Anhur Robe",
        --hands="Ayao's Gloves"
    --------------------------------------
    -- Idle/resting/defense/etc sets
    --------------------------------------

    -- Resting sets
    sets.resting = {
        neck="Twilight Torque",
        body="Azimuth Coat +1",
        hands="Geomancy Mitaines +2",
        ring1="Dark Ring",
        ring2="Paguroidea Ring",
        --waist="Austerity Belt",
        --legs="Nares Trews",
    }

    -- Idle sets
    sets.idle = {
        sub="Genbu's Shield",
        range="Dunna",
        head="Azimuth Hood",
        neck="Sanctity Necklace",
        ear1="Friomisi Earring",
        ear2="Crematio Earring",
        body="Azimuth Coat +1",
        hands="Merlinic Dastanas",
        ring1="Archon Ring",
        ring2="Warp Ring",
        back="Solemnity Cape",
        waist="Fucho-no-obi",
        legs="Merlinic Shalwar",
        feet="Merlinic Crackows"
    }
    sets.idle.PDT = set_combine(sets.idle, {
        head="Hike Khat +1",
        neck="Twilight Torque",
        hands="Geomancy Mitaines +2",
        back="Solemnity Cape",
        feet="Azimuth Gaiters"
    })

    -- .Pet sets are for when Luopan is present.
    sets.idle.Pet = set_combine(sets.idle, {
        head="Azimuth Hood",
        neck="Twilight Torque",
        hands="Telchine Gloves",
        back="Nantosuelta's Cape",
        feet="Telchine Pigaches"
    })

    sets.idle.PDT.Pet = set_combine(sets.idle.Pet, {
        ring2="Patricius Ring",
    })

    sets.idle.Melee = set_combine(sets.idle, {
        main="Malevolence",
        neck="Lissome Necklace",
        --sub="Bolelabunga"
    })

    -- .Indi sets are for when an Indi-spell is active.
    --sets.idle.Indi = set_combine(sets.idle, {
    --    legs="Bagua Pants", 
    --    feet="Geomancy Sandals +2",
    --    back="Lifestream Cape",
    --    --feet="Azimuth Gaiters"
    --})
    --sets.idle.Pet.Indi = set_combine(sets.idle.Pet, {
    --    legs="Bagua Pants", 
    --})
    --sets.idle.PDT.Indi = set_combine(sets.idle.PDT, {
    --    legs="Bagua Pants", 
    --    feet="Azimuth Gaiters"
    --})
    --sets.idle.PDT.Pet.Indi = set_combine(sets.idle.PDT.Pet, {
    --    legs="Bagua Pants", 
    --})

    sets.idle.Town = set_combine(sets.idle, {
        body="Councilor's Garb",
        hands="Amalric Gages", 
    })

    sets.idle.Weak = sets.idle

    -- Defense sets

    sets.defense.PDT = {
        range="Dunna",
        head="Welkin Crown",
        neck="Twilight Torque",
        ear1="Zennaroi Earring",
        body="Azimuth Coat +1",
        hands="Geomancy Mitaines +2",
        ring1="Dark Ring",
        ring2="Defending Ring",
        --back="Umbra Cape",
        feet="Azimuth Gaiters"
    }

    sets.defense.MDT = {
        range="Dunna",
        --head="Nahtirah Hat",
        --neck="Wiglen Gorget",
        ear1="Zennaroi Earring",
        ear2="Loquacious Earring",
        body="Azimuth Coat +1",
        hands="Geomancy Mitaines +2",
        --ring1="Defending Ring",
        --ring2="Shadow Ring",
        --back="Umbra Cape",
        waist="Yamabuki-no-Obi",
        --legs="Bokwus Slops",
    }

    sets.Kiting = {}

    sets.latent_refresh = {waist="Fucho-no-obi"}

    --------------------------------------
    -- Engaged sets
    --------------------------------------

    -- Variations for TP weapon and (optional) offense/defense modes.  Code will fall back on previous
    -- sets if more refined versions aren't defined.
    -- If you create a set with both offense and defense modes, the offense mode should be first.
    -- EG: sets.engaged.Dagger.Accuracy.Evasion

    -- Normal melee group
    sets.engaged = {
        range="Dunna",
        neck="Asperity Necklace",
        ear1="Bladeborn Earring",
        ear2="Steelflash Earring",
        body="Azimuth Coat +1",
        --body="Vanir Cotehardie",
        hands="Geomancy Mitaines +2",
        ring1="Rajas Ring",
        ring2="K'ayres Ring",
        back="Kayapa Cape",
        waist="Windbuffet Belt +1",
        legs="Geomancy Pants +1",
        feet="Umbani Boots"
    }
    sets.engaged.Melee = set_combine(sets.engaged, {
        main="Malevolence",
    })
    --------------------------------------
    -- Custom buff sets
    --------------------------------------

end

-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for standard casting events.
-------------------------------------------------------------------------------------------------------------------
function job_precast(spell, action, spellMap, eventArgs)
    refine_various_spells(spell, action, spellMap, eventArgs)
    --if state.Buff.Poison then
    --    classes.CustomClass = 'Mindmelter'
    --end
end

function job_post_precast(spell, action, spellMap, eventArgs)
    -- Make sure abilities using head gear don't swap 
    if spell.type:lower() == 'weaponskill' then
        -- CP mantle must be worn when a mob dies, so make sure it's equipped for WS.
        if state.CapacityMode.value then
            equip(sets.CapacityMantle)
        end
    end
end

function job_aftercast(spell, action, spellMap, eventArgs)
    if not spell.interrupted then
        if spell.english:startswith('Indi') then
            if not classes.CustomIdleGroups:contains('Indi') then
                classes.CustomIdleGroups:append('Indi')
            end
            send_command('@timers d "'..indi_timer..'"')
            indi_timer = spell.english
            send_command('@timers c "'..indi_timer..'" '..indi_duration..' down spells/00136.png')
        elseif spell.english == 'Sleep' or spell.english == 'Sleepga' then
            send_command('@timers c "'..spell.english..' ['..spell.target.name..']" 60 down spells/00220.png')
        elseif spell.english == 'Sleep II' or spell.english == 'Sleepga II' then
            send_command('@timers c "'..spell.english..' ['..spell.target.name..']" 90 down spells/00220.png')
        end
    elseif not player.indi then
        classes.CustomIdleGroups:clear()
    end
end

-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for non-casting events.
-------------------------------------------------------------------------------------------------------------------
--function job_status_change(newStatus, oldStatus, eventArgs)
--    if newStatus == 'Engaged' then
--        -- nothing yet
--        elseif newStatus == 'Idle' then
--            determine_idle_group()
--    end
--end

-- Called when a player gains or loses a buff.
-- buff == buff gained or lost
-- gain == true if the buff was gained, false if it was lost.
function job_buff_change(buff, gain)
    if player.indi and not classes.CustomIdleGroups:contains('Indi')then
        classes.CustomIdleGroups:append('Indi')
        handle_equipping_gear(player.status)
    elseif classes.CustomIdleGroups:contains('Indi') and not player.indi then
        classes.CustomIdleGroups:clear()
        handle_equipping_gear(player.status)
    end
end

function job_state_change(stateField, newValue, oldValue)
    if stateField == 'Offense Mode' then
        if newValue == 'Melee' then
            disable('main','sub')
        else
            enable('main','sub')
        end
    end
end

-------------------------------------------------------------------------------------------------------------------
-- User code that supplements standard library decisions.
-------------------------------------------------------------------------------------------------------------------

function job_get_spell_map(spell, default_spell_map)
    if spell.action_type == 'Magic' then
        if spell.skill == 'Enfeebling Magic' then
            if spell.type == 'WhiteMagic' then
                return 'MndEnfeebles'
            else
                return 'IntEnfeebles'
            end
        elseif spell.skill == 'Dark Magic' and absorbs:contains(spell.english) then
            return 'Absorb'
        elseif spell.skill == 'Geomancy' then
            if spell.english:startswith('Indi') then
                return 'Indi'
            end
        elseif spell.skill == 'Elemental Magic' and default_spell_map ~= 'ElementalEnfeeble' then
            if lowTierNukes:contains(spell.english) then
                return 'LowTierNuke'
            else
                return 'HighTierNuke'
            end
        elseif spell.type == 'Trust' then
            return 'Trust'

        end
    end
end

function customize_idle_set(idleSet)
    if player.mpp < 51 then
        idleSet = set_combine(idleSet, sets.latent_refresh)
    end
    if state.CapacityMode.value then
        idleSet = set_combine(idleSet, sets.CapacityMantle)
    end
    if state.OffenseMode.value == 'Melee' then
        idleSet = set_combine(sets.idle, sets.idle.Melee)
    end
    return idleSet
end

-- Modify the default melee set after it was constructed.
function customize_melee_set(meleeSet)
    if state.CapacityMode.value then
        meleeSet = set_combine(meleeSet, sets.CapacityMantle)
    end
    return meleeSet
end
-- Called by the 'update' self-command.
function job_update(cmdParams, eventArgs)
    classes.CustomIdleGroups:clear()
    if player.indi then
        classes.CustomIdleGroups:append('Indi')
    end
end

-- Function to display the current relevant user state when doing an update.
function display_current_job_state(eventArgs)
    display_current_caster_state()
    eventArgs.handled = true
end

-------------------------------------------------------------------------------------------------------------------
-- Utility functions specific to this job.
-------------------------------------------------------------------------------------------------------------------

-- Select default macro book on initial load or subjob change.
function select_default_macro_book()
    set_macro_page(1, 3)
end
--Refine Nuke Spells
function refine_various_spells(spell, action, spellMap, eventArgs)
    aspirs = S{'Aspir','Aspir II','Aspir III'}
    sleeps = S{'Sleep II','Sleep'}
    sleepgas = S{'Sleepga II','Sleepga'}
    nukes = S{'Fire', 'Blizzard', 'Aero', 'Stone', 'Thunder', 'Water',
    'Fire II', 'Blizzard II', 'Aero II', 'Stone II', 'Thunder II', 'Water II',
    'Fire III', 'Blizzard III', 'Aero III', 'Stone III', 'Thunder III', 'Water III',
    'Fire IV', 'Blizzard IV', 'Aero IV', 'Stone IV', 'Thunder IV', 'Water IV',
    'Fire V', 'Blizzard V', 'Aero V', 'Stone V', 'Thunder V', 'Water V',
    'Fire VI', 'Blizzard VI', 'Aero VI', 'Stone VI', 'Thunder VI', 'Water VI',
    'Firaga', 'Blizzaga', 'Aeroga', 'Stonega', 'Thundaga', 'Waterga',
    'Firaga II', 'Blizzaga II', 'Aeroga II', 'Stonega II', 'Thundaga II', 'Waterga II',
    'Firaga III', 'Blizzaga III', 'Aeroga III', 'Stonega III', 'Thundaga III', 'Waterga III',    
    'Firaja', 'Blizzaja', 'Aeroja', 'Stoneja', 'Thundaja', 'Waterja',
    }
    cures = S{'Cure IV','Cure V','Cure IV','Cure III','Curaga III','Curaga II', 'Curaga',}

    if spell.skill == 'Healing Magic' then
        if not cures:contains(spell.english) then
            return
        end

        local newSpell = spell.english
        local spell_recasts = windower.ffxi.get_spell_recasts()
        local cancelling = 'All '..spell.english..' spells are on cooldown. Cancelling spell casting.'

        if spell_recasts[spell.recast_id] > 0 then
            if cures:contains(spell.english) then
                if spell.english == 'Cure' then
                    add_to_chat(122,cancelling)
                    eventArgs.cancel = true
                return
                elseif spell.english == 'Cure IV' then
                    newSpell = 'Cure V'
                elseif spell.english == 'Cure V' then
                    newSpell = 'Cure IV'
                elseif spell.english == 'Cure IV' then
                    newSpell = 'Cure III'
                end
            end
        end

        if newSpell ~= spell.english then
            send_command('@input /ma "'..newSpell..'" '..tostring(spell.target.raw))
            eventArgs.cancel = true
            return
        end
    elseif spell.skill == 'Dark Magic' then
        if not aspirs:contains(spell.english) then
            return
        end

        local newSpell = spell.english
        local spell_recasts = windower.ffxi.get_spell_recasts()
        local cancelling = 'All '..spell.english..' spells are on cooldown. Cancelling spell casting.'

        if spell_recasts[spell.recast_id] > 0 then
            if aspirs:contains(spell.english) then
                if spell.english == 'Aspir' then
                    add_to_chat(122,cancelling)
                    eventArgs.cancel = true
                return
                elseif spell.english == 'Aspir II' then
                    newSpell = 'Aspir'
                elseif spell.english == 'Aspir III' then
                    newSpell = 'Aspir II'
                end
            end
        end

        if newSpell ~= spell.english then
            send_command('@input /ma "'..newSpell..'" '..tostring(spell.target.raw))
            eventArgs.cancel = true
            return
        end
    elseif spell.skill == 'Elemental Magic' then
        if not sleepgas:contains(spell.english) and not sleeps:contains(spell.english) and not nukes:contains(spell.english) then
            return
        end

        local newSpell = spell.english
        local spell_recasts = windower.ffxi.get_spell_recasts()
        local cancelling = 'All '..spell.english..' spells are on cooldown. Cancelling spell casting.'

        if spell_recasts[spell.recast_id] > 0 then
            if sleeps:contains(spell.english) then
                if spell.english == 'Sleep' then
                    add_to_chat(122,cancelling)
                    eventArgs.cancel = true
                return
                elseif spell.english == 'Sleep II' then
                    newSpell = 'Sleep'
                end
            elseif sleepgas:contains(spell.english) then
                if spell.english == 'Sleepga' then
                    add_to_chat(122,cancelling)
                    eventArgs.cancel = true
                    return
                elseif spell.english == 'Sleepga II' then
                    newSpell = 'Sleepga'
                end
            elseif nukes:contains(spell.english) then    
                if spell.english == 'Fire' then
                    eventArgs.cancel = true
                    return
                elseif spell.english == 'Fire VI' then
                    newSpell = 'Fire V'
                elseif spell.english == 'Fire V' then
                    newSpell = 'Fire IV'
                elseif spell.english == 'Fire IV' then
                    newSpell = 'Fire III'    
                elseif spell.english == 'Fire II' then
                    newSpell = 'Fire'
                elseif spell.english == 'Firaja' then
                    newSpell = 'Firaga III'
                elseif spell.english == 'Firaga II' then
                    newSpell = 'Firaga'
                end 
                if spell.english == 'Blizzard' then
                    eventArgs.cancel = true
                    return
                elseif spell.english == 'Blizzard VI' then
                    newSpell = 'Blizzard V'
                elseif spell.english == 'Blizzard V' then
                    newSpell = 'Blizzard IV'
                elseif spell.english == 'Blizzard IV' then
                    newSpell = 'Blizzard III'    
                elseif spell.english == 'Blizzard II' then
                    newSpell = 'Blizzard'
                elseif spell.english == 'Blizzaja' then
                    newSpell = 'Blizzaga III'
                elseif spell.english == 'Blizzaga II' then
                    newSpell = 'Blizzaga'    
                end 
                if spell.english == 'Aero' then
                    eventArgs.cancel = true
                    return
                elseif spell.english == 'Aero VI' then
                    newSpell = 'Aero V'
                elseif spell.english == 'Aero V' then
                    newSpell = 'Aero IV'
                elseif spell.english == 'Aero IV' then
                    newSpell = 'Aero III'    
                elseif spell.english == 'Aero II' then
                    newSpell = 'Aero'
                elseif spell.english == 'Aeroja' then
                    newSpell = 'Aeroga III'
                elseif spell.english == 'Aeroga II' then
                    newSpell = 'Aeroga'    
                end 
                if spell.english == 'Stone' then
                    eventArgs.cancel = true
                    return
                elseif spell.english == 'Stone VI' then
                    newSpell = 'Stone V'
                elseif spell.english == 'Stone V' then
                    newSpell = 'Stone IV'
                elseif spell.english == 'Stone IV' then
                    newSpell = 'Stone III'    
                elseif spell.english == 'Stone II' then
                    newSpell = 'Stone'
                elseif spell.english == 'Stoneja' then
                    newSpell = 'Stonega III'
                elseif spell.english == 'Stonega II' then
                    newSpell = 'Stonega'    
                end 
                if spell.english == 'Thunder' then
                    eventArgs.cancel = true
                    return
                elseif spell.english == 'Thunder VI' then
                    newSpell = 'Thunder V'
                elseif spell.english == 'Thunder V' then
                    newSpell = 'Thunder IV'
                elseif spell.english == 'Thunder IV' then
                    newSpell = 'Thunder III'    
                elseif spell.english == 'Thunder II' then
                    newSpell = 'Thunder'
                elseif spell.english == 'Thundaja' then
                    newSpell = 'Thundaga III'
                elseif spell.english == 'Thundaga II' then
                    newSpell = 'Thundaga'    
                end 
                if spell.english == 'Water' then
                    eventArgs.cancel = true
                    return
                elseif spell.english == 'Water VI' then
                    newSpell = 'Water V'
                elseif spell.english == 'Water V' then
                    newSpell = 'Water IV'
                elseif spell.english == 'Water IV' then
                    newSpell = 'Water III'    
                elseif spell.english == 'Water II' then
                    newSpell = 'Water'
                elseif spell.english == 'Waterja' then
                    newSpell = 'Waterga III'
                elseif spell.english == 'Waterga II' then
                    newSpell = 'Waterga'    
                end 
            end
        end

        if newSpell ~= spell.english then
            send_command('@input /ma "'..newSpell..'" '..tostring(spell.target.raw))
            eventArgs.cancel = true
            return
        end
    end
end
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License