Helix / Helix II Question

Eorzea Time
 
 
 
Langues: JP EN FR DE
users online
Forum » FFXI » Jobs » Scholar » Helix / Helix II Question
Helix / Helix II Question
 Odin.Wyclef
Offline
Serveur: Odin
Game: FFXI
user: wyclef
Posts: 21
By Odin.Wyclef 2017-03-14 22:44:55
Link | Citer | R
 
Bismarck.Snprphnx said: »
Odin.Wyclef said: »
Hello everyone.

I have a new question about helix II casting and MBing.
My Lua swaps casting modes from Normal > Mid > Resistant > MagicBurst etc. but my helix casts are only done in the original Lua's helix set, even though i also made Mid > Resistant > MagicBurst extensions for the helix castings. Does anyone have a suggestion or example how i can get my Lua to swap helix casting sets too?

It also took me a while to figure out why my Helix MB's where not using my obi for the MB but seing that they are not supposed to be used I understand why they are not factored in.
Does the same apply for the klimaform boots? are they useless too?

Greatly appreciate the help!

Klimaform boots are the best. helix does not automatically gain the boost from them.

for casting helix, does it swap for helix 1 and not helix 2, or is it both?

also, post your .lua so we can see it.

double checked today and when i cast helix it just ignores my arbatel loafers +1 completely even though there is a bit of klimaform code in lua.
Code
    sets.buff['Klimaform'] = {feet="Arbatel Loafers +1"}
    state.Buff['Klimaform'] = buffactive['Klimaform'] or false
    state.Buff['Klimaform'] = buffactive['Klimaform'] or false
        if state.Buff.Klimaform and spell.element == world.weather_element then
            equip(sets.buff['Klimaform'])
 Ifrit.Wyclef
Offline
Serveur: Ifrit
Game: FFXI
user: wyclef
Posts: 40
By Ifrit.Wyclef 2017-03-14 22:47:00
Link | Citer | R
 
here is my full lua btw.

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

--[[
        Custom commands:
        Shorthand versions for each strategem type that uses the version appropriate for
        the current Arts.
                                        Light Arts              Dark Arts
        gs c scholar light              Light Arts/Addendum
        gs c scholar dark                                       Dark Arts/Addendum
        gs c scholar cost               Penury                  Parsimony
        gs c scholar speed              Celerity                Alacrity
        gs c scholar aoe                Accession               Manifestation
        gs c scholar power              Rapture                 Ebullience
        gs c scholar duration           Perpetuance
        gs c scholar accuracy           Altruism                Focalization
        gs c scholar enmity             Tranquility             Equanimity
        gs c scholar skillchain                                 Immanence
        gs c scholar addendum           Addendum: White         Addendum: Black
--]]



-- Initialization function for this job file.
function get_sets()
    mote_include_version = 2
	
	include('organizer-lib')
    -- Load and initialize the include file.
    include('Mote-Include.lua')
end

-- Setup vars that are user-independent.  state.Buff vars initialized here will automatically be tracked.
function job_setup()
    info.addendumNukes = S{"Stone IV", "Water IV", "Aero IV", "Fire IV", "Blizzard IV", "Thunder IV",
        "Stone V", "Water V", "Aero V", "Fire V", "Blizzard V", "Thunder V"}

        Non_Obi_Spells = S{
                        'Burn','Choke','Drown','Frost','Rasp','Shock','Impact','Anemohelix','Cryohelix',
                        'Geohelix','Hydrohelix','Ionohelix','Luminohelix','Noctohelix','Pyrohelix','Anemohelix II','Cryohelix II',
						'Geohelix II','Hydrohelix II','Ionohelix II','Luminohelix II','Noctohelix II','Pyrohelix II'}
 
        Cure_Spells = {"Cure","Cure II","Cure III","Cure IV"} -- Cure Degradation --
        Curaga_Spells = {"Curaga","Curaga II"} -- Curaga Degradation --
		
    state.Buff['Sublimation: Activated'] = buffactive['Sublimation: Activated'] or false
    update_active_strategems()
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.OffenseMode:options('None', 'Normal')
    state.CastingMode:options('Normal', 'Mid', 'Resistant', 'MagicBurst', 'MBresist')
    state.IdleMode:options('Normal', 'PDT','MDT','Hybrid','Burst')

		MagicBurstIndex = 0
    state.MagicBurst = M(false, 'Magic Burst')


    info.low_nukes = S{"Stone", "Water", "Aero", "Fire", "Blizzard", "Thunder","Stone II", "Water II", "Aero II", "Fire II", "Blizzard II", "Thunder II",}
    info.mid_nukes = S{"Stone III", "Water III", "Aero III", "Fire III", "Blizzard III", "Thunder III",
                       "Stone IV", "Water IV", "Aero IV", "Fire IV", "Blizzard IV", "Thunder IV",}
    info.high_nukes = S{"Stone V", "Water V", "Aero V", "Fire V", "Blizzard V", "Thunder V"}



    send_command('bind ^` input /ma Stun <t>')
    send_command('bind @` gs c toggle MagicBurst')
	

    select_default_macro_book()
end

function user_unload()
    send_command('unbind ^`')
