diff options
-rw-r--r-- | lib/mods/theme/scpt/gods_new.lua | 27 | ||||
-rw-r--r-- | src/xtra2.c | 64 |
2 files changed, 64 insertions, 27 deletions
diff --git a/lib/mods/theme/scpt/gods_new.lua b/lib/mods/theme/scpt/gods_new.lua index 61aba56b..1256932a 100644 --- a/lib/mods/theme/scpt/gods_new.lua +++ b/lib/mods/theme/scpt/gods_new.lua @@ -9,33 +9,6 @@ GOD_AULE = add_god }, ["hooks"] = { - [HOOK_MONSTER_DEATH] = function(m_idx) - if (player.pgod == GOD_AULE) then - m_ptr = monster(m_idx) - if - (m_ptr.r_idx == test_monster_name("Petty-dwarf")) or - (m_ptr.r_idx == test_monster_name("Petty-dwarf mage")) or - (m_ptr.r_idx == test_monster_name("Dark dwarven warrior")) or - (m_ptr.r_idx == test_monster_name("Dark dwarven smith")) or - (m_ptr.r_idx == test_monster_name("Dark dwarven lord")) or - (m_ptr.r_idx == test_monster_name("Dark dwarven priest")) or - (m_ptr.r_idx == test_monster_name("Dwarven warrior")) then - -- Aule dislikes you killing dwarves - set_grace(player.grace - 20) - end - if - (m_ptr.r_idx == test_monster_name("Nar, the Dwarf")) or - (m_ptr.r_idx == test_monster_name("Naugladur, Lord of Nogrod")) or - (m_ptr.r_idx == test_monster_name("Telchar the Smith")) or - (m_ptr.r_idx == test_monster_name("Fundin Bluecloak")) or - (m_ptr.r_idx == test_monster_name("Khim, Son of Mim")) or - (m_ptr.r_idx == test_monster_name("Ibun, Son of Mim")) or - (m_ptr.r_idx == test_monster_name("Mim, Betrayer of Turin")) then - -- These uniques earn a bigger penalty - set_grace(player.grace - 500) - end - end - end, } } diff --git a/src/xtra2.c b/src/xtra2.c index 7fae3fbf..5a9d8cb6 100644 --- a/src/xtra2.c +++ b/src/xtra2.c @@ -2327,6 +2327,67 @@ void place_corpse(monster_type *m_ptr) /* + * Check if monster race is in a given list. The list + * must be NULL-terminated. + */ +static bool_ monster_race_in_list_p(monster_type *m_ptr, cptr races[]) +{ + int i=0; + for (i=0; races[i] != NULL; i++) + { + if (m_ptr->r_idx == test_monster_name(races[i])) { + return TRUE; + } + } + /* Not found */ + return FALSE; +} + +/* + * Handle the "death" of a monster (Gods) + */ +static void monster_death_gods(int m_idx, monster_type *m_ptr) +{ + if (p_ptr->pgod == GOD_AULE) + { + /* TODO: This should really be a racial flag + which can be added to the r_info file. */ + cptr DWARVES[] = { + "Petty-dwarf", + "Petty-dwarf mage", + "Dark dwarven warrior", + "Dark dwarven smith", + "Dark dwarven lord", + "Dark dwarven priest", + "Dwarven warrior", + NULL, + }; + cptr UNIQUE_DWARVES[] = { + "Nar, the Dwarf", + "Naugladur, Lord of Nogrod", + "Telchar the Smith", + "Fundin Bluecloak", + "Khim, Son of Mim", + "Ibun, Son of Mim", + "Mim, Betrayer of Turin", + NULL, + }; + + /* Aule dislikes the killing of dwarves */ + if (monster_race_in_list_p(m_ptr, DWARVES)) + { + inc_piety(GOD_ALL, -20); + } + + /* ... and UNIQUE dwarves */ + if (monster_race_in_list_p(m_ptr, UNIQUE_DWARVES)) + { + inc_piety(GOD_ALL, -500); + } + } +} + +/* * Handle the "death" of a monster. * * Disperse treasures centered at the monster location based on the @@ -2369,6 +2430,9 @@ void monster_death(int m_idx) /* Process the appropriate hooks */ process_hooks(HOOK_MONSTER_DEATH, "(d)", m_idx); + /* Per-god processing */ + monster_death_gods(m_idx, m_ptr); + /* If companion dies, take note */ if (m_ptr->status == MSTATUS_COMPANION) p_ptr->companion_killed++; |