Page 1 of 1

Customized Paladin Spells

Posted: Sun Nov 06, 2022 9:36 pm
by Azzerhoden
Added the following paladin spells and attached them to the Paladin spell book. The spells added are:
#. . Name . . . . . . . . . . Mana . . . .Skill . . .Tithing . . . . . Description
1 -- Create Food . . . . . . . 5 . . . . . 0 . . . . . . 5 . . . . . . . As Mage Spell
2 -- Divine Prayer . . . . . .10 . . . . . 5 . . . . . .10. . . . . . . Raise Magic Resistance
3 -- Blessing . . . . . . . . . 10 . . . . . 10 . . . . . .5. . . . . . . Longer lasting Bless spell
4 -- Cleanse by Fire . . . . 10 . . . . . 15 . . . . . 10. . . . . . . Removes poison from target, damages caster with fire
5 -- Blessed Weapon . . . .10 . . . . . 20 . . . . . 10. . . . . . . Weapon receives silver bonus for a time
6 -- Faithful Mantra . . . . .0 . . . . . 25 . . . . . 30. . . . . . . 0 mana spell, converts 30 Tithing to 15 Mana
7 -- Summon Mount . . . . 30 . . . . . 30 . . . . . 50. . . . . . . Paladin’s Mount - Does not go away
8 -- Close Wounds . . . . . 10 . . . . . 35 . . . . . 10. . . . . . . Heals 25% Chivalry + 1d6
9 -- Second Wind . . . . . .10 . . . . . 40 . . . . . 10. . . . . . . Converts 25% Chivalry Hps to Stamina + 1d6
10 - Divine Shield . . . . . .20 . . . . . 45 . . . . . 10. . . . . . . Reflect next spell cast at Paladin
11 - Righteous Fury . . . . .10 . . . . . 50 . . . . . 10. . . . . . . Increase in Tactics, Sword Skills at the expense of Parry
12 - Sacred Journey . . . . 20 . . . . . 55 . . . . . 15. . . . . . . As the Mage spell recall, when out of combat
13 - Banishment . . . . . . .20 . . . . . 60 . . . . . 20. . . . . . . Dispels summoned creature
14 - Noble Sacrifice . . . . 20 . . . . . 65 . . . . . 30. . . . . . . Resurrects, Removes Poison, Greater Heals within 6 tiles
15 - Holy Aura . . . . . . . .30 . . . . . 75 . . . . . 40. . . . . . . Undead, Daemons, and Murderers within 3 tiles take AoE damage
16 - Raise the Dead . . . . 50 . . . . . 85 . . . . . 50. . . . . . . As Mage spell resurrection
//  Paladin Spells Enablement
//  By Azzerhoden Razeri
//  Nov, 2022 - version .5a#1
//  This script adds 16 spells for Paladins, using tithe points as currency.  
//  For new Paladins, an amount of tithing points is set the first time they open their spell book.  After that they must Tithe at an Ankh
//  On my server, I added the ability to tithe on the Ankh tiles in Britain, but at a 10 gold to 1 tithe ratio. At the actual Ankh's, its 1 for 1.
//  On my server, I added a special Paladin Mount, using these values
//      NAME=a paladins charger
//      ID=0x011c
//      SKIN=0x070a
//      TOTAME=1199
//
//      I also raised some of the other values to reflect the tougher nature of the mount.
//  In this script, Paladins are not allowed to cast spells while a criminal, nor cast targeted spells on criminals.

var initTithing = 100;          //  The initial amount of thithing granted for opening the paladin book the first time.
var palMount = "paladinmount";  //  The default mount that Paladins summon.  If not added as a separate mount in mounts.dfn, use a different mount type

function getChivDuration(pUser)
{
    return (parseInt((pUser.skills.chivalry)/30*10000)); // The default length of time a spell will last.  At skill of 60 this is 200 seconds)
}

function getChivEffect(pUser)
{
    return (parseInt((pUser.skills.chivalry)/100)* 2); // Default effect of a spell that is cast (Blessing).  At 60 this is 12.
}

