D4rkh0bb1T
Member
RunUO
How does it work, and why it is not working?
I can't get the spell to be harmful. There are no damage toward the attacker.
The code uses public static void Initialize(), PlayerEvent is in another .cs file.
Please help I would like to use this in my shard ...
How does it work, and why it is not working?
I can't get the spell to be harmful. There are no damage toward the attacker.
The code uses public static void Initialize(), PlayerEvent is in another .cs file.
Please help I would like to use this in my shard ...
C#:
using System;
using System.Collections;
using Server.Targeting;
using Server.Network;
using Server.Mobiles;
using Server.Items;
using Server.Spells;
namespace Server.ACC.CSS.Systems.Cleric
{
public class ClericTrialByFireSpell : ClericSpell
{
private static SpellInfo m_Info = new SpellInfo(
"Trial by Fire", "Temptatio Exsuscito",
//SpellCircle.Third,
212,
9041
);
public override SpellCircle Circle
{
get { return SpellCircle.Third; }
}
public override int RequiredTithing{ get{ return 25; } }
public override double RequiredSkill{ get{ return 45.0; } }
public override int RequiredMana{ get{ return 9; } }
public static void Initialize()
{
PlayerEvent.HitByWeapon += new PlayerEvent.OnWeaponHit( InternalCallback );
}
public ClericTrialByFireSpell( Mobile caster, Item scroll ) : base( caster, scroll, m_Info )
{
}
public override bool CheckCast()
{
if ( !base.CheckCast() )
return false;
if ( !Caster.CanBeginAction( typeof(ClericTrialByFireSpell) ))
{
Caster.SendLocalizedMessage( 501775 ); // This spell is already in effect
return false;
}
return true;
}
public override void OnCast()
{
if ( CheckSequence() )
{
Caster.SendMessage( "Your body is covered by holy flames." );
Caster.BeginAction( typeof( ClericTrialByFireSpell ) );
Caster.FixedParticles( 0x3709, 10, 30, 5052, 0x480, 0, EffectLayer.LeftFoot );
Caster.PlaySound( 0x208 );
DateTime Expire = DateTime.Now + TimeSpan.FromSeconds( Caster.Skills[SkillName.DetectHidden].Value / 7.0 );
new InternalTimer( Caster, Expire ).Start();
}
FinishSequence();
}
private static void InternalCallback( Mobile attacker, Mobile defender, int damage, WeaponAbility a )
{
if ( !defender.CanBeginAction( typeof( ClericTrialByFireSpell ) ) && Utility.RandomBool() )
{
defender.DoHarmful( attacker );
double scale = 1.0;
scale += defender.Skills[SkillName.DetectHidden].Value * 0.001;
if ( defender.Player )
{
scale += defender.Int * 0.001;
scale += AosAttributes.GetValue( defender, AosAttribute.SpellDamage ) * 0.01;
}
int baseDamage = 6 + (int)(defender.Skills[SkillName.DetectHidden].Value / 5.0);
double firedmg = Utility.RandomMinMax( baseDamage, baseDamage + 3 ) * ClericDivineFocusSpell.GetScalar( defender );
firedmg *= scale;
SpellHelper.Damage( TimeSpan.Zero, attacker, defender, firedmg, 0, 100, 0, 0, 0 );
attacker.FixedParticles( 0x3709, 10, 30, 5052, 0x480, 0, EffectLayer.LeftFoot );
attacker.PlaySound( 0x208 );
attacker.SendMessage( "TESTING" );
defender.SendMessage( "TESTING" );
}
}
private class InternalTimer : Timer
{
private Mobile Source;
private DateTime Expire;
public InternalTimer( Mobile from, DateTime end ) : base( TimeSpan.Zero, TimeSpan.FromSeconds( 0.1 ) )
{
Source = from;
Expire = end;
}
protected override void OnTick()
{
if ( DateTime.Now >= Expire || !Source.CheckAlive() )
{
Source.EndAction( typeof( ClericTrialByFireSpell ) );
Stop();
Source.SendMessage( "The holy fire around you fades." );
}
}
}
}
}
C#:
using System;
using Server;
using Server.Mobiles;
using Server.Items;
using Server.ACC.CSS.Systems.Cleric;
namespace Server.ACC.CSS.Systems.Cleric
{
public class PlayerEvent
{
public delegate void OnWeaponHit( Mobile attacker, Mobile defender, int damage, WeaponAbility a );
public static event OnWeaponHit HitByWeapon;
public static void InvokeHitByWeapon( Mobile attacker, Mobile defender, int damage, WeaponAbility a )
{
if ( HitByWeapon != null )
HitByWeapon( attacker, defender, damage, a );
}
}
}
Last edited: