|
||
|
|||||||
| New Join Forum So your new to RunUO and looking to work with people that are new, this is the place. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Forum Novice
Join Date: Jun 2004
Posts: 133
|
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) |
|
|
|
|
|
#2 (permalink) | ||
|
Forum Expert
Join Date: Mar 2004
Location: NorthCentral IL, USA
Age: 35
Posts: 3,848
|
Quote:
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:
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." |
||
|
|
|
|
|
#3 (permalink) | |
|
Account Terminated
|
Quote:
Without the code, I can't suggest what I want to, once you post the code I can help you. |
|
|
|
|
|
|
#4 (permalink) |
|
Forum Novice
Join Date: Jun 2004
Posts: 133
|
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 );
}
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();
}
}
}
}
}
|
|
|
|
|
|
#5 (permalink) | ||
|
Account Terminated
|
The code you pasted makes no sense.
Quote:
Horrible: Quote:
|
||
|
|
|
|
|
#6 (permalink) |
|
Forum Novice
Join Date: Jun 2004
Posts: 133
|
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.
|
|
|
|
|
|
#7 (permalink) | |
|
Account Terminated
|
Quote:
Perhaps I don't understand the problem, is a StatMod removed if a Player dies? |
|
|
|
|
|
|
#8 (permalink) |
|
Forum Novice
Join Date: Jun 2004
Posts: 133
|
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();
}
}
}
}
}
|
|
|
|
|
|
#10 (permalink) |
|
Administrator
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,868
|
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|