function onUseChecked( pUser, iUsed )
{
    // Is this the first time the paladin has opened the book?  If so, give them some tithing
    if (pUser.GetTag("Tithing") == "")
        pUser.SetTag("Tithing",initTithing);

    var socket = pUser.socket;
    socket.tempObj = iUsed;
    if( iUsed.container != null )
    {
        var paladinGump = new Gump;
        paladinGump.AddPage(0);
        paladinGump.AddGump( 30, 30, 2200 );
        paladinGump.AddText( 70, 40, 55, "BOOK of CHIVALRY" );
        paladinGump.AddText( 230, 40, 55, "FAITH:  " + numberWithCommas(pUser.GetTag("Tithing")));
        paladinGump.AddButton( 60, 70, 0x837, 1, 0, 1 );
        paladinGump.AddText( 80, 65, 47, "Summon Food" );               //  Summon Food or Water
        paladinGump.AddButton( 60, 90, 0x837, 1, 0, 2 );
        paladinGump.AddText( 80, 85, 47, "Divine Prayer" );             //  Raise Magic Resistance
        paladinGump.AddButton( 60, 110, 0x837, 1, 0, 3 );
        paladinGump.AddText( 80, 105, 47, "Blessing" );                 //  Better, longer lasting Bless spell
        paladinGump.AddButton( 60, 130, 0x837, 1, 0, 4 );
        paladinGump.AddText( 80, 125, 47, "Cleanse by Fire" );          //  As written
        paladinGump.AddButton( 60, 150, 0x837, 1, 0, 5 );
        paladinGump.AddText( 80, 145, 47, "Blessed Weapon" );           //  Weapon receives silver bonus for a time
        paladinGump.AddButton( 60, 170, 0x837, 1, 0, 6 );
        paladinGump.AddText( 80, 165, 47, "Faithful Mantra" );          //  0 mana spell, converts Tithing  to Mana
        paladinGump.AddButton( 60, 190, 0x837, 1, 0, 7 );
        paladinGump.AddText( 80, 185, 47, "Summon Mount" );             //  Paladin’s Mount - Does not go away
        paladinGump.AddButton( 60, 210, 0x837, 1, 0, 8 );
        paladinGump.AddText( 80, 205, 47, "Close Wounds" );             //  Heals 25% Chivalry + 1d6
        paladinGump.AddButton( 220, 70, 0x837, 1, 0, 9 );
        paladinGump.AddText( 240, 65, 47, "Second Wind" );              //  Converts 25% Chivalry Hps to Stamina + 1d6
        paladinGump.AddButton( 220, 90, 0x837, 1, 0, 10 );
        paladinGump.AddText( 240, 85, 47, "Divine Shield" );            //  Reflect next spell cast at Paladin
        paladinGump.AddButton( 220, 110, 0x837, 1, 0, 11 );
        paladinGump.AddText( 240, 105, 47, "Righteous Fury" );          //  Increase in Tactics, Weapon Skills, Parry
        paladinGump.AddButton( 220, 130, 0x837, 1, 0, 12 );
        paladinGump.AddText( 240, 125, 47, "Sacred Journey" );          //  recall when out of combat
        paladinGump.AddButton( 220, 150, 0x837, 1, 0, 13 );
        paladinGump.AddText( 240, 145, 47, "Banishment" );              //  Dispels summoned creature
        paladinGump.AddButton( 220, 170, 0x837, 1, 0, 14 );
        paladinGump.AddText( 240, 165, 47, "Noble Sacrifice" );         //  As written
        paladinGump.AddButton( 220, 190, 0x837, 1, 0, 15 );
        paladinGump.AddText( 240, 185, 47, "Holy Aura" );               //  Nearby Undead, Red’s, take AoE damage
        paladinGump.AddButton( 220, 210, 0x837, 1, 0, 16 );
        paladinGump.AddText( 240, 205, 47, "Raise Dead" );              //  As the mage spell
        paladinGump.Send( pUser ); // send this gump to client now
        paladinGump.Free(); // clear this gump from uox-memory
        return false;
    }
    else
        pUser.SysMessage( "That must be in your pack for you to use it." );
    return false;
}

