예제 #1
0
        public bool CheckSpellTargetMultiple(Mobile from, Object target)
        {
            if (this is SpellTemplate || this is AuraEffect)
            {
                #region multiple auras
                if (this is AuraEffect && target is Mobile)
                {
                    AuraEffect ae      = (AuraEffect)this;
                    byte       purebin = ae.GetPureBin();
                    Console.WriteLine(purebin);
                    //if(ae.Unpure == true) return true;
                    ArrayList al1 = new ArrayList();
                    foreach (Mobile.AuraReleaseTimer art1 in (target as Mobile).Auras)
                    {
                        AuraEffect af = art1.ae;
                        if (af.Aura == ae.Aura)
                        {
                            if (af.Id > ae.Id)
                            {
                                return(false);
                            }
                            else
                            {
                                al1.Add(art1);
                            }
                        }
                    }
                    foreach (Mobile.AuraReleaseTimer art2 in al1)
                    {
                        (target as Mobile).ReleaseAura(art2);
                    }
                }
                #endregion

                #region target is dead
                if (target is Mobile)
                {
                    if ((target as Mobile).Dead == true)
                    {
                        return(false);
                    }
                }
                #endregion
            }

            else
            {
                Console.WriteLine("Ability/Teach spell casted - Id: " + this.Id);
            }
            return(true);
        }
예제 #2
0
        public bool CheckSpell(Mobile from, Object target)
        {
            if (this is SpellTemplate || this is AuraEffect)
            {
                #region multiple auras
                if (this is AuraEffect && target is Mobile)
                {
                    AuraEffect ae      = (AuraEffect)this;
                    byte       purebin = ae.GetPureBin();
                    Console.WriteLine(purebin);
                    //if(ae.Unpure == true) return true;
                    ArrayList al1 = new ArrayList();
                    foreach (Mobile.AuraReleaseTimer art1 in (target as Mobile).Auras)
                    {
                        AuraEffect af = art1.ae;
                        if (af.Aura == ae.Aura)
                        {
                            if (af.Id > ae.Id)
                            {
                                (from as Character).SpellFaillure(SpellFailedReason.AMorePowerfulSpellAlreadyActive);
                                return(false);
                            }
                            else
                            {
                                al1.Add(art1);
                            }
                        }
                    }
                    foreach (Mobile.AuraReleaseTimer art2 in al1)
                    {
                        (target as Mobile).ReleaseAura(art2);
                    }
                }
                #endregion
                #region silence test
                if (from.ForceSilence)
                {
                    from.SpellFaillure(SpellFailedReason.CanDoWhileSilenced);
                    return(false);
                }
                #endregion
                #region avoid cast
                foreach (Mobile.AuraReleaseTimer art in from.Auras)
                {
                    if (art.aura.AvoidCastMagicClass != 0)
                    {
                        if (AbilityClasses.abilityClasses[(int)Id] == art.aura.AvoidCastMagicClass)
                        {
                            from.SpellFaillure(SpellFailedReason.YouCantDoThatYet);
                            return(false);
                        }
                    }
                }

                #endregion
                #region Mana test
                if (!(from is Character) || (from as Character).Player.AccessLevel == AccessLevels.PlayerLevel)
                {
                    if ((this as SpellTemplate).GetManaCost(from) > from.Mana)
                    {
                        from.SpellFaillure(SpellFailedReason.NotEnoughMana);
                        return(false);
                    }
                }
                #endregion
                #region invalid target
                if ((SpellTemplate.SpellEffects[this.Id] is SingleTargetSpellEffect) && !(target is Mobile || target is Character))
                {
                    from.SpellFaillure(SpellFailedReason.InvalidTarget);
                    return(false);
                }
                if ((SpellTemplate.SpellEffects[this.Id] is OnSingleTargetItemSpellEffect) && !(target is Items.Item))
                {
                    from.SpellFaillure(SpellFailedReason.InvalidTarget);
                    return(false);
                }
                if ((SpellTemplate.SpellEffects[this.Id] is TargetXYZSpellEffect) && !(target == null))
                {
                    from.SpellFaillure(SpellFailedReason.InvalidTarget);
                    return(false);
                }
                if ((SpellTemplate.SpellEffects[this.Id] is OnSelfSpellEffect) && target != from)
                {
                    from.SpellFaillure(SpellFailedReason.InvalidTarget);
                    return(false);
                }
                if ((SpellTemplate.SpellEffects[this.Id] is GameObjectTargetSpellEffect) && target is GameObject)
                {
                    from.SpellFaillure(SpellFailedReason.InvalidTarget);
                    return(false);
                }
                #endregion
                #region Standing
                if (from is Character)
                {
                    int st = (int)from.StandState;
                    st = st & 0xffff;
                    StandStates s = (StandStates)st;
                    if (s != StandStates.Standing)
                    {
                        from.SpellFaillure(SpellFailedReason.YouHaveToStandingToDoThat);
                        return(false);
                    }
                }
                #endregion
                #region caster is dead
                if (from.Dead == true)
                {
                    from.SpellFaillure(SpellFailedReason.YouAreDead);
                    return(false);
                }
                #endregion
                #region have spell
                if (!from.HaveSpell(this.Id))
                {
                    from.SpellFaillure(SpellFailedReason.SpellNotLearned);
                    return(false);
                }
                #endregion
                #region level test
                if (from is Character)
                {
                    if (!((from as Character).AccountLevel == AccessLevels.Admin || (from as Character).AccountLevel == AccessLevels.GM))
                    {
                        if (from.Level < (this as SpellTemplate).RequieredLevel)
                        {
                            from.SpellFaillure(SpellFailedReason.YouAreNotEnoughLevel);
                            return(false);
                        }
                    }
                }
                else
                {
                    if (this is SpellTemplate || this is AuraEffect)
                    {
                        if (from.Level < (this as SpellTemplate).RequieredLevel)
                        {
                            from.SpellFaillure(SpellFailedReason.YouAreNotEnoughLevel);
                            return(false);
                        }
                    }
                }
                #endregion
                #region target type
                if (SpecificSpellTargets.specificSpellTargets[(int)this.Id] != 0 && target is Mobile)
                {
                    int    k   = (int)SpecificSpellTargets.specificSpellTargets[(int)this.Id];
                    int    j   = k;
                    Mobile mob = (Mobile)target;
                    Console.WriteLine(" " + j + " ");
                    j &= mob.NpcType;
                    Console.WriteLine(" " + j + " " + mob.NpcType);
                    if ((j == 0))
                    {
                        from.SpellFaillure(SpellFailedReason.RequiredExoticAmno);
                        Console.WriteLine("upppppps");
                        return(false);
                    }
                }
                #endregion
            }
            else
            {
                Console.WriteLine("Ability/Teach spell casted - Id: " + this.Id);
            }
            return(true);
        }
