GearSwap: Need Help Changing Weapon

言語: JP EN DE FR
2010-06-21
New Items
users online
フォーラム » Windower » Support » GearSwap: Need help changing weapon
GearSwap: Need help changing weapon
Offline
Posts: 8
By militades 2020-05-24 00:17:06  
Hi All,

Not sure if this question has been asked before, if there is something similar and I didn't see it, you can refer me to that thread. I'm no programmer so I'm struggling to alter the lua I ripped of the internet to do the following: -

1. Change weapon based on keystroke

This is what I added not sure what I am doing wrong (bold are what I added)

function get_sets()
mote_include_version = 2

-- Load and initialize the include file.
include('Mote-Include.lua')
end
function user_setup()
state.OffenseMode:options('Normal', 'Acc')
state.HybridMode:options('Normal', 'PDT', 'Reraise')
state.WeaponskillMode:options('Normal', 'Acc')
state.CastingMode:options('Normal', 'Resistant')
state.PhysicalDefenseMode:options('PDT', 'HP', 'Reraise', 'Charm')
state.MagicalDefenseMode:options('MDT', 'HP', 'Reraise', 'Charm')
state.ExtraDefenseMode = M{['description']='Extra Defense Mode', 'None', 'MP', 'Knockback', 'MP_Knockback'}
state.CombatWeapon = M('KOTR','Savage')
state.EquipShield = M(false, 'Equip Shield w/Defense')

update_defense_mode()

-- Allows the use of Ctrl + ~ and Alt + ~ for 2 more macros of your choice.
send_command('bind !` input /ja "Intervene" <stnpc>') --Ctrl'~'
send_command('bind ^` input /ja "Invincible" <me>') --Alt'~'
send_command('bind ^f11 gs c cycle MagicalDefenseMode') --^ means ctrl
send_command('bind !f11 gs c cycle ExtraDefenseMode') -- ! means alt
send_command('bind @f1 gs c cycle CombatWeapon')
send_command('bind @f10 gs c toggle EquipShield') --@ means windows button
send_command('bind @f11 gs c toggle EquipShield')

select_default_macro_book()
end

function init_gear_sets()
--------------------------------------
-- Weapons
--------------------------------------

sets.weapon = {}
sets.weapon.KOTR = {main="Excalibur",}
sets.weapon.Savage = {main="Kaja Sword",}
end

-- Equip Weapon
function equip_weapon(weaponSet)
if state.weapon.value ~= 'KOTR' then
equip(sets.weapon.KOTR)
end

if state.weapon.value ~= 'Savage' then
equip(sets.weapon.Savage)
end

return weaponSet
end


Any help is greatly appreciated

--- Edited post to show what I did instead of the chunk --
[+]
Offline
Posts: 8
By militades 2020-05-24 10:03:27  
My entire lua file below, if someone can point me in the right direction how do I create the keybind to change the weapon.
I'm trying to do it as I am using 2 seperate lua files now for the 2 weapons. Was thinking of simplifying my updating with only 1 lua and a keybind to select weapon.
Offline
Posts: 8
By militades 2020-05-25 00:16:58  
Figured out my problem for those interested in doing something similar

The appropriate place to add the weapon changes are in the melee/idle functions

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

-- 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_defense_mode()
end

-- 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
if state.Buff.Doom then
idleSet = set_combine(idleSet, sets.buff.Doom)
end

if state.CombatWeapon.value == 'KOTR' then
idleSet = set_combine(idleSet, sets.weapons.KOTR)
end

if state.CombatWeapon.value == 'Savage' then
idleSet = set_combine(idleSet, sets.weapons.Savage)
end


return idleSet
end



-- Modify the default melee set after it was constructed.
function customize_melee_set(meleeSet)
if state.Buff.Doom then
meleeSet = set_combine(meleeSet, sets.buff.Doom)
end

if state.CombatWeapon.value == 'KOTR' then
meleeSet = set_combine(meleeSet, sets.weapons.KOTR)
end

if state.CombatWeapon.value == 'Savage' then
meleeSet = set_combine(meleeSet, sets.weapons.Savage)
end


return meleeSet
end

function customize_defense_set(defenseSet)
if state.ExtraDefenseMode.value ~= 'None' then
defenseSet = set_combine(defenseSet, sets[state.ExtraDefenseMode.value])
end

if state.EquipShield.value == true then
defenseSet = set_combine(defenseSet, sets[state.DefenseMode.current .. 'Shield'])
end

if state.Buff.Doom then
defenseSet = set_combine(defenseSet, sets.buff.Doom)
end

if state.CombatWeapon.value == 'KOTR' then
defenseSet = set_combine(defenseSet, sets.weapons.KOTR)
end

if state.CombatWeapon.value == 'Savage' then
defenseSet = set_combine(defenseSet, sets.weapons.Savage)
end


return defenseSet
end

My lua file for reference, I did some changes which defers from my previous post (e.g. weapons instead of weapon etc)
[+]
necroskull Necro Bump Detected! [139 days between previous and next post]
 Ragnarok.Obijam
Offline
サーバ: Ragnarok
Game: FFXI
user: obijam
Posts: 2
By Ragnarok.Obijam 2020-10-11 09:22:27  
Just wanted to say thank you for posting this. Was exactly what i was looking for and worked perfectly.
Log in to post.