Page 1 of 1

AutoBeastlord based off of Latest RogueHelper

Posted: Wed Jun 30, 2004 8:52 pm
by zertful
Hey guys, I've been out of this for awhile since working on Liza2d's Macro Kit (MQ 1.0?) so I'm a bit lost with the new MQ2Data syntax's but I've been playing around with Jerle69's wonderful Rogue Helper script... adapting it to the beastlord. There have been a few nice adaptations now and again usually based off this macro but none that make use of the latest features.. (the thing really is awesome if you haven't tried it I suggest downloading it now)

Well I've come here for some suggestions and maybe some contributions by some other beastlord macroers out there... So far, I've got basic functionality including pet control and very basic buff maintainers.

Some things I need to fix but can't really think of a good way:

1. I can't figure out how to get it to auto slow by spell reliabily, I would like to have an option that allows me to turn this on and off (if there is another slower in the group) The script already has lots of toggles like this so I can probably figure it out from reading over the macro, but once I have the toggle working I don't know how to have it handle resists, and not to slow more than once. Anyone have a good example I can work with?

2. The Event_SLOW will announce when my epic procs and a mob is slowed, but it does it every single time it procs and looks kind of suspicious (especially if there is another Beastlord with Epic in the group), so I've got it commented out for now...

3. I'd also like a better way to buff myself rather than just pressing tab and using spellcast.inc to cast the spell.

4. I haven't added the auto-kick when available yet, there's no excuse for that I just haven't gotten around to it.

5. The buff maintainer isn't working for my pet buff, I'm not sure why because I've had this work before in an older script, but I've recently leveled up to Arag's Celerity, maybe I've got a typo but I checked and it seemed to be in order.

6. Ultimately, I'd like the buff maintainer to be setup in the RH INI file so that people can easily change what buffs they will cast.


Thats about it on the todo list for now, I'm not posting here to ask someone to do it for me, just looking for some guidance. Although any contributions certainly would be appreciated... :lol:


Here's the code: (btw, there are some very long strings, unless you've got 1600x1200 or higher you may need to fix some word wrapping issues if you try and cut and paste this)

Code: Select all


| 
| Rogue Helper (RH) Macro modified for Beastlord v0.1alpha
| - v5.4 by Jerle (6/24/04) 
| 
| Omitted the very large Changes and Documentation so this post isn't huge
|--------------------------------------------------------------------------------- 
| 
| RH Syntax: 
| 
| Usage: /mac rh 
| 
| Default settings can be changed by their respective controlling /command
|
| Type /rhhelp for help or /status to see current settings!
| 
|--------------------------------------------------------------------------------- 

#Chat tell 
#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 Exp             "#*#You gain#*#experience#*#" 
#Event Zoned           "#*#You have entered#*#"
#Event GotHit          "#*#hits YOU#*#"
#Event GotMissed       "#*#hit YOU#*#"
#Event SwitchWeapon    "#*#|${switchtext}|#*#"
#Event TogEvade        "[MQ2] Autoevade#*#"
#Event TogPick         "[MQ2] Autopick#*#"
#Event TogStick        "[MQ2] Autostick#*#" 
#Event TogHS           "[MQ2] Auto Hide & Sneak#*#" 
#Event TogLeash        "[MQ2] Leash#*#" 
#Event TogAuto         "[MQ2] Autoassist#*#" 
#Event TogDynaggro     "[MQ2] Dynaggro#*#" 
#Event TogPause        "[MQ2] Pause#*#"
#Event TogTSwitch      "[MQ2] AutoTargetSwitch#*#"
#Event SetStopFighting "[MQ2] SetStopFighting#*#"
#Event SetEndFloor     "[MQ2] SetEndFloor#*#"
#Event SetStrikeDisc   "[MQ2] SetStrikeDisc#*#"
#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 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] RH Help#*#"
#Event StatInfo        "[MQ2] -------=======(Current Status)=======--------"

| - Beastlord Stuff

#Event SpellCast		"#*#You begin casting#*#"#Event FEROC "#*#The ferocity fades.#*#" 
#Event SV			"#*#Your spiritual vigor fades.#*#" 
#Event DOMIN		"#*#The aura of purity fades.#*#" 
#Event IOS			"#*#Your power fades.#*#" 
#Event STR			"#*#Your Furious Strength fades.#*#" 
#Event HASTE		"#*#Your speed returns to normal.#*#" 
#Event TALIS		"#*#Your hit points fade.#*#" 
#Event FREN			"#*#Your frenzy fades.#*#" 
#Event STA			"#*#Your stamina fades.#*#" 
#Event DEX			"#*#Your dexterity fades.#*#" 
#Event PETH			"#*#Your pet's Arag's Celerity#*#"
#Event PETP			"#*#Your pet's Spirit of Rellic#*#"
| #Event SLOW			"#*#wracked by the vengeance of Sha#*#"

#include spellcast.inc

