Gearswap Support Thread

Eorzea Time
 
 
 
Langues: JP EN FR DE
users online
Forum » Windower » Support » Gearswap Support Thread
Gearswap Support Thread
First Page 2 3 ... 111 112 113 ... 181 182 183
Offline
By Calinari 2016-10-18 01:24:51
Link | Citer | R
 
Can someone show me what to add for a TH tag mode like on the THF gs?

So that first hit is chaac belt etc for other jobs
 Asura.Hitome
Offline
Serveur: Asura
Game: FFXI
Posts: 59
By Asura.Hitome 2016-10-18 19:13:06
Link | Citer | R
 
Ragnarok.Flippant said: »
The only issue I know with rings is if you're already wearing one of the rings, Gearswap will cancel equipping both rings. I could've sworn I reported this to Byrth years ago, but I can't find it so I must've not submitted after all... I looked just now and the issue appears to be when it gets rid of "redundancies," canceling gear if it determines that same piece is currently equipped; this is because it's selecting the same exact item (by ID) for both rings, which is the real problem. I'll take another look tomorrow and see if I can think of something to fix that.

Note that the order that you put elements in a table has no effect on anything, specifically because of the way tables work. But you could try assigning different priorities. i.e. ring1={name="Ramuh's ring",priority=16}; items with higher priority are equipped first. I assume this won't fix it.

On this topic: has there been any method developed to swap ears or rings if they are already equipped? Is GS fast enough to do that?

I've been pretty good so far about always making sure a specific ring or earring is in my right or left slot. I've been consistent throughout all my files. But finally, I ran into an issue in my BLU lua.

For most jobs I use the following convention:

ear1="Suppanomimi"
ear2="Brutal Earring"
ear2="Cessance Earring"

The problem arises when I need to TP in Cessance Earring and also WS with it. So either it needs to go into ear1 while Brutal stays in ear2 or my engaged.ACC needs to change in some other way.

Any ideas? The priority system in the quote didn't seem to work for me.
 Ragnarok.Flippant
Offline
Serveur: Ragnarok
Game: FFXI
user: Enceladus
Posts: 658
By Ragnarok.Flippant 2016-10-18 21:00:46
Link | Citer | R
 
Can't do it. At the point right before the final determined equip set is about to be pushed, GS goes over the items; if any of them target a specific inventory slot that is currently equipped (or will be at the time of the event), it will just cancel equipping that slot.

For solving the issue I mentioned, at the point it is selecting the item's inventory ID, it needs to check if its equipped, and if it is, look for another item by that name in a different inventory slot; if found, select it, if not then cancel. That said, the redundancy checking can just be moved to this stage instead. (I'm mostly writing this as a note to either myself or someone interested in writing the solution.)

For allowing a user to equip earring immediately into another slot, there would first be the question of whether that's a "legal" move. I'm going to guess not, or Byrth probably would've done that. Likewise, if using priority was a solution, I would assume that he wouldn't have it canceling it out.

It's not ideal, but you could set either bogus earrings or no earrings in precast and equip your WS sets in midcast. Still going to mess up when changing back to TP, though, unless you set something bogus in aftercast, then use send_command to issue a gs command to call your status change.
[+]
 Asura.Hitome
Offline
Serveur: Asura
Game: FFXI
Posts: 59
By Asura.Hitome 2016-10-18 21:59:14
Link | Citer | R
 
Thanks for the answer, Flippant! Adding a line for midcast seems like a good solution. Maybe even just a line to switch ears or a toggle to do so.
Offline
Posts: 256
By Brynach 2016-10-24 18:42:44
Link | Citer | R
 
I have a small issue with a rule concerning swapping in gear for time of day and when tp <2950:
Code
function job_post_precast(spell, action, spellMap, eventArgs)
	if spell.type == 'WeaponSkill' then
		if world.time >= (17*60) or world.time <= (7*60) then
			equip({ear1="Lugra Earring +1",ear2="Lugra Earring"})
		else
		if moonshade_WS:contains(spell.english) and player.tp<2950 then	
			equip({ear2="Moonshade Earring"})
			end
		end
	end
end


It works to pull in moonshade if tp is under 2950, and it works from dusk to dawn pulling in Lugra +1 and Lugra. The issue I am having is when it is nighttime and tp is under 2950. I think I could use some assistance working this out if anyone doesnt mind.
 Odin.Lygre
Offline
Serveur: Odin
Game: FFXI
user: Dylaudid
Posts: 89
By Odin.Lygre 2016-10-24 19:38:49
Link | Citer | R
 
Code
function job_post_precast(spell, action, spellMap, eventArgs)
	if spell.type == 'WeaponSkill' then
		if world.time >= (17*60) or world.time <= (7*60) then
			equip({ear1="Lugra Earring +1",ear2="Lugra Earring"})
		end
		if moonshade_WS:contains(spell.english) and player.tp<2950 then	
			equip({ear2="Moonshade Earring"})
		end
	end
end
Offline
Posts: 148
By RolandJ 2016-10-24 21:08:23
Link | Citer | R
 
Code
function job_post_precast(spell, action, spellMap, eventArgs)
    if spell.type == 'WeaponSkill' then
        if world.time >= (17*60) or world.time <= (7*60) then
            equip({ear1="Lugra Earring +1",ear2="Lugra Earring"})
        else --*****PAY ATTENTION TO THIS!******-- o.o
        if moonshade_WS:contains(spell.english) and player.tp<2950 then  
            equip({ear2="Moonshade Earring"})
            end
        end
    end
end


What that else is doing is saying "if the world time isn't between 17:00-7:00 then do the next thing listed after the else". In other words it is explicitly saying that when the world time is between 17:00-7:00 do not do the next thing. By replacing that else with end, as Lygre suggested, you separate the time-based condition from your TP-based condition - which in fact is how you desire it to function rather than the way you had it setup to function. Stuff like that gets me sometimes too, lol ^^;
Offline
Posts: 256
By Brynach 2016-10-24 21:28:58
Link | Citer | R
 
Thanks. Works perfectly.
 Odin.Psycooo
Offline
Serveur: Odin
Game: FFXI
user: Psycooo
Posts: 42
By Odin.Psycooo 2016-10-24 21:57:40
Link | Citer | R
 
Ok, I am back with more questions....
I managed to add/define sets based of the amount of magical haste I have. So now if I have no haste it equips one set of gear, if I get haste 1 or haste 2 it equips based on value of haste all the way up to capped haste.
What I would like additionally is for it to auto equip the single wield gearset in the event I don't have a dual wield subjob, furthermore I would like a way to add in additional sets if I am using /dnc instead of my normal /nin, because the native DW traits are different I would need to add a whole bunch of rules and sets, the problem is I have NO FRIGGIN' IDEA how to do any of that. I literally stole all my haste defined rules from a thf lua and spent like 3 hours til I got it to work.

Edit: Ideally I would like to do this same thing for my terribly designed cor lua, that way I don't have to cycle through 14 sets
Code
-------------------------------------------------------------------------------------------------------------------
-- Setup functions for this job.  Generally should not be modified.
-------------------------------------------------------------------------------------------------------------------

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

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

-- Setup vars that are user-independent.  state.Buff vars initialized here will automatically be tracked.
function job_setup()
	determine_haste_group()
	
    state.Buff.Saboteur = buffactive.saboteur or false
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('Normal', 'Mid', 'Acc', 'SingleWield')
    state.HybridMode:options('Normal', 'PhysicalDef', 'MagicalDef')
    state.CastingMode:options('Normal', 'Resistant')
    state.IdleMode:options('Normal', 'PDT', 'MDT')

    select_default_macro_book()
	gear.CureStaff = {name=""}
	gear.CureFeet = {name=""}
	
	state.MagicBurst = M(false, 'Magic Burst')
	state.CureHate = M(false, 'Cure Hate')

 
	send_command('bind !` gs c toggle MagicBurst')
	send_command('bind ^` gs c toggle CureHate')


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['Chainspell'] = {body="Vitivation Tabard +1"}
	

    -- Waltz set (chr and vit)
    sets.precast.Waltz = {}

    -- Don't need any special gear for Healing Waltz.
    sets.precast.Waltz['Healing Waltz'] = {}

    -- Fast cast sets for spells

    -- 80% Fast Cast (including trait) for all spells, plus 5% quick cast
    -- No other FC sets necessary.
    sets.precast.FC = {}

    sets.precast.FC.Impact = set_combine(sets.precast.FC, {head=empty,body="Twilight Cloak"})

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

	sets.precast.WS['Circle Blade'] = set_combine(sets.precast.WS, {})

	sets.precast.WS['Sanguine Blade'] = set_combine(sets.precast.WS, {})

	sets.precast.WS['Requiescat'] = {}

	sets.precast.WS['Aeolian Edge'] = set_combine(sets.precast.WS, {})

	sets.precast.WS['Savage Blade'] = {}

	sets.precast.WS['Chant du Cygne'] = {}

	sets.precast.WS['True Strike'] = {}

	sets.precast.WS['Exenterator'] = {}

	sets.precast.WS['Evisceration'] = {}

	sets.precast.WS['Death Blossom'] = {}
  
    -- Midcast Sets
    sets.midcast.Cure = {}
  
    sets.midcast.Curaga = sets.midcast.Cure
 
    sets.midcast.CureWeather = {}
 
    sets.midcast.CureSelf = {}
  
    sets.midcast.CureMelee = {}
  
    sets.midcast['Enhancing Magic'] = {} 
  
	sets.midcast['Enhancing Magic'].Temper = {}
	
	sets.midcast['Enhancing Magic'].RegenSelf = {}
  
	sets.midcast['Enhancing Magic'].RefreshSelf = {}
  
	sets.midcast['Enhancing Magic'].HasteSelf = {}
	
    sets.midcast['Enhancing Magic'].EnSpells = set_combine(sets.midcast['Enhancing Magic'],{})
  
    sets.midcast['Enhancing Magic'].GainSpells = set_combine(sets.midcast['Enhancing Magic'],{})
	
	sets.midcast['Enhancing Magic'].BarSpells = set_combine(sets.midcast['Enhancing Magic'],{})
     
    sets.buff.ComposureOther = {head="Lethargy Chappel +1",body="Lethargy Sayon +1",
		legs="Lethargy Fuseau +1",feet="Lethargy Houseaux +1"}
  
    sets.midcast.Protect = {}
    
	sets.midcast.Shell = sets.midcast.Protect
  
    sets.midcast['Enhancing Magic'].Phalanx = {}
  
    sets.midcast.Cursna = {}
  
    sets.midcast.Stoneskin = {}
  
	sets.midcast['Enfeebling Magic'] = {}
	
	sets.midcast.MndEnfeebles = {}

    sets.midcast.IntEnfeebles = {}

	
	sets.midcast.Blind = {}
	
    sets.midcast.ElementalEnfeeble = sets.midcast.IntEnfeebles
	
	sets.midcast.Distract = {}

	sets.midcast.Frazzle = {}
  
  	sets.midcast['Distract II'] = sets.midcast.Distract
	sets.midcast['Distract III'] = sets.midcast.Distract

	sets.midcast['Frazzle II'] = {}
	sets.midcast['Frazzle III'] = sets.midcast.Frazzle

  
    sets.midcast['Dia III'] = set_combine(sets.midcast['Enfeebling Magic'], {head="Vitivation Chapeau +1"})
	sets.midcast['Slow II'] = set_combine(sets.midcast['Enfeebling Magic'], {head="Vitivation Chapeau +1"})
	
	sets.Lunge = {}

	sets.Convert = {main="Murgleis"}
	
	sets.midcast['Elemental Magic'] ={}
	  
	
    sets.midcast['Elemental Magic']['Low'] = {}
	  
    sets.midcast.Impact = set_combine(sets.midcast['Elemental Magic'], {head=empty,body="Twilight Cloak"})
  
    sets.midcast['Stun'] = {}
  
    sets.midcast.Drain = {}
		  
    sets.midcast.Aspir = sets.midcast.Drain
			
    -- Sets to return to when not performing an action.
  
    -- Resting sets
    sets.resting = {}
  
    -- Idle sets
    sets.idle = {}
  
    sets.idle.Town = {}
  
    sets.idle.Weak = {}
  
    -- Defense sets
    sets.defense.PDT = {}
  
    sets.defense.MDT = {}
  
    sets.Kiting = {}
  
    sets.latent_refresh = {}
  
    -- 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 = {}
	
	sets.engaged.Mid = {}

	sets.engaged.Acc = {}	
		
	sets.engaged.SingleWield = {}
	
	sets.engaged.Evasion = sets.engaged
	sets.engaged.Mid.Evasion = sets.engaged.Mid
	sets.engaged.Acc.Evasion = sets.engaged.Acc
	
	sets.engaged.PDT = sets.defense.PDT
	sets.engaged.Mid.PDT = sets.defense.MDT
	sets.engaged.Acc.PDT = sets.defense.PDT

		
	-- Haste 43%
	sets.engaged.Haste_43 = set_combine(sets.engaged, {})
	sets.engaged.Mid.Haste_43 = sets.engaged.Mid
	sets.engaged.Acc.Haste_43 = sets.engaged.Acc
	sets.engaged.Evasion.Haste_43 = sets.engaged.Haste_43
	sets.engaged.PDT.Haste_43 = sets.defense.PDT

	-- 40
	sets.engaged.Haste_40 = set_combine(sets.engaged.Haste_43, {})
	sets.engaged.Mid.Haste_40 = sets.engaged.Mid
	sets.engaged.Acc.Haste_40 = sets.engaged.Acc
	sets.engaged.Evasion.Haste_40 = sets.engaged.Haste_40
	sets.engaged.PDT.Haste_40 = sets.defense.PDT

	-- 30
	sets.engaged.Haste_30 = sets.engaged
	sets.engaged.Mid.Haste_30 = sets.engaged.Mid
	sets.engaged.Acc.Haste_30 = sets.engaged.Acc
	sets.engaged.Evasion.Haste_30 = sets.engaged
	sets.engaged.PDT.Haste_30 = sets.defense.PDT

		-- 25
	sets.engaged.Haste_25 = set_combine(sets.engaged.Haste_30, {})
	sets.engaged.Acc.Haste_25 = sets.engaged.Acc
    sets.engaged.Mid.Haste_25 = sets.engaged.Mid
    sets.engaged.Evasion.Haste_25 = sets.engaged
    sets.engaged.PDT.Haste_25 = sets.defense.PDT


   
 	sets.magic_burst = {}
	
	sets.cure_hate = {}
		
	sets.Enmity = {}
		
    -- Sets for special buff conditions on spells.
    sets.buff.Saboteur = {hands="Lethargy Gantherots +1"}
end


			
			
LowNukes                                    = S{'Stone' , 'Aero' , 'Blizzard' , 'Fire' , 'Water' , 'Thunder' , 
												'Stone II' , 'Aero II' , 'Blizzard II' , 'Fire II' , 'Water II' , 'Thunder II',
												'Stonega' , 'Aeroga' , 'Blizzaga' , 'Firaga' , 'Waterga' , 'Thundaga',
												'Stonega II' , 'Aeroga II' , 'Blizzaga II' , 'Firaga II' , 'Waterga II' , 'Thundaga II'}
MndEnfeebles                                = S{'Slow' , 'Silence' , 'Paralyze' , 'Addle' , 'Slow II' , 'Paralyze II' , 'Addle II'}
IntEnfeebles                                = S{'Bind' , 'Break' , 'Gravity' , 'Poison' , 'Sleep' , 'Gravity II' , 'Poison II' , 'Sleep II'}
-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for standard casting events.
-------------------------------------------------------------------------------------------------------------------
 
function job_precast(spell, action, spellMap, eventArgs)
    if spell.skill == 'Healing Magic' and spellMap ~= 'StatusRemoval' then
        gear.CureFeet.name = "Vanya Clogs"
		if player.status == 'Engaged' then
            gear.default.obi_back = { name="Sucellos's Cape", augments={'MND+20','Mag. Acc+20 /Mag. Dmg.+20','Mag. Acc.+10','"Cure" potency +10%',}}
            if spell.target.type == 'SELF' then
                gear.CureFeet.name = "Medium's Sabots"
            else
                gear.CureFeet.name = "Vanya Clogs"
            end
        else
            gear.default.obi_back = { name="Sucellos's Cape", augments={'MND+20','Mag. Acc+20 /Mag. Dmg.+20','Mag. Acc.+10','"Cure" potency +10%',}}
        end
        if spell.target.type == 'SELF' then
            gear.default.obi_waist = "Chuq'aba Belt"
        else
            gear.default.obi_waist = "Salire belt"
        end
        if world.weather_element == 'Light' then
            gear.CureStaff.name = "Chatoyant Staff"
        else
            gear.CureStaff.name = "Serenity"
        end
		else
        gear.default.obi_waist = "Salire belt"
        gear.default.obi_back = { name="Sucellos's Cape", augments={'MND+20','Mag. Acc+20 /Mag. Dmg.+20','Mag. Acc.+10','"Cure" potency +10%',}}
	end
		if spell.name == 'Lunge' or spell.name == 'Swipe' then
			equip(sets.Lunge)
			end
		if spell.name == 'Vallation' then
			equip(sets.Enmity)
		end  
		if spell.name == 'Pflug' then
			equip(sets.Enmity)
		end
		if spell.name == 'Warcry' 
		or spell.name == 'Swordplay' or spell.name == 'Rayke' or spell.name == 'Meditate' or spell.name == 'Provoke' then   
			equip(sets.Enmity)
		end
		--prevents casting Utsusemi if you already have 3 or more shadows
		if spell.name == 'Utsusemi: Ichi' and ShadowType == 'Ni' and (buffactive['Copy Image (3)'] or buffactive['Copy Image (4+)']) then
			cancel_spell()
		end
		if buffactive['terror'] or buffactive['petrification'] or buffactive['stun'] or buffactive['sleep'] then
			if TP_ind == 4 then
				equip(sets.defense.MDT) else
				equip(sets.defense.PDT)
			end
		end
		if spell.name == 'Convert' then
			equip(sets.Convert)
		end
	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>')
	end	
end      


 
-- Run after the default midcast() is done.
-- eventArgs is the same one used in job_midcast, in case information needs to be persisted.
function job_post_midcast(spell, action, spellMap, eventArgs)
    if spell.skill == 'Enfeebling Magic' and state.Buff.Saboteur then
        equip(sets.buff.Saboteur)
    elseif spell.skill == 'Enhancing Magic' and not spell.english == 'Stoneskin' then
        equip(sets.midcast.EnhancingDuration)
        if buffactive.composure and spell.target.type == 'PLAYER' then
            equip(sets.buff.ComposureOther)
        end
    elseif spellMap == 'Cure' then
        if spell.target.type == 'SELF' then
            equip(sets.midcast.CureSelf)
        end
        if state.CureHate.value then
            equip(sets.cure_hate)
        end
        if world.weather_element == 'Light' then
            equip(sets.midcast.CureWeather)
        end
    elseif spell.skill == 'Elemental Magic' then
        if state.MagicBurst.value then
            equip(sets.magic_burst)
        end
        if spell.element == world.day_element or spell.element == world.weather_element then
            equip({waist="Hachirin-no-Obi"})
        end
    elseif spell.skill == "Ninjutsu" then
            equip(sets.midcast.Recast)
            if spell.name == 'Utsusemi: Ichi' and ShadowType == 'Ni' then
                if buffactive['Copy Image'] then
                    windower.ffxi.cancel_buff(66)
                elseif buffactive['Copy Image (2)'] then
                    windower.ffxi.cancel_buff(444)
                elseif buffactive['Copy Image (3)'] then
                    windower.ffxi.cancel_buff(445)
                elseif buffactive['Copy Image (4+)'] then
                    windower.ffxi.cancel_buff(446)
            end
        elseif spell.name == 'Monomi: Ichi' and buffactive.Sneak and spell.target.type == 'SELF' then
            windower.ffxi.cancel_buff(71)
        end
	end
	if spell.name == 'Foil' or spell.name == 'Flash' or spell.name == 'Blank Gaze'
		or spell.name == 'Geist Wall' or spell.name == 'Poison Breath' or spell.name == 'Jettatura'
		or spell.name == 'Cocoon' or spell.name == 'Soporific' or spell.name == 'Sheep Song' 
		or spell.name == 'Refueling' then 
		equip(sets.Enmity)
	end
end
	
	

function job_get_spell_map(spell, default_spell_map)
    if spell.action_type == 'Magic' then
        if spell.skill == 'Enhancing Magic' then
            if spell.english:startswith('En') then
                return 'EnSpells'
			elseif spell.english:startswith('Gain') then
                return 'GainSpells'
			elseif spell.english:startswith('Phalanx') then
                return 'Phalanx'
			elseif spell.english:startswith('Bar') then
                return 'Bar'
			elseif spell.english:startswith('Temper') then
                return 'Temper'
			elseif spell.english:startswith('Haste') then
				if spell.target.type == 'SELF' then
				return 'HasteSelf'
			    end
			elseif spell.english:startswith('Refresh') then
				if spell.target.type == 'SELF' then
				return 'RefreshSelf'
			    end
            end
        elseif default_spell_map == 'Cure' or default_spell_map == 'Curaga' then
            if player.status == 'Engaged' then
                return "CureMelee"
            end
        end
		if spell.action_type == 'Magic' then
			if spell.skill == 'Enfeebling Magic' then
				if spell.type == 'WhiteMagic' then
					return 'MndEnfeebles'
				else
					return 'IntEnfeebles'
				end
			elseif spell.skill == 'Elemental Magic' then
				if LowNukes:contains(spell.name) then
					return 'Low'
				else
					return
				end
				
			end
		end
    end
end

  
-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for non-casting events.
-------------------------------------------------------------------------------------------------------------------
  
-- Handle notifications of general user state change.
function job_state_change(stateField, newValue, oldValue)
    if stateField == 'Offense Mode' then
        if newValue == 'None' then
            enable('main','sub','range')
        else
            disable('main','sub','range')
        end
    end
end
  
  
    -------------------------------------------------------------------------------------------------------------------
    -- General hooks for change 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 we gain or lose any haste buffs, adjust which gear set we target.
        if S{'haste','march', 'madrigal','embrava','haste samba'}:contains(buff:lower()) then
            determine_haste_group()
            handle_equipping_gear(player.status)
        end
        if state.Buff[buff] ~= nil then
            state.Buff[buff] = gain
            if not midaction() then
                handle_equipping_gear(player.status)
            end
        end
    end

-------------------------------------------------------------------------------------------------------------------
-- User code that supplements standard library decisions.
-------------------------------------------------------------------------------------------------------------------
  
-- Modify the default idle set after it was constructed.
function customize_idle_set(idleSet)
    if player.mpp < 51 then
        idleSet = set_combine(idleSet, sets.latent_refresh)
    end
    return idleSet
end
  
function customize_melee_set(meleeSet)
    if player.sub_job == 'DNC' or player.sub_job == 'NIN' then
        meleeSet = set_combine(meleeSet, sets.engaged.DW)
    end
    return meleeSet
end 
  
-- Set eventArgs.handled to true if we don't want the automatic display to be run.
function display_current_job_state(eventArgs)
    display_current_caster_state()
    eventArgs.handled = true
end
  
