forked from github/server
implementation of adamant and tunnels
This commit is contained in:
parent
a473991f67
commit
8656b2323b
4 changed files with 128 additions and 0 deletions
|
@ -173,6 +173,19 @@
|
|||
</resourcelimit>
|
||||
</resource>
|
||||
|
||||
<resource name="diamondaxe">
|
||||
<item weight="100" score="500">
|
||||
<construction skill="weaponsmithing" minskill="8" reqsize="1">
|
||||
<requirement type="diamond" quantity="1"/>
|
||||
<requirement type="log" quantity="1"/>
|
||||
</construction>
|
||||
<weapon cut="true" skill="melee" offmod="2" defmod="-2" magres="0.30">
|
||||
<damage type="rider" value="3d4+15"/>
|
||||
<damage type="footman" value="3d4+15"/>
|
||||
</weapon>
|
||||
</item>
|
||||
</resource>
|
||||
|
||||
<resource name="diamondplate">
|
||||
<item weight="100" score="2000">
|
||||
<construction skill="armorer" minskill="10" reqsize="1">
|
||||
|
|
68
src/scripts/adamant.lua
Normal file
68
src/scripts/adamant.lua
Normal file
|
@ -0,0 +1,68 @@
|
|||
-- adamant gifts and setup for tunnels
|
||||
|
||||
-- use only once to hand out some items to existing factions
|
||||
function adamant_gifts()
|
||||
for f in factions() do
|
||||
local i = math.mod(test.rng_int(), 2)
|
||||
if i==0 then
|
||||
f:add_item("diamond", 1)
|
||||
f:add_item("diamondplate", 1)
|
||||
else
|
||||
f:add_item("diamond", 3)
|
||||
f:add_item("diamondaxe", 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- create a fixed path to a specific region
|
||||
local function create_path(from, to)
|
||||
local param = tostring(to.uid)
|
||||
local b = add_building(from, "portal")
|
||||
b.name = "Weltentor"
|
||||
b.size = 1
|
||||
b:add_action("tunnel_action", param)
|
||||
end
|
||||
|
||||
-- create a wonky tunnel wth more than one exit
|
||||
local function create_tunnel(from, param)
|
||||
local b = add_building(from, "portal")
|
||||
b.name = "Weltentor"
|
||||
b.size = 1
|
||||
b:add_action("tunnel_action", param)
|
||||
end
|
||||
|
||||
-- make a tunnel from the cursor to the first selected region
|
||||
function mktunnel()
|
||||
local from = gmtool.cursor()
|
||||
local to = gmtool.selection()()
|
||||
if to~=nil then
|
||||
terraform(from.x, from.y, "glacier")
|
||||
create_tunnel(from, to)
|
||||
gmtool.select(to, 0)
|
||||
gmtool.highlight(to, 1)
|
||||
end
|
||||
end
|
||||
|
||||
-- turn all selected regions into targets for a wonky tunnel ("tnnL")
|
||||
function mkanchors()
|
||||
for r in gmtool.selection() do
|
||||
if not r:get_key("tnnL") then
|
||||
r:set_key("tnnL", true)
|
||||
if r:get_flag(0) then
|
||||
-- RF_CHAOTIC
|
||||
r:set_flag(0, true)
|
||||
end
|
||||
r:set_resource("peasant", r:get_resource("peasant") + 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- terraform and prepare all hell-regions to become wonky gates
|
||||
function mkgates()
|
||||
for r in regions() do
|
||||
if r.plane_id==0 and r.terrain=="hell" then
|
||||
create_tunnel(r, "tnnL")
|
||||
terraform(r.x, r.y, "glacier")
|
||||
end
|
||||
end
|
||||
end
|
|
@ -40,6 +40,7 @@ function load_scripts()
|
|||
"eressea/xmas2005.lua",
|
||||
"eressea/xmas2006.lua",
|
||||
"eressea/embassy.lua",
|
||||
"eressea/tunnels.lua",
|
||||
"eressea/ents.lua"
|
||||
}
|
||||
for index, value in pairs(scripts) do
|
||||
|
|
46
src/scripts/eressea/tunnels.lua
Normal file
46
src/scripts/eressea/tunnels.lua
Normal file
|
@ -0,0 +1,46 @@
|
|||
local function tunnel_travellers(b)
|
||||
local units = {}
|
||||
for u in b.units do
|
||||
units[u] = u
|
||||
end
|
||||
return units
|
||||
end
|
||||
|
||||
targets = nil
|
||||
ntargets = 0
|
||||
|
||||
local function get_target(param)
|
||||
if targets == nil then
|
||||
targets = {}
|
||||
local r
|
||||
for r in regions() do
|
||||
if r:get_key(param) then
|
||||
targets[ntargets] = r
|
||||
ntargets = ntargets + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
if ntargets==0 then
|
||||
return nil
|
||||
end
|
||||
local rn = math.mod(test.rng_int(), ntargets)
|
||||
return targets[rn]
|
||||
end
|
||||
|
||||
-- export, will be called from lc_age()
|
||||
function tunnel_action(b, param)
|
||||
local r = nil
|
||||
if tonumber(param)~=nil then
|
||||
r = get_region_by_id(tonumber(param))
|
||||
end
|
||||
if r~=nil then
|
||||
local units = tunnel_travelers(b)
|
||||
for key, u in pairs(units) do
|
||||
if r==nil then
|
||||
u.region = get_target(param)
|
||||
else
|
||||
u.region = r
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue