mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-04 00:15:45 +02:00
mountain_fortress map update
This commit is contained in:
parent
f372b8c381
commit
6a5fd055e1
@ -3,9 +3,9 @@
|
||||
local event = require 'utils.event'
|
||||
|
||||
local biter_values = {
|
||||
["medium-biter"] = {"blood-explosion-big", 15, 1},
|
||||
["big-biter"] = {"blood-explosion-huge", 30, 1.5},
|
||||
["behemoth-biter"] = {"blood-explosion-huge", 45, 2}
|
||||
["medium-biter"] = {"blood-explosion-big", 25, 1.5},
|
||||
["big-biter"] = {"blood-explosion-huge", 50, 2},
|
||||
["behemoth-biter"] = {"blood-explosion-huge", 75, 2.5}
|
||||
}
|
||||
|
||||
local function damage_entities_in_radius(surface, position, radius, damage)
|
||||
@ -25,7 +25,8 @@ local function damage_entities_in_radius(surface, position, radius, damage)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local function on_entity_died(event)
|
||||
if not event.entity.valid then return end
|
||||
if biter_values[event.entity.name] then
|
||||
local entity = event.entity
|
||||
entity.surface.create_entity({name = biter_values[entity.name][1], position = entity.position})
|
||||
|
31
maps/modules/rocks_regenerate_health.lua
Normal file
31
maps/modules/rocks_regenerate_health.lua
Normal file
@ -0,0 +1,31 @@
|
||||
---- WIP!
|
||||
|
||||
local event = require 'utils.event'
|
||||
|
||||
local healing_amount = {
|
||||
["rock-big"] = 4,
|
||||
["sand-rock-big"] = 4,
|
||||
["rock-huge"] = 16
|
||||
}
|
||||
|
||||
local function heal_rocks()
|
||||
for key, rock in pairs(global.damaged_rocks) do
|
||||
if rock.last_damage + 300 < game.tick then
|
||||
if rock.entity.valid then
|
||||
rock.entity.health = rock.entity.health + healing_amount[rock.entity.name]
|
||||
if rock.entity.prototype.max_health == rock.entity.health then global.damaged_rocks[key] = nil end
|
||||
else
|
||||
global.damaged_rocks[key] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
if not event.entity.valid then return end
|
||||
if event.entity.type == "simple-entity" then
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
@ -31,15 +31,18 @@ end
|
||||
|
||||
local function get_amount(entity)
|
||||
local distance_to_center = math.sqrt(entity.position.x^2 + entity.position.y^2)
|
||||
local amount = 25 + (distance_to_center * 0.2)
|
||||
if amount > 200 then amount = 200 end
|
||||
local amount = 33 + (distance_to_center * 0.33)
|
||||
if amount > 150 then amount = 150 end
|
||||
amount = rock_yield[entity.name] * amount
|
||||
amount = math.random(math.ceil(amount * 0.5), math.ceil(amount * 1.5))
|
||||
return amount
|
||||
end
|
||||
|
||||
local coords = {{x = 0, y = 0},{x = -1, y = -1},{x = 1, y = -1},{x = 0, y = -1},{x = -1, y = 0},{x = -1, y = 1},{x = 0, y = 1},{x = 1, y = 1},{x = 1, y = 0}}
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then return end
|
||||
if rock_yield[entity.name] then
|
||||
event.buffer.clear()
|
||||
local amount = get_amount(entity)
|
||||
@ -48,5 +51,20 @@ local function on_player_mined_entity(event)
|
||||
entity.surface.create_entity({name = "flying-text", position = entity.position, text = amount .. " " .. texts[ore][1], color = texts[ore][2]})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function on_entity_died(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then return end
|
||||
if rock_yield[entity.name] then
|
||||
local surface = entity.surface
|
||||
local amount = get_amount(entity)
|
||||
amount = math.ceil(amount * 0.2)
|
||||
local ore = ore_raffle[math.random(1, #ore_raffle)]
|
||||
local pos = {entity.position.x, entity.position.y}
|
||||
entity.destroy()
|
||||
surface.spill_item_stack(pos,{name = ore, count = amount}, true)
|
||||
end
|
||||
end
|
||||
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
||||
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
74
maps/modules/rocks_yield_ore_veins.lua
Normal file
74
maps/modules/rocks_yield_ore_veins.lua
Normal file
@ -0,0 +1,74 @@
|
||||
local event = require 'utils.event'
|
||||
local math_random = math.random
|
||||
|
||||
local valid_entities = {
|
||||
["rock-big"] = true,
|
||||
["rock-huge"] = true,
|
||||
["sand-rock-big"] = true
|
||||
}
|
||||
|
||||
local rock_mining_chance_weights = {
|
||||
{"iron-ore", 25},
|
||||
{"copper-ore",18},
|
||||
{"coal",14},
|
||||
{"stone",10},
|
||||
{"uranium-ore",3}
|
||||
}
|
||||
|
||||
local ore_raffle = {}
|
||||
for _, t in pairs (rock_mining_chance_weights) do
|
||||
for x = 1, t[2], 1 do
|
||||
table.insert(ore_raffle, t[1])
|
||||
end
|
||||
end
|
||||
|
||||
local size_raffle = {
|
||||
{"huge", 33, 42},
|
||||
{"big", 17, 32},
|
||||
{"", 8, 16},
|
||||
{"tiny", 3, 7}
|
||||
}
|
||||
|
||||
local ore_prints = {
|
||||
["coal"] = {"dark", "Coal"},
|
||||
["iron-ore"] = {"shiny", "Iron"},
|
||||
["copper-ore"] = {"glimmering", "Copper"},
|
||||
["uranium-ore"] = {"glowing", "Uranium"},
|
||||
["stone"] = {"solid", "Stone"}
|
||||
}
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then return end
|
||||
if valid_entities[entity.name] then
|
||||
if math_random(1,64) == 1 then
|
||||
local player = game.players[event.player_index]
|
||||
local p = {x = entity.position.x, y = entity.position.y}
|
||||
local tile_distance_to_center = p.x^2 + p.y^2
|
||||
local radius = 32
|
||||
if entity.surface.count_entities_filtered{area={{p.x - radius,p.y - radius},{p.x + radius,p.y + radius}}, type="resource", limit=1} == 0 then
|
||||
local size = size_raffle[math_random(1, #size_raffle)]
|
||||
local ore = ore_raffle[math_random(1, #ore_raffle)]
|
||||
player.print("You notice something " .. ore_prints[ore][1] .. " underneath the rubble covered floor. It's a " .. size[1] .. " vein of " .. ore_prints[ore][2] .. "!!", { r=0.98, g=0.66, b=0.22})
|
||||
tile_distance_to_center = math.sqrt(tile_distance_to_center)
|
||||
local ore_entities_placed = 0
|
||||
local modifier_raffle = {{0,-1},{-1,0},{1,0},{0,1}}
|
||||
while ore_entities_placed < math_random(size[2],size[3]) do
|
||||
local a = math.ceil((math_random(tile_distance_to_center*4, tile_distance_to_center*5)) / 1 + ore_entities_placed * 0.5, 0)
|
||||
for x = 1, 150, 1 do
|
||||
local m = modifier_raffle[math_random(1,#modifier_raffle)]
|
||||
local pos = {x = p.x + m[1], y = p.y + m[2]}
|
||||
if entity.surface.can_place_entity({name=ore, position=pos, amount=a}) then
|
||||
entity.surface.create_entity {name=ore, position=pos, amount=a}
|
||||
p = pos
|
||||
break
|
||||
end
|
||||
end
|
||||
ore_entities_placed = ore_entities_placed + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
@ -17,6 +17,7 @@ local biter_building_inhabitants = {
|
||||
}
|
||||
|
||||
local function on_entity_died(event)
|
||||
if not event.entity.valid then return end
|
||||
if event.entity.type ~= "unit-spawner" then return end
|
||||
local e = math.ceil(game.forces.enemy.evolution_factor*10, 0)
|
||||
for _, t in pairs (biter_building_inhabitants[e]) do
|
||||
|
@ -9,6 +9,7 @@ local biter_fragmentation = {
|
||||
}
|
||||
|
||||
local function on_entity_died(event)
|
||||
if not event.entity.valid then return end
|
||||
if biter_fragmentation[event.entity.name] then
|
||||
local entity = event.entity
|
||||
local amount = 1
|
||||
|
@ -4,6 +4,7 @@ require "maps.modules.satellite_score"
|
||||
require "maps.modules.dynamic_landfill"
|
||||
require "maps.modules.dynamic_player_spawn"
|
||||
require "maps.modules.rocks_yield_ore"
|
||||
require "maps.modules.rocks_yield_ore_veins"
|
||||
require "maps.modules.fluids_are_explosive"
|
||||
require "maps.modules.explosives_are_explosive"
|
||||
require "maps.modules.explosive_biters"
|
||||
@ -69,14 +70,19 @@ local function on_player_joined_game(event)
|
||||
local radius = 256
|
||||
game.forces.player.chart(surface, {{x = -1 * radius, y = -1 * radius}, {x = radius, y = radius}})
|
||||
|
||||
--game.map_settings.enemy_expansion.enabled = true
|
||||
--game.map_settings.enemy_evolution.destroy_factor = 0
|
||||
--game.map_settings.enemy_evolution.time_factor = 0
|
||||
--game.map_settings.enemy_evolution.pollution_factor = 0
|
||||
--game.map_settings.pollution.enabled = true
|
||||
|
||||
game.map_settings.pollution.enabled = true
|
||||
game.map_settings.enemy_expansion.enabled = true
|
||||
game.map_settings.enemy_evolution.destroy_factor = 0.004
|
||||
game.map_settings.enemy_evolution.time_factor = 0.00001
|
||||
game.map_settings.enemy_evolution.pollution_factor = 0.00003
|
||||
game.map_settings.enemy_expansion.max_expansion_distance = 15
|
||||
game.map_settings.enemy_expansion.settler_group_min_size = 15
|
||||
game.map_settings.enemy_expansion.settler_group_max_size = 30
|
||||
game.map_settings.enemy_expansion.min_expansion_cooldown = 3600
|
||||
game.map_settings.enemy_expansion.max_expansion_cooldown = 3600
|
||||
|
||||
surface.ticks_per_day = surface.ticks_per_day * 2
|
||||
game.forces.player.manual_mining_speed_modifier = 2
|
||||
game.forces.player.manual_mining_speed_modifier = 1.75
|
||||
|
||||
global.surface_init_done = true
|
||||
end
|
||||
@ -122,7 +128,7 @@ local function generate_north_chunk(event, surface)
|
||||
e.destroy()
|
||||
end
|
||||
|
||||
if left_top.y < -512 then
|
||||
if left_top.y < -480 then
|
||||
local tiles_to_set = {}
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
@ -152,8 +158,13 @@ local function generate_north_chunk(event, surface)
|
||||
if rock_amount < 1 then break end
|
||||
end
|
||||
|
||||
local waters = {"water-green", "deepwater-green"}
|
||||
if math_random(1,7) == 1 then
|
||||
map_functions.draw_noise_tile_circle(tile_positions[math_random(1, #tile_positions)], "deepwater-green", surface, math_random(2, 6))
|
||||
local pos = tile_positions[math_random(1, #tile_positions)]
|
||||
map_functions.draw_noise_tile_circle(pos, waters[math_random(1, #waters)], surface, math_random(2, 6))
|
||||
for x = 1, math_random(2,7), 1 do
|
||||
surface.create_entity({name = "fish", position = pos})
|
||||
end
|
||||
end
|
||||
|
||||
if math_random(1,20) == 1 then
|
||||
@ -170,11 +181,25 @@ local function generate_north_chunk(event, surface)
|
||||
end
|
||||
|
||||
local function generate_south_chunk(event, surface)
|
||||
for _, e in pairs(surface.find_entities_filtered({area = event.area})) do
|
||||
e.destroy()
|
||||
end
|
||||
|
||||
local left_top = event.area.left_top
|
||||
|
||||
if left_top.y > 32 then
|
||||
for _, e in pairs(surface.find_entities_filtered({area = event.area})) do
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
if left_top.y > 480 then
|
||||
local tiles_to_set = {}
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
insert(tiles_to_set, {name = "out-of-map", position = {x = left_top.x + x, y = left_top.y + y}})
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles_to_set, true)
|
||||
return
|
||||
end
|
||||
|
||||
local current_depth = math.abs(left_top.y) - 32
|
||||
|
||||
local i = math.ceil(current_depth / 32)
|
||||
@ -247,7 +272,7 @@ local function on_chunk_generated(event)
|
||||
|
||||
replace_spawn_water(surface)
|
||||
|
||||
if left_top.y < -32 then
|
||||
if left_top.y < 0 then
|
||||
generate_north_chunk(event, surface)
|
||||
end
|
||||
if left_top.y > 0 then
|
||||
@ -255,6 +280,36 @@ local function on_chunk_generated(event)
|
||||
end
|
||||
end
|
||||
|
||||
local coords = {{x = 0, y = 0},{x = -1, y = -1},{x = 1, y = -1},{x = 0, y = -1},{x = -1, y = 0},{x = -1, y = 1},{x = 0, y = 1},{x = 1, y = 1},{x = 1, y = 0}}
|
||||
local function on_player_mined_entity(event)
|
||||
local entity = event.entity
|
||||
if entity.type == "simple-entity" then
|
||||
local tiles = {}
|
||||
for _, p in pairs(coords) do
|
||||
local pos = {x = entity.position.x + p.x, y = entity.position.y + p.y}
|
||||
local tile = entity.surface.get_tile(pos)
|
||||
if not tile.collides_with("player-layer") then
|
||||
insert(tiles, {name = "dirt-3", position = pos})
|
||||
end
|
||||
end
|
||||
if #tiles == 0 then return end
|
||||
entity.surface.set_tiles(tiles, true)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then return end
|
||||
if entity.type == "simple-entity" then
|
||||
if event.force.name == "player" then
|
||||
event.entity.health = event.entity.health + (event.final_damage_amount * 0.5)
|
||||
if event.entity.health <= event.final_damage_amount then
|
||||
event.entity.die("player")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local disabled_for_deconstruction = {
|
||||
["fish"] = true,
|
||||
["rock-huge"] = true,
|
||||
@ -268,6 +323,8 @@ local function on_marked_for_deconstruction(event)
|
||||
end
|
||||
end
|
||||
|
||||
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
||||
event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||
event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
|
||||
event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
Loading…
Reference in New Issue
Block a user