summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-04-05 20:12:21 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-07 15:28:25 +0200
commit2bd0f18da7dbccd650d8a83aa457d5190f4ce1bc (patch)
treecb248715a89b2af50a5ee27cfb9a862322df331a
parent6548c6fb76232f4502d0856e04f169394deb6093 (diff)
Lua: Move HOOK_CALC_BONUS code for gods to C
-rw-r--r--lib/mods/theme/scpt/gods_new.lua56
-rw-r--r--lib/mods/theme/scpt/s_mandos.lua9
-rw-r--r--src/externs.h1
-rw-r--r--src/loadsave.c1
-rw-r--r--src/player.pkg5
-rw-r--r--src/variable.c5
-rw-r--r--src/xtra1.c69
7 files changed, 81 insertions, 65 deletions
diff --git a/lib/mods/theme/scpt/gods_new.lua b/lib/mods/theme/scpt/gods_new.lua
index 9a020915..0a3b7283 100644
--- a/lib/mods/theme/scpt/gods_new.lua
+++ b/lib/mods/theme/scpt/gods_new.lua
@@ -22,24 +22,6 @@ GOD_AULE = add_god
},
["hooks"] =
{
- [HOOK_CALC_BONUS] = function()
- if (player.pgod == GOD_AULE) and (player.grace > 0) then
- -- Resist fire, not shown on the character screen (?)
- if (player.grace > 5000) then
- player.resist_fire = TRUE
- end
-
- local bonus = player.grace / 5000
- if bonus > 5 then
- bonus = 5
- end
- player.to_h = player.to_h + bonus
- player.dis_to_h = player.dis_to_h + bonus
- player.to_d = player.to_d + bonus
- player.dis_to_d = player.dis_to_d + bonus
-
- end
- end,
[HOOK_PROCESS_WORLD] = function()
if (player.pgod == GOD_AULE) then
GRACE_DELAY = GRACE_DELAY + 1
@@ -204,25 +186,6 @@ GOD_ULMO = add_god
},
["hooks"] =
{
- [HOOK_CALC_BONUS] = function()
- if (player.pgod == GOD_ULMO) then
- player.water_breath = TRUE
- end
- if (player.pgod == GOD_ULMO) and (player.grace > 0) then
- local bonus = player.grace / 5000
- if bonus > 5 then
- bonus = 5
- end
-
- if ((player.grace > 1000) and (player.praying == TRUE)) then
- player.resist_pois = TRUE
- end
- if ((player.grace > 15000) and (player.praying == TRUE)) then
- player.magic_breath = TRUE
- end
- end
- end,
-
[HOOK_MONSTER_DEATH] = function(m_idx)
if (player.pgod == GOD_ULMO) then
m_ptr = monster(m_idx)
@@ -319,25 +282,6 @@ GOD_MANDOS = add_god
},
["hooks"] =
{
- [HOOK_CALC_BONUS] = function()
- if (player.pgod == GOD_MANDOS) then
- player.resist_neth = TRUE
- end
- if (player.pgod == GOD_MANDOS) and (player.grace > 0) then
- local bonus = player.grace / 5000
- if bonus > 5 then
- bonus = 5
- end
-
- if ((player.grace > 10000) and (player.praying == TRUE)) then
- player.resist_continuum = TRUE
- end
-
- if ((player.grace > 20000) and (player.praying == TRUE)) then
- player.immune_neth = TRUE
- end
- end
- end,
[HOOK_PROCESS_WORLD] = function()
if (player.pgod == GOD_MANDOS) then
GRACE_DELAY = GRACE_DELAY + 1
diff --git a/lib/mods/theme/scpt/s_mandos.lua b/lib/mods/theme/scpt/s_mandos.lua
index cc7e346a..90876930 100644
--- a/lib/mods/theme/scpt/s_mandos.lua
+++ b/lib/mods/theme/scpt/s_mandos.lua
@@ -4,8 +4,6 @@ BOOK_MANDOS = 66
-- precognition timer for high-level spell [from T-Plus by Ingeborg S. Norden]
-add_loadsave("tim_precognition",0)
-
function set_precognition(v)
local notice = FALSE
if (v < 0) then v = 0 end
@@ -33,13 +31,6 @@ end
-- related hooks
add_hooks{
- [HOOK_CALC_BONUS] = function()
- if (tim_precognition > 0) then
- --player.precognition = TRUE
- apply_flags(0, 0, 0, TR4_PRECOGNITION, 0, 0, 0, 0, 0, 0, 0)
- end
- end,
-
[HOOK_PROCESS_WORLD] = function()
if (tim_precognition > 0) then
set_precognition(tim_precognition - 1)
diff --git a/src/externs.h b/src/externs.h
index 4f8def3a..6821fd30 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -602,6 +602,7 @@ extern s32b DUNGEON_ASTRAL_WILD_Y;
extern deity_type *deity_info;
extern s32b max_gods;
extern timer_type *gl_timers;
+extern s16b tim_precognition;
extern const char *get_version_string();
/* plots.c */
diff --git a/src/loadsave.c b/src/loadsave.c
index 5d43d79a..58a0931b 100644
--- a/src/loadsave.c
+++ b/src/loadsave.c
@@ -512,6 +512,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_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 dfdced26..b2f46506 100644
--- a/src/player.pkg
+++ b/src/player.pkg
@@ -2622,6 +2622,11 @@ extern void apply_flags(u32b f1, u32b f2, u32b f3, u32b f4, u32b f5, u32b esp, s
#define SHIELD_FEAR 0x0008
/** @} */
+/**
+ * Timered precognition
+ */
+extern s16b tim_precognition;
+
/** @fn set_tim_thunder(int v, int p1, int p2)
* @brief Player has timed thunderstorm.\n
diff --git a/src/variable.c b/src/variable.c
index 9ed084b4..5b1afc3b 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -1592,6 +1592,11 @@ s32b max_gods = MAX_GODS_INIT;
*/
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 c708f3f9..e39c2fad 100644
--- a/src/xtra1.c
+++ b/src/xtra1.c
@@ -2424,6 +2424,69 @@ void calc_gods()
if (p_ptr->grace > 15000) p_ptr->stat_add[A_STR] += 1;
if (p_ptr->grace > 20000) p_ptr->stat_add[A_STR] += 1;
}
+
+ /* Aule provides to-hit/damage bonuses and fire resistance */
+ GOD(get_god_AULE())
+ {
+ if (p_ptr->grace > 0)
+ {
+ int bonus;
+ /* Resist fire, not shown on the character screen (?) */
+ if (p_ptr->grace > 5000)
+ {
+ p_ptr->resist_fire = TRUE;
+ }
+
+ bonus = p_ptr->grace / 5000;
+ if (bonus > 5)
+ {
+ bonus = 5;
+ }
+
+ p_ptr->to_h = p_ptr->to_h + bonus;
+ p_ptr->dis_to_h = p_ptr->dis_to_h + bonus;
+ p_ptr->to_d = p_ptr->to_d + bonus;
+ p_ptr->dis_to_d = p_ptr->dis_to_d + bonus;
+ }
+ }
+
+ /* Mandos provides nether resistance and, while praying,
+ nether immunity and prevents teleportation. */
+ GOD(get_god_MANDOS())
+ {
+ p_ptr->resist_neth = TRUE;
+
+ if ((p_ptr->grace > 10000) &&
+ (p_ptr->praying == TRUE))
+ {
+ p_ptr->resist_continuum = TRUE;
+ }
+
+ if ((p_ptr->grace > 20000) &&
+ (p_ptr->praying == TRUE))
+ {
+ p_ptr->immune_neth = TRUE;
+ }
+ }
+
+ /* Ulmo provides water breath and, while praying can
+ provide poison resistance and magic breath. */
+ GOD(get_god_ULMO())
+ {
+ p_ptr->water_breath = TRUE;
+
+ if ((p_ptr->grace > 1000) &&
+ (p_ptr->praying == TRUE))
+ {
+ p_ptr->resist_pois = TRUE;
+ }
+
+ if ((p_ptr->grace > 15000) &&
+ (p_ptr->praying == TRUE))
+ {
+ p_ptr->magical_breath = TRUE;
+ }
+ }
}
/* Apply flags */
@@ -3151,6 +3214,12 @@ void calc_bonuses(bool_ silent)
p_ptr->dis_to_a += 100;
}
+ /* Temporary precognition */
+ if (tim_precognition > 0)
+ {
+ apply_flags(0, 0, 0, TR4_PRECOGNITION, 0, 0, 0, 0, 0, 0, 0);
+ }
+
/* Breath */
if (p_ptr->tim_water_breath)
{