summaryrefslogblamecommitdiff
path: root/world/map/npc/functions/magic.txt
blob: 426bf28cd8c3d7de52577ea378b78f276f538365 (plain) (tree)
1
2
3
4
5
6
7
8




                                                                 


                    



                                                               
                              
 
                                                      


                                                      
           
 



                                                                
                                     
 









                            




                                                               
                                                               

                                                               
                             
 








                                                              
                          
 
                 






                                                                        
                           
 
                  






                                                  
                             
 
                    






                                                     
                        
 
               






                                                       
                          
 
                 






                                                         
                           
 
                  






                                                    
                         
 
                






                                                                         
                      
 
             








                                                              
                             
 
                    




                                                











                                 






                               
 



                                                               



                                                                          
                                                               
                       
 









                                                         

           

                                                                                     
 
// Basic magic functionality

// Magic system uses:
// - MAGIC_EXP (magic experience points, gained for spellcasting)
// - MAGIC_FLAGS
// Magic quests use:
// - QUEST_MAGIC
// - QUEST_MAGIC2

// ------------------------------------------------------------
// Gain initial magic skill
// ------------------------------------------------------------
function|script|MagicGainBasic
{
    set MAGIC_FLAGS, MAGIC_FLAGS | MFLAG_DRANK_POTION;
    // Doomsday Act 5 utils
    if (getmap() == "099-5")
        addtimer 10, "Zax De'Kagen#0::OnAdjustPotion";
    return;
}

// ------------------------------------------------------------
// Initialise Menu for selecting a choice of things to ask about
// ------------------------------------------------------------
function|script|MagicTalkOptionsSetup
{
    set @QQ_ELANORE, 1;
    set @QQ_MANASEED, 2;
    set @QQ_MANAPOTION, 4;
    set @QQ_WYARA, 8;
    set @QQ_SAGATHA, 16;
    set @QQ_AULDSBEL, 32;
    set @QQ_IMP, 64;
    set @QQ_OLDWIZ, 128;
    set @QQ_ASTRALSOUL, 256;
    return;
}

// ------------------------------------------------------------
// Print and run menu for choice of things to ask about
// Ignores the entry in @ignore
// Returns the result in @c, or returns 0 if there is no result
// ------------------------------------------------------------

