If you call this function it will give you the value of of X Pos like
you mentioned...
ok if you press "w" button you will walk in the direction your
cam is looking...
to calculate in what direction you are looking... lets say North is
0 or 360 degree (circle)... Now you know your Chara Pos and
the Pos of your Camera.... Make a line across these points (draw
it on a paper)... now make a triangle with 1X90 degree angle so
you can calculate the othe angles...
like that you can calculate how many degree away from North
you are looking...
do the same with your current Pos and the Target Pos where to walk
to... and you know the angle you should be looking to in order to walk
streight to your Target Point...
seems a bit complicated with my bad english... maybe the code helps
its only for 2 dimensional walk points.. but can be extended the same
way for 3-dimensional walking (like for flying in Aion..)
this should help:
http://en.wikipedia.org/wiki/Slope
Calculate the view angle (incl. translation 90 to 360 degree...)
Code:
Func playerrotation()
;~ Return MEMREADDLL($playerrotation, "float")
OPENAIONMEMORY()
$STATICOFFSET = Dec("00D149AC")
Global $PID
Global $CUROFFSET[1]
$CUROFFSET[0] = 0
$BASEADDR = _MEMORYMODULEGETBASEADDRESS($PID, "ffxivgame.exe")
$FINALADDR = "0x" & Hex($BASEADDR + $STATICOFFSET)
$MEMTEST = _MEMORYREAD($FINALADDR, $OPENMEM)
$MEMTEST = _MEMORYREAD($MEMTEST + 0x40 , $OPENMEM)
$MEMTEST = _MEMORYREAD($MEMTEST + 0x64 , $OPENMEM )
$MEMTEST = _MEMORYREAD($MEMTEST + 0x1A4 , $OPENMEM )
$MEMTEST = _MEMORYREAD($MEMTEST , $OPENMEM )
$MEMTEST = _MEMORYREAD($MEMTEST + 0x10 , $OPENMEM )
$camx = _MEMORYREAD($MEMTEST + 0x030 , $OPENMEM, "Float")
$camy = _MEMORYREAD($MEMTEST + 0x038 , $OPENMEM, "Float")
$playerxcoord = playerxpos()
$playerycoord = playerypos()
$diffy = round( $camy - $playerycoord,6)
$diffx = round($camx - $playerxcoord,6)
$Steigung = $diffy/ $diffx
$pi = 3.14159265358979
$RADZUGRAD = 180 / $pi
$GRAD = atan( $Steigung ) * $RADZUGRAD
$GRAD = 90 - $GRAD
if $diffy > 0 and $diffx > 0 Then
$GRAD = 90 - $GRAD +270
Return $GRAD
ElseIf $diffy < 0 and $diffx < 0 Then
$grad = 180 - $GRAD
Return $GRAD
ElseIf $diffy > 0 and $diffx < 0 Then
$grad = ( 180 - $GRAD )
Return $GRAD
ElseIf $diffy < 0 and $diffx > 0 Then
$grad = (180 - $GRAD ) +180
Return $GRAD
EndIf
EndFunc
other useful stuff:
Code:
func switchrotate($target, $now)
if($target < $now) then
if(($now - $target) > 180) then
$rot_key = GUICtrlRead($rightkey)
else
$rot_key = GUICtrlRead($leftkey)
Endif
else
if(($target - $now) > 180) then
$rot_key = GUICtrlRead($leftkey)
else
$rot_key = GUICtrlRead($rightkey)
endif
endif
endfunc
func getangle($diffx, $diffy)
$Steigung = $diffy/ $diffx
$pi = 3.14159265358979
$RADZUGRAD = 180 / $pi
$GRAD = atan( $Steigung ) * $RADZUGRAD
$GRAD = 90 - $GRAD
if $diffy > 0 and $diffx > 0 Then ;
$GRAD = 180 - $GRAD
;~ MsgBox( 0 , "after1" , $GRAD )
Return $GRAD
ElseIf $diffy < 0 and $diffx < 0 Then ;
$grad = 270 + $GRAD
;~ MsgBox( 0 , "after2" , $GRAD )
Return $GRAD
ElseIf $diffy > 0 and $diffx < 0 Then ;
$grad = ( 180 - $GRAD ) + 180
;~ MsgBox( 0 , "after3" , $GRAD )
Return $GRAD
ElseIf $diffy < 0 and $diffx > 0 Then ;
$grad = (180 - $GRAD )
;~ MsgBox( 0 , "after4" , $GRAD )
Return $GRAD
EndIf
endfunc
func getthreesixty($angle, $flag = false)
if($flag) then
if($angle < 0) then
$angle = (360 - ($angle * -1))
endif
else
if($angle > 360)then
$angle = $angle - 360
elseif($angle < 0)then
$angle = $angle + 360
endif
endif
return $angle
endfunc
func AlignRotation($x, $y, $z , $move = false)
$playerxcoord = playerxpos()
$playerycoord = playerypos()
$playerzcoord = playerzpos()
if onflight() <> 0 then
$higth = $zcoord - $playerzcoord
$length = $Ycoord - $playerYcoord
if $length < 0 Then
$length = $length * -1
EndIf
$slope = ($higth / $length)
$pi = 3.14159265358979
$radToDeg = 180 / $pi
$winkelff = (ATan($slope) * $radToDeg ) / 2
$winkel = round( $winkelff * -1 , 8)
MemWriteDLL($camy, $winkel ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EndIf
;....
$diffy = round($y - $playerycoord,2)
$diffx = round($x - $playerxcoord,2)
$angle = getangle($diffx, $diffy)
$nowang = playerrotation()
if $readmemwrite = 1 Then
MemWriteDLL($camx, $angle ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$higth = $zcoord - $playerzcoord
$length = $Ycoord - $playerYcoord
if $length < 0 Then
$length = $length * -1
EndIf
$slope = ($higth / $length)
$pi = 3.14159265358979
$radToDeg = 180 / $pi
$winkelff = (ATan($slope) * $radToDeg ) / 2
$winkel = round( $winkelff * -1 , 8)
MemWriteDLL($camy, $winkel ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
Else
switchrotate($angle, $nowang)
If ($angle + 14) < $nowang or ($angle - 14) > $nowang Then
If ($angle+14) < $nowang Then
$nowang = playerrotation()
switchrotate($angle, $nowang)
ControlSend("FINAL FANTASY XIV" , "" , "" , "{"&$rot_key&' down'&"}")
While 1
$nowang= playerrotation()
IF ($angle+4) > $nowang Then
ExitLoop
ElseIf calcdist($xcoord,$ycoord) < 5 Then
ExitLoop
EndIf
WEnd
ElseIf ($angle-14) >$nowang Then
$nowang = playerrotation()
switchrotate($angle, $nowang)
ControlSend("FINAL FANTASY XIV" , "" , "" , "{"&$rot_key&' down'&"}")
While 1
$nowang=playerrotation()
IF ($angle-4) < $nowang Then
ExitLoop
ElseIf calcdist($xcoord,$ycoord) < 5 Then
ExitLoop
EndIf
WEnd
EndIf
ControlSend("FINAL FANTASY XIV" , "" , "" , "{"&$rot_key&' UP'&"}")
EndIf
EndIf
endfunc
sample for walkpoints (has to be tuned a bit):
Code:
func walkpoints($wptype,$WPmax, $gatheronlytype )
$wporgp = "itswp"
$who = guictrlread($whocombo)
$wpX=0
buff()
while $wpX < ($WPmax-1)
for $zx = 1 to $WPmax-1
$wpX=$wpX+1
GUICtrlSetData($status,"Walking to "&$wptype& " "& $zx)
StatusListviewUpdate("Walking to "&$wptype& " "& $zx)
AlignRotation($xcoord, $ycoord, $zcoord , true)
$value=StringSplit(IniRead("Setup.ini",$who,$wptype&$zx,""),"|")
If @error Then MsgBox(0+262144,"",$wptype &" "&$zx & " - WPS")
$xcoord=$value[2]
$ycoord=$value[3]
$zcoord=$value[4]
$type =$value[5]
$distance = calcdist($xcoord,$ycoord)
while $distance > 8
ControlSend("FINAL FANTASY XIV" , "" , "" , "{"&Guictrlread($upkey)&' down'&"}")
AlignRotation($xcoord, $ycoord, $zcoord , true)
$Distance = calcDist($xCoord, $yCoord)
wend
Next
if $wptype = "wp" then
$wpX=0
EndIf
wend
if $wptype = "gwp" then
send("{"&GUICtrlRead($upkey)&' up'&"}")
$wpX=0
walkpoints("wp",$countmax ,$gatheronly)
EndIf
endfunc
should keep you busy for a bit ;)
Peace
Chefes