diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-04-10 20:58:10 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-04-10 20:58:10 +0200 |
commit | 2a7627098fd014fc7b835e67cf37a3b615dbf5c4 (patch) | |
tree | fe24c76483484d81d039c5b73e5c57ce4b0e0f3d | |
parent | b34352dcd834057993a5e4c146b5b61cca41da15 (diff) |
Lua: Gods: Move Aule's HOOK_SACRIFICE_GOD to C
-rw-r--r-- | lib/mods/theme/scpt/gods_new.lua | 33 | ||||
-rw-r--r-- | src/cmd2.c | 41 |
2 files changed, 41 insertions, 33 deletions
diff --git a/lib/mods/theme/scpt/gods_new.lua b/lib/mods/theme/scpt/gods_new.lua index b6ff3b04..61aba56b 100644 --- a/lib/mods/theme/scpt/gods_new.lua +++ b/lib/mods/theme/scpt/gods_new.lua @@ -9,39 +9,6 @@ GOD_AULE = add_god }, ["hooks"] = { - [HOOK_SACRIFICE_GOD] = function() - if (player.pgod == GOD_AULE) then - local ret, item, obj, value - ret, item = get_item( - "Sacrifice which item? ", - "You have nothing to sacrifice.", - USE_INVEN, - function(obj) - -- perhaps restrict this only to metal armour and weapons - if (obj.found == OBJ_FOUND_SELFMADE) then - return TRUE - end - return FALSE - end - ) - - -- Item selected - if ret == TRUE then - -- Increase piety by the value of the item / 10 - -- object_value is not available in Lua, therefore I used the - -- cost of the base item, without magical boni - obj = get_object(item) - -- value = object_value(obj)/10 - value = k_info[obj.k_idx + 1].cost/10 - - set_grace(player.grace + value) - - -- remove the object - inven_item_increase(item, -1) - inven_item_optimize(item) - end - end - end, [HOOK_MONSTER_DEATH] = function(m_idx) if (player.pgod == GOD_AULE) then m_ptr = monster(m_idx) @@ -4574,6 +4574,43 @@ static bool_ item_tester_hook_sacrifiable(object_type *o_ptr) } /* + * Is item eligible for sacrifice to Aule? + */ +static bool_ item_tester_hook_sacrifice_aule(object_type *o_ptr) +{ + /* perhaps restrict this only to metal armour and weapons */ + return (o_ptr->found == OBJ_FOUND_SELFMADE); +} + +/* + * Handle sacrifices to Aule + */ +static void do_cmd_sacrifice_aule() +{ + int item; + + item_tester_hook = item_tester_hook_sacrifice_aule; + if (!get_item(&item, + "Sacrifice which item? ", + "You have nothing to sacrifice.", + USE_INVEN)) + { + return; + } + + /* Increase piety by the value of the item / 10. */ + { + object_type *o_ptr = get_object(item); + s32b delta = object_value(o_ptr) / 10; + + inc_piety(GOD_ALL, delta); + } + + /* Destroy the object */ + inc_stack_size(item, -1); +} + +/* * Handle sacrifices. * Grace is increased by value of sacrifice. */ @@ -4666,6 +4703,10 @@ void do_cmd_sacrifice(void) inc_stack_size(item, -1); } } + else if (p_ptr->pgod == GOD_AULE) + { + do_cmd_sacrifice_aule(); + } else { process_hooks(HOOK_SACRIFICE_GOD, "()", ""); |