forked from github/server
- scripts for kingdoms
- per-game folders to organize scripts a bit more
This commit is contained in:
parent
4157bfbea2
commit
de9264bc4c
24 changed files with 127 additions and 62 deletions
|
@ -25,9 +25,9 @@ function run_scripts()
|
|||
scripts = {
|
||||
"spells.lua",
|
||||
"extensions.lua",
|
||||
"eternath.lua",
|
||||
"wedding-jadee.lua",
|
||||
"ponnuki.lua"
|
||||
"eressea/eternath.lua",
|
||||
"eressea/wedding-jadee.lua",
|
||||
"eressea/ponnuki.lua"
|
||||
}
|
||||
for index in scripts do
|
||||
loadscript(scripts[index])
|
||||
|
@ -69,7 +69,7 @@ function process(orders)
|
|||
init_summary()
|
||||
|
||||
-- kill multi-players (external script)
|
||||
loadscript("eressea-multis.lua")
|
||||
loadscript("eressea/multis.lua")
|
||||
|
||||
-- run the turn:
|
||||
if read_orders(orders) ~= 0 then
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
-- implements gates and travel between them
|
||||
-- used in HSE and Eressea
|
||||
|
||||
function gate_travel(b, units)
|
||||
-- we've found which units we want to exchange, now swap them:
|
||||
local u
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
dofile(scriptpath .. "/hse-grails.lua")
|
||||
dofile(scriptpath .. "/hse-spoils.lua")
|
||||
dofile(scriptpath .. "/hse-buildings.lua")
|
||||
dofile(scriptpath .. "/hse/grails.lua")
|
||||
dofile(scriptpath .. "/hse/spoils.lua")
|
||||
dofile(scriptpath .. "/hse/buildings.lua")
|
||||
|
||||
function write_stats(filename)
|
||||
local file = io.open(reportpath .. "/" .. filename, "w")
|
|
@ -2,8 +2,8 @@ function run_scripts()
|
|||
scripts = {
|
||||
"spells.lua",
|
||||
"extensions.lua",
|
||||
"hse-portals.lua",
|
||||
"hse-stats.lua"
|
||||
"hse/portals.lua",
|
||||
"hse/stats.lua"
|
||||
}
|
||||
for index in scripts do
|
||||
local script = scriptpath .. "/" .. scripts[index]
|
||||
|
|
|
@ -2,8 +2,8 @@ function run_scripts()
|
|||
scripts = {
|
||||
"spells.lua",
|
||||
"extensions.lua",
|
||||
"hse-portals.lua",
|
||||
"hse-stats.lua"
|
||||
"hse/portals.lua",
|
||||
"hse/stats.lua"
|
||||
}
|
||||
for index in scripts do
|
||||
local script = scriptpath .. "/" .. scripts[index]
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
function teleport(u, r)
|
||||
u.region:add_notice(tostring(u) .. " wird durchsichtig und verschwindet.")
|
||||
u.region = r
|
||||
u.region:add_notice(tostring(u) .. " erscheint.")
|
||||
end
|
||||
|
||||
function call_igjarjuk()
|
||||
u = get_unit(atoi36("50ki"))
|
||||
if (u==nil) then
|
||||
return
|
||||
end
|
||||
fog = u.region
|
||||
|
||||
laoris = get_unit(atoi36("cshL"))
|
||||
wyrm = get_unit(atoi36("igjr"))
|
||||
if (laoris==nil or wyrm==nil or laoris.region==fog) then
|
||||
return
|
||||
end
|
||||
|
||||
-- make him a special kind of wyrm
|
||||
wyrm.race = "skeletal_wyrm"
|
||||
wyrm.hp = 10000
|
||||
wyrm.status = 1
|
||||
wyrm.magic = "nomagic"
|
||||
wyrm:set_skill("magic", 20)
|
||||
wyrm.aura = 1000
|
||||
wyrm.faction:set_policy(laoris.faction, "fight", true)
|
||||
wyrm.faction:set_policy(get_faction(atoi36("dpen")), "fight", true)
|
||||
|
||||
laoris:add_item("wand_of_tears", -6)
|
||||
-- inform the folks in the grave about what's up
|
||||
grave = wyrm.region
|
||||
fog:add_notice(tostring(laoris) .. " schwingt die Schwinge des Greifen. Das Auge des Dämons glüht in hellem weißen Licht, Blitze springen auf " .. tostring(wyrm) .. " über.")
|
||||
fog:add_notice(tostring(wyrm) .. " wird durchsichtig und verschwindet.")
|
||||
fog:add_notice(tostring(laoris) .. " wird durchsichtig und verschwindet.")
|
||||
|
||||
-- andere Pentagramm-Meister
|
||||
teleport(get_unit(atoi36("q7qf")), fog)
|
||||
teleport(get_unit(atoi36("abqp")), fog)
|
||||
|
||||
-- Wyrm und Laoris
|
||||
wyrm.region = fog
|
||||
laoris.region = fog
|
||||
|
||||
fog:add_notice("von " .. tostring(wyrm) .. ": 'DER TAG MEINER RÜCKKEHR IST GEKOMMEN. MIT DEM BLUT DER STERBLICHEN WILL ICH AUF DIESEN TAG ANSTOSSEN.'")
|
||||
fog:add_notice(tostring(laoris) .. " erscheint. Auf seinem Rücken sind die Schwingen eines mächtigen Greifen zu sehen, in seinen Händen hält er beschwörend einen hell leuchtenden Kristall, das Auge des Dämon.")
|
||||
fog:add_notice(tostring(wyrm) .. " erscheint.")
|
||||
fog:add_notice("von " .. tostring(wyrm) .. ": 'WAS IST DAS? DIES IST NICHT DIE WELT DER STERBLICHEN. LAORIS! WOHIN HAST DU MICH GEBRACHT?'")
|
||||
end
|
92
src/scripts/kingdoms-run.lua
Normal file
92
src/scripts/kingdoms-run.lua
Normal file
|
@ -0,0 +1,92 @@
|
|||
function loadscript(name)
|
||||
local script = scriptpath .. "/" .. name
|
||||
print("- loading " .. script)
|
||||
if pcall(dofile, script)==0 then
|
||||
print("Could not load " .. script)
|
||||
end
|
||||
end
|
||||
|
||||
function write_emails()
|
||||
local locales = { "de", "en" }
|
||||
local files = {}
|
||||
local key
|
||||
for key in locales do
|
||||
local locale = locales[key]
|
||||
files[locale] = io.open(basepath .. "/emails." .. locale, "w")
|
||||
end
|
||||
|
||||
local faction
|
||||
for faction in factions() do
|
||||
-- print(faction.id .. " - " .. faction.locale)
|
||||
files[faction.locale]:write(faction.email .. "\n")
|
||||
end
|
||||
|
||||
for key in files do
|
||||
files[key]:close()
|
||||
end
|
||||
end
|
||||
|
||||
function update_owners()
|
||||
-- update the region's owners. currently uses the owner of
|
||||
-- the largest castle.
|
||||
local r
|
||||
for r in regions() do
|
||||
local lb = nil
|
||||
for b in r.buildings do
|
||||
if b.type=="castle" and (lb==nil or b.size>lb.size) then
|
||||
lb = b
|
||||
end
|
||||
end
|
||||
local u
|
||||
u = b.units()
|
||||
if u~=nil and u.faction~=r.owner then
|
||||
r.owner = u.faction
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function process(orders)
|
||||
file = "" .. get_turn()
|
||||
if read_game(file)~=0 then
|
||||
print("could not read game")
|
||||
return -1
|
||||
end
|
||||
init_summary()
|
||||
|
||||
-- run the turn:
|
||||
read_orders(orders)
|
||||
|
||||
-- DISABLED: plan_monsters()
|
||||
process_orders()
|
||||
update_owners()
|
||||
|
||||
-- use newfactions file to place out new players
|
||||
autoseed(basepath .. "/newfactions", true)
|
||||
|
||||
write_passwords()
|
||||
write_reports()
|
||||
write_emails()
|
||||
write_summary()
|
||||
|
||||
file = "" .. get_turn()
|
||||
if write_game(file)~=0 then
|
||||
print("could not write game")
|
||||
return -1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- main body of script
|
||||
--
|
||||
|
||||
-- orderfile: contains the name of the orders.
|
||||
if orderfile==nil then
|
||||
print "you must specify an orderfile"
|
||||
else
|
||||
-- loadscript("spells.lua")
|
||||
loadscript("extensions.lua")
|
||||
loadscript("kingdoms/extensions.lua")
|
||||
process(orderfile)
|
||||
end
|
||||
|
19
src/scripts/kingdoms/extensions.lua
Normal file
19
src/scripts/kingdoms/extensions.lua
Normal file
|
@ -0,0 +1,19 @@
|
|||
function get_wage(r, f, race)
|
||||
return 10
|
||||
end
|
||||
|
||||
|
||||
function get_maintenance(u)
|
||||
local f = u.region.owner
|
||||
if f ~= nil then
|
||||
if f == u.faction then
|
||||
return 2 * u.number
|
||||
else if f:get_policy(u.faction, "money") then
|
||||
return 5 * u.number
|
||||
end
|
||||
end
|
||||
return 10 * u.number
|
||||
end
|
||||
|
||||
overload("maintenance", get_maintenance)
|
||||
overload("wage", get_wage)
|
|
@ -47,8 +47,8 @@ print("- Running wdw-run.lua")
|
|||
scripts = {
|
||||
"spells.lua",
|
||||
"extensions.lua",
|
||||
"wdw-sphinx.lua",
|
||||
"wdw-standings.lua"
|
||||
"wdw/sphinx.lua",
|
||||
"wdw/standings.lua"
|
||||
}
|
||||
|
||||
-- orderfile: contains the name of the orders.
|
||||
|
|
Loading…
Reference in a new issue