Wanted to create a set of functions to figure out (eventually) if an agent is in front, behind, left or right of the player based on rotation - wanted to speed up runs a bit by using Heart of Shadow if we're running away from an enemy towards a location.
I know that the player's rotation is from 0 = East to 3 = West, and that some mathematical witchcraft needs to be done based on the target Agent's position relative to the player's position to figure this out. May want to open it up to use MoveX and MoveY instead (player may be running somewhere backwards just after casting)
Has anyone already written code to figure this out?
Well ... i wrote this some years ago for my private uwsc bot.
Can also be used in vaetir bot ...
Code:
;~ Description: Returns best Target to hos from for get best Direction to next Coordinates
Func GetGoodAngle($lDestX, $lDestY)
SendChat("stuck", "/")
RndSleep(100)
Local $lTargetX, $lTargetY, $lBestHosTarget = -1, $lBestHosAngle = 360, $lPI = 3.14159
Local $lMeX = MemoryRead($MePtr + 116, 'float')
Local $lMeY = MemoryRead($MePtr + 120, 'float')
If ComputeDistance($lDestX, $lDestY, $lMeX, $lMeY) < 200 Then Return -3 ; We are too close to our Destination Coords, so take next Coords
Local $lWantedAngle = _ATan2(($lDestY - $lMeY), ($lDestX - $lMeX)) * 180 / $lPI
;Out("WANTED: " & Int($lWantedAngle))
Local $aAgentArray = GetAgentPtrArray2(0xDB, 3, True)
For $i = 1 to $aAgentArray[0]
If GetDistance($MePtr, $aAgentArray[$i]) > 1150 Then ContinueLoop
$lTargetX = MemoryRead($aAgentArray[$i] + 116, 'float')
$lTargetY = MemoryRead($aAgentArray[$i] + 120, 'float')
$lTargetAngle = _ATan2(($lMeY - $lTargetY), ($lMeX - $lTargetX)) * 180 / $lPI
;Out("NOW: " & int($lTargetAngle))
If Abs($lWantedAngle - $lTargetAngle) < $lBestHosAngle Then
$lBestHosTarget = $aAgentArray[$i]
$lBestHosAngle = Abs($lWantedAngle - $lTargetAngle)
;Out("BestTempAngle: " & Int($lTargetAngle))
EndIf
Next
;Out("BESTDIFF: " & Int($lBestHosAngle))
Return $lBestHosTarget
EndFunc
Func _ATan2($y, $x)
$lPI = 3.14159
Select
Case $x > 0
Return ATan($y / $x)
Case $x < 0 And $y >= 0
Return ATan($y / $x) + $lPI
Case $x < 0 And $y < 0
Return ATan($y / $x) - $lPI
Case $x = 0 And $y > 0
Return $lPI / 2
Case $x = 0 And $y < 0
Return -$lPI / 2
Case $x = 0 And $y = 0
Return @ Error
EndSelect
EndFunc
You'll need to edit this to your needs.
Edit: Delete the space between "@" and "Error" in last Return Case.
How the fu** can i disable the **** as this Board interprets it as an internal link without the space?
Well ... i wrote this some years ago for my private uwsc bot.
Can also be used in vaetir bot ...
Code:
;~ Description: Returns best Target to hos from for get best Direction to next Coordinates
Func GetGoodAngle($lDestX, $lDestY)
SendChat("stuck", "/")
RndSleep(100)
Local $lTargetX, $lTargetY, $lBestHosTarget = -1, $lBestHosAngle = 360, $lPI = 3.14159
Local $lMeX = MemoryRead($MePtr + 116, 'float')
Local $lMeY = MemoryRead($MePtr + 120, 'float')
If ComputeDistance($lDestX, $lDestY, $lMeX, $lMeY) < 200 Then Return -3 ; We are too close to our Destination Coords, so take next Coords
Local $lWantedAngle = _ATan2(($lDestY - $lMeY), ($lDestX - $lMeX)) * 180 / $lPI
;Out("WANTED: " & Int($lWantedAngle))
Local $aAgentArray = GetAgentPtrArray2(0xDB, 3, True)
For $i = 1 to $aAgentArray[0]
If GetDistance($MePtr, $aAgentArray[$i]) > 1150 Then ContinueLoop
$lTargetX = MemoryRead($aAgentArray[$i] + 116, 'float')
$lTargetY = MemoryRead($aAgentArray[$i] + 120, 'float')
$lTargetAngle = _ATan2(($lMeY - $lTargetY), ($lMeX - $lTargetX)) * 180 / $lPI
;Out("NOW: " & int($lTargetAngle))
If Abs($lWantedAngle - $lTargetAngle) < $lBestHosAngle Then
$lBestHosTarget = $aAgentArray[$i]
$lBestHosAngle = Abs($lWantedAngle - $lTargetAngle)
;Out("BestTempAngle: " & Int($lTargetAngle))
EndIf
Next
;Out("BESTDIFF: " & Int($lBestHosAngle))
Return $lBestHosTarget
EndFunc
Func _ATan2($y, $x)
$lPI = 3.14159
Select
Case $x > 0
Return ATan($y / $x)
Case $x < 0 And $y >= 0
Return ATan($y / $x) + $lPI
Case $x < 0 And $y < 0
Return ATan($y / $x) - $lPI
Case $x = 0 And $y > 0
Return $lPI / 2
Case $x = 0 And $y < 0
Return -$lPI / 2
Case $x = 0 And $y = 0
Return @ Error
EndSelect
EndFunc
You'll need to edit this to your needs.
Edit: Delete the space between "@" and "Error" in last Return Case.
How the fu** can i disable the shit as this Board interprets it as an internal link without the space?
This is great, thankyou - looks like I can also pull out a good candidate for a GetDirection() function from this, too
Frage zu Relative Exp 10/09/2011 - Metin2 Private Server - 3 Replies kann man über in einem P server die Relative Exp einstellen wie im DE metin?
siehe hier (Quelle Metin2 Wiki)
Suche Relative neuen P-Server 09/11/2011 - Metin2 Private Server - 3 Replies Heey, suche ein P-Server wo noch nich so viele Leute sind.
Sollte regelmäßig On sein und so im August erstellt worden sein...
Pocketnightmares relative neues Browser Game 05/06/2010 - Browsergames - 0 Replies Hi leute
hoffe das ich hier im richtigen bereich bin.
Auf jedenfall, dies ist ein recht neues browser game das vor 2 jahren gestartet wurde und jetzt in open beta ist (keine accounts werden gewhiped oda so falls ihr interesiert seit)
Pocketnightmares handelt sich um einen gemeinen Spielzeug macher der versucht unschuldige kinder in seiner Albtraub welt zu locken und deren unschuldigkeit stehlen will.
Hier sind ein paar features:
Relative EXP ändern 04/01/2010 - Metin2 Private Server - 0 Replies Hi Com ich möchte die Realtive Exp der Mobs ändern also wie das hier:
Wenn der Mob 15 Level über Dir ist = 175% Exp.
Wenn der Mob 14 Level über Dir ist = 170% Exp.
Wenn der Mob 13 Level über Dir ist = 165% Exp.
Wenn der Mob 12 Level über Dir ist = 160% Exp.
Wenn der Mob 11 Level über Dir ist = 155% Exp.
Wenn der Mob 10 Level über Dir ist = 150% Exp.
Wenn der Mob 9 Level über Dir ist = 145% Exp.
Wenn der Mob 8 Level über Dir ist = 140% Exp.