Page 1 of 5

swapcast.mac a swap item and cast it macro (updated 7-2-5)

Posted: Fri May 14, 2004 5:03 pm
by bardomatic
This is my first attempt at a useful macro, i have lots of right click items and hate searching through packs to find them then equip them then put them back ....

Useage: /mac swapcast itemname [slot]

example:

Code: Select all

 /mac swapcast coldain
will find and equip Coldain Hero's Insignia Ring , then cast and return it to where it was found.

if you have multiple items with similar names then use quotes.

Code: Select all

/mac swapcast "Coldain Hero's Insignia Ring"
if you want to specify the slot to equip it in then you may.

Code: Select all

/mac swapcast "Coldain Hero's Insignia Ring" rightfinger
if you want to make this an .inc file then just remove the Sub Main section.

Code: Select all

Sub Main(p0,p1)
   /call SwapCast "${p0}" "${p1}"
/endmacro

Sub SwapCast(item,equipslot)
   /declare inventoryslot int local
   /declare pack local
   /declare packslot int local
   /declare leaveopen int local 1
   /declare packnumber int local 0
   /declare leavetwisting int local 0

   /if (!${Defined[item]}) /goto :end
   /if (${Twist}) {
      /twist stop
      /varset leavetwisting 1
   }
   :stopsingingdelay
   /if (${Me.Casting.ID}>0) {
      /stopsong
      /goto :stopsingingdelay
      }
   /varset inventoryslot ${FindItem[${item}].InvSlot}
   /if (!${inventoryslot}) /goto :notfound
   :packcountloop
   /if (${inventoryslot}>250 && ${inventoryslot}<331) {
      /varset packnumber ${Math.Calc[${packnumber}+1]}
      /varset inventoryslot ${Math.Calc[${inventoryslot}-10]}
      /goto :packcountloop
      }
   /if (${packnumber} > 0) {
      /varset pack pack${packnumber}
      /varset packslot ${Math.Calc[${inventoryslot}-240]}
      /goto :foundit
      }
   :notinpack
      /call CastItem ${inventoryslot}
      /goto :end
   :foundit
      /if (!${Window[${pack}].Open}) {
         /nomod /itemnotify ${pack} rightmouseup
         /varset leaveopen 0
         }
      /call WaitCursor ${packslot} ${pack}
      /if (${equipslot.Find[null]}) {
         /if (${Cursor.WornSlots}>0) {
            /varset equipslot ${Cursor.WornSlot[1]}
         } else {
               /varset equipslot pack1
         }
      }
      /call WaitCursor ${equipslot}
      /call CastItem ${equipslot}
      /call WaitCursor ${equipslot}
      /call WaitCursor ${packslot} ${pack}
      /if (${leaveopen} == 0) /nomod /itemnotify ${pack} rightmouseup
      /goto :end
   :notfound
      /echo ${item} not found in inventory.
   :end
   /if (${leavetwisting} == 1) /twist start
/return

Sub CastItem(slot)
   /nomod /itemnotify ${slot} rightmouseup
   /echo Swapcast::Casting the effect on your ${InvSlot[${slot}].Item.Name}
   :castloop
|| special case composer greaves don't ever stop casting
      /if (${InvSlot[${slot}].Item.Name.Find["Composers Greaves"]}) {
         /delay 12
         /stopsong
      }
|| special cases for epics and other items that don't seem to cast proper with default cast times
       /if (${InvSlot[${slot}].Item.Name.Find["Blade of Vesagran"]}) {
         /delay 10
         /stopsong
      }
      /if (${InvSlot[${slot}].Item.Name.Find["Prismatic Dragon Blade"]}) {
         /delay 10
         /stopsong
      }
      /if (${Me.Casting.ID}>0) /goto :castloop
/return

