2010-08-08 09:40:42 +02:00
|
|
|
local function create_ents(r, number)
|
2014-07-26 22:52:25 +02:00
|
|
|
local f = get_faction(666)
|
|
|
|
if f~=nil and number>0 then
|
2015-02-19 17:30:13 +01:00
|
|
|
u = unit.create(f, r, number, "ent")
|
2014-07-26 22:52:25 +02:00
|
|
|
u.name = "Wütende Ents"
|
|
|
|
u:set_skill("perception", 2)
|
|
|
|
|
|
|
|
msg = message.create("entrise")
|
|
|
|
msg:set_region("region", r)
|
|
|
|
msg:send_region(r)
|
|
|
|
return u
|
|
|
|
end
|
|
|
|
return nil
|
2010-08-08 09:40:42 +02:00
|
|
|
end
|
|
|
|
|
2015-02-19 17:30:13 +01:00
|
|
|
local function repair_ents(r)
|
|
|
|
for u in r.units do
|
|
|
|
if u.faction.id==666 and u.race == "undead" and u.name == "Wütende Ents" then
|
2015-07-02 11:08:38 +02:00
|
|
|
eressea.log.info("ent repair: " .. tostring(u))
|
2015-02-19 17:30:13 +01:00
|
|
|
u.race = "ent"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-07-26 22:52:25 +02:00
|
|
|
local ents = {}
|
|
|
|
|
|
|
|
function ents.update()
|
|
|
|
local r
|
|
|
|
for r in regions() do
|
2015-02-19 17:30:13 +01:00
|
|
|
repair_ents(r)
|
2014-07-26 22:52:25 +02:00
|
|
|
if r:get_flag(0) then -- RF_CHAOTIC
|
|
|
|
if r.terrain == "plain" and r:get_resource("tree")==0 then
|
|
|
|
if math.random(3)==1 then
|
|
|
|
u = create_ents(r, math.random(30))
|
|
|
|
if u ~= nil then
|
|
|
|
r:set_resource("tree", u.number)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-08-08 09:40:42 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-07-26 22:52:25 +02:00
|
|
|
|
|
|
|
return ents
|