From 3f819c170739b098f9f7951fc9c2ff407f3bbf03 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Fri, 6 Apr 2012 11:40:03 +0200 Subject: Lua: Moved corruption "can_gain" checks to C --- src/externs.h | 1 + src/lua_bind.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/player.pkg | 1 + 3 files changed, 47 insertions(+) (limited to 'src') 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 #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 * @{ */ -- cgit v1.2.3