Being Attacked by mob..

A forum for macro code snippets to be used in writing other macros. Post routines or .inc files here only, completed macros go to the Macro Depot. MQ2Data format only!

Moderator: MacroQuest Developers

zizak51
orc pawn
orc pawn
Posts: 28
Joined: Thu Nov 26, 2009 1:53 pm

Being Attacked by mob..

Post by zizak51 » Tue Aug 02, 2011 12:51 am

I noticed a post about detecting // reporting the mob that is attacking your bot characters. There is probably a better way to do this but here is my prototype example in answer to

viewtopic.php?f=24&t=6668.

Code: Select all

|=====VARS
|
| o  UnderAttack exists so that you can filter based on wether or not you are currently being attacked, like:
|    /if (${UnderAttack.Equal[True]}) {
|          /yell
|    }
|
| o  AlertTank exists to ensure you're tank doesn't get spammed each time you get hit.
|
| o  MTank is tank's name.  (Who recieves the help cry)
|
|===========

/declare	UnderAttack		string	outer	FALSE
/declare	AlertTank		  string	outer	FALSE
/declare	MTank		      string	outer	Tank

|========== Description: ===============
|
|      The advantage here is that it will actually return a target's unique spawn name instead of
|   just pulling it out of the combat text.  This is so that another character can target the exact 
|   mob that is attacking you if you have more than one "orc pawn" around.
|      It clears the target and waits up to 4 seconds (count for ${i}) for the game to auto-target
|   the next mob that hits you.  Once this happens, it reportts to the tank the unique name of 
|   the mob that whacked you.
|
|==============================


Sub Event_Attacked
  /declare	i	int	local
  /varset UnderAttack TRUE 
  /varset i 0
  /squelch /target clear 
  :gettarget
  /delay 5
  /if (${Target.ID} && ${AlertTank.Equal[FALSE]}) {
      /tell ${MTank} Help! ${Target.Name} is attacking ${Me.Name}!!
	  /varset AlertTank TRUE
	  /return
  } else {
	  /if (${i}<7) {
	      /varcalc i ${i}+1
	      /goto :gettarget
	  }
  }
 /return

I guess this macro assumes only ONE mob is kicking your ass..