Page 1 of 1

Aggro checker, or is npc facing pc or loc z?

Posted: Fri Jul 23, 2004 12:41 pm
by Vexix
I haven't seen any other routines that check if X is facing mob Y or a particular location (assuming both X and Y != me), so I wrote one for genbot.

This is an excellent way to check aggro, and doesn't depend on which way the PC is facing. Enjoy.

Code: Select all

| CheckIsLookingAt
| Used for checking if an NPC is attacking.someone.  Default PC is master
|Usage /call CheckIsLookingAt "id of mob to check" "id of PC to check"
Sub CheckIsLookingAt(int MobID,int PCID)
   /declare MobHeading int local 0
   /declare HeadingToPC int local 
   /declare DeltaX local float 
   /declare DeltaY local float 
   /declare HeadingDelta local float 
   /if (!${Defined[PCID]}) /varset PCID ${Spawn[${MasterName}].ID}
   /if (${Spawn[id ${MobID}].ID}) { 
      /varcalc DeltaX ${Spawn[id ${PCID}].X}-${Spawn[id ${MobID}].X}
      /varcalc DeltaY ${Spawn[id ${PCID}].Y}-${Spawn[id ${MobID}].Y}
      /varcalc MobHeading ${Spawn[id ${MobID}].Heading.Degrees}
      /if (${DeltaX}>0) {
         /varcalc HeadingToPC ${Math.Atan[${DeltaY}/${DeltaX}]}+270
      } else /if (${DeltaX}<0) {
         /varcalc HeadingToPC ${Math.Atan[${DeltaY}/${DeltaX}]}+90
      } else {
         /if (${DeltaY}>0) {
            /varcalc HeadingToPC 90
         } else {
            /varcalc HeadingToPC 270
         }
      }
      /varcalc HeadingDelta ${Math.Abs[${HeadingToPC}-${MobHeading}]}
      |/echo DeltaY ${DeltaY} DeltaX ${DeltaX}  Atan ${Math.Atan[${DeltaY}/${DeltaX}]}
      /echo Mob ${Spawn[id ${MobID}].Name} MobHeading ${MobHeading} HeadingToPC ${HeadingToPC}
      /if (${HeadingDelta}<4 || ${HeadingDelta}>356) { 
         /return 1
      } 
   }
/return 0

Posted: Tue Sep 28, 2004 10:36 pm
by bushdaka
I am looking for a way to know if I've got aggro during a battle. Since this routine was posted a while ago, and it doesn't actually check to see if you're being hit, anyone have experience with this routine to know if it's working well?

I've tried some #events but for some reason even handing them off to different routines causes all events to stop processing. In the following, if hit2 and hit3 and missed2 and missed3 are set (not commented out) all events stop (for me anyway). So I'm looking for an alternative.

Code: Select all

#event fight_gothit1 "#*#hits YOU#*#"
#event fight_gothit2 "#*#bites YOU#*#"
#event fight_gothit3 "#*#bashes YOU#*#"
#event fight_gotmissed1 "#*#hit YOU#*#"
#event fight_gotmissed2 "#*#bite YOU#*#"
#event fight_gotmissed3 "#*#bash YOU#*#"

Posted: Mon Oct 04, 2004 1:02 pm
by Wink-
I know in character they have: spawn TargetOfTarget | Target of target (moved to character type) So ${Target.TargetOfTarget} might be what you could use.

Posted: Mon Oct 04, 2004 6:50 pm
by Timplo
Wink- wrote:I know in character they have: spawn TargetOfTarget | Target of target (moved to character type) So ${Target.TargetOfTarget} might be what you could use.
This i belive is only set if group leader has the LDR ability.

Posted: Mon Oct 04, 2004 6:52 pm
by eqjoe
You could /assist the mob if you are close enough....


-j

Posted: Mon Oct 04, 2004 7:20 pm
by Chill
If you have the HoTT LAA and you can assume you will always be in a group of 3 or more when running your macro, then it's easy:

Code: Select all

/if (${Me.TargetOfTarget.ID} == ${Me.ID}) {
   <AGRO CODE>
} else {
   <NON AGRO CODE>
}
This is what I use in most of my macros, and it works great for me.