[Usage("Cast <name>")]
[Description("Casts a spell by name.")]
public static void Cast_OnCommand(CommandEventArgs e)
{
if (e.Length == 1)
{
if (!Multis.DesignContext.Check(e.Mobile))
return; // They are customizing
Spell spell = SpellRegistry.NewSpell(e.GetString(0), e.Mobile, null);
if (spell != null)
spell.Cast();
else
e.Mobile.SendMessage("That spell was not found.");
}
else
{
e.Mobile.SendMessage("Format: Cast <name>");
}
}
you could use this example for any spells.Thanks for the reply, I was just trying to get it to work for players and acc spell system so they could macro it out. The spell icon setup in acc spells is a little perplexing for players it seems. I think there was a script back in the day for this but runuo is not responding agaain lol.
using System;
using System.Collections;
using Server.Items;
using Server.Targeting;
using Server.Mobiles;
using Server.Spells;
using Server.Commands;
//using Server.ACC.CSS;
namespace Server.Scripts.Commands
{
public class AllSpellCommands
{
public static void Initialize()
{
CommandSystem.Register( "CS", AccessLevel.Player, new CommandEventHandler( CS_OnCommand ) );
}
[Usage( "CS" )]
[Description( "Casts the specified spell." )]
public static void CS_OnCommand( CommandEventArgs e )
{
if( e.Length == 1 )
{
if( !Multis.DesignContext.Check( e.Mobile ) )
return; // They are customizing
string spellType = e.GetString( 0 ) + "Spell";
Spell spell = null;
for( int i = 0; i < SpellRegistry.Types.Length; i++ )
{
Type type = SpellRegistry.Types[i];
if( type == null )
continue;
string currentName = type.Name;
if( currentName == null )
continue;
if( Insensitive.Equals( spellType, currentName ) )
{
if( HasSpell( e.Mobile, i ) )
{
spell = SpellRegistry.NewSpell( i, e.Mobile, null );
break;
}
else
{
e.Mobile.SendLocalizedMessage( 500015 ); // You do not have that spell!
return;
}
}
}
if( spell != null )
spell.Cast();
else
e.Mobile.SendMessage( "That spell was not found." );
}
else
{
e.Mobile.SendMessage( "Format: CS <name>" );
}
}
public static bool HasSpell(Mobile from, int spellID)
{
Spellbook book = Spellbook.Find(from, spellID);
return (book != null && book.HasSpell(spellID));
}
}
}
We use essential cookies to make this site work, and optional cookies to enhance your experience.