FANDOM


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#singleinstance, force
#notrayicon

;---------------------------------------------------------------------------------------------------------------------Associate Job With Abbreviation
joblist := {"Warrior":"WAR","Monk":"MNK","White Mage":"WHM","Black Mage":"BLM","Red Mage":"RDM","Thief":"THF","Paladin":"PLD"
,"Dark Knight":"DRK","Beastmaster":"BST","Bard":"BRD","Ranger":"RNG","Samurai":"SAM","Ninja":"NIN","Dragoon":"DRG","Summoner":"SMN"
,"Blue Mage":"BLU","Corsair":"COR","Puppetmaster":"PUP","Dancer":"DNC","Scholar":"SCH","Geomancer":"GEO","Rune Fencer":"RUN"}

;---------------------------------------------------------------------------------------------------------------------------Associate Slots with Gear
main_table = axe|club|daggers|great axe|great katana|great swords|hand-to-hand|katana|polearms|scythe|staff|swords
sub_table = shields|grips|axe|club|daggers|katana|swords
range_table = archery|marksmanship|boomerangs|string instruments|wind instruments
ammo_table = arrows|bolts|throwing
armor_table = head|neck|earrings|earrings|body|hands|rings|rings|back|waist|legs|feet
slots = main|sub|range|ammo|head|neck|ear1|ear2|body|hands|ring1|ring2|back|waist|legs|feet

;---------------------------------------------------------------------------------------------------------------------------Table of Actionable Items
cause = Spell|Job Ability|Weapon Skill|Status|Buff/Debuff|HP|MP|TP|Pet's HP|Pet's MP|Pet's TP
|Target's HP|Target's MP|Target's TP
magic_table = Blue|Dark|Divine|Elemental|Enfeebling|Enhancing|Healing|Ninjutsu|Singing|Summoning
magic_table_2 = Blue|Dark|Divine|Enfeebling|Enhancing|Healing|Ninjutsu|Singing|Summoning
magic_table_3 = Earth|Fire|Ice|Thunder|Water|Wind|Misc


job_table = Bard|Beastmaster|Black Mage|Blue Mage|Corsair|Dancer|Dark Knight|Dragoon|Geomancer|Monk|Ninja|Paladin|Puppetmaster|Ranger|Red Mage|Rune Fencer|Samurai|Scholar|Summoner|Thief|Warrior|White Mage
weapon_table = Archery|Automaton|Axe|Club|Dagger|Great Axe|Great Katana|Great Sword|Hand-to-Hand|Katana|Marksmanship|Polearm|Scythe|Staff|Sword

;--------------------------------------------------------------------------------------------------------------------------Create Default Directories
db = database
ud = userdata
filecreatedir, %db%
filecreatedir, %ud%

;----------------------------------------------------------------------------------------------------------------------------Call Initial Subroutines
gosub guiwindow
gosub gui.tab.equip
gosub gui.tab.action
gosub gui.tab.gearswap
gosub ePopList
gosub ePopSlots
gosub tPopList
return

;-----------------------------------------------------------------------------------------------------------------------------------Create Gui Window
guiwindow:
gui, new,, SN Easy Swap 1.0
gui, add, tab2, w770 h330, Equipment Sets|Actions List|Generate Gear Swap
gui, show, w790 h350
return

;---------------------------------------------------------------------------------------------------------------------------Create Equipment Sets Tab
gui.tab.equip:
gui, tab, 1
												;---------------------------------------------------Equipment Slots
gui, add, text, x40 y40 w170, Main
gui, add, text, x+10 w170, Sub
gui, add, text, x+10 w170, Range
gui, add, text, x+10 w170, Ammo
gui, add, combobox, x40 y+2 w170 vMain			;-------------------------------------combobox1
gui, add, combobox, x+10 w170 vSub				;-------------------------------------combobox2
gui, add, combobox, x+10 w170 vRange			;-------------------------------------combobox3
gui, add, combobox, x+10 w170 vAmmo				;-------------------------------------combobox4
gui, add, text, x40 y+6 w170, Head
gui, add, text, x+10 w170, Neck
gui, add, text, x+10 w170, Ear 1
gui, add, text, x+10 w170, Ear 2
gui, add, combobox, x40 y+2 w170 vHead			;-------------------------------------combobox5
gui, add, combobox, x+10 w170 vNeck				;-------------------------------------combobox6
gui, add, combobox, x+10 w170 vEar1				;-------------------------------------combobox7
gui, add, combobox, x+10 w170 vEar2				;-------------------------------------combobox8
gui, add, text, x40 y+6 w170, Body
gui, add, text, x+10 w170, Hands
gui, add, text, x+10 w170, Ring1
gui, add, text, x+10 w170, Ring2
gui, add, combobox, x40 y+2 w170 vBody			;-------------------------------------combobox9
gui, add, combobox, x+10 w170 vHands			;------------------------------------combobox10
gui, add, combobox, x+10 w170 vRing1			;------------------------------------combobox11
gui, add, combobox, x+10 w170 vRing2			;------------------------------------combobox12
gui, add, text, x40 y+6 w170, Back
gui, add, text, x+10 w170, Waist
gui, add, text, x+10 w170, Legs
gui, add, text, x+10 w170, Feet
gui, add, combobox, x40 y+2 w170 vBack			;------------------------------------combobox13
gui, add, combobox, x+10 w170 vWaist			;------------------------------------combobox14
gui, add, combobox, x+10 w170 vLegs				;------------------------------------combobox15
gui, add, combobox, x+10 w170 vFeet				;------------------------------------combobox16
												;-----------------------------------------------Equipment Sets List
gui, add, text, x330 y250 w50, Name Set:
gui, add, edit, x+2 w150 veName					;----------------------------------------edit17
gui, add, button, x+2 w75 h21 geSave, Save		;---------------------------------------button1
gui, add, text, x330 y+8 w50, Load Set:
gui, add, ddl, x+2 w150 geLoad vseName,			;------------------------------------combobox17
gui, add, button, x+2 w75 h21 geDelete, Delete	;---------------------------------------button3
return

