|
Scholar Gearswap .lua
Bismarck.Snprphnx
Serveur: Bismarck
Game: FFXI
Posts: 2707
By Bismarck.Snprphnx 2013-12-16 19:25:26
Posted below is a _SCH.lua file that I wrote using Byrths original file as an example, and tweaked and edited to work out any errors. I will not call it complete, due to me potentially missing specific rules for certain JAs or spells. However, I would say that it covers the majority of what is needed.
If you have any questions about it, please feel free to post them here for Byrths or myself to answer. Also, if you noticed I missed anything crucial, let me know and we can add it in.
This same file is included in the Gearswap download in the examples section, and I will try to keep it as up-to-date as possible.
Code function get_sets()
sets = {}
sets.aftercast_Idle_noSub = {main="Owleyes",sub="Genbu's Shield",ammo="Incantor Stone",
head="Savant's bonnet +2",neck="Twilight Torque",ear1="Lifestorm Earring",ear2="Loquacious Earring",
body="Hagondes Coat",hands="Serpentes Cuffs",ring1="Sangoma Ring",ring2="Maquette Ring",
back="Shadow Mantle",waist="Korin Obi",legs="Nares Trews",feet="Serpentes Sabots"}
sets.aftercast_Idle_Sub = {main="Owleyes",sub="Genbu's Shield",ammo="Incantor Stone",
head="Savant's bonnet +2",neck="Twilight Torque",ear1="Savant's Earring",ear2="Loquacious Earring",
body="Hagondes Coat",hands="Serpentes Cuffs",ring1="Sangoma Ring",ring2="Maquette Ring",
back="Shadow Mantle",waist="Korin Obi",legs="Nares Trews",feet="Serpentes Sabots"}
sets.aftercast_Idle = sets.aftercast_Idle_noSub
sets.precast_FastCast = {ammo="Incantor Stone",head="Nahtirah Hat",ear2="Loquacious Earring",
body="Anhur Robe",hands="Gendewitha Gages",back="Swith Cape",legs="Orvail Pants",feet="Chelona Boots"}
sets.Resting = {main="Chatoyant Staff",sub="Mephitis Grip",
head="Nahtirah Hat",neck="Twilight Torque",ear1="Lifestorm Earring",ear2="Loquacious Earring",
body="Hagondes Coat",hands="Nares Cuffs",ring1="Sangoma Ring",ring2="Maquette Ring",
back="Shadow Mantle",waist="Korin Obi",legs="Nares Trews",feet="Chelona Boots"}
sets.midcast_ElementalMagic = {main="Atinian Staff",sub="Wizzan Grip",ammo="Witchstone",
head="Nares Cap",neck="Eddy Necklace",ear1="Hecate's Earring",ear2="Novio Earring",
body="Hagondes Coat",hands="Yaoyotl Gloves",ring1="Strendu Ring",ring2="Icesoul Ring",
back="Searing Cape",waist="Maniacus Sash",legs="Hagondes Pants",feet="Bokwus Boots"}
sets.midcast_DarkMagic = {main="Chatoyant Staff",sub="Arbuda Grip",ammo="Hasty Pinion",
head="Appetence Crown",neck="Aesir Torque",ear1="Hirudinea Earring",ear2="Loquacious Earring",
body="Hedera Cotehardie",hands="Ayao's Gages",ring1="Balrahn's Ring",ring2="Excelsis Ring",
back="Merciful Cape",waist="Goading Belt",legs="Auspex Slops",feet="Bokwus Boots"}
sets.midcast_EnfeeblingMagic = {main="Atinian Staff",sub="Mephitis Grip",ammo="Savant's Treatise",
head="Nahtirah Hat",neck="Eddy Necklace",ear1="Lifestorm Earring",ear2="Psystorm Earring",
body="Hedera Cotehardie",hands="Hagondes Cuffs",ring1="Sangoma Ring",ring2="Maquette Ring",
back="Merciful Cape",waist="Cascade Belt",legs="Orvail Pants",feet="Rubeus Boots"}
sets.midcast_Impact = {main="Atinian Staff",sub="Wizzan Grip",ammo="Witchstone",
neck="Eddy Necklace",ear1="Hecate's Earring",ear2="Novio Earring",
hands="Yaoyotl Gloves",ring1="Strendu Ring",ring2="Icesoul Ring",
back="Searing Cape",waist="Maniacus Sash",legs="Hagondes Pants",feet="Bokwus Boots"}
sets.midcast_Embrava = {main="Kirin's Pole",sub="Fulcio Grip",ammo="Savant's Treatise",
head="Svnt. Bonnet +2",neck="Colossus's Torque",ear1="Lifestorm Earring",ear2="Loquacious Earring",
body="Anhur Robe",hands="Savant's Bracers +2",
back="Merciful Cape",waist="Cascade Belt",legs="Shedir Seraweels",feet="Rubeus Boots"}
sets.midcast_EnhancingMagic = {main="Kirin's Pole",sub="Fulcio Grip",ammo="Incantor Stone",
head="Nahtirah Hat",neck="Colossus's Torque",ear1="Lifestorm Earring",ear2="Loquacious Earring",
body="Anhur Robe",hands="Gendewitha Gages",
back="Swith Cape",waist="Ninurta's Sash",legs="Orvail Pants",feet="Chelona Boots"}
sets.precast_Stun = {main="Apamajas II",sub="Mephitis Grip",ranged="Aureole",
head="Nahtirah Hat",neck="Eddy Necklace",ear1="Lifestorm Earring",ear2="Psystorm Earring",
body="Hedera Cotehardie",hands="Gendewitha Gages",ring1="Sangoma Ring",ring2="Maquette Ring",
back="Swith Cape",waist="Ninurta's Sash",legs="Bokwus Slops",feet="Argute Loafers +2"}
sets.midcast_Cure = {main="Chatoyant Staff",head="Paean Mitra",neck="Phalaina Locket",
body="Anhur Robe",hands="Bokwus Gloves",back="Oretanis's Cape",legs="Nares Trews"}
sets.midcast_Helix = {main="Chatoyant Staff",sub="Wizzan Grip",ammo="Snow Sachet",
head="Nahtirah Hat",neck="Stoicheion Medal",ear1="Hecate's Earring",ear2="Novio Earring",
body="Nares Saio",hands="Nares Cuffs",ring1="Icesoul Ring",ring2="Icesoul Ring",
back="Twilight Cape",waist="Wanion Belt",legs="Akasha Chaps",feet="Nares Clogs"}
sets.midcast_Stoneskin = {main="Kirin's Pole",neck="Stone Gorget",waist="Siegel Sash",legs="Shedir Seraweels"}
sets.Obi = {}
sets.Obi.Fire = {waist='Karin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.Obi.Earth = {waist='Dorin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.Obi.Water = {waist='Suirin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.Obi.Wind = {waist='Furin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.Obi.Ice = {waist='Hyorin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.Obi.Thunder = {waist='Rairin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.Obi.Light = {waist='Korin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.Obi.Dark = {waist='Anrin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.staves = {}
sets.staves.damage = {}
sets.staves.damage.Thunder = {main="Apamajas I"}
sets.staves.damage.Fire = {main="Atar I"}
sets.staves.accuracy = {}
sets.staves.damage.Thunder = {main="Apamajas II"}
sets.staves.damage.Ice = {main="Vourukasha II"}
stuntarg = 'Shantotto'
end
function precast(spell,action)
if spell.english == 'Impact' then
cast_delay(2)
equip(sets['precast_FastCast'],{body="Twilight Cloak"})
if not buffactive['elemental seal'] then
add_to_chat(8,'--------- Elemental Seal is down ---------')
end
elseif spell.skill=='ElementalMagic' and spell.casttime < 3 then
cast_delay(0.1)
equip(sets.midcast_ElementalMagic)
if spell.element == 'Earth' then
equip({neck="Quanpur Necklace"})
end
if spell.element == world.weather_element or spell_element == world.day_element and sets.Obi[spell.element] then
equip(sets.Obi[spell.element])
end
elseif spell.english == 'Stun' then
cast_delay(0.1)
equip(sets['precast_Stun'])
if not buffactive.thunderstorm then
add_to_chat(8,'--------- Thunderstorm is down ---------')
elseif not buffactive.klimaform then
add_to_chat(8,'----------- Klimaform is down -----------')
end
if stuntarg ~= 'Shantotto' then
send_command('@input /t '..stuntarg..' ---- Byrth Stunned!!! ---- ')
end
else
equip(sets['precast_FastCast'])
cast_delay(0.5)
end
if (buffactive.alacrity or buffactive.celerity) and world.weather_element == spell.element then
equip({feet='Argute Loafers +2'})
end
end
function midcast(spell,action)
if string.find(spell.english,'Cur') then
equip(sets.midcast_Cure)
if spell.element == world.weather_element or spell_element == world.day_element then
equip({main="Chatoyant Staff"},sets.Obi[spell.element])
end
if buffactive.rapture then
equip({head="Savant's Bonnet +2"})
end
elseif spell.english == 'Impact' then
local tempset = sets['midcast_Impact']
tempset['body'] = 'Twilight Cloak'
tempset['head'] = empty
equip(tempset)
if spell.element == world.weather_element or spell_element == world.day_element then
equip(sets.Obi[spell.element])
end
if sets.staves.damage[spell.element] then
equip(sets.staves.damage[spell.element])
end
elseif spell.skill=="ElementalMagic" then
if string.find(spell.english,'helix') then
equip(sets['midcast_Helix'])
else
equip(sets.midcast_ElementalMagic)
if spell.element=='Earth' then
equip({neck="Quanpur Necklace"})
end
if spell.element == world.weather_element or spell_element == world.day_element then
equip(sets.Obi[spell.element])
end
end
if buffactive.ebullience then
equip({head="Savant's Bonnet +2"})
end
if buffactive.klimform then
equip ({feet="Savant's Loafers +2"})
end
elseif spell.english == 'Stoneskin' then
equip(sets['midcast_Stoneskin'])
elseif spell.skill == 'EnhancingMagic' then
if spell.english == 'Embrava' then
equip(sets['midcast_Embrava'])
if not buffactive.perpetuance then
add_to_chat(8,'--------- Perpetuance is down ---------')
end
if not buffactive.accession then
add_to_chat(8,'--------- Accession is down ---------')
end
if not buffactive.penury then
add_to_chat(8,'--------- Penury is down ---------')
end
end
if buffactive.perpetuance then
equip(sets['midcast_EnhancingMagic'],{hands="Savant's Bracers +2"})
else
equip(sets['midcast_EnhancingMagic'])
end
else
weathercheck(spell.element,sets['midcast_'..spell.skill])
end
if spell.english == 'Sneak' then
send_command('@wait 1.8;cancel 71;')
end
end
function aftercast(spell,action)
equip(sets['aftercast_Idle'])
if spell.english == 'Sleep' or spell.english == 'Sleepga' 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
end
function status_change(new,tab)
if new == 'Resting' then
equip(sets['Resting'])
else
equip(sets['aftercast_Idle'])
end
end
function buff_change(status,gain_or_loss)
if status == 'Sublimation: Complete' and gain_or_loss == 'gain' and not 'stunmode' then -- True whether gained or lost
sets.aftercast_Idle = sets.aftercast_Idle_noSub
elseif status == 'Sublimation: Activated' and gain_or_loss == 'gain' and not 'stunmode' then
sets.aftercast_Idle = sets.aftercast_Idle_Sub
end
equip(sets.aftercast_Idle)
end
function pet_midcast(spell,action)
end
function pet_aftercast(spell,action)
end
function self_command(command)
if command == 'stuntarg' then
stuntarg = target.name
elseif command == 'stunmode' then
windower.add_to_chat(100,'Stun Mode')
if sets.aftercast_Idle ~= sets.precast_Stun then
stunmode = true
sets.aftercast_Idle = sets.precast_Stun
elseif buffactive['Sublimation: Activated'] then
stunmode = false
sets.aftercast_Idle = sets.aftercast_Idle_Sub
else
stunmode = false
sets.aftercast_Idle = sets.aftercast_Idle_noSub
end
equip(sets.aftercast_Idle)
end
end
-- This function is user defined, but never called by GearSwap itself. It's just a user function that's only called from user functions. I wanted to check the weather and equip a weather-based set for some spells, so it made sense to make a function for it instead of replicating the conditional in multiple places.
function weathercheck(spell_element,set)
if spell_element == world.weather_element or spell_element == world.day_element then
equip(set,sets['Obi_'..spell_element])
else
equip(set)
end
end
[+]
Serveur: Cerberus
Game: FFXI
Posts: 1809
By Cerberus.Shadowmeld 2013-12-17 08:59:50
Kind of curious as I haven't really looked at gearswap yet, does it have the ability to have subsets of gear? For example, lets say you have a set added to your .lua called Refresh.
Code
sets.Refresh = {head="Nefer Khat", body="Heka's Kalasiris", hands="Serpentes Cuffs", legs="Nares Trews", feet="Serpentes Sabots"}
Could you add this set as a base for an Idle set or something.
Code
sets.Idle = sets.Refresh + {neck="Twilight Torque"}
Obviously, I am unpracticed with lua, so I don't know how you would actually do the addition, just curious if the concept is there.
Lakshmi.Byrth
VIP
Serveur: Lakshmi
Game: FFXI
Posts: 6193
By Lakshmi.Byrth 2013-12-17 09:16:19
Yeah, this will make a set as you described: Code sets.Idle = set_combine(sets.Refresh,{neck="Twilight Torque"})
Serveur: Cerberus
Game: FFXI
Posts: 1809
By Cerberus.Shadowmeld 2013-12-17 09:55:24
So, how does it handle overlap. If your refresh set had a neck piece, would the {neck="Twilight Torque"} overwrite the neck in the refresh set? Is there a way to lock gear to not be overwritten?
Lakshmi.Byrth
VIP
Serveur: Lakshmi
Game: FFXI
Posts: 6193
By Lakshmi.Byrth 2013-12-17 10:08:03
It replaces from left to right. If you want to lock a slot, use disable(slot name).
Bismarck.Mazikeen
Serveur: Bismarck
Game: FFXI
Posts: 3
By Bismarck.Mazikeen 2013-12-17 10:14:54
What is the benefit to using gearswap over spellcast? I'm extremely happy with my modified Motenten spellcast right now and can't see the benefit of learning a new system.
Leviathan.Behemothx
Serveur: Leviathan
Game: FFXI
Posts: 323
By Leviathan.Behemothx 2013-12-17 10:18:41
Bismarck.Mazikeen said: »What is the benefit to using gearswap over spellcast? I'm extremely happy with my modified Motenten spellcast right now and can't see the benefit of learning a new system.
It's probably too hard to maintain since it breaks every update.
Lakshmi.Byrth
VIP
Serveur: Lakshmi
Game: FFXI
Posts: 6193
By Lakshmi.Byrth 2013-12-17 10:55:40
Serveur: Cerberus
Game: FFXI
Posts: 1809
By Cerberus.Shadowmeld 2013-12-17 11:13:45
Byrth, what would it take to add a method sets_combine that combines > 2 sets. In pseudocode something like this.
Code
function sets_combine(...)
tempsets= {...}
combinedset = {}
for each set in tempsets
combinedset = set_combine(combinedset, set)
end
I omitted some psuedocode for error handling, but would this be possible? The reason I ask is my current method of building sets is using a lot of 'basesets'
Additionally, how does gearswap do with the feature of spellcast where equip commands within a certain time (~0.5 seconds) don't always process correctly?
Lakshmi.Byrth
VIP
Serveur: Lakshmi
Game: FFXI
Posts: 6193
By Lakshmi.Byrth 2013-12-17 11:30:02
I'm pretty sure set_combine takes an arbitrary number of sets and combines them.
If you don't need to precompose the set for some reason, the equip command also takes an arbitrary number of sets and collapses them leftwards (so the rightmost set gets priority for slot assignments, then next rightmost, etc.)
When I say ambivalent things like "I'm pretty sure," keep in mind that GearSwap has been in its current form with only minor alterations since ~August.
Serveur: Cerberus
Game: FFXI
Posts: 1809
By Cerberus.Shadowmeld 2013-12-17 11:36:03
This is mostly just personal preference on my part, I like keeping my rules as simple as possible on spellcast, so in order to do that I will make one set for a rule, such as Idle for an idle set, and then I will add basesets as needed such as Refresh for refresh gear or PDT when needed. I prefer to precompose them in order to keep the rules as simple as possible. I will play around with this and see how I like it.
I added this above, but you were already responding, so I will ask it again. Does gearswap also have the same problem as spellcast where if commands process to quickly in succession they won't equip properly. Such as nuking and you idle in hagondes coat, switch to anhur robe for fast cast and then it fails to switch back to hagondes coat because it still sees it as equipped.
Edit: I was looking at the lua and the set_combine method has an explicit number of parameters whereas the equip method is stated equip(...). I'll see if I can do multiple sets.
Lakshmi.Byrth
VIP
Serveur: Lakshmi
Game: FFXI
Posts: 6193
By Lakshmi.Byrth 2013-12-17 12:32:55
Okay, I can adjust set_combine to take a variable number of arguments tonight. If you don't mind, could you please open an issue for it? ( https://github.com/Byrth/Lua/issues )
GearSwap does not have that issue, because it is sending equip packets directly. That issue was due to the game refusing to send equip packets for currently equipped gear. It's like this:
* You enter an /equip command
* Game checks to see if you can equip the item (right slot? right race? right gender? right level? right job? is it already equipped? in a menu?)
* Game sends an equip packet if all those conditions are met.
* Server sends back an equip packet, along with a few other item change packets that set the inventory status to "equipped." Now your gear changes.
So if you sent two equip commands rapidly, the second one would hit before the equip packet had arrived from the server. Thus your equip command would be canceled because you were still wearing the item.
GearSwap bypasses this (and every other native check) by sending the equip packets itself. I've recreated most of the checks, but have intentionally left out the menu check and have changed the "is it equipped?" check so that this issue doesn't occur.
Serveur: Cerberus
Game: FFXI
Posts: 1809
By Cerberus.Shadowmeld 2013-12-17 13:18:13
I will gladly do that Byrth.
Woo Hoo!!!! That is truly great to hear, that might have convinced me to switch to Gearswap from spellcast.
Serveur: Cerberus
Game: FFXI
Posts: 1809
By Cerberus.Shadowmeld 2013-12-18 08:38:44
I have another question. How does gearswap deal with fast cast on gear? In my spellcast I have a very extensive set of rules for calculating fast cast so I can more efficiently swap gear. Because aftercast basically just automatically defaults to the cast time of the spell + 1 second or so, I was wondering whether gearswap actually dealt with the fast cast gear itself or if those extensive calculations would still need to be done.
The case I am trying to address is long cast time spells like tier 5 nukes (cast time is 10 seconds). With my fast cast gear + grimoire + elemental staves, I cast them in about 1.8 seconds. With spellcast, if I let it do its normal processing, aftercast action gives me ~9 seconds of idling in my casting gear and not my refresh/pdt idle set.
Would gearswap have this same problem?
Cerberus.Conagh
Serveur: Cerberus
Game: FFXI
Posts: 3189
By Cerberus.Conagh 2013-12-18 15:26:18
As soon as the packet leaves saying "you are casting" it swaps, this is another benefit to Packet version gearswaps instead of Spellcast.
Phoenix.Aerolite
Serveur: Phoenix
Game: FFXI
Posts: 45
By Phoenix.Aerolite 2013-12-19 19:14:29
I tried that example .lua file out, and I was wondering if there's a way to get the precast swap only to occur for spells? It was kind of annoying having to gearswap every time I used light arts or a stratagem.
Also, the sublimation rule in that file doesn't work. It doesn't switch into my sublimation gear when it's activated.
Fenrir.Jinjo
VIP
Serveur: Fenrir
Game: FFXI
Posts: 2269
By Fenrir.Jinjo 2013-12-19 19:25:16
if action.type ~= "Magic" then return end
[+]
Phoenix.Aerolite
Serveur: Phoenix
Game: FFXI
Posts: 45
By Phoenix.Aerolite 2013-12-19 20:32:52
if action.type ~= "Magic" then return end Thanks! I'm still having trouble with the sublimation set though! I thought maybe it was like spellcast where I would have to cast a spell before gearswap would recognize that it's active, but it doesn't even do that.
Serveur: Odin
Game: FFXI
Posts: 170
By Odin.Quixacotl 2013-12-24 03:01:20
Thanks! I'm still having trouble with the sublimation set though! I was also having probs with the sublimation set not firing but was able to find a fix.
Right out of the box, Snprphnx's following code doesn't work as it should. Code
function buff_change(status,gain_or_loss)
if status == 'Sublimation: Complete' and gain_or_loss == 'gain' and not 'stunmode' then -- True whether gained or lost
sets.aftercast_Idle = sets.aftercast_Idle_noSub
elseif status == 'Sublimation: Activated' and gain_or_loss == 'gain' and not 'stunmode' then
sets.aftercast_Idle = sets.aftercast_Idle_Sub
end
equip(sets.aftercast_Idle)
end
What I did was to follow my own xml code and put the check in function aftercast where it belongs. Now it works. Code
function aftercast(spell,action)
if not spell.english['Sublimation'] and buffactive['Sublimation: Activated'] and 'stunmode' ~= 'true' then
equip(sets['aftercast_Idle_Sub'])
elseif spell.english == 'Sublimation' and not buffactive['Sublimation: Activated'] and 'stunmode' ~= 'true' then
equip(sets['aftercast_Idle_Sub'])
else
equip(sets['aftercast_Idle_noSub'])
end
end
function buff_change(status,gain_or_loss)
if status == 'Sublimation: Activated' and gain_or_loss == 'loss' and'stunmode' ~= 'true' then
equip(sets['aftercast_Idle_noSub'])
sets.aftercast_Idle = sets.aftercast_Idle_noSub
end
end
I also found some other discrepancies which I was able to fix. I've been using a variant based on Mortensen's xml (read: butchered and rewritten) and just now getting into lua. Below is my own SCH lua (if anyone is interested). It is based on Snprphnx's lua and a WIP. I'm still trying to figure out how to add multiple layers based on active strategems. =/
http://pastebin.com/aKm0D4xv
[+]
Serveur: Cerberus
Game: FFXI
Posts: 1809
By Cerberus.Shadowmeld 2013-12-25 11:41:31
Adding my 2 cents, been working on this for about a week but I have a good bit of the logic from motenten's sch.xml translated over for strategems and stuff, I also added aliases so you can just type //addend or //cost to fire off the strats in game.
It has fairly extensive processing to build dynamic sets when casting spells, including active strategems. I only have savant's gloves at the moment though, so that was the only testing I have done so far. I still have a long way to go, but this is a good first draft for me. Good enough that I am willing to let people see at least.
I still need to add processing for using spells that require addendums and some other rules. I am also working on implementing the strategem queue, but that has taken a back seat to getting it to work. Here it is.
http://pastebin.com/AeERyE2X
Bismarck.Snprphnx
Serveur: Bismarck
Game: FFXI
Posts: 2707
By Bismarck.Snprphnx 2013-12-25 20:25:59
Thanks! I'm still having trouble with the sublimation set though! I was also having probs with the sublimation set not firing but was able to find a fix.
Right out of the box, Snprphnx's following code doesn't work as it should. Code
function buff_change(status,gain_or_loss)
if status == 'Sublimation: Complete' and gain_or_loss == 'gain' and not 'stunmode' then -- True whether gained or lost
sets.aftercast_Idle = sets.aftercast_Idle_noSub
elseif status == 'Sublimation: Activated' and gain_or_loss == 'gain' and not 'stunmode' then
sets.aftercast_Idle = sets.aftercast_Idle_Sub
end
equip(sets.aftercast_Idle)
end
What I did was to follow my own xml code and put the check in function aftercast where it belongs. Now it works. Code
function aftercast(spell,action)
if not spell.english['Sublimation'] and buffactive['Sublimation: Activated'] and 'stunmode' ~= 'true' then
equip(sets['aftercast_Idle_Sub'])
elseif spell.english == 'Sublimation' and not buffactive['Sublimation: Activated'] and 'stunmode' ~= 'true' then
equip(sets['aftercast_Idle_Sub'])
else
equip(sets['aftercast_Idle_noSub'])
end
end
function buff_change(status,gain_or_loss)
if status == 'Sublimation: Activated' and gain_or_loss == 'loss' and'stunmode' ~= 'true' then
equip(sets['aftercast_Idle_noSub'])
sets.aftercast_Idle = sets.aftercast_Idle_noSub
end
end
I also found some other discrepancies which I was able to fix. I've been using a variant based on Mortensen's xml (read: butchered and rewritten) and just now getting into lua. Below is my own SCH lua (if anyone is interested). It is based on Snprphnx's lua and a WIP. I'm still trying to figure out how to add multiple layers based on active strategems. =/
http://pastebin.com/aKm0D4xv
Thank you for finding the issue. The file posted in the OP did work, however shortly after posting it, the windower dev team pushed an update that borked the logic somehow. Even Byrth was stumped as to why it wasn't working. Between working OT and the holidays, I hadn't had a chance to log in for more that 5 minutes to figure it out.
Also, thank you for the line change for swapping to precast gear for magic only. Again, it was something that was minor, and I was planning in to addressing this coming weekend.
VIP
Serveur: Fenrir
Game: FFXI
Posts: 764
By Fenrir.Motenten 2013-12-25 21:12:43
This is improperly formatted: Code if status == 'Sublimation: Complete' and gain_or_loss == 'gain' and not 'stunmode' then -- True whether gained or lost
You have [not 'stunmode'], however by quoting 'stunmode' you're making a string, not referring to a variable. Since it's an explicit string, 'stunmode' will also be considered True in a boolean check, which means that the overall line will -always- be False.
Take the quotes off from around 'stunmode' for it to work properly.
As a followup, Quixacotl's statement that that code 'belongs' in the aftercast() section is also false. Aftercast may make use of which sublimation set you want to use, but it would be best to define the set within the buff_change() function, since that will always tell you immediately when the buff is added or removed, whereas aftercast() has to wait for you to take action.
Next, Qixacotl's correction adds a new error: Code if status == 'Sublimation: Activated' and gain_or_loss == 'loss' and'stunmode' ~= 'true' then
In this case, he tried to fix the [not 'stunmode'] error with ['stunmode' ~= 'true']. However, he's still using strings, so it will do a literal comparison of the string 'stunmode' with the string 'true'. Since those are explicitly not the same, the comparison of 'stunmode' ~= 'true' will always be true.
For this, stunmode is a variable, so should not be in quotes, and true is a boolean value, so should also not be in quotes.
Speaking of stunmode as a variable: It's not defined or given a default value in the get_sets() function. As such, its value will be nil until it's actually toggled. This is not really a bad thing, since nil is the same as false as far as the boolean check goes, but it's not as clear since you never declare the variable at the top of the script, so you don't know that it exists.
Anyway, I've been building a few of my Spellcast scripts into lua, and they're coming along pretty well. I've done a few simple ones so far. Going to try a couple complicated ones now (thf and sch).
VIP
Serveur: Fenrir
Game: FFXI
Posts: 764
By Fenrir.Motenten 2013-12-25 21:24:10
Oh, and a simple way that I'd do those sublimation sets:
Code
function get_sets()
sets.idle = {} -- normal idle gear
sets.idle.Sublimation = {} -- idle gear with sublimation gear
state.IdleMode = 'Normal'
state.StunMode = false
end
function buff_change(buff, gain_or_lose)
if buff == "Sublimation: Activated" then
if gain_or_lose == 'gain' and not state.StunMode then
state.IdleMode = 'Sublimation'
else
state.IdleMode = 'Normal'
end
end
update_gear_sets(player.status)
end
function aftercast(spell, action)
update_gear_sets(player.status)
end
function update_gear_sets(status)
if status == 'idle' then
if sets.idle[state.IdleMode] then
equip(sets.idle[state.IdleMode])
else
equip(sets.idle)
end
elseif status == 'engaged'
-- etc...
end
end
Serveur: Odin
Game: FFXI
Posts: 170
By Odin.Quixacotl 2013-12-26 00:56:54
Bismarck.Snprphnx said: »Thank you for finding the issue. The file posted in the OP did work, however shortly after posting it, the windower dev team pushed an update that borked the logic somehow. Even Byrth was stumped as to why it wasn't working. Between working OT and the holidays, I hadn't had a chance to log in for more that 5 minutes to figure it out.
Also, thank you for the line change for swapping to precast gear for magic only. Again, it was something that was minor, and I was planning in to addressing this coming weekend. It's all good. :) Lua is all very new to me so I'm still learning as I go along. I do have some understanding of code logic and a fast learner so whatever I find I'm more than happy to share with our community. I do see the advantages and potential that lua has over xmls'
As a followup, Quixacotl's statement that that code 'belongs' in the aftercast() section is also false. Aftercast may make use of which sublimation set you want to use, but it would be best to define the set within the buff_change() function, since that will always tell you immediately when the buff is added or removed, whereas aftercast() has to wait for you to take action.
Next, Qixacotl's correction adds a new error: Code if status == 'Sublimation: Activated' and gain_or_loss == 'loss' and'stunmode' ~= 'true' then
In this case, he tried to fix the [not 'stunmode'] error with ['stunmode' ~= 'true']. However, he's still using strings, so it will do a literal comparison of the string 'stunmode' with the string 'true'. Since those are explicitly not the same, the comparison of 'stunmode' ~= 'true' will always be true.
For this, stunmode is a variable, so should not be in quotes, and true is a boolean value, so should also not be in quotes.
Speaking of stunmode as a variable: It's not defined or given a default value in the get_sets() function. As such, its value will be nil until it's actually toggled. This is not really a bad thing, since nil is the same as false as far as the boolean check goes, but it's not as clear since you never declare the variable at the top of the script, so you don't know that it exists. Yea I discovered the error once I switched to stun mode and found, to my dismay, that I couldn't stay idled in stun gear. So it was back to the drawing board for me.
Quote: Anyway, I've been building a few of my Spellcast scripts into lua, and they're coming along pretty well. I've done a few simple ones so far. Going to try a couple complicated ones now (thf and sch).
Oh, and a simple way that I'd do those sublimation sets: Thanks for the explaination and the Sublimation code. That makes a lot more sense and certainly helps a lot.
I'm looking forward to seeing your results. I have to admit there's a lot I don't know and having some issues of my own as I'm writing Lua code on the fly. But for me it presents new challenges and gets my interest peaked. Whatever ideas I've learned for xmls and lua I've gotten from yours and others' examples. You are da man!
Necro Bump Detected!
[177 days between previous and next post]
Quetzalcoatl.Setsuai
Serveur: Quetzalcoatl
Game: FFXI
Posts: 61
By Quetzalcoatl.Setsuai 2014-06-20 18:05:28
So I have a question regarding gearswap. Would there be a reason it wouldn't be swapping to my nuking gear? On sch it swaps to the cure gear no problem, but it won't swap to nukes. The same problem is happening on my blm, expcept it won't even swap to cure gear. I just started using gearswap not even a week ago, so it could just be the fact that I'm new to the system. Any help is appreciated.
Bismarck.Snprphnx
Serveur: Bismarck
Game: FFXI
Posts: 2707
By Bismarck.Snprphnx 2014-06-20 18:55:32
Post a link to your .lua. Without seeing the code, we can't troubleshoot
Serveur: Ragnarok
Game: FFXI
Posts: 585
By Ragnarok.Presidentobama 2014-06-20 19:20:59
How exactly do I install and activate this file for my sch?
Bismarck.Snprphnx
Serveur: Bismarck
Game: FFXI
Posts: 2707
By Bismarck.Snprphnx 2014-06-20 19:38:26
1. Copy/Edit the file and save it as a .lua file, as charactername.lua
2. save it into the \addons\Gearswap\data folder.
3. Load Gearswap in ffxi
From there, the file should be auto loaded and run.
Quetzalcoatl.Setsuai
Serveur: Quetzalcoatl
Game: FFXI
Posts: 61
By Quetzalcoatl.Setsuai 2014-06-20 20:40:58
It's okay. I figured it out. It was because I was typing in commands for spells like I normally do instead of menu casting them.
Bismarck.Snprphnx
Serveur: Bismarck
Game: FFXI
Posts: 2707
By Bismarck.Snprphnx 2014-06-20 20:44:44
You should still be able to type them in. Like my macros have a single line in them, example: /ma "Thunder V" <t> or /ja "Rapture" <me>
Posted below is a _SCH.lua file that I wrote using Byrths original file as an example, and tweaked and edited to work out any errors. I will not call it complete, due to me potentially missing specific rules for certain JAs or spells. However, I would say that it covers the majority of what is needed.
If you have any questions about it, please feel free to post them here for Byrths or myself to answer. Also, if you noticed I missed anything crucial, let me know and we can add it in.
This same file is included in the Gearswap download in the examples section, and I will try to keep it as up-to-date as possible.
Code function get_sets()
sets = {}
sets.aftercast_Idle_noSub = {main="Owleyes",sub="Genbu's Shield",ammo="Incantor Stone",
head="Savant's bonnet +2",neck="Twilight Torque",ear1="Lifestorm Earring",ear2="Loquacious Earring",
body="Hagondes Coat",hands="Serpentes Cuffs",ring1="Sangoma Ring",ring2="Maquette Ring",
back="Shadow Mantle",waist="Korin Obi",legs="Nares Trews",feet="Serpentes Sabots"}
sets.aftercast_Idle_Sub = {main="Owleyes",sub="Genbu's Shield",ammo="Incantor Stone",
head="Savant's bonnet +2",neck="Twilight Torque",ear1="Savant's Earring",ear2="Loquacious Earring",
body="Hagondes Coat",hands="Serpentes Cuffs",ring1="Sangoma Ring",ring2="Maquette Ring",
back="Shadow Mantle",waist="Korin Obi",legs="Nares Trews",feet="Serpentes Sabots"}
sets.aftercast_Idle = sets.aftercast_Idle_noSub
sets.precast_FastCast = {ammo="Incantor Stone",head="Nahtirah Hat",ear2="Loquacious Earring",
body="Anhur Robe",hands="Gendewitha Gages",back="Swith Cape",legs="Orvail Pants",feet="Chelona Boots"}
sets.Resting = {main="Chatoyant Staff",sub="Mephitis Grip",
head="Nahtirah Hat",neck="Twilight Torque",ear1="Lifestorm Earring",ear2="Loquacious Earring",
body="Hagondes Coat",hands="Nares Cuffs",ring1="Sangoma Ring",ring2="Maquette Ring",
back="Shadow Mantle",waist="Korin Obi",legs="Nares Trews",feet="Chelona Boots"}
sets.midcast_ElementalMagic = {main="Atinian Staff",sub="Wizzan Grip",ammo="Witchstone",
head="Nares Cap",neck="Eddy Necklace",ear1="Hecate's Earring",ear2="Novio Earring",
body="Hagondes Coat",hands="Yaoyotl Gloves",ring1="Strendu Ring",ring2="Icesoul Ring",
back="Searing Cape",waist="Maniacus Sash",legs="Hagondes Pants",feet="Bokwus Boots"}
sets.midcast_DarkMagic = {main="Chatoyant Staff",sub="Arbuda Grip",ammo="Hasty Pinion",
head="Appetence Crown",neck="Aesir Torque",ear1="Hirudinea Earring",ear2="Loquacious Earring",
body="Hedera Cotehardie",hands="Ayao's Gages",ring1="Balrahn's Ring",ring2="Excelsis Ring",
back="Merciful Cape",waist="Goading Belt",legs="Auspex Slops",feet="Bokwus Boots"}
sets.midcast_EnfeeblingMagic = {main="Atinian Staff",sub="Mephitis Grip",ammo="Savant's Treatise",
head="Nahtirah Hat",neck="Eddy Necklace",ear1="Lifestorm Earring",ear2="Psystorm Earring",
body="Hedera Cotehardie",hands="Hagondes Cuffs",ring1="Sangoma Ring",ring2="Maquette Ring",
back="Merciful Cape",waist="Cascade Belt",legs="Orvail Pants",feet="Rubeus Boots"}
sets.midcast_Impact = {main="Atinian Staff",sub="Wizzan Grip",ammo="Witchstone",
neck="Eddy Necklace",ear1="Hecate's Earring",ear2="Novio Earring",
hands="Yaoyotl Gloves",ring1="Strendu Ring",ring2="Icesoul Ring",
back="Searing Cape",waist="Maniacus Sash",legs="Hagondes Pants",feet="Bokwus Boots"}
sets.midcast_Embrava = {main="Kirin's Pole",sub="Fulcio Grip",ammo="Savant's Treatise",
head="Svnt. Bonnet +2",neck="Colossus's Torque",ear1="Lifestorm Earring",ear2="Loquacious Earring",
body="Anhur Robe",hands="Savant's Bracers +2",
back="Merciful Cape",waist="Cascade Belt",legs="Shedir Seraweels",feet="Rubeus Boots"}
sets.midcast_EnhancingMagic = {main="Kirin's Pole",sub="Fulcio Grip",ammo="Incantor Stone",
head="Nahtirah Hat",neck="Colossus's Torque",ear1="Lifestorm Earring",ear2="Loquacious Earring",
body="Anhur Robe",hands="Gendewitha Gages",
back="Swith Cape",waist="Ninurta's Sash",legs="Orvail Pants",feet="Chelona Boots"}
sets.precast_Stun = {main="Apamajas II",sub="Mephitis Grip",ranged="Aureole",
head="Nahtirah Hat",neck="Eddy Necklace",ear1="Lifestorm Earring",ear2="Psystorm Earring",
body="Hedera Cotehardie",hands="Gendewitha Gages",ring1="Sangoma Ring",ring2="Maquette Ring",
back="Swith Cape",waist="Ninurta's Sash",legs="Bokwus Slops",feet="Argute Loafers +2"}
sets.midcast_Cure = {main="Chatoyant Staff",head="Paean Mitra",neck="Phalaina Locket",
body="Anhur Robe",hands="Bokwus Gloves",back="Oretanis's Cape",legs="Nares Trews"}
sets.midcast_Helix = {main="Chatoyant Staff",sub="Wizzan Grip",ammo="Snow Sachet",
head="Nahtirah Hat",neck="Stoicheion Medal",ear1="Hecate's Earring",ear2="Novio Earring",
body="Nares Saio",hands="Nares Cuffs",ring1="Icesoul Ring",ring2="Icesoul Ring",
back="Twilight Cape",waist="Wanion Belt",legs="Akasha Chaps",feet="Nares Clogs"}
sets.midcast_Stoneskin = {main="Kirin's Pole",neck="Stone Gorget",waist="Siegel Sash",legs="Shedir Seraweels"}
sets.Obi = {}
sets.Obi.Fire = {waist='Karin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.Obi.Earth = {waist='Dorin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.Obi.Water = {waist='Suirin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.Obi.Wind = {waist='Furin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.Obi.Ice = {waist='Hyorin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.Obi.Thunder = {waist='Rairin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.Obi.Light = {waist='Korin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.Obi.Dark = {waist='Anrin Obi',back='Twilight Cape',lring='Zodiac Ring'}
sets.staves = {}
sets.staves.damage = {}
sets.staves.damage.Thunder = {main="Apamajas I"}
sets.staves.damage.Fire = {main="Atar I"}
sets.staves.accuracy = {}
sets.staves.damage.Thunder = {main="Apamajas II"}
sets.staves.damage.Ice = {main="Vourukasha II"}
stuntarg = 'Shantotto'
end
function precast(spell,action)
if spell.english == 'Impact' then
cast_delay(2)
equip(sets['precast_FastCast'],{body="Twilight Cloak"})
if not buffactive['elemental seal'] then
add_to_chat(8,'--------- Elemental Seal is down ---------')
end
elseif spell.skill=='ElementalMagic' and spell.casttime < 3 then
cast_delay(0.1)
equip(sets.midcast_ElementalMagic)
if spell.element == 'Earth' then
equip({neck="Quanpur Necklace"})
end
if spell.element == world.weather_element or spell_element == world.day_element and sets.Obi[spell.element] then
equip(sets.Obi[spell.element])
end
elseif spell.english == 'Stun' then
cast_delay(0.1)
equip(sets['precast_Stun'])
if not buffactive.thunderstorm then
add_to_chat(8,'--------- Thunderstorm is down ---------')
elseif not buffactive.klimaform then
add_to_chat(8,'----------- Klimaform is down -----------')
end
if stuntarg ~= 'Shantotto' then
send_command('@input /t '..stuntarg..' ---- Byrth Stunned!!! ---- ')
end
else
equip(sets['precast_FastCast'])
cast_delay(0.5)
end
if (buffactive.alacrity or buffactive.celerity) and world.weather_element == spell.element then
equip({feet='Argute Loafers +2'})
end
end
function midcast(spell,action)
if string.find(spell.english,'Cur') then
equip(sets.midcast_Cure)
if spell.element == world.weather_element or spell_element == world.day_element then
equip({main="Chatoyant Staff"},sets.Obi[spell.element])
end
if buffactive.rapture then
equip({head="Savant's Bonnet +2"})
end
elseif spell.english == 'Impact' then
local tempset = sets['midcast_Impact']
tempset['body'] = 'Twilight Cloak'
tempset['head'] = empty
equip(tempset)
if spell.element == world.weather_element or spell_element == world.day_element then
equip(sets.Obi[spell.element])
end
if sets.staves.damage[spell.element] then
equip(sets.staves.damage[spell.element])
end
elseif spell.skill=="ElementalMagic" then
if string.find(spell.english,'helix') then
equip(sets['midcast_Helix'])
else
equip(sets.midcast_ElementalMagic)
if spell.element=='Earth' then
equip({neck="Quanpur Necklace"})
end
if spell.element == world.weather_element or spell_element == world.day_element then
equip(sets.Obi[spell.element])
end
end
if buffactive.ebullience then
equip({head="Savant's Bonnet +2"})
end
if buffactive.klimform then
equip ({feet="Savant's Loafers +2"})
end
elseif spell.english == 'Stoneskin' then
equip(sets['midcast_Stoneskin'])
elseif spell.skill == 'EnhancingMagic' then
if spell.english == 'Embrava' then
equip(sets['midcast_Embrava'])
if not buffactive.perpetuance then
add_to_chat(8,'--------- Perpetuance is down ---------')
end
if not buffactive.accession then
add_to_chat(8,'--------- Accession is down ---------')
end
if not buffactive.penury then
add_to_chat(8,'--------- Penury is down ---------')
end
end
if buffactive.perpetuance then
equip(sets['midcast_EnhancingMagic'],{hands="Savant's Bracers +2"})
else
equip(sets['midcast_EnhancingMagic'])
end
else
weathercheck(spell.element,sets['midcast_'..spell.skill])
end
if spell.english == 'Sneak' then
send_command('@wait 1.8;cancel 71;')
end
end
function aftercast(spell,action)
equip(sets['aftercast_Idle'])
if spell.english == 'Sleep' or spell.english == 'Sleepga' 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
end
function status_change(new,tab)
if new == 'Resting' then
equip(sets['Resting'])
else
equip(sets['aftercast_Idle'])
end
end
function buff_change(status,gain_or_loss)
if status == 'Sublimation: Complete' and gain_or_loss == 'gain' and not 'stunmode' then -- True whether gained or lost
sets.aftercast_Idle = sets.aftercast_Idle_noSub
elseif status == 'Sublimation: Activated' and gain_or_loss == 'gain' and not 'stunmode' then
sets.aftercast_Idle = sets.aftercast_Idle_Sub
end
equip(sets.aftercast_Idle)
end
function pet_midcast(spell,action)
end
function pet_aftercast(spell,action)
end
function self_command(command)
if command == 'stuntarg' then
stuntarg = target.name
elseif command == 'stunmode' then
windower.add_to_chat(100,'Stun Mode')
if sets.aftercast_Idle ~= sets.precast_Stun then
stunmode = true
sets.aftercast_Idle = sets.precast_Stun
elseif buffactive['Sublimation: Activated'] then
stunmode = false
sets.aftercast_Idle = sets.aftercast_Idle_Sub
else
stunmode = false
sets.aftercast_Idle = sets.aftercast_Idle_noSub
end
equip(sets.aftercast_Idle)
end
end
-- This function is user defined, but never called by GearSwap itself. It's just a user function that's only called from user functions. I wanted to check the weather and equip a weather-based set for some spells, so it made sense to make a function for it instead of replicating the conditional in multiple places.
function weathercheck(spell_element,set)
if spell_element == world.weather_element or spell_element == world.day_element then
equip(set,sets['Obi_'..spell_element])
else
equip(set)
end
end
|
|