-------------------------------------------------------------------------------------------------------------------
-- Utility functions specific to this job.
-------------------------------------------------------------------------------------------------------------------
    function determine_haste_group()

        classes.CustomMeleeGroups:clear()
		-- assuming +4 for marches (ghorn has +5)
		-- Haste (white magic) 15%
		-- Haste Samba (Sub) 5%
		-- Haste (Merited DNC) 10% (never account for this)
		-- Victory March +0/+3/+4/+5    9.4/14%/15.6%/17.1% +0
		-- Advancing March +0/+3/+4/+5  6.3/10.9%/12.5%/14%  +0
		-- Embrava 30% with 500 enhancing skill
		-- Mighty Guard - 15%
		-- buffactive[580] = geo haste
		-- buffactive[33] = regular haste
		-- buffactive[604] = mighty guard
		-- state.HasteMode = toggle for when you know Haste II is being cast on you
		-- Hi = Haste II is being cast. This is clunky to use when both haste II and haste I are being cast
       if ( ( (buffactive[33] or buffactive[580] or buffactive.embrava) and (buffactive.march or buffactive[604]) ) or
             ( buffactive[33] and (buffactive[580] or buffactive.embrava) ) or
             ( buffactive.march == 2 and buffactive[604] ) ) then
            add_to_chat(8, '-------------Haste 43%-------------')
            classes.CustomMeleeGroups:append('Haste_43')
		elseif buffactive.embrava and buffactive.haste then
            add_to_chat(8, '-------------Haste 40%-------------')
            classes.CustomMeleeGroups:append('Haste_40')
        elseif ( (buffactive[33] or buffactive.march == 2 or buffactive[580]) and buffactive['haste samba'] ) then
            add_to_chat(8, '-------------Haste 35%-------------')
            classes.CustomMeleeGroups:append('Haste_35')
        elseif ( ( buffactive[580] or buffactive[33] or buffactive.march == 2 ) or
                 ( buffactive.march == 1 and buffactive[604] ) ) then
            add_to_chat(8, '-------------Haste 30%-------------')
            classes.CustomMeleeGroups:append('Haste_30')
        elseif ( buffactive.march == 1 or buffactive[604] ) then
            add_to_chat(8, '-------------Haste 15%-------------')
            classes.CustomMeleeGroups:append('Haste_15')
		elseif ( buffactive[580] and ( buffactive.march or buffactive[33] or buffactive.embrava or buffactive[604]) ) or  -- geo haste + anything
           ( buffactive.embrava and (buffactive.march or buffactive[33] or buffactive[604]) ) or  -- embrava + anything
           ( buffactive.march == 2 and (buffactive[33] or buffactive[604]) ) or  -- two marches + anything
           ( buffactive[33] and buffactive[604] and buffactive.march ) then -- haste + mighty guard + any marches
            add_to_chat(8, '-------------Max Haste Mode Enabled--------------')
            classes.CustomMeleeGroups:append('Haste_43')
        elseif ( (buffactive[604] or buffactive[33]) and buffactive['haste samba'] and buffactive.march == 1) or -- MG or haste + samba with 1 march
               ( buffactive.march == 2 and buffactive['haste samba'] ) or
               ( buffactive[580] and buffactive['haste samba'] ) then 
            add_to_chat(8, '-------------Haste 35%-------------')
            classes.CustomMeleeGroups:append('Haste_35')
        elseif ( buffactive.march == 2 ) or -- two marches from ghorn
               ( (buffactive[33] or buffactive[604]) and buffactive.march == 1 ) or  -- MG or haste + 1 march
               ( buffactive[580] ) or  -- geo haste
               ( buffactive[33] and buffactive[604] ) then  -- haste with MG
            add_to_chat(8, '-------------Haste 30%-------------')
            classes.CustomMeleeGroups:append('Haste_30')
        elseif buffactive[33] or buffactive[604] or buffactive.march == 1 then
            add_to_chat(8, '-------------Haste 15%-------------')
            classes.CustomMeleeGroups:append('Haste_15')
        end
end

	

-- Select default macro book on initial load or subjob change.
function select_default_macro_book()
    -- Default macro set/book
    if player.sub_job == 'DNC' then
        set_macro_page(2, 4)
	elseif player.sub_job == 'WHM' then
        set_macro_page(3, 4)
    elseif player.sub_job == 'NIN' then
        set_macro_page(10, 4)
    elseif player.sub_job == 'THF' then
        set_macro_page(4, 4)
	elseif player.sub_job == 'BLM' then
        set_macro_page(5, 4)
    else
        set_macro_page(1, 4)
    end
end
 Bismarck.Mitchel
Offline
Serveur: Bismarck
Game: FFXI
Posts: 153
By Bismarck.Mitchel 2016-10-25 17:41:09
Link | Citer | R
 
Could anyone help explain how I would go about adding a new cycle to my gearswap, e.g lowacc/midacc, for Quick Draw (STP/Resistant etc)?
 Odin.Blizzy
Offline
Serveur: Odin
Game: FFXI
user: Blizzit
Posts: 45
By Odin.Blizzy 2016-10-25 22:33:15
Link | Citer | R
 
Need a bit of help please, I am currently trying to fit this months Ambuscade gear into my gearswap, but when I do //gs export, I recive the message: Gearswap: you are wearing an item that is not in the resources yet. I have also tried to //update and no fix. Is there a way to fix this
 Odin.Lygre
Offline
Serveur: Odin
Game: FFXI
user: Dylaudid
Posts: 89
By Odin.Lygre 2016-10-26 09:30:18
Link | Citer | R
 
Odin.Psycooo said: »
Ok, I am back with more questions....
I managed to add/define sets based of the amount of magical haste I have. So now if I have no haste it equips one set of gear, if I get haste 1 or haste 2 it equips based on value of haste all the way up to capped haste.
What I would like additionally is for it to auto equip the single wield gearset in the event I don't have a dual wield subjob, furthermore I would like a way to add in additional sets if I am using /dnc instead of my normal /nin, because the native DW traits are different I would need to add a whole bunch of rules and sets, the problem is I have NO FRIGGIN' IDEA how to do any of that. I literally stole all my haste defined rules from a thf lua and spent like 3 hours til I got it to work.

Edit: Ideally I would like to do this same thing for my terribly designed cor lua, that way I don't have to cycle through 14 sets
Code
-------------------------------------------------------------------------------------------------------------------
-- Setup functions for this job.  Generally should not be modified.
-------------------------------------------------------------------------------------------------------------------
 
-- Initialization function for this job file.
function get_sets()
	mote_include_version = 2
 
	-- Load and initialize the include file.
	include('Mote-Include.lua')
end
 
-- Setup vars that are user-independent.  state.Buff vars initialized here will automatically be tracked.
function job_setup()
	determine_haste_group()
	 
	state.Buff.Saboteur = buffactive.saboteur or false
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('Normal', 'Mid', 'Acc')
	state.HybridMode:options('Normal', 'PDT', 'Evasion')
	state.CastingMode:options('Normal', 'Resistant')
	state.IdleMode:options('Normal', 'PDT', 'MDT')
 
	select_default_macro_book()
	gear.CureStaff = {name=""}
	gear.CureFeet = {name=""}
	 
	state.MagicBurst = M(false, 'Magic Burst')
	state.CureHate = M(false, 'Cure Hate')
 
	Shields = S{'Genmei Shield','Culminus'}
	LowNukes = S{'Stone' , 'Aero' , 'Blizzard' , 'Fire' , 'Water' , 'Thunder' , 
				'Stone II' , 'Aero II' , 'Blizzard II' , 'Fire II' , 'Water II' , 'Thunder II',
				'Stonega' , 'Aeroga' , 'Blizzaga' , 'Firaga' , 'Waterga' , 'Thundaga',
				'Stonega II' , 'Aeroga II' , 'Blizzaga II' , 'Firaga II' , 'Waterga II' , 'Thundaga II'}
	MndEnfeebles = S{'Slow' , 'Silence' , 'Paralyze' , 'Addle' , 'Slow II' , 'Paralyze II' , 'Addle II'}
	IntEnfeebles = S{'Bind' , 'Break' , 'Gravity' , 'Poison' , 'Sleep' , 'Gravity II' , 'Poison II' , 'Sleep II'}

  
	send_command('bind !` gs c toggle MagicBurst')
	send_command('bind ^` gs c toggle CureHate')
 
	update_combat_form()
	determine_haste_group()
 
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['Chainspell'] = {body="Vitivation Tabard +1"}
	 
 
	-- Waltz set (chr and vit)
	sets.precast.Waltz = {}
 
	-- Don't need any special gear for Healing Waltz.
	sets.precast.Waltz['Healing Waltz'] = {}
 
	-- Fast cast sets for spells
 
	-- 80% Fast Cast (including trait) for all spells, plus 5% quick cast
	-- No other FC sets necessary.
	sets.precast.FC = {}
 
	sets.precast.FC.Impact = set_combine(sets.precast.FC, {head=empty,body="Twilight Cloak"})
 
	-- Weaponskill sets
	-- Default set for any weaponskill that isn't any more specifically defined
	sets.precast.WS = {}
 
	sets.precast.WS['Circle Blade'] = set_combine(sets.precast.WS, {})
 
	sets.precast.WS['Sanguine Blade'] = set_combine(sets.precast.WS, {})
 
	sets.precast.WS['Requiescat'] = {}
 
	sets.precast.WS['Aeolian Edge'] = set_combine(sets.precast.WS, {})
 
	sets.precast.WS['Savage Blade'] = {}
 
	sets.precast.WS['Chant du Cygne'] = {}
 
	sets.precast.WS['True Strike'] = {}
 
	sets.precast.WS['Exenterator'] = {}
 
	sets.precast.WS['Evisceration'] = {}
 
	sets.precast.WS['Death Blossom'] = {}
   
	-- Midcast Sets
	sets.midcast.Cure = {}
   
	sets.midcast.Curaga = sets.midcast.Cure
  
	sets.midcast.CureWeather = {}
  
	sets.midcast.CureSelf = {}
   
	sets.midcast.CureMelee = {}
   
	sets.midcast['Enhancing Magic'] = {} 
   
	sets.midcast['Enhancing Magic'].Temper = {}
	 
	sets.midcast['Enhancing Magic'].RegenSelf = {}
   
	sets.midcast['Enhancing Magic'].RefreshSelf = {}
   
	sets.midcast['Enhancing Magic'].HasteSelf = {}
	 
	sets.midcast['Enhancing Magic'].EnSpells = set_combine(sets.midcast['Enhancing Magic'],{})
   
	sets.midcast['Enhancing Magic'].GainSpells = set_combine(sets.midcast['Enhancing Magic'],{})
	 
	sets.midcast['Enhancing Magic'].BarSpells = set_combine(sets.midcast['Enhancing Magic'],{})
	  
	sets.buff.ComposureOther = {head="Lethargy Chappel +1",body="Lethargy Sayon +1",
		legs="Lethargy Fuseau +1",feet="Lethargy Houseaux +1"}
   
	sets.midcast.Protect = {}
	 
	sets.midcast.Shell = sets.midcast.Protect
   
	sets.midcast['Enhancing Magic'].Phalanx = {}
   
	sets.midcast.Cursna = {}
   
	sets.midcast.Stoneskin = {}
   
	sets.midcast['Enfeebling Magic'] = {}
	 
	sets.midcast.MndEnfeebles = {}
 
	sets.midcast.IntEnfeebles = {}
 
	 
	sets.midcast.Blind = {}
	 
	sets.midcast.ElementalEnfeeble = sets.midcast.IntEnfeebles
	 
	sets.midcast.Distract = {}
 
	sets.midcast.Frazzle = {}
   
	sets.midcast['Distract II'] = sets.midcast.Distract
	sets.midcast['Distract III'] = sets.midcast.Distract
 
	sets.midcast['Frazzle II'] = {}
	sets.midcast['Frazzle III'] = sets.midcast.Frazzle
 
   
	sets.midcast['Dia III'] = set_combine(sets.midcast['Enfeebling Magic'], {head="Vitivation Chapeau +1"})
	sets.midcast['Slow II'] = set_combine(sets.midcast['Enfeebling Magic'], {head="Vitivation Chapeau +1"})
	 
	sets.Lunge = {}
 
	sets.Convert = {main="Murgleis"}
	 
	sets.midcast['Elemental Magic'] ={}
	   
	 
	sets.midcast['Elemental Magic']['Low'] = {}
	   
	sets.midcast.Impact = set_combine(sets.midcast['Elemental Magic'], {head=empty,body="Twilight Cloak"})
   
	sets.midcast['Stun'] = {}
   
	sets.midcast.Drain = {}
		   
	sets.midcast.Aspir = sets.midcast.Drain
			 
	-- Sets to return to when not performing an action.
   
	-- Resting sets
	sets.resting = {}
   
	-- Idle sets
	sets.idle = {}
   
	sets.idle.Town = {}
   
	sets.idle.Weak = {}
   
	-- Defense sets
	sets.defense.PDT = {}
   
	sets.defense.MDT = {}
   
	sets.Kiting = {}
   
	sets.latent_refresh = {}
   
	-- 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 = {}
	 
	sets.engaged.Mid = {}
 
	sets.engaged.Acc = {}   
			  
	sets.engaged.Evasion = sets.engaged
	sets.engaged.Mid.Evasion = sets.engaged.Mid
	sets.engaged.Acc.Evasion = sets.engaged.Acc
	 
	sets.engaged.PDT = sets.defense.PDT
	sets.engaged.Mid.PDT = sets.defense.MDT
	sets.engaged.Acc.PDT = sets.defense.PDT
 
		 
	-- Haste 43%
	sets.engaged.Haste_43 = set_combine(sets.engaged, {})
	sets.engaged.Mid.Haste_43 = sets.engaged.Mid
	sets.engaged.Acc.Haste_43 = sets.engaged.Acc
	sets.engaged.Evasion.Haste_43 = sets.engaged.Haste_43
	sets.engaged.PDT.Haste_43 = sets.defense.PDT
 
	-- 40
	sets.engaged.Haste_40 = set_combine(sets.engaged.Haste_43, {})
	sets.engaged.Mid.Haste_40 = sets.engaged.Mid
	sets.engaged.Acc.Haste_40 = sets.engaged.Acc
	sets.engaged.Evasion.Haste_40 = sets.engaged.Haste_40
	sets.engaged.PDT.Haste_40 = sets.defense.PDT
 
	-- 30
	sets.engaged.Haste_30 = sets.engaged
	sets.engaged.Mid.Haste_30 = sets.engaged.Mid
	sets.engaged.Acc.Haste_30 = sets.engaged.Acc
	sets.engaged.Evasion.Haste_30 = sets.engaged
	sets.engaged.PDT.Haste_30 = sets.defense.PDT
 
		-- 25
	sets.engaged.Haste_25 = set_combine(sets.engaged.Haste_30, {})
	sets.engaged.Acc.Haste_25 = sets.engaged.Acc
	sets.engaged.Mid.Haste_25 = sets.engaged.Mid
	sets.engaged.Evasion.Haste_25 = sets.engaged
	sets.engaged.PDT.Haste_25 = sets.defense.PDT
 
	 -- DW nin sub melee group
	sets.engaged.DW_nin = {}
	 
	sets.engaged.DW_nin.Mid = {}
 
	sets.engaged.DW_nin.Acc = {}   
			  
	sets.engaged.DW_nin.Evasion = sets.engaged.DW_nin
	sets.engaged.DW_nin.Mid.Evasion = sets.engaged.DW_nin.Mid
	sets.engaged.DW_nin.Acc.Evasion = sets.engaged.DW_nin.Acc
	 
	sets.engaged.DW_nin.PDT = sets.defense.PDT
	sets.engaged.DW_nin.Mid.PDT = sets.defense.MDT
	sets.engaged.DW_nin.Acc.PDT = sets.defense.PDT
 
		 
	-- Haste 43%
	sets.engaged.DW_nin.Haste_43 = set_combine(sets.engaged.DW_nin, {})
	sets.engaged.DW_nin.Mid.Haste_43 = sets.engaged.DW_nin.Mid
	sets.engaged.DW_nin.Acc.Haste_43 = sets.engaged.DW_nin.Acc
	sets.engaged.DW_nin.Evasion.Haste_43 = sets.engaged.DW_nin.Haste_43
	sets.engaged.DW_nin.PDT.Haste_43 = sets.defense.PDT
 
	-- 40
	sets.engaged.DW_nin.Haste_40 = set_combine(sets.engaged.DW_nin.Haste_43, {})
	sets.engaged.DW_nin.Mid.Haste_40 = sets.engaged.DW_nin.Mid
	sets.engaged.DW_nin.Acc.Haste_40 = sets.engaged.DW_nin.Acc
	sets.engaged.DW_nin.Evasion.Haste_40 = sets.engaged.DW_nin.Haste_40
	sets.engaged.DW_nin.PDT.Haste_40 = sets.defense.PDT
 
	-- 30
	sets.engaged.DW_nin.Haste_30 = sets.engaged.DW_nin
	sets.engaged.DW_nin.Mid.Haste_30 = sets.engaged.DW_nin.Mid
	sets.engaged.DW_nin.Acc.Haste_30 = sets.engaged.DW_nin.Acc
	sets.engaged.DW_nin.Evasion.Haste_30 = sets.engaged.DW_nin
	sets.engaged.DW_nin.PDT.Haste_30 = sets.defense.PDT
 
		-- 25
	sets.engaged.DW_nin.Haste_25 = set_combine(sets.engaged.DW_nin.Haste_30, {})
	sets.engaged.DW_nin.Acc.Haste_25 = sets.engaged.DW_nin.Acc
	sets.engaged.DW_nin.Mid.Haste_25 = sets.engaged.DW_nin.Mid
	sets.engaged.DW_nin.Evasion.Haste_25 = sets.engaged.DW_nin
	sets.engaged.DW_nin.PDT.Haste_25 = sets.defense.PDT

	 -- DW dnc sub melee group
	sets.engaged.DW_dnc = {}
	 
	sets.engaged.DW_dnc.Mid = {}
 
	sets.engaged.DW_dnc.Acc = {}   
			  
	sets.engaged.DW_dnc.Evasion = sets.engaged.DW_dnc
	sets.engaged.DW_dnc.Mid.Evasion = sets.engaged.DW_dnc.Mid
	sets.engaged.DW_dnc.Acc.Evasion = sets.engaged.DW_dnc.Acc
	 
	sets.engaged.DW_dnc.PDT = sets.defense.PDT
	sets.engaged.DW_dnc.Mid.PDT = sets.defense.MDT
	sets.engaged.DW_dnc.Acc.PDT = sets.defense.PDT
 
		 
	-- Haste 43%
	sets.engaged.DW_dnc.Haste_43 = set_combine(sets.engaged.DW_dnc, {})
	sets.engaged.DW_dnc.Mid.Haste_43 = sets.engaged.DW_dnc.Mid
	sets.engaged.DW_dnc.Acc.Haste_43 = sets.engaged.DW_dnc.Acc
	sets.engaged.DW_dnc.Evasion.Haste_43 = sets.engaged.DW_dnc.Haste_43
	sets.engaged.DW_dnc.PDT.Haste_43 = sets.defense.PDT
 
	-- 40
	sets.engaged.DW_dnc.Haste_40 = set_combine(sets.engaged.DW_dnc.Haste_43, {})
	sets.engaged.DW_dnc.Mid.Haste_40 = sets.engaged.DW_dnc.Mid
	sets.engaged.DW_dnc.Acc.Haste_40 = sets.engaged.DW_dnc.Acc
	sets.engaged.DW_dnc.Evasion.Haste_40 = sets.engaged.DW_dnc.Haste_40
	sets.engaged.DW_dnc.PDT.Haste_40 = sets.defense.PDT
 
	-- 30
	sets.engaged.DW_dnc.Haste_30 = sets.engaged.DW_dnc
	sets.engaged.DW_dnc.Mid.Haste_30 = sets.engaged.DW_dnc.Mid
	sets.engaged.DW_dnc.Acc.Haste_30 = sets.engaged.DW_dnc.Acc
	sets.engaged.DW_dnc.Evasion.Haste_30 = sets.engaged.DW_dnc
	sets.engaged.DW_dnc.PDT.Haste_30 = sets.defense.PDT
 
		-- 25
	sets.engaged.DW_dnc.Haste_25 = set_combine(sets.engaged.DW_dnc.Haste_30, {})
	sets.engaged.DW_dnc.Acc.Haste_25 = sets.engaged.DW_dnc.Acc
	sets.engaged.DW_dnc.Mid.Haste_25 = sets.engaged.DW_dnc.Mid
	sets.engaged.DW_dnc.Evasion.Haste_25 = sets.engaged.DW_dnc
	sets.engaged.DW_dnc.PDT.Haste_25 = sets.defense.PDT
 
 
	
	sets.magic_burst = {}
	 
	sets.cure_hate = {}
		 
	sets.Enmity = {}
		 
	-- Sets for special buff conditions on spells.
	sets.buff.Saboteur = {hands="Lethargy Gantherots +1"}
end
 
 
			 
			 
-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for standard casting events.
-------------------------------------------------------------------------------------------------------------------
  
function job_precast(spell, action, spellMap, eventArgs)
	if spell.skill == 'Healing Magic' and spellMap ~= 'StatusRemoval' then
		gear.CureFeet.name = "Vanya Clogs"
		if player.status == 'Engaged' then
			gear.default.obi_back = { name="Sucellos's Cape", augments={'MND+20','Mag. Acc+20 /Mag. Dmg.+20','Mag. Acc.+10','"Cure" potency +10%',}}
			if spell.target.type == 'SELF' then
				gear.CureFeet.name = "Medium's Sabots"
			else
				gear.CureFeet.name = "Vanya Clogs"
			end
		else
			gear.default.obi_back = { name="Sucellos's Cape", augments={'MND+20','Mag. Acc+20 /Mag. Dmg.+20','Mag. Acc.+10','"Cure" potency +10%',}}
		end
		if spell.target.type == 'SELF' then
			gear.default.obi_waist = "Chuq'aba Belt"
		else
			gear.default.obi_waist = "Salire belt"
		end
		if world.weather_element == 'Light' then
			gear.CureStaff.name = "Chatoyant Staff"
		else
			gear.CureStaff.name = "Serenity"
		end
		else
		gear.default.obi_waist = "Salire belt"
		gear.default.obi_back = { name="Sucellos's Cape", augments={'MND+20','Mag. Acc+20 /Mag. Dmg.+20','Mag. Acc.+10','"Cure" potency +10%',}}
	end
		if spell.name == 'Lunge' or spell.name == 'Swipe' then
			equip(sets.Lunge)
			end
		if spell.name == 'Vallation' then
			equip(sets.Enmity)
		end  
		if spell.name == 'Pflug' then
			equip(sets.Enmity)
		end
		if spell.name == 'Warcry' 
		or spell.name == 'Swordplay' or spell.name == 'Rayke' or spell.name == 'Meditate' or spell.name == 'Provoke' then   
			equip(sets.Enmity)
		end
		--prevents casting Utsusemi if you already have 3 or more shadows
		if spell.name == 'Utsusemi: Ichi' and ShadowType == 'Ni' and (buffactive['Copy Image (3)'] or buffactive['Copy Image (4+)']) then
			cancel_spell()
		end
		if buffactive['terror'] or buffactive['petrification'] or buffactive['stun'] or buffactive['sleep'] then
			if TP_ind == 4 then
				equip(sets.defense.MDT) else
				equip(sets.defense.PDT)
			end
		end
		if spell.name == 'Convert' then
			equip(sets.Convert)
		end
	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>')
	end 
