Auto monk code, small problem

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

mcdebug
a lesser mummy
a lesser mummy
Posts: 30
Joined: Mon Jun 07, 2004 4:24 am

Auto monk code, small problem

Post by mcdebug » Tue Jun 22, 2004 10:14 am

i recently started converting Jerle's rogue helper to work for a monk. It wasnt hard converting it to flying kick all the time. I also made it so when the monk arrived at its anchor, whether it be a character or a loc, he fd'd. Today i started working on a variable doFD and implemented all the necessary code but for some reason it freezes my eq window when it gets to ** Auto Feign: FALSE or it could say true i forget. but either way heres the code and if you can see what i did wrong i would love some help. Im really new to this macro stuff, thanks in advance 8)




EDIT: i guess it would be good if i added the code :P and also, it still uses the RH files.

Code: Select all


|--------------------------------------------------------------------------------- 
| 
| MH Syntax: 
| 
| Usage: /mac mh 
| 
| Default settings can be changed by their respective controlling /command 
| 
| Type /mhhelp 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 SpellBounced    "#*#Your spell did not take hold#*#" 
#Event SwitchWeapon    "#*#|${switchtext}|#*#" 
#Event TogFD           "[MQ2] AutoFD#*#"  
#Event TogStick        "[MQ2] Autostick#*#"  
#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 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] MH Help#*#" 
#Event StatInfo        "[MQ2] -------=======(Current Status)=======--------" 

Sub Main 

  /echo Loading Monk Helper... Please Wait! 

  
  /declare doFD 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 

  /squelch /alias /status /echo -------=======(Current Status)=======-------- 
  /squelch /alias /nhhelp /echo MH Help  
  /squelch /alias /autopick /echo Autopick 
  /squelch /alias /stopfight /echo SetStopFighting  
  /squelch /alias /endfloor /echo SetEndFloor 
  /squelch /alias /autostick /echo Autostick 
  /squelch /alias /autohs /echo Auto Hide & Sneak 
  /squelch /alias /leash /echo Leash 
  /squelch /alias /fd /echo FD
  /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,StopFightingHealth].NotEqual[NULL]}) /varset StopFightingHealth ${Ini[RHSettings.ini,General,StopFightingHealth]} 
  /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,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,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 Xeb's Monk Helper Derived from Jerle's RH (v5.2) Starting... 
  /echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 
  /echo Use "/mhhelp" 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... 

   |- Are we suposed to stick to a target? (Don't if we're tanking!) 
   /if (${Me.Combat} && ${Target.ID} && ${doStick} && ${Target.Type.Equal[NPC]} && !${aggrotimer.Value} && !${Me.TargetOfTarget.Name.Equal[${Me}]}) {
     /if (!${Me.Standing}) /stand
     /if (${Target.ID}) /face 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 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 ** 

     |- 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 (2 second checks) 
     /if (${doTSwitch} && ${doAutoassist} && ${Target.ID} && !${assisttimer}) { 
       /varset oldtargetID ${Target.ID} 
       /assist ${mainassist} 
       /varset assisttimer 2s 
     } 

     |- 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 
       /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.) 
		 /stand
         /face 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 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["Flying Kick"]}) { 
         /doability "Flying Kick" 
         /echo Kicking the fuck out ${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["Flying Kick"]}) { 
         /doability "Flying Kick" 
         /echo Tanking -> Putting my foot in: ${Target.CleanName} 's mouth! 
       } 
     } 

     

     |- 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 
	 /if (${Me.Standing} && !${Me.Moving} && ${doFD[TRUE]}) {
		/if (${Me.AbilityReady["Feign Death"]} && !${Target.Type.Equal[NPC]}) {
				/doability "Feign Death"
		} 
	}
     /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 

     
     

     

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

     /if (${doLeash}) { 
       /if (${leashholder.Equal[Nobody]} && (${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]}>20)) { 
         /if (!${Me.Standing}) /stand
		 /echo Moving closer to the Stake... ${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]} ft. away 
         /face nolook loc ${stakeY},${stakeX} 
         /keypress forward hold 
         /delay 1s ${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]}<20 
         /keypress forward 
         /if (${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]}<20) { 
           /echo Arrived near the Stake, Flopping. 
			/if (${Me.AbilityReady["Feign Death"]} && ${doFD[TRUE]}) {
				/doability "Feign Death"
			} 
           /face fast nolook away loc ${stakeY},${stakeX} 
         } 

       } 
       /if (!${leashholder.Equal[Nobody]} && ${Spawn[${leashholder}].ID} && (${Spawn[${leashholder}].Distance}>21)) { 
		 
		 /echo Moving closer to ${leashholder}... ${Spawn[${leashholder}].Distance} ft. away 
         /if (${Target.ID}!=${Spawn[${leashholder}].ID}) /target id ${Spawn[${leashholder}].ID} 
		 /if (!${Me.Standing}) /stand 
         /if (${Me.Combat}) /attack off 
         /face nolook 
         /keypress forward hold 
         /delay 1s ${Spawn[${leashholder}].Distance}<20
         /keypress forward 
         /if (${Spawn[${leashholder}].Distance}<20) { 
				/echo Arrived near Master (${leashholder}) , Flopping. 
				/if (${Me.AbilityReady["Feign Death"]} && ${doFD[TRUE]}) {
					/doability "Feign Death"
					}   
			}
	   } 
       |- 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}" 
       } 
     } 

     |- 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 2s 
         |- 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 
           /echo Seeking a Victim...        
         } 
       } 
     } 
   } 

  /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 
  |- 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 
  /echo Autoattack activated! Target: ${Target.CleanName} 
