SwapCast.iss
Posted: Sun May 21, 2006 12:45 am
Code: Select all
;***************************************************************************
;swapcast.iss
;
;optional files:
; isxeqmoveit.dll
; 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 swapcast
;
;commands:
; /swapcast <item> [slot]
; /swapcast -effect <effect>
; /swapcast -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:
; /swapcast "coldain hero"
; /swapcast -effect "skeleton"
;
;
;note: if no slot is specified then it will try to cask in pack1 slot
; this will work if there is a pack there
; also this will pause twisting if using with twist.iss
;***************************************************************************
variable(global) queue:string SwapCast_Cmd
variable bool SwapCast_KeepRunning=1
variable bool Bardomatic_SetUIOnce=1
function main()
{
call init
do
{
if "${SwapCast_Cmd.Size}"
{
if "${SwapCast_Cmd.Peek.Equal[-quit]}"
SwapCast_KeepRunning:Set[0]
else
call doSwapCast
SwapCast_Cmd:Clear
}
if ${QueuedCommands}
ExecuteQueued
else
WaitFrame
}
while "${SwapCast_KeepRunning}"
}
function atexit()
{
deleteatom SwapCast
deletevariable SwapCast_Cmd
echo [Bard-o-Matic] SwapCast 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
SwapCast_Cmd:Queue[-list]
SwapCast_Cmd:Queue[silent]
Bardomatic_SetUIOnce:Set[0]
}
}
echo [Bard-o-Matic] SwapCast Engaged
}
global atom SwapCast(... param)
{
variable int i=1
SwapCast_Cmd:Clear
while "${i}<=${param.Size}"
{
SwapCast_Cmd:Queue[${param[${i}]}]
i:Inc
}
}
;***************************************************************
;
; SwapCast functions
;
;***************************************************************
function doSwapCast()
{
variable int inventoryslot
variable string pack
variable int packslot
variable int packnumber=0
variable string item
variable string equipslot
variable string whentocast
variable int i=1
variable string Cmd=${SwapCast_Cmd.Peek}
if "${Cmd.Mid[1,1].Equal[-]}"
{
SwapCast_Cmd:Dequeue
if "${Cmd.Equal[-list]}"
{
if "${UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[SwapCast].FindChild[SwapCastListBox](exists)}"
{
UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[SwapCast].FindChild[SwapCastListBox]:ClearItems
}
do
{
if "${InvSlot[${i}].Item.EffectType.Find[Click]}"
{
if "${SwapCast_Cmd.Peek.NotEqual[silent]}"
echo slot ${i} == ${InvSlot[${i}].Item.Spell.Name} == ${InvSlot[${i}].Item.EffectType}
if "${UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[SwapCast].FindChild[SwapCastListBox](exists)}"
{
UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[SwapCast].FindChild[SwapCastListBox]:AddItem[${InvSlot[${i}].Item.Spell.Name}]
}
}
}
while "${i:Inc}<22"
i:Set[251]
do
{
if "${InvSlot[${i}].Item.EffectType.Find[Click]}"
{
if "${SwapCast_Cmd.Peek.NotEqual[silent]}"
echo slot ${i} == ${InvSlot[${i}].Item.Spell.Name} == ${InvSlot[${i}].Item.EffectType}
if "${UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[SwapCast].FindChild[SwapCastListBox](exists)}"
{
UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[SwapCast].FindChild[SwapCastListBox]:AddItem[${InvSlot[${i}].Item.Spell.Name}]
}
}
}
while "${i:Inc}<330"
SwapCast_Cmd:Clear
return
}
if "${Cmd.Equal[-effect]}"
{
i:Set[1]
do
{
if "${InvSlot[${i}].Item.Spell.Name.Equal[${SwapCast_Cmd.Peek}]}"
{
; echo slot ${i} == ${InvSlot[${i}].Item.Spell.Name} == ${InvSlot[${i}].Item.EffectType}
item:Set["${InvSlot[${i}].Item.Name}"]
equipslot:Set[""]
whentocaststring:Set[""]
SwapCast_Cmd:Dequeue
break
}
}
while "${i:Inc}<22"
i:Set[251]
if "${Cmd.Equal[-effect]}"
{
do
{
if "${InvSlot[${i}].Item.Spell.Name.Find[${SwapCast_Cmd.Peek}]}"
{
; echo slot ${i} == ${InvSlot[${i}].Item.Spell.Name} == ${InvSlot[${i}].Item.EffectType}
item:Set["${InvSlot[${i}].Item.Name}"]
equipslot:Set[""]
whentocaststring:Set[""]
item:Set["${InvSlot[${i}].Item.Name}"]
SwapCast_Cmd:Dequeue
break
}
}
while "${i:Inc}<330"
}
}
if "${SwapCast_Command.Equal[-add]}"
{
echo adding
; if "${UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[SwapCast].FindChild[SwapCastListBox](exists)}"
; {
; UIElement[Bardomatic ui].FindChild[Bardomatic Control Options].FindChild[SwapCast].FindChild[SwapCastListBox]:AddItem[${SwapCast_CommandParams[1]}]
; }
; SettingXML[${Bardomatic_FileName}].Set["SwapCast"]:AddSet["${SwapCast_CommandParams[1]}",0]
}
if "${SwapCast_Command.Equal[-delete]}"
{
}
if "${SwapCast_Command.Mid[1,1].Equal[-]}"
return
}
Exchange_LeaveOpen:Set[1]
if "${item.Length}==0"
{
item:Set[${SwapCast_Cmd.Peek}]
SwapCast_Cmd:Dequeue
}
if "${SwapCast_Cmd.Size}>0"
{
equipslot:Set[${SwapCast_Cmd.Peek}]
SwapCast_Cmd:Dequeue
}
if "${SwapCast_Cmd.Size}>0"
{
whentocast:Set[${SwapCast_Cmd.Peek}]
SwapCast_Cmd:Dequeue
}
; echo ${item}, ${equipslot}, ${whentocast}
;find item and set pack and packslot or inventoryslot
inventoryslot:Set[${FindItem[${item}].InvSlot}]
if "!(${inventoryslot}>0)"
{
echo [bard-o-matic] SwapCast failed, Item not found like WTF
return
}
if "${inventoryslot}>250 && ${inventoryslot}<331"
{
packnumber:Set[${Math.Calc[((${inventoryslot}-251)/10)+1].Int}]
packslot:Set[${Math.Calc[(${inventoryslot}-251)%10].Int}]
}
else
{
call castit ${inventoryslot} ${whentocast}
return
}
;echo slot ${inventoryslot}, ${equipslot}
;verify equipslot is set
if "${equipslot.Length}==0 || ${equipslot.Equal[NULL]}"
if "${FindItem[${item}].EffectType.Find["Click Inventory"]}"
equipslot:Set[pack1]
else
if "${FindItem[${item}].WornSlots}>0"
equipslot:Set[${FindItem[${item}].WornSlot[1].Name}]
variable string tempstring
tempstring:Set[${InvSlot[${inventoryslot}]}]
inventoryslot:Set[${tempstring}]
tempstring:Set[${InvSlot[${equipslot}]}]
equipslot:Set[${tempstring}]
;start the SwapCast
;echo slot ${inventoryslot}, ${equipslot}
call swapit ${inventoryslot} ${equipslot}
call castit ${equipslot} ${whentocast}
call swapit ${equipslot} ${inventoryslot}
}
function castit(slot, whenwhen)
{
variable int resumetwist=0
variable int i=1
if "${Script[twist](exists)}==TRUE"
{
if "${Twist_Twisting}==1"
{
resumetwist:Set[1]
twist -pause
while "${Twist_Twisting}==1"
{
}
}
}
echo [Bard-o-Matic] SwapCast::Casting ${InvSlot[${slot}].Item.Spell.Name} on your ${InvSlot[${slot}].Item.Name}
; check if casting an illusion and click off old illusion
if "${InvSlot[${slot}].Item.Spell.Name.Find[Illusion]}"
do
{
; echo buff${i}=${Me.Buff[${i}].Name}
if "${Me.Buff[${i}].Name.Find[Illusion]}"
If "${Me.Buff[${i}].Name.NotEqual[${InvSlot[${slot}].Item.Spell.Name}]}"
NoModKey EQnotify BuffWindow BW_Buff${Math.Calc[${i}-1].Int}_Button leftmouseup
}
while "${i:Inc}<=21"
while "${Me.Casting.ID}>0"
EQExecute /stopsong
; special case delays for items that have recast timers that don't trigger properly
if "${InvSlot[${slot}].Item.Name.Find["Blade of Vesagran"]}"
wait 5
; cast item now
NoModKey EQItemNotify ${slot} rightmouseup
; special case composer greaves don't ever stop casting and other items that resuming Twist_Twisting will interrupt
if "${InvSlot[${slot}].Item.Name.Find["Composers Greaves"]}"
{
wait 13
EQExecute /stopsong
}
if "${InvSlot[${slot}].Item.Name.Find["Flautist's Sorrow"]}"
{
wait 33
EQExecute /stopsong
}
; these items have odd timing for their casts
if "${InvSlot[${slot}].Item.Name.Find["Mirrored Mask"]}"
wait 10
if "${InvSlot[${slot}].Item.Name.Find["Blade of Vesagran"]}"
wait 12
if "${InvSlot[${slot}].Item.Name.Find["Prismatic Dragon Blade"]}"
wait 12
wait 200 !${Me.Casting(exists)}
;done casting let twist resume
if "${resumetwist}"
twist -start
}
;***************************************************************
;
; Exchange functions
;
;***************************************************************
function swapit(fromslot, toslot, lastslot)
{
variable string item
variable int timeout=15
; echo [SwapIt] ${fromslot}, ${toslot}, ${lastslot}
item:Set[${Cursor.ID}]
do
{
if "${fromslot}>250"
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"
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"
moveitem 30 ${lastslot}
else
NoModKey EQItemNotify ${lastslot} leftmouseup
WaitFrame
}
while "${item}==${Cursor.ID} && ${timeout}>0"
}
}