remove obsolete scripts and module definitions.

a lot of these were from before the module rewrite, and duplicates of the new code.
This commit is contained in:
Enno Rehling 2014-10-14 18:55:44 +02:00
parent ce3e9cd7d0
commit 7987b82c62
9 changed files with 0 additions and 580 deletions

View File

@ -1,193 +0,0 @@
function size()
return 16
end
function make_island(pl, x, y, a, b)
if b==nil then b = a/3 end
local nx, ny = plane.normalize(pl, x, y)
gmtool.make_island(nx, ny, a, b)
end
function make_block(pl, x, y, r)
local nx, ny = plane.normalize(pl, x, y)
gmtool.make_block(nx, ny, r)
end
function find(email)
for f in factions() do if f.email==email then return f end end
return nil
end
function give_item(email, id, uname, iname)
f = find(email)
for u in f.units do
u.id=atoi36(id)
u.name=uname
u:add_item(iname, 1)
break
end
end
function give_items()
give_item("hongeldongel@web.de", "boss", "Drollitz", "rpg_item_1")
give_item("zangerl.helmut@chello.at", "holb", "Holbard", "rpg_item_2")
give_item("r.lang@chello.at", "brtL", "Bertl", "rpg_item_2")
give_item("schlaustauch@gmx.de", "bert", "Bertram", "rpg_item_3")
end
function island(pl, x, y, r)
make_block(pl, x, y, r)
make_island(pl, x+r/2+2, y+r/2, size() * 3)
make_island(pl, x-r-2, y+r/2, size() * 3)
make_island(pl, x-r/2-2, y-r/2, size() * 3)
make_island(pl, x+r+2, y-r/2, size() * 3)
make_island(pl, x+r/2+2, y-r-2, size() * 3)
make_island(pl, x-r/2-2, y+r+2, size() * 3)
end
function cross(pl, x, y, r)
make_block(pl, x-r, y+r*2, r)
make_block(pl, x+r*4/3, y, r)
make_block(pl, x-r*4/3, y, r)
make_block(pl, x+r, y-r*2, r)
make_island(pl, x, y, size() * 3)
make_island(pl, x, y-r*4/3, size() * 3)
make_island(pl, x, y+r*4/3, size() * 3)
make_island(pl, x+r*4/3, y-r*4/3, size() * 3)
make_island(pl, x-r*4/3, y+r*4/3, size() * 3)
end
function clean()
for r in regions() do
if r.terrain=="ocean" then
region.destroy(r)
end
end
end
function count()
local i = 0
for f in factions() do i = i + 1 end
print(i)
end
function line(pl)
local m = 0
local i = 0
local x, y = plane.normalize(pl, 0, i)
local r = get_region(x, y)
while true do
if r==nil then
if m==0 and (i>=0 or i<-10) then
local s = size()
gmtool.make_island(x, y, s*3, s)
else
gmtool.make_block(x, y, 6)
end
r = get_region(x, y)
if r==nil then
r = region.create(x, y, "ocean")
end
m = 1 - m
end
i = r.y + 1
x, y = plane.normalize(pl, 0, i)
r = get_region(x, y)
if r~=nil and r.y==0 then break end
end
end
function build(pl)
local d = 28
local h = 20
line(pl)
island(pl, d+15, -6, 11)
island(pl, -d, -h-10, 11)
cross(pl, -d, h-10, 6)
island(pl, d, 2*h, 11)
end
function fill(pl, w, h)
local x, y
for x=0,w do
for y=0,h do
local nx, ny = plane.normalize(pl, x, y)
local r = get_region(nx, ny)
if r==nil then
r = region.create(nx, ny, "ocean")
end
end
end
end
function seed()
local input = io.open(config.basepath .. "/parteien.txt")
for f in factions() do
if f.race=="vampunicorn" then
local str = input:read("*line")
if str==nil then break end
local race, lang, email = str:match("([^ ]*) ([^ ]*) ([^ ]*)")
f.race = race:lower()
f.options = f.options + 4096
f.email = email
f.locale = lang
for u in f.units do
u.race = race:lower()
u.hp = u.hp_max
local b = building.create(u.region, "castle")
if lang=="de" then
u.name = "Entdecker"
b.name = "Heimat"
else
u.name = "Explorer"
b.name = "Home"
end
b.size = 10
u.building = b
end
end
end
for r in regions() do
r:set_resource("sapling", r:get_resource("tree")/4)
r:set_resource("seed", 0)
end
update_owners()
end
function select()
for f in factions() do
if f.email=="enno@eressea.de" then
for u in f.units do
gmtool.select(u.region, true)
u.number = 0
end
end
end
end
function justWords(str)
local t = {}
local function helper(word) table.insert(t, word) return "" end
if not str:gsub("%w+", helper):find"%S" then return t end
end
function rebuild()
free_game()
local w = 110
local h = 80
local pl = plane.create(0, -w/2, -h/2, w+1, h+1)
build(pl)
fill(pl, w, h)
write_map("export.cr")
end
function testwelt()
free_game()
local w = 10
local h = 10
local pl = plane.create(0, -w/2, -h/2, w+1, h+1)
gmtool.make_island(0, 0, 30, 3)
fill(pl, w, h)
write_map("export.cr")
end

