summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-04-05 23:42:13 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-07 15:28:26 +0200
commit62e385cb769000cfefa052b1ab3e155314e7ac37 (patch)
treea3f9acc5147789393128df51dadd0599c4aacb5e /src
parenta9b597979d99a53c56d2fa5b8498834364fef7a9 (diff)
Lua: Move HOOK_CALC_BONUS corruption code to C
Diffstat (limited to 'src')
-rw-r--r--src/externs.h16
-rw-r--r--src/lua_bind.c13
-rw-r--r--src/player.pkg19
-rw-r--r--src/variable.c18
-rw-r--r--src/xtra1.c75
5 files changed, 141 insertions, 0 deletions
diff --git a/src/externs.h b/src/externs.h
index 6821fd30..c8e34c84 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -604,6 +604,20 @@ extern s32b max_gods;
extern timer_type *gl_timers;
extern s16b tim_precognition;
extern const char *get_version_string();
+extern s16b CORRUPT_BALROG_AURA;
+extern s16b CORRUPT_BALROG_WINGS;
+extern s16b CORRUPT_BALROG_STRENGTH;
+extern s16b CORRUPT_BALROG_FORM;
+extern s16b CORRUPT_DEMON_SPIRIT;
+extern s16b CORRUPT_DEMON_HIDE;
+extern s16b CORRUPT_DEMON_BREATH;
+extern s16b CORRUPT_DEMON_REALM;
+extern s16b CORRUPT_RANDOM_TELEPORT;
+extern s16b CORRUPT_ANTI_TELEPORT;
+extern s16b CORRUPT_TROLL_BLOOD;
+extern s16b CORRUPT_VAMPIRE_TEETH;
+extern s16b CORRUPT_VAMPIRE_STRENGTH;
+extern s16b CORRUPT_VAMPIRE_VAMPIRE;
/* plots.c */
extern FILE *hook_file;
@@ -1834,6 +1848,8 @@ extern void lua_delete_list(list_type *, int size);
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 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 765b8072..424d1f74 100644
--- a/src/lua_bind.c
+++ b/src/lua_bind.c
@@ -586,6 +586,19 @@ void lua_display_list(int y, int x, int h, int w, cptr title, list_type* list, i
}
/*
+ * Corruptions
+ */
+bool_ player_has_corruption(int corruption_idx)
+{
+ if (corruption_idx < 0)
+ {
+ return FALSE;
+ }
+
+ return (p_ptr->corruptions[corruption_idx]);
+}
+
+/*
* Gods
*/
s16b add_new_gods(char *name)
diff --git a/src/player.pkg b/src/player.pkg
index ef85926a..16370b0a 100644
--- a/src/player.pkg
+++ b/src/player.pkg
@@ -1815,6 +1815,25 @@ struct player_type
bool leaving;
};
+/**
+ * Corruptions
+ */
+extern s16b CORRUPT_BALROG_AURA;
+extern s16b CORRUPT_BALROG_WINGS;
+extern s16b CORRUPT_BALROG_STRENGTH;
+extern s16b CORRUPT_BALROG_FORM;
+extern s16b CORRUPT_DEMON_SPIRIT;
+extern s16b CORRUPT_DEMON_HIDE;
+extern s16b CORRUPT_DEMON_BREATH;
+extern s16b CORRUPT_DEMON_REALM;
+extern s16b CORRUPT_RANDOM_TELEPORT;
+extern s16b CORRUPT_ANTI_TELEPORT;
+extern s16b CORRUPT_TROLL_BLOOD;
+extern s16b CORRUPT_VAMPIRE_TEETH;
+extern s16b CORRUPT_VAMPIRE_STRENGTH;
+extern s16b CORRUPT_VAMPIRE_VAMPIRE;
+
+
/** @name Spellbinder triggers
* @{ */
/** @def SPELLBINDER_HP75
diff --git a/src/variable.c b/src/variable.c
index 5b1afc3b..3c2295b1 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -1598,6 +1598,24 @@ timer_type *gl_timers = NULL;
s16b tim_precognition = 0;
/**
+ * Corruptions
+ */
+s16b CORRUPT_BALROG_AURA = -1;
+s16b CORRUPT_BALROG_WINGS = -1;
+s16b CORRUPT_BALROG_STRENGTH = -1;
+s16b CORRUPT_BALROG_FORM = -1;
+s16b CORRUPT_DEMON_SPIRIT = -1;
+s16b CORRUPT_DEMON_HIDE = -1;
+s16b CORRUPT_DEMON_BREATH = -1;
+s16b CORRUPT_DEMON_REALM = -1;
+s16b CORRUPT_RANDOM_TELEPORT = -1;
+s16b CORRUPT_ANTI_TELEPORT = -1;
+s16b CORRUPT_TROLL_BLOOD = -1;
+s16b CORRUPT_VAMPIRE_TEETH = -1;
+s16b CORRUPT_VAMPIRE_STRENGTH = -1;
+s16b CORRUPT_VAMPIRE_VAMPIRE = -1;
+
+/**
* Get the version string.
*/
const char *get_version_string()
diff --git a/src/xtra1.c b/src/xtra1.c
index 1d2d8ba0..c30d6e4d 100644
--- a/src/xtra1.c
+++ b/src/xtra1.c
@@ -2503,6 +2503,78 @@ static void calc_schools()
}
}
+/* Apply corruptions */
+static void calc_corruptions()
+{
+ if (player_has_corruption(CORRUPT_BALROG_AURA))
+ {
+ p_ptr->xtra_f3 |= TR3_SH_FIRE;
+ p_ptr->xtra_f3 |= TR3_LITE1;
+ }
+
+ if (player_has_corruption(CORRUPT_BALROG_WINGS))
+ {
+ p_ptr->xtra_f4 |= TR4_FLY;
+ p_ptr->stat_add[A_CHR] -= 4;
+ p_ptr->stat_add[A_DEX] -= 2;
+ }
+
+ if (player_has_corruption(CORRUPT_BALROG_STRENGTH))
+ {
+ p_ptr->stat_add[A_STR] += 3;
+ p_ptr->stat_add[A_CON] += 1;
+ p_ptr->stat_add[A_DEX] -= 3;
+ p_ptr->stat_add[A_CHR] -= 1;
+ }
+
+ if (player_has_corruption(CORRUPT_DEMON_SPIRIT))
+ {
+ p_ptr->stat_add[A_INT] += 1;
+ p_ptr->stat_add[A_CHR] -= 2;
+ }
+
+ if (player_has_corruption(CORRUPT_DEMON_HIDE))
+ {
+ p_ptr->to_a = p_ptr->to_a + p_ptr->lev;
+ p_ptr->dis_to_a = p_ptr->dis_to_a + p_ptr->lev;
+ p_ptr->pspeed = p_ptr->pspeed - (p_ptr->lev / 7);
+ if (p_ptr->lev >= 40)
+ {
+ p_ptr->xtra_f2 |= TR2_IM_FIRE;
+ }
+ }
+
+ if (player_has_corruption(CORRUPT_DEMON_REALM))
+ {
+ /* 1500 may seem a lot, but people are rather unlikely to
+ get the corruption very soon due to the dependencies. */
+ if (s_info[SKILL_DAEMON].mod == 0)
+ {
+ s_info[SKILL_DAEMON].mod = 1500;
+ }
+ s_info[SKILL_DAEMON].hidden = FALSE;
+ }
+
+ if (player_has_corruption(CORRUPT_RANDOM_TELEPORT))
+ {
+ p_ptr->xtra_f3 |= TR3_TELEPORT;
+ }
+
+ if (player_has_corruption(CORRUPT_ANTI_TELEPORT))
+ {
+ if (p_ptr->corrupt_anti_teleport_stopped == FALSE)
+ {
+ p_ptr->resist_continuum = TRUE;
+ }
+ }
+
+ if (player_has_corruption(CORRUPT_TROLL_BLOOD))
+ {
+ p_ptr->xtra_f3 |= (TR3_REGEN | TR3_AGGRAVATE);
+ p_ptr->xtra_esp |= ESP_TROLL;
+ }
+}
+
/* Apply flags */
static int extra_blows;
static int extra_shots;
@@ -2920,6 +2992,9 @@ void calc_bonuses(bool_ silent)
/* Take care of spell schools */
calc_schools();
+ /* Take care of corruptions */
+ calc_corruptions();
+
/* The powers gived by the wielded monster */
calc_wield_monster();