equip new orcs in e2 with lua and a hacky callback.

This commit is contained in:
Enno Rehling 2018-05-13 21:23:54 +02:00
parent 1d7318d9b6
commit a741eaca97
2 changed files with 51 additions and 37 deletions

View File

@ -36,11 +36,6 @@
<skill name="perception" level="3"/> <skill name="perception" level="3"/>
</set> </set>
<set name="new_orc">
<skill name="polearm" level="1"/>
<skill name="melee" level="1"/>
</set>
<set name="spo_seaserpent"> <set name="spo_seaserpent">
<item name="dragonblood" amount="6"/> <item name="dragonblood" amount="6"/>
<item name="seaserpenthead" amount="1"/> <item name="seaserpenthead" amount="1"/>

View File

@ -1,6 +1,46 @@
-- Equipment -- forward declaration required:
local sets = {}
local sets = { local function equip_new_orc(u, flags)
local eqname = 'orc_' .. config.rules
local set = sets[eqname]
if set then
return equip_unit(u, eqname, flags)
end
return false
end
function equip_unit(u, name, flags)
local set = sets[name]
if set then
local items = set['items']
if items then
for k,v in pairs(items) do
u:add_item(k, v)
end
end
local skills = set['skills']
if skills then
for k,v in pairs(skills) do
u:set_skill(k, v)
end
end
local spells = set['spells']
if spells then
for k, v in ipairs(spells) do
u:add_spell(v)
end
end
local callback = set['callback']
if callback and type(callback) == 'function' then
callback(u, flags)
end
return true
end
return false
end
sets = {
['first_unit'] = { ['first_unit'] = {
['items'] = { ['items'] = {
['money'] = 2500, ['money'] = 2500,
@ -25,6 +65,15 @@ local sets = {
['melee'] = 1 ['melee'] = 1
} }
}, },
['new_orc'] = {
['callback'] = equip_new_orc
},
['orc_e2'] = {
['skills'] = {
['polearm'] = 1,
['melee'] = 1
}
},
['seed_dwarf'] = { ['seed_dwarf'] = {
['items'] = { ['items'] = {
['axe'] = 1, ['axe'] = 1,
@ -108,34 +157,4 @@ local sets = {
}, },
} }
function equip_unit(u, name, flags)
local set = sets[name]
if set then
local items = set['items']
if items then
for k,v in pairs(items) do
u:add_item(k, v)
end
end
local skills = set['skills']
if skills then
for k,v in pairs(skills) do
u:set_skill(k, v)
end
end
local spells = set['spells']
if spells then
for k, v in ipairs(spells) do
u:add_spell(v)
end
end
local callback = set['callback']
if callback and type(callback) == 'function' then
callback(u)
end
return true
end
return false
end
return nil return nil