Exemple #1
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);
            }
        }
Exemple #2
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();
                }
            }
        }