Monk Macro (MK) v1.0

Troll

New member
Joined
Mar 16, 2006
Messages
308
Reaction score
0
Points
0
Location
USA
Okay so I took the RH Macro apart and reconfigured it for a Monk I have been playin. As best as i can tell it works out and doesn't crash or anything. Let me know Preferred with SS's or exact syntax errors if something goes stupid but I have been playin with it for last 5 hours and it didn't even burp.

Macro will create a Custom ToonName_Settings.ini file and a ToonNameItems.ini file.

This is for those like me who play multiple of the same class on the same system with different gear and clickies.

MOST of the code and commands are still exactly like RH.

Make sure you have autoattack on assist OFF (/assist off)

Plugins needed: MQ2MoveUtils, MQ2Exchange

Some Key Changes/Additions
--------------------------------------------
Code:
[B]Nimble[/B] has been Changed to Voiddance

[B]Escape[/B] has been Changed to Imitate Death

[B]Mend[/B] has been added to fire right before Voiddance to increase chances of survivability.
[B]
/autoability "ability"[/B] = This is where you can set Kick, Flying Kick, Eagle Strike, etc... Just make sure you put it in quotes like you see above.

Commands
-----------------------------------
Code:
[b]/status[/b] This will give you the current settings of the Macro
[b]/mkhelp[/b] This will give you a brief summary of the commands and their syntax
[b]/stopfight <%health>[/b] This will set at what % of your current health Autoattack will turn off.
[b]/endfloor <%endurance>[/b] No Effect will be removed in later versions
[b]/autostick[/b] Toggles automatic sticking to targets while fighting them. Autosticking implies staying behind the target as well, unless obstructed by an object preventing you from getting behind it or while tanking.
[b]/autos[/b] Toggles Auto Sneak while not fighting (This means you will not be able to run at full speed and appear to be walking)
[b]/leash OFF|<distance> <master>[/b] With the leash command, you can dynamically create one of two types of leashes and tether yourself to it: a stake-bound leash or a master-bound leash. If you specify just a distance and no master, /leash will drive a "stake" in the ground at your current position, and return to this point after you finish a combat. If you specify both distance and a master, after combats you'll return to the "master's" side, regardless of where the master is located. If you indicate OFF as a parameter instead of a distance, leashing will be turned off.
[b]/autoassist ON|OFF|<main assist> [<%health>][/b] Allows you to activate or deactivate automatically assisting a PC or NPC, as well as setting the name of the PC or NPC you wish to assist. The "% health" parameter is a value from 1 to 99 designating the percentage health that your target must reach before you engage. The percentage health is an optional parameter that defaults to 98%
[b]/dynaggro[/b] Toggles whether or not MK should be responsible for the your rogue's aggression level (only meaningful if you're using /autoassist). This feature will LOWER the percentage at which autoassist will fire by 1% if you were attacked during any given fight. If you were not attacked on the most recent fight, it will RAISE the percentage at which autoassist will fire by 1%. The assist percentage never stabilizes--it will always either go up or down after every fight. When using this command, if the feature is on, it will be turned off (and vice versa).
[b]/closeness <%hitrange>[/b] With this command you can set the percentage of the maximum range used in order to reach your target while autosticking. For some zones (Kael for example) the reported range is incorrect and too large--for such zones, set the closeness range to a smaller value such as 20 or 30. For most zones, 70% is adequate.
[b]/mainassist <player>[/b] This command is part of a set of three commands used to designate who you should autoassist, assuming you've activated the autoassist feature. This particular command sets the main assist (the main assist is also settable via /autoassist; however using autoassist both sets the main assist AND turns autoassist on--this command will only set the main assist).
[b]/secondassist <player>[/b] This command is part of a set of three commands used to designate who you should autoassist, assuming you've activated the autoassist feature. This particular command sets the secondary assist. If the main assist dies, zones, or linkdies, MK will cascade to the secondary assist as a backup and will reinstate the main assist whenever they're alive or reconnect again.
[b]/thirdassist <player>[/b] This command is part of a set of three commands used to designate who you should autoassist, assuming you've activated the autoassist feature. This particular command sets the tertiary assist. If the main assist and secondary assist die, zone, or linkdie, MK will cascade to the tertiary assist as a backup's backup and will reinstate the main assist whenever they're alive or reconnect again.
[b]/drag <body1> <body2> ... <bodyN>[/b] Drag corpses. You must supply one or more player names as parameters (unlimited). In order to stop dragging bodies, target yourself (F1).
[b]/lootmycorpse <# of items to leave on corpse>[/b] With this command, you request MK to loot your entire corpse. Be warned that it's not aware of whether or not you've received a resurrection yet or not! If you're body is too far away or lag is too intense, it will abort with an appropriate failure message.
[b]/autofollow [<name>] [<distance>][/b] This command will activate autofollowing, which will stay active until your target changes (to nothing, yourself, or anything else). If an MK event is detected (such as a situation where autoassist is warranted, or looting, for example) autofollow will be deactivated automatically and the interrupting activity will take place. You need not specify range or target (it will use the current target if one isn't specified).
[b]/iset <itemalias> KEEPUP|NOKEEPUP <"Item Name">[/b] This command is part of a set of three commands used to manage clickable items and their effects. This particular command allows you to set and store an item alias for a given clickable item. You also can specify whether or not you want MK to automatically try to maintain the spell effect of this item. If a superior spell effect doesn't stack with the item's effect, you should use the /ibounce command to specify said spells.
[b]/ibounce <itemalias> <"Spell Name">[/b] This command is part of a set of three commands used to manage clickable items and their effects. This particular command allows you to set and store which spell effects do not stack with the spell effect created by a given clickable item. You may store an unlimited number of spell effects that "bounce off" of a given clickable item's effect. When MK maintains your clickable buffs, it will consult your existing buffs looking for these bounce spells prior to trying to re-click the conflicting item. Enclose spell names in double quotes (" ")! The item in question must be aliased with the /iset command prior to using this command.
[b]/iclick <itemalias>[/b] This command is part of a set of three commands used to manage clickable items and their effects. This particular command allows you to request MK to invoke the clickable effect for a given item. If you're not wearing the item, MK will fetch it, click it, put it back in it's original container (in it's original spot) and close the container. The item in question must be aliased with the /iset command prior to using this command.
[b]/pause[/b] The pause command suspends all of MK's operations. Use this if you want to temporarily disable MK without unloading it.
[b]/autoninja OFF|DROP|DROPABLE|ALL [<range>][/b] This command will activate automatic NPC corpse looting whenever you are awarded experience. The first parameter can be set to ALL (which will loot everything on a corpse), DROP or DROPABLE (which will only loot non-NODROP flagged items), or OFF (which disables corpse looting). The optional range parameter determines how far away MK will "look" for a corpse from your position at time of experience award (default is 50 feet).
[b]/addmaster <name>[/b] This command adds a "master" (an authorized remote controller) given the supplied name to the master control list stored within the ToonNameSettings.INI file. Whenever a "master" sends a tell to the rogue running MK, and the tell starts with a "/" character, MK will execute the entire line of the tell. A maximum of 20 masters can be stored; after the 20th master is stored, you'll be forced to delete one before you can add another.
[b]/remmaster <name>[/b] This command removes a "master" (an authorized remote controller) given the supplied name from the master control list stored within the ToonNameSettings.INI file. It is a complimentary function to the ADDMASTER command.
[b]/weaponswitch OFF|<weapon1> <"switch text"> <weapon2>[/b] With this command, you can have MK automatically choose between two different weapons, depending on a settable situation. At the end of a combat, MK will restore weapon1 to your grasp. Whenever the supplied "switch text" is encountered (usually this the proc message, be it personal buff or target debuff) the weapon will be swapped out for weapon2. WEAPONSWITCH is also smart enough to determine if the weapon procs a buff (in which case you'd probably like it to only switch back to weapon1 when the proc'ed buff wears off rather than after you finish off the mob. It handles this automatically. Make sure you do not typo the name of the weapons, or the switch text; also, the switch text does not need to be complete, but should be as complete as possible to not accidentally swap weapons around if someone speaks the trigger text. Weapons will be retrieved and deposited in any containers they come from (or on your character). Alternately, you can specify OFF as the first parameter to stop weaponswitching.
[b]/targetswitch[/b] Toggles whether or not MK should automatically choose a new target if the main assist does, or if it should "finish off" the current target. If your main assist is also the puller, you may want target switching OFF, as it will be expected that you finish off the last one before the next one is arrives. When using this command, if the feature is on, it will be turned off (and vice versa).
[b]/stickdist <range_to_target> <range_to_tank>[/b] With this command, you can regulate how close you must be to both your current target or the main assist in order to continue (or begin) autosticking to a given target. If you find yourself farther than the specified range to target or you've wandered farther than the specified range to your tank/mainassist, you will stop sticking to the target. This command is mostly useful to prevent you from chasing down runners when the main assist does not (or should not) as well as not running after mobs that recently gated far, far away.
[b]/autochicken [ON|OFF|<voiddance%>] [Imitate][/b] Provides you with automatic self-preservation. When activated, MK will execute a Mend if available then Voiddance discipline if available whenever you health percentage reaches the "voiddance%" parameter. If the word "imitate" is optionally supplied, if nimble is unavailable, this feature will cease combat and use you Imitate Death AA skill.
[b]/autodisc1 ON|OFF|<"discipline name"> <end%> <reuse>[/b] Establish an optional discipline to employ while fighting. The specified discipline (enclosed within " " if it's more than one word!) will be executed any time you have at least "end%" amount of endurance. You must also specify the reuse time of the discipline (minutes) as this information is currently unknown to MQ2 for the original combat disciplines.
[b]/autodisc2 ON|OFF|<"discipline name"> <end%> <reuse>[/b] Establish an optional discipline to employ while fighting. The specified discipline (enclosed within " " if it's more than one word!) will be executed any time you have at least "end%" amount of endurance. You must also specify the reuse time of the discipline (minutes) as this information is currently unknown to MQ2 for the original combat disciplines.
[b]/autoability "ability"[/b] This is used for abilities like Kick, Flying Kick, etc....  Make sure you include the " "
[b]/leashflex <%length>[/b] With this command you can set the threshold of when MK considers you to be "close enough" to the stake or master to stop moving toward it. If you set the leash flexibility very low (1), you'll return to the leash and nearly be on top of the stake or master. If you set the leash flexibility very high (100), you'll never return to the stake or master, but you won't go beyond your leash length when autosticking either.
[b]/verbosity 0|1|2[/b] With this command, you determine the level of text output that MK generates. A verbosity level of '0' will only output command switching information, but MK operational output will be almost completely silent. Verbosity level 1 shows all major MK activity. Verbosity level 2 shows everything, including ancillary MK background operations. The default is 2.
[b]/channel <channel>[/b] With this command, you can control where MK directs it's output. Status information and general MK operations text will go to whatever channel you set. In essence, whatever text you supply here is suffixed after a "/" and then output strings are appended afterwards. "Echo" is the default channel. Creative users can use the IRC plugin and set the channel to "I" to send MK output to an existing IRC channel(assuming you've loaded the MQ2IRC plugin and already joined a channel).
[b]/dynclose[/b] Toggles whether or not MK should be responsible for the temporary automatic adjustment of the closeness to target (requires /autostick to be on). This feature will move you 20% closer to the target every two seconds, until you're in swinging range. Original closeness value is restored when the current target is killed. When using this command, if the feature is on, it will be turned off (and vice versa).
[b]/lp[/b] Never Used most likely will remove later versions

Any Question, Comments, Suggestions, Bugs, etc.... just let me know I will see what I can do.


Code:
|--------------------------------------------------------------------------------- 
| Originally RH.mac by: Jerle
| Reconfigured for Monks by: Troll
| 
| MK Syntax: 
| 
| Usage: /mac mk 
| 
| Default settings can be changed by their respective controlling /command
|
| Type /mkhelp for help or /status to see current settings!
| 
|--------------------------------------------------------------------------------- 

#Chat tell'
#Event ImDead          "You have been slain by#*#" 
#Event StrikeVic       "#*#Seeking a Victim#*#"
#Event AttackOn        "#*#Auto attack is on#*#" 
#Event AttackOff       "#*#Auto attack is off#*#" 
#Event Enraged         "#*#|${Target.CleanName}| has become ENRAGED#*#" 
#Event NLEnraged       "#*#|${Target.CleanName}| is no longer enraged#*#" 
#Event TooFarAway      "#*#Your target is too far away, get closer#*#"
#Event Exp             "#*#You gain#*#experience#*#" 
#Event Slain           "#*# slain#*#"
#Event Zoned           "#*#You have entered#*#"
#Event GotHit          "#1#YOU for#*#points of damage."
#Event GotMissed       "#1#to#*#YOU, but #*#" 
#Event SpellBounced    "#*#Your spell did not take hold#*#"
#Event SwitchWeapon    "#*#|${switchtext}|#*#"
#Event TogStick        "[MQ2] Autostick#*#" 
#Event TogS            "[MQ2] Auto Sneak#*#" 
#Event TogLeash        "[MQ2] Leash#*#" 
#Event TogAuto         "[MQ2] Autoassist#*#" 
#Event TogDynaggro     "[MQ2] Dynaggro#*#" 
#Event TogPause        "[MQ2] Pause#*#"
#Event TogTSwitch      "[MQ2] AutoTargetSwitch#*#"
#Event TogDynclose     "[MQ2] Dynclose#*#" 
#Event LinkParse       "[MQ2] LinkParse#*#" 
#Event SetStopFighting "[MQ2] SetStopFighting#*#"
#Event SetEndFloor     "[MQ2] SetEndFloor#*#"
#Event SetCloseness    "[MQ2] SetCloseness#*#"
#Event SetFirstassist  "[MQ2] SetMainassist#*#"
#Event SetSecondassist "[MQ2] SetSecondassist#*#"
#Event SetThirdassist  "[MQ2] SetThirdassist#*#"
#Event SetAutoNinja    "[MQ2] SetAutoNinja#*#"
#Event SetWeaponSwitch "[MQ2] SetWeaponSwitch#*#"
#Event SetStickDist    "[MQ2] SetStickDist#*#"
#Event SetChicken      "[MQ2] SetChicken#*#"
#Event SetDisc1        "[MQ2] SetDisc1#*#"
#Event SetAbility      "[MQ2] SetAbility#*#"
#Event SetDisc2        "[MQ2] SetDisc2#*#"
#Event SetLeashFlex    "[MQ2] SetLeashFlex#*#"
#Event SetVerbosity    "[MQ2] SetVerbosity#*#"
#Event SetChannel      "[MQ2] SetChannel#*#"
#Event DragBodies      "[MQ2] DragBodies#*#"
#Event LootMyCorpse    "[MQ2] LootMyCorpse#*#"
#Event AutoFollow      "[MQ2] AutoFollow#*#"
#Event AddMaster       "[MQ2] AddMaster#*#"
#Event RemMaster       "[MQ2] RemoveMaster#*#"
#Event ItemSet         "[MQ2] ItemSet#*#"
#Event ItemBounce      "[MQ2] ItemBounce#*#"
#Event ItemCast        "[MQ2] ItemCast#*#"
#Event HelpInfo        "[MQ2] MK Help#*#"
#Event StatInfo        "[MQ2] MK Status#*#"

Sub Main
  /echo Loading Monk Helper... Please Wait!

  /declare StopFightingHealth int outer 30 
  /declare MinEndurance int outer 80 
  /declare isEnraged bool outer FALSE 
  /declare LDExp float outer ${Me.PctGroupLeaderExp} 
  /declare AAExp float outer ${Me.PctAAExp} 
  /declare Exp float outer ${Me.PctExp} 
  /declare doStick bool outer TRUE 
  /declare X float outer 
  /declare Y float outer 
  /declare behindTarget bool outer FALSE 
  /declare i int outer 
  /declare dir int outer 
  /declare delta int outer 
  /declare strafedir string outer 
  /declare closeness int outer 70
  /declare doSneak bool outer TRUE
  /declare doLeash bool outer FALSE 
  /declare leashlength int outer 0
  /declare stakeX int outer ${Me.X}
  /declare stakeY int outer ${Me.Y}
  /declare leashholder string outer Nobody
  /declare doAutoassist bool outer FALSE 
  /declare mainassist string outer Nobody
  /declare firstassist string outer Nobody
  /declare secondassist string outer Nobody
  /declare thirdassist string outer Nobody
  /declare assistpct int outer 98 
  /declare oldtargetID int outer ${Target.ID}
  /declare assisttimer timer outer 0
  /declare doDynaggro bool outer FALSE
  /declare gotHit bool outer FALSE
  /declare aggrotimer timer outer 0
  /declare ialias string outer None
  /declare doIclick bool outer FALSE
  /declare bouncenum int outer 1
  /declare ibounce string outer None
  /declare itemspellname string outer None
  /declare clicktimer timer outer 0
  /declare isPaused bool outer FALSE
  /declare ninjamode string outer OFF
  /declare ninjadist int outer 50
  /declare doSwitch bool outer FALSE 
  /declare switchtext string outer +Undefined+
  /declare weapon1 string outer None
  /declare weapon2 string outer None
  /declare wstype string outer Detrimental
  /declare doTSwitch bool outer TRUE
  /declare lastevent string outer None
  /declare rngtarget int outer 200
  /declare rngtank int outer 100
  /declare useMU bool outer FALSE
  /declare oldheading string outer Default
  /declare doChicken bool outer FALSE
  /declare nimblehealth int outer 20
  /declare doEscape bool outer FALSE
  /declare nimbletimer timer outer 0
  /declare nimbleactive timer outer 0
  /declare chickentimer timer outer 0
  /declare doDisc1 bool outer FALSE
  /declare disc1 string outer Disc1
  /declare disc1end int outer 60
  /declare disc1reuse int outer 5
  /declare disc1reusetimer timer outer 0
  /declare doDisc2 bool outer FALSE
  /declare disc2 string outer Disc1
  /declare disc2end int outer 60
  /declare disc2reuse int outer 5
  /declare disc2reusetimer timer outer 0
  /declare discactive timer outer 0
  /declare ability string outer Ability
  /declare leashflex int outer 10
  /declare doDynclose bool outer TRUE
  /declare closenessdesired int outer 70
  /declare acquiretimer timer outer 0
  /declare snuggleup bool outer FALSE
  /declare isTanking bool outer FALSE
  /declare verbosity int outer 2
  /declare channel string outer echo
  /declare mkversion string outer 1.0
  /goto :BypassVCheck
  |- Check versions and load aliases if necessary
  /if (${Ini[${Me.Name}_Settings.ini,General,Version].Equal[${mkversion}]}) /goto :EndAlias
  :BypassVCheck

  /if (${verbosity}>=0) /${channel} Setting Aliases...
  /squelch /alias /status /echo MK Status
  /squelch /alias /mkhelp /echo MK Help
  /squelch /alias /stopfight /echo SetStopFighting
  /squelch /alias /endfloor /echo SetEndFloor
  /squelch /alias /autostick /echo Autostick 
  /squelch /alias /autos /echo Auto Sneak
  /squelch /alias /leash /echo Leash 
  /squelch /alias /autoassist /echo Autoassist 
  /squelch /alias /dynaggro /echo Dynaggro
  /squelch /alias /closeness /echo SetCloseness
  /squelch /alias /mainassist /echo SetMainassist
  /squelch /alias /secondassist /echo SetSecondassist
  /squelch /alias /thirdassist /echo SetThirdassist
  /squelch /alias /drag /echo DragBodies
  /squelch /alias /lootmycorpse /echo LootMyCorpse
  /squelch /alias /autofollow /echo AutoFollow
  /squelch /alias /iset /echo ItemSet
  /squelch /alias /ibounce /echo ItemBounce
  /squelch /alias /iclick /echo ItemCast
  /squelch /alias /pause /echo Pause
  /squelch /alias /autoninja /echo SetAutoNinja
  /squelch /alias /addmaster /echo AddMaster
  /squelch /alias /remmaster /echo RemoveMaster
  /squelch /alias /weaponswitch /echo SetWeaponSwitch
  /squelch /alias /targetswitch /echo AutoTargetSwitch
  /squelch /alias /stickdist /echo SetStickDist
  /squelch /alias /autochicken /echo SetChicken
  /squelch /alias /autodisc1 /echo SetDisc1
  /squelch /alias /autodisc2 /echo SetDisc2
  /squelch /alias /autoability /echo SetAbility
  /squelch /alias /leashflex /echo SetLeashFlex
  /squelch /alias /verbosity /echo SetVerbosity
  /squelch /alias /channel /echo SetChannel
  /squelch /alias /dynclose /echo Dynclose
  /squelch /alias /lp /echo LinkParse

  :EndAlias

  |-- Update the Version information
  /ini "${Me.Name}_Settings.ini" "General" "Version" "${mkversion}"

  |-- Read in INI settings, if defined...  Leashing is only stored TRUE if there is a Leash-holding Master!
  /if (${Ini[${Me.Name}_Settings.ini,General,StopFightingHealth].NotEqual[NULL]}) /varset StopFightingHealth ${Ini[${Me.Name}_Settings.ini,General,StopFightingHealth]}
  /if (${Ini[${Me.Name}_Settings.ini,General,MinEndurance].NotEqual[NULL]}) /varset MinEndurance ${Ini[${Me.Name}_Settings.ini,General,MinEndurance]}    
  /if (${Ini[${Me.Name}_Settings.ini,General,AutoStick].NotEqual[NULL]}) /varset doStick ${Ini[${Me.Name}_Settings.ini,General,AutoStick]} 
  /if (${Ini[${Me.Name}_Settings.ini,General,Closeness].NotEqual[NULL]}) /varset closeness ${Ini[${Me.Name}_Settings.ini,General,Closeness]} 
  /if (${Ini[${Me.Name}_Settings.ini,General,AutoSneak].NotEqual[NULL]}) /varset doSneak ${Ini[${Me.Name}_Settings.ini,General,AutoSneak]}
  /if (${Ini[${Me.Name}_Settings.ini,General,Leashing].NotEqual[NULL]}) /varset doLeash ${Ini[${Me.Name}_Settings.ini,General,Leashing]} 
  /if (${Ini[${Me.Name}_Settings.ini,General,LeashHolder].NotEqual[NULL]}) /varset leashholder ${Ini[${Me.Name}_Settings.ini,General,LeashHolder]} 
  /if (${Ini[${Me.Name}_Settings.ini,General,LeashLength].NotEqual[NULL]}) /varset leashlength ${Ini[${Me.Name}_Settings.ini,General,LeashLength]} 
  /if (${Ini[${Me.Name}_Settings.ini,General,LeashFlex].NotEqual[NULL]}) /varset leashflex ${Ini[${Me.Name}_Settings.ini,General,LeashFlex]}
  /if (${Ini[${Me.Name}_Settings.ini,General,AutoAssist].NotEqual[NULL]}) /varset doAutoassist ${Ini[${Me.Name}_Settings.ini,General,AutoAssist]} 
  /if (${Ini[${Me.Name}_Settings.ini,General,AssistPercentage].NotEqual[NULL]}) /varset assistpct ${Ini[${Me.Name}_Settings.ini,General,AssistPercentage]} 
  /if (${Ini[${Me.Name}_Settings.ini,General,MainAssist].NotEqual[NULL]}) /varset mainassist ${Ini[${Me.Name}_Settings.ini,General,MainAssist]} 
  /if (${Ini[${Me.Name}_Settings.ini,General,MainAssist].NotEqual[NULL]}) /varset firstassist ${Ini[${Me.Name}_Settings.ini,General,MainAssist]}
  /if (${Ini[${Me.Name}_Settings.ini,General,SecondAssist].NotEqual[NULL]}) /varset secondassist ${Ini[${Me.Name}_Settings.ini,General,SecondAssist]} 
  /if (${Ini[${Me.Name}_Settings.ini,General,ThirdAssist].NotEqual[NULL]}) /varset thirdassist ${Ini[${Me.Name}_Settings.ini,General,ThirdAssist]} 
  /if (${Ini[${Me.Name}_Settings.ini,General,DynamicAggro].NotEqual[NULL]}) /varset doDynaggro ${Ini[${Me.Name}_Settings.ini,General,DynamicAggro]} 
  /if (${Ini[${Me.Name}_Settings.ini,General,AutoNinjaMode].NotEqual[NULL]}) /varset ninjamode ${Ini[${Me.Name}_Settings.ini,General,AutoNinjaMode]} 
  /if (${Ini[${Me.Name}_Settings.ini,General,AutoNinjaDistance].NotEqual[NULL]}) /varset ninjadist ${Ini[${Me.Name}_Settings.ini,General,AutoNinjaDistance]} 
  /if (${Ini[${Me.Name}_Settings.ini,General,WeaponSwitching].NotEqual[NULL]}) /varset doSwitch ${Ini[${Me.Name}_Settings.ini,General,WeaponSwitching]}
  /if (${Ini[${Me.Name}_Settings.ini,General,TargetSwitching].NotEqual[NULL]}) /varset doTSwitch ${Ini[${Me.Name}_Settings.ini,General,TargetSwitching]}
  /if (${Ini[${Me.Name}_Settings.ini,General,StickRangeToTarget].NotEqual[NULL]}) /varset rngtarget ${Ini[${Me.Name}_Settings.ini,General,StickRangeToTarget]}
  /if (${Ini[${Me.Name}_Settings.ini,General,StickRangeToTank].NotEqual[NULL]}) /varset rngtank ${Ini[${Me.Name}_Settings.ini,General,StickRangeToTank]}
  /if (${Ini[${Me.Name}_Settings.ini,General,AutoChicken].NotEqual[NULL]}) /varset doChicken ${Ini[${Me.Name}_Settings.ini,General,AutoChicken]}
  /if (${Ini[${Me.Name}_Settings.ini,General,NimbleHealth].NotEqual[NULL]}) /varset nimblehealth ${Ini[${Me.Name}_Settings.ini,General,NimbleHealth]}
  /if (${Ini[${Me.Name}_Settings.ini,General,ContingencyEscape].NotEqual[NULL]}) /varset doEscape ${Ini[${Me.Name}_Settings.ini,General,ContingencyEscape]}
  /if (${Ini[${Me.Name}_Settings.ini,General,AutoAbility].NotEqual[NULL]}) /varset ability ${Ini[${Me.Name}_Settings.ini,General,AutoAbility]}
  /if (${Ini[${Me.Name}_Settings.ini,General,AutoDisc1].NotEqual[NULL]}) /varset doDisc1 ${Ini[${Me.Name}_Settings.ini,General,AutoDisc1]}
  /if (${Ini[${Me.Name}_Settings.ini,General,Disc1].NotEqual[NULL]}) /varset disc1 ${Ini[${Me.Name}_Settings.ini,General,Disc1]}
  /if (${Ini[${Me.Name}_Settings.ini,General,Disc1Endurance].NotEqual[NULL]}) /varset disc1end ${Ini[${Me.Name}_Settings.ini,General,Disc1Endurance]}
  /if (${Ini[${Me.Name}_Settings.ini,General,Disc1Reuse].NotEqual[NULL]}) /varset disc1reuse ${Ini[${Me.Name}_Settings.ini,General,Disc1Reuse]}
  /if (${Ini[${Me.Name}_Settings.ini,General,AutoDisc2].NotEqual[NULL]}) /varset doDisc2 ${Ini[${Me.Name}_Settings.ini,General,AutoDisc2]}
  /if (${Ini[${Me.Name}_Settings.ini,General,Disc2].NotEqual[NULL]}) /varset disc2 ${Ini[${Me.Name}_Settings.ini,General,Disc2]}
  /if (${Ini[${Me.Name}_Settings.ini,General,Disc2Endurance].NotEqual[NULL]}) /varset disc2end ${Ini[${Me.Name}_Settings.ini,General,Disc2Endurance]}
  /if (${Ini[${Me.Name}_Settings.ini,General,Disc2Reuse].NotEqual[NULL]}) /varset disc2reuse ${Ini[${Me.Name}_Settings.ini,General,Disc2Reuse]}
  /if (${Ini[${Me.Name}_Settings.ini,General,DynamicCloseness].NotEqual[NULL]}) /varset dynclose ${Ini[${Me.Name}_Settings.ini,General,DynamicCloseness]}
  /if (${Ini[${Me.Name}_Settings.ini,General,Verbosity].NotEqual[NULL]}) /varset verbosity ${Ini[${Me.Name}_Settings.ini,General,Verbosity]}
  /if (${Ini[${Me.Name}_Settings.ini,General,Channel].NotEqual[NULL]}) /varset channel ${Ini[${Me.Name}_Settings.ini,General,Channel]}
  /if (${Ini[${Me.Name}_Settings.ini,Weapons,Weapon1].NotEqual[NULL]}) /varset weapon1 ${Ini[${Me.Name}_Settings.ini,Weapons,Weapon1]}
  /if (${Ini[${Me.Name}_Settings.ini,Weapons,Weapon2].NotEqual[NULL]}) /varset weapon2 ${Ini[${Me.Name}_Settings.ini,Weapons,Weapon2]}
  /if (${Ini[${Me.Name}_Settings.ini,Weapons,SwitchText].NotEqual[NULL]}) /varset switchtext ${Ini[${Me.Name}_Settings.ini,Weapons,SwitchText]}
  /varset closenessdesired ${closeness}
  /varset wstype ${FindItem[${weapon1}].Spell.SpellType}

  |- Build Empty master list in ${Me.Name}_Settings.ini file if it doesn't exist
  /if (!${Ini[${Me.Name}_Settings.ini,Masters,Controller1].Length}) {
    |- It's not in there yet
    /for i 1 to 20
      /ini "${Me.Name}_Settings.ini" "Masters" "Controller${i}" "Nobody"
    /next i
  }

  /echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 
  /echo Monk Helper Macro (v${mkversion}) Starting... 
  /echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 
  /echo Use "/mkhelp" to display help information
  /echo MK Status

  :ForeverLoop 

   |- Service any events 

   /doevents 
    
   |- If we're stunned or MK is paused, just service events 

   /if (${Me.State.Equal[STUN]} || ${isPaused}) {
     /delay 2
     /goto :ForeverLoop 
   }

   |- While fighting or not fighting...

   |- Turn attacking back on if enraged target, and no longer facing it
   /if (${isEnraged} && ${Target.ID} && ${doAutoassist} && !${Me.Combat} && !${Me.State.Equal[FEIGN]}) {
     /call Check_Behind
     /varset behindTarget ${Macro.Return} 
     /if (${Target.ID} && ${behindTarget}) {
       /attack on
       /if (${verbosity}>=1) /${channel} ** Attack re-started (No Enrage Risk): ${Target.CleanName}
     }  
   }

   |- Check if we should chicken out
   /if (${doChicken} && (${Me.PctHPs}<=${nimblehealth}) && !${chickentimer}) {
     /if (${verbosity}>=1) /${channel} Autochicken to the rescue!
     /if (!${nimbletimer}) {
       /if (${Me.AltAbilityReady[Mend]}) /doability "Mend"
       /disc voiddance
       /if (${verbosity}>=1) /${channel} Void Dance mode activated!
       /varset nimbletimer 40m
       /varset nimbleactive 12s
     } else /if (${Me.AltAbilityReady[Imitate Death]} && !${nimbleactive}) {
       /if (${verbosity}>=1) /${channel} Contingency Imitate Death activated! (Void Dance expired/unavailable)
       /attack off
       /delay 2s
       /alt activate 420 
       /varset chickentimer 30s
     } else {
       /if (${verbosity}>=1) /${channel} ... or not! Can't Imitate Death, can't Void Dance... Farewell!
       /attack off
       /delay 1s
       /if (${Me.AltAbilityReady[Feign Death]}) /doability "Feign Death"
       /varset chickentimer 2m
     }
   }

   |- Stop fighting if we lose our target or FD
   /if ((${Me.Combat} && !${Target.ID}) || ${Me.State.Equal[FEIGN]}) /attack off 

   |- Are we suposed to stick to a target?
   /if (${Me.Combat} && ${Target.ID} && ${doStick} && (${Target.Distance}<${rngtarget}) && ${Target.Type.Equal[NPC]}) { 
     
     |- Check to see if we're too far from our tank (if applicable)
     /if (${doAutoassist} && (${Spawn[${mainassist}].Distance}>${rngtank})) {
       /if (${useMU} && ${Stick.Status.Equal[ON]}) /squelch /stick off
       /goto :DoneSticking
     }
  
     |- Check to see if we're mounted and dismount if so
     /if (${Me.Buff[Summon Drogmor].ID} || ${Me.Buff[Summon Horse].ID}) /dismount

     |- Use MQ2MoveUtils ? If so, start sticking and bypass MK movement tools
     /if (${useMU}) {
       /varset isTanking FALSE
       /if (${aggrotimer.Value} || ${Me.TargetOfTarget.Name.Equal[${Me}]}) /varset isTanking TRUE
       /if (!${Stick.Status.Equal[ON]} || ${snuggleup}) {
         /if (${isTanking}) {
           /squelch /stick ${closeness}% mpause ${If[${Me.Underwater},uw,]}
         } else {
           /squelch /stick ${closeness}% behind mpause ${If[${me.underwater},uw,]}
         }
         /varset snuggleup FALSE
       } else {
         /if (${Stick.MoveBehind}) {
           /if (${isTanking}) {
             /squelch /stick off
             /if (${verbosity}>=2) /${channel} Switched to frontal sticking...
           }
         } else {
           /if (!${isTanking}) {
             /squelch /stick off
             /if (${verbosity}>=2) /${channel} Maneuvering behind target again...
           }
         }
       }
       /goto :DoneSticking
     }

     /if (${Target.ID}) /face ${If[${me.underwater},,nolook]} 

     |- If we're too far away to hit it, get 1 second closer, unless we can hit it in less time 
     /if (${Target.Distance}>${Math.Calc[${Target.MaxRangeTo}*${closeness}/100]}) { 

       |- Set current position first before potentially moving (in case we get stuck) 
       /varset X ${Me.X} 
       /varset Y ${Me.Y}  

       /if (!${Target.ID}) /goto :Foreverloop 

       |- Move
       /keypress forward hold 
       /delay 1s ${Target.Distance}<${Math.Calc[${Target.MaxRangeTo}*${closeness}/100]} 
       /keypress forward 

       |- Check to see if we got stuck trying that 
       /if ((${Me.X}==${X}) && (${Me.Y}==${Y})) { 
         |- We're stuck, back off a second, move left or right (randomly) for .5 seconds 
         /if (${verbosity}>=2) /${channel} We're STUCK on something, backing up... 
         /keypress back hold 
         /delay 1s 
         /keypress back 
         /if (${Math.Rand[2]}) { 
           /varset strafedir STRAFE_LEFT 
         } else { 
           /varset strafedir STRAFE_RIGHT 
         } 
         /if (${verbosity}>=2) /${channel} Unsticking: Strafing ${strafedir} a half-second... 
         /keypress ${strafedir} hold 
         /delay 5 
         /keypress ${strafedir} 
       } 
     } 

     /if (!${Target.ID}) /goto :Foreverloop 

     |- If we are close enough to hit it (and don't have aggro), lets try to get behind it a little bit at a time 

     /if ((${Target.Distance}<=${Target.MaxRangeTo}) && !${aggrotimer.Value} && !${Me.TargetOfTarget.Name.Equal[${Me}]}) { 
        
       /call Check_Behind
       /varset behindTarget ${Macro.Return}    

       |- If we're not behind it, strafe around it a little 
       /if (!${behindTarget}) { 
         |- Which way do we strafe? 
         /varcalc delta ${Me.Heading.Clock}-${Target.Heading.Clock} 
         /if (${delta}>6) /varcalc delta ${delta}-12 
         /if (${delta}<-6) /varcalc delta ${delta}+12 
         /if (${delta}<0) { 
           /varset strafedir STRAFE_LEFT 
         } else { 
           /varset strafedir STRAFE_RIGHT 
         } 
         |- Set current position first before moving (in case we get stuck) 
         /varset X ${Me.X} 
         /varset Y ${Me.Y}    
 
         /if (!${Target.ID}) /goto :Foreverloop  

         |- Execute a strafe in the correct direction 
         /keypress ${strafedir} hold 
         /delay 2
         /keypress ${strafedir} 
         /if (${Target.ID}) /face ${If[${me.underwater},,nolook]} 
         |- Check if we're stuck and warn if so (go through target to fix it)
         /if ((${Me.X}==${X}) && (${Me.Y}==${Y})) { 
           /if (${verbosity}>=2) /${channel} We're STUCK trying to get behind target!
           /delay 1s
         } 
       } 
     } 
   } else {
     /if (${useMU} && ${Stick.Status.Equal[ON]}) /squelch /stick off
   }
   :DoneSticking

   |- Check on switching weapons (assuming it's a buff-weapon and buff is down)

   /if (${doSwitch} && ${wstype.Equal[Beneficial]}) {
     /varset itemspellname ${FindItem[${weapon1}].Spell}
     /if (${itemspellname.NotEqual[${Me.Buff[${itemspellname}]}]} && !${FindItem[${weapon1}].InvSlot.Name.Equal[mainhand]} && !${FindItem[${weapon1}].InvSlot.Name.Equal[offhand]}) {
       /if (${verbosity}>=1) /${channel} ** Beneficial proc-weapon swapping...
       /call Weapon_Swap "${weapon1}" "${weapon2}"
     }
   }

    |- Are we fighting? 

    /if (${Me.Combat} && !${Me.State.Equal[FEIGN]}) { 
     |- ** We are fighting ** 

     |- Respond to enraged targets
     /if (${isEnraged} && ${Target.ID}) {
       /call Check_Behind
       /varset behindTarget ${Macro.Return} 
       /if (${Target.ID} && !${behindTarget}) {
         /attack off
         /if (${verbosity}>=1) /${channel} ** Attack ceased (Enrage Risk): ${Target.CleanName}
       }  
     }

     |- If we're sneaking, stop... since it serves no purpose and affects strafing
     /if (${Me.Sneaking}) /doability "Sneak"  

     |- Check up on our autoassist targets if applicable, and switch if MA switches (1 second checks)
     /if (${doTSwitch} && ${doAutoassist} && ${Target.ID} && !${assisttimer}) {
       /varset oldtargetID ${Target.ID}
       /assist ${mainassist}
       /varset assisttimer 1s
     }

     |- Did we just switch targets?  If so, turn off attack and start the loop over!
     /if (${doAutoassist} && ${Target.ID}!=${oldtargetID}) {
       /if (${verbosity}>=1) /${channel} --> *SWITCH* target to: ${Target.CleanName}
       /varset oldtargetID ${Target.ID}
       /attack off
       /delay 2
       /varset assisttimer 1s
       /goto :ForeverLoop
     }

     |- Check for leash tugging and move back to stake some if so 
     /if (${doLeash}) { 
       /if (${leashholder.Equal[Nobody]} && (${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]}>${leashlength})) {
         /if (${verbosity}>=2) /${channel} CHOKE! We're at the leash's length! (${leashlength} ft.) 
         /if (${verbosity}>=1) /${channel} ** Autoassist is now OFF!
         /varset doAutoassist FALSE 
         /attack off
         /if (${useMU}) /squelch /stick off
         /face ${If[${me.underwater},,nolook]} loc ${stakeY},${stakeX} 
         /keypress forward hold 
         /delay 1s ${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]}<${Math.Calc[${leashlength}*${leashflex}/100]}
         /keypress forward         
         |- Slow 180degree turns take time, and we may have turned off attack, so...
         /goto :ForeverLoop
       }
       /if (!${leashholder.Equal[Nobody]} && ${Spawn[${leashholder}].ID} && (${Spawn[${leashholder}].Distance}>${leashlength})) {
         /if (${verbosity}>=2) /${channel} CHOKE! Tugging on ${leashholder}'s leash! (${leashlength} ft.) 
         /if (${verbosity}>=1) /${channel} ** Autoassist is now OFF!
         /varset doAutoassist FALSE 
         /attack off
         /if (${useMU}) /squelch /stick off
         /squelch /face ${If[${me.underwater},,nolook]} id ${Spawn[${leashholder}].ID}
         /keypress forward hold 
         /delay 1s ${Spawn[${leashholder}].Distance}<${Math.Calc[${leashlength}*${leashflex}/100]}
         /keypress forward         
         |- Slow 180degree turns take time, and we may have turned off attack, so...
         /goto :ForeverLoop
       }
       |- Broken leash check
       /if (!${leashholder.Equal[Nobody]} && !${Spawn[${leashholder}].ID}) {
         /if (${verbosity}>=1) /${channel} ** Master DEAD or ZONED! Leash is BROKEN! 
         /varset doLeash FALSE
         /varset leashholder Nobody
         /ini "${Me.Name}_Settings.ini" "General" "Leashing" "${doLeash}" 
         /ini "${Me.Name}_Settings.ini" "General" "LeashHolder" "${leashholder}" 
         /goto :ForeverLoop
       }
     } 

     |- Are we standing, have a target 

     /call Check_Behind
     /varset behindTarget ${Macro.Return} 

     |- Are we so hurt we should stop fighting for a bit? 

     /if (${Me.PctHPs}<=${StopFightingHealth}) { 
       /attack off 
       /if (${verbosity}>=1) /${channel} Getting my ass kicked, ceasing combat! 
     } 

     |- Shall we do our optional discs?

     /if (${doDisc1} && !${disc1reusetimer} && !${discactive} && ${Target.ID} && ${Target.PctHPs}>=50 && ${Me.PctEndurance}>=${disc1end}) {
       /disc ${disc1}
       /if (${verbosity}>=1) /${channel} Disc #1: ${disc1} activated
       /delay 1s
       /varset discactive 1m
       /varset disc1reusetimer ${disc1reuse}m
     }

     /if (${doDisc2} && !${disc2reusetimer} && !${discactive} && ${Target.ID} && ${Target.PctHPs}>=50 && ${Me.PctEndurance}>=${disc2end}) {
       /disc ${disc2}
       /if (${verbosity}>=1) /${channel} Disc #2: ${disc2} activated
       /delay 1s
       /varset discactive 1m
       /varset disc2reusetimer ${disc2reuse}m
     }
     /if ( ${Me.AbilityReady["${ability}"]} ) { 
        /doability "${ability}"  
     }
    } else { 
     |- ** We are not fighting

     |- If we're not moving, check clicky maintained spells
     /if (${Me.Invis} || ${Me.Moving} || ${clicktimer} || ${Me.State.Equal[BIND]}) /goto :DoneItemChecks
     /varset i 1
     :ItemCheckLoop
     /varset ialias ${Ini[${Me.Name}Items.ini].Arg[${i},|]}
     /if (${ialias.NotEqual[NULL]}) {
       |- Obtained an itemalias from the ${Me.Name}Items.ini file
       |- We supposed to keep this spell up?
       /if (${Ini[${Me.Name}Items.ini,${ialias},KeepUp].Equal[FALSE]}) /goto :NextItem
       |- Scan the item's bounce list for the active bouncers
       /varset bouncenum 1
       /varset doIclick TRUE
       :BounceCheckLoop
       /varset ibounce ${Ini[${Me.Name}Items.ini,${ialias},BounceOff${bouncenum}]}
       /if (${ibounce.NotEqual[NULL]}) {
         /if (${ibounce.Equal[${Me.Buff[${ibounce}]}]}) /varset doIclick FALSE
       } else /goto :DoneBounceChecks
       /varcalc bouncenum ${bouncenum}+1
       /goto :BounceCheckLoop
       :DoneBounceChecks
       |- By now we won't click the item if a bouncer spell is on us
       |- Just have to check to see if the existing buff is on too
       /varset itemspellname ${FindItem[${Ini[${Me.Name}Items.ini,${ialias},FullName]}].Spell}
       /if (${itemspellname.Equal[${Me.Buff[${itemspellname}]}]}) /varset doIclick FALSE
       |- Finally, do it if we should
       /if (${doIclick}) /docommand /iclick ${ialias}
       |- Did we fail to find that previous item? (i.e. Dead and naked at bind point!)
       /if (${clicktimer}) /goto :DoneItemChecks
       :NextItem
       /varcalc i ${i}+1
     } else /goto :DoneItemChecks
     /goto :ItemCheckLoop
     :DoneItemChecks

     |- Put the closeness value back to the user's desired setting...
     /varset closeness ${closenessdesired}

     |- Lets sneak if not already and we're set to do so ** 

     /if (${doSneak} && ${Me.AbilityReady["Sneak"]} && !${Me.Casting.ID} && ${Me.State.NotEqual[BIND]} && !${Window[TradeWnd].Open} && !${Window[MerchantWnd].Open} && !${Window[BigBankWnd].Open}) /doability "Sneak" 

     /call Check_Behind
     /varset behindTarget ${Macro.Return} 
     
     |- If we're set to autoassist, lets find a target 
     /if (${doAutoassist} && !${isEnraged} && !${Me.Casting.ID} && ${Me.State.NotEqual[BIND]}) { 
       |- Is main assist alive/in-zone? 
       /if (!${assisttimer}) { 
         |- Lets try all the assists in priority order until we get an NPC to whack on
         /if (!${Me.Casting.ID}) /assist ${firstassist}
         /delay 1
         /if (${Target.ID} && ${Target.Type.Equal[NPC]}) /goto :EngageCheck
         /if (!${Me.Casting.ID}) /assist ${secondassist} 
         /delay 1
         /if (${Target.ID} && ${Target.Type.Equal[NPC]}) /goto :EngageCheck
         /if (!${Me.Casting.ID}) /assist ${thirdassist} 
         /delay 1
         /if (${Target.ID} && ${Target.Type.Equal[NPC]}) /goto :EngageCheck
         |- If we got here and don't have a target, tanks are invalid or no fighting is going on
         /goto :EndAutoassist
         :EngageCheck
         /varset oldtargetID ${Target.ID}
         /varset assisttimer ${Math.Calc[10+${Math.Rand[5]}].Int}
         |- Who is the valid tank?
         /if (${firstassist.Equal[Main]} || (${Math.Distance[${Target.Y},${Target.X}:${Spawn[pc ${firstassist}].Y},${Spawn[pc ${firstassist}].X}]}<${Target.MaxRangeTo})) {
           /varset mainassist ${firstassist}
           /goto :LastAttackCheck
         }
         /if (${secondassist.Equal[Main]} || (${Math.Distance[${Target.Y},${Target.X}:${Spawn[pc ${secondassist}].Y},${Spawn[pc ${secondassist}].X}]}<${Target.MaxRangeTo})) {
           /varset mainassist ${secondassist}
           /goto :LastAttackCheck
         }
         /if (${thirdassist.Equal[Main]} || (${Math.Distance[${Target.Y},${Target.X}:${Spawn[pc ${thirdassist}].Y},${Spawn[pc ${thirdassist}].X}]}<${Target.MaxRangeTo})) {
           /varset mainassist ${thirdassist}
           /goto :LastAttackCheck
         }
         /goto :EndAutoassist
         :LastAttackCheck
         |- Do we have an NPC targeted and is it hurt enough to attack? 
         /if (${Target.PctHPs}<=${assistpct} && ${Target.Animation}!=32 && ${Target.Animation}!=110) { 
           /if (${verbosity}>=1) /${channel} --> Assisting ${mainassist} on ${Target.CleanName} @ (${Target.PctHPs}%) HPs 
           /echo Seeking a Victim... 
           /goto :Foreverloop      
         } 
       } 
     } 
     :EndAutoassist

     |- We could be on a leash, if so move 1s closer to our stake point (or master)\\

     /if (${doLeash}) { 
       /varset lastevent Event_Leashing
       :LeashStart
       |- Look for new events
       /doevents
       /if (!${lastevent.Equal[Event_Leashing]}) /goto :ForeverLoop
       /if (${Me.Combat} && !${Me.State.Equal[FEIGN]) /goto :ForeverLoop
       /if (${leashholder.Equal[Nobody]} && (${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]}>${Math.Calc[${leashlength}*${leashflex}/100]})) {
         /if (${verbosity}>=2) /${channel} Moving closer to the Stake... ${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]} ft. away 
        /face ${If[${me.underwater},,nolook]} loc ${stakeY},${stakeX} 
         /keypress forward hold 
         /delay 1s ${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]}<${Math.Calc[${leashlength}*${leashflex}/100]}
         /keypress forward 
         /if (${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]}<${Math.Calc[${leashlength}*${leashflex}/100]}) {
           /if (${verbosity}>=2) /${channel} Arrived near enough to the Stake. 
           /face ${If[${me.underwater},,nolook]} away loc ${stakeY},${stakeX}
           /goto :LeashEnd
         }
         /goto :LeashStart
       }
       /if (!${leashholder.Equal[Nobody]} && ${Spawn[${leashholder}].ID} && (${Spawn[${leashholder}].Distance}>${Math.Calc[${leashlength}*${leashflex}/100]})) {
         /if (${verbosity}>=2) /${channel} Moving closer to ${leashholder}... ${Spawn[${leashholder}].Distance} ft. away 
         /if (${Target.ID}!=${Spawn[${leashholder}].ID}) /target id ${Spawn[${leashholder}].ID}
         /if (${Me.Combat}) /attack off
         /face ${If[${me.underwater},,nolook]}
         /keypress forward hold 
         /delay 1s ${Spawn[${leashholder}].Distance}<${Math.Calc[${leashlength}*${leashflex}/100]}  
         /keypress forward 
         /if (${Spawn[${leashholder}].Distance}<${Math.Calc[${leashlength}*${leashflex}/100]}) {
           /if (${verbosity}>=2) /${channel} Arrived near enough to Master (${leashholder}). 
           /goto :LeashEnd
         }
         /goto :LeashStart
       }
       |- Broken leash check
       /if (!${leashholder.Equal[Nobody]} && !${Spawn[${leashholder}].ID}) {
         /if (${verbosity}>=1) /${channel} ** Master DEAD or ZONED! Leash is BROKEN! 
         /varset doLeash FALSE
         /varset leashholder Nobody
         /ini "${Me.Name}_Settings.ini" "General" "Leashing" "${doLeash}" 
         /ini "${Me.Name}_Settings.ini" "General" "LeashHolder" "${leashholder}" 
         /goto :LeashEnd
       }
       :LeashEnd
     } 
   } 
  /goto :ForeverLoop 
/return 

|---- SUBROUTINES

Sub Check_Behind
  /declare behindIt FALSE 
  |- Are we behind our target? 
  /for i -1 to 1 
    /varcalc dir (${Target.Heading.Clock}+${i})%12 
    /if (${dir}<1) /varcalc dir ${dir}+12 
    /if (${dir}>12) /varcalc dir ${dir}-12 
    /if (${dir} == ${Me.Heading.Clock}) /varset behindIt TRUE 
  /next i    
/return ${behindIt}

Sub Weapon_Swap(string weapon, string wieldedweapon)
  |- Is it in a Bag?
  /declare camefrom ${FindItem[${weapon}].InvSlot}
  /declare goingto ${FindItem[${wieldedweapon}].InvSlot}
  /if (${verbosity}>=2) /${channel} ** Looking for weapon: ${weapon}
  /if (${FindItem[${weapon}].InvSlot.Pack}) {
    :OpenPack
    /if (!${Window[${FindItem[${weapon}].InvSlot.Pack.Name}].Open}) {
      /itemnotify ${FindItem[${weapon}].InvSlot.Pack.Name} rightmouseup
      /delay 2
      /goto :OpenPack
    } 
    :GrabItem
    /if (!${Cursor.ID}) {
      /itemnotify ${InvSlot[${camefrom}]} leftmouseup
      /delay 2
      /goto :GrabItem
    }
    /declare weaponID int local ${Cursor.ID}
    :SwapIt
    /if (${Cursor.ID}==${weaponID}) {
      /itemnotify ${InvSlot[${goingto}]} leftmouseup
      /delay 2
      /goto :SwapIt
    }
    /delay 2
    /if (${verbosity}>=2) /${channel} ** Swapping out: ${weapon}
    /itemnotify ${InvSlot[${camefrom}]} leftmouseup
    /delay 2
    /if (${Cursor.ID}) {
      /if (${verbosity}>=1) /${channel} ** Failed to use existing slot, dropping to inventory!
      /autoinv
    }
    :ClosePack
    /if (${Window[${InvSlot[${camefrom}].Pack.Name}].Open}) {
      /itemnotify ${InvSlot[${camefrom}].Pack.Name} rightmouseup
      /delay 2
      /goto :ClosePack
    }
  } else {
    |- It's in the main inventory
    /if (${FindItem[${weapon}].InvSlot}) {
      /itemnotify ${FindItem[${weapon}].InvSlot} leftmouseup
      /delay 2
      /itemnotify ${InvSlot[${goingto}]} leftmouseup
      /delay 2
      /if (${verbosity}>=2) /${channel} ** Swapping out: ${weapon}
      /itemnotify ${InvSlot[${camefrom}]} leftmouseup
      /delay 2
      /if (${Cursor.ID}) {
        /if (${verbosity}>=1) /${channel} ** Failed to use existing slot, dropping to inventory!
        /autoinv
      }
    } else {
      /if (${verbosity}>=1) /${channel} ** "${weapon}" not found!
    }
  }
/return

Sub NinjaLoot
  |- Ninja the corpse's loot, if applicable
  /if (${ninjamode.NotEqual[OFF]}) {
    /declare LootTotal int local -1
    /declare LootSlot int local
    |- Get NPC corpse on target and continue if possible
    /squelch /target npc corpse radius ${ninjadist} 
    /if (${Target.Type.NotEqual[CORPSE]} || !${Target.ID}) { 
      /if (${verbosity}>=1) /${channel} ** NPC corpse out of range or already looted! 
      /return
    }   
    |- Get 5 seconds (max) closer; warning, no detecting being stuck!
    /face ${If[${me.underwater},,nolook]}
    /keypress forward hold 
    /delay 5s ${Target.Distance}<5 
    /keypress forward 
    |- Open up the loot window
    /loot 
    /delay 1s
    /if (${Me.State.NotEqual[BIND]}) {
      /if (${verbosity}>=1) /${channel} ** Massive lag or error getting to corpse.  Aborting!
      /return
    }
    /if (${verbosity}>=1) /${channel} ** Looting ${Target.CleanName}  
    |- Get item count accurately  
    :LootLag 
    /if (${LootTotal}!=${Corpse.Items}) { 
      /varset LootTotal ${Corpse.Items} 
      /delay 5 
      /goto :LootLag 
    } 
    /if (!${LootTotal}) {
      /if (${verbosity}>=1) /${channel} ** Empty corpse!
      /goto :DoneLooting
    }
    |- Loot Loop
    /for LootSlot 1 to ${LootTotal} 
      |- Check for full inventory
      /if (!${Me.FreeInventory}) {
        /beep
        /if (${verbosity}>=1) /${channel} ** INVENTORY FULL !
        /varset ninjamode OFF
        /if (${verbosity}>=1) /${channel} ** AutoNinja is now OFF!
        /goto :DoneLooting
      }
      |- Loot item if we should, skip it if not
      /if (${Corpse.Item[${LootSlot}].ID}) {
        /if (!${Corpse.Item[${LootSlot}].NoDrop}) /goto :LootItem
        /if (${Corpse.Item[${LootSlot}].NoDrop} && ${ninjamode.Equal[ALL]}) {
          /if (${verbosity}>=1) /${channel} ** Looting NODROP Item: ${Corpse.Item[${LootSlot}].Name}
          /goto :LootItem
        }
      }
      /if (${verbosity}>=1) /${channel} ** Skipping Item: ${Corpse.Item[${LootSlot}].Name}
      /goto :SkipIt
      :LootItem 
      /itemnotify loot${LootSlot} rightmouseup 
      /delay 3
      /if (${Corpse.Item[${LootSlot}].ID}) { 
        /delay 2
        /goto :LootItem
      } 
      :SkipIt
    /next LootSlot
    /if (${verbosity}>=1) /${channel} ** Done looting ${Target.CleanName}
    :DoneLooting
    /delay 5
    /notify LootWnd DoneButton leftmouseup 
    /delay 5
  }
/return

|---- EVENTS

Sub Event_StrikeVic 
  /varset lastevent Event_StrikeVic 
  /attack on 
/return 

Sub Event_AttackOn 
  /varset lastevent Event_AttackOn
  /if (${verbosity}>=1) /${channel} Autoattack activated! Target: ${Target.CleanName}
  /varset acquiretimer 2s
/return 

Sub Event_AttackOff 
  /varset lastevent Event_AttackOff
  /if (${verbosity}>=1) /${channel} Autoattack turned off! Target: ${Target.CleanName} 
/return 

Sub Event_Enraged 
  /varset lastevent Event_Enraged
  /if (${verbosity}>=1) /${channel} Enrage detected! Target: ${Target.CleanName} 
  /varset isEnraged TRUE 
/return 

Sub Event_NLEnraged 
  /varset lastevent Event_NLEnraged
  /if (${verbosity}>=1) /${channel} Enrage done! Target: ${Target.CleanName} 
  /varset isEnraged FALSE 
  /if (${Target.ID} && ${doAutoassist}) /attack on 
/return 

Sub Event_Exp(string Line)
  /varset lastevent Event_Exp
  |- Ignore leadership experience event triggers (redundant trigger)
  /if (${Line.Find[leadership]}) /return

  |- Manage aggro control here optionally
  /if (${doDynaggro} && ${doAutoassist}) {
    /if (${gotHit}) {
      |- Got hurt that fight, drop it 1%
      /if (${assistpct}>1) /varcalc assistpct ${assistpct}-1
      /varset gotHit FALSE
      /if (${verbosity}>=1) /${channel} ** Had Aggro! Reducing assist% to ${assistpct}%
    } else {
      |- Did not get hurt that fight, raise it 1%
      /if (${assistpct}<99) /varcalc assistpct ${assistpct}+1
      /if (${verbosity}>=1) /${channel} ** No Aggro! Raising assist% to ${assistpct}%
    }
  }

  |- Experience calculation and reporting
  /if (${verbosity}>=1) /${channel} ** XP-Delta: REG (${Math.Calc[${Me.PctExp}-${Exp}]}%), AA (${Math.Calc[${Me.PctAAExp}-${AAExp}]}%), LDR (${Math.Calc[${Me.PctGroupLeaderExp}-${LDExp}]}%) 
  /varset LDExp ${Me.PctGroupLeaderExp} 
  /varset AAExp ${Me.PctAAExp} 
  /varset Exp ${Me.PctExp} 

  |- If target died while enraged, reset it so autoassist isn't broken...
  /varset isEnraged FALSE 

  |- Do weapon swapping (back to weapon1), if applicable
  /if (${doSwitch} && ${wstype.Equal[Detrimental]}) {
    /call Weapon_Swap "${weapon1}" "${weapon2}"
  } 
/return 

Sub Event_Slain
  /varset lastevent Event_Slain
  /call NinjaLoot
/return

Sub Event_Zoned
  /varset lastevent Event_Zoned
  /if (${verbosity}>=1) /${channel} ** Zoned... Setting Leash and Autoassist to OFF!
  /varset doLeash FALSE
  /varset doAutoassist FALSE
  /ini "${Me.Name}_Settings.ini" "General" "AutoAssist" "${doAutoassist}"
  /ini "${Me.Name}_Settings.ini" "General" "Leashing" "${doLeash}" 
/return 

Sub Event_TooFarAway
  /varset lastevent Event_TooFarAway
  /if (${doDynclose} && !${acquiretimer}) {
    /if (${verbosity}>=1) /${channel} ** Too far away - Getting 20% closer now!
    /varset closeness ${Math.Calc[${closeness}*0.8].Int}
    /if (${closeness}<20) /varset closeness 20
    /varset acquiretimer 2s
    /varset snuggleup TRUE
  }
/return 

Sub Event_SetStopFighting(string Line)
  /varset lastevent Event_SetStopFighting
  /if (${Line.Arg[3].Length}) /varset StopFightingHealth ${Line.Arg[3]}
  /if ((${StopFightingHealth}<0) || (${StopFightingHealth}>100)) {
    /if (${verbosity}>=0) /${channel} Whacko stopfighting percentage input! Defaulting...
  }
  /if (${verbosity}>=0) /${channel} ** Cease Combat when at: ${StopFightingHealth}% HP 
  /ini "${Me.Name}_Settings.ini" "General" "StopFightingHealth" "${StopFightingHealth}"
/return

Sub Event_SetEndFloor(string Line)
  /varset lastevent Event_SetEndFLoor
  /if (${Line.Arg[3].Length}) /varset MinEndurance ${Line.Arg[3]}
  /if ((${MinEndurance}<0) || (${MinEndurance}>101)) {
    /if (${verbosity}>=0) /${channel} Whacko endurance percentage input! Defaulting...
  }
  /if (${verbosity}>=0) /${channel} ** Endurance Floor: ${MinEndurance}% 
  /ini "${Me.Name}_Settings.ini" "General" "MinEndurance" "${MinEndurance}"
/return

Sub Event_TogStick 
  /varset lastevent Event_TogStick
  /if (${doStick}) { 
    /varset doStick FALSE 
    /if (${verbosity}>=0) /${channel} ** Auto-Sticking target is now OFF! 
  } else { 
    /varset doStick TRUE 
    /if (${verbosity}>=0) /${channel} ** Auto-Sticking target is now ON! 
  } 
  /ini "${Me.Name}_Settings.ini" "General" "AutoStick" "${doStick}"
/return 

Sub Event_TogS 
  /varset lastevent Event_TogS
  /if (${doSneak}) { 
    /varset doSneak FALSE 
    /if (${verbosity}>=0) /${channel} ** Auto-Sneaking is now OFF! 
  } else { 
    /varset doSneak TRUE 
    /if (${verbosity}>=0) /${channel} ** Auto-Sneaking is now ON! 
  } 
  /ini "${Me.Name}_Settings.ini" "General" "AutoSneak" "${doSneak}"
/return 

Sub Event_TogLeash(string Line) 
  /varset lastevent Event_TogLeash
  /if (${Line.Arg[3].Equal[ON]}) { 
    /varset doLeash TRUE
    /if (${verbosity}>=0) /${channel} ** Leashing is now ON!
    /ini "${Me.Name}_Settings.ini" "General" "Leashing" "${doLeash}" 
  } else /if (${Line.Arg[3].Equal[OFF]} || (${Int[${Line.Arg[3]}]}<=0)) { 
    /varset doLeash FALSE 
    /varset leashholder Nobody
    /if (${verbosity}>=0) /${channel} ** Leashing is now OFF!
    /ini "${Me.Name}_Settings.ini" "General" "Leashing" "${doLeash}" 
  } else { 
    /if (${Line.Arg[4].Length}) {
      /varset leashholder ${Line.Arg[4]}
      /if (${Spawn[${leashholder}].ID}) {
        /varset doLeash TRUE
        /varset leashlength ${Int[${Line.Arg[3]}]}
        /if (${verbosity}>=0) /${channel} ** Leashing is now ON! Leashlength: ${leashlength} ft. 
        /if (${verbosity}>=0) /${channel} ** Leash-holding master is: ${leashholder}
        /ini "${Me.Name}_Settings.ini" "General" "Leashing" "${doLeash}" 
      } else {
        |- This spawn/thing/target doesn't exist
        /if (${verbosity}>=0) /${channel} ** Can't find "${leashholder}" -- Who is that?!
        /if (${verbosity}>=0) /${channel} ** Leashing is now OFF! 
        /varset doLeash FALSE 
        /varset leashholder Nobody
      }
    } else {
      /varset doLeash TRUE 
      /varset leashholder Nobody
      /varset leashlength ${Int[${Line.Arg[3]}]} 
      /varset stakeX ${Me.X} 
      /varset stakeY ${Me.Y} 
      /if (${verbosity}>=0) /${channel} ** Leashing is now ON! Leashlength: ${leashlength} ft. 
      /if (${verbosity}>=0) /${channel} ** Stake planted at X:${stakeX}, Y:${stakeY} 
    }
  } 
  /ini "${Me.Name}_Settings.ini" "General" "LeashHolder" "${leashholder}" 
  /ini "${Me.Name}_Settings.ini" "General" "LeashLength" "${leashlength}" 
/return 

Sub Event_SetLeashFlex(string Line)
  /varset lastevent Event_SetLeashFlex
  /if (${Line.Arg[3].Length}) /varset leashflex ${Line.Arg[3]}
  /if ((${leashflex}<10) || (${leashflex}>101)) {
    /if (${verbosity}>=0) /${channel} Leash flexibility must be between 10 and 100! Defaulting to 10...
    /varset leashflex 10
  }
  /if (${verbosity}>=0) /${channel} ** Leash Flexibility: ${leashflex}% 
  /ini "${Me.Name}_Settings.ini" "General" "LeashFlex" "${leashflex}"
/return

Sub Event_TogAuto(string Line) 
  /varset lastevent Event_TogAuto
  /if (${Line.Arg[3].Equal[OFF]}) { 
    /varset doAutoassist FALSE 
    /if (${verbosity}>=0) /${channel} ** Autoassist is now OFF! 
  } else /if (${Line.Arg[3].Equal[ON]}) {
    /varset doAutoassist TRUE 
    /if (${verbosity}>=0) /${channel} ** Autoassist is now ON! 
  } else { 
    /varset doAutoassist TRUE 
    /if (${Line.Arg[3].Length}) /varset firstassist ${Line.Arg[3]} 
    /varset mainassist ${firstassist} 
    /if (${Line.Arg[4]} > 0) /varset assistpct ${Line.Arg[4]} 
    /if (${verbosity}>=0) /${channel} ** Autoassist is now ON! 
    /if (${verbosity}>=0) /${channel} ** Assisting: ${mainassist} @${assistpct}% target health 
    /if (${verbosity}>=0) /${channel} ** SA is ${secondassist} & TA is ${thirdassist}
  } 
  /ini "${Me.Name}_Settings.ini" "General" "AutoAssist" "${doAutoassist}"
  /ini "${Me.Name}_Settings.ini" "General" "MainAssist" "${firstassist}"
  /ini "${Me.Name}_Settings.ini" "General" "AssistPercentage" "${assistpct}"
/return 

Sub Event_TogPause 
  /varset lastevent Event_TogPause
  /beep
  /if (${isPaused}) { 
    /varset isPaused FALSE 
    /if (${verbosity}>=0) /${channel} ** Monk Helper is now RESUMING! 
  } else { 
    /varset isPaused TRUE 
    /if (${verbosity}>=0) /${channel} ** Monk Helper is now PAUSED!
  } 
/return 

Sub Event_TogDynaggro 
  /varset lastevent Event_TogDynaggro
  /if (${doDynaggro}) { 
    /varset doDynaggro FALSE 
    /if (${verbosity}>=0) /${channel} ** Dynamic Aggro Control is now OFF! 
  } else { 
    /varset doDynaggro TRUE 
    /if (${verbosity}>=0) /${channel} ** Dynamic Aggro Control is now ON! 
  } 
  /ini "${Me.Name}_Settings.ini" "General" "DynamicAggro" "${doDynaggro}"
/return 

Sub Event_TogDynclose
  /varset lastevent Event_TogDynclose
  /if (${doDynclose}) { 
    /varset doDynclose FALSE 
    /if (${verbosity}>=0) /${channel} ** Dynamic Closeness Control is now OFF! 
  } else { 
    /varset doDynclose TRUE 
    /if (${verbosity}>=0) /${channel} ** Dynamic Closeness Control is now ON! 
  } 
  /ini "${Me.Name}_Settings.ini" "General" "DynamicCloseness" "${doDynclose}"
/return 

Sub Event_TogTSwitch 
  /varset lastevent Event_TogTSwitch
  /if (${doTSwitch}) { 
    /varset doTSwitch FALSE 
    /if (${verbosity}>=0) /${channel} ** Auto-Target Switching is now OFF! 
  } else { 
    /varset doTSwitch TRUE 
    /if (${verbosity}>=0) /${channel} ** Auto-Target Switching is now ON! 
  } 
  /ini "${Me.Name}_Settings.ini" "General" "TargetSwitching" "${doTSwitch}"
/return 

Sub Event_SetCloseness(string Line)
  /varset lastevent Event_SetCloseness
  /if (${Line.Arg[3].Length}) /varset closeness ${Line.Arg[3]}
  /if ((${closeness}<1) || (${closeness}>100)) {
    /if (${verbosity}>=0) /${channel} Whacko closeness percentage input! Defaulting...
    /varset closeness 70
  }
  /varset closenessdesired ${closeness}
  /if (${verbosity}>=0) /${channel} ** AutoStick: ${doStick}, Closeness: ${closeness}
  /ini "${Me.Name}_Settings.ini" "General" "Closeness" "${closeness}"
/return

Sub Event_SetFirstassist(string Line)
  /varset lastevent Event_SetFirstassist
  /if (${Line.Arg[3].Length}) /varset firstassist ${Line.Arg[3]}
  /varset mainassist ${firstassist}
  /if (${verbosity}>=0) /${channel} ** Assisting: ${mainassist} @${assistpct}% target health 
  /if (${verbosity}>=0) /${channel} ** SA is ${secondassist} & TA is ${thirdassist}
  /ini "${Me.Name}_Settings.ini" "General" "MainAssist" "${firstassist}"
/return

Sub Event_SetSecondassist(string Line)
  /varset lastevent Event_SetSecondassist
  /if (${Line.Arg[3].Length}) /varset secondassist ${Line.Arg[3]}
  /if (${verbosity}>=0) /${channel} ** Assisting: ${mainassist} @${assistpct}% target health 
  /if (${verbosity}>=0) /${channel} ** SA is ${secondassist} & TA is ${thirdassist}
  /ini "${Me.Name}_Settings.ini" "General" "SecondAssist" "${secondassist}"
/return

Sub Event_SetThirdassist(string Line)
  /varset lastevent Event_SetThirdassist
  /if (${Line.Arg[3].Length}) /varset thirdassist ${Line.Arg[3]}
  /if (${verbosity}>=0) /${channel} ** Assisting: ${mainassist} @${assistpct}% target health 
  /if (${verbosity}>=0) /${channel} ** SA is ${secondassist} & TA is ${thirdassist}
  /ini "${Me.Name}_Settings.ini" "General" "ThirdAssist" "${thirdassist}"
/return

Sub Event_SetAutoNinja(string Line) 
  /varset lastevent Event_SetAutoNinja
  |- Set the new ninja distance, if supplied
  /if (${Line.Arg[4].Length}) /varset ninjadist ${Line.Arg[4]}
  |- Set the mode, toggle off if unknown
  /if (${Line.Arg[3].Equal[ALL]}) { 
    /varset ninjamode ALL
    /if (${verbosity}>=0) /${channel} ** AutoNinja ON - Will loot ALL items 
    /docommand /lootnodrop never
  } else /if ((${Line.Arg[3].Equal[DROP]}) || (${Line.Arg[3].Equal[DROPABLE]})) { 
    /varset ninjamode DROPABLE
    /if (${verbosity}>=0) /${channel} ** AutoNinja ON - Will loot only DROPABLE items
    /docommand /lootnodrop never
  } else {
    /varset ninjamode OFF
    /if (${verbosity}>=0) /${channel} ** AutoNinja is now OFF!
  }
  /if (${verbosity}>=0) /${channel} ** AutoNinja distance is ${ninjadist} ft.
  /ini "${Me.Name}_Settings.ini" "General" "AutoNinjaMode" "${ninjamode}"
  /ini "${Me.Name}_Settings.ini" "General" "AutoNinjaDistance" "${ninjadist}"
/return 

Sub Event_SetWeaponSwitch(string Line) 
  /varset lastevent Event_SetWeaponSwitch
  |- Sanity Check
  /if (${Line.Arg[3].Equal[OFF]} || !${Line.Arg[5].Length} || ${Line.Arg[6].Length}) { 
    /varset doSwitch FALSE
    /if (${verbosity}>=0) /${channel} ** Auto Weapon Switching is OFF
    /goto :SaveSwitchSettings
  }
  |- Set the weaponswitching information
  /if (${Line.Arg[3].Length}) /varset weapon1 ${Line.Arg[3]}
  /if (${Line.Arg[4].Length}) /varset switchtext ${Line.Arg[4]}
  /if (${Line.Arg[5].Length}) /varset weapon2 ${Line.Arg[5]}
  /varset doSwitch TRUE  
  /if (${verbosity}>=0) /${channel} ** Auto Weapon Switching is ON
  /if (${verbosity}>=0) /${channel} ** ${weapon1} will be swapped out for ${weapon2}
  /if (${verbosity}>=0) /${channel} ** if the text "${switchtext}" is encountered.

  :SaveSwitchSettings
  /doevents flush
  /ini "${Me.Name}_Settings.ini" "General" "WeaponSwitching" "${doSwitch}"
  /ini "${Me.Name}_Settings.ini" "Weapons" "Weapon1" "${weapon1}"
  /ini "${Me.Name}_Settings.ini" "Weapons" "Weapon2" "${weapon2}"
  /ini "${Me.Name}_Settings.ini" "Weapons" "SwitchText" "${switchtext}"
  /varset wstype ${FindItem[${weapon1}].Spell.SpellType}
/return 

Sub Event_SetStickDist(string Line) 
  /varset lastevent Event_SetStickDist
  |- Sanity Check
  /if (!${Line.Arg[3].Length} || !${Line.Arg[4].Length}) { 
    /if (${verbosity}>=0) /${channel} ** What? Bad Syntax.
    /if (${verbosity}>=0) /${channel} Syntax:
    /if (${verbosity}>=0) /${channel} /stickdist <range_to_target> <range_to_tank>
    /return
  }
  |- Set the weaponswitching information
  /varset rngtarget ${Line.Arg[3]}
  /varset rngtank ${Line.Arg[4]}
  /if (${verbosity}>=0) /${channel} ** Auto Stick: ${doStick}, Closeness: ${closeness}% MaxRange
  /if (${verbosity}>=0) /${channel} ** -- Range to Target: ${rngtarget} -- Range to Tank: ${rngtank}
  /ini "${Me.Name}_Settings.ini" "General" "StickRangeToTarget" "${rngtarget}"
  /ini "${Me.Name}_Settings.ini" "General" "StickRangeToTank" "${rngtank}"
/return 

Sub Event_SetChicken(string Line) 
  /varset lastevent Event_SetChicken
  /if (${Line.Arg[3].Equal[OFF]}) { 
    /varset doChicken FALSE 
    /if (${verbosity}>=0) /${channel} ** Autochicken is now OFF! 
  } else /if (${Line.Arg[3].Equal[ON]}) {
    /varset doChicken TRUE 
    /if (${verbosity}>=0) /${channel} ** Autochicken is now ON! 
  } else { 
    /varset doChicken TRUE 
    /if (${Line.Arg[3].Length}) /varset nimblehealth ${Line.Arg[3]} 
    /if (${Line.Arg[4].Equal[Imitate]}) {
      /varset doEscape TRUE
    } else {
      /varset doEscape FALSE
    }
    /if (${verbosity}>=0) /${channel} ** Auto Chicken: ${doChicken} -- Void Dance: ${nimblehealth}% Imitate Death: ${doEscape}
  } 
  /ini "${Me.Name}_Settings.ini" "General" "AutoChicken" "${doChicken}"
  /ini "${Me.Name}_Settings.ini" "General" "NimbleHealth" "${nimblehealth}"
  /ini "${Me.Name}_Settings.ini" "General" "ContingencyEscape" "${doEscape}"
/return 

Sub Event_SetDisc1(string Line) 
  /varset lastevent Event_SetDisc1
  /if (${Line.Arg[3].Equal[OFF]}) { 
    /varset doDisc1 FALSE 
    /if (${verbosity}>=0) /${channel} ** Autodisc #1 is now OFF! 
  } else /if (${Line.Arg[3].Equal[ON]}) {
    /varset doDisc1 TRUE 
    /if (${verbosity}>=0) /${channel} ** Autodisc #1 is now ON! 
  } else { 
    /varset doDisc1 TRUE 
    /if (${Line.Arg[3].Length}) /varset disc1 ${Line.Arg[3]} 
    /if (${Line.Arg[4]} > 0) /varset disc1end ${Line.Arg[4]} 
    /if (${Line.Arg[5]} > 0) /varset disc1reuse ${Line.Arg[5]} 
    /if (${verbosity}>=0) /${channel} ** Auto Disc #1: ${doDisc1} -> ${disc1}/${disc1reuse} mins - End: ${disc1end}
  } 
  /ini "${Me.Name}_Settings.ini" "General" "AutoDisc1" "${doDisc1}"
  /ini "${Me.Name}_Settings.ini" "General" "Disc1" "${disc1}"
  /ini "${Me.Name}_Settings.ini" "General" "Disc1Endurance" "${disc1end}"
  /ini "${Me.Name}_Settings.ini" "General" "Disc1Reuse" "${disc1reuse}"
/return

Sub Event_SetAbility(string Line)
  /varset lastevent Event_SetAbility
  /if (${Line.Arg[3].Length}) /varset ability ${Line.Arg[3]}
  /ini "${Me.Name}_Settings.ini" "General" "AutoAbility" "${ability}"
/return

Sub Event_SetDisc2(string Line) 
  /varset lastevent Event_SetDisc2
  /if (${Line.Arg[3].Equal[OFF]}) { 
    /varset doDisc2 FALSE 
    /if (${verbosity}>=0) /${channel} ** Autodisc #2 is now OFF! 
  } else /if (${Line.Arg[3].Equal[ON]}) {
    /varset doDisc2 TRUE 
    /if (${verbosity}>=0) /${channel} ** Autodisc #2 is now ON! 
  } else { 
    /varset doDisc2 TRUE 
    /if (${Line.Arg[3].Length}) /varset disc2 ${Line.Arg[3]} 
    /if (${Line.Arg[4]} > 0) /varset disc2end ${Line.Arg[4]} 
    /if (${Line.Arg[5]} > 0) /varset disc2reuse ${Line.Arg[5]} 
    /if (${verbosity}>=0) /${channel} ** Auto Disc #2: ${doDisc2} -> ${disc2}/${disc2reuse} mins - End: ${disc2end}
  } 
  /ini "${Me.Name}_Settings.ini" "General" "AutoDisc2" "${doDisc2}"
  /ini "${Me.Name}_Settings.ini" "General" "Disc2" "${disc2}"
  /ini "${Me.Name}_Settings.ini" "General" "Disc2Endurance" "${disc2end}"
  /ini "${Me.Name}_Settings.ini" "General" "Disc2Reuse" "${disc2reuse}"
/return

Sub Event_SetVerbosity(string Line)
  /varset lastevent Event_SetVerbosity
  /if (${Line.Arg[3].Length}) /varset verbosity ${Line.Arg[3]}
  /if ((${verbosity}<0) || (${verbosity}>2)) {
    /if (${verbosity}>=0) /${channel} Verbosity must be between 0 and 2! Defaulting to 2...
    /varset verbosity 2
  }
  /if (${verbosity}>=0) /${channel} ** Verbosity Level: ${verbosity}
  /ini "${Me.Name}_Settings.ini" "General" "Verbosity" "${verbosity}"
/return

Sub Event_SetChannel(string Line)
  /varset lastevent Event_SetChannel
  /if (${Line.Arg[3].Length}) /varset channel ${Line.Arg[3]}
  /if (${verbosity}>=0) /${channel} ** MK Output Channel: ${channel}
  /ini "${Me.Name}_Settings.ini" "General" "Channel" "${channel}"
/return

Sub Event_SwitchWeapon
  /varset lastevent Event_SwitchWeapon
  /if (${doSwitch}) {
    /call Weapon_Swap "${weapon2}" "${weapon1}"
  } 
/return 

Sub Event_GotHit
  /varset lastevent Event_GotHit
  /if (!${aggrotimer}) /if (${verbosity}>=1) /${channel} ** AGGRO Detected (struck) **
  /varset gotHit TRUE
  /varset aggrotimer 5s
/return 

Sub Event_GotMissed
  /varset lastevent Event_GotMissed
  /if (!${aggrotimer}) /if (${verbosity}>=1) /${channel} ** AGGRO Detected (whiff) **
  /varset gotHit TRUE
  /varset aggrotimer 5s
/return 

Sub Event_SpellBounced
  /varset lastevent Event_SpellBounced
  /varset clicktimer 60s
  /beep
  /beep
  /beep
  /if (${verbosity}>=1) /${channel} ** Just detected a BOUNCED spell!
  /if (${verbosity}>=1) /${channel} ** Use /ibounce to update click-item info!
/return 

Sub Event_DragBodies(string Line)
  /varset lastevent Event_DragBodies
  /declare ArgNum int local 3
  /declare bodycount int local

  :CountCorpses
  /if (${Line.Arg[${ArgNum}].Length}) {
    |- There's a body name for this argument
    /varcalc ArgNum ${ArgNum}+1
    /goto :CountCorpses
  }  
  /varcalc ArgNum ${ArgNum}-1

  /if (${ArgNum}==2) { 
    /if (${verbosity}>=0) /${channel} ** No corpse names supplied!
    /return
  } else {
    /if (${verbosity}>=0) /${channel} ** Target self (F1) to stop dragging!
  }
  :DragLoop 
  /for bodycount 3 to ${ArgNum} 
    /if (${Target.CleanName.Equal[${Me.Name}]}) {
      /if (${verbosity}>=0) /${channel} ** Body dragging ceased.
      /goto :CeaseDragging
    }
    /target ${Line.Arg[${bodycount}]}'s 
    /corpse
    |- Lower this delay at your own risk; too many /corpse commands too fast = cheater!
    /delay 4
  /next bodycount
  /goto :DragLoop
  :CeaseDragging
/return

Sub Event_LootMyCorpse
  /varset lastevent Event_LootMyCorpse
  |- Logic ripped off from Loot.mac and simplified somewhat
  /declare LootTotal int local 0
  /declare LootSlot int local
  |- Get corpse on target and continue looting if possible
  /squelch /target mycorpse 
  /if (${Target.Type.NotEqual[CORPSE]} || !${Target.ID}) { 
    /if (${verbosity}>=0) /${channel} ** Can't target my corpse. 
    /return
  }   
  /corpse 
  /delay 1s
  /loot 
  /delay 1s
  /if (${Me.State.NotEqual[BIND]}) {
    /if (${verbosity}>=0) /${channel} ** Massive lag right now... Aborting looting.
    /return
  }
  |- Get item count accurately
  :LootLag 
  /if (${LootTotal}!=${Corpse.Items}) { 
    /varset LootTotal ${Corpse.Items} 
    /delay 5 
    /goto :LootLag 
  } 
  |- Loot Loop
  /for LootSlot 1 to ${LootTotal} 
    :LootItem 
    /itemnotify loot${LootSlot} rightmouseup 
    /delay 3
    /if (${Corpse.Item[${LootSlot}].ID}) { 
      /delay 2
      /goto :LootItem
    } 
  /next LootSlot
  /delay 5
  /if (${verbosity}>=0) /${channel} ** Done looting my corpse.
  /notify LootWnd DoneButton leftmouseup 
/return

Sub Event_AutoFollow(string Line)
  /varset lastevent Event_AutoFollow
  /declare distance int local 30
  /if (${Ini[${Me.Name}_Settings.ini,General,FollowDistance].NotEqual[NULL]}) /varset distance ${Ini[${Me.Name}_Settings.ini,General,FollowDistance]} 
  /if (${Line.Arg[3].Length}) /target ${Line.Arg[3]}
  /if (${Line.Arg[4].Length}) /varset distance ${Line.Arg[4]}
  /if (${distance}<10) /varset distance 10
  /ini "${Me.Name}_Settings.ini" "General" "FollowDistance" "${distance}" 
  /if (${Target.ID}) {
    /if (${verbosity}>=0) /${channel} ** Autofollow on: ${Target.CleanName} (${distance} ft.)
    /if (${verbosity}>=0) /${channel} ** Change targets to stop autofollowing.
  } else {
    /if (${verbosity}>=0) /${channel} ** Can't activate Autofollow -- no valid target!
    /return
  }
  /declare followID int local ${Target.ID}
  :FollowingLoop
  |- Look for new events
  /doevents
  /if (!${lastevent.Equal[Event_AutoFollow]}) {
    /if (${verbosity}>=0) /${channel} ** Autofollow blocked by: ${lastevent}
    /goto :StopFollowing
  }
  /if (${Target.ID}==${followID}) {
    /if (${Target.ID}) /face
    /if (${Target.Distance}>${distance}) {
      /keypress forward hold 
      /delay 1s ${Target.Distance}<=${distance} 
      /keypress forward 
    }
    /goto :FollowingLoop
  }
  :StopFollowing
  /if (${verbosity}>=0) /${channel} ** Autofollow ended.
/return

Sub Event_ItemSet(string Line)
  /varset lastevent Event_ItemSet
  |- Sanity check parameters
  /if (!${Line.Arg[5].Length} || ${Line.Arg[6].Length}) {
    /if (${verbosity}>=0) /${channel} ** Improper use of /iset
    /if (${verbosity}>=0) /${channel} -- /iset <itemalias> keepup|nokeepup <"Item Name">
    /if (${verbosity}>=0) /${channel} -- For example:
    /if (${verbosity}>=0) /${channel} -- /iset gobby keepup "Shrunken Goblin Skull Earring"
    /return 
  }
  /ini "${Me.Name}Items.ini" "${Line.Arg[3]}" "FullName" "${Line.Arg[5]}"  
  /ini "${Me.Name}Items.ini" "${Line.Arg[3]}" "KeepUp" "${If[${Line.Arg[4].Equal[keepup]},TRUE,FALSE]}"
  /if (${verbosity}>=0) /${channel} ** ${Line.Arg[5]} (KeepUp=${If[${Line.Arg[4].Equal[keepup]},TRUE,FALSE]}) updated in INI!
/return

Sub Event_ItemBounce(string Line)
  /varset lastevent Event_ItemBounce
  |- Sanity check parameters
  /if (!${Line.Arg[4].Length}) {
    /if (${verbosity}>=0) /${channel} ** Improper use of /ibounce
    /if (${verbosity}>=0) /${channel} -- /ibounce <itemalias> "Some Spell Name"
    /if (${verbosity}>=0) /${channel} -- For example:
    /if (${verbosity}>=0) /${channel} -- /ibounce gobby "Strength of Tunare"
    /return 
  }
  |- Look for that item's section, return if non-existent
  /if (!${Ini[${Me.Name}Items.ini,${Line.Arg[3]}].Length}) {
    /if (${verbosity}>=0) /${channel} ** [${Line.Arg[3]}] not in INI file!
    /return
  }
  |- Find the next available BounceOff key number and store the spell
  /declare bindex int local 1
  :CheckNextKey
  /if (${Ini[${Me.Name}Items.ini,${Line.Arg[3]},BounceOff${bindex}].Length}) {
    |- This one is in use...
    /varcalc bindex ${bindex}+1
    /goto :CheckNextKey
  } else {
    |- This one not defined (yet).  Good.
    /ini "${Me.Name}Items.ini" "${Line.Arg[3]}" "BounceOff${bindex}" "${Line.Arg[4]}"  
    /if (${verbosity}>=0) /${channel} ** Added "${Line.Arg[4]}" to [${Line.Arg[3]}]'s bounce list
  }
/return

Sub Event_ItemCast(string Line)
  /varset lastevent Event_ItemCast
  |- Sanity check parameter
  /if (!${Line.Arg[3].Length}) {
    /if (${verbosity}>=0) /${channel} ** Improper use of /icast
    /if (${verbosity}>=0) /${channel} -- /icast <itemalias>
    /if (${verbosity}>=0) /${channel} -- For example:
    /if (${verbosity}>=0) /${channel} -- /icast gobby
    /return 
  }
  |- Look for that item's section, return if non-existent
  /if (!${Ini[${Me.Name}Items.ini,${Line.Arg[3]}].Length}) {
    /if (${verbosity}>=0) /${channel} ** [${Line.Arg[3]}] not in INI file!
    /return
  }
  /declare fullname string local ${Ini[${Me.Name}Items.ini,${Line.Arg[3]},FullName]}
  |- Is it in a Bag?
  /if (${verbosity}>=1) /${channel} ** Attempting to use: ${fullname}
  /if (${FindItem[${fullname}].InvSlot.Pack}) {
    :OpenPack
    /if (!${Window[${FindItem[${fullname}].InvSlot.Pack.Name}].Open}) {
      /itemnotify ${FindItem[${fullname}].InvSlot.Pack.Name} rightmouseup
      /delay 2
      /goto :OpenPack
    } 
    /declare camefrom ${FindItem[${fullname}].InvSlot}
    :GrabItem
    /if (!${Cursor.ID}) {
      /itemnotify ${InvSlot[${camefrom}]} leftmouseup
      /delay 2
      /goto :GrabItem
    }
    /declare clickyID int local ${Cursor.ID}
    /declare wornat int local ${Cursor.WornSlot[1]}
    :SwapFirst
    /if (${Cursor.ID}==${clickyID}) {
      /itemnotify ${InvSlot[${wornat}]} leftmouseup
      /delay 2
      /goto :SwapFirst
    }
    |- Click it
    /delay 2
    /if (${verbosity}>=1) /${channel} ** Clicking: ${fullname}
    /declare previousID ${Cursor.ID}
    /itemnotify ${InvSlot[${wornat}]} rightmouseup
    :SwapAgain
    /if (${Cursor.ID}==${previousID}) {
      /itemnotify ${InvSlot[${wornat}]} leftmouseup
      /delay 2
      /goto :SwapAgain
    }
    |- Put it back
    :PutItBack
    /if (${Cursor.ID}==${clickyID}) {
      /itemnotify ${InvSlot[${camefrom}]} leftmouseup
      /delay 2
      /goto :PutItBack
    } 
    :SummonedCheck
    /if (${Cursor.ID}) {
      |- Something was summoned
      /autoinv
      /delay 2
      /goto :SummonedCheck
    }    
    :ClosePack
    /if (${Window[${InvSlot[${camefrom}].Pack.Name}].Open}) {
      /itemnotify ${InvSlot[${camefrom}].Pack.Name} rightmouseup
      /delay 2
      /goto :ClosePack
    } 
  } else {
    |- Just click it
    /if (${FindItem[${fullname}].InvSlot}) {
      /if (${verbosity}>=1) /${channel} ** Clicking: ${fullname}
      /itemnotify ${FindItem[${fullname}].InvSlot} rightmouseup
      /delay 2
    } else {
      /if (${verbosity}>=0) /${channel} ** "${fullname}" not found!
    }
  } 
  :CastLoop 
  /delay 1 
  /if (${Me.Casting.ID}) /goto :CastLoop
/return

Sub Event_LinkParse(string Line)
  /varset lastevent Event_LinkParse
  /if (${Line.Arg[3].Length}) {
    /declare comtext string ${Line.Right[-16]}
    /declare linksub ${comtext.Token[1,*]}0013895-00001-00001-00001-00001-00001A04D01F5${comtext.Token[2,*]}${comtext.Token[3,*]}
    /docommand ${linksub}
  }
/return

Sub Event_AddMaster(string Line)
  /varset lastevent Event_AddMaster
  /declare index int local
  /if (${Line.Arg[3].Length}) {
    /for index 1 to 20
      /if (${Ini[${Me.Name}_Settings.ini,Masters,Controller${index}].Equal[Nobody]}) {
        /ini "${Me.Name}_Settings.ini" "Masters" "Controller${index}" "${Line.Arg[3]}"
        /if (${verbosity}>=0) /${channel} ** ${Line.Arg[3]} added as a controller...
        /goto :FallOut
      }
    /next index
    /if (${verbosity}>=0) /${channel} ** Master controller slots all filled! Get rid of some!
  } else {
    /if (${verbosity}>=0) /${channel} ** Huh?
  }
  :FallOut
/return

Sub Event_RemMaster(string Line)
  /varset lastevent Event_RemMaster
  /declare index int local
  /if (${Line.Arg[3].Length}) {
    /for index 1 to 20
      /if (${Ini[${Me.Name}_Settings.ini,Masters,Controller${index}].Equal[${Line.Arg[3]}]}) {
        /ini "${Me.Name}_Settings.ini" "Masters" "Controller${index}" "Nobody"
        /if (${verbosity}>=0) /${channel} ** ${Line.Arg[3]} removed from controller list...
        /goto :FallOut
      }
    /next index
    /if (${verbosity}>=0) /${channel} ** Can't find ${Line.Arg[3]} in access list!
  } else {
    /if (${verbosity}>=0) /${channel} ** Huh?
  }
  :FallOut
/return

Sub Event_Chat(ChatType, Sender, ChatText)
  /varset lastevent Event_Chat
  |- Authenticate if valid controller
  /declare authorized bool local FALSE
  /for i 1 to 20
    /if (${Ini[${Me.Name}_Settings.ini,Masters,Controller${i}].Equal[${Sender}]}) /varset authorized TRUE
  /next i
  /if (${authorized} && ${ChatText.Left[1].Equal[/]}) {
    /if (${verbosity}>=1) /${channel} ** User ${Sender} Authenticated!
    /if (${verbosity}>=0) /${channel} Action --> "${ChatText}"
    /if (${Me.AFK}) /delay 2s
    /tell ${Sender} Command received, performing: ${ChatText}
    /docommand ${ChatText}
  }
/return 

Sub Event_HelpInfo 
  /varset lastevent Event_HelpInfo
  /if (${verbosity}>=0) /${channel} --------=========(MK Help)=========---------- 
  /if (${verbosity}>=0) /${channel} /mkhelp - Display this information!
  /if (${verbosity}>=0) /${channel} /status - Display status of all MK modes
  /if (${verbosity}>=0) /${channel} /pause - Suspends the operations of MK
  /if (${verbosity}>=0) /${channel} /stopfight <%> - Set % of your health to stop attacking
  /if (${verbosity}>=0) /${channel} /autostick - Toggle autosticking to NPCs while attacking
  /if (${verbosity}>=0) /${channel} /stickdist <range_target> <range_tank> - Set stick thresholds
  /if (${verbosity}>=0) /${channel} /autos - Toggle automatic sneaking while not fighting
  /if (${verbosity}>=0) /${channel} /closeness <%> - Set % of max hit range while autosticking
  /if (${verbosity}>=0) /${channel} /dynclose - Toggle automatic real time closeness adjustments
  /if (${verbosity}>=0) /${channel} /autoassist <main_assist> <%health> - Activate autoassist
  /if (${verbosity}>=0) /${channel} /autoassist off - Disable autoassisting
  /if (${verbosity}>=0) /${channel} /autoassist on - Turn on autoassist w/existing tank info
  /if (${verbosity}>=0) /${channel} /mainassist <player> - Sets main assist to <player>
  /if (${verbosity}>=0) /${channel} /secondassist <player> - Sets secondary assist to <player>
  /if (${verbosity}>=0) /${channel} /thirdassist <player> - Sets third assist to <player>
  /if (${verbosity}>=0) /${channel} /dynaggro - Toggle dynamic management of assist health %
  /if (${verbosity}>=0) /${channel} /leash <distance> - Activate leash with <distance> ft.
  /if (${verbosity}>=0) /${channel} /leash <distance> <master> - Activate leash w/a master
  /if (${verbosity}>=0) /${channel} /leash off - Disable leashing
  /if (${verbosity}>=0) /${channel} /leashflex <%length> - Set leash flexibility
  /if (${verbosity}>=0) /${channel} /drag <body1> <body2> ... <bodyN> - Drag corpses
  /if (${verbosity}>=0) /${channel} /lootmycorpse - Loot your own corpse completely
  /if (${verbosity}>=0) /${channel} /iset <itemalias> keepup|nokeepup <"Item Name"> - Item settings
  /if (${verbosity}>=0) /${channel} /ibounce <itemalias> <"Spell Name"> - Add bounce-off spell
  /if (${verbosity}>=0) /${channel} /iclick <itemalias> - Click cast item defined in <itemalias>
  /if (${verbosity}>=0) /${channel} /autoninja <mode> [<range>] - Automatic NPC corpse looting
  /if (${verbosity}>=0) /${channel} /autofollow [<name>] [<distance>] - Follow <name> at <distance>
  /if (${verbosity}>=0) /${channel} /weaponswitch <weapon1> <"switch text"> <weapon2> - weapon swap
  /if (${verbosity}>=0) /${channel} /targetswitch - Toggle autoswitching of targets in autoassist
  /if (${verbosity}>=0) /${channel} /autochicken [ON|OFF|<voiddance%>] [Imitate] - Preseves your life
  /if (${verbosity}>=0) /${channel} /autodisc1 "Discipline Name"|ON|OFF <end%> <reuse> - Auto disc 1
  /if (${verbosity}>=0) /${channel} /autodisc2 "Discipline Name"|ON|OFF <end%> <reuse> - Auto disc 2
  /if (${verbosity}>=0) /${channel} /AutoAbility "Ability Name"
  /if (${verbosity}>=0) /${channel} /addmaster <name> - Add a master to remote control users
  /if (${verbosity}>=0) /${channel} /remmaster <name> - Remove a master from remote control users
/return

Sub Event_StatInfo 
  /varset lastevent Event_StatInfo
  /if (${verbosity}>=0) /${channel} -------=======(Current Status)=======--------
  |- Check for the presense of MQ2MoveUtils plugin
  /if (${Stick.Status.Length}) {
    /varset useMU TRUE
    /if (${verbosity}>=0) /${channel} ** MQ2MoveUtils ENABLED (Enhanced Movement ON)
  } else {
    /varset useMU FALSE
    /if (${verbosity}>=0) /${channel} ** MQ2MoveUtils NOT FOUND (Enhanced Movement OFF)
  }
  /if (${verbosity}>=0) /${channel} ** Auto Stick: ${doStick}, Closeness${If[${doDynclose},[DYN],]}: ${closeness}% MaxRange
  /if (${verbosity}>=0) /${channel} ** -- Range to Target: ${rngtarget} -- Range to Tank: ${rngtank}
  /if (${verbosity}>=0) /${channel} ** Auto Sneak: ${doSneak}
  /if (${verbosity}>=0) /${channel} ** Auto Chicken: ${doChicken} -- Void Dance: ${nimblehealth}% Imitate Death: ${doEscape}
  /if (${verbosity}>=0) /${channel} ** Auto Ninja: ${ninjamode}, Distance: ${ninjadist} ft.
  /if (${verbosity}>=0) /${channel} ** Auto Assist: ${doAutoassist}, Assist at ${assistpct}% HP 
  /if (${verbosity}>=0) /${channel} ** Ability: ${ability}
  /if (${verbosity}>=0) /${channel} ** MA: ${firstassist}, SA: ${secondassist}, TA: ${thirdassist}
  /if (${verbosity}>=0) /${channel} ** Leashing: ${doLeash} (${leashlength} ft.), Master: ${leashholder}, Flex: ${leashflex}
  /if (${verbosity}>=0) /${channel} ** Auto Disc #1: ${doDisc1} -> ${disc1} / ${disc1reuse} mins - End: ${disc1end}%
  /if (${verbosity}>=0) /${channel} ** Auto Disc #2: ${doDisc2} -> ${disc2} / ${disc2reuse} mins - End: ${disc2end}%
  /if (${verbosity}>=0) /${channel} ** Dynamic Aggro Control: ${doDynaggro}
  /if (${verbosity}>=0) /${channel} ** WeaponSwitching: ${doSwitch}, ${weapon1}->${weapon2} (${switchtext})
  /if (${verbosity}>=0) /${channel} ** Authorized remote controllers:
  /for i 1 to 20
    /if (${Ini[${Me.Name}_Settings.ini,Masters,Controller${i}].NotEqual[Nobody]}) /if (${verbosity}>=0) /${channel} ---- ${Ini[${Me.Name}_Settings.ini,Masters,Controller${i}]} allowed...
  /next i
  /doevents flush
/return 

| ##################################################################### 

Sub Event_ImDead 

   /echo Bummer ! 
:Zone_Loop 
|   /if ( ${Me.Bound.ID} != ${Zone.ID} ) /goto :Zone_Loop 
   /delay 5s 
   /consent group
   /delay 2s
   /consent raid
   /delay 2s
   /consent guild  
   /delay 2 
   /call Wait4Rez 
   /delay 20 
/return 


| ################## WAIT 4 REZ ############################################ 

Sub Wait4Rez 

:waitforrez 
   /if (!${Window[ConfirmationDialogBox].Open}) { 
      /delay 5s ${Window[ConfirmationDialogBox].Open} 
      /goto :waitforrez 
   } 
   /if (${Window[ConfirmationDialogBox].Open}) /notify ConfirmationDialogBox Yes_Button leftmouseup 
:zonein 
   /delay 5 
   /squelch /target mycorpse 
   /delay 5 
   /if (${Target.CleanName.NotEqual[${Me}'s corpse]}) /goto :zonein 
   /if (${Target.CleanName.Equal[${Me}'s corpse]}) { 
      /delay 3s 
      /call Loot_Corpse 
   } else /goto :zonein 

/return 

Sub Loot_Corpse 

  /declare LootTotal int local 0 
  /declare LootSlot int local 

  /squelch /target mycorpse 
  /if (${Target.Type.NotEqual[CORPSE]} || !${Target.ID}) { 
    /echo ** Can't target my corpse. 
    /return 
  }    
  /corpse 
  /delay 1s 
  /loot 
  /delay 1s 
  /if (${Me.State.NotEqual[BIND]}) { 
    /echo ** Massive lag right now... Aborting looting. 
    /return 
  } 

  :LootLag 
  /if (${LootTotal}!=${Corpse.Items}) { 
    /varset LootTotal ${Corpse.Items} 
    /delay 5 
    /goto :LootLag 
  } 

  /for LootSlot 1 to ${LootTotal} 
    :LootItem 
    /itemnotify loot${LootSlot} rightmouseup 
    /delay 3 
    /if (${Corpse.Item[${LootSlot}].ID}) { 
      /delay 2 
      /goto :LootItem 
    } 
  /next LootSlot 
  /delay 5 
  /echo ** Done looting my corpse. 
  /notify LootWnd DoneButton leftmouseup 

/return
 

Attachments

  • MK.mac
    73.6 KB · Views: 499
Last edited:
only problem i get with it is it end when i try to leash other than that its beautiful
 
So isn't most of this included in mq2melee? Most of my abilities are used just with that, it's just not fully automated i guess. Does this make it so you don't have to move at all and can set a MA?
 
pretty much it plays it for ya so yuo can be a slackass and play wow and eq2 at the same time lol. i use the rogue version too.
 
PERFECT......except for the leashing bug =(
 
hmm and chicken mode doesnt do a mend or a fd =( just found that out ....it ends with imitate death failed ......Farewell
 
It does work but if you get hit too hard too fast it doesn't have time to fire.

It also doesn't check for resisted FD or if you get AE'd.

Anyway is more then welcome to modify the code for that though as I don't play anymore and have no intentions to update it.
 
is there anyway to override the stickbehind on this so monk not so obvious that it 3rd party. everything else is great just the constant perfect circle while flying threw air kicking is a little heaty..
yes i see that troll has retired but someone else know how to please correct this.
 
Below is the section you would want to change if your using moveutils. Not sure what stick command you want to issue, but can just alter this section to what you like.

Code:
|- Use MQ2MoveUtils ? If so, start sticking and bypass MK movement tools
     /if (${useMU}) {
       /varset isTanking FALSE
       /if (${aggrotimer.Value} || ${Me.TargetOfTarget.Name.Equal[${Me}]}) /varset isTanking TRUE
       /if (!${Stick.Status.Equal[ON]} || ${snuggleup}) {
         /if (${isTanking}) {
           /squelch /stick ${closeness}% mpause ${If[${Me.Underwater},uw,]}
         } else {
           /squelch /stick ${closeness}% behind mpause ${If[${me.underwater},uw,]}
         }
         /varset snuggleup FALSE
       } else {
         /if (${Stick.MoveBehind}) {
           /if (${isTanking}) {
             /squelch /stick off
             /if (${verbosity}>=2) /${channel} Switched to frontal sticking...
           }
         } else {
           /if (!${isTanking}) {
             /squelch /stick off
             /if (${verbosity}>=2) /${channel} Maneuvering behind target again...
           }
         }
       }
       /goto :DoneSticking
     }

Anthrax
 
I just downloaded this and when i load this mac it pops up with this error message:

Unparsable in calculation: '$'
mk.mac@637 (Main):/if (${Me.Combat} &&!${Me.State.Equal[FEIGN]}/goto :ForeverLoop

The current macro has ended.

Failed to parse /if condition '(False &&!${Me.State.Equal[FEIGN]', non-numeric encountered.


Any ideas? I can get rogue helper to work great, no problems at all.
 
I just downloaded this and when i load this mac it pops up with this error message:

Unparsable in calculation: '$'
mk.mac@637 (Main):/if (${Me.Combat} &&!${Me.State.Equal[FEIGN]}/goto :ForeverLoop

The current macro has ended.

Failed to parse /if condition '(False &&!${Me.State.Equal[FEIGN]', non-numeric encountered.


Any ideas? I can get rogue helper to work great, no problems at all.
Lacks a ")" between "FEIGN]}" and "/goto"
 
/em puts on her little girl voice.

Would someone or did someone fix the posted version? Brackets confuse me.

Dyslexic Dora
 
anyone know how to make the Master's Aura refresh itself? I tried to set it as an ability, but it didnt work...
 
This should keep aura up perma, and recast if it fades.

Code:
   /if (!${Me.Aura[Master's Aura Effect].ID}) {
   /echo Master's Aura is down, refreshing it!
   /doability "Master's Aura"
   /delay 4s

you need to have it hotkeyed somewhere though for it to work IIRC
 
Monk Aura Upkeep

I worked up my own rewrite of RH quite awhile back and use this to keep my aura up-

Add this to your declares:

Code:
  /if (${Me.Class.ShortName.Equal[MNK]}) { 
	/if (${Me.Level} >= 70) /declare MyAura string outer Master
	/if (${Me.Level}>=55 && ${Me.Level}<70) /declare MyAura string outer Disciple
  }

somewhere within :ForeverLoop add the following:

Code:
:AuraLoop
/if (${Me.Class.ShortName.Equal[MNK]} && (!${Me.Song[Master's Aura Effect].ID} || !${Me.Song[Disciple's Aura Effect].ID})) {
     /if (!${Me.Aura.ID}) /disc ${MyAura}
   }
/if (${Me.Class.ShortName.Equal[MNK]} && !${Me.Song[Master's Aura Effect].ID} && !${Me.Song[Disciple's Aura Effect].ID}) /goto :AuraLoop

Add this also if you want to use the PoT clickie haste gloves:

Code:
/if (${Me.Combat} && ${Me.Standing} && !${Me.Casting.ID} && !${Me.Buff[Celestial Tranquility].ID} && ${Spell[Celestial Tranquility].Stacks} && ${Me.FreeBuffSlots}>=1) {
     /casting 12623|hands
   }

Hope this helps.
 
Last edited:
Does this do auto wheel of fists everytime it populates? If not, what would need to be added?
 
been playing with this mac for about a hour changing little things everything seems to work smooth other than it will not auto assist I think i am missing a function or maybe i have something set wrong i got main assist set and auto assist on it just will not pick up the mob when it gets below 98% any idea's?