end      
 
 
  
-- Run after the default midcast() is done.
-- eventArgs is the same one used in job_midcast, in case information needs to be persisted.
function job_post_midcast(spell, action, spellMap, eventArgs)
	if spell.skill == 'Enfeebling Magic' and state.Buff.Saboteur then
		equip(sets.buff.Saboteur)
	elseif spell.skill == 'Enhancing Magic' and not spell.english == 'Stoneskin' then
		equip(sets.midcast.EnhancingDuration)
		if buffactive.composure and spell.target.type == 'PLAYER' then
			equip(sets.buff.ComposureOther)
		end
	elseif spellMap == 'Cure' then
		if spell.target.type == 'SELF' then
			equip(sets.midcast.CureSelf)
		end
		if state.CureHate.value then
			equip(sets.cure_hate)
		end
		if world.weather_element == 'Light' then
			equip(sets.midcast.CureWeather)
		end
	elseif spell.skill == 'Elemental Magic' then
		if state.MagicBurst.value then
			equip(sets.magic_burst)
		end
		if spell.element == world.day_element or spell.element == world.weather_element then
			equip({waist="Hachirin-no-Obi"})
		end
	elseif spell.skill == "Ninjutsu" then
			equip(sets.midcast.Recast)
			if spell.name == 'Utsusemi: Ichi' and ShadowType == 'Ni' then
				if buffactive['Copy Image'] then
					windower.ffxi.cancel_buff(66)
				elseif buffactive['Copy Image (2)'] then
					windower.ffxi.cancel_buff(444)
				elseif buffactive['Copy Image (3)'] then
					windower.ffxi.cancel_buff(445)
				elseif buffactive['Copy Image (4+)'] then
					windower.ffxi.cancel_buff(446)
			end
		elseif spell.name == 'Monomi: Ichi' and buffactive.Sneak and spell.target.type == 'SELF' then
			windower.ffxi.cancel_buff(71)
		end
	end
	if spell.name == 'Foil' or spell.name == 'Flash' or spell.name == 'Blank Gaze'
		or spell.name == 'Geist Wall' or spell.name == 'Poison Breath' or spell.name == 'Jettatura'
		or spell.name == 'Cocoon' or spell.name == 'Soporific' or spell.name == 'Sheep Song' 
		or spell.name == 'Refueling' then 
		equip(sets.Enmity)
	end
end
	 
	 
 
function job_get_spell_map(spell, default_spell_map)
	if spell.action_type == 'Magic' then
		if spell.skill == 'Enhancing Magic' then
			if spell.english:startswith('En') then
				return 'EnSpells'
			elseif spell.english:startswith('Gain') then
				return 'GainSpells'
			elseif spell.english:startswith('Phalanx') then
				return 'Phalanx'
			elseif spell.english:startswith('Bar') then
				return 'Bar'
			elseif spell.english:startswith('Temper') then
				return 'Temper'
			elseif spell.english:startswith('Haste') then
				if spell.target.type == 'SELF' then
				return 'HasteSelf'
				end
			elseif spell.english:startswith('Refresh') then
				if spell.target.type == 'SELF' then
				return 'RefreshSelf'
				end
			end
		elseif default_spell_map == 'Cure' or default_spell_map == 'Curaga' then
			if player.status == 'Engaged' then
				return "CureMelee"
			end
		end
		if spell.action_type == 'Magic' then
			if spell.skill == 'Enfeebling Magic' then
				if spell.type == 'WhiteMagic' then
					return 'MndEnfeebles'
				else
					return 'IntEnfeebles'
				end
			elseif spell.skill == 'Elemental Magic' then
				if LowNukes:contains(spell.name) then
					return 'Low'
				else
					return
				end
				 
			end
		end
	end
end
 
   
-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for non-casting events.
-------------------------------------------------------------------------------------------------------------------
   
-- Handle notifications of general user state change.
function job_state_change(stateField, newValue, oldValue)
	if stateField == 'Offense Mode' then
		if newValue == 'None' then
			enable('main','sub','range')
		else
			disable('main','sub','range')
		end
	end
end
   
   
	-------------------------------------------------------------------------------------------------------------------
	-- General hooks for change 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 we gain or lose any haste buffs, adjust which gear set we target.
		if S{'haste','march', 'madrigal','embrava','haste samba'}:contains(buff:lower()) then
			determine_haste_group()
			handle_equipping_gear(player.status)
		end
		if state.Buff[buff] ~= nil then
			state.Buff[buff] = gain
			if not midaction() then
				handle_equipping_gear(player.status)
			end
		end
	end
 
-------------------------------------------------------------------------------------------------------------------
-- User code that supplements standard library decisions.
-------------------------------------------------------------------------------------------------------------------
   
-- Modify the default idle set after it was constructed.
function customize_idle_set(idleSet)
	if player.mpp < 51 then
		idleSet = set_combine(idleSet, sets.latent_refresh)
	end
	return idleSet
end
   
-- function customize_melee_set(meleeSet)
--     if player.sub_job == 'DNC' or player.sub_job == 'NIN' then
--         meleeSet = set_combine(meleeSet, sets.engaged.DW)
--     end
--     return meleeSet
-- end 


function update_combat_form()
	-- Check for H2H or single-wielding
	if player.equipment.sub == 'empty' then
		state.CombatForm:reset()
	elseif Shields:contains(player.equipment.sub) then
		state.CombatForm:reset()
	else
		if player.sub_job == 'NIN' then
			state.CombatForm:set('DW_nin')
		elseif player.sub_job == 'DNC' then
			state.CombatForm:set('DW_dnc')
		end     
	end
end

function job_update(cmdParams, eventArgs)
	update_combat_form()
	determine_haste_group()
end

-- Set eventArgs.handled to true if we don't want the automatic display to be run.
function display_current_job_state(eventArgs)
	display_current_caster_state()
	eventArgs.handled = true
end
   
-------------------------------------------------------------------------------------------------------------------
-- Utility functions specific to this job.
-------------------------------------------------------------------------------------------------------------------
	function determine_haste_group()
 
		classes.CustomMeleeGroups:clear()
		-- assuming +4 for marches (ghorn has +5)
		-- Haste (white magic) 15%
		-- Haste Samba (Sub) 5%
		-- Haste (Merited DNC) 10% (never account for this)
		-- Victory March +0/+3/+4/+5    9.4/14%/15.6%/17.1% +0
		-- Advancing March +0/+3/+4/+5  6.3/10.9%/12.5%/14%  +0
		-- Embrava 30% with 500 enhancing skill
		-- Mighty Guard - 15%
		-- buffactive[580] = geo haste
		-- buffactive[33] = regular haste
		-- buffactive[604] = mighty guard
		-- state.HasteMode = toggle for when you know Haste II is being cast on you
		-- Hi = Haste II is being cast. This is clunky to use when both haste II and haste I are being cast
	   if ( ( (buffactive[33] or buffactive[580] or buffactive.embrava) and (buffactive.march or buffactive[604]) ) or
			 ( buffactive[33] and (buffactive[580] or buffactive.embrava) ) or
			 ( buffactive.march == 2 and buffactive[604] ) ) then
			add_to_chat(8, '-------------Haste 43%-------------')
			classes.CustomMeleeGroups:append('Haste_43')
		elseif buffactive.embrava and buffactive.haste then
			add_to_chat(8, '-------------Haste 40%-------------')
			classes.CustomMeleeGroups:append('Haste_40')
		elseif ( (buffactive[33] or buffactive.march == 2 or buffactive[580]) and buffactive['haste samba'] ) then
			add_to_chat(8, '-------------Haste 35%-------------')
			classes.CustomMeleeGroups:append('Haste_35')
		elseif ( ( buffactive[580] or buffactive[33] or buffactive.march == 2 ) or
				 ( buffactive.march == 1 and buffactive[604] ) ) then
			add_to_chat(8, '-------------Haste 30%-------------')
			classes.CustomMeleeGroups:append('Haste_30')
		elseif ( buffactive.march == 1 or buffactive[604] ) then
			add_to_chat(8, '-------------Haste 15%-------------')
			classes.CustomMeleeGroups:append('Haste_15')
		elseif ( buffactive[580] and ( buffactive.march or buffactive[33] or buffactive.embrava or buffactive[604]) ) or  -- geo haste + anything
		   ( buffactive.embrava and (buffactive.march or buffactive[33] or buffactive[604]) ) or  -- embrava + anything
		   ( buffactive.march == 2 and (buffactive[33] or buffactive[604]) ) or  -- two marches + anything
		   ( buffactive[33] and buffactive[604] and buffactive.march ) then -- haste + mighty guard + any marches
			add_to_chat(8, '-------------Max Haste Mode Enabled--------------')
			classes.CustomMeleeGroups:append('Haste_43')
		elseif ( (buffactive[604] or buffactive[33]) and buffactive['haste samba'] and buffactive.march == 1) or -- MG or haste + samba with 1 march
			   ( buffactive.march == 2 and buffactive['haste samba'] ) or
			   ( buffactive[580] and buffactive['haste samba'] ) then 
			add_to_chat(8, '-------------Haste 35%-------------')
			classes.CustomMeleeGroups:append('Haste_35')
		elseif ( buffactive.march == 2 ) or -- two marches from ghorn
			   ( (buffactive[33] or buffactive[604]) and buffactive.march == 1 ) or  -- MG or haste + 1 march
			   ( buffactive[580] ) or  -- geo haste
			   ( buffactive[33] and buffactive[604] ) then  -- haste with MG
			add_to_chat(8, '-------------Haste 30%-------------')
			classes.CustomMeleeGroups:append('Haste_30')
		elseif buffactive[33] or buffactive[604] or buffactive.march == 1 then
			add_to_chat(8, '-------------Haste 15%-------------')
			classes.CustomMeleeGroups:append('Haste_15')
		end
end
 
	 
 
-- Select default macro book on initial load or subjob change.
function select_default_macro_book()
	-- Default macro set/book
	if player.sub_job == 'DNC' then
		set_macro_page(2, 4)
	elseif player.sub_job == 'WHM' then
		set_macro_page(3, 4)
	elseif player.sub_job == 'NIN' then
		set_macro_page(10, 4)
	elseif player.sub_job == 'THF' then
		set_macro_page(4, 4)
	elseif player.sub_job == 'BLM' then
		set_macro_page(5, 4)
	else
		set_macro_page(1, 4)
	end
end


I added a list called 'Shields' under user_seup that you'll need to update with any shields you want gearswap to look for to automatically identify single-wielding. It will also identify single-wielding if your sub slot is empty.
You'll also need to continue/finish iterating hybrid sets over the different combat forms (DW_nin and DW_dnc, e.g. sets.engaged.DW_nin.Acc.PDT.Haste_43), I just didn't feel like doing it all.
 Odin.Lygre
Offline
Serveur: Odin
Game: FFXI
user: Dylaudid
Posts: 89
By Odin.Lygre 2016-10-26 09:37:10
Link | Citer | R
 
Bismarck.Mitchel said: »
Could anyone help explain how I would go about adding a new cycle to my gearswap, e.g lowacc/midacc, for Quick Draw (STP/Resistant etc)?
Code
-------------------------------------------------------------------------------------------------------------------
-- Setup functions for this job. Generally should not be modified.
-------------------------------------------------------------------------------------------------------------------

--[[
Custom commands:

gs c shot
Uses the currently configured shot on the target, with either <t> or <stnpc> depending on setting.
gs c shot t
Uses the currently configured shot on the target, but forces use of <t>.


Configuration commands:

gs c cycle mainshot
Cycles through the available steps to use as the primary shot when using one of the above commands.

gs c cycle altshot
Cycles through the available steps to use for alternating with the configured main shot.

gs c toggle usealtshot
Toggles whether or not to use an alternate shot.

gs c toggle selectshottarget
Toggles whether or not to use <stnpc> (as opposed to <t>) when using a shot.


gs c toggle LuzafRing -- Toggles use of Luzaf Ring on and off

gs c cycle QuickDraw -- Cycles through Normal, STP, Resistant QuickDraw sets. 
	--If set to Resistant and using light/dark shot, will use sets.precast.CorsairShot.StatusShot
	--Other shots will use sets.precast.CorsairShot.Resistant
	
Offense mode is melee or ranged. Used ranged offense mode if you are engaged
for ranged weaponskills, but not actually meleeing.

Weaponskill mode, if set to 'Normal', is handled separately for melee and ranged weaponskills.
--]]


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

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

-- Setup vars that are user-independent. state.Buff vars initialized here will automatically be tracked.
function job_setup()


-- QuickDraw Selector
state.MainShot = M{['description']='Primary Shot', 'Dark Shot', 'Earth Shot', 'Water Shot', 'Wind Shot', 'Fire Shot', 'Ice Shot', 'Thunder Shot'}
state.AltShot = M{['description']='Secondary Shot', 'Earth Shot', 'Water Shot', 'Wind Shot', 'Fire Shot', 'Ice Shot', 'Thunder Shot', 'Dark Shot'}
state.UseAltShot = M(false, 'Use Secondary Shot')
state.SelectShotTarget = M(false, 'Select Quick Draw Target')
state.IgnoreTargetting = M(false, 'Ignore Targetting')

state.CurrentShot = M{['description']='Current Quick Draw', 'Main', 'Alt'}

state.QuickDraw = M{['description']='QD Mode', 'Normal','STP', 'Resistant'}

-- Whether to use Luzaf's Ring
state.LuzafRing = M(false, "Luzaf's Ring")
-- Whether a warning has been given for low ammo
state.warned = M(false)

define_roll_values()
determine_haste_group()

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('Normal', 'LowAcc', 'MidAcc', 'HighAcc', 'Fodder')
state.RangedMode:options('Normal', 'Acc', 'Fodder')
state.WeaponskillMode:options('Normal', 'Acc')
state.CastingMode:options('Normal', 'Resistant')
state.IdleMode:options('Normal', 'DT')


gear.RAbullet = "Adlivun Bullet"
gear.WSbullet = "Adlivun Bullet"
gear.MAbullet = "Orichalc. Bullet"
gear.QDbullet = "Animikii Bullet"
options.ammo_warning_limit = 5

-- Additional local binds
send_command('bind ^` input /ja "Double-up" <me>')
send_command('bind !` input /ja "Bolter\'s Roll" <me>')
send_command ('bind @` gs c toggle LuzafRing')

send_command('bind ^- gs c cycleback mainshot')
send_command('bind ^= gs c cycle mainshot')
send_command('bind !- gs c cycle altshot')
send_command('bind != gs c cycleback altshot')
send_command('bind ^[ gs c toggle selectshottarget')
send_command('bind ^] gs c toggle usealtshot')
send_command('bind ^, input /ja "Spectral Jig" <me>')
send_command('unbind ^.')

select_default_macro_book()
end


-- Called when this job file is unloaded (eg: job change)
function user_unload()
send_command('unbind ^`')
send_command('unbind !`')
send_command('unbind @`')
send_command('unbind ^-')
send_command('unbind ^=')
send_command('unbind !-')
send_command('unbind !=')
send_command('unbind ^[')
send_command('unbind ^]')
send_command('unbind ^,')
end

-- Define sets and vars used by this job file.
function init_gear_sets()
--------------------------------------
-- Start defining the sets
--------------------------------------
-- Augmented Gear
-- Herculean
gear.Herc_MAB_Head = {name="Herculean Helm", augments={'Mag. Acc.+20 "Mag.Atk.Bns."+20','INT+7','"Mag.Atk.Bns."+11',}}
gear.Herc_TP_Gloves = {name="Herculean Gloves", augments={'Accuracy+30','"Triple Atk."+3','DEX+3',}}
gear.Herc_TP_Legs = {name="Herculean Trousers", augments={'Attack+23','"Triple Atk."+4','STR+3','Accuracy+8',}}
gear.Herc_MAB_Legs = { name="Herculean Trousers", augments={'"Mag.Atk.Bns."+25','Weapon skill damage +3%','MND+10',}}
gear.Herc_MAB_Feet = {name="Herculean Boots", augments={'Mag. Acc.+18 "Mag.Atk.Bns."+18','STR+10','Mag. Acc.+11','"Mag.Atk.Bns."+12',}}
gear.Herc_TP_Feet = {name="Herculean Boots", augments={'Accuracy+27','"Triple Atk."+2','DEX+7',}}
-- Taeon
gear.Taeon_WS_Head = {name="Taeon Chapeau", augments={'Mag. Acc.+15 "Mag.Atk.Bns."+15','Weapon skill damage +2%',}}
gear.Taeon_TP_Head = {name="Taeon Chapeau", augments={'Accuracy+23','"Triple Atk."+1',}}
gear.Taeon_TP_Legs = {name="Taeon Tights", augments={'Accuracy+23','"Triple Atk."+2',}}
-- Ambuscade Capes
gear.COR_WS_Cape = {name="Camulus's Mantle", augments={'AGI+20','Mag. Acc+20 /Mag. Dmg.+20','Weapon skill damage +10%',}}
gear.COR_WS2_Cape = {name="Ankou's Mantle", augments={'STR+20','Accuracy+20 Attack+20','Weapon skill damage +10%',}}
gear.COR_TP_Cape = { name="Camulus's Mantle", augments={'DEX+20','Accuracy+20 Attack+20','"Store TP"+10',}}

-- Precast Sets

sets.precast.JA['Triple Shot'] = {body="Chasseur's Frac",back=gear.COR_WS_Cape}
sets.precast.JA['Snake Eye'] = {legs="Commodore Culottes +2"}
sets.precast.JA['Wild Card'] = {feet="Lanun Bottes +1"}
sets.precast.JA['Random Deal'] = {body="Lanun Frac +1"}

sets.precast.CorsairRoll = {
head="Lanun Tricorne",
body="Meg. Cuirie +1",
hands="Chasseur's Gants",
legs="Desultor Tassets",
feet="Lanun Bottes +1",
neck="Twilight Torque",
ear1="Darkness earring",
ear2="Darkness earring",
ring1="Luzaf's Ring",
ring2="Barataria Ring",
back="Camulus's Mantle",
waist="Flume Belt",
}

--	sets.precast.CorsairRoll["Caster's Roll"] = set_combine(sets.precast.CorsairRoll, {legs="Chas. Culottes"})
sets.precast.CorsairRoll["Courser's Roll"] = set_combine(sets.precast.CorsairRoll, {feet="Chass. Bottes"})
sets.precast.CorsairRoll["Blitzer's Roll"] = set_combine(sets.precast.CorsairRoll, {head="Chass. Tricorne"})
sets.precast.CorsairRoll["Tactician's Roll"] = set_combine(sets.precast.CorsairRoll, {body="Chasseur's Frac"})
sets.precast.CorsairRoll["Allies' Roll"] = set_combine(sets.precast.CorsairRoll, {hands="Chasseur's Gants"})

sets.precast.LuzafRing = {ring2="Luzaf's Ring"}
sets.precast.FoldDoubleBust = {hands="Lanun Gants"}

sets.precast.CorsairShot = {
	ammo=gear.QDbullet,
	head=gear.Herc_MAB_Head,
	body="Mirke wardecors",
	hands="Carmine Fin. Ga. +1",
	legs="Laksamana's trews +1",
	feet=gear.Herc_MAB_Feet,
	neck="Sanctity Necklace",
	ear1="Hecate's Earring",
	ear2="Friomisi Earring",
	ring1="Arvina Ringlet +1",
	ring2="Acumen Ring",
	back=gear.COR_WS_Cape,
	waist="Eschan Stone",
}
sets.precast.CorsairShot.STP = {
ammo=gear.QDbullet,
head="",
body="Mirke wardecors",
hands="Schutzen Mittens",
legs="Chas. Culottes",
feet="Carmine Greaves",
neck="Sanctity Necklace",
ear1="",
ear2="",
ring1="Raja Ring",
ring2="Petrov Ring",
back=gear.COR_TP_Cape,
waist="Goading Belt",
}

sets.precast.CorsairShot.Resistant = {
ammo=gear.QDbullet,
head="Carmine Mask",
body="Mirke wardecors",
hands="Leyline gloves",
legs="Rawhide Trousers",
feet=gear.Herc_MAB_Feet,
neck="Sanctity Necklace",
ear1="Lifestorm Earring",
ear2="Psystorm Earring",
ring1="Weatherspoon ring",
ring2="Etana Ring",
back=gear.COR_WS_Cape,
waist="Eschan Stone",
}

sets.precast.CorsairShot.StatusShot = {
	ammo=gear.QDbullet,
	head="Carmine Mask",
	body="Mirke wardecors",
	hands="Leyline gloves",
	legs="Rawhide Trousers",
	feet=gear.Herc_MAB_Feet,
	neck="Sanctity Necklace",
	ear1="Lifestorm Earring",
	ear2="Psystorm Earring",
	ring1="Weatherspoon ring",
	ring2="Etana Ring",
	back=gear.COR_WS_Cape,
	waist="Eschan Stone",
}

sets.precast.CorsairShot['Light Shot'] = set_combine(sets.precast.CorsairShot, {
hands="Leyline gloves",
head="Carmine Mask",
legs="Rawhide Trousers",
ear1="Lifestorm Earring",
ear2="Psystorm Earring",
ring1="Weatherspoon ring",
ring2="Etana Ring",
})

sets.precast.CorsairShot['Dark Shot'] = set_combine(sets.precast.CorsairShot, {
hands="Leyline gloves",
head="Pixie Hairpin +1",
legs="Rawhide Trousers",
ear1="Lifestorm Earring",
ear2="Psystorm Earring",
ring1="Weatherspoon ring",
ring2="Archon Ring",
})

sets.precast.Waltz = {
hands="Slither Gloves +1",
legs="Desultor Tassets",
ring1="Asklepian Ring",
ring2="Valseur's Ring",
} -- CHR and VIT

sets.precast.Waltz['Healing Waltz'] = {}

sets.precast.FC = {
head="Carmine Mask", --12
body="Taeon Tabard", --7
hands="Leyline Gloves", --8
legs="Rawhide Trousers", --5
feet="Carmine Greaves", --7
neck="Orunmila's Torque", --5
ear1="Loquacious Earring", --2
ear2="Halasz Earring", --1
ring1="Prolix Ring", --2
ring2="Weatherspoon ring", --5(3)
waist="Flume belt",
}

sets.precast.FC.Utsusemi = set_combine(sets.precast.FC, {
neck="Magoraga Beads",
ring1="Lebeche Ring",
})

sets.precast.RA = {
ammo=gear.RAbullet,
head="Aurore Beret +1", --5
body="Pursuer's Doublet", --6
hands="Carmine Fin. Ga. +1", --8
legs="Chasseur's culottes", --6
feet="Meg. Jam. +1", --8
back="Navarch's Mantle", --6.5
waist="Impulse Belt", --3
}


-- Weaponskill sets
-- Default set for any weaponskill that isn't any more specifically defined
sets.precast.WS = {
ammo=gear.WSbullet,
head="Meghanada Visor +1",
body="Meg. Cuirie +1",
hands="Meghanada gloves +1",
legs="Meg. Chausses +1",
feet="Meg. Jam. +1",
neck="Fotia Gorget",
ear1="Moonshade Earring",
ear2="Ishvara Earring",
ring1="Arvina Ringlet +1",
ring2="Garuda Ring",
back=gear.COR_WS_Cape,
waist="Fotia belt",
}

sets.precast.WS.Acc = set_combine(sets.precast.WS, {
hands="Meg. Gloves +1",
})

