Esempio n. 1
0
 public TAVFlourish(int weaponability)
 {
     m_Ability = WeaponAbility.Abilities[weaponability];
 }
Esempio n. 2
0
        public virtual void Serialize(GenericWriter writer)
        {
            writer.Write(1);

            writer.Write(DamageIndex);

            writer.Write((int)MagicalAbility);
            writer.Write(TokunoTame);

            writer.Write(RegenHits);
            writer.Write(RegenStam);
            writer.Write(RegenMana);

            writer.Write(SpecialAbilities != null ? SpecialAbilities.Length : 0);

            if (SpecialAbilities != null)
            {
                for (var index = 0; index < SpecialAbilities.Length; index++)
                {
                    SpecialAbility abil = SpecialAbilities[index];

                    writer.Write(Array.IndexOf(SpecialAbility.Abilities, abil));
                }
            }

            writer.Write(AreaEffects != null ? AreaEffects.Length : 0);

            if (AreaEffects != null)
            {
                for (var index = 0; index < AreaEffects.Length; index++)
                {
                    AreaEffect abil = AreaEffects[index];

                    writer.Write(Array.IndexOf(AreaEffect.Effects, abil));
                }
            }

            writer.Write(WeaponAbilities != null ? WeaponAbilities.Length : 0);

            if (WeaponAbilities != null)
            {
                for (var index = 0; index < WeaponAbilities.Length; index++)
                {
                    WeaponAbility abil = WeaponAbilities[index];

                    writer.Write(Array.IndexOf(WeaponAbility.Abilities, abil));
                }
            }

            writer.Write(Advancements != null ? Advancements.Count : 0);

            if (Advancements != null)
            {
                for (var index = 0; index < Advancements.Count; index++)
                {
                    object o = Advancements[index];

                    if (o is MagicalAbility ability)
                    {
                        writer.Write(1);
                        writer.Write((int)ability);
                    }
                    else if (o is SpecialAbility specialAbility)
                    {
                        writer.Write(2);
                        writer.Write(Array.IndexOf(SpecialAbility.Abilities, specialAbility));
                    }
                    else if (o is AreaEffect effect)
                    {
                        writer.Write(3);
                        writer.Write(Array.IndexOf(AreaEffect.Effects, effect));
                    }
                    else if (o is WeaponAbility weaponAbility)
                    {
                        writer.Write(4);
                        writer.Write(Array.IndexOf(WeaponAbility.Abilities, weaponAbility));
                    }
                    else if (o is SkillName skillName)
                    {
                        writer.Write(5);
                        writer.Write((int)skillName);
                    }
                    else
                    {
                        writer.Write(0);
                    }
                }
            }
        }
Esempio n. 3
0
        public AbilityProfile(BaseCreature bc, GenericReader reader)
        {
            int version = reader.ReadInt();

            Creature = bc;

            switch (version)
            {
            case 0:
                DamageIndex = -1;
                break;

            case 1:
                DamageIndex = reader.ReadInt();
                break;
            }

            MagicalAbility = (MagicalAbility)reader.ReadInt();
            TokunoTame     = reader.ReadBool();

            RegenHits = reader.ReadInt();
            RegenStam = reader.ReadInt();
            RegenMana = reader.ReadInt();

            int count = reader.ReadInt();

            SpecialAbilities = new SpecialAbility[count];

            for (int i = 0; i < count; i++)
            {
                SpecialAbilities[i] = SpecialAbility.Abilities[reader.ReadInt()];
            }

            count       = reader.ReadInt();
            AreaEffects = new AreaEffect[count];

            for (int i = 0; i < count; i++)
            {
                AreaEffects[i] = AreaEffect.Effects[reader.ReadInt()];
            }

            count           = reader.ReadInt();
            WeaponAbilities = new WeaponAbility[count];

            for (int i = 0; i < count; i++)
            {
                WeaponAbilities[i] = WeaponAbility.Abilities[reader.ReadInt()];
            }

            count = reader.ReadInt();
            for (int i = 0; i < count; i++)
            {
                if (Advancements == null)
                {
                    Advancements = new List <object>();
                }

                switch (reader.ReadInt())
                {
                case 1: Advancements.Add((MagicalAbility)reader.ReadInt()); break;

                case 2: Advancements.Add(SpecialAbility.Abilities[reader.ReadInt()]); break;

                case 3: Advancements.Add(AreaEffect.Effects[reader.ReadInt()]); break;

                case 4: Advancements.Add(WeaponAbility.Abilities[reader.ReadInt()]); break;

                case 5: Advancements.Add((SkillName)reader.ReadInt()); break;
                }
            }
        }
