diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index a3561240d..461ece091 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -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); diff --git a/src/common/kernel/faction.c b/src/common/kernel/faction.c index 2fbbc0aee..f9a14b156 100644 --- a/src/common/kernel/faction.c +++ b/src/common/kernel/faction.c @@ -105,6 +105,11 @@ get_monsters(void) } } } + if (monsters==NULL) { + /* shit! */ + monsters = findfaction(666); + if (monsters) fset(monsters, FFL_NPC); + } return monsters; } diff --git a/src/eressea/tolua/bind_building.c b/src/eressea/tolua/bind_building.c index b9107b7ec..ebe13201a 100644 --- a/src/eressea/tolua/bind_building.c +++ b/src/eressea/tolua/bind_building.c @@ -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); diff --git a/src/eressea/tolua/bindings.c b/src/eressea/tolua/bindings.c index 46514dd3a..eb091114e 100644 --- a/src/eressea/tolua/bindings.c +++ b/src/eressea/tolua/bindings.c @@ -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); diff --git a/src/scripts/run-e3a.lua b/src/scripts/run-e3a.lua index 99d2453ea..c077afc15 100644 --- a/src/scripts/run-e3a.lua +++ b/src/scripts/run-e3a.lua @@ -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()