-- Specific weaponskill sets. Uses the base set if an appropriate WSMod version isn't found.

sets.precast.WS["Last Stand"] = set_combine(sets.precast.WS['Last Stand'], {
hands="Meg. Gloves +1",
ring1="Garuda Ring",
})

sets.precast.WS['Last Stand'].Acc = set_combine(sets.precast.WS['Last Stand'], {
ammo=gear.WSbullet,
hands="Meg. Gloves +1",
ear2="Volley Earring",
ring1="Cacoethic Ring +1",
back="Gunslinger's cape",
})

sets.precast.WS['Wildfire'] = {
ammo=gear.MAbullet,
head=gear.Herc_MAB_Head,
body="Samnuha Coat",
hands="Carmine Fin. Ga. +1",
legs=gear.Herc_MAB_Legs,
feet=gear.Herc_MAB_Feet,
neck="Sanctity Necklace",
ear1="Hecate's Earring",
ear2="Friomisi Earring",
ring1="Arvina Ringlet +1",
ring2="Garuda Ring",
back=gear.COR_WS_Cape,
waist="Eschan Stone",
}

sets.precast.WS['Leaden Salute'] = {
ammo=gear.MAbullet,
head="Pixie Hairpin +1",
body="Samnuha Coat",
hands="Carmine Fin. Ga. +1",
legs=gear.Herc_MAB_Legs,
feet=gear.Herc_MAB_Feet,
neck="Sanctity Necklace",
ear1="Moonshade Earring",
ear2="Friomisi Earring",
ring1="Archon Ring",
ring2="Arvina Ringlet +1",
back=gear.COR_WS_Cape,
waist="Eschan Stone",
}

sets.precast.WS['Aeolian Edge'] = {
ammo=gear.MAbullet,
head=gear.Herc_MAB_Head,
body="Samnuha Coat",
hands="Leyline gloves",
legs=gear.Herc_MAB_Legs,
feet=gear.Herc_MAB_Feet,
neck="Sanctity Necklace",
ear1="Hecate's Earring",
ear2="Friomisi Earring",
ring1="Arvina Ringlet +1",
ring2="Garuda Ring",
back=gear.COR_WS_Cape,
waist="Eschan Stone",
}

sets.precast.WS['Evisceration'] = {
head="",
body="Meg. Cuirie +1",
hands="Meg. Gloves +1",
legs="",
feet="",
neck="Fotia gorget",
ear1="Moonshade Earring",
ear2="Brutal Earring",
ring1="",
ring2="Epona's Ring",
back="",
waist="Fotia belt",
}

sets.precast.WS['Savage Blade'] = {
head="Meghanada Visor +1",
body="Meg. Cuirie +1",
hands="Meghanada gloves +1",
legs="Meg. Chausses +1",
feet="Rawhide boots",
neck="Caro necklace",
ear1="Moonshade Earring",
ear2="Ishvara Earring",
ring1="Ifrit Ring",
ring2="Ifrit Ring",
back=gear.COR_WS2_Cape,
waist="Prosilio belt +1",
}

sets.precast.WS['Savage Blade'].Acc = set_combine(sets.precast.WS['Savage Blade'], {
ring1="Rufescent Ring",
waist="Grunfeld Rope",
})

sets.precast.WS['Requiescat'] = set_combine(sets.precast.WS['Savage Blade'], {
neck="Fotia gorget",
ring1="Rufescent Ring",
ring2="Epona's Ring",
back="Bleating Mantle",
waist="Fotia Belt",
}) --MND

sets.precast.WS['Requiescat'].Acc = set_combine(sets.precast.WS['Requiescat'], {
head="Carmine Mask"
})

-- Midcast Sets

sets.midcast.CorsairRoll = {
head="Lanun Tricorne",
body="Meg. Cuirie +1",
hands="Chasseur's Gants",
legs="Desultor Tassets",
feet="Lanun Bottes +1",
neck="Twilight Torque",
ear1="Darkness earring",
ear2="Darkness earring",
ring1="Luzaf's Ring",
ring2="Barataria Ring",
back="Camulus's Mantle",
waist="Flume Belt",
}

sets.midcast.FastRecast = {
ear1="Loquacious Earring",
ear2="",
}

sets.midcast.Cure = {
neck="Incanter's Torque",
ear1="Roundel Earring",
ear2="Mendi. Earring",
ring1="",
ring2="",
waist="",
}	

sets.midcast.Utsusemi = {
waist="Pya'ekue belt",
}



-- Ranged gear
sets.midcast.RA = {
ammo=gear.RAbullet,	
head="Pursuer's Beret",
body="Pursuer's Doublet",
hands="Carmine Fin. Ga. +1",
legs="Meg. Chausses +1",
feet="Meg. Jam. +1",
neck="Marked Gorget",
ear1="Navarch's Earring",
ear2="Volley Earring",
ring1="Arvina Ringlet +1",
ring2="Garuda Ring",
back="Gunslinger's Cape",
waist="Eschan Stone",
}

sets.midcast.RA.Acc = set_combine(sets.midcast.RA, {
ammo=gear.RAbullet,
hands="Meg. Gloves +1",
body="Meg. Cuirie +1",
ring1="Cacoethic Ring +1",
ring1="Hadjuk Ring",
})

sets.midcast.RA.Fodder = set_combine(sets.midcast.RA, {
ammo=gear.RAbullet,
neck="Ocachi Gorget",
})

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

-- Resting sets
sets.resting = {}

-- Idle sets
sets.idle = {
ammo=gear.RAbullet,
head="Meghanada visor +1",
body="Meg. Cuirie +1",
hands="Kurys gloves",
legs="Carmine Cuisses +1",
feet="Lanun bottes +1",
neck="Sanctity Necklace",
ear1="Eabani Earring",
ear2="Infused Earring",
ring1="Paguroidea Ring",
ring2="Sheltered Ring",
back="Solemnity Cape",
waist="Flume Belt",
}

sets.idle.DT = set_combine (sets.idle, {
head="Meghanada visor +1", --4/0
body="Meg. Cuirie +1", --7/0
hands="Meg. Gloves +1", --3/0
legs="Meg. Chausses +1", --5/0
feet="Lanun Bottes +1", --4/0
neck="Twilight Torque", --5/5
ear1="Darkness Earring", --2/0
ear2="Darkness Earring", --2/0
ring1="Gelatinous Ring +1", --6/(-2)
ring2="Dark Ring", --0/4
back="Solemnity Cape", --4/4
waist="Flume Belt", --4/0
})

sets.idle.Town = set_combine(sets.idle, {
hands="Carmine Fin. Ga. +1",
back=gear.COR_WS_Cape,
waist="Eschan Stone",
})


-- Defense sets
sets.defense.PDT = {
head="Meghanada visor +1", --4/0
body="Meg. Cuirie +1", --7/0
hands="Meg. Gloves +1", --3/0
legs="Meg. Chausses +1", --5/0
feet="Lanun Bottes +1", --4/0
neck="Twilight Torque", --5/5
ear1="Darkness Earring", --2/0
ear2="Darkness Earring", --2/0
ring1="Gelatinous Ring +1", --6/(-2)
ring2="Jelly Ring", --10/10
back="Solemnity Cape", --4/4
waist="Flume Belt", --4/0
}

sets.defense.MDT = set_combine(sets.defense.PDT, {
ear1="Merman's Earring", --0/2
ear2="Merman's Earring", --0/2
ring1="Dark Ring", --0/4
ring2="Minerva's Ring", --(-8)/8
})

sets.Kiting = {legs="Crimson cuisses"}

-- 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=gear.RAbullet,
head="Adhemar Bonnet",
body="Adhemar Jacket",
hands="Adhemar Wristbands",
legs="Carmine cuisses +1",
feet="Taeon boots",
neck="Lissome Necklace",
ear1="Eabani Earring",
ear2="Suppanomimi",
ring1="Petrov Ring",
ring2="Epona's Ring",
back="Bleating Mantle",
waist="Windbuffet Belt +1",
}

sets.engaged.LowAcc = set_combine(sets.engaged, {
ring2="Rajas Ring",
back=gear.COR_TP_Cape,
})

sets.engaged.MidAcc = set_combine(sets.engaged.LowAcc, {
ear1="Cessance Earring",
feet=gear.Herc_TP_Feet,
waist="Kentarch Belt +1",
})

sets.engaged.HighAcc = set_combine(sets.engaged.MidAcc, {
head="Carmine Mask",
neck="Subtlety spectacles",
ear2="Mache Earring",
ring1="Cacoethic Ring +1",
ring2="Enlivened Ring",
back=gear.COR_TP_Cape,
})

sets.engaged.Fodder = set_combine(sets.engaged, {
body="Thaumas Coat",
neck="Asperity Necklace",
})

sets.engaged.HighHaste = {
ammo=gear.RAbullet,
head="Adhemar Bonnet",
body="Adhemar Jacket", --5
hands="Adhemar Wristbands", --3
legs=gear.Herc_TP_Legs,
feet=gear.Herc_TP_Feet,
neck="Lissome Necklace",
ear1="Cessance Earring",
ear2="Suppanomimi", --5
ring1="Petrov Ring",
ring2="Epona's Ring",
back="Bleating Mantle",
waist="Windbuffet Belt +1",
}

sets.engaged.HighHaste.LowAcc = set_combine(sets.engaged.HighHaste, {
ring2="Rajas Ring",
back=gear.COR_TP_Cape,
})

sets.engaged.HighHaste.MidAcc = set_combine(sets.engaged.HighHaste.LowAcc, {
legs="Taeon tights",
ring1="Cacoethic Ring +1",
waist="Kentarch Belt +1",
})

sets.engaged.HighHaste.HighAcc = set_combine(sets.engaged.HighHaste.MidAcc, {
head="Carmine Mask",
legs="Carmine cuisses +1",
neck="Subtlety spectacles",
ear2="Mache Earring",
ring2="Enlivened Ring",
})

sets.engaged.HighHaste.Fodder = set_combine(sets.engaged.HighHaste, {
body="Thaumas Coat",
neck="Asperity Necklace",
})

sets.engaged.MaxHaste = {
ammo=gear.RAbullet,
head="Adhemar Bonnet",
body="Adhemar Jacket", --5
hands="Adhemar Wristbands", --3
legs=gear.Herc_TP_legs,
feet=gear.Herc_TP_feet,
neck="Lissome Necklace",
ear1="Cessance Earring",
ear2="Suppanomimi",
ring1="Petrov Ring",
ring2="Epona's Ring",
back="Bleating Mantle",
waist="Windbuffet Belt +1",
}

sets.engaged.MaxHaste.LowAcc = set_combine(sets.engaged.HighHaste, {
ring2="Rajas Ring",
back=gear.COR_TP_Cape,
})

sets.engaged.MaxHaste.MidAcc = set_combine(sets.engaged.MaxHaste.LowAcc, {
legs="Taeon tights",
ring1="Cacoethic Ring +1",
waist="Kentarch Belt +1",
})

sets.engaged.MaxHaste.HighAcc = set_combine(sets.engaged.MaxHaste.MidAcc, {
head="Carmine Mask",
neck="Subtlety spectacles",
ear2="Mache Earring",
ring2="Enlivened Ring",
})

sets.engaged.MaxHaste.Fodder = set_combine(sets.engaged.MaxHaste, {
body="Thaumas Coat",
neck="Asperity Necklace",
})

sets.Obi = {waist="Hachirin-no-Obi"}

end


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

-- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
-- Set eventArgs.useMidcastGear to true if we want midcast gear equipped on precast.
function job_precast(spell, action, spellMap, eventArgs)
-- Check that proper ammo is available if we're using ranged attacks or similar.
	if spell.action_type == 'Ranged Attack' or spell.type == 'WeaponSkill' or spell.type == 'CorsairShot' then
		do_bullet_checks(spell, spellMap, eventArgs)
	end
	if (spell.type == 'CorsairRoll' or spell.english == "Double-Up") and state.LuzafRing.value then
		equip(sets.precast.LuzafRing)
	elseif spell.type == 'CorsairShot' and S{'Dark Shot','Light Shot'}:contains(spell.english) then
		if state.CastingMode.value == 'Resistant' or state.QuickDraw.value == 'Resistant' then
			--To specify a FULL M.ACC set for LightShot/DarkShot, whereas for other shots, the resistant mode would prefer a different ratio of m.acc/mab
			classes.CustomClass = 'StatusShot'
		end
	elseif spell.type == 'CorsairShot' and state.QuickDraw.value ~= 'Normal' then
		classes.CustomClass = state.QuickDraw.value 
	elseif spell.english == 'Fold' and buffactive['Bust'] == 2 then
		if sets.precast.FoldDoubleBust then
			equip(sets.precast.FoldDoubleBust)
			eventArgs.handled = true
		end
	end
end

function job_post_precast(spell, action, spellMap, eventArgs)
-- Equip obi if weather/day matches for WS/Quick Draw.
if spell.type == 'WeaponSkill' or spell.type == 'CorsairShot' then
if spell.english == 'Leaden Salute' and (world.weather_element == 'Dark' or world.day_element == 'Dark') then
equip(sets.Obi)
elseif spell.english == 'Wildfire' and (world.weather_element == 'Fire' or world.day_element == 'Fire') then
equip(sets.Obi)
elseif spell.type == 'CorsairShot' and (spell.element == world.weather_element or spell.element == world.day_element) then
equip(sets.Obi)
end
end
end

-- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
function job_aftercast(spell, action, spellMap, eventArgs)
if spell.type == 'CorsairRoll' and not spell.interrupted then
display_roll_info(spell)
end
end

function job_status_change(new_status, old_status)
if new_status == 'Engaged' then
determine_haste_group()
end
end

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

-- Return a customized weaponskill mode to use for weaponskill sets.
-- Don't return anything if you're not overriding the default value.

-- Set eventArgs.handled to true if we don't want the automatic display to be run.

function job_update(cmdParams, eventArgs)
determine_haste_group()
end

function get_custom_wsmode(spell, spellMap, default_wsmode)
if buffactive['Transcendancy'] then
return 'Brew'
end
end


-- Called by the 'update' self-command, for common needs.
-- Set eventArgs.handled to true if we don't want automatic equipping of gear.
function job_update(cmdParams, eventArgs)
if newStatus == 'Engaged' and player.equipment.main == 'Chatoyant Staff' then
state.OffenseMode:set('Ranged')
end
end

-- Handle auto-targetting based on local setup.
function job_auto_change_target(spell, action, spellMap, eventArgs)
if spell.type == 'CorsairShot' then
if state.IgnoreTargetting.value == true then
state.IgnoreTargetting:reset()
eventArgs.handled = true
end

eventArgs.SelectNPCTargets = state.SelectShotTarget.value
end
end

-- Set eventArgs.handled to true if we don't want the automatic display to be run.
function display_current_job_state(eventArgs)
local msg = ''

msg = msg .. '[ Offense/Ranged: '..state.OffenseMode.current..'/'..state.RangedMode.current
msg = msg .. ' ][ WS: '..state.WeaponskillMode.current

if state.DefenseMode.value ~= 'None' then
msg = msg .. ' ][ Defense: ' .. state.DefenseMode.value .. state[state.DefenseMode.value .. 'DefenseMode'].value
end

if state.Kiting.value then
msg = msg .. ' ][ Kiting Mode: ON'
end

msg = msg .. ' ][ '..state.MainShot.current

if state.UseAltShot.value == true then
msg = msg .. '/'..state.AltShot.current
end

msg = msg .. ' ]'

add_to_chat(061, msg)

eventArgs.handled = true
end

-------------------------------------------------------------------------------------------------------------------
-- User self-commands.
-------------------------------------------------------------------------------------------------------------------

-- Called for custom player commands.
function job_self_command(cmdParams, eventArgs)
if cmdParams[1] == 'Shot' then
if cmdParams[2] == 't' then
state.IgnoreTargetting:set()
end

local doShot = ''
if state.UseAltShot.value == true then
doShot = state[state.CurrentShot.current..'Shot'].current
state.CurrentShot:cycle()
else
doShot = state.MainShot.current
end	

send_command('@input /ja "'..doShot..'" <t>')
end
end


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

function determine_haste_group()
-- We have three groups of DW in gear: Charis body, Charis neck + DW earrings, and Patentia Sash.

-- For high haste, we want to be able to drop one of the 10% groups (body, preferably).
-- High haste buffs:
-- 2x Marches + Haste
-- 2x Marches + Haste Samba
-- 1x March + Haste + Haste Samba
-- Embrava + any other haste buff

-- For max haste, we probably need to consider dropping all DW gear.
-- Max haste buffs:
-- Embrava + Haste/March + Haste Samba
-- 2x March + Haste + Haste Samba

classes.CustomMeleeGroups:clear()

if buffactive.embrava and (buffactive.haste or buffactive.march) then
classes.CustomMeleeGroups:append('MaxHaste')
elseif buffactive.march == 2 and buffactive.haste then
classes.CustomMeleeGroups:append('MaxHaste')
elseif buffactive.embrava and (buffactive.haste or buffactive.march) then
classes.CustomMeleeGroups:append('HighHaste')
elseif buffactive.march == 1 and buffactive.haste then
classes.CustomMeleeGroups:append('HighHaste')
elseif buffactive.march == 2 and buffactive.haste then
classes.CustomMeleeGroups:append('HighHaste')
end
end

function define_roll_values()
rolls = {
["Corsair's Roll"] = {lucky=5, unlucky=9, bonus="Experience Points"},
["Ninja Roll"]	= {lucky=4, unlucky=8, bonus="Evasion"},
["Hunter's Roll"]	= {lucky=4, unlucky=8, bonus="Accuracy"},
["Chaos Roll"]	= {lucky=4, unlucky=8, bonus="Attack"},
["Magus's Roll"]	= {lucky=2, unlucky=6, bonus="Magic Defense"},
["Healer's Roll"]	= {lucky=3, unlucky=7, bonus="Cure Potency Received"},
["Drachen Roll"]	= {lucky=4, unlucky=8, bonus="Pet Magic Accuracy/Attack"},
["Choral Roll"]	= {lucky=2, unlucky=6, bonus="Spell Interruption Rate"},
["Monk's Roll"]	= {lucky=3, unlucky=7, bonus="Subtle Blow"},
["Beast Roll"]	= {lucky=4, unlucky=8, bonus="Pet Attack"},
["Samurai Roll"]	= {lucky=2, unlucky=6, bonus="Store TP"},
["Evoker's Roll"]	= {lucky=5, unlucky=9, bonus="Refresh"},
["Rogue's Roll"]	= {lucky=5, unlucky=9, bonus="Critical Hit Rate"},
["Warlock's Roll"] = {lucky=4, unlucky=8, bonus="Magic Accuracy"},
["Fighter's Roll"] = {lucky=5, unlucky=9, bonus="Double Attack Rate"},
["Puppet Roll"]	= {lucky=3, unlucky=7, bonus="Pet Magic Attack/Accuracy"},
["Gallant's Roll"] = {lucky=3, unlucky=7, bonus="Defense"},
["Wizard's Roll"]	= {lucky=5, unlucky=9, bonus="Magic Attack"},
["Dancer's Roll"]	= {lucky=3, unlucky=7, bonus="Regen"},
["Scholar's Roll"] = {lucky=2, unlucky=6, bonus="Conserve MP"},
["Naturalist's Roll"]	= {lucky=3, unlucky=7, bonus="Enh. Magic Duration"},
["Runeist's Roll"]	= {lucky=4, unlucky=8, bonus="Magic Evasion"},
["Bolter's Roll"]	= {lucky=3, unlucky=9, bonus="Movement Speed"},
["Caster's Roll"]	= {lucky=2, unlucky=7, bonus="Fast Cast"},
["Courser's Roll"] = {lucky=3, unlucky=9, bonus="Snapshot"},
["Blitzer's Roll"] = {lucky=4, unlucky=9, bonus="Attack Delay"},
["Tactician's Roll"] = {lucky=5, unlucky=8, bonus="Regain"},
["Allies's Roll"]	= {lucky=3, unlucky=10, bonus="Skillchain Damage"},
["Miser's Roll"]	= {lucky=5, unlucky=7, bonus="Save TP"},
["Companion's Roll"] = {lucky=2, unlucky=10, bonus="Pet Regain and Regen"},
["Avenger's Roll"] = {lucky=4, unlucky=8, bonus="Counter Rate"},
}
end

function display_roll_info(spell)
rollinfo = rolls[spell.english]
local rollsize = (state.LuzafRing.value and 'Large') or 'Small'

if rollinfo then
add_to_chat(104, '[ Lucky: '..tostring(rollinfo.lucky)..' / Unlucky: '..tostring(rollinfo.unlucky)..' ] '..spell.english..': '..rollinfo.bonus..' ('..rollsize..') ')
end
end


-- Determine whether we have sufficient ammo for the action being attempted.
function do_bullet_checks(spell, spellMap, eventArgs)
local bullet_name
local bullet_min_count = 1

if spell.type == 'WeaponSkill' then
if spell.skill == "Marksmanship" then
if spell.element == 'None' then
-- physical weaponskills
bullet_name = gear.WSbullet
else
-- magical weaponskills
bullet_name = gear.MAbullet
end
else
-- Ignore non-ranged weaponskills
return
end
elseif spell.type == 'CorsairShot' then
bullet_name = gear.QDbullet
elseif spell.action_type == 'Ranged Attack' then
bullet_name = gear.RAbullet
if buffactive['Triple Shot'] then
bullet_min_count = 3
end
end

local available_bullets = player.inventory[bullet_name] or player.wardrobe[bullet_name]

-- If no ammo is available, give appropriate warning and end.
if not available_bullets then
if spell.type == 'CorsairShot' and player.equipment.ammo ~= 'empty' then
add_to_chat(104, 'No Quick Draw ammo left. Using what\'s currently equipped ('..player.equipment.ammo..').')
return
elseif spell.type == 'WeaponSkill' and player.equipment.ammo == gear.RAbullet then
--	add_to_chat(104, 'No weaponskill ammo left. Using what\'s currently equipped (standard ranged bullets: '..player.equipment.ammo..').')
return
else
add_to_chat(104, 'No ammo ('..tostring(bullet_name)..') available for that action.')
eventArgs.cancel = true
return
end
end

-- Don't allow shooting or weaponskilling with ammo reserved for quick draw.
if spell.type ~= 'CorsairShot' and bullet_name == gear.QDbullet and available_bullets.count <= bullet_min_count then
add_to_chat(104, 'No ammo will be left for Quick Draw. Cancelling.')
eventArgs.cancel = true
return
end

