fix demon hunger in E3 and one intermittent test.

tests involving demons can disable skill changes.
This commit is contained in:
Enno Rehling 2017-12-22 19:14:01 +01:00
parent cba452786f
commit 73f49ec90a
3 changed files with 22 additions and 12 deletions

View File

@ -48,6 +48,7 @@
"healing.forest": 2.0,
"hunger.long": false,
"hunger.damage": "1d9+9",
"hunger.demon.skills": true,
"hunger.demon.peasant_tolerance": true,
"init_spells": 0,
"recruit.allow_merge": true,

View File

@ -31,10 +31,9 @@ function setup()
end
function teardown()
set_rule("rules.move.owner_leave")
set_rule("rules.food.flags")
set_rule("rules.ship.drifting")
set_rule("rules.ship.storms")
for k,_ in pairs(settings) do
set_rule(k)
end
end
function test_calendar()
@ -1011,6 +1010,7 @@ end
function test_demons_using_mallornlance()
-- bug 2392
set_rule("skillchange.demon.up", "0")
local r = region.create(0, 0, "plain")
local f = faction.create('goblin')
local u = unit.create(f, r, 1, 'demon')

View File

@ -860,19 +860,28 @@ void reduce_skill_days(unit *u, skill_t sk, int days) {
void demon_skillchange(unit *u)
{
skill *sv = u->skills;
int upchance = 15;
int downchance = 10;
int upchance = 15, downchance = 10;
static int config;
static bool rule_hunger;
static int cfgup, cfgdown;
if (config_changed(&config)) {
rule_hunger = config_get_int("hunger.demon.skills", 0) != 0;
cfgup = config_get_int("skillchange.demon.up", 15);
cfgdown = config_get_int("skillchange.demon.down", 10);
}
if (cfgup == 0) {
/* feature is disabled */
return;
}
upchance = cfgup;
downchance = cfgdown;
if (fval(u, UFL_HUNGER)) {
/* hungry demons only go down, never up in skill */
static int config;
static bool rule_hunger;
if (config_changed(&config)) {
rule_hunger = config_get_int("hunger.demon.skill", 0) != 0;
}
if (rule_hunger) {
downchance = upchance;
upchance = 0;
downchance = 15;
}
}