Quick lil question

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

Tangeleno
a hill giant
a hill giant
Posts: 193
Joined: Fri Feb 20, 2004 6:00 pm

Quick lil question

Post by Tangeleno » Sat Feb 21, 2004 12:12 pm

Ok so I read the manual and I was wondering how I would go about checking two things in an /if statement. I need to check to make sure a mob isn't in melee range and won't be in the next second or two.

Code: Select all

/if $target(distance) <= $target(maxrange)
I'm pretty sure thats checking to make sure the mob isn't in melee range at the moment. If not please correct me. :( Any help would be great.


TIA

MacroFiend
a grimling bloodguard
a grimling bloodguard
Posts: 662
Joined: Mon Jul 28, 2003 2:47 am

Post by MacroFiend » Sat Feb 21, 2004 12:40 pm

Don't put spaces between the comparison and you should be ok.

Code: Select all

/if $target(distance)<=$target(maxrange)

Tangeleno
a hill giant
a hill giant
Posts: 193
Joined: Fri Feb 20, 2004 6:00 pm

Post by Tangeleno » Sat Feb 21, 2004 12:48 pm

Oh alright thank you didn't know about that.:) Do you know anything about how to check more than one instance in the same if?

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Sat Feb 21, 2004 1:18 pm

Code: Select all

/if [color=red]n[/color] $target(distance)<=$target(maxrange)

User avatar
Bad Karma
a snow griffon
a snow griffon
Posts: 346
Joined: Sat Nov 22, 2003 9:34 pm
Contact:

Post by Bad Karma » Sat Feb 21, 2004 5:08 pm

Yeah, don't forget the 'n' as DKAA pointed out for numerical comp's.

As for more than one instance in the same /if...what exactly do you mean? More than one mob in one /if?

You could set an array and cycle through it.

Or, check $spawn(radius)
[b]- Bad Karma
________________________________________[/b]

In our own quest for excellence, we should strive to take the time to help those who help themselves.

All others should [b]RTFM[/b]!!!!!!!!!

Gumby
a ghoul
a ghoul
Posts: 99
Joined: Sat Jan 24, 2004 5:27 pm

Re: Quick lil question

Post by Gumby » Sat Feb 21, 2004 8:55 pm

Tangeleno wrote:Ok so I read the manual and I was wondering how I would go about checking two things in an /if statement. I need to check to make sure a mob isn't in melee range and won't be in the next second or two.

Code: Select all

/if $target(distance) <= $target(maxrange)
I'm pretty sure thats checking to make sure the mob isn't in melee range at the moment. If not please correct me. :( Any help would be great.
Well as DKAA / Macrofiend corrected, that'd check to see if a mob is within it's melee radius of you.

The second part, if I understand your question correctly, intrigued me enough while waiting for a rez to do a quick test to see how far something moves per unit time. Don't know if this or something akin to this has been before and I apologize in advance if so, but here's my test code and trial conditions. Was useful experiment for me, may work into a kite routine for various conditions, data may be useful to someone else too.

Trialconditions: North Karana for the zone
4 Tests, unbuffed, SoW, SoE, FoE. 60 second times on each, 1 second instant in time speed slices to attempt to account for variation due to obstacles. Data's slightly off as I had small hills on the first two tests which were mostly negated by SoE/FoE on the second two, and there are rounding estimation errors time and other data and others but for a quick ballpark estimate it'll play:

Code: Select all

#turbo

Sub Main
  /declare OriginalY     global
  /declare OriginalX     global
  /declare SpeedArray    array
  /declare TotalSpeed    global
  /declare InitSpeed     global
  /declare TotalDist     global
  /declare i             global
  /declare InitTime      global
  /declare TotalTime     global
  /declare DistPerTime   global
  /declare AverageSpeed  global

  /echo Macro Start
  /varset TotalSpeed 0
  /varset InitSpeed $char(speed)
  /varset InitTime  $running
  /varset OriginalY $char(y)
  /varset OriginalX $char(x)  
  /for i 0 to 59 do
     /varset SpeedArray(@i) $char(speed)
     /delay 10
  /next i
  /varset TotalDist $distance(@OriginalY,@OriginalX)
  /mqlog TotalDist @TotalDist
  /varset TotalTime $calc($running-@InitTime)
  /mqlog TotalTime @TotalTime
  /mqlog InitSpeed @InitSpeed
  /for i 0 to 59 do
     /varadd TotalSpeed @SpeedArray(@i)
  /next i
  /mqlog TotalSpeed @TotalSpeed
  /varset AverageSpeed $calc(@TotalSpeed/@TotalTime)
  /mqlog AverageSpeed @AverageSpeed
  /varset DistPerTime $calc(@TotalDist/@TotalTime)
  /mqlog DistPerTime @DistPerTime
  /mqlog AverageSpeed/DistPerTime: $calc(@AverageSpeed/@DistPerTime)
/return
Result set:

Code: Select all

Unbuffed/RS3:
[2004/02/21 19:20:02] TotalDist 2327
[2004/02/21 19:20:02] TotalTime 60.00
[2004/02/21 19:20:02] InitSpeed 130.00
[2004/02/21 19:20:02] TotalSpeed 7800.00
[2004/02/21 19:20:02] AverageSpeed 130.00
[2004/02/21 19:20:02] DistPerTime 38.78
[2004/02/21 19:20:02] AverageSpeed/DistPerTime: 3.35

Buffed: SoW
[2004/02/21 19:21:21] TotalDist 2773
[2004/02/21 19:21:21] TotalTime 60.00
[2004/02/21 19:21:21] InitSpeed 155.00
[2004/02/21 19:21:21] TotalSpeed 9300.00
[2004/02/21 19:21:21] AverageSpeed 155.00
[2004/02/21 19:21:21] DistPerTime 46.22
[2004/02/21 19:21:21] AverageSpeed/DistPerTime: 3.35

Buffed: SoE
[2004/02/21 19:25:34] TotalDist 2861
[2004/02/21 19:25:34] TotalTime 59.00
[2004/02/21 19:25:34] InitSpeed 160.00
[2004/02/21 19:25:34] TotalSpeed 9600.00
[2004/02/21 19:25:34] AverageSpeed 162.71
[2004/02/21 19:25:34] DistPerTime 48.49
[2004/02/21 19:25:34] AverageSpeed/DistPerTime: 3.36

Buffed: FoE
[2004/02/21 19:28:17] TotalDist 2948
[2004/02/21 19:28:17] TotalTime 59.00
[2004/02/21 19:28:17] InitSpeed 165.00
[2004/02/21 19:28:17] TotalSpeed 9900.00
[2004/02/21 19:28:17] AverageSpeed 167.80
[2004/02/21 19:28:17] DistPerTime 49.97
[2004/02/21 19:28:17] AverageSpeed/DistPerTime: 3.36
To summarize: It appears as though characters / spawns will move approximately 1 distance per second for each 3.35-3.36 speed (probably could've stated this clearer in the log / analysis).

So to check to see if an incoming mob will be within melee range within a given amount of time in seconds (@Time) based upon it's speed (full, walking, snared, whatever), you can use something like this assuming the mob is headed towards you (using 3.35 as the more conservative number for this application):

Code: Select all

/if n $calc($calc($target(speed)/3.35)*@Time)<=$calc($target(distance)-$target(maxrange)) {
   // do stuff while mob is outside of melee range for @Time seconds
} 
Probably to play it safe you'd be better off dropping the 3.35 value down to 3 to give an extra margin of safety.

Hope this helps,

G

Tangeleno
a hill giant
a hill giant
Posts: 193
Joined: Fri Feb 20, 2004 6:00 pm

Post by Tangeleno » Sat Feb 21, 2004 11:45 pm

Ok what i mean by two instances is in some other programming language ,not sure which, theres an & or && comparitive. So what I need is to check to make sure the mob is not within melee range and won't be in a couple of seconds which would be

Code: Select all

/if n $target(distance)<=$target(maxrange)&&(what ever here to make sure its not going to be in melee range in a second or two)
If the && or & comparitives exist. But as to what I plan on doing is getting this little bugger to automatically sit me down every tic so I get the mana and HP regen while sitting. Dunno if it's been done before and to tell you the truth I wanna make it on my own, with a 'lil help of course :).

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Sat Feb 21, 2004 11:53 pm


Gumby
a ghoul
a ghoul
Posts: 99
Joined: Sat Jan 24, 2004 5:27 pm

Post by Gumby » Sun Feb 22, 2004 3:21 am

If it won't be in melee range for a couple of seconds, it's a pretty safe assumption it's not in melee range now :).

Don't need the compound operator as you really only need one check in this instance.

G

Tangeleno
a hill giant
a hill giant
Posts: 193
Joined: Fri Feb 20, 2004 6:00 pm

Post by Tangeleno » Mon Feb 23, 2004 2:46 pm

. . . . Ya know gumby that thought never even came across my mind. :) but you are right. Thank you all for the help.