示例#1
0
 public void Add(params SpellId[] ids)
 {
     foreach (SpellId id in ids)
     {
         Add(SpellHandler.Get(id));
     }
 }
        /// <summary>
        /// Adds the spell without doing any further checks nor adding any spell-related skills or showing animations (after load)
        /// </summary>
        internal void OnlyAdd(SpellRecord record)
        {
            SpellId spellId = record.SpellId;
            Spell   spell   = SpellHandler.Get(spellId);

            this.m_byId[spellId] = spell;
        }
示例#3
0
 public void Add(params SpellId[] ids)
 {
     foreach (SpellId id in ids)
     {
         this.Add((ISpellGroup)SpellHandler.Get(id));
     }
 }
示例#4
0
        /// <summary>
        /// Adds the spell without doing any further checks nor adding any spell-related skills or showing animations (after load)
        /// </summary>
        internal void OnlyAdd(SpellRecord record)
        {
            var id = record.SpellId;
            //DeleteFromDB(id);
            var spell = SpellHandler.Get(id);

            m_byId[id] = spell;
        }
示例#5
0
 public void Add(params SpellId[] ids)
 {
     foreach (var id in ids)
     {
         var spell = SpellHandler.Get(id);
         Add(spell);
     }
 }
示例#6
0
 /// <summary>
 /// Teaches a new spell to the unit. Also sends the spell learning animation, if applicable.
 /// </summary>
 public void AddSpell(SpellId spellId)
 {
     if (this.Contains(spellId))
     {
         return;
     }
     this.AddSpell(SpellHandler.Get(spellId));
 }
示例#7
0
        /// <summary>
        /// Only works if you have 2 valid spell ids and oldSpellId already exists.
        /// </summary>
        public void Replace(SpellId oldSpellId, SpellId newSpellId)
        {
            Spell oldSpell, newSpell = SpellHandler.Get(newSpellId);

            if (m_byId.TryGetValue(oldSpellId, out oldSpell))
            {
                Replace(oldSpell, newSpell);
            }
        }
示例#8
0
        /// <summary>
        /// Teaches a new spell to the unit. Also sends the spell learning animation, if applicable.
        /// </summary>
        public void AddSpell(SpellId spellId)
        {
            if (Contains(spellId))
            {
                return;
            }
            var spell = SpellHandler.Get(spellId);

            AddSpell(spell);
        }
示例#9
0
        public Spell GetTriggerSpell()
        {
            var spell = SpellHandler.Get(TriggerSpellId);

            if (spell == null && ContentMgr.ForceDataPresence)
            {
                throw new ContentException("Spell {0} does not have a valid TriggerSpellId: {1}", this, TriggerSpellId);
            }
            return(spell);
        }
示例#10
0
        /// <summary>
        /// Only works if you have 2 valid spell ids and oldSpellId already exists.
        /// </summary>
        public void Replace(SpellId oldSpellId, SpellId newSpellId)
        {
            Spell newSpell = SpellHandler.Get(newSpellId);
            Spell oldSpell;

            if (!this.m_byId.TryGetValue(oldSpellId, out oldSpell))
            {
                return;
            }
            this.Replace(oldSpell, newSpell);
        }
示例#11
0
 /// <summary>
 /// Adds a set of spells to the explicite relationship set of this effect, which is used to determine whether
 /// a certain Spell and this effect have some kind of influence on one another (for procs, talent modifiers etc).
 /// Only adds the spells, will not work on the spells' trigger spells.
 /// </summary>
 /// <param name="abilities"></param>
 public void AddAffectingSpells(params SpellId[] spells)
 {
     if (AffectSpellSet == null)
     {
         AffectSpellSet = new HashSet <Spell>();
     }
     foreach (var spellId in spells)
     {
         AffectSpellSet.Add(SpellHandler.Get(spellId));
     }
 }
 void RunSpell(Unit target, uint spellId)
 {
     if(Util.Utility.Random(0,101)>Cast.Spell.ProcChance)
         return;
    
     Spell spell = SpellHandler.Get(spellId);
     
     if (spell != null)
     {
         Vector3 loc = target.Position;
         SpellCast.Trigger(m_cast.CasterUnit, spell, ref loc, target);
     }
 }
        private void RunSpell(Unit target, uint spellId)
        {
            if ((long)Utility.Random(0, 101) > (long)this.Cast.Spell.ProcChance)
            {
                return;
            }
            Spell spell = SpellHandler.Get(spellId);

            if (spell == null)
            {
                return;
            }
            Vector3 position = target.Position;

            SpellCast.Trigger((WorldObject)this.m_cast.CasterUnit, spell, ref position, (WorldObject)target);
        }
