Insolence Posted November 20, 2006 Share Posted November 20, 2006 Original topic: http://www.edgeofnowhere.cc/viewtopic.php?t=332679I've experimented with a few things, but I'm pretty terrible at math.I can get the character X/Y, then I can teleport to a certain window X/Y and compare the differences. However, the D2 world uses 45° isometric planes(?), I'm not sure how to calculate it. Here are some results I found:; Went to : 4616, 4613; Went from : 4623, 4620; Clicked : 400, 200; Difference: 7, 7; Went to : 4612, 4618; Went from : 4625, 4631; Clicked : 400, 100; Difference: 13, 13; Went to : 4629, 4611; Went from : 4645, 4627; Clicked : 400, 50; Difference: 16, 16 "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
The Kandie Man Posted November 20, 2006 Share Posted November 20, 2006 (edited) I normally don't replay to bot topics, but I love the diagram. Use WinGetPos () to find the position of the window. From there you should be able to get all the information you need about the diablo 2 window to do what you want. You will get its current X and Y value along with the actual windows height and width. If you read the help file you will see that WinGetPos() returns the following array: Success: Returns a 4-element array containing the following information: $array[0]= X position $array[1] = Y position $array[2] = Width $array[3] = Height Edited November 20, 2006 by The Kandie Man "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
Insolence Posted November 20, 2006 Author Share Posted November 20, 2006 Yeah, that's the easy stuff to get; that diagram (I assume) wasn't made specifically for this topic. The problem I'm having is converting the screen x/y coordinates into Diablo II game world coordinates. Thanks for the reply, though, I'll try to explain a bit better: Given the values: Current world X,Y - 4623, 4620 Current mouse position in window X,Y - 400, 200 I need to find an equation to get the value under the mouse, which is: World X,Y = 4616, 4613 The Diablo II world is made on an isometric plane, and I have no idea how to convert the coordinates "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
erifash Posted November 20, 2006 Share Posted November 20, 2006 (edited) I don't know about the isometric or API stuff (I would say use client coords) but this formula I wrote (from a previous topic) should put you on the right track: ; converts coords (x,y) in (a,b ) screen resolution ; to coords (u,v) in (c,d) screen resolution $x = 800 $y = 600 $a = 1024 $b = 768 $c = @DesktopWidth $d = @DesktopHeight $u = ( $c * $x ) / $a ;resulting x coord $v = ( $d * $y ) / $b ;resulting y coord MsgBox(0, "original(" & $x & "," & $y & ")", "new(" & $u & "," & $v & ")") EDIT: two posts went by when I was writing this! Edited November 20, 2006 by erifash My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
Insolence Posted November 20, 2006 Author Share Posted November 20, 2006 Erifash: thanks for the reply, but I'm not sure what to plug in there? The Diablo II world is huge, and I'm only viewing a small amount tiles of it at one time. I'm sure there has to be some kind of rotation in the numbers there, because it's on an isometric plane. Thanks for digging up that function though And thanks for the reply "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
darkshadow791 Posted November 20, 2006 Share Posted November 20, 2006 Not sure exactly what you want, but if you're looking for pixel length from one point to another point with degree's just google for some of the stuff.If it's 45* exactly based on your screen (I dunno if it is) then here is how you'd do it:Take the middle of the screen, or wherever it is you are.Make a diagram if you can't do it in your head.|\| \|__\So if the x aka bottom distance (to the left) is 1 unit and the y degree (up) is 1 units, then in a 45-45-90 triangle, which is what this would be, it would be (Square root of)2 units.http://en.wikipedia.org/wiki/45-45-90_triangleMake a func of it to make it easier. $x distance * squarerootof2 or w/e it is. Note Taker Lite - a note taking / converting tool. Link to comment Share on other sites More sharing options...
Insolence Posted November 20, 2006 Author Share Posted November 20, 2006 Thanks for the reply, darkshadow, but that's not what I'm looking for. "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
jvanegmond Posted November 20, 2006 Share Posted November 20, 2006 (edited) I have created a 3D library once, it used a very simple way of translating one coordinate system to another...The fact that Diablo II uses '45° isometric planes' has nothing to do with how the maps are build and how you should navigate. It is a way of converting a 2D game to almost-3D without it taking a lot of work. Here's the function that calculates the actual coordinates. You might want to learn from it and modify it to use it inside Diablo II.Func _3Dto2D($Px,$Py,$Pz, $Roll, $Pitch, $Yaw) ;calculate roll $Sx = ($Px*Cos($Roll))+($Py*Sin($Roll)) $Sy = ($Py*Cos($Roll))+($Px*Sin(-1*$Roll)) $Px = $Sx $Py = $Sy ;calculate yaw $Sx = ($Px*Cos($yaw))+(-1*$Pz*Sin($yaw)) $Sz = (-1*$Pz*Cos($yaw))+($Px*Sin(-1*$yaw)) $Px = $Sx $Pz = $Sz ;calculate pitch $Sy = ($Py*Cos($Pitch))+(-1*$Pz*Sin($Pitch)) $Sz = (-1*$Pz*Cos($Pitch))+($Py*Sin(-1*$Pitch)) $Py = $Sy $Pz = $Sz ;the actual projection $Pos[0] = (($Px + $Pz)) + $xMid $Pos[1] = (((-1 * $Py) + (0.35 * $Px) - (0.35 * $Pz))) + $yMid Return $Pos EndFuncBy the way, turn the Perspective option off inside Diablo II to see what 45° isometric planes do.and a little bit of info to as to how this works Trigonometric functionIf you are not good at math, don't click this link. Edited November 20, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Insolence Posted November 20, 2006 Author Share Posted November 20, 2006 (edited) Manadar: Thanks a lot! That looks exactly like what I need, I'll just need to figure out what Roll, Pitch, and Yaw are EDIT:http://liftoff.msfc.nasa.gov/academy/rocke...titude/pyr.htmlWhat do I plug in for those variables with Diablo II? Edited November 20, 2006 by Insolence "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
jvanegmond Posted November 20, 2006 Share Posted November 20, 2006 I think that you would be better off doing these calculations in a 2D plane in stead of a 3D one, so I apologize for setting you off on the wrong foot. Calculating a pitch of 45 degrees is definitely a good idea though! Something like this perhaps. $Sy = ($y*Cos(45))+(-1*$x*Sin(45)) $Sx = (-1*$x*Cos(45))+($y*Sin(-45)) $Py = $Sy $Px = $Sx github.com/jvanegmond Link to comment Share on other sites More sharing options...
Insolence Posted November 20, 2006 Author Share Posted November 20, 2006 Thanks for the reply Manadar, and I appriciate you writing out the equation I need. I'll try to implement this immediately "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
jvanegmond Posted November 20, 2006 Share Posted November 20, 2006 (edited) I was still thinking 3D algorithms, here's the 2D version. ^^ Even though this doesn't get the direction right ( I think AutoIt needs radians by default ), you get a good idea of what you want. Func MouseMoveDirection($Direction, $Distance,$speed=10) $x = MouseGetPos(0) $y = MouseGetPos(1) $x=$x + (Cos($Direction)*$Distance) $y=$y + (Sin($Direction)*$Distance) MouseMove($x,$y,$speed) EndFuncoÝ÷ Ù8b²h ÖÞjè¥êÜ¢{Þ®Æí¡©ìº{^²×jëh×6Func MouseMoveDirection($Direction, $Distance,$speed=10) $x = MouseGetPos(0) $y = MouseGetPos(1) $x=$x + (Cos($Direction/180*3.14)*$Distance) $y=$y + (Sin($Direction/180*3.14)*$Distance) MouseMove($x,$y,$speed) EndFunc Edited November 20, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Insolence Posted November 20, 2006 Author Share Posted November 20, 2006 (edited) Unsure as to what I should put for direction, but I'm getting closer and closer to solving this thanks to you! ; Moving from : 4623, 4620 ; Mouse X/Y : 400, 200 ; Move world position to the 0, 0 screen x/y coordinate. $WorldX = 4623 - 30 $WorldY = 4620 - 5 ; Screen coordinates $x = 400 $y = 200 #cs $Sy = abs( ($y*Cos(45))+(-1*$x*Sin(45)) ) $Sx = abs( (-1*$x*Cos(45))+($y*Sin(-45)) ) $Py = Round(($Sy/15) + $WorldY) $Px = Round(($Sx/15) + $WorldX) ; Should get this result: 4616, 4613 ; but returns 4618, 4631 MsgBox("","", $Sx & ", " & $Sy & @CRLF & _ $Px & ", " & $Py ) #CE $Direction = 45 $Distance = Sqrt(($x)^2 + ($y)^2); Distance from 0,0 $x=$x + (Cos($Direction/180*3.14)*$Distance) $y=$y + (Sin($Direction/180*3.14)*$Distance) $Px = Round(($x/15) + $WorldX) $Py = Round(($y/15) + $WorldY) ; Should get this result: 4616, 4613 ; but returns 4641, 4649 MsgBox("","", $x & ", " & $y & @CRLF & _ $Px & ", " & $Py ) I'm trying both methods, the 3D one was pretty close to the results, but for the 2nd one I might be putting in the wrong thing for "Distance." Thanks for your help EDIT: Added what should be returned Edited November 20, 2006 by Insolence "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
jvanegmond Posted November 20, 2006 Share Posted November 20, 2006 You're getting ahead of me now, and I'm having trouble keeping up. Why do you do this? Does this require intimate knowledge of Diablo II coordinates? $Px = Round(($x/15) + $WorldX) $Py = Round(($y/15) + $WorldY) I've written this merely as some exemplary mathematics, so I can't help you from here. Good luck! github.com/jvanegmond Link to comment Share on other sites More sharing options...
Insolence Posted November 20, 2006 Author Share Posted November 20, 2006 Every 15px = 1 tile, in the Diablo world. Thanks for all your help, I'll have to go to my math teacher tomorrow to figure this out. "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
jvanegmond Posted November 20, 2006 Share Posted November 20, 2006 (edited) In that case, I think you could just do this: $TilesToMoveDown = 5 $TitlesToMoveRight = 2 MouseMove(MouseGetPos(0)+($TilesToMoveDown*15),MouseGetPos(1)+($TilesToMoveRight*15)) Edited November 20, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Insolence Posted November 20, 2006 Author Share Posted November 20, 2006 Exactly, but I want to get the World coordinate I'm about to move to, not actually move there. Thanks again for replying, I can tell we're very close "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
jvanegmond Posted November 20, 2006 Share Posted November 20, 2006 (edited) $WorldX = 4162 ; declare some random numbers $WorldY = 4839 $TilesToMoveDown = 5 ; declare the movements $TitlesToMoveRight = 2 $WorldX += $TilesToMoveDown*15 ;the calculations $WorldY += $TilesToMoveRight*15 No need to thank me, I enjoy doing this. ^^ Edited November 20, 2006 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Insolence Posted November 20, 2006 Author Share Posted November 20, 2006 lol, thanks. I still need a functions sort of like these, that use mouse coords: Func MouseCoordsToD2Coords($MouseX,$MouseY) Func D2CoordsToMouseCoords($WorldX,$WorldY) that returns the Diablo II tile underneath the mouse cursor, and the mouse X/Y position of the Diablo II tile on the screen "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
Insolence Posted November 21, 2006 Author Share Posted November 21, 2006 Bump "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now