sahisahi

Member
1#
I want players to deal +3 lightning damage spell if they are carring an "archmage" staff.

This is what i have righ now, not working so far


Code:
using Server.Items;
using Server.Mobiles;
using Server.Targeting;
using System;
using Server.Regions;


using System; //edited

namespace Server.Spells.Fourth
{
    public class LightningSpell : MagerySpell
    {
        public override SpellCircle Circle { get { return SpellCircle.Fourth; } }
        public override int Sound { get { return 0x29; } }
        public override int ManaCost { get { return 18; } } // edited

        private static readonly SpellInfo m_Info = new SpellInfo(
                "Lightning", "Por Ort Grav",
                263,
                9021,
                Reagent.MandrakeRoot,
                Reagent.SulfurousAsh
            );

        public LightningSpell( Mobile caster, Item scroll ) : base( caster, scroll, m_Info )
        {
        }

       //: pvp changes
        public override TimeSpan GetCastDelay()
        {
            return TimeSpan.FromSeconds(1.7);
        }

        public override double GetResistPercent( Mobile target )
        {
            return 20.0;
        }
     
        public override void OnPlayerCast()
        {
            if (SphereSpellTarget is Mobile)
                Target((Mobile)SphereSpellTarget);
            else if (SphereSpellTarget is BaseWand)
            {
                BaseWand bw = SphereSpellTarget as BaseWand;
                bw.RechargeWand(Caster, this);
            }
            else
                DoFizzle();
        }

        public override void OnCast()
        {
            Caster.Target = new InternalTarget( this );
        }

        public override bool DelayedDamage{ get{ return false; } }

        public void Target( Mobile m )
        {
            if ( !Caster.CanSee( m ) )
            {
                Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
            }

            if ( CheckHSequence( m ) )
            {
                SpellHelper.CheckReflect( (int)Circle, Caster, ref m );
             
                         
                double damage = 14 + ((int)(GetDamageSkill(Caster) - GetResistSkill(m)) / 12);
                             
                             
                if ( CheckResisted( m ) )
             
                         {
                          
                          
                    Caster.SendAsciiMessage (28, "Tu objetivo resiste la magia");
                    m.SendAsciiMessage(93,"Sientes como resistes la magia");
                    damage = (int)(damage * 0.8);
                          

                     
                }
             
                 
             
                m.BoltEffect( 0 );
                Caster.RevealingAction();             
                SpellHelper.Damage( this, m, damage, 0, 0, 0, 0, 100 );
                m.PlaySound(m.GetHurtSound());
                m.Animate(!m.Mounted ? 20 : 29, 5, 1, true, false, 0);
                ////////////////////////////////
             #region lightningboost
             Item weap = (Item)m.FindItemOnLayer(Layer.TwoHanded);
             if (weap is archimagestaff)
             {
                 if (m is PlayerMobile)
                {
 
             damage +=3;
             
               }
               #endregion
              
                ////////////////////////
             
                FinishSequence();

             
                } 
        }
        }
          
            Thanks, sorry for the cheese

 
     
     

        private class InternalTarget : Target
        {
            private readonly LightningSpell m_Owner;

            public InternalTarget( LightningSpell owner ) : base( 12, false, TargetFlags.Harmful )
            {
                m_Owner = owner;
            }

            protected override void OnTarget( Mobile from, object o )
            {
                if ( o is Mobile )
                    m_Owner.Target( (Mobile)o );
            }

            protected override void OnTargetFinish( Mobile from )
            {
                m_Owner.FinishSequence();
            }
        }
    }
        }

2# I want to deal 10% more damage wearing a quiver:

this is my baseranged.cs
Code:
using System;
using Server.Mobiles;
using Server.Network;
using System;
using Server.Items;


namespace Server.Items
{
    public abstract class BaseRanged : BaseMeleeWeapon
    {
        public abstract int EffectID{ get; }
        public abstract Type AmmoType{ get; }
        public abstract Item Ammo{ get; }

              public override int DefHitSound { get { return 0x234; }}
        public override int DefMissSound {get { return Utility.RandomList(0x238, 0x239, 0x23A); }}

