/if (behind mob)

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

Moderator: MacroQuest Developers

User avatar
a_troll_01
a lesser mummy
a lesser mummy
Posts: 46
Joined: Sat Dec 06, 2003 6:06 am
Location: Memphis, TN
Contact:

/if (behind mob)

Post by a_troll_01 » Wed May 26, 2004 4:58 pm

I was looking for an MQ2Dat version of this. I have used the search feature and readme.chm and haven't been able to find any references to go on. I don't get very in depth with my macros, just enough to get by, so this is a bit beyond me.

Simply put, I'm looking for this:

Code: Select all

/if (${Me.AbilityReady[Backstab]} && ${Target.PctHPs}<90 && [b][color=red]Me=BehindMob[/color][/b]) /doability "Backstab"
To go with my:

Code: Select all

|=============================================================================
|------------------------------ GrpRogue.mac v1.8 ----------------------------
|--------------------------- Rogue Ability Autopilot -------------------------
|-----------------------------------------------------------------------------
|--- Usage: /macro GrpRogue
|---        Duck to stop attacking
|--- Does Rogue abilities during combat for you. 
|--- (Pick Pockets, Disarm, Backstab, Evade, Begging)
|-----------------------------------------------------------------------------
|--- By: a_troll_01 - Last Updated (5/25/04) 
|--- MQ2Dat Conversion by Wassup
|--- 'Duck to turn attack off' by Preocts
|--- Enjoy! 
|=============================================================================

#event Attack "Auto attack is on." 

|=============================================================================

Sub Main 
   /echo GrpRogue.mac v.1.8 Activated! Be sure Backstab, Hide, Pick Pockets, & Disarm are on Ability/Combat buttons.
   :MainLoop 
   /if (${Target.Type.Equal[NPC]}) /doevents 
   /goto :MainLoop 
/endmacro 

|=============================================================================

Sub Event_Attack
   /echo -( ${Target.CleanName} )- ... Level ${Target.Level} ${Target.Class.Name}
   :SubLoop 
   /if (${Target.Type.Equal[NPC]} && !${Me.Ducking}) {
      /if (${Target.Type.Equal[NPC]}) /face nolook
      /if (!${Me.Combat} && !${Me.Ducking}) /attack on
      /if (${Me.AbilityReady[Backstab]} && ${Target.PctHPs}<90) /doability "Backstab"
      /if (${Me.AbilityReady[Pick Pockets]} && ${Me.AbilityReady[Hide]}) {
         /attack off
         /delay 1
         /if (${Target.Type.Equal[NPC]} && ${Target.PctHPs}<65) /doability "Pick Pockets"
         /if (${Target.Type.Equal[NPC]}) /face nolook
         /if (${Target.Type.Equal[NPC]} && ${Target.PctHPs}>64) /doability "Begging"
         /doability "Hide" 
         /if (${Target.Type.Equal[NPC]}) /attack on
      }
      /if (${Me.AbilityReady[Disarm]}) /doability "Disarm"
      /if (${Target.Type.Equal[NPC]}) /goto :SubLoop
      }
   /attack off
/return
Any help would be greatly appreciated. This has been bugging me for a while. Thanks in advance :)
-- a_troll_01

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

Post by Jerle69 » Wed May 26, 2004 5:36 pm

You have to calculate this, currently. There are a couple of ways to figure it out. I came up with a fairly easy-to-understand algroithm that uses the Clocks Heading member for a given target.

The concept is this: you can discern a target's heading, you can discern your heading, and you can ensure you're facing your target. With this information you can determine if you're behind the target. If you're "one hour" off (on an analog clock) either minus an hour or plus an hour in your heading, you're behind the target. You're mostly behind a target if you're minus 2 hours or plus two hours off of your heading from target, but +/- 1 hour is for sure. With this in mind:

... make sure previous code establishes that youre target is actually targeted... and then:

Code: Select all

  /face nolook
  /declare behindTarget bool
  /declare dir int
  /declare i int
  |- Are we behind our target? 
  /varset behindTarget FALSE 
  /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 behindTarget TRUE 
  /next i   
Once this code is executed, behindTarget contains the boolean condition you're looking for. Enjoy (ripped this out of my RH macro).
Last edited by Jerle69 on Wed May 26, 2004 5:43 pm, edited 3 times in total.
--Jerle

User avatar
a_troll_01
a lesser mummy
a lesser mummy
Posts: 46
Joined: Sat Dec 06, 2003 6:06 am
Location: Memphis, TN
Contact:

Post by a_troll_01 » Wed May 26, 2004 5:39 pm

Awesome. That's great Jerle. Thanks for the help, much appreciated. I learn something new everyday. :)
-- a_troll_01

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

Post by Jerle69 » Wed May 26, 2004 5:42 pm

I had to go back and add some declares for variables in there. I had my variable declarations far earlier in the code than the algorithm that actually used them :)
--Jerle