Sub Main

  /echo Loading Rogue Helper... Please Wait!

  /declare doEvade bool outer TRUE 
  /declare StopFightingHealth int outer 30 
  /declare StrikeSkill string outer Assassin 
  /declare MinEndurance int outer 80 
  /declare isEnraged bool outer FALSE 
  /declare strikeReady bool outer FALSE 
  /declare strikeTimer timer outer 0 
  /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 doHideSneak bool outer TRUE
  /declare doLeash bool outer FALSE 
  /declare leashlength int outer 0
  /declare stakeX int outer 
  /declare stakeY int outer 
  /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 doPick bool outer FALSE 
  /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

  /squelch /alias /status /echo -------=======(Current Status)=======--------
  /squelch /alias /rhhelp /echo RH Help
  /squelch /alias /autoevade /echo Autoevade
  /squelch /alias /autopick /echo Autopick
  /squelch /alias /stopfight /echo SetStopFighting
  /squelch /alias /strikedisc /echo SetStrikeDisc
  /squelch /alias /endfloor /echo SetEndFloor
  /squelch /alias /autostick /echo Autostick 
  /squelch /alias /autohs /echo Auto Hide & 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

  |-- Read in INI settings, if defined...  Leashing is only stored TRUE if there is a Leash-holding Master!

  /if (${Ini[RHSettings.ini,General,AutoEvade].NotEqual[NULL]}) /varset doEvade ${Ini[RHSettings.ini,General,AutoEvade]}
  /if (${Ini[RHSettings.ini,General,StopFightingHealth].NotEqual[NULL]}) /varset StopFightingHealth ${Ini[RHSettings.ini,General,StopFightingHealth]}
  /if (${Ini[RHSettings.ini,General,StrikeSkill].NotEqual[NULL]}) /varset StrikeSkill ${Ini[RHSettings.ini,General,StrikeSkill]}    
  /if (${Ini[RHSettings.ini,General,MinEndurance].NotEqual[NULL]}) /varset MinEndurance ${Ini[RHSettings.ini,General,MinEndurance]}    
  /if (${Ini[RHSettings.ini,General,AutoStick].NotEqual[NULL]}) /varset doStick ${Ini[RHSettings.ini,General,AutoStick]} 
  /if (${Ini[RHSettings.ini,General,Closeness].NotEqual[NULL]}) /varset closeness ${Ini[RHSettings.ini,General,Closeness]} 
  /if (${Ini[RHSettings.ini,General,AutoHideSneak].NotEqual[NULL]}) /varset doHideSneak ${Ini[RHSettings.ini,General,AutoHideSneak]}
  /if (${Ini[RHSettings.ini,General,Leashing].NotEqual[NULL]}) /varset doLeash ${Ini[RHSettings.ini,General,Leashing]} 
  /if (${Ini[RHSettings.ini,General,LeashHolder].NotEqual[NULL]}) /varset leashholder ${Ini[RHSettings.ini,General,LeashHolder]} 
  /if (${Ini[RHSettings.ini,General,LeashLength].NotEqual[NULL]}) /varset leashlength ${Ini[RHSettings.ini,General,LeashLength]} 
  /if (${Ini[RHSettings.ini,General,AutoAssist].NotEqual[NULL]}) /varset doAutoassist ${Ini[RHSettings.ini,General,AutoAssist]} 
  /if (${Ini[RHSettings.ini,General,AssistPercentage].NotEqual[NULL]}) /varset assistpct ${Ini[RHSettings.ini,General,AssistPercentage]} 
  /if (${Ini[RHSettings.ini,General,MainAssist].NotEqual[NULL]}) /varset mainassist ${Ini[RHSettings.ini,General,MainAssist]} 
  /if (${Ini[RHSettings.ini,General,MainAssist].NotEqual[NULL]}) /varset firstassist ${Ini[RHSettings.ini,General,MainAssist]}
  /if (${Ini[RHSettings.ini,General,SecondAssist].NotEqual[NULL]}) /varset secondassist ${Ini[RHSettings.ini,General,SecondAssist]} 
  /if (${Ini[RHSettings.ini,General,ThirdAssist].NotEqual[NULL]}) /varset thirdassist ${Ini[RHSettings.ini,General,ThirdAssist]} 
  /if (${Ini[RHSettings.ini,General,DynamicAggro].NotEqual[NULL]}) /varset doDynaggro ${Ini[RHSettings.ini,General,DynamicAggro]} 
  /if (${Ini[RHSettings.ini,General,AutoNinjaMode].NotEqual[NULL]}) /varset ninjamode ${Ini[RHSettings.ini,General,AutoNinjaMode]} 
  /if (${Ini[RHSettings.ini,General,AutoNinjaDistance].NotEqual[NULL]}) /varset ninjadist ${Ini[RHSettings.ini,General,AutoNinjaDistance]} 
  /if (${Ini[RHSettings.ini,General,AutoPickPocket].NotEqual[NULL]}) /varset doPick ${Ini[RHSettings.ini,General,AutoPickPocket]}
  /if (${Ini[RHSettings.ini,General,WeaponSwitching].NotEqual[NULL]}) /varset doSwitch ${Ini[RHSettings.ini,General,WeaponSwitching]}
  /if (${Ini[RHSettings.ini,General,TargetSwitching].NotEqual[NULL]}) /varset doTSwitch ${Ini[RHSettings.ini,General,TargetSwitching]}

  /if (${Ini[RHSettings.ini,Weapons,Weapon1].NotEqual[NULL]}) /varset weapon1 ${Ini[RHSettings.ini,Weapons,Weapon1]}
  /if (${Ini[RHSettings.ini,Weapons,Weapon2].NotEqual[NULL]}) /varset weapon2 ${Ini[RHSettings.ini,Weapons,Weapon2]}
  /if (${Ini[RHSettings.ini,Weapons,SwitchText].NotEqual[NULL]}) /varset switchtext ${Ini[RHSettings.ini,Weapons,SwitchText]}
  /varset wstype ${FindItem[${weapon1}].Spell.SpellType}

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

  /echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 
  /echo Jerle's Rogue Helper Macro (v5.4) Starting... 
  /echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 
  /echo Use "/rhhelp" to display help information
  /echo -------=======(Current Status)=======--------  

  :ForeverLoop 

   |- Service any events 

   /doevents 
    
   |- If we're stunned or RH 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}) {
     /call Check_Behind
     /varset behindTarget ${Macro.Return} 
     /if (${Target.ID} && ${behindTarget}) {
       /attack on
	 /pet attack
       /echo ** Attack re-started (No Enrage Risk): ${Target.CleanName}
     }  
   }

   |- Stop fighting if we lose our target
   /if (${Me.Combat} && !${Target.ID}) /attack off 

   |- Are we suposed to stick to a target? (Don't if we're tanking!) 
   /if ((${Me.Combat} || ${strikeReady}) && ${Target.ID} && ${doStick} && ${Target.Type.Equal[NPC]} && !${aggrotimer.Value} && !${Me.TargetOfTarget.Name.Equal[${Me}]}) { 

     /if (${Target.ID}) /face ${If[${Me.Swimming},,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 
         /echo 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 
         } 
         /echo 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, lets try to get behind it a little bit at a time 

     /if (${Target.Distance}<=${Target.MaxRangeTo}) { 
        
       /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 quarter-second strafe in the correct direction 
         /keypress ${strafedir} hold 
         /delay 3 
         /keypress ${strafedir} 
         /if (${Target.ID}) /face fast ${If[${Me.Swimming},,nolook]} 
         |- Check if we're stuck and warn if so (go through target to fix it)
         /if ((${Me.X}==${X}) && (${Me.Y}==${Y})) { 
           /echo We're STUCK trying to get behind target!
           /delay 1s
         } 
       } 
     } 
   } 

   |- 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]}) {
       /echo ** Beneficial proc-weapon swapping...
       /call Weapon_Swap "${weapon1}" "${weapon2}"
     }
   }

    |- Are we fighting? 

    /if (${Me.Combat}) { 
     |- ** We are fighting ** 

     |- Respond to enraged targets
     /if (${isEnraged} && ${Target.ID}) {
       /call Check_Behind
       /varset behindTarget ${Macro.Return} 
       /if (${Target.ID} && !${behindTarget}) {
         /attack off
         /echo ** 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 tank(s) health/presence, update main assist as needed
     /if (${doAutoassist} && (!${Spawn[${mainassist}].ID} || !${mainassist.Equal[${firstassist}]})) {
       /if (${Spawn[${firstassist}].ID}) {
         /varset mainassist ${firstassist}
         /echo ** Main assist *SWITCHED* to: ${mainassist}
       } else /if (${Spawn[${secondassist}].ID}) {
         /varset mainassist ${secondassist}
         /echo ** Main assist *SWITCHED* to: ${mainassist}
       } else /if (${Spawn[${thirdassist}].ID}) {
         /varset mainassist ${thirdassist}
         /echo ** Main assist *SWITCHED* to: ${mainassist}
       } else {
         |- Uh oh, all set tanks are dead, zoned or otherwise missing
         /varset doAutoassist FALSE 
         /echo ** All assists are dead or missing!
         /echo ** Autoassist is now OFF! 
         /if (!${leashholder.Equal[Nobody]) /tell ${leashholder} ACK! All tanks are dead or missing!
       }
     }

     |- 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}) {
       /echo --> *SWITCH* target to: ${Target.CleanName}
       /varset oldtargetID ${Target.ID}
       /attack off
	 /pet back off
       /delay 2
       /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})) {
         /echo CHOKE! We're at the leash's length! (${leashlength} ft.) 
         /face ${If[${Me.Swimming},,nolook]} loc ${stakeY},${stakeX} 
         /keypress forward hold 
         /delay 1s ${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]}<10 
         /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})) {
         /echo CHOKE! Tugging on ${leashholder}'s leash! (${leashlength} ft.) 
         /squelch /face ${If[${Me.Swimming},,nolook]} id ${Spawn[${leashholder}].ID}
         /keypress forward hold 
         /delay 1s ${Spawn[${leashholder}].Distance}<10 
         /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}) {
         /echo ** Master DEAD or ZONED! Leash is BROKEN! 
         /varset doLeash FALSE
         /varset leashholder Nobody
         /ini "RHSettings.ini" "General" "Leashing" "${doLeash}" 
         /ini "RHSettings.ini" "General" "LeashHolder" "${leashholder}" 
         /goto :Foreverloop
       }
     } 

     |- Are we standing, have a target, have backstab ready and can we stick it in the back? 

     /call Check_Behind
     /varset behindTarget ${Macro.Return} 
     /if (${Target.ID} && ${Me.Standing} && ${behindTarget}) { 
       /if (${Me.AbilityReady["Backstab"]}) { 
         /doability "Backstab" 
         /echo Backstabbing: ${Target.CleanName} 
       } 
     } 

     |- Are we tanking?  If so, just stab it in the face if we can! 

     /if (${Target.ID} && ${Me.Standing} && (${aggrotimer.Value} || ${Me.TargetOfTarget.Name.Equal[${Me}]})) { 
       /if (${Me.AbilityReady["Backstab"]} && ${InvSlot[mainhand].Item.Type.Equal[Piercing]}) { 
         /doability "Backstab" 
         /echo Tanking -> Facestabbing: ${Target.CleanName} 
       } 
     } 

     |- Can we evade?  Should we?

     /if (${doEvade} && ${Target.ID} && ${Me.AbilityReady["Hide"]} && (!${Me.Moving} || ${Me.AltAbilityReady[Nimble Evasion]})) { 
       /echo Evading ${Target.CleanName}
       /attack off 
       /delay 1 
       /doability "Hide" 
       /attack on 
     } 

     |- What's it got in it's pocketses?

     /if (${doPick} && ${Target.ID} && (${Target.Distance}<15) && ${Me.AbilityReady["Pick Pockets"]}) {
       /echo Pick-pocketing ${Target.CleanName}
       /attack off
       /delay 1
       /doability "Pick Pockets"
       /attack on
       /delay 1
       /if (${Cursor.ID}) /autoinv     
     }

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

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

    } else { 
     |- ** We are not fighting

     |- If we're not hiding or moving, check clicky maintained spells
     /if (${Me.Invis} || ${Me.Moving} || ${clicktimer}) /goto :DoneItemChecks
     /varset i 1
     :ItemCheckLoop
     /varset ialias ${Ini[RHItems.ini].Arg[${i},|]}
     /if (${ialias.NotEqual[NULL]}) {
       |- Obtained an itemalias from the RHItems.ini file
       |- We supposed to keep this spell up?
       /if (${Ini[RHItems.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[RHItems.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[RHItems.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

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

     /if (${doHideSneak} && ${Me.AbilityReady["Sneak"]} && !${Me.Casting.ID} && ${Me.State.NotEqual[BIND]} && !${Window[TradeWnd].Open} && !${Window[MerchantWnd].Open} && !${Window[BigBankWnd].Open}) /doability "Sneak" 
     /if (${doHideSneak} && ${Me.AbilityReady["Hide"]} && !${Me.Casting.ID} && (!${Me.Moving} || ${Me.AltAbilityReady[Nimble Evasion]}) && ${Me.State.NotEqual[BIND]} && !${Window[TradeWnd].Open} && !${Window[MerchantWnd].Open} && !${Window[BigBankWnd].Open}) /doability "Hide" 

     |- It's possible we're poised for a Strike, check and fight if so 

     /call Check_Behind
     /varset behindTarget ${Macro.Return} 
     /if (${Target.ID} && ${Me.Standing} && ${behindTarget}) { 
       /if (${strikeReady} && ${Me.AbilityReady["Backstab"]}) { 
         /doability "Backstab" 
         /echo Executing a strike: ${Target.CleanName} 
         /varset strikeReady FALSE 
         /attack on 
       } 
     } 

     |- It's also possible we never got behind a target and strike expired! 

     /if (${strikeReady} && ${Target.ID} && !${strikeTimer.Value} && ${Target.Type.Equal[NPC]}) { 
       /echo Didn't find the back of a target in 30 seconds! 
       /varset strikeReady FALSE 
       /attack on 
     } 

     |- If we're set to autoassist, lets monitor the main tank's target 
     /if (${doAutoassist} && !${isEnraged}) { 
       |- Is main assist alive/in-zone? 
       /if (${Spawn[pc ${mainassist}].ID} && !${assisttimer}) { 
         |- Main tank is alive 
         /assist ${mainassist} 
         /varset oldtargetID ${Target.ID}
         /varset assisttimer 1s
         |- Do we have an NPC targeted and is it hurt enough to attack? 
         /if (${Target.ID} && ${Target.Type.Equal[NPC]} && (${Target.PctHPs}<=${assistpct})) { 
           /echo --> Assisting ${mainassist} on ${Target.CleanName} @ (${Target.PctHPs}%) HPs 
	     /pet attack
           /echo Seeking a Victim... 
           /goto :Foreverloop      
         } 
       } 
     } 

     |- We could be on a leash, if so move 1s closer to our stake point (or master)
     /if (${doLeash} && !${strikeReady}) { 
       /if (${leashholder.Equal[Nobody]} && (${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]}>10)) {
         /echo Moving closer to the Stake... ${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]} ft. away 
         /face ${If[${Me.Swimming},,nolook]} loc ${stakeY},${stakeX} 
         /keypress forward hold 
         /delay 1s ${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]}<10 
         /keypress forward 
         /if (${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]}<10) {
           /echo Arrived near the Stake. 
           /face fast ${If[${Me.Swimming},,nolook]} away loc ${stakeY},${stakeX}
         }
       }
       /if (!${leashholder.Equal[Nobody]} && ${Spawn[${leashholder}].ID} && (${Spawn[${leashholder}].Distance}>10)) {
         /echo 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.Swimming},,nolook]}
         /keypress forward hold 
         /delay 1s ${Spawn[${leashholder}].Distance}<10  
         /keypress forward 
         /if (${Spawn[${leashholder}].Distance}<10) /echo Arrived near Master (${leashholder}). 
       }
       |- Broken leash check
       /if (!${leashholder.Equal[Nobody]} && !${Spawn[${leashholder}].ID}) {
         /echo ** Master DEAD or ZONED! Leash is BROKEN! 
         /varset doLeash FALSE
         /varset leashholder Nobody
         /ini "RHSettings.ini" "General" "Leashing" "${doLeash}" 
         /ini "RHSettings.ini" "General" "LeashHolder" "${leashholder}" 
       }
     } 
   } 

  /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}
  /echo ** 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
    /echo ** Swapping out: ${weapon}
    /itemnotify ${InvSlot[${camefrom}]} leftmouseup
    /delay 2
    /if (${Cursor.ID}) {
      /echo ** 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
      /echo ** Swapping out: ${weapon}
      /itemnotify ${InvSlot[${camefrom}]} leftmouseup
      /delay 2
      /if (${Cursor.ID}) {
        /echo ** Failed to use existing slot, dropping to inventory!
        /autoinv
      }
    } else {
      /echo ** "${weapon}" not found!
    }
  }
