summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--npc/012-3_Cave/_import.txt1
-rw-r--r--npc/012-3_Cave/mana-seed.txt265
-rw-r--r--npc/functions/magic.txt19
3 files changed, 285 insertions, 0 deletions
diff --git a/npc/012-3_Cave/_import.txt b/npc/012-3_Cave/_import.txt
index 92995992..7d427ad8 100644
--- a/npc/012-3_Cave/_import.txt
+++ b/npc/012-3_Cave/_import.txt
@@ -1,4 +1,5 @@
map: 012-3.gat
npc: npc/012-3_Cave/_mobs.txt
npc: npc/012-3_Cave/_warps.txt
+npc: npc/012-3_Cave/mana-seed.txt
npc: npc/012-3_Cave/monsters.txt
diff --git a/npc/012-3_Cave/mana-seed.txt b/npc/012-3_Cave/mana-seed.txt
new file mode 100644
index 00000000..1d973fff
--- /dev/null
+++ b/npc/012-3_Cave/mana-seed.txt
@@ -0,0 +1,265 @@
+012-3.gat,62,130,0 script Mana Seed#MAGIC 166,{
+
+ setarray @magic_exp_needed,
+ 0, // level 0
+ 0,
+ 100,
+ 1200,
+ 8000,
+ 40000; // level 5
+
+ setarray @exp_bonus,
+ 0,
+ 1000, // level 1
+ 10000,
+ 100000,
+ 400000,
+ 2000000; // level 5
+
+ setarray @min_level,
+ 0,
+ 10,
+ 30,
+ 50,
+ 65,
+ 80; // level 5
+
+ set @visions_nr, 13;
+ setarray @visions$,
+ "You see a dark underground temple; you are kneeling, praying for the safety of the planet. You smile as a friend joins you in the dark-- but suddenly a shadow falls over you from above, and a stabbing pain...",
+ "It is midnight; you are in an underground cavern deep inside the desert ruins. Slowly, as if half-asleep, you wander up the spiral pathway, towards the ancient vase at its center. As you reach out to touch it...",
+ "The old castle smells of mildew and swamp gas. It has not been used in centuries, but you were here before, when the world was young. You turn to face your companions-- but something is wrong with all three; an ancient force has possessed them...",
+ "As you put the horn to your lips, you feel winds flowing, gathering, condensing in your chest. Soon, you can no longer contain it; the storm unleashes through your mouth, into a deafening fanfare. The black dome around you begins to crack...",
+ "You are alone inside your head, confined by the laughing man's circlet. Powerless, you witness how your hands shoot out flame after flame, incinerating innocents for that man's experiments...",
+ "The village may be in ruins, but it must have been where you grew up. The engravings on the walls-- images of powerful beasts-- look strangely familiar, and you can make out writing, words about you, wishes and prayers for you... You are at home...",
+ "Deep underneath the city, the rocky cavern maze turns into an opulent palace. This must be where the beast of the many eyes resides. Nervously you grip the wand; will the power to repel it be sufficient to defeat it and its magic?",
+ "At the bottom of the abyss, infinity opens before you. You have proven yourself worthy, and the ancient finally reveals its wisdom...",
+ "You may only be children, but you recognize that it is this man only who can save the world. As the walls rush towards you to crush your small group, you exchange a glance with your twin sister-- there is no doubt what you must do...",
+ "The sacred place is surrounded by nothingness; were it not for your magic, you would have no hope of returning. The old and young man stands nearby; he has been waiting for you, for centuries. He has all the time in the world, after all...",
+ "Nothing remains behind. The underground castle is empty now, its chambers plundered, its throne destroyed. Shivering, you climb down the stairs, towards the wailing of the underworld that is waiting beneath...",
+ "You feel soft, fluffy fur brushing against your skin and are filled with happines. Somehow, the word `" + getspellinvocation("happy-curse") + "' comes to mind...";
+
+ set @max_magic, 2;
+
+ set @has_magic, getskilllv(SKILL_MAGIC);
+ set @drank_potion, MAGIC_FLAGS & @MFLAG_DRANK_POTION;
+ set @knows_seed, MAGIC_FLAGS & @MFLAG_KNOWS_MANASEED;
+
+ if (@has_magic)
+ goto L_magic_start;
+
+ if (@knows_seed)
+ goto L_quick_nomagic;
+
+ // first time here
+
+ set MAGIC_FLAGS, MAGIC_FLAGS | MFLAG_KNOWS_MANASEED;
+
+ mes "[Mana Seed]";
+ mes "You see a glowing orb, swimming in the water like a sea rose.";
+ mes "An unearthly glow is emanating from within, lighting up the water and filling the cave with an eerie light.";
+ next;
+
+ mes "[Mana Seed]";
+ if (@drank_potion)
+ mes "Slowly, the tingling sensation you felt before begins to spread through your body again.";
+ mes "What would you like to do?";
+ next;
+ goto L_nomagic_mainmenu;
+
+L_quick_nomagic:
+ mes "[Mana Seed]";
+ mes "Again you stand before the orb.";
+ if (@drank_potion)
+ mes "Slowly, the tingling sensation you felt before begins to spread through your body again.";
+ mes "What would you like to do?";
+ next;
+
+ goto L_nomagic_mainmenu;
+
+// Non-Magic main menu ------------------------------------------------------------
+L_nomagic_mainmenu:
+ menu "Examine it more closely", L_nomagic_examine,
+ "Take it with you", L_nomagic_touch,
+ "Touch it", L_nomagic_touch,
+ "Throw a rock at it", L_nomagic_throwrock,
+ "Destroy it", L_nomagic_destroy,
+ "Leave it alone", L_end;
+ close;
+
+L_nomagic_examine:
+ mes "[Mana Seed]";
+ mes "The orb seems to be perfectly round and emitting a steady glow. It appears to be floating in the water.";
+ next;
+ goto L_nomagic_mainmenu;
+
+L_nomagic_throwrock:
+ mes "[Mana Seed]";
+ mes "Your rock makes hardly a sound as it strikes the orb and glances off into the water, leaving neither scratch nor impression.";
+ mes "The orb budges slightly, but then floats back into its old position, as if it were tethered into place.";
+ next;
+ goto L_nomagic_mainmenu;
+
+L_nomagic_touch:
+ mes "[Mana Seed]";
+ if (@drank_potion)
+ goto L_magic_level_1;
+ mes "As you touch the orb, you feel a terrible force within, separated from you by only the thinnest of membranes-- like a tempest, all packed up in one tiny waterskin.";
+ next;
+ mes "[Mana Seed]";
+ mes "For one instant you feel that force rushing past your hands, through your body, as if you had unleashed this tempest upon yourself. Unable to contain the power, you stumble backwards, away from the orb.";
+ set MAGIC_FLAGS, MAGIC_FLAGS | MFLAG_TOUCHED_MANASEED;
+ next;
+ goto L_nomagic_mainmenu;
+
+L_magic_level_1:
+ if (getskilllv(SKILL_MAGIC))
+ goto L_end; // shouldn't be happening
+
+ mes "Again you feel the tempest rushing through the Mana Seed's membrane, into your body. You only manage to hold on to it for an instant and find yourself forced to pull your hands away again quickly.";
+ next;
+
+ mes "[Mana Seed]";
+ mes "But this time something is different-- that tingling sensation is back, and stronger than before. It is spreading through your body, head to toes, and you feel yourself brimming with energy.";
+ next;
+
+ mes "[Mana Seed]";
+ mes "It is a light-headed feeling, and you find yourself forced to sit down for a few seconds to recover.";
+ mes "Something is different. A new power has grown within you and is waiting to be understood.";
+ mes "[1000 experience points]";
+ next;
+
+ skill SKILL_MAGIC, 1;
+ getexp 1000, 0;
+ next;
+
+ goto L_end;
+
+L_nomagic_destroy:
+ mes "[Mana Seed]";
+ mes "Try as you might, the orb seems impervious to all forms of attack you can fathom. You are forced to abandon your efforts.";
+ next;
+ goto L_nomagic_mainmenu;
+
+// Magic main menu ------------------------------------------------------------
+L_magic_start:
+ mes "[Mana Seed]";
+ mes "The Mana Seed is still in the same place as during your last visit, spreading its light throughout the cavern.";
+ mes "What would you like to do?";
+ next;
+
+L_magic_mainmenu:
+ menu "Touch it", L_magic_touch,
+ "Destroy it", L_magic_destroy,
+ "Leave it alone", L_end;
+ close;
+
+L_magic_touch:
+ mes "[Mana Seed]";
+ mes "You touch the Mana Seed again.";
+
+ if (getskilllv(SKILL_MAGIC) >= @max_magic)
+ goto L_magic_maxed_out;
+
+ set @exp_needed, @magic_exp_needed[getskilllv(SKILL_MAGIC) + 1];
+ set @magic_exp, MAGIC_EXPERIENCE & 65535;
+ if (@magic_exp >= @exp_needed)
+ goto L_magic_levelup;
+
+ set @prev_exp_needed, @magic_exp_needed[getskilllv(SKILL_MAGIC)];
+ set @exp_diff, @exp_needed - @prev_exp_needed;
+ set @index, ((@magic_exp - @prev_exp_needed) * 5) / @exp_diff;
+ setarray @messages$,
+ "The orb's energy effortlessly rushes through you, ignoring your feeble attempts at containing it. You will need considerably more practice with your magical skills before you can hope to contain it.",
+ "You only barely manage to hang on to some strands of the orb's energy, but not enough to contain it. You still need noticeably more practice with your magical skills.",
+ "The orb's powers are still no match for you; you will need more practice to contain more of its powers.",
+ "You feel close to being able to contain the orb's powers. Still, some more practice is needed.",
+ "The orb's energy only barely evades your attempts at containing it. Soon you will be able to extract more power from it.";
+
+ mes @messages$[@index];
+ next;
+ goto L_magic_mainmenu;
+
+L_magic_levelup:
+ set @baselevel_needed, @min_level[getskilllv(SKILL_MAGIC) + 1];
+ if (base_level < @baselevel_needed)
+ goto L_insufficient_baselevel;
+ mes "Its energy permeates you, surrounds you. You are suddenly uncertain if it is you who is containing the orb's powers or if it is the orb who is seeking out yours.";
+ next;
+
+ mes "[Mana Seed]";
+ mes "The Seed's tempest is calming beneath your hands, and its energies resonate with yours.";
+ next;
+
+ mes "[Mana Seed]";
+ mes "A feeling of harmony is spreading through your body, and the tingling sensation is back, within and without.";
+ next;
+
+ mes "[Mana Seed]";
+ mes "As the tingling increases, you feel light-headed, weightless.";
+ mes "Everything fades...";
+ next;
+
+ mes "Both the tingling and the sense of harmony have vanished, making room for darkness. You can't feel the Mana Seed anymore...";
+ next;
+
+ mes "... you can't feel anything.";
+ next;
+
+ mes "You are floating...";
+ next;
+
+ mes "The darkness is no longer complete. You begin to make out stars in the distance, circling each other, dancing a cosmic dance.";
+ next;
+
+ mes "Images rush past you, shadows of thoughts and dreams. Some touch you, filling you with powerful emotions-- despair, extasy; sometimes loss, sometimes hope; hate, love.";
+ next;
+
+ mes "Someone else's thoughts pass through your mind...";
+ next;
+
+ set @nr, rand(@visions_nr);
+ mes @visions$[@nr];
+ next;
+
+ mes "The image fades.";
+ next;
+
+ mes "[Mana Seed]";
+ mes "You awaken, lying on the ground.";
+ next;
+
+ mes "[Mana Seed]";
+ mes "Something has changed... you feel more confident in your magical abilities.";
+
+ skill SKILL_MAGIC, 1 + getskilllv(SKILL_MAGIC);
+ set @exp, @exp_bonus[getskilllv(SKILL_MAGIC)];
+ itemheal 0, 10000;
+ getexp @exp, 0;
+ mes "[" + @exp + " experience points]";
+ next;
+
+ goto L_magic_end;
+
+L_magic_maxed_out:
+ mes "Strangely, you feel nothing, as if its membrane had closed towards you.";
+ set MAGIC_FLAGS, MAGIC_FLAGS | MFLAG_MANASEED_MAXEDOUT;
+ next;
+
+ goto L_magic_mainmenu;
+
+L_insufficent_baselevel:
+ mes "Its energies rush through you. You fight to keep them under control, to contain them in your body. Alas, your body is too frail-- you have to let go.";
+ mes "Frustrated, you give up. You have the skill needed to control this power, but you will have to grow up some more before your body can handle it.";
+ next;
+ goto L_magic_mainmenu;
+
+L_magic_destroy:
+ mes "[Mana Seed]";
+ mes "Try as you might, you cannot find a way, magical or physical, to destroy the seed. Frustrated, you give up.";
+ next;
+ goto L_magic_mainmenu;
+
+L_end:
+ close;
+}
diff --git a/npc/functions/magic.txt b/npc/functions/magic.txt
new file mode 100644
index 00000000..9cce48c2
--- /dev/null
+++ b/npc/functions/magic.txt
@@ -0,0 +1,19 @@
+// Basic magic functionality
+
+// Magic system uses:
+// - MAGIC_EXP (magic experience points, gained for spellcasting)
+// - MAGIC_FLAGS
+
+// ------------------------------------------------------------
+// Gain initial magic skill
+// ------------------------------------------------------------
+function script MagicGainBasic {
+
+ set MAGIC_FLAGS, MAGIC_FLAGS | MFLAG_DRANK_POTION;
+ close;
+
+}
+
+function script MagicGainExp {
+ set MAGIC_EXP, MAGIC_EXP + (@value * @value);
+}