summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mods/theme/scpt/s_mandos.lua111
-rw-r--r--src/defines.h1
-rw-r--r--src/dungeon.c9
-rw-r--r--src/externs.h16
-rw-r--r--src/loadsave.c2
-rw-r--r--src/player.pkg1
-rw-r--r--src/spells.pkg14
-rw-r--r--src/spells3.c123
-rw-r--r--src/types.h1
-rw-r--r--src/util.pkg6
-rw-r--r--src/variable.c5
-rw-r--r--src/xtra1.c2
-rw-r--r--src/xtra2.c11
13 files changed, 182 insertions, 120 deletions
diff --git a/lib/mods/theme/scpt/s_mandos.lua b/lib/mods/theme/scpt/s_mandos.lua
index 90876930..48b73c27 100644
--- a/lib/mods/theme/scpt/s_mandos.lua
+++ b/lib/mods/theme/scpt/s_mandos.lua
@@ -2,42 +2,6 @@
BOOK_MANDOS = 66
--- precognition timer for high-level spell [from T-Plus by Ingeborg S. Norden]
-
-function set_precognition(v)
- local notice = FALSE
- if (v < 0) then v = 0 end
- if (v > 10000) then v = 10000 end
-
- -- Check if the state will change
- if (v > 0) and (tim_precognition == 0) then
- msg_print("You feel able to predict the future.")
- notice = TRUE
- elseif (v == 0) and (tim_precognition > 0) then
- msg_print("You feel less able to predict the future.")
- notice = TRUE
- end
-
- -- set the new value
- tim_precognition = v
-
- if (notice == TRUE) then
- player.update = bor(player.update, PU_BONUS)
- disturb(0,0)
- end
- return notice
-end
-
--- related hooks
-
-add_hooks{
- [HOOK_PROCESS_WORLD] = function()
- if (tim_precognition > 0) then
- set_precognition(tim_precognition - 1)
- end
- end,
-}
-
-- "Tears of Luthien" based on Holy Word from T-Plus
MANDOS_TEARS_LUTHIEN = add_spell
{
@@ -50,25 +14,16 @@ MANDOS_TEARS_LUTHIEN = add_spell
["piety"] = TRUE,
["stat"] = A_WIS,
["random"] = SKILL_SPIRITUALITY,
- ["spell"] = function()
- local level = get_level(MANDOS_TEARS_LUTHIEN, 30)
- local obvious = hp_player(10 * level)
- obvious = is_obvious (set_stun(0), obvious)
- obvious = is_obvious (set_cut(0), obvious)
- obvious = is_obvious (set_afraid(0), obvious)
- return obvious
- end,
- ["info"] = function()
- local level = get_level(MANDOS_TEARS_LUTHIEN, 30)
- return "heals "..(10 * level)
- end,
+ ["spell"] = function() return mandos_tears_of_luthien_spell() end,
+ ["info"] = function() return mandos_tears_of_luthien_info() end,
["desc"] = {
"Calls upon the spirit of Luthien to ask Mandos for healing and succour."
}
}
-- "Spirit of the Feanturi" based on Restore Mind from T-Plus
-MANDOS_SPIRIT_FEANTURI = add_spell {
+MANDOS_SPIRIT_FEANTURI = add_spell
+{
["name"] = "Feanturi",
["school"] = {SCHOOL_MANDOS},
["level"] = 10,
@@ -79,33 +34,8 @@ MANDOS_SPIRIT_FEANTURI = add_spell {
["piety"] = TRUE,
["stat"] = A_WIS,
["random"] = SKILL_SPIRITUALITY,
- ["spell"] = function()
- local level = get_level(MANDOS_SPIRIT_FEANTURI, 50)
- local obvious
- obvious = set_afraid(0)
- obvious = is_obvious(set_confused(0), obvious)
-
- if level >= 20 then
- obvious = is_obvious(do_res_stat(A_WIS, TRUE), obvious)
- obvious = is_obvious(do_res_stat(A_INT, TRUE), obvious)
- end
-
- if level >= 30 then
- obvious = is_obvious(set_image(0), obvious)
- obvious = is_obvious(heal_insanity(player.msane * level / 100), obvious)
- end
-
- return obvious
- end,
-
- ["info"] = function()
- local level = get_level(MANDOS_SPIRIT_FEANTURI, 50)
- if level >= 20 then
- return "heals "..level.."%"
- else
- return ""
- end
- end,
+ ["spell"] = function() return mandos_spirit_of_the_feanturi_spell() end,
+ ["info"] = function() return mandos_spirit_of_the_feanturi_info() end,
["desc"] = {
"Channels the power of Mandos to cure fear and confusion.",
"At level 20 it restores lost INT and WIS",
@@ -127,12 +57,8 @@ MANDOS_TALE_DOOM = add_spell
["piety"] = TRUE,
["stat"] = A_WIS,
["random"] = SKILL_SPIRITUALITY,
- ["spell"] = function()
- return set_precognition(5 + get_level(MANDOS_TALE_DOOM,10))
- end,
- ["info"] = function()
- return "dur "..(5 + get_level(MANDOS_TALE_DOOM,10))
- end,
+ ["spell"] = function() return mandos_tale_of_doom_spell() end,
+ ["info"] = function() return mandos_tale_of_doom_info() end,
["desc"] = {
"Allows you to predict the future for a short time."
}
@@ -140,7 +66,6 @@ MANDOS_TALE_DOOM = add_spell
-- "Call to the Halls" based on Call Blessed Soul from T-Plus
MANDOS_CALL_HALLS= add_spell
-
{
["name"] = "Call to the Halls",
["school"] = {SCHOOL_MANDOS},
@@ -151,24 +76,8 @@ MANDOS_CALL_HALLS= add_spell
["piety"] = TRUE,
["stat"] = A_WIS,
["random"] = SKILL_SPIRITUALITY,
- ["spell"] = function()
- local y, x, m_idx
- local summons =
- {
- test_monster_name("Experienced spirit"),
- test_monster_name("Wise spirit"),
- }
- y, x = find_position(player.py, player.px)
- m_idx = place_monster_one(y, x, summons[rand_range(1, 2)], 0, FALSE, MSTATUS_FRIEND)
- if m_idx ~= 0 then
- monster_set_level(m_idx, 20 + get_level(MANDOS_CALL_HALLS, 70, 0))
- return TRUE
- end
- end,
-
- ["info"] = function()
- return "level "..(get_level(MANDOS_CALL_HALLS, 70))
- end,
+ ["spell"] = function() return mandos_call_to_the_halls_spell() end,
+ ["info"] = function() return mandos_call_to_the_halls_info() end,
["desc"] = {
"Summons a leveled spirit from the Halls of Mandos",
"to fight for you."
diff --git a/src/defines.h b/src/defines.h
index 57c4c674..b4a02a11 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -4493,7 +4493,6 @@
#define HOOK_LEVEL_REGEN 42
#define HOOK_LEVEL_END_GEN 43
#define HOOK_BUILDING_ACTION 44
-#define HOOK_PROCESS_WORLD 45
#define HOOK_WIELD_SLOT 46
#define HOOK_STORE_STOCK 47
#define HOOK_STORE_BUY 48
diff --git a/src/dungeon.c b/src/dungeon.c
index b23a4829..e60f1ef0 100644
--- a/src/dungeon.c
+++ b/src/dungeon.c
@@ -1325,9 +1325,6 @@ static void process_world(void)
*/
if (dun_level || (!p_ptr->wild_mode))
{
- /* Let the script live! */
- process_hooks(HOOK_PROCESS_WORLD, "()");
-
/* Handle corruptions */
process_world_corruptions();
@@ -2150,6 +2147,12 @@ static void process_world(void)
(void)set_tim_breath(p_ptr->tim_magic_breath - 1, TRUE);
}
+ /* Timed precognition */
+ if (p_ptr->tim_precognition > 0)
+ {
+ set_tim_precognition(p_ptr->tim_precognition - 1);
+ }
+
/* Timed regen */
if (p_ptr->tim_regen)
{
diff --git a/src/externs.h b/src/externs.h
index 06e0ec76..233f7ea3 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -594,7 +594,6 @@ extern s32b DUNGEON_ASTRAL_WILD_X;
extern s32b DUNGEON_ASTRAL_WILD_Y;
extern deity_type deity_info[MAX_GODS];
extern timer_type *gl_timers;
-extern s16b tim_precognition;
extern const char *get_version_string();
/* plots.c */
@@ -1855,6 +1854,20 @@ char *aule_enchant_armour_info();
bool_ *aule_child_spell();
char *aule_child_info();
+extern s32b MANDOS_TEARS_LUTHIEN;
+extern s32b MANDOS_SPIRIT_FEANTURI;
+extern s32b MANDOS_TALE_DOOM;
+extern s32b MANDOS_CALL_HALLS;
+
+bool_ *mandos_tears_of_luthien_spell();
+char *mandos_tears_of_luthien_info();
+bool_ *mandos_spirit_of_the_feanturi_spell();
+char *mandos_spirit_of_the_feanturi_info();
+bool_ *mandos_tale_of_doom_spell();
+char *mandos_tale_of_doom_info();
+bool_ *mandos_call_to_the_halls_spell();
+char *mandos_call_to_the_halls_info();
+
/* randart.c */
extern int get_activation_power(void);
extern void build_prob(cptr learn);
@@ -2021,6 +2034,7 @@ extern bool_ set_disrupt_shield(int v);
extern bool_ set_prob_travel(int v);
extern bool_ set_absorb_soul(int v);
extern bool_ set_tim_breath(int v, bool_ magical);
+extern bool_ set_tim_precognition(int v);
extern bool_ set_tim_deadly(int v);
extern bool_ set_tim_res_time(int v);
extern bool_ set_tim_reflect(int v);
diff --git a/src/loadsave.c b/src/loadsave.c
index ad982e8d..40718194 100644
--- a/src/loadsave.c
+++ b/src/loadsave.c
@@ -513,7 +513,7 @@ static bool_ do_extra(int flag)
do_s16b(&p_ptr->blessed, flag);
do_s16b(&p_ptr->control, flag);
do_byte(&p_ptr->control_dir, flag);
- do_s16b(&tim_precognition, flag);
+ do_s16b(&p_ptr->tim_precognition, flag);
do_s16b(&p_ptr->tim_thunder, flag);
do_s16b(&p_ptr->tim_thunder_p1, flag);
do_s16b(&p_ptr->tim_thunder_p2, flag);
diff --git a/src/player.pkg b/src/player.pkg
index fdde5229..9115d7cf 100644
--- a/src/player.pkg
+++ b/src/player.pkg
@@ -2633,7 +2633,6 @@ extern void apply_flags(u32b f1, u32b f2, u32b f3, u32b f4, u32b f5, u32b esp, s
/**
* Timered precognition
*/
-extern s16b tim_precognition;
/** @fn set_tim_thunder(int v, int p1, int p2)
diff --git a/src/spells.pkg b/src/spells.pkg
index ac17116b..1b253e12 100644
--- a/src/spells.pkg
+++ b/src/spells.pkg
@@ -2858,3 +2858,17 @@ bool_ *aule_enchant_armour_spell();
char *aule_enchant_armour_info();
bool_ *aule_child_spell();
char *aule_child_info();
+
+extern s32b MANDOS_TEARS_LUTHIEN;
+extern s32b MANDOS_SPIRIT_FEANTURI;
+extern s32b MANDOS_TALE_DOOM;
+extern s32b MANDOS_CALL_HALLS;
+
+bool_ *mandos_tears_of_luthien_spell();
+char *mandos_tears_of_luthien_info();
+bool_ *mandos_spirit_of_the_feanturi_spell();
+char *mandos_spirit_of_the_feanturi_info();
+bool_ *mandos_tale_of_doom_spell();
+char *mandos_tale_of_doom_info();
+bool_ *mandos_call_to_the_halls_spell();
+char *mandos_call_to_the_halls_info();
diff --git a/src/spells3.c b/src/spells3.c
index 15f101de..355d94e4 100644
--- a/src/spells3.c
+++ b/src/spells3.c
@@ -152,6 +152,11 @@ s32b AULE_ENCHANT_WEAPON;
s32b AULE_ENCHANT_ARMOUR;
s32b AULE_CHILD;
+s32b MANDOS_TEARS_LUTHIEN = -1;
+s32b MANDOS_SPIRIT_FEANTURI = -1;
+s32b MANDOS_TALE_DOOM = -1;
+s32b MANDOS_CALL_HALLS = -1;
+
/* FIXME: Hackish workaround while we're still tied to Lua. This lets
us return Lua's "nil" and a non-nil value (which is all the s_aux.lua
@@ -4421,3 +4426,121 @@ char *aule_child_info()
20 + get_level_s(AULE_CHILD, 70));
return buf;
}
+
+static int tears_of_luthien_hp()
+{
+ return 10 * get_level_s(MANDOS_TEARS_LUTHIEN, 30);
+}
+
+bool_ *mandos_tears_of_luthien_spell()
+{
+ hp_player(tears_of_luthien_hp());
+ set_stun(0);
+ set_cut(0);
+ set_afraid(0);
+ return CAST;
+}
+
+char *mandos_tears_of_luthien_info()
+{
+ static char buf[128];
+ sprintf(buf,
+ "heals %d",
+ tears_of_luthien_hp());
+ return buf;
+}
+
+bool_ *mandos_spirit_of_the_feanturi_spell()
+{
+ s32b level = get_level_s(MANDOS_SPIRIT_FEANTURI, 50);
+
+ set_afraid(0);
+ set_confused(0);
+
+ if (level >= 20)
+ {
+ do_res_stat(A_WIS, TRUE);
+ do_res_stat(A_INT, TRUE);
+ }
+
+ if (level >= 30)
+ {
+ set_image(0);
+ heal_insanity(p_ptr->msane * level / 100);
+ }
+
+ return CAST;
+}
+
+char *mandos_spirit_of_the_feanturi_info()
+{
+ static char buf[128];
+ s32b level = get_level_s(MANDOS_SPIRIT_FEANTURI, 50) ;
+ if (level >= 20)
+ {
+ sprintf(buf, "heals " FMTs32b "%%", level);
+ return buf;
+ }
+ else
+ {
+ return "";
+ }
+}
+
+static int tale_of_doom_duration()
+{
+ return 5 + get_level_s(MANDOS_TALE_DOOM,10);
+}
+
+bool_ *mandos_tale_of_doom_spell()
+{
+ set_tim_precognition(tale_of_doom_duration());
+ return CAST;
+}
+
+char *mandos_tale_of_doom_info()
+{
+ static char buf[128];
+ sprintf(buf,
+ "dur %d",
+ tale_of_doom_duration());
+ return buf;
+}
+
+int call_to_the_halls_mlev()
+{
+ return 20 + get_level(MANDOS_CALL_HALLS, 70, 0);
+}
+
+bool_ *mandos_call_to_the_halls_spell()
+{
+#define N_SUMMONS 2
+ int y, x;
+ s16b m_idx, r_idx;
+ s16b summons[N_SUMMONS] = {
+ test_monster_name("Experienced spirit"),
+ test_monster_name("Wise spirit"),
+ };
+
+ r_idx = summons[rand_int(N_SUMMONS)];
+ assert(r_idx >= 0);
+
+ find_position(p_ptr->py, p_ptr->px, &y, &x);
+ m_idx = place_monster_one(y, x, r_idx, 0, FALSE, MSTATUS_FRIEND);
+ if (m_idx)
+ {
+ monster_set_level(m_idx, call_to_the_halls_mlev());
+ return CAST;
+ }
+ return NO_CAST;
+#undef N_SUMMONS
+}
+
+char *mandos_call_to_the_halls_info()
+{
+ static char buf[128];
+ sprintf(buf,
+ "level %d",
+ call_to_the_halls_mlev());
+ return buf;
+}
diff --git a/src/types.h b/src/types.h
index 6066e215..8d12fa68 100644
--- a/src/types.h
+++ b/src/types.h
@@ -1587,6 +1587,7 @@ struct player_type
s16b absorb_soul; /* Timed soul absordtion */
s16b tim_magic_breath; /* Magical breathing -- can breath anywhere */
s16b tim_water_breath; /* Water breathing -- can breath underwater */
+ s16b tim_precognition; /* Timed precognition */
s16b immov_cntr; /* Timed -- Last ``immovable'' command. */
diff --git a/src/util.pkg b/src/util.pkg
index e6f0294f..2ec70acf 100644
--- a/src/util.pkg
+++ b/src/util.pkg
@@ -524,12 +524,6 @@ typedef unsigned int u32b;
*/
#define HOOK_BUILDING_ACTION 44
-/** @def HOOK_PROCESS_WORLD
- * @brief Update world every ten turns.
- * @note (see file dungeon.c)
- */
-#define HOOK_PROCESS_WORLD 45
-
/** @def HOOK_WIELD_SLOT
* @brief Find equipment slot for object.\n
* @param Object o_ptr \n the object to wield.
diff --git a/src/variable.c b/src/variable.c
index 11019a22..105bbc7f 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -1574,11 +1574,6 @@ s32b DUNGEON_ASTRAL_WILD_Y = 19;
*/
timer_type *gl_timers = NULL;
-/*
- * Timered precognition.
- */
-s16b tim_precognition = 0;
-
/**
* Get the version string.
diff --git a/src/xtra1.c b/src/xtra1.c
index c20b9036..f393635f 100644
--- a/src/xtra1.c
+++ b/src/xtra1.c
@@ -3336,7 +3336,7 @@ void calc_bonuses(bool_ silent)
}
/* Temporary precognition */
- if (tim_precognition > 0)
+ if (p_ptr->tim_precognition > 0)
{
apply_flags(0, 0, 0, TR4_PRECOGNITION, 0, 0, 0, 0, 0, 0, 0);
}
diff --git a/src/xtra2.c b/src/xtra2.c
index 7958827b..d78858b3 100644
--- a/src/xtra2.c
+++ b/src/xtra2.c
@@ -241,6 +241,17 @@ bool_ set_tim_breath(int v, bool_ magical)
}
/*
+ * Set timered precognition
+ */
+bool_ set_tim_precognition(int v)
+{
+ return set_simple_field(
+ &p_ptr->tim_precognition, v,
+ TERM_WHITE, "You feel able to predict the future.",
+ TERM_WHITE, "You feel less able to predict the future.");
+}
+
+/*
* Set "p_ptr->absorb_soul"
* notice observable changes
*/