RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

SpellChanting.cs (Cast Spells by Mantra)

Lokai

Knight
SpellChanting.cs (Cast Spells by Mantra)

/************ SpellChanting.cs *************
*
* (C) 2008, Lokai
*
* Description: Speech Handler that will
* detect if you have a particular
* spell based on the mantra that
* you speak, and will cast it.
*
*******************************************/



Spell Chanting (- or - "Say it, don't 'splay it!")

Created by request (sort of.)

This was tested on Admin and player characters.

No mods needed. If it matches the mantra for a spell
you possess, what you say will not be displayed as
normal speech, but instead you will cast that spell.

NEW ZIP FILE POSTED:

This version of SpellChanting includes support for disabling casting of spells using the spell book.
If you want to make it so users must use Scrolls, Wands or "Chant the Mantra" to cast, make the following change to Spell.cs:
In the Cast() method, add the following line at the top:

Code:
if (!string.IsNullOrEmpty(Mantra) && !m_Spoken && !(m_Scroll is SpellScroll) && !(m_Scroll is BaseWand)) return false;

This is what it will look like in the method:

Code:
  public bool Cast()
  {
  if (!string.IsNullOrEmpty(Mantra) && !m_Spoken && !(m_Scroll is SpellScroll) && !(m_Scroll is BaseWand)) return false;
  m_StartCastTime = DateTime.Now;
  ...snip...


Before the Cast() method, add the following new variable and method:

Code:
  #region Added for SpellChanting
  private bool m_Spoken = false;
  public bool Cast(bool spoken)
  {
  m_Spoken = spoken;
  return Cast();
  }
  #endregion
 

Attachments

  • SpellChanting V3.zip
    1.4 KB · Views: 343

F4B10Z

Wanderer
Ok, i'm getting annoying...
Will this work even with necromancer, paladin and arcanist spells?

EDIT: i tried. it works with EVERY spell ;)

I love you Lokai xD
 

Lokai

Knight
F4B10Z;754947 said:
Ok, i'm getting annoying...
Will this work even with necromancer, paladin and arcanist spells?

EDIT: i tried. it works with EVERY spell ;)

I love you Lokai xD

It will work with any spell that has a Mantra.

It will not work with spells that have a null Mantra, or with Special Moves.
 

Miller.

Wanderer
I assume that the purpose for a script like this is to just add a little more realism and flavor to spell casting? Would you consider removing the clickable icons to force everyone to chant the mantra? And if so, what would prevent someone from setting up a macro to say the mantra instead of "cast spell - xyz"?

I mean, this thing looks really interesting, but I just can't see a way to really implement it other than as an add-on for uniqueness. I'd like to hear some ideas of how other people are using it or plan to use it.
 

Lokai

Knight
Miller.;754967 said:
I assume that the purpose for a script like this is to just add a little more realism and flavor to spell casting? Would you consider removing the clickable icons to force everyone to chant the mantra? And if so, what would prevent someone from setting up a macro to say the mantra instead of "cast spell - xyz"?

I mean, this thing looks really interesting, but I just can't see a way to really implement it other than as an add-on for uniqueness. I'd like to hear some ideas of how other people are using it or plan to use it.

Since the icons are built in to the client code, I think the only way to do that would be to release custom-written spellbooks, which do not use the same code at all. Not sure if there would be a way for you to prevent users from having the icons anyway. This is really just for flavoring, unless someone has specific ways of enforcing it's use.
 

Lokai

Knight
NEW ZIP FILE POSTED:

This version of SpellChanting includes support for disabling casting of spells using the spell book.
If you want to make it so users must use Scrolls, Wands or "Chant the Mantra" to cast, make the following change to Spell.cs:
In the Cast() method, add the following line at the top:

Code:
if (!string.IsNullOrEmpty(Mantra) && !(m_Scroll is SpellScroll) && !(m_Scroll is BaseWand)) return false;

This is what it will look like in the method:

Code:
  public bool Cast()
  {
   if (!string.IsNullOrEmpty(Mantra) && !(m_Scroll is SpellScroll) && !(m_Scroll is BaseWand)) return false;
   m_StartCastTime = DateTime.Now;
   ...snip...
 

Greystar

Wanderer
I really like this concept, makes the game a bit more interactive and I might take it a bit farther after I look at this code. Since being drunk really doesn't do anything I might make it penalize spell casters and make skills fail more often.
 

Lokai

Knight
Greystar;755047 said:
I really like this concept, makes the game a bit more interactive and I might take it a bit farther after I look at this code. Since being drunk really doesn't do anything I might make it penalize spell casters and make skills fail more often.

Nice. Slurred speech penalty...
 
I have added it to my shard also

I did have to add in a check to make sure they where allowed to use the spell (based on our class system)
but that was easy to do

and i really like the fact that if they can not cast the spell (no book, restricted, etc) it just puts the words up them making them look foolish, like "you where tring to fireball me there, but forgot your book" :D
 

F4B10Z

Wanderer
The uses for a script like this are many.

Imagine having a totally new spell system. Not magery related maybe, but based on % written in playermobile.cs (Something like a SpellName property with a value from 0 to 100 that means 100% success), so it just need the mantra to be casted...
 

alex92

Sorceror
uhm...
when i cast a spell from the book it works as well...
but when i cast from mantra, i flizz every spell (120 magery, both admin and player)...

i just placed the script in my custom folder, have i miss something?
 

Lokai

Knight
alex92;755543 said:
uhm...
when i cast a spell from the book it works as well...
but when i cast from mantra, i flizz every spell (120 magery, both admin and player)...

i just placed the script in my custom folder, have i miss something?

Yes, read the first post, it says what change you have to make to Spell.cs. :)
 

alex92

Sorceror
Lokai;755568 said:
Yes, read the first post, it says what change you have to make to Spell.cs. :)

i edited spell.cs, and now from book it doesn't work anymore, but from mantra it still flizz everything i cast (magery, chivalry, necro) :confused:
 

Lokai

Knight
alex92;755570 said:
i edited spell.cs, and now from book it doesn't work anymore, but from mantra it still flizz everything i cast (magery, chivalry, necro) :confused:

Did you change something in Spell.cs that would cause scrolls to fizz?

*** EDIT ***

No, I think I did, when I forgot to add the scroll to the player's pack. Just a minute...
 
Top