;----------------------------------------------------------------------------------------------------------------------Save Equipment Set To Userdata
eSave:
gui, submit, nohide
if eName =
{
	msgbox, 262144, Error, Name cannot be left blank
	return
}
inidelete, %ud%\equipmentsets.ini, %eName%
loop, parse, slots, |
{
	guicontrolget, item, , combobox%A_Index%
	iniwrite, "%item%", %ud%\equipmentsets.ini, %eName%, %A_LoopField%
}
gosub ePopList
guicontrol, choose, combobox17, %eName%
return

;----------------------------------------------------------------------------------------------------------------------------Load from Equipment List
eLoad:
gui, submit, nohide
guicontrol,, edit17,
loop, parse, slots, |
{
	iniread, item, %ud%\equipmentsets.ini, %seName%, %A_LoopField%
	guicontrol, choose, combobox%A_Index%, %item%
}
return

;--------------------------------------------------------------------------------------------------------------------------Delete from Equipment List
eDelete:
gui, submit, nohide
inidelete, %ud%/equipmentsets.ini,%seName%
gosub ePopList
return

;------------------------------------------------------------------------------------------------------------------------Populate Equipment Sets List
ePopList:
iniread, eList, %ud%/equipmentsets.ini
stringreplace, eList, eList, `n, `|, all
guicontrol,, combobox17, |%eList%
elist = -None-|%elist%
guicontrol,, combobox19, |%eList%
guicontrol,, combobox20, |%eList%
guicontrol,, combobox21, |%eList%
guicontrol, choose, combobox19, -None-
guicontrol, choose, combobox20, -None-
guicontrol, choose, combobox21, -None-
return

;----------------------------------------------------------------------------------------------------------------------------Populate Equipment Slots
ePopSlots:
																;---------------------main slot
guicontrol, ,combobox1, |
loop, parse, main_table, |
{
	iniread, contents, %db%\%A_LoopField%.ini
	sort, contents	
	stringreplace, contents, contents, `n, |, all
	guicontrol, , combobox1, %contents%
}

																;----------------------sub slot
guicontrol, ,combobox2, |
loop, parse, sub_table, |
{
	iniread, contents, %db%\%A_LoopField%.ini
	sort, contents
	stringreplace, contents, contents, `n, |, all
	guicontrol, , combobox2, %contents%
}
																;--------------------range slot
guicontrol, ,combobox3, |
loop, parse, range_table, |
{
	iniread, contents, %db%\%A_LoopField%.ini
	sort, contents
	stringreplace, contents, contents, `n, |, all
	guicontrol, , combobox3, %contents%
}
																;---------------------ammo slot
guicontrol, ,combobox4, |
loop, parse, ammo_table, |
{
	iniread, contents, %db%\%A_LoopField%.ini
	sort, contents
	stringreplace, contents, contents, `n, |, all
	guicontrol, , combobox4, %contents%
}

																;------------------and the rest
