how to calc ../loc ? help please

Status
Not open for further replies.

kool26

New member
Joined
Aug 7, 2006
Messages
134
Reaction score
0
Points
0
Hello was wondering how to go about getting a toon to go to

Code:
/if ([${Me.Y},${Me.X}]!=${Math.Calc}${stakeY},${stakeX})


i havnt used Calc's befor but i have been messing with it for awhile now and cant seem to get it to work...lil help please?



Thanks
 
Heres a line of code out of a macro I'm currently working on.

Code:
/moveto loc ${Math.Calc[${Math.Rand[25]}-1456]} ${Math.Calc[${Math.Rand[25]}-746]}

That will move to a random loc thats generated within 25 distance of those two locations -1456 and -746.

or a simple

Code:
/moveto loc -1356 -834

Will work. I think you might need MQ2MoveUtils loaded though.

Fry.
 
Fry said:
Heres a line of code out of a macro I'm currently working on.

Code:
/moveto loc ${Math.Calc[${Math.Rand[25]}-1456]} ${Math.Calc[${Math.Rand[25]}-746]}

That will move to a random loc thats generated within 25 distance of those two locations -1456 and -746.

or a simple

Code:
/moveto loc -1356 -834

Will work. I think you might need MQ2MoveUtils loaded though.

Fry.

thanks for that info.will be usfull later...but iam tring to make an
Code:
/if ([${Me.Y},${Me.X}not at loc ${stakeY},${stakeX}) /call blah

is it doable?

Thanks, for anyhelp
 
This should do the job.

Code:
/if (${Me.Y}!= 1800 && ${Me.X}!= 1000) {
/call MoveMe
}

Change 1800 and 1000 to the Y and X loc you need. You might need to add a math calc to give or take 10 or so distance if the loc isn't always exact.

Drop by IRC if you need a hand with anything.

Fry.
 
Fry said:
This should do the job.

Code:
/if (${Me.Y}!= 1800 && ${Me.X}!= 1000) {
/call MoveMe
}

Change 1800 and 1000 to the Y and X loc you need. You might need to add a math calc to give or take 10 or so distance if the loc isn't always exact.

Drop by IRC if you need a hand with anything.

Fry.

ahh cool wasnt aware of the irc :eek:

lol after i see the code, damn easy lol...bit tired..:D ;)

TY again fry
 
You can also do things like this.
These are 2 lines I grabbed from macros I wrote few months back. The first is more of what you are looking for I think. Just change it to 10. Unless you want exact location, then use whta Fry posted.
HTML:
/if (${Math.Distance[${homeY},${homeX}]} < 50) /dowhatever

Sub ReturnHome
/delay ${Math.Calc[5+${Math.Rand[10]}]}   
  /if (${Math.Distance[${homeY}, ${homeX}]}>=${Math.Calc[20+${Math.Rand[10]}]}) {
   /call MoveToLoc ${Math.Calc[${homeY}+${Math.Rand[10]}]} ${Math.Calc[${homeX}+${Math.Rand[10]}]}
    /return
  } 
 /return
 
Variation #627

Code:
/if (${Me.X} < 1530 || ${Me.X} > 1550) {
  /if (${Me.Y} < 870 || ${Me.Y} > 890) {
    /call MoveToHome
  }
}

Assuming you want to hover X around 1540, and Y around 880.
 
You shouldnt need to spread that out so many lines.
HTML:
/if ((${Me.X} < 1530 || ${Me.X} > 1550) && (${Me.Y} < 870 || ${Me.Y} > 890))  /call MoveToHome
 
Actually the entire thing should be seperated by OR's looking at it again, since allowing any of the 4 to be true would call the reset function. Else the way it is now you could run to an extreme X and still be within Y range.

But either way it's a coding preference. I've made the ones with ridiculously long if statements, and looking back over them I much prefer it broken down into stages.
 
Added lines do increase your memory requirements, even if its just a single " } " the less lines in a macro the better. But your right it is coder preference.
 
Now we gather around and bum some pizza

*grabs a slice*
 
ok hmm none of this is working correctly so gona post what iam trying to add this too

