[Code Release] Cooldown (IsGCD, SpellReady)  and UnitAura(Has Buff, Stacks, TimeLeft) menu

User Tag List

Results 1 to 10 of 10
  1. #1
    SwInY's Avatar Member
    Reputation
    29
    Join Date
    Jul 2009
    Posts
    97
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Code Release] Cooldown (IsGCD, SpellReady) and UnitAura(Has Buff, Stacks, TimeLeft)

    Releasing some more code C#,

    some code is messy, but hey it works.
    any thoughts and words are appreciated.

    dont mind the console.writeline,
    my heal bot is console. as i didn't need a GUI.


    cooldowns.cs
    Code:
    using System;
    using System.Collections.Generic;
    using System.Runtime.InteropServices;
    using System.Linq;
    using System.Text;
    using ConsoleDruidHeals.Managers;
    
    namespace ConsoleDruidHeals.WoWFunctions
    {
    
        public static class Cooldowns
        {
    
            /// <summary>
            /// Returns Is spell on global cooldown
            /// </summary>
            /// <returns>Bool, Yes = on cooldown</returns>
            public static bool IsGCD()
            {
                ulong CurrentTime = ProcessManager.WoWProcess.ReadUInt64((uint)Addresses.CoolDown.PerformanceCounter);
                uint ObjectList = ProcessManager.WoWProcess.ReadUInt((uint)Addresses.CoolDown.GlobalCooldown + 0x8);
    
                try
                {
                    while (ObjectList != 0)
                    {
                        uint StartTime = ProcessManager.WoWProcess.ReadUInt(ObjectList + 0x10);
                        uint GlobalTime = ProcessManager.WoWProcess.ReadUInt(ObjectList + 0x2C);
    
    
                        // Check spell on GCD
                        if ((ulong)(StartTime + GlobalTime) > CurrentTime)
                        {
                            // Some reason bugs out hard. so if global under 10 secs lets just say we found
                            // Cheat way but works ?
                            if (GlobalTime < 10000 && GlobalTime != 0)
                            {
                                return true;
                            }
                        }
    
                        ObjectList = ProcessManager.WoWProcess.ReadUInt(ObjectList + 4);
                    }
                }
                catch (Exception)
                {
                    return false;
                }
                return false;
            }
    
            public static bool SpellReady(int SpellID)
            {
                ulong CurrentTime = ProcessManager.WoWProcess.ReadUInt64((uint)Addresses.CoolDown.PerformanceCounter);
                uint ObjectList = ProcessManager.WoWProcess.ReadUInt((uint)Addresses.CoolDown.GlobalCooldown + 0x8);
    
                try
                {
                    while (ObjectList != 0)
                    {
    
                        try
                        {
                            uint ListSpellID = ProcessManager.WoWProcess.ReadUInt(ObjectList + 8);
                            uint StartTime = ProcessManager.WoWProcess.ReadUInt(ObjectList + 0x10);
                            uint GlobalTime = ProcessManager.WoWProcess.ReadUInt(ObjectList + 0x2C);
                            uint GlobalCooldown = ProcessManager.WoWProcess.ReadUInt(ObjectList + 0x14) + ProcessManager.WoWProcess.ReadUInt(ObjectList + 0x20);
    
                            // Hax fix ****ing heaps annoying and gay
                             if (GlobalTime > 100000) GlobalTime = 0;
    
                            if (ListSpellID == SpellID)
                            {
    
                                // Check spell on GCD
                                if ((ulong)(StartTime + Math.Max(GlobalCooldown, GlobalTime)) > CurrentTime)
                                {
                                    return false;
                                }
    
                            }
    
                        }
                        catch (Exception)
                        {
                        }
    
                        ObjectList = ProcessManager.WoWProcess.ReadUInt(ObjectList + 4);
                    }
                }
                catch (Exception)
                {
                    return true;
                }
    
                return true;
    
            }
    
    
        }
    }

    my UnitAura,
    im sure there is better ways of doing this, but this works fine for me
    UnitAura.cs

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using ConsoleDruidHeals.Managers;
    using ConsoleDruidHeals.Offsets;
    using ConsoleDruidHeals.WoWObjects;
    using System.Runtime.InteropServices;
    
    namespace ConsoleDruidHeals.WoWFunctions
    {
    
        public static class UnitAura
        {
            /// <summary>
            /// Returns If player has buff
            /// </summary>
            /// <param name="SpellID"></param>
            /// <param name="PlayerBase"></param>
            /// <returns></returns>
            public static bool HasBuff(int SpellID, uint PlayerBase)
            {
                try
                {
                    int Count = ProcessManager.WoWProcess.ReadInt(PlayerBase + (uint)Addresses.UnitBaseGetUnitAura.AURA_COUNT_1);
                    uint Table = PlayerBase + (uint)Addresses.UnitBaseGetUnitAura.AURA_TABLE_1;
    
                    if (Count == -1)
                    {
                        Count = ProcessManager.WoWProcess.ReadInt(PlayerBase + (uint)Addresses.UnitBaseGetUnitAura.AURA_COUNT_2);
                        Table = ProcessManager.WoWProcess.ReadUInt(PlayerBase + (uint)Addresses.UnitBaseGetUnitAura.AURA_TABLE_2);
                    }
    
                    uint SpellIndexID;
                    ulong SpellOwnerGUID;
    
                    // Loop threw all our buffs
                    for (int Index = 0; Index < Count - 1; Index++)
                    {
                        SpellIndexID = GetSpellID(Index, Table);
                        SpellOwnerGUID = GetSpellOwnerGUID(Index, Table);
    
                        // If its not us, and not our spell go next
                        if (WoWMe.GUID != SpellOwnerGUID) continue;
                        if (SpellIndexID != SpellID) continue;
    
                        // return true we found him!
                        return true;
                    }
    
                    // nup no good didnt find him false
                    return false;
    
    
                }
                catch (Exception e)
                {
                    Console.WriteLine("TargetSite: {0}\nSource: {1}\nMessage:{2}", e.TargetSite, e.Source, e.Message);
                    return false;
                }
    
            }
    
    
            /// <summary>
            /// Returns Number of stacks SpellID has
            /// </summary>
            /// <param name="SpellID"></param>
            /// <param name="PlayerBase"></param>
            /// <returns></returns>
            public static int Stacks(int SpellID, uint PlayerBase)
            {
                try
                {
                    int Count = ProcessManager.WoWProcess.ReadInt(PlayerBase + (uint)Addresses.UnitBaseGetUnitAura.AURA_COUNT_1);
                    uint Table = PlayerBase + (uint)Addresses.UnitBaseGetUnitAura.AURA_TABLE_1;
    
                    if (Count == -1)
                    {
                        Count = ProcessManager.WoWProcess.ReadInt(PlayerBase + (uint)Addresses.UnitBaseGetUnitAura.AURA_COUNT_2);
                        Table = ProcessManager.WoWProcess.ReadUInt(PlayerBase + (uint)Addresses.UnitBaseGetUnitAura.AURA_TABLE_2);
                    }
    
                    uint SpellIndexID;
                    ulong SpellOwnerGUID;
    
                    // Loop threw all our buffs
                    for (int Index = 0; Index < Count - 1; Index++)
                    {
                        SpellIndexID = GetSpellID(Index, Table);
                        SpellOwnerGUID = GetSpellOwnerGUID(Index, Table);
    
                        // If its not us, and not our spell go next
                        if (WoWMe.GUID != SpellOwnerGUID) continue;
                        if (SpellIndexID != SpellID) continue;
    
                        return GetStacks(Index, Table);
                    }
    
                    return 0;
    
    
                }
                catch (Exception e)
                {
                    Console.WriteLine("TargetSite: {0}\nSource: {1}\nMessage:{2}", e.TargetSite, e.Source, e.Message);
                    return 0;
                }
            }
    
    
            /// <summary>
            /// Returns Number of stacks SpellID has
            /// </summary>
            /// <param name="SpellID"></param>
            /// <param name="PlayerBase"></param>
            /// <returns></returns>
            public static int TimeLeft(int SpellID, uint PlayerBase)
            {
                try
                {
                    int Count = ProcessManager.WoWProcess.ReadInt(PlayerBase + (uint)Addresses.UnitBaseGetUnitAura.AURA_COUNT_1);
                    uint Table = PlayerBase + (uint)Addresses.UnitBaseGetUnitAura.AURA_TABLE_1;
    
                    if (Count == -1)
                    {
                        Count = ProcessManager.WoWProcess.ReadInt(PlayerBase + (uint)Addresses.UnitBaseGetUnitAura.AURA_COUNT_2);
                        Table = ProcessManager.WoWProcess.ReadUInt(PlayerBase + (uint)Addresses.UnitBaseGetUnitAura.AURA_TABLE_2);
                    }
    
                    uint SpellIndexID;
                    ulong SpellOwnerGUID;
    
                    // Loop threw all our buffs
                    for (int Index = 0; Index < Count - 1; Index++)
                    {
                        SpellIndexID = GetSpellID(Index, Table);
                        SpellOwnerGUID = GetSpellOwnerGUID(Index, Table);
    
                        // If its not us, and not our spell go next
                        if (WoWMe.GUID != SpellOwnerGUID) continue;
                        if (SpellIndexID != SpellID) continue;
    
                        return (int)GetTimeLeft(Index, Table);
                    }
    
                    return 0;
    
                }
                catch (Exception e)
                {
                    Console.WriteLine("TargetSite: {0}\nSource: {1}\nMessage:{2}", e.TargetSite, e.Source, e.Message);
                    return 0;
                }
            }
    
    
    
    
    
    // Shouldnt need to touch anything below here
    // this is where all the magic happens :p
            #region MemoryReads
    
            private static uint GetSpellID(int Index, uint Table)
            {
                try
                {
                    return ProcessManager.WoWProcess.ReadUInt(
                        Table + (uint)((uint)Addresses.UnitBaseGetUnitAura.AURA_SPELL_SIZE * Index)
                        + (int)Addresses.UnitBaseGetUnitAura.AURA_SPELL_ID);
                }
                catch (Exception e)
                {
                    Console.WriteLine("TargetSite: {0}\nSource: {1}\nMessage:{2}", e.TargetSite, e.Source, e.Message);
                    return 0;
                }
            }
    
            private static int GetStacks(int Index, uint Table)
            {
                try
                {
                    byte[] Flags;
                    Flags = ProcessManager.WoWProcess.ReadBytes(
                        Table + (uint)((uint)Addresses.UnitBaseGetUnitAura.AURA_SPELL_SIZE * Index)
                        + (uint)Addresses.UnitBaseGetUnitAura.AURA_SPELL_FLAGS, 3);
    
                    return (int)Flags[2];
                }
                catch (Exception e)
                {
                    Console.WriteLine("TargetSite: {0}\nSource: {1}\nMessage:{2}", e.TargetSite, e.Source, e.Message);
                    return 0;
                }
            }
    
            private static ulong GetSpellOwnerGUID(int Index, uint Table)
            {
                try
                {
                    return ProcessManager.WoWProcess.ReadUInt64(
                        Table + (uint)((int)Addresses.UnitBaseGetUnitAura.AURA_SPELL_SIZE * Index));
                }
                catch (Exception e)
                {
                    Console.WriteLine("TargetSite: {0}\nSource: {1}\nMessage:{2}", e.TargetSite, e.Source, e.Message);
                    return 0;
                }
            }
    
    
            private static uint GetTimeLeft(int Index, uint Table)
            {
                try
                {
                    ulong CurrentTime = ProcessManager.WoWProcess.ReadUInt64((uint)Addresses.CoolDown.PerformanceCounter);
                    uint EndTime = ProcessManager.WoWProcess.ReadUInt((uint)Table + (uint)Addresses.UnitBaseGetUnitAura.AURA_SPELL_SIZE * (uint)Index + (uint)Addresses.UnitBaseGetUnitAura.AURA_SPELL_ENDTIME);
    
                    return (uint)(EndTime - CurrentTime);
    
                }
                catch (Exception e)
                {
                    Console.WriteLine("TargetSite: {0}\nSource: {1}\nMessage:{2}", e.TargetSite, e.Source, e.Message);
                    return 0;
                }
            }
    
            #endregion
    
        }
    }
    Last edited by SwInY; 03-29-2011 at 06:59 PM.

    [Code Release] Cooldown (IsGCD, SpellReady)  and UnitAura(Has Buff, Stacks, TimeLeft)
  2. #2
    Seifer's Avatar Site Donator
    Reputation
    129
    Join Date
    Apr 2007
    Posts
    270
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice contribution!

  3. #3
    teufel123's Avatar Active Member
    Reputation
    30
    Join Date
    Feb 2008
    Posts
    114
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is freakin awesome thanks for the share !

  4. #4
    evil2's Avatar Active Member
    Reputation
    27
    Join Date
    Feb 2009
    Posts
    164
    Thanks G/R
    25/9
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    please note
    1) gcd value also depends on latency (if you pvp bot :-)
    2) some spells share cooldows.

    if you are oop, you have to check these manually.
    for example :

    if time > 0 switch SpellId
    case 35395: // Crusader Strike
    if (!unit.SpellCd.ContainsKey(53595)) unit.SpellCd.Add(53595,time); // Hammer of the Righteous
    break;
    case 53595: // Hammer of the Righteous
    if (!unit.SpellCd.ContainsKey(35395)) unit.SpellCd.Add(35395,time); // Crusader Strike
    break;

  5. #5
    SwInY's Avatar Member
    Reputation
    29
    Join Date
    Jul 2009
    Posts
    97
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    evil,

    #1,
    im pritty sure latency has nothing to do with my GCD, since i am using
    ulong CurrentTime = ProcessManager.WoWProcess.ReadUInt64((uint)Addresses.CoolDown.PerformanceCounter );

    if i was using my own performance counter, id have the latency diffrence, but since im reading wow's time. i have no latency issues.

    i am not guessing the time. im actualy reading wow's memory time.
    my bot i made this for is a actual healbot for PVP, it works EXTREMLY fast.
    and latency doesnt have a issue what so ever, and i run at 300-400ms

    Correct me if im wrong guys,

    #2
    also some spells share a cooldown YES,
    this is the base code. not a actual spell code.
    checking them should NOT be in that base code what so ever.


    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using ConsoleDruidHeals.WoWObjects;
    using ConsoleDruidHeals.WoWFunctions;
    using ConsoleDruidHeals.Managers;
    
    
    namespace ConsoleDruidHeals.Druid.Spells
    {
        public static class NaturesSwiftness
        {
            // Public Vars
            public const int SpellID = 17116;
            public const string SpellName = "Nature's Swiftness";
            public static int Button;
    
    
            public static void Init()
            {
                Button = BarManager.GetBarLocation(SpellID);
    
                if (Button != 0)
                {
                    Console.WriteLine("{0} - Button: {1}", SpellName, Button);
                }
                else
                {
                    Console.WriteLine("\t {0} - Not found", SpellName);
                }
            }
    
            public static bool Pulse(WoWUnit Player)
            {
                // If no button to use Return
                if (Button == 0) return false;
    
                // Check if player health higher than swiftmend heal at, if so return
                if (Player.Health_Percent > Swiftmend.HealAt) return false;
    
    
                // Check if swiftmend isnt on CD
                if (!Cooldowns.SpellReady(Swiftmend.SpellID)) return false;
    
                // Check if naturesgrasp isnt on CD
                if (!Cooldowns.SpellReady(SpellID)) return false;
    
                // Tell console were casting?
                Console.WriteLine("Casting {0}", SpellName);
                
                // Press Button
                ControlManager.BGKeyboardPress(Button.ToString());
    
                Spells.Regrowth.Pulse(Player);
    
                return true;
    
    
            }
    
        }
    }

    might just release my whole DruidHealBot,
    since it has EVERYTHING in it.
    Last edited by SwInY; 03-31-2011 at 04:51 PM.

  6. #6
    evil2's Avatar Active Member
    Reputation
    27
    Join Date
    Feb 2009
    Posts
    164
    Thanks G/R
    25/9
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this, got me even better results in pvp:

    StartTime > 0 && StartTime + GlobalTime + latencyfactor > systimeCur = gcd true
    Last edited by evil2; 03-31-2011 at 08:28 PM.

  7. #7
    SwInY's Avatar Member
    Reputation
    29
    Join Date
    Jul 2009
    Posts
    97
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your uselessness is not needed here.
    so stop writing crap.
    i release code and u try correcting me over what 50-60ms??
    be happy i released some of my code. stop trying to correct people over stupid shit that has nothing to do with anything ESPECIALLY my core code..
    you are really miss leading people also, your comments were not needed what so ever.


    My code is the most ACCURATE way of reading the IsGCD being out of process.


    you might be right, if you were getting performancecount threw CODE.
    Code:
                    long frequency;
                    long perfCount;
                    Imports.QueryPerformanceFrequency(out frequency);
                    Imports.QueryPerformanceCounter(out perfCount);
    
                    //Current time in ms
                    long currentTime = (perfCount * 1000) / frequency;
    but i am reading this from WOW.

    Code:
    ulong CurrentTime = ProcessManager.WoWProcess.ReadUInt64((uint)Addresses.CoolDown.PerformanceCounter );
    i stand by my code, untill some one like APOC, or maiN or Cypher says something. untill then. enuff said.
    Last edited by SwInY; 03-31-2011 at 10:36 PM.

  8. #8
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So you're mad because someone is trying to help and make your code better? Strange.

  9. #9
    evil2's Avatar Active Member
    Reputation
    27
    Join Date
    Feb 2009
    Posts
    164
    Thanks G/R
    25/9
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why all the hate?
    i didn't attack you in any way or criticized your code.

    but now i do, because that is not the "most ACCURATE way".

  10. #10
    Apoc's Avatar Angry Penguin
    Reputation
    1387
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/12
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They're correct.

    Also; your buff code is atrocious. Learn how to read entire structs for christs sake.

Similar Threads

  1. [Release] Joker's Fun and Useful Sql Quarie's And Extra!
    By jokerjokes in forum World of Warcraft Emulator Servers
    Replies: 52
    Last Post: 06-19-2008, 04:23 PM
  2. [Release]WoW Fansite Tools and Info
    By xsyx in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 05-10-2008, 07:19 PM
  3. [Release] Amani War Bear and Flying Machine
    By chronic7 in forum World of Warcraft Emulator Servers
    Replies: 23
    Last Post: 01-07-2008, 07:18 PM
  4. Question about release crack for Glider and other nice stuff
    By RedDevil in forum World of Warcraft General
    Replies: 39
    Last Post: 12-13-2006, 12:40 AM
  5. Codes for CE Mountain climb and No damage fall =D
    By FoRbIdDeN in forum World of Warcraft Bots and Programs
    Replies: 23
    Last Post: 10-28-2006, 09:21 AM
All times are GMT -5. The time now is 10:44 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search