--- s_meta-old.lua Sun Dec 12 10:07:02 2004 +++ s_meta.lua Wed Mar 23 15:10:22 2005 @@ -36,26 +36,34 @@ ["mana_max"] = 300, ["fail"] = 85, ["spell"] = function() - local i, ret, c - if player.spellbinder_num ~= 0 then - local t = + local HP_percentage_to_string = { [SPELLBINDER_HP75] = "75% HP", [SPELLBINDER_HP50] = "50% HP", [SPELLBINDER_HP25] = "25% HP", } + msg_print("The spellbinder is already active.") - msg_print("It will trigger at "..t[player.spellbinder_trigger]..".") - msg_print("With the spells: ") + msg_print("It will trigger at "..HP_percentage_to_string[player.spellbinder_trigger]..".") + msg_print("With the spells") for i = 1, player.spellbinder_num do - msg_print(spell(player.spellbinder[i]).name) + local separator + if i == player.spellbinder_num then + separator = "." + elseif i + 1 == player.spellbinder_num then + separator = " and" + else + separator = "," + end + msg_print(spell(player.spellbinder[i]).name..separator) end - return TRUE + + if get_check("Reselect the bound spells?") == FALSE then return end end - ret, c = get_com("Trigger at [a]75% hp [b]50% hp [c]25% hp?", strbyte("a")) - if ret == FALSE then return TRUE end + local ret, c = get_com("Trigger at [a]75% hp [b]50% hp [c]25% hp?", strbyte("a")) + if ret == FALSE then return end if c == strbyte("a") then player.spellbinder_trigger = SPELLBINDER_HP75 @@ -66,26 +74,27 @@ else return end + player.spellbinder_num = get_spellbinder_max() - i = player.spellbinder_num - while i > 0 do - local s - - s = get_school_spell("bind", "is_ok_spell", 0) - if s == -1 then + for i = 1, player.spellbinder_num do + local s = get_school_spell("bind", "is_ok_spell", 0) + if s == -1 then -- the player pressed escape, so don't bind any spells player.spellbinder_trigger = 0 player.spellbinder_num = 0 + msg_print("Spellbinder cancelled.") return TRUE else - if spell(s).skill_level > 7 + get_level(SPELLBINDER, 35) then - msg_print("You are only allowed spells with a base level of "..(7 + get_level(SPELLBINDER, 35)).."."); + local max_allowed_spell_level = 7 + get_level(SPELLBINDER, 35) + if spell(s).skill_level > max_allowed_spell_level then + msg_print("You are only allowed spells with a base level of "..max_allowed_spell_level.."."); return TRUE end end player.spellbinder[i] = s - i = i - 1 end - player.energy = player.energy - 3100; + + -- only take extra game time if new spells were actually bound + player.energy = player.energy - 3100 msg_print("Spellbinder ready.") return TRUE end,