2005-03-23 19:55:47 +01:00
function loadscript ( name )
local script = scriptpath .. " / " .. name
print ( " - loading " .. script )
if pcall ( dofile , script ) == 0 then
print ( " Could not load " .. script )
end
end
2005-04-09 11:11:41 +02:00
function change_locales ( )
2005-09-09 00:25:56 +02:00
-- local localechange = { }
2005-10-09 21:52:21 +02:00
local localechange = { de = { " 2xwr " } }
2005-04-09 11:11:41 +02:00
for loc , flist in localechange do
for index , name in flist do
f = get_faction ( atoi36 ( name ) )
if f ~= nil then
f.locale = loc
print ( " LOCALECHANGE " , f , loc )
end
end
end
end
2005-01-01 18:50:35 +01:00
function run_scripts ( )
scripts = {
2005-10-08 23:34:00 +02:00
" spells.lua " ,
2005-10-29 16:48:37 +02:00
" extensions.lua " ,
2005-11-27 14:40:09 +01:00
" write_emails.lua " ,
2005-11-26 00:32:56 +01:00
" eressea/eternath.lua " ,
" eressea/wedding-jadee.lua " ,
" eressea/ponnuki.lua "
2005-01-01 18:50:35 +01:00
}
for index in scripts do
2005-03-23 19:55:47 +01:00
loadscript ( scripts [ index ] )
2005-01-01 18:50:35 +01:00
end
end
2005-12-11 12:43:18 +01:00
function use_seashell ( u , amount )
-- Muschelplateau...
local visit = u.faction . objects [ " muschel " ]
if visit ~= nil then
local turns = get_turn ( ) - visit
local msg = message ( " msg_event " )
msg : set_string ( " string " , tostring ( u ) .. " erz<72> hlt den Bewohnern von " .. r.name .. " von Muschelplateau, das seine Partei vor " .. turns .. " Wochen besucht hat. " )
msg : send_region ( u.region )
end
end
function update_special ( )
-- Muschelplateau
local r = get_region ( 165 , 30 )
if r ~= nil then
local u
for u in r.units do
if u.faction . objects [ " muschel " ] ~= nil then
if ( u.faction . add_item ( " muschel " , 1 ) > 0 ) then
u.faction . objects [ " seashell " ] = get_turn ( )
end
end
end
end
end
2004-06-26 22:51:19 +02:00
function process ( orders )
2005-10-02 17:54:24 +02:00
-- initialize starting equipment for new players
2005-10-02 22:28:44 +02:00
equipment_setitem ( " new_faction " , " conquesttoken " , " 1 " ) ;
equipment_setitem ( " new_faction " , " log " , " 30 " ) ;
equipment_setitem ( " new_faction " , " stone " , " 30 " ) ;
equipment_setitem ( " new_faction " , " money " , " 4200 " ) ;
2005-10-02 17:54:24 +02:00
2004-06-26 22:51:19 +02:00
file = " " .. get_turn ( )
if read_game ( file ) ~= 0 then
print ( " could not read game " )
return - 1
end
2005-04-16 15:03:35 +02:00
init_summary ( )
2004-06-26 22:51:19 +02:00
2005-07-23 22:38:14 +02:00
-- kill multi-players (external script)
2005-11-26 00:32:56 +01:00
loadscript ( " eressea/multis.lua " )
2005-07-23 22:38:14 +02:00
2004-06-26 22:51:19 +02:00
-- run the turn:
2005-04-24 23:54:57 +02:00
if read_orders ( orders ) ~= 0 then
print ( " could not read " .. orders )
return - 1
end
2005-01-01 18:50:35 +01:00
run_scripts ( )
2005-11-26 12:03:44 +01:00
-- create new monsters:
spawn_dragons ( )
spawn_undead ( )
2005-10-02 18:06:12 +02:00
spawn_braineaters ( 0.25 )
2005-11-26 12:03:44 +01:00
2005-06-04 17:34:04 +02:00
plan_monsters ( )
process_orders ( )
2005-11-26 12:03:44 +01:00
-- post-turn updates:
2005-12-11 12:43:18 +01:00
update_special ( )
2005-11-20 13:58:59 +01:00
update_guards ( )
update_scores ( )
2005-06-04 17:34:04 +02:00
change_locales ( )
2005-04-09 11:11:41 +02:00
-- use newfactions file to place out new players
2005-08-07 15:48:18 +02:00
autoseed ( basepath .. " /newfactions " , false )
2005-03-13 11:05:51 +01:00
2004-06-26 22:51:19 +02:00
write_passwords ( )
write_reports ( )
write_emails ( )
2005-04-16 15:03:35 +02:00
write_summary ( )
2004-06-26 22:51:19 +02:00
file = " " .. get_turn ( )
if write_game ( file ) ~= 0 then
print ( " could not write game " )
return - 1
end
end
2005-11-20 13:58:59 +01:00
-- demo: how to add a special familiars-constructor
function initfamiliar_lynx ( u )
print ( " a lynx is born ;-) " )
end
2004-06-26 22:51:19 +02:00
--
-- main body of script
--
-- orderfile: contains the name of the orders.
if orderfile == nil then
print " you must specify an orderfile "
else
process ( orderfile )
end