From bae4b92e560c2694eaaf0e8b4d9e95e56204471b Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sat, 18 Jun 2011 21:58:47 -0700 Subject: Move to a subdirectory --- world/map/npc/functions/magic.txt | 176 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 world/map/npc/functions/magic.txt (limited to 'world/map/npc/functions/magic.txt') diff --git a/world/map/npc/functions/magic.txt b/world/map/npc/functions/magic.txt new file mode 100644 index 00000000..c4abcab6 --- /dev/null +++ b/world/map/npc/functions/magic.txt @@ -0,0 +1,176 @@ +// 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; + close; + +} + +// ------------------------------------------------------------ +// 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; +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; +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; +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; +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; +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; +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; +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; +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; +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], -, + @choice$[1], -, + @choice$[2], -, + @choice$[3], -, + @choice$[4], -, + @choice$[5], -, + @choice$[6], -, + @choice$[7], -, + @choice$[8], -, + @choice$[9], -; + + 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; +} -- cgit v1.2.3-60-g2f50