        public override SkillName DefSkill{ get{ return SkillName.Archery; } }
        public override WeaponType DefType{ get{ return WeaponType.Ranged; } }
        public override WeaponAnimation DefAnimation{ get{ return WeaponAnimation.ShootBow; } }

        public override SkillName AccuracySkill{ get{ return SkillName.Tactics; } }

        private Timer m_RecoveryTimer; // so we don't start too many timers
        private bool m_Balanced;
        private int m_Velocity;

        [CommandProperty(AccessLevel.GameMaster)]
        public bool Balanced
        {
            get { return m_Balanced; }
            set { m_Balanced = value; InvalidateProperties(); }
        }

        [CommandProperty(AccessLevel.GameMaster)]
        public int Velocity
        {
            get { return m_Velocity; }
            set { m_Velocity = value; InvalidateProperties(); }
        }

        public BaseRanged( int itemID ) : base( itemID )
        {
        }

        public BaseRanged( Serial serial ) : base( serial )
        {
        }

        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            WeaponAbility a = WeaponAbility.GetCurrentAbility(attacker);

            // If you move the swing delay will be reset
            if (DateTime.Now > (attacker.LastMoveTime + GetDelay(attacker)))
            {
                bool canSwing = true;
                Spells.SpellHelper.Turn(attacker, defender);

                attacker.DisruptiveAction();
                attacker.Send(new Swing(0, attacker, defender));
                if ( attacker.InRange( defender.Location, 1 ) )
                {
                attacker.SendAsciiMessage("You are too close!");
                //attacker.Animate( 27, 5, 1, true, false, 0 );                // You are too close to the target.
                 }
                else
                 {

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender, attacker as PlayerMobile))
                        {
                            if (attacker is PlayerMobile)
                            {
                                PlayerMobile pm = (PlayerMobile) attacker;

                                if (pm.LastSwingActionResult == PlayerMobile.SwingAction.Hit)
                                    pm.SwingCount++;
                                else
                                {
                                    pm.LastSwingActionResult = PlayerMobile.SwingAction.Hit;
                                    pm.SwingCount = 2;
                                }
                            }
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            if (attacker is PlayerMobile)
                            {
                                PlayerMobile pm = (PlayerMobile) attacker;
                                if (pm.LastSwingActionResult == PlayerMobile.SwingAction.Miss)
                                    pm.SwingCount++;
                                else
                                {
                                    pm.LastSwingActionResult = PlayerMobile.SwingAction.Miss;
                                    pm.SwingCount = 2;
                                }
                            }
                            OnMiss(attacker, defender);
                        }
                    }
                    else
                        attacker.SendAsciiMessage("You run out of ammo");
                }

                attacker.RevealingAction();

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

                return TimeSpan.FromSeconds(0.25);
            }
        }

        public override void OnHit( Mobile attacker, Mobile defender, double damageBonus )
        {
            ////////////////////////////////////////
            BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver;
            Container pack = attacker.Backpack;
            if (attacker.Player)
                {
                    if (defender is BaseCreature)
                    {
                   //if (quiver == null)
                  // {
                        damageBonus = 0.1;
                }
                if (quiver == null)
                   {
                      // damageBonus = 0.0;
                    }
               
           
            ////////////////////////////////////////
            if (!EventItem)
                if ( attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) && 0.4 >= Utility.RandomDouble() )
                    defender.AddToBackpack( Ammo );

            if (Core.ML && m_Velocity > 0)
            {
                int bonus = (int)attacker.GetDistanceToSqrt(defender);

                if (bonus > 0 && m_Velocity > Utility.Random(100))
                {
                    AOS.Damage(defender, attacker, bonus * 3, 100, 0, 0, 0, 0);

                    if (attacker.Player)
                        attacker.SendLocalizedMessage(1072794); // Your arrow hits its mark with velocity!

                    if (defender.Player)
                        defender.SendLocalizedMessage(1072795); // You have been hit by an arrow with velocity!
                }
            }

            base.OnHit( attacker, defender, damageBonus );
        }
                }
        //////////////////////////////////
               
       
