|
||
|
|||||||
| Script Support Get support for modifying RunUO Scripts, or writing your own! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Forum Novice
|
I'm trying to make Spell Channeling work on my Glacial Staffs. Although the item's little characteristic overview window says it has SpellChanneling (when you hover over the item that is), when I try to cast, it still removes the item from my hands. This happens regardless if I've got SpellChanneling added to the script so it spawns with SpellChanneling or if I don't have it and manually add it in-game.
So I'm thinking there is an issue with my Glacial Staff script all together. Here's the code; Code:
using System;
using Server.Network;
using Server;
using System.Collections;
using Server.Gumps;
using Server.Items;
using Server.Spells;
using Server.Spells.GlacialStaff;
using Server.Targeting;
namespace Server.Items
{
public enum StaffEffect2
{
Freeze,
IceStrike,
IceBall
}
[FlipableAttribute( 0xDF1, 0xDF0 )]
public class GlacialStaff : BaseStaff
{
public override WeaponAbility PrimaryAbility{ get{ return WeaponAbility.CrushingBlow; } }
public override WeaponAbility SecondaryAbility{ get{ return WeaponAbility.Disarm; } }
public override int AosStrengthReq{ get{ return 20; } }
public override int AosMinDamage{ get{ return 11; } }
public override int AosMaxDamage{ get{ return 13; } }
public override int AosSpeed{ get{ return 41; } }
public override int OldStrengthReq{ get{ return 10; } }
public override int OldMinDamage{ get{ return 3; } }
public override int OldMaxDamage{ get{ return 12; } }
public override int OldSpeed{ get{ return 30; } }
private bool m_CanIceStrike;
private bool m_CanFreeze;
private bool m_CanIceBall;
[CommandProperty( AccessLevel.GameMaster )]
public bool CanIceStrike
{
get { return m_CanIceStrike; }
set { m_CanIceStrike = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool CanFreeze
{
get { return m_CanFreeze; }
set { m_CanFreeze = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool CanIceBall
{
get { return m_CanIceBall; }
set { m_CanIceBall = value; }
}
private DateTime PreviousUse;
private StaffEffect2 m_StaffEffect2;
private int m_Charges;
[CommandProperty( AccessLevel.GameMaster )]
public int Charges
{
get
{
return m_Charges;
}
set
{
m_Charges = value;
}
}
[CommandProperty( AccessLevel.GameMaster )]
public StaffEffect2 Effect
{
get
{
return m_StaffEffect2;
}
set
{
m_StaffEffect2 = value;
}
}
[Constructable]
public GlacialStaff() : base( 0xDF1 )
{
int firsteffect = Utility.Random ( 1, 3 );
int secondeffect = Utility.Random ( 1, 3 );
while ( firsteffect == secondeffect )
secondeffect = Utility.Random ( 1, 3 );
switch ( firsteffect )
{
case 1: m_CanIceStrike = true; break;
case 2: m_CanFreeze = true; break;
case 3: m_CanIceBall = true; break;
}
switch ( secondeffect )
{
case 1: m_CanIceStrike = true; break;
case 2: m_CanFreeze = true; break;
case 3: m_CanIceBall = true; break;
}
switch ( firsteffect )
{
case 1: m_StaffEffect2 = StaffEffect2.IceStrike; break;
case 2: m_StaffEffect2 = StaffEffect2.Freeze; break;
case 3: m_StaffEffect2 = StaffEffect2.IceBall; break;
}
this.m_Charges = Utility.Random( 20, 50 );
Hue = 0x480;
Weight = 3.0;
Name = "a glacial staff";
Attributes.SpellChanneling = 1;
WeaponAttributes.UseBestSkill = 1;
}
public GlacialStaff( Serial serial ) : base( serial )
{
}
public override bool HandlesOnSpeech{ get{ return true; } }
public override void OnSpeech( SpeechEventArgs e )
{
Mobile m = e.Mobile;
if ((Parent == m ) && (m.FindItemOnLayer( Layer.TwoHanded ) == this ))
{
if (e.Speech.ToLower() == "an ex del")
{
if ( m_CanFreeze )
{
m.PlaySound( 0xF6 );
m_StaffEffect2 = StaffEffect2.Freeze;
if ( m.FindItemOnLayer( Layer.TwoHanded ) == this )
{
if ( DateTime.Now >= PreviousUse + TimeSpan.FromSeconds(30) )
{
PreviousUse = DateTime.Now;
if ( m_Charges == 0 )
{
m.SendLocalizedMessage( 1019073 ); // This item is out of charges.
return;
}
else
{
--m_Charges;
InvalidateProperties();
new FreezeSpell( m, null ).Cast();
}
}
else
{
m.SendLocalizedMessage( 1062012 );
}
}
else
{
m.SendLocalizedMessage( 502641 ); // You must equip this item to use it.
}
}
else
{
m.SendMessage( "It appears this item would react to the words Des Corp Del or In Corp Del." );
}
}
if (e.Speech.ToLower() == "in corp del")
{
if ( m_CanIceStrike )
{
m.PlaySound( 0xF7 );
m_StaffEffect2 = StaffEffect2.IceStrike;
if ( m.FindItemOnLayer( Layer.TwoHanded ) == this )
{
if ( DateTime.Now >= PreviousUse + TimeSpan.FromSeconds(03) )
{
PreviousUse = DateTime.Now;
if ( m_Charges == 0 )
{
m.SendLocalizedMessage( 1019073 ); // This item is out of charges.
return;
}
else
{
--m_Charges;
InvalidateProperties();
new IceStrikeSpell( m, null ).Cast();
}
}
else
{
m.SendLocalizedMessage( 1062012 );
}
}
else
{
m.SendLocalizedMessage( 502641 ); // You must equip this item to use it.
}
}
else
{
m.SendMessage( "It appears this item would react to the words Des Corp Del or An Ex Del." );
}
}
if (e.Speech.ToLower() == "des corp del")
{
if ( m_CanIceBall )
{
m.PlaySound( 0xF8 );
m_StaffEffect2 = StaffEffect2.IceBall;
if ( m.FindItemOnLayer( Layer.TwoHanded ) == this )
{
if ( DateTime.Now >= PreviousUse + TimeSpan.FromSeconds(30) )
{
PreviousUse = DateTime.Now;
if ( m_Charges == 0 )
{
m.SendLocalizedMessage( 1019073 ); // This item is out of charges.
return;
}
else
{
--m_Charges;
InvalidateProperties();
new IceBallSpell( m, null ).Cast();
}
}
else
{
m.SendLocalizedMessage( 1062012 );
}
}
else
{
m.SendLocalizedMessage( 502641 ); // You must equip this item to use it.
}
}
else
{
m.SendMessage( "It appears this item would react to the words In Corp Del or An Ex Del." );
}
}
}
}
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
if ( m_Charges != 0 )
list.Add( 1060584, m_Charges.ToString() );
}
public override void OnSingleClick( Mobile from )
{
ArrayList attrs = new ArrayList();
if ( !Identified && !Core.AOS )
attrs.Add( new EquipInfoAttribute( 1038000 ) ); // Unidentified
else
attrs.Add( new EquipInfoAttribute( 1041367, m_Charges ) );
EquipmentInfo eqInfo = new EquipmentInfo( 1017413, Crafter, false, (EquipInfoAttribute[])attrs.ToArray( typeof( EquipInfoAttribute ) ) );
from.Send( new DisplayEquipmentInfo( this, eqInfo ) );
}
public override void OnDoubleClick( Mobile from )
{
if ( from.FindItemOnLayer( Layer.TwoHanded ) == this )
{
if ( DateTime.Now >= PreviousUse + TimeSpan.FromSeconds(30) )
{
PreviousUse = DateTime.Now;
if ( m_Charges == 0 )
{
from.SendLocalizedMessage( 1019073 ); // This item is out of charges.
return;
}
else
{
--m_Charges;
}
switch ( m_StaffEffect2 )
{
case StaffEffect2.Freeze: new FreezeSpell( from, null ).Cast(); break;
case StaffEffect2.IceStrike: new IceStrikeSpell( from, null ).Cast(); break;
case StaffEffect2.IceBall: new IceBallSpell( from, null ).Cast(); break;
}
}
else
{
from.SendLocalizedMessage( 1062012 );
}
}
else
{
from.SendLocalizedMessage( 502641 ); // You must equip this item to use it.
}
}
public override bool AllowEquipedCast( Mobile from )
{
string spellcast = from.Spell.GetType().ToString();
switch (spellcast)
{
case "Server.Spells.GlacialStaff.FreezeSpell": return true;
case "Server.Spells.GlacialStaff.IceStrikeSpell": return true;
case "Server.Spells.GlacialStaff.IceBallSpell": return true;
}
return false;
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 1 ); // version
writer.Write( m_CanIceStrike );
writer.Write( m_CanFreeze );
writer.Write( m_CanIceBall );
writer.Write( (int) m_StaffEffect2 );
writer.Write( (int) m_Charges );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
if ( version == 1 )
{
m_CanIceStrike = reader.ReadBool();
m_CanFreeze = reader.ReadBool();
m_CanIceBall = reader.ReadBool();
}
m_StaffEffect2 = (StaffEffect2)reader.ReadInt();
m_Charges = (int)reader.ReadInt();
}
}
}
namespace Server.Spells.GlacialStaff
{
public class FreezeSpell : Spell
{
private static SpellInfo m_Info = new SpellInfo(
"Freeze", "",/*"An Ex Del", */
SpellCircle.First,
218
);
public FreezeSpell( Mobile caster, Server.Items.SpellScroll scroll ) : base( caster, scroll, m_Info )
{
}
public override TimeSpan GetCastDelay()
{
return TimeSpan.FromSeconds( 0.0 );
}
public override void OnCast()
{
Caster.Target = new InternalTarget( this );
}
public void Target( Mobile m )
{
if ( !Caster.CanSee( m ) )
{
Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
}
else if ( Caster.HarmfulCheck( m ) && CheckSequence() )
{
Mobile source = Caster;
SpellHelper.CheckReflect( (int)this.Circle, ref source, ref m );
double duration = 7.0;
m.Paralyze( TimeSpan.FromSeconds( duration ) );
Caster.Mana = 0;
if ( Caster != m )
{
Caster.Direction = Caster.GetDirectionTo( m );
}
m.PlaySound( 0x204 );
Effects.SendTargetEffect( m, 0x376A, 16 );
Caster.SendLocalizedMessage( 1008127 );
}
FinishSequence();
}
private class InternalTarget : Target
{
private FreezeSpell m_Owner;
public InternalTarget( FreezeSpell owner ) : base( 12, true, 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();
}
}
}
public class IceBallSpell : Spell
{
private static SpellInfo m_Info = new SpellInfo
(
"IceBall", "",/*"Des Corp Del", */
SpellCircle.First,
203
);
public IceBallSpell( Mobile caster, Server.Items.SpellScroll scroll ) : base( caster, scroll, m_Info )
{
}
public override TimeSpan GetCastDelay()
{
return TimeSpan.FromSeconds( 0.0 );
}
public override void OnCast()
{
Caster.Target = new InternalTarget( this );
}
public void Target( Mobile m )
{
if ( !Caster.CanSee( m ) )
{
Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
}
else if ( Caster.HarmfulCheck( m ) && CheckSequence() )
{
Mobile source = Caster;
SpellHelper.CheckReflect( (int)this.Circle, ref source, ref m );
double damage = Utility.Random( 12, 15 );
damage *= GetDamageScalar( m );
if ( Caster != m )
Caster.Direction = Caster.GetDirectionTo( m );
Caster.PlaySound( 0x15E );
Effects.SendMovingEffect( Caster, m, 0x36D4, 7, 0, false, true ,0x47e,3);
Caster.PlaySound( 0x440 );
m.Damage( (int) damage );
Caster.SendLocalizedMessage( 1008127 );
}
FinishSequence();
}
private class InternalTarget : Target
{
private IceBallSpell m_Owner;
public InternalTarget( IceBallSpell 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();
}
}
}
public class IceStrikeSpell : Spell
{
private static SpellInfo m_Info = new SpellInfo
(
"Ice Strike", "",/* "In Corp Del", */
SpellCircle.First
);
public IceStrikeSpell( Mobile caster, Server.Items.SpellScroll scroll ) : base( caster, scroll, m_Info )
{
}
public override TimeSpan GetCastDelay()
{
return TimeSpan.FromSeconds( 0.0 );
}
public override void OnCast()
{
Caster.Target = new InternalTarget( this );
}
public void Target( Mobile m )
{
if ( !Caster.CanSee( m ) )
{
Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
}
else if ( Caster.HarmfulCheck( m ) && CheckSequence() )
{
Mobile source = Caster;
SpellHelper.CheckReflect( (int)this.Circle, ref source, ref m );
double damage = Caster.Mana / 2;
Caster.Mana = 0;
if ( Caster != m )
Caster.Direction = Caster.GetDirectionTo( m );
Caster.PlaySound( 0x208 );
Effects.SendTargetEffect( m, 0x3709, 32,0x47E,3 );
m.Damage( (int) damage );
Caster.SendLocalizedMessage( 1008127 );
}
FinishSequence();
}
private class InternalTarget : Target
{
private IceStrikeSpell m_Owner;
public InternalTarget( IceStrikeSpell 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();
}
}
}
}
|
|
|
|
|
|
#2 (permalink) |
|
Forum Master
|
are you using razor and have "unequip weapons/shield when casting" checked?
__________________
http://www.AoAUO.com
:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :) |
|
|
|
|
|
#4 (permalink) |
|
Forum Master
Join Date: Feb 2005
Location: ShatteredSosaria.com
Posts: 9,260
|
Here's your problem:
Code:
public override bool AllowEquipedCast( Mobile from )
{
string spellcast = from.Spell.GetType().ToString();
switch (spellcast)
{
case "Server.Spells.GlacialStaff.FreezeSpell": return true;
case "Server.Spells.GlacialStaff.IceStrikeSpell": return true;
case "Server.Spells.GlacialStaff.IceBallSpell": return true;
}
return false;
}
Code:
public override bool AllowEquipedCast( Mobile from )
{
string spellcast = from.Spell.GetType().ToString();
switch (spellcast)
{
case "Server.Spells.GlacialStaff.FreezeSpell": return true;
case "Server.Spells.GlacialStaff.IceStrikeSpell": return true;
case "Server.Spells.GlacialStaff.IceBallSpell": return true;
}
return base.AllowEquipedCast( from );
}
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|