1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00
ComfyFactorio/maps/mountain_fortress_v2/main.lua

138 lines
4.8 KiB
Lua
Raw Normal View History

2019-10-07 09:48:17 +02:00
-- Mountain digger fortress, protect the locomotive! -- by MewMew
2019-10-06 18:16:32 +02:00
2019-10-07 09:48:17 +02:00
require "modules.biter_evasion_hp_increaser"
2019-10-07 01:46:26 +02:00
require "modules.wave_defense"
2019-10-07 04:37:23 +02:00
--require "modules.dense_rocks"
2019-10-07 16:40:52 +02:00
require "functions.soft_reset"
2019-10-07 22:40:05 +02:00
--require "modules.dynamic_player_spawn"
2019-10-07 09:48:17 +02:00
require "modules.biters_yield_coins"
2019-10-07 22:40:05 +02:00
require "modules.no_deconstruction_of_neutral_entities"
2019-10-07 09:48:17 +02:00
require "modules.rocks_broken_paint_tiles"
require "modules.rocks_heal_over_time"
require "modules.rocks_yield_ore_veins"
require "modules.rocks_yield_ore"
require "modules.spawners_contain_biters"
require "modules.map_info"
require "modules.rpg"
2019-10-07 01:46:26 +02:00
2019-10-07 09:48:17 +02:00
global.map_info = {}
global.map_info.main_caption = "Mountain Fortress"
2019-10-07 22:40:05 +02:00
global.map_info.sub_caption = " ..diggy diggy choo choo.."
2019-10-07 09:48:17 +02:00
global.map_info.text = [[
The biters have catched the scent of fish in the cargo wagon.
Guide the choo into the mountain and protect it as long as possible!
This however will not be an easy task,
since their strength and resistance increases constantly over time.
As you dig, you will encounter black bedrock that is just too solid for your pickaxe.
Some explosives could even break through the impassable dark rock.
All they need is a container and a well aimed shot.
]]
require "maps.mountain_fortress_v2.market"
require "maps.mountain_fortress_v2.treasure"
require "maps.mountain_fortress_v2.terrain"
require "maps.mountain_fortress_v2.locomotive"
require "maps.mountain_fortress_v2.explosives"
2019-10-07 22:40:05 +02:00
require "maps.mountain_fortress_v2.flamethrower_nerf"
2019-10-06 18:16:32 +02:00
2019-10-07 16:40:52 +02:00
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16, ['wood'] = 16}
local function get_gen_settings()
2019-10-06 18:16:32 +02:00
local map = {
["seed"] = math.random(1, 1000000),
2019-10-07 17:37:57 +02:00
["water"] = 0.001,
2019-10-06 18:16:32 +02:00
["starting_area"] = 1,
2019-10-07 22:40:05 +02:00
["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
2019-10-07 09:48:17 +02:00
["default_enable_all_autoplace_controls"] = true,
2019-10-06 18:16:32 +02:00
["autoplace_settings"] = {
["entity"] = {treat_missing_as_default = false},
2019-10-07 09:48:17 +02:00
["tile"] = {treat_missing_as_default = true},
["decorative"] = {treat_missing_as_default = true},
2019-10-06 18:16:32 +02:00
},
}
2019-10-07 16:40:52 +02:00
return map
end
function reset_map()
global.chunk_queue = {}
if not global.active_surface then
global.active_surface = game.create_surface("mountain_fortress", get_gen_settings())
2019-10-07 17:37:57 +02:00
else
game.forces.player.set_spawn_position({-2, 16}, global.active_surface)
2019-10-07 16:40:52 +02:00
global.active_surface = soft_reset_map(global.active_surface, get_gen_settings(), starting_items)
end
global.active_surface.request_to_generate_chunks({0,0}, 2)
global.active_surface.force_generate_chunk_requests()
game.map_settings.enemy_evolution.destroy_factor = 0
game.map_settings.enemy_evolution.pollution_factor = 0
game.map_settings.enemy_evolution.time_factor = 0
game.map_settings.enemy_expansion.enabled = true
game.map_settings.enemy_expansion.max_expansion_cooldown = 1800
game.map_settings.enemy_expansion.min_expansion_cooldown = 1800
game.map_settings.enemy_expansion.settler_group_max_size = 16
game.map_settings.enemy_expansion.settler_group_min_size = 32
game.map_settings.pollution.enabled = false
game.forces.player.technologies["steel-axe"].researched = true
game.forces.player.technologies["railway"].researched = true
game.forces.player.set_spawn_position({-2, 16}, global.active_surface)
locomotive_spawn(global.active_surface, {x = 0, y = 16})
reset_wave_defense()
global.wave_defense.surface = global.active_surface
global.wave_defense.target = global.locomotive_cargo
if global.rpg then rpg_reset_all_players() end
2019-10-06 18:16:32 +02:00
end
2019-10-07 04:37:23 +02:00
local function on_entity_died(event)
if not event.entity.valid then return end
2019-10-07 17:37:57 +02:00
if event.entity == global.locomotive_cargo then
game.print("The cargo was destroyed!")
reset_map()
2019-10-07 09:48:17 +02:00
for _, player in pairs(game.connected_players) do
player.play_sound{path="utility/game_lost", volume_modifier=0.75}
end
--global.wave_defense.game_lost = true
2019-10-07 04:37:23 +02:00
return
end
end
2019-10-07 07:19:41 +02:00
local function on_entity_damaged(event)
if not event.entity.valid then return end
if event.entity.force.index ~= 1 then return end
if event.entity == global.locomotive or event.entity == global.locomotive_cargo then
if event.cause then
if event.cause.force.index == 2 then
return
end
end
event.entity.health = event.entity.health + event.final_damage_amount
end
end
2019-10-07 16:40:52 +02:00
local function on_player_joined_game(event)
2019-10-06 18:16:32 +02:00
local player = game.players[event.player_index]
if player.online_time == 0 then
2019-10-07 16:40:52 +02:00
player.teleport(global.active_surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(global.active_surface), 3, 0.5), global.active_surface)
for item, amount in pairs(starting_items) do
player.insert({name = item, count = amount})
end
2019-10-06 18:16:32 +02:00
end
end
local function on_init(surface)
2019-10-07 16:40:52 +02:00
reset_map()
2019-10-06 18:16:32 +02:00
end
local event = require 'utils.event'
event.on_init(on_init)
2019-10-07 07:19:41 +02:00
event.add(defines.events.on_entity_damaged, on_entity_damaged)
2019-10-07 04:37:23 +02:00
event.add(defines.events.on_entity_died, on_entity_died)
2019-10-06 18:16:32 +02:00
event.add(defines.events.on_player_joined_game, on_player_joined_game)