View File

@ -1,52 +0,0 @@
module('frost', package.seeall)
local function is_winter(turn)
local season = get_season(turn)
return season == "calendar::winter"
end
local function is_spring(turn)
local season = get_season(turn)
return season == "calendar::spring"
end
local function freeze(r, chance)
for i, rn in ipairs(r.adj) do
-- each region has a chance to freeze
if rn.terrain=="ocean" and (chance>=100 or math.fmod(rng_int(), 100)<chance) then
rn.terrain = "packice"
end
end
end
local function thaw(r, chance)
if chance>=100 or math.fmod(rng_int(), 100)<chance then
r.terrain = "ocean"
for s in r.ships do
s.coast = nil
end
end
end
function update()
local turn = get_turn()
if is_winter(turn) then
for r in regions() do
if r.terrain=="glacier" then
freeze(r, 20)
end
end
elseif is_spring(turn) then
for r in regions() do
if r.terrain=="packice" then
thaw(r, 20)
end
end
elseif is_spring(turn-1) then
for r in regions() do
if r.terrain=="packice" then
thaw(r, 100)
end
end
end
end

View File

@ -1,64 +0,0 @@
require "multis"
require "e3a.frost"
function process(orders)
local confirmed_multis = { }
local suspected_multis = { }
if open_game(get_turn())~=0 then
print("could not read game")
return -1
end
init_summary()
-- kill multi-players (external script)
kill_multis(confirmed_multis, false)
mark_multis(suspected_multis, false)
-- run the turn:
if read_orders(orders) ~= 0 then
print("could not read " .. orders)
return -1
end
-- plan_monsters()
local mon = get_faction(666)
if mon ~= nil then
mon.lastturn = get_turn()
end
if nmr_check(config.maxnmrs or 30)~=0 then
return -1
end
process_orders()
if xmas2009~=nil then
xmas2009()
end
-- create new monsters:
spawn_dragons()
spawn_undead()
-- spawn_braineaters(0.25)
-- spawn_ents()
-- post-turn updates:
update_guards()
update_scores()
frost.update()
local localechange = { en = { "L46o" } }
change_locales(localechange)
-- use newfactions file to place out new players
-- autoseed(config.basepath .. "/newfactions", false)
write_files(config.locales)
file = "" .. get_turn() .. ".dat"
if eressea.write_game(file)~=0 then
print("could not write game")
return -1
end
return 0
end

View File

@ -1,89 +0,0 @@
function get_markets(r, result)
local n = 0
result = result or {}
for b in r.buildings do
if b.type=="market" then
u = b.owner
if u~=nil then
table.insert(result, u)
n = n + 1
end
end
end
return n, result
end
function collect_markets(r, result)
local result = result or {}
local n = 0
n, result = get_markets(r, result)
for i, r in ipairs(r.adj) do
if r then
local x, result = get_markets(r, result)
n = n + x
end
end
return n, result
end
function market_action(r)
local f = r.owner
local trade = 1000
if f~=nil and f.race=="halfling" then
trade = 600
end
local p = r:get_resource("peasant")
if p > 500 then
local n, markets = collect_markets(r)
if n>0 then
local give
if r.luxury~=nil then
give = {}
local numlux = p / trade
for x = 1, numlux do
local m = 1+math.fmod(rng_int(), n)
u = markets[m]
if give[u] then
give[u] = give[u] + 1
else
give[u] = 1
end
end
for u, v in pairs(give) do
u:add_item(r.luxury, v)
end
end
if r.herb~=nil then
give = {}
local numherb = p / 500
for x = 1, numherb do
local m = 1+math.fmod(rng_int(), n)
u = markets[m]
if give[u] then
give[u] = give[u] + 1
else
give[u] = 1
end
end
for u, v in pairs(give) do
u:add_item(r.herb, v)
end
end
end
end
end
local function markets()
local r
for r in regions() do
market_action(r)
end
end
-- add_proc(markets, "Markets", "Bauernwanderung")

View File

