summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-04-11 18:10:49 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-11 18:10:49 +0200
commitc4db19005072f39faf67235d180d00eab6a4666f (patch)
tree90039d3890d58967996a132be68d8c914dc10b4f /src
parent8c31b55cffc3d1d85b90126a9dd2ba6526723fcd (diff)
Lua: Gods: Refactor HOOK_FOLLOW_GOD code to C
Diffstat (limited to 'src')
-rw-r--r--src/defines.h1
-rw-r--r--src/gods.c29
-rw-r--r--src/util.pkg16
3 files changed, 25 insertions, 21 deletions
diff --git a/src/defines.h b/src/defines.h
index c93abb73..04920e63 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -4540,7 +4540,6 @@
#define HOOK_CALC_MANA 60
#define HOOK_LOAD_END 61
#define HOOK_RECALL 62
-#define HOOK_FOLLOW_GOD 63
#define HOOK_BODY_PARTS 65
#define HOOK_APPLY_MAGIC 66
#define HOOK_PLAYER_EXP 67
diff --git a/src/gods.c b/src/gods.c
index 56b1380b..170f56b3 100644
--- a/src/gods.c
+++ b/src/gods.c
@@ -44,6 +44,30 @@ void abandon_god(int god)
}
/*
+ * Check if god may be followed by player
+ */
+static bool_ may_follow_god(int god)
+{
+ if (god == GOD_MELKOR)
+ {
+ int i;
+
+ /* Check if player has wielded The One Ring */
+ for (i = INVEN_WIELD; i < INVEN_TOTAL; i++)
+ {
+ if (p_ptr->inventory[i].name1 == ART_POWER)
+ {
+ msg_print("The One Ring has corrupted "
+ "you, and you are rejected.");
+ return FALSE;
+ }
+ }
+ }
+ /* Default is to allow */
+ return TRUE;
+}
+
+/*
* Get a religion
*/
void follow_god(int god, bool_ silent)
@@ -56,7 +80,7 @@ void follow_god(int god, bool_ silent)
}
/* Are we allowed ? */
- if (process_hooks(HOOK_FOLLOW_GOD, "(d,s)", god, "ask"))
+ if (!may_follow_god(god))
return;
if (p_ptr->pgod == GOD_NONE)
@@ -69,9 +93,6 @@ void follow_god(int god, bool_ silent)
s_info[SKILL_UDUN].hidden = FALSE;
if (!silent) msg_print("You feel the dark powers of Melkor in you. You can now use the Udun skill.");
}
-
- /* Anything to be done? */
- process_hooks(HOOK_FOLLOW_GOD, "(d,s)", god, "done");
}
}
diff --git a/src/util.pkg b/src/util.pkg
index 3e977785..12a28a71 100644
--- a/src/util.pkg
+++ b/src/util.pkg
@@ -708,22 +708,6 @@ typedef unsigned int u32b;
*/
#define HOOK_RECALL 62
-/** @def HOOK_FOLLOW_GOD
- * @brief Player follows a god (gets religion).\n
- * @param Number god \n the god to follow.
- * @brief God
- * @param String action \n "ask" to check if player can follow the god, or
- * "done" to do something with the god.
- * @brief Action
- * @return Boolean \n For "ask": TRUE if player can not follow the god,
- * otherwise FALSE.
- * @note
- * If the action is "ask" and the hook returns TRUE, follow_god() returns.
- * If the action is "done" the return code is ignored.
- * @note (see file gods.c)
- */
-#define HOOK_FOLLOW_GOD 63
-
/** @def HOOK_BODY_PARTS
* @brief Calculate which body parts the player has.
* @note (see file xtra1.c)