Hello,
I'm needing help with setting up explosion potions to have a 5-second delay BUT also able to cancel the pot mid-way through the timer and bring it back up.

(Line 142)
BasePotion.cs:
Timer.DelayCall(TimeSpan.FromMilliseconds(5000), () => from.EndAction(this.GetType())); // Default (500)

I've changed this line here to (5000) to give the explosion potions that 5-second delay but you cant bring the potion back up after canceling the timer until that 5-second delay timer has finished, resulting in damage to the thrower. Any help or guidance is greatly appreciated. I'm sure there's a ton of others looking to resolve this issue as well. All of the old posts that fixed this issue no longer exist.

Maybe BaseExplosionPotion.cs has some lines to settle this issue.

I've attached my current files below.

Thanks in advance.
 

Attachments

  • BasePotion.cs
    8.3 KB · Views: 4
  • BaseExplosionPotion.cs
    6.4 KB · Views: 5
SOLVED
BaseExplosionPotion.cs changes to add delay are listed below.

Around Line 70

BaseExplosionPotion.cs:
        public override void Drink(Mobile from)
        {
            if (Core.AOS && (from.Paralyzed || from.Frozen || (from.Spell != null && from.Spell.IsCasting)))
            {
                from.SendLocalizedMessage(1062725); // You can not use a purple potion while paralyzed.
                return;
            }

            int delay = GetDelay(from);

            if (delay > 0)
            {
                from.SendLocalizedMessage(1072529, String.Format("{0}\t{1}", delay, delay > 1 ? "seconds." : "second.")); // You cannot use that for another ~1_NUM~ ~2_TIMEUNITS~
                return;
            }


Around Line 328

BaseExplosionPotion.cs:
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Potion.Deleted || m_Potion.Map == Map.Internal)
                    return;

                IPoint3D p = targeted as IPoint3D;

                if (p == null)
                    return;

                // Add delay
                if (from.AccessLevel == AccessLevel.Player)
                {
                    BaseExplosionPotion.AddDelay(from);
                }

                Map map = from.Map;

                if (map == null)
                    return;

                SpellHelper.GetSurfaceTop(ref p);

                from.RevealingAction();

                IEntity to;

                to = new Entity(Serial.Zero, new Point3D(p), map);

                if (p is Mobile)
                {
                    if (!RelativeLocation) // explosion location = current mob location.
                        p = ((Mobile)p).Location;
                    else
                        to = (Mobile)p;
                }
 
In BaseExplosionPotion:

C#:
public override void Drink(Mobile from)
        {
            if (Core.AOS && (from.Paralyzed || from.Frozen || (from.Spell != null && from.Spell.IsCasting)))
            {
                from.SendLocalizedMessage(1062725); // You can not use a purple potion while paralyzed.
                return;
            }

            var locker = typeof( BaseExplosionPotion );
            if ( !from.BeginAction( locker ) )
                {
                        from.SendMessage( "You must wait a moment before using another purple potion." );
                        return;
                }

                Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), from.EndAction, locker  );

            ThrowTarget targ = from.Target as ThrowTarget;
            Stackable = false; // Scavenged explosion potions won't stack with those ones in backpack, and still will explode.

            if (targ != null && targ.Potion == this)
            {
                return;
            }

            from.RevealingAction();
            from.Target = new ThrowTarget(this);

            if (m_Timer == null)
            {
                from.SendLocalizedMessage(500236); // You should throw it now!

                if (Core.ML)
                {
                    m_Timer = Timer.DelayCall(
                        TimeSpan.FromSeconds(1.0),
                        TimeSpan.FromSeconds(1.25),
                        5,
                        new TimerStateCallback(Detonate_OnTick),
                        new object[] {from, 3}); // 3.6 seconds explosion delay
                }
                else
                {
                    m_Timer = Timer.DelayCall(
                        TimeSpan.FromSeconds(0.75),
                        TimeSpan.FromSeconds(1.0),
                        4,
                        new TimerStateCallback(Detonate_OnTick),
                        new object[] {from, 3}); // 2.6 seconds explosion delay
                }
            }
        }
You need:

C#:
var locker = typeof( BaseExplosionPotion );
            if ( !from.BeginAction( locker ) )
                {
                        from.SendMessage( "You must wait a moment before using another purple potion." );
                        return;
                }

                Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), from.EndAction, locker  );
 
In BaseExplosionPotion:

C#:
public override void Drink(Mobile from)
        {
            if (Core.AOS && (from.Paralyzed || from.Frozen || (from.Spell != null && from.Spell.IsCasting)))
            {
                from.SendLocalizedMessage(1062725); // You can not use a purple potion while paralyzed.
                return;
            }

            var locker = typeof( BaseExplosionPotion );
            if ( !from.BeginAction( locker ) )
                {
                        from.SendMessage( "You must wait a moment before using another purple potion." );
                        return;
                }

                Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), from.EndAction, locker  );

            ThrowTarget targ = from.Target as ThrowTarget;
            Stackable = false; // Scavenged explosion potions won't stack with those ones in backpack, and still will explode.

            if (targ != null && targ.Potion == this)
            {
                return;
            }

            from.RevealingAction();
            from.Target = new ThrowTarget(this);

            if (m_Timer == null)
            {
                from.SendLocalizedMessage(500236); // You should throw it now!

                if (Core.ML)
                {
                    m_Timer = Timer.DelayCall(
                        TimeSpan.FromSeconds(1.0),
                        TimeSpan.FromSeconds(1.25),
                        5,
                        new TimerStateCallback(Detonate_OnTick),
                        new object[] {from, 3}); // 3.6 seconds explosion delay
                }
                else
                {
                    m_Timer = Timer.DelayCall(
                        TimeSpan.FromSeconds(0.75),
                        TimeSpan.FromSeconds(1.0),
                        4,
                        new TimerStateCallback(Detonate_OnTick),
                        new object[] {from, 3}); // 2.6 seconds explosion delay
                }
            }
        }
You need:

C#:
var locker = typeof( BaseExplosionPotion );
            if ( !from.BeginAction( locker ) )
                {
                        from.SendMessage( "You must wait a moment before using another purple potion." );
                        return;
                }

                Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), from.EndAction, locker  );

Thanks I will take a look now
 
Back