mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-05-13 21:56:29 +02:00
update
no biter attacks for new towns at high evo clear spawn of biters for outlanders clear units that are out of the current evolution range prevent outlanders from building close to towns centers
This commit is contained in:
parent
ff8583f8c3
commit
e3e476a06a
@ -52,6 +52,7 @@ require "modules.autostash"
|
||||
--require "modules.satellite_score"
|
||||
--require "modules.show_health"
|
||||
--require "modules.splice_double"
|
||||
--require "modules.ores_are_mixed"
|
||||
--require "modules.team_teleport" --(REQUIRES "on_tick_schedule" !)
|
||||
--require "modules.surrounded_by_worms"
|
||||
--require "modules.more_attacks"
|
||||
@ -114,12 +115,13 @@ require "modules.autostash"
|
||||
-----------------------------
|
||||
|
||||
---- more modules here ----
|
||||
--require "modules.towny.main"
|
||||
require "modules.towny.main"
|
||||
--require "modules.rpg"
|
||||
--require "modules.trees_grow"
|
||||
--require "modules.trees_randomly_die"
|
||||
--require "terrain_layouts.cone_to_east"
|
||||
--require "terrain_layouts.biters_and_resources_east"
|
||||
require "terrain_layouts.scrap_01"
|
||||
------
|
||||
|
||||
if _DUMP_ENV then
|
||||
|
@ -48,7 +48,9 @@ end
|
||||
local function roll_market()
|
||||
local r_max = 0
|
||||
local town_centers = global.towny.town_centers
|
||||
local research_threshold = game.forces.enemy.evolution_factor ^ 0.5 * 50
|
||||
|
||||
--Skip Towns that are too low in reserach for the current biter evolution.
|
||||
local research_threshold = game.forces.enemy.evolution_factor * #game.technology_prototypes * 0.175
|
||||
|
||||
for k, town_center in pairs(town_centers) do
|
||||
if town_center.research_counter >= research_threshold then
|
||||
@ -101,6 +103,35 @@ function Public.validate_swarms()
|
||||
end
|
||||
end
|
||||
|
||||
--Destroy biters that are out of the current evolution range.
|
||||
function Public.wipe_units_out_of_evo_range()
|
||||
local units_to_wipe = {}
|
||||
local evo = game.forces.enemy.evolution_factor
|
||||
if evo > 0.80 then return end
|
||||
units_to_wipe[#units_to_wipe + 1] = "behemoth-biter"
|
||||
units_to_wipe[#units_to_wipe + 1] = "behemoth-spitter"
|
||||
if evo < 0.40 then
|
||||
units_to_wipe[#units_to_wipe + 1] = "big-biter"
|
||||
units_to_wipe[#units_to_wipe + 1] = "big-spitter"
|
||||
end
|
||||
if evo < 0.10 then
|
||||
units_to_wipe[#units_to_wipe + 1] = "medium-biter"
|
||||
units_to_wipe[#units_to_wipe + 1] = "medium-spitter"
|
||||
end
|
||||
for k, surface in pairs(game.surfaces) do
|
||||
for k2, unit in pairs(surface.find_entities_filtered({name = units_to_wipe, force = "enemy"})) do
|
||||
unit.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.clear_spawn_for_player(player)
|
||||
local area = {{player.position.x - 64, player.position.y - 64}, {player.position.x + 64, player.position.y + 64}}
|
||||
for _, e in pairs(player.surface.find_entities_filtered({force = "enemy", type = {"unit-spawner", "unit", "turret"}, area = area})) do
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
function Public.unit_groups_start_moving()
|
||||
for k, swarm in pairs(global.towny.swarms) do
|
||||
if swarm.group then
|
||||
|
@ -89,6 +89,16 @@ local function error_floaty(surface, position, msg)
|
||||
})
|
||||
end
|
||||
|
||||
local function is_town_market_nearby(entity)
|
||||
local area = {{entity.position.x - 48, entity.position.y - 48}, {entity.position.x + 48, entity.position.y + 48}}
|
||||
local markets = entity.surface.find_entities_filtered({name = "market", area = area})
|
||||
if not markets[1] then return false end
|
||||
for _, market in pairs(markets) do
|
||||
if market.force.index > 3 then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function Public.prevent_isolation(event)
|
||||
local entity = event.created_entity
|
||||
if not entity.valid then return end
|
||||
@ -128,10 +138,19 @@ end
|
||||
|
||||
local square_min_distance_to_spawn = 80 ^ 2
|
||||
|
||||
function Public.protect_spawn(event)
|
||||
function Public.restrictions(event)
|
||||
local entity = event.created_entity
|
||||
if not entity.valid then return end
|
||||
if entity.force.index == 1 then return end
|
||||
|
||||
if entity.force.index == 1 then
|
||||
if is_town_market_nearby(entity) then
|
||||
refund_item(event, event.stack.name)
|
||||
error_floaty(entity.surface, entity.position, "Building too close to a town center!")
|
||||
entity.destroy()
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not entity_type_whitelist[entity.type] then return end
|
||||
if entity.position.x ^ 2 + entity.position.y ^ 2 > square_min_distance_to_spawn then return end
|
||||
refund_item(event, event.stack.name)
|
||||
|
@ -15,6 +15,7 @@ Only the owner can banish members.
|
||||
Members can invite other players and teams.
|
||||
Members can leave their town with a piece of coal.
|
||||
The Market can only repaired manually.
|
||||
Outlanders can not build close to it.
|
||||
|
||||
All towns are opponents to each other, if no alliance is formed with a raw fish.
|
||||
If a center falls, the whole team will fall with it and all buildings will turn neutral and lootable.
|
||||
|
@ -41,6 +41,7 @@ local function on_player_respawned(event)
|
||||
if player.force.index ~= 1 then return end
|
||||
Team.set_player_to_outlander(player)
|
||||
Team.give_outlander_items(player)
|
||||
Biters.clear_spawn_for_player(player)
|
||||
end
|
||||
|
||||
local function on_player_used_capsule(event)
|
||||
@ -50,12 +51,12 @@ end
|
||||
local function on_built_entity(event)
|
||||
if Town_center.found(event) then return end
|
||||
if Building.prevent_isolation(event) then return end
|
||||
Building.protect_spawn(event)
|
||||
Building.restrictions(event)
|
||||
end
|
||||
|
||||
local function on_robot_built_entity(event)
|
||||
if Building.prevent_isolation(event) then return end
|
||||
Building.protect_spawn(event)
|
||||
Building.restrictions(event)
|
||||
end
|
||||
|
||||
local function on_player_built_tile(event)
|
||||
@ -135,10 +136,11 @@ end
|
||||
local tick_actions = {
|
||||
[60 * 5] = Team.update_town_chart_tags,
|
||||
[60 * 10] = Team.set_all_player_colors,
|
||||
[60 * 20] = Biters.wipe_units_out_of_evo_range,
|
||||
[60 * 25] = Biters.unit_groups_start_moving,
|
||||
[60 * 45] = Biters.validate_swarms,
|
||||
[60 * 50] = Biters.swarm,
|
||||
[60 * 55] = Biters.set_evolution,
|
||||
[60 * 55] = Biters.set_evolution,
|
||||
}
|
||||
|
||||
local function on_nth_tick(event)
|
||||
|
@ -311,7 +311,7 @@ function Public.kill_force(force_name)
|
||||
end
|
||||
|
||||
local player_force_disabled_recipes = {"lab", "automation-science-pack", "stone-brick"}
|
||||
local player_force_enabled_recipes = {"submachine-gun", "assembling-machine-1", "small-lamp", "shotgun", "shotgun-shell", "underground-belt", "splitter", "steel-plate", "car", "cargo-wagon", "constant-combinator", "engine-unit", "green-wire", "locomotive", "rail", "train-stop"}
|
||||
local player_force_enabled_recipes = {"submachine-gun", "assembling-machine-1", "small-lamp", "shotgun", "shotgun-shell", "underground-belt", "splitter", "steel-plate", "car", "cargo-wagon", "constant-combinator", "engine-unit", "green-wire", "locomotive", "rail", "train-stop", "arithmetic-combinator", "decider-combinator"}
|
||||
|
||||
function Public.setup_player_force()
|
||||
local p = game.permissions.create_group("outlander")
|
||||
|
Loading…
x
Reference in New Issue
Block a user