What's new
  • Visit Rebornbuddy
  • Visit Resources
  • Visit API Documentation
  • Visit Downloads
  • Visit Portal
  • Visit Panda Profiles
  • Visit LLamamMagic

Buff.RemainingTime

TarasBulba

Community Developer
Joined
Apr 27, 2015
Messages
794
Reaction score
25
Does anyone know how to get the remaining time of a Buff using ZetaDia.Me.CommonData.GetAttribute & Zeta.Game.Internals.Actors.ActorAttributeType.BuffIconEndTickx.

Thanks.
 
Last edited:
ZetaDia.Me.CommonData.GetAttribute<int>(((int)Power << 12) + ((int)ActorAttributeType.BuffIconEndTick0 & 0xFFF));

dunno if it work
 
Works for most of the skills, thanks, now I need to figure out the CurrentTick of the game to calculate the remaining time :)
 
Solution is below. It seems like certain buffs use different icon index and some buffs have more than one icons, these needs to be hardcoded. Also, the offsets might change with each patch. Haven't checked performance

Code:
    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;
        }
    }

Thanks for the help, BuddyMe :)
 
Back
Top