Beispiel #1
0
        void HandleUseCritterItem(UseCritterItem useCritterItem)
        {
            Item item = GetPlayer().GetItemByGuid(useCritterItem.ItemGuid);

            if (!item)
            {
                return;
            }

            foreach (var itemEffect in item.GetEffects())
            {
                if (itemEffect.TriggerType != ItemSpelltriggerType.LearnSpellId)
                {
                    continue;
                }

                var speciesEntry = Global.SpellMgr.GetBattlePetSpecies((uint)itemEffect.SpellID);
                if (speciesEntry != null)
                {
                    GetBattlePetMgr().AddPet(speciesEntry.Id, BattlePetMgr.SelectPetDisplay(speciesEntry), BattlePetMgr.RollPetBreed(speciesEntry.Id), BattlePetMgr.GetDefaultPetQuality(speciesEntry.Id));
                }
            }

            GetPlayer().DestroyItem(item.GetBagSlot(), item.GetSlot(), true);
        }
Beispiel #2
0
        void HandleUseCritterItem(UseCritterItem useCritterItem)
        {
            Item item = GetPlayer().GetItemByGuid(useCritterItem.ItemGuid);

            if (!item)
            {
                return;
            }

            if (item.GetTemplate().Effects.Count < 2)
            {
                return;
            }

            uint spellToLearn = (uint)item.GetTemplate().Effects[1].SpellID;

            foreach (BattlePetSpeciesRecord entry in CliDB.BattlePetSpeciesStorage.Values)
            {
                if (entry.SummonSpellID == spellToLearn)
                {
                    GetBattlePetMgr().AddPet(entry.Id, entry.CreatureID, BattlePetMgr.RollPetBreed(entry.Id), BattlePetMgr.GetDefaultPetQuality(entry.Id));
                    _player.UpdateCriteria(CriteriaTypes.OwnBattlePetCount);
                    break;
                }
            }

            GetPlayer().DestroyItem(item.GetBagSlot(), item.GetSlot(), true);
        }
Beispiel #3
0
        void HandleUseCritterItem(UseCritterItem useCritterItem)
        {
            Item item = GetPlayer().GetItemByGuid(useCritterItem.ItemGuid);

            if (!item)
            {
                return;
            }

            if (item.GetBonus().EffectCount < 2)
            {
                return;
            }

            uint spellToLearn = (uint)item.GetEffect(1).SpellID;

            var entry = Global.SpellMgr.GetBattlePetSpecies(spellToLearn);

            if (entry != null)
            {
                GetBattlePetMgr().AddPet(entry.Id, entry.CreatureID, BattlePetMgr.RollPetBreed(entry.Id), BattlePetMgr.GetDefaultPetQuality(entry.Id));
                _player.UpdateCriteria(CriteriaTypes.OwnBattlePetCount);
            }

            GetPlayer().DestroyItem(item.GetBagSlot(), item.GetSlot(), true);
        }
Beispiel #4
0
        public WorldSession(uint id, string name, uint battlenetAccountId, WorldSocket sock, AccountTypes sec, Expansion expansion, long mute_time, string os, Locale locale, uint recruiter, bool isARecruiter)
        {
            m_muteTime = mute_time;
            AntiDOS    = new DosProtection(this);
            m_Socket[(int)ConnectionType.Realm] = sock;
            _security           = sec;
            _accountId          = id;
            _accountName        = name;
            _battlenetAccountId = battlenetAccountId;
            m_accountExpansion  = expansion;
            m_expansion         = (Expansion)Math.Min((byte)expansion, WorldConfig.GetIntValue(WorldCfg.Expansion));
            _os = os;
            m_sessionDbcLocale     = Global.WorldMgr.GetAvailableDbcLocale(locale);
            m_sessionDbLocaleIndex = locale;
            recruiterId            = recruiter;
            isRecruiter            = isARecruiter;
            expireTime             = 60000; // 1 min after socket loss, session is deleted
            m_currentBankerGUID    = ObjectGuid.Empty;
            _battlePetMgr          = new BattlePetMgr(this);
            _collectionMgr         = new CollectionMgr(this);

            m_Address = sock.GetRemoteIpAddress().Address.ToString();
            ResetTimeOutTime(false);
            DB.Login.Execute("UPDATE account SET online = 1 WHERE id = {0};", GetAccountId());     // One-time query
        }
Beispiel #5
0
        public void TeachSpell(Creature npc, Player player, uint spellId)
        {
            TrainerSpell trainerSpell = GetSpell(spellId);

            if (trainerSpell == null || !CanTeachSpell(player, trainerSpell))
            {
                SendTeachFailure(npc, player, spellId, TrainerFailReason.Unavailable);
                return;
            }

            bool sendSpellVisual = true;
            var  speciesEntry    = Global.SpellMgr.GetBattlePetSpecies(trainerSpell.SpellId);

            if (speciesEntry != null)
            {
                if (player.GetSession().GetBattlePetMgr().HasMaxPetCount(speciesEntry, player.GetGUID()))
                {
                    // Don't send any error to client (intended)
                    return;
                }

                sendSpellVisual = false;
            }

            float reputationDiscount = player.GetReputationPriceDiscount(npc);
            long  moneyCost          = (long)(trainerSpell.MoneyCost * reputationDiscount);

            if (!player.HasEnoughMoney(moneyCost))
            {
                SendTeachFailure(npc, player, spellId, TrainerFailReason.NotEnoughMoney);
                return;
            }

            player.ModifyMoney(-moneyCost);

            if (sendSpellVisual)
            {
                npc.SendPlaySpellVisualKit(179, 0, 0);     // 53 SpellCastDirected
                player.SendPlaySpellVisualKit(362, 1, 0);  // 113 EmoteSalute
            }

            // learn explicitly or cast explicitly
            if (trainerSpell.IsCastable())
            {
                player.CastSpell(player, trainerSpell.SpellId, true);
            }
            else
            {
                bool dependent = false;

                if (speciesEntry != null)
                {
                    player.GetSession().GetBattlePetMgr().AddPet(speciesEntry.Id, BattlePetMgr.SelectPetDisplay(speciesEntry), BattlePetMgr.RollPetBreed(speciesEntry.Id), BattlePetMgr.GetDefaultPetQuality(speciesEntry.Id));
                    // If the spell summons a battle pet, we fake that it has been learned and the battle pet is added
                    // marking as dependent prevents saving the spell to database (intended)
                    dependent = true;
                }

                player.LearnSpell(trainerSpell.SpellId, dependent);
            }
        }