Sub WaitCursor(slot, pack)
   /declare item local
   /declare timeout timer 30
   /varset item ${Cursor.ID}
   /if (${Defined[pack]}) /goto :waitloop2
   :waitloop1
      /nomod /itemnotify ${slot} leftmouseup
   /if ((${item} == ${Cursor.ID}) && (${timeout} > 0)) /goto :waitloop1
   /goto :donewaiting
   :waitloop2
      /nomod /itemnotify in ${pack} ${slot} leftmouseup
   /if ((${item} == ${Cursor.ID}) && (${timeout} > 0)) /goto :waitloop2
   :donewaiting
/return
edit: added timeout delay for poofed items 5-20-04
edit: fixed to work with 6-29-05 patch

Posted: Fri May 14, 2004 5:29 pm
by Drumstix42
Not much of a looker huh?

http://macroquest2.com/phpBB2/viewtopic.php?t=7126


(that topic is but 3 days old)

Posted: Fri May 14, 2004 5:35 pm
by Preocts
Why the fuck do people do that? Who cares if he saw my macro or not? He wrote is own, working, functional, inovative, and creative macro to do the job he needed done. Fuck of a lot better than most the whiny people on this board.

I will never understand....

Posted: Fri May 14, 2004 5:38 pm
by bardomatic
Actually i did see Preocts, but his has alot of configuring overhead, this one is very simple, just feed it a name and your done, no ini, no telling it where what who why, just a name a it casts.

Posted: Fri May 14, 2004 5:46 pm
by Drumstix42
Didn't say his macro was bad, and I'm not criticizing at all. Just seemed like he hadn't seen any. But now I know he has.

Posted: Sat May 15, 2004 3:07 pm
by TheUnholy
this macro works very well. can even name items already equipped and it'll cast them for us lazy people who'd rather just hotkey 10 clickies )

Posted: Sat May 15, 2004 8:23 pm
by yesman
nm I had a /declare that was fucking up your .inc

Great btw, I love it much more than spellcast.inc

Posted: Tue May 18, 2004 7:05 pm
by dirx
First of all great first offering. This macro is very useful I now have buttons for all my illusions and all of my clickys. One issue I have run into is that if you use this to cast something that disapears when you cast it like a potion or poison it goes into a loop that says "no container at pack7 open" or something similiar. I made a macro to cast all my clickys and then poison my blade. It works if I manually end it at the end of the cycle but otherwise it hangs up when the poison disapears at the end. Any help would be appreciated. Here is the code i am using.

Code: Select all


Sub Main(p0,p1) 
   
   /call SwapCast "guise of the coercer" "${p1}"
   /call SwapCast "anizok's minimizing device" "${p1}"
   /call SwapCast "anizok's minimizing device" "${p1}"
   /call SwapCast "coldain" "${p1}"
   /call SwapCast "shrunken" "${p1}"
   /call SwapCast "green" "${p1}"
   /call SwapCast "black" "${p1}"
   /call SwapCast "stanos' wicked breastplate" "${p1}"
   /call SwapCast "stanos' wicked gauntlets" "${p1}"
   /call SwapCast "stanos' wicked leggings" "${p1}"
   /delay 3
   /autoinv
   /delay 3
   /call SwapCast "summoned: scoriae bite" "${p1}"




/endmacro 