function onGumpPress( pSock, pButton, gumpData )
{
    var iUsed = pSock.tempObj;
    var pUser = pSock.currentChar;

    // Are we recovering from another spell that was just cast
    if( pUser.GetTimer( Timer.SPELLRECOVERYTIME ) != 0 )
    {
        if( pUser.GetTimer( Timer.SPELLRECOVERYTIME ) > GetCurrentClock() )
        {
            if( pSock )
                pSock.SysMessage( GetDictionaryEntry( 1638, mSock.language ) ); // You must wait a little while before casting
            return true;
        }
    }

    // Are we already casting?
    if( !spellTimerCheck( pUser, pSock ) )
        return true;

    if( !jailTimerCheck( pUser, pSock ) )
        return true;

    if (pUser.criminal) // Test if the Paladin is a criminal as they cannot case spells when true
    {
        pUser.SysMessage("You cannot cast spells while flag as a criminal!");
        return true;       
    }


    // Region checks
    var ourRegion = pUser.region;
    if( pButton == 12 && !ourRegion.canRecall )
    {
        if( pSock )
            pSock.SysMessage( GetDictionaryEntry( 705, pSock.language ) );
        pUser.SetTimer( Timer.SPELLTIME, 0 );
        pUser.isCasting = false;
        pUser.spellCast = -1;
        return true;
    }

    if( pUser.visible == 1 || pUser.visible == 2 )
        pUser.visible = 0;

    if( pSock )
        pUser.BreakConcentration( pSock );

    switch(pButton)
    {
        case 0: // abort and do nothing
            break;
        case 1:     //  Create Food
            if (checkMana(pUser, 5) && checkTithing(pUser, 5))  
            {
                pUser.mana = (pUser.mana - 5);
                deductTithing(pUser, 5);
                if( pUser.CheckSkill( 51, 0, 251 ) )  // check if create food succeeds
                {
                    pUser.TextMessage("In Mani Yelm");
                    if( !pUser.isonhorse )
                        pUser.DoAction( 17 );
                    pUser.StartTimer( 750, 1, true );
                    break;
                }
                else
                    spellFailed(pUser, "nourishment");
            }
            break;
        case 2:      // Devine Prayer
            if (checkMana(pUser, 10) && checkTithing(pUser, 10))  
            {
                pUser.mana = (pUser.mana - 10);
                deductTithing(pUser, 10);
                if( pUser.CheckSkill( 51, 50, 301 ) )  // check if divine prayer succeeds
                {      
                    pUser.TextMessage("Divinum Sancti");
                    if( !pUser.isonhorse )
                        pUser.DoAction( 17 );
                    pUser.StartTimer( 1500, 2, true );
                    break;
                }
                else
                    spellFailed(pUser, "protection");
            }
            break;
        case 3:     //  Blessing
            if (checkMana(pUser, 10) && checkTithing(pUser, 5))  
            {
                pUser.mana = (pUser.mana - 10);
                deductTithing(pUser, 5);
                if( pUser.CheckSkill( 51, 100, 351 ) )  // check if blessing succeeds
                {      
                    pUser.TextMessage("Rel Sanct");
                    if( !pUser.isonhorse )
                        pUser.DoAction( 17 );
                    pUser.StartTimer( 1500, 3, true );
                    break;
                }
                else
                    spellFailed(pUser, "a blessing");
            }
            break;
        case 4: // Cleanse by Fire
            if (checkMana(pUser, 10) && checkTithing(pUser, 10))  
            {
                pUser.mana = (pUser.mana - 10);
                deductTithing(pUser, 10);
                if( pUser.CheckSkill( 51, 150, 401 ) )  // check if cure succeeds
                {      
                    pUser.TextMessage("Vas Nox Sanna");
                    if( !pUser.isonhorse )
                        pUser.DoAction( 17 );
                    pUser.StartTimer( 1500, 4, true );
                    break;
                }
                else
                    spellFailed(pUser, "a clensing");
            }
            break;
        case 5:     // Blessed Weapon
            if (checkMana(pUser, 10) && checkTithing(pUser, 10))  
            {
                pUser.mana = (pUser.mana - 10);
                deductTithing(pUser, 10);
                if( pUser.CheckSkill( 51, 200, 451 ) )  // check if weapon is blessed
                {      
                    pUser.TextMessage("Rel Telum Sanct");
                    if( !pUser.isonhorse )
                        pUser.DoAction( 17 );
                    pUser.StartTimer( 2000, 5, true );
                    break;
                }
                else
                    spellFailed(pUser, "a clensing");
            }
            break;
        case 6:     //  Faithful Mantra
            if (checkMana(pUser, 0) && checkTithing(pUser, 30))  
            {
                pUser.mana = (pUser.mana - 0);
                deductTithing(pUser, 30);
                if( pUser.CheckSkill( 51, 250, 501 ) )  // check if faithful mantra succeeds
                {      
                    pUser.TextMessage("Precatio Votum Vis");
                    if( !pUser.isonhorse )
                        pUser.DoAction( 17 );
                    pUser.StartTimer( 3000, 6, true );
                    break;
                }
                else
                    spellFailed(pUser, "mental focus");
            }
            break;
        case 7:     // Summon Mount
            if (checkMana(pUser, 30) && checkTithing(pUser, 50))  
            {
                pUser.mana = (pUser.mana - 30);
                deductTithing(pUser, 50);
                if( pUser.CheckSkill( 51, 300, 551 ) )  // check if summon mount succeeds
                {      
                    pUser.TextMessage("Sanct Kal Xen");
                    if( !pUser.isonhorse )
                        pUser.DoAction( 17 );
                    pUser.StartTimer( 3000, 7, true );
                    break;
                }
                else
                    spellFailed(pUser, "a mount");
            }
            break;
        case 8:     // Close Wounds  
            if (checkMana(pUser, 10) && checkTithing(pUser, 10))  
            {
                pUser.mana = (pUser.mana - 10);
                deductTithing(pUser, 10);
                if( pUser.CheckSkill( 51, 350, 601 ) )  // check if close wounds succeeds
                {      
                    pUser.TextMessage("In Vas Sana");
                    if( !pUser.isonhorse )
                        pUser.DoAction( 17 );
                    pUser.StartTimer( 1500, 8, true );
                    break;
                }
                else
                    spellFailed(pUser, "healing");
            }
            break;
        case 9:     // Second Wind
            if (checkMana(pUser, 10) && checkTithing(pUser, 10))  
            {
                pUser.mana = (pUser.mana - 10);
                deductTithing(pUser, 10);
                if( pUser.CheckSkill( 51, 400, 651 ) )  // check if second wind succeeds
                {      
                    pUser.TextMessage("In Vas Navitas");
                    if( !pUser.isonhorse )
                        pUser.DoAction( 17 );
                    pUser.StartTimer( 2000, 9, true );
                    break;
                }
                else
                    spellFailed(pUser, "recovery");
            }
            break;
        case 10:        // Divine Shield
            if (checkMana(pUser, 20) && checkTithing(pUser, 10))  
            {
                pUser.mana = (pUser.mana - 20);
                deductTithing(pUser, 10);
                if( pUser.CheckSkill( 51, 450, 701 ) )  // check if divine shield succeeds
                {      
                    pUser.TextMessage("Sanct Recrepo");
                    if( !pUser.isonhorse )
                        pUser.DoAction( 17 );
                    pUser.StartTimer( 3000, 10, true );
                    break;
                }
                else
                    spellFailed(pUser, "reflection");
            }
            break;
        case 11:        //  Righteous Fury
            if (checkMana(pUser, 10) && checkTithing(pUser, 10))  
            {
                pUser.mana = (pUser.mana - 10);
                deductTithing(pUser, 10);
                if( pUser.CheckSkill( 51, 500, 751 ) )  // check if righteous fury shield succeeds
                {      
                    pUser.TextMessage("Profor Furia");
                    if( !pUser.isonhorse )
                        pUser.DoAction( 17 );
                    pUser.StartTimer( 3000, 11, true );
                    break;
                }
                else
                    spellFailed(pUser, "righteous fury");
            }      
            break;
        case 12:        // Sacred Journey
            if (checkMana(pUser, 20) && checkTithing(pUser, 15))  
            {
                pUser.mana = (pUser.mana - 20);
                deductTithing(pUser, 15);
                if( pUser.CheckSkill( 51, 550, 801 ) )  // check if sacred journey succeeds
                {      
                    pUser.TextMessage("Sanctus Travectio");
                    if( !pUser.isonhorse )
                        pUser.DoAction( 17 );
                    pUser.StartTimer( 3000, 12, true );
                    break;
                }
                else
                    spellFailed(pUser, "a quick journey");
            }      
            break;
        case 13:        // Banishment
            if (checkMana(pUser, 20) && checkTithing(pUser, 20))  
            {
                pUser.mana = (pUser.mana - 20);
                deductTithing(pUser, 20);
                if( pUser.CheckSkill( 51, 800, 851 ) )  // check if banishment succeeds
                {      
                    pUser.TextMessage("Malus Ejicio");
                    if( !pUser.isonhorse )
                        pUser.DoAction( 17 );
                    pUser.StartTimer( 3000, 13, true );
                    break;
                }
                else
                    spellFailed(pUser, "a banishment");
            }      
            break;
        case 14:        // Noble Sacrifice
            if (checkMana(pUser, 20) && checkTithing(pUser, 30))  
            {
                pUser.mana = (pUser.mana - 20);
                deductTithing(pUser, 30);
                if( pUser.CheckSkill( 51, 650, 901 ) )  // check if noble sacrifise succeeds
                {      
                    pUser.TextMessage("Magnus Sui Sacrum");
                    if( !pUser.isonhorse )
                        pUser.DoAction( 17 );
                    pUser.StartTimer( 3000, 14, true );
                    break;
                }
                else
                    spellFailed(pUser, "self sacrifice");
            }      
            break;
        case 15:        // Holy Aura
            if (checkMana(pUser, 30) && checkTithing(pUser, 40))  
            {
                pUser.mana = (pUser.mana - 30);
                deductTithing(pUser, 40);
                if( pUser.CheckSkill( 51, 750, 1001 ) )  // check if holy aura succeeds
                {
                    if ( pUser.GetTempTag("HolyAuraActive") == "" )     // Only 1 active at a time
                    {
                        pUser.SetTempTag("HolyAuraActive", "true");
                        pUser.SetTempTag("HolyAuraCount", 0);
                        pUser.TextMessage("Castus Templum");
                        if( !pUser.isonhorse )
                            pUser.DoAction( 17 );
                        pUser.StartTimer( 3000, 15, true );
                    }
                    else
                        pUser.SysMessage("Holy Aura already in effect");
                    break;
                }
                else
                    spellFailed(pUser, "holy aura");
            }      
            break;
        case 16:        // Raise the Dead
            if (checkMana(pUser, 50) && checkTithing(pUser, 50))  
            {
                pUser.mana = (pUser.mana - 50);
                deductTithing(pUser, 50);
                if( pUser.CheckSkill( 51, 850, 1001 ) )  // check if divine shield succeeds
                {      
                    pUser.TextMessage("Mors Verto Vita");
                    if( !pUser.isonhorse )
                        pUser.DoAction( 17 );
                    pUser.StartTimer( 5000, 16, true );
                    break;
                }
                else
                    spellFailed(pUser, "a resurrection");
            }                  
            break;
        default:
            break;
    }
}