/return

|---- EVENTS

Sub Event_StrikeVic 
  /varset lastevent Event_StrikeVic 
  |- Is strike disc available, are we hiding/sneaking and do we have enough endurance to use it? 
  /if ((${Me.Invis} && ${Me.PctEndurance}>=${MinEndurance}) && !${strikeTimer.Value}) { 
    /echo Taking careful aim: ${Target.CleanName} 
    /varset strikeTimer 30s 
    /disc ${StrikeSkill} 
    /varset strikeReady TRUE 
  } else { 
    |- Guess not, just attack normally then 
    /attack on 
    /varset strikeReady FALSE 
  } 
/return 

Sub Event_AttackOn 
  /varset lastevent Event_AttackOn
  /echo Autoattack activated! Target: ${Target.CleanName}
/return 

Sub Event_AttackOff 
  /varset lastevent Event_AttackOff
  /echo Autoattack turned off! Target: ${Target.CleanName} 
/return 

Sub Event_Enraged 
  /varset lastevent Event_Enraged
  /echo Enrage detected! Target: ${Target.CleanName} 
  /echo Backing off Pet!
  /pet back off
  /varset isEnraged TRUE 
/return 

Sub Event_NLEnraged 
  /varset lastevent Event_NLEnraged
  /echo Enrage done! Target: ${Target.CleanName} 
  /varset isEnraged FALSE 
  /if (${Target.ID} && ${doAutoassist}) /attack on 
  /pet attack

