diff --git a/conf/e2/config.json b/conf/e2/config.json index ba974c414..ebc385adf 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -12,7 +12,6 @@ "config://res/buildings/castle.xml", "config://res/eressea/races.xml", "config://res/eressea/artrewards.xml", - "config://res/eressea/familiars.xml", "config://res/eressea/spells.xml", "config://res/eressea/spellbooks/gray.xml", "config://res/eressea/spellbooks/gwyrrd.xml", diff --git a/res/eressea/familiars.xml b/res/eressea/familiars.xml deleted file mode 100644 index 112a82420..000000000 --- a/res/eressea/familiars.xml +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/scripts/eressea/e2/familiars.lua b/scripts/eressea/e2/familiars.lua new file mode 100644 index 000000000..720cb81eb --- /dev/null +++ b/scripts/eressea/e2/familiars.lua @@ -0,0 +1,153 @@ +local sets = { + ['fam_lynx'] = { + ['skills'] = { + ['espionage'] = 1, + ['magic'] = 1, + ['stealth'] = 1, + ['perception'] = 1, + } + }, + ['fam_tunnelworm'] = { + ['skills'] = { + ['forestry'] = 1, + ['magic'] = 1, + ['mining'] = 1, + ['stamina'] = 1, + } + }, + ['fam_eagle'] = { + ['skills'] = { + ['magic'] = 1, + ['perception'] = 1, + } + }, + ['fam_rat'] = { + ['skills'] = { + ['magic'] = 1, + ['espionage'] = 1, + ['stealth'] = 1, + ['perception'] = 1, + ['stamina'] = 6, + } + }, + ['fam_owl'] = { + ['skills'] = { + ['magic'] = 1, + ['espionage'] = 1, + ['stealth'] = 1, + ['perception'] = 1, + } + }, + ['fam_direwolf'] = { + ['skills'] = { + ['magic'] = 1, + ['perception'] = 1, + } + }, + ['fam_hellcat'] = { + ['skills'] = { + ['magic'] = 1, + ['perception'] = 1, + } + }, + ['fam_tiger'] = { + ['skills'] = { + ['magic'] = 1, + ['perception'] = 1, + } + }, + ['fam_songdragon'] = { + ['skills'] = { + ['magic'] = 1, + }, + ['spells'] = { + ['flee'] = 2, + ['sleep'] = 7, + ['frighten'] = 8, + }, + }, + ['fam_ghost'] = { + ['skills'] = { + ['magic'] = 1, + }, + ['spells'] = { + ['steal_aura'] = 6, + ['summonundead'] = 6, + ['frighten'] = 8, + }, + }, + ['fam_fairy'] = { + ['skills'] = { + ['magic'] = 1, + }, + ['spells'] = { + ['appeasement'] = 1, + ['calm_monster'] = 6, + ['seduction'] = 6, + }, + }, + ['fam_unicorn'] = { + ['skills'] = { + ['magic'] = 1, + ['stealth'] = 1, + ['perception'] = 1, + }, + ['spells'] = { + ['resist_magic'] = 3, + ['song_of_peace'] = 12, + ['calm_monster'] = 6, + ['heroic_song'] = 5, + ['song_of_healing'] = 3, + ['appeasement'] = 2, + }, + }, + ['fam_imp'] = { + ['skills'] = { + ['magic'] = 1, + ['stealth'] = 1, + ['perception'] = 1, + ['espionage'] = 1, + ['taxation'] = 1, + }, + ['spells'] = { + ['steal_aura'] = 6, + ['shapeshift'] = 3, + ['seduction'] = 6, + }, + }, + ['fam_dreamcat'] = { + ['skills'] = { + ['magic'] = 1, + ['stealth'] = 1, + ['perception'] = 1, + ['espionage'] = 1, + ['taxation'] = 1, + }, + ['spells'] = { + ['shapeshift'] = 3, + ['transferauratraum'] = 3, + }, + }, + ['fam_nymph'] = { + ['skills'] = { + ['magic'] = 1, + ['bow'] = 1, + ['herbalism'] = 1, + ['training'] = 1, + ['riding'] = 1, + ['espionage'] = 1, + ['stealth'] = 1, + ['entertainment'] = 1, + ['perception'] = 1, + }, + ['spells'] = { + ['seduction'] = 6, + ['calm_monster'] = 3, + ['song_of_confusion'] = 4, + ['appeasement'] = 1, + }, + }, +} + +local equipment = require('eressea.equipment') +equipment.add_multiple(sets) diff --git a/scripts/eressea/e2/init.lua b/scripts/eressea/e2/init.lua index 24f679e17..52636d207 100644 --- a/scripts/eressea/e2/init.lua +++ b/scripts/eressea/e2/init.lua @@ -115,4 +115,5 @@ return { require('eressea.jsreport'), require('eressea.ents'), require('eressea.cursed'), + require('eressea.e2.familiars') } diff --git a/scripts/eressea/equipment.lua b/scripts/eressea/equipment.lua index a2999284d..6e4ccfc9b 100644 --- a/scripts/eressea/equipment.lua +++ b/scripts/eressea/equipment.lua @@ -114,20 +114,20 @@ function equip_unit(u, name, flags) if set then local items = set['items'] if items then - for k,v in pairs(items) do - u:add_item(k, v * u.number) + for name, count in pairs(items) do + u:add_item(name, count * u.number) end end local skills = set['skills'] if skills then - for k,v in pairs(skills) do - u:set_skill(k, v) + for name, level in pairs(skills) do + u:set_skill(name, level) end end local spells = set['spells'] if spells then - for k, v in ipairs(spells) do - u:add_spell(v) + for name, level in ipairs(spells) do + u:add_spell(name, level) end end local callback = set['callback'] @@ -144,8 +144,8 @@ self.add = function(name, set) end self.add_multiple = function(sets) - for name, v in pairs(sets) do - mysets[name] = v + for name, set in pairs(sets) do + mysets[name] = set end end diff --git a/scripts/run-turn.lua b/scripts/run-turn.lua index 34340d43c..62d48ec51 100644 --- a/scripts/run-turn.lua +++ b/scripts/run-turn.lua @@ -183,6 +183,8 @@ if file_exists('execute.lock') then assert(false) end +math.randomseed(rng.random()) + local path = 'scripts' if config.install then path = config.install .. '/' .. path diff --git a/scripts/tests/e2/spells.lua b/scripts/tests/e2/spells.lua index deeb2798c..a9f49d2b8 100644 --- a/scripts/tests/e2/spells.lua +++ b/scripts/tests/e2/spells.lua @@ -124,3 +124,15 @@ function test_familiar() end end end + +function test_familiar_lynx() + local r = region.create(0, 0, 'plain') + local f = faction.create('human') + local u = unit.create(f, r) + u.race = 'lynx' + u:equip('fam_lynx') + assert_equal(1, u:get_skill('stealth')) + assert_equal(1, u:get_skill('espionage')) + assert_equal(1, u:get_skill('magic')) + assert_equal(1, u:get_skill('perception')) +end