function onTimer( pUser, timerID )
{
    var socket = pUser.socket;
    switch(timerID)
    {
        case 1:     // Create Food
            pUser.SoundEffect( 0x01E2, true );
            var itemMade = CreateDFNItem( pUser.socket, pUser, "listobject72", 1, "ITEM", true );
            break;
        case 2:     // Divine Prayer
            if( socket )
            {
                socket.CustomTarget( 0, "Select the beneficiary", 2 ); // Friendly cursor type
            }
            break;
        case 3:     // Cast Blessing
            if( socket )
            {
                socket.CustomTarget( 1, "Select the beneficiary", 2 ); // Friendly cursor type
            }
            break;
        case 4:     // Clense by Fire
            if( socket )
            {
                socket.CustomTarget( 4, "Select the beneficiary", 2 ); // Friendly cursor type
            }
            break;         
        case 5:     //  Blessed Weapon
            if (pUser.GetTag("BlessedItem") != "")
            {
                pUser.SysMessage("Your may only have 1 blessed weapon at a time.");
                break;
            }
            var itemRHand = pUser.FindItemLayer( 0x01 );
            var itemLHand = pUser.FindItemLayer( 0x02 );
            if( itemLHand || ( itemRHand && itemRHand.type != 9 ) ) // Spellbook
            {
                if (itemRHand)
                {
                    pUser.SetTag("BlessedItem", "True");               
                    itemRHand.race = 11;
                    itemRHand.StartTimer( getChivDuration(pUser), 22, true);       
                }
                else
                {
                    itemLHand.race = 11;
                    pUser.SetTag("BlessedItem", "True");               
                    itemLHand.StartTimer( getChivDuration(pUser), 22, true);       
                }
                pUser.SoundEffect(0x01E7, true );
                pUser.SysMessage("Your held weapon is now blessed against undead");
                // We call a timer on the item to expire the blessing, but we have to also call a timer on the owner to reset tag
                pUser.StartTimer(getChivDuration(pUser),23,true);
            }
            else
                pUser.SysMessage("You do not have a weapon equipped.");                            
            break;
        case 6:     // Faithful Mantra
            pUser.SoundEffect( 0x01E7, true );
            pUser.mana = (pUser.mana + 15);
            break;
        case 7:     // Summon Mount
            pUser.SoundEffect( 0x1FB, true );
            var nSpawned = SpawnNPC( palMount, pUser.x, pUser.y, pUser.z, pUser.worldnumber );  // palMount set at top of script
            if( nSpawned )
            {
                nSpawned.owner = pUser;
                nSpawned.aitype = 0;
                nSpawned.Follow( pUser );
                nSpawned.wandertype = 1;
            }
            break;
        case 8:     // Close Wounds
            if( socket )
            {
                socket.CustomTarget( 8, "Select the beneficiary", 2 ); // Friendly cursor type
            }
            break;
        case 9:     // Second Wind
            pUser.SoundEffect( 0x01E7, true );
            pUser.StaticEffect( 0x373A, 0, 15 );
            pUser.stamina = (pUser.stamina + getChivEffect(pUser) + RandomNumber(1,6));
            break;
        case 10:    // Divine Shield
            pUser.SoundEffect( 0x01E9, true );
            pUser.StaticEffect( 0x373A, 0, 15 );
            pUser.magicReflect = true;
            break;
        case 11:    // Righteous Fury
            pUser.SoundEffect( 0x01E7, true );
            pUser.StaticEffect( 0x373A, 0, 15 );
            var furyEffect = (getChivEffect(pUser) * 20);
            pUser.SetTempTag("furyTactics", pUser.skills.tactics);
            pUser.SetTempTag("furySword", pUser.skills.swordsmanship);
            pUser.SetTempTag("furyParry", pUser.skills.parrying);
            pUser.skills.tactics += furyEffect;
            pUser.skills.swordsmanship += furyEffect;
            if (furyEffect > parseInt(pUser.skills.parrying))
                pUser.skills.parrying = 0;
            else
                pUser.skills.parrying = (parseInt(pUser.skills.parrying) - furyEffect);
            pUser.StartTimer( getChivDuration(pUser), 21, true);           
            break;
        case 12:    // Sacred Journey
            if( socket )
            {
                socket.CustomTarget( 5, "Select the destination rune", 2 ); // Friendly cursor type
            }
            break;         
        case 13:    // Banishment
            if( socket )
            {
                socket.CustomTarget( 6, "Select the target for banishment", 2 ); // Friendly cursor type
            }
            break;         
        case 14:    // Noble Sacrifice
            AreaCharacterFunction("DoNobleSacrifice", pUser, 6);
            pUser.health = 1;
            pUser.mana = 1;
            pUser.stamina = 1;
            break;
        case 15:    // Holy Aura
            if ( pUser.GetTempTag("HolyAuraActive") != "" )
            {
                pUser.SetTempTag("HolyAuraCount", parseInt(pUser.GetTempTag("HolyAuraCount") + 1));
                AreaCharacterFunction("DoHolyAura", pUser, 3);
                pUser.StartTimer( 5000, 15, true );
            }
            break;
        case 16:    // Raise the Dead
            if( socket )
            {
                socket.CustomTarget( 7, "Select the beneficiary", 2 ); // Friendly cursor type
            }
            break;         
        case 20:
            pUser.skills.magicresistance = pUser.GetTempTag("origMagResist");
            pUser.SetTempTag("origMagResist", "");
            break; 
        case 21:
            pUser.skills.tactics = pUser.GetTempTag("furyTactics");
            pUser.skills.swordsmanship = pUser.GetTempTag("furySword");
            pUser.skills.parrying = pUser.GetTempTag("furyParry");;
            pUser.SetTempTag("furyTactics", "");
            pUser.SetTempTag("furySword", "");
            pUser.SetTempTag("furyParry", "");
        case 22:
            // Not really a user as the timer is called on an item.  Set to -1 as setting to null actually sets it to 0 (human)
            pUser.race = -1;
            break;
        case 23:
            pUser.SetTag("BlessedItem", "");
            pUser.SysMessage("Your weapon's blessing has worn off.");
            break;
        default:
            break;
    }  
}