예제 #3
0
        public bool CheckSpellTarget(Mobile from, Object target)
        {
            if (this is SpellTemplate || this is AuraEffect)
            {
                #region multiple auras
                if (this is AuraEffect && target is Mobile)
                {
                    AuraEffect ae      = (AuraEffect)this;
                    byte       purebin = ae.GetPureBin();
                    Console.WriteLine(purebin);
                    //if(ae.Unpure == true) return true;
                    ArrayList al1 = new ArrayList();
                    foreach (Mobile.AuraReleaseTimer art1 in (target as Mobile).Auras)
                    {
                        AuraEffect af = art1.ae;
                        if (af.Aura == ae.Aura)
                        {
                            if (af.Id > ae.Id)
                            {
                                (from as Character).SpellFaillure(SpellFailedReason.AMorePowerfulSpellAlreadyActive);
                                return(false);
                            }
                            else
                            {
                                al1.Add(art1);
                            }
                        }
                    }
                    foreach (Mobile.AuraReleaseTimer art2 in al1)
                    {
                        (target as Mobile).ReleaseAura(art2);
                    }
                }
                #endregion
                #region invalid target
                if ((SpellTemplate.SpellEffects[this.Id] is SingleTargetSpellEffect) && !(target is Mobile || target is Character))
                {
                    from.SpellFaillure(SpellFailedReason.InvalidTarget);
                    return(false);
                }
                if ((SpellTemplate.SpellEffects[this.Id] is OnSingleTargetItemSpellEffect) && !(target is Items.Item))
                {
                    from.SpellFaillure(SpellFailedReason.InvalidTarget);
                    return(false);
                }
                if ((SpellTemplate.SpellEffects[this.Id] is TargetXYZSpellEffect) && !(target == null))
                {
                    from.SpellFaillure(SpellFailedReason.InvalidTarget);
                    return(false);
                }
                if ((SpellTemplate.SpellEffects[this.Id] is OnSelfSpellEffect) && target != from)
                {
                    from.SpellFaillure(SpellFailedReason.InvalidTarget);
                    return(false);
                }
                if ((SpellTemplate.SpellEffects[this.Id] is GameObjectTargetSpellEffect) && target is GameObject)
                {
                    from.SpellFaillure(SpellFailedReason.InvalidTarget);
                    return(false);
                }
                #endregion
                #region target is dead
                if (target is Mobile)
                {
                    if ((target as Mobile).Dead == true)
                    {
                        from.SpellFaillure(SpellFailedReason.YouAreDead);
                        return(false);
                    }
                }
                #endregion
            }

            else
            {
                Console.WriteLine("Ability/Teach spell casted - Id: " + this.Id);
            }
            return(true);
        }