${Spawn.Look}?

A forum for reporting bugs NOT related to custom plugins.

Moderator: MacroQuest Developers

Vayeco Dynn
a ghoul
a ghoul
Posts: 113
Joined: Wed Aug 25, 2004 3:00 am

${Spawn.Look}?

Post by Vayeco Dynn » Thu Jul 03, 2014 12:18 am

I'm not sure how this is *supposed* to work, but the way I assumed it was supposed to work was that it would tell you the spawn's looking angle relative to YOU (i.e. 0.00 directly at you, 180.00 directly away from you, range 0,359.99). In client, I'm usually getting 0.00 on most spawns, or occasionally something crazy like 489.00. What's the deal with this?

Vayeco Dynn
a ghoul
a ghoul
Posts: 113
Joined: Wed Aug 25, 2004 3:00 am

Re: ${Spawn.Look}?

Post by Vayeco Dynn » Thu Jul 03, 2014 1:22 am

Anyway, here's some macro code for anyone looking to figure this out:

(Note: Return range is 0-180 in the Normalized sub, 0-360 in the original)

Code: Select all

#turbo

Sub Main

   /call MobLookNormalized ${Target.ID}

/return



|--------------------------------------------------------------------------------
|SUB: Angle from 2 points
|--------------------------------------------------------------------------------
Sub SlopeToAngle(float P1X, float P1Y, float P2X, float P2Y)

	/declare Denominator float
	
	/varcalc Denominator ${P2X} - ${P1X}
	
	/if ( ${Math.Abs[${Denominator}]} < 0.01 ) {
	
		/return 0
	
	}
	
	/return ${Math.Atan[${Math.Calc[(${P2Y}-${P1Y})/(${P2X}-${P1X})]}]}

/return

|--------------------------------------------------------------------------------
|SUB: Angle a mob is looking relative to Me
|--------------------------------------------------------------------------------
Sub MobLook(float SpawnID)

	/call SlopeToAngle ${Me.Y} ${Me.X} ${Spawn[${SpawnID}].Y} ${Spawn[${SpawnID}].X} 
	/declare MobAngle float ${Macro.Return}
	
	/if ( ${Math.Calc[${Me.Y} - ${Spawn[${SpawnID}].Y}]} < 0 ) /varcalc MobAngle ${MobAngle} + 180
	
	/if ( ${MobAngle} < 0 ) /varcalc MobAngle ${MobAngle} + 360
	
	/declare Result float ${Math.Abs[${Math.Calc[${MobAngle} - ${Spawn[${SpawnID}].Heading.DegreesCCW}]}]}
	
	/echo Mob is looking: ${Result} relative to Me (${MobAngle} vs ${Spawn[${SpawnID}].Heading.DegreesCCW})
	/return ${Result}

/return

|--------------------------------------------------------------------------------
|SUB: Angle a mob is looking relative to Me (normalized from 0-180)
|--------------------------------------------------------------------------------
Sub MobLookNormalized(float SpawnID)

	/call MobLook ${SpawnID}
	/declare Result float ${Macro.Return}
	/if ( ${Result} > 180 ) {
	
		/varcalc Result 360 - ${Result}
	
	}
	
	/echo Mob is looking: ${Result} relative to Me (normalized)
	/return ${Result}
	
/return
Last edited by Vayeco Dynn on Thu Jul 03, 2014 8:15 pm, edited 2 times in total.

EqMule
Developer
Developer
Posts: 2697
Joined: Fri Jan 03, 2003 9:57 pm
Contact:

Re: ${Spawn.Look}?

Post by EqMule » Thu Jul 03, 2014 10:54 am

.Look just returns look up/down angle -128 to 128 where 0.0 is center.
Never seen 489.0 if u get tht again let us know which mob maybe it's a bug.
You can target yourself and /Echo ${Target.Look} then look into the ground it will return -128
You are probably looking for .Heading.Degrees or .HeadingTo.Degrees
My status o/
If you like MQ2 and would like to contribute, please do. My goal is 25 donations per month.
So far I've received Image donations for this month's patches.

Bitcoin: 1Aq8ackjQ4f7AUvbUL7BE6oPfT8PmNP4Zq
Krono: PM me.
I can always use characters for testing, PM me if you can donate one.

Vayeco Dynn
a ghoul
a ghoul
Posts: 113
Joined: Wed Aug 25, 2004 3:00 am

Re: ${Spawn.Look}?

Post by Vayeco Dynn » Thu Jul 03, 2014 8:13 pm

Ah, okay. Sounds like it's working as intended then. I was getting the bogus 489.0 or whatever when chaining a lot of Spawn.Next's, not sure if that's related.

On another note, there is no implementation of what I was looking for in MQ2 which is "What angle is the mob looking relative to me, with 0.00 being directly at me and 180.00 being directly away from me?"

The code I had posted earlier was slightly incorrect, so I'm going to edit it with corrected code in just a moment here.