-- Low ammo warning.
if spell.type ~= 'CorsairShot' and state.warned.value == false
and available_bullets.count > 1 and available_bullets.count <= options.ammo_warning_limit then
local msg = '***** LOW AMMO WARNING: '..bullet_name..' *****'
--local border = string.repeat("*", #msg)
local border = ""
for i = 1, #msg do
border = border .. "*"
end

add_to_chat(104, border)
add_to_chat(104, msg)
add_to_chat(104, border)

state.warned:set()
elseif available_bullets.count > options.ammo_warning_limit and state.warned then
state.warned:reset()
end
end

-- Select default macro book on initial load or subjob change.
function select_default_macro_book()
if player.sub_job == 'DNC' then
set_macro_page(1, 10)
else
set_macro_page(1, 10)
end
end


Is this what you are looking for? Added self-command and brief explanation where you have the others at the beginning of the file
[+]
 Odin.Psycooo
Offline
Serveur: Odin
Game: FFXI
user: Psycooo
Posts: 42
By Odin.Psycooo 2016-10-26 12:43:51
Link | Citer | R
 
Odin.Lygre said: »
Odin.Psycooo said: »
Ok, I am back with more questions....
I managed to add/define sets based of the amount of magical haste I have. So now if I have no haste it equips one set of gear, if I get haste 1 or haste 2 it equips based on value of haste all the way up to capped haste.
What I would like additionally is for it to auto equip the single wield gearset in the event I don't have a dual wield subjob, furthermore I would like a way to add in additional sets if I am using /dnc instead of my normal /nin, because the native DW traits are different I would need to add a whole bunch of rules and sets, the problem is I have NO FRIGGIN' IDEA how to do any of that. I literally stole all my haste defined rules from a thf lua and spent like 3 hours til I got it to work.

Edit: Ideally I would like to do this same thing for my terribly designed cor lua, that way I don't have to cycle through 14 sets
Code
-------------------------------------------------------------------------------------------------------------------
-- Setup functions for this job.  Generally should not be modified.
-------------------------------------------------------------------------------------------------------------------
 
-- Initialization function for this job file.
function get_sets()
	mote_include_version = 2
 
	-- Load and initialize the include file.
	include('Mote-Include.lua')
end
 
-- Setup vars that are user-independent.  state.Buff vars initialized here will automatically be tracked.
function job_setup()
	determine_haste_group()
	 
	state.Buff.Saboteur = buffactive.saboteur or false
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('Normal', 'Mid', 'Acc')
	state.HybridMode:options('Normal', 'PDT', 'Evasion')
	state.CastingMode:options('Normal', 'Resistant')
	state.IdleMode:options('Normal', 'PDT', 'MDT')
 
	select_default_macro_book()
	gear.CureStaff = {name=""}
	gear.CureFeet = {name=""}
	 
	state.MagicBurst = M(false, 'Magic Burst')
	state.CureHate = M(false, 'Cure Hate')
 
	Shields = S{'Genmei Shield','Culminus'}
	LowNukes = S{'Stone' , 'Aero' , 'Blizzard' , 'Fire' , 'Water' , 'Thunder' , 
				'Stone II' , 'Aero II' , 'Blizzard II' , 'Fire II' , 'Water II' , 'Thunder II',
				'Stonega' , 'Aeroga' , 'Blizzaga' , 'Firaga' , 'Waterga' , 'Thundaga',
				'Stonega II' , 'Aeroga II' , 'Blizzaga II' , 'Firaga II' , 'Waterga II' , 'Thundaga II'}
	MndEnfeebles = S{'Slow' , 'Silence' , 'Paralyze' , 'Addle' , 'Slow II' , 'Paralyze II' , 'Addle II'}
	IntEnfeebles = S{'Bind' , 'Break' , 'Gravity' , 'Poison' , 'Sleep' , 'Gravity II' , 'Poison II' , 'Sleep II'}

  
	send_command('bind !` gs c toggle MagicBurst')
	send_command('bind ^` gs c toggle CureHate')
 
	update_combat_form()
	determine_haste_group()
 
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['Chainspell'] = {body="Vitivation Tabard +1"}
	 
 
	-- Waltz set (chr and vit)
	sets.precast.Waltz = {}
 
	-- Don't need any special gear for Healing Waltz.
	sets.precast.Waltz['Healing Waltz'] = {}
 
	-- Fast cast sets for spells
 
	-- 80% Fast Cast (including trait) for all spells, plus 5% quick cast
	-- No other FC sets necessary.
	sets.precast.FC = {}
 
	sets.precast.FC.Impact = set_combine(sets.precast.FC, {head=empty,body="Twilight Cloak"})
 
	-- Weaponskill sets
	-- Default set for any weaponskill that isn't any more specifically defined
	sets.precast.WS = {}
 
	sets.precast.WS['Circle Blade'] = set_combine(sets.precast.WS, {})
 
	sets.precast.WS['Sanguine Blade'] = set_combine(sets.precast.WS, {})
 
	sets.precast.WS['Requiescat'] = {}
 
	sets.precast.WS['Aeolian Edge'] = set_combine(sets.precast.WS, {})
 
	sets.precast.WS['Savage Blade'] = {}
 
	sets.precast.WS['Chant du Cygne'] = {}
 
	sets.precast.WS['True Strike'] = {}
 
	sets.precast.WS['Exenterator'] = {}
 
	sets.precast.WS['Evisceration'] = {}
 
	sets.precast.WS['Death Blossom'] = {}
   
	-- Midcast Sets
	sets.midcast.Cure = {}
   
	sets.midcast.Curaga = sets.midcast.Cure
  
	sets.midcast.CureWeather = {}
  
	sets.midcast.CureSelf = {}
   
	sets.midcast.CureMelee = {}
   
	sets.midcast['Enhancing Magic'] = {} 
   
	sets.midcast['Enhancing Magic'].Temper = {}
	 
	sets.midcast['Enhancing Magic'].RegenSelf = {}
   
	sets.midcast['Enhancing Magic'].RefreshSelf = {}
   
	sets.midcast['Enhancing Magic'].HasteSelf = {}
	 
	sets.midcast['Enhancing Magic'].EnSpells = set_combine(sets.midcast['Enhancing Magic'],{})
   
	sets.midcast['Enhancing Magic'].GainSpells = set_combine(sets.midcast['Enhancing Magic'],{})
	 
	sets.midcast['Enhancing Magic'].BarSpells = set_combine(sets.midcast['Enhancing Magic'],{})
	  
	sets.buff.ComposureOther = {head="Lethargy Chappel +1",body="Lethargy Sayon +1",
		legs="Lethargy Fuseau +1",feet="Lethargy Houseaux +1"}
   
	sets.midcast.Protect = {}
	 
	sets.midcast.Shell = sets.midcast.Protect
   
	sets.midcast['Enhancing Magic'].Phalanx = {}
   
	sets.midcast.Cursna = {}
   
	sets.midcast.Stoneskin = {}
   
	sets.midcast['Enfeebling Magic'] = {}
	 
	sets.midcast.MndEnfeebles = {}
 
	sets.midcast.IntEnfeebles = {}
 
	 
	sets.midcast.Blind = {}
	 
	sets.midcast.ElementalEnfeeble = sets.midcast.IntEnfeebles
	 
	sets.midcast.Distract = {}
 
	sets.midcast.Frazzle = {}
   
	sets.midcast['Distract II'] = sets.midcast.Distract
	sets.midcast['Distract III'] = sets.midcast.Distract
 
	sets.midcast['Frazzle II'] = {}
	sets.midcast['Frazzle III'] = sets.midcast.Frazzle
 
   
	sets.midcast['Dia III'] = set_combine(sets.midcast['Enfeebling Magic'], {head="Vitivation Chapeau +1"})
	sets.midcast['Slow II'] = set_combine(sets.midcast['Enfeebling Magic'], {head="Vitivation Chapeau +1"})
	 
	sets.Lunge = {}
 
	sets.Convert = {main="Murgleis"}
	 
	sets.midcast['Elemental Magic'] ={}
	   
	 
	sets.midcast['Elemental Magic']['Low'] = {}
	   
	sets.midcast.Impact = set_combine(sets.midcast['Elemental Magic'], {head=empty,body="Twilight Cloak"})
   
	sets.midcast['Stun'] = {}
   
	sets.midcast.Drain = {}
		   
	sets.midcast.Aspir = sets.midcast.Drain
			 
	-- Sets to return to when not performing an action.
   
	-- Resting sets
	sets.resting = {}
   
	-- Idle sets
	sets.idle = {}
   
	sets.idle.Town = {}
   
	sets.idle.Weak = {}
   
	-- Defense sets
	sets.defense.PDT = {}
   
	sets.defense.MDT = {}
   
	sets.Kiting = {}
   
	sets.latent_refresh = {}
   
	-- 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 = {}
	 
	sets.engaged.Mid = {}
 
	sets.engaged.Acc = {}   
			  
	sets.engaged.Evasion = sets.engaged
	sets.engaged.Mid.Evasion = sets.engaged.Mid
	sets.engaged.Acc.Evasion = sets.engaged.Acc
	 
	sets.engaged.PDT = sets.defense.PDT
	sets.engaged.Mid.PDT = sets.defense.MDT
	sets.engaged.Acc.PDT = sets.defense.PDT
 
		 
	-- Haste 43%
	sets.engaged.Haste_43 = set_combine(sets.engaged, {})
	sets.engaged.Mid.Haste_43 = sets.engaged.Mid
	sets.engaged.Acc.Haste_43 = sets.engaged.Acc
	sets.engaged.Evasion.Haste_43 = sets.engaged.Haste_43
	sets.engaged.PDT.Haste_43 = sets.defense.PDT
 
	-- 40
	sets.engaged.Haste_40 = set_combine(sets.engaged.Haste_43, {})
	sets.engaged.Mid.Haste_40 = sets.engaged.Mid
	sets.engaged.Acc.Haste_40 = sets.engaged.Acc
	sets.engaged.Evasion.Haste_40 = sets.engaged.Haste_40
	sets.engaged.PDT.Haste_40 = sets.defense.PDT
 
	-- 30
	sets.engaged.Haste_30 = sets.engaged
	sets.engaged.Mid.Haste_30 = sets.engaged.Mid
	sets.engaged.Acc.Haste_30 = sets.engaged.Acc
	sets.engaged.Evasion.Haste_30 = sets.engaged
	sets.engaged.PDT.Haste_30 = sets.defense.PDT
 
		-- 25
	sets.engaged.Haste_25 = set_combine(sets.engaged.Haste_30, {})
	sets.engaged.Acc.Haste_25 = sets.engaged.Acc
	sets.engaged.Mid.Haste_25 = sets.engaged.Mid
	sets.engaged.Evasion.Haste_25 = sets.engaged
	sets.engaged.PDT.Haste_25 = sets.defense.PDT
 
	 -- DW nin sub melee group
	sets.engaged.DW_nin = {}
	 
	sets.engaged.DW_nin.Mid = {}
 
	sets.engaged.DW_nin.Acc = {}   
			  
	sets.engaged.DW_nin.Evasion = sets.engaged.DW_nin
	sets.engaged.DW_nin.Mid.Evasion = sets.engaged.DW_nin.Mid
	sets.engaged.DW_nin.Acc.Evasion = sets.engaged.DW_nin.Acc
	 
	sets.engaged.DW_nin.PDT = sets.defense.PDT
	sets.engaged.DW_nin.Mid.PDT = sets.defense.MDT
	sets.engaged.DW_nin.Acc.PDT = sets.defense.PDT
 
		 
	-- Haste 43%
	sets.engaged.DW_nin.Haste_43 = set_combine(sets.engaged.DW_nin, {})
	sets.engaged.DW_nin.Mid.Haste_43 = sets.engaged.DW_nin.Mid
	sets.engaged.DW_nin.Acc.Haste_43 = sets.engaged.DW_nin.Acc
	sets.engaged.DW_nin.Evasion.Haste_43 = sets.engaged.DW_nin.Haste_43
	sets.engaged.DW_nin.PDT.Haste_43 = sets.defense.PDT
 
	-- 40
	sets.engaged.DW_nin.Haste_40 = set_combine(sets.engaged.DW_nin.Haste_43, {})
	sets.engaged.DW_nin.Mid.Haste_40 = sets.engaged.DW_nin.Mid
	sets.engaged.DW_nin.Acc.Haste_40 = sets.engaged.DW_nin.Acc
	sets.engaged.DW_nin.Evasion.Haste_40 = sets.engaged.DW_nin.Haste_40
	sets.engaged.DW_nin.PDT.Haste_40 = sets.defense.PDT
 
	-- 30
	sets.engaged.DW_nin.Haste_30 = sets.engaged.DW_nin
	sets.engaged.DW_nin.Mid.Haste_30 = sets.engaged.DW_nin.Mid
	sets.engaged.DW_nin.Acc.Haste_30 = sets.engaged.DW_nin.Acc
	sets.engaged.DW_nin.Evasion.Haste_30 = sets.engaged.DW_nin
	sets.engaged.DW_nin.PDT.Haste_30 = sets.defense.PDT
 
		-- 25
	sets.engaged.DW_nin.Haste_25 = set_combine(sets.engaged.DW_nin.Haste_30, {})
	sets.engaged.DW_nin.Acc.Haste_25 = sets.engaged.DW_nin.Acc
	sets.engaged.DW_nin.Mid.Haste_25 = sets.engaged.DW_nin.Mid
	sets.engaged.DW_nin.Evasion.Haste_25 = sets.engaged.DW_nin
	sets.engaged.DW_nin.PDT.Haste_25 = sets.defense.PDT

	 -- DW dnc sub melee group
	sets.engaged.DW_dnc = {}
	 
	sets.engaged.DW_dnc.Mid = {}
 
	sets.engaged.DW_dnc.Acc = {}   
			  
	sets.engaged.DW_dnc.Evasion = sets.engaged.DW_dnc
	sets.engaged.DW_dnc.Mid.Evasion = sets.engaged.DW_dnc.Mid
	sets.engaged.DW_dnc.Acc.Evasion = sets.engaged.DW_dnc.Acc
	 
	sets.engaged.DW_dnc.PDT = sets.defense.PDT
	sets.engaged.DW_dnc.Mid.PDT = sets.defense.MDT
	sets.engaged.DW_dnc.Acc.PDT = sets.defense.PDT
 
		 
	-- Haste 43%
	sets.engaged.DW_dnc.Haste_43 = set_combine(sets.engaged.DW_dnc, {})
	sets.engaged.DW_dnc.Mid.Haste_43 = sets.engaged.DW_dnc.Mid
	sets.engaged.DW_dnc.Acc.Haste_43 = sets.engaged.DW_dnc.Acc
	sets.engaged.DW_dnc.Evasion.Haste_43 = sets.engaged.DW_dnc.Haste_43
	sets.engaged.DW_dnc.PDT.Haste_43 = sets.defense.PDT
 
	-- 40
	sets.engaged.DW_dnc.Haste_40 = set_combine(sets.engaged.DW_dnc.Haste_43, {})
	sets.engaged.DW_dnc.Mid.Haste_40 = sets.engaged.DW_dnc.Mid
	sets.engaged.DW_dnc.Acc.Haste_40 = sets.engaged.DW_dnc.Acc
	sets.engaged.DW_dnc.Evasion.Haste_40 = sets.engaged.DW_dnc.Haste_40
	sets.engaged.DW_dnc.PDT.Haste_40 = sets.defense.PDT
 
	-- 30
	sets.engaged.DW_dnc.Haste_30 = sets.engaged.DW_dnc
	sets.engaged.DW_dnc.Mid.Haste_30 = sets.engaged.DW_dnc.Mid
	sets.engaged.DW_dnc.Acc.Haste_30 = sets.engaged.DW_dnc.Acc
	sets.engaged.DW_dnc.Evasion.Haste_30 = sets.engaged.DW_dnc
	sets.engaged.DW_dnc.PDT.Haste_30 = sets.defense.PDT
 
		-- 25
	sets.engaged.DW_dnc.Haste_25 = set_combine(sets.engaged.DW_dnc.Haste_30, {})
	sets.engaged.DW_dnc.Acc.Haste_25 = sets.engaged.DW_dnc.Acc
	sets.engaged.DW_dnc.Mid.Haste_25 = sets.engaged.DW_dnc.Mid
	sets.engaged.DW_dnc.Evasion.Haste_25 = sets.engaged.DW_dnc
	sets.engaged.DW_dnc.PDT.Haste_25 = sets.defense.PDT
 
 
	
	sets.magic_burst = {}
	 
	sets.cure_hate = {}
		 
	sets.Enmity = {}
		 
	-- Sets for special buff conditions on spells.
	sets.buff.Saboteur = {hands="Lethargy Gantherots +1"}
end
 
 
			 
			 
-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for standard casting events.
-------------------------------------------------------------------------------------------------------------------
  
function job_precast(spell, action, spellMap, eventArgs)
	if spell.skill == 'Healing Magic' and spellMap ~= 'StatusRemoval' then
		gear.CureFeet.name = "Vanya Clogs"
		if player.status == 'Engaged' then
			gear.default.obi_back = { name="Sucellos's Cape", augments={'MND+20','Mag. Acc+20 /Mag. Dmg.+20','Mag. Acc.+10','"Cure" potency +10%',}}
			if spell.target.type == 'SELF' then
				gear.CureFeet.name = "Medium's Sabots"
			else
				gear.CureFeet.name = "Vanya Clogs"
			end
		else
			gear.default.obi_back = { name="Sucellos's Cape", augments={'MND+20','Mag. Acc+20 /Mag. Dmg.+20','Mag. Acc.+10','"Cure" potency +10%',}}
		end
		if spell.target.type == 'SELF' then
			gear.default.obi_waist = "Chuq'aba Belt"
		else
			gear.default.obi_waist = "Salire belt"
		end
		if world.weather_element == 'Light' then
			gear.CureStaff.name = "Chatoyant Staff"
		else
			gear.CureStaff.name = "Serenity"
		end
		else
		gear.default.obi_waist = "Salire belt"
		gear.default.obi_back = { name="Sucellos's Cape", augments={'MND+20','Mag. Acc+20 /Mag. Dmg.+20','Mag. Acc.+10','"Cure" potency +10%',}}
	end
		if spell.name == 'Lunge' or spell.name == 'Swipe' then
			equip(sets.Lunge)
			end
		if spell.name == 'Vallation' then
			equip(sets.Enmity)
		end  
		if spell.name == 'Pflug' then
			equip(sets.Enmity)
		end
		if spell.name == 'Warcry' 
		or spell.name == 'Swordplay' or spell.name == 'Rayke' or spell.name == 'Meditate' or spell.name == 'Provoke' then   
			equip(sets.Enmity)
		end
		--prevents casting Utsusemi if you already have 3 or more shadows
		if spell.name == 'Utsusemi: Ichi' and ShadowType == 'Ni' and (buffactive['Copy Image (3)'] or buffactive['Copy Image (4+)']) then
			cancel_spell()
		end
		if buffactive['terror'] or buffactive['petrification'] or buffactive['stun'] or buffactive['sleep'] then
			if TP_ind == 4 then
				equip(sets.defense.MDT) else
				equip(sets.defense.PDT)
			end
		end
		if spell.name == 'Convert' then
			equip(sets.Convert)
		end
	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>')
	end 
end      
 
 
  
-- Run after the default midcast() is done.
-- eventArgs is the same one used in job_midcast, in case information needs to be persisted.
function job_post_midcast(spell, action, spellMap, eventArgs)
	if spell.skill == 'Enfeebling Magic' and state.Buff.Saboteur then
		equip(sets.buff.Saboteur)
	elseif spell.skill == 'Enhancing Magic' and not spell.english == 'Stoneskin' then
		equip(sets.midcast.EnhancingDuration)
		if buffactive.composure and spell.target.type == 'PLAYER' then
			equip(sets.buff.ComposureOther)
		end
	elseif spellMap == 'Cure' then
		if spell.target.type == 'SELF' then
			equip(sets.midcast.CureSelf)
		end
		if state.CureHate.value then
			equip(sets.cure_hate)
		end
		if world.weather_element == 'Light' then
			equip(sets.midcast.CureWeather)
		end
	elseif spell.skill == 'Elemental Magic' then
		if state.MagicBurst.value then
			equip(sets.magic_burst)
		end
		if spell.element == world.day_element or spell.element == world.weather_element then
			equip({waist="Hachirin-no-Obi"})
		end
	elseif spell.skill == "Ninjutsu" then
			equip(sets.midcast.Recast)
			if spell.name == 'Utsusemi: Ichi' and ShadowType == 'Ni' then
				if buffactive['Copy Image'] then
					windower.ffxi.cancel_buff(66)
				elseif buffactive['Copy Image (2)'] then
					windower.ffxi.cancel_buff(444)
				elseif buffactive['Copy Image (3)'] then
					windower.ffxi.cancel_buff(445)
				elseif buffactive['Copy Image (4+)'] then
					windower.ffxi.cancel_buff(446)
			end
		elseif spell.name == 'Monomi: Ichi' and buffactive.Sneak and spell.target.type == 'SELF' then
			windower.ffxi.cancel_buff(71)
		end
	end
	if spell.name == 'Foil' or spell.name == 'Flash' or spell.name == 'Blank Gaze'
		or spell.name == 'Geist Wall' or spell.name == 'Poison Breath' or spell.name == 'Jettatura'
		or spell.name == 'Cocoon' or spell.name == 'Soporific' or spell.name == 'Sheep Song' 
		or spell.name == 'Refueling' then 
		equip(sets.Enmity)
	end
end
	 
	 
 
function job_get_spell_map(spell, default_spell_map)
	if spell.action_type == 'Magic' then
		if spell.skill == 'Enhancing Magic' then
			if spell.english:startswith('En') then
				return 'EnSpells'
			elseif spell.english:startswith('Gain') then
				return 'GainSpells'
			elseif spell.english:startswith('Phalanx') then
				return 'Phalanx'
			elseif spell.english:startswith('Bar') then
				return 'Bar'
			elseif spell.english:startswith('Temper') then
				return 'Temper'
			elseif spell.english:startswith('Haste') then
				if spell.target.type == 'SELF' then
				return 'HasteSelf'
				end
			elseif spell.english:startswith('Refresh') then
				if spell.target.type == 'SELF' then
				return 'RefreshSelf'
				end
			end
		elseif default_spell_map == 'Cure' or default_spell_map == 'Curaga' then
			if player.status == 'Engaged' then
				return "CureMelee"
			end
		end
		if spell.action_type == 'Magic' then
			if spell.skill == 'Enfeebling Magic' then
				if spell.type == 'WhiteMagic' then
					return 'MndEnfeebles'
				else
					return 'IntEnfeebles'
				end
			elseif spell.skill == 'Elemental Magic' then
				if LowNukes:contains(spell.name) then
					return 'Low'
				else
					return
				end
				 
			end
		end
	end
end
 
   
-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for non-casting events.
-------------------------------------------------------------------------------------------------------------------
   
-- Handle notifications of general user state change.
function job_state_change(stateField, newValue, oldValue)
	if stateField == 'Offense Mode' then
		if newValue == 'None' then
			enable('main','sub','range')
		else
			disable('main','sub','range')
		end
	end
end
   
   
	-------------------------------------------------------------------------------------------------------------------
	-- General hooks for change 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 we gain or lose any haste buffs, adjust which gear set we target.
		if S{'haste','march', 'madrigal','embrava','haste samba'}:contains(buff:lower()) then
			determine_haste_group()
			handle_equipping_gear(player.status)
		end
		if state.Buff[buff] ~= nil then
			state.Buff[buff] = gain
			if not midaction() then
				handle_equipping_gear(player.status)
			end
		end
	end
 
-------------------------------------------------------------------------------------------------------------------
-- User code that supplements standard library decisions.
-------------------------------------------------------------------------------------------------------------------
   
-- Modify the default idle set after it was constructed.
function customize_idle_set(idleSet)
	if player.mpp < 51 then
		idleSet = set_combine(idleSet, sets.latent_refresh)
	end
	return idleSet
end
   
-- function customize_melee_set(meleeSet)
--     if player.sub_job == 'DNC' or player.sub_job == 'NIN' then
--         meleeSet = set_combine(meleeSet, sets.engaged.DW)
--     end
--     return meleeSet
-- end 


function update_combat_form()
	-- Check for H2H or single-wielding
	if player.equipment.sub == 'empty' then
		state.CombatForm:reset()
	elseif Shields:contains(player.equipment.sub) then
		state.CombatForm:reset()
	else
		if player.sub_job == 'NIN' then
			state.CombatForm:set('DW_nin')
		elseif player.sub_job == 'DNC' then
			state.CombatForm:set('DW_dnc')
		end     
	end
end

function job_update(cmdParams, eventArgs)
	update_combat_form()
	determine_haste_group()
end

-- Set eventArgs.handled to true if we don't want the automatic display to be run.
function display_current_job_state(eventArgs)
	display_current_caster_state()
	eventArgs.handled = true
end
   
-------------------------------------------------------------------------------------------------------------------
-- Utility functions specific to this job.
-------------------------------------------------------------------------------------------------------------------
	function determine_haste_group()
 
		classes.CustomMeleeGroups:clear()
		-- assuming +4 for marches (ghorn has +5)
		-- Haste (white magic) 15%
		-- Haste Samba (Sub) 5%
		-- Haste (Merited DNC) 10% (never account for this)
		-- Victory March +0/+3/+4/+5    9.4/14%/15.6%/17.1% +0
		-- Advancing March +0/+3/+4/+5  6.3/10.9%/12.5%/14%  +0
		-- Embrava 30% with 500 enhancing skill
		-- Mighty Guard - 15%
		-- buffactive[580] = geo haste
		-- buffactive[33] = regular haste
		-- buffactive[604] = mighty guard
		-- state.HasteMode = toggle for when you know Haste II is being cast on you
		-- Hi = Haste II is being cast. This is clunky to use when both haste II and haste I are being cast
	   if ( ( (buffactive[33] or buffactive[580] or buffactive.embrava) and (buffactive.march or buffactive[604]) ) or
			 ( buffactive[33] and (buffactive[580] or buffactive.embrava) ) or
			 ( buffactive.march == 2 and buffactive[604] ) ) then
			add_to_chat(8, '-------------Haste 43%-------------')
			classes.CustomMeleeGroups:append('Haste_43')
		elseif buffactive.embrava and buffactive.haste then
			add_to_chat(8, '-------------Haste 40%-------------')
			classes.CustomMeleeGroups:append('Haste_40')
		elseif ( (buffactive[33] or buffactive.march == 2 or buffactive[580]) and buffactive['haste samba'] ) then
			add_to_chat(8, '-------------Haste 35%-------------')
			classes.CustomMeleeGroups:append('Haste_35')
		elseif ( ( buffactive[580] or buffactive[33] or buffactive.march == 2 ) or
				 ( buffactive.march == 1 and buffactive[604] ) ) then
			add_to_chat(8, '-------------Haste 30%-------------')
			classes.CustomMeleeGroups:append('Haste_30')
		elseif ( buffactive.march == 1 or buffactive[604] ) then
			add_to_chat(8, '-------------Haste 15%-------------')
			classes.CustomMeleeGroups:append('Haste_15')
		elseif ( buffactive[580] and ( buffactive.march or buffactive[33] or buffactive.embrava or buffactive[604]) ) or  -- geo haste + anything
		   ( buffactive.embrava and (buffactive.march or buffactive[33] or buffactive[604]) ) or  -- embrava + anything
		   ( buffactive.march == 2 and (buffactive[33] or buffactive[604]) ) or  -- two marches + anything
		   ( buffactive[33] and buffactive[604] and buffactive.march ) then -- haste + mighty guard + any marches
			add_to_chat(8, '-------------Max Haste Mode Enabled--------------')
			classes.CustomMeleeGroups:append('Haste_43')
		elseif ( (buffactive[604] or buffactive[33]) and buffactive['haste samba'] and buffactive.march == 1) or -- MG or haste + samba with 1 march
			   ( buffactive.march == 2 and buffactive['haste samba'] ) or
			   ( buffactive[580] and buffactive['haste samba'] ) then 
			add_to_chat(8, '-------------Haste 35%-------------')
			classes.CustomMeleeGroups:append('Haste_35')
		elseif ( buffactive.march == 2 ) or -- two marches from ghorn
			   ( (buffactive[33] or buffactive[604]) and buffactive.march == 1 ) or  -- MG or haste + 1 march
			   ( buffactive[580] ) or  -- geo haste
			   ( buffactive[33] and buffactive[604] ) then  -- haste with MG
			add_to_chat(8, '-------------Haste 30%-------------')
			classes.CustomMeleeGroups:append('Haste_30')
		elseif buffactive[33] or buffactive[604] or buffactive.march == 1 then
			add_to_chat(8, '-------------Haste 15%-------------')
			classes.CustomMeleeGroups:append('Haste_15')
		end
end
 
	 
 
-- Select default macro book on initial load or subjob change.
function select_default_macro_book()
	-- Default macro set/book
	if player.sub_job == 'DNC' then
		set_macro_page(2, 4)
	elseif player.sub_job == 'WHM' then
		set_macro_page(3, 4)
	elseif player.sub_job == 'NIN' then
		set_macro_page(10, 4)
	elseif player.sub_job == 'THF' then
		set_macro_page(4, 4)
	elseif player.sub_job == 'BLM' then
		set_macro_page(5, 4)
	else
		set_macro_page(1, 4)
	end
end


I added a list called 'Shields' under user_seup that you'll need to update with any shields you want gearswap to look for to automatically identify single-wielding. It will also identify single-wielding if your sub slot is empty.
You'll also need to continue/finish iterating hybrid sets over the different combat forms (DW_nin and DW_dnc, e.g. sets.engaged.DW_nin.Acc.PDT.Haste_43), I just didn't feel like doing it all.


Holy crap thank you, hopefully one day I will have everything I want in this lua and not bother you with it anymore.


edit: Just tried and it wouldn't swap the sets based on haste, I know I need to adjust this code here for that, but when I thought about it I realized I would need a subjob variable in there as well otherwise I would just cycle one of the sets. Thank you for any help in advace.

Also I realized it doesn't recognize the difference in haste 1 vs haste 2
Code
-------------------------------------------------------------------------------------------------------------------
-- Utility functions specific to this job.
-------------------------------------------------------------------------------------------------------------------
    function determine_haste_group()
  
        classes.CustomMeleeGroups:clear()
        -- assuming +4 for marches (ghorn has +5)
        -- Haste (white magic) 15%
        -- Haste Samba (Sub) 5%
        -- Haste (Merited DNC) 10% (never account for this)
        -- Victory March +0/+3/+4/+5    9.4/14%/15.6%/17.1% +0
        -- Advancing March +0/+3/+4/+5  6.3/10.9%/12.5%/14%  +0
        -- Embrava 30% with 500 enhancing skill
        -- Mighty Guard - 15%
        -- buffactive[580] = geo haste
        -- buffactive[33] = regular haste
        -- buffactive[604] = mighty guard
        -- state.HasteMode = toggle for when you know Haste II is being cast on you
        -- Hi = Haste II is being cast. This is clunky to use when both haste II and haste I are being cast
       if ( ( (buffactive[33] or buffactive[580] or buffactive.embrava) and (buffactive.march or buffactive[604]) ) or
             ( buffactive[33] and (buffactive[580] or buffactive.embrava) ) or
             ( buffactive.march == 2 and buffactive[604] ) ) then
            add_to_chat(8, '-------------Haste 43%-------------')
            classes.CustomMeleeGroups:append('Haste_43')
        elseif buffactive.embrava and buffactive.haste then
            add_to_chat(8, '-------------Haste 40%-------------')
            classes.CustomMeleeGroups:append('Haste_40')
        elseif ( (buffactive[33] or buffactive.march == 2 or buffactive[580]) and buffactive['haste samba'] ) then
            add_to_chat(8, '-------------Haste 35%-------------')
            classes.CustomMeleeGroups:append('Haste_35')
        elseif ( ( buffactive[580] or buffactive[33] or buffactive.march == 2 ) or
                 ( buffactive.march == 1 and buffactive[604] ) ) then
            add_to_chat(8, '-------------Haste 30%-------------')
            classes.CustomMeleeGroups:append('Haste_30')
        elseif ( buffactive.march == 1 or buffactive[604] ) then
            add_to_chat(8, '-------------Haste 15%-------------')
            classes.CustomMeleeGroups:append('Haste_15')
        elseif ( buffactive[580] and ( buffactive.march or buffactive[33] or buffactive.embrava or buffactive[604]) ) or  -- geo haste + anything
           ( buffactive.embrava and (buffactive.march or buffactive[33] or buffactive[604]) ) or  -- embrava + anything
           ( buffactive.march == 2 and (buffactive[33] or buffactive[604]) ) or  -- two marches + anything
           ( buffactive[33] and buffactive[604] and buffactive.march ) then -- haste + mighty guard + any marches
            add_to_chat(8, '-------------Max Haste Mode Enabled--------------')
            classes.CustomMeleeGroups:append('Haste_43')
        elseif ( (buffactive[604] or buffactive[33]) and buffactive['haste samba'] and buffactive.march == 1) or -- MG or haste + samba with 1 march
               ( buffactive.march == 2 and buffactive['haste samba'] ) or
               ( buffactive[580] and buffactive['haste samba'] ) then 
            add_to_chat(8, '-------------Haste 35%-------------')
            classes.CustomMeleeGroups:append('Haste_35')
        elseif ( buffactive.march == 2 ) or -- two marches from ghorn
               ( (buffactive[33] or buffactive[604]) and buffactive.march == 1 ) or  -- MG or haste + 1 march
               ( buffactive[580] ) or  -- geo haste
               ( buffactive[33] and buffactive[604] ) then  -- haste with MG
            add_to_chat(8, '-------------Haste 30%-------------')
            classes.CustomMeleeGroups:append('Haste_30')
        elseif buffactive[33] or buffactive[604] or buffactive.march == 1 then
            add_to_chat(8, '-------------Haste 15%-------------')
            classes.CustomMeleeGroups:append('Haste_15')
        end
end
 Shiva.Berzerk
Offline
Serveur: Shiva
Game: FFXI
user: Berzerk06
Posts: 357
By Shiva.Berzerk 2016-10-27 04:35:18
Link | Citer | R
 
Currently have a BLU gs that doesn't auto-switch macro books/pages, so was going to try the kinematics lua since it already has it built in, but it's not switching to engaged set when i go to attack something. Have tried looking at other luas to add macro functionality to the other GS or to add an auto-equip engaged to the kinematics one but no luck.
Code
-------------------------------------------------------------------------------------------------------------------
-- Setup functions for this job.  Generally should not be modified.
-------------------------------------------------------------------------------------------------------------------

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


-- Setup vars that are user-independent.  state.Buff vars initialized here will automatically be tracked.
function job_setup()
    state.Buff['Burst Affinity'] = buffactive['Burst Affinity'] or false
    state.Buff['Chain Affinity'] = buffactive['Chain Affinity'] or false
    state.Buff.Convergence = buffactive.Convergence or false
    state.Buff.Diffusion = buffactive.Diffusion or false
    state.Buff.Efflux = buffactive.Efflux or false
    
    state.Buff['Unbridled Learning'] = buffactive['Unbridled Learning'] or false


    blue_magic_maps = {}
    
    -- Mappings for gear sets to use for various blue magic spells.
    -- While Str isn't listed for each, it's generally assumed as being at least
    -- moderately signficant, even for spells with other mods.
    
    -- Physical Spells --
    
    -- Physical spells with no particular (or known) stat mods
    blue_magic_maps.Physical = S{
        'Bilgestorm'
    }

    -- Spells with heavy accuracy penalties, that need to prioritize accuracy first.
    blue_magic_maps.PhysicalAcc = S{
        'Heavy Strike',
    }

    -- Physical spells with Str stat mod
    blue_magic_maps.PhysicalStr = S{
        'Battle Dance','Bloodrake','Death Scissors','Dimensional Death',
        'Empty Thrash','Quadrastrike','Sinker Drill','Spinal Cleave',
        'Uppercut','Vertical Cleave'
    }
        
    -- Physical spells with Dex stat mod
    blue_magic_maps.PhysicalDex = S{
        'Amorphic Spikes','Asuran Claws','Barbed Crescent','Claw Cyclone','Disseverment',
        'Foot Kick','Frenetic Rip','Goblin Rush','Hysteric Barrage','Paralyzing Triad',
        'Seedspray','Sickle Slash','Smite of Rage','Terror Touch','Thrashing Assault',
        'Vanity Dive'
    }
        
    -- Physical spells with Vit stat mod
    blue_magic_maps.PhysicalVit = S{
        'Body Slam','Cannonball','Delta Thrust','Glutinous Dart','Grand Slam',
        'Power Attack','Quad. Continuum','Sprout Smack','Sub-zero Smash'
    }
        
    -- Physical spells with Agi stat mod
    blue_magic_maps.PhysicalAgi = S{
        'Benthic Typhoon','Feather Storm','Helldive','Hydro Shot','Jet Stream',
        'Pinecone Bomb','Spiral Spin','Wild Oats'
    }

    -- Physical spells with Int stat mod
    blue_magic_maps.PhysicalInt = S{
        'Mandibular Bite','Queasyshroom'
    }

    -- Physical spells with Mnd stat mod
    blue_magic_maps.PhysicalMnd = S{
        'Ram Charge','Screwdriver','Tourbillion'
    }

    -- Physical spells with Chr stat mod
    blue_magic_maps.PhysicalChr = S{
        'Bludgeon'
    }

    -- Physical spells with HP stat mod
    blue_magic_maps.PhysicalHP = S{
        'Final Sting'
    }

    -- Magical Spells --

    -- Magical spells with the typical Int mod
    blue_magic_maps.Magical = S{
        'Blastbomb','Blazing Bound','Bomb Toss','Cursed Sphere','Dark Orb','Death Ray',
        'Diffusion Ray','Droning Whirlwind','Embalming Earth','Firespit','Foul Waters',
        'Ice Break','Leafstorm','Maelstrom','Rail Cannon','Regurgitation','Rending Deluge',
        'Retinal Glare','Subduction','Tem. Upheaval','Water Bomb'
    }

    -- Magical spells with a primary Mnd mod
    blue_magic_maps.MagicalMnd = S{
        'Acrid Stream','Evryone. Grudge','Magic Hammer','Mind Blast'
    }

    -- Magical spells with a primary Chr mod
    blue_magic_maps.MagicalChr = S{
        'Eyes On Me','Mysterious Light'
    }

    -- Magical spells with a Vit stat mod (on top of Int)
    blue_magic_maps.MagicalVit = S{
        'Thermal Pulse'
    }

    -- Magical spells with a Dex stat mod (on top of Int)
    blue_magic_maps.MagicalDex = S{
        'Charged Whisker','Gates of Hades'
    }
            
    -- Magical spells (generally debuffs) that we want to focus on magic accuracy over damage.
    -- Add Int for damage where available, though.
    blue_magic_maps.MagicAccuracy = S{
        '1000 Needles','Absolute Terror','Actinic Burst','Auroral Drape','Awful Eye',
        'Blank Gaze','Blistering Roar','Blood Drain','Blood Saber','Chaotic Eye',
        'Cimicine Discharge','Cold Wave','Corrosive Ooze','Demoralizing Roar','Digest',
        'Dream Flower','Enervation','Feather Tickle','Filamented Hold','Frightful Roar',
        'Geist Wall','Hecatomb Wave','Infrasonics','Jettatura','Light of Penance',
        'Lowing','Mind Blast','Mortal Ray','MP Drainkiss','Osmosis','Reaving Wind',
        'Sandspin','Sandspray','Sheep Song','Soporific','Sound Blast','Stinking Gas',
        'Sub-zero Smash','Venom Shell','Voracious Trunk','Yawn'
    }
        
    -- Breath-based spells
    blue_magic_maps.Breath = S{
        'Bad Breath','Flying Hip Press','Frost Breath','Heat Breath',
        'Hecatomb Wave','Magnetite Cloud','Poison Breath','Radiant Breath','Self-Destruct',
        'Thunder Breath','Vapor Spray','Wind Breath'
    }

    -- Stun spells
    blue_magic_maps.Stun = S{
        'Blitzstrahl','Frypan','Head Butt','Sudden Lunge','Tail slap','Temporal Shift',
        'Thunderbolt','Whirl of Rage'
    }
        
    -- Healing spells
    blue_magic_maps.Healing = S{
        'Healing Breeze','Magic Fruit','Plenilune Embrace','Pollen','Restoral','White Wind',
        'Wild Carrot'
    }
    
    -- Buffs that depend on blue magic skill
    blue_magic_maps.SkillBasedBuff = S{
        'Barrier Tusk','Diamondhide','Magic Barrier','Metallic Body','Plasma Charge',
        'Pyric Bulwark','Reactor Cool',
    }

    -- Other general buffs
    blue_magic_maps.Buff = S{
        'Amplification','Animating Wail','Battery Charge','Carcharian Verve','Cocoon',
        'Erratic Flutter','Exuviation','Fantod','Feather Barrier','Harden Shell',
        'Memento Mori','Nat. Meditation','Occultation','Orcish Counterstance','Refueling',
        'Regeneration','Saline Coat','Triumphant Roar','Warm-Up','Winds of Promyvion',
        'Zephyr Mantle'
    }
    
    
    -- Spells that require Unbridled Learning to cast.
    unbridled_spells = S{
        'Absolute Terror','Bilgestorm','Blistering Roar','Bloodrake','Carcharian Verve',
        'Crashing Thunder','Droning Whirlwind','Gates of Hades','Harden Shell','Polar Roar',
        'Pyric Bulwark','Thunderbolt','Tourbillion','Uproot'
    }
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('Normal', 'Acc', 'Refresh', 'Learning')
    state.WeaponskillMode:options('Normal', 'Acc')
    state.CastingMode:options('Normal', 'Resistant')
    state.IdleMode:options('Normal', 'PDT', 'Learning')

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

    -- Additional local binds
    send_command('bind ^` input /ja "Chain Affinity" <me>')
    send_command('bind !` input /ja "Efflux" <me>')
    send_command('bind @` input /ja "Burst Affinity" <me>')

    update_combat_form()
    select_default_macro_book()
end


-- Called when this job file is unloaded (eg: job change)
function user_unload()
    send_command('unbind ^`')
    send_command('unbind !`')
    send_command('unbind @`')
end


-- Set up gear sets.
function init_gear_sets()
    --------------------------------------
    -- Start defining the sets
    --------------------------------------

    sets.buff['Burst Affinity'] = {feet="Mavi Basmak +2"}
    sets.buff['Chain Affinity'] = {head="Mavi Kavuk +2", feet="Assimilator's Charuqs"}
    sets.buff.Convergence = {head="Luhlaza Keffiyeh"}
    sets.buff.Diffusion = {feet="Luhlaza Charuqs"}
    sets.buff.Enchainment = {body="Luhlaza Jubbah"}
    sets.buff.Efflux = {legs="Mavi Tayt +2"}

    
    -- Precast Sets
    
    -- Precast sets to enhance JAs
    sets.precast.JA['Azure Lore'] = {hands="Mirage Bazubands +2"}


    -- Waltz set (chr and vit)
    sets.precast.Waltz = {ammo="Sonia's Plectrum",
        head="Uk'uxkaj Cap",
        body="Vanir Cotehardie",hands="Buremte Gloves",ring1="Spiral Ring",
        back="Iximulew Cape",waist="Caudata Belt",legs="Hagondes Pants",feet="Iuitl Gaiters +1"}
        
    -- Don't need any special gear for Healing Waltz.
    sets.precast.Waltz['Healing Waltz'] = {}

    -- Fast cast sets for spells
    
    sets.precast.FC = {ammo="Impatiens",
        head="Haruspex Hat",ear2="Loquacious Earring",
        body="Luhlaza Jubbah",hands="Thaumas Gloves",ring1="Prolix Ring",
        back="Swith Cape +1",waist="Witful Belt",legs="Enif Cosciales",feet="Chelona Boots +1"}
        
    sets.precast.FC['Blue Magic'] = set_combine(sets.precast.FC, {body="Mavi Mintan +2"})

       
    -- Weaponskill sets
    -- Default set for any weaponskill that isn't any more specifically defined
    sets.precast.WS = {
        head="Whirlpool Mask",neck=gear.ElementalGorget,ear1="Bladeborn Earring",ear2="Steelflash Earring",
        body="Qaaxo Harness",hands="Assimilator's Bazubands +1",ring1="Rajas Ring",ring2="Epona's Ring",
        back="Atheling Mantle",waist=gear.ElementalBelt,legs="Manibozho Brais",feet="Iuitl Gaiters +1"}
    
    sets.precast.WS.acc = set_combine(sets.precast.WS, {hands="Buremte Gloves"})

    -- Specific weaponskill sets.  Uses the base set if an appropriate WSMod version isn't found.
    sets.precast.WS['Requiescat'] = set_combine(sets.precast.WS, {ring1="Aquasoul Ring",feet="Luhlaza Charuqs"})

    sets.precast.WS['Sanguine Blade'] = {
        head="Hagondes Hat",neck="Eddy Necklace",ear1="Friomisi Earring",ear2="Hecate's Earring",
        body="Hagondes Coat",hands="Mavi Bazubands +2",ring1="Acumen Ring",ring2="Strendu Ring",
        back="Toro Cape",legs="Hagondes Pants",feet="Iuitl Gaiters +1"}
    
    
    -- Midcast Sets
    sets.midcast.FastRecast = {
        head="Haruspex Hat",ear2="Loquacious Earring",
        body="Luhlaza Jubbah",hands="Mavi Bazubands +2",ring1="Prolix Ring",
        back="Swith Cape +1",waist="Hurch'lan Sash",legs="Enif Cosciales",feet="Iuitl Gaiters +1"}
        
    sets.midcast['Blue Magic'] = {}
    
    -- Physical Spells --
    
    sets.midcast['Blue Magic'].Physical = {ammo="Mavi Tathlum",
        head="Whirlpool Mask",neck="Ej Necklace",ear1="Heartseeker Earring",ear2="Steelflash Earring",
        body="Vanir Cotehardie",hands="Buremte Gloves",ring1="Rajas Ring",ring2="Spiral Ring",
        back="Cornflower Cape",waist="Caudata Belt",legs="Nahtirah Trousers",feet="Qaaxo Leggings"}

    sets.midcast['Blue Magic'].PhysicalAcc = {ammo="Jukukik Feather",
        head="Whirlpool Mask",neck="Ej Necklace",ear1="Heartseeker Earring",ear2="Steelflash Earring",
        body="Luhlaza Jubbah",hands="Buremte Gloves",ring1="Rajas Ring",ring2="Patricius Ring",
        back="Letalis Mantle",waist="Hurch'lan Sash",legs="Manibozho Brais",feet="Qaaxo Leggings"}

    sets.midcast['Blue Magic'].PhysicalStr = set_combine(sets.midcast['Blue Magic'].Physical,
        {body="Iuitl Vest",hands="Assimilator's Bazubands +1"})

    sets.midcast['Blue Magic'].PhysicalDex = set_combine(sets.midcast['Blue Magic'].Physical,
        {ammo="Jukukik Feather",body="Iuitl Vest",hands="Assimilator's Bazubands +1",
         waist="Chaac Belt",legs="Manibozho Brais"})

    sets.midcast['Blue Magic'].PhysicalVit = set_combine(sets.midcast['Blue Magic'].Physical,
        {body="Vanir Cotehardie",hands="Assimilator's Bazubands +1",back="Iximulew Cape"})

    sets.midcast['Blue Magic'].PhysicalAgi = set_combine(sets.midcast['Blue Magic'].Physical,
        {body="Vanir Cotehardie",hands="Iuitl Wristbands",ring2="Stormsoul Ring",
         waist="Chaac Belt",feet="Iuitl Gaiters +1"})

    sets.midcast['Blue Magic'].PhysicalInt = set_combine(sets.midcast['Blue Magic'].Physical,
        {ear1="Psystorm Earring",body="Vanir Cotehardie",hands="Assimilator's Bazubands +1",
         ring2="Icesoul Ring",back="Toro Cape",feet="Hagondes Sabots"})

    sets.midcast['Blue Magic'].PhysicalMnd = set_combine(sets.midcast['Blue Magic'].Physical,
        {ear1="Lifestorm Earring",body="Vanir Cotehardie",hands="Assimilator's Bazubands +1",
         ring2="Aquasoul Ring",back="Refraction Cape"})

    sets.midcast['Blue Magic'].PhysicalChr = set_combine(sets.midcast['Blue Magic'].Physical,
        {body="Vanir Cotehardie",hands="Assimilator's Bazubands +1",back="Refraction Cape",
         waist="Chaac Belt"})

    sets.midcast['Blue Magic'].PhysicalHP = set_combine(sets.midcast['Blue Magic'].Physical)


    -- Magical Spells --
    
    sets.midcast['Blue Magic'].Magical = {ammo="Dosis Tathlum",
        head="Hagondes Hat",neck="Eddy Necklace",ear1="Friomisi Earring",ear2="Hecate's Earring",
        body="Hagondes Coat",hands="Mavi Bazubands +2",ring1="Icesoul Ring",ring2="Acumen Ring",
        back="Cornflower Cape",waist="Caudata Belt",legs="Hagondes Pants",feet="Hagondes Sabots"}

    sets.midcast['Blue Magic'].Magical.Resistant = set_combine(sets.midcast['Blue Magic'].Magical,
        {body="Vanir Cotehardie",ring1="Sangoma Ring",legs="Iuitl Tights",feet="Mavi Basmak +2"})
    
    sets.midcast['Blue Magic'].MagicalMnd = set_combine(sets.midcast['Blue Magic'].Magical,
        {ring1="Aquasoul Ring"})

    sets.midcast['Blue Magic'].MagicalChr = set_combine(sets.midcast['Blue Magic'].Magical)

    sets.midcast['Blue Magic'].MagicalVit = set_combine(sets.midcast['Blue Magic'].Magical,
        {ring1="Spiral Ring"})

    sets.midcast['Blue Magic'].MagicalDex = set_combine(sets.midcast['Blue Magic'].Magical)

    sets.midcast['Blue Magic'].MagicAccuracy = {ammo="Mavi Tathlum",
        head="Luhlaza Keffiyeh",neck="Ej Necklace",ear1="Lifestorm Earring",ear2="Psystorm Earring",
        body="Vanir Cotehardie",hands=gear.macc_hagondes,ring2="Sangoma Ring",
        back="Cornflower Cape",legs="Iuitl Tights",feet="Iuitl Gaiters +1"}

    -- Breath Spells --
    
    sets.midcast['Blue Magic'].Breath = {ammo="Mavi Tathlum",
        head="Luhlaza Keffiyeh",neck="Ej Necklace",ear1="Lifestorm Earring",ear2="Psystorm Earring",
        body="Vanir Cotehardie",hands="Assimilator's Bazubands +1",ring1="K'ayres Ring",ring2="Beeline Ring",
        back="Refraction Cape",legs="Enif Cosciales",feet="Iuitl Gaiters +1"}

    -- Other Types --
    
    sets.midcast['Blue Magic'].Stun = set_combine(sets.midcast['Blue Magic'].MagicAccuracy,
        {waist="Chaac Belt"})
        
    sets.midcast['Blue Magic']['White Wind'] = {
        head="Whirlpool Mask",neck="Lavalier +1",ear1="Bloodgem Earring",ear2="Loquacious Earring",
        body="Vanir Cotehardie",hands="Buremte Gloves",ring1="K'ayres Ring",ring2="Meridian Ring",
        back="Fravashi Mantle",waist="Hurch'lan Sash",legs="Enif Cosciales",feet="Hagondes Sabots"}

    sets.midcast['Blue Magic'].Healing = {
        head="Uk'uxkaj Cap",ear1="Lifestorm Earring",ear2="Loquacious Earring",
        body="Vanir Cotehardie",hands="Buremte Gloves",ring1="Aquasoul Ring",ring2="Sirona's Ring",
        back="Pahtli Cape",legs="Hagondes Pants",feet="Hagondes Sabots"}

    sets.midcast['Blue Magic'].SkillBasedBuff = {ammo="Mavi Tathlum",
        head="Luhlaza Keffiyeh",
        body="Assimilator's Jubbah",
        back="Cornflower Cape",legs="Mavi Tayt +2",feet="Luhlaza Charuqs"}

    sets.midcast['Blue Magic'].Buff = {}
    
    sets.midcast.Protect = {ring1="Sheltered Ring"}
    sets.midcast.Protectra = {ring1="Sheltered Ring"}
    sets.midcast.Shell = {ring1="Sheltered Ring"}
    sets.midcast.Shellra = {ring1="Sheltered Ring"}
    

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

    -- Gear for learning spells: +skill and AF hands.
    sets.Learning = {ammo="Mavi Tathlum",hands="Assimilator's Bazubands +1"}
        --head="Luhlaza Keffiyeh",  
        --body="Assimilator's Jubbah",hands="Assimilator's Bazubands +1",
        --back="Cornflower Cape",legs="Mavi Tayt +2",feet="Luhlaza Charuqs"}


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

    -- Resting sets
    sets.resting = {
        head="Ocelomeh Headpiece +1",neck="Wiglen Gorget",
        body="Hagondes Coat",hands="Serpentes Cuffs",ring1="Sheltered Ring",ring2="Paguroidea Ring",
        waist="Austerity Belt",feet="Chelona Boots +1"}
    
    -- Idle sets
    sets.idle = {ammo="Impatiens",
        head="Whirlpool Mask",neck="Wiglen Gorget",ear1="Bloodgem Earring",ear2="Loquacious Earring",
        body="Hagondes Coat",hands="Serpentes Cuffs",ring1="Defending Ring",ring2="Paguroidea Ring",
        back="Shadow Mantle",waist="Flume Belt",legs="Crimson Cuisses",feet="Serpentes Sabots"}

    sets.idle.PDT = {ammo="Impatiens",
        head="Whirlpool Mask",neck="Wiglen Gorget",ear1="Bloodgem Earring",ear2="Loquacious Earring",
        body="Hagondes Coat",hands="Iuitl Wristbands",ring1="Defending Ring",ring2="Paguroidea Ring",
        back="Shadow Mantle",waist="Flume Belt",legs="Crimson Cuisses",feet="Iuitl Gaiters +1"}

    sets.idle.Town = {main="Buramenk'ah",ammo="Impatiens",
        head="Mavi Kavuk +2",neck="Wiglen Gorget",ear1="Bloodgem Earring",ear2="Loquacious Earring",
        body="Luhlaza Jubbah",hands="Assimilator's Bazubands +1",ring1="Sheltered Ring",ring2="Paguroidea Ring",
        back="Atheling Mantle",waist="Flume Belt",legs="Crimson Cuisses",feet="Luhlaza Charuqs"}

    sets.idle.Learning = set_combine(sets.idle, sets.Learning)

    
    -- Defense sets
    sets.defense.PDT = {ammo="Iron Gobbet",
        head="Whirlpool Mask",neck="Wiglen Gorget",ear1="Bloodgem Earring",
        body="Iuitl Vest",hands="Iuitl Wristbands",ring1="Defending Ring",ring2=gear.DarkRing.physical,
        back="Shadow Mantle",waist="Flume Belt",legs="Nahtirah Trousers",feet="Iuitl Gaiters +1"}

    sets.defense.MDT = {ammo="Demonry Stone",
        head="Whirlpool Mask",neck="Twilight Torque",ear1="Bloodgem Earring",
        body="Hagondes Coat",hands="Iuitl Wristbands",ring1="Defending Ring",ring2="Shadow Ring",
        back="Engulfer Cape",waist="Flume Belt",legs="Nahtirah Trousers",feet="Iuitl Gaiters +1"}

    sets.Kiting = {legs="Crimson Cuisses"}

    -- 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="Jukukik Feather",
        head="Whirlpool Mask",neck="Asperity Necklace",ear1="Bladeborn Earring",ear2="Steelflash Earring",
        body="Luhlaza Jubbah",hands="Assimilator's Bazubands +1",ring1="Rajas Ring",ring2="Epona's Ring",
        back="Atheling Mantle",waist="Windbuffet Belt",legs="Manibozho Brais",feet="Iuitl Gaiters +1"}

    sets.engaged.Acc = {ammo="Jukukik Feather",
        head="Whirlpool Mask",neck="Ej Necklace",ear1="Bladeborn Earring",ear2="Steelflash Earring",
        body="Luhlaza Jubbah",hands="Buremte Gloves",ring1="Rajas Ring",ring2="Epona's Ring",
        back="Letalis Mantle",waist="Hurch'lan Sash",legs="Manibozho Brais",feet="Qaaxo Leggings"}

    sets.engaged.Refresh = {ammo="Jukukik Feather",
        head="Whirlpool Mask",neck="Asperity Necklace",ear1="Bladeborn Earring",ear2="Steelflash Earring",
        body="Luhlaza Jubbah",hands="Assimilator's Bazubands +1",ring1="Rajas Ring",ring2="Epona's Ring",
        back="Atheling Mantle",waist="Windbuffet Belt",legs="Manibozho Brais",feet="Qaaxo Leggings"}

    sets.engaged.DW = {ammo="Jukukik Feather",
        head="Whirlpool Mask",neck="Asperity Necklace",ear1="Heartseeker Earring",ear2="Dudgeon Earring",
        body="Luhlaza Jubbah",hands="Assimilator's Bazubands +1",ring1="Rajas Ring",ring2="Epona's Ring",
        back="Atheling Mantle",waist="Windbuffet Belt",legs="Manibozho Brais",feet="Iuitl Gaiters +1"}

    sets.engaged.DW.Acc = {ammo="Jukukik Feather",
        head="Whirlpool Mask",neck="Ej Necklace",ear1="Heartseeker Earring",ear2="Dudgeon Earring",
        body="Luhlaza Jubbah",hands="Buremte Gloves",ring1="Rajas Ring",ring2="Epona's Ring",
        back="Letalis Mantle",waist="Hurch'lan Sash",legs="Manibozho Brais",feet="Qaaxo Leggings"}

    sets.engaged.DW.Refresh = {ammo="Jukukik Feather",
        head="Whirlpool Mask",neck="Asperity Necklace",ear1="Heartseeker Earring",ear2="Dudgeon Earring",
        body="Luhlaza Jubbah",hands="Assimilator's Bazubands +1",ring1="Rajas Ring",ring2="Epona's Ring",
        back="Letalis Mantle",waist="Windbuffet Belt",legs="Manibozho Brais",feet="Qaaxo Leggings"}

    sets.engaged.Learning = set_combine(sets.engaged, sets.Learning)
    sets.engaged.DW.Learning = set_combine(sets.engaged.DW, sets.Learning)


    sets.self_healing = {ring1="Kunaji Ring",ring2="Asklepian Ring"}