/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
      /echo ** Had Aggro! Reducing assist% to ${assistpct}%
    } else {
      |- Did not get hurt that fight, raise it 1%
      /if (${assistpct}<99) /varcalc assistpct ${assistpct}+1
      /echo ** No Aggro! Raising assist% to ${assistpct}%
    }
  }

  |- Experience calculation and reporting
  /echo ** 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}"
  } 

  |- 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}) { 
      /echo ** NPC corpse out of range or already looted! 
      /return
    }   
    |- Get 5 seconds (max) closer; warning, no detecting being stuck!
    /face ${If[${Me.Swimming},,nolook]} fast
    /keypress forward hold 
    /delay 5s ${Target.Distance}<5 
    /keypress forward 
    |- Open up the loot window
    /loot 
    /delay 1s
    /if (${Me.State.NotEqual[BIND]}) {
      /echo ** Massive lag or error getting to corpse.  Aborting!
      /return
    }
    /echo ** Looting ${Target.CleanName}  
    |- Get item count accurately  
    :LootLag 
    /if (${LootTotal}!=${Corpse.Items}) { 
      /varset LootTotal ${Corpse.Items} 
      /delay 5 
      /goto :LootLag 
    } 
    /if (!${LootTotal}) {
      /echo ** Empty corpse!
      /goto :DoneLooting
    }
    |- Loot Loop
    /for LootSlot 1 to ${LootTotal} 
      |- Check for full inventory
      /if (!${Me.FreeInventory}) {
        /beep
        /echo ** INVENTORY FULL !
        /varset ninjamode OFF
        /echo ** 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]}) {
          /echo ** Looting NODROP Item: ${Corpse.Item[${LootSlot}].Name}
          /goto :LootItem
        }
      }
      /echo ** 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
    /echo ** Done looting ${Target.CleanName}
    :DoneLooting
    /delay 5
    /notify LootWnd DoneButton leftmouseup 
    /delay 5
  }