///////////////////////////////////////////
        public override void OnMiss( Mobile attacker, Mobile defender )
        {
            if (!EventItem)
            {
                if (attacker.Player && 0.4 >= Utility.RandomDouble())
                {
                    if (Core.SE)
                    {
                        PlayerMobile p = attacker as PlayerMobile;

                        if (p != null)
                        {
                            Type ammo = AmmoType;

                            if (p.RecoverableAmmo.ContainsKey(ammo))
                                p.RecoverableAmmo[ammo]++;
                            else
                                p.RecoverableAmmo.Add(ammo, 1);

                            if (!p.Warmode)
                            {
                                if (m_RecoveryTimer == null)
                                    m_RecoveryTimer = Timer.DelayCall(TimeSpan.FromSeconds(10), new TimerCallback(p.RecoverAmmo));

                                if (!m_RecoveryTimer.Running)
                                    m_RecoveryTimer.Start();
                            }
                        }
                    }
                    else
                    {
                        Point3D loc = new Point3D(defender.X + Utility.RandomMinMax(-1, 1), defender.Y + Utility.RandomMinMax(-1, 1), defender.Z);
                        IPooledEnumerable eable = defender.Map.GetItemsInRange(loc, 0);
                        int ammoCount = 0;

                        foreach (Item i in eable)
                        {
                            if ((i is Arrow && Ammo is Arrow) || (i is Bolt && Ammo is Bolt))
                            {
                                i.Amount++;
                                ammoCount++;
                                break;
                            }
                        }

                        if (ammoCount < 1)
                            Ammo.MoveToWorld(loc, defender.Map);

                        eable.Free();
                    }
                }
            }
            base.OnMiss( attacker, defender );
        }

        public virtual bool OnFired( Mobile attacker, Mobile defender )
        {
            BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver;
            Container pack = attacker.Backpack;

            if (!EventItem || (EventItem && EventItemConsume))
            {
                if (attacker.Player)
                {
                    if (quiver == null || quiver.LowerAmmoCost == 0 || quiver.LowerAmmoCost > Utility.Random(100))
                    {
                        if (quiver != null && quiver.ConsumeTotal(AmmoType, 1))
                            quiver.InvalidateWeight();
                        else if (pack == null || !pack.ConsumeTotal(AmmoType, 1))
                            return false;
                    }
                }
            }

            if (attacker.Mounted)
            {
                if (DefAnimation == WeaponAnimation.ShootBow)
                    attacker.Animate(27, 5, 1, true, false, 0);
                else if (DefAnimation == WeaponAnimation.ShootXBow)
                    attacker.Animate(28, 5, 1, true, false, 0);
            }
            else
            {
                if (DefAnimation == WeaponAnimation.ShootBow)
                    attacker.Animate(18, 5, 1, true, false, 0);
                else if (DefAnimation == WeaponAnimation.ShootXBow)
                    attacker.Animate(19, 5, 1, true, false, 0);
            }

            attacker.MovingEffect( defender, EffectID, 18, 1, false, false );

            return true;
        }

        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );

            writer.Write( 3 ); // version

            writer.Write((bool)m_Balanced);
            writer.Write((int)m_Velocity);
        }

        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();

            switch ( version )
            {
                case 3:
                    {
                        m_Balanced = reader.ReadBool();
                        m_Velocity = reader.ReadInt();

                        goto case 2;
                    }
                case 2:
                case 1:
                {
                    break;
                }
                case 0:
                {
                    /*m_EffectID =*/ reader.ReadInt();
                    break;
                }
            }

            if ( version < 2 )
            {
                WeaponAttributes.MageWeapon = 0;
                WeaponAttributes.UseBestSkill = 0;
            }
        }

        public override void OnDoubleClick(Mobile from)
        {
            base.OnDoubleClick(from);
        }
    }
}

Right now every arrow deals 1 damage :/
 
Last edited:
For the lightningbolt damage, you need to adjust it befor
Code:
SpellHelper.Damage( this, m, damage, 0, 0, 0, 0, 100 );
 
For the lightningbolt damage, you need to adjust it befor
Code:
SpellHelper.Damage( this, m, damage, 0, 0, 0, 0, 100 );

I did it,

not working,
now lightning deals 17 dmg on my self and 0 damage on other targets :p
 
hmm, I will take a look at lightning then.

for your quiver damage. Replace your code check with
Code:
Item quiver = attacker.FindItemOnLayer(Layer.Cloak);
if (quiver != null && quiver is BaseQuiver)
	if (attacker.Player && defender is BaseCreature)
		damageBonus = 1.1;
 