function onCallback0( socket, myTarget)     // Divine Prayer
{
    var pUser = socket.currentChar;
    var iUsed = socket.tempObj;

    if ( myTarget.GetTempTag("origMagResist") != "" )  //  Only 1 active at a time
    {
        pUser.SysMessage(myTarget.name + "already benefits from Divine Prayer!");
        return;
    }
    if (isTargetCriminal(pUser, myTarget))
    {
        return;
    }
   
    myTarget.SetTempTag("origMagResist", pUser.skills.magicresistance);
    if( !socket.GetWord( 1 ) && myTarget.isChar )
    {
        if( pUser.InRange( myTarget, 12 ))
        {
            myTarget.SoundEffect( 0x0202, true );
            myTarget.StaticEffect( 0x373A, 0, 15 );
            myTarget.skills.magicresistance += parseInt((getChivEffect(pUser) * 10) + (RandomNumber(1,6) * 10));
            myTarget.StartTimer( getChivDuration(pUser), 20, true );
        }
        else
            pUser.SysMessage( "Your target is out of range." );
    }
    else
        pUser.SysMessage( "You cannot target that." );
}

function onCallback1( socket, myTarget)     // Blessing
{
    var pUser = socket.currentChar;
    var iUsed = socket.tempObj;
    if (isTargetCriminal(pUser, myTarget))
    {
        return;
    }

    if( !socket.GetWord( 1 ) && myTarget.isChar )
    {
        if( pUser.InRange( myTarget, 12 ))
        {
            myTarget.SoundEffect( 0x0202, true );
            myTarget.StaticEffect( 0x373A, 0, 15 );
            pUser.SysMessage("Effect is: " + getChivEffect(pUser));
            DoTempEffect( 0, pUser, myTarget, 11, getChivEffect(pUser), getChivDuration(pUser), 0);
        }
        else
            pUser.SysMessage( "Your target is out of range." );
    }
    else
        pUser.SysMessage( "You cannot target that." );
}