Code:
  :LeashStart
       /echo lea started
       |- Look for new events
       /doevents
       /moveto loc ${stakeY} ${stakeX}
         /delay 2s 
         /if (${verbosity}>=2) /${channel} Moving closer to the Stake... ${Math.Distance[${Me.Y},${Me.X}:${stakeY},${stakeX}]} ft. away 
         /if (${Math.Distance[${Me.Y},${Me.X}:${StakeY},${StakeX}]} > ${leashflex}) /goto :LeashStart
         {
          {
         /delay 1 
         /if (${verbosity}>=2) /${channel} Arrived near enough to the Stake.
           /echo doing leash4
           /goto :LeashEnd
         }
         /goto :LeashStart
       }

:LeashEnd
        /varset arrive TRUE
        /echo doing leash7
        /return

yes messy, but this is like a test mac, what i named it lol...ive tried what you all have posted here and in irc....toon always stops far away stake.
once i get it going right gona clean up code, added the echo's for problem sovleing...to which brought me to the leashing.
 
Code:
:LeashStart
	/echo lea started
	|- Look for new events
	/doevents
	/moveto loc ${stakeY} ${stakeX}
	/delay 4s !${Me.Moving}
	/if (${Math.Distance[${StakeY},${StakeX}]} > ${leashflex}) {
		/if (${verbosity}>=2) /${channel} Moving closer to the Stake... ${Math.Distance[${stakeY},${stakeX}]} ft. away 
		/goto :LeashStart
	}

	/if (${verbosity}>=2) /${channel} Arrived near enough to the Stake.

:LeashEnd
	/varset arrive TRUE
	/return
 
Z166204 said:
Code:
:LeashStart
	/echo lea started
	|- Look for new events
	/doevents
	/moveto loc ${stakeY} ${stakeX}
	/delay 4s !${Me.Moving}
	/if (${Math.Distance[${StakeY},${StakeX}]} > ${leashflex}) {
		/if (${verbosity}>=2) /${channel} Moving closer to the Stake... ${Math.Distance[${stakeY},${stakeX}]} ft. away 
		/goto :LeashStart
	}

	/if (${verbosity}>=2) /${channel} Arrived near enough to the Stake.

:LeashEnd
	/varset arrive TRUE
	/return


Code:
/if (${Math.Distance[${StakeY},${StakeX}]} > ${leashflex}) {
		/if (${verbosity}>=2) /${channel} Moving closer to the Stake... ${Math.Distance[${stakeY},${stakeX}]} ft. away 
		/goto :LeashStart

stuck in loop, just sits there where i started mac and loops
this is the biggest pain in my ass ive came across yet =/
 
is your stakeX stakeY set? code looks mostly workable this is my leashsub, pretty simular but I dont use moveutils for my movement I use move.inc

HTML:
Sub ReturnHome
/delay ${Math.Calc[5+${Math.Rand[10]}]}
  /if (${Math.Distance[${homeY}, ${homeX}]}>=${Math.Calc[40+${Math.Rand[10]}]} && ${SpawnCount[NPC Loc ${Spawn[${TankID}].X} ${Spawn[${TankID}].Y} Radius ${MeleeDistance}]} ) { 
    /call MoveToLoc ${Math.Calc[${Spawn[${TankID}].Y}+${Math.Rand[10]}]} ${Math.Calc[${Spawn[${TankID}].X}+${Math.Rand[10]}]}
    /face heading ${Spawn[${TankID}].Heading.Degrees}
    /return
   }
   
  /if (${Math.Distance[${homeY}, ${homeX}]}>=${Math.Calc[40+${Math.Rand[10]}]} && !${SpawnCount[NPC Loc ${Spawn[${TankID}].X} ${Spawn[${TankID}].Y} Radius ${MeleeDistance}]} ) {
    /call MoveToLoc ${Math.Calc[${homeY}+${Math.Rand[10]}]} ${Math.Calc[${homeX}+${Math.Rand[10]}]}
   /face heading ${Math.Calc[${MeHeading}+${Math.Rand[15]}]}
    /return
  }    
 /return
 
Status
Not open for further replies.