/return 

Sub Event_Zoned
  /varset lastevent Event_Zoned
  /echo ** Zoned... Setting Leash and Autoassist to OFF!
  /varset doLeash FALSE
  /varset doAutoassist FALSE
  /ini "RHSettings.ini" "General" "AutoAssist" "${doAutoassist}"
  /ini "RHSettings.ini" "General" "Leashing" "${doLeash}" 
/return 

Sub Event_TogEvade
  /varset lastevent Event_TogEvade
  /if (${doEvade}) { 
    /varset doEvade FALSE 
    /echo ** Auto-Evading target is now OFF! 
  } else { 
    /varset doEvade TRUE 
    /echo ** Auto-Evading target is now ON! 
  } 
  /ini "RHSettings.ini" "General" "AutoEvade" "${doEvade}"
/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)) {
    /echo Whacko stopfighting percentage input! Defaulting...
  }
  /echo ** Cease Combat when at: ${StopFightingHealth}% HP 
  /ini "RHSettings.ini" "General" "StopFightingHealth" "${StopFightingHealth}"
/return

Sub Event_SetStrikeDisc(string Line)
  /varset lastevent Event_SetStrikeDisc
  /if (${Line.Arg[3].Length}) /varset StrikeSkill ${Line.Arg[3]}
  /echo ** Strike Discipline set to: "${StrikeSkill}"
  /ini "RHSettings.ini" "General" "StrikeSkill" "${StrikeSkill}"
/return

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

Sub Event_TogStick 
  /varset lastevent Event_TogStick
  /if (${doStick}) { 
    /varset doStick FALSE 
    /echo ** Auto-Sticking target is now OFF! 
  } else { 
    /varset doStick TRUE 
    /echo ** Auto-Sticking target is now ON! 
  } 
  /ini "RHSettings.ini" "General" "AutoStick" "${doStick}"
/return 

Sub Event_TogHS 
  /varset lastevent Event_TogHS
  /if (${doHideSneak}) { 
    /varset doHideSneak FALSE 
    /echo ** Auto-Hiding & Sneaking is now OFF! 
  } else { 
    /varset doHideSneak TRUE 
    /echo ** Auto-Hiding & Sneaking is now ON! 
  } 
  /ini "RHSettings.ini" "General" "AutoHideSneak" "${doHideSneak}"
/return 

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

Sub Event_TogAuto(string Line) 
  /varset lastevent Event_TogAuto
  /if (${Line.Arg[3].Equal[OFF]}) { 
    /varset doAutoassist FALSE 
    /echo ** Autoassist is now OFF! 
  } else /if (${Line.Arg[3].Equal[ON]}) {
    /varset doAutoassist TRUE 
    /echo ** 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]} 
    /echo ** Autoassist is now ON! 
    /echo ** Assisting: ${mainassist} @${assistpct}% target health 
    /echo ** SA is ${secondassist} & TA is ${thirdassist}
  } 
  /ini "RHSettings.ini" "General" "AutoAssist" "${doAutoassist}"
  /ini "RHSettings.ini" "General" "MainAssist" "${firstassist}"
  /ini "RHSettings.ini" "General" "AssistPercentage" "${assistpct}"
