forked from github/server
BUG 2334 and 2339: fix script update and init calls
Ponnuki and Portals scripts are working. Ponnuki may still attack? More testing required.
This commit is contained in:
parent
3ec1476da2
commit
eed93b7470
|
@ -10,23 +10,25 @@ local jokes = {
|
||||||
}
|
}
|
||||||
|
|
||||||
local function ponnuki_brain(u)
|
local function ponnuki_brain(u)
|
||||||
|
u:clear_orders()
|
||||||
local i = math.random(#jokes)
|
local i = math.random(#jokes)
|
||||||
u:add_notice("Eine Botschaft von " .. tostring(u) .. ": " ..jokes[i])
|
u:add_order("BOTSCHAFT REGION \"" .. jokes[i] .. "\"")
|
||||||
|
eressea.log.info("Ponnuki is telling jokes in " .. tostring(u.region))
|
||||||
local d = math.random(6)
|
local d = math.random(6)
|
||||||
local r = u.region:next(d-1)
|
local r = u.region:next(d-1)
|
||||||
if r.terrain == 'glacier' then
|
if r.terrain == 'glacier' then
|
||||||
u:clear_orders()
|
|
||||||
u:add_order("NACH " .. directions[d])
|
u:add_order("NACH " .. directions[d])
|
||||||
|
eressea.log.info("Ponnuki is walking to " .. tostring(r))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ponnuki.init()
|
function ponnuki.init()
|
||||||
-- initialize other scripts
|
-- initialize other scripts
|
||||||
|
local f = get_faction(666)
|
||||||
local u = get_unit(atoi36("ponn"))
|
local u = get_unit(atoi36("ponn"))
|
||||||
if not u then
|
if not u then
|
||||||
eressea.log.error("Ponnuki is missing, will re-create")
|
eressea.log.error("Ponnuki is missing, will re-create")
|
||||||
local home = get_region(-67, -5)
|
local home = get_region(-67, -5)
|
||||||
local f = get_faction(666)
|
|
||||||
if home and f then
|
if home and f then
|
||||||
if home.terrain~="glacier" then
|
if home.terrain~="glacier" then
|
||||||
home.terrain="glacier"
|
home.terrain="glacier"
|
||||||
|
@ -44,10 +46,11 @@ function ponnuki.init()
|
||||||
else
|
else
|
||||||
eressea.log.error("Ponnuki cannot find Magrathea")
|
eressea.log.error("Ponnuki cannot find Magrathea")
|
||||||
end
|
end
|
||||||
|
elseif u.faction==f then
|
||||||
|
eressea.log.info("Ponnuki is in " .. tostring(u.region))
|
||||||
|
u.status = 5 -- FLIEHE
|
||||||
end
|
end
|
||||||
if u then
|
|
||||||
ponnuki_brain(u)
|
ponnuki_brain(u)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return ponnuki
|
return ponnuki
|
||||||
|
|
|
@ -144,7 +144,6 @@ function process(rules, orders)
|
||||||
|
|
||||||
turn_begin()
|
turn_begin()
|
||||||
init_summary()
|
init_summary()
|
||||||
callbacks(rules, 'init')
|
|
||||||
|
|
||||||
-- run the turn:
|
-- run the turn:
|
||||||
if eressea.read_orders(orders) ~= 0 then
|
if eressea.read_orders(orders) ~= 0 then
|
||||||
|
@ -152,19 +151,18 @@ function process(rules, orders)
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
|
|
||||||
plan_monsters()
|
|
||||||
|
|
||||||
if nmr_check(config.maxnmrs or 80)~=0 then
|
if nmr_check(config.maxnmrs or 80)~=0 then
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
|
plan_monsters()
|
||||||
callbacks(rules, 'update')
|
callbacks(rules, 'init')
|
||||||
turn_process()
|
turn_process()
|
||||||
|
callbacks(rules, 'update')
|
||||||
|
turn_end() -- ageing, etc.
|
||||||
|
|
||||||
write_files(config.locales)
|
write_files(config.locales)
|
||||||
dbupdate()
|
dbupdate()
|
||||||
|
|
||||||
turn_end()
|
|
||||||
file = '' .. get_turn() .. '.dat'
|
file = '' .. get_turn() .. '.dat'
|
||||||
if eressea.write_game(file)~=0 then
|
if eressea.write_game(file)~=0 then
|
||||||
eressea.log.error("could not write game")
|
eressea.log.error("could not write game")
|
||||||
|
|
Loading…
Reference in New Issue