function onCallback4( socket, myTarget) // Cleanse by Fire
{
    var pUser = socket.currentChar;
    var iUsed = socket.tempObj;
    if (isTargetCriminal(pUser, myTarget))
    {
        return;
    }

    if( !socket.GetWord( 1 ) && myTarget.isChar )
    {
        if( pUser.InRange( myTarget, 12 ))
        {
            var damage = 20;
            if( pUser.health < 20)
                damage = pUser.health - 1;
            if (pUser != myTarget)
            {
                DoTempEffect( 0, pUser, pUser, 30, damage, 0, 0);
                myTarget.criminal = false;
            }
            else
                pUser.health = (pUser.health - damage);
            myTarget.poison = 0;
            myTarget.StaticEffect( 0x373A, 0, 15 );
            myTarget.SoundEffect(0x01E0, true );
        }
        else
            pUser.SysMessage( "Your target is out of range." );
    }
    else
        pUser.SysMessage( "You cannot target that." );
}

function onCallback5( socket, myTarget)     //  Sacred Journey
{
    var pUser = socket.currentChar;
    var iUsed = socket.tempObj;
    if (isTargetCriminal(pUser, myTarget))
    {
        return;
    }

    if( !socket.GetWord( 1 ) && (myTarget.id == 0x1f14) )
    {
        pUser.StaticEffect( 0x373A, 0, 15 );
        pUser.SoundEffect(0x01FC, true );
        pUser.Recall(myTarget);
    }      
}

