Code: Select all
;***************************************************************************
;bandolier.iss
;
;optional files:
; ${LavishScript.CurrentDirectory}/Extensions/isxeqmoveit.dll
; ${LavishScript.CurrentDirectory}/Scripts/bardomatic.xml
;
;currently isxeqmoveit is still in development and can cause crashes if misused
;it adds the functionality of being able to exchange items without opening packs
;
;to start:
; extension isxeqmoveit (optional)
; ui -reload bardomatic (optional)
; run bandolier
;
;commands:
; /bandolier -add <setname> <slots>
; /bandolier -set {same as -add}
; /bandolier -activate <setname>
; /bandolier -delete <setname>
; /bandolier -list [silent]
; /bandolier -quit
;
;valid slots:
; charm leftear head face rightear neck shoulder arms back leftwrist
; rightwrist ranged hands mainhand offhand leftfinger rightfinger chest
; legs feet waist ammo pack1 pack2 pack3 pack4 pack5 pack6 pack7 pack8
;
;examples:
; /bandolier -add bestweaps mainhand offhand
; /bandolier -add "healing focus" rightear
; /bandolier -activate bestweaps
; /bandolier -list
; /bandolier -list silent (populates the UI without echoing)
;
;
;note: issue the -set/-add command with the gear you want already equiped
;***************************************************************************
variable(global) queue:string Bandolier_Cmd
variable bool Bandolier_KeepRunning=1
variable string Bardomatic_FileName="${LavishScript.CurrentDirectory}/Scripts/Bardomatic_${Me.CleanName}.xml"
variable bool Bardomatic_SetUIOnce=1
variable bool Bandolier_Active=0
variable queue:int Exchange_Packopen
function main()
{
call init
do
{
if ${Bandolier_Cmd.Size}
{
if ${Bandolier_Cmd.Peek.Equal[-quit]}
Bandolier_KeepRunning:Set[0]
else
call dobandolier
Bandolier_Cmd:Clear
}
if ${QueuedCommands}
ExecuteQueued
else
WaitFrame
}
while ${Bandolier_KeepRunning}
}
function atexit()
{
echo [Bard-o-Matic] Bandolier Disengaged
}
function init()
{
if ${Bardomatic_SetUIOnce}
{
if ${UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[Bandolier].FindChild[BandolierListBox](exists)}
{
echo [Bard-o-Matic] Bandolier UI detected
Bandolier_Cmd:Queue[-list]
Bandolier_Cmd:Queue[silent]
Bardomatic_SetUIOnce:Set[0]
}
}
LavishSettings:AddSet[Bardomatic]
LavishSettings[Bardomatic]:Import[${Bardomatic_FileName}]
echo [Bard-o-Matic] Bandolier Engaged
}
atom(global) bandolier(... param)
{
variable int i=1
Bandolier_Cmd:Clear
while ${i}<=${param.Size}
{
Bandolier_Cmd:Queue[${param[${i}]}]
i:Inc
}
}
;***************************************************************
;
; Bandolier functions
;
;***************************************************************
function dobandolier()
{
variable string cmdlist="-add-set-delete-list-activate"
variable string Cmd
variable string prm1
variable iterator Iterator
variable iterator Iterator2
Cmd:Set[${Bandolier_Cmd.Peek}]
Bandolier_Cmd:Dequeue
prm1:Set[${Bandolier_Cmd.Peek}]
if ${cmdlist.Find[${Cmd}]}
{
if ${prm1.Equal["NULL"]}
{
Cmd:Set["-list"]
}
if ${Cmd.Equal[-activate]}
{
Bandolier_Active:Set[1]
if ${prm1.Equal["NULL"]}
return
echo [Bard-o-Matic] Bandolier::Activating set "${prm1}"
LavishSettings[Bardomatic].FindSet[bandolier].FindSet[${prm1}]:GetSettingIterator[Iterator]
while ${Iterator.Key(exists)}
{
if !${InvSlot[${Iterator.Key}].Item.Name.Find[${Iterator.Value}]}
call dounequip ${Iterator.Key}
Iterator:Next
}
Iterator:First
while ${Iterator.Key(exists)}
{
if !${InvSlot[${Iterator.Key}].Item.Name.Find[${Iterator.Value}]}
call doexchange "${Iterator.Value}" "${Iterator.Key}"
Iterator:Next
}
call closepack
Bandolier_Active:Set[0]
}
if ${Cmd.Equal[-set]} || ${Cmd.Equal[-add]}
{
if ${Bandolier_Cmd.Size}
{
echo [Bard-o-Matic] Bandolier::Adding set ${prm1}
if ${UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[Bandolier].FindChild[BandolierListBox](exists)}
{
UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[Bandolier].FindChild[BandolierListBox]:AddItem[]
}
Bandolier_Cmd:Dequeue
}
LavishSettings[Bardomatic].FindSet[bandolier]:AddSet["${prm1}"]
while ${Bandolier_Cmd.Size}>0
{
LavishSettings[Bardomatic].FindSet[bandolier].FindSet["${prm1}"]:AddSetting["${Bandolier_Cmd.Peek}","${InvSlot[${Bandolier_Cmd.Peek}].Item.Name}"]
Bandolier_Cmd:Dequeue
}
LavishSettings[Bardomatic]:Export[${Bardomatic_FileName}]
Cmd:Set["-list"]
prm1:Set["silent"]
}
if ${Cmd.Equal[-delete]}
{
echo [Bard-o-Matic] Bandolier::Deleting set ${prm1}
LavishSettings[Bardomatic].FindSet[bandolier].FindSet["${prm1}"]:Remove
LavishSettings[Bardomatic]:Export[${Bardomatic_FileName}]
if ${UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[Bandolier].FindChild[BandolierListBox](exists)}
{
UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[Bandolier].FindChild[BandolierListBox]:AddItem[]
Cmd:Set["-list"]
prm1:Set["silent"]
}
}
if ${Cmd.Equal[-list]}
{
if ${prm1.NotEqual["silent"]}
echo [Bard-o-Matic] Bandolier::List sets
if ${UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[Bandolier].FindChild[BandolierListBox](exists)}
UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[Bandolier].FindChild[BandolierListBox]:ClearItems
LavishSettings[Bardomatic].FindSet[bandolier]:GetSetIterator[Iterator]
while ${Iterator.Key(exists)}
{
if ${prm1.NotEqual["silent"]}
echo \ \ ::${Iterator.Key}
if ${UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[Bandolier].FindChild[BandolierListBox](exists)}
UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[Bandolier].FindChild[BandolierListBox]:AddItem[${Iterator.Key}]
LavishSettings[Bardomatic].FindSet[bandolier].FindSet["${Iterator.Key}"]:GetSettingIterator[Iterator2]
while ${Iterator2.Key(exists)}
{
if ${prm1.NotEqual["silent"]}
echo \ \ \ \ \ :: ${Iterator2.Key} => ${Iterator2.Value}
Iterator2:Next
}
Iterator:Next
}
}
}
}
;***************************************************************
;
; Exchange functions
;
;***************************************************************
function dounequip(fromslotpassed, direction=-1)
{
variable int packcount=29
variable int bagslot=1
variable int putslot=-1
variable bool slotfound=0
variable string validslots="charm:leftear:head:face:rightear:neck:shoulder:arms:back:leftwrist:rightwrist:ranged:hands:mainhand:offhand:leftfinger:rightfinger:chest:legs:feet:waist:ammo:pack1:pack2:pack3:pack4:pack5:pack6:pack7:pack8"
variable bool validate=0
variable string fromslot
variable int i=1
variable bool isnum=0
isnum:Set[${fromslotpassed.Equal[${Int[${fromslotpassed}]}]}]
fromslot:Set[${fromslotpassed}]
if ${validslots.Find[${fromslot}]} && ${fromslot.Length}>3
{
validate:Set[1]
}
if ${isnum} && ${fromslot}<21
validate:Set[1]
if ${validate}==0
{
if ${FindItem[${fromslot}].InvSlot}<22
{
fromslot:Set[${FindItem[${fromslot}].InvSlot}]
validate:Set[1]
}
}
if !${InvSlot[${fromslot}].Item.Name(exists)} || ${validate}==0
{
if ${Bandolier_Cmd.Size}==0
echo [Bard-o-Matic] Unequip::Nothing to unequip!
return
}
if ${putslot}==-1
{
call findopenbagslot "${InvSlot[${fromslot}].Item.Name}" ${direction}
if ${Return}>0
{
putslot:Set[${Return}]
slotfound:Set[1]
}
}
if ${slotfound}
{
if ${Bandolier_Cmd.Size}==0
echo [Bard-o-Matic] Exchange::Unequipping ${InvSlot[${fromslot}].Item.Name}
if ${Extension[isxeqmoveit](exists)}==FALSE
call openpack ${packcount}
if ${Extension[isxeqmoveit](exists)}==FALSE
call openpack ${Math.Calc[((${putslot}-251)/10)+22].Int}
variable string tempstring
tempstring:Set[${InvSlot[${fromslot}]}]
fromslot:Set[${tempstring}]
call swapit ${fromslot} ${putslot}
if ${Extension[isxeqmoveit](exists)}==FALSE && ${Bandolier_Active}==0
call closepack ${packcount}
}
else
{
echo [Bard-o-Matic] Unequip::No bag slots available!
}
}
function doexchange(string item, string passedtoslot, direction=-1)
{
variable int inventoryslot
variable string pack
variable int packslot
variable int packnumber=0
variable string toslot=${InvSlot[${passedtoslot}]}
;find item and set pack and packslot or inventoryslot
inventoryslot:Set[${FindItem[${item}].InvSlot}]
if !(${inventoryslot}>0)
{
return
}
if ${inventoryslot}>250 && ${inventoryslot}<331
{
packnumber:Set[${Math.Calc[((${inventoryslot}-251)/10)+1].Int}]
packslot:Set[${Math.Calc[(${inventoryslot}-251)%10].Int}]
}
else
{
if ${Bandolier_Cmd.Size}==0
echo [Bard-o-Matic] Exchange::Item already equipped!
return
}
;verify toslot is set
if ${toslot.Equal[""]}
if ${FindItem[${item}].WornSlots}>0
toslot:Set[${FindItem[${item}].WornSlot[1].Name}]
else
{
echo [Bard-o-Matic] Exchange::No valid destination!
return
}
variable int packcount=29
variable int bagslot=1
variable int putslot=-1
variable bool slotfound=0
if ${Extension[isxeqmoveit](exists)}==FALSE
call openpack ${Math.Calc[${packnumber}+21]}
if ${InvSlot[${Math.Calc[${packnumber}+21]}].Item.SizeCapacity}>=${InvSlot[${toslot}].Item.Size}
{
putslot:Set[${inventoryslot}]
slotfound:Set[1]
}
if ${putslot}==-1
{
do
{
if !${InvSlot[${packcount}].Item.Name(exists)}
{
putslot:Set[${packcount}]
slotfound:Set[1]
break
}
}
while ${packcount:Dec}>21
}
if ${putslot}==-1
{
call findopenbagslot "${InvSlot[${toslot}].Item.Name}" ${direction}
if ${Return}>0
{
putslot:Set[${Return}]
slotfound:Set[1]
}
}
if ${slotfound}
{
if ${Bandolier_Cmd.Size}==0
echo [Bard-o-Matic] Exchange::Equipping ${InvSlot[${inventoryslot}].Item.Name} to ${InvSlot[${toslot}].Name}
variable string tempstring
tempstring:Set[${InvSlot[${inventoryslot}]}]
inventoryslot:Set[${tempstring}]
tempstring:Set[${InvSlot["${fromslot}"]}]
fromslot:Set[${tempstring}]
call swapit ${inventoryslot} ${toslot} ${putslot}
}
else
{
if ${Bandolier_Cmd.Size}==0
echo [Bard-o-Matic] Exchange::No bag slots available!
}
if ${Extension[isxeqmoveit](exists)}==FALSE && ${Bandolier_Active}==0
call closepack
}
function findopenbagslot(searchitem, direction=-1)
{
variable int packcount
variable int finalcount
variable int putslot=-1
variable int bagslot
variable bool slotfound=0
packcount:Set[29]
do
{
if !${InvSlot[${packcount}].Item.Name(exists)}
{
putslot:Set[${packcount}]
slotfound:Set[1]
return ${putslot}
}
}
while ${packcount:Dec}>21
if ${direction}==1
{
packcount:Set[22]
finalcount:Set[30]
}
else
{
packcount:Set[29]
finalcount:Set[21]
}
do
{
if ${InvSlot[${packcount}].Item.Container}>0
{
if ${InvSlot[${packcount}].Item.SizeCapacity}>=${FindItem[${searchitem}].Size}
{
if ${InvSlot[${packcount}].Item.Items}<${InvSlot[${packcount}].Item.Container}
{
bagslot:Set[1]
do
{
putslot:Set[${Math.Calc[250+(${packcount}-22)*10+${bagslot}].Int}]
if !${InvSlot[${putslot}].Item.Name(exists)}
{
slotfound:Set[1]
return ${putslot}
}
}
while ${bagslot:Inc}<${InvSlot[${packcount}].Item.Container}
}
}
}
if ${direction}==1
packcount:Inc
else
packcount:Dec
}
while ${packcount}!=${finalcount}
return ${putslot}
}
function openpack(packslot)
{
variable int timeout=15
if !${Window[pack${Math.Calc[${packslot}-21].Int}].Open}
Exchange_Packopen:Queue[${packslot}]
while !${Window[pack${Math.Calc[${packslot}-21].Int}].Open} && ${timeout}>0
{
NoModKey EQItemNotify ${packslot} rightmouseup
WaitFrame
}
}
function closepack()
{
variable int packslot
variable int timeout=15
while ${Exchange_Packopen.Size}
{
packslot:Set[${Exchange_Packopen.Peek}]
while ${Window[pack${Math.Calc[${packslot}-21].Int}].Open} && ${timeout}>0
{
NoModKey EQItemNotify ${packslot} rightmouseup
WaitFrame
}
Exchange_Packopen:Dequeue
}
}
function swapit(fromslot, toslot, lastslot)
{
variable string item
variable int timeout=15
item:Set[${Cursor.ID}]
do
{
if ${fromslot}>250 && ${Extension[isxeqmoveit](exists)}==TRUE
moveitem ${fromslot} 30
else
NoModKey EQItemNotify ${fromslot} leftmouseup
WaitFrame
}
while ${item}==${Cursor.ID} && ${timeout}>0
timeout:Set[15]
item:Set[${Cursor.ID}]
do
{
if ${toslot}>250 && ${Extension[isxeqmoveit](exists)}==TRUE
moveitem 30 ${toslot}
else
NoModKey EQItemNotify ${toslot} leftmouseup
WaitFrame
}
while ${item}==${Cursor.ID} && ${timeout}>0
if ${lastslot.Length}>0
{
timeout:Set[15]
item:Set[${Cursor.ID}]
do
{
if !${Cursor.ID(exists)}
break
if ${lastslot}>250 && ${Extension[isxeqmoveit](exists)}==TRUE
moveitem 30 ${lastslot}
else
NoModKey EQItemNotify ${lastslot} leftmouseup
WaitFrame
}
while ${item}==${Cursor.ID} && ${timeout}>0
}
}

