convert E2 familiars from XML to Lua

This commit is contained in:
Enno Rehling 2018-05-15 06:58:07 +02:00
parent e46cfa5e77
commit 9dd38a6593
7 changed files with 176 additions and 142 deletions

View File

@ -12,7 +12,6 @@
"config://res/buildings/castle.xml", "config://res/buildings/castle.xml",
"config://res/eressea/races.xml", "config://res/eressea/races.xml",
"config://res/eressea/artrewards.xml", "config://res/eressea/artrewards.xml",
"config://res/eressea/familiars.xml",
"config://res/eressea/spells.xml", "config://res/eressea/spells.xml",
"config://res/eressea/spellbooks/gray.xml", "config://res/eressea/spellbooks/gray.xml",
"config://res/eressea/spellbooks/gwyrrd.xml", "config://res/eressea/spellbooks/gwyrrd.xml",

View File

@ -1,133 +0,0 @@
<?xml version="1.0"?>
<eressea>
<equipment>
<!-- equipment given to familiars -->
<set name="fam_lynx">
<skill name="espionage" level="1"/>
<skill name="magic" level="1"/>
<skill name="stealth" level="1"/>
<skill name="perception" level="1"/>
</set>
<set name="fam_tunnelworm">
<skill name="magic" level="1"/>
<skill name="mining" level="1"/>
<skill name="forestry" level="1"/>
<skill name="stamina" level="1"/>
</set>
<set name="fam_eagle">
<skill name="magic" level="1"/>
<skill name="perception" level="1"/>
</set>
<set name="fam_rat">
<skill name="magic" level="1"/>
<skill name="espionage" level="1"/>
<skill name="stealth" level="1"/>
<skill name="perception" level="1"/>
<skill name="stamina" level="6"/>
</set>
<set name="fam_songdragon">
<skill name="magic" level="1"/>
<!-- spells -->
<spell name="flee" level="2"/>
<spell name="sleep" level="7"/>
<spell name="frighten" level="8"/>
</set>
<set name="fam_nymph">
<skill name="magic" level="1"/>
<skill name="bow" level="1"/>
<skill name="herbalism" level="1"/>
<skill name="training" level="1"/>
<skill name="riding" level="1"/>
<skill name="espionage" level="1"/>
<skill name="stealth" level="1"/>
<skill name="entertainment" level="1"/>
<skill name="perception" level="1"/>
<!-- spells -->
<spell name="seduction" level="6"/>
<spell name="calm_monster" level="6"/>
<spell name="song_of_confusion" level="4"/>
<spell name="appeasement" level="1"/>
</set>
<set name="fam_unicorn">
<skill name="magic" level="1"/>
<skill name="stealth" level="1"/>
<skill name="perception" level="1"/>
<!-- spells -->
<spell name="resist_magic" level="3"/>
<spell name="song_of_peace" level="12"/>
<spell name="calm_monster" level="6"/>
<spell name="heroic_song" level="5"/>
<spell name="song_of_healing" level="2"/>
<spell name="appeasement" level="1"/>
</set>
<set name="fam_direwolf">
<skill name="magic" level="1"/>
<skill name="perception" level="1"/>
</set>
<set name="fam_ghost">
<skill name="magic" level="1"/>
<!-- spells -->
<spell name="steal_aura" level="6"/>
<spell name="frighten" level="8"/>
<spell name="summonundead" level="6"/>
</set>
<set name="fam_imp">
<skill name="magic" level="1"/>
<skill name="espionage" level="1"/>
<skill name="stealth" level="1"/>
<skill name="perception" level="1"/>
<skill name="taxation" level="1"/>
<!-- spells -->
<spell name="steal_aura" level="6"/>
<spell name="shapeshift" level="3"/>
<spell name="seduction" level="6"/>
</set>
<set name="fam_dreamcat">
<skill name="magic" level="1"/>
<skill name="espionage" level="1"/>
<skill name="stealth" level="1"/>
<skill name="perception" level="1"/>
<skill name="taxation" level="1"/>
<!-- spells -->
<spell name="shapeshift" level="3"/>
<spell name="transferauratraum" level="3"/>
</set>
<set name="fam_fairy">
<skill name="magic" level="1"/>
<!-- spells -->
<spell name="appeasement" level="1"/>
<spell name="calm_monster" level="6"/>
<spell name="seduction" level="6"/>
</set>
<set name="fam_owl">
<skill name="magic" level="1"/>
<skill name="espionage" level="1"/>
<skill name="stealth" level="1"/>
<skill name="perception" level="1"/>
</set>
<set name="fam_hellcat">
<skill name="magic" level="1"/>
<skill name="perception" level="1"/>
</set>
<set name="fam_tiger">
<skill name="magic" level="1"/>
<skill name="perception" level="1"/>
</set>
</equipment>
</eressea>

View File

@ -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)

View File

@ -115,4 +115,5 @@ return {
require('eressea.jsreport'), require('eressea.jsreport'),
require('eressea.ents'), require('eressea.ents'),
require('eressea.cursed'), require('eressea.cursed'),
require('eressea.e2.familiars')
} }

View File

@ -114,20 +114,20 @@ function equip_unit(u, name, flags)
if set then if set then
local items = set['items'] local items = set['items']
if items then if items then
for k,v in pairs(items) do for name, count in pairs(items) do
u:add_item(k, v * u.number) u:add_item(name, count * u.number)
end end
end end
local skills = set['skills'] local skills = set['skills']
if skills then if skills then
for k,v in pairs(skills) do for name, level in pairs(skills) do
u:set_skill(k, v) u:set_skill(name, level)
end end
end end
local spells = set['spells'] local spells = set['spells']
if spells then if spells then
for k, v in ipairs(spells) do for name, level in ipairs(spells) do
u:add_spell(v) u:add_spell(name, level)
end end
end end
local callback = set['callback'] local callback = set['callback']
@ -144,8 +144,8 @@ self.add = function(name, set)
end end
self.add_multiple = function(sets) self.add_multiple = function(sets)
for name, v in pairs(sets) do for name, set in pairs(sets) do
mysets[name] = v mysets[name] = set
end end
end end

View File

@ -183,6 +183,8 @@ if file_exists('execute.lock') then
assert(false) assert(false)
end end
math.randomseed(rng.random())
local path = 'scripts' local path = 'scripts'
if config.install then if config.install then
path = config.install .. '/' .. path path = config.install .. '/' .. path

View File

@ -124,3 +124,15 @@ function test_familiar()
end end
end 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