2017-01-22 11:38:01 +01:00
|
|
|
if not config.ponnuki then return nil end
|
2014-07-26 22:52:25 +02:00
|
|
|
local ponnuki = {}
|
2010-08-08 09:40:42 +02:00
|
|
|
|
2014-07-26 22:52:25 +02:00
|
|
|
local directions = { "NW", "NO", "O", "SO", "SW", "W" }
|
|
|
|
local jokes = {
|
|
|
|
"Ein Bummerang ist, wenn man ihn wegwirft und er kommt nicht wieder, dann war's keiner.",
|
2010-08-08 09:40:42 +02:00
|
|
|
"Merke: Mit Schwabenwitzen soll man ganz sparsam sein.",
|
|
|
|
"Was bekommt man, wenn man Katzen und Elfen kreuzt? Elfen ohne Rheuma.",
|
|
|
|
"Was bekommt man, wenn man Insekten und Katzen kreuzt? Tiger, die Crisan benutzen."
|
2014-07-26 22:52:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
local function ponnuki_brain(u)
|
2017-04-09 13:35:55 +02:00
|
|
|
u:clear_orders()
|
2017-06-18 12:23:19 +02:00
|
|
|
local i = math.random(#jokes)
|
|
|
|
u:add_order("BOTSCHAFT REGION \"" .. jokes[i] .. "\"")
|
|
|
|
eressea.log.info("Ponnuki is telling jokes in " .. tostring(u.region))
|
|
|
|
local d = math.random(6)
|
|
|
|
local r = u.region:next(d-1)
|
|
|
|
if r.terrain == 'glacier' then
|
|
|
|
u:add_order("NACH " .. directions[d])
|
|
|
|
eressea.log.info("Ponnuki is walking to " .. tostring(r))
|
|
|
|
end
|
2010-08-08 09:40:42 +02:00
|
|
|
end
|
|
|
|
|
2014-07-26 22:52:25 +02:00
|
|
|
function ponnuki.init()
|
|
|
|
-- initialize other scripts
|
2017-06-18 12:23:19 +02:00
|
|
|
local f = get_faction(666)
|
2014-07-26 22:52:25 +02:00
|
|
|
local u = get_unit(atoi36("ponn"))
|
|
|
|
if not u then
|
|
|
|
eressea.log.error("Ponnuki is missing, will re-create")
|
|
|
|
local home = get_region(-67, -5)
|
|
|
|
if home and f then
|
2017-04-09 13:35:55 +02:00
|
|
|
if home.terrain~="glacier" then
|
|
|
|
home.terrain="glacier"
|
|
|
|
home.name = 'Magrathea'
|
|
|
|
end
|
|
|
|
u = unit.create(f, home, 1, "template")
|
|
|
|
if u then
|
|
|
|
u.id = atoi36("ponn")
|
|
|
|
u.name = "Ponnuki"
|
|
|
|
u.info = "Go, Ponnuki, Go!"
|
|
|
|
u.race_name = "Ritter von Go"
|
2017-05-07 17:29:55 +02:00
|
|
|
u.status = 5 -- FLIEHE
|
2017-04-09 13:35:55 +02:00
|
|
|
print(u:show())
|
|
|
|
end
|
2014-07-26 22:52:25 +02:00
|
|
|
else
|
|
|
|
eressea.log.error("Ponnuki cannot find Magrathea")
|
|
|
|
end
|
2017-06-18 12:23:19 +02:00
|
|
|
elseif u.faction==f then
|
|
|
|
eressea.log.info("Ponnuki is in " .. tostring(u.region))
|
|
|
|
u.status = 5 -- FLIEHE
|
2014-07-26 22:52:25 +02:00
|
|
|
end
|
2017-06-18 12:23:19 +02:00
|
|
|
ponnuki_brain(u)
|
2010-08-08 09:40:42 +02:00
|
|
|
end
|
|
|
|
|
2014-07-26 22:52:25 +02:00
|
|
|
return ponnuki
|