/return 

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

Sub Event_Enraged 
  /echo Enrage detected! Target: ${Target.CleanName} 
  /varset isEnraged TRUE 
  /attack off 
/return 

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

Sub Event_Exp(string Line) 
  |- 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 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 
  /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       
  /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_TogFD
  /if ($[doFD}) {
	/varset doFD TRUE
	/echo ** Auto-FDing is now ON!
  } else {
    /varset doFD FALSE 
	/echo ** Auto-FDing is now OFF!
  }
  /ini "RHSettings.ini" "General" "AutoFD" "${doFD}"
/return

Sub Event_SetStopFighting(string Line) 
  /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) 
  /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) 
  /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 
  /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 
  /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) 
  /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) 
  /if (${Line.Arg[3].Equal[OFF]}) { 
    /varset doAutoassist FALSE 
    /echo ** Autoassist is now OFF! 
  } 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 
  /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 
  /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 
  /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) 
  /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) 
  /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) 
  /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) 
  /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) 
  |- 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) 
  |- 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 
  /if (${doSwitch}) { 
    /call Weapon_Swap "${weapon2}" "${weapon1}" 
  } 
/return 

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

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

Sub Event_SpellBounced 
  /varset clicktimer 60s 
  /beep 
  /beep 
  /beep 
  /echo ** Just detected a BOUNCED spell! 
  /echo ** Use /ibounce to update click-item info! 
/return 

Sub 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) 
  /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 
  |- 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) 
  /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 
  /if (!${Me.Standing})  /stand
  /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 
  } 
	/goto :FollowingLoop	
	}
  /echo ** Autofollow ended. 
/return 