/return 

Sub Event_TogPause 
  /varset lastevent Event_TogPause
  /beep
  /if (${isPaused}) { 
    /varset isPaused FALSE 
    /echo ** Rogue Helper is now RESUMING! 
  } else { 
    /varset isPaused TRUE 
    /echo ** Rogue Helper is now PAUSED!
  } 
/return 

Sub Event_TogPick
  /varset lastevent Event_TogPick
  /if (${doPick}) { 
    /varset doPick FALSE 
    /echo ** Auto-Pickpocketing is now OFF! 
  } else { 
    /varset doPick TRUE 
    /echo ** Auto-Pickpocketing is now ON! 
  } 
  /ini "RHSettings.ini" "General" "AutoPickPocket" "${doPick}"
/return 

Sub Event_TogTSwitch 
  /varset lastevent Event_TogTSwitch
  /if (${doTSwitch}) { 
    /varset doTSwitch FALSE 
    /echo ** Auto-Target Switching is now OFF! 
  } else { 
    /varset doTSwitch TRUE 
    /echo ** Auto-Target Switching is now ON! 
  } 
  /ini "RHSettings.ini" "General" "AutoTargetSwitch" "${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)) {
    /echo Whacko closeness percentage input! Defaulting...
  }
  /echo ** AutoStick: ${doStick}, Closeness: ${closeness}
  /ini "RHSettings.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}
  /echo ** Assisting: ${mainassist} @${assistpct}% target health 
  /echo ** SA is ${secondassist} & TA is ${thirdassist}
  /ini "RHSettings.ini" "General" "MainAssist" "${firstassist}"
/return

Sub Event_SetSecondassist(string Line)
  /varset lastevent Event_SetSecondassist
  /if (${Line.Arg[3].Length}) /varset secondassist ${Line.Arg[3]}
  /echo ** Assisting: ${mainassist} @${assistpct}% target health 
  /echo ** SA is ${secondassist} & TA is ${thirdassist}
  /ini "RHSettings.ini" "General" "SecondAssist" "${secondassist}"
/return

Sub Event_SetThirdassist(string Line)
  /varset lastevent Event_SetThirdassist
  /if (${Line.Arg[3].Length}) /varset thirdassist ${Line.Arg[3]}
  /echo ** Assisting: ${mainassist} @${assistpct}% target health 
  /echo ** SA is ${secondassist} & TA is ${thirdassist}
  /ini "RHSettings.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
    /echo ** AutoNinja ON - Will loot ALL items 
    /docommand /lootnodrop never
  } else /if ((${Line.Arg[3].Equal[DROP]}) || (${Line.Arg[3].Equal[DROPABLE]})) { 
    /varset ninjamode DROPABLE
    /echo ** AutoNinja ON - Will loot only DROPABLE items
    /docommand /lootnodrop never
  } else {
    /varset ninjamode OFF
    /echo ** AutoNinja is now OFF!
  }
  /echo ** AutoNinja distance is ${ninjadist} ft.
  /ini "RHSettings.ini" "General" "AutoNinjaMode" "${ninjamode}"
  /ini "RHSettings.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
    /echo ** 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  
  /echo ** Auto Weapon Switching is ON
  /echo ** ${weapon1} will be swapped out for ${weapon2}
  /echo ** if the text "${switchtext}" is encountered.

  :SaveSwitchSettings
  /doevents flush
  /ini "RHSettings.ini" "General" "WeaponSwitching" "${doSwitch}"
  /ini "RHSettings.ini" "Weapons" "Weapon1" "${weapon1}"
  /ini "RHSettings.ini" "Weapons" "Weapon2" "${weapon2}"
  /ini "RHSettings.ini" "Weapons" "SwitchText" "${switchtext}"
  /varset wstype ${FindItem[${weapon1}].Spell.SpellType}
/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}) /echo ** AGGRO Detected (struck) **
  /varset gotHit TRUE
  /varset aggrotimer 5s
/return 

Sub Event_GotMissed
  /varset lastevent Event_GotMissed
  /if (!${aggrotimer}) /echo ** AGGRO Detected (whiff) **
  /varset gotHit TRUE
  /varset aggrotimer 5s
/return 

Sub Event_TogDynaggro 
  /varset lastevent Event_TogDynaggro
  /if (${doDynaggro}) { 
    /varset doDynaggro FALSE 
    /echo ** Dynamic Aggro Control is now OFF! 
  } else { 
    /varset doDynaggro TRUE 
    /echo ** Dynamic Aggro Control is now ON! 
  } 
  /ini "RHSettings.ini" "General" "DynamicAggro" "${doDynaggro}"
/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) { 
    /echo ** No corpse names supplied!
    /return
  } else {
    /echo ** Target self (F1) to stop dragging!
  }
  :DragLoop 
  /for bodycount 3 to ${ArgNum} 
    /if (${Target.CleanName.Equal[${Me.Name}]}) {
      /echo ** 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}) { 
    /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
  }
  |- 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
  /echo ** 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[RHSettings.ini,General,FollowDistance].NotEqual[NULL]}) /varset distance ${Ini[RHSettings.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 "RHSettings.ini" "General" "FollowDistance" "${distance}" 
  /if (${Target.ID}) {
    /echo ** Autofollow on: ${Target.CleanName} (${distance} ft.)
    /echo ** Change targets to stop autofollowing.
  } else {
    /echo ** 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]}) {
    /echo ** Autofollow blocked by: ${lastevent}
    /goto :StopFollowing
  }
  /if (${Target.ID}==${followID}) {
    /if (${Target.ID}) /face fast
    /if (${Target.Distance}>${distance}) {
      /keypress forward hold 
      /delay 1s ${Target.Distance}<=${distance} 
      /keypress forward 
    }
    /goto :FollowingLoop
  }
  :StopFollowing
  /echo ** Autofollow ended.