hmm, I will take a look at lightning then.

for your quiver damage. Replace your code check with
Code:
Item quiver = attacker.FindItemOnLayer(Layer.Cloak);
if (quiver != null && quiver is BaseQuiver)
	if (attacker.Player && defender is BaseCreature)
		damageBonus = 1.1;


THANK YOUUUUUUUUUUU
 
Moving it up before the call to inflict damage should have worked. Can you post what you have now for the spell?



Code:
using Server.Items;
using Server.Mobiles;
using Server.Targeting;
using System;
using Server.Regions;


using System; //edited

namespace Server.Spells.Fourth
{
    public class LightningSpell : MagerySpell
    {
        public override SpellCircle Circle { get { return SpellCircle.Fourth; } }
        public override int Sound { get { return 0x29; } }
        public override int ManaCost { get { return 18; } } // edited

        private static readonly SpellInfo m_Info = new SpellInfo(
                "Lightning", "Por Ort Grav",
                263,
                9021,
                Reagent.MandrakeRoot,
                Reagent.SulfurousAsh
            );

        public LightningSpell( Mobile caster, Item scroll ) : base( caster, scroll, m_Info )
        {
        }

       // pvp changes
        public override TimeSpan GetCastDelay()
        {
            return TimeSpan.FromSeconds(1.7);
        }

        public override double GetResistPercent( Mobile target )
        {
            return 20.0;
        }
       
        public override void OnPlayerCast()
        {
            if (SphereSpellTarget is Mobile)
                Target((Mobile)SphereSpellTarget);
            else if (SphereSpellTarget is BaseWand)
            {
                BaseWand bw = SphereSpellTarget as BaseWand;
                bw.RechargeWand(Caster, this);
            }
            else
                DoFizzle();
        }

        public override void OnCast()
        {
            Caster.Target = new InternalTarget( this );
        }

        public override bool DelayedDamage{ get{ return false; } }

        public void Target( Mobile m )
        {
            if ( !Caster.CanSee( m ) )
            {
                Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
            }

            if ( CheckHSequence( m ) )
            {
                SpellHelper.CheckReflect( (int)Circle, Caster, ref m );
               
                           
                double damage = 14 + ((int)(GetDamageSkill(Caster) - GetResistSkill(m)) / 12);
                               
                               
                if ( CheckResisted( m ) )
               
                         {
                            
                            
                    Caster.SendAsciiMessage (28, "Tu objetivo resiste la magia");
                    m.SendAsciiMessage(93,"Sientes como resistes la magia");
                    damage = (int)(damage * 0.8);
                            

                       
                }
               
                   
               
                m.BoltEffect( 0 );
                Caster.RevealingAction();               
               
                 #region lightningboost
             Item weap = (Item)m.FindItemOnLayer(Layer.TwoHanded);
             if (weap is bastonarchimago)
             {
                // if (m is PlayerMobile)
              //  {
   
             damage +=3;
               
              
            
               #endregion
                
                ////////////////////////
                SpellHelper.Damage( this, m, damage, 0, 0, 0, 0, 100 );
                m.PlaySound(m.GetHurtSound());
                m.Animate(!m.Mounted ? 20 : 29, 5, 1, true, false, 0);
               
                FinishSequence();

               
                }   
        }
        }
            
            

   
       
       

        private class InternalTarget : Target
        {
            private readonly LightningSpell m_Owner;

            public InternalTarget( LightningSpell owner ) : base( 12, false, TargetFlags.Harmful )
            {
                m_Owner = owner;
            }

            protected override void OnTarget( Mobile from, object o )
            {
                if ( o is Mobile )
                    m_Owner.Target( (Mobile)o );
            }

            protected override void OnTargetFinish( Mobile from )
            {
                m_Owner.FinishSequence();
            }
        }
    }
        }
 
All you need to do in the lightning target is revert your change for the damage and add this
Code:
Item weap = Caster.FindItemOnLayer(Layer.TwoHanded);
if (weap != null && weap is Bow && Caster is PlayerMobile)
	damage += 3;