Sub Event_ItemSet(string Line) 
  |- 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) 
  |- 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 
  } 
  |- 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) 
  |- 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) 
  /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) 
  /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) 
  |- 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 
  /echo --------=========(MH Help)=========---------- 
  /echo /rhhelp - Display this information! 
  /echo /status - Display status of all RH modes 
  /echo /pause - Suspends the operations of MH 
  /echo /autoFD - Toggle FDing when arriving at anchor 
  /echo /stopfight <%> - Set % of your health to stop attacking 
  /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 /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  
  /echo ** Auto Stick: ${doStick}, Closeness: ${closeness}% MaxRange  
  /echo ** Auto Ninja: ${ninjamode}, Distance: ${ninjadist} ft. 
  /echo ** Auto TargetSwitching: ${doTSwitch} 
  /echo ** Auto Feigning: ${doFD}
  /echo ** Auto Assist: ${doAutoassist}, Assist at ${assistpct}% HP 
  /echo ** MA: ${firstassist}, SA: ${secondassist}, TA: ${thirdassist} 
  /echo ** Leashing: ${doLeash} (${leashlength} ft.), Master: ${leashholder}  
  /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 

see what ya come up with 8)
Last edited by mcdebug on Tue Jun 22, 2004 7:00 pm, edited 1 time in total.

mcdebug
a lesser mummy
a lesser mummy
Posts: 30
Joined: Mon Jun 07, 2004 4:24 am

Post by mcdebug » Tue Jun 22, 2004 3:42 pm

man this is kinda makin me mad, i cant find the problem. can someone at least tell me how to monitor this and go through it line by line? its makin me go insane :shock: :x :evil:

Programmer
a hill giant
a hill giant
Posts: 195
Joined: Mon Dec 01, 2003 2:41 am

Post by Programmer » Tue Jun 22, 2004 4:25 pm

There is no way to singlestep lines in a debugger-like environment. You do however have 2 tools at your disposal. The first is /echo, allowing you to utilize the worlds most commonly-used debugging technique (printf). The second, the command /mqpause (or is it /mq2pause? something along these lines; check the docs) will halt your macro until you allow it to continue.