@ -1,17 +0,0 @@
require "spells"
require "e3a.xmas2009"
require "e3a.rules"
require "e3a.markets"
local srcpath = config.source_dir
tests = {
srcpath .. '/core/scripts/tests/common.lua',
srcpath .. '/core/scripts/tests/spells.lua',
-- srcpath .. '/eressea/scripts/tests/bson.lua',
-- srcpath .. '/eressea/scripts/tests/attrib.lua',
srcpath .. '/scripts/tests/spells.lua',
srcpath .. '/scripts/tests/castles.lua',
srcpath .. '/scripts/tests/morale.lua',
srcpath .. '/scripts/tests/e3a.lua',
srcpath .. '/scripts/tests/stealth.lua',
}

View File

@ -1,77 +0,0 @@
-- when appending to this, make sure the item has a canuse-function!
local goblin_denied = " plate lance mallornlance greatbow axe greatsword halberd rustyaxe rustyhalberd towershield scale "
function item_canuse(u, iname)
local race = u.race
if race=="goblin" then
if string.find(goblin_denied, " " .. iname .. " ") then
return false
end
end
if iname=="rep_crossbow" then
-- only dwarves and halflings allowed to use repeating crossbow
return race=="dwarf" or race=="halfling"
end
if iname=="scale" then
-- only dwarves and halflings can use scale
return race=="dwarf" or race=="halfling"
end
if iname=="towershield" then
-- only dwarves allowed to use towershield
return race=="dwarf"
end
if iname=="greatbow" then
-- only elves use greatbow
return race=="elf"
end
return true
end
function building_protection(b, u)
return 1
end
function building_taxes(b, blevel)
btype = b.type
if btype=="castle" then
return blevel * 0.01
elseif btype=="watch" then
return blevel * 0.005
end
return 0.0
end
-- the "raindance" spell
function raindance(r, mage, level, force)
if (create_curse(mage, r, "blessedharvest", force, 1+force*2, 100 * force)) then
-- slightly crooked way of reporting an action to everyone in the region
local msg = message.create("raindance_effect")
msg:set_unit("mage", mage)
if (msg:report_action(r, mage, 3)) then
local msg2 = message.create("raindance_effect")
msg2:set_unit("mage", nil)
msg2:report_action(r, mage, 4)
end
end
return level
end
-- the "blessed harvest" spell
function blessedharvest(r, mage, level, force)
if create_curse(mage, r, "blessedharvest", force, 1+force*2, 50 * force) then
-- slightly crooked way of reporting an action to everyone in the region
local msg = message.create("harvest_effect")
msg:set_unit("mage", mage)
if (msg:report_action(r, mage, 3)) then
local msg2 = message.create("harvest_effect")
msg2:set_unit("mage", nil)
msg2:report_action(r, mage, 4)
end
for idx, rn in ipairs(r.adj) do
-- nur landregionen haben moral>=0
if r.morale>=0 then
create_curse(mage, r, "blessedharvest", force, force*2, 50 * force)
end
end
end
return level
end

View File

@ -1,26 +0,0 @@
function xmas2009()
if not get_key("xm09") then
-- print("Es weihnachtet sehr (2009)")
set_key("xm09", true)
for f in factions() do
f:add_item("xmastree", 1)
local msg = message.create("msg_event")
msg:set_string("string", translate("santa2006"))
msg:send_faction(f)
end
end
return 0
end
function use_xmastree(u, amount)
if u.region.herb~=nil then
local trees = u.region:get_resource("tree")
u.region:set_resource("tree", 10+trees)
u:use_pooled("xmastree", amount)
local msg = message.create("usepotion")
msg:set_unit("unit", u)
msg:set_resource("potion", "xmastree")
msg:send_region(u.region)
return 0
end
end

View File

@ -1,58 +0,0 @@
require "multis"
require "e3a.frost"
function process(orders)
local confirmed_multis = { }
local suspected_multis = { }
if open_game(get_turn())~=0 then
print("could not read game")
return -1
end
init_summary()
-- run the turn:
if read_orders(orders) ~= 0 then
print("could not read " .. orders)
return -1
end
-- plan_monsters()
local mon = get_faction(666)
if mon ~= nil then
mon.lastturn = get_turn()
end
if nmr_check(config.maxnmrs or 30)~=0 then
return -1
end
process_orders()
if xmas2009~=nil then
xmas2009()
end
-- create new monsters:
spawn_dragons()
spawn_undead()
-- post-turn updates:
update_guards()
update_scores()
frost.update()
local localechange = { en = { "L46o" } }
change_locales(localechange)
-- use newfactions file to place out new players
-- autoseed(config.basepath .. "/newfactions", false)
write_files(config.locales)
file = "" .. get_turn() .. ".dat"
if eressea.write_game(file)~=0 then
print("could not write game")
return -1
end
return 0
end

View File

@ -1,4 +0,0 @@
require "spells"
require "e3a.rules"
require "e3a.markets"
require "e3a.frost"