diff --git a/maps/mountain_fortress_v3/functions.lua b/maps/mountain_fortress_v3/functions.lua index 058543b3..f7b4237f 100644 --- a/maps/mountain_fortress_v3/functions.lua +++ b/maps/mountain_fortress_v3/functions.lua @@ -943,7 +943,7 @@ Public.disable_minable_callback = Task.register( function (entity) if entity and entity.valid then - entity.minable = false + entity.minable_flag = false end end ) @@ -953,7 +953,7 @@ Public.disable_minable_and_ICW_callback = function (entity) if entity and entity.valid then local wagons_in_the_wild = Public.get('wagons_in_the_wild') - entity.minable = false + entity.minable_flag = false entity.destructible = false ICW.register_wagon(entity) @@ -967,7 +967,7 @@ Public.disable_destructible_callback = function (entity) if entity and entity.valid then entity.destructible = false - entity.minable = false + entity.minable_flag = false end end ) @@ -1059,7 +1059,7 @@ Public.magic_item_crafting_callback = return end - entity.minable = false + entity.minable_flag = false entity.destructible = false entity.operable = false @@ -1122,7 +1122,7 @@ Public.magic_item_crafting_callback_weighted = entity.destructible = false end - entity.minable = false + entity.minable_flag = false entity.operable = false local p = entity.position @@ -2354,6 +2354,28 @@ function Public.set_spawn_position() ::continue:: end +local function on_marked_for_deconstruction(event) + local entity = event.entity + if not entity or not entity.valid then + return + end + + if not event.player_index then + return + end + + local player = game.get_player(event.player_index) + if not player or not player.valid then + return + end + + if player.controller_type == defines.controllers.remote then + entity.cancel_deconstruction(player.force, player) + player.print("You cannot deconstruct while in remove view!", { r = 1, g = 0.5, b = 0.5 }) + end +end + + function Public.on_player_joined_game(event) local players = Public.get('players') local player = game.players[event.player_index] @@ -2362,7 +2384,7 @@ function Public.on_player_joined_game(event) Difficulty.clear_top_frame(player) Modifiers.update_player_modifiers(player) local active_surface_index = Public.get('active_surface_index') - local surface = game.surfaces[active_surface_index or 'nauvis'] + local surface = game.surfaces[active_surface_index or 'fortress'] local current_task = Public.get('current_task') if not current_task.done then @@ -2964,6 +2986,7 @@ Event.add(de.on_player_driving_changed_state, on_player_driving_changed_state) Event.add(de.on_pre_player_toggled_map_editor, on_pre_player_toggled_map_editor) Event.add(de.on_player_cursor_stack_changed, on_player_cursor_stack_changed) Event.add(de.on_chart_tag_added, on_chart_tag_added) +Event.add(de.on_marked_for_deconstruction, on_marked_for_deconstruction) Event.on_nth_tick(10, tick) Event.add(WD.events.on_wave_created, on_wave_created) Event.add(WD.events.on_primary_target_missing, on_primary_target_missing) diff --git a/maps/mountain_fortress_v3/ic/functions.lua b/maps/mountain_fortress_v3/ic/functions.lua index 72508a8e..8b0b270e 100644 --- a/maps/mountain_fortress_v3/ic/functions.lua +++ b/maps/mountain_fortress_v3/ic/functions.lua @@ -82,7 +82,7 @@ local enable_car_to_be_mined = local entity = event.entity local owner_name = event.owner_name if entity and entity.valid then - entity.minable = true + entity.minable_flag = true local msg = owner_name .. "'s vehicle is now minable!" local p = { position = entity.position @@ -706,7 +706,7 @@ local function construct_doors(car) } ) e.destructible = false - e.minable = false + e.minable_flag = false e.operable = false e.get_inventory(defines.inventory.fuel).insert({ name = 'coal', count = 1 }) if type(car.entity) == 'boolean' then @@ -1034,7 +1034,7 @@ function Public.kill_car_but_save_surface(entity) kick_players_out_of_vehicles(car) kick_players_from_surface(car) - car.entity.minable = true + car.entity.minable_flag = true local trust_system = IC.get('trust_system') local owner = car.owner @@ -1226,7 +1226,7 @@ function Public.create_car_room(car) } ) e1.destructible = false - e1.minable = false + e1.minable_flag = false local e2 = surface.create_entity( @@ -1238,7 +1238,7 @@ function Public.create_car_room(car) } ) e2.destructible = false - e2.minable = false + e2.minable_flag = false car.transfer_entities = { e1, e2 } end @@ -1445,7 +1445,7 @@ function Public.use_door_with_entity(player, door) state = 'add' } ) - car.entity.minable = false + car.entity.minable_flag = false end if not validate_entity(surface) then @@ -1476,7 +1476,7 @@ function Public.use_door_with_entity(player, door) state = 'remove' } ) - car.entity.minable = true + car.entity.minable_flag = true end local surface = car.entity.surface local x_vector = (door.position.x / math.abs(door.position.x)) * 2 @@ -1514,7 +1514,7 @@ function Public.on_player_died(player) if car.owner == player.name then local entity = car.entity if entity and entity.valid then - entity.minable = false + entity.minable_flag = false end end end @@ -1526,7 +1526,7 @@ function Public.on_player_respawned(player) if car.owner == player.name then local entity = car.entity if entity and entity.valid then - entity.minable = true + entity.minable_flag = true end end end diff --git a/maps/mountain_fortress_v3/ic/gui.lua b/maps/mountain_fortress_v3/ic/gui.lua index 0c321bd3..6b2bb352 100644 --- a/maps/mountain_fortress_v3/ic/gui.lua +++ b/maps/mountain_fortress_v3/ic/gui.lua @@ -106,7 +106,7 @@ local function transfer_player_table(player, new_player) end car.owner = new_player.name - car.entity.minable = true + car.entity.minable_flag = true Functions.render_owner_text(renders, player, car.entity, new_player) diff --git a/maps/mountain_fortress_v3/ic/table.lua b/maps/mountain_fortress_v3/ic/table.lua index a53f5e07..ca82a2bc 100644 --- a/maps/mountain_fortress_v3/ic/table.lua +++ b/maps/mountain_fortress_v3/ic/table.lua @@ -36,7 +36,7 @@ function Public.reset() this.renders = {} this.saved_surfaces = {} this.surfaces_deleted_by_button = {} - this.allowed_surface = 'nauvis' + this.allowed_surface = 'fortress' this.trust_system = {} this.players = {} this.players_persistent = {} diff --git a/maps/mountain_fortress_v3/icw/functions.lua b/maps/mountain_fortress_v3/icw/functions.lua index 1cfc14d4..df2c7910 100644 --- a/maps/mountain_fortress_v3/icw/functions.lua +++ b/maps/mountain_fortress_v3/icw/functions.lua @@ -12,12 +12,7 @@ local deepcopy = table.deepcopy local random = math.random local sqrt = math.sqrt -local is_modded = script.active_mods['MtnFortressAddons'] or false - local out_of_map_tile = 'out-of-map' -if is_modded then - out_of_map_tile = 'void-tile' -end local scenario_name = WPT.scenario_name local fallout_width = 64 @@ -57,67 +52,67 @@ local add_chests_to_wagon_token = return error('Surface was invalid, please check this out!') end left_1.destructible = false - left_1.minable = false + left_1.minable_flag = false local left_2 = LinkedChests.add(surface, { position1[1] - 1, position1[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_2') left_2.destructible = false - left_2.minable = false + left_2.minable_flag = false local left_3 = LinkedChests.add(surface, { position1[1] - 2, position1[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_3') left_3.destructible = false - left_3.minable = false + left_3.minable_flag = false local left_4 = LinkedChests.add(surface, { position1[1] - 3, position1[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_4') left_4.destructible = false - left_4.minable = false + left_4.minable_flag = false local right_1 = LinkedChests.add(surface, position2, 'player', 'wagon_' .. wagon.entity.unit_number .. '_5') right_1.destructible = false - right_1.minable = false + right_1.minable_flag = false local right_2 = LinkedChests.add(surface, { position2[1] + 1, position2[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_6') right_2.destructible = false - right_2.minable = false + right_2.minable_flag = false local right_3 = LinkedChests.add(surface, { position2[1] + 2, position2[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_7') right_3.destructible = false - right_3.minable = false + right_3.minable_flag = false local right_4 = LinkedChests.add(surface, { position2[1] + 3, position2[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_8') right_4.destructible = false - right_4.minable = false + right_4.minable_flag = false local bottom_left_1 = LinkedChests.add(surface, position3, 'player', 'wagon_' .. wagon.entity.unit_number .. '_9') bottom_left_1.destructible = false - bottom_left_1.minable = false + bottom_left_1.minable_flag = false local bottom_left_2 = LinkedChests.add(surface, { position3[1] - 1, position3[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_10') bottom_left_2.destructible = false - bottom_left_2.minable = false + bottom_left_2.minable_flag = false local bottom_left_3 = LinkedChests.add(surface, { position3[1] - 2, position3[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_11') bottom_left_3.destructible = false - bottom_left_3.minable = false + bottom_left_3.minable_flag = false local bottom_left_4 = LinkedChests.add(surface, { position3[1] - 3, position3[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_12') bottom_left_4.destructible = false - bottom_left_4.minable = false + bottom_left_4.minable_flag = false local bottom_right_1 = LinkedChests.add(surface, position4, 'player', 'wagon_' .. wagon.entity.unit_number .. '_13') bottom_right_1.destructible = false - bottom_right_1.minable = false + bottom_right_1.minable_flag = false local bottom_right_2 = LinkedChests.add(surface, { position4[1] + 1, position4[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_14') bottom_right_2.destructible = false - bottom_right_2.minable = false + bottom_right_2.minable_flag = false local bottom_right_3 = LinkedChests.add(surface, { position4[1] + 2, position4[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_15') bottom_right_3.destructible = false - bottom_right_3.minable = false + bottom_right_3.minable_flag = false local bottom_right_4 = LinkedChests.add(surface, { position4[1] + 3, position4[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_16') bottom_right_4.destructible = false - bottom_right_4.minable = false + bottom_right_4.minable_flag = false end ) @@ -227,7 +222,7 @@ local function teleport_char(position, destination_area, wagon) player.physical_position.x, player.physical_position.y + (destination_area.left_top.y - wagon.area.left_top.y) } - player.teleport({ 0, 0 }, game.surfaces.nauvis) + player.teleport({ 0, 0 }, game.surfaces.fortress) end end end @@ -513,7 +508,7 @@ local function construct_wagon_doors(icw, wagon) } ) e.destructible = false - e.minable = false + e.minable_flag = false e.operable = false e.get_inventory(defines.inventory.fuel).insert({ name = 'coal', count = 1 }) icw.doors[e.unit_number] = wagon.entity.unit_number @@ -686,7 +681,7 @@ function Public.create_wagon_room(icw, wagon) } ) e.destructible = false - e.minable = false + e.minable_flag = false wagon.transfer_entities = { e } return end @@ -740,7 +735,7 @@ function Public.migrate_wagon(icw, source, target) return end - target.minable = false + target.minable_flag = false local target_wagon = target.unit_number local source_wagon = source.unit_number diff --git a/maps/mountain_fortress_v3/icw/linked_chests.lua b/maps/mountain_fortress_v3/icw/linked_chests.lua index c725b339..1caf6e8b 100644 --- a/maps/mountain_fortress_v3/icw/linked_chests.lua +++ b/maps/mountain_fortress_v3/icw/linked_chests.lua @@ -263,7 +263,7 @@ local function create_chest(entity, name, mode) container.link_id = previous.link_id container.chest.link_id = previous.link_id container.mode = 2 - container.chest.minable = false + container.chest.minable_flag = false container.chest.destructible = false end @@ -943,7 +943,7 @@ local function on_gui_checked_state_changed(event) container.mode = 2 container.linked_to = nil container.link_id = nil - container.chest.minable = true + container.chest.minable_flag = true container.chest.get_inventory(defines.inventory.chest).set_bar(1) refresh_main_frame({ unit_number = unit_number, player = player }) end @@ -1110,7 +1110,7 @@ local function on_entity_settings_pasted(event) destination_container.link_id = source_link_id destination_container.chest.link_id = source_link_id destination_container.mode = 2 - destination_container.chest.minable = false + destination_container.chest.minable_flag = false destination_container.chest.destructible = false destination_container.chest.get_inventory(defines.inventory.chest).set_bar() end @@ -1146,7 +1146,7 @@ function Public.migrate(source, destination) this.main_containers[destination.unit_number] = source_data - destination.minable = false + destination.minable_flag = false destination.destructible = false restore_link(source.unit_number, destination.unit_number) @@ -1178,7 +1178,7 @@ Event.on_nth_tick( if container.chest and container.chest.valid then if container.chest.surface.index == active_surface_index then if not WPT.locomotive.is_around_train(container.chest) then - container.chest.minable = true + container.chest.minable_flag = true container.chest.link_id = 99999 container.chest.get_inventory(defines.inventory.chest).set_bar(1) remove_chest(container.unit_number) @@ -1186,14 +1186,14 @@ Event.on_nth_tick( end end if container.chest.link_id == 99999 then - container.chest.minable = true + container.chest.minable_flag = true container.chest.get_inventory(defines.inventory.chest).set_bar(1) remove_chest(container.unit_number) goto continue end if container.mode == 1 then - container.chest.minable = false + container.chest.minable_flag = false end end if not container.chest or not container.chest.valid then @@ -1356,7 +1356,7 @@ Gui.on_click( container.chest.link_id = share_container.link_id container.link_id = share_container.link_id - container.chest.minable = false + container.chest.minable_flag = false this.linked_gui[event.player.name].updated = false if element and element.valid then @@ -1413,7 +1413,7 @@ Gui.on_click( container.chest.link_id = share_container.link_id container.link_id = share_container.link_id - container.chest.minable = false + container.chest.minable_flag = false this.linked_gui[event.player.name].updated = false refresh_main_frame({ unit_number = container.unit_number, player = event.player }) diff --git a/maps/mountain_fortress_v3/locomotive/market.lua b/maps/mountain_fortress_v3/locomotive/market.lua index be65974a..d2850d1e 100644 --- a/maps/mountain_fortress_v3/locomotive/market.lua +++ b/maps/mountain_fortress_v3/locomotive/market.lua @@ -55,7 +55,7 @@ local function add_mystical_chest(surface) end this.mystical_chest = surface.create_entity { name = 'requester-chest', position = { x = this.market.position.x, y = this.market.position.y + 2 }, force = 'neutral' } - this.mystical_chest.minable = false + this.mystical_chest.minable_flag = false this.mystical_chest.destructible = false if not this.mystical_chest_price then Public.add_mystical_chest() @@ -148,7 +148,6 @@ local function get_items(player) local aura_cost = round(fixed_prices.aura_cost * (1 + upgrades.aura_upgrades)) local xp_point_boost_cost = round(fixed_prices.xp_point_boost_cost * (1 + upgrades.xp_points_upgrade)) local explosive_bullets_cost = round(fixed_prices.explosive_bullets_cost) - local redraw_mystical_chest_cost = round(fixed_prices.redraw_mystical_chest_cost) local flamethrower_turrets_cost = round(fixed_prices.flamethrower_turrets_cost * (1 + flame_turret)) local land_mine_cost = round(fixed_prices.land_mine_cost * (1 + upgrades.landmine.bought)) local car_health_upgrade_pool = fixed_prices.car_health_upgrade_pool_cost @@ -304,17 +303,6 @@ local function get_items(player) } end - main_market_items['redraw_mystical_chest'] = { - stack = 1, - value = 'coin', - price = redraw_mystical_chest_cost, - tooltip = ({ 'main_market.mystical_chest' }), - sprite = 'achievement/logistic-network-embargo', - enabled = true, - upgrade = true, - static = true - } - if upgrades.explosive_bullets_purchased then main_market_items['explosive_bullets'] = { stack = 1, @@ -1352,27 +1340,6 @@ local function gui_click(event) return end - if name == 'redraw_mystical_chest' then - remove_item_count(player, item.value, item.price) - local message = ({ 'locomotive.mystical_bought_info', shopkeeper, player.name, format_number(item.price, true) }) - - Event.raise(Public.events.on_market_item_purchased, { cost = item.price }) - - Alert.alert_all_players(5, message) - Server.to_discord_bold( - table.concat { - player.name .. ' has rerolled the mystical chest for ' .. format_number(item.price) .. ' coins.' - } - ) - - Public.init_price_check(this.locomotive, this.mystical_chest) - - redraw_market_items(data.item_frame, player, data.search_text) - redraw_coins_left(data.coins_left, player) - - return - end - if name == 'explosive_bullets' then remove_item_count(player, item.value, item.price) local message = ({ diff --git a/maps/mountain_fortress_v3/locomotive/spawn_locomotive.lua b/maps/mountain_fortress_v3/locomotive/spawn_locomotive.lua index ed5c72fc..46778f43 100644 --- a/maps/mountain_fortress_v3/locomotive/spawn_locomotive.lua +++ b/maps/mountain_fortress_v3/locomotive/spawn_locomotive.lua @@ -119,7 +119,7 @@ local set_loco_cargo = end if surface.can_place_entity({ name = name, position = p[i] }) then local e = surface.create_entity({ name = name, position = p[i], force = 'neutral', create_build_effect_smoke = false }) - e.minable = false + e.minable_flag = false e.destructible = true e.health = random(15, 30) local inventory = e.get_inventory(defines.inventory.chest) @@ -224,8 +224,8 @@ function Public.locomotive_spawn(surface, position, reversed) end this.locomotive.color = { random(2, 255), random(60, 255), random(60, 255) } - this.locomotive.minable = false - this.locomotive_cargo.minable = false + this.locomotive.minable_flag = false + this.locomotive_cargo.minable_flag = false this.locomotive_cargo.operable = true local locomotive = ICW.register_wagon(this.locomotive) @@ -255,7 +255,7 @@ function Public.locomotive_spawn(surface, position, reversed) for _ = 1, extra_wagons do local new_wagon = surface.create_entity({ name = 'cargo-wagon', position = new_position, force = 'player', defines.direction.north }) if new_wagon and new_wagon.valid then - new_wagon.minable = false + new_wagon.minable_flag = false new_wagon.operable = true inc = inc + 7 new_position = { x = pos.x, y = pos.y + inc } diff --git a/maps/mountain_fortress_v3/loot.lua b/maps/mountain_fortress_v3/loot.lua index b5f4ef28..71e401b4 100644 --- a/maps/mountain_fortress_v3/loot.lua +++ b/maps/mountain_fortress_v3/loot.lua @@ -66,7 +66,7 @@ function Public.add_loot(surface, position, chest, collision) for _, item_stack in pairs(item_stacks) do container.insert(item_stack) end - container.minable = false + container.minable_flag = false if random(1, 8) == 1 then container.insert({ name = 'coin', count = random(1, 32) }) @@ -119,7 +119,7 @@ function Public.add_loot_rare(surface, position, chest, magic) for _, item_stack in pairs(item_stacks) do container.insert(item_stack) end - container.minable = false + container.minable_flag = false if random(1, 8) == 1 then container.insert({ name = 'coin', count = random(1, 32) }) diff --git a/maps/mountain_fortress_v3/main.lua b/maps/mountain_fortress_v3/main.lua index 6d3c4dea..c232a16b 100644 --- a/maps/mountain_fortress_v3/main.lua +++ b/maps/mountain_fortress_v3/main.lua @@ -43,6 +43,7 @@ local RPG_Progression = require 'utils.datastore.rpg_data' local OfflinePlayers = require 'modules.clear_vacant_players' local Beam = require 'modules.render_beam' local Commands = require 'utils.commands' +local RobotLimits = require 'modules.robot_limits' local send_ping_to_channel = Discord.channel_names.mtn_channel local role_to_mention = Discord.role_mentions.mtn_fortress @@ -412,7 +413,7 @@ function Public.pre_init_task(current_task) WD.set_track_bosses_only(true) WD.set_pause_waves_custom_callback(Public.pause_waves_custom_callback_token) WD.set_threat_event_custom_callback(Public.check_if_spawning_near_train_custom_callback) - WD.set('surface_index', this.active_surface_index) + WD.set('nest_building_density', 32) WD.set('spawn_position', { x = 0, y = 84 }) WD.set('game_lost', true) @@ -500,8 +501,8 @@ function Public.announce_new_map(current_task) Server.to_discord_named_raw(send_ping_to_channel, role_to_mention .. ' ** Mtn Fortress was just reset! **') end current_task.message = 'Announced new map!' - current_task.state = 'to_nauvis' - current_task.surface_name = 'nauvis' + current_task.state = 'to_fortress' + current_task.surface_name = 'fortress' current_task.delay = game.tick + 200 end @@ -525,7 +526,7 @@ function Public.move_players(current_task) current_task.state = 'pre_init_task' end -function Public.to_nauvis(current_task) +function Public.to_fortress(current_task) local surface = game.get_surface(current_task.surface_name) if not surface or not surface.valid then return @@ -567,7 +568,7 @@ function Public.to_nauvis(current_task) local starting_items = Public.get_func('starting_items') Public.equip_players(starting_items, false) - current_task.message = 'Moved players back to nauvis!' + current_task.message = 'Moved players back to fortress!' current_task.done = true end @@ -584,30 +585,33 @@ function Public.init_stateful(current_task) end current_task.message = 'Initialized stateful!' - current_task.state = 'clear_nauvis' + current_task.state = 'clear_fortress' end -function Public.create_custom_nauvis_surface(current_task) - local nauvis = game.surfaces['nauvis'] - if nauvis then - nauvis.clear() +function Public.create_custom_fortress_surface(current_task) + local fortress = game.surfaces['fortress'] + if fortress then + fortress.clear() end Public.set('active_surface_index', Public.create_surface()) - current_task.message = 'Created custom nauvis surface!' + local active_surface_index = Public.get('active_surface_index') + + WD.set('surface_index', active_surface_index) + current_task.message = 'Created custom fortress surface!' current_task.delay = game.tick + 300 current_task.state = 'reset_map' end -function Public.clear_nauvis(current_task) - local surface = game.surfaces['nauvis'] +function Public.clear_fortress(current_task) + local surface = game.surfaces['fortress'] surface.clear() surface.request_to_generate_chunks({ x = -20, y = -22 }, 1) surface.force_generate_chunk_requests() - current_task.state = 'create_custom_nauvis_surface' + current_task.state = 'create_custom_fortress_surface' current_task.delay = game.tick + 50 - current_task.message = 'Cleared nauvis!' + current_task.message = 'Cleared fortress!' end function Public.reset_map(current_task) @@ -778,6 +782,8 @@ function Public.init_mtn() WD.set_pause_waves_custom_callback(Public.pause_waves_custom_callback_token) WD.set_threat_event_custom_callback(Public.check_if_spawning_near_train_custom_callback) + RobotLimits.enable(false) + Explosives.disable(false) Explosives.slow_explode(true) BiterHealthBooster.acid_nova(true) @@ -820,7 +826,9 @@ function Public.init_mtn() Explosives.set_destructible_tile('water-mud', 1000) Explosives.set_destructible_tile('lab-dark-2', 1000) Explosives.set_whitelist_entity('straight-rail') - Explosives.set_whitelist_entity('curved-rail') + Explosives.set_whitelist_entity('curved-rail-a') + Explosives.set_whitelist_entity('curved-rail-b') + Explosives.set_whitelist_entity('half-diagonal-rail') Explosives.set_whitelist_entity('character') Explosives.set_whitelist_entity('spidertron') Explosives.set_whitelist_entity('car') diff --git a/maps/mountain_fortress_v3/mystical_chest.lua b/maps/mountain_fortress_v3/mystical_chest.lua index 322b8142..d62e8989 100644 --- a/maps/mountain_fortress_v3/mystical_chest.lua +++ b/maps/mountain_fortress_v3/mystical_chest.lua @@ -6,12 +6,15 @@ local Alert = require 'utils.alert' local Task = require 'utils.task_token' local StatData = require 'utils.datastore.statistics' +local zone_settings = Public.zone_settings local shuffle = table.shuffle_table local random = math.random local floor = math.floor local insert = table.insert local abs = math.abs +local modifier_cooldown = 108000 -- 30 minutes + local item_worths = { ['water-barrel'] = 4, ['copper-cable'] = 1, @@ -125,9 +128,13 @@ local function init_price_check(locomotive) if not (mystical_chest and mystical_chest.valid) then return end + local adjusted_zones = Public.get('adjusted_zones') + + local zone = floor((abs(locomotive.position.y / zone_settings.zone_depth)) % adjusted_zones.size) + 1 local roll = 48 + abs(locomotive.position.y) * 1.75 roll = roll * random(25, 1337) * 0.01 + roll = roll * zone local item_stacks = {} local roll_count = 2 @@ -194,6 +201,19 @@ local restore_crafting_speed_token = end ) +local restore_modifier_token = + Task.register( + function (event) + local mc_rewards = Public.get('mc_rewards') + local modifier = event.modifier + if not modifier then + return + end + + mc_rewards.temp_boosts[modifier] = false + end + ) + local restore_movement_speed_token = Task.register( function (event) @@ -211,10 +231,19 @@ local restore_movement_speed_token = local mc_random_rewards = { { name = 'XP', + str = 'xp', color = { r = 0.00, g = 0.45, b = 0.00 }, tooltip = 'Selecting this will insert random XP onto the global xp pool!', - func = (function (player) + func = (function (player, zone) + local mc_rewards = Public.get('mc_rewards') + if mc_rewards.temp_boosts.xp then + return false, '[Rewards] XP bonus is already applied and is on cooldown. Please choose another reward.' + end + mc_rewards.temp_boosts.xp = true + Task.set_timeout_in_ticks(modifier_cooldown, restore_modifier_token, { modifier = 'xp' }) local rng = random(2048, 10240) + local scale_factor = 0.5 + (zone / 20) + rng = floor(rng * scale_factor) RPG.add_to_global_pool(rng) local message = ({ 'locomotive.xp_bonus', player.name }) Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac') @@ -224,12 +253,22 @@ local mc_random_rewards = { }, { name = 'Coins', + str = 'coins', color = { r = 0.00, g = 0.35, b = 0.00 }, tooltip = 'Selecting this will grant each player some coins!', - func = (function (p) - local rng = random(512, 2048) + func = (function (p, zone) + local mc_rewards = Public.get('mc_rewards') + if mc_rewards.temp_boosts.coins then + return false, '[Rewards] Coin bonus is already applied and is on cooldown. Please choose another reward.' + end + + mc_rewards.temp_boosts.coins = true + Task.set_timeout_in_ticks(modifier_cooldown, restore_modifier_token, { modifier = 'coins' }) local players = game.connected_players for i = 1, #players do + local rng = random(256, 1024) + local scale_factor = 0.5 + (zone / 20) + rng = floor(rng * scale_factor) local player = players[i] if player and player.valid then if player.can_insert({ name = 'coin', count = rng }) then @@ -249,7 +288,7 @@ local mc_random_rewards = { str = 'movement', color = { r = 0.00, g = 0.25, b = 0.00 }, tooltip = 'Selecting this will grant the team a bonus movement speed for 15 minutes!', - func = (function (player) + func = (function (player, zone) local mc_rewards = Public.get('mc_rewards') local force = game.forces.player if mc_rewards.temp_boosts.movement then @@ -259,7 +298,12 @@ local mc_random_rewards = { mc_rewards.temp_boosts.movement = true Task.set_timeout_in_ticks(54000, restore_movement_speed_token, { speed = force.character_running_speed_modifier }) - force.character_running_speed_modifier = force.character_running_speed_modifier + 0.6 + local scale_factor = 0.5 + (zone / 10) + local speed = 0.6 * scale_factor + if speed > 1 then + speed = 1 + end + force.character_running_speed_modifier = force.character_running_speed_modifier + speed local message = ({ 'locomotive.movement_bonus', player.name }) Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac') return true @@ -290,6 +334,7 @@ local mc_random_rewards = { }, { name = 'Crafting speed bonus', + str = 'crafting', color = { r = 0.00, g = 0.00, b = 0.25 }, tooltip = 'Selecting this will grant all players 100% crafting bonus for 15 minutes!', func = (function (player) @@ -420,7 +465,16 @@ local function on_gui_click(event) for id, data in pairs(current) do if data.id == i then - local success, msg = mc_random_rewards[id].func(player) + local locomotive = Public.get('locomotive') + if not locomotive then + return + end + if not locomotive.valid then + return + end + local adjusted_zones = Public.get('adjusted_zones') + local zone = floor((abs(locomotive.position.y / zone_settings.zone_depth)) % adjusted_zones.size) + 1 + local success, msg = mc_random_rewards[id].func(player, zone) if not success then return player.print(msg, { color = Color.fail }) end @@ -504,6 +558,7 @@ function Public.add_mystical_chest(player) return end + local mystical_chest_price = Public.get('mystical_chest_price') local mystical_chest = Public.get('mystical_chest') if not (mystical_chest and mystical_chest.valid) then diff --git a/maps/mountain_fortress_v3/soft_reset.lua b/maps/mountain_fortress_v3/soft_reset.lua index 2cd881ec..3d8b5d7d 100644 --- a/maps/mountain_fortress_v3/soft_reset.lua +++ b/maps/mountain_fortress_v3/soft_reset.lua @@ -5,7 +5,7 @@ local Event = require 'utils.event' local mapkeeper = '[color=blue]Mapkeeper:[/color]' local function reset_forces() - local surface = game.get_surface('nauvis') + local surface = game.get_surface('fortress') if not surface or not surface.valid then return end @@ -21,7 +21,7 @@ local function reset_forces() end local function teleport_players() - local surface = game.get_surface('nauvis') + local surface = game.get_surface('fortress') if not surface or not surface.valid then return end @@ -141,18 +141,18 @@ function Public.soft_reset_map(old_surface) end this.soft_reset_counter = this.soft_reset_counter + 1 - local nauvis = game.surfaces.nauvis - nauvis.clear(true) - -- nauvis.request_to_generate_chunks({ 0, 0 }, 1) - -- nauvis.force_generate_chunk_requests() + local fortress = game.surfaces.fortress + fortress.clear(true) + -- fortress.request_to_generate_chunks({ 0, 0 }, 1) + -- fortress.force_generate_chunk_requests() local radius = 512 local area = { { x = -radius, y = -radius }, { x = radius, y = radius } } - for _, entity in pairs(nauvis.find_entities_filtered { area = area, type = 'logistic-robot' }) do + for _, entity in pairs(fortress.find_entities_filtered { area = area, type = 'logistic-robot' }) do entity.destroy() end - for _, entity in pairs(nauvis.find_entities_filtered { area = area, type = 'construction-robot' }) do + for _, entity in pairs(fortress.find_entities_filtered { area = area, type = 'construction-robot' }) do entity.destroy() end @@ -173,7 +173,7 @@ function Public.soft_reset_map(old_surface) game.print(message, { r = 0.98, g = 0.66, b = 0.22 }) Server.to_discord_embed(message_to_discord) - return nauvis + return fortress end Event.on_nth_tick(10, scheduled_surface_clearing) diff --git a/maps/mountain_fortress_v3/stateful/blueprints.lua b/maps/mountain_fortress_v3/stateful/blueprints.lua index af7064b5..0a6c39da 100644 --- a/maps/mountain_fortress_v3/stateful/blueprints.lua +++ b/maps/mountain_fortress_v3/stateful/blueprints.lua @@ -42,7 +42,7 @@ function Public.blueprint() local _, ent = ghost.silent_revive({ raise_revive = true }) if ent and ent.valid then ent.destructible = false - ent.minable = false + ent.minable_flag = false end end end diff --git a/maps/mountain_fortress_v3/stateful/table.lua b/maps/mountain_fortress_v3/stateful/table.lua index e8759b96..935163b8 100644 --- a/maps/mountain_fortress_v3/stateful/table.lua +++ b/maps/mountain_fortress_v3/stateful/table.lua @@ -476,7 +476,7 @@ local function get_item_produced_count(_, item_name) local loco_surface = Public.get('loco_surface') - local production = force.get_item_production_statistics('nauvis').input_counts[item_name] + local production = force.get_item_production_statistics('fortress').input_counts[item_name] if not production then production = 0 end @@ -520,7 +520,7 @@ local function get_entity_mined_count(_, item_name) local force = game.forces.player local count = 0 - for name, entity_count in pairs(force.get_entity_build_count_statistics('nauvis').output_counts) do + for name, entity_count in pairs(force.get_entity_build_count_statistics('fortress').output_counts) do if name:find(item_name) then count = count + entity_count end @@ -533,7 +533,7 @@ local function get_killed_enemies_count(primary, secondary) local force = game.forces.player local count = 0 - for name, entity_count in pairs(force.get_kill_count_statistics('nauvis').input_counts) do + for name, entity_count in pairs(force.get_kill_count_statistics('fortress').input_counts) do if name:find(primary) or name:find(secondary) then count = count + entity_count end diff --git a/maps/mountain_fortress_v3/surface.lua b/maps/mountain_fortress_v3/surface.lua index 11d3d91a..d2973a90 100644 --- a/maps/mountain_fortress_v3/surface.lua +++ b/maps/mountain_fortress_v3/surface.lua @@ -60,13 +60,13 @@ function Public.create_surface() if not this.active_surface_index then - this.active_surface_index = game.surfaces.nauvis.index + this.active_surface_index = game.surfaces.fortress.index -- this.active_surface_index = game.planets['fulgora'].create_surface(surface_name, map_gen_settings).index else this.active_surface_index = Public.soft_reset_map(game.surfaces[this.active_surface_index], map_gen_settings).index end - game.surfaces.nauvis.map_gen_settings = map_gen_settings + game.surfaces.fortress.map_gen_settings = map_gen_settings -- this.soft_reset_counter = Public.get_reset_counter() @@ -126,7 +126,7 @@ function Public.create_landing_surface() for _, entity in pairs(walls) do local e = surface.create_entity(entity) e.destructible = false - e.minable = false + e.minable_flag = false end rendering.draw_text { diff --git a/maps/mountain_fortress_v3/table.lua b/maps/mountain_fortress_v3/table.lua index c223367c..fd38a43b 100644 --- a/maps/mountain_fortress_v3/table.lua +++ b/maps/mountain_fortress_v3/table.lua @@ -52,7 +52,7 @@ Public.events = { local init_name = 'Init' Public.init_name = init_name -local scenario_name = 'nauvis' +local scenario_name = 'fortress' Public.scenario_name = scenario_name local discord_name = 'Mtn Fortress' Public.discord_name = discord_name @@ -207,7 +207,7 @@ function Public.reset_main_table() this.mined_scrap = 0 this.print_tech_to_discord = true this.biters_killed = 0 - this.cleared_nauvis = false + this.cleared_fortress = false this.locomotive_pos = { tbl = {} } this.trusted_only_car_tanks = true --!grief prevention @@ -303,7 +303,6 @@ function Public.reset_main_table() land_mine_cost = 2, car_health_upgrade_pool_cost = 100000, tile_when_mining_cost = random(45000, 70000), - redraw_mystical_chest_cost = 3000, roboport_cost = random(750, 1500), construction_bot_cost = random(150, 350), chest_cost = random(400, 600) diff --git a/maps/mountain_fortress_v3/terrain.lua b/maps/mountain_fortress_v3/terrain.lua index 5ac31947..10082fa2 100644 --- a/maps/mountain_fortress_v3/terrain.lua +++ b/maps/mountain_fortress_v3/terrain.lua @@ -688,57 +688,57 @@ local function wall(p, data) end elseif abs(p.y) < zone_settings.zone_depth * 2.5 then if random(1, 4) == 1 then - spawn_turret(entities, p, 3) + spawn_turret(entities, p, 1) else - spawn_turret(entities, p, 4) + spawn_turret(entities, p, 2) end elseif abs(p.y) < zone_settings.zone_depth * 3.5 then if random(1, 4) == 1 then - spawn_turret(entities, p, 5) + spawn_turret(entities, p, 2) else - spawn_turret(entities, p, 6) + spawn_turret(entities, p, 3) end elseif abs(p.y) < zone_settings.zone_depth * 4.5 then if random(1, 4) == 1 then - spawn_turret(entities, p, 7) + spawn_turret(entities, p, 4) else - spawn_turret(entities, p, 8) + spawn_turret(entities, p, 5) end elseif abs(p.y) < zone_settings.zone_depth * 5.5 then if random(1, 4) == 1 then - spawn_turret(entities, p, 9) + spawn_turret(entities, p, 6) elseif random(1, 2) == 1 then - spawn_turret(entities, p, 10) + spawn_turret(entities, p, 7) end elseif abs(p.y) < zone_settings.zone_depth * 6.5 then if random(1, 4) == 1 then - spawn_turret(entities, p, 11) + spawn_turret(entities, p, 8) elseif random(1, 2) == 1 then - spawn_turret(entities, p, 12) + spawn_turret(entities, p, 9) end elseif abs(p.y) < zone_settings.zone_depth * 7.5 then if random(1, 4) == 1 then - spawn_turret(entities, p, 13) + spawn_turret(entities, p, 10) elseif random(1, 2) == 1 then - spawn_turret(entities, p, 14) + spawn_turret(entities, p, 11) end elseif abs(p.y) < zone_settings.zone_depth * 8.5 then if random(1, 4) == 1 then - spawn_turret(entities, p, 15) + spawn_turret(entities, p, 12) elseif random(1, 2) == 1 then - spawn_turret(entities, p, 16) + spawn_turret(entities, p, 13) end elseif abs(p.y) < zone_settings.zone_depth * 9.5 then if random(1, 4) == 1 then - spawn_turret(entities, p, 17) + spawn_turret(entities, p, 14) elseif random(1, 2) == 1 then - spawn_turret(entities, p, 18) + spawn_turret(entities, p, 15) end elseif abs(p.y) < zone_settings.zone_depth * 10.5 then if random(1, 4) == 1 then - spawn_turret(entities, p, 19) + spawn_turret(entities, p, 16) elseif random(1, 2) == 1 then - spawn_turret(entities, p, 20) + spawn_turret(entities, p, 17) end end elseif abs(p.y) > zone_settings.zone_depth * 5.5 then diff --git a/utils/datastore/jail_data.lua b/utils/datastore/jail_data.lua index 74aa78ba..788a9c9d 100644 --- a/utils/datastore/jail_data.lua +++ b/utils/datastore/jail_data.lua @@ -320,7 +320,7 @@ local function create_gulag_surface() for _, entity in pairs(walls) do local e = surface.create_entity(entity) e.destructible = false - e.minable = false + e.minable_flag = false end rendering.draw_text {