summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-04-06 11:40:03 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-07 15:28:26 +0200
commit3f819c170739b098f9f7951fc9c2ff407f3bbf03 (patch)
tree911a13dd8d57a68c701fe4d38dd82653482abbfa /src
parent6a860ab9022123d9fc5387424ef49eb3a814c64b (diff)
Lua: Moved corruption "can_gain" checks to C
Diffstat (limited to 'src')
-rw-r--r--src/externs.h1
-rw-r--r--src/lua_bind.c45
-rw-r--r--src/player.pkg1
3 files changed, 47 insertions, 0 deletions
diff --git a/src/externs.h b/src/externs.h
index 97569fc0..469f9633 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -1869,6 +1869,7 @@ extern void lua_add_to_list(list_type *, int idx, cptr str);
extern void lua_display_list(int y, int x, int h, int w, cptr title, list_type *list, int max, int begin, int sel, byte sel_color);
extern bool_ player_has_corruption(int corruption_idx);
+extern bool_ player_can_gain_corruption(int corruption_idx);
extern cptr compass(int y, int x, int y2, int x2);
extern cptr approximate_distance(int y, int x, int y2, int x2);
diff --git a/src/lua_bind.c b/src/lua_bind.c
index 424d1f74..e9eb95a0 100644
--- a/src/lua_bind.c
+++ b/src/lua_bind.c
@@ -11,6 +11,7 @@
*/
#include "angband.h"
+#include <assert.h>
#include "lua.h"
#include "tolua.h"
@@ -595,9 +596,53 @@ bool_ player_has_corruption(int corruption_idx)
return FALSE;
}
+
+
return (p_ptr->corruptions[corruption_idx]);
}
+bool_ player_can_gain_corruption(int corruption_idx)
+{
+ cptr r_name = rp_ptr->title + rp_name;
+ bool_ allowed = TRUE; /* Allowed by default */
+
+ assert(corruption_idx >= 0);
+
+ if (corruption_idx == CORRUPT_TROLL_BLOOD)
+ {
+ /* Ok trolls should not get this one. never. */
+ if (streq(r_name, "Troll"))
+ {
+ allowed = FALSE;
+ }
+ }
+
+ /* Theme module adds additional restrictions for Maiar */
+
+ if (game_module_idx == MODULE_THEME)
+ {
+ if (streq(r_name, "Maia"))
+ {
+ /* We use a whitelist of corruptions for Maiar */
+ bool_ allow = FALSE;
+ if ((corruption_idx == CORRUPT_BALROG_AURA) ||
+ (corruption_idx == CORRUPT_BALROG_WINGS) ||
+ (corruption_idx == CORRUPT_BALROG_STRENGTH) ||
+ (corruption_idx == CORRUPT_BALROG_FORM) ||
+ (corruption_idx == CORRUPT_DEMON_BREATH))
+ {
+ allow = TRUE;
+ };
+
+ /* Mix result into 'allowed' flag */
+ allowed = allowed & allow;
+ }
+ }
+
+ /* Result */
+ return allowed;
+}
+
/*
* Gods
*/
diff --git a/src/player.pkg b/src/player.pkg
index f34d108b..16b280c9 100644
--- a/src/player.pkg
+++ b/src/player.pkg
@@ -1853,6 +1853,7 @@ extern s16b MUT1_GROW_MOLD;
extern s16b MUT1_RESIST;
extern s16b MUT1_EARTHQUAKE;
+extern bool player_can_gain_corruption(int corruption_idx);
/** @name Spellbinder triggers
* @{ */