Go Back   RunUO - Ultima Online Emulation > RunUO > New Join Forum

New Join Forum So your new to RunUO and looking to work with people that are new, this is the place.

Reply
 
Thread Tools Display Modes
Old 07-01-2005, 12:00 PM   #1 (permalink)
Forum Novice
 
Join Date: Jun 2004
Posts: 133
Default Stoptimer? EndAction?

I created a command that alters a players stats for a given time. I want to end the alteration if the player dies but am not sure which way is the best way to do this. Stoptimer will just stop the timer right and not return the player mobile's stats to it's original number or does it set the timer value to zero? I tried EndAction but am not sure if that will do the trick either. I gues my questions are what stoptimer and endaction do so that I know if I need to use them or if I am barking up the wrong tree.

(Oh I have looked through the forums and found nothing to answer my questions yet)
Taffer is offline   Reply With Quote
Old 07-01-2005, 07:49 PM   #2 (permalink)
Forum Expert
 
Greystar's Avatar
 
Join Date: Mar 2004
Location: NorthCentral IL, USA
Age: 35
Posts: 3,848
Default

Quote:
Originally Posted by Taffer
I created a command that alters a players stats for a given time. I want to end the alteration if the player dies but am not sure which way is the best way to do this. Stoptimer will just stop the timer right and not return the player mobile's stats to it's original number or does it set the timer value to zero? I tried EndAction but am not sure if that will do the trick either. I gues my questions are what stoptimer and endaction do so that I know if I need to use them or if I am barking up the wrong tree.

(Oh I have looked through the forums and found nothing to answer my questions yet)

in the OnDeath (or whichever it is for players) ot can do a stop for the timer. Although we do need some examples of what you are trying to accomplish. but by what you just described I think the timer may have to be created and stored in your PlayerMobile then called with the command, which you probably already did.
__________________
Quote:
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination.
Killable Guards (GS Version)
Just a Simple Staff Tool
You can leave me messages.
Ernest Gary Gygax - Quote "I would like the world to remember me as the guy who really enjoyed playing games and sharing his knowledge and his fun pastimes with everybody else."
Greystar is offline   Reply With Quote
Old 07-01-2005, 07:50 PM   #3 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

Quote:
Originally Posted by Taffer
I created a command that alters a players stats for a given time. I want to end the alteration if the player dies but am not sure which way is the best way to do this. Stoptimer will just stop the timer right and not return the player mobile's stats to it's original number or does it set the timer value to zero? I tried EndAction but am not sure if that will do the trick either. I gues my questions are what stoptimer and endaction do so that I know if I need to use them or if I am barking up the wrong tree.

(Oh I have looked through the forums and found nothing to answer my questions yet)

Without the code, I can't suggest what I want to, once you post the code I can help you.
Phantom is offline   Reply With Quote
Old 07-01-2005, 08:47 PM   #4 (permalink)
Forum Novice
 
Join Date: Jun 2004
Posts: 133
Default

This is the code or a version of it. It compiles fine I just would like to end the modification on death if I could. I can get the StopTimer to compile but I am not certain how to referance it in the player mobile.

I can add these with compile:
Code:
StopTimer( Caster );

Timer t = new InternalTimer( Caster );

m_Timers[Caster] = t;

t.Start();
Code:
		private static Hashtable m_Timers = new Hashtable();

		public static bool StopTimer( Mobile m )
		{
			Timer t = (Timer)m_Timers[m];

			if ( t != null )
			{
				t.Stop();
				m_Timers.Remove( m );
			}

			return ( t != null );
		}
But when I referance OnDeath in playermobile with this I get errors that it does not recognize the class I put.

Code:
Desta.StopTimer( this );


Code:
using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Misc;
using Server.Network;
using Server.Targeting;

namespace Server.Scripts.Commands
{
	public class Desta
	{
		public static void Initialize()
		{
			Server.Commands.Register( "Desta", AccessLevel.Player, new CommandEventHandler( Desta_OnCommand ) );
		}

		public static void Desta_OnCommand( CommandEventArgs e ) 
		{
			Mobile from = e.Mobile;
						
			if ( !from.Mounted )
			{				
				TimeSpan duration = TimeSpan.FromMinutes( from.Skills[SkillName.Tactics].Value * 0.08 ); 
				int amount = (int)( from.Skills[SkillName.Parry].Value * .40 );
						
				ResistanceMod mod1 = new ResistanceMod( StatType.Str, + amount );
					
				from.AddResistanceMod( mod1 );
				new DeStaTimer( from, mod1, duration ).Start();
			}

			if ( from.Mounted )
			{
				from.SendMessage( "You can not do this while mounted." );
			}
		}

		private class DeStaTimer : Timer
		{
			private Mobile m_Mobile;
			private ResistanceMod m_Mods;
			
			public DeStaTimer( Mobile m, ResistanceMod mod, TimeSpan delay ) : base( delay )
			{
				m_Mobile = m;
				m_Mods = mod;
			}