befor SpellHelper.Damage(this, m, damage, 0, 0, 0, 0, 100);
be aware that 3 damage is not flat damage so resist still lower that value

quick edit:
You also need to change weap is Bow to what you want to use there
 
All you need to do in the lightning target is revert your change for the damage and add this
Code:
Item weap = Caster.FindItemOnLayer(Layer.TwoHanded);
if (weap != null && weap is Bow && Caster is PlayerMobile)
	damage += 3;

befor SpellHelper.Damage(this, m, damage, 0, 0, 0, 0, 100);
be aware that 3 damage is not flat damage so resist still lower that value

quick edit:
You also need to change weap is Bow to what you want to use there

What would i do without you guys @Lokai @PyrO

I like the that is not flag damage :)
 
Just in case you need to see it in context:

Code:
        public void Target(Mobile m)
        {
            if (!this.Caster.CanSee(m))
            {
                this.Caster.SendLocalizedMessage(500237); // Target can not be seen.
            }
            else if (this.CheckHSequence(m))
            {
                SpellHelper.Turn(this.Caster, m);

                SpellHelper.CheckReflect((int)this.Circle, this.Caster, ref m);

                double damage;

                if (Core.AOS)
                {
                    damage = this.GetNewAosDamage(23, 1, 4, m);
                }
                else
                {
                    damage = Utility.Random(12, 9);

                    if (this.CheckResisted(m))
                    {
                        damage *= 0.75;

                        m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy.
                    }

                    damage *= this.GetDamageScalar(m);
                }

                m.BoltEffect(0);
               
                Item weap = Caster.FindItemOnLayer(Layer.TwoHanded);
                // last part needed if you only want it to affect other players (m is PlayerMobile)
                if (weap != null && weap is ArchMageStaff && Caster is PlayerMobile && m is PlayerMobile)
                    damage += 3;

                SpellHelper.Damage(this, m, damage, 0, 0, 0, 0, 100);
            }

            this.FinishSequence();
        }
 
Code:
public override void OnHit( Mobile attacker, Mobile defender, double damageBonus )
{
////////////////////////////////////////
Item quiver = attacker.FindItemOnLayer(Layer.Cloak);
if (quiver != null && quiver is BaseQuiver)
if (attacker.Player && defender is BaseCreature)
damageBonus = 1.2;

Item Necklace = attacker.FindItemOnLayer(Layer.Neck);
if (Necklace != null && Necklace is Anillocazador)
if (attacker.Player && defender is BaseCreature)
damageBonus = 1.05;
////////////////////////////////////////
if (!EventItem)
if ( attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) && 0.4 >= Utility.RandomDouble() )
defender.AddToBackpack( Ammo );

if (Core.ML && m_Velocity > 0)
{
int bonus = (int)attacker.GetDistanceToSqrt(defender);

if (bonus > 0 && m_Velocity > Utility.Random(100))
{
AOS.Damage(defender, attacker, bonus * 3, 100, 0, 0, 0, 0);

if (attacker.Player)
attacker.SendLocalizedMessage(1072794); // Your arrow hits its mark with velocity!

if (defender.Player)
defender.SendLocalizedMessage(1072795); // You have been hit by an arrow with velocity!
}
}

base.OnHit( attacker, defender, damageBonus );
}
I added 2 different items that give damage bonus to BaseRanged weapons, if i wear both items, the quiver and the necklace only the higher gets applied:

example: if i wear both and i if i take off the quiver, the bonus from necklace gets applied, if i wear again the quiver the damage from necklace is not there anymore, unless i take out the quiver or vice versa

Is there a way to make them stack?
Thanks!!!!


-----edit--------

Im testing and i changed the necklace bonus to +=0.5 it seems to stack not sure thought
 
Last edited:
Just moved it around a bit basically, worked fine for me
Code:
Item quiver = attacker.FindItemOnLayer(Layer.Cloak);
Item necklace = attacker.FindItemOnLayer(Layer.Neck);
if (attacker.Player && defender is BaseCreature)
{
 	if (quiver != null && quiver is BaseQuiver)
 		damageBonus += .2;

 	if (necklace != null && necklace is Anillocazador)
 		damageBonus += .05;
}
 

Active Shards

Donations

Total amount
$50.00
Goal
$1,000.00
Back