Hello guys,
I'm running into some problems with these functions. When I use the HasEffect(1043) (SkillID from the skill "Rush" which I found while using "Rush" and watching in the Effects/Buffs). The function HasEffect seems to ALWAYS return False (tested with various Effects & Buffs), it always returns False. I'm not able to manage to find why it is going so wrong. I'm hopping that someone can help me.
Code:
;~ Description: Returns time remaining before an effect expires, in milliseconds.
Func GetEffectTimeRemaining($aEffect)
If Not IsDllStruct($aEffect) Then $aEffect = GetEffect($aEffect)
If IsArray($aEffect) Then Return 0
Return DllStructGetData($aEffect, 'Duration') * 1000 - (GetSkillTimer() - DllStructGetData($aEffect, 'TimeStamp'))
EndFunc ;==>GetEffectTimeRemaining
Code:
;Pass skill ID, returns True if you're under the effect
Func HasEffect($Effect)
If IsDllStruct($Effect) = 0 Then $Effect = GetSkillByID($Effect)
If DllStructGetData(GetEffect($Effect), 'SkillID') < 1 Then ; If you're not under effect
Return False
Else
Return True
EndIf
EndFunc ;==>HasEffect
Code:
;~ Description: Returns effect struct or array of effects.
Func GetEffect($aSkillID = 0, $aHeroNumber = 0)
Local $lEffectCount, $lEffectStructAddress
Local $lReturnArray[1] = [0]
Local $lOffset[4]
$lOffset[0] = 0
$lOffset[1] = 0x18
$lOffset[2] = 0x2C
$lOffset[3] = 0x510
Local $lCount = MemoryReadPtr($mBasePointer, $lOffset)
ReDim $lOffset[5]
$lOffset[3] = 0x508
Local $lBuffer
For $i = 0 To $lCount[1] - 1
$lOffset[4] = 0x24 * $i
$lBuffer = MemoryReadPtr($mBasePointer, $lOffset)
If $lBuffer[1] == GetHeroID($aHeroNumber) Then
$lOffset[4] = 0x1C + 0x24 * $i
$lEffectCount = MemoryReadPtr($mBasePointer, $lOffset)
ReDim $lOffset[6]
$lOffset[4] = 0x14 + 0x24 * $i
$lOffset[5] = 0
$lEffectStructAddress = MemoryReadPtr($mBasePointer, $lOffset)
If $aSkillID = 0 Then
ReDim $lReturnArray[$lEffectCount[1] + 1]
$lReturnArray[0] = $lEffectCount[1]
For $i = 0 To $lEffectCount[1] - 1
$lReturnArray[$i + 1] = DllStructCreate('long SkillId;long EffectType;long EffectId;long AgentId;float Duration;long TimeStamp')
$lEffectStructAddress[1] = $lEffectStructAddress[0] + 24 * $i
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lEffectStructAddress[1], 'ptr', DllStructGetPtr($lReturnArray[$i + 1]), 'int', 24, 'int', '')
Next
ExitLoop
Else
Local $lReturn = DllStructCreate('long SkillId;long EffectType;long EffectId;long AgentId;float Duration;long TimeStamp')
For $i = 0 To $lEffectCount[1] - 1
DllCall($mKernelHandle, 'int', 'ReadProcessMemory', 'int', $mGWProcHandle, 'int', $lEffectStructAddress[0] + 24 * $i, 'ptr', DllStructGetPtr($lReturn), 'int', 24, 'int', '')
If DllStructGetData($lReturn, 'SkillID') = $aSkillID Then Return $lReturn
Next
EndIf
EndIf
Next
Return $lReturnArray
EndFunc ;==>GetEffect