end

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

-- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
-- Set eventArgs.useMidcastGear to true if we want midcast gear equipped on precast.
function job_precast(spell, action, spellMap, eventArgs)
    if unbridled_spells:contains(spell.english) and not state.Buff['Unbridled Learning'] then
        eventArgs.cancel = true
        windower.send_command('@input /ja "Unbridled Learning" <me>; wait 1.5; input /ma "'..spell.name..'" '..spell.target.name)
    end
end

-- Run after the default midcast() is done.
-- eventArgs is the same one used in job_midcast, in case information needs to be persisted.
function job_post_midcast(spell, action, spellMap, eventArgs)
    -- Add enhancement gear for Chain Affinity, etc.
    if spell.skill == 'Blue Magic' then
        for buff,active in pairs(state.Buff) do
            if active and sets.buff[buff] then
                equip(sets.buff[buff])
            end
        end
        if spellMap == 'Healing' and spell.target.type == 'SELF' and sets.self_healing then
            equip(sets.self_healing)
        end
    end

    -- If in learning mode, keep on gear intended to help with that, regardless of action.
    if state.OffenseMode.value == 'Learning' then
        equip(sets.Learning)
    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 state.Buff[buff] ~= nil then
        state.Buff[buff] = gain
    end
end

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

-- Custom spell mapping.
-- Return custom spellMap value that can override the default spell mapping.
-- Don't return anything to allow default spell mapping to be used.
function job_get_spell_map(spell, default_spell_map)
    if spell.skill == 'Blue Magic' then
        for category,spell_list in pairs(blue_magic_maps) do
            if spell_list:contains(spell.english) then
                return category
            end
        end
    end
