2019-10-11 21:52:32 +02:00
|
|
|
-- Mountain digger fortress, protect the cargo wagon! -- by MewMew
|
2019-10-06 18:16:32 +02:00
|
|
|
|
2020-01-01 19:25:14 +02:00
|
|
|
--enable / disable collapsing of the map
|
|
|
|
local collapse_enabled = false
|
2020-01-26 12:43:07 +02:00
|
|
|
local darkness = true
|
2020-01-01 19:25:14 +02:00
|
|
|
|
|
|
|
require "player_modifiers"
|
2019-10-07 16:40:52 +02:00
|
|
|
require "functions.soft_reset"
|
2019-10-08 05:50:32 +02:00
|
|
|
require "functions.basic_markets"
|
2019-10-28 10:04:30 +02:00
|
|
|
|
2019-10-29 16:35:01 +02:00
|
|
|
local RPG = require "modules.rpg"
|
2019-10-29 12:26:59 +02:00
|
|
|
require "modules.wave_defense.main"
|
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"
|
2020-01-26 13:07:00 +02:00
|
|
|
require "modules.no_solar"
|
2019-10-25 08:09:39 +02:00
|
|
|
require "modules.shotgun_buff"
|
2019-10-11 07:13:08 +02:00
|
|
|
require "modules.explosives"
|
2019-11-02 17:09:58 +02:00
|
|
|
require "modules.mineable_wreckage_yields_scrap"
|
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"
|
2019-10-29 12:26:59 +02:00
|
|
|
local level_depth = require "maps.mountain_fortress_v2.terrain"
|
2019-11-14 18:54:28 +02:00
|
|
|
local Collapse = require "maps.mountain_fortress_v2.collapse"
|
2019-10-07 22:40:05 +02:00
|
|
|
require "maps.mountain_fortress_v2.flamethrower_nerf"
|
2019-10-28 18:38:36 +02:00
|
|
|
local BiterRolls = require "modules.wave_defense.biter_rolls"
|
2019-11-28 04:53:19 +02:00
|
|
|
local BiterHealthBooster = require "modules.biter_health_booster"
|
2019-10-28 18:38:36 +02:00
|
|
|
local Reset = require "functions.soft_reset"
|
|
|
|
local Pets = require "modules.biter_pets"
|
|
|
|
local Map = require "modules.map_info"
|
|
|
|
local WD = require "modules.wave_defense.table"
|
|
|
|
local Treasure = require "maps.mountain_fortress_v2.treasure"
|
2019-11-14 18:54:28 +02:00
|
|
|
local Locomotive = require "maps.mountain_fortress_v2.locomotive"
|
2019-10-28 18:38:36 +02:00
|
|
|
local Modifier = require "player_modifiers"
|
2019-11-09 16:46:18 +02:00
|
|
|
local math_random = math.random
|
2019-10-28 18:38:36 +02:00
|
|
|
local Public = {}
|
2019-10-06 18:16:32 +02:00
|
|
|
|
2019-10-23 06:01:19 +02:00
|
|
|
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16, ['wood'] = 16, ['explosives'] = 32}
|
2019-10-10 19:33:32 +02:00
|
|
|
local treasure_chest_messages = {
|
|
|
|
"You notice an old crate within the rubble. It's filled with treasure!",
|
|
|
|
"You find a chest underneath the broken rocks. It's filled with goodies!",
|
|
|
|
"We has found the precious!",
|
|
|
|
}
|
2019-10-07 16:40:52 +02:00
|
|
|
|
2019-11-17 20:17:15 +02:00
|
|
|
local function set_difficulty()
|
|
|
|
local wave_defense_table = WD.get_table()
|
|
|
|
local player_count = #game.connected_players
|
|
|
|
|
2020-01-19 11:31:16 +02:00
|
|
|
wave_defense_table.max_active_biters = 1024
|
|
|
|
|
2019-11-17 20:17:15 +02:00
|
|
|
-- threat gain / wave
|
|
|
|
wave_defense_table.threat_gain_multiplier = 2 + player_count * 0.1
|
|
|
|
|
2019-11-28 04:53:19 +02:00
|
|
|
--1 additional map collapse tile / 8 players in game
|
|
|
|
global.map_collapse.speed = math.floor(player_count * 0.125) + 1
|
2019-11-17 20:17:15 +02:00
|
|
|
|
|
|
|
--20 Players for fastest wave_interval
|
|
|
|
wave_defense_table.wave_interval = 3600 - player_count * 90
|
|
|
|
if wave_defense_table.wave_interval < 1800 then wave_defense_table.wave_interval = 1800 end
|
|
|
|
end
|
|
|
|
|
2019-10-28 18:38:36 +02:00
|
|
|
function Public.reset_map()
|
|
|
|
local wave_defense_table = WD.get_table()
|
2019-10-12 10:58:02 +02:00
|
|
|
global.chunk_queue = {}
|
|
|
|
|
2019-11-20 21:43:50 +02:00
|
|
|
if game.surfaces["cargo_wagon"] then game.delete_surface(game.surfaces["cargo_wagon"]) end
|
|
|
|
|
2019-10-12 10:58:02 +02:00
|
|
|
local map_gen_settings = {
|
2019-11-09 16:46:18 +02:00
|
|
|
["seed"] = math_random(1, 1000000),
|
2019-11-04 14:04:43 +02:00
|
|
|
["width"] = level_depth,
|
2019-11-09 16:46:18 +02:00
|
|
|
["water"] = 0.1,
|
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
|
|
|
|
2019-10-11 21:52:32 +02:00
|
|
|
if not global.active_surface_index then
|
2019-10-12 10:58:02 +02:00
|
|
|
global.active_surface_index = game.create_surface("mountain_fortress", map_gen_settings).index
|
2019-10-07 17:37:57 +02:00
|
|
|
else
|
2019-10-11 21:52:32 +02:00
|
|
|
game.forces.player.set_spawn_position({-2, 16}, game.surfaces[global.active_surface_index])
|
2019-10-28 18:38:36 +02:00
|
|
|
global.active_surface_index = Reset.soft_reset_map(game.surfaces[global.active_surface_index], map_gen_settings, starting_items).index
|
2019-10-07 16:40:52 +02:00
|
|
|
end
|
|
|
|
|
2019-10-11 21:52:32 +02:00
|
|
|
local surface = game.surfaces[global.active_surface_index]
|
|
|
|
|
2020-01-26 12:43:07 +02:00
|
|
|
if darkness then
|
|
|
|
surface.min_brightness = 0
|
|
|
|
surface.brightness_visual_weights = {1, 1, 1}
|
2020-01-26 13:07:00 +02:00
|
|
|
surface.daytime = 0.44
|
2020-01-26 12:43:07 +02:00
|
|
|
surface.freeze_daytime = true
|
2020-01-26 13:07:00 +02:00
|
|
|
surface.solar_power_multiplier = 999
|
2020-01-26 12:43:07 +02:00
|
|
|
end
|
|
|
|
|
2019-10-11 21:52:32 +02:00
|
|
|
surface.request_to_generate_chunks({0,0}, 2)
|
|
|
|
surface.force_generate_chunk_requests()
|
2019-10-07 16:40:52 +02:00
|
|
|
|
2019-10-09 21:09:53 +02:00
|
|
|
for x = -768 + 32, 768 - 32, 32 do
|
2019-10-11 21:52:32 +02:00
|
|
|
surface.request_to_generate_chunks({x, 96}, 1)
|
|
|
|
surface.force_generate_chunk_requests()
|
2019-10-09 21:09:53 +02:00
|
|
|
end
|
|
|
|
|
2019-11-20 20:26:34 +02:00
|
|
|
game.difficulty_settings.technology_price_multiplier = 0.5
|
2019-10-07 16:40:52 +02:00
|
|
|
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
|
2019-10-12 02:19:37 +02:00
|
|
|
game.map_settings.enemy_expansion.max_expansion_cooldown = 3600
|
|
|
|
game.map_settings.enemy_expansion.min_expansion_cooldown = 3600
|
|
|
|
game.map_settings.enemy_expansion.settler_group_max_size = 8
|
|
|
|
game.map_settings.enemy_expansion.settler_group_min_size = 16
|
2019-11-01 17:24:44 +02:00
|
|
|
game.map_settings.pollution.enabled = false
|
2019-10-07 16:40:52 +02:00
|
|
|
|
2019-11-16 21:50:34 +02:00
|
|
|
game.forces.player.technologies["land-mine"].enabled = false
|
2019-11-09 16:46:18 +02:00
|
|
|
game.forces.player.technologies["landfill"].enabled = false
|
2019-10-07 16:40:52 +02:00
|
|
|
game.forces.player.technologies["railway"].researched = true
|
2019-10-11 21:52:32 +02:00
|
|
|
game.forces.player.set_spawn_position({-2, 16}, surface)
|
2019-10-07 16:40:52 +02:00
|
|
|
|
2019-11-14 18:54:28 +02:00
|
|
|
Locomotive.locomotive_spawn(surface, {x = 0, y = 16})
|
2019-10-07 16:40:52 +02:00
|
|
|
|
2019-10-28 18:38:36 +02:00
|
|
|
WD.reset_wave_defense()
|
|
|
|
wave_defense_table.surface_index = global.active_surface_index
|
|
|
|
wave_defense_table.target = global.locomotive_cargo
|
|
|
|
wave_defense_table.nest_building_density = 32
|
|
|
|
wave_defense_table.game_lost = false
|
2019-10-29 21:07:19 +02:00
|
|
|
|
2019-11-14 18:54:28 +02:00
|
|
|
Collapse.init()
|
|
|
|
|
|
|
|
RPG.rpg_reset_all_players()
|
2019-11-17 20:17:15 +02:00
|
|
|
|
|
|
|
set_difficulty()
|
2019-10-06 18:16:32 +02:00
|
|
|
end
|
|
|
|
|
2019-10-08 01:17:00 +02:00
|
|
|
local function protect_train(event)
|
|
|
|
if event.entity.force.index ~= 1 then return end --Player Force
|
2019-10-13 12:57:54 +02:00
|
|
|
if event.entity == global.locomotive_cargo then
|
2019-10-08 01:17:00 +02:00
|
|
|
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-11-09 16:46:18 +02:00
|
|
|
|
2019-10-08 01:17:00 +02:00
|
|
|
local function biters_chew_rocks_faster(event)
|
|
|
|
if event.entity.force.index ~= 3 then return end --Neutral Force
|
|
|
|
if not event.cause then return end
|
|
|
|
if not event.cause.valid then return end
|
|
|
|
if event.cause.force.index ~= 2 then return end --Enemy Force
|
2019-10-25 08:09:39 +02:00
|
|
|
event.entity.health = event.entity.health - event.final_damage_amount * 2.5
|
2019-10-08 01:17:00 +02:00
|
|
|
end
|
|
|
|
|
2019-10-08 05:50:32 +02:00
|
|
|
local function hidden_biter(entity)
|
2019-11-28 04:53:19 +02:00
|
|
|
local d = math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2)
|
|
|
|
|
|
|
|
BiterRolls.wave_defense_set_unit_raffle(d * 0.25)
|
|
|
|
|
|
|
|
local unit
|
2019-11-09 16:46:18 +02:00
|
|
|
if math_random(1,3) == 1 then
|
2019-11-28 04:53:19 +02:00
|
|
|
unit = entity.surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = entity.position})
|
|
|
|
else
|
|
|
|
unit = entity.surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = entity.position})
|
|
|
|
end
|
|
|
|
|
|
|
|
local m = 1 / level_depth
|
|
|
|
m = m * d
|
|
|
|
|
|
|
|
if math_random(1, 256) == 1 then
|
|
|
|
BiterHealthBooster.add_boss_unit(unit, m * 15 + 1, 0.38)
|
2019-10-12 04:06:48 +02:00
|
|
|
else
|
2019-11-28 04:53:19 +02:00
|
|
|
BiterHealthBooster.add_unit(unit, m * 2.5 + 1)
|
2019-10-12 04:06:48 +02:00
|
|
|
end
|
2019-10-08 05:50:32 +02:00
|
|
|
end
|
|
|
|
|
2019-10-29 12:26:59 +02:00
|
|
|
local function hidden_worm(entity)
|
2019-10-31 17:18:17 +02:00
|
|
|
BiterRolls.wave_defense_set_worm_raffle(math.sqrt(entity.position.x ^ 2 + entity.position.y ^ 2) * 0.25)
|
2019-10-29 12:26:59 +02:00
|
|
|
entity.surface.create_entity({name = BiterRolls.wave_defense_roll_worm_name(), position = entity.position})
|
|
|
|
end
|
|
|
|
|
2019-10-13 08:28:08 +02:00
|
|
|
local function hidden_biter_pet(event)
|
2019-11-09 16:46:18 +02:00
|
|
|
if math_random(1, 2048) ~= 1 then return end
|
2019-10-31 17:18:17 +02:00
|
|
|
BiterRolls.wave_defense_set_unit_raffle(math.sqrt(event.entity.position.x ^ 2 + event.entity.position.y ^ 2) * 0.25)
|
2019-10-13 08:28:08 +02:00
|
|
|
local unit
|
2019-11-09 16:46:18 +02:00
|
|
|
if math_random(1,3) == 1 then
|
2019-10-28 18:38:36 +02:00
|
|
|
unit = event.entity.surface.create_entity({name = BiterRolls.wave_defense_roll_spitter_name(), position = event.entity.position})
|
2019-10-13 08:28:08 +02:00
|
|
|
else
|
2019-10-28 18:38:36 +02:00
|
|
|
unit = event.entity.surface.create_entity({name = BiterRolls.wave_defense_roll_biter_name(), position = event.entity.position})
|
|
|
|
end
|
|
|
|
Pets.biter_pets_tame_unit(game.players[event.player_index], unit, true)
|
2019-10-13 08:28:08 +02:00
|
|
|
end
|
|
|
|
|
2019-10-10 19:33:32 +02:00
|
|
|
local function hidden_treasure(event)
|
2019-11-09 16:46:18 +02:00
|
|
|
if math_random(1, 320) ~= 1 then return end
|
|
|
|
game.players[event.player_index].print(treasure_chest_messages[math_random(1, #treasure_chest_messages)], {r=0.98, g=0.66, b=0.22})
|
2019-11-02 19:41:17 +02:00
|
|
|
Treasure(event.entity.surface, event.entity.position, "wooden-chest")
|
2019-10-10 19:33:32 +02:00
|
|
|
end
|
|
|
|
|
2019-10-29 12:26:59 +02:00
|
|
|
local projectiles = {"grenade", "explosive-rocket", "grenade", "explosive-rocket", "explosive-cannon-projectile"}
|
2019-10-29 13:14:28 +02:00
|
|
|
local function angry_tree(entity, cause)
|
2019-10-29 12:26:59 +02:00
|
|
|
if entity.type ~= "tree" then return end
|
2019-10-30 18:29:15 +02:00
|
|
|
if math.abs(entity.position.y) < level_depth then return end
|
2019-11-09 16:46:18 +02:00
|
|
|
if math_random(1,4) == 1 then hidden_biter(entity) end
|
|
|
|
if math_random(1,8) == 1 then hidden_worm(entity) end
|
|
|
|
if math_random(1,16) ~= 1 then return end
|
2019-10-29 12:26:59 +02:00
|
|
|
local position = false
|
|
|
|
if cause then
|
|
|
|
if cause.valid then
|
|
|
|
position = cause.position
|
|
|
|
end
|
|
|
|
end
|
2019-11-09 16:46:18 +02:00
|
|
|
if not position then position = {entity.position.x + (-20 + math_random(0, 40)), entity.position.y + (-20 + math_random(0, 40))} end
|
2019-10-29 12:26:59 +02:00
|
|
|
|
|
|
|
entity.surface.create_entity({
|
2019-11-09 16:46:18 +02:00
|
|
|
name = projectiles[math_random(1, 5)],
|
2019-10-29 12:26:59 +02:00
|
|
|
position = entity.position,
|
|
|
|
force = "neutral",
|
|
|
|
source = entity.position,
|
|
|
|
target = position,
|
|
|
|
max_range = 64,
|
|
|
|
speed = 0.10
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2019-10-29 16:35:01 +02:00
|
|
|
local function give_coin(player)
|
|
|
|
player.insert({name = "coin", count = 1})
|
|
|
|
end
|
|
|
|
|
2019-10-08 05:50:32 +02:00
|
|
|
local function on_player_mined_entity(event)
|
2019-10-08 23:50:57 +02:00
|
|
|
if not event.entity.valid then return end
|
2019-10-29 12:26:59 +02:00
|
|
|
if event.entity.force.index ~= 3 then return end
|
|
|
|
|
2019-10-29 16:35:01 +02:00
|
|
|
if event.entity.type == "simple-entity" then
|
|
|
|
give_coin(game.players[event.player_index])
|
|
|
|
|
2019-11-09 16:46:18 +02:00
|
|
|
if math_random(1,32) == 1 then
|
2019-10-08 05:50:32 +02:00
|
|
|
hidden_biter(event.entity)
|
2019-10-10 19:33:32 +02:00
|
|
|
return
|
2019-10-28 18:38:36 +02:00
|
|
|
end
|
2019-11-09 16:46:18 +02:00
|
|
|
if math_random(1,512) == 1 then
|
2019-10-29 21:07:19 +02:00
|
|
|
hidden_worm(event.entity)
|
2019-10-29 12:26:59 +02:00
|
|
|
return
|
|
|
|
end
|
2019-10-13 08:28:08 +02:00
|
|
|
hidden_biter_pet(event)
|
2019-10-29 12:26:59 +02:00
|
|
|
hidden_treasure(event)
|
2019-10-08 05:50:32 +02:00
|
|
|
end
|
2019-10-29 12:26:59 +02:00
|
|
|
|
|
|
|
angry_tree(event.entity, game.players[event.player_index].character)
|
2019-10-08 05:50:32 +02:00
|
|
|
end
|
|
|
|
|
2019-10-07 04:37:23 +02:00
|
|
|
local function on_entity_died(event)
|
2019-10-28 18:38:36 +02:00
|
|
|
local wave_defense_table = WD.get_table()
|
2019-10-07 04:37:23 +02:00
|
|
|
if not event.entity.valid then return end
|
2019-10-07 17:37:57 +02:00
|
|
|
if event.entity == global.locomotive_cargo then
|
2019-10-10 19:33:32 +02:00
|
|
|
game.print("The cargo was destroyed!")
|
2019-10-28 18:38:36 +02:00
|
|
|
wave_defense_table.game_lost = true
|
|
|
|
wave_defense_table.target = nil
|
2019-10-23 21:17:15 +02:00
|
|
|
global.game_reset_tick = game.tick + 1800
|
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
|
2019-10-10 19:33:32 +02:00
|
|
|
event.entity.surface.spill_item_stack(event.entity.position,{name = "raw-fish", count = 512}, false)
|
2019-10-12 05:44:19 +02:00
|
|
|
return
|
2019-10-07 04:37:23 +02:00
|
|
|
end
|
2019-10-28 18:38:36 +02:00
|
|
|
|
2019-10-08 05:50:32 +02:00
|
|
|
if event.cause then
|
|
|
|
if event.cause.valid then
|
2019-10-08 23:50:57 +02:00
|
|
|
if event.cause.force.index == 2 or event.cause.force.index == 3 then return end
|
2019-10-08 05:50:32 +02:00
|
|
|
end
|
|
|
|
end
|
2019-10-29 12:26:59 +02:00
|
|
|
|
2019-10-08 05:50:32 +02:00
|
|
|
if event.entity.force.index == 3 then
|
2019-10-31 17:18:17 +02:00
|
|
|
--local r_max = 15 - math.floor(math.abs(event.entity.position.y) / (level_depth * 0.5))
|
|
|
|
--if r_max < 3 then r_max = 3 end
|
2019-11-09 16:46:18 +02:00
|
|
|
if math_random(1,8) == 1 then
|
2019-10-08 05:50:32 +02:00
|
|
|
hidden_biter(event.entity)
|
|
|
|
end
|
2019-10-29 12:26:59 +02:00
|
|
|
|
2019-11-09 16:46:18 +02:00
|
|
|
if math_random(1,256) == 1 then hidden_worm(event.entity) end
|
2019-10-29 12:26:59 +02:00
|
|
|
|
|
|
|
angry_tree(event.entity, event.cause)
|
2019-10-08 05:50:32 +02:00
|
|
|
end
|
2019-10-07 04:37:23 +02:00
|
|
|
end
|
|
|
|
|
2019-10-07 07:19:41 +02:00
|
|
|
local function on_entity_damaged(event)
|
2019-10-08 01:17:00 +02:00
|
|
|
if not event.entity.valid then return end
|
|
|
|
protect_train(event)
|
2019-10-09 21:09:53 +02:00
|
|
|
|
|
|
|
if not event.entity.health then return end
|
2019-10-08 01:17:00 +02:00
|
|
|
biters_chew_rocks_faster(event)
|
2019-10-10 19:33:32 +02:00
|
|
|
--neutral_force_player_damage_resistance(event)
|
2019-10-07 07:19:41 +02:00
|
|
|
end
|
|
|
|
|
2019-10-08 18:22:42 +02:00
|
|
|
local function on_research_finished(event)
|
|
|
|
event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 50 -- +5 Slots / level
|
2019-10-09 21:09:53 +02:00
|
|
|
local mining_speed_bonus = game.forces.player.mining_drill_productivity_bonus * 5 -- +50% speed / level
|
2019-10-17 00:06:18 +02:00
|
|
|
if event.research.force.technologies["steel-axe"].researched then mining_speed_bonus = mining_speed_bonus + 0.5 end -- +50% speed for steel-axe research
|
2019-10-08 18:22:42 +02:00
|
|
|
event.research.force.manual_mining_speed_modifier = mining_speed_bonus
|
|
|
|
end
|
|
|
|
|
2019-10-07 16:40:52 +02:00
|
|
|
local function on_player_joined_game(event)
|
2019-11-10 23:02:45 +02:00
|
|
|
local player_modifiers = Modifier.get_table()
|
2019-10-18 07:01:14 +02:00
|
|
|
local player = game.players[event.player_index]
|
2019-10-29 12:26:59 +02:00
|
|
|
|
2019-10-19 09:20:40 +02:00
|
|
|
set_difficulty()
|
2019-10-18 07:01:14 +02:00
|
|
|
|
2019-10-11 21:52:32 +02:00
|
|
|
local surface = game.surfaces[global.active_surface_index]
|
2019-10-06 18:16:32 +02:00
|
|
|
|
|
|
|
if player.online_time == 0 then
|
2019-11-17 20:17:15 +02:00
|
|
|
player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface)
|
2019-10-07 16:40:52 +02:00
|
|
|
for item, amount in pairs(starting_items) do
|
|
|
|
player.insert({name = item, count = amount})
|
|
|
|
end
|
2019-10-06 18:16:32 +02:00
|
|
|
end
|
2019-10-08 09:32:54 +02:00
|
|
|
|
2019-11-21 08:02:39 +02:00
|
|
|
if player.surface.index ~= global.active_surface_index and player.surface.name ~= "cargo_wagon" then
|
2019-10-17 00:06:18 +02:00
|
|
|
player.character = nil
|
|
|
|
player.set_controller({type=defines.controllers.god})
|
|
|
|
player.create_character()
|
2019-11-17 20:17:15 +02:00
|
|
|
player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface)
|
2019-10-17 00:06:18 +02:00
|
|
|
for item, amount in pairs(starting_items) do
|
|
|
|
player.insert({name = item, count = amount})
|
2019-11-21 08:02:39 +02:00
|
|
|
end
|
2019-10-22 08:29:30 +02:00
|
|
|
end
|
|
|
|
|
2019-11-10 23:02:45 +02:00
|
|
|
player_modifiers[player.index].character_mining_speed_modifier["mountain_fortress"] = 0.5
|
2019-10-28 18:38:36 +02:00
|
|
|
Modifier.update_player_modifiers(player)
|
2019-11-17 20:17:15 +02:00
|
|
|
|
|
|
|
local tile = surface.get_tile(player.position)
|
|
|
|
if tile.valid then
|
|
|
|
if tile.name == "out-of-map" then
|
|
|
|
player.teleport(surface.find_non_colliding_position("character", game.forces.player.get_spawn_position(surface), 32, 0.5), surface)
|
|
|
|
end
|
|
|
|
end
|
2019-10-06 18:16:32 +02:00
|
|
|
end
|
2019-10-29 12:26:59 +02:00
|
|
|
|
|
|
|
local function on_player_left_game(event)
|
|
|
|
set_difficulty()
|
2019-10-18 07:01:14 +02:00
|
|
|
end
|
|
|
|
|
2019-11-14 20:24:42 +02:00
|
|
|
local function tick()
|
|
|
|
local tick = game.tick
|
|
|
|
if tick % 30 == 0 then
|
|
|
|
if tick % 1800 == 0 then
|
2019-11-14 18:54:28 +02:00
|
|
|
Locomotive.set_player_spawn_and_refill_fish()
|
2019-11-14 20:24:42 +02:00
|
|
|
local surface = game.surfaces[global.active_surface_index]
|
2019-11-14 19:48:03 +02:00
|
|
|
local last_position = global.map_collapse.last_position
|
2019-11-15 01:03:38 +02:00
|
|
|
local position = surface.find_non_colliding_position("stone-furnace", {last_position.x, last_position.y - 32}, 128, 4)
|
2019-11-14 19:48:03 +02:00
|
|
|
if position then
|
|
|
|
local wave_defense_table = WD.get_table()
|
|
|
|
wave_defense_table.spawn_position = position
|
2019-11-14 20:24:42 +02:00
|
|
|
end
|
2019-11-16 21:50:34 +02:00
|
|
|
--if tick % 216000 == 0 then
|
|
|
|
-- Collapse.delete_out_of_map_chunks(surface)
|
|
|
|
--end
|
2019-11-14 18:54:28 +02:00
|
|
|
end
|
|
|
|
if global.game_reset_tick then
|
2019-11-14 20:24:42 +02:00
|
|
|
if global.game_reset_tick < tick then
|
2019-11-14 18:54:28 +02:00
|
|
|
global.game_reset_tick = nil
|
|
|
|
require "maps.mountain_fortress_v2.main".reset_map()
|
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
|
|
|
Locomotive.fish_tag()
|
|
|
|
end
|
2020-01-01 19:25:14 +02:00
|
|
|
if not collapse_enabled then return end
|
2019-11-14 18:54:28 +02:00
|
|
|
Collapse.process()
|
|
|
|
end
|
|
|
|
|
2019-10-28 18:38:36 +02:00
|
|
|
local function on_init()
|
|
|
|
local T = Map.Pop_info()
|
2019-12-05 09:58:26 +02:00
|
|
|
T.localised_category = "mountain_fortress"
|
2019-10-28 18:38:36 +02:00
|
|
|
T.main_caption_color = {r = 150, g = 150, b = 0}
|
|
|
|
T.sub_caption_color = {r = 0, g = 150, b = 0}
|
2019-10-18 07:01:14 +02:00
|
|
|
global.rocks_yield_ore_maximum_amount = 999
|
2019-10-09 21:09:53 +02:00
|
|
|
global.rocks_yield_ore_base_amount = 50
|
2019-10-27 20:26:55 +02:00
|
|
|
global.rocks_yield_ore_distance_modifier = 0.025
|
2019-10-11 07:13:08 +02:00
|
|
|
|
|
|
|
global.explosion_cells_destructible_tiles = {
|
2019-10-21 07:16:03 +02:00
|
|
|
["out-of-map"] = 1500,
|
|
|
|
["water"] = 1000,
|
|
|
|
["water-green"] = 1000,
|
|
|
|
["deepwater-green"] = 1000,
|
|
|
|
["deepwater"] = 1000,
|
2019-10-18 07:01:14 +02:00
|
|
|
["water-shallow"] = 1000,
|
2019-10-11 07:13:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-28 18:38:36 +02:00
|
|
|
Public.reset_map()
|
2019-10-06 18:16:32 +02:00
|
|
|
end
|
|
|
|
|
2019-11-20 20:26:34 +02:00
|
|
|
local function on_player_driving_changed_state(event)
|
|
|
|
local player = game.players[event.player_index]
|
|
|
|
local vehicle = event.entity
|
|
|
|
Locomotive.enter_cargo_wagon(player, vehicle)
|
|
|
|
end
|
|
|
|
|
2019-10-06 18:16:32 +02:00
|
|
|
local event = require 'utils.event'
|
|
|
|
event.on_init(on_init)
|
2019-11-14 18:54:28 +02:00
|
|
|
event.on_nth_tick(2, tick)
|
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-29 12:26:59 +02:00
|
|
|
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
|
|
|
event.add(defines.events.on_player_left_game, on_player_left_game)
|
2019-10-08 05:50:32 +02:00
|
|
|
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
2019-10-08 18:22:42 +02:00
|
|
|
event.add(defines.events.on_research_finished, on_research_finished)
|
2019-11-20 20:26:34 +02:00
|
|
|
event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state)
|
2019-10-08 05:50:32 +02:00
|
|
|
|
2019-10-28 18:38:36 +02:00
|
|
|
require "modules.rocks_yield_ore"
|
|
|
|
|
|
|
|
return Public
|