Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
MewMew committed Apr 29, 2020
1 parent 2cef6ef commit 17d2144
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 36 deletions.
35 changes: 16 additions & 19 deletions maps/mountain_fortress_v2/main.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
-- Mountain digger fortress, protect the cargo wagon! -- by MewMew

--enable / disable collapsing of the map
global.collapse_enabled = true
global.offline_loot = true
local darkness = false

require "player_modifiers"
require "functions.soft_reset"
require "functions.basic_markets"

local Collapse = require "modules.collapse"
local RPG = require "modules.rpg"
require "modules.wave_defense.main"
require "modules.biters_yield_coins"
Expand All @@ -21,7 +20,6 @@ require "modules.rocks_heal_over_time"
require "modules.rocks_yield_ore_veins"
local level_depth = require "maps.mountain_fortress_v2.terrain"
local Immersive_cargo_wagons = require "modules.immersive_cargo_wagons.main"
local Collapse = require "maps.mountain_fortress_v2.collapse"
require "maps.mountain_fortress_v2.flamethrower_nerf"
local BiterRolls = require "modules.wave_defense.biter_rolls"
local BiterHealthBooster = require "modules.biter_health_booster"
Expand All @@ -45,17 +43,16 @@ local treasure_chest_messages = {
local function set_difficulty()
local wave_defense_table = WD.get_table()
local player_count = #game.connected_players
if player_count > 24 then player_count = 24 end


wave_defense_table.max_active_biters = 1024

-- threat gain / wave
wave_defense_table.threat_gain_multiplier = 2 + player_count * 0.1

--1 additional map collapse tile / 8 players in game, with too high threat, the collapse speeds up.
local speed = 1 + math.floor(player_count * 0.125) + math.floor(wave_defense_table.threat / 100000)
if speed > 10 then speed = 10 end
global.map_collapse.speed = speed
local amount = player_count * 0.25 + 21
amount = math.floor(amount)
if amount > 10 then amount = 10 end
Collapse.set_amount(amount)

--20 Players for fastest wave_interval
wave_defense_table.wave_interval = 3600 - player_count * 90
Expand All @@ -64,7 +61,7 @@ end

function Public.reset_map()
Immersive_cargo_wagons.reset()

for _,player in pairs(game.players) do
if player.controller_type == defines.controllers.editor then player.toggle_map_editor() end
end
Expand Down Expand Up @@ -138,8 +135,14 @@ function Public.reset_map()
wave_defense_table.nest_building_density = 32
wave_defense_table.game_lost = false
game.reset_time_played()

Collapse.init()

Collapse.set_kill_entities(false)
Collapse.set_speed(2)
Collapse.set_amount(1)
Collapse.set_max_line_size(level_depth)
Collapse.set_surface(surface)
Collapse.set_position({0, 130})
Collapse.set_direction("north")

RPG.rpg_reset_all_players()

Expand Down Expand Up @@ -434,15 +437,11 @@ local function tick()
if tick % 1800 == 0 then
Locomotive.set_player_spawn_and_refill_fish()
local surface = game.surfaces[global.active_surface_index]
local last_position = global.map_collapse.last_position
local position = surface.find_non_colliding_position("stone-furnace", {last_position.x, last_position.y - 32}, 128, 4)
local position = surface.find_non_colliding_position("stone-furnace", Collapse.get_position(), 128, 1)
if position then
local wave_defense_table = WD.get_table()
wave_defense_table.spawn_position = position
end
-- if tick % 216000 == 0 then
-- Collapse.delete_out_of_map_chunks(surface)
-- end
if global.offline_loot then
offline_players()
end
Expand All @@ -456,8 +455,6 @@ local function tick()
end
Locomotive.fish_tag()
end
if not global.collapse_enabled then return end
Collapse.process()
end

local function on_init()
Expand Down
40 changes: 23 additions & 17 deletions modules/collapse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ local function set_collapse_tiles()
if not collapse.tiles then return end
collapse.size_of_tiles = #collapse.tiles
if collapse.size_of_tiles > 0 then table_shuffle_table(collapse.tiles) end
collapse.current_position = {x = collapse.current_position.x + collapse.vector[1], y = collapse.current_position.y + collapse.vector[2]}
collapse.position = {x = collapse.position.x + collapse.vector[1], y = collapse.position.y + collapse.vector[2]}
local v = collapse.vector
local area = collapse.area
collapse.area = {{area[1][1] + v[1], area[1][2] + v[2]}, {area[2][1] + v[1], area[2][2] + v[2]}}
Expand All @@ -72,9 +72,11 @@ local function progress()
local tile = tiles[collapse.size_of_tiles]
if not tile then collapse.tiles = nil return end
collapse.size_of_tiles = collapse.size_of_tiles - 1
local position = {tile.position.x + 0.5, tile.position.y + 0.5}
for _, e in pairs(surface.find_entities_filtered({area = {{position[1] - 2, position[2] - 2}, {position[1] + 2, position[2] + 2}}})) do
if e.valid and e.health then e.die() end
if collapse.kill then
local position = {tile.position.x + 0.5, tile.position.y + 0.5}
for _, e in pairs(surface.find_entities_filtered({area = {{position[1] - 2, position[2] - 2}, {position[1] + 2, position[2] + 2}}})) do
if e.valid and e.health then e.die() end
end
end
surface.set_tiles({{name = "out-of-map", position = tile.position}}, true)
end
Expand All @@ -89,13 +91,13 @@ end

function Public.set_direction(direction)
if not directions[direction] then print_debug(11) return end
directions[direction](collapse.current_position)
directions[direction](collapse.position)
end

function Public.set_speed(speed)
if not speed then print_debug(8) return end
speed = math_floor(speed)
if speed < 0 then speed = 0 end
if speed < 1 then speed = 1 end
collapse.speed = speed
end

Expand All @@ -106,7 +108,7 @@ function Public.set_amount(amount)
collapse.amount = amount
end

function Public.set_start_position(position)
function Public.set_position(position)
if not position then print_debug(4) return end
if not position.x and not position[1] then print_debug(5) return end
if not position.y and not position[2] then print_debug(6) return end
Expand All @@ -119,26 +121,30 @@ function Public.set_start_position(position)
collapse.position = {x = x, y = y}
end

function Public.get_position()
return collapse.position
end

function Public.set_max_line_size(size)
if not size then print_debug(22) return end
size = math_floor(size)
if size <= 0 then print_debug(21) return end
collapse.max_line_size = size
end

function Public.reset()
if not collapse.surface then Public.set_surface(game.surfaces.nauvis) end
if not collapse.position then Public.set_start_position({0, 32}) end
collapse.current_position = {x = collapse.position.x, y = collapse.position.y}
if not collapse.max_line_size then Public.set_max_line_size(256) end
if not collapse.vector then Public.set_direction("north") end
collapse.tiles = nil
collapse.speed = 1
collapse.amount = 8
function Public.set_kill_entities(a)
collapse.kill = a
end

local function on_init()
Public.reset()
Public.set_surface(game.surfaces.nauvis)
Public.set_position({0, 32})
Public.set_max_line_size(256)
Public.set_direction("north")
Public.set_kill_entities(true)
collapse.tiles = nil
collapse.speed = 1
collapse.amount = 8
end

local function on_tick()
Expand Down

0 comments on commit 17d2144

Please sign in to comment.