From 8517857d5569df84ebaa170fdc025b7dec2dd6b9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 27 Aug 2017 19:55:04 +0200 Subject: [PATCH] BUG 2361: familiars cannot forget magic. https://bugs.eressea.de/view.php?id=2361 --- scripts/tests/economy.lua | 17 +++++++++++++++++ src/economy.c | 7 ++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/scripts/tests/economy.lua b/scripts/tests/economy.lua index a1bfa3bb6..9289efa2b 100644 --- a/scripts/tests/economy.lua +++ b/scripts/tests/economy.lua @@ -11,6 +11,23 @@ function setup() eressea.settings.set("rules.encounters", "0") end +function test_bug_2361_forget_magic() + -- https://bugs.eressea.de/view.php?id=2361 + -- familiars cannot forget magic + local r = region.create(0, 0, "plain") + local f = faction.create("human") + local u = unit.create(f, r, 1) + u:clear_orders() + u:add_order("VERGESSE Magie") + u:set_skill('magic', 5) + u.race = 'unicorn' + process_orders() + assert_equal(5, u:get_skill('magic')) + u.race = 'human' + process_orders() + assert_equal(0, u:get_skill('magic')) +end + function test_mine_bonus() local r = region.create(0, 0, "mountain") r:set_resource("iron", 100) diff --git a/src/economy.c b/src/economy.c index 4122fa6a1..546f7876e 100644 --- a/src/economy.c +++ b/src/economy.c @@ -661,7 +661,12 @@ static int forget_cmd(unit * u, order * ord) init_order(ord); s = gettoken(token, sizeof(token)); - if ((sk = get_skill(s, u->faction->locale)) != NOSKILL) { + sk = get_skill(s, u->faction->locale); + if (sk != NOSKILL) { + if (sk == SK_MAGIC && (u_race(u)->flags & RCF_FAMILIAR)) { + /* some races cannot forget their innate magical abilities */ + return 0; + } ADDMSG(&u->faction->msgs, msg_message("forget", "unit skill", u, sk)); set_level(u, sk, 0); }