			public void DoExpire()
			{
				m_Mobile.RemoveResistanceMod( m_Mods );
				Stop();
			}

			protected override void OnTick()
			{
				if ( m_Mobile != null )
				{
					DoExpire();
				}
			}
		}
	}
}
Taffer is offline   Reply With Quote
Old 07-01-2005, 08:50 PM   #5 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

The code you pasted makes no sense.

Quote:
ResistanceMod mod1 = new ResistanceMod( StatType.Str, + amount );
That code couldn't compile so I am confused, the ResistanceMod constructor doesn't have a StatType enum argument.

Horrible:

Quote:
new DeStaTimer( from, mod1, duration ).Start();
You should never create an instance like this, do it the correct way.
Phantom is offline   Reply With Quote
Old 07-01-2005, 09:02 PM   #6 (permalink)
Forum Novice
 
Join Date: Jun 2004
Posts: 133
Default

I know how to delay the timespan before someone can use tha command again. What I am looking for hopefully is to avoid someone using the command which say lasts for 8 minutes and then dies with 7 minutes left on the timer. That same person gets ressed in another 2 minutes which leaves 5 more minutes that they have the stat mod on them. I was hoping to be able to cancel the stat mod if I could OnDeath so that it didn't carry over.
Taffer is offline   Reply With Quote
Old 07-01-2005, 09:05 PM   #7 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

Quote:
Originally Posted by Taffer
I know how to delay the timespan before someone can use tha command again. What I am looking for hopefully is to avoid someone using the command which say lasts for 8 minutes and then dies with 7 minutes left on the timer. That same person gets ressed in another 2 minutes which leaves 5 more minutes that they have the stat mod on them. I was hoping to be able to cancel the stat mod if I could OnDeath so that it didn't carry over.
The code you posted doesn't use a StatMod, why?

Perhaps I don't understand the problem, is a StatMod removed if a Player dies?
Phantom is offline   Reply With Quote
Old 07-01-2005, 09:25 PM   #8 (permalink)
Forum Novice
 
Join Date: Jun 2004
Posts: 133
Default

Sorry I posted one with an error. Here is the correct one. With that I am looking for the same thing I listed above:

The problem is when the player dies in game and there is still time on the timer, the mobile can be ressurected and walk around with the stat modification.

Code:
using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Misc;
using Server.Network;
using Server.Targeting;

namespace Server.Scripts.Commands
{
	public class Desta
	{
		public static void Initialize()
		{
			Server.Commands.Register( "Desta", AccessLevel.Player, new CommandEventHandler( Desta_OnCommand ) );
		}

		public static void Desta_OnCommand( CommandEventArgs e ) 
		{
			Mobile from = e.Mobile;
						
			if ( !from.Mounted )
			{				
				TimeSpan duration = TimeSpan.FromMinutes( from.Skills[SkillName.Tactics].Value * 0.08 ); 
				int amount = (int)( from.Skills[SkillName.Parry].Value * .40 );
						
				ResistanceMod mod1 = new ResistanceMod( ResistanceType.Physical, + amount );
					
				from.AddResistanceMod( mod1 );
				new DeStaTimer( from, mod1, duration ).Start();
			}

			if ( from.Mounted )
			{
				from.SendMessage( "You can not do this while mounted." );
			}
		}

		private class DeStaTimer : Timer
		{
			private Mobile m_Mobile;
			private ResistanceMod m_Mods;
			
			public DeStaTimer( Mobile m, ResistanceMod mod, TimeSpan delay ) : base( delay )
			{
				m_Mobile = m;
				m_Mods = mod;
			}

			public void DoExpire()
			{
				m_Mobile.RemoveResistanceMod( m_Mods );
				Stop();
			}

			protected override void OnTick()
			{
				if ( m_Mobile != null )
				{
					DoExpire();
				}
			}
		}
	}
}
Taffer is offline   Reply With Quote
Old 07-02-2005, 02:09 AM   #9 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

Modify the method that handles what happens when a Mobile dies.

If you you don't want thoe bonus to be there, if the Player dies, you will have to remove the ResistanceMod when it dies.
Phantom is offline   Reply With Quote
Old 07-03-2005, 12:29 AM   #10 (permalink)
Administrator
 
Zippy's Avatar
 
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,868
Default

You could considering changing the timer to tick once every second and check if the player is alive (if not, do whatever). Or you could change OnDeath in the PlayerMobile class to handle your stuff... but that's probably a bit harder.

Though, you should study other uses of Stat Mods in the core, they already support the type or thing you want to do internally, you code will be a lot simpler if you use statmods to their full potential. Take a look at Scripts/Spells/First/Cunning.cs and others for examples.
__________________
Zippy, Razor Creator and RunUO Core Developer
The RunUO Software Team

"Intuition, like a flash of lightning, lasts only for a second. It generally comes when one is tormented by a difficult decipherment and when one reviews in his mind the fruitless experiments already tried. Suddenly the light breaks through and one finds after a few minutes what previous days of labor were unable to reveal."
~The Cryptonomicon

Zippy is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5