RNG Gearswap Help.

言語: JP EN DE FR
2010-06-21
New Items
668 users online
フォーラム » Windower » Support » RNG Gearswap help.
RNG Gearswap help.
 Shiva.Mortechai
Offline
サーバ: Shiva
Game: FFXI
user: Mortechai
Posts: 11
By Shiva.Mortechai 2020-04-03 12:47:09  
I need to know whether my lua will swap back to my default ammo type on next ranged attack after I swap to hauksbok arrow to savage blade. As it's setup right now, it just stays on hauksbok after I SB and im too afraid to test if it'll go back to antlion arrows on my next ranged attack automatically or just piss away my 1k domain point ammo. Included below is part of my lua:
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.Barrage = buffactive.Barrage or false
	state.Buff.Camouflage = buffactive.Camouflage or false
	state.Buff['Unlimited Shot'] = buffactive['Unlimited Shot'] 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', 'DT')
	state.RangedMode:options('Normal', 'Acc')
	state.WeaponskillMode:options('Normal', 'Acc')
	
	gear.default.weaponskill_neck = "Ocachi Gorget"
	gear.default.weaponskill_waist = "Elanid Belt"
	
	DefaultAmmo = {['Sparrowhawk'] = "Antlion arrow", ['Annihilator'] = "Achiyalabopa bullet"}
	U_Shot_Ammo = {['Sparrowhawk'] = "Eminent arrow", ['Annihilator'] = "Achiyalabopa bullet"}

	set_macro_page(1, 17)
	send_command('wait 1.5;input /lockstyleset 16')

	send_command('bind f9 gs c cycle RangedMode')
	send_command('bind ^f9 gs c cycle OffenseMode')
end


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


