1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Spellbook casts only equipped how set it - medit in mov

Discussion in 'Script Support' started by Fred1990, Mar 11, 2019.

  1. Fred1990
    Offline

    Fred1990 Member

    Joined:
    Jan 23, 2019
    Messages:
    63
    Likes Received:
    2
    Hi guys, how can I set the spell book that casts spells only equipped ?
    then, how can I set meditation in movement?

    Thanks!
     
  2. Quasar
    Offline

    Quasar Member

    Joined:
    Oct 26, 2018
    Messages:
    84
    Likes Received:
    4
    The casting is a good question, i would guess from looking around a little it would be to change the check in spellbook.cs
    from.Backpack; to equipped but not positive. Someone will know more and be on soon, but it might be a place to start looking. The meditation.cs seems to handle equipped items for that skill but not on movement but it refrences Server.SkillHandlers and SkillInfo.Table[46].Callback So sorry I wasnt more help but it might be places to investigate untill some one with more knowledge can help you out.
     
    • Thanks! Thanks! x 1
  3. Fred1990
    Offline

    Fred1990 Member

    Joined:
    Jan 23, 2019
    Messages:
    63
    Likes Received:
    2
    Yes the code I guess that should be put here , the problem is what code !

    public static Spellbook FindEquippedSpellbook( Mobile from )
    {
    return (from.FindItemOnLayer( Layer.OneHanded ) as Spellbook);
    }
     
  4. Quasar
    Offline

    Quasar Member

    Joined:
    Oct 26, 2018
    Messages:
    84
    Likes Received:
    4
    check out caddellite.cs maybe some direction can be found there
     
  5. Fred1990
    Offline

    Fred1990 Member

    Joined:
    Jan 23, 2019
    Messages:
    63
    Likes Received:
    2
    I have runuo I don't have that file uhm
     
  6. Quasar
    Offline

    Quasar Member

    Joined:
    Oct 26, 2018
    Messages:
    84
    Likes Received:
    4
  7. Lokai
    Offline

    Moderator ServUO Developer

    Joined:
    Dec 4, 2014
    Messages:
    1,123
    Likes Received:
    160
    Are you trying to make a specific type of spellbook that needs to be equipped to work, or are you trying to make it so that ALL spellbooks must be equipped to work?
     
  8. Fred1990
    Offline

    Fred1990 Member

    Joined:
    Jan 23, 2019
    Messages:
    63
    Likes Received:
    2
    Hi Lokay I would like to set the mage spellbook to be equipped to work
     
  9. Lokai
    Offline

    Moderator ServUO Developer

    Joined:
    Dec 4, 2014
    Messages:
    1,123
    Likes Received:
    160
    Try this. In Spellbook.cs, modify the EventSink at the bottom of the script like this:

    Code (C#):
    1.        
    2.         private static void EventSink_CastSpellRequest(CastSpellRequestEventArgs e)
    3.         {
    4.             Mobile from = e.Mobile;
    5.            
    6.             if (!DesignContext.Check(from))
    7.             {
    8.                 return; // They are customizing
    9.             }
    10.            
    11.             Spellbook book = e.Spellbook as Spellbook;
    12.             int spellID = e.SpellID;
    13.            
    14.             if (book == null || !book.HasSpell(spellID))
    15.             {
    16.                 book = Find(from, spellID);
    17.             }
    18.            
    19.             if (book != null && book.HasSpell(spellID))
    20.             {
    21.                 SpecialMove move = SpellRegistry.GetSpecialMove(spellID);
    22.                
    23.                 if (move != null)
    24.                 {
    25.                     SpecialMove.SetCurrentMove(from, move);
    26.                 }
    27.                 // THIS WILL CHECK TO SEE IF THE MAGERY BOOK IS EQUIPPED
    28.                 else if (book is MagerySpellbook && !(book == FindEquippedSpellbook(from)))
    29.                 {
    30.                     from.SendMessage("That spellbook must be equipped.");
    31.                 }
    32.                 else
    33.                 {
    34.                     Spell spell = SpellRegistry.NewSpell(spellID, from, null);
    35.  
    36.                     if (spell != null)
    37.                     {
    38.                         spell.Cast();
    39.                     }
    40.                     else if ( !Server.Spells.SkillMasteries.MasteryInfo.IsPassiveMastery( spellID ) )
    41.                     {
    42.                         from.SendLocalizedMessage( 502345 ); // This spell has been temporarily disabled.
    43.                     }
    44.                 }
    45.             }
    46.             else
    47.             {
    48.                 from.SendLocalizedMessage(500015); // You do not have that spell!
    49.             }
    50.         }
     
    • Two Thumbs Up Two Thumbs Up x 1
  10. Fred1990
    Offline

    Fred1990 Member

    Joined:
    Jan 23, 2019
    Messages:
    63
    Likes Received:
    2
    Ok Loki I will try ;) very thanks !
    --- Double Post Merged, Mar 13, 2019 at 10:54 AM ---
    I tried I got this error ; certainly because of the different language between servant and runuo maybe!

    + Articles / Skills / Magic / Spellbook.cs:
    CS0103: Line 116: The name 'DesignContext' does not exist in the current context.
    CS0246: Line 138: Could not find the namespace type "MagerySpellbook". Probably missing a directive using or a reference to an assembly
    CS0234: Line 150: The type or name of the namespace 'SkillMasteries' does not exist in the namespace 'Server.Spells'. Probably missing a reference to an assembly.
    --- Double Post Merged, Mar 13, 2019 at 11:16 AM ---
    Here my spellbook.cs is needed
     

    Attached Files:

  11. Fred1990
    Offline

    Fred1990 Member

    Joined:
    Jan 23, 2019
    Messages:
    63
    Likes Received:
    2
  12. Lokai
    Offline

    Moderator ServUO Developer

    Joined:
    Dec 4, 2014
    Messages:
    1,123
    Likes Received:
    160
    OK. Minor tweaks. That method should look like this:

    Code (C#):
    1.  
    2.         private static void EventSink_CastSpellRequest( CastSpellRequestEventArgs e )
    3.         {
    4.             Mobile from = e.Mobile;
    5.  
    6.             if ( !Multis.DesignContext.Check( from ) )
    7.                 return; // They are customizing
    8.  
    9.             Spellbook book = e.Spellbook as Spellbook;
    10.             int spellID = e.SpellID;
    11.  
    12.             if ( book == null || !book.HasSpell( spellID ) )
    13.                 book = Find( from, spellID );
    14.  
    15.             if ( book != null && book.HasSpell( spellID ) )
    16.             {
    17.                 SpecialMove move = SpellRegistry.GetSpecialMove( spellID );
    18.  
    19.                 if ( move != null )
    20.                 {
    21.                     SpecialMove.SetCurrentMove( from, move );
    22.                 }
    23.                 else if (book.SpellbookType = SpellbookType.Regular && !(book = FindEquippedSpellbook(from)))
    24.                 {
    25.                     from.SendMessage("That spellbook must be equipped.");
    26.                 }
    27.                 else
    28.                 {
    29.                     Spell spell = SpellRegistry.NewSpell( spellID, from, null );
    30.    
    31.                     if ( spell != null )
    32.                         spell.Cast();
    33.                     else
    34.                         from.SendLocalizedMessage( 502345 ); // This spell has been temporarily disabled.
    35.                 }
    36.             }
    37.             else
    38.             {
    39.                 from.SendLocalizedMessage( 500015 ); // You do not have that spell!
    40.             }
    41.         }
    42.  
     
    • Two Thumbs Up Two Thumbs Up x 1
  13. Fred1990
    Offline

    Fred1990 Member

    Joined:
    Jan 23, 2019
    Messages:
    63
    Likes Received:
    2
    Ok Loki I will try thanks for you help !
    --- Double Post Merged, Mar 16, 2019 at 7:46 AM ---
    CS0023: Line 135: Unable to apply operator '!'to the operand of type 'Server.Items.Spellbook'.
    this line

    else if (book.SpellbookType = SpellbookType.Regular && !(book = FindEquippedSpellbook(from)))

    If I remove the "!" same error with && .
     
  14. Lokai
    Offline

    Moderator ServUO Developer

    Joined:
    Dec 4, 2014
    Messages:
    1,123
    Likes Received:
    160
    change it to book == instead of book =

    Like this:

    Code (C#):
    1.  
    2.                 else if (book.SpellbookType == SpellbookType.Regular && !(book == FindEquippedSpellbook(from)))
    3.                 {
     
    • Two Thumbs Up Two Thumbs Up x 1
  15. Fred1990
    Offline

    Fred1990 Member

    Joined:
    Jan 23, 2019
    Messages:
    63
    Likes Received:
    2
    Thanks Loki now works! you are a pro ;)
     
    • No Problem! No Problem! x 1
Similar Threads: Spellbook casts
Forum Title Date
ServUO Discussion Player crafted Fey slayer spellbook. Aug 17, 2018
Archived Bug Reports Lesser slayer spellbooks and dmg percentage Jul 12, 2018
Script Support How to make a spellbook never close on logout/death. Jun 5, 2018
Archived Bug Reports VvV Spellbooks are not antique and do not have durability Jan 19, 2018
Script Support Spellbook corrupted Oct 7, 2017
Script Support Complete Spell System spellbook gump issue Aug 9, 2017
Script Support Crafting FullSpellBook Jun 5, 2017