Code:
;**********************************************************************
;** Baically tells if you are in combat or not, yes the way it's calculated is gimp...
;** Didn't have a real choice since doing a BitAND between 0x00080000 and
;** byte[4] of the real flags yeilded me with 0 combat or not...go go Autoit
;**********************************************************************
Func _inCombat($handle)
$Obj = _WoWPlayerBase($handle)
$lvl1Pointer = _MemoryRead($Obj + 0x8,$handle,'ptr')
$Flags = _MemoryRead($lvl1Pointer + 0x3A * 4,$handle,'int')
If $Flags > 8 AND $Flags <> 33554440 Then
return 1
EndIf
return 0
EndFunc
;**********************************************************************
;** Basically this will return an array with the name of the zone and subzone
;** [0] - Real Zone [1] - Sub Zone
;**********************************************************************
Func _WoWZoneInfo($handle)
Dim $zone[2]
$ptrRZ = _MemoryRead(0x010A68B4,$handle,'ptr') ;(p) pointer to real zone
$ptrSZ = _MemoryRead(0x010A68B8,$handle,'ptr') ;(p) pointer to sub zone
$zone[0] = _MemoryRead($ptrRZ,$handle,'char[32]')
$zone[1] = _MemoryRead($ptrSZ,$wow,'char[32]')
return $zone
EndFunc
;**********************************************************************
;** Returns the faction id of target or yourself based on loc given.
;**********************************************************************
Func _WoWFactionID($loc,$handle)
If $loc = "me" Then
$Obj = _WoWPlayerBase($handle)
ElseIf $loc = "target" Then
$Obj = _WoWTargetObj($handle)
EndIf
$lvl1Pointer = _MemoryRead($Obj + 0x8,$handle,'ptr')
$fID = _MemoryRead($lvl1Pointer + 0x36 * 4,$handle,'int')
return $fID
EndFunc
;**********************************************************************
;** Will test if a given factionid from previous function is horde.
;**********************************************************************
Func _isHorde($fID)
If $fID = 1 OR $fID = 3 OR $fID = 4 OR $fID = 115 OR $fID = 1629 Then
return 0
ElseIf $fID = 2 OR $fID = 5 OR $fID = 6 OR $fID = 116 OR $fID = 1610 Then
return 1
EndIf
EndFunc
;**********************************************************************
;** Basically will return some target info in the form of an array
;** [0] - X [4] - Rot Ptr
;** [1] - Y [5] - Current HP
;** [2] - Z
;** [3] - Rotation
;**********************************************************************
Func _WoWTargetInfo($handle)
$tObj = _WoWTargetObj($handle)
$ptrXLoc = $tObj + 0x7D0
$ptrYLoc = $tObj + 0x7D4
$ptrZLoc = $tObj + 0x7D8
$ptrRotLoc = $tObj + 0x7DC
$ptrHealth = $tObj + 0xFF4
Dim $tInf[6]
$tInf[0] = _MemoryRead($ptrXLoc,$handle,'float')
$tInf[1] = _MemoryRead($ptrYLoc,$handle,'float')
$tInf[2] = _MemoryRead($ptrZLoc,$handle,'float')
$tInf[3] = _MemoryRead($ptrRotLoc,$handle,'float')
$tInf[4] = $ptrRotLoc
$tInf[5] = _MemoryRead($ptrHealth,$handle,'int')
return $tInf
EndFunc
;**********************************************************************
;** Basically this will return the target object given the wow handle
;**********************************************************************
Func _WoWTargetObj($handle)
$targetGUID = _MemoryRead(0x10A68E0,$handle,'ptr') ;(p)
$s_curMgrlvl1Pointer = _MemoryRead(0x011CB310,$wow,'ptr') ;(p)
$s_curMgr = _MemoryRead($s_curMgrlvl1Pointer + 0x28A4,$wow,'ptr') ;(p)
$curObj = _MemoryRead($s_curMgr + 0xAC,$handle,'ptr')
While 1
$cGUID = _MemoryRead($curObj + 0x30,$handle,'ptr')
If $cGUID = $targetGUID Then
return $curObj
EndIf
$nextObj = _MemoryRead($curObj + 0x3C,$handle,'ptr')
if $nextObj = $curObj then
return 0
else
$curObj = $nextObj
endif
Wend
EndFunc
;**********************************************************************
;** Sets rotation to a given x/y
;**********************************************************************
Func _WoWSetRot($cordx,$cordy,$handle)
$pInfo = _WoWPlayerInfo($handle)
$curX = $pInfo[0]
$curY = $pInfo[1]
$rotNeed = _WoWRotNeeded($cordx,$cordy,$handle)
_MemoryWrite($pInfo[4],$handle,$rotNeed,'float')
EndFunc
;**********************************************************************
;** calculates rotation needed to x/y
;**********************************************************************
Func _WoWRotNeeded($cordx,$cordy,$handle)
$pInfo = _WoWPlayerInfo($handle)
$curX = $pInfo[0]
$curY = $pInfo[1]
$rotNeed = _ATAN22($cordy - $cury,$cordx - $curX)
If $rotNeed < 0 Then
$rotNeed = $rotNeed + ($pi * 2)
EndIf
return $rotNeed
EndFunc
;**********************************************************************
;** Moves char to x/y loc b line like
;**********************************************************************
Func _WoWGoTo($cordx,$cordy,$handle,$rotWithin = .05,$distWithin = 2)
$i = 0
$sChk = 0
$lastDist = 10000000
Do
$pInfo = _WoWPlayerInfo($handle)
$curRot = $pInfo[3]
$curX = $pInfo[0]
$curY = $pInfo[1]
$mChk = $curRot - _WoWRotNeeded($cordx,$cordy,$handle)
If $mChk < 0 Then
$mChk = 0 - $mChk
EndIf
$dist = _Max(($curX + $curY),($cordx + $cordy)) - _Min(($curX + $curY),($cordx + $cordy))
If $mChk > $rotWithin OR $dist > 3 OR $lastDist > $dist Then
_WoWSetRot($cordx,$cordy,$handle)
EndIf
If $i = 1 AND $lastDist = $dist Then
$sChk = $sChk + 1
EndIf
$lastDist = $dist
$i = 1
Send("{w down}")
Until $dist < $distWithin OR $pInfo[5] = 0 OR $sChk > 25
Send("{w up}")
EndFunc
;**********************************************************************
;** Returns the playerbase
;**********************************************************************
Func _WoWPlayerBase($handle)
$lvl1Pointer = _MemoryRead(0x0127F13C,$handle,'ptr') ;(p)
$lvl2Pointer = _MemoryRead($lvl1Pointer + 0x30,$handle,'ptr')
$pBase = _MemoryRead($lvl2Pointer + 0x28,$handle,'ptr')
return $pBase
EndFunc
;**********************************************************************
;** Returns array with some player info in it
;** [0] - X [4] - Rot Ptr
;** [1] - Y [5] - Current HP
;** [2] - Z
;** [3] - Rotation
;**********************************************************************
Func _WoWPlayerInfo($handle)
$PlayerBase = _WoWPlayerBase($handle)
$ptrXLoc = $PlayerBase + 0x7D0
$ptrYLoc = $PlayerBase + 0x7D4
$ptrZLoc = $PlayerBase + 0x7D8
$ptrRotLoc = $PlayerBase + 0x7DC
$ptrHealth = $PlayerBase + 0xFF4
Dim $pInf[7]
$pInf[0] = _MemoryRead($ptrXLoc,$handle,'float')
$pInf[1] = _MemoryRead($ptrYLoc,$handle,'float')
$pInf[2] = _MemoryRead($ptrZLoc,$handle,'float')
$pInf[3] = _MemoryRead($ptrRotLoc,$handle,'float')
$pInf[4] = $ptrRotLoc
$pInf[5] = _MemoryRead($ptrHealth,$handle,'int')
return $pInf
EndFunc
;**********************************************************************
;** Checks if target or player has a certain buff or debuff based on SpellID.
;**********************************************************************
Func _haveBuff($loc,$bID,$handle)
$buffs = _buffIDs($loc,$handle)
$i = 0
Do
If $buffs[$i] = $bID Then
return 1
EndIf
$i = $i + 1
Until $i > 79
return 0
EndFunc
;**********************************************************************
;** Returns an array of all the buffs/debuffs for a given target or player.
;**********************************************************************
Func _buffIDs($loc,$handle)
If $loc = "me" Then
$Obj = _WoWPlayerBase($handle)
ElseIf $loc = "target" Then
$Obj = _WoWTargetObj($handle)
EndIf
$bStart = 0xE34
Dim $buffs[80]
$bNum = 0
Do
$buffs[$bNum] = _MemoryRead($Obj + $bStart + ($bNum * 4),$handle,'int')
$bNum = $bNum + 1
Until $bNum > 79
return $buffs
EndFunc
;**********************************************************************
;** Checks if you have a certain questID.
;**********************************************************************
Func _haveQuest($qID,$handle)
$curQuests = _questIDs($handle)
$qCnt = 0
While $qCnt < 25
If $curQuests[$qCnt] = $qID Then
return 1
EndIf
$qCnt = $qCnt + 1
WEnd
return 0
EndFunc
;**********************************************************************
;** Returns an array of all the questIDs the player has.
;**********************************************************************
Func _questIDs($handle)
$PlayerBase = _WoWPlayerBase($handle)
$lvl1Pointer = _MemoryRead($PlayerBase + 0x8,$handle,'ptr')
$qStart = 0x9E
Dim $qID[25]
$qNum = 0
Do
$qID[$qNum] = _MemoryRead($lvl1Pointer + ($qStart + (0x04 * ($qNum))) * 4,$handle,'int')
$qNum = $qNum + 1
Until $qNum > 24
return $qID
EndFunc
;**********************************************************************
;** Found this somewhere online thought it was better than default atan
;**********************************************************************
Func _ATAN22(Const $NY, Const $NX)
Const $NPI = 3.14159265358979
Local $NRESULT
If IsNumber($NY) = 0 Then
SetError(1)
Return 0
ElseIf IsNumber($NX) = 0 Then
SetError(1)
Return 0
EndIf
If $NX = 0 Then
If $NY > 0 Then
$NRESULT = $NPI / 2
ElseIf $NY < 0 Then
$NRESULT = 3 * $NPI / 2
Else
SetError(2)
Return 0
EndIf
ElseIf $NX < 0 Then
$NRESULT = ATan($NY / $NX) + $NPI
Else
$NRESULT = ATan($NY / $NX)
EndIf
While $NRESULT < 0
$NRESULT += 2 * $NPI
WEnd
Return $NRESULT
EndFunc