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!

Spell Delay [CERTAIN SPELLS]

Marcus247

Wanderer
Iv'e tried this...

[code:1]using System;
using Server.Targeting;
using Server.Network;

namespace Server.Spells.First
{
public class MagicArrowSpell : Spell
{
private static TimeSpan NextSpellDelay = TimeSpan.FromSeconds( 0.4 );

private static SpellInfo m_Info = new SpellInfo(
"Magic Arrow", "In Por Ylem",
SpellCircle.First,
212,
9041,
Reagent.SulfurousAsh
);

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

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

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

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

SpellHelper.Turn( source, m );

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

double damage;

if ( Core.AOS )
{
damage = GetAosDamage( 3, 1, 10.0 );
}
else
{
damage = Utility.Random( 3, 5 );

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

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

damage *= GetDamageScalar( m );
}

source.MovingParticles( m, 0x36E4, 5, 0, false, true, 3006, 4006, 0 );
source.PlaySound( 0x1E5 );

SpellHelper.Damage( TimeSpan.Zero, m, Caster, damage, 0, 100, 0, 0, 0 );
}

FinishSequence();
}

private class InternalTarget : Target
{
private MagicArrowSpell m_Owner;

public InternalTarget( MagicArrowSpell 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();
}
}
}
}[/code:1]

The script goes thru. but it does not work...
 

Rokam

Wanderer
use a internaltimer.
[code:1]
private class InternalTimer : Timer
{
private Spell m_Spell;
private Mobile m_Target;
private Mobile m_Attacker, m_Defender;

public InternalTimer( Spell spell, Mobile attacker, Mobile defender, Mobile target ) : base( TimeSpan.FromSeconds( Core.AOS ? 3.0 : 2.5 ) )
{
m_Spell = spell;
m_Attacker = attacker;
m_Defender = defender;
m_Target = target;

Priority = TimerPriority.FiftyMS;
}

protected override void OnTick()
{
if ( m_Attacker.HarmfulCheck( m_Defender ) )
{
double damage;

if ( Core.AOS )
{
damage = m_Spell.GetAosDamage( 11, 3, 2.75 );
}
else
{
damage = Utility.Random( 23, 22 );

if ( m_Spell.CheckResisted( m_Target ) )
{
damage *= 0.75;

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

damage *= m_Spell.GetDamageScalar( m_Target );
}

m_Target.FixedParticles( 0x36BD, 20, 10, 5044, EffectLayer.Head );
m_Target.PlaySound( 0x307 );

SpellHelper.Damage( m_Spell, m_Target, damage, 0, 100, 0, 0, 0 );
}
}
}
[/code:1]

This one is for explosion... see explosion spell.
 

Nykovious

Wanderer
Since the base GetCastDelay() method in the Spells.cs script is virtual,:[code:1]public virtual TimeSpan GetCastDelay()
{
if ( m_Scroll is BaseWand )
return TimeSpan.Zero;

if ( !Core.AOS )
return TimeSpan.FromSeconds( 0.5 + (0.25 * (int)Circle) );

int fc = AosAttributes.GetValue( m_Caster, AosAttribute.CastSpeed );

if ( ProtectionSpell.Registry.Contains( m_Caster ) )
fc -= 2;

int circleDelay = CastDelayCircleScalar * (1 + (int)Circle); // Note: Circle is 0-based so we must offset
int fcDelay = -(CastDelayFastScalar * fc);

int delay = CastDelayBase + circleDelay + fcDelay;

if ( delay < CastDelayMinimum )
delay = CastDelayMinimum;

return TimeSpan.FromSeconds( (double)delay / CastDelayPerSecond );
}[/code:1] you can override it, to create your own version of the method, like this:[code:1]public override TimeSpan GetCastDelay()
{
return TimeSpan.FromSeconds( 3.0 );
}[/code:1]which would cause the spell cast time to be 3 seconds. So, you can add the last piece of code, to a spell script, to make it's cast delay 3 seconds or what ever you change it to.
 

Marcus247

Wanderer
So, if I just add this to the script it would add that spell delay?

[code:1]public override TimeSpan GetCastDelay()
{
return TimeSpan.FromSeconds( 3.0 );
}[/code:1]

Or do I have to add the the rest of the codes u posted?
 

Nykovious

Wanderer
No, you just add:[code:1]public override TimeSpan GetCastDelay()
{
return TimeSpan.FromSeconds( 3.0 );
}[/code:1]to the spell script that you want to change the delay time on.
So, if you want the Fireball spell to take 3 second to cast. Change your FireBall.cs file, or whatever spell you wish to change, like this:[code:1]using System;
using Server.Targeting;
using Server.Network;

namespace Server.Spells.Third
{
public class FireballSpell : Spell
{
private static SpellInfo m_Info = new SpellInfo(
"Fireball", "Vas Flam",
SpellCircle.Third,
203,
9041,
Reagent.BlackPearl
);

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

//
///// Begin: Added for spell delay /////////////////////
//
public override TimeSpan GetCastDelay()
{
return TimeSpan.FromSeconds( 3.0 );
}
//
///// End: Added for spell delay ///////////////////////
//

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

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

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

SpellHelper.Turn( source, m );

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

double damage;

if ( Core.AOS )
{
damage = GetAosDamage( 6, 3, 5.5 );
}
else
{
damage = Utility.Random( 10, 7 );

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

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

damage *= GetDamageScalar( m );
}

//Effects.SendMovingEffect( source, m, 0x36E4, 7, 0, false, true, 1151, 0);
source.MovingParticles( m, 0x36D4, 7, 0, false, true, 9502, 4019, 0x160 );
source.PlaySound( Core.AOS ? 0x15E : 0x44B );

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

FinishSequence();
}

private class InternalTarget : Target
{
private FireballSpell m_Owner;

public InternalTarget( FireballSpell 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();
}
}
}
}[/code:1]

The first piece of code, in my last post, is the base GetCastDelay() from the Spell.cs file. I was just showing that that method is virtual, so it can be overridden within a derived class, and you can create your own version of that method. For that matter, a method that use the modifier override or abstract can be overridden as well, as long as it has the same access level modifier.
 

Crack177

Wanderer
Just a lil question. What if you wanted to do it to all spells. I know there is a basespell. I can't find it. Is it Spell.cs?
 
Top