示例#14
0
        public void AddRequiredActivationAuras(params SpellId[] ids)
        {
            var spells = new Spell[ids.Length];

            for (var i = 0; i < ids.Length; i++)
            {
                var spellId = ids[i];
                var spell   = SpellHandler.Get(spellId);
                if (spell == null)
                {
                    throw new ArgumentException("Invalid spell in AddRequiredActivationAuras: " + spellId);
                }
                spells[i] = spell;
            }
            AddRequiredActivationAuras(spells);
        }
示例#15
0
        /// <summary>
        /// Add Spells which, when casted by others on the owner of this Aura, can cause it to trigger it's procs.
        /// Don't add damage spells (they will generate a Proc event anyway).
        /// </summary>
        public void AddTargetProcSpells(params SpellId[] spellIds)
        {
            var spells = new Spell[spellIds.Length];

            for (var i = 0; i < spellIds.Length; i++)
            {
                var id    = spellIds[i];
                var spell = SpellHandler.Get(id);
                if (spell == null)
                {
                    throw new InvalidSpellDataException("Invalid SpellId: " + id);
                }
                spells[i] = spell;
            }
            AddTargetProcSpells(spells);
        }
示例#16
0
        public void AddRequiredActivationAuras(params SpellId[] ids)
        {
            Spell[] spellArray = new Spell[ids.Length];
            for (int index = 0; index < ids.Length; ++index)
            {
                SpellId id    = ids[index];
                Spell   spell = SpellHandler.Get(id);
                if (spell == null)
                {
                    throw new ArgumentException("Invalid spell in AddRequiredActivationAuras: " + id);
                }
                spellArray[index] = spell;
            }

            AddRequiredActivationAuras(spellArray);
        }
示例#17
0
        /// <summary>
        /// Clears the cooldown for the given spell
        /// </summary>
        public void ClearCooldown(SpellId spellId, bool alsoClearCategory = true)
        {
            var spell = SpellHandler.Get(spellId);

            if (spell == null)
            {
                try
                {
                    throw new ArgumentException("No spell given for cooldown", "spellId");
                }
                catch (Exception e)
                {
                    LogUtil.WarnException(e);
                }
                return;
            }
            ClearCooldown(spell, alsoClearCategory);
        }
示例#18
0
        public SkillLearnStatus TryLearnSpell(short skillId, byte level)
        {
            var spell = SpellHandler.Get((uint)(skillId + level * 1000));

            if (spell == null || level <= 0)
            {
                return(SkillLearnStatus.Fail);
            }
            if (spell.LearnLevel > OwnerChar.Level)
            {
                return(SkillLearnStatus.LowLevel);
            }
            if (spell.ClassMask != Asda2ClassMask.All && !spell.ClassMask.HasFlag(OwnerChar.Asda2ClassMask))
            {
                return(SkillLearnStatus.BadProffession);
            }

            if (spell.ProffNum > OwnerChar.RealProffLevel)
            {
                return(SkillLearnStatus.BadProffession);
            }
            if (AvalibleSkillPoints <= 0)
            {
                return(SkillLearnStatus.NotEnoghtSpellPoints);
            }
            if (!OwnerChar.SubtractMoney((uint)spell.Cost))
            {
                return(SkillLearnStatus.NotEnoghtMoney);
            }
            if (level > 1)
            {
                var previusLvlSpell = this.FirstOrDefault(s => s.RealId == skillId);
                if (previusLvlSpell == null || previusLvlSpell.Level != spell.Level - 1)
                {
                    return(SkillLearnStatus.BadSpellLevel);
                }
                Replace(previusLvlSpell, spell);
                return(SkillLearnStatus.Ok);
            }
            AddSpell(spell, true);
            OwnerChar.SendMoneyUpdate();
            return(SkillLearnStatus.Ok);
        }
示例#19
0
        /// <summary>Clears the cooldown for the given spell</summary>
        public void ClearCooldown(SpellId spellId, bool alsoClearCategory = true)
        {
            Spell cooldownSpell = SpellHandler.Get(spellId);

            if (cooldownSpell == null)
            {
                try
                {
                    throw new ArgumentException("No spell given for cooldown", nameof(spellId));
                }
                catch (Exception ex)
                {
                    LogUtil.WarnException(ex);
                }
            }
            else
            {
                this.ClearCooldown(cooldownSpell, alsoClearCategory);
            }
        }
