Ejemplo n.º 1
0
        /// <summary>
        /// Teaches a new spell to the unit. Also sends the spell learning animation, if applicable.
        /// </summary>
        private void AddSpell(Spell spell, bool sendPacket)
        {
            if (spell.Ability != null)
            {
                Skill skill = this.OwnerChar.Skills[spell.Ability.Skill.Id] ??
                              this.OwnerChar.Skills.Add(spell.Ability.Skill, true);
                if (skill.CurrentTierSpell == null || skill.CurrentTierSpell.SkillTier < spell.SkillTier)
                {
                    skill.CurrentTierSpell = spell;
                }
            }

            if (!this.m_byId.ContainsKey(spell.SpellId))
            {
                Character          ownerChar = this.OwnerChar;
                int                specIndex = this.GetSpecIndex(spell);
                List <SpellRecord> spellList = this.GetSpellList(spell);
                SpellRecord        record    = new SpellRecord(spell.SpellId, ownerChar.EntityId.Low, specIndex);
                record.SaveLater();
                spellList.Add(record);
                base.AddSpell(spell);
            }

            if (!this.m_sendPackets || !sendPacket)
            {
                return;
            }
            if (spell.Level == 1)
            {
                Asda2SpellHandler.SendSkillLearnedFirstTimeResponse(this.OwnerChar.Client, spell.RealId,
                                                                    spell.CooldownTime);
            }
            Asda2SpellHandler.SendSkillLearnedResponse(SkillLearnStatus.Ok, this.OwnerChar, (uint)spell.RealId,
                                                       spell.Level);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Teaches a new spell to the unit. Also sends the spell learning animation, if applicable.
        /// </summary>
        void AddSpell(Spell spell, bool sendPacket)
        {
            // make sure the char knows the skill that this spell belongs to
            if (spell.Ability != null)
            {
                var skill = OwnerChar.Skills[spell.Ability.Skill.Id];
                if (skill == null)
                {
                    // learn new skill
                    skill = OwnerChar.Skills.Add(spell.Ability.Skill, true);
                }

                if (skill.CurrentTierSpell == null || skill.CurrentTierSpell.SkillTier < spell.SkillTier)
                {
                    // upgrade tier
                    skill.CurrentTierSpell = spell;
                }
            }

            if (!m_byId.ContainsKey(spell.SpellId))
            {
                var owner = OwnerChar;


                var specIndex = GetSpecIndex(spell);
                var spells    = GetSpellList(spell);
                var newRecord = new SpellRecord(spell.SpellId, owner.EntityId.Low, specIndex);
                newRecord.SaveLater();
                spells.Add(newRecord);

                base.AddSpell(spell);
            }
            if (m_sendPackets && sendPacket)
            {
                if (spell.Level == 1)
                {
                    Asda2SpellHandler.SendSkillLearnedFirstTimeResponse(OwnerChar.Client, spell.RealId, spell.CooldownTime);
                }
                Asda2SpellHandler.SendSkillLearnedResponse(SkillLearnStatus.Ok, OwnerChar, (uint)spell.RealId, spell.Level);
                //SpellHandler.SendLearnedSpell(owner.Client, spell.Id);

                /*if (!spell.IsPassive)
                 * {
                 *  SpellHandler.SendVisual(owner, 362);	// ouchy: Unnamed constants
                 * }*/
            }
        }