internal static class Game
{
const int ObjectManagerAddress = 0x01D895DC;
const int ObjectManagerOfsStorage = 0x798;
const int ObjectManagerStorageOfsTicks = 0x0F8;
internal static int CurrentTick
{
get
{
try
{
var objectManagerPtr = ZetaDia.Memory.Read<IntPtr>(new IntPtr(ObjectManagerAddress));
var objectManagerStoragePtr = IntPtr.Add(objectManagerPtr, ObjectManagerOfsStorage);
return ZetaDia.Memory.Read<int>(IntPtr.Add(objectManagerStoragePtr, ObjectManagerStorageOfsTicks));
}
catch (Exception)
{
return -1;
}
}
}
}
internal static class BuffExtensions
{
/// <summary>
/// Tries to get the remaining time of buff in milliseconds
/// </summary>
internal static bool TryGetRemainingTime(this Buff buff, out int remainingTime)
{
var currentTick = Game.CurrentTick;
if (currentTick == -1)
{
remainingTime = -1;
return false;
}
var buffToLook = buff.SNOId;
var endTickAttribute = ActorAttributeType.BuffIconEndTick0;
switch (buffToLook)
{
// Taeguk
case (int)SNOPower.ItemPassive_Unique_Gem_015_x1:
endTickAttribute = ActorAttributeType.BuffIconEndTick1;
break;
}
var endTick = ZetaDia.Me.CommonData.GetAttribute<int>((buffToLook << 12) + ((int)endTickAttribute & 0xFFF));
remainingTime = (int)((endTick > currentTick) ? (endTick - currentTick) / 60.0d * 1000 : -1);
return remainingTime >= 0;
}
}