Esempio n. 4
0
    /// <summary>
    /// Generate shell parts in the blueprint, change ship stats accordingly
    /// </summary>
    protected virtual void BuildEntity()
    {
        // all created entities should have blueprints!
        if (!blueprint)
        {
            Debug.Log(this + " does not have a blueprint! EVERY constructed entity should have one!");
        }

        // Remove possible old parts from list
        foreach (var part in parts)
        {
            if (part && part.gameObject && part.gameObject.name != "Shell Sprite")
            {
                Destroy(part.gameObject);
            }
        }
        parts.Clear();
        blueprint.shellHealth.CopyTo(maxHealth, 0);
        blueprint.baseRegen.CopyTo(regenRate, 0);

        if (blueprint)
        {
            this.dialogue = blueprint.dialogue;
        }

        AttemptAddComponents();
        var renderer = GetComponent <SpriteRenderer>();

        if (blueprint)
        { // check if it contains a blueprint (it should)
            if (blueprint.coreSpriteID == "" && blueprint.intendedType == EntityBlueprint.IntendedType.ShellCore)
            {
                Debug.Log(this + "'s blueprint does not contain a core sprite ID!");
                // check if the blueprint does not contain a core sprite ID (it should)
            }
            renderer.sprite = ResourceManager.GetAsset <Sprite>(blueprint.coreSpriteID);
        }
        else
        {
            renderer.sprite = ResourceManager.GetAsset <Sprite>("core1_light");
        }
        renderer.sortingOrder = 101;

        renderer = transform.Find("Minimap Image").GetComponent <SpriteRenderer>();
        if (category == EntityCategory.Station && !(this is Turret))
        {
            if (this as Outpost)
            {
                renderer.sprite = ResourceManager.GetAsset <Sprite>("outpost_minimap_sprite");
            }
            else if (this as Bunker)
            {
                renderer.sprite = ResourceManager.GetAsset <Sprite>("bunker_minimap_sprite");
            }
            else
            {
                renderer.sprite = ResourceManager.GetAsset <Sprite>("minimap_sprite");
            }
            renderer.transform.localScale = new Vector3(3.5F, 3.5F, 3.5F);
        }
        else
        {
            renderer.sprite = ResourceManager.GetAsset <Sprite>("minimap_sprite");
        }


        abilities = new List <Ability>();

        entityName = blueprint.entityName;
        name       = blueprint.entityName;
        GetComponent <Rigidbody2D>().mass = 1; // reset mass
        weight = this as Drone ? 25 : coreWeight;

        var isLightDrone = this as Drone && (this as Drone).type == DroneType.Light; // used for light drone weight reduction

        //For shellcores, create the tractor beam
        // Create shell parts
        if (blueprint != null)
        {
            for (int i = 0; i < blueprint.parts.Count; i++)
            {
                EntityBlueprint.PartInfo part          = blueprint.parts[i];
                PartBlueprint            partBlueprint = ResourceManager.GetAsset <PartBlueprint>(part.partID);

                GameObject partObject = ShellPart.BuildPart(partBlueprint);
                ShellPart  shellPart  = partObject.GetComponent <ShellPart>();
                shellPart.info = part;

                //Add an ability to the part:

                WeaponAbility ab = AbilityUtilities.AddAbilityToGameObjectByID(partObject, part.abilityID, part.secondaryData, part.tier) as WeaponAbility;
                if (ab)  // add weapon diversity
                {
                    ab.type = DroneUtilities.GetDiversityTypeByEntity(this);
                }
                partObject.transform.SetParent(transform, false);
                partObject.transform.SetAsFirstSibling();
                partObject.transform.localEulerAngles = new Vector3(0, 0, part.rotation);
                partObject.transform.localPosition    = new Vector3(part.location.x, part.location.y, 0);
                SpriteRenderer sr = partObject.GetComponent <SpriteRenderer>();
                // sr.flipX = part.mirrored; this doesn't work, it does not flip the collider hitbox
                var tmp = partObject.transform.localScale;
                tmp.x = part.mirrored ? -1 : 1;
                partObject.transform.localScale = tmp;
                sr.sortingOrder = i + 2;
                //entityBody.mass += (isLightDrone ? partBlueprint.mass * 0.6F : partBlueprint.mass);
                var partWeight = isLightDrone ? partBlueprint.mass * 0.6F * weightMultiplier : partBlueprint.mass * weightMultiplier;
                weight       += partWeight;
                maxHealth[0] += partBlueprint.health / 2;
                maxHealth[1] += partBlueprint.health / 4;

                // Drone shell and core health penalty
                if (this as Drone)
                {
                    maxHealth[0] /= 2;
                    maxHealth[1] /= 4;
                }

                string shooterID = AbilityUtilities.GetShooterByID(part.abilityID, part.secondaryData);
                // Add shooter
                if (shooterID != null)
                {
                    var shooter = new GameObject("Shooter");
                    shooter.transform.SetParent(partObject.transform);
                    shooter.transform.localPosition = Vector3.zero;
                    var shooterSprite = shooter.AddComponent <SpriteRenderer>();
                    shooterSprite.sprite = ResourceManager.GetAsset <Sprite>(shooterID);
                    // if(blueprint.parts.Count < 2) shooterSprite.sortingOrder = 500; TODO: Figure out what these lines do
                    // shooterSprite.sortingOrder = sr.sortingOrder + 1;
                    shooterSprite.sortingOrder = 500;
                    shellPart.shooter          = shooter;
                    if (AbilityUtilities.GetAbilityTypeByID(part.abilityID) == AbilityHandler.AbilityTypes.Weapons)
                    {
                        shellPart.weapon = true;
                    }
                }

                var weaponAbility = partObject.GetComponent <WeaponAbility>();
                if (weaponAbility)
                {
                    // if the terrain and category wasn't preset set to the enitity's properties

                    if (weaponAbility.terrain == TerrainType.Unset)
                    {
                        weaponAbility.terrain = Terrain;
                    }
                    if (weaponAbility.category == EntityCategory.Unset)
                    {
                        weaponAbility.category = category;
                    }
                }


                parts.Add(partObject.GetComponent <ShellPart>());
                if (partObject.GetComponent <Ability>())
                {
                    abilities.Insert(0, partObject.GetComponent <Ability>());
                }

                // Disable collider if no sprite
                if (!(partObject.GetComponent <SpriteRenderer>() && partObject.GetComponent <SpriteRenderer>().sprite) &&
                    partObject.GetComponent <Collider2D>() && !partObject.GetComponent <Harvester>())
                {
                    partObject.GetComponent <Collider2D>().enabled = false;
                }
            }
        }

        if (this as ShellCore)
        {
            if (!gameObject.GetComponentInChildren <MainBullet>())
            {
                MainBullet mainBullet = gameObject.AddComponent <MainBullet>();
                mainBullet.SetTier(Mathf.Min(3, 1 + CoreUpgraderScript.GetCoreTier(blueprint.coreShellSpriteID)));
                mainBullet.bulletPrefab = ResourceManager.GetAsset <GameObject>("bullet_prefab");
                mainBullet.terrain      = TerrainType.Air;
                mainBullet.SetActive(true);
                abilities.Insert(0, mainBullet);
            }
            else
            {
                MainBullet mainBullet = gameObject.GetComponentInChildren <MainBullet>();
                mainBullet.SetTier(Mathf.Min(3, 1 + CoreUpgraderScript.GetCoreTier(blueprint.coreShellSpriteID)));
                mainBullet.SetDestroyed(false);
                abilities.Insert(0, mainBullet);
            }
        }

        // unique abilities for mini and worker drones here
        if (this as Drone)
        {
            Drone drone = this as Drone;
            switch (drone.type)
            {
            case DroneType.Mini:
                var     shellObj = transform.Find("Shell Sprite").gameObject;
                Ability ab       = AbilityUtilities.AddAbilityToGameObjectByID(shellObj, 6, null, 1);
                var     shooter  = new GameObject("Shooter");
                shooter.transform.SetParent(shellObj.transform);
                shooter.transform.localPosition = Vector3.zero;
                var shooterSprite = shooter.AddComponent <SpriteRenderer>();
                shooterSprite.sprite       = ResourceManager.GetAsset <Sprite>(AbilityUtilities.GetShooterByID(6));
                shooterSprite.sortingOrder = 500;
                shellObj.GetComponent <ShellPart>().shooter = shooter;
                (ab as WeaponAbility).terrain = TerrainType.Air;
                abilities.Insert(0, ab);
                break;

            default:
                break;
            }
        }
        IsInvisible = false;

        // check to see if the entity is interactible
        if (dialogue && faction == 0)
        {
            interactible = true;
        }

        Transform shellSprite = shell.transform;

        if (shellSprite)
        {
            parts.Add(shellSprite.GetComponent <ShellPart>());
        }
        ConnectedTreeCreator();

        maxHealth.CopyTo(currentHealth, 0);

        if (OnEntitySpawn != null)
        {
            OnEntitySpawn.Invoke(this);
        }
    }