function onCallback6( socket, myTarget) // Banishment
{
    var pUser = socket.currentChar;
    var iUsed = socket.tempObj;
    if( !pUser.InRange( myTarget, 12 ))
    {
        pUser.SysMessage( "Your target is out of range." );
        return;
    }
    if (isTargetCriminal(pUser, myTarget))
    {
        return;
    }
    if( !socket.GetWord( 1 ) && myTarget.npc && myTarget.isDispellable)
    {
        pUser.SoundEffect( 0x01E9, true );
        myTarget.StaticEffect( 0x373A, 0, 15 );
        var targetOwner = myTarget.owner;
        var useResist = (myTarget.baseskills.magicresistance < targetOwner.skills.magicresistance ? targetOwner.skills.magicresistance : myTarget.baseskills.magicresistance);
        var dispellChance = ((500-(useResist - pUser.skills.chivalry) / 1.5) > 950 ? 950 : (500-(useResist - pUser.skills.chivalry) / 1.5));
        var rndNumber = RandomNumber(0, 1000);
        if (myTarget.race == 10 || myTarget.race == 11)
            rndNumber -= 100;  // give a boost to banishing undead and daemons
        if ( dispellChance > rndNumber)
            myTarget.Delete();
        else
            pUser.SysMessage( myTarget.name + " resisted your banishment." );
    }  
    else
        pUser.SysMessage( "Your target cannot be banished." );
}

function onCallback7( socket, myTarget) // Raise the Dead
{
    var pUser = socket.currentChar;
    var iUsed = socket.tempObj;
    if (isTargetCriminal(pUser, myTarget))
    {
        return;
    }
    if( !socket.GetWord( 1 ) && myTarget.isChar )
    {
        if( pUser.InRange( myTarget, 12 ) && myTarget.dead)
        {
            myTarget.Resurrect();
            return true;
        }
    }      
}


function onCallback8( socket, myTarget) // Close Wounds
{
    var pUser = socket.currentChar;
    var iUsed = socket.tempObj;
    if (isTargetCriminal(pUser, myTarget))
    {
        return;
    }
    if( !socket.GetWord( 1 ) && myTarget.isChar )
    {
        if( pUser.InRange( myTarget, 12 ) && !myTarget.dead)
        {
            myTarget.StaticEffect( 0x373A, 0, 15 );
            myTarget.SoundEffect(0x01E0, true );
            myTarget.health = (myTarget.health + (getChivEffect(pUser) * 2) + RandomNumber(1,10));
        }
    }      
}

function DoNobleSacrifice(pUser, trgChar)   // Noble Sacrifice
{
    if( ValidateObject( trgChar ) && trgChar != pUser && trgChar.vulnerable && (( trgChar.npc && ( trgChar.tamed || trgChar.hireling )) || trgChar.online ))
    {  
        if( !trgChar.npc && trgChar.dead )
            trgChar.Resurrect();
        if( trgChar.poison > 0 )
            trgChar.poison = 0;
        trgChar.health += (getChivEffect(pUser) * 2) + RandomNumber(1, 10);
        trgChar.mana += (getChivEffect(pUser) * 2) + RandomNumber(1, 10);
        trgChar.stamina += (getChivEffect(pUser) * 2) + RandomNumber(1, 10);
        trgChar.SoundEffect( 0x0202, true );
        trgChar.StaticEffect( 0x373A, 0, 15 );
    }
}

