diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-04-10 19:59:22 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-04-10 20:19:20 +0200 |
commit | 767d7864bbeff83c8ad2f70a86dd5b8445cdccc7 (patch) | |
tree | 50049b62511daedce760d960b478434e6235ede1 | |
parent | 2586acc8701593574b52922af7540d3efa83b5b9 (diff) |
Lua: Gods: Move Aule's HOOK_PROCESS_WORLD to C
-rw-r--r-- | lib/mods/theme/scpt/gods_new.lua | 58 | ||||
-rw-r--r-- | src/dungeon.c | 81 |
2 files changed, 81 insertions, 58 deletions
diff --git a/lib/mods/theme/scpt/gods_new.lua b/lib/mods/theme/scpt/gods_new.lua index 8f97441a..8a5eecfa 100644 --- a/lib/mods/theme/scpt/gods_new.lua +++ b/lib/mods/theme/scpt/gods_new.lua @@ -2,17 +2,6 @@ add_loadsave("GRACE_DELAY",0) -function aule_stone_skin() -local type - if player.grace >= 10000 then - type = SHIELD_COUNTER - else - type = 0 - end - - set_shield(randint(10) + 10 + (player.grace / 100), 10 + (player.grace / 100), type, 2 + (player.grace / 200), 3 + (player.grace / 400)) -end - GOD_AULE = add_god { ["name"] = "Aule the Smith", @@ -22,53 +11,6 @@ GOD_AULE = add_god }, ["hooks"] = { - [HOOK_PROCESS_WORLD] = function() - if (player.pgod == GOD_AULE) then - GRACE_DELAY = GRACE_DELAY + 1 - if GRACE_DELAY >= 15 then - -- Aule likes Dwarves and Dark Elves (Eol's influence here) - if - (get_race_name() ~= "Dwarf") and - (get_race_name() ~= "Petty-dwarf") and - (get_race_name() ~= "Gnome") and - (get_race_name() ~= "Dark-Elf") then - set_grace(player.grace - 1) - end - - -- Search inventory for axe or hammer - Gain 1 point of grace for each hammer or axe - for i = 0, INVEN_TOTAL - 1 do - if ((player.inventory(i).tval) == TV_AXE) then - set_grace(player.grace + 1) - end - if ((player.inventory(i).tval) == TV_HAFTED) then - if (((player.inventory(i).sval) == SV_WAR_HAMMER) or ((player.inventory(i).sval) == SV_LUCERN_HAMMER) or ((player.inventory(i).sval) == SV_GREAT_HAMMER)) then - set_grace(player.grace + 1) - end - end - end - - if (player.praying == TRUE) then - set_grace(player.grace - 2) - - -- Chance of casting Stoneskin if praying - local chance - if (player.grace >= 50000) then - chance = 50000 - else - chance = 50000 - player.grace - end - - if (randint(100000) <= 100000 / chance) then - aule_stone_skin() - msg_print("Aule casts Stone Skin on you.") - end - - end - GRACE_DELAY = 0 - end - - end - end, [HOOK_SACRIFICE_GOD] = function() if (player.pgod == GOD_AULE) then local ret, item, obj, value diff --git a/src/dungeon.c b/src/dungeon.c index fa9da194..282def7e 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -1163,6 +1163,87 @@ static void process_world_gods() } } + GOD(GOD_AULE) + { + if (grace_delay_trigger()) + { + int i; + + /* Aule likes Dwarves and Dark Elves (Eol's + * influence here) */ + if (!(streq(race_name, "Dwarf") || + streq(race_name, "Petty-dwarf") || + streq(race_name, "Gnome") || + streq(race_name, "Dark-Elf"))) + { + inc_piety(GOD_ALL, -1); + } + + /* Search inventory for axe or hammer - Gain 1 + * point of grace for each hammer or axe */ + for (i = 0; i < INVEN_TOTAL; i++) + { + int tval = p_ptr->inventory[i].tval; + int sval = p_ptr->inventory[i].sval; + + switch (tval) + { + case TV_AXE: + inc_piety(GOD_ALL, 1); + break; + + case TV_HAFTED: + if ((sval == SV_WAR_HAMMER) || + (sval == SV_LUCERN_HAMMER) || + (sval == SV_GREAT_HAMMER)) + { + inc_piety(GOD_ALL, 1); + } + break; + } + } + + /* Praying may grant you a free stone skin + * once in a while */ + if (p_ptr->praying) + { + int chance; + s32b grace; + + inc_piety(GOD_ALL, -2); + grace = p_ptr->grace; /* shorthand */ + + chance = 1; + if (grace >= 50000) + { + chance = 50000; + } + else + { + chance = 50000 - grace; + } + + if (randint(100000) <= 100000 / chance) + { + s16b type = 0; + + if (grace >= 10000) + { + type = SHIELD_COUNTER; + } + + set_shield( + randint(10) + 10 + (grace / 100), + 10 + (grace / 100), + type, + 2 + (grace / 200), + 3 + (grace / 400)); + + msg_print("Aule casts Stone Skin on you."); + } + } + } + } } /* |