Network: WoW Gold | WoW Accounts | MPS Games | FPSowned
MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides
Homepage »      Register »      Hall of Fame »      Ranks And Awards »      Advertise »      Marketplace »
 
Sign up



Do you like this excellent information? Then Donate HERE to remove ads and support the MMOwned community.


Go Back   MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides > WoW Discussions > WoW General

WoW General World of Warcraft General Chat
[All WoW Related Questions Belong Here]

Reply
 
LinkBack Thread Tools
  #1  
Old 07-17-2009
abuckau907 is offline.
Sergeant
  
 
Join Date: Jun 2009
Posts: 66
Reputation: 19
[Guide] Rotating using Right_Mouse_Click

[Required Knowledge]
1. You have to be able to calculate a points relative rotation to you (ie. south = pi, north = 0 or 2*pi)
2. Must be able to read LocalPlayer.position from ram

When I say 'relative rotation' I actually mean the rotation we need to have to be perfectly facing the
point in-game. So from what I was told on this forum, this can easily be done with Math.Atan2(x1,y1,x2,y2)
where x1,y1 = localPlayer.x/y and x2y2 = the other point in-game..but I don't do it this way..if you don't want
to know how I find it..skip the next section. However, if you have problems w/ the 1 liner..try my code

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''
[How I find 'relative rotation']

I know this is pretty basic math, and I almost feel like using this equation is a cliche..but it's powerful
and enough for what we need. Pythagorean's Theorem: a^2+b^2=c^2, if you don't understand this one..leave sorry
Also used are the, basic, Sin, Cos, Tan (well actually just ArcTan, but don't worry..your programming language has it
and it's almost exactly the same as Tan..so if you haven't used it before, don't worry, you don't have to understand it
too well.) So, here is a picture that shows how to calculate all possible angles(taking into consideration which quadrant
the point is in)

Click the image to open in full size.


The logic behind it goes something like this: At the top of a circle is 0 radians, and going to the LEFT it increases
around the circle all the way back to the top which is 6.2 (actually 2 * Math.Pi). What does this mean? So the top
is 0, what is the bottom? ( Well it's half way around the circle, so it's half of our..total radians) so 2*Pi / 2 = PI!
so south = 3.141! You have to understand that 100% before continuing my way..otherwise you're just gonna copy/paste
So, to the left would be pi/2 (1.5 about) and right is 3*pi/2 = 4.5 about. which makes sense..each one is about 1.5 larger.
So 1.5, 3, 4.5, 6..those are *ROUGH estimates* because you should really use the values of pi, not just say 'about'.
Anyway, the reason I drew out the picture is because at first I just tried a one line equation and apparently got it wrong
and couldn't get the angles correct. I thought it had something to do w/ some values being negative, which was larger, etc
and instead of just throwing in a few math.absoluteValue() and just guess..i decided to..logic my way through it, even if it
requires the use of IF statements in my code vs just 1 equation..trust me, it's still fast code, and it's easier to understand
coming back in a month, imo. Some basic info: Wow's coordinate system is weird: X gets smaller to the right (y is normal)

so this mean if LocalPlayer.x > gamePoint.x then // point is to our RIGHT (top or bottom...don't know yet)
and for y (obvious) if Localplayer.y > gamePoint.y then // point is to our SOUTH (left or right depending on above if


