manofwar

Member
ServUO Version
Publish 57
Ultima Expansion
Time Of Legends
Does anyone remember a script that would cast a spell by using a command like [cs spellname?
 
It's already defined for Counselors by "[Cast SpellName" command

C#:
        [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>");
            }
        }
 
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.
 
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.
you could use this example for any spells.
 
C#:
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));
        }

    }
}


It is possible there are some things in there that need to be removed from my server from our customs. But that is what you were looking for.
 
I was just curious on this one, I noticed "using Server.ACC.CSS;" so I uncommented that line and it doesn't seem to work with the ACC spells. Does anyone have a copy that does? From what I can tell it looks like they might have their own spell registry SpellInfoRegistry rather than SpellRegistry but I am not entirely sure how to modify it to work. That's my thought anyways..
 
I'll check it out Dramoor Thanks. It does seem the on cast command doesnt work with regular spells either for me even when i set it to player. Iomeg0318 yes they do use their own SpellRegirsties in ACC AllSpells, if I fina a work around I'll post it.
 
Sorry if that does not work I added the custom spells directly into my spell system for other settings to work for my server. Just figured it might work out for someone. I will go see if I have a blank one from when I first obtained it in my repo history.
 
Appreciate that help Dramoor, yeah the updated ACC Spells actually has a version of cast like Servuo but neither seem to work. The original spells or the new spells.
 
Okay I figured out how to have the cast the new spells with the acc css.cs, you actually got to open a spellbook and open the spell you want and put in at the bottom the name of spell or what you wannt to use lol.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back