Esempio n. 5
0
        public virtual bool Cast()
        {
            m_StartCastTime = Core.TickCount;

            if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).Peaced)
            {
                m_Caster.SendLocalizedMessage(1072060);                 // You cannot cast a spell while calmed.
            }
            else if (m_Scroll is BaseWand && m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502643);                 // You can not cast a spell while frozen.
            }
            else if (SkillHandlers.SpiritSpeak.IsInSpiritSpeak(m_Caster) || (m_Caster.Spell != null && m_Caster.Spell.IsCasting))
            {
                m_Caster.SendLocalizedMessage(502642);                 // You are already casting a spell.
            }
            else if (BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation(m_Caster, typeof(HorrificBeastSpell)) ||
                     (BlockedByAnimalForm && AnimalForm.UnderTransformation(m_Caster)))
            {
                m_Caster.SendLocalizedMessage(1061091);                 // You cannot cast that spell in this form.
            }
            else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendLocalizedMessage(502643);                 // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && Core.TickCount - m_Caster.NextSpellTime < 0)
            {
                m_Caster.SendLocalizedMessage(502644);                 // You have not yet recovered from casting a spell.
            }
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.UtcNow)
            {
                m_Caster.SendLocalizedMessage(1072060);                 // You cannot cast a spell while calmed.
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                #region Stygian Abyss
                if (m_Caster.Race == Race.Gargoyle && m_Caster.Flying)
                {
                    if (BaseMount.OnFlightPath(m_Caster))
                    {
                        if (m_Caster.IsPlayer())
                        {
                            m_Caster.SendLocalizedMessage(1113750); // You may not cast spells while flying over such precarious terrain.
                            return(false);
                        }
                        else
                        {
                            m_Caster.SendMessage("Your staff level allows you to cast while flying over precarious terrain.");
                        }
                    }
                }
                #endregion

                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() &&
                    m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State        = SpellState.Casting;
                    m_Caster.Spell = this;

                    Caster.Delta(MobileDelta.Flags);

                    if (!(m_Scroll is BaseWand) && RevealOnCast)
                    {
                        m_Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = GetCastDelay();

                    if (ShowHandMovement && !(m_Scroll is SpellStone) && (m_Caster.Body.IsHuman || (m_Caster.Player && m_Caster.Body.IsMonster)))
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (m_Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }

                    if (Core.ML)
                    {
                        WeaponAbility.ClearCurrentAbility(m_Caster);
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    //m_CastTimer.Start();

                    OnBeginCast();

                    if (castDelay > TimeSpan.Zero)
                    {
                        m_CastTimer.Start();
                    }
                    else
                    {
                        m_CastTimer.Tick();
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625, ScaleMana(GetMana()).ToString()); // Insufficient mana. You must have at least ~1_MANA_REQUIREMENT~ Mana to use this spell.
            }

            return(false);
        }
Esempio n. 6
0
        public bool Cast()
        {
            m_StartCastTime = DateTime.Now;

            if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502642);                   // You are already casting a spell.
            }
            else if (BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation(m_Caster, typeof(HorrificBeastSpell)) || (BlockedByAnimalForm && AnimalForm.UnderTransformation(m_Caster)))
            {
                m_Caster.SendLocalizedMessage(1061091);                   // You cannot cast that spell in this form.
            }
            else if (!(m_Scroll is BaseWand || m_Scroll is GnarledStaff) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendLocalizedMessage(502643);                   // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && DateTime.Now < m_Caster.NextSpellTime)
            {
                m_Caster.SendLocalizedMessage(502644);                             // You have not yet recovered from casting a spell.
                m_Caster.NextSpellTime = DateTime.Now + TimeSpan.FromSeconds(0.1); // ANTI SPAM
            }
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.Now)
            {
                m_Caster.SendLocalizedMessage(1072060);                   // You cannot cast a spell while calmed.
            }
            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() && m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State        = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (RevealOnCast)
                    {
                        m_Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    if (ShowHandMovement && m_Caster.Body.IsHuman)
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (m_Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }

                    if (Core.ML)
                    {
                        WeaponAbility.ClearCurrentAbility(m_Caster);
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    OnBeginCast();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                   // Insufficient mana
            }

            return(false);
        }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            int idx = info.ButtonID;

            if (idx == 0)
            {
                sender.Mobile.CloseGump(typeof(SpecialAttackGump));
            }
            if (idx == 1)
            {
                if (PrimaryState == 9781)
                {
                    if (CustomWeaponAbilities.ServerSideSetAbility(sender.Mobile, Primary))
                    {
                        PrimaryState   = 9780;
                        SecondaryState = 9781;
                        ThirdState     = 9781;
                        FourthState    = 9781;
                        FifthState     = 9781;
                    }
                    sender.Mobile.CloseGump(typeof(SpecialAttackGump));
                    sender.Mobile.SendGump(new SpecialAttackGump(m_weapon, sender.Mobile, Abilities, PrimaryState, SecondaryState, ThirdState, FourthState, FifthState));
                }
                else
                {
                    PrimaryState = 9781;
                    WeaponAbility.ClearCurrentAbility(sender.Mobile);
                }
            }
            if (idx == 2)
            {
                if (SecondaryState == 9781)
                {
                    if (CustomWeaponAbilities.ServerSideSetAbility(sender.Mobile, Secondary))
                    {
                        SecondaryState = 9780;
                        PrimaryState   = 9781;
                        ThirdState     = 9781;
                        FourthState    = 9781;
                        FifthState     = 9781;
                    }
                    sender.Mobile.CloseGump(typeof(SpecialAttackGump));
                    sender.Mobile.SendGump(new SpecialAttackGump(m_weapon, sender.Mobile, Abilities, PrimaryState, SecondaryState, ThirdState, FourthState, FifthState));
                }
                else
                {
                    SecondaryState = 9781;
                    WeaponAbility.ClearCurrentAbility(sender.Mobile);
                }
            }
            if (idx == 3)
            {
                if (ThirdState == 9781)
                {
                    if (CustomWeaponAbilities.ServerSideSetAbility(sender.Mobile, Third))
                    {
                        ThirdState     = 9780;
                        SecondaryState = 9781;
                        PrimaryState   = 9781;
                        FourthState    = 9781;
                        FifthState     = 9781;
                    }
                    sender.Mobile.CloseGump(typeof(SpecialAttackGump));
                    sender.Mobile.SendGump(new SpecialAttackGump(m_weapon, sender.Mobile, Abilities, PrimaryState, SecondaryState, ThirdState, FourthState, FifthState));
                }
                else
                {
                    ThirdState = 9781;
                    WeaponAbility.ClearCurrentAbility(sender.Mobile);
                }
            }
            if (idx == 4)
            {
                if (FourthState == 9781)
                {
                    if (CustomWeaponAbilities.ServerSideSetAbility(sender.Mobile, Fourth))
                    {
                        FourthState    = 9780;
                        SecondaryState = 9781;
                        PrimaryState   = 9781;
                        ThirdState     = 9781;
                        FifthState     = 9781;
                    }
                    sender.Mobile.CloseGump(typeof(SpecialAttackGump));
                    sender.Mobile.SendGump(new SpecialAttackGump(m_weapon, sender.Mobile, Abilities, PrimaryState, SecondaryState, ThirdState, FourthState, FifthState));
                }
                else
                {
                    FourthState = 9781;
                    WeaponAbility.ClearCurrentAbility(sender.Mobile);
                }
            }
            if (idx == 5)
            {
                if (FifthState == 9781)
                {
                    if (CustomWeaponAbilities.ServerSideSetAbility(sender.Mobile, Fifth))
                    {
                        FifthState     = 9780;
                        SecondaryState = 9781;
                        PrimaryState   = 9781;
                        FourthState    = 9781;
                        ThirdState     = 9781;
                    }
                    sender.Mobile.CloseGump(typeof(SpecialAttackGump));
                    sender.Mobile.SendGump(new SpecialAttackGump(m_weapon, sender.Mobile, Abilities, PrimaryState, SecondaryState, ThirdState, FourthState, FifthState));
                }
                else
                {
                    FifthState = 9781;
                    WeaponAbility.ClearCurrentAbility(sender.Mobile);
                }
            }
        }