end


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

    -- Precast Sets

    -- Precast sets to enhance JAs

    sets.precast.JA['Rapture'] = {head="Arbatel Bonnet +1"}
	sets.precast.JA['Ebullience'] = {head="Arbatel Bonnet +1"}
	sets.precast.JA['Addendum: White'] = {body="Arbatel Gown +1"}
	sets.precast.JA['Addendum: Black'] = {body="Arbatel Gown +1"}
	sets.precast.JA['Perpetuance'] = {hands="Arbatel Bracers +1"}
	sets.precast.JA['Immanence'] = {hands="Arbatel Bracers +1"}
	sets.precast.JA['Penury'] = {legs="Savant's Pants +2"}
	sets.precast.JA['Parsimony'] = {legs="Savant's Pants +2"}
    sets.precast.JA['Tabula Rasa'] = {legs="Pedagogy Pants"}
	sets.precast.JA['Celerity'] = {feet="Pedagogy Loafers"}
	sets.precast.JA['Alacrity'] = {feet="Pedagogy Loafers"}


    -- Fast cast sets for spells

    sets.precast.FC = {ammo="Incantor Stone",
    head="Amalric Coif",
    body="Shango Robe",
    hands="Gendewitha Gages",
    legs={ name="Psycloth Lappas", augments={'MP+80','Mag. Acc.+15','"Fast Cast"+7',}},
    feet="Acad. Loafers +1",
    neck="Incanter's Torque",
    waist="Witful Belt",
    left_ear="Loquac. Earring",
    right_ear="Etiolation Earring",
    left_ring="Defending Ring",
    right_ring="Prolix Ring",
    back="Swith Cape",
}

	
    sets.precast.FC.Stun = {ammo="Incantor Stone",
    head="Amalric Coif",
    body="Shango Robe",
    hands="Gendewitha Gages",
    legs={ name="Psycloth Lappas", augments={'MP+80','Mag. Acc.+15','"Fast Cast"+7',}},
    feet="Acad. Loafers +1",
    neck="Incanter's Torque",
    waist="Witful Belt",
    left_ear="Loquac. Earring",
    right_ear="Etiolation Earring",
    left_ring="Defending Ring",
    right_ring="Prolix Ring",
    back="Swith Cape",
}

    sets.precast.FC.Arts = {feet="Acad. Loafers +1"}

    sets.precast.FC['Enhancing Magic'] = set_combine(sets.precast.FC, {body="Rosette Jaseran +1",waist="Siegel Sash"})

    sets.precast.FC['Enhancing Magic'].Stoneskin = set_combine(sets.precast.FC, {head="Umuthi Hat",body="Rosette Jaseran +1",neck="Nodens Gorget",legs="Doyen Pants",hands="Carapacho Cuffs",waist="Siegel Sash"})

    sets.precast.FC['Elemental Magic'] = set_combine(sets.precast.FC, {ear2="Barkarole earring"})

    sets.precast.FC.Cure = set_combine(sets.precast.FC, 
		{body="Nefer Kalasiris",hands="Chironic Gloves",legs="Doyen Pants",feet="Vanya Clogs",right_ear="Mendi. Earring",
    back="Pahtli Cape",})

    sets.precast.FC.Curaga = sets.precast.FC.Cure

    sets.precast.FC.Impact = set_combine(sets.precast.FC['Elemental Magic'], {head=empty,body=""})

	sets.precast.WS = {}
	
	sets.precast.WS['Omniscience'] = {ammo="Ghastly Tathlum +1",
    head="Pixie Hairpin +1",
    body="Jhakri Robe +1",
    hands="Jhakri Cuffs +1",
    legs="Jhakri Slops +1",
    feet="Jhakri Pigaches +1",
    neck="Sanctity Necklace",
    waist="Fotia Belt",
    left_ear="Barkaro. Earring",
    right_ear="Friomisi Earring",
    left_ring="Vertigo Ring",
    right_ring="Archon Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},}
    
	sets.precast.WS['Myrkr'] = {
}



    -- Midcast Sets 

    sets.midcast.FastRecast = {ammo="Incantor Stone",
    head={ name="Merlinic Hood", augments={'Mag. Acc.+18 "Mag.Atk.Bns."+18','Magic burst mdg.+7%','INT+1','Mag. Acc.+7','"Mag.Atk.Bns."+11',}},
    body="Shango Robe",
    hands="Gendewitha Gages",
    legs={ name="Psycloth Lappas", augments={'MP+80','Mag. Acc.+15','"Fast Cast"+7',}},
    feet="Acad. Loafers +1",
    neck="Incanter's Torque",
    waist="Witful Belt",
    left_ear="Loquac. Earring",
    right_ear="Gifted Earring",
    left_ring="Defending Ring",
    right_ring="Dark Ring",
    back="Swith Cape",
	}

    sets.midcast.Cure = {ammo="Clarus Stone",
    head={ name="Merlinic Hood", augments={'Mag. Acc.+18 "Mag.Atk.Bns."+18','Magic burst mdg.+7%','INT+1','Mag. Acc.+7','"Mag.Atk.Bns."+11',}},
    body="Nefer Kalasiris",
    hands="Telchine Gloves",
    legs="Gyve Trousers",
    feet={ name="Vanya Clogs", augments={'"Cure" potency +5%','"Cure" spellcasting time -15%','"Conserve MP"+6',}},
    neck="Nodens Gorget",
    waist="Rumination Sash",
    left_ear="Loquac. Earring",
    right_ear="Mendi. Earring",
    left_ring="Aquasoul Ring",
    right_ring="Sirona's Ring",
    back="Pahtli Cape",
}

    sets.midcast.CureWithLightWeather = {ammo="Clarus Stone",
    head={ name="Merlinic Hood", augments={'Mag. Acc.+18 "Mag.Atk.Bns."+18','Magic burst mdg.+7%','INT+1','Mag. Acc.+7','"Mag.Atk.Bns."+11',}},
    body="Nefer Kalasiris",
    hands="Telchine Gloves",
    legs="Gyve Trousers",
    feet={ name="Vanya Clogs", augments={'"Cure" potency +5%','"Cure" spellcasting time -15%','"Conserve MP"+6',}},
    neck="Nodens Gorget",
    waist="Hachirin-no-Obi",
    left_ear="Loquac. Earring",
    right_ear="Mendi. Earring",
    left_ring="Aquasoul Ring",
    right_ring="Sirona's Ring",
    back="Pahtli Cape",
}

    sets.midcast.Curaga = sets.midcast.Cure

 
    sets.midcast.Cursna = set_combine(sets.midcast.FastRecast,{})

    sets.midcast['Enhancing Magic'] = {ammo="Savant's Treatise",
		head="Telchine Cap",
		body="Telchine Chas.",
		hands="Arbatel Bracers +1",
		legs="Telchine Braconi",
		feet={ name="Telchine Pigaches", augments={'Enh. Mag. eff. dur. +7',}},
        neck="Incanter's Torque",
		waist="Olympus Sash",
		left_ear="Loquac. Earring",
		right_ear="Gifted Earring",
		left_ring="Defending Ring", 
		right_ring="Dark Ring",
		back="Fi Follet Cape",
}

    sets.midcast.Regen = {ammo="Savant's Treatise",
    head="Arbatel Bonnet +1",
    body="Telchine Chas.",
    hands="Arbatel Bracers +1",
    legs="Telchine Braconi",
    feet={ name="Telchine Pigaches", augments={'Enh. Mag. eff. dur. +7',}},
    neck="Incanter's Torque",
    waist="Olympus Sash",
    left_ear="Loquac. Earring",
    right_ear="Gifted Earring",
    left_ring="Defending Ring",
    right_ring="Dark Ring",
    back={ name="Bookworm's Cape", augments={'INT+2','MND+1','Helix eff. dur. +19','"Regen" potency+8',}},}

	sets.midcast.Refresh = set_combine(sets.midcast['Enhancing Magic'],
		{head="Amalric coif",
                 feet="Inspirited boots",
                 waist="Gishdubar sash"})

    sets.midcast.Stoneskin = set_combine(sets.midcast['Enhancing Magic'], {neck="Nodens Gorget",waist="Siegel Sash"})

    sets.midcast.Aquaveil = set_combine(sets.midcast['Enhancing Magic'], {})
    
    sets.midcast.Storm = set_combine(sets.midcast['Enhancing Magic'], {feet="Pedagogy Loafers"})
    
    sets.midcast.Protect = {ring2="Sheltered Ring"}
    sets.midcast.Protectra = sets.midcast.Protect

    sets.midcast.Shell = {ring2="Sheltered Ring"}
    sets.midcast.Shellra = sets.midcast.Shell


    -- Custom spell classes
    sets.midcast.MndEnfeebles = {ammo="Savant's Treatise",
    head="Befouled Crown",
    body="Vanya Robe",
    hands="Lurid Mitts",
    legs={ name="Psycloth Lappas", augments={'MP+80','Mag. Acc.+15','"Fast Cast"+7',}},
    feet={ name="Medium's Sabots", augments={'MP+50','MND+10','"Conserve MP"+7','"Cure" potency +5%',}},
    neck="Incanter's Torque",
    waist="Rumination Sash",
    left_ear="Psystorm Earring",
    right_ear="Lifestorm Earring",
    left_ring="Sangoma Ring",
    right_ring="Perception Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
}

sets.midcast.MndEnfeebles.Resistant = {ammo="Savant's Treatise",
    ammo="Kalboron Stone",
    head="Befouled Crown",
    body="Jhakri Robe +1",
    hands="Jhakri Cuffs +1",
    legs={ name="Chironic Hose", augments={'Mag. Acc.+27','"Resist Silence"+4','INT+12','"Mag.Atk.Bns."+5',}},
    feet="Jhakri Pigaches +1",
    neck="Incanter's Torque",
    waist="Rumination Sash",
    left_ear="Barkaro. Earring",
    right_ear="Gwati Earring",
    left_ring="Vertigo Ring",
    right_ring="Sangoma Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
}

    sets.midcast.IntEnfeebles = {ammo="Savant's Treatise",
    head="Befouled Crown",
    body="Vanya Robe",
    hands="Lurid Mitts",
    legs={ name="Psycloth Lappas", augments={'MP+80','Mag. Acc.+15','"Fast Cast"+7',}},
    feet={ name="Medium's Sabots", augments={'MP+50','MND+10','"Conserve MP"+7','"Cure" potency +5%',}},
    neck="Incanter's Torque",
    waist="Rumination Sash",
    left_ear="Barkaro. Earring",
    right_ear="Gwati Earring",
    left_ring="Sangoma Ring",
    right_ring="Shiva Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
}

    sets.midcast.IntEnfeebles.Resistant = {ammo="Pemphredo Tathlum",
    head="Befouled Crown",
    body="Jhakri Robe +1",
    hands="Jhakri Cuffs +1",
    legs={ name="Chironic Hose", augments={'Mag. Acc.+27','"Resist Silence"+4','INT+12','"Mag.Atk.Bns."+5',}},
    feet="Jhakri Pigaches +1",
    neck="Incanter's Torque",
    waist="Rumination Sash",
    left_ear="Barkaro. Earring",
    right_ear="Gwati Earring",
    left_ring="Vertigo Ring",
    right_ring="Sangoma Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
}


    sets.midcast.ElementalEnfeeble = sets.midcast.IntEnfeebles

    sets.midcast['Dark Magic'] = {ammo="Ghastly Tathlum +1",
    head="Pixie Hairpin +1",
    body="Shango Robe",
    hands="Jhakri Cuffs +1",
    legs={ name="Merlinic Shalwar", augments={'Mag. Acc.+23','Magic Damage +16','"Mag.Atk.Bns."+10',}},
    feet="Jhakri Pigaches +1",
    neck="Incanter's Torque",
    waist="Eschan Stone",
    left_ear="Barkaro. Earring",
    right_ear="Gwati Earring",
    left_ring="Evanescence Ring",
    right_ring="Archon Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
}

    sets.midcast.Kaustra = {ammo="Ghastly Tathlum +1",
    head="Pixie Hairpin +1",
    body="Shango Robe",
    hands="Jhakri Cuffs +1",
    legs={ name="Merlinic Shalwar", augments={'Mag. Acc.+23','Magic Damage +16','"Mag.Atk.Bns."+10',}},
    feet="Jhakri Pigaches +1",
    neck="Sanctity Necklace",
    waist="Eschan Stone",
    left_ear="Barkaro. Earring",
    right_ear="Gwati Earring",
    left_ring="Evanescence Ring",
    right_ring="Archon Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
	}

	sets.midcast.Drain = {ammo="Kalboron Stone",
    head="Jhakri Coronal +1",
    body="Shango Robe",
    hands="Jhakri Cuffs +1",
    legs={ name="Merlinic Shalwar", augments={'Mag. Acc.+25 "Mag.Atk.Bns."+25','"Drain" and "Aspir" potency +9','Mag. Acc.+14',}},
    feet="Jhakri Pigaches +1",
    neck="Incanter's Torque",
    waist="Fucho-no-Obi",
    left_ear="Barkaro. Earring",
    right_ear="Gwati Earring",
    left_ring="Evanescence Ring",
    right_ring="Sangoma Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
}
    sets.midcast.Aspir = sets.midcast.Drain

    sets.midcast.Stun = {ammo="Pemphredo Tathlum",
    head={ name="Merlinic Hood", augments={'Mag. Acc.+24 "Mag.Atk.Bns."+24','Magic burst mdg.+8%','INT+2','"Mag.Atk.Bns."+7',}},
    body="Jhakri Robe +1",
    hands={ name="Chironic Gloves", augments={'Mag. Acc.+28','"Cure" spellcasting time -8%','CHR+3',}},
    legs={ name="Merlinic Shalwar", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','INT+15','Mag. Acc.+12','"Mag.Atk.Bns."+5',}},
    feet="Jhakri Pigaches +1",
    neck="Sanctity Necklace",
    waist="Eschan Stone",
    left_ear="Lifestorm Earring",
    right_ear="Psystorm Earring",
    left_ring="Vertigo Ring",
    right_ring="Evanescence Ring",
	back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
    }

    sets.midcast.Stun.Resistant = set_combine(sets.midcast.Stun, {ammo="Pemphredo Tathlum",
    head={ name="Merlinic Hood", augments={'Mag. Acc.+24 "Mag.Atk.Bns."+24','Magic burst mdg.+8%','INT+2','"Mag.Atk.Bns."+7',}},
    body="Jhakri Robe +1",
    hands={ name="Chironic Gloves", augments={'Mag. Acc.+28','"Cure" spellcasting time -8%','CHR+3',}},
    legs={ name="Merlinic Shalwar", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','INT+15','Mag. Acc.+12','"Mag.Atk.Bns."+5',}},
    feet="Jhakri Pigaches +1",
    neck="Sanctity Necklace",
    waist="Eschan Stone",
    left_ear="Lifestorm Earring",
    right_ear="Psystorm Earring",
    left_ring="Vertigo Ring",
    right_ring="Evanescence Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},})
	
	sets.midcast.Helix = {ammo="Pemphredo Tathlum",
    head={ name="Merlinic Hood", augments={'Mag. Acc.+24 "Mag.Atk.Bns."+24','Magic burst dmg.+8%','INT+2','"Mag.Atk.Bns."+7',}},
    body={ name="Merlinic Jubbah", augments={'Mag. Acc.+16 "Mag.Atk.Bns."+16','Magic burst dmg.+10%','INT+7','Mag. Acc.+11',}},
    hands={ name="Amalric Gages", augments={'INT+10','Mag. Acc.+15','"Mag.Atk.Bns."+15',}},
    legs={ name="Merlinic Shalwar", augments={'Mag. Acc.+18 "Mag.Atk.Bns."+18','Magic burst dmg.+9%','AGI+5','Mag. Acc.+10','"Mag.Atk.Bns."+8',}},
    feet="Mallquis Clogs +1",
    neck="Mizu. Kubikazari",
    waist="Refoccilation Stone",
    left_ear="Barkaro. Earring",
    right_ear="Friomisi Earring",
    left_ring="Mujin Band",
    right_ring="Locus Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
}

sets.midcast.Helix.Mid = {ammo="Pemphredo Tathlum",
    head="Mallquis Chapeau +1",
    body="Mallquis Saio +1",
    hands="Mallquis Cuffs +1",
    legs="Mallquis Trews +1",
    feet="Mallquis Clogs +1",
    neck="Eddy Necklace",
    waist="Refoccilation Stone",
    left_ear="Barkaro. Earring",
    right_ear="Friomisi Earring",
    left_ring="Shiva Ring",
    right_ring="Fenrir Ring +1",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
}

	sets.midcast.Helix.Resistant = {ammo="Pemphredo Tathlum",
    head="Mallquis Chapeau +1",
    body={ name="Merlinic Jubbah", augments={'Mag. Acc.+16 "Mag.Atk.Bns."+16','Magic burst dmg.+10%','INT+7','Mag. Acc.+11',}},
    hands="Mallquis Cuffs +1",
    legs={ name="Merlinic Shalwar", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','INT+15','Mag. Acc.+12','"Mag.Atk.Bns."+5',}},
    feet="Mallquis Clogs +1",
    neck="Sanctity Necklace",
    waist="Eschan Stone",
    left_ear="Barkaro. Earring",
    right_ear="Friomisi Earring",
    left_ring="Vertigo Ring",
    right_ring="Fenrir Ring +1",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
}

	sets.midcast.Helix.MagicBurst = {ammo="Pemphredo Tathlum",
    head={ name="Merlinic Hood", augments={'Mag. Acc.+24 "Mag.Atk.Bns."+24','Magic burst dmg.+8%','INT+2','"Mag.Atk.Bns."+7',}},
    body={ name="Merlinic Jubbah", augments={'Mag. Acc.+16 "Mag.Atk.Bns."+16','Magic burst dmg.+10%','INT+7','Mag. Acc.+11',}},
    hands={ name="Amalric Gages", augments={'INT+10','Mag. Acc.+15','"Mag.Atk.Bns."+15',}},
    legs={ name="Merlinic Shalwar", augments={'Mag. Acc.+18 "Mag.Atk.Bns."+18','Magic burst dmg.+9%','AGI+5','Mag. Acc.+10','"Mag.Atk.Bns."+8',}},
    feet="Mallquis Clogs +1",
    neck="Mizu. Kubikazari",
    waist="Eschan Stone",
    left_ear="Barkaro. Earring",
    right_ear="Friomisi Earring",
    left_ring="Mujin Band",
    right_ring="Locus Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
}
	
    sets.midcast['Noctohelix'] = set_combine(sets.midcast.Helix,{head="Pixie Hairpin +1"})
    sets.midcast['Noctohelix II'] = set_combine(sets.midcast.Helix,{head="Pixie Hairpin +1"})

	
    -- Elemental Magic sets are default for handling low-tier nukes.
    sets.midcast['Elemental Magic'] ={ammo="Pemphredo Tathlum",
    head={ name="Merlinic Hood", augments={'Mag. Acc.+24 "Mag.Atk.Bns."+24','Magic burst mdg.+8%','INT+2','"Mag.Atk.Bns."+7',}},
    body="Jhakri Robe +1",
    hands={ name="Amalric Gages", augments={'INT+10','Mag. Acc.+15','"Mag.Atk.Bns."+15',}},
    legs={ name="Merlinic Shalwar", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','INT+15','Mag. Acc.+12','"Mag.Atk.Bns."+5',}},
    feet="Jhakri Pigaches +1",
    neck="Eddy Necklace",
    waist="Refoccilation Stone",
    left_ear="Barkaro. Earring",
    right_ear="Friomisi Earring",
    left_ring="Shiva Ring",
    right_ring="Strendu Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
}

	sets.midcast['Elemental Magic'].Mid = {ammo="Pemphredo Tathlum",
    head={ name="Merlinic Hood", augments={'Mag. Acc.+24 "Mag.Atk.Bns."+24','Magic burst mdg.+8%','INT+2','"Mag.Atk.Bns."+7',}},
    body="Jhakri Robe +1",
    hands={ name="Amalric Gages", augments={'INT+10','Mag. Acc.+15','"Mag.Atk.Bns."+15',}},
    legs={ name="Merlinic Shalwar", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','INT+15','Mag. Acc.+12','"Mag.Atk.Bns."+5',}},
    feet="Jhakri Pigaches +1",
    neck="Sanctity Necklace",
    waist="Eschan Stone",
    left_ear="Barkaro. Earring",
    right_ear="Friomisi Earring",
    left_ring="Vertigo Ring",
    right_ring="Shiva Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
}


    sets.midcast['Elemental Magic'].Resistant = {ammo="Pemphredo Tathlum",
    head={ name="Merlinic Hood", augments={'Mag. Acc.+24 "Mag.Atk.Bns."+24','Magic burst mdg.+8%','INT+2','"Mag.Atk.Bns."+7',}},
    body="Jhakri Robe +1",
    hands="Jhakri Cuffs +1",
    legs={ name="Merlinic Shalwar", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','INT+15','Mag. Acc.+12','"Mag.Atk.Bns."+5',}},
    feet="Jhakri Pigaches +1",
    neck="Sanctity Necklace",
    waist="Eschan Stone",
    left_ear="Barkaro. Earring",
    right_ear="Friomisi Earring",
    left_ring="Vertigo Ring",
    right_ring="Shiva Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
}

    

    -- Custom refinements for certain nuke tiers
    sets.midcast['Elemental Magic'].HighTierNuke = 	{ammo="Pemphredo Tathlum",
    head={ name="Merlinic Hood", augments={'Mag. Acc.+24 "Mag.Atk.Bns."+24','Magic burst mdg.+8%','INT+2','"Mag.Atk.Bns."+7',}},
    body="Jhakri Robe +1",
    hands={ name="Amalric Gages", augments={'INT+10','Mag. Acc.+15','"Mag.Atk.Bns."+15',}},
    legs={ name="Merlinic Shalwar", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','INT+15','Mag. Acc.+12','"Mag.Atk.Bns."+5',}},
    feet="Jhakri Pigaches +1",
    neck="Sanctity Necklace",
    waist="Eschan Stone",
    left_ear="Barkaro. Earring",
    right_ear="Friomisi Earring",
    left_ring="Strendu Ring",
    right_ring="Shiva Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
	}

    sets.midcast['Elemental Magic'].HighTierNuke.Mid = set_combine(sets.midcast['Elemental Magic'].Mid, 
		
		{})

    sets.midcast['Elemental Magic'].HighTierNuke.Resistant = set_combine(sets.midcast['Elemental Magic'].Resistant, 
		{})

    sets.magic_burst = {ammo="Pemphredo Tathlum",
    head={ name="Merlinic Hood", augments={'Mag. Acc.+24 "Mag.Atk.Bns."+24','Magic burst mdg.+8%','INT+2','"Mag.Atk.Bns."+7',}},
    body={ name="Merlinic Jubbah", augments={'Mag. Acc.+16 "Mag.Atk.Bns."+16','Magic burst mdg.+10%','INT+7','Mag. Acc.+11',}},
    hands={ name="Amalric Gages", augments={'INT+10','Mag. Acc.+15','"Mag.Atk.Bns."+15',}},
    legs={ name="Merlinic Shalwar", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','INT+15','Mag. Acc.+12','"Mag.Atk.Bns."+5',}},
    feet="Jhakri Pigaches +1",
    neck="Mizu. Kubikazari",
    waist="Refoccilation Stone",
    left_ear="Barkaro. Earring",
    right_ear="Friomisi Earring",
    left_ring="Mujin Band",
    right_ring="Locus Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
}

	sets.midcast['Elemental Magic'].MagicBurst = {
    ammo="Pemphredo Tathlum",
    head={ name="Merlinic Hood", augments={'Mag. Acc.+24 "Mag.Atk.Bns."+24','Magic burst mdg.+8%','INT+2','"Mag.Atk.Bns."+7',}},
    body={ name="Merlinic Jubbah", augments={'Mag. Acc.+16 "Mag.Atk.Bns."+16','Magic burst mdg.+10%','INT+7','Mag. Acc.+11',}},
    hands={ name="Amalric Gages", augments={'INT+10','Mag. Acc.+15','"Mag.Atk.Bns."+15',}},
    legs={ name="Merlinic Shalwar", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','INT+15','Mag. Acc.+12','"Mag.Atk.Bns."+5',}},
    feet="Jhakri Pigaches +1",
    neck="Mizu. Kubikazari",
    waist="Refoccilation Stone",
    left_ear="Barkaro. Earring",
    right_ear="Friomisi Earring",
    left_ring="Mujin Band",
    right_ring="Locus Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
} 
	
	sets.midcast['Elemental Magic'].MBresist = {ammo="Pemphredo Tathlum",
    head={ name="Merlinic Hood", augments={'Mag. Acc.+24 "Mag.Atk.Bns."+24','Magic burst mdg.+8%','INT+2','"Mag.Atk.Bns."+7',}},
    body={ name="Merlinic Jubbah", augments={'Mag. Acc.+16 "Mag.Atk.Bns."+16','Magic burst mdg.+10%','INT+7','Mag. Acc.+11',}},
    hands={ name="Amalric Gages", augments={'INT+10','Mag. Acc.+15','"Mag.Atk.Bns."+15',}},
    legs={ name="Merlinic Shalwar", augments={'Mag. Acc.+18 "Mag.Atk.Bns."+18','Magic burst mdg.+9%','AGI+5','Mag. Acc.+10','"Mag.Atk.Bns."+8',}},
    feet="Jhakri Pigaches +1",
    neck="Mizu. Kubikazari",
    waist="Eschan Stone",
    left_ear="Barkaro. Earring",
    right_ear="Friomisi Earring",
    left_ring="Mujin Band",
    right_ring="Locus Ring",
    back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},
}
		
		
		

    sets.midcast.Impact = {main=gear.EnfeebStaff,sub="Mephitis Grip",ammo="Savant's treatise",
        head=empty,neck="Incanter's torque",ear1="Barkarole Earring",ear2="Gwati Earring",
        body="Twilight Cloak",hands="Kaykaus cuffs",ring1="Metamorph Ring",ring2="Sangoma Ring",
        back="Bookworm's Cape",waist="Eschan Stone",legs="Merlinic shalwar",feet="Medium's Sabots"}


    -- Sets to return to when not performing an action.

    -- Resting sets
    sets.resting = {
        head="Befouled crown",
        body="Witching Robe",hands="",legs="Lengo Pants",feet=""}


    -- Idle sets (default idle set not needed since the other three are defined, but leaving for testing purposes)

    sets.idle.Town = {ammo="Homiliary",
    head="Arbatel Bonnet +1",
    body="Councilor's Garb",
    hands={ name="Amalric Gages", augments={'INT+10','Mag. Acc.+15','"Mag.Atk.Bns."+15',}},
    legs={ name="Pedagogy Pants", augments={'Enhances "Tabula Rasa" effect',}},
    feet={ name="Amalric Nails", augments={'Mag. Acc.+15','"Mag.Atk.Bns."+15','"Conserve MP"+6',}},
    neck="Incanter's Torque",
    waist="Fucho-no-Obi",
    left_ear="Barkaro. Earring",
    right_ear="Ethereal Earring",
    left_ring="Defending Ring",
    right_ring="Dark Ring",
    back={ name="Bookworm's Cape", augments={'INT+2','MND+1','Helix eff. dur. +19','"Regen" potency+8',}},}

    sets.idle.Field = {ammo="Homiliary",
    head="Befouled Crown",
    body="Jhakri Robe +1",
    hands="Shrieker's Cuffs",
    legs={ name="Lengo Pants", augments={'INT+7','Mag. Acc.+7','"Mag.Atk.Bns."+3','"Refresh"+1',}},
    feet="Mallquis Clogs +1",
    neck="Twilight Torque",
    waist="Fucho-no-Obi",
    left_ear="Savant's Earring",
    right_ear="Ethereal Earring",
    left_ring="Defending Ring",
    right_ring="Dark Ring",
    back="Solemnity Cape",
}

    sets.idle.Field.PDT = {ammo="Brigantia Pebble",
    head="Befouled Crown",
    body="Mallquis Saio +1",
    hands="Shrieker's Cuffs",
    legs="Miasmic Pants",
    feet="Mallquis Clogs +1",
    neck="Twilight Torque",
    waist="Fucho-no-Obi",
    left_ear="Etiolation Earring",
    right_ear="Ethereal Earring",
    left_ring="Defending Ring",
    right_ring="Dark Ring",
    back="Solemnity Cape",}

sets.idle.Field.MDT = {ammo="Vanir Battery",
    head="Chironic Hat",
    body="Mallquis Saio +1",
    hands="Shrieker's Cuffs",
    legs="Gyve Trousers",
    feet={ name="Amalric Nails", augments={'Mag. Acc.+15','"Mag.Atk.Bns."+15','"Conserve MP"+6',}},
    neck="Twilight Torque",
    waist="Slipor Sash",
    left_ear="Savant's Earring",
    right_ear="Etiolation Earring",
    left_ring="Defending Ring",
    right_ring="Fortified Ring",
    back="Solemnity Cape",}

	sets.idle.Field.Burst = {}

sets.idle.Field.Hybrid = {}


    sets.idle.Field.Stun ={} 

    sets.idle.Weak = {}

    -- Defense sets

    sets.defense.PDT = {}

    sets.defense.MDT = {}

    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 = {
    ammo="Vanir Battery",
    head="Jhakri Coronal +1",
    body="Jhakri Robe +1",
    hands="Jhakri Cuffs +1",
    legs="Jhakri Slops +1",
    feet="Jhakri Pigaches +1",
    neck="Lissome Necklace",
    waist="Grunfeld Rope",
    left_ear="Cessance Earring",
    right_ear="Brutal Earring",
    left_ring="Petrov Ring",
    right_ring="Defending Ring",
    back="Relucent Cape",
}

    -- Elemental Obi/Twilight Cape --
        sets.Obi = {main=gear.NukeStaff,
		back="Twilight Cape",waist='Hachirin-no-Obi'}
       
    -- Buff sets: Gear that needs to be worn to actively enhance a current player buff.
    sets.buff['Ebullience'] = {head="Arbatel Bonnet +1"}
    sets.buff['Rapture'] = {head="Arbatel Bonnet +1"}
    sets.buff['Perpetuance'] = {hands="Arbatel Bracers +1"}
    sets.buff['Immanence'] = {hands="Arbatel Bracers +1"}
    sets.buff['Penury'] = {legs="Savant's Pants +2"}
    sets.buff['Parsimony'] = {legs="Savant's Pants +2"}
    sets.buff['Celerity'] = {feet="Pedagogy Loafers"}
    sets.buff['Alacrity'] = {feet="Pedagogy Loafers"}

    sets.buff['Klimaform'] = {feet="Arbatel Loafers +1"}

    sets.buff.FullSublimation = {head="Academic's Mortarboard",ear1="Savant's Earring",body="Pedagogy Gown"}
    sets.buff.PDTSublimation = {head="Academic's Mortarboard",ear1="Savant's Earring"}

end

-------------------------------------------------------------------------
--Pretarget
-------------------------------------------------------------------------
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:ifind("Cure") and player.mp<actualCost(spell.mp_cost) then
                        degrade_spell(spell,Cure_Spells)
                elseif spell.english:ifind("Curaga") and player.mp<actualCost(spell.mp_cost) then
                        degrade_spell(spell,Curaga_Spells)
                elseif buffactive['Light Arts'] or buffactive['Addendum: White'] then
                        if spell.english == "Light Arts" and not buffactive['Addendum: White'] then
                                cancel_spell()
                                send_command('input /ja Addendum: White <me>')
                        elseif spell.english == "Manifestation" then
                                cancel_spell()
                                send_command('input /ja Accession <me>')
                        elseif spell.english == "Alacrity" then
                                cancel_spell()
                                send_command('input /ja Celerity <me>')
                        elseif spell.english == "Parsimony" then
                                cancel_spell()
                                send_command('input /ja Penury <me>')
                end
                elseif buffactive['Dark Arts'] or buffactive['Addendum: Black'] then
                        if spell.english == "Dark Arts" and not buffactive['Addendum: Black'] then
                                cancel_spell()
                                send_command('input /ja Addendum: Black <me>')
                        elseif spell.english == "Accession" then
                                cancel_spell()
                                send_command('input /ja Manifestation <me>')
                        elseif spell.english == "Celerity" then
                                cancel_spell()
                                send_command('input /ja Alacrity <me>')
                        elseif spell.english == "Penury" then
                                cancel_spell()
                                send_command('input /ja Parsimony <me>')
                end
    end
end
-----------------------------------------------------------------
--Precast
------------------------------------------------------------------
function job_precast(spell, action, spellMap)
                        if string.find(spell.english,'Cur') and spell.english ~= "Cursna" then
                                equip(sets.precast.FC.Cure)
					end
                        if spell.english == "Impact" then
                                equip(set_combine(sets.precast.FC,{body="Twilight Cloak"}))
					end
end

function job_post_precast(spell, action, spellMap, eventArgs)
		if (buffactive['Addendum: White'] or buffactive['Light Arts']) and spell.type == 'WhiteMagic' then
			equip(sets.precast.FC.Arts)
		end
		if (buffactive['Addendum: Black'] or buffactive['Dark Arts']) and spell.type == 'BlackMagic' then
			equip(sets.precast.FC.Arts)
		end
end

-----------------------------------------------------------------------
--Midcast
-------------------------------------------------------------------------
function job_midcast(spell, action, spellMap, eventArgs)
    equipSet = {}
                        if spell.type:endswith('Magic') or spell.type == 'Ninjutsu' or spell.type == 'BardSong' then
                                equipSet = sets.midcast

                        elseif string.find(spell.english,'Cure') then
                                equipSet = equipSet.Cure
                        elseif string.find(spell.english,'Cura') then
                                equipSet = equipSet.Curaga
                        elseif string.find(spell.english,'Banish') then
                                equipSet = set_combine(equipSet.MndEnfeebles)
                        elseif spell.english == "Stoneskin" then
						  equipSet = equipSet.Stoneskin
                                if buffactive.Stoneskin then
                                        send_command('cancel stoneskin')
							end
                        elseif spell.english == "Sneak" then
                                if spell.target.name == player.name and buffactive['Sneak'] then
                                        send_command('cancel sneak')
                                end
                                equipSet = equipSet.Haste
                        elseif 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
                                equipSet = equipSet.Haste
                        elseif spell.english == 'Monomi: Ichi' then
                                if buffactive['Sneak'] then
                                        send_command('@wait 1.7;cancel sneak')
                                end
                                equipSet = equipSet.Haste
                    
                        else
                        if equipSet[spell.english] then
                                equipSet = equipSet[spell.english]
                        end
                        if equipSet[spell.skill] then
                                equipSet = equipSet[spell.skill]
                        end
                        if equipSet[spell.type] then
                                equipSet = equipSet[spell.type]
                        end
                        
                        if string.find(spell.english,'Cure')  and (world.weather_element == spell.element) or  (world.day_element == spell.element) then
                                equipSet = set_combine(equipSet,sets.Obi)
                        end    
                        if ((spell.english == 'Drain') or (spell.english == 'Aspir')) and ((world.day_element == spell.element) or (world.weather_element == spell.element)) then
                                equipSet = set_combine(equipSet,sets.Obi)
                        end  
			end
    if equipSet[spell.english] then
        equipSet = equipSet[spell.english]
    end
    equip(equipSet)
end


-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for standard casting events.
-------------------------------------------------------------------------------------------------------------------

-- Run after the general midcast() is done.
function job_post_midcast(spell, action, spellMap, eventArgs)
    if spell.action_type == 'Magic' then
	apply_grimoire_bonuses(spell, action, spellMap, eventArgs)
	   if spell.skill == 'Elemental Magic' then
		if spell.element == world.day_element or spell.element == world.weather_element then
			equip(equipSet, sets.Obi)
			if string.find(spell.english,'helix') then
				equip(sets.midcast.Helix)
				if state.MagicBurst.value then
					equip(sets.magic_burst)
				end
			elseif state.MagicBurst.value then
				equip(sets.magic_burst) 
			end
		elseif state.MagicBurst.value then
			equip(sets.magic_burst) 
		end
	   end
	end
	if not spell.interrupted then
                if spell.english == "Sleep II" then -- Sleep II Countdown --
                        send_command('wait 60;input /echo Sleep Effect: [WEARING OFF IN 30 SEC.];wait 15;input /echo Sleep Effect: [WEARING OFF IN 15 SEC.];wait 10;input /echo Sleep Effect: [WEARING OFF IN 5 SEC.]')
                elseif spell.english == "Sleep" or spell.english == "Sleepga" then -- Sleep & Sleepga Countdown --
                        send_command('wait 30;input /echo Sleep Effect: [WEARING OFF IN 30 SEC.];wait 15;input /echo Sleep Effect: [WEARING OFF IN 15 SEC.];wait 10;input /echo Sleep Effect: [WEARING OFF IN 5 SEC.]')
                elseif spell.english == "Break" then -- Break Countdown --
                        send_command('wait 25;input /echo Break Effect: [WEARING OFF IN 5 SEC.]')
                elseif spell.english == "Paralyze" then -- Paralyze Countdown --
                        send_command('wait 115;input /echo Paralyze Effect: [WEARING OFF IN 5 SEC.]')
                elseif spell.english == "Slow" then -- Slow Countdown --
                        send_command('wait 115;input /echo Slow Effect: [WEARING OFF IN 5 SEC.]')
                elseif spell.english == "Banish II" then -- Banish II Countdown --
                        send_command('wait 20;input /echo Banish Effect: [WEARING OFF IN 10 SEC.]')
			elseif spell.english == "Gravity" then
				send_command('wait 60;input /echo Gravity Effect: [WEARING OFF IN 60 SEC.];wait 30;input /echo Gravity Effect: [WEARING OFF IN 30 SEC.];wait 20;input /echo Gravity Effect: [WEARING OFF IN 10 SEC.]')
			elseif spell.english == "Frazzle" then
				send_command('wait 90;input /echo Frazzle Effect: [WEARING OFF IN 30 SEC.];wait 20;input /echo Frazzle Effect: [WEARING OFF IN 10 SEC.]')
			elseif spell.english == "Distract" then
				send_command('wait 90;input /echo Distract Effect: [WEARING OFF IN 30 SEC.];wait 20;input /echo Distract Effect: [WEARING OFF IN 10 SEC.]')
			elseif spell.english == "Silence" then
				send_command('wait 90;input /echo Silence Effect: [WEARING OFF IN 30 SEC.];wait 20;input /echo Silence Effect: [WEARING OFF IN 10 SEC.]')
			elseif spell.english == "Poison II" then
				send_command('wait 90;input /echo Poison Effect: [WEARING OFF IN 30 SEC.];wait 20;input /echo Poison Effect: [WEARING OFF IN 10 SEC.]')
                end
     end
end

function job_aftercast(spell, action, spellMap, eventArgs)
     if not spell.interrupted then
         if spell.skill == 'Elemental Magic' then
            ---state.MagicBurst:reset()
        end
    end
end

-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for non-casting events.
-------------------------------------------------------------------------------------------------------------------

-- 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 buff == "Sublimation: Activated" then
        handle_equipping_gear(player.status)
    end
end

-- Handle notifications of general user state change.
function job_state_change(stateField, newValue, oldValue)
    if stateField == 'Offense Mode' then
        if newValue == 'Normal' then
            disable('main','sub','range')
        else
            enable('main','sub','range')
        end
    end
end

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

-- Custom spell mapping.
function job_get_spell_map(spell, default_spell_map)
    if spell.action_type == 'Magic' then
        if default_spell_map == 'Cure' or default_spell_map == 'Curaga' then
            if world.weather_element == 'Light' then
                return 'CureWithLightWeather'
            end
        elseif spell.skill == 'Enfeebling Magic' then
            if spell.type == 'WhiteMagic' then
                return 'MndEnfeebles'
            else
                return 'IntEnfeebles'
            end
        elseif spell.skill == 'Elemental Magic' then
            if info.low_nukes:contains(spell.english) then
                return 'LowTierNuke'
            elseif info.mid_nukes:contains(spell.english) then
                return 'MidTierNuke'
            elseif info.high_nukes:contains(spell.english) then
                return 'HighTierNuke'
            end
        end
    end
end

function customize_idle_set(idleSet)
    if state.Buff['Sublimation: Activated'] then
        if state.IdleMode.value == 'Normal' then
            idleSet = set_combine(idleSet, sets.buff.FullSublimation)
        elseif state.IdleMode.value == 'PDT' then
            idleSet = set_combine(idleSet, sets.buff.PDTSublimation)
        end
    end

    if player.mpp < 51 then
        idleSet = set_combine(idleSet, sets.latent_refresh)
    end

    return idleSet
end

-- Called by the 'update' self-command.
function job_update(cmdParams, eventArgs)
    if cmdParams[1] == 'user' and not (buffactive['light arts']      or buffactive['dark arts'] or
                       buffactive['addendum: white'] or buffactive['addendum: black']) then
        if state.IdleMode.value == 'Stun' then
            send_command('@input /ja "Dark Arts" <me>')
        else
            send_command('@input /ja "Light Arts" <me>')
        end
    end

    update_active_strategems()
    update_sublimation()
end

-- Function to display the current relevant user state when doing an update.
-- Return true if display was handled, and you don't want the default info shown.
function display_current_job_state(eventArgs)
    display_current_caster_state()
    eventArgs.handled = true
end

-------------------------------------------------------------------------------------------------------------------
-- User code that supplements self-commands.
-------------------------------------------------------------------------------------------------------------------
-- In Game: //gs c (command), Macro: /console gs c (command), Bind: gs c (command) --
-- Called for direct player commands.
function job_self_command(cmdParams, eventArgs)
    if cmdParams[1]:lower() == 'scholar' then
        handle_strategems(cmdParams)
        eventArgs.handled = true

    end
end

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

-- Reset the state vars tracking strategems.
function update_active_strategems()
    state.Buff['Ebullience'] = buffactive['Ebullience'] or false
    state.Buff['Rapture'] = buffactive['Rapture'] or false
    state.Buff['Perpetuance'] = buffactive['Perpetuance'] or false
    state.Buff['Immanence'] = buffactive['Immanence'] or false
    state.Buff['Penury'] = buffactive['Penury'] or false
    state.Buff['Parsimony'] = buffactive['Parsimony'] or false
    state.Buff['Celerity'] = buffactive['Celerity'] or false
    state.Buff['Alacrity'] = buffactive['Alacrity'] or false

    state.Buff['Klimaform'] = buffactive['Klimaform'] or false
end

function update_sublimation()
    state.Buff['Sublimation: Activated'] = buffactive['Sublimation: Activated'] or false
end

-- Equip sets appropriate to the active buffs, relative to the spell being cast.
function apply_grimoire_bonuses(spell, action, spellMap)
    if state.Buff.Perpetuance and spell.type =='WhiteMagic' and spell.skill == 'Enhancing Magic' then
        equip(sets.buff['Perpetuance'])
    end
    if (spellMap == 'Cure' or spellMap == 'Curaga') and (buffactive['Light Arts'] or buffactive['Addendum: White']) then
		if state.Buff.Rapture then
        		equip(sets.buff['Rapture'])
		end
    end
    if spell.skill == 'Elemental Magic' and spellMap ~= 'ElementalEnfeeble' then
        if state.Buff.Ebullience and spell.english ~= 'Impact' then
            equip(sets.buff['Ebullience'])
        end
        if state.Buff.Immanence then
            equip(sets.buff['Immanence'])
        end
        if state.Buff.Klimaform and spell.element == world.weather_element then
            equip(sets.buff['Klimaform'])
        end
    end

    if state.Buff.Penury then equip(sets.buff['Penury']) end
    if state.Buff.Parsimony then equip(sets.buff['Parsimony']) end
    if state.Buff.Celerity then equip(sets.buff['Celerity']) end
    if state.Buff.Alacrity then equip(sets.buff['Alacrity']) end
end


-- General handling of strategems in an Arts-agnostic way.
-- Format: gs c scholar <strategem>
function handle_strategems(cmdParams)
    -- cmdParams[1] == 'scholar'
    -- cmdParams[2] == strategem to use

    if not cmdParams[2] then
        add_to_chat(123,'Error: No strategem command given.')
        return
    end
	
	local currentStrats = get_current_strategem_count()
	local newStratCount = currentStrats - 1
	if currentStrats > 0 then
		add_to_chat(122, '***Current Charges Available: ['..newStratCount..']***')
	else
		add_to_chat(122, '***Out of stratagems! Cancelling...***')
		return
	end
    local strategem = cmdParams[2]:lower()

    if strategem == 'light' then
        if buffactive['light arts'] then
            send_command('input /ja "Addendum: White" <me>')
        elseif buffactive['addendum: white'] then
            add_to_chat(122,'Error: Addendum: White is already active.')
        else
            send_command('input /ja "Light Arts" <me>')
        end
    elseif strategem == 'dark' then
        if buffactive['dark arts'] then
            send_command('input /ja "Addendum: Black" <me>')
        elseif buffactive['addendum: black'] then
            add_to_chat(122,'Error: Addendum: Black is already active.')
        else
            send_command('input /ja "Dark Arts" <me>')
        end
    elseif buffactive['light arts'] or buffactive['addendum: white'] then
        if strategem == 'cost' then
            send_command('input /ja Penury <me>')
        elseif strategem == 'speed' then
            send_command('input /ja Celerity <me>')
        elseif strategem == 'aoe' then
            send_command('input /ja Accession <me>')
        elseif strategem == 'power' then
            send_command('input /ja Rapture <me>')
        elseif strategem == 'duration' then
            send_command('input /ja Perpetuance <me>')
        elseif strategem == 'accuracy' then
            send_command('input /ja Altruism <me>')
        elseif strategem == 'enmity' then
            send_command('input /ja Tranquility <me>')
        elseif strategem == 'skillchain' then
            add_to_chat(122,'Error: Light Arts does not have a skillchain strategem.')
        elseif strategem == 'addendum' then
            send_command('input /ja "Addendum: White" <me>')
        else
            add_to_chat(123,'Error: Unknown strategem ['..strategem..']')
        end
    elseif buffactive['dark arts']  or buffactive['addendum: black'] then
        if strategem == 'cost' then
            send_command('input /ja Parsimony <me>')
        elseif strategem == 'speed' then
            send_command('input /ja Alacrity <me>')
        elseif strategem == 'aoe' then
            send_command('input /ja Manifestation <me>')
        elseif strategem == 'power' then
            send_command('input /ja Ebullience <me>')
        elseif strategem == 'duration' then
            add_to_chat(122,'Error: Dark Arts does not have a duration strategem.')
        elseif strategem == 'accuracy' then
            send_command('input /ja Focalization <me>')
        elseif strategem == 'enmity' then
            send_command('input /ja Equanimity <me>')
        elseif strategem == 'skillchain' then
            send_command('input /ja Immanence <me>')
        elseif strategem == 'addendum' then
            send_command('input /ja "Addendum: Black" <me>')
        else
            add_to_chat(123,'Error: Unknown strategem ['..strategem..']')
        end
    else
        add_to_chat(123,'No arts has been activated yet.')
    end
end


-- Gets the current number of available strategems based on the recast remaining
-- and the level of the sch.
function get_current_strategem_count()
    -- returns recast in seconds.
    local allRecasts = windower.ffxi.get_ability_recasts()
    local stratsRecast = allRecasts[231]

    local maxStrategems = (player.main_job_level + 10) / 20

    local fullRechargeTime = 5*33

    local currentCharges = math.floor(maxStrategems - maxStrategems * stratsRecast / fullRechargeTime)

    return currentCharges
end


-- Select default macro book on initial load or subjob change.
function select_default_macro_book()
    set_macro_page(3, 14)
end
necroskull Necro Bump Detected! [462 days between previous and next post]
 Asura.Massacres
Offline
Serveur: Asura
Game: FFXI
user: hamany9
Posts: 28
By Asura.Massacres 2018-06-20 08:53:51
Link | Citer | R
 
Asura.Thorva said: »
Bahamut.Neb said: »
If you are using gearswap make sure you add all the Helix II spells to the Mote-Mappings Lua too or you wont gear swap I had that problem for a while wondering why my dmg sucked so bad.
Shiva.Arislan said: »
Lakshmi.Ashtopcat said: »
windower 4 > addons > gearswap > libs> mote-mappings

line 194 should be the helices (just add the t2s)
Code
['Pyrohelix']='Helix',['Cryohelix']='Helix',['Anemohelix']='Helix',['Geohelix']='Helix',['Ionohelix']='Helix',['Hydrohelix']='Helix',['Luminohelix']='Helix',['Noctohelix']='Helix',
    ['Firestorm']='Storm',['Hailstorm']='Storm',['Windstorm']='Storm',['Sandstorm']='Storm',['Thunderstorm']='Storm',['Rainstorm']='Storm',['Aurorastorm']='Storm',['Voidstorm']='Storm',
	['Pyrohelix II']='Helix',['Cryohelix II']='Helix',['Anemohelix II']='Helix',['Geohelix II']='Helix',['Ionohelix II']='Helix',['Hydrohelix II']='Helix',['Luminohelix II']='Helix',['Noctohelix II']='Helix',
    ['Firestorm II']='Storm',['Hailstorm II']='Storm',['Windstorm II']='Storm',['Sandstorm II']='Storm',['Thunderstorm II']='Storm',['Rainstorm II']='Storm',['Aurorastorm II']='Storm',['Voidstorm II']='Storm',

Just wanted to a add a useful tidbit to this already extremely helpful post: it's possible to set Nocto and Lumino to their own separate categories so you can pop in affinity gear for those (Pixie Hairpin +1, Archon Ring, Weatherspoon Ring).

Code
['Luminohelix']='LightHelix',['Noctohelix']='DarkHelix',['Luminohelix II']='LightHelix',['Noctohelix II']='DarkHelix',

I tried to edit mote-mapping file to make noctohelix and noctohelix II into DarkHelix but it's not working, do i also need to edit my sch macro? sets.midcast.DarkHelix doesn't work.

here's my mote-mapping and my sch macross.

Mote-mapping:
Code
['Pyrohelix']='Helix',['Cryohelix']='Helix',['Anemohelix']='Helix',['Geohelix']='Helix',['Ionohelix']='Helix',['Hydrohelix']='Helix',['Luminohelix']='Helix',['Noctohelix']='DarkHelix',
    ['Firestorm']='Storm',['Hailstorm']='Storm',['Windstorm']='Storm',['Sandstorm']='Storm',['Thunderstorm']='Storm',['Rainstorm']='Storm',['Aurorastorm']='Storm',['Voidstorm']='Storm',
    ['Pyrohelix II']='Helix',['Cryohelix II']='Helix',['Anemohelix II']='Helix',['Geohelix II']='Helix',['Ionohelix II']='Helix',['Hydrohelix II']='Helix',['Luminohelix II']='Helix',['Noctohelix II']='DarkHelix',
    ['Firestorm II']='Storm',['Hailstorm II']='Storm',['Windstorm II']='Storm',['Sandstorm II']='Storm',['Thunderstorm II']='Storm',['Rainstorm II']='Storm',['Aurorastorm II']='Storm',['Voidstorm II']='Storm',


Here's my sch lua:
Code
-------------------------------------------------------------------------------------------------------------------
-- Setup functions for this job.  Generally should not be modified.
-------------------------------------------------------------------------------------------------------------------

--[[
        Custom commands:
        Shorthand versions for each strategem type that uses the version appropriate for
        the current Arts.
                                        Light Arts              Dark Arts
        gs c scholar light              Light Arts/Addendum
        gs c scholar dark                                       Dark Arts/Addendum
        gs c scholar cost               Penury                  Parsimony
        gs c scholar speed              Celerity                Alacrity
        gs c scholar aoe                Accession               Manifestation
        gs c scholar power              Rapture                 Ebullience
        gs c scholar duration           Perpetuance
        gs c scholar accuracy           Altruism                Focalization
        gs c scholar enmity             Tranquility             Equanimity
        gs c scholar skillchain                                 Immanence
        gs c scholar addendum           Addendum: White         Addendum: Black
--]]



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

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

-- Setup vars that are user-independent.  state.Buff vars initialized here will automatically be tracked.
function job_setup()
    info.addendumNukes = S{"Stone IV", "Water IV", "Aero IV", "Fire IV", "Blizzard IV", "Thunder IV",
        "Stone V", "Water V", "Aero V", "Fire V", "Blizzard V", "Thunder V"}

    state.Buff['Sublimation: Activated'] = buffactive['Sublimation: Activated'] or false
    update_active_strategems()
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.OffenseMode:options('None', 'Normal', 'DT')
    state.CastingMode:options('Normal','MagicBurst','Resistant')
    state.IdleMode:options('Normal', 'PDT')


    info.low_nukes = S{"Stone", "Water", "Aero", "Fire", "Blizzard", "Thunder"}
    info.mid_nukes = S{"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",}
    info.high_nukes = S{"Stone V", "Water V", "Aero V", "Fire V", "Blizzard V", "Thunder V"}
    

    gear.macc_hagondes = {name="Hagondes Cuffs", augments={'Phys. dmg. taken -3%','Mag. Acc.+29'}}

    send_command('bind ^` input /ma Stun <t>')
    send_command('wait 6;input /lockstyleset 82')

    select_default_macro_book()
end

function user_unload()
    send_command('unbind ^`')
end


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

    -- Precast Sets

    -- Precast sets to enhance JAs

    sets.precast.JA['Tabula Rasa'] = {legs="Pedagogy Pants"}


    -- Fast cast sets for spells

    sets.precast.FC = {ammo="Sapience orb",neck="Orunmila's Torque",
        head={ name="Merlinic Hood", augments={'"Fast Cast"+6','CHR+2','Mag. Acc.+13','"Mag.Atk.Bns."+8',}},ear2="Loquacious Earring",ear1="Etiolation Earring",
        body={ name="Merlinic Jubbah", augments={'"Mag.Atk.Bns."+12','"Fast Cast"+7','AGI+1',}},hands={ name="Merlinic Dastanas", augments={'"Fast Cast"+6','INT+3','Mag. Acc.+1',}},ring1="Rahab Ring",ring2="Kishar ring",
        back="Swith Cape",waist="Witful Belt",legs="Psycloth Lappas",feet={ name="Merlinic Crackows", augments={'"Fast Cast"+6','MND+5','Mag. Acc.+9','"Mag.Atk.Bns."+7',}}}

    sets.precast.FC['Enhancing Magic'] = set_combine(sets.precast.FC, {waist="Siegel Sash"})

    sets.precast.FC['Elemental Magic'] = set_combine(sets.precast.FC, {neck="Orunmila's Torque"})

    sets.precast.FC.Cure = set_combine(sets.precast.FC, {body={ name="Merlinic Jubbah", augments={'"Mag.Atk.Bns."+12','"Fast Cast"+7','AGI+1',}},back="Pahtli Cape"})

    sets.precast.FC.Curaga = sets.precast.FC.Cure

    sets.precast.FC.Impact = set_combine(sets.precast.FC['Elemental Magic'], {head=empty,body="Twilight Cloak"})


    -- Midcast Sets

    sets.midcast.FastRecast = {ammo="Sapience orb",neck="Orunmila's Torque",
        head={ name="Merlinic Hood", augments={'"Fast Cast"+6','CHR+2','Mag. Acc.+13','"Mag.Atk.Bns."+8',}},ear2="Loquacious Earring",ear1="Etiolation Earring",
        body={ name="Merlinic Jubbah", augments={'"Mag.Atk.Bns."+12','"Fast Cast"+7','AGI+1',}},hands="Kaykaus cuffs",ring1="Rahab Ring",ring2="Kishar ring",
        back="Swith Cape",waist="Goading Belt",legs="Psycloth Lappas",feet={ name="Merlinic Crackows", augments={'"Fast Cast"+6','MND+5','Mag. Acc.+9','"Mag.Atk.Bns."+7',}}}

    sets.midcast.Cure = {ammo="Pemphredo tathlum",
        head="Kaykaus mitra",neck="Incanter's Torque",ear1="Moonshade earring",ear2="Mendicant's Earring",
        body="Kaykaus bliaut",hands="Kaykaus cuffs",ring1="Mephitas's ring +1",ring2="Ephedra ring",
        back="Fi follet cape +1",waist="Gishdubar sash",legs="Kaykaus tights",feet="Kaykaus boots"}

    sets.midcast.CureWithLightWeather = {ammo="Pemphredo tathlum",
        head="Kaykaus mitra",neck="Incanter's Torque",ear1="Mendicant's Earring",ear2="Moonshade earring",
        body="Kaykaus bliaut",hands="Kaykaus cuffs",ring1="Mephitas's ring +1",ring2="Ephedra ring",
        back="Solemnity cape",waist="Hachirin-no-obi",legs="Kaykaus tights",feet="Kaykaus boots"}
    sets.midcast.Curaga = sets.midcast.Cure

    sets.midcast.Regen = {main="Bolelabunga",sub="Ammurapi Shield",ammo="Pemphredo tathlum",
        head="Arbatel Bonnet +1",neck="Incanter's Torque",left_ear="Mendi. Earring",right_ear="Gwati Earring",
        body={ name="Telchine Chas.", augments={'Enh. Mag. eff. dur. +10',}},hands={ name="Telchine Gloves", augments={'Enh. Mag. eff. dur. +9',}},
        back={ name="Lugh's Cape", augments={'INT+20','Mag. Acc+20 /Mag. Dmg.+20','INT+10','"Mag.Atk.Bns."+10',}},waist="Luminary Sash",legs={ name="Telchine Braconi", augments={'Enh. Mag. eff. dur. +10',}},
        feet={ name="Telchine Pigaches", augments={'Enh. Mag. eff. dur. +9',}}}

    sets.midcast.Cursna = {
        neck="Malison Medallion",
        hands="Hieros Mittens",ring1="Ephedra Ring",
        feet="Vanya clogs"}

    sets.midcast['Enhancing Magic'] = {main="Gada",sub="Ammurapi shield",ammo="Savant's Treatise",
        head={ name="Telchine Cap", augments={'Enh. Mag. eff. dur. +9',}},neck="Incanter's Torque",ear1="Andoaa Earring",
        body={ name="Telchine Chas.", augments={'Enh. Mag. eff. dur. +10',}},hands={ name="Telchine Gloves", augments={'Enh. Mag. eff. dur. +9',}},
        back="Fi follet cape +1",waist="Olympus Sash",legs={ name="Telchine Braconi", augments={'Enh. Mag. eff. dur. +10',}},Feet={ name="Telchine Pigaches", augments={'Enh. Mag. eff. dur. +9',}}}

    sets.midcast.Stoneskin = set_combine(sets.midcast['Enhancing Magic'], {waist="Siegel Sash"})

    sets.midcast.Storm = set_combine(sets.midcast['Enhancing Magic'], {feet={ name="Telchine Pigaches", augments={'Enh. Mag. eff. dur. +9',}}})

    sets.midcast.Protect = {main="Gada",sub="Ammurapi shield",ammo="Savant's Treatise",
        head={ name="Telchine Cap", augments={'Enh. Mag. eff. dur. +9',}},neck="Incanter's Torque",ear1="Andoaa Earring",
        body={ name="Telchine Chas.", augments={'Enh. Mag. eff. dur. +10',}},hands={ name="Telchine Gloves", augments={'Enh. Mag. eff. dur. +9',}},
        back="Fi follet cape +1",waist="Olympus Sash",legs={ name="Telchine Braconi", augments={'Enh. Mag. eff. dur. +10',}},Feet={ name="Telchine Pigaches", augments={'Enh. Mag. eff. dur. +9',}}}
    sets.midcast.Protectra = sets.midcast.Protect

    sets.midcast.Shell = {main="Gada",sub="Ammurapi shield",ammo="Savant's Treatise",
        head={ name="Telchine Cap", augments={'Enh. Mag. eff. dur. +9',}},neck="Incanter's Torque",ear1="Andoaa Earring",
        body={ name="Telchine Chas.", augments={'Enh. Mag. eff. dur. +10',}},hands={ name="Telchine Gloves", augments={'Enh. Mag. eff. dur. +9',}},
        back="Fi follet cape +1",waist="Olympus Sash",legs={ name="Telchine Braconi", augments={'Enh. Mag. eff. dur. +10',}},Feet={ name="Telchine Pigaches", augments={'Enh. Mag. eff. dur. +9',}}}
    sets.midcast.Shellra = sets.midcast.Shell

    sets.midcast.Haste = {main="Gada",sub="Ammurapi shield",ammo="Savant's Treatise",
        head={ name="Telchine Cap", augments={'Enh. Mag. eff. dur. +9',}},neck="Incanter's Torque",ear1="Andoaa Earring",
        body={ name="Telchine Chas.", augments={'Enh. Mag. eff. dur. +10',}},hands={ name="Telchine Gloves", augments={'Enh. Mag. eff. dur. +9',}},
        back="Fi follet cape +1",waist="Olympus Sash",legs={ name="Telchine Braconi", augments={'Enh. Mag. eff. dur. +10',}},Feet={ name="Telchine Pigaches", augments={'Enh. Mag. eff. dur. +9',}}}
    
    sets.midcast.Refresh=  {main="Gada",sub="Ammurapi shield",ammo="Savant's Treatise",
        head="Amalric coif",neck="Incanter's Torque",ear1="Andoaa Earring",
        body={ name="Telchine Chas.", augments={'Enh. Mag. eff. dur. +10',}},hands={ name="Telchine Gloves", augments={'Enh. Mag. eff. dur. +9',}},
        back="Fi follet cape +1",waist="Olympus Sash",legs={ name="Telchine Braconi", augments={'Enh. Mag. eff. dur. +10',}},Feet={ name="Telchine Pigaches", augments={'Enh. Mag. eff. dur. +9',}}}



    -- Custom spell classes
    sets.midcast.MndEnfeebles = {main="Oranyan",sub="Enki strap",ammo="Pemphredo tathlum",
        head="Jhakri coronal +1",neck="Erra pendant",ear1="Psystorm Earring",ear2="Lifestorm Earring",
        body="Jhakri robe +2",hands="Jhakri cuffs +1",ring1="Kishar ring",ring2="Sangoma Ring",
        back="Lugh's cape",waist="Luminary sash",legs="Jhakri robe +1",feet="Medium's sabots"}

    sets.midcast.IntEnfeebles = {main="Oranyan",sub="Enki strap",ammo="Pemphredo tathlum",
        head="Jhakri coronal +1",neck="Erra pendant",ear1="Psystorm Earring",ear2="Lifestorm Earring",
        body="Jhakri robe +2",hands="Jhakri cuffs +1",ring1="Kishar ring",ring2="Sangoma Ring",
        back="Lugh's cape",waist="Luminary sash",legs="Jhakri robe +1",feet="Medium's sabots"}

    sets.midcast.ElementalEnfeeble = sets.midcast.IntEnfeebles

    sets.midcast['Dark Magic'] = {main="Oranyan",sub="Enki strap",ammo="Pemphredo tathlum",
        head="Jhakri coronal +1",neck="Erra pendant",ear1="Psystorm Earring",ear2="Lifestorm Earring",
        body="Jhakri robe +2",hands="Jhakri cuffs +1",ring1="Archon ring",ring2="Kishar Ring",
        back="Lugh's cape",waist="Luminary sash",legs="Jhakri robe +1",feet="Medium's sabots"}

    sets.midcast.Kaustra =  {main="Akademos",sub="Alber strap",ammo="Pemphredo tathlum",
        head="Pixie hairpin +1",neck="Baetyl pendant",ear1="Barkarole earring",ear2="Friomisi earring",
        body={ name="Amalric Doublet +1", augments={'MP+80','"Mag.Atk.Bns."+25','"Fast Cast"+4',}},hands={ name="Amalric Gages +1", augments={'INT+12','Mag. Acc.+20','"Mag.Atk.Bns."+20',}},ring1="Acumen ring",ring2="Archon ring",
        back="Lugh's cape",waist="Refoccilation stone",legs={ name="Amalric Slops +1", augments={'MP+80','"Mag.Atk.Bns."+25','Enmity-6',}},
        feet={ name="Amalric Nails +1", augments={'Mag. Acc.+20','"Mag.Atk.Bns."+20','"Conserve MP"+7',}}}


    sets.midcast.Drain =  {main="Rubicundity",sub="Ammurapi shield",ammo="Pemphredo tathlum",
        head="Pixie hairpin +1",neck="Erra pendant",ear1="Hirudinea earring",ear2="Dignitary's earring",
        body="Jhakri robe +2",hands="Jhakri cuffs +1",ring1="Evanescence ring",ring2="Excelsis ring",
        back="Lugh's cape",waist="Fucho-no-obi",legs="Jhakri Slops +1",
        feet="Merlinic Crackows"}

    sets.midcast.Aspir = sets.midcast.Drain

    sets.midcast.Stun = {main="Oranyan",sub="Alber strap",ammo="Pemphredo tathlum",
        head="Amalric coif",neck="Erra pendant",ear1="Psystorm Earring",ear2="Lifestorm Earring",
        body="Jhakri robe +2",hands="Jhakri cuffs +1",ring1="Kishar Ring",ring2="Sangoma Ring",
        back="Lugh's cape",waist="Luminary sash",legs="Jhakri slops +1",
        feet="Jhakri pigaches +1"}

    sets.midcast.Stun.Resistant = set_combine(sets.midcast.Stun, {main="Oranyan"})

    sets.midcast.Helix = {main="Akademos",sub="Alber strap",ammo="Pemphredo tathlum",
        head={ name="Merlinic Hood", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','"Occult Acumen"+11','INT+3','"Mag.Atk.Bns."+15',}},neck="Baetyl pendant",ear1="Barkarole earring",ear2="Friomisi earring",
        body={ name="Amalric Doublet +1", augments={'MP+80','"Mag.Atk.Bns."+25','"Fast Cast"+4',}},hands={ name="Amalric Gages +1", augments={'INT+12','Mag. Acc.+20','"Mag.Atk.Bns."+20',}},ring1="Acumen ring",ring2="Strendu ring",
        back="Lugh's cape",waist="Refoccilation stone",legs={ name="Amalric Slops +1", augments={'MP+80','"Mag.Atk.Bns."+25','Enmity-6',}},
        feet={ name="Amalric Nails +1", augments={'Mag. Acc.+20','"Mag.Atk.Bns."+20','"Conserve MP"+7',}}}

    sets.midcast.Helix.MagicBurst = {main="Akademos",sub="Elan strap +1",ammo="Pemphredo tathlum",
        head={ name="Merlinic Hood", augments={'"Mag.Atk.Bns."+28','Magic burst dmg.+11%','INT+9','Mag. Acc.+5',}},neck="Mizukage-no-kubikazari",ear1="Barkarole earring",ear2="Friomisi earring",
        body={ name="Amalric Doublet +1", augments={'MP+80','"Mag.Atk.Bns."+25','"Fast Cast"+4',}},hands={ name="Amalric Gages +1", augments={'INT+12','Mag. Acc.+20','"Mag.Atk.Bns."+20',}},ring1="Acumen ring",ring2="Mujin band",
        back="Lugh's cape",waist="Refoccilation stone",legs={ name="Amalric Slops +1", augments={'MP+80','"Mag.Atk.Bns."+25','Enmity-6',}},
        feet={ name="Merlinic Crackows", augments={'Mag. Acc.+16 "Mag.Atk.Bns."+16','Magic burst dmg.+10%','MND+10','Mag. Acc.+8','"Mag.Atk.Bns."+10',}}}

    sets.midcast.DarkHelix = {main="Akademos",sub="Alber strap",ammo="Pemphredo tathlum",
        head="Pixie hairpin +1",neck="Baetyl pendant",ear1="Barkarole earring",ear2="Friomisi earring",
        body={ name="Amalric Doublet +1", augments={'MP+80','"Mag.Atk.Bns."+25','"Fast Cast"+4',}},hands={ name="Amalric Gages +1", augments={'INT+12','Mag. Acc.+20','"Mag.Atk.Bns."+20',}},ring1="Acumen ring",ring2="Archon ring",
        back="Lugh's cape",waist="Refoccilation stone",legs={ name="Amalric Slops +1", augments={'MP+80','"Mag.Atk.Bns."+25','Enmity-6',}},
        feet={ name="Amalric Nails +1", augments={'Mag. Acc.+20','"Mag.Atk.Bns."+20','"Conserve MP"+7',}}}


    -- Elemental Magic sets are default for handling low-tier nukes.
    sets.midcast['Elemental Magic'] = {main="Akademos",sub="Alber strap",ammo="Pemphredo tathlum",
        head={ name="Merlinic Hood", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','"Occult Acumen"+11','INT+3','"Mag.Atk.Bns."+15',}},neck="Baetyl pendant",ear1="Barkarole earring",ear2="Friomisi earring",
        body={ name="Amalric Doublet +1", augments={'MP+80','"Mag.Atk.Bns."+25','"Fast Cast"+4',}},hands={ name="Amalric Gages +1", augments={'INT+12','Mag. Acc.+20','"Mag.Atk.Bns."+20',}},ring1="Acumen ring",ring2="Strendu ring",
        back="Lugh's cape",waist="Refoccilation stone",legs={ name="Amalric Slops +1", augments={'MP+80','"Mag.Atk.Bns."+25','Enmity-6',}},
        feet={ name="Amalric Nails +1", augments={'Mag. Acc.+20','"Mag.Atk.Bns."+20','"Conserve MP"+7',}}}

        sets.midcast['Elemental Magic'].MagicBurst = {main="Akademos",sub="Alber strap",ammo="Pemphredo tathlum",
        head={ name="Merlinic Hood", augments={'"Mag.Atk.Bns."+28','Magic burst dmg.+11%','INT+9','Mag. Acc.+5',}},neck="Mizukage-no-kubikazari",ear1="Barkarole earring",ear2="Friomisi earring",
        body={ name="Amalric Doublet +1", augments={'MP+80','"Mag.Atk.Bns."+25','"Fast Cast"+4',}},hands={ name="Amalric Gages +1", augments={'INT+12','Mag. Acc.+20','"Mag.Atk.Bns."+20',}},ring1="Acumen ring",ring2="Mujin band",
        back="Lugh's cape",waist="Refoccilation stone",legs={ name="Amalric Slops +1", augments={'MP+80','"Mag.Atk.Bns."+25','Enmity-6',}},
        feet={ name="Merlinic Crackows", augments={'Mag. Acc.+16 "Mag.Atk.Bns."+16','Magic burst dmg.+10%','MND+10','Mag. Acc.+8','"Mag.Atk.Bns."+10',}}}

    sets.midcast['Elemental Magic'].Resistant = {main="Akademos",sub="Alber strap",ammo="Pemphredo tathlum",
        head={ name="Merlinic Hood", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','"Occult Acumen"+11','INT+3','"Mag.Atk.Bns."+15',}},neck="Baetyl pendant",ear1="Barkarole earring",ear2="Friomisi earring",
        body={ name="Amalric Doublet +1", augments={'MP+80','"Mag.Atk.Bns."+25','"Fast Cast"+4',}},hands={ name="Amalric Gages +1", augments={'INT+12','Mag. Acc.+20','"Mag.Atk.Bns."+20',}},ring1="Acumen ring",ring2="Strendu ring",
        back="Lugh's cape",waist="Refoccilation stone",legs={ name="Amalric Slops +1", augments={'MP+80','"Mag.Atk.Bns."+25','Enmity-6',}},
        feet={ name="Amalric Nails +1", augments={'Mag. Acc.+20','"Mag.Atk.Bns."+20','"Conserve MP"+7',}}}

    -- Custom refinements for certain nuke tiers
    sets.midcast['Elemental Magic'].HighTierNuke = {main="Akademos",sub="Alber strap",ammo="Pemphredo tathlum",
        head={ name="Merlinic Hood", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','"Occult Acumen"+11','INT+3','"Mag.Atk.Bns."+15',}},neck="Baetyl pendant",ear1="Barkarole earring",ear2="Friomisi earring",
        body={ name="Amalric Doublet +1", augments={'MP+80','"Mag.Atk.Bns."+25','"Fast Cast"+4',}},hands={ name="Amalric Gages +1", augments={'INT+12','Mag. Acc.+20','"Mag.Atk.Bns."+20',}},ring1="Acumen ring",ring2="Strendu ring",
        back="Lugh's cape",waist="Refoccilation stone",legs={ name="Amalric Slops +1", augments={'MP+80','"Mag.Atk.Bns."+25','Enmity-6',}},
        feet={ name="Amalric Nails +1", augments={'Mag. Acc.+20','"Mag.Atk.Bns."+20','"Conserve MP"+7',}}}

        sets.midcast['Elemental Magic'].HighTierNuke.MagicBurst = {main="Akademos",sub="Alber strap",ammo="Pemphredo tathlum",
        head={ name="Merlinic Hood", augments={'"Mag.Atk.Bns."+28','Magic burst dmg.+11%','INT+9','Mag. Acc.+5',}},neck="Mizukage-no-kubikazari",ear1="Barkarole earring",ear2="Friomisi earring",
        body={ name="Amalric Doublet +1", augments={'MP+80','"Mag.Atk.Bns."+25','"Fast Cast"+4',}},hands={ name="Amalric Gages +1", augments={'INT+12','Mag. Acc.+20','"Mag.Atk.Bns."+20',}},ring1="Acumen ring",ring2="Mujin band",
        back="Lugh's cape",waist="Refoccilation stone",legs={ name="Amalric Slops +1", augments={'MP+80','"Mag.Atk.Bns."+25','Enmity-6',}},
        feet={ name="Merlinic Crackows", augments={'Mag. Acc.+16 "Mag.Atk.Bns."+16','Magic burst dmg.+10%','MND+10','Mag. Acc.+8','"Mag.Atk.Bns."+10',}}}

    sets.midcast['Elemental Magic'].HighTierNuke.Resistant =  {main="Akademos",sub="Alber strap",ammo="Pemphredo tathlum",
        head={ name="Merlinic Hood", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','"Occult Acumen"+11','INT+3','"Mag.Atk.Bns."+15',}},neck="Baetyl pendant",ear1="Barkarole earring",ear2="Friomisi earring",
        body={ name="Amalric Doublet +1", augments={'MP+80','"Mag.Atk.Bns."+25','"Fast Cast"+4',}},hands={ name="Amalric Gages +1", augments={'INT+12','Mag. Acc.+20','"Mag.Atk.Bns."+20',}},ring1="Acumen ring",ring2="Strendu ring",
        back="Lugh's cape",waist="Refoccilation stone",legs={ name="Amalric Slops +1", augments={'MP+80','"Mag.Atk.Bns."+25','Enmity-6',}},
        feet={ name="Amalric Nails +1", augments={'Mag. Acc.+20','"Mag.Atk.Bns."+20','"Conserve MP"+7',}}}
    
    sets.midcast.Impact = {main="Akademos",sub="Alber strap",ammo="Pemphredo tathlum",
        head={ name="Merlinic Hood", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','"Occult Acumen"+11','INT+3','"Mag.Atk.Bns."+15',}},neck="Baetyl pendant",ear1="Barkarole earring",ear2="Friomisi earring",
        body={ name="Amalric Doublet +1", augments={'MP+80','"Mag.Atk.Bns."+25','"Fast Cast"+4',}},hands={ name="Amalric Gages +1", augments={'INT+12','Mag. Acc.+20','"Mag.Atk.Bns."+20',}},ring1="Acumen ring",ring2="Strendu ring",
        back="Lugh's cape",waist="Refoccilation stone",legs={ name="Amalric Slops +1", augments={'MP+80','"Mag.Atk.Bns."+25','Enmity-6',}},
        feet={ name="Amalric Nails +1", augments={'Mag. Acc.+20','"Mag.Atk.Bns."+20','"Conserve MP"+7',}}}


    -- Sets to return to when not performing an action.

    -- Resting sets
    sets.resting = {main="Bolelabunga",sub="Genmei shield",ammo="Homiliary",
        head="Befouled crown",neck="Sanctity necklace",ear1="Moonshade earring",ear2="Infused earring",
        body="Jhakri robe +2",hands={ name="Merlinic Dastanas", augments={'Pet: STR+5','Attack+8','"Refresh"+2','Mag. Acc.+9 "Mag.Atk.Bns."+9',}},ring1="Defending ring",ring2="Patricius ring",
        back="Moonbeam cape",waist="Fucho-no-obi",legs="Assiduity pants +1",feet={ name="Merlinic Crackows", augments={'Pet: "Store TP"+5','Pet: Haste+3','"Refresh"+1','Accuracy+6 Attack+6','Mag. Acc.+15 "Mag.Atk.Bns."+15',}}}


    -- Idle sets (default idle set not needed since the other three are defined, but leaving for testing purposes)

    sets.idle.Town = {main="Akademos",sub="Oneiros grip",ammo="Homiliary",
        head="Befouled crown",neck="Loricate torque +1",ear1="Moonshade earring",ear2="Infused earring",
        body="Jhakri robe +2",hands={ name="Merlinic Dastanas", augments={'Pet: STR+5','Attack+8','"Refresh"+2','Mag. Acc.+9 "Mag.Atk.Bns."+9',}},ring1="Defending ring",ring2="Patricius ring",
        back="Moonbeam cape",waist="Fucho-no-obi",legs="Assiduity pants +1",feet={ name="Merlinic Crackows", augments={'Pet: "Store TP"+5','Pet: Haste+3','"Refresh"+1','Accuracy+6 Attack+6','Mag. Acc.+15 "Mag.Atk.Bns."+15',}}}

    sets.idle.Field = {main="Akademos",sub="Oneiros grip",ammo="Homiliary",
        head="Befouled crown",neck="Loricate torque +1",ear1="Moonshade earring",ear2="Infused earring",
        body="Jhakri robe +2",hands={ name="Merlinic Dastanas", augments={'Pet: STR+5','Attack+8','"Refresh"+2','Mag. Acc.+9 "Mag.Atk.Bns."+9',}},ring1="Defending ring",ring2="Patricius ring",
        back="Moonbeam cape",waist="Fucho-no-obi",legs="Assiduity pants +1",feet={ name="Merlinic Crackows", augments={'Pet: "Store TP"+5','Pet: Haste+3','"Refresh"+1','Accuracy+6 Attack+6','Mag. Acc.+15 "Mag.Atk.Bns."+15',}}}

    sets.idle.Field.PDT = {main="Bolelabunga",sub="Genmei shield","Homiliary",
        head="Befouled crown",neck="Loricate torque +1",ear1="Moonshade earring",ear2="Ethereal earring",
        body="Mallquis saio +1",hands={ name="Merlinic Dastanas", augments={'Pet: STR+5','Attack+8','"Refresh"+2','Mag. Acc.+9 "Mag.Atk.Bns."+9',}},ring1="Defending ring",ring2="Patricius ring",
        back="Moonbeam cape",waist="Fucho-no-obi",legs="Assiduity pants +1",feet="Mallquis clogs +1"}

    sets.idle.Field.Stun = {main="Apamajas II",sub="Mephitis Grip",ammo="Sapience orb",
        head="Nahtirah Hat",neck="Aesir Torque",ear1="Psystorm Earring",ear2="Lifestorm Earring",
        body="Vanir Cotehardie",hands="Gendewitha Gages",ring1="Prolix Ring",ring2="Sangoma Ring",
        back="Swith Cape +1",waist="Goading Belt",legs="Bokwus Slops",feet="Academic's Loafers"}

    sets.idle.Weak = {main="Akademos",sub="Oneiros grip",ammo="Homiliary",
        head="Befouled crown",neck="Loricate torque +1",ear1="Moonshade earring",ear2="Infused earring",
        body="Jhakri robe +2",hands={ name="Merlinic Dastanas", augments={'Pet: STR+5','Attack+8','"Refresh"+2','Mag. Acc.+9 "Mag.Atk.Bns."+9',}},ring1="Defending ring",ring2="Patricius ring",
        back="Moonbeam cape",waist="Fucho-no-obi",legs="Assiduity pants +1",feet={ name="Merlinic Crackows", augments={'Pet: "Store TP"+5','Pet: Haste+3','"Refresh"+1','Accuracy+6 Attack+6','Mag. Acc.+15 "Mag.Atk.Bns."+15',}}}

    -- Defense sets

    sets.defense.PDT = {main="Bolelabunga",sub="Genmei shield","Homiliary",
        head="Befouled crown",neck="Loricate torque +1",ear1="Moonshade earring",ear2="Ethereal earring",
        body="Jhakri robe +2",hands={ name="Merlinic Dastanas", augments={'Pet: STR+5','Attack+8','"Refresh"+2','Mag. Acc.+9 "Mag.Atk.Bns."+9',}},ring1="Defending ring",ring2="Patricius ring",
        back="Moonbeam cape",waist="Fucho-no-obi",legs="Assiduity pants +1",feet="Chironic slippers"}

    sets.defense.MDT = {main="Akademos",sub="Oneiros grip",ammo="Homiliary",
        head="Befouled crown",neck="Loricate torque +1",ear1="Moonshade earring",ear2="Infused earring",
        body="Jhakri robe +2",hands={ name="Merlinic Dastanas", augments={'Pet: STR+5','Attack+8','"Refresh"+2','Mag. Acc.+9 "Mag.Atk.Bns."+9',}},ring1="Defending ring",ring2="Patricius ring",
        back="Moonbeam cape",waist="Fucho-no-obi",legs="Assiduity pants +1",feet="Chironic slippers"}

    sets.Kiting = {feet="Herald's Gaiters"}

    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 = {main="Akademos",sub="Bloodrain strap",ammo="Homiliary",
        head="Merlinic hood",neck="Sanctity necklace",ear1="Cessance earring",ear2="Dignitary's earring",
        body="Jhakri robe +2",hands={ name="Merlinic Dastanas", augments={'Pet: STR+5','Attack+8','"Refresh"+2','Mag. Acc.+9 "Mag.Atk.Bns."+9',}},ring1="Petrov ring",ring2="Rajas ring",
        back="Moonbeam cape",waist="Goading belt",legs="Lengo pants",feet="Chironic slippers"}

    sets.engaged.DT = {main="Akademos",sub="Oneiros grip",ammo="Staunch tathlum",
        head="Befouled crown",neck="Loricate torque +1",ear1="Genmei earring",ear2="Infused earring",
        body="Mallquis saio +1",hands={ name="Merlinic Dastanas", augments={'Pet: STR+5','Attack+8','"Refresh"+2','Mag. Acc.+9 "Mag.Atk.Bns."+9',}},ring1="Defending ring",ring2="Patricius ring",
        back="Moonbeam cape",waist="Fucho-no-obi",legs="Assiduity pants +1",feet="Mallquis clogs +1"}


    -- Buff sets: Gear that needs to be worn to actively enhance a current player buff.
    sets.buff['Ebullience'] = {head="Arbatel Bonnet +1"}
    sets.buff['Rapture'] = {head="Arbatel Bonnet +1"}
    sets.buff['Perpetuance'] = {hands="Arbatel Bracers +1"}
    sets.buff['Immanence'] = {hands="Arbatel Bracers +1"}
    sets.buff['Penury'] = {legs="Savant's Pants +2"}
    sets.buff['Parsimony'] = {legs="Savant's Pants +2"}
    sets.buff['Celerity'] = {feet="Pedagogy Loafers"}
    sets.buff['Alacrity'] = {feet="Pedagogy Loafers"}

    sets.buff['Klimaform'] = {feet="Savant's Loafers +2"}

    sets.buff.FullSublimation = {head="Academic's Mortarboard +1",ear2="Savant's Earring",body="Pedagogy Gown +1"}
    sets.buff.PDTSublimation = {head="Academic's Mortarboard +1",ear2="Savant's Earring"}

    --sets.buff['Sandstorm'] = {feet="Desert Boots"}
end

-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for standard casting events.
-------------------------------------------------------------------------------------------------------------------

-- Run after the general midcast() is done.
function job_post_midcast(spell, action, spellMap, eventArgs)
    if spell.action_type == 'Magic' then
        apply_grimoire_bonuses(spell, action, spellMap, eventArgs)
    end
end

-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for non-casting events.
-------------------------------------------------------------------------------------------------------------------

-- 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 buff == "Sublimation: Activated" then
        handle_equipping_gear(player.status)
    end
end

-- Handle notifications of general user state change.
function job_state_change(stateField, newValue, oldValue)
    if stateField == 'Offense Mode' then
        if newValue == 'Normal' then
            disable('main','sub','range')
        else
            enable('main','sub','range')
        end
    end
end

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

-- Custom spell mapping.
function job_get_spell_map(spell, default_spell_map)
    if spell.action_type == 'Magic' then
        if default_spell_map == 'Cure' or default_spell_map == 'Curaga' then
            if world.weather_element == 'Light' then
                return 'CureWithLightWeather'
            end
        elseif spell.skill == 'Enfeebling Magic' then
            if spell.type == 'WhiteMagic' then
                return 'MndEnfeebles'
            else
                return 'IntEnfeebles'
            end
        elseif spell.skill == 'Elemental Magic' then
            if info.low_nukes:contains(spell.english) then
                return 'LowTierNuke'
            elseif info.mid_nukes:contains(spell.english) then
                return 'MidTierNuke'
            elseif info.high_nukes:contains(spell.english) then
                return 'HighTierNuke'
            end
        end
    end
end

function customize_idle_set(idleSet)
    if state.Buff['Sublimation: Activated'] then
        if state.IdleMode.value == 'Normal' then
            idleSet = set_combine(idleSet, sets.buff.FullSublimation)
        elseif state.IdleMode.value == 'PDT' then
            idleSet = set_combine(idleSet, sets.buff.PDTSublimation)
        end
    end

    if player.mpp < 51 then
        idleSet = set_combine(idleSet, sets.latent_refresh)
    end

    return idleSet
end

-- Called by the 'update' self-command.
function job_update(cmdParams, eventArgs)
    if cmdParams[1] == 'user' and not (buffactive['light arts']      or buffactive['dark arts'] or
                       buffactive['addendum: white'] or buffactive['addendum: black']) then
        if state.IdleMode.value == 'Stun' then
            send_command('@input /ja "Dark Arts" <me>')
        else
            send_command('@input /ja "Light Arts" <me>')
        end
    end

    update_active_strategems()
    update_sublimation()
end

-- Function to display the current relevant user state when doing an update.
-- Return true if display was handled, and you don't want the default info shown.
function display_current_job_state(eventArgs)
    display_current_caster_state()
    eventArgs.handled = true
end

-------------------------------------------------------------------------------------------------------------------
-- User code that supplements self-commands.
-------------------------------------------------------------------------------------------------------------------

-- Called for direct player commands.
function job_self_command(cmdParams, eventArgs)
    if cmdParams[1]:lower() == 'scholar' then
        handle_strategems(cmdParams)
        eventArgs.handled = true
    end
end

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

-- Reset the state vars tracking strategems.
function update_active_strategems()
    state.Buff['Ebullience'] = buffactive['Ebullience'] or false
    state.Buff['Rapture'] = buffactive['Rapture'] or false
    state.Buff['Perpetuance'] = buffactive['Perpetuance'] or false
    state.Buff['Immanence'] = buffactive['Immanence'] or false
    state.Buff['Penury'] = buffactive['Penury'] or false
    state.Buff['Parsimony'] = buffactive['Parsimony'] or false
    state.Buff['Celerity'] = buffactive['Celerity'] or false
    state.Buff['Alacrity'] = buffactive['Alacrity'] or false

    state.Buff['Klimaform'] = buffactive['Klimaform'] or false
end

function update_sublimation()
    state.Buff['Sublimation: Activated'] = buffactive['Sublimation: Activated'] or false
end

-- Equip sets appropriate to the active buffs, relative to the spell being cast.
function apply_grimoire_bonuses(spell, action, spellMap)
    if state.Buff.Perpetuance and spell.type =='WhiteMagic' and spell.skill == 'Enhancing Magic' then
        equip(sets.buff['Perpetuance'])
    end
    if state.Buff.Rapture and (spellMap == 'Cure' or spellMap == 'Curaga') then
        equip(sets.buff['Rapture'])
    end
    if spell.skill == 'Elemental Magic' and spellMap ~= 'ElementalEnfeeble' then
        if state.Buff.Ebullience and spell.english ~= 'Impact' then
            equip(sets.buff['Ebullience'])
        end
        if state.Buff.Immanence then
            equip(sets.buff['Immanence'])
        end
        if state.Buff.Klimaform and spell.element == world.weather_element then
            equip(sets.buff['Klimaform'])
        end
    end

    if state.Buff.Penury then equip(sets.buff['Penury']) end
    if state.Buff.Parsimony then equip(sets.buff['Parsimony']) end
    if state.Buff.Celerity then equip(sets.buff['Celerity']) end
    if state.Buff.Alacrity then equip(sets.buff['Alacrity']) end
end


-- General handling of strategems in an Arts-agnostic way.
-- Format: gs c scholar <strategem>
function handle_strategems(cmdParams)
    -- cmdParams[1] == 'scholar'
    -- cmdParams[2] == strategem to use

    if not cmdParams[2] then
        add_to_chat(123,'Error: No strategem command given.')
        return
    end
    local strategem = cmdParams[2]:lower()

    if strategem == 'light' then
        if buffactive['light arts'] then
            send_command('input /ja "Addendum: White" <me>')
        elseif buffactive['addendum: white'] then
            add_to_chat(122,'Error: Addendum: White is already active.')
        else
            send_command('input /ja "Light Arts" <me>')
        end
    elseif strategem == 'dark' then
        if buffactive['dark arts'] then
            send_command('input /ja "Addendum: Black" <me>')
        elseif buffactive['addendum: black'] then
            add_to_chat(122,'Error: Addendum: Black is already active.')
        else
            send_command('input /ja "Dark Arts" <me>')
        end
    elseif buffactive['light arts'] or buffactive['addendum: white'] then
        if strategem == 'cost' then
            send_command('input /ja Penury <me>')
        elseif strategem == 'speed' then
            send_command('input /ja Celerity <me>')
        elseif strategem == 'aoe' then
            send_command('input /ja Accession <me>')
        elseif strategem == 'power' then
            send_command('input /ja Rapture <me>')
        elseif strategem == 'duration' then
            send_command('input /ja Perpetuance <me>')
        elseif strategem == 'accuracy' then
            send_command('input /ja Altruism <me>')
        elseif strategem == 'enmity' then
            send_command('input /ja Tranquility <me>')
        elseif strategem == 'skillchain' then
            add_to_chat(122,'Error: Light Arts does not have a skillchain strategem.')
        elseif strategem == 'addendum' then
            send_command('input /ja "Addendum: White" <me>')
        else
            add_to_chat(123,'Error: Unknown strategem ['..strategem..']')
        end
    elseif buffactive['dark arts']  or buffactive['addendum: black'] then
        if strategem == 'cost' then
            send_command('input /ja Parsimony <me>')
        elseif strategem == 'speed' then
            send_command('input /ja Alacrity <me>')
        elseif strategem == 'aoe' then
            send_command('input /ja Manifestation <me>')
        elseif strategem == 'power' then
            send_command('input /ja Ebullience <me>')
        elseif strategem == 'duration' then
            add_to_chat(122,'Error: Dark Arts does not have a duration strategem.')
        elseif strategem == 'accuracy' then
            send_command('input /ja Focalization <me>')
        elseif strategem == 'enmity' then
            send_command('input /ja Equanimity <me>')
        elseif strategem == 'skillchain' then
            send_command('input /ja Immanence <me>')
        elseif strategem == 'addendum' then
            send_command('input /ja "Addendum: Black" <me>')
        else
            add_to_chat(123,'Error: Unknown strategem ['..strategem..']')
        end
    else
        add_to_chat(123,'No arts has been activated yet.')
    end
end


-- Gets the current number of available strategems based on the recast remaining
-- and the level of the sch.
function get_current_strategem_count()
    -- returns recast in seconds.
    local allRecasts = windower.ffxi.get_ability_recasts()
    local stratsRecast = allRecasts[231]

    local maxStrategems = (player.main_job_level + 10) / 20

    local fullRechargeTime = 4*60

    local currentCharges = math.floor(maxStrategems - maxStrategems * stratsRecast / fullRechargeTime)

    return currentCharges
end


-- Select default macro book on initial load or subjob change.
function select_default_macro_book()
    set_macro_page(1, 6)
end