Sub SwapCast(item,equipslot) 
   /declare inventoryslot int local 
   /declare pack local 
   /declare packslot int local 
   /declare leaveopen int local 1 
   /declare packnumber int local 0 
   /declare leavetwisting int local 0 

   /if (!${Defined[item]}) /goto :end 
   /if (${Twisting}) { 
      /twist stop 
      /varset leavetwisting 1 
   } 
   :stopsingingdelay 
   /if (${Me.Casting.ID}>0) { 
      /stopsong 
      /goto :stopsingingdelay 
      } 
   /varset inventoryslot ${FindItem[${item}].InvSlot} 
   /if (!${inventoryslot}) /goto :notfound 
   :packcountloop 
   /if (${inventoryslot}>250 && ${inventoryslot}<331) { 
      /varset packnumber ${Math.Calc[${packnumber}+1]} 
      /varset inventoryslot ${Math.Calc[${inventoryslot}-10]} 
      /goto :packcountloop 
      } 
   /if (${packnumber} > 0) { 
      /varset pack pack${packnumber} 
      /varset packslot ${Math.Calc[${inventoryslot}-240]} 
      /goto :foundit 
      } 
   :notinpack 
      /call CastItem ${inventoryslot} 
      /goto :end 
   :foundit 
      /if (!${Window[${pack}].Open}) { 
         /nomod /itemnotify ${pack} rightmouseup 
         /varset leaveopen 0 
         } 
      /call WaitCursor ${packslot} ${pack} 
      /if (${String[${equipslot}].Find[null]}) { 
         /if (${Cursor.WornSlots}>0) { 
            /varset equipslot ${Cursor.WornSlot[1]} 
         } else { 
               /varset equipslot pack1 
         } 
      } 
      /call WaitCursor ${equipslot} 
      /call CastItem ${equipslot} 
      /call WaitCursor ${equipslot} 
      /call WaitCursor ${packslot} ${pack} 
      /if (${leaveopen} == 0) /nomod /itemnotify ${pack} rightmouseup 
      /goto :end 
   :notfound 
      /echo ${item} not found in inventory. 
   :end 
   /if (${leavetwisting} == 1) /twist start 
/return 

Sub CastItem(slot) 
   /nomod /itemnotify ${slot} rightmouseup 
   /echo Casting the effect on your ${InvSlot[${slot}].Item.Name} 
   :castloop 
|| special case composer greaves don't ever stop casting 
      /if (${InvSlot[${slot}].Item.Name.Find["Composers Greaves"]}) { 
         /delay 12
         /stopsong 
      } 
      /if (${Me.Casting.ID}>0) /goto :castloop 
/return 

Sub WaitCursor(slot, pack) 
   /declare item local 
   /varset item ${Cursor.ID} 
   /if (${Defined[pack]}) /goto :waitloop2 
   :waitloop1 
      /nomod /itemnotify ${slot} leftmouseup 
   /if (${item} == ${Cursor.ID}) /goto :waitloop1 
   /goto :donewaiting 
   :waitloop2 
      /nomod /itemnotify in ${pack} ${slot} leftmouseup 
   /if (${item} == ${Cursor.ID}) /goto :waitloop2 
   :donewaiting 
/return

Thanks,

Dirx

Posted: Thu May 20, 2004 6:15 pm
by bardomatic
added a timeout in original post to allow for expended potions 5-20-04

Posted: Fri May 21, 2004 8:32 am
by dirx
Great thanks! That fixed it. (there is a typo on second timeout - after I added the E worked like a charm) Great script once again :)

Dirx

Posted: Fri May 21, 2004 10:33 am
by A Troll
How to put stuff in maininventory slot ?
Amulet of necropotence for example, not useabel by troll sk but clicable in inv

Posted: Fri May 21, 2004 11:23 am
by bardomatic

Code: Select all

/mac swapcast necrop pack1

Posted: Tue May 25, 2004 12:17 pm
by BlackShadow
Added these 2 lines, otherwise it doesnt work with expendable items when they are gone.

Code: Select all

      /call WaitCursor ${equipslot} 
      /call CastItem ${equipslot} 
      /call WaitCursor ${equipslot} 
[color=red]      /if (${Cursor.ID}) {[/color]
        /call WaitCursor ${packslot} ${pack} 
[color=red]      }[/color]
      /if (${leaveopen} == 0) /nomod /itemnotify ${pack} rightmouseup 

Posted: Thu Jun 17, 2004 8:24 pm
by yesman
nm it's because Calc is broken

Swapcast help me please..

Posted: Tue Jun 22, 2004 8:01 am
by Saelinye
I really want to use this Macro, however for some reason, it neither swaps nor casts (due to the not swap thing).

It does try to click the item, however it never actually swaps it with my current item Im wearing.

Any help is appreciated.

Basically I have my item in my main inv slot.. not a bag. I run

/call swapcast "Shrunken Goblin Skull earring" rightfinger

and it says, must be equipped to cast... or something like that.

Thanks in advance for any help,
Saelinye.