Esempio n. 8
0
        public bool Cast()
        {
            m_StartCastTime = Core.TickCount;

            if (Core.AOS && m_Caster.Spell is Spell && ((Spell)m_Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)m_Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!m_Caster.CheckAlive())
            {
                return(false);
            }
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).Peaced)
            {
                m_Caster.SendLocalizedMessage(1072060);                 // You cannot cast a spell while calmed.
            }
            else if (m_Scroll is BaseWand && m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502643);                 // You can not cast a spell while frozen.
            }
            else if (m_Caster.Spell != null && m_Caster.Spell.IsCasting)
            {
                m_Caster.SendLocalizedMessage(502642);                 // You are already casting a spell.
            }
            else if (BlockedByHorrificBeast && TransformationSpellHelper.UnderTransformation(m_Caster, typeof(HorrificBeastSpell)) ||
                     (BlockedByAnimalForm && AnimalForm.UnderTransformation(m_Caster)))
            {
                m_Caster.SendLocalizedMessage(1061091);                 // You cannot cast that spell in this form.
            }
            else if (!(m_Scroll is BaseWand) && (m_Caster.Paralyzed || m_Caster.Frozen))
            {
                m_Caster.SendLocalizedMessage(502643);                 // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && Core.TickCount - m_Caster.NextSpellTime < 0)
            {
                m_Caster.SendLocalizedMessage(502644);                 // You have not yet recovered from casting a spell.
            }
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).PeacedUntil > DateTime.UtcNow)
            {
                m_Caster.SendLocalizedMessage(1072060);                 // You cannot cast a spell while calmed.
            }
            #region Dueling
            else if (m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).DuelContext != null &&
                     !((PlayerMobile)m_Caster).DuelContext.AllowSpellCast(m_Caster, this))
            {
            }
            #endregion

            else if (m_Caster.Mana >= ScaleMana(GetMana()))
            {
                #region Stygian Abyss
                if (m_Caster.Race == Race.Gargoyle && m_Caster.Flying)
                {
                    var      tiles = Caster.Map.Tiles.GetStaticTiles(Caster.X, Caster.Y, true);
                    ItemData itemData;
                    bool     cancast = true;

                    for (int i = 0; i < tiles.Length && cancast; ++i)
                    {
                        itemData = TileData.ItemTable[tiles[i].ID & TileData.MaxItemValue];
                        cancast  = !(itemData.Name == "hover over");
                    }

                    if (!cancast)
                    {
                        if (m_Caster.IsPlayer())
                        {
                            m_Caster.SendLocalizedMessage(1113750);                             // You may not cast spells while flying over such precarious terrain.
                            return(false);
                        }
                        else
                        {
                            m_Caster.SendMessage("Your staff level allows you to cast while flying over precarious terrain.");
                        }
                    }
                }
                #endregion

                if (m_Caster.Spell == null && m_Caster.CheckSpellCast(this) && CheckCast() &&
                    m_Caster.Region.OnBeginSpellCast(m_Caster, this))
                {
                    m_State        = SpellState.Casting;
                    m_Caster.Spell = this;

                    if (!(m_Scroll is BaseWand) && RevealOnCast)
                    {
                        m_Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = GetCastDelay();

                    if (ShowHandMovement && (m_Caster.Body.IsHuman || (m_Caster.Player && m_Caster.Body.IsMonster)))
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (m_Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (m_Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, m_Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

                    if (ClearHandsOnCast)
                    {
                        m_Caster.ClearHands();
                    }

                    if (Core.ML)
                    {
                        WeaponAbility.ClearCurrentAbility(m_Caster);
                    }

                    m_CastTimer = new CastTimer(this, castDelay);
                    //m_CastTimer.Start();

                    OnBeginCast();

                    if (castDelay > TimeSpan.Zero)
                    {
                        m_CastTimer.Start();
                    }
                    else
                    {
                        m_CastTimer.Tick();
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                 // Insufficient mana
            }

            return(false);
        }
 public ShiftInfo(int shiftID, string name, double strScale, double dexScale, double intScale, double damage, double speed, double armor, double hits, double stam, double mana, double hitRegen, double stamRegen, double manaRegen, int weapID, WeaponAbility primary, WeaponAbility secondary)
 {
     m_ShiftID         = shiftID;
     m_Name            = name;
     m_StrScale        = strScale;
     m_DexScale        = dexScale;
     m_IntScale        = intScale;
     m_DamageScale     = damage;
     m_SwingSpeedScale = speed;
     m_ArmorScale      = armor;
     m_HitScale        = hits;
     m_StamScale       = stam;
     m_ManaScale       = mana;
     m_HitRegen        = hitRegen;
     m_StamRegen       = stamRegen;
     m_ManaRegen       = manaRegen;
     m_WeapID          = weapID;
     m_Primary         = primary;
     m_Secondary       = secondary;
 }
Esempio n. 10
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            WeaponAbility a = WeaponAbility.GetCurrentAbility(attacker);

            // Make sure we've been standing still for .25/.5/1 second depending on Era
            if (DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds(Core.SE ? 0.25 : (Core.AOS ? 0.5 : 1.0))) || (Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot))
            {
                bool canSwing = true;

                if (Core.AOS)
                {
                    canSwing = (!attacker.Paralyzed && !attacker.Frozen);

                    if (canSwing)
                    {
                        Spell sp = attacker.Spell as Spell;

                        canSwing = (sp == null || !sp.IsCasting || !sp.BlocksMovement);
                    }
                }

                if (canSwing && attacker.HarmfulCheck(defender))
                {
                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, defender));

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }
                    }
                }

                attacker.RevealingAction();

                return(GetDelay(attacker));
            }
            else
            {
                attacker.RevealingAction();

                return(TimeSpan.FromSeconds(0.25));
            }
        }