summaryrefslogtreecommitdiff
path: root/npc/functions/magic.txt
blob: c4abcab6b0a12305818d0f7b77dbc310aebfdc87 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
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;
}