summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mods/theme/scpt/misc.lua30
-rw-r--r--src/birth.c3
-rw-r--r--src/dungeon.c1
-rw-r--r--src/externs.h1
-rw-r--r--src/loadsave.c1
-rw-r--r--src/modules.c41
-rw-r--r--src/types.h3
7 files changed, 50 insertions, 30 deletions
diff --git a/lib/mods/theme/scpt/misc.lua b/lib/mods/theme/scpt/misc.lua
index a41f9288..726574d2 100644
--- a/lib/mods/theme/scpt/misc.lua
+++ b/lib/mods/theme/scpt/misc.lua
@@ -1,33 +1,3 @@
--- Neil's automagic statgain script
-
-player.last_rewarded_level = 1
-add_loadsave("player.last_rewarded_level", 1)
-
-add_hooks
- {
- [HOOK_PLAYER_LEVEL] = function()
- while player.last_rewarded_level * 5 <= player.lev do
- do_inc_stat(A_STR)
- do_inc_stat(A_INT)
- do_inc_stat(A_WIS)
- do_inc_stat(A_DEX)
- do_inc_stat(A_CON)
- do_inc_stat(A_CHR)
- player.last_rewarded_level = player.last_rewarded_level + 1
- end
- end,
- }
-
-add_hooks
-{
- [HOOK_BIRTH_OBJECTS] = function()
- if player.last_rewarded_level >= 1
- then player.last_rewarded_level = 1
- else
- end
- end
-}
-
-- silly function that allows a drunk to take a bottle of wine/ale from the player
function drunk_takes_wine(m_idx, item)
diff --git a/src/birth.c b/src/birth.c
index 14c0b44f..41abe3ad 100644
--- a/src/birth.c
+++ b/src/birth.c
@@ -1041,6 +1041,9 @@ static void player_wipe(void)
/* Inertia control */
p_ptr->inertia_controlled_spell = -1;
+
+ /* Automatic stat-gain */
+ p_ptr->last_rewarded_level = 1;
}
diff --git a/src/dungeon.c b/src/dungeon.c
index f4803e3b..af46976d 100644
--- a/src/dungeon.c
+++ b/src/dungeon.c
@@ -5631,6 +5631,7 @@ void play_game(bool_ new_game)
/* Initialize hooks */
init_hooks();
init_hooks_help();
+ init_hooks_module();
/* React to changes */
Term_xtra(TERM_XTRA_REACT, 0);
diff --git a/src/externs.h b/src/externs.h
index e1f77bc1..38511e48 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -2362,6 +2362,7 @@ extern bool_ select_module(void);
extern bool_ module_savefile_loadable(cptr savefile_mod);
extern void tome_intro();
extern void theme_intro();
+extern void init_hooks_module();
/* lua_bind.c */
diff --git a/src/loadsave.c b/src/loadsave.c
index 349db36d..65d72d9c 100644
--- a/src/loadsave.c
+++ b/src/loadsave.c
@@ -580,6 +580,7 @@ static bool_ do_extra(int flag)
do_s32b(&p_ptr->loan_time, flag);
do_s16b(&p_ptr->absorb_soul, flag);
do_s32b(&p_ptr->inertia_controlled_spell, flag);
+ do_s16b(&p_ptr->last_rewarded_level, flag);
do_s16b(&p_ptr->chaos_patron, flag);
diff --git a/src/modules.c b/src/modules.c
index 8a4c5644..ff8a24fb 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -495,3 +495,44 @@ void theme_intro()
exit:
screen_load();
}
+
+static bool_ auto_stat_gain_hook(void *data, void *in, void *out)
+{
+ while (p_ptr->last_rewarded_level * 5 <= p_ptr->lev)
+ {
+ do_inc_stat(A_STR);
+ do_inc_stat(A_INT);
+ do_inc_stat(A_WIS);
+ do_inc_stat(A_DEX);
+ do_inc_stat(A_CON);
+ do_inc_stat(A_CHR);
+
+ p_ptr->last_rewarded_level += 1;
+ }
+
+ return FALSE;
+}
+
+void init_hooks_module()
+{
+ switch (game_module_idx)
+ {
+ case MODULE_TOME:
+ {
+ break;
+ }
+
+ case MODULE_THEME:
+ {
+ add_hook_new(HOOK_PLAYER_LEVEL,
+ auto_stat_gain_hook,
+ "auto_stat_gain",
+ NULL);
+
+ break;
+ }
+
+ default:
+ assert(FALSE);
+ }
+}
diff --git a/src/types.h b/src/types.h
index 3e634beb..44ffd67a 100644
--- a/src/types.h
+++ b/src/types.h
@@ -1863,6 +1863,9 @@ struct player_type
/* Inertia control */
s32b inertia_controlled_spell;
+ /* For automatic stat-gain */
+ s16b last_rewarded_level;
+
/*** Temporary fields ***/
bool_ did_nothing; /* True if the last action wasnt a real action */