server/scripts/eressea/ents.lua
Enno Rehling d9457a2488 rewrite of the Lua module system.
At this time, only E2 is working.
Fixing a lot of old code (monster is no longer id 0).
package.paths configured from eressea.ini
install directory configured from eressea.ini
moving building_action into a seaprate module (it's deprecated)
2014-07-26 22:52:25 +02:00

34 lines
848 B
Lua

local function create_ents(r, number)
local f = get_faction(666)
if f~=nil and number>0 then
u = unit.create(f, r, number)
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
end
local ents = {}
function ents.update()
local r
for r in regions() do
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
end
end
end
return ents