ePopSlotsCounter = 5
loop, parse, armor_table, |
{
	iniread, contents, %db%\%A_LoopField%.ini
	sort, contents
	stringreplace, contents, contents, `n, |, all
	guicontrol, , combobox%ePopSlotsCounter%, |%contents%
	ePopSlotsCounter := ePopSlotsCounter + 1
}
return

;-----------------------------------------------------------------------------------------------------------------------------Create Actions List Tab
gui.tab.action:
gui, tab, 2
gui, add, text, x100 y74 w220 vstatic19, 						,----------------------static19
gui, add, TreeView, x100 y100 w220 h200 gsummary				;-----------------------------------Cause List Tree
gosub, malist
gosub, jalist
gosub, wslist
gosub, otherlist
gui, add, text, x+50 y74, ...									;------------------------------------Effect Options
choice = Equip gear||Send macro command
gui, add, ddl, x+1 y70 w150 altsubmit gwhattohide vthis, %choice% ;------------------combobox18
gui, add, edit, x380 y100 w150 vmacro							;------------------------edit18
gui, add, text, x+10 y104 w150, ex: /item "Echo Drops" <me>		;----------------------static21
gui, add, ddl, x380 w150 y+16 vprecast							;--------------------combobox19
gui, add, text, x+10, Precast									;----------------------static22
gui, add, ddl, x380 y+20 w150 vmidcast							;--------------------combobox20
gui, add, text, x+10, Midcast									;----------------------static23
gui, add, ddl, x380 y+20 w150 vaftercast						;--------------------combobox21
gui, add, text, x+10, Aftercast									;----------------------static24
																;----------------------------------Action Sets List
gui, add, text, x330 y250 w50, Name Set:
gui, add, edit, x+2 w150 w150 vaName							;------------------------edit19
gui, add, button, x+2 w75 h21 gaSave, Save						;-----------------------button3
gui, add, text, x330 y+8 w50, Load Set:
gui, add, ddl, x+2 w150 vsaName gtload,							;--------------------combobox22
gui, add, button, x+2 w75 h21 gaDelete, Delete					;-----------------------button4
guicontrol, disable, edit18
guicontrol, disable, static21

gui, add, ddl, x210 y70 w110 voper, Equal To||Greater Than|Less Than ;-------------------combobox23
gui, add, edit, x+2 w50 number limit4 vnumb						;------------------------edit20
gui, add, updown, range0-1000
return

;--------------------------------------------------------------------------------------------------------------------------------Chooses What To Hide
whattohide:
gui, submit, nohide
tv_gettext(select_name, select_id)
parent_id := tv_getparent(select_id)
tv_gettext(parent_name, parent_id)
grand_id := tv_getparent(parent_id)
tv_gettext(grand_name, grand_id)
ancient_id := tv_getparent(grand_id)
tv_gettext(ancient_name, ancient_id)

if this = 1
{
	if select_name = Magic
		gosub fullcastreset
	else if parent_name contains Magic
		gosub fullcastreset
	else if grand_name contains Magic
		gosub fullcastreset
	else if ancient_name contains Magic
		gosub fullcastreset
	else if select_name contains Ability
		gosub twocastreset
	else if parent_name contains Ability
		gosub twocastreset
	else if grand_name contains Ability
		gosub twocastreset
	else if ancient_name contains Ability
		gosub twocastreset
	else if select_name contains Skill
		gosub twocastreset
	else if parent_name contains Skill
		gosub twocastreset
	else if grand_name contains Skill
		gosub twocastreset
	else if ancient_name contains Skill
		gosub twocastreset
	else gosub lastcastreset
}
if this = 2
	gosub nocastreset
return

;--------------------------------------------------------------------------------------------------------------------------------Reset Action Choices
reset:
resetlist = edit18|static21|combobox19|static22|combobox20|static23|combobox21|static24
loop, parse, resetlist, |
{
	guicontrol, disable, %A_LoopField%
}
return
																;--------Enable All Equip Times
fullcastreset:
gosub reset
enablelist = combobox19|Static22|combobox20|static23|combobox21|static24
loop, parse, enablelist, |
{
	guicontrol, enable, %A_LoopField%
}
return
																;------Enable Precast & Midcast
twocastreset:
gosub reset
enablelist = combobox19|Static22|combobox21|static24
loop, parse, enablelist, |
{
	guicontrol, enable, %A_LoopField%
}
guicontrol, choose, combobox20 , -None-
return
																;---------Enable Aftercast Only
lastcastreset:
gosub reset
enablelist = combobox21|static24
loop, parse, enablelist, |
{
	guicontrol, enable, %A_LoopField%
}
guicontrol, choose, combobox19 , -None-
guicontrol, choose, combobox20 , -None-
return
																;-------Disable All Equip Times
nocastreset:
gosub reset
enablelist = edit18|static21
loop, parse, enablelist, |
{
	guicontrol, enable, %A_LoopField%
}
guicontrol, choose, combobox19 , -None-
guicontrol, choose, combobox20 , -None-
guicontrol, choose, combobox21 , -None-
return

;-------------------------------------------------------------------------------------------------------------------------------Magic List Subroutine
malist:
Magic := tv_add("Magic")
loop, parse, magic_table, |
{
	Magic_%A_LoopField% := tv_add(A_LoopField, Magic)
}

loop, parse, magic_table_2, |
{
	type = %A_LoopField%
	iniread, %type%list, %db%\spells\%type%.ini
	loop, parse, %type%list, `n
	{
		stringreplace, name, A_LoopField, %A_Space%, ,ALL
		stringreplace, name, name, `', ,ALL
		stringreplace, name, name, `:, ,ALL
		stringreplace, name, name, `-, ,ALL
		Magic_%type%_%name% := tv_add(A_LoopField, Magic_%type%)
	}
}
loop, parse, magic_table_3, |
{
	type = %A_LoopField%
	Magic_Elemental_%type% := tv_add(type, Magic_Elemental)
	iniread %type%list, %db%\spells\elemental_%type%.ini
	loop, parse, %type%list, `n
	{
		stringreplace, name, A_LoopField, %A_Space%, ,ALL
		stringreplace, name, name, `', ,ALL
		stringreplace, name, name, `:, ,ALL
		stringreplace, name, name, `-, ,ALL
		stringreplace, name, name, `,, ,ALL
		Magic_Elemental_%type%_%name% := tv_add(A_LoopField, Magic_Elemental_%type%)
	}
}
return

;-------------------------------------------------------------------------------------------------------------------------Job Ability List Subroutine
jalist:
Ability := tv_add("Job Ability")
loop, parse, job_table, |
{
	stringreplace, job, A_LoopField, %A_Space%, , ALL
	Ability_%job% := tv_add(A_LoopField, Ability)
}
loop, parse, job_table, |
{
	stringreplace, nospaceName, A_LoopField, %A_Space%, , ALL
	iniread %nospaceName%, %db%\abilities\%A_LoopField%.ini
	loop, parse, %nospaceName%, `n
	{
		action = %A_LoopField%
		stringreplace, action, action, %A_Space%, , ALL
		stringreplace, action, action, `', ,ALL
		stringreplace, action, action, `:, ,ALL
		stringreplace, action, action, `-, ,ALL
		Ability_%nospaceName%_%action% := tv_add(A_LoopField, Ability_%nospacename%)
	}
}

return

