mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-08 00:39:30 +02:00
updates
This commit is contained in:
parent
b1032a0772
commit
9ee7acf841
@ -260,8 +260,22 @@ local function get_unit_group_position(surface, nearest_player_unit, spawner)
|
||||
return unit_group_position
|
||||
end
|
||||
|
||||
local function get_active_threat(biter_force_name)
|
||||
local active_threat = 0
|
||||
for unit_number, biter in pairs(global.active_biters[biter_force_name]) do
|
||||
if biter.entity then
|
||||
if biter.entity.valid then
|
||||
active_threat = active_threat + threat_values[biter.entity.name]
|
||||
end
|
||||
end
|
||||
end
|
||||
return active_threat
|
||||
end
|
||||
|
||||
local function create_attack_group(surface, force_name, biter_force_name)
|
||||
if global.bb_threat[biter_force_name] <= 0 then return false end
|
||||
local threat = global.bb_threat[biter_force_name]
|
||||
if get_active_threat(biter_force_name) > threat * 1.20 then return end
|
||||
if threat <= 0 then return false end
|
||||
|
||||
if bb_config.max_active_biters - get_active_biter_count(biter_force_name) < bb_config.max_group_size then
|
||||
if global.bb_debug then game.print("Not enough slots for biters for team " .. force_name .. ". Available slots: " .. bb_config.max_active_biters - get_active_biter_count(biter_force_name)) end
|
||||
|
@ -12,11 +12,11 @@ local balance_functions = {
|
||||
game.forces[force_name].set_ammo_damage_modifier("flamethrower", global.combat_balance[force_name].flamethrower_damage)
|
||||
end,
|
||||
["land-mine"] = function(force_name)
|
||||
if not global.combat_balance[force_name].land_mine then global.combat_balance[force_name].land_mine = -0.5 end
|
||||
if not global.combat_balance[force_name].land_mine then global.combat_balance[force_name].land_mine = -0.75 end
|
||||
game.forces[force_name].set_ammo_damage_modifier("landmine", global.combat_balance[force_name].land_mine)
|
||||
end,
|
||||
["stronger-explosives"] = function(force_name)
|
||||
if not global.combat_balance[force_name].land_mine then global.combat_balance[force_name].land_mine = -0.5 end
|
||||
if not global.combat_balance[force_name].land_mine then global.combat_balance[force_name].land_mine = -0.75 end
|
||||
global.combat_balance[force_name].land_mine = global.combat_balance[force_name].land_mine + 0.05
|
||||
game.forces[force_name].set_ammo_damage_modifier("landmine", global.combat_balance[force_name].land_mine)
|
||||
end,
|
||||
|
@ -65,7 +65,7 @@ local function get_random_close_spawner(surface, market)
|
||||
local size_of_spawners = #spawners
|
||||
local center = market.position
|
||||
local spawner = spawners[math_random(1, size_of_spawners)]
|
||||
for i = 1, 16, 1 do
|
||||
for i = 1, 64, 1 do
|
||||
local spawner_2 = spawners[math_random(1, size_of_spawners)]
|
||||
if (center.x - spawner_2.position.x) ^ 2 + (center.y - spawner_2.position.y) ^ 2 < (center.x - spawner.position.x) ^ 2 + (center.y - spawner.position.y) ^ 2 then
|
||||
spawner = spawner_2
|
||||
@ -81,7 +81,7 @@ function Public.swarm()
|
||||
local surface = market.surface
|
||||
local spawner = get_random_close_spawner(surface, market)
|
||||
if not spawner then return end
|
||||
local units = spawner.surface.find_enemy_units(spawner.position, 256, market.force)
|
||||
local units = spawner.surface.find_enemy_units(spawner.position, 160, market.force)
|
||||
if not units[1] then return end
|
||||
local unit_group_position = surface.find_non_colliding_position("market", units[1].position, 256, 1)
|
||||
if not unit_group_position then return end
|
||||
|
@ -126,7 +126,7 @@ function Public.prevent_isolation_landfill(event)
|
||||
end
|
||||
end
|
||||
|
||||
local square_min_distance_to_spawn = 96 ^ 2
|
||||
local square_min_distance_to_spawn = 80 ^ 2
|
||||
|
||||
function Public.protect_spawn(event)
|
||||
local entity = event.created_entity
|
||||
|
@ -6,6 +6,7 @@ local Market = require "modules.towny.market"
|
||||
local Team = require "modules.towny.team"
|
||||
local Town_center = require "modules.towny.town_center"
|
||||
require "modules.custom_death_messages"
|
||||
require "modules.flashlight_toggle_button"
|
||||
require "modules.global_chat_toggle"
|
||||
require "modules.biters_yield_coins"
|
||||
|
||||
|
@ -15,6 +15,13 @@ local upgrade_functions = {
|
||||
if force.character_inventory_slots_bonus > 100 then return end
|
||||
force.character_inventory_slots_bonus = force.character_inventory_slots_bonus + 5
|
||||
end,
|
||||
--Upgrade Backpack
|
||||
[3] = function(town_center)
|
||||
local force = town_center.market.force
|
||||
if town_center.upgrades.mining_prod >= 10 then return end
|
||||
town_center.upgrades.mining_prod = town_center.upgrades.mining_prod + 1
|
||||
force.mining_drill_productivity_bonus = force.mining_drill_productivity_bonus + 0.1
|
||||
end,
|
||||
}
|
||||
|
||||
local function clear_offers(market)
|
||||
@ -35,10 +42,16 @@ local function set_offers(town_center)
|
||||
special_offers[1] = {{{"computer", 1}}, "Maximum Health upgrades reached!"}
|
||||
end
|
||||
if force.character_inventory_slots_bonus <= 100 then
|
||||
special_offers[2] = {{{"coin", (force.character_inventory_slots_bonus / 5 + 1) * 35}}, "Upgrade Backpack +5 Slot"}
|
||||
special_offers[2] = {{{"coin", (force.character_inventory_slots_bonus / 5 + 1) * 50}}, "Upgrade Backpack +5 Slot"}
|
||||
else
|
||||
special_offers[2] = {{{"computer", 1}}, "Maximum Backpack upgrades reached!"}
|
||||
end
|
||||
if town_center.upgrades.mining_prod < 10 then
|
||||
special_offers[3] = {{{"coin", (town_center.upgrades.mining_prod + 1) * 400}}, "Upgrade Mining Productivity +10%"}
|
||||
else
|
||||
special_offers[3] = {{{"computer", 1}}, "Maximum Backpack upgrades reached!"}
|
||||
end
|
||||
|
||||
|
||||
local market_items = {}
|
||||
for _, v in pairs(special_offers) do
|
||||
|
@ -242,7 +242,7 @@ local function delete_chart_tag_for_all_forces(market)
|
||||
end
|
||||
end
|
||||
|
||||
local function add_chart_tag(force, market)
|
||||
function Public.add_chart_tag(force, market)
|
||||
local position = market.position
|
||||
local tags = force.find_chart_tags(market.surface, {{position.x - 0.1, position.y - 0.1}, {position.x + 0.1, position.y + 0.1}})
|
||||
if tags[1] then return end
|
||||
@ -256,7 +256,7 @@ function Public.update_town_chart_tags()
|
||||
local market = town_center.market
|
||||
for _, force in pairs(forces) do
|
||||
if force.is_chunk_visible(market.surface, town_center.chunk_position) then
|
||||
add_chart_tag(force, market)
|
||||
Public.add_chart_tag(force, market)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5,7 +5,7 @@ local math_random = math.random
|
||||
local table_insert = table.insert
|
||||
local math_floor = math.floor
|
||||
|
||||
local min_distance_to_spawn = 136
|
||||
local min_distance_to_spawn = 128
|
||||
local square_min_distance_to_spawn = min_distance_to_spawn ^ 2
|
||||
local town_radius = 27
|
||||
local radius_between_towns = 160
|
||||
@ -35,13 +35,17 @@ for v = c1, c2, c3 do
|
||||
end
|
||||
|
||||
local town_wall_vectors = {}
|
||||
for x = town_radius * -1, town_radius, 1 do
|
||||
for x = 2, town_radius, 1 do
|
||||
table_insert(town_wall_vectors, {x, town_radius})
|
||||
table_insert(town_wall_vectors, {x * -1, town_radius})
|
||||
table_insert(town_wall_vectors, {x, town_radius * -1})
|
||||
table_insert(town_wall_vectors, {x * -1, town_radius * -1})
|
||||
end
|
||||
for y = (town_radius - 1) * -1, town_radius - 1, 1 do
|
||||
for y = 2, town_radius - 1, 1 do
|
||||
table_insert(town_wall_vectors, {town_radius, y})
|
||||
table_insert(town_wall_vectors, {town_radius, y * -1})
|
||||
table_insert(town_wall_vectors, {town_radius * -1, y})
|
||||
table_insert(town_wall_vectors, {town_radius * -1, y * -1})
|
||||
end
|
||||
|
||||
local gate_vectors_horizontal = {}
|
||||
@ -110,6 +114,15 @@ local starter_supplies = {
|
||||
{name = "gun-turret", count = 2},
|
||||
}
|
||||
|
||||
local function count_nearby_ore(surface, position, ore_name)
|
||||
local count = 0
|
||||
local r = town_radius + 8
|
||||
for _, e in pairs(surface.find_entities_filtered({area = {{position.x - r, position.y - r}, {position.x + r, position.y + r}}, force = "neutral", name = ore_name})) do
|
||||
count = count + e.amount
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
local function draw_town_spawn(player_name)
|
||||
local market = global.towny.town_centers[player_name].market
|
||||
local position = market.position
|
||||
@ -125,20 +138,23 @@ local function draw_town_spawn(player_name)
|
||||
|
||||
for _, vector in pairs(gate_vectors_horizontal) do
|
||||
local p = {position.x + vector[1], position.y + vector[2]}
|
||||
if surface.can_place_entity({name = "gate", position = p, force = player_name}) then
|
||||
p = surface.find_non_colliding_position("gate", p, 64, 1)
|
||||
if p then
|
||||
surface.create_entity({name = "gate", position = p, force = player_name, direction = 2})
|
||||
end
|
||||
end
|
||||
for _, vector in pairs(gate_vectors_vertical) do
|
||||
local p = {position.x + vector[1], position.y + vector[2]}
|
||||
if surface.can_place_entity({name = "gate", position = p, force = player_name}) then
|
||||
p = surface.find_non_colliding_position("gate", p, 64, 1)
|
||||
if p then
|
||||
surface.create_entity({name = "gate", position = p, force = player_name, direction = 0})
|
||||
end
|
||||
end
|
||||
|
||||
for _, vector in pairs(town_wall_vectors) do
|
||||
local p = {position.x + vector[1], position.y + vector[2]}
|
||||
if surface.can_place_entity({name = "stone-wall", position = p, force = player_name}) then
|
||||
local p = {position.x + vector[1], position.y + vector[2]}
|
||||
p = surface.find_non_colliding_position("stone-wall", p, 64, 1)
|
||||
if p then
|
||||
surface.create_entity({name = "stone-wall", position = p, force = player_name})
|
||||
end
|
||||
end
|
||||
@ -147,11 +163,13 @@ local function draw_town_spawn(player_name)
|
||||
table.shuffle_table(ores)
|
||||
|
||||
for i = 1, 4, 1 do
|
||||
for _, vector in pairs(resource_vectors[i]) do
|
||||
local p = {position.x + vector[1], position.y + vector[2]}
|
||||
p = surface.find_non_colliding_position(ores[i], p, 64, 1)
|
||||
if p then
|
||||
surface.create_entity({name = ores[i], position = p, amount = ore_amount})
|
||||
if count_nearby_ore(surface, position, ores[i]) < 200000 then
|
||||
for _, vector in pairs(resource_vectors[i]) do
|
||||
local p = {position.x + vector[1], position.y + vector[2]}
|
||||
p = surface.find_non_colliding_position(ores[i], p, 64, 1)
|
||||
if p then
|
||||
surface.create_entity({name = ores[i], position = p, amount = ore_amount})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -191,12 +209,14 @@ local function draw_town_spawn(player_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, vector in pairs(additional_resource_vectors[vector_indexes[3]]) do
|
||||
local p = {position.x + vector[1], position.y + vector[2]}
|
||||
p = surface.find_non_colliding_position("uranium-ore", p, 64, 1)
|
||||
if p then
|
||||
surface.create_entity({name = "uranium-ore", position = p, amount = ore_amount})
|
||||
end
|
||||
if count_nearby_ore(surface, position, "uranium-ore") < 100000 then
|
||||
for _, vector in pairs(additional_resource_vectors[vector_indexes[3]]) do
|
||||
local p = {position.x + vector[1], position.y + vector[2]}
|
||||
p = surface.find_non_colliding_position("uranium-ore", p, 64, 1)
|
||||
if p then
|
||||
surface.create_entity({name = "uranium-ore", position = p, amount = ore_amount * 2})
|
||||
end
|
||||
end
|
||||
end
|
||||
local vectors = additional_resource_vectors[vector_indexes[4]]
|
||||
for _ = 1, 3, 1 do
|
||||
@ -354,6 +374,8 @@ function Public.found(event)
|
||||
town_center.health = town_center.max_health
|
||||
town_center.color = get_color()
|
||||
town_center.research_counter = 1
|
||||
town_center.upgrades = {}
|
||||
town_center.upgrades.mining_prod = 0
|
||||
|
||||
town_center.health_text = rendering.draw_text{
|
||||
text = "HP: " .. town_center.health .. " / " .. town_center.max_health,
|
||||
@ -386,6 +408,7 @@ function Public.found(event)
|
||||
draw_town_spawn(player_name)
|
||||
|
||||
Team.add_player_to_town(player, town_center)
|
||||
Team.add_chart_tag(game.forces.player, town_center.market)
|
||||
|
||||
local force = player.force
|
||||
force.set_spawn_position({x = town_center.market.position.x, y = town_center.market.position.y + 4}, surface)
|
||||
|
Loading…
Reference in New Issue
Block a user