end

-- Modify the default idle set after it was constructed.
function customize_idle_set(idleSet)
    if player.mpp < 51 then
        set_combine(idleSet, sets.latent_refresh)
    end
    return idleSet
end

-- Called by the 'update' self-command, for common needs.
-- Set eventArgs.handled to true if we don't want automatic equipping of gear.
function job_update(cmdParams, eventArgs)
    update_combat_form()
end


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

function update_combat_form()
    -- Check for H2H or single-wielding
    if player.equipment.sub == "Genbu's Shield" or player.equipment.sub == 'empty' then
        state.CombatForm:reset()
    else
        state.CombatForm:set('DW')
    end
end


-- Select default macro book on initial load or subjob change.
function select_default_macro_book()
    -- Default macro set/book
    if player.sub_job == 'DNC' then
        set_macro_page(2, 7)
    else
        set_macro_page(1, 7)
    end
end

 Shiva.Arislan
Offline
Serveur: Shiva
Game: FFXI
user: Arislan
Posts: 1052
By Shiva.Arislan 2016-10-27 07:52:40
Link | Citer | R
 
Quote:
Currently have a BLU gs that doesn't auto-switch macro books/pages...

Just use your old lua, and in function user_setup() add this line:
Code
select_default_macro_book()

And at the end of your lua, paste this function:
Code
function select_default_macro_book()
	-- Default macro set/book
	if player.sub_job == 'WAR' then
		set_macro_page(1, 10)
	elseif player.sub_job == 'RDM' then
		set_macro_page(2, 10)
	else
		set_macro_page(1, 10)
	end
end

Change the macro book #'s to whatever you're currently using, and add/subtract subjob conditionals if needed.
 Shiva.Berzerk
Offline
Serveur: Shiva
Game: FFXI
user: Berzerk06
Posts: 357
By Shiva.Berzerk 2016-10-27 09:21:37
Link | Citer | R
 
Shiva.Arislan said: »
Quote:
Currently have a BLU gs that doesn't auto-switch macro books/pages...

Just use your old lua, and in function user_setup() add this line:
Code
select_default_macro_book()

And at the end of your lua, paste this function:
Code
function select_default_macro_book()
	-- Default macro set/book
	if player.sub_job == 'WAR' then
		set_macro_page(1, 10)
	elseif player.sub_job == 'RDM' then
		set_macro_page(2, 10)
	else
		set_macro_page(1, 10)
	end
end

Change the macro book #'s to whatever you're currently using, and add/subtract subjob conditionals if needed.

For some reason the current BLU lua I'm using doesn't have a user_setup, hence when i copy the macro stuff over it doesn't want to work :/ Will post the code of the current BLU lua w/o the macro pages that CAN swap gear properly when engaging. I've tried adding it in the get_sets() function, creating a user_setup() function with a call to the macro-setting function but just getting errors. Will try playing on a bigger resolution so i can see the full error message.
 Odin.Lygre
Offline
Serveur: Odin
Game: FFXI
user: Dylaudid
Posts: 89
By Odin.Lygre 2016-10-27 10:03:22
Link | Citer | R
 
Odin.Psycooo said: »
Ok, I am back with more questions....
I managed to add/define sets based of the amount of magical haste I have. So now if I have no haste it equips one set of gear, if I get haste 1 or haste 2 it equips based on value of haste all the way up to capped haste.
What I would like additionally is for it to auto equip the single wield gearset in the event I don't have a dual wield subjob, furthermore I would like a way to add in additional sets if I am using /dnc instead of my normal /nin, because the native DW traits are different I would need to add a whole bunch of rules and sets, the problem is I have NO FRIGGIN' IDEA how to do any of that. I literally stole all my haste defined rules from a thf lua and spent like 3 hours til I got it to work.

Edit: Ideally I would like to do this same thing for my terribly designed cor lua, that way I don't have to cycle through 14 sets

It most definitely does work. You just have all of the sets defined recursively, so debugmode doesn't show it swapping to the appropriate haste value. Eliminate the recursions and it works, I promise.

Here is the current version I can confirm works.
 Asura.Pintseyes
Offline
Serveur: Asura
Game: FFXI
user: yurmy123
Posts: 115
By Asura.Pintseyes 2016-10-27 17:08:09
Link | Citer | R
 
I just started playing SCH again and downloaded Kinematics lua and silverseans lue (Were basically the same lua) The issue is with both that elemental magic does not swap, no precast or midcast happens on anything over tier2. So mid tier and high tier dont swap at all. Anyone else had this problem or can maybe look over the lua and explain why showswaps doesnt show mid or high tier nukes swapping? Thanks for your time an effort.

Note: To attempt to fix the issue I added the same set to all the ele magic rules.
 Odin.Psycooo
Offline
Serveur: Odin
Game: FFXI
user: Psycooo
Posts: 42
By Odin.Psycooo 2016-10-27 22:30:21
Link | Citer | R
 
Odin.Lygre said: »
Odin.Psycooo said: »
Ok, I am back with more questions....
I managed to add/define sets based of the amount of magical haste I have. So now if I have no haste it equips one set of gear, if I get haste 1 or haste 2 it equips based on value of haste all the way up to capped haste.
What I would like additionally is for it to auto equip the single wield gearset in the event I don't have a dual wield subjob, furthermore I would like a way to add in additional sets if I am using /dnc instead of my normal /nin, because the native DW traits are different I would need to add a whole bunch of rules and sets, the problem is I have NO FRIGGIN' IDEA how to do any of that. I literally stole all my haste defined rules from a thf lua and spent like 3 hours til I got it to work.

Edit: Ideally I would like to do this same thing for my terribly designed cor lua, that way I don't have to cycle through 14 sets

It most definitely does work. You just have all of the sets defined recursively, so debugmode doesn't show it swapping to the appropriate haste value. Eliminate the recursions and it works, I promise.

Here is the current version I can confirm works.

Plugged in all the gear, engaged cast haste 1 received the "----haste 30%----" did not change gear. Cast haste 2 did not receive a new message mentioning haste, did not change gear.

Also not 100% certain on what you mean about sets being defined recursively nor what recursions to eliminate.
 Odin.Lygre
Offline
Serveur: Odin
Game: FFXI
user: Dylaudid
Posts: 89
By Odin.Lygre 2016-10-27 23:11:48
Link | Citer | R
 
There is no way for gearswap to differentiate between Haste and Haste II on its own that I'm aware of. I tested haste, marches, MG, geomancy haste and it was all gucci. To deal with this, on jobs that can provide themselves with Haste II, I design the function under the assumption that buffactive[33] being true equates to 30% magical haste. For jobs this isn't true for, I have a state variable I switch between which determines if the function's logic treats Haste as 15% or 30%

Code
	-- Haste 43%
Ln 273:	sets.engaged.DW_nin.Haste_43 = set_combine(sets.engaged.DW_nin, {})

Until I added in a piece of gear instead of an empty set, debugmode wouldn't identify it actually changing to this set, since I guess it's technically the same set or something. As soon as I added one piece inside the brackets it immediately began showing the changes as expected.
Offline
By Nyruul 2016-10-28 20:11:49
Link | Citer | R
 
I'm having a problem where Ioskeha belt will not swap in to my TP set. I've tried adding it to other sets and used showswaps and it certainly does not get swapped in (yes i spelled it correctly.) Anyone know the reason why this belt is not registering?
Offline
Posts: 5
By Dyrandal 2016-10-28 21:44:34
Link | Citer | R
 
Quote:
I'm having a problem where Ioskeha belt will not swap in to my TP set. I've tried adding it to other sets and used showswaps and it certainly does not get swapped in (yes i spelled it correctly.) Anyone know the reason why this belt is not registering?

Just to make sure, you used the export function of gearswap, right?
Offline
Posts: 21
By Ineeedmoney 2016-10-29 03:35:01
Link | Citer | R
 
Trying to Figure out what I am doing wrong here with my Precast for Cor it wont flash in my Beaters mantle then flash back to normal range Acc

And I know it is something I am doing wrong it is my third GS that I have tried to work with
Offline
By Nyruul 2016-10-29 06:22:05
Link | Citer | R
 
Dyrandal said: »
Quote:
I'm having a problem where Ioskeha belt will not swap in to my TP set. I've tried adding it to other sets and used showswaps and it certainly does not get swapped in (yes i spelled it correctly.) Anyone know the reason why this belt is not registering?

Just to make sure, you used the export function of gearswap, right?

I'm not sure what the export function is tbh.
 Bismarck.Mitchel
Offline
Serveur: Bismarck
Game: FFXI
Posts: 153
By Bismarck.Mitchel 2016-10-29 06:25:00
Link | Citer | R
 
Odin.Lygre said: »
Is this what you are looking for? Added self-command and brief explanation where you have the others at the beginning of the file

Will give this a try, thanks for the response!
Offline
Posts: 21
By Ineeedmoney 2016-10-29 10:33:56
Link | Citer | R
 
Any information would be appreciated. I have used this same Cor.lua in the past and my precast.ra worked and now it isnt.
 Asura.Ragnarky
Offline
Serveur: Asura
Game: FFXI
user: Ragnark
Posts: 19
By Asura.Ragnarky 2016-10-30 10:39:53
Link | Citer | R
 
Everytime I weaponskill as sch i get the following error ...

