RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Stacking Explo Pot's for insta kill....need modifying

Devinticus

Wanderer
Stacking Explo Pot's for insta kill....need modifying

here's the scenario...

Player's afk in town or stationary for any length of time and someone runs up and just dumps mad explo pot's on them and they die... instantly.

Question: How do i put a delay on the amount of time between using the same potion twice?
 

TheNorthStar

Sorceror
Taken from BaseHealPotion.cs

Code:
					if ( from.BeginAction( typeof( BaseHealPotion ) ) )
					{
...

						Timer.DelayCall( TimeSpan.FromSeconds( Delay ), new TimerStateCallback( ReleaseHealLock ), from );

...
		private static void ReleaseHealLock( object state )
		{
			((Mobile)state).EndAction( typeof( BaseHealPotion ) );
		}

So if I understand your question correctly, similar code will give you what you want.
 

Devinticus

Wanderer
unfortunatlly, i dont understand what u just wrote.... hehe i am what most would call a newb, but i think that is still giving me too much credit.. if you could elaborate a little bit please that would be great. like a step by step...Thank you :)
 

TheNorthStar

Sorceror
Ok, open up
RunUO\Scripts\Items\Skill Items\Magical\Potions\Explosion Potions\BaseExplosionPotion.cs

and where it says

Code:
		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;
			}

			ThrowTarget targ = from.Target as ThrowTarget;

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

			from.RevealingAction();

			if ( m_Users == null )
				m_Users = new ArrayList();

			if ( !m_Users.Contains( from ) )
				m_Users.Add( from );

			from.Target = new ThrowTarget( this );

			if ( m_Timer == null )
			{
				from.SendLocalizedMessage( 500236 ); // You should throw it now!
				m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 0.75 ), TimeSpan.FromSeconds( 1.0 ), 4, new TimerStateCallback( Detonate_OnTick ), new object[]{ from, 3 } );
			}
		}

replace it with this:

Code:
		public override void Drink( Mobile from )
		{
			int Delay = 5; // <- Added this line to set the delay between use
			if ( from.BeginAction( typeof( BaseExplosionPotion ) ) ) // <- Added this line and set it to BaseExplosionPotion
			{


			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;
			}

			ThrowTarget targ = from.Target as ThrowTarget;

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

			from.RevealingAction();

			if ( m_Users == null )
				m_Users = new ArrayList();

			if ( !m_Users.Contains( from ) )
				m_Users.Add( from );

			from.Target = new ThrowTarget( this );

			Timer.DelayCall( TimeSpan.FromSeconds( Delay ), new TimerStateCallback( ReleaseExploderLock ), from ); // <- Added this line to set the timer for allowing you to throw another

			if ( m_Timer == null )
			{
				from.SendLocalizedMessage( 500236 ); // You should throw it now!
				m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 0.75 ), TimeSpan.FromSeconds( 1.0 ), 4, new TimerStateCallback( Detonate_OnTick ), new object[]{ from, 3 } );
			}
		}

		private static void ReleaseExploderLock( object state ) // <- Added this as well! Hooray!
		{
			((Mobile)state).EndAction( typeof( BaseExplosionPotion ) );
		}

I haven't actually tested that, but it should work, and hopefully you can see what I did there, I commented it for you.
 

Devinticus

Wanderer
Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
Errors:
+ Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs:
CS1513: Line 100: } expected
CS1518: Line 109: Expected class, delegate, enum, interface, or struct
CS1001: Line 114: Identifier expected
CS1518: Line 114: Expected class, delegate, enum, interface, or struct
CS1001: Line 114: Identifier expected
CS1518: Line 114: Expected class, delegate, enum, interface, or struct
CS1001: Line 115: Identifier expected
CS1001: Line 116: Identifier expected
CS1001: Line 153: Identifier expected
CS1022: Line 155: Type or namespace definition, or end-of-file expected
CS0101: Line 114: The namespace 'Server.Items' already contains a definition
for '?'
CS0101: Line 115: The namespace 'Server.Items' already contains a definition
for '?'
CS0101: Line 116: The namespace 'Server.Items' already contains a definition
for '?'
CS0101: Line 153: The namespace 'Server.Items' already contains a definition
for '?'
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

is the error im getting after copying and pasting tht code into baseexplosionpotion.cs
 

TheNorthStar

Sorceror
oops
Code:
			if ( m_Timer == null )
			{
				from.SendLocalizedMessage( 500236 ); // You should throw it now!
				m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 0.75 ), TimeSpan.FromSeconds( 1.0 ), 4, new TimerStateCallback( Detonate_OnTick ), new object[]{ from, 3 } );
			}
			[B]}[/B] // <-- Just added that

Add a ending bracket as shown above

between

Code:
			if ( m_Timer == null )
			{
				from.SendLocalizedMessage( 500236 ); // You should throw it now!
				m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 0.75 ), TimeSpan.FromSeconds( 1.0 ), 4, new TimerStateCallback( Detonate_OnTick ), new object[]{ from, 3 } );
			}

and

Code:
		}

		private static void ReleaseExploderLock( object state ) // <- Added this as well! Hooray!
		{
			((Mobile)state).EndAction( typeof( BaseExplosionPotion ) );
		}

so it comes out like this:

Code:
		public override void Drink( Mobile from )
		{
			int Delay = 5; // <- Added this line to set the delay between use
			if ( from.BeginAction( typeof( BaseExplosionPotion ) ) ) // <- Added this line and set it to BaseExplosionPotion
			{


			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;
			}

			ThrowTarget targ = from.Target as ThrowTarget;

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

			from.RevealingAction();

			if ( m_Users == null )
				m_Users = new ArrayList();

			if ( !m_Users.Contains( from ) )
				m_Users.Add( from );

			from.Target = new ThrowTarget( this );

			Timer.DelayCall( TimeSpan.FromSeconds( Delay ), new TimerStateCallback( ReleaseExploderLock ), from ); // <- Added this line to set the timer for allowing you to throw another

			if ( m_Timer == null )
			{
				from.SendLocalizedMessage( 500236 ); // You should throw it now!
				m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 0.75 ), TimeSpan.FromSeconds( 1.0 ), 4, new TimerStateCallback( Detonate_OnTick ), new object[]{ from, 3 } );
			}
			} // <-- Just added that
		}


		private static void ReleaseExploderLock( object state ) // <- Added this as well! Hooray!
		{
			((Mobile)state).EndAction( typeof( BaseExplosionPotion ) );
		}

That's a little messy, but you get the idea. I just didn't end the if statement that checks if your timer is expired yet.
 
Top