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

Post your completed (working) macros here. Only for macros using MQ2Data syntax!

Moderator: MacroQuest Developers

bardomatic
a ghoul
a ghoul
Posts: 131
Joined: Thu Apr 29, 2004 12:09 am

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

Post by bardomatic » Fri May 14, 2004 5:03 pm

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
Last edited by bardomatic on Sat Jul 02, 2005 11:58 pm, edited 5 times in total.

Drumstix42
a grimling bloodguard
a grimling bloodguard
Posts: 808
Joined: Mon May 03, 2004 4:25 pm

Post by Drumstix42 » Fri May 14, 2004 5:29 pm

Not much of a looker huh?

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


(that topic is but 3 days old)

Preocts
a snow griffon
a snow griffon
Posts: 312
Joined: Thu Jan 29, 2004 1:02 pm

Post by Preocts » Fri May 14, 2004 5:35 pm

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....

bardomatic
a ghoul
a ghoul
Posts: 131
Joined: Thu Apr 29, 2004 12:09 am

Post by bardomatic » Fri May 14, 2004 5:38 pm

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.

Drumstix42
a grimling bloodguard
a grimling bloodguard
Posts: 808
Joined: Mon May 03, 2004 4:25 pm

Post by Drumstix42 » Fri May 14, 2004 5:46 pm

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.

User avatar
TheUnholy
a hill giant
a hill giant
Posts: 269
Joined: Wed Mar 03, 2004 11:59 pm

Post by TheUnholy » Sat May 15, 2004 3:07 pm

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 )

yesman
a lesser mummy
a lesser mummy
Posts: 64
Joined: Tue Apr 27, 2004 9:06 pm

Post by yesman » Sat May 15, 2004 8:23 pm

nm I had a /declare that was fucking up your .inc

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

dirx
orc pawn
orc pawn
Posts: 21
Joined: Fri Dec 05, 2003 1:00 am
Location: orlando

Post by dirx » Tue May 18, 2004 7:05 pm

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

bardomatic
a ghoul
a ghoul
Posts: 131
Joined: Thu Apr 29, 2004 12:09 am

Post by bardomatic » Thu May 20, 2004 6:15 pm

added a timeout in original post to allow for expended potions 5-20-04

dirx
orc pawn
orc pawn
Posts: 21
Joined: Fri Dec 05, 2003 1:00 am
Location: orlando

Post by dirx » Fri May 21, 2004 8:32 am

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

A Troll
a lesser mummy
a lesser mummy
Posts: 30
Joined: Fri May 21, 2004 10:04 am

Post by A Troll » Fri May 21, 2004 10:33 am

How to put stuff in maininventory slot ?
Amulet of necropotence for example, not useabel by troll sk but clicable in inv

bardomatic
a ghoul
a ghoul
Posts: 131
Joined: Thu Apr 29, 2004 12:09 am

Post by bardomatic » Fri May 21, 2004 11:23 am

Code: Select all

/mac swapcast necrop pack1

BlackShadow
a lesser mummy
a lesser mummy
Posts: 72
Joined: Thu Apr 22, 2004 9:06 am

Post by BlackShadow » Tue May 25, 2004 12:17 pm

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 

yesman
a lesser mummy
a lesser mummy
Posts: 64
Joined: Tue Apr 27, 2004 9:06 pm

Post by yesman » Thu Jun 17, 2004 8:24 pm

nm it's because Calc is broken

Saelinye
a lesser mummy
a lesser mummy
Posts: 31
Joined: Thu Jun 03, 2004 8:17 am

Swapcast help me please..

Post by Saelinye » Tue Jun 22, 2004 8:01 am

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.