GearSwap: Lua runtime error: GearSwap/flow.lua:336:
...Windower4/addons/GearSwap/data/SCH.lua:327: attempt to compare number with nil
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')
	include('organizer-lib')
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')
    state.CastingMode:options('Normal', 'Resistant')
    state.IdleMode:options('Normal', 'PDT')

    state.MagicBurst = M(false, 'Magic Burst')
	
	info.Helix = S{"Geohelix","Hydrohelix","Anemohelix","Pyrohelix","Cryohelix","Ionohelix","Luminohelix","Noctohelix",
					"Geohelix II","Hydrohelix II","Anemohelix II","Pyrohelix II","Cryohelix II","Ionohelix II","Luminohelix II","Noctohelix II"}

    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"}
	
    info.high_nukes = 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"}

    degrade_array = {
        ['Fire'] = {'Fire','Fire II','Fire III','Fire IV','Fire V','Fire VI'},
        ['Firega'] = {'Firaga','Firaga II','Firaga III'},
        ['Ice'] = {'Blizzard','Blizzard II','Blizzard III','Blizzard IV','Blizzard V','Blizzard VI'},
        ['Icega'] = {'Blizzaga','Blizzaga II','Blizzaga III'},
        ['Wind'] = {'Aero','Aero II','Aero III','Aero IV','Aero V','Aero VI'},
        ['Windga'] = {'Aeroga','Aeroga II','Aeroga III'},
        ['Earth'] = {'Stone','Stone II','Stone III','Stone IV','Stone V','Stone VI'},
        ['Earthga'] = {'Stonega','Stonega II','Stonega III'},
        ['Lightning'] = {'Thunder','Thunder II','Thunder III','Thunder IV','Thunder V','Thunder VI'},
        ['Lightningga'] = {'Thundaga','Thundaga II','Thundaga III'},
        ['Water'] = {'Water', 'Water II','Water III', 'Water IV','Water V','Water VI'},
        ['Waterga'] = {'Waterga','Waterga II','Waterga III'},
        ['Aspirs'] = {'Aspir','Aspir II','Aspir III'},
        ['Sleepgas'] = {'Sleepga','Sleepga II'}
    }
	
	send_command('bind ^` input /ma Stun <t>')

    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 +1"}
	sets.precast.JA['Dark Arts'] = {body="Academic's Gown +1"}
	sets.precast.JA['Light Arts'] = {legs="Academic's Pants +1"}
	sets.precast.JA['Enlightenment'] = {body="Pedagogy Gown +1"}
	sets.precast.JA['Stratagems'] = {head="Pedagogy Mortarboard +1",legs="Arbatel Pants +1",feet="Academic's Loafers +1"}

    -- Fast cast sets for spells

    sets.precast.FC = {ammo="Impatiens",
        head="Nahtirah Hat",neck="Incanter's Torque",ear1="Dignitary's Earring",ear2="Loquacious Earring",
        body="Vanir Cotehardie",ring1="Prolix Ring",
        back="Swith Cape",waist="Witful Belt",legs="Merlinic Shalwar",feet="Chelona Boots"}

    sets.precast.FC['Elemental Magic'] = set_combine(sets.precast.FC, {body="Amalric Doublet"})

    sets.precast.FC.Cure = set_combine(sets.precast.FC, {body="Amalric Doublet",legs="Assiduity Pants +1"})

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

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

	sets.precast.FC.Storm ={ammo="Strobilus",
    head="Merlinic Hood",neck="Baetyl Pendant",ear1="Dignitary's Earring",ear2="Loquacious Earring",
	body="Amalric Doublet",hands="Amalric Gages",ring1="Stikini Ring",ring2="Stikini Ring",
    back="Bookworm's Cape",waist="Cascade Belt",legs="Merlinic Shalwar",feet="Merlinic Crackows"}

    -- Midcast Sets

    sets.midcast.FastRecast = {ammo="Incantor Stone",
        head="Nahtirah Hat",ear2="Loquacious Earring",
        body="Vanir Cotehardie",ring1="Stikini Ring",ring2="Stikini Ring",
        back="Swith Cape",waist="Witful belt",legs="",feet="Academic's Loafers +1"}

    sets.midcast.Cure = {main="Bolelabunga",sub="Culminus",ammo="Incantor Stone",
        head="Nahtirah Hat",neck="Nodens Gorget",ear1="Lifestorm Earring",ear2="Loquacious Earring",
        body="Heka's Kalasiris",hands="Bokwus Gloves",ring1="Stikini Ring",ring2="Stikini Ring",
        back="Swith Cape",waist="Witful belt",legs="Orvail Pants +1",feet="Academic's Loafers +1"}

	sets.midcast.CureWithLightWeather = {ammo="Incantor Stone",
        head="Gendewitha Caubeen",neck="Nodens Gorget",ear1="Lifestorm Earring",ear2="Loquacious Earring",
        body="Heka's Kalasiris",hands="Bokwus Gloves",ring1="Stikini Ring",ring2="Stikini Ring",
        back="Twilight Cape",waist="Witful belt",legs="Assiduity Pants +1",feet="Academic's Loafers +1"}

    sets.midcast.Curaga = sets.midcast.Cure

    sets.midcast.Regen = {
		head="Arbatel Bonnet +1",neck="Incanter's Torque",
		body="Telchine Chasuble",hands="Telchine Gloves",ring1="Stikini Ring",ring2="Stikini Ring",
		back="Lugh's Cape",waist="Cascade belt",legs="Telchine Braconi",feet="Telchine Pigaches"}

    sets.midcast.Cursna = {
        neck="Malison Medallion",
        hands="Hieros Mittens",ring1="Stikini Ring",ring2="Stikini Ring",
        feet="Gendewitha Galoshes"}

    sets.midcast['Enhancing Magic'] = {ammo="Savant's Treatise",
        head="Telchine Cap",neck="Incanter's Torque",
		body="Telchine Chasuble",hands="Arbatel Bracers +1",ring1="Stikini Ring",ring2="Stikini Ring",
		waist="Cascade belt",legs="Telchine Braconi",feet="Telchine Pigaches"}

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

    sets.midcast.Storm = set_combine(sets.midcast['Enhancing Magic'], {feet="Pedagogy Loafers +1"})

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

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


    -- Custom spell classes
	sets.midcast.MndEnfeebles = {ammo="Pemphredo Tathlum",
		head="Merlinic Hood",neck="Incanter's Torque",ear1="Psystorm Earring",ear2="Lifestorm Earring",
		body="Vanya Robe",hands="Pedagogy Bracers +1",ring1="Stikini Ring",ring2="Stikini Ring",
		back="Refraction Cape",waist="Eschan Stone",legs="Arbatel Pants +1",feet="Jhakri Pigaches +1"}

	sets.midcast.IntEnfeebles = {ammo="Pemphredo Tathlum",
		head="Merlinic Hood",neck="Incanter's Torque",ear1="Psystorm Earring",ear2="Lifestorm Earring",
		body="Vanya Robe",hands="Pedagogy Bracers +1",ring1="Stikini Ring",ring2="Stikini Ring",
		back="Refraction Cape",waist="Eschan Stone",legs="Arbatel Pants +1",feet="Jhakri Pigaches +1"}

	sets.midcast.ElementalEnfeeble = sets.midcast.IntEnfeebles

	sets.midcast['Dark Magic'] = {ammo="Pemphredo Tathlum",
		head="Nahtirah Hat",neck="Mizukage-no-Kubikazari",ear1="Psystorm Earring",ear2="Lifestorm Earring",
		body="Amalric Doublet",hands="Amalric Gages",ring1="Locus Ring",ring2="Prolix ring",
		back="Bookworm's Cape",waist="Eschan Stone",legs="Pedagogy Pants +1",feet="Jhakri Pigaches +1"}

	sets.midcast.Kaustra = {ammo="Pemphredo Tathlum",
		head="Nahtirah Hat",neck="Mizukage-no-Kubikazari",ear1="Psystorm Earring",ear2="Lifestorm Earring",
		body="Amalric Doublet",hands="Amalric Gages",ring1="Locus Ring",ring2="Prolix ring",
		back="Bookworm's Cape",waist="Eschan Stone",legs="Merlinic Shalwar",feet="Merlinic Crackows"}

	sets.midcast.Drain = {ammo="Pemphredo Tathlum",
		head="Nahtirah Hat",neck="Mizukage-no-Kubikazari",ear1="Psystorm Earring",ear2="Lifestorm Earring",
		body="Amalric Doublet",hands="Amalric Gages",ring1="Locus Ring",ring2="Prolix ring",
		back="Bookworm's Cape",waist="Austerity Belt +1",legs="Pedagogy Pants +1",feet="Merlinic Crackows"}

	sets.midcast.Aspir = sets.midcast.Drain

	sets.midcast.Stun = {ammo="Incantor Stone",
		head="Nahtirah Hat",neck="Aesir Torque",ear1="Psystorm Earring",ear2="Lifestorm Earring",
		hands="Yaoyotl Gloves",ring1="Prolix Ring",ring2="Sangoma Ring",
		back="Refraction Cape",waist="Witful Belt",legs="Pedagogy Pants +1",feet="Academic's Loafers +1"}

    -- Elemental Magic sets are default for handling low-tier nukes.
	sets.midcast['Elemental Magic'] = {ammo="Ghastly Tathlum",
		head="Merlinic Hood",neck="Mizukage-no-Kubikazari",ear1="Barkarole earring",ear2="Hermetic Earring",
		body="Amalric Doublet",hands="Amalric Gages",ring1="Locus Ring",ring2="Mujin Band",
		back="Toro Cape",waist="Refoccilation Stone",legs="Merlinic Shalwar",feet="Jhakri Pigaches +1"}

	sets.midcast['Elemental Magic'].Resistant = {ammo="Ghastly Tathlum",
		head="Merlinic Hood",neck="Mizukage-no-Kubikazari",ear1="Barkarole earring",ear2="Hermetic Earring",
		body="Amalric Doublet",hands="Amalric Gages",ring1="Locus Ring",ring2="Mujin Band",
		back="Toro Cape",waist="Refoccilation Stone",legs="Merlinic Shalwar",feet="Jhakri Pigaches +1"}

    -- Custom refinements for certain nuke tiers
    sets.midcast['Elemental Magic'].HighTierNuke = set_combine(sets.midcast['Elemental Magic'], {sub="Wizzan Grip"})

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

    sets.midcast.Impact = {head=empty,body="Twilight Cloak"}

	sets.midcast.Helix={ammo="Ghastly Tathlum",
		head="Amalric Coif",neck="Incanter's Torque",ear1="Barkarole earring",ear2="Dignitary's Earring",
		body="Amalric Doublet",hands="Amalric Gages",ring1="Locus Ring",ring2="Mujin Band",
		back="Bookworm's Cape",waist="Refoccilation Stone",legs="Merlinic Shalwar",feet="Merlinic Crackows"}

	sets.midcast.Noctohelix = set_combine(sets.midcast.Helix, {head="Pixie Hairpin +1"})

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

    -- Resting sets
	sets.resting = {main="Boonwell Staff",
		body="Chelona Blazer",neck="Grandiose chain",ring1="Sheltered Ring",ring2="Paguroidea Ring",
		waist="Shinjutsu-no-Obi",legs="Assiduity Pants +1",feet="Chelona Boots"}


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

	sets.idle.Town = {main="Akademos",sub="Niobid Strap",ammo="Homiliary",
		head="Amalric Coif",neck="Bathy Choker +1",ear1="Psystorm Earring",ear2="Lifestorm Earring",
		body="Arbatel Gown +1",hands="Arbatel Bracers +1",ring1="Sheltered Ring",ring2="Paguroidea Ring",
		back="Kumbira Cape",waist="Witful Belt",legs="Assiduity Pants +1",feet="Herald's Gaiters"}

	sets.idle.Field = {main="Akademos",sub="Niobid Strap",ammo="Homiliary",
		head="Amalric Coif",neck="Bathy Choker +1",ear1="Psystorm Earring",ear2="Lifestorm Earring",
		body="Arbatel Gown +1",hands="Arbatel Bracers +1",ring1="Sheltered Ring",ring2="Paguroidea Ring",
		back="Mecistopins Mantle",waist="Witful Belt",legs="Assiduity Pants +1",feet="Herald's Gaiters"}

	sets.idle.Field.PDT = {main="Akademos",sub="Niobid Strap",ammo="Homiliary",
		head="Amalric Coif",neck="Bathy Choker +1",ear1="Psystorm Earring",ear2="Lifestorm Earring",
		body="Arbatel Gown +1",hands="Arbatel Bracers +1",ring1="Sheltered Ring",ring2="Paguroidea Ring",
		back="Cheviot Cape",waist="Hierarch Belt",legs="Assiduity Pants +1",feet="Herald's Gaiters"}

	sets.idle.Weak = {main="Akademos",sub="Niobid Strap",ammo="Homiliary",
		head="Amalric Coif",neck="Bathy Choker +1",ear1="Psystorm Earring",ear2="Lifestorm Earring",
		body="Arbatel Gown +1",hands="Arbatel Bracers +1",ring1="Sheltered Ring",ring2="Paguroidea Ring",
		back="Kumbira Cape",waist="Witful Belt",legs="Assiduity Pants +1",feet="Herald's Gaiters"}

    -- Defense sets

	sets.defense.PDT = {main="Akademos",sub="Niobid Strap",ammo="Incantor Stone",
		head="Nahtirah Hat",neck="Twilight Torque",ear1="Bloodgem Earring",ear2="Loquacious Earring",
		body="Hagondes Coat",hands="Yaoyotl Gloves",ring1="Defending Ring",ring2="Dark ring",
		back="Cheviot Cape",waist="Hierarch Belt",legs="Merlinic Shalwar",feet="Hagondes Sabots"}

	sets.defense.MDT = {main="Akademos",sub="Niobid Strap",ammo="Incantor Stone",
		head="Nahtirah Hat",neck="Twilight Torque",ear1="Bloodgem Earring",ear2="Loquacious Earring",
		body="Vanir Cotehardie",hands="Yaoyotl Gloves",ring1="Defending Ring",ring2="Shadow Ring",
		back="Tuilha Cape",waist="Hierarch Belt",legs="Bokwus Slops",feet="Hagondes Sabots"}

	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="Niobid Strap",ammo="Homiliary",
		head="Amalric Coif",neck="Twilight Torque",ear1="Psystorm Earring",ear2="Lifestorm Earring",
		body="Arbatel Gown +1",hands="Arbatel Bracers +1",ring1="Defending Ring",ring2="Dark ring",
		back="Cheviot Cape",waist="Witful Belt",legs="Assiduity Pants +1",feet="Merlinic Crackows"}

    -- 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="Arbatel Pants +1"}
    sets.buff['Parsimony'] = {legs="Arbatel Pants +1"}
    sets.buff['Celerity'] = {feet="Pedagogy Loafers +1"}
    sets.buff['Alacrity'] = {feet="Pedagogy Loafers +1"}

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

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

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

-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for standard casting events.
-------------------------------------------------------------------------------------------------------------------
function refine_various_spells(spell, action, spellMap, eventArgs)
    local aspirs = S{'Aspir','Aspir II'}
    local sleeps = S{'Sleep','Sleep II'}
 
    local newSpell = spell.english
    local spell_recasts = windower.ffxi.get_spell_recasts()
    local cancelling = 'All '..spell.english..' spells are on cooldown. Cancelling spell casting.'
 
    local spell_index
 
    if spell_recasts[spell.recast_id] > 0 then
        if spell.skill == 'Elemental Magic' then
            if table.find(degrade_array[ele],spell.name) then
                spell_index = table.find(degrade_array[ele],spell.name)
                if spell_index > 1 then
                    newSpell = degrade_array[ele][spell_index - 1]
                    add_to_chat(8,spell.name..' Canceled: ['..player.mp..'/'..player.max_mp..'MP::'..player.mpp..'%] Casting '..newSpell..' instead.')
                    send_command('@input /ma '..newSpell..' '..tostring(spell.target.raw))
                    eventArgs.cancel = true
                end
            else 
                spell_index = table.find(degrade_array[spell.element],spell.name)
                if spell_index > 1 then
                    newSpell = degrade_array[spell.element][spell_index - 1]
                    add_to_chat(8,spell.name..' Canceled: ['..player.mp..'/'..player.max_mp..'MP::'..player.mpp..'%] Casting '..newSpell..' instead.')
                    send_command('@input /ma '..newSpell..' '..tostring(spell.target.raw))
                    eventArgs.cancel = true
                end
            end
        elseif aspirs:contains(spell.name) then
            spell_index = table.find(degrade_array['Aspirs'],spell.name)
            if spell_index > 1 then
                newSpell = degrade_array['Aspirs'][spell_index - 1]
                add_to_chat(8,spell.name..' Canceled: ['..player.mp..'/'..player.max_mp..'MP::'..player.mpp..'%] Casting '..newSpell..' instead.')
                send_command('@input /ma '..newSpell..' '..tostring(spell.target.raw))
                eventArgs.cancel = true
            end
        end
    end
end

function job_precast(spell, action, spellMap, eventArgs)	
    refine_various_spells(spell, action, spellMap, eventArgs)
    if (spell.type:endswith('Magic') or spell.type == "Ninjutsu") then
	   if buffactive.Silence then
		cancel_spell()
		send_command('input /item "Echo Drops" <me>')
       end
    end	
	
	if spell.english == "Paralyna" and buffactive.Paralyzed then
        -- no gear swaps if we're paralyzed, to avoid blinking while trying to remove it.
        eventArgs.handled = true
    end
	
end	
	
-- 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
	if spell.skill == 'Elemental Magic' then
        if state.MagicBurst.value then
        equip(sets.magic_burst)
        end
	end
	if spell.skill == 'Elemental Magic' and spell.element == world.day_element or spell.element == world.weather_element then
        equip ({waist="Hachirin-no-Obi"})
    end
end

function job_aftercast(spell, action, spellMap, eventArgs)
    if spell.english == 'Sleep' then
        send_command('@wait 50;input /echo ------- '..spell.english..' is wearing off in 10 seconds -------')
    elseif spell.english == 'Sleep II' or spell.english == 'Sleepga II' then
        send_command('@wait 80;input /echo ------- '..spell.english..' is wearing off in 10 seconds -------')
    elseif spell.english == 'Break' or spell.english == 'Breakga' then
        send_command('@wait 20;input /echo ------- '..spell.english..' is wearing off in 10 seconds -------')
    end
 
	if spell.english == 'Sleep II' then
		send_command('timers c "Sleep II" 90 down spells/00259.png')
	elseif spell.english == 'Sleep' then
		send_command('timers c "Sleep" 60 down spells/00253.png')
	elseif spell.english == 'Break' then
		send_command('timers c "Break" 30 down spells/00255.png')
	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' then --or spellMap ~= 'ElementalEnfeeble'
        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.skill == "Elemental Magic" 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


function display_current_caster_state()
	local msg = ''

	if state.OffenseMode.value ~= 'None' then
		msg = msg .. 'Melee'

		if state.CombatForm.has_value then
			msg = msg .. ' (' .. state.CombatForm.value .. ')'
		end
        
		msg = msg .. ', '
	end

	msg = msg .. 'Idle ['..state.IdleMode.value..'], Casting ['..state.CastingMode.value..']'

	add_to_chat(122, msg)
	local currentStrats = get_current_strategem_count()
	local arts
	if buffactive['Light Arts'] or buffactive['Addendum: White'] then
		arts = 'Light Arts'
	elseif buffactive['Dark Arts'] or buffactive['Addendum: Black'] then
		arts = 'Dark Arts'
	else
		arts = 'No Arts Activated'
	end
	add_to_chat(122, 'Current Available Strategems: ['..currentStrats..'], '..arts..'')
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
	local strategem = cmdParams[2]:lower()
	
	if currentStrats > 0 and strategem ~= 'light' and strategem ~= 'dark' then
		add_to_chat(122, '***Current Charges Available: ['..newStratCount..']***')
	elseif currentStrats == 0 then
		add_to_chat(122, '***Out of strategems! Canceling...***')
		return
	end

	if strategem == 'light' then
		if buffactive['light arts'] then
			send_command('input /ja "Addendum: White" <me>')
			add_to_chat(122, '***Current Charges Available: ['..newStratCount..']***')
		elseif buffactive['addendum: white'] then
			add_to_chat(122,'Error: Addendum: White is already active.')
		elseif buffactive['dark arts']  or buffactive['addendum: black'] then
			send_command('input /ja "Light Arts" <me>')
			add_to_chat(122, '***Changing Arts! Current Charges Available: ['..currentStrats..']***')
		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>')
			add_to_chat(122, '***Current Charges Available: ['..newStratCount..']***')
        elseif buffactive['addendum: black'] then
			add_to_chat(122,'Error: Addendum: Black is already active.')
		elseif buffactive['light arts'] or buffactive['addendum: white'] then
			send_command('input /ja "Dark Arts" <me>')
			add_to_chat(122, '***Changing Arts! Current Charges Available: ['..currentStrats..']***')
		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

function get_current_strategem_count()
	local allRecasts = windower.ffxi.get_ability_recasts()
	local stratsRecast = allRecasts[231]

	local maxStrategems = math.floor(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()
    if player.sub_job == 'RDM' then
        set_macro_page(1, 16)
    elseif player.sub_job == 'BLM' then
        set_macro_page(1, 16)	
    elseif player.sub_job == 'WHM' then
        set_macro_page(1, 16)
	end	
end
 Bismarck.Dunigs
Offline
Serveur: Bismarck
Game: FFXI
user: Dunigs
Posts: 83
By Bismarck.Dunigs 2016-10-30 10:52:56
Link | Citer | R
 
You need to modify your refine_various_spell function to cancel, or have some kind of handling specifically for weapon skills, since they have no recast for the API to return. Alternatively you can add something to job_precast to avoid refine_various_spells when using a weapon skill.

few quick and dirty snippets :
Code
function refine_various_spells(spell, action, spellMap, eventArgs)
    if spell.type == 'WeaponSkill' then return end
    local aspirs = S{'Aspir','Aspir II'}
    local sleeps = S{'Sleep','Sleep II'}
  
    local newSpell = spell.english
    local spell_recasts = windower.ffxi.get_spell_recasts()
    local cancelling = 'All '..spell.english..' spells are on cooldown. Cancelling spell casting.'
  
    local spell_index
  
    if spell_recasts[spell.recast_id] > 0 then
        if spell.skill == 'Elemental Magic' then
            if table.find(degrade_array[ele],spell.name) then
                spell_index = table.find(degrade_array[ele],spell.name)
                if spell_index > 1 then
                    newSpell = degrade_array[ele][spell_index - 1]
                    add_to_chat(8,spell.name..' Canceled: ['..player.mp..'/'..player.max_mp..'MP::'..player.mpp..'%] Casting '..newSpell..' instead.')
                    send_command('@input /ma '..newSpell..' '..tostring(spell.target.raw))
                    eventArgs.cancel = true
                end
            else 
                spell_index = table.find(degrade_array[spell.element],spell.name)
                if spell_index > 1 then
                    newSpell = degrade_array[spell.element][spell_index - 1]
                    add_to_chat(8,spell.name..' Canceled: ['..player.mp..'/'..player.max_mp..'MP::'..player.mpp..'%] Casting '..newSpell..' instead.')
                    send_command('@input /ma '..newSpell..' '..tostring(spell.target.raw))
                    eventArgs.cancel = true
                end
            end
        elseif aspirs:contains(spell.name) then
            spell_index = table.find(degrade_array['Aspirs'],spell.name)
            if spell_index > 1 then
                newSpell = degrade_array['Aspirs'][spell_index - 1]
                add_to_chat(8,spell.name..' Canceled: ['..player.mp..'/'..player.max_mp..'MP::'..player.mpp..'%] Casting '..newSpell..' instead.')
                send_command('@input /ma '..newSpell..' '..tostring(spell.target.raw))
                eventArgs.cancel = true
            end
        end
    end
end


Or handling in precast(moved refine_various_spells) into your "Magic" check) :
Code
function job_precast(spell, action, spellMap, eventArgs)    
    if (spell.type:endswith('Magic') or spell.type == "Ninjutsu") then
       refine_various_spells(spell, action, spellMap, eventArgs)
       if buffactive.Silence then
        cancel_spell()
        send_command('input /item "Echo Drops" <me>')
       end
    end 
     
    if spell.english == "Paralyna" and buffactive.Paralyzed then
        -- no gear swaps if we're paralyzed, to avoid blinking while trying to remove it.
        eventArgs.handled = true
    end
     
end 
First Page 2 3 ... 111 112 113 ... 181 182 183