Noteable changes:
- Mobs are given priority in the order they are listed in the ini file over distance.
- Items are checked against the loot list before being looted, then right-clicked if found in the ini. No unwanted items get looted, and nothing gets destroyed.
- Added buff support, and included Preocts swap macro for swapping in buff gear.
- Added in support for monk self-haste.
- /squelched the /target commands so the acquire loop doesnt spam you.
- The results subs displays information only for items you have looted.
Code: Select all
| Monkey Farmer Macro
| MonkFarm.mac
| Author : Chill
| Version : v1.2.2 27-May-2004 4:30PM EDT
| Useage : /macro Hunter
| Description : This macro will run your monk around the zone killing any mobs in
| MF_MobArray within MF_MaxRadius, then attempt to loot all items in
| MF_LootArray. Based heavily on robdawg's Hunter.mac.
|------------------------------------------------------------------------------------
#turbo 20
#Include SpellCast.inc
#Include Swap.inc
Sub Main
|------------------------------------------------------------
|How many times should aquire target fail before delaying?
|------------------------------------------------------------
/declare MF_FailMax int outer 3
|------------------------------------------------------------
|How far would you like to target a mob?
|------------------------------------------------------------
/declare MF_MaxRadius int outer 4000
|------------------------------------------------------------
|How far is the combat range?
|------------------------------------------------------------
/declare MF_Range int outer 10
|------------------------------------------------------------
|What is the minimum Z Value of mobs I should target?
|------------------------------------------------------------
/declare MF_MinZRange int outer -1000
|------------------------------------------------------------
|What is the maximum Z Value of mobs I should target?
|------------------------------------------------------------
/declare MF_MaxZRange int outer 1000
|------------------------------------------------------------
|Should I loot all items?
|------------------------------------------------------------
/declare MF_LootAllItems int outer 0
|------------------------------------------------------------
|Should I display stats?
|------------------------------------------------------------
/declare MF_DisplayStats int outer 0
|------------------------------------------------------------
|How many ticks should I let buffs run down to?
|------------------------------------------------------------
/declare MF_BuffTicks int outer 20
|------------------------------------------------------------
|What percent should I not engage mobs under? (anti KS code)
|------------------------------------------------------------
/declare MF_EngageHP int outer 98
|------------------------------------------------------------
|Generic Counter Variable
|------------------------------------------------------------
/declare c int outer 0
|------------------------------------------------------------
|Loot Array Information.
|------------------------------------------------------------
/call ReadINI HunterMob.ini "${Zone.Name}"
/if (!${Defined[MF_MobArray]}) {
/echo Mob Array Creation Error, ending macro...
/endmacro
}
|------------------------------------------------------------
|Mob Array Information.
|------------------------------------------------------------
/call ReadINI HunterLoot.ini "${Zone.Name}"
/if (!${Defined[MF_LootArray]}) {
/echo No Loot Array Created...
}
|------------------------------------------------------------
|Variables that you don't need to worry about.
|------------------------------------------------------------
/declare MF_FailCounter int outer 0
/declare MF_MyTargetID int outer 0
/declare MF_MyTargetName string outer
/declare MF_MyTargetDead int outer 0
/declare MF_InvalidTargetID int outer 0
/declare MF_HasTarget int outer 0
/declare MF_RandomWait int outer 0
/declare MF_LootSlot int outer 0
/declare MF_CheckLook int outer 0
/declare MF_Fighting int outer 0
/declare MF_TargetDead int outer 0
/declare MF_MyXLOC int outer 0
/declare MF_MyYLOC int outer 0
/declare MF_FastRange int outer
/declare MF_RangeMax int outer
/declare MF_RangeMin int outer
/varcalc MF_FastRange ${MF_Range}+3
/varcalc MF_RangeMax ${MF_Range}+1
/varcalc MF_RangeMin ${MF_Range}-1
/declare MF_HasteGloves string outer
/varset MF_HasteGloves Gauntlets of Enlightenment
/fastdrop on
/lootn never
:Start
/doevents
/call GMCheck
/call BuffCheck
/call GetTarget ${MF_MaxRadius} 1
:KillAdds
/if (${MF_HasTarget}) /call MoveToMob
/if (${MF_HasTarget}) /call CombatSub
/if (${MF_HasTarget}) /call MoveToMob
/if (${Target.Type.Equal[Corpse]} && (${Defined[MF_LootArray]} || ${MF_LootAllItems})) /call LootMob
/if (${MF_DisplayStats}) /call DisplayStats
/call ResetSub
/if (${SpawnCount[pc]}>1) {
/varset MF_RandomWait ${Math.Rand[2]}
/varcalc MF_RandomWait ${MF_RandomWait}+1
/echo Paranoia - Waiting ${MF_RandomWait} seconds before resuming
/delay ${MF_RandomWait}s
}
/if (${Target.ID}) {
/echo Looks like something is attacking us, killing it...
/delay 2
/varset MF_HasTarget 1
/varset MF_Fighting 1
/goto :KillAdds
}
/goto :Start
/return
|--------------------------------------------------------------------------------
|SUB: Aquire Target
|Usage: /call GetTarget [search radius] [prefered mob #]
|--------------------------------------------------------------------------------
Sub GetTarget(int Radius, int Sub)
/if (!${Defined[Radius]}) /declare Radius int local ${MF_MaxRadius}
/if (${Target.ID}) {
/declare TempTarget int local ${Target.ID}
/target clear
}
/declare MF_CurrentRadius int local ${Radius}
/declare MF_TargetSub int local 1
:Acquire
/if (${Defined[Sub]}) {
/squelch /target npc radius ${Radius} notid ${MF_InvalidTargetID} "${MF_MobArray[${Sub}]}"
/if (${Target.ID}) {
/varset MF_MyTargetID ${Target.ID}
/varset MF_MyTargetDead 0
/if (${SpawnCount[pc]}>1 && ${Int[${Target.PctHPs}]}<${MF_EngageHP}) {
/echo ${Target.CleanName} already engaged at ${Target.PctHPs}% health, picking another...
/varset MF_InvalidTargetID ${Target.ID}
/call ResetSub
/goto :Acquire
}
/if (${Int[${Target.Z}]}<${MF_MinZRange}) {
/echo Mob is BELOW Min Z Range, picking another...
/varset MF_InvalidTargetID ${Target.ID}
/call ResetSub
/goto :Acquire
}
/if (${Int[${Target.Z}]}>${MF_MaxZRange}) {
/echo Mob is ABOVE Max Z Range, picking another...
/varset MF_InvalidTargetID ${Target.ID}
/call ResetSub
/goto :Acquire
}
/varset MF_HasTarget 1
/varset MF_MyTargetName ${Target.Name}
/echo Acquired ${Target.Name} at range ${Int[${Target.Distance}]}
/return
}
}
/for MF_CurrentRadius 50 to ${Radius} step 50
/for MF_TargetSub 1 to ${MF_MobArray.Size}
/squelch /target npc radius ${MF_CurrentRadius} notid ${MF_InvalidTargetID} "${MF_MobArray[${MF_TargetSub}]}"
/varset MF_MyTargetID ${Target.ID}
/varset MF_MyTargetDead 0
/if (${Target.ID}) {
/if (${SpawnCount[pc]}>1 && ${Int[${Target.PctHPs}]}<${MF_EngageHP}) {
/echo ${Target.CleanName} already engaged at ${Target.PctHPs}% health, picking another...
/varset MF_InvalidTargetID ${Target.ID}
/call ResetSub
/goto :Acquire
}
/if (${Int[${Target.Z}]}<${MF_MinZRange}) {
/echo Mob is BELOW Min Z Range, picking another...
/varset MF_InvalidTargetID ${Target.ID}
/call ResetSub
/goto :Acquire
}
/if (${Int[${Target.Z}]}>${MF_MaxZRange}) {
/echo Mob is ABOVE Max Z Range, picking another...
/varset MF_InvalidTargetID ${Target.ID}
/call ResetSub
/goto :Acquire
}
/varset MF_HasTarget 1
/varset MF_MyTargetName ${Target.Name}
/echo Acquired ${Target.Name} at range ${Int[${Target.Distance}]}
/return
}
/next MF_TargetSub
/delay 1
/next MF_CurrentRadius
/if (${Defined[TempTarget]}) {
/squelch /target npc id ${TempTarget}
/return
}
/if (!${Target.ID}) {
/delay 2
/varcalc MF_FailCounter ${MF_FailCounter}+1
/echo Failed to Acquire Target in Range ${MF_MaxRadius} ${MF_FailCounter} Time(s)
/if (${MF_FailCounter}>=${MF_FailMax}) {
/echo Waiting for Respawns, Resetting Failure Counter...
/delay 2s
/varset MF_FailCounter 0
}
/goto :Acquire
}
/return
|--------------------------------------------------------------------------------
|SUB: Moving
|--------------------------------------------------------------------------------
Sub MoveToMob
/varset MF_MyXLOC ${Int[${Me.X}]}
/varset MF_MyYLOC ${Int[${Me.Y}]}
/declare MF_DistanceTimer timer 15
/doevents
:MovementLoop
|if not yet fighting, the only player in the zone, and you run over a mob not your target, check if you want to kill it.
/if (!${MF_Fighting} && ${SpawnCount[pc]}==1 && ${SpawnCount[npc radius 40]} && ${Target.Distance}>40) /call GetTarget 50
/if (!${MF_Fighting} && !${MF_TargetDead}) {
/if (${Int[${Target.PctHPs}]}<${MF_EngageHP} && ${SpawnCount[pc]}>1) {
/echo ${Target.CleanName} already engaged at ${Target.PctHPs}% health, picking another...
/varset MF_InvalidTargetID ${Target.ID}
/varset MF_HasTarget 0
/call ResetSub
/return
}
}
/if (${Target.ID}) /face fast
/if (${Int[${Target.Distance}]}>${MF_FastRange}) {
/keypress forward hold
}
/if (${Int[${Target.Distance}]}<${MF_FastRange}&&${Int[${Target.Distance}]}>${MF_RangeMax}) {
/keypress forward
}
/if (${Int[${Target.Distance}]}<${MF_RangeMin}) {
/keypress back
}
/if (!${MF_DistanceTimer}) {
/if ((${MF_MyXLOC}==${Int[${Me.X}]})&&(${MF_MyYLOC}==${Int[${Me.Y}]})) /call HitObstacle
/varset MF_MyXLOC ${Int[${Me.X}]}
/varset MF_MyYLOC ${Int[${Me.Y}]}
/varset MF_DistanceTimer 15
/goto :Movementloop
}
/if (${Int[${Target.Distance}]}>${MF_FastRange}) /goto :MovementLoop
/return
|--------------------------------------------------------------------------------
|SUB: Combat
|--------------------------------------------------------------------------------
Sub CombatSub
/echo Attacking ${Target.CleanName} NOW!
/varset MF_Fighting 1
/varset MF_TargetDead 0
:CombatLoop
/doevents
/if (${MF_HasteGloves.Equal[${Me.Inventory[hands]}]} && !${Me.Buff["Celestial Tranquility"].Duration}) /cast item "${MF_HasteGloves}"
/delay 1
/attack on
/call MoveToMob
/call SpecialIT
/if (!${Target.ID} || ${Target.Type.Equal[Corpse]}) {
/attack off
/keypress forward hold
/keypress back
/varset MF_TargetDead 1
/varset MF_Fighting 0
/target npc corpse radius 40
/delay 1
/if (!${Target.ID}) {
/call ResetSub
/return
}
/face fast
}
/if (!${MF_TargetDead}) {
/goto :CombatLoop
}
/return
|--------------------------------------------------------------------------------
|SUB: Special Combat
|--------------------------------------------------------------------------------
Sub SpecialIt
/if ((${Target.Distance}<11)&&(${Me.AbilityReady["Flying Kick"]})) /doability "Flying Kick"
/if ((${Int[${Me.PctHPs}]}<40) && ${Me.AbilityReady["Mend"]}) {
/echo Mending at ${Me.PctHPs} health...
/doability "Mend"
/if (${Int[${Me.PctHPs}]}<20) {
/echo Getting my ass kicked, feigning death...
/cleanup
/keypress esc
/attack off
/keypress forward
/keypress back
/delay 1
/doability "Feign Death"
/beep
/beep
/endmacro
}
}
/return
|--------------------------------------------------------------------------------
|SUB: Looting
|--------------------------------------------------------------------------------
Sub LootMob
/declare LootSlot int inner 0
/declare LootCheck int inner 0
/declare LootTotal int inner 0
/declare LootName string inner
/declare Looted bool inner
/if (${Target.ID}) /face fast
/keypress forward hold
/keypress back
/delay 2
/loot
/delay 2s
/if (!${Corpse.Items}) {
/echo NO LOOT! Cheap Bastard!
/return
}
/varset LootTotal ${Corpse.Items}
/for LootSlot 1 to ${LootTotal}
/varset LootName ${Corpse.Item[${LootSlot}]}
/if (${MF_LootAllItems}) {
/echo ${LootSlot} - Looting a ${LootName}... WOOT!
/itemnotify loot${LootSlot} rightmouseup
/varcalc MF_LootStats[${LootCheck}] ${MF_LootStats[${LootCheck}]}+1
/delay 6
} else {
/varset Looted 0
/for LootCheck 1 to ${MF_LootArray.Size}
/if (${LootName.Find[${MF_LootArray[${LootCheck}]}]}) {
/echo ${LootSlot} - Looting a ${LootName}... WOOT!
/itemnotify loot${LootSlot} rightmouseup
/varcalc MF_LootStats[${LootCheck}] ${MF_LootStats[${LootCheck}]}+1
/varset Looted 1
/delay 6
}
/next LootCheck
/if (!${Looted}) /echo ${LootSlot} - Leaving a ${LootName}...
}
/next LootSlot
/if (${Cursor.ID}) {
/popup INVENTORY FULL?
/echo Inventory seems full, no room for ${Cursor.Name}...
/beep
/autoinventory
}
/notify LootWnd DoneButton leftmouseup
/delay 1s
/return
|--------------------------------------------------------------------------------
|SUB: Reset
|--------------------------------------------------------------------------------
Sub ResetSub
/if (${Corpse.Open}) /notify LootWnd DoneButton leftmouseup
| /cleanup
| /keypress esc
/delay 1
/varset MF_HasTarget 0
/varset MF_TargetDead 0
/varset MF_Fighting 0
/return
|--------------------------------------------------------------------------------
|SUB: Obstacle Avoidance
|--------------------------------------------------------------------------------
Sub HitObstacle
/if (${Corpse.Open}) /notify LootWnd DoneButton leftmouseup
/echo Obstacle hit, moving around it...
/keypress forward
/keypress back hold
/delay 5
/keypress back
/if (${Math.Rand[100]}+1>50) {
/keypress strafe_right hold
} else {
/keypress strafe_left hold
}
/delay 5
/keypress strafe_right
/keypress strafe_left
/keypress forward hold
/delay 1
/keypress jump
/return
|--------------------------------------------------------------------------------
|SUB: GM Check
|--------------------------------------------------------------------------------
Sub GMCheck
/if (${Spawn[gm].ID}) {
/beep
/beep
/beep
/echo GM has entered the zone!
/echo FUCK HIM but ending the macro...
/keypress forward
/keypress back
/quit
/endmacro
}
/return
|--------------------------------------------------------------------------------
|SUB: Reading from an INI File
|--------------------------------------------------------------------------------
Sub ReadINI(FileName,SectionName)
/echo Attempting to Read Section "${SectionName}" Zone Information from ${FileName}...
/if (${Ini[${FileName},${SectionName},-1,NO].Equal[NO]}) {
/echo "${SectionName}" is not a Valid Section for FILE:${FileName}, ending macro...
/delay 1
/return
}
/declare nValues int local 1
/declare nArray int local 0
/declare KeySet string local ${Ini[${FileName},${SectionName}]}
:CounterLoop
/if (!${KeySet.Arg[${nValues},|].Length}) {
/varcalc nValues ${nValues}-1
/goto :MakeArray
}
/varcalc nValues ${nValues}+1
/goto :CounterLoop
:MakeArray
/if (!${nValues}) /return
/if (${FileName.Equal["HunterMob.ini"]}&&${nValues}>0) {
/echo Declaring Mob Array...
/declare MF_MobArray[${nValues}] string outer
/declare MF_MobStats[${nValues}] string outer
}
/if (${FileName.Equal["HunterLoot.ini"]}&&${nValues}>0) {
/echo Declaring Loot Array...
/declare MF_LootArray[${nValues}] string outer
/declare MF_LootStats[${nValues}] string outer
}
/for nArray 1 to ${nValues}
/if (${FileName.Equal["HunterMob.ini"]}) {
/varset MF_MobArray[${nArray}] ${Ini[${FileName},${SectionName},${KeySet.Arg[${nArray},|]},NULL]}
/varset MF_MobStats[${nArray}] 0
}
/if (${FileName.Equal["HunterLoot.ini"]}) {
/varset MF_LootArray[${nArray}] ${Ini[${FileName},${SectionName},${KeySet.Arg[${nArray},|]},NULL]}
/varset MF_LootStats[${nArray}] 0
}
/next nArray
/echo "${SectionName}" Zone Information Read Successfully from ${FileName}...
/delay 1
/return
|--------------------------------------------------------------------------------
|SUB: Display Stats
|--------------------------------------------------------------------------------
Sub DisplayStats
/declare nArray int local
/if (${Defined[MF_LootArray]}) {
/for nArray 1 to ${MF_LootArray.Size}
/if (${Int[${MF_LootStats[${nArray}]}]} > 0) /echo (${Int[${MF_LootStats[${nArray}]}]}) ${MF_LootArray[${nArray}]}'s
/next nArray
}
/return
|--------------------------------------------------------------------------------
|SUB: Buff Check - Monk Specific, but can be edited for other classes
|--------------------------------------------------------------------------------
Sub BuffCheck
/echo Checking Buffs...
/if (!${Me.Standing} && !${Me.Mount.ID}>0) /stand
/if (${Me.Moving}) {
/keypress forward
/keypress back
/delay 5
}
/if (${Me.Buff["Vengeful Guard"].Duration} < ${MF_BuffTicks}) /call cast "Cloak of Retribution" item
/for c 1 to 15
/if (${Me.Buff[${c}].Name.Find["boar"]} || ${Me.Buff[${c}].Name.Find["bear"]} || ${Me.Buff[${c}].Name.Find["stamina"]}) /goto :nosta
/next c
/if (${Me.Buff["Health"].Duration} < ${MF_BuffTicks}) {
/target myself
/delay 1
/call swap "swap:Ton Po's Leggings of Composure=Leggings of Enlightenment|clicky:Leggings of Enlightenment|swap:Leggings of Enlightenment=Ton Po's
Leggings of Composure"
/delay 1
/target clear
}
:nosta
/if (!(${MF_HasteGloves.Equal[${Me.Inventory[hands]}]} || ${Me.Buff["Strength of Tunare"].Duration} || ${Me.Buff["Spiritual Vigor"].Duration} ||
${Me.Buff["Celestial Tranquility"].Duration})) {
/if (${Me.Buff["Grim Aura"].Duration} < ${MF_BuffTicks}) /call swap "swap:Resonating Earring of Battle=Shrunken Goblin Skull Earring|clicky:Shrunken
Goblin Skull Earring|swap:Shrunken Goblin Skull Earring=Resonating Earring of Battle"
}
/for c 1 to 15
/if (${Me.Buff[${c}].Name.Find["focus"]}) /goto :focused
/next c
/if (${Me.Buff["Shield of the Arcane"].Duration} < ${MF_BuffTicks}) /call swap "swap:Stonehide Tunic=Chestwraps of
Enlightenment|clicky:chest|swap:Chestwraps of Enlightenment=Stonehide Tunic"
/delay 1
:focused
/return
HunterMob.ini
Code: Select all
[Eastern Plains of Karana]
Mob1=spider
Mob2=giant
Mob3=lion
Mob4=chasm
Mob5=snake
[East Commonlands]
Mob1=Spider
[The Feerrott]
Mob1=SpiderCode: Select all
[Eastern Plains of Karana]
Loot1=Silk
Loot2=High Quality
Loot3=Medium Quality
Loot4=egg
[East Commonlands]
Loot1=Silk
[The Feerrott]
Loot1=SilkCode: Select all
|** Swap.mac Version 2. by: Preocts Updated Last: 05/15/2004
As a summer project to help me learn C++ I am currently creating
a plugin that will completely replace this macro and more. I am
thinking this will eliminate the ini functions of the operation. In
replacement /commands will be able to be used in macros for complex
or multi-staged swaps. Everything is up in the air at this point
because I still get headaches trying to learn Pointers. ::sigh::
As my knowledge of C++ increases I hope to be able to contribute
to the advancement of the MacroQuest project.
Introduction:
A much much much evolved version of my old switch.mac that I wrote about
a month ago. This one is VERY flexible in what you can do. Ini or param
driven commands. You can also store ini commands in-game. Does not open
your inventory window but will open packs as needed. Resets your packs
after macro is done so if you had 'that' one open it will remain open.
I use this most heavily on my bard, allowing me to swap instruments out
with a push of a hotkey. Wrote in a clicky command for my rogue who always
seemed to lose her buff gear in her packs! ((cronic packrat))
This is written to be modular and expanded. Almost all the subs handle one
aspect of the 'switch' so adding this to your existing macros as an include
should be almost painless.
Making an Include File: (or using parts of this macro)
There are 7 subs below that can be pulled out of this entire macro and
used inside your own macros for the manipulation of items and slots.
The two rightclick subs will wait for any casting items to finsih before
releasing control back to where they were called
1) Sub LeftClickItem(ItemName) <------ Searches, finds, left clicks
2) Sub LeftClickSlot(Slot) <---------- Left clicks any slot name or num
3) Sub LeftClickPackSlot(Pack,Slot) <- Opens bags, then left clicks
4) Sub RightClickItem(ItemName) <----- For those rightclick items
5) Sub RightClickSlot(Slot) <--------- Same, but with slotnames
*6) Sub OpenPack(Pack) <--------------- Needed for 1, and 3
*7) Sub DisplayError(sInput) <--------- Needed for ALL the above.
The parameters they need are self explaining. If you want to use them just
copy them and the following two subs to you macro file or an include.
*These are standalones but required if you use 1-5
Some important notes:
+ If the item is stacked the ENTIRE stack is picked up.
+ Be cool. "Enclose your commandline in quotes"
+ Options are explicit. If it tells you [ItemName]>[SlotName/CustomName] then
that is what you MUST give it. IN THAT ORDER!
+ All commands must be separated by | when entering mulitple actions. The
expection are IF commands. They use /. Mixing will cause problems.
+ No command will check Cursor Status before executing. Assumed Empty!
This means you need to think your logic out. If move an item to your neck
slot and then move an item to your mainhand, be sure you did something with
the item that 'was' in your neck slot before you began.
+ Clicky Commands for items inside packs are pointless and will do nothing.
+ bouncy bouncy bouncy bouncy boun- damnit
+ HolyShit! Did I just add IF statements? Why yes! Yes I did.
+ VERY VERY IMPORTANT INOFRMATION:
The newest installment of this macro includes rewritten command handling.
What does this mean to you? Well, you now have no limits as to how you
do commands. You can call CommandSet@s from CommandSet@s, inside IFs, and
'nest' them as deeply as MQ2 can handle. THE MAJOR FACTOR HERE IS:
You now run the change of creating an infinite loop. In non-programming
terms this means you can cause this macro to keep running forever with no
end. There is an example of this at the end of the comments section.
(although I haven't tested it, I'm sure you still CANNOT nest ifs. Sorry)
Commands:
+ "Swap:[ItemName/SlotName/CustomName]=[ItemName/SlotName/CustomName]"
Puts the first item you give it where the second is and puts the second
where the first was.
+ "MoveTo:[ItemName]>[SlotName/CustomName]"
Moves Item to Slot
+ "PickUp:[ItemName/SlotName/CustomName]"
Places Item onto cursor (More literally, preforms a leftmouseup on [])
+ "Clicky:[ItemName/SlotName]"
Rightclicks Item/Slot. Waits for Cast.
+ "Empty"
Smart Empty of Cursor. Fails on full Inv.
+ "IfOn?ItemName?TrueAction/?FalseAction/?"
If ItemName is on the cursor, preform TrueAction. Else, preform FalseAction
Ending ? is required or you risk errors.
Actions can contain more than one command. Divider inside Ifs is / not |.
Neither True or False actions are required. ?-1? will skip that action
+ "IfIn?ItemName:SlotName?TrueAction/?FalseAction/?"
If ItemName is in SlotName then do TrueAction, else do FalseAction.
Ending ? is required or you risk errors. CANNOT CHECK INSIDE PACKS.
Actions can contain more than one command. Divider inside Ifs is / not |.
Neither True or False actions are required. ?-1? will skip that action
+ "KeyName$Commands"
Writes Commands to KeyName in the INI file. Does not run Commands.
Options:
[ItemName] are full item names only. No partial names will be found.
[SlotName] The following list are valid slot names:
mainhand offhand ranged charm leftear rightear leftwrist rightwrist arms
head neck face shoulder chest legs waist rightfinger leftfinger feet ammo
back pack1 pack2 pack3 pack4 pack5 pack6 pack7 pack8
(Slot Numbers will work as long as they are not located inside a pack)
[CustomName] may be used to identify a slot inside a pack. Format:
pack1!2 Slot 2 in Pack1
pack5!4 Slot 4 in Pack5
(Forces the macro to make sure that pack is open)
Using Swap.Mac:
Something to always remember: Swap.Mac does not care what is on the cursor
when it runs a command. That's why I made Ifs.
/macro swap "Swap:Foraging Machette=Scimitar of the Emerald Dawn"
Swaps the two items between their current slots.
/macro swap "MoveTo:Fisherman's Companion>Pack8!3"
Moves Companion to pack8, slot three. Note: if anything was there it is
now on the cursor.
/macro swap "pickup:arms"
Leftclicks the arms slot.
/macro swap "Clicky:LeftEar"
This rightclicks your left ear piece.
/macro swap "Moveto:Shrunken Goblin Skull Earring>LeftEar|Clicky:LeftEar|Pickup:LeftEar|Empty"
Moves your SGSE to your ear slot (whatever was there in on cursor)
Clicks the slot, casting the self-buff
Picks up the SGSE(leftear) which places whatever was there back there.
Empty the Cursor.
/macro swap "EarBuff$Moveto:Shrunken Goblin Skull Earring>LeftEar|Clicky:LeftEar|Pickup:LeftEar|Empty"
Writes the command to ini. DOES NOT RUN COMMANDS
Ini would then contain:
EarBuff=Moveto:Shrunken Goblin Skull Earring>LeftEar|Clicky:LeftEar|Pickup:LeftEar|Empty
/macro swap "EarBuff@" <------- MUST end with @ to pull from ini.
The same thing as:
/macro swap "Moveto:Shrunken Goblin Skull Earring>LeftEar|Clicky:LeftEar|Pickup:LeftEar|Empty"
/macro swap "IfOn?Foraging Machette?pickup:MainHand/Empty?-1?"
If your foraging Machette is on the cursor, place it in the MainHand
slot and empty cursor.
/macro swap "IfIn?Shrunken Goblin Skull Earring:LeftEar?clicky:LeftEar?EarBuff@?
If the SGKE is in the leftear click it.
Otherwise, do a bunch of commands to put the earring in the LeftEar
slot and click it.
Rules about IFs
1) Thou shalt not ever nest IFs.
2) Thou shalt not ever use | in IFs. Thou shall use / instead.
Ini File:
Default Ini Filename: Swapper.ini
Example:
[SwapCommands]
Drums=Swap:OffHand=Mistmoore Battle Drums|
Lute=Swap:OffHand=Lute|
Fight=PickUp:OffHand|MoveTo:Symphonic Saber>MainHand|MoveTo:Battle Drummers Main Gauche>OffHand|
Kite=PickUp:MainHand|MoveTo:Mistmoore Battle Drums>OffHand|Empty|
EarBuff=Moveto:Shrunken Goblin Skull Earring>LeftEar|Clicky:LeftEar|Pickup:LeftEar|Empty
Examples of things you can now do:
[SwapCommands]
Wow=Drums@|Lute@|EarBuff@
/macro swap "Wow@"
/macro swap "ifin?Mistmoore Battle Drums:offhand?Lute@?Drums@?"
Never End Loop: (really simple "duh!" kind of example)
[SwapCommands]
Set1=bunchofcommandshere|Swap2@
Set2=bunchmorecommandshere|Swap1@
/macro swap Swap1@
THIS WILL NEVER STOP! Set1 calls Set2 which calls Set1 again, on and on.
**|
#define IniFileName Swapper.ini
Sub Swap(sInput)
/if (!${Defined[sInput]}) /call DisplayError "SwitchMain;No Parameter Defined"
/if (${sInput.Right[1].NotEqual[|]}) /varset sInput ${sInput}|
| /declare GlobalTimerOut timer outer 0
/declare nCount int local
/declare InvState[8] int local
/if (${sInput.Find[$]}) {
/ini "IniFileName" "SwapCommands" "${sInput.Arg[1,$]}" "${sInput.Arg[2,$]}"
/echo Written to IniFileName:
/echo ${sInput.Arg[1,$]}=${sInput.Arg[2,$]}
/return
}
/for nCount 1 to 8
/if (${Window[Pack${nCount}].Open}) {
/varset InvState[${nCount}] 0
} else {
/varset InvState[${nCount}] 1
}
/next nCount
/call Parser "${sInput}"
/for nCount 1 to 8
/if (${Window[Pack${nCount}].Open} && ${InvState[${nCount}]}) /itemnotify Pack${nCount} rightmouseup
/delay 1
/next nCount
/return
Sub Parser(sInput)
/if (!${Defined[sInput]}) /call DisplayError "Parser;No Parameter Defined"
/if (${sInput.Right[1].NotEqual[|]}) /varset sInput ${sInput}|
/declare CommandSet string local
/declare nCount int local 1
:ParserLoop
/if (${sInput.Arg[${nCount},|].Find[@]}) {
/varset CommandSet ${Ini[IniFileName,SwapCommands,${sInput.Arg[${nCount},|].Arg[1,@]},NOTFOUND]}
/if (${CommandSet.Equal[NOTFOUND]}) /call DisplayError "Main;Swapset ${sInput.Arg[${nCount},|].Arg[1,@]} not found"
/call Parser "${CommandSet}"
} else {
/call HandleCommand "${sInput.Arg[${nCount},|]}"
}
/varcalc nCount ${nCount}+1
/if (${sInput.Arg[${nCount},|].Length}) /goto :ParserLoop
/return
Sub IfCommandSet(sInput)
|This does absolutly nothing with the commands given. It only changes
|all the /s to |s for the main parser.
/if (!${Defined[sInput]}) /call DisplayError "IfCommandSet;No parameter given"
/if (${sInput.Equal[-1]}) /return
/declare nStep int local 1
/declare sStep string local
/for nStep 1 to ${sInput.Length}
/if (${sInput.Mid[${nStep},1].Equal[/]}) {
/varset sStep ${sStep}|
} else {
/varset sStep ${sStep}${sInput.Mid[${nStep},1]}
}
/next nStep
/call Parser "${sStep}"
/return
Sub HandleCommand(sInput)
/if (!${Defined[sInput]}) /call DisplayError "HandleCommand;No Parameter Defined
|IfOn: IF statement directly checks the cursor.name and compares. Pulls the
|resulting command out of sInput and parses them separetly.
/if (${sInput.Arg[1,?].Equal[IfOn]}) {
/if (${Cursor.Name.Equal[${sInput.Arg[2,?]}]}) {
/call IfCommandSet "${sInput.Arg[3,?]}"
} else {
/call IfCommandSet "${sInput.Arg[4,?]}"
}
}
|IfIn: If statement checks for the presents of an item in a slot. Pulls the
|resulting command out of sInput and parses them separetly. ITEM BEFORE SLOT
/if (${sInput.Arg[1,?].Equal[IfIn]}) {
/if (${sInput.Arg[2,?].Arg[2,:].Find[!]}) /varset ${sInput}
/if (${InvSlot[${sInput.Arg[2,?].Arg[2,:]}].Item.Name.Equal[${sInput.Arg[2,?].Arg[1,:]}]}) {
/call IfCommandSet "${sInput.Arg[3,?]}"
} else {
/call IfCommandSet "${sInput.Arg[4,?]}"
}
}
|Swap: Most complex since both params can be any of the three types. Determine
|what type the param is, send a leftclick command, then do the same for the
|next param. In the end send a leftclick command to the slot used in the first
|param. Follow?
/if (${sInput.Arg[1,:].Equal[Swap]}) {
/varset sInput ${sInput.Arg[2,:]}
/declare Param1 string local ${sInput.Arg[1,=]}
/declare Param2 string local ${sInput.Arg[2,=]}
/declare SlotUsed int local
/if (${Param1.Find[!]}) {
/call LeftClickPackSlot ${Param1.Arg[1,!]} ${Param1.Arg[2,!]}
} else {
/call ValidSlot ${Param1}
/if (${Macro.Return.Equal[true]}) {
/call LeftClickSlot "${Param1}"
/varset SlotUsed ${InvSlot[${Param1}].ID}
} else {
/call LeftClickItem "${Param1}"
/varset SlotUsed ${Macro.Return}
}
}
/if (${Param2.Find[!]}) {
/call LeftClickPackSlot ${Param2.Arg[1,!]} ${Param2.Arg[2,!]}
} else {
/call ValidSlot ${Param2}
/if (${Macro.Return.Equal[true]}) {
/call LeftClickSlot "${Param2}"
} else {
/call LeftClickItem "${Param2}"
}
}
/call LeftClickSlot ${SlotUsed}
}
|MoveTo: Pickup the item and move it to the slot. Nothing is done to the
|cursor after this point. i.e. If the slot had an item in it that item is now
|on the cursor.
/if (${sInput.Arg[1,:].Equal[Moveto]}) {
/varset sInput ${sInput.Arg[2,:]}
/call LeftClickItem "${sInput.Arg[1,>]}"
/varset sInput ${sInput.Arg[2,>]}
/if (${sInput.Find[!]}) {
/call LeftClickPackSlot ${sInput.Arg[1,!]} ${sInput.Arg[2,!]}
} else {
/call LeftClickSlot "${sInput}"
}
}
|PickUp: Determine whether the param given is a slot/packslot/or item then
|send the proper leftclick command. Does not concider any items already on
|the cursor.
/if (${sInput.Arg[1,:].Equal[PickUp]}) {
/varset sInput ${sInput.Arg[2,:]}
/if (${sInput.Find[!]}) {
/call LeftClickPackSlot ${sInput.Arg[1,!]} ${sInput.Arg[2,!]}
} else {
/call ValidSlot ${sInput}
/if (${Macro.Return.Equal[true]}) {
/call LeftClickSlot "${sInput}"
} else {
/call LeftClickItem "${sInput}"
}
}
}
|Clicky: Determine whether the param given is a slot or item. Send a click
|command to that slot/item. Very simple.
/if (${sInput.Arg[1,:].Equal[Clicky]}) {
/varset sInput ${sInput.Arg[2,:]}
/call ValidSlot ${sInput}
/if (${Macro.Return.Equal[true]}) {
/call RightClickSlot "${sInput}"
} else {
/call RightClickItem "${sInput}"
}
}
|Empty: Easiest of all. Empty the cursor of any contents as long as there is
|room for them in the inventory. Will error exit if there is not room.
/if (${sInput.Arg[1,:].Equal[EMPTY]}) {
/call Command_Empty
}
| /delay 1
/return
| BEGIN THE GUTS OF THE MACRO ------------------------
Sub LeftClickItem(ItemName)
/if (!${Defined[ItemName]}) /call DisplayError "LeftClickItem;No Parameter"
/declare CC int local ${Cursor.ID}
/if (${Window[BigBankWnd]}) {
/declare ItemLoc int local ${FindItem[=${ItemName}].InvSlot.ID}
/if (!${ItemLoc}) {
/varset ItemLoc ${FindItemBank[=${ItemName}].InvSlot.ID}
/if (!${ItemLoc}) /call DisplayError "LeftClickItem;${ItemName} not found in inventory or bank."
}
} else {
/declare ItemLoc int local ${FindItem[=${ItemName}].InvSlot.ID}
/if (!${ItemLoc}) /call DisplayError "LeftClickItem;${ItemName} not found in inventory."
}
/if (${InvSlot[${ItemLoc}].Pack.ID}) /call OpenPack ${InvSlot[${ItemLoc}].Pack.ID}
|Inventory Window doesn't need to be open but Packs do for /itemnotify to work
/shift /itemnotify ${ItemLoc} leftmouseup
/declare TimerOut timer local 2s
:LCIWait
/if (!${TimerOut}) /call DisplayError "LeftClickItem;Operation Timed Out"
/if (${Cursor.ID}==${CC}) /goto :LCIWait
|Stay in loop until timeout or cursor change. Error exit on timeout because
|something has gone wrong at that point. The item WAS reported in the slot
|we DID just click. If we don't get a change in the cursor....
|Return ItemLoc so we can use it in a Swap call.
|ItemLoc==SlotNumber of where we just got this item.
/return ${ItemLoc}
Sub LeftClickSlot(Slot)
/if (!${Defined[Slot]}) /call DisplayError "LeftClickSlot;No Parameter"
/declare CC int local ${Cursor.ID}
/shift /itemnotify ${Slot} leftmouseup
/declare TimerOut timer local 2s
:LCSWait
/if (${Cursor.ID}==${CC} && ${TimerOut}) /goto :LCSWait
|Keep in loop until cursor changes or timeout. Don't error on timeout since
|we can assume no cursor change meant that slot was empty or the item can't
|go into that slot.
/return
Sub LeftClickPackSlot(Pack,Slot)
/if (!${Defined[Pack]} || !${Defined[Slot]}) /call DisplayError "LeftClickPackSlot;No Parameter"
/declare CC int local ${Cursor.ID}
/call OpenPack ${Pack}
/shift /itemnotify in ${Pack} ${Slot} leftmouseup
/declare TimerOut timer local 2s
:LCPSWait
/if (${Cursor.ID}==${CC} && ${TimerOut}) /goto :LCPSWait
|Keep in loop until cursor changes or timeout. Don't error on timeout since
|we can assume no cursor change meant that slot was empty or the item can't
|go into that slot.
/return
Sub RightClickItem(ItemName)
/if (!${Defined[ItemName]}) /call DisplayError "RightClickItem;No Parameter"
/declare ItemLoc int local ${FindItem[=${ItemName}].InvSlot.ID}
/if (!${ItemLoc}) /call DisplayError "RightClickItem;Error, ${ItemName} not found in inventory."
/if (${InvSlot[${ItemLoc}].Pack.ID}) /return
|If the item is inside a pack just exit. Nothing happens if you click them.
/itemnotify ${ItemLoc} rightmouseup
/delay 2
:WaitForCast
/if (${Me.Casting.ID}) /goto :WaitForCast
|Really nothing to check beyond waiting for a spell to cast. Either something
|happens or something doesn't. Items don't fizzle and one should hope this
|isn't being used to cast a Crusiable of Escape where interuppts matter.
/return
Sub RightClickSlot(Slot)
/if (!${Defined[Slot]}) /call DisplayError "RightClickSlot;No Parameter"
/itemnotify ${Slot} rightmouseup
/delay 2
:WaitForCast
/if (${Me.Casting.ID}) /goto :WaitForCast
|Yay, so easy. Slot name->Click->WaitForCast->DONE!
/return
Sub OpenPack(Pack)
|Input can be string or int.
/if (!${Defined[Pack]}) /call DisplayError "OpenPack;No Parameter Defined"
|Looks reduntant but makes sense. This allows either a slotname or number to be evaluated.
/if (!${Window[${InvSlot[${Pack}].Name}].Open}) {
/itemnotify ${Pack} rightmouseup
/declare TimerOut timer local 4s
:Wait1
/if (!${TimerOut}) /call DisplayError "OpenPack;Error Could Not open ${InvSlot[${Pack}].Name}"
/if (!${Window[${InvSlot[${Pack}].Name}].Open}) /goto :Wait1
/delay 3
|Bags seem to take a few extra cycles to register 'open' with both MQ and EQ, hence the /delay
}
/return
Sub DisplayError(sInput)
/echo Warning, Error. Macro Ended in Sub ${sInput.Arg[1,;]}
/if (${sInput.Arg[2,;].Length}) /echo Error Message: ${sInput.Arg[2,;]}
/endmacro
/return
| END THE GUTS OF THE MACRO ------------------------
Sub Command_Empty
|Rather basic. Exception is now we can make sure there is room for the item.
:EmptyLoop
/if (!${Cursor.ID}) /return
|Better to end the macro than drop something really important.
/if (!${Me.FreeInventory[${Cursor.Size}]}) /call DisplayError "Command_Empty:No Inventory Space for ${Cursor.Name}."
/autoinventory
/goto :EmptyLoop
/return
Sub ValidSlot(SlotName)
|Input can be string or int.
/if (!${Defined[SlotName]}) /call DisplayError "ValidSlot;No Parameter Defined"
|If the slotname or number has an ID then it exists.
/if (${InvSlot[${SlotName}].ID}) {
/return TRUE
} else {
/return FALSE
}
/return FALSE



