Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using Server.Network;
  4. using Server.Items;
  5. using Server.Targeting;
  6.  
  7. namespace Server.Spells.Necromancy
  8. {
  9. public class CurseWeaponSpell : NecromancerSpell
  10. {
  11. private static SpellInfo m_Info = new SpellInfo(
  12. "Curse Weapon", "An Sanct Gra Char",
  13. 203,
  14. 9031,
  15. Reagent.PigIron
  16. );
  17.  
  18. public override TimeSpan CastDelayBase { get { return TimeSpan.FromSeconds( 0.75 ); } }
  19.  
  20. public override double RequiredSkill{ get{ return 0.0; } }
  21. public override int RequiredMana{ get{ return 7; } }
  22.  
  23. public CurseWeaponSpell( Mobile caster, Item scroll ) : base( caster, scroll, m_Info )
  24. {
  25. }
  26.  
  27. public override void OnCast()
  28. {
  29. BaseWeapon weapon = Caster.Weapon as BaseWeapon;
  30.  
  31. if ( weapon == null || weapon is Fists )
  32. {
  33. Caster.SendLocalizedMessage( 501078 ); // You must be holding a weapon.
  34. }
  35. else if ( CheckSequence() )
  36. {
  37. /* Temporarily imbues a weapon with a life draining effect.
  38. * Half the damage that the weapon inflicts is added to the necromancer's health.
  39. * The effects lasts for (Spirit Speak skill level / 34) + 1 seconds.
  40. *
  41. * NOTE: Above algorithm is fixed point, should be :
  42. * (Spirit Speak skill level / 3.4) + 1
  43. *
  44. * TODO: What happens if you curse a weapon then give it to someone else? Should they get the drain effect?
  45. */
  46.  
  47. Caster.PlaySound( 0x387 );
  48. Caster.FixedParticles( 0x3779, 1, 15, 9905, 32, 2, EffectLayer.Head );
  49. Caster.FixedParticles( 0x37B9, 1, 14, 9502, 32, 5, (EffectLayer)255 );
  50. new SoundEffectTimer( Caster ).Start();
  51.  
  52. TimeSpan duration = TimeSpan.FromSeconds( (Caster.Skills[SkillName.SpiritSpeak].Value / 3.4) + 1.0 );
  53.  
  54.  
  55. Timer t = (Timer)m_Table[weapon];
  56.  
  57. if ( t != null )
  58. t.Stop();
  59.  
  60. weapon.Cursed = true;
  61.  
  62. m_Table[weapon] = t = new ExpireTimer( weapon, duration );
  63.  
  64. t.Start();
  65. }
  66.  
  67. FinishSequence();
  68. }
  69.  
  70. private static Hashtable m_Table = new Hashtable();
  71.  
  72. private class ExpireTimer : Timer
  73. {
  74. private BaseWeapon m_Weapon;
  75.  
  76. public ExpireTimer( BaseWeapon weapon, TimeSpan delay ) : base( delay )
  77. {
  78. m_Weapon = weapon;
  79. Priority = TimerPriority.OneSecond;
  80. }
  81.  
  82. protected override void OnTick()
  83. {
  84. m_Weapon.Cursed = false;
  85. Effects.PlaySound( m_Weapon.GetWorldLocation(), m_Weapon.Map, 0xFA );
  86. m_Table.Remove( this );
  87. }
  88. }
  89.  
  90. private class SoundEffectTimer : Timer
  91. {
  92. private Mobile m_Mobile;
  93.  
  94. public SoundEffectTimer( Mobile m ) : base( TimeSpan.FromSeconds( 0.75 ) )
  95. {
  96. m_Mobile = m;
  97. Priority = TimerPriority.FiftyMS;
  98. }
  99.  
  100. protected override void OnTick()
  101. {
  102. m_Mobile.PlaySound( 0xFA );
  103. }
  104. }
  105. }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement