server/scripts/eressea/equipment.lua

163 lines
3.4 KiB
Lua
Raw Permalink Normal View History

2018-07-12 20:24:23 +02:00
-- forward declarations required:
local self = {}
2018-07-12 20:24:23 +02:00
local function equip_first(u)
name = 'seed_' .. u.race
equip_unit(u, name, 255)
end
local mysets = {
['first_unit'] = {
['items'] = {
['money'] = 2500,
['log'] = 10,
['stone'] = 4
2018-07-12 20:24:23 +02:00
},
['callback'] = equip_first
},
['seed_unit'] = {
['items'] = {
['log'] = 50,
['stone'] = 50,
['iron'] = 50,
['laen'] = 10,
['sword'] = 1,
['mallorn'] = 10,
['skillpotion'] = 5,
['lifepotion'] = 5,
['money'] = 20000
},
['skills'] = {
['perception'] = 30,
['melee'] = 1
}
},
['seed_dwarf'] = {
['items'] = {
['axe'] = 1,
['chainmail'] = 1,
},
['skills'] = {
['melee'] = 1
}
},
['seed_elf'] = {
['items'] = {
['fairyboot'] = 1,
},
['callback'] = equip_newunits
},
['seed_orc'] = {
['skills'] = {
['polearm'] = 4,
['melee'] = 4,
['crossbow'] = 4,
['catapult'] = 4,
['bow'] = 4,
}
},
['seed_goblin'] = {
['items'] = {
['roi'] = 1
},
['callback'] = equip_newunits
},
['seed_human'] = {
['callback'] = equip_newunits
},
['seed_troll'] = {
['items'] = {
['stone'] = 50,
},
['skills'] = {
['building'] = 1,
['perception'] = 3,
}
},
['seed_demon'] = {
['skills'] = {
['stamina'] = 15
},
},
['seed_insect'] = {
['items'] = {
2018-07-12 20:24:23 +02:00
['nestwarmth'] = 9
}
},
['seed_halfling'] = {
['items'] = {
['horse'] = 2,
['cart'] = 1,
['balm'] = 5,
['spice'] = 5,
['myrrh'] = 5,
['jewel'] = 5,
['oil'] = 5,
['silk'] = 5,
['incense'] = 5
},
['skills'] = {
['trade'] = 1,
['riding'] = 2
}
},
['seed_cat'] = {
['items'] = {
['roi'] = 1
},
['callback'] = equip_newunits
},
['seed_aquarian'] = {
['skills'] = {
['sailing'] = 1
},
['callback'] = equip_newunits
},
}
function equip_unit(u, name, flags)
local set = mysets[name]
if set then
local items = set['items']
if items then
2018-05-15 06:58:07 +02:00
for name, count in pairs(items) do
u:add_item(name, count * u.number)
end
end
local skills = set['skills']
if skills then
2018-05-15 06:58:07 +02:00
for name, level in pairs(skills) do
u:set_skill(name, level)
end
end
local spells = set['spells']
if spells then
for name, level in pairs(spells) do
2018-05-15 06:58:07 +02:00
u:add_spell(name, level)
end
end
local callback = set['callback']
if callback and type(callback) == 'function' then
callback(u, flags)
end
return true
end
return false
end
self.add = function(name, set)
mysets[name] = set
end
self.add_multiple = function(sets)
2018-05-15 06:58:07 +02:00
for name, set in pairs(sets) do
mysets[name] = set
end
end
self.get = function(name)
return mysets[name]
end
return self