function|script|MagicTalkMenu
{
    setarray @choice$, "", "", "", "", "", "", "", "", "", "";
    set @choices_nr, 0;
    setarray @choice_idx, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;

    if (@ignore & @QQ_ELANORE)
        goto L_Q_post_elanore;
    set @choice$[@choices_nr], "...Elanore the Healer?";
    set @choice_idx[@choices_nr], @QQ_ELANORE;
    set @choices_nr, @choices_nr + 1;
    goto L_Q_post_elanore;

L_Q_post_elanore:
    if (@ignore == @QQ_MANASEED)
        goto L_Q_post_manaseed;
    if (!(MAGIC_FLAGS & (MFLAG_KNOWS_MANASEED | MFLAG_MANASEED_RUMOUR)))
        goto L_Q_post_manaseed;
    set @choice$[@choices_nr], "...the Mana Seed?";
    set @choice_idx[@choices_nr], @QQ_MANASEED;
    set @choices_nr, @choices_nr + 1;
    goto L_Q_post_manaseed;

L_Q_post_manaseed:
    if (@ignore & @QQ_MANAPOTION)
        goto L_Q_post_manapotion;
    if (!(MAGIC_FLAGS & MFLAG_KNOWS_MANAPOTION))
        goto L_Q_post_manapotion;
    set @choice$[@choices_nr], "...Mana Potions?";
    set @choice_idx[@choices_nr], @QQ_MANAPOTION;
    set @choices_nr, @choices_nr + 1;
    goto L_Q_post_manapotion;

L_Q_post_manapotion:
    if (@ignore & @QQ_WYARA)
        goto L_Q_post_wyara;
    if (!(MAGIC_FLAGS & MFLAG_KNOWS_WYARA))
        goto L_Q_post_wyara;
    set @choice$[@choices_nr], "...Wyara the Witch?";
    set @choice_idx[@choices_nr], @QQ_WYARA;
    set @choices_nr, @choices_nr + 1;
    goto L_Q_post_wyara;

L_Q_post_wyara:
    if (@ignore & @QQ_SAGATHA)
        goto L_Q_post_sagatha;
    if (!(MAGIC_FLAGS & MFLAG_KNOWS_SAGATHA))
        goto L_Q_post_sagatha;
    set @choice$[@choices_nr], "...Sagatha the Witch?";
    set @choice_idx[@choices_nr], @QQ_SAGATHA;
    set @choices_nr, @choices_nr + 1;
    goto L_Q_post_sagatha;

L_Q_post_sagatha:
    if (@ignore & @QQ_AULDSBEL)
        goto L_Q_post_auldsbel;
    if (!(MAGIC_FLAGS & MFLAG_KNOWS_AULDSBEL))
        goto L_Q_post_auldsbel;
    set @choice$[@choices_nr], "...Auldsbel the Wizard?";
    set @choice_idx[@choices_nr], @QQ_AULDSBEL;
    set @choices_nr, @choices_nr + 1;
    goto L_Q_post_auldsbel;

L_Q_post_auldsbel:
    if (@ignore & @QQ_OLDWIZ)
        goto L_Q_post_oldwiz;
    if (!(MAGIC_FLAGS & MFLAG_KNOWS_OLD_WIZARD))
        goto L_Q_post_oldwiz;
    set @choice$[@choices_nr], "...the Old Wizard?";
    set @choice_idx[@choices_nr], @QQ_OLDWIZ;
    set @choices_nr, @choices_nr + 1;
    goto L_Q_post_oldwiz;

L_Q_post_oldwiz:
    if (@ignore & @QQ_IMP)
        goto L_Q_post_imp;
    if (!(MAGIC_FLAGS & MFLAG_KNOWS_IMP))
        goto L_Q_post_imp;
    set @choice$[@choices_nr], "...the Earth Spirit in the desert well?";
    set @choice_idx[@choices_nr], @QQ_IMP;
    set @choices_nr, @choices_nr + 1;
    goto L_Q_post_imp;

L_Q_post_imp:
    if (@ignore & @QQ_ASTRALSOUL)
        goto L_Q_post_astralsoul;
    if (!(getskilllv(SKILL_MAGIC)))
        goto L_Q_post_astralsoul;
    if (!(getskilllv(SKILL_POOL)))
        goto L_Q_post_astralsoul;
    set @choice$[@choices_nr], "...ways to improve my magic?";
    set @choice_idx[@choices_nr], @QQ_ASTRALSOUL;
    set @choices_nr, @choices_nr + 1;
    goto L_Q_post_astralsoul;

L_Q_post_astralsoul:
    set @choice$[@choices_nr], "...never mind.";
    set @choice_idx[@choices_nr], 0;
    set @choices_nr, @choices_nr + 1;

    menu
        @choice$[0], L_MenuItems,
        @choice$[1], L_MenuItems,
        @choice$[2], L_MenuItems,
        @choice$[3], L_MenuItems,
        @choice$[4], L_MenuItems,
        @choice$[5], L_MenuItems,
        @choice$[6], L_MenuItems,
        @choice$[7], L_MenuItems,
        @choice$[8], L_MenuItems,
        @choice$[9], L_MenuItems;

L_MenuItems:
    set @menu, @menu - 1;

    if (@menu >= @choices_nr)
        set @menu, 0;

    set @c, @choice_idx[@menu];
    return;
}


// ------------------------------------------------------------
// Level up a skill
// @SUP_id        skill ID to level up
// @SUP_lvl        skill level to attain
// @SUP_name$        name of the skill to level up
// @SUP_xp        # of experience points to award if the level up succeeds
// ------------------------------------------------------------
function|script|SkillUp
{
    if (getskilllv(@SUP_id) >= @SUP_lvl)
        goto L_shortcut;

    misceffect sfx_skillup, strcharinfo(0);
    setskill @SUP_id, @SUP_lvl;
    getexp @SUP_xp, 0;
    if (@SUP_xp)
        mes "[" + @SUP_xp + " experience points]";
    mes "[Level " + @SUP_lvl + " in " + @SUP_name$ + "]";
    return;

L_shortcut:
    mes "[You already have level " + getskilllv(@SUP_id) + " in " + @SUP_name$ + "]";
    return;
}