-- Set up all gear sets.
function init_gear_sets()
	--------------------------------------
	-- Precast sets
	--------------------------------------

	-- Precast sets to enhance JAs
	sets.precast.JA['Eagle Eye Shot'] = {legs="Arc. Braccae +1"}
	sets.precast.JA['Bounty Shot'] = {hands="Amini Glove. +1"}
	sets.precast.JA['Camouflage'] = {body="Orion Jerkin +1"}
	sets.precast.JA['Scavenge'] = {feet="Orion Socks +1"}
	sets.precast.JA['Shadowbind'] = {hands="Orion Bracers +1"}
	sets.precast.JA['Sharpshot'] = {legs="Orion Braccae +1"}


	-- Fast cast sets for spells

	sets.precast.FC = {}

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


	-- Ranged sets (snapshot)
	
	sets.precast.RA = {head="Orion Beret +1", 
	hands="Carmine Fin. Ga. +1", 
	legs="Arc. Braccae +1", 
	feet="Meg. Jam. +2",
	back={ name="Belenus's Cape", augments={'Eva.+20 /Mag. Eva.+20','"Snapshot"+10',}},}


	-- Weaponskill sets
	-- Default set for any weaponskill that isn't any more specifically defined
	sets.precast.WS = {head="Meghanada Visor +2",
    body="Mummu Jacket +2",
    hands="Meg. Gloves +2",
    legs="Mummu Kecks +2",
    feet="Meg. Jam. +2",
    neck="Fotia Gorget",
    waist="Eschan Stone",
    left_ear="Ishvara Earring",
    right_ear="Moonshade Earring",
    left_ring="Ilabrat Ring",
    right_ring="Apate Ring",
    back={ name="Belenus's Cape", augments={'AGI+20','Mag. Acc+20 /Mag. Dmg.+20','AGI+10','Weapon skill damage +10%',}},}

	--sets.precast.WS.Acc = set_combine(sets.precast.WS, {body="Kyujutsugi",ring1="Hajduk Ring +1",
		--back="Lutian Cape",legs="Orion Braccae +1"})

	-- Specific weaponskill sets.  Uses the base set if an appropriate WSMod version isn't found.
	sets.precast.WS['Trueflight'] = {head="Meghanada Visor +2",
    body="Carm. Sc. Mail +1",
    hands="Carmine Fin. Ga. +1",
    legs="Mummu Kecks +2",
    feet={ name="Herculean Boots", augments={'Attack+25','"Triple Atk."+4','Accuracy+15',}},
    neck="Sanctity Necklace",
    waist="Eschan Stone",
    left_ear="Friomisi Earring",
    right_ear="Moonshade Earring", 
    left_ring="Ilabrat Ring",
    right_ring="Apate Ring",
    back={ name="Belenus's Cape", augments={'AGI+20','Mag. Acc+20 /Mag. Dmg.+20','AGI+10','Weapon skill damage +10%',}},}
	
	sets.precast.WS['Savage Blade'] = {ammo="Eminent Arrow",
	head="Meghanada Visor +2",
    body={ name="Herculean Vest", augments={'Accuracy+22 Attack+22','Crit.hit rate+1','DEX+12','Accuracy+2','Attack+2',}},
    hands="Meg. Gloves +2",
    legs="Meg. Chausses +1",
    feet={ name="Herculean Boots", augments={'Attack+25','"Triple Atk."+4','Accuracy+15',}},
    neck="Fotia Gorget",
    waist="Prosilio Belt +1",
    left_ear={ name="Moonshade Earring", augments={'Accuracy+4','TP Bonus +250',}},
    right_ear="Ishvara Earring",
    left_ring="Ilabrat Ring",
    right_ring="Apate Ring",
    back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','AGI+1','"Store TP"+10',}},}

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

	-- Fast recast for spells
	
	sets.midcast.FastRecast = {
		head="Orion Beret +1",ear1="Loquacious Earring",
		ring1="Prolix Ring",
		waist="Pya'ekue Belt +1",legs="Orion Braccae +1",feet="Orion Socks +1"}

	sets.midcast.Utsusemi = {}

	-- Ranged sets

	sets.midcast.RA = {head="Arcadian Beret +1", 
    body="Mummu Jacket +2",
    hands="Meg. Gloves +2",
    legs="Meg. Chausses +1",
    feet="Meg. Jam. +2",
    neck="Iskur Gorget",
    waist="Eschan Stone",
    left_ear="Sherida Earring",
    right_ear="Telos Earring",
    left_ring="Ilabrat Ring",
    right_ring="Rajas Ring",
    back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','AGI+1','"Store TP"+10',}},}
	
	--sets.midcast.RA.Acc = set_combine(sets.midcast.RA,
		--{head="Orion Beret +1",neck="Ej Necklace +1",hands="Manibozho Gloves",ring2="Hajduk Ring +1",
		--back="Lutian Cape",legs="Orion Braccae +1"})

	sets.midcast.RA.Annihilator = set_combine(sets.midcast.RA)

	sets.midcast.RA.Annihilator.Acc = set_combine(sets.midcast.RA.Acc)

	sets.midcast.RA.Yoichinoyumi = set_combine(sets.midcast.RA, {ear2="Clearview Earring",ring2="Rajas Ring",
		back="Sylvan Chlamys"})

	sets.midcast.RA.Yoichinoyumi.Acc = set_combine(sets.midcast.RA.Acc, {ear2="Clearview Earring"})
	
	--------------------------------------
	-- Idle/resting/defense/etc sets
	--------------------------------------

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

	-- Resting sets
	sets.resting = {}

	-- Idle sets
	sets.idle = {head="Meghanada Visor +2",
    body="Mummu Jacket +2",
    hands="Meg. Gloves +2",
    legs={ name="Carmine Cuisses +1", augments={'Accuracy+20','Attack+12','"Dual Wield"+6',}},
    feet="Meg. Jam. +2",
    neck="Loricate Torque +1",
    waist="Flume Belt",
    left_ear="Eabani Earring",
    right_ear="Etiolation Earring",
    left_ring="Defending Ring",
    right_ring="Vocane Ring",
    back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','AGI+1','"Store TP"+10',}},}
	
	-- Defense sets
	sets.defense.PDT = {head="Meghanada Visor +2",
    body="Mummu Jacket +2",
    hands="Meg. Gloves +2",
    legs={ name="Carmine Cuisses +1", augments={'Accuracy+20','Attack+12','"Dual Wield"+6',}},
    feet="Meg. Jam. +2",
    neck="Loricate Torque +1",
    waist="Flume Belt",
    left_ear="Eabani Earring",
    right_ear="Etiolation Earring",
    left_ring="Defending Ring",
    right_ring="Vocane Ring",
    back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','AGI+1','"Store TP"+10',}},}

	sets.defense.MDT = {head="Meghanada Visor +2",
    body="Mummu Jacket +2",
    hands="Meg. Gloves +2",
    legs={ name="Carmine Cuisses +1", augments={'Accuracy+20','Attack+12','"Dual Wield"+6',}},
    feet="Meg. Jam. +2",
    neck="Loricate Torque +1",
    waist="Flume Belt",
    left_ear="Eabani Earring",
    right_ear="Etiolation Earring",
    left_ring="Defending Ring",
    right_ring="Vocane Ring",
    back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','AGI+1','"Store TP"+10',}},}

	sets.Kiting = {feet="Fajin Boots"}


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

	sets.engaged = {head="Meghanada Visor +2",
    body="Mummu Jacket +2",
    hands="Mummu Wrists +2",
    legs="Mummu Kecks +2",
    feet="Meg. Jam. +2",
    neck="Iskur Gorget",
    waist="Sarissapho. Belt",
    left_ear="Sherida Earring",
    right_ear="Telos Earring",
    left_ring="Ilabrat Ring",
    right_ring="Rajas Ring",
    back={ name="Belenus's Cape", augments={'AGI+20','Rng.Acc.+20 Rng.Atk.+20','AGI+1','"Store TP"+10',}},}

	sets.engaged.Acc = {}

	--------------------------------------
	-- Custom buff sets
	--------------------------------------

	sets.buff.Barrage = set_combine(sets.midcast.RA.Acc, {hands="Orion Bracers +1"})
	sets.buff.Camouflage = {body="Orion Jerkin +1"}
	sets.buff.Doubleshot = set_combine(sets.midcast.RA, {body="Arc. Jerkin +1"})
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 spell.action_type == 'Ranged Attack' then
		state.CombatWeapon:set(player.equipment.range)
	end

	if spell.action_type == 'Ranged Attack' or
	  (spell.type == 'WeaponSkill' and (spell.skill == 'Marksmanship' or spell.skill == 'Archery')) then
		check_ammo(spell, action, spellMap, eventArgs)
	end
	
	if state.DefenseMode.value ~= 'None' and spell.type == 'WeaponSkill' then
		-- Don't gearswap for weaponskills when Defense is active.
		eventArgs.handled = true
	end
end


-- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
function job_midcast(spell, action, spellMap, eventArgs)
	if spell.action_type == 'Ranged Attack' and state.Buff.Barrage then
		equip(sets.buff.Barrage)
		eventArgs.handled = true
	end
end

function job_post_precast(spell, action, spellMap, eventArgs)
	if player.equipment.ammo == 'Hauksbok Arrow' and (
		spell.action_type == 'Ranged Attack'
	or
		(spell.type == 'WeaponSkill' and spell.skill == 'Archery')
	or
		(spell.type == 'JobAbility' and S{'Shadowbind', 'Bounty Shot', 'Barrage','Eagle Eye Shot'}:contains(spell.name))
		) then
			add_to_chat(122, 'Aborting action to save special ammo.')
	eventArgs.cancel = true
	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 == "Camouflage" then
		if gain then
			equip(sets.buff.Camouflage)
			disable('body')
		else
			enable('body')
		end
	end
end

function job_buff_change(buff, gain)
	if buff == "Double Shot" then
		if gain then
			equip(sets.buff.Doubleshot)
			disable('body')
		else
			enable('body')
		end
	end
end

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

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

end

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

-- Check for proper ammo when shooting or weaponskilling
function check_ammo(spell, action, spellMap, eventArgs)
	-- Filter ammo checks depending on Unlimited Shot
	if state.Buff['Unlimited Shot'] then
		if player.equipment.ammo ~= U_Shot_Ammo[player.equipment.range] then
			if player.inventory[U_Shot_Ammo[player.equipment.range]] or player.wardrobe[U_Shot_Ammo[player.equipment.range]] then
				add_to_chat(122,"Unlimited Shot active. Using custom ammo.")
				equip({ammo=U_Shot_Ammo[player.equipment.range]})
			elseif player.inventory[DefaultAmmo[player.equipment.range]] or player.wardrobe[DefaultAmmo[player.equipment.range]] then
				add_to_chat(122,"Unlimited Shot active but no custom ammo available. Using default ammo.")
				equip({ammo=DefaultAmmo[player.equipment.range]})
			else
				add_to_chat(122,"Unlimited Shot active but unable to find any custom or default ammo.")
			end
		end
	else
		if player.equipment.ammo == U_Shot_Ammo[player.equipment.range] and player.equipment.ammo ~= DefaultAmmo[player.equipment.range] then
			if DefaultAmmo[player.equipment.range] then
				if player.inventory[DefaultAmmo[player.equipment.range]] then
					add_to_chat(122,"Unlimited Shot not active. Using Default Ammo")
					equip({ammo=DefaultAmmo[player.equipment.range]})
				else
					add_to_chat(122,"Default ammo unavailable.  Removing Unlimited Shot ammo.")
					equip({ammo=empty})
				end
			else
				add_to_chat(122,"Unable to determine default ammo for current weapon.  Removing Unlimited Shot ammo.")
				equip({ammo=empty})
			end
		elseif player.equipment.ammo == 'empty' then
			if DefaultAmmo[player.equipment.range] then
				if player.inventory[DefaultAmmo[player.equipment.range]] then
					add_to_chat(122,"Using Default Ammo")
					equip({ammo=DefaultAmmo[player.equipment.range]})
				else
					add_to_chat(122,"Default ammo unavailable.  Leaving empty.")
				end
			else
				add_to_chat(122,"Unable to determine default ammo for current weapon.  Leaving empty.")
			end
		elseif player.inventory[player.equipment.ammo].count < 15 then
			add_to_chat(122,"Ammo '"..player.inventory[player.equipment.ammo].shortname.."' running low ("..player.inventory[player.equipment.ammo].count..")")
		end
	end
end



-- Select default macro book on initial load or subjob change.

 Shiva.Hiep
Offline
サーバ: Shiva
Game: FFXI
user: Hiepo
Posts: 654
By Shiva.Hiep 2020-04-03 14:10:02  
Could put this in your lua to lock actions when the WSD arrow is equipped.

function job_post_precast(spell, action, spellMap, eventArgs)
if player.equipment.ammo == 'Hauksbok Arrow' and (
spell.action_type == 'Ranged Attack'
or
(spell.type == 'WeaponSkill' and spell.skill == 'Archery')
or
(spell.type == 'JobAbility' and S{'Shadowbind', 'Bounty Shot', 'Barrage','Eagle Eye Shot'}:contains(spell.name))
) then
add_to_chat(122, 'Aborting action to save special ammo.')
eventArgs.cancel = true
end

Can test it out by trying to JA/WS while targeting an npc in town.
 Shiva.Mortechai
Offline
サーバ: Shiva
Game: FFXI
user: Mortechai
Posts: 11
By Shiva.Mortechai 2020-04-03 19:19:59  
So I ran a test by switching my savage blade arrow to a vendor moogle eminent arrow to see if ranged attacking after savage blading would switch back to antlion arrows and I got the error linked below:
 Bismarck.Xurion
Offline
サーバ: Bismarck
Game: FFXI
user: Xurion
Posts: 448
By Bismarck.Xurion 2020-04-04 06:30:21  
It's difficult to say without seeing your entire file. Your above code only has about 120 lines and the error occurs on like 364.
Code
Also put your code in one of these code blocks
 Shiva.Mortechai
Offline
サーバ: Shiva
Game: FFXI
user: Mortechai
Posts: 11
By Shiva.Mortechai 2020-04-05 21:21:52  
Bismarck.Xurion said: »
It's difficult to say without seeing your entire file. Your above code only has about 120 lines and the error occurs on like 364.
Code
Also put your code in one of these code blocks


Ty for the tip buddy! I added the whole lua onto the OP, still trying to figure a way around this issue :(
Log in to post.