forked from github/server
nuking empty/2nmr regions
This commit is contained in:
parent
7563f57432
commit
0dbd20184d
|
@ -873,7 +873,9 @@ demographics(void)
|
|||
|
||||
calculate_emigration(r);
|
||||
peasants(r);
|
||||
plagues(r, false);
|
||||
if (r->age>20) {
|
||||
plagues(r, false);
|
||||
}
|
||||
horses(r);
|
||||
if (current_season != SEASON_WINTER) {
|
||||
growing_trees(r, current_season, last_weeks_season);
|
||||
|
|
|
@ -105,6 +105,11 @@ get_monsters(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (monsters==NULL) {
|
||||
/* shit! */
|
||||
monsters = findfaction(666);
|
||||
if (monsters) fset(monsters, FFL_NPC);
|
||||
}
|
||||
return monsters;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,23 @@ static int tolua_building_set_region(lua_State* L)
|
|||
}
|
||||
|
||||
|
||||
static int tolua_building_get_info(lua_State* L)
|
||||
{
|
||||
building* self = (building*) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, self->display);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_building_set_info(lua_State* L)
|
||||
{
|
||||
building* self = (building*)tolua_tousertype(L, 1, 0);
|
||||
const char * info = tolua_tostring(L, 2, 0);
|
||||
free(self->display);
|
||||
if (info) self->display = strdup(info);
|
||||
else self->display = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_building_get_name(lua_State* L)
|
||||
{
|
||||
building* self = (building*) tolua_tousertype(L, 1, 0);
|
||||
|
@ -180,6 +197,7 @@ tolua_building_open(lua_State* L)
|
|||
tolua_variable(L, TOLUA_CAST "id", tolua_building_get_id, NULL);
|
||||
tolua_variable(L, TOLUA_CAST "type", tolua_building_get_type, NULL);
|
||||
tolua_variable(L, TOLUA_CAST "name", tolua_building_get_name, tolua_building_set_name);
|
||||
tolua_variable(L, TOLUA_CAST "info", tolua_building_get_info, tolua_building_set_info);
|
||||
tolua_variable(L, TOLUA_CAST "units", tolua_building_get_units, NULL);
|
||||
tolua_variable(L, TOLUA_CAST "region", tolua_building_get_region, tolua_building_set_region);
|
||||
tolua_variable(L, TOLUA_CAST "size", tolua_building_get_size, tolua_building_set_size);
|
||||
|
|
|
@ -135,6 +135,20 @@ tolua_getkey(lua_State* L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
tolua_translate(lua_State* L)
|
||||
{
|
||||
const char * str = tolua_tostring(L, 1, 0);
|
||||
const char * lang = tolua_tostring(L, 2, 0);
|
||||
struct locale * loc = lang?find_locale(lang):default_locale;
|
||||
if (loc) {
|
||||
str = locale_string(loc, str);
|
||||
tolua_pushstring(L, str);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
tolua_setkey(lua_State* L)
|
||||
{
|
||||
|
@ -962,6 +976,8 @@ tolua_eressea_open(lua_State* L)
|
|||
tolua_function(L, TOLUA_CAST "get_key", tolua_getkey);
|
||||
tolua_function(L, TOLUA_CAST "set_key", tolua_setkey);
|
||||
|
||||
tolua_function(L, TOLUA_CAST "translate", &tolua_translate);
|
||||
|
||||
tolua_function(L, TOLUA_CAST "rng_int", tolua_rng_int);
|
||||
|
||||
tolua_function(L, TOLUA_CAST "spells", tolua_get_spells);
|
||||
|
|
|
@ -9,16 +9,51 @@ local confirmed_multis = {
|
|||
local suspected_multis = {
|
||||
}
|
||||
|
||||
function num_oceans(r)
|
||||
local oceans = 0
|
||||
local p = r:next(5)
|
||||
for d = 0,5 do
|
||||
local n = r:next(d)
|
||||
if p.terrain~="ocean" and n.terrain=="ocean" then
|
||||
oceans = oceans +1
|
||||
end
|
||||
p = n
|
||||
end
|
||||
return oceans
|
||||
end
|
||||
|
||||
-- destroy a faction and all of its buildings.
|
||||
-- destroy the home region, too
|
||||
function kill_faction(f)
|
||||
for u in f.units do
|
||||
if u.building~=nil then
|
||||
building.destroy(u.building)
|
||||
u.region.terrain = "firewall"
|
||||
u.region.terrain_name = nil
|
||||
end
|
||||
local r = u.region
|
||||
local b = u.building
|
||||
unit.destroy(u)
|
||||
if b~=nil then
|
||||
building.destroy(b)
|
||||
local nuke = true
|
||||
for v in r.units do
|
||||
if v.faction.id~=f.id then
|
||||
-- print("cannot nuke: " .. tostring(v.faction))
|
||||
nuke = false
|
||||
break
|
||||
end
|
||||
end
|
||||
r.terrain_name = nil
|
||||
if nuke and num_oceans(r)<=1 then
|
||||
-- print("nuke!")
|
||||
r.terrain = "ocean"
|
||||
else
|
||||
-- print("cannot nuke: > 1 oceans")
|
||||
r.terrain = "glacier"
|
||||
r.peasants = 10
|
||||
r:set_resource("money", 100)
|
||||
b = building.create(r, "monument")
|
||||
b.size = 1
|
||||
b.name = "Memento Mori"
|
||||
b.info = "Eine kleine " .. translate("race::" .. f.race .."_x") .. "-Statue erinnert hier an ein verschwundenes Volk"
|
||||
end
|
||||
end
|
||||
end
|
||||
faction.destroy(f)
|
||||
end
|
||||
|
@ -26,7 +61,6 @@ end
|
|||
function kill_nonstarters()
|
||||
for f in factions() do
|
||||
if f.lastturn==1 then
|
||||
print(f, f.lastturn)
|
||||
kill_faction(f)
|
||||
end
|
||||
end
|
||||
|
@ -133,7 +167,6 @@ function process(orders)
|
|||
return -1
|
||||
end
|
||||
|
||||
kill_nonstarters()
|
||||
kill_multis(confirmed_multis)
|
||||
plan_monsters()
|
||||
|
||||
|
@ -154,6 +187,7 @@ function process(orders)
|
|||
-- spawn_braineaters(0.25)
|
||||
-- spawn_ents()
|
||||
|
||||
kill_nonstarters()
|
||||
mark_multis(suspected_multis)
|
||||
-- post-turn updates:
|
||||
update_guards()
|
||||
|
|
Loading…
Reference in New Issue