function DoHolyAura(pUser, trgChar)     // Holy Aura effects undead, daemons, npc murderers and player murderers who are online
{                                      
    if ( parseInt(pUser.GetTempTag("HolyAuraCount")) <= (getChivEffect(pUser) / 2))
    {
        if( ValidateObject( trgChar ) && trgChar != pUser && trgChar.vulnerable &&
                (( trgChar.npc && ( trgChar.race.id == 11 || trgChar.race.id == 10 || trgChar.murderer )) || (trgChar.online && trgChar.murderer)))
        {  
            trgChar.health = parseInt(trgChar.health - (getChivEffect(pUser) / 2));
            trgChar.StaticEffect(0x374a, 0, 15 );
            trgChar.SoundEffect(0x5cf, true);
        }
    }
    else
    {
        pUser.SetTempTag("HolyAuraActive", "");
        pUser.SetTempTag("HolyAuraCount", 0);
    }
}

function numberWithCommas(x) {
    x = x.toString();
    var pattern = /(-?\d+)(\d{3})/;
    while (pattern.test(x))
        x = x.replace(pattern, "$1,$2");
    return x;
}

function checkMana(pUser, min)
{
    if ( pUser.mana < min)
    {
        pUser.SysMessage("Your mana is to low.");
        return false;
    }
    return true;
}

function checkTithing(pUser, min)
{
    if ( pUser.GetTag("Tithing") < min)
    {
        pUser.SysMessage("Your faith is lacking.");
        return false;
    }
    return true;
}

function deductTithing(pUser, amt)
{
    pUser.SetTag("Tithing", (pUser.GetTag("Tithing") - amt));
    if (pUser.GetTag("Tithing") < 100)
        pUser.SysMessage("You tithe is dangerously low.");
    else
        pUser.SysMessage("You used " + amt + " of your tithe total.");
    return true;
}

function spellFailed(pUser, name)
{
    pUser.SysMessage( "You failed to pray for " + name + "." );
    pUser.StaticEffect( 0x3735, 0, 15 );
    pUser.SoundEffect( 0x56D, true );
    return true;    
}

function isTargetCriminal(pUser, myTarget)
{
    if (myTarget.criminal || myTarget.murderer)
    {
        pUser.SysMessage("You cannot cast this on a criminal!");
        return true;
    }
    return
        false;
}

function spellTimerCheck( mChar, mSock )
{
    if( mChar.GetTimer( Timer.SPELLTIME ) != 0 )
    {
        if( mChar.isCasting )
        {
            if( mSock )
                mSock.SysMessage( GetDictionaryEntry( 762, mSock.language ) );
            return false;
        }
        else if( mChar.GetTimer( Timer.SPELLTIME ) > GetCurrentClock() )
        {
            if( mSock )
                mSock.SysMessage( GetDictionaryEntry( 1638, mSock.language ) );
            return false;
        }
    }
    return true;
}


function jailTimerCheck( mChar, mSock )
{
    if( mChar.isJailed && mChar.commandlevel < 2 )
    {
        mSock.SysMessage( GetDictionaryEntry( 704, mSock.language ) );
        mChar.SetTimer( Timer.SPELLTIME, 0 );
        mChar.isCasting = false;
        mChar.spellCast = -1;
        return false;
    }
    return true;
}

function spellEnableCheck( mChar, mSock, mSpell )
{
    if( !mSpell.enabled )
    {
        if( mSock )
            mSock.SysMessage( GetDictionaryEntry( 707, mSock.language ) );
        mChar.SetTimer( Timer.SPELLTIME, 0 );
        mChar.isCasting = false;
        mChar.spellCast = -1;
        return false;
    }
    return true;
}

Re: Customized Paladin Spells

Posted: Sun Nov 06, 2022 9:37 pm
by Azzerhoden
At some later point I will rebuild the book and allow for scribing of Paladin spells. Will also move the hard coded spell values to spells.dfn for easier tweaking.

BUG FIXES (code above already changed)
#1 - On the attached file, on the function
function isTargetCriminal(pUser, myTarget)
{
    if (myTarget.criminal)
    {
        pUser.SysMessage("You cannot cast this on a criminal!");
        return true;
    }
    return
        false;
}
Update test to read
    if (myTarget.criminal || myTarget.murderer)

Re: Customized Paladin Spells

Posted: Sun Nov 06, 2022 10:28 pm
by Azzerhoden
I am sure this tithing script can be written better, but for now, here it is for your convenience. First I added a file for invisible floor tiles that I placed on the ankh tiles in the wilderness and within the Britain church.
.\dfndata\items\building\floors\invisible_tiles.dfn

// Invisible tiles that call scripts

// invisible britain ankh planks
[invisible_ba_tile]
{
get=0x04A1
name=invisible britain ankh tile
movable=2
visible=3
script=5038
decay=0
}

[invisible_wild_tile]
{
get=0x04A1
name=invisible wildnerness ankh tile
movable=2
visible=3
script=5039
decay=0
}

Then I associated those above tiles with the attached scripts.