;-----------------------------------------------------------------------------------------------------------------------Weapon Skills List Subroutine
wslist:
Weaponskill := tv_add("Weapon Skill")
loop, parse, weapon_table, |
{
	stringreplace, weaopn, A_LoopField, %A_Space%, ,ALL
	stringreplace, weapon, weapon, `-, , ALL
	Weaponskill_%weapon% := tv_add(A_LoopField, Weaponskill)
	iniread, skill, %db%\weaponskills\%A_LoopField%.ini
	loop, parse, skill, `n
	{
		stringreplace, nospaceSkill, A_LoopField, %A_Space%, , ALL
		stringreplace, nospaceSkill, nospaceSkill, `-, , ALL
		stringreplace, nospaceSkill, nospaceSkill, `:, , ALL
		stringreplace, nospaceSkill, nospaceSkill, `', , ALL
		Weaponskill_%weapon%_%nospaceskill% := tv_add(A_LoopField, Weaponskill_%weapon%)
	}
}
return

;-------------------------------------------------------------------------------------------------------------------------Other Parameters Subroutine
otherlist:
																;------------------------Status
Status := tv_add("Status")
Status_Idle := tv_add("Idle", Status)
Status_Engaged := tv_add("Engaged", Status)
Status_Resting := tv_add("Resting", Status)
																;-------------------------Buffs
Enhance := tv_add("Enhancement")
Enhance_Gain := tv_add("Gain Enhancement", Enhance)
iniread, buff, %db%\statusbar\buff.ini
loop, parse, buff, `n
{
	name = %A_LoopField%
	stringreplace, name, name, %A_Space%, , ALL
	stringreplace, name, name, `'
	Enhance_Gain_%name% := tv_add(A_LoopField, Enhance_Gain)
}
Enhance_Lose := tv_add("Lose Enhancement", Enhance)
iniread, buff, %db%\statusbar\buff.ini
loop, parse, buff, `n
{
	name = %A_LoopField%
	stringreplace, name, name, %A_Space%, , ALL
	stringreplace, name, name, `'
	Enhance_Lose_%name% := tv_add(A_LoopField, Enhance_Lose)
}
																;-----------------------Debuffs
Ail := tv_add("Affliction")
Ail_Gain := tv_add("Gain Affliction", Ail)
iniread, debuff, %db%\statusbar\debuff.ini
loop, parse, debuff, `n
{
	name = %A_LoopField%
	stringreplace, name, name, %A_Space%, , ALL
	stringreplace, name, name, `'
	Ail_Gain_%name% := tv_add(A_LoopField, Ail_Gain)
}
Ail_Lose := tv_add("Lose Affliction", Ail)
iniread, buff, %db%\statusbar\debuff.ini
loop, parse, debuff, `n
{
	name = %A_LoopField%
	stringreplace, name, name, %A_Space%, , ALL
	stringreplace, name, name, `'
	Ail_Lose_%name% := tv_add(A_LoopField, Ail_Lose)
}

																;-------------------Player Info
Player := tv_add("Player Info")
Player_HP := tv_add("HP %", Player)
Player_MP := tv_add("MP %", Player)
Player_TP := tv_add("TP", Player)
																;----------------------Pet Info
Pet := tv_add("Pet Info")
Pet_HP := tv_add("HP %", Pet)
Pet_MP := tv_add("MP %", Pet)
Pet_TP := tv_add("TP", Pet)
																;-------------------Player Info
Target := tv_add("Target Info")
Target_HP := tv_add("HP %", Target)
Target_MP := tv_add("MP %", Target)
Target_TP := tv_add("TP", Target)

return

;----------------------------------------------------------------------------------------------------------------------Changes Summary Field To Match
Summary:
																;-------------------------Magic
guicontrol, move, static19, w220
guicontrol, hide, combobox23
guicontrol, hide, edit20
guicontrol, hide, msctls_updown321
select_id := tv_getselection()
tv_gettext(select_name, select_id)
parent_id := tv_getparent(select_id)
tv_gettext(parent_name, parent_id)

loop, parse, magic_table, |
{
	if select_name = Magic
		guicontrol,, static19, When casting ANY Magic...
	else if select_name = %A_LoopField%
		guicontrol,, static19, When casting ANY %select_name% Magic...
	else if parent_name = %A_LoopField%
		guicontrol,, static19, When casting %select_name%...
}
loop, parse, magic_table_3, |
{
	if (select_name = A_LoopField && parent_name = "Elemental")
		guicontrol,, static19, When casting ANY %select_name% Elemental Magic...
	if (parent_name = A_LoopField)
		guicontrol,, static19, When casting %select_name%...
}
if select_name = Singing
	guicontrol,, static19, When casting ANY Song...
																;-----------------Job Abilities

loop, parse, job_table, |
{
	if (select_name = A_LoopField or select_name = "Job Ability")
		guicontrol,, static19, When using ANY Job Ability...
	else if parent_name = %A_LoopField%
		guicontrol,, static19, When using %select_name%...
}
																;-----------------Weapon Skills
loop, parse, weapon_table, |
{
	if select_name = Weapon Skill
		guicontrol,, static19, When performing ANY Weapon Skill...
	else if select_name = %A_LoopField%
		guicontrol,, static19, When performing ANY %select_name% Skill...
	else if parent_name = %A_LoopField%
		guicontrol,, static19, When performing %select_name%...
}

state = Idle|Engaged|Resting
loop, parse, state, |
{
	if select_name = %A_LoopField%
		guicontrol,, static19, When player is %select_name%...
}
																;--------------------Misc Stuff
miscstuff = Status|Enhancement|Affliction|Player Info|Pet Info|Target Info
loop, parse, miscstuff, |
{
	if select_name contains %A_LoopField%
		guicontrol,, static19, Pick a sub-option
}
																;---------------------Buff Info
if parent_name contains Gain
	guicontrol,, static19, When %select_name% is gained...
if parent_name contains Lose
	guicontrol,, static19, When %select_name% is removed...
if (select_name = "HP %" OR select_name = "MP %" OR select_name = "TP")
{
	stringtrimright, name, parent_name, 5
	guicontrol, move, static19, w110
	guicontrol, show, combobox23
	guicontrol, show, edit20
	guicontrol, show, msctls_updown321
	guicontrol,, static19, When %name% %select_name% is
}

gosub whattohide
return

;----------------------------------------------------------------------------------------------------------------------------Save Actions To Userdata
aSave:
gui, submit, nohide
iniDelete, %ud%\actionsets.ini, %aName%
if aName =
{
	msgbox, 262144, Error, Name cannot be left blank
	return
}
select_id := tv_getselection()
tv_gettext(select_name, select_id)
parent_id := tv_getparent(select_id)
tv_gettext(parent_name, parent_id)
grand_id := tv_getparent(parent_id)
tv_gettext(grand_name, grand_id)
ancient_id := tv_getparent(grand_id)
tv_gettext(ancient_name, ancient_id)

forbidden = Status|Enhancement|Affliction|Player Info|Pet Info|Target Info
loop, parse, forbidden, |
{
	if select_name = %A_LoopField%
	{
		msgbox, 262144, Error, Please make a proper selection
		return
	}

}
																;----------------Tree View Path
iniwrite, %select_name%, %ud%\actionsets.ini, %aName%, Trigger
iniwrite, %parent_name%, %ud%\actionsets.ini, %aName%, Parent
iniwrite, %grand_name%, %ud%\actionsets.ini, %aName%, Grand
iniwrite, %ancient_name%, %ud%\actionsets.ini, %aName%, Ancient
iniwrite, %this%, %ud%\actionsets.ini, %aName%, Type

path = select_name|parent_name|grand_name|ancient_name

if this = 2
{
	Command = send_command('@input %macro%')
	iniwrite, %Command%, %ud%\actionsets.ini, %aName%, Command
	iniwrite, nocast, %ud%\actionsets.ini, %aName%, equiptype
}

if this = 2
{
	loop, parse, path, |
	{
		if (%A_LoopField% = "Magic" or %A_LoopField% = "Job Ability" or %A_LoopField% = "Weapon Skill")
			iniwrite, 1, %ud%\actionsets.ini, %aName%, category
	}
}
if this = 2
{
	loop, parse, path, |
	{
		if (%A_LoopField% = "Idle" or %A_LoopField% = "Resting" or %A_LoopField% = "Engaged")
			iniwrite, 2, %ud%\actionsets.ini, %aName%, category
	}
}
if this = 2
{
	loop, parse, path, |
	{
		if (%A_LoopField% = "Enhancement" or %A_LoopField% = "Affliction")
			iniwrite, 3, %ud%\actionsets.ini, %aName%, category
	}
}
if this = 2
{
	loop, parse, path, |
	{
		if (%A_LoopField% = "Player Info" or %A_LoopField% = "Pet Info" or %A_LoopField% = "Target Info")
			iniwrite, 4, %ud%\actionsets.ini, %aName%, category
	}
}
;-----------------------------------------------------------------------------------Magic Logic
if select_name = Magic
	gosub onetype
if parent_name = Magic
	gosub sameskill
else if parent_name = Elemental
	gosub sameelement
magic_path = blue|dark|divine|enfeebling|enhancing|healing|ninjutsu|singing|summoning
loop, parse, magic_path, |
{
	if parent_name = %A_LoopField%
		gosub oneaction
}
loop, parse, magic_table_3, |
{
	if parent_name = %A_LoopField%
		gosub oneaction
}

loop, parse, path, |
{
	if (this = 1 && %A_LoopField% = "Magic")
	{
		iniwrite, fullcast, %ud%\actionsets.ini, %aName%, equiptype
		iniwrite, %precast%, %ud%\actionsets.ini, %aName%, precast_file
		iniwrite, %midcast%, %ud%\actionsets.ini, %aName%, midcast_file
		iniwrite, %aftercast%, %ud%\actionsets.ini, %aName%, aftercast_file
		iniwrite, 1, %ud%\actionsets.ini, %aName%, category
		equiptype = fullcast
		gosub luaequip
	}
}
gosub clearout
;------------------------------------------------------------Job Ability and Weapon Skill Logic
if (select_name = "Job Ability" or select_name = "Weapon Skill" or parent_name = "Job_Ability")
	gosub onetype
if parent_name = Weapon Skill
	gosub sameskill
loop, parse, weapon_table, |
{
	if parent_name = %A_LoopField%
		gosub oneaction
}
loop, parse, job_table, |
{
	if parent_name = %A_LoopField%
		gosub oneaction
}

loop, parse, path, |
{
	if (this = 1 && (%A_LoopField% = "Job Ability" or %A_LoopField% = "Weapon Skill"))
	{
		iniwrite, twocast, %ud%\actionsets.ini, %aName%, equiptype
		iniwrite, %precast%, %ud%\actionsets.ini, %aName%, precast_file
		iniwrite, %aftercast%, %ud%\actionsets.ini, %aName%, aftercast_file
		iniwrite, 1, %ud%\actionsets.ini, %aName%, category
		equiptype = twocast
		gosub luaequip
	}
}
gosub clearout
;------------------------------------------------------------------------Other Parameters Logic
if (select_name = "Idle" or select_name = "Resting" or select_name = "Engaged")
{
	action = if new == '%select_name%' then
	iniwrite, %action%, %ud%\actionsets.ini, %aName%, action
	iniwrite, 2, %ud%\actionsets.ini, %aName%, category
}
if parent_name contains Gain
{
	action = if new == '%select_name%' and gain then
	iniwrite, %action%, %ud%\actionsets.ini, %aName%, action
	iniwrite, 3, %ud%\actionsets.ini, %aName%, category
}
if parent_name contains Lose
{
	action = if new == '%select_name%' and not gain then
	iniwrite, %action%, %ud%\actionsets.ini, %aName%, action
	iniwrite, 3, %ud%\actionsets.ini, %aName%, category
}
if (parent_name = "Player Info" && (select_name ="HP %" or select_name = "MP %" or select_name = "TP"))
{
	iniwrite, %oper%, %ud%\actionsets.ini, %aName%, operator
	iniwrite, %numb%, %ud%\actionsets.ini, %aName%, number
	iniwrite, 4, %ud%\actionsets.ini, %aName%, category
	if oper = Equal To
		oper = `=`=
	else if oper = Greater Than
		oper = `>
	else oper = `<
		if select_name = HP `%
			percent = hpp
		else if select_name = MP `%
			percent = mpp
		else if select_name = TP `%
			recent = tp
	action = if player.%percent% %oper% %numb% then
	iniwrite, %action%, %ud%\actionsets.ini, %aName%, action
}
if (parent_name = "Pet Info" && (select_name ="HP %" or select_name = "MP %" or select_name = "TP"))
{
	iniwrite, %oper%, %ud%\actionsets.ini, %aName%, operator
	iniwrite, %numb%, %ud%\actionsets.ini, %aName%, number
	iniwrite, 4, %ud%\actionsets.ini, %aName%, category
	if oper = Equal To
		oper = `=`=
	else if oper = Greater Than
		oper = `>
	else oper = `<
	if select_name = HP `%
			percent = hpp
		else if select_name = MP `%
			percent = mpp
		else if select_name = TP `%
			recent = tp
	action = if pet.%percent% %oper% %numb% then
	iniwrite, %action%, %ud%\actionsets.ini, %aName%, action
}
if (parent_name = "Target Info" && (select_name ="HP %" or select_name = "MP %" or select_name = "TP"))
{
	iniwrite, %oper%, %ud%\actionsets.ini, %aName%, operator
	iniwrite, %numb%, %ud%\actionsets.ini, %aName%, number
	iniwrite, 4, %ud%\actionsets.ini, %aName%, category
	if oper = Equal To
		oper = `=`=
	else if oper = Greater Than
		oper = `>
	else oper = `<
	if select_name = HP `%
			percent = hpp
		else if select_name = MP `%
			percent = mpp
		else if select_name = TP `%
			recent = tp
	action = if target.%percent% %oper% %numb% then
	iniwrite, %action%, %ud%\actionsets.ini, %aName%, action
}
status = Status|Enhancement|Affliction|Player Info|Pet Info|Target Info
loop, parse, status, |
{
	if (this = 1 && (parent_name = A_LoopField OR grand_name = A_LoopField))
	{
		iniwrite, lastcast, %ud%\actionsets.ini, %aName%, equiptype
		iniwrite, %aftercast%, %ud%\actionsets.ini, %aName%, aftercast_file
		equiptype = lastcast
		gosub luaequip
	}
}
gosub tPopList
gosub clearout
return
;------------------------------------------------------------Write Gear Swap Initial Conditions
onetype:
stringreplace, altered_name, select_name, %A_Space%,, ALL
action = if spell.type:contains('%altered_name%') then
iniwrite, %action%, %ud%\actionsets.ini, %aName%, action
return

sameelement:
action = if spell.element:contains('%select_name%') then
iniwrite, %action%, %ud%\actionsets.ini, %aName%, action
return

sameskill:
action = if spell.skill:contains('%select_name%') then
iniwrite, %action%, %ud%\actionsets.ini, %aName%, action
return

oneaction:
action = if spell.name == '%select_name%' then
iniwrite, %action%, %ud%\actionsets.ini, %aName%, action
return
;----------------------------------------------------------Write Gear Swap Equipment Conditions
luaequip:
if (precast != "-None-" && (equiptype = "fullcast" OR equiptype = "twocast"))
{
	loop, parse, slots, |
	{
		iniread, precast_%A_LoopField%, %ud%\equipmentsets.ini, %precast%, %A_LoopField%
	}
	preout = equip({main="%precast_main%", sub="%precast_sub%", range="%precast_range%", ammo="%precast_ammo%", head="%precast_head%", neck="%precast_neck%", ear1="%precast_ear1%", ear2="%precast_ear2%", body="%precast_body%", hands="%precast_hands%", ring1="%precast_ring1%", ring2="%precast_ring2%", back="%precast_back%", waist="%precast_waist%", legs="%precast_legs%", feet="%precast_feet%"})
	iniwrite, %preout%, %ud%\actionsets.ini, %aName%, precast_lua
}
if (midcast != "-None-" && equiptype = "fullcast")
{
	loop, parse, slots, |
	{
		iniread, midcast_%A_LoopField%, %ud%\equipmentsets.ini, %midcast%, %A_LoopField%
	}
	midout = equip({main="%midcast_main%", sub="%midcast_sub%", range="%midcast_range%", ammo="%midcast_ammo%", head="%midcast_head%", neck="%midcast_neck%", ear1="%midcast_ear1%", ear2="%midcast_ear2%", body="%midcast_body%", hands="%midcast_hands%", ring1="%midcast_ring1%", ring2="%midcast_ring2%", back="%midcast_back%", waist="%midcast_waist%", legs="%midcast_legs%", feet="%midcast_feet%"})
	iniwrite, %midout%, %ud%\actionsets.ini, %aName%, midcast_lua
}
if (aftercast != "-None-" && (equiptype = "fullcast" OR equiptype = "twocast" OR equiptype = "lastcast"))
{
	loop, parse, slots, |
	{
		iniread, aftercast_%A_LoopField%, %ud%\equipmentsets.ini, %aftercast%, %A_LoopField%
	}
	afterout = equip({main="%aftercast_main%", sub="%aftercast_sub%", range="%aftercast_range%", ammo="%aftercast_ammo%", head="%aftercast_head%", neck="%aftercast_neck%", ear1="%aftercast_ear1%", ear2="%aftercast_ear2%", body="%aftercast_body%", hands="%aftercast_hands%", ring1="%aftercast_ring1%", ring2="%aftercast_ring2%", back="%aftercast_back%", waist="%aftercast_waist%", legs="%aftercast_legs%", feet="%aftercast_feet%"})
	iniwrite, %afterout%, %ud%\actionsets.ini, %aName%, aftercast_lua
}
return
;-------------------------------------------------Clearing Memory / Error Correcting Redundency
clearout:
cleath_path = preout|midout|afterout|type|precast_file|midcast_file|aftercast_file|command|operator|number
loop, parse, clear_path, |
{
%A_LoopField% =
}
return
;------------------------------------------------------------------------------------------------------------------------Load to Action Sets Database
tLoad:
gui, submit, nohide
guicontrol,, edit19,
iniread, trigger, %ud%/actionsets.ini, %saName%, trigger
iniread, parent, %ud%/actionsets.ini, %saName%, parent
iniread, grand, %ud%/actionsets.ini, %saName%, grand
iniread, ancient, %ud%/actionsets.ini, %saName%, ancient

if ancient !=
	controlsend, systreeview321, %ancient%{right}%grand%{right}%parent%{right}%trigger%
else if grand !=
	controlsend, systreeview321, %grand%{right}%parent%{right}%trigger%
else if parent !=
	controlsend, systreeview321, %parent%{right}%trigger%
else controlsend, systreeview321, %trigger%

iniread, type, %ud%/actionsets.ini, %saName%, type
guicontrol, choose, combobox18, %type%
iniread, precast_file, %ud%/actionsets.ini, %saName%, precast_file
guicontrol, choose, combobox19, %precast_file%
iniread, midcast_file, %ud%/actionsets.ini, %saName%, midcast_file
guicontrol, choose, combobox20, %midcast_file%
iniread, aftercast_file, %ud%/actionsets.ini, %saName%, aftercast_file
guicontrol, choose, combobox21, %aftercast_file%
iniread, command, %ud%/actionsets.ini, %saName%, command
stringtrimleft, command, command, 21
stringtrimright, command, command, 2
if command != error
	guicontrol,, edit18, %command%
iniread, operator, %ud%/actionsets.ini, %saName%, operator
guicontrol, choose, combobox23, %operator%
iniread, number, %ud%/actionsets.ini, %saName%, number
if number != error
	guicontrol,, edit20, %number%
return
;----------------------------------------------------------------------------------------------------------------------Delete to Action Sets Database
aDelete:
gui, submit, nohide
inidelete, %ud%/actionsets.ini,%saName%
gosub tPopList
return
;-------------------------------------------------------------------------------------------------------------------------------Populate Actions List
tPopList:
iniread, tList, %ud%/actionsets.ini
stringreplace, tList, tList, `n, `|, all
guicontrol,, combobox22, |%tList%
guicontrol,, listbox1, |%tlist%
return

;--------------------------------------------------------------------------------------------------------------------------------Create Gear Swap Tab
gui.tab.gearswap:
gui, tab, 3
gui, add, button, x40 y40 w200 gAddGear, Add Actions To List >>			;---------------Button5
gui, add, listbox, y+10 w200 h250 vsGear								;--------------ListBox1
gui, add, button, x+20 y40 w200 gDelGear, << Remove Actions From List	;---------------Button6
gui, add, listbox, y+10 w200 h250 vItemInGear							;--------------ListBox2
gui, add, text, y+4 w200, Items here will be used in Gear Swap file
gui, add, text, x+60 y70 w200, Choose a job
gui, add, ddl, y+4 w200 vjobtab, %job_table%							;------------Combobox24
gui, add, button, y+20 w200 h40 gMakeGearSwap, Create Gear Swap Lua		;---------------Button7
return

AddGear:
gui, submit, nohide
loop, parse, perminfo, |
{
	if sgear = %A_LoopField%
	{
		msgbox, Action is already inside list
		return
	}
}
iniread, tempinfo, %ud%/actionsets.ini, %sGear%
fileappend, [%sGear%]`n%tempinfo%`n, %ud%/temp.ini
iniread, tempinfo, %ud%/temp.ini
stringreplace, tempinfo, tempinfo, `n, |, ALL
perminfo = %tempinfo%
guicontrol,, listbox2, |%tempinfo%
return

DelGear:
gui, submit, nohide
inidelete, %ud%/temp.ini, %ItemInGear%
iniread, tempinfo, %ud%/temp.ini
stringreplace, tempinfo, tempinfo, `n, |
perminfo = %tempinfo%
guicontrol,, listbox2, |%tempinfo%
return

;--------------------------------------------------------------------------------------------------------------------------------Create Gear Swap Lua
MakeGearSwap:
gui, submit, nohide
if jobtab =
{
	msgbox, 262144, Error, Must Select A Job
	return
}
gosub precast_loop
gosub midcast_loop
gosub aftercast_loop
gosub status_loop
gosub buff_loop
gosub life_loop
gosub theend
return

;---------------------------------------------------------------------------------------------------------Precast Loop
precast_loop:
precast_top = function precast(spell)
bottom = end`r`n
fileappend, %precast_top%`r`n, %ud%\temp.lua
iniread, temp_section_info, %ud%\temp.ini
loop, parse, temp_section_info, `n
{
	iniread, temp_precast_info, %ud%\temp.ini, %A_LoopField%, precast_lua
	iniread, temp_action_info, %ud%\temp.ini, %A_LoopField%, action
	if temp_precast_info != error
	{
		fileappend, %temp_action_info%`r`n, %ud%\temp.lua
		fileappend, `t%temp_precast_info%`r`n, %ud%\temp.lua
		fileappend, %bottom%, %ud%\temp.lua
	}
}
fileappend, %bottom%, %ud%\temp.lua
gosub cleantemp
return

;---------------------------------------------------------------------------------------------------------Midcast Loop
midcast_loop:
midcast_top = function midcast(spell)
bottom = end`r`n
fileappend, %midcast_top%`r`n, %ud%\temp.lua
iniread, temp_section_info, %ud%\temp.ini
loop, parse, temp_section_info, `n
{
	iniread, temp_midcast_info, %ud%\temp.ini, %A_LoopField%, midcast_lua
	iniread, temp_action_info, %ud%\temp.ini, %A_LoopField%, action
	if temp_midcast_info != error
	{
		fileappend, %temp_action_info%`r`n, %ud%\temp.lua
		fileappend, `t%temp_midcast_info%`r`n, %ud%\temp.lua
		fileappend, %bottom%, %ud%\temp.lua
	}
}
fileappend, %bottom%, %ud%\temp.lua
gosub cleantemp
return

;-------------------------------------------------------------------------------------------------------Aftercast Loop
aftercast_loop:
aftercast_top = function aftercast(spell)
bottom = end`r`n
fileappend, %aftercast_top%`r`n, %ud%\temp.lua
iniread, temp_section_info, %ud%\temp.ini
loop, parse, temp_section_info, `n
{
	iniread, temp_aftercast_info, %ud%\temp.ini, %A_LoopField%, aftercast_lua
	iniread, temp_action_info, %ud%\temp.ini, %A_LoopField%, action
	iniread, temp_cat_info, %ud%\temp.ini, %A_LoopField%, category
	iniread, temp_command_info, %ud%\temp.ini, %A_LoopField%, command
	iniread, temp_type_info, %ud%\temp.ini, %A_LoopField%, type
	if (temp_aftercast_info != "error" && temp_cat_info = 1)
	{
		fileappend, %temp_action_info%`r`n, %ud%\temp.lua
		fileappend, `t%temp_aftercast_info%`r`n, %ud%\temp.lua
		fileappend, %bottom%, %ud%\temp.lua
	}
	if (temp_command_info != "error" && temp_cat_info = 1)
	{
		fileappend, %temp_action_info%`r`n, %ud%\temp.lua
		fileappend, `t%temp_command_info%`r`n, %ud%\temp.lua	
		fileappend, %bottom%, %ud%\temp.lua	
	}
}
fileappend, %bottom%, %ud%\temp.lua
gosub cleantemp
return

;----------------------------------------------------------------------------------------------------------Status Loop
status_loop:
status_top = function status_change(new,old)
bottom = end`r`n
fileappend, %status_top%`r`n, %ud%\temp.lua
iniread, temp_section_info, %ud%\temp.ini
loop, parse, temp_section_info, `n
{
	iniread, temp_status_info, %ud%\temp.ini, %A_LoopField%, aftercast_lua
	iniread, temp_action_info, %ud%\temp.ini, %A_LoopField%, action
	iniread, temp_cat_info, %ud%\temp.ini, %A_LoopField%, category
	iniread, temp_command_info, %ud%\temp.ini, %A_LoopField%, command
	iniread, temp_type_info, %ud%\temp.ini, %A_LoopField%, type
	if (temp_status_info != "error" && temp_cat_info = 2)
	{
		fileappend, %temp_action_info%`r`n, %ud%\temp.lua
		fileappend, `t%temp_status_info%`r`n, %ud%\temp.lua
		fileappend, %bottom%, %ud%\temp.lua
	}
	if (temp_command_info != "error" && temp_cat_info = 2)
	{
		fileappend, %temp_action_info%`r`n, %ud%\temp.lua
		fileappend, `t%temp_command_info%`r`n, %ud%\temp.lua
		fileappend, %bottom%, %ud%\temp.lua		
	}
}
fileappend, %bottom%, %ud%\temp.lua
gosub cleantemp
return	

;------------------------------------------------------------------------------------------------------------Buff Loop
buff_loop:
buff_top = function buff_change(name,gain)
bottom = end`r`n
fileappend, %buff_top%`r`n, %ud%\temp.lua
iniread, temp_section_info, %ud%\temp.ini
loop, parse, temp_section_info, `n
{
	iniread, temp_buff_info, %ud%\temp.ini, %A_LoopField%, aftercast_lua
	iniread, temp_action_info, %ud%\temp.ini, %A_LoopField%, action
	iniread, temp_cat_info, %ud%\temp.ini, %A_LoopField%, category
	iniread, temp_command_info, %ud%\temp.ini, %A_LoopField%, command
	iniread, temp_type_info, %ud%\temp.ini, %A_LoopField%, type
	if (temp_buff_info != "error" && temp_cat_info = 3)
	{
		fileappend, %temp_action_info%`r`n, %ud%\temp.lua
		fileappend, `t%temp_buff_info%`r`n, %ud%\temp.lua
		fileappend, %bottom%, %ud%\temp.lua
	}
	if (temp_command_info != "error" && temp_cat_info = 3)
	{
		fileappend, %temp_action_info%`r`n, %ud%\temp.lua
		fileappend, `t%temp_command_info%`r`n, %ud%\temp.lua		
	}
}
fileappend, %bottom%, %ud%\temp.lua
gosub cleantemp
return	

;------------------------------------------------------------------------------------------------------------Life Loop
life_loop:
life_top = windower.register_event('prerender', function(new, old)
bottom = end`r`n
bottom2 = end)`r`n
fileappend, %life_top%`r`n, %ud%\temp.lua
iniread, temp_section_info, %ud%\temp.ini
loop, parse, temp_section_info, `n
{
	iniread, temp_life_info, %ud%\temp.ini, %A_LoopField%, aftercast_lua
	iniread, temp_action_info, %ud%\temp.ini, %A_LoopField%, action
	iniread, temp_cat_info, %ud%\temp.ini, %A_LoopField%, category
	iniread, temp_command_info, %ud%\temp.ini, %A_LoopField%, command
	iniread, temp_type_info, %ud%\temp.ini, %A_LoopField%, type
	if (temp_life_info != "error" && temp_cat_info = 4)
	{
		fileappend, %temp_action_info%`r`n, %ud%\temp.lua
		fileappend, `t%temp_life_info%`r`n, %ud%\temp.lua
		fileappend, %bottom%, %ud%\temp.lua
	}
	if (temp_command_info != "error" && temp_cat_info = 4)
	{
		fileappend, %temp_action_info%`r`n, %ud%\temp.lua
		fileappend, `t%temp_command_info%`r`n, %ud%\temp.lua
		fileappend, %bottom%, %ud%\temp.lua		
	}
}
fileappend, %bottom2%, %ud%\temp.lua
gosub cleantemp
return	

;---------------------------------------------------------------------------------------------------------Cleanup Crew
cleantemp:
temp_type_info =
temp_command_info =
temp_section_info =
temp_action_info =
temp_cat_info =
temp_precast_info =
temp_midcast_info =
temp_aftercast_info =
temp_status_info =
temp_buffs_info =
temp_life_info =
return


;------------------------------------------------------------------------------------------------------------------End
theend:
jobtab := joblist[jobtab]
filecopy, %ud%/temp.lua, %jobtab%.lua
msgbox, %jobtab%.lua has been created in the Easy Swap folder`r`nPlease move it to \Windower4\addons\GearSwap\data\
filedelete, %ud%/temp.lua

return


;--------------------------------------------------------------------------------------------------------------------------------------Exit Easy Swap
guiclose:
filedelete, %ud%/temp.ini
exitapp
return


This program was compiled with AHK (AutoHotKey) using its own programming language

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.