/return

Sub Event_ItemSet(string Line)
  /varset lastevent Event_ItemSet
  |- Sanity check parameters
  /if (!${Line.Arg[5].Length} || ${Line.Arg[6].Length}) {
    /echo ** Improper use of /iset
    /echo -- /iset <itemalias> keepup|nokeepup <"Item Name">
    /echo -- For example:
    /echo -- /iset gobby keepup "Shrunken Goblin Skull Earring"
    /return 
  }
  /ini "RHItems.ini" "${Line.Arg[3]}" "FullName" "${Line.Arg[5]}"  
  /ini "RHItems.ini" "${Line.Arg[3]}" "KeepUp" "${If[${Line.Arg[4].Equal[keepup]},TRUE,FALSE]}"
  /echo ** ${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}) {
    /echo ** Improper use of /ibounce
    /echo -- /ibounce <itemalias> "Some Spell Name"
    /echo -- For example:
    /echo -- /ibounce gobby "Strength of Tunare"
    /return 
  }
  |- Look for that item's section, return if non-existent
  /if (!${Ini[RHItems.ini,${Line.Arg[3]}].Length}) {
    /echo ** [${Line.Arg[3]}] not in INI file!
    /return
  }

| - Continued in next post...


Posted: Wed Jun 30, 2004 8:57 pm
by zertful

Code: Select all

  |- Find the next available BounceOff key number and store the spell
  /declare bindex int local 1
  :CheckNextKey
  /if (${Ini[RHItems.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 "RHItems.ini" "${Line.Arg[3]}" "BounceOff${bindex}" "${Line.Arg[4]}"  
    /echo ** 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}) {
    /echo ** Improper use of /icast
    /echo -- /icast <itemalias>
    /echo -- For example:
    /echo -- /icast gobby
    /return 
  }
  |- Look for that item's section, return if non-existent
  /if (!${Ini[RHItems.ini,${Line.Arg[3]}].Length}) {
    /echo ** [${Line.Arg[3]}] not in INI file!
    /return
  }
  /declare fullname string local ${Ini[RHItems.ini,${Line.Arg[3]},FullName]}
  |- Is it in a Bag?
  /echo ** 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
    /echo ** 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}) {
      /echo ** Clicking: ${fullname}
      /itemnotify ${FindItem[${fullname}].InvSlot} rightmouseup
      /delay 2
    } else {
      /echo ** "${fullname}" not found!
    }
  } 
  :CastLoop 
  /delay 1 
  /if (${Me.Casting.ID}) /goto :CastLoop
/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[RHSettings.ini,Masters,Controller${index}].Equal[Nobody]}) {
        /ini "RHSettings.ini" "Masters" "Controller${index}" "${Line.Arg[3]}"
        /echo ** ${Line.Arg[3]} added as a controller...
        /goto :FallOut
      }
    /next index
    /echo ** Master controller slots all filled! Get rid of some!
  } else {
    /echo ** 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[RHSettings.ini,Masters,Controller${index}].Equal[${Line.Arg[3]}]}) {
        /ini "RHSettings.ini" "Masters" "Controller${index}" "Nobody"
        /echo ** ${Line.Arg[3]} removed from controller list...
        /goto :FallOut
      }
    /next index
    /echo ** Can't find ${Line.Arg[3]} in access list!
  } else {
    /echo ** 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[RHSettings.ini,Masters,Controller${i}].Equal[${Sender}]}) /varset authorized TRUE
  /next i
  /if (${authorized} && ${ChatText.Left[1].Equal[/]}) {
    /echo ** User ${Sender} Authenticated!
    /echo Action --> "${ChatText}"
    /if (${Me.AFK}) /delay 2s
    /tell ${Sender} Command received, performing: ${ChatText}
    /docommand ${ChatText}
  }
/return 

Sub Event_HelpInfo 
  /varset lastevent Event_HelpInfo
  /echo --------=========(RH Help)=========---------- 
  /echo /rhhelp - Display this information!
  /echo /status - Display status of all RH modes
  /echo /pause - Suspends the operations of RH
  /echo /autoevade - Toggle autoevading on or off
  /echo /stopfight <%> - Set % of your health to stop attacking
  /echo /strikedisc <StrikeSkill> - Set to your best strike skill
  /echo /endfloor <%> - Set % of your endurance needed to strike
  /echo /autostick - Toggle autosticking to NPCs while attacking
  /echo /autohs - Toggle automatic hiding/sneaking while not fighting
  /echo /closeness <%> - Set % of max hit range while autosticking
  /echo /autoassist <main_assist> <%health> - Activate autoassist
  /echo /autoassist off - Disable autoassisting
  /echo /autoassist on - Turn on autoassist w/existing tank info
  /echo /mainassist <player> - Sets main assist to <player>
  /echo /secondassist <player> - Sets secondary assist to <player>
  /echo /thirdassist <player> - Sets third assist to <player>
  /echo /dynaggro - Toggle dynamic management of assist health %
  /echo /leash <distance> - Activate leash with <distance> ft.
  /echo /leash <distance> <master> - Activate leash w/a master
  /echo /leash off - Disable leashing
  /echo /drag <body1> <body2> ... <bodyN> - Drag corpses
  /echo /lootmycorpse - Loot your own corpse completely
  /echo /iset <itemalias> keepup|nokeepup <"Item Name"> - Item settings
  /echo /ibounce <itemalias> <"Spell Name"> - Add bounce-off spell
  /echo /iclick <itemalias> - Click cast item defined in <itemalias>
  /echo /autoninja <mode> [<range>] - Automatic NPC corpse looting
  /echo /autofollow [<name>] [<distance>] - Follow <name> at <distance>
  /echo /autopick - Toggle pick-pocketing during combat on or off
  /echo /weaponswitch <weapon1> <"switch text"> <weapon2> - weapon swap
  /echo /targetswitch - Toggle autoswitching of targets in autoassist
  /echo /addmaster <name> - Add a master to remote control users
  /echo /remmaster <name> - Remove a master from remote control users