示例#20
0
        public override void AddDefaultSpells()
        {
            // add the default Spells for the race/class

            /*for (var i = 0; i < OwnerChar.Archetype.Spells.Count; i++)
             * {
             *      var spell = OwnerChar.Archetype.Spells[i];
             *      AddNew(spell);
             * }*/
            AddNew(SpellHandler.Get(SpellId.BashRank1));
            AddNew(SpellHandler.Get(SpellId.ArrowStrikeRank1));
            // add all default Spells of all Skills the Char already has
            //foreach (var skill in OwnerChar.Skills)
            //{
            //    for (var i = 0; i < skill.SkillLine.InitialAbilities.Count; i++)
            //    {
            //        var ability = skill.SkillLine.InitialAbilities[i];
            //        AddNew(ability.Spell);
            //    }
            //}
        }
示例#21
0
        /// <summary>
        /// Teaches a new spell to the unit. Also sends the spell learning animation, if applicable.
        /// </summary>
        public void AddSpell(SpellId spellId)
        {
            var spell = SpellHandler.Get(spellId);

            AddSpell(spell);
        }
示例#22
0
 public void Remove(SpellId spellId)
 {
     Replace(SpellHandler.Get(spellId), null);
 }
示例#23
0
        public SkillLearnStatus TryLearnSpell(short skillId, byte level)
        {
            Spell spell = SpellHandler.Get((uint)skillId + (uint)level * 1000U);

            if (spell == null || level <= (byte)0)
            {
                return(SkillLearnStatus.Fail);
            }
            if ((int)spell.LearnLevel > this.OwnerChar.Level)
            {
                return(SkillLearnStatus.LowLevel);
            }
            if (spell.ClassMask != Asda2ClassMask.All &&
                !spell.ClassMask.HasFlag((Enum)this.OwnerChar.Asda2ClassMask) ||
                (int)spell.ProffNum > (int)this.OwnerChar.RealProffLevel)
            {
                return(SkillLearnStatus.JoblevelIsNotHighEnought);
            }
            if (this.AvalibleSkillPoints <= 0)
            {
                return(SkillLearnStatus.NotEnoghtSpellPoints);
            }
            if (!this.OwnerChar.SubtractMoney((uint)spell.Cost))
            {
                return(SkillLearnStatus.NotEnoghtMoney);
            }
            AchievementProgressRecord progressRecord = this.OwnerChar.Achievements.GetOrCreateProgressRecord(1U);

            ++progressRecord.Counter;
            if (progressRecord.Counter == 45U)
            {
                switch (this.OwnerChar.Profession)
                {
                case Asda2Profession.Warrior:
                    this.OwnerChar.DiscoverTitle(Asda2TitleId.ofBattle24);
                    break;

                case Asda2Profession.Archer:
                    this.OwnerChar.DiscoverTitle(Asda2TitleId.ofArchery25);
                    break;

                case Asda2Profession.Mage:
                    this.OwnerChar.DiscoverTitle(Asda2TitleId.ofMagic26);
                    break;
                }
            }

            if (progressRecord.Counter > 90U)
            {
                switch (this.OwnerChar.Profession)
                {
                case Asda2Profession.Warrior:
                    this.OwnerChar.GetTitle(Asda2TitleId.ofBattle24);
                    break;

                case Asda2Profession.Archer:
                    this.OwnerChar.GetTitle(Asda2TitleId.ofArchery25);
                    break;

                case Asda2Profession.Mage:
                    this.OwnerChar.GetTitle(Asda2TitleId.ofMagic26);
                    break;
                }
            }

            progressRecord.SaveAndFlush();
            if (level > (byte)1)
            {
                Spell oldSpell = this.FirstOrDefault <Spell>((Func <Spell, bool>)(s => (int)s.RealId == (int)skillId));
                if (oldSpell == null || oldSpell.Level != spell.Level - 1)
                {
                    return(SkillLearnStatus.BadSpellLevel);
                }
                this.Replace(oldSpell, spell);
                return(SkillLearnStatus.Ok);
            }

            this.AddSpell(spell, true);
            this.OwnerChar.SendMoneyUpdate();
            return(SkillLearnStatus.Ok);
        }
示例#24
0
 public override void AddDefaultSpells()
 {
     this.AddNew(SpellHandler.Get(SpellId.BashRank1));
     this.AddNew(SpellHandler.Get(SpellId.ArrowStrikeRank1));
 }
示例#25
0
 public void Remove(SpellId spellId)
 {
     this.Replace(SpellHandler.Get(spellId), (Spell)null);
 }