Using that logic (of If statements) I came up with this: (it's vb.net, very basic stuff tho)
Code:
    Public Function GetObjectRelativeRads(ByVal posX As Single, ByVal posY As Single) As Single
        'Returns 0 for fail/same position  , 2Pi for vertical
        Dim rads As Single = 0
        Dim lpX As Single = LocalPlayer.XPos
        Dim lpY As Single = LocalPlayer.YPos

        Select Case posX

            Case Is > lpX
                'To our LEFT
                Select Case posY
                    Case Is > lpY
                        'Above Us, Top Left
                        rads = Math.Atan((posX - lpX) / (posY - lpY))
                        Return rads
                    Case Is = lpY
                        'Perfectly Left-->WEST
                        Return (Math.PI / 2)
                    Case Is < lpY
                        'Below us, Bottom Left
                        rads = (Math.PI / 2) + Math.Atan((lpY - posY) / (posX - lpX))
                        Return rads
                End Select
            Case Is < lpX
                'To Our RIght
                Select Case posY
                    Case Is > lpY
                        'Above Us, Top Right
                        rads = (3 * Math.PI / 2) + Math.Atan((posY - lpY) / (lpX - posX))
                        Return rads
                    Case Is < lpY
                        'Below Us, Bottom Right
                        rads = Math.PI + Math.Atan((lpX - posX) / (lpY - posY))
                        Return rads
                    Case Is = lpY
                        'Perfectly Right-->EAST
                        Return (3 * Math.PI / 2)
                End Select
            Case Is = lpX
                'Directly ABove or BElow
                Select Case posY
                    Case Is > lpY
                        'Directly Above-->NORTH
                        Return 2 * Math.PI
                    Case Is < lpY
                        'Directly Below-->SOUTH
                        Return Math.PI
                    Case Is = lpY
                        'x1,y1==x2,y2 :: SAME POINT!
                        Return 0
                End Select
        End Select
    End Function
That code has been thoroughly tested and works great. Again..this is the rotation you WANT to be
facing the object.
[END How I find 'relative rotation']
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''

Problem: How to rotate our character, using the mouse, toward any in-game point ( x,y,z location)
well We Know the following is true

If Math.AbsoluteValue(LocalPlayer.Rotation -targetPoint.RelativeLocation) < .2 //TODO: use value computed by distance
{
//our rotations are almost ==, so I'm facing it!
}
else
{
//we aren't facing it...we need to rotate left or right
}


VERY IMPORTANT: If the object is top-left of you, and almost perfectly north , and you are facing top-right almost perfectly north
math.abs(local.rot-relativeRot) will == 6 BUT you will still be facing them! BIG BUG..be sure you have an IF or something
to handle that exception in your 'RotateTowardPoint(float x, float y)' function.

I'm sure most (100? hopefully) of us use the right-click-down/move the mouse/right-click-up feature of wow to rotate the view
while in-game. If not..it works really well and can be extremely accurate (MUCH more accurate than pressing a/d
to turn - ASSUMING the camera angle is good. If you're looking directly over yourself...the code still works, but..it's bad.


To start of with an example, I climbed on-top of a fence post and wrote down the x,y pos.
That is the 'target point' referred to in here/the screenshots.


Click the image to open in full size.

(text in picture, basically) As you see I'm facing north and my .rot almost == 0, so that working.
The point is to the south of me, almost, and has a .relativeRotation of almost Pi, perfect. Also
The distance appears to be correct ( SqrRoot[(x2-x1)^2 + (y2-y1)^2] )


The first problem I ran into was ..when turning towards a point, how close should the two .rotations have to be
before you consider it 'directly in-front of you?' And an even more important question: Does it need to be *almost
perfectly* in-front of you? I say, it depends and sometimes I'll need it. at first I used a constant like .2
which works, well..it works differently when you're far/close to an object. This might not affect you, but if you
plan to have points that are more than...lets say 50 units apart..well..let's just see. I ran 50 units away from the post..and then
rotated until I was within .2 of it and then ran forward...how close did I end up?


Click the image to open in full size.
As I ran forward, the closest I could get was 10units away... if you plan to use melee this *could* be a problem?
And it'll get stuck on game objects? There is somewhat of a workaround, where in your RunToPoint() function you have
an if statement like (if .diffInRotations > .2 then TurnToPoint() again..) ...sloppy: The RunToPoint() function
should take into consideration the objects distance when calculating the 'closeness' the .rotations need to be.

So for example, at 50u, .2 wasn't so great..but it depends on what you're doing. For something like combat, they don't
have to be exactly dead-center (unless you're using the /tab key to find your mob..then it matters :P ), but for
pathing it's nice to be able to move to a very specific spot (ie. with .2 you could only get w/in 10u!! not close)
So if you tried to run through a city using .2 you'd probably get stuck..using a more exact angle can be good.

At the moment I'm testing different values out (how far to move the mouse, 3px, 2px, etc, and how far that changes your rotation)
Depending on resolution, moving only 1px might not change rotation much, but on 60x80 it'd move a lot There could be
some initialization function that turns 1px and sees how much the angle changes, and used that in calculations later also.
At the moment all I have is something like...

While (differenceInRotations > .2)
mouse_move 10 * Random(10) pixels
}
while (differenceInRotation > .004)
mouse_move 2*Random(4) pixels
}

which equates to..it spinning faster at first..and then slowing down to get the most exact rotation. I did this because if you just
use something like 10, sometimes it'll spin too far past the point, but if you use 2 the whole time it's too slow..I like the multi-
speed thing that code does..I wonder what type of monitoring (pattern recognition :P?) blizzard does on things like position, rotation
etc ? I don't think it's too bot-like tho...I want more opinions for sure, maybe I'll make a video on how well it runs a path/what it
looks like while rotating if anyone is interested.


[Conclusion]

The only problem I can foresee is if the camera angle gets mess up..it'll still rotate your character, but you'll be looking at the ground.
Since we're controlling the mouse..chances are we might mess up the angle (..I hope not? So far the code doesn't..but for example if you
use /tab to target the mob in front of you...it won't work if you're looking down)
One last thing: The 'relative rotation' doesn't take into consideration you're local play.Rotation, which means
if the object is to the south of you..it will always be around 3.1 (duh) 'relative rads' even if you're facing it. Sometimes
I would be facing the target and think 'difference in angles' (if I'm looking at it or not) but look at the 'relative rads' and confuse myself. Just a tip.

Anyway, I hope this helps someone.

-Andrew

edit: Just ran into my first problem --> On the mouse_right_up it keeps changing my camera angle down a little bit..after a few Rotations i'm looking down over myself..definitely not good. It works fine while actually rotating, but when it releases the right_click it's changing the view. I think it has something to do the mouse_event function and how it handles the dx,dy inputs..but I can't figure it out. Anyone have an idea?

Last edited by abuckau907; 07-17-2009 at 07:23 AM.
Reply With Quote


Donate to remove ads, get your "DONATOR title, and get access to the MMOwned community's elite Shoutbawx.

  #2  
Old 07-17-2009
Timzorize is offline.
Knight
  
 
Join Date: May 2008
Posts: 196
Reputation: 9
Points: 1,560, Level: 3
Points: 1,560, Level: 3 Points: 1,560, Level: 3 Points: 1,560, Level: 3
Level up: 23%, 540 Points needed
Level up: 23% Level up: 23% Level up: 23%
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%

This is so sick....
__________________
I need EU Gamecards, PM me if you have one, there will be a price.
Reply With Quote
  #3  
Old 07-18-2009
Därkness is offline.
Master Sergeant
  
 
Join Date: Jul 2009
Posts: 72
Reputation: 7
Points: 252, Level: 1
Points: 252, Level: 1 Points: 252, Level: 1 Points: 252, Level: 1
Level up: 63%, 148 Points needed
Level up: 63% Level up: 63% Level up: 63%
Activity: 0.4%
Activity: 0.4% Activity: 0.4% Activity: 0.4%

Nice guide. Read through most of it. The math is easy, but i think my next program in my learning is going to be one that moves in a circle (using coordinates ).
Reply With Quote
  #4  
Old 07-18-2009
Sayu's Avatar
Sayu is offline.
Knight-Lieutenant
  
 
Join Date: Jul 2008
Location: Stormwind
Posts: 301
Reputation: 13
Points: 1,079, Level: 2
Points: 1,079, Level: 2 Points: 1,079, Level: 2 Points: 1,079, Level: 2
Level up: 36%, 321 Points needed
Level up: 36% Level up: 36% Level up: 36%
Activity: 30.4%
Activity: 30.4% Activity: 30.4% Activity: 30.4%

someone tell me he didn't just do all the math just to calculate how to rotate ur character in a perfect angle!
Reply With Quote
  #5  
Old 07-18-2009
abuckau907 is offline.
Sergeant
  
 
Join Date: Jun 2009
Posts: 66
Reputation: 19
that's exactly what I did..like I said, there are 1 line equations, or there is this way...thank's for reposting what I said.. +rep fo sho'

(This was more of a tutorial for those of us who don't understand circles, radians, Pythagorean's theorem, the wow coordinate system. If you don't know about atan2..this functions works exactly the same, and it only took logic and basic math skills to create it..not searching on google, so if someone reads this and learns something ..sweet. If you don't want to know this, sorry you read it.)

ps. I thought (i never actually finished looking it up, obviously, so I wouldn't know: but I thought there was a problem w/ using that function because it only returned 0-180d? or maybe not? Again, I didn't learn about it, sry if that's wrong (restrict your flame to 1 word( wrong|wrong) plz)
Reply With Quote
  #6  
Old 07-18-2009
Sayu's Avatar
Sayu is offline.
Knight-Lieutenant
  
 
Join Date: Jul 2008
Location: Stormwind
Posts: 301
Reputation: 13
Points: 1,079, Level: 2
Points: 1,079, Level: 2 Points: 1,079, Level: 2 Points: 1,079, Level: 2
Level up: 36%, 321 Points needed
Level up: 36% Level up: 36% Level up: 36%
Activity: 30.4%
Activity: 30.4% Activity: 30.4% Activity: 30.4%

i appreciate ur work, it's just that it seems to be awfully lot for such a simple(?) thing. i'm pretty sure someone could actually learn from it if he actually took his time to read all this.
Reply With Quote
  #7  
Old 07-18-2009
FartBlast's Avatar
FartBlast is offline.
Knight-Lieutenant
  
 
Join Date: Mar 2007
Posts: 263
Reputation: 38
Points: 2,635, Level: 4
Points: 2,635, Level: 4 Points: 2,635, Level: 4 Points: 2,635, Level: 4
Level up: 77%, 165 Points needed
Level up: 77% Level up: 77% Level up: 77%
Activity: 0.4%
Activity: 0.4% Activity: 0.4% Activity: 0.4%

Might come in handy, i suck at those parts of math
__________________

Reply With Quote
  #8  
Old 07-18-2009
abuckau907 is offline.
Sergeant
  
 
Join Date: Jun 2009
Posts: 66
Reputation: 19
Ya..I guess it's more of a guide to ppl who haven't used coordinate systems in a while, just to kinda..refresh their memory..which will help with their pathing logic later, hopefully? If not, I did waste my time writing it :P

ps. How do you guys handle your RotateCharacter function..i mean: I used a big switch/select case for each situation (I'm facing Top-Right, they are in xx, etc) so i think
it was like 16 different cases + 4 more for perfect north/east/south/west ..for example: you get the object's relative rotation..then what? Turn Left or right? basically that's what my switch does..but there has to be a shorter way? I guess you could calculate their pos. relative to your rotation and then if < pi turn left else turn right..but again, that's just a bit more math...but less switch/select statements
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On



All times are GMT -4. The time now is 11:40 PM.




Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493