Using these techniques requires you to instrument your code, making it somewhat a pain, but its better than scratching your head. Unless you like baldness (and can't afford a razor).

mcdebug
a lesser mummy
a lesser mummy
Posts: 30
Joined: Mon Jun 07, 2004 4:24 am

Post by mcdebug » Tue Jun 22, 2004 7:03 pm

awesome thanks programmer. helped alot i found out where its haning up at, but i still dont see a problem with this line, people probably didnt take a look at the code cus the problem was like finding a needle in a haystack but ive isolated it now. the problem lies in this line

Code: Select all

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

because i put a pause right before it and right after it, and narrowed it down to it. i still dont see whats wrong with it though . any ideas?

mcdebug
a lesser mummy
a lesser mummy
Posts: 30
Joined: Mon Jun 07, 2004 4:24 am

Post by mcdebug » Tue Jun 22, 2004 7:20 pm

what the heck is wrong with this thing, it hung up on this :

Code: Select all

|- Are we suposed to stick to a target? (Don't if we're tanking!) 
   
   /if (${Target.ID}) {
   /mqpause
		/if (${Me.Combat}) { 
		
			/if (${doStick}) {

				/if (${Target.Type.Equal[NPC]}) {

					/if (!${aggrotimer.Value}) {

						/if (!${Me.TargetOfTarget.Name.Equal[${Me}]}) { 
							
							/if (!${Me.Standing}) /stand
						
							/if (${Target.ID}) /face nolook 
and on this :

Code: Select all

|- Are we suposed to stick to a target? (Don't if we're tanking!) 
   
   /if (${Me.Combat}) { 
   /mqpause
		/if (${Target.ID}) {
		
			/if (${doStick}) {

				/if (${Target.Type.Equal[NPC]}) {

					/if (!${aggrotimer.Value}) {

						/if (!${Me.TargetOfTarget.Name.Equal[${Me}]}) { 

so what the heck, is it a problem with the /if statements or something?

creations
orc pawn
orc pawn
Posts: 10
Joined: Thu May 06, 2004 1:57 am

Post by creations » Tue Jun 22, 2004 7:28 pm

wish I knew more about macros so I could give ya a hand with it. I've been hoping someone would take the time to do something like this for monks.

goodluck with it and please post it once you're done =P

User avatar
ieatacid
Developer
Developer
Posts: 2727
Joined: Wed Sep 03, 2003 7:44 pm

Post by ieatacid » Tue Jun 22, 2004 8:28 pm

Me.TargetOfTarget only works if the group leader skill is active.

Maybe that's why.

mcdebug
a lesser mummy
a lesser mummy
Posts: 30
Joined: Mon Jun 07, 2004 4:24 am

Post by mcdebug » Tue Jun 22, 2004 10:01 pm

hmmm thats actually part of the code that previously worked in the macro. and i dont necessarily think that someone with mq would need someone in thier group with the leader ability, if the information is available to the client i assume mq can access it. this really is an odd case.

mcdebug
a lesser mummy
a lesser mummy
Posts: 30
Joined: Mon Jun 07, 2004 4:24 am

Post by mcdebug » Tue Jun 22, 2004 10:03 pm

also the fact that eq froze before it even got to me.targetoftarget means it doesnt have anything to do with it. i put a /mqpause in front of 2 different forms of the same /if sequence and both times, reguardless of which /if statement was first, it froze on the first one.

User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Wed Jun 23, 2004 6:32 am

Me.TargetOfTarget just returns NULL if you don't have the ability so that's probably not what's wrong.. I don't really see anything else though. Maybe there are open braces or something?

User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Wed Jun 23, 2004 7:22 am

Hmm now I'm really confused.. I copied the /if block and it works for me, however the /if statement that checks your X,Y vs the ones you saved never executes even though I haven't moved.

However if I copy the whole thing it crashes for me too, but I haven't found the reason. It's probably not the /if thing though. If I were you I'd count braces and stuff like that.

mcdebug
a lesser mummy
a lesser mummy
Posts: 30
Joined: Mon Jun 07, 2004 4:24 am

Post by mcdebug » Wed Jun 23, 2004 10:10 am

yeah guess im gunna have to, oh boy

Jerle69
a hill giant
a hill giant
Posts: 263
Joined: Wed Apr 28, 2004 3:26 pm

Post by Jerle69 » Wed Jun 23, 2004 6:02 pm

Hello... I saw this derived macro and smiled. I guess RH is something now, since others are using it as an engine for other macros =)

I'll take a look at the macro and see if I can find out what's going on wrong. My initial guess is that you're missing a bracer { or } somewhere, so the scoping is getting hosed, placing you in an infinite loop. I also have a monk. I'll try to run a copy of your code and tell you what's wrong, providing I get a chance :)

Oh, just taking a look at your FD alias, it needs to read /squelch /alias fd /echo AutoFD
Right now it's just echoing FD, which won't trigger your event.

Also, you got doFD[TRUE] all over the place, just look for ${doFD} if you're checking to see if it's in the ON state or not.

Likewise, here's your bracket problem:

Code: Select all

Sub Event_TogFD 
  /if ([color=red]$[doFD}[/color]) { 
   /varset doFD TRUE 
   /echo ** Auto-FDing is now ON! 
  } else { 
    /varset doFD FALSE 
   /echo ** Auto-FDing is now OFF! 
  } 
  /ini "RHSettings.ini" "General" "AutoFD" "${doFD}" 
/return 
Take care,
--Jerle

mcdebug
a lesser mummy
a lesser mummy
Posts: 30
Joined: Mon Jun 07, 2004 4:24 am

Post by mcdebug » Thu Jun 24, 2004 8:33 am

lol ok cant believe i missed that, usually the problem is right in front of you, thanks for the help jerle 8). i knew if you took a look at it the problem would be solved.

mcdebug
a lesser mummy
a lesser mummy
Posts: 30
Joined: Mon Jun 07, 2004 4:24 am

Post by mcdebug » Thu Jun 24, 2004 8:55 am

also i missed an end bracket up by the section i was having trouble with, figures