예제 #1
0
 public static bool InRange(WoWUnit unit)
 {
     if (!IsAliveCombatClass && HealerClass.IsAliveHealerClass)
     {
         return(HealerClass.InRange(unit));
     }
     return(unit.GetDistance < CombatDistance(unit) + (IsMeleeClass ? -1f : GetRange));
 }
예제 #2
0
        public static bool InAggroRange(WoWUnit unit)
        {
            if (!IsAliveCombatClass && HealerClass.IsAliveHealerClass)
            {
                return(HealerClass.InRange(unit));
            }
            float unitCombatReach = unit.GetCombatReach;
            float reach           = unitCombatReach + GetAggroRange;

            return(unit.GetDistance < reach);
        }
예제 #3
0
        public static void UpdateSpellBook()
        {
            try
            {
                uint nbSpells =
                    Memory.WowMemory.Memory.ReadUInt(Memory.WowProcess.WowModule + (uint)Addresses.SpellBook.nbSpell);
                uint spellBookInfoPtr =
                    Memory.WowMemory.Memory.ReadUInt(Memory.WowProcess.WowModule + (uint)Addresses.SpellBook.knownSpell);

                for (UInt32 i = 0; i < nbSpells; i++)
                {
                    uint      Struct = Memory.WowMemory.Memory.ReadUInt(spellBookInfoPtr + i * 4);
                    SpellInfo si     = (SpellInfo)Memory.WowMemory.Memory.ReadObject(Struct, typeof(SpellInfo));
                    if (si.State == SpellInfo.SpellState.Known)
                    {
                        if (!_spellBookID.Contains(si.ID))
                        {
                            _spellBookID.Add(si.ID);
                            _spellBookName.Add(SpellListManager.SpellNameByIdExperimental(si.ID));
                            _spellBookSpell.Add(SpellInfoLUA(si.ID));
                        }
                    }
                    Application.DoEvents();
                }


                foreach (Spell o in _spellBookSpell)
                {
                    o.Update();
                }

                if (CombatClass.IsAliveCombatClass)
                {
                    CombatClass.ResetCombatClass();
                }
                if (HealerClass.IsAliveHealerClass)
                {
                    HealerClass.ResetHealerClass();
                }
            }
            catch (Exception exception)
            {
                Logging.WriteError("UpdateSpellBook(): " + exception);
            }
        }
예제 #4
0
 public static bool InSpellRange(WoWUnit unit, float minRange, float maxRange)
 {
     try
     {
         if (!IsAliveCombatClass && HealerClass.IsAliveHealerClass)
         {
             return(HealerClass.InCustomRange(unit, minRange, maxRange));
         }
         float distance = unit.GetDistance;
         float reach    = maxRange <= 5.0f ? CombatDistance(unit) : CombatDistance(unit, false);
         return(distance <= reach + maxRange && (Math.Abs(minRange) < 0.001 || distance >= reach + minRange));
     }
     catch (Exception exception)
     {
         Logging.WriteError("CombatClass > InCustomRange: " + exception);
         return(false);
     }
 }
예제 #5
0
        public static void UpdateSpellBookThread()
        {
            lock (SpellManagerLocker)
            {
                try
                {
                    Logging.Write("Initialize Character's SpellBook update.");
                    uint nbSpells =
                        Memory.WowMemory.Memory.ReadUInt(Memory.WowProcess.WowModule + (uint)Addresses.SpellBook.SpellBookNumSpells);
                    uint spellBookInfoPtr =
                        Memory.WowMemory.Memory.ReadUInt(Memory.WowProcess.WowModule + (uint)Addresses.SpellBook.SpellBookSpellsPtr);

                    for (UInt32 i = 0; i < nbSpells; i++)
                    {
                        uint Struct = Memory.WowMemory.Memory.ReadUInt(spellBookInfoPtr + i * 4);
                        var  si     = (SpellInfo)Memory.WowMemory.Memory.ReadObject(Struct, typeof(SpellInfo));
                        if ((si.TabId <= 1 || si.TabId > 4) && si.State == SpellInfo.SpellState.Known)
                        {
                            if (!_spellBookID.Contains(si.ID))
                            {
                                _spellBookID.Add(si.ID);
                            }
                            Spell Spell = SpellInfoLUA(si.ID);
                            if (!_spellBookSpell.Contains(Spell))
                            {
                                _spellBookSpell.Add(Spell);
                            }
                        }
                        Application.DoEvents();
                    }

                    UInt32 MountBookNumMounts =
                        Memory.WowMemory.Memory.ReadUInt(Memory.WowProcess.WowModule +
                                                         (uint)Addresses.SpellBook.MountBookNumMounts);
                    UInt32 MountBookMountsPtr =
                        Memory.WowMemory.Memory.ReadUInt(Memory.WowProcess.WowModule +
                                                         (uint)Addresses.SpellBook.MountBookMountsPtr);

                    for (UInt32 i = 0; i < MountBookNumMounts; i++)
                    {
                        uint MountId = Memory.WowMemory.Memory.ReadUInt(MountBookMountsPtr + i * 4);
                        if (MountId > 0)
                        {
                            if (!_spellBookID.Contains(MountId))
                            {
                                _spellBookID.Add(MountId);
                            }
                            Spell MountSpell = SpellInfoLUA(MountId);
                            if (!_spellBookSpell.Contains(MountSpell))
                            {
                                _spellBookSpell.Add(MountSpell);
                            }
                        }
                        Application.DoEvents();
                    }

                    Logging.Write("Character's SpellBook is currently being fully updated. May take few seconds...");
                    Memory.WowMemory.GameFrameLock();

                    Parallel.ForEach(_spellBookSpell, (spell, loopState) =>
                    {
                        spell.Update();
                    });
                    Memory.WowMemory.GameFrameUnLock();

                    if (CombatClass.IsAliveCombatClass)
                    {
                        CombatClass.ResetCombatClass();
                    }
                    if (HealerClass.IsAliveHealerClass)
                    {
                        HealerClass.ResetHealerClass();
                    }
                    Plugins.Plugins.ReLoadPlugins();
                    Logging.Write("Character's SpellBook fully updated. Found " + _spellBookID.Count + " spells, mounts and professions.");
                }
                catch (Exception exception)
                {
                    Logging.WriteError("UpdateSpellBook(): " + exception);
                }
                finally
                {
                    Memory.WowMemory.GameFrameUnLock();
                }
            }
        }