mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-17 20:58:13 +02:00
pp: add annihilation ending
Map will be reset, when this happens.
This commit is contained in:
parent
5ef9052b16
commit
9e5012c582
@ -1,6 +1,7 @@
|
||||
global.this = {}
|
||||
local _global = require("utils.global")
|
||||
local _evt = require("utils.event")
|
||||
local _server = require("utils.server")
|
||||
local _map = require("tools.map_functions")
|
||||
local _timers = require("planet_prison.mod.timers")
|
||||
local _common = require("planet_prison.mod.common")
|
||||
@ -227,6 +228,12 @@ local function init_merchant_bp(entity, _)
|
||||
end
|
||||
end
|
||||
|
||||
local function create_orbit_group()
|
||||
local orbit = game.permissions.create_group("orbit")
|
||||
for _, perm in pairs(global.this._config.permission_orbit) do
|
||||
orbit.set_allows_action(perm, false)
|
||||
end
|
||||
end
|
||||
|
||||
global.this.bp = {
|
||||
player_ship = require("planet_prison.bp.player_ship"),
|
||||
@ -254,7 +261,10 @@ local function init_game()
|
||||
global.this.events.merchant.spawn_tick = game.tick + 5000
|
||||
global.this.events.raid_groups = {}
|
||||
global.this.events.raid_init = false
|
||||
global.this.events.annihilation = false
|
||||
global.this.events.reset_time = nil
|
||||
|
||||
create_orbit_group()
|
||||
game.map_settings.pollution.enabled = false
|
||||
game.map_settings.enemy_evolution.enabled = false
|
||||
game.difficulty_settings.technology_price_multiplier = 0.1
|
||||
@ -404,11 +414,28 @@ local function switchable_perk(caption, status)
|
||||
return string.format("[color=80,0,0]%s[/color]", caption)
|
||||
end
|
||||
|
||||
local function redraw_gui(p)
|
||||
p.gui.left.clear()
|
||||
|
||||
local function draw_normal_gui(player)
|
||||
local button
|
||||
local merchant = global.this.events.merchant
|
||||
local perks = global.this.perks[p.name]
|
||||
if merchant.alive then
|
||||
button = {
|
||||
type = "button",
|
||||
name = "merchant_find",
|
||||
caption = "Merchant",
|
||||
}
|
||||
player.gui.left.add(button)
|
||||
end
|
||||
|
||||
button = {
|
||||
type = "button",
|
||||
name = "flashlight_toggle",
|
||||
caption = "Toggle flashlight"
|
||||
}
|
||||
player.gui.left.add(button)
|
||||
end
|
||||
|
||||
local function draw_common_gui(player)
|
||||
local perks = global.this.perks[player.name]
|
||||
local chat_type = "Global chat"
|
||||
if not perks.chat_global then
|
||||
chat_type = "NAP chat"
|
||||
@ -419,30 +446,33 @@ local function redraw_gui(p)
|
||||
name = "manual_toggle",
|
||||
caption = "Manual"
|
||||
}
|
||||
p.gui.left.add(button)
|
||||
player.gui.left.add(button)
|
||||
|
||||
button = {
|
||||
type = "button",
|
||||
name = "chat_toggle",
|
||||
caption = chat_type,
|
||||
}
|
||||
p.gui.left.add(button)
|
||||
player.gui.left.add(button)
|
||||
end
|
||||
|
||||
if merchant.alive then
|
||||
button = {
|
||||
type = "button",
|
||||
name = "merchant_find",
|
||||
caption = "Merchant",
|
||||
}
|
||||
p.gui.left.add(button)
|
||||
end
|
||||
|
||||
button = {
|
||||
local function draw_orbit_gui(player)
|
||||
local button = {
|
||||
type = "button",
|
||||
name = "flashlight_toggle",
|
||||
caption = "Toggle flashlight"
|
||||
name = "annihilate",
|
||||
caption = "Annihilate"
|
||||
}
|
||||
p.gui.left.add(button)
|
||||
player.gui.left.add(button)
|
||||
end
|
||||
|
||||
local function redraw_gui(player)
|
||||
player.gui.left.clear()
|
||||
draw_common_gui(player)
|
||||
if player.spectator == true then
|
||||
draw_orbit_gui(player)
|
||||
else
|
||||
draw_normal_gui(player)
|
||||
end
|
||||
end
|
||||
|
||||
local function print_merchant_position(player)
|
||||
@ -456,6 +486,56 @@ local function print_merchant_position(player)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_tick_reset()
|
||||
if global.this.events.reset_time == nil then
|
||||
return
|
||||
end
|
||||
|
||||
if global.this.events.reset_time > game.tick then
|
||||
return
|
||||
end
|
||||
|
||||
_server.start_scenario('planet_prison')
|
||||
global.this.events.reset_time = nil
|
||||
end
|
||||
|
||||
local function annihilate(caller)
|
||||
global.this.events.annihilation = true
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if player.name == caller.name then
|
||||
goto continue
|
||||
end
|
||||
|
||||
local coeff
|
||||
for i = 1, 5 do
|
||||
if i % 2 == 0 then
|
||||
coeff = -1
|
||||
else
|
||||
coeff = 1
|
||||
end
|
||||
|
||||
local query = {
|
||||
name = "atomic-rocket",
|
||||
position = {
|
||||
player.position.x - 100,
|
||||
player.position.y - 100,
|
||||
},
|
||||
target = {
|
||||
player.position.x + (8 * i * coeff),
|
||||
player.position.y + (8 * i * coeff),
|
||||
},
|
||||
speed = 0.1,
|
||||
}
|
||||
|
||||
player.surface.create_entity(query)
|
||||
player.print(">> Annihilation in progress...")
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
|
||||
global.this.events.reset_time = game.tick + (60 * 15)
|
||||
end
|
||||
|
||||
local function on_gui_click(e)
|
||||
local elem = e.element
|
||||
local p = game.players[e.player_index]
|
||||
@ -498,6 +578,13 @@ local function on_gui_click(e)
|
||||
text_box.style.minimal_width = 512
|
||||
text_box.read_only = true
|
||||
text_box.word_wrap = true
|
||||
elseif elem.name == "annihilate" then
|
||||
if global.this.events.annihilation == true then
|
||||
return
|
||||
end
|
||||
|
||||
elem.destroy()
|
||||
annihilate(p)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1291,6 +1378,19 @@ local function on_research_finished(e)
|
||||
end
|
||||
end
|
||||
|
||||
local function move_to_orbit(player)
|
||||
local char = player.character
|
||||
player.character = nil
|
||||
char.destroy()
|
||||
|
||||
game.merge_forces(player.name, "neutral")
|
||||
player.spectator = true
|
||||
redraw_gui(player)
|
||||
|
||||
local orbit_perms = game.permissions.get_group("orbit")
|
||||
orbit_perms.add_player(player)
|
||||
end
|
||||
|
||||
local function on_rocket_launched(e)
|
||||
local surf = global.this.surface
|
||||
local pid = e.player_index
|
||||
@ -1298,10 +1398,9 @@ local function on_rocket_launched(e)
|
||||
if pid == nil then
|
||||
surf.print(">> Nobody escaped by it")
|
||||
else
|
||||
local p = game.players[pid]
|
||||
surf.print(string.format(">> The %s was able to escape", p.name))
|
||||
on_player_died({player_index = pid})
|
||||
p.character.die()
|
||||
local player = game.players[pid]
|
||||
surf.print(string.format(">> The %s was able to escape", player.name))
|
||||
move_to_orbit(player)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1325,6 +1424,7 @@ _evt.add(defines.events.on_chunk_charted, on_chunk_charted)
|
||||
_evt.add(defines.events.on_console_chat, on_console_chat)
|
||||
_evt.add(defines.events.on_gui_click, on_gui_click)
|
||||
_evt.add(defines.events.on_tick, on_tick)
|
||||
_evt.add(defines.events.on_tick, on_tick_reset)
|
||||
_evt.add(defines.events.on_rocket_launched, on_rocket_launched)
|
||||
|
||||
_global.register_init({},
|
||||
|
@ -35,6 +35,178 @@ public.player_ship_loot = {
|
||||
}
|
||||
}
|
||||
|
||||
public.permission_orbit = {
|
||||
defines.input_action.activate_copy,
|
||||
defines.input_action.activate_cut,
|
||||
defines.input_action.activate_paste,
|
||||
defines.input_action.add_permission_group,
|
||||
defines.input_action.add_train_station,
|
||||
defines.input_action.admin_action,
|
||||
defines.input_action.alt_select_area,
|
||||
defines.input_action.alt_select_blueprint_entities,
|
||||
defines.input_action.alternative_copy,
|
||||
defines.input_action.begin_mining,
|
||||
defines.input_action.begin_mining_terrain,
|
||||
defines.input_action.build_item,
|
||||
defines.input_action.build_rail,
|
||||
defines.input_action.build_terrain,
|
||||
defines.input_action.cancel_craft,
|
||||
defines.input_action.cancel_deconstruct,
|
||||
defines.input_action.cancel_new_blueprint,
|
||||
defines.input_action.cancel_research,
|
||||
defines.input_action.cancel_upgrade,
|
||||
defines.input_action.change_active_item_group_for_crafting,
|
||||
defines.input_action.change_active_item_group_for_filters,
|
||||
defines.input_action.change_active_quick_bar,
|
||||
defines.input_action.change_arithmetic_combinator_parameters,
|
||||
defines.input_action.change_blueprint_book_record_label,
|
||||
defines.input_action.change_decider_combinator_parameters,
|
||||
defines.input_action.change_item_label,
|
||||
defines.input_action.change_multiplayer_config,
|
||||
defines.input_action.change_picking_state,
|
||||
defines.input_action.change_programmable_speaker_alert_parameters,
|
||||
defines.input_action.change_programmable_speaker_circuit_parameters,
|
||||
defines.input_action.change_programmable_speaker_parameters,
|
||||
defines.input_action.change_riding_state,
|
||||
defines.input_action.change_shooting_state,
|
||||
defines.input_action.change_single_blueprint_record_label,
|
||||
defines.input_action.change_train_stop_station,
|
||||
defines.input_action.change_train_wait_condition,
|
||||
defines.input_action.change_train_wait_condition_data,
|
||||
defines.input_action.clean_cursor_stack,
|
||||
defines.input_action.clear_selected_blueprint,
|
||||
defines.input_action.clear_selected_deconstruction_item,
|
||||
defines.input_action.clear_selected_upgrade_item,
|
||||
defines.input_action.connect_rolling_stock,
|
||||
defines.input_action.copy_entity_settings,
|
||||
defines.input_action.craft,
|
||||
defines.input_action.create_blueprint_like,
|
||||
defines.input_action.cursor_split,
|
||||
defines.input_action.cursor_transfer,
|
||||
defines.input_action.custom_input,
|
||||
defines.input_action.cycle_blueprint_book_backwards,
|
||||
defines.input_action.cycle_blueprint_book_forwards,
|
||||
defines.input_action.deconstruct,
|
||||
defines.input_action.delete_blueprint_library,
|
||||
defines.input_action.delete_blueprint_record,
|
||||
defines.input_action.delete_custom_tag,
|
||||
defines.input_action.delete_permission_group,
|
||||
defines.input_action.destroy_opened_item,
|
||||
defines.input_action.disconnect_rolling_stock,
|
||||
defines.input_action.drag_train_schedule,
|
||||
defines.input_action.drag_train_wait_condition,
|
||||
defines.input_action.drop_blueprint_record,
|
||||
defines.input_action.drop_item,
|
||||
defines.input_action.drop_to_blueprint_book,
|
||||
defines.input_action.edit_custom_tag,
|
||||
defines.input_action.edit_permission_group,
|
||||
defines.input_action.export_blueprint,
|
||||
defines.input_action.fast_entity_split,
|
||||
defines.input_action.fast_entity_transfer,
|
||||
defines.input_action.go_to_train_station,
|
||||
defines.input_action.grab_blueprint_record,
|
||||
defines.input_action.import_blueprint,
|
||||
defines.input_action.import_blueprint_string,
|
||||
defines.input_action.import_permissions_string,
|
||||
defines.input_action.inventory_split,
|
||||
defines.input_action.inventory_transfer,
|
||||
defines.input_action.launch_rocket,
|
||||
defines.input_action.lua_shortcut,
|
||||
defines.input_action.map_editor_action,
|
||||
defines.input_action.market_offer,
|
||||
defines.input_action.mod_settings_changed,
|
||||
defines.input_action.open_achievements_gui,
|
||||
defines.input_action.open_blueprint_library_gui,
|
||||
defines.input_action.open_blueprint_record,
|
||||
defines.input_action.open_bonus_gui,
|
||||
defines.input_action.open_character_gui,
|
||||
defines.input_action.open_equipment,
|
||||
defines.input_action.open_gui,
|
||||
defines.input_action.open_item,
|
||||
defines.input_action.open_kills_gui,
|
||||
defines.input_action.open_logistic_gui,
|
||||
defines.input_action.open_mod_item,
|
||||
defines.input_action.open_production_gui,
|
||||
defines.input_action.open_technology_gui,
|
||||
defines.input_action.open_train_gui,
|
||||
defines.input_action.open_train_station_gui,
|
||||
defines.input_action.open_trains_gui,
|
||||
defines.input_action.open_tutorials_gui,
|
||||
defines.input_action.paste_entity_settings,
|
||||
defines.input_action.place_equipment,
|
||||
defines.input_action.quick_bar_pick_slot,
|
||||
defines.input_action.quick_bar_set_selected_page,
|
||||
defines.input_action.quick_bar_set_slot,
|
||||
defines.input_action.remove_cables,
|
||||
defines.input_action.remove_train_station,
|
||||
defines.input_action.reset_assembling_machine,
|
||||
defines.input_action.rotate_entity,
|
||||
defines.input_action.select_area,
|
||||
defines.input_action.select_blueprint_entities,
|
||||
defines.input_action.select_entity_slot,
|
||||
defines.input_action.select_item,
|
||||
defines.input_action.select_mapper_slot,
|
||||
defines.input_action.select_next_valid_gun,
|
||||
defines.input_action.select_tile_slot,
|
||||
defines.input_action.set_auto_launch_rocket,
|
||||
defines.input_action.set_autosort_inventory,
|
||||
defines.input_action.set_behavior_mode,
|
||||
defines.input_action.set_car_weapons_control,
|
||||
defines.input_action.set_circuit_condition,
|
||||
defines.input_action.set_circuit_mode_of_operation,
|
||||
defines.input_action.set_deconstruction_item_tile_selection_mode,
|
||||
defines.input_action.set_deconstruction_item_trees_and_rocks_only,
|
||||
defines.input_action.set_entity_color,
|
||||
defines.input_action.set_entity_energy_property,
|
||||
defines.input_action.set_filter,
|
||||
defines.input_action.set_heat_interface_mode,
|
||||
defines.input_action.set_heat_interface_temperature,
|
||||
defines.input_action.set_infinity_container_filter_item,
|
||||
defines.input_action.set_infinity_container_remove_unfiltered_items,
|
||||
defines.input_action.set_infinity_pipe_filter,
|
||||
defines.input_action.set_inserter_max_stack_size,
|
||||
defines.input_action.set_inventory_bar,
|
||||
defines.input_action.set_logistic_filter_item,
|
||||
defines.input_action.set_logistic_filter_signal,
|
||||
defines.input_action.set_logistic_trash_filter_item,
|
||||
defines.input_action.set_request_from_buffers,
|
||||
defines.input_action.set_research_finished_stops_game,
|
||||
defines.input_action.set_signal,
|
||||
defines.input_action.set_single_blueprint_record_icon,
|
||||
defines.input_action.set_splitter_priority,
|
||||
defines.input_action.set_train_stopped,
|
||||
defines.input_action.setup_assembling_machine,
|
||||
defines.input_action.setup_blueprint,
|
||||
defines.input_action.setup_single_blueprint_record,
|
||||
defines.input_action.smart_pipette,
|
||||
defines.input_action.stack_split,
|
||||
defines.input_action.stack_transfer,
|
||||
defines.input_action.start_repair,
|
||||
defines.input_action.start_research,
|
||||
defines.input_action.stop_building_by_moving,
|
||||
defines.input_action.switch_connect_to_logistic_network,
|
||||
defines.input_action.switch_constant_combinator_state,
|
||||
defines.input_action.switch_inserter_filter_mode_state,
|
||||
defines.input_action.switch_power_switch_state,
|
||||
defines.input_action.switch_to_rename_stop_gui,
|
||||
defines.input_action.take_equipment,
|
||||
defines.input_action.toggle_deconstruction_item_entity_filter_mode,
|
||||
defines.input_action.toggle_deconstruction_item_tile_filter_mode,
|
||||
defines.input_action.toggle_driving,
|
||||
defines.input_action.toggle_enable_vehicle_logistics_while_moving,
|
||||
defines.input_action.toggle_equipment_movement_bonus,
|
||||
defines.input_action.toggle_map_editor,
|
||||
defines.input_action.toggle_personal_roboport,
|
||||
defines.input_action.toggle_show_entity_info,
|
||||
defines.input_action.translate_string,
|
||||
defines.input_action.undo,
|
||||
defines.input_action.upgrade,
|
||||
defines.input_action.upgrade_opened_blueprint,
|
||||
defines.input_action.use_artillery_remote,
|
||||
defines.input_action.use_item,
|
||||
defines.input_action.wire_dragging,
|
||||
}
|
||||
|
||||
public.self_explode = 60 * 60 * 10
|
||||
public.claim_markers = {
|
||||
"gun-turret",
|
||||
|
Loading…
x
Reference in New Issue
Block a user