コード例 #1
0
 public void Add(params SpellId[] ids)
 {
     foreach (SpellId id in ids)
     {
         Add(SpellHandler.Get(id));
     }
 }
コード例 #2
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)
        {
            SpellId spellId = record.SpellId;
            Spell   spell   = SpellHandler.Get(spellId);

            this.m_byId[spellId] = spell;
        }
コード例 #3
0
ファイル: SpellGroup.cs プロジェクト: uvbs/Asda2-Server
 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
ファイル: SpellGroup.cs プロジェクト: NecroSharper/WCell
 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
ファイル: SpellCollection.cs プロジェクト: NecroSharper/WCell
        /// <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
ファイル: SpellCollection.cs プロジェクト: 0xFh/Asda2-Project
        /// <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
ファイル: SpellEffect.cs プロジェクト: NecroSharper/WCell
 /// <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));
     }
 }
コード例 #12
0
 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);
     }
 }
コード例 #13
0
        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
ファイル: SpellEffect.cs プロジェクト: NecroSharper/WCell
        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
ファイル: SpellCollection.cs プロジェクト: NecroSharper/WCell
        /// <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
ファイル: SpellCollection.cs プロジェクト: NecroSharper/WCell
        /// <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
ファイル: SpellCollection.cs プロジェクト: NecroSharper/WCell
 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);
 }