/return

Sub Event_StatInfo 
  /varset lastevent Event_StatInfo
  /echo ** Auto Evade: ${doEvade}, Cease Combat: ${StopFightingHealth}% HP 
  /echo ** Auto Stick: ${doStick}, Closeness: ${closeness}% MaxRange
  /echo ** Auto Hide&Sneak: ${doHideSneak}, Auto Pickpocket: ${doPick}
  /echo ** Auto Ninja: ${ninjamode}, Distance: ${ninjadist} ft.
  /echo ** Auto TargetSwitching: ${doTSwitch}
  /echo ** Auto Assist: ${doAutoassist}, Assist at ${assistpct}% HP 
  /echo ** MA: ${firstassist}, SA: ${secondassist}, TA: ${thirdassist}
  /echo ** Leashing: ${doLeash} (${leashlength} ft.), Master: ${leashholder}
  /echo ** Strike Skill: "${StrikeSkill}", End. Floor: ${MinEndurance}% END 
  /echo ** Dynamic Aggro Control: ${doDynaggro}
  /echo ** WeaponSwitching: ${doSwitch}, ${weapon1}->${weapon2} (${switchtext})
  /echo ** Authorized remote controllers:
  /for i 1 to 20
    /if (${Ini[RHSettings.ini,Masters,Controller${i}].NotEqual[Nobody]}) /echo ---- ${Ini[RHSettings.ini,Masters,Controller${i}]} allowed...
  /next i
  /doevents flush
/return

Sub Event_SpellCast
   /echo Casting...
   :checkcast
   /delay 1
   /if (${Me.Casting.ID}) /goto :checkcast
/return

Sub Event_FEROC 
/keypress tab 
/call Cast "Ferocity" 
/keypress tab 
/return 

Sub Event_DOMIN 
/call Cast "Spiritual Purity" 
/return 

Sub Event_SV 
/call Cast "Spiritual Vigor" 
/return 

Sub Event_IOS 
/keypress tab 
/call Cast "Infusion of Spirit" 
/keypress tab 
/return 

Sub Event_STR 
/keypress tab 
/call Cast "Furious Strength" 
/keypress tab 
/return 

Sub Event_TALIS 
/keypress tab 
/call Cast "Talisman of Kragg" 
/keypress tab 
/return 

Sub Event_FREN 
/call Cast "Frenzy" 
/return 

Sub Event_STA 
/keypress tab 
/call Cast "Stamina" 
/keypress tab 
/return 

Sub Event_DEX 
/keypress tab 
/call Cast "Dexterity" 
/keypress tab 
/return 

Sub Event_HASTE 
/keypress tab 
/call Cast "Celerity" 
/keypress tab 
/return 

Sub Event_PETH
/call cast "Arag's Celerity"
/return

Sub Event_PETH
/call cast "Spirit of Rellic"
/return

Sub Event_SLOW
/gsay %T has been SLOWED 55% (Proc)
/return

Posted: Thu Jul 01, 2004 5:57 am
by blueninja
This should make it only announce slows once. It would still pick up the slow message if another bst procs before you, but there really is no way to know who procced it I believe since procs only give one message (or am I remembering this wrong?). The same problem would still exist for a player so it shouldn't matter.

Also, if you switch to a second mob, then go back to the first you will announce next proc to that mob again.This could be avoided by making a short array of the last few mobs to check against instead of just a single variable.

Code: Select all

| This declare should be in Sub Main somewhere
/declare LastSlowedMob int outer

.....

Sub Event_SLOW 
/if (${Target.ID} && ${Target.ID}!=${LastSlowedMob}) {
    /varset LastSlowedMob ${Target.ID}
    /gsay %T has been SLOWED 55% (Proc) 
}
/return 

Posted: Thu Jul 01, 2004 3:52 pm
by zertful
Thanks I'll try that out tonight when I get home... :cool: If it works out ok I'll add it to the code above. Gotta get back to work...


Zertful

Posted: Thu Jul 01, 2004 5:25 pm
by Drumstix42
Careful how the BBcode shows it. At a quick glance I noticed:

#Event SpellCast "#*#You begin casting#*#"#Event FEROC "#*#The ferocity fades.#*#"


All on one line.

Posted: Wed Jul 07, 2004 3:37 pm
by wolf5
Feel free to cannibalize/use some of my code on the Natural Beast Hunter. I have Subs there that buffs up either you or your pet.

http://halsvik.net/d/?/public/nbh.mac
Sub MaintainPetBuffs
and
Sub MaintainSelfBuffs

The buff arrays are declared in Sub Main.

-Wolf5

Posted: Mon Jul 19, 2004 2:41 pm
by Jerle69
Just dropped by this thread to say "HI." If you need a little help adapting something, you can PM me via MQ2 (quite a few do). I've written some other macros for my wife's cleric and my enchanter, but I'm afraid they're too cosmic (Lax and the whole community would come down on my ears for releasing them).

For example, the enchanter helper macro can crowdcontrol as good as anyone (hehe, it has some rulesets in an INI) and I got a cleric helper macro that kicks in in a clutch to heal your group if you fell asleep or aren't paying attention (also rule-based). They're about the same responsiveness and comprehensiveness as RH, but for those respective classes.

Anyway, let me know if you need a bit of help. I wrote my own spellcasting engine similar to the spellcast.inc, but tuned for respective classes, so I can prolly help you through a hurdle or two.