diff --git a/maps/island_troopers/enemies.lua b/maps/island_troopers/enemies.lua index b9f64a9f..65d7b2a1 100644 --- a/maps/island_troopers/enemies.lua +++ b/maps/island_troopers/enemies.lua @@ -45,13 +45,13 @@ function set_biter_chances(level) ["behemoth-biter"] = 0, ["behemoth-spitter"] = 0, } - if level > 100 then - global.biter_chances["big-biter"] = (level - 100) * 25 - global.biter_chances["big-spitter"] = (level - 100) * 25 + if level > 75 then + global.biter_chances["big-biter"] = (level - 75) * 25 + global.biter_chances["big-spitter"] = (level - 75) * 25 end - if level > 200 then - global.biter_chances["behemoth-biter"] = (level - 200) * 50 - global.biter_chances["behemoth-spitter"] = (level - 200) * 50 + if level > 150 then + global.biter_chances["behemoth-biter"] = (level - 150) * 50 + global.biter_chances["behemoth-spitter"] = (level - 150) * 50 end for k, v in pairs(global.biter_chances) do if global.biter_chances[k] < 0 then global.biter_chances[k] = 0 end @@ -65,13 +65,13 @@ function set_worm_chances(level) ["big-worm-turret"] = 0, ["behemoth-worm-turret"] = 0, } - if level > 100 then - global.worm_chances["big-worm-turret"] = (level - 100) * 25 - global.worm_chances["big-worm-turret"] = (level - 100) * 25 + if level > 75 then + global.worm_chances["big-worm-turret"] = (level - 75) * 25 + global.worm_chances["big-worm-turret"] = (level - 75) * 25 end - if level > 200 then - global.worm_chances["behemoth-worm-turret"] = (level - 200) * 50 - global.worm_chances["behemoth-worm-turret"] = (level - 200) * 50 + if level > 150 then + global.worm_chances["behemoth-worm-turret"] = (level - 150) * 50 + global.worm_chances["behemoth-worm-turret"] = (level - 150) * 50 end for k, v in pairs(global.worm_chances) do if global.worm_chances[k] < 0 then global.worm_chances[k] = 0 end @@ -79,17 +79,18 @@ function set_worm_chances(level) end -local function is_boss_stage() +local function is_boss_stage() if global.current_stage == 1 then return false end - if global.current_stage % 5 == 0 then return true end if global.current_stage == #global.stages - 1 then return true end + if #global.stages < 8 then return false end + if global.current_stage == math.floor(#global.stages * 0.5) then return true end end function add_enemies(surface, tiles) table.shuffle_table(tiles) if is_boss_stage() then - set_biter_chances(global.current_level + 100) + set_biter_chances(math.floor((global.current_level * difficulties_votes[global.difficulty_vote_index].strength_modifier) + 65)) local boss_count = math.random(1, math.floor(global.current_level * 0.5) + 1) if boss_count > 16 then boss_count = 16 end for k, tile in pairs(tiles) do @@ -97,7 +98,7 @@ function add_enemies(surface, tiles) local unit = surface.create_entity({name = get_biter(), position = tile.position, force = "enemy"}) unit.ai_settings.allow_destroy_when_commands_fail = false unit.ai_settings.allow_try_return_to_spawner = false - add_boss_unit(unit, global.current_level * difficulties_votes[global.difficulty_vote_index].boss_modifier, 0.55) + add_boss_unit(unit, (1.5 + global.current_level * 0.1) * difficulties_votes[global.difficulty_vote_index].boss_modifier, 0.55) global.alive_boss_enemy_count = global.alive_boss_enemy_count + 1 global.alive_boss_enemy_entities[unit.unit_number] = unit global.alive_enemies = global.alive_enemies + 1 @@ -121,7 +122,7 @@ function add_enemies(surface, tiles) end end - set_biter_chances(global.current_level * difficulties_votes[global.difficulty_vote_index].strength_modifier) + set_biter_chances(math.floor(global.current_level * difficulties_votes[global.difficulty_vote_index].strength_modifier) + 1) local amount = ((global.current_level * 25) / #global.stages) * global.current_stage amount = amount * difficulties_votes[global.difficulty_vote_index].amount_modifier for k, tile in pairs(tiles) do diff --git a/maps/island_troopers/main.lua b/maps/island_troopers/main.lua index fc733126..c8975112 100644 --- a/maps/island_troopers/main.lua +++ b/maps/island_troopers/main.lua @@ -1,3 +1,5 @@ +--map by mewmew and kyte + require "maps.island_troopers.map_intro" require "functions.noise_vector_path" require "modules.shopping_chests" @@ -25,7 +27,11 @@ end function update_stage_gui() local caption = "Level: " .. global.current_level caption = caption .. " | Stage: " - caption = caption .. global.current_stage + local stage = global.current_stage + if stage > #global.stages - 1 then stage = #global.stages - 1 end + caption = caption .. stage + caption = caption .. "/" + caption = caption .. #global.stages - 1 caption = caption .. " | Bugs remaining: " caption = caption .. global.alive_enemies @@ -51,6 +57,18 @@ local function bring_players() end end +local function drift_corpses_toward_beach() + local surface = game.surfaces[1] + for _, corpse in pairs(surface.find_entities_filtered({name = "character-corpse"})) do + if corpse.position.y < 0 then + if surface.get_tile(corpse.position).collides_with("resource-layer") then + corpse.clone{position={corpse.position.x, corpse.position.y + 1}, surface=surface, force=corpse.force.name} + corpse.destroy() + end + end + end +end + local function set_next_level() global.alive_enemies = 0 global.alive_boss_enemy_count = 0 @@ -61,12 +79,12 @@ local function set_next_level() global.path_tiles = nil - local island_size = 16 + math.random(global.current_level, global.current_level * 2) + local island_size = math.random(global.current_level, global.current_level * 2) + 7 if island_size > 128 then island_size = 128 end global.stages = {} global.stages[1] = { - path_length = 16 + island_size * 2, + path_length = 24 + island_size * 2, size = island_size, } @@ -91,14 +109,14 @@ end local function earn_credits(amount) for _, player in pairs(game.connected_players) do - player.play_sound{path="utility/new_objective", volume_modifier=0.5} + player.play_sound{path="utility/new_objective", volume_modifier=0.4} end game.print(amount .. " credits have been transfered to the factory.", {r = 255, g = 215, b = 0}) global.credits = global.credits + amount end local function slowmo() - if not global.slowmo then global.slowmo = 0.10 end + if not global.slowmo then global.slowmo = 0.15 end game.speed = global.slowmo global.slowmo = global.slowmo + 0.01 if game.speed < 1 then return end @@ -111,17 +129,27 @@ end local function wait_until_stage_is_beaten() if global.alive_enemies > 0 then return end + local reward_amount = false + local gamestate = 2 + if global.stages[global.current_stage].size then - earn_credits(global.current_stage * global.current_level * 50) - global.current_stage = global.current_stage + 1 - global.gamestate = 2 + if global.current_stage < #global.stages -1 then + reward_amount = global.current_stage * global.current_level * 75 + else + reward_amount = global.current_stage * global.current_level * 150 + end + else + game.print("Final Stage complete!") + game.print("Level is collapsing !!", {r = 255, g = 0, b = 0}) + gamestate = 5 + end + + if reward_amount then + earn_credits(reward_amount) update_stage_gui() - return end - earn_credits(global.current_stage * global.current_level * 100) - --game.print("Level " .. global.current_level .. " complete!!") - global.gamestate = 5 - update_stage_gui() + global.current_stage = global.current_stage + 1 + global.gamestate = gamestate end local function on_player_joined_game(event) @@ -137,6 +165,13 @@ local function on_init() surface.request_to_generate_chunks({x = 0, y = 0}, 16) surface.force_generate_chunk_requests() + tree_raffle = {} + for _, e in pairs(game.entity_prototypes) do + if e.type == "tree" then + table.insert(tree_raffle, e.name) + end + end + global.difficulty_poll_closing_timeout = 3600 * 5 global.level_vectors = {} global.alive_boss_enemy_entities = {} @@ -150,6 +185,7 @@ local msg = { "We got the brainbug!", "Good job troopers!", "This will pay off well!", + "I'm doing my part!", } local function on_entity_died(event) @@ -186,7 +222,8 @@ local gamestate_functions = { } local function on_tick() - gamestate_functions[global.gamestate]() + gamestate_functions[global.gamestate]() + if game.tick % 300 == 0 then drift_corpses_toward_beach() end end local event = require 'utils.event' diff --git a/maps/island_troopers/map_intro.lua b/maps/island_troopers/map_intro.lua index d6290425..18fa1ca5 100644 --- a/maps/island_troopers/map_intro.lua +++ b/maps/island_troopers/map_intro.lua @@ -14,6 +14,14 @@ local info = [[ These can already be found on the coast. Be careful! Over time, residents will send stronger bugs to the surface! + + Turrets unfortunately malfunction in this world. + + Any container bearing dangerous goods, like ammo, grenades or barrels, + causes heavy explosions when it breaks. + Maybe this can be used to our advantage. + + --Good Luck Troopers-- ]] local function create_map_intro_button(player) diff --git a/maps/island_troopers/terrain.lua b/maps/island_troopers/terrain.lua index 9810b190..71429cf9 100644 --- a/maps/island_troopers/terrain.lua +++ b/maps/island_troopers/terrain.lua @@ -62,7 +62,9 @@ function draw_the_island() local position = global.path_tiles[#global.path_tiles].position local tiles = draw_island_tiles(surface, position, global.stages[global.current_stage].size) - local tree = "tree-0" .. math_random(1,9) + + --local tree = "tree-0" .. math_random(1,9) + local tree = tree_raffle[math.random(1, #tree_raffle)] local seed = math.random(1, 1000000) for _, t in pairs(tiles) do @@ -186,6 +188,7 @@ end local function process_tile(surface, position) if position.x < -96 then surface.set_tiles({{name = "out-of-map", position = position}}, true) return end + if position.x > 8192 then surface.set_tiles({{name = "out-of-map", position = position}}, true) return end if position.y < 0 then surface.set_tiles({{name = "deepwater", position = position}}, true) return end if position.y > 32 then surface.set_tiles({{name = "water-green", position = position}}, true) return end @@ -194,8 +197,10 @@ local function process_tile(surface, position) surface.set_tiles({{name = "sand-1", position = position}}, true) if position.y == 6 then - if position.x % 64 == 32 then create_shopping_chest(surface, position, false) end - if position.x % 128 == 0 then create_dump_chest(surface, position, false) end + if position.x % 60 == 30 then + create_dump_chest(surface, {x = position.x, y = position.y - 1}, false) + create_shopping_chest(surface, position, false) + end end end diff --git a/modules/shopping_chests.lua b/modules/shopping_chests.lua index 45444256..13a84cd9 100644 --- a/modules/shopping_chests.lua +++ b/modules/shopping_chests.lua @@ -1,14 +1,14 @@ local shop_list = { - ["iron-ore"] = 1, - ["copper-ore"] = 1, - ["uranium-ore"] = 3, ["coal"] = 1, - ["stone"] = 1, - ["wood"] = 0.75, + ["copper-ore"] = 1, ["crude-oil-barrel"] = 6, ["empty-barrel"] = 5, + ["iron-ore"] = 1, ["landfill"] = 2.5, ["raw-fish"] = 4, + ["stone"] = 1, + ["uranium-ore"] = 3, + ["wood"] = 0.75, } function create_shopping_chest(surface, position, destructible)