diff --git a/antigrief.lua b/antigrief.lua index 6b6f7148..c94f29b4 100644 --- a/antigrief.lua +++ b/antigrief.lua @@ -187,7 +187,7 @@ local function on_player_ammo_inventory_changed(event) playtime = player.online_time + tracker[player.name] end if playtime < 1296000 then - if this.enable_capsule_warning then + if this.enable_capsule_warning then local nukes = player.remove_item({name = 'atomic-bomb', count = 1000}) if nukes > 0 then Utils.action_warning('{Nuke}', player.name .. ' tried to equip nukes but was not trusted.') @@ -671,17 +671,11 @@ end local function on_init() local branch_version = '0.18.35' local sub = string.sub - game.forces.player.research_queue_enabled = true local is_branch_18 = sub(branch_version, 3, 4) local get_active_version = sub(game.active_mods.base, 3, 4) local default = game.permissions.get_group('Default') - default.set_allows_action(defines.input_action.change_multiplayer_config, false) - default.set_allows_action(defines.input_action.edit_permission_group, false) - default.set_allows_action(defines.input_action.import_permissions_string, false) - default.set_allows_action(defines.input_action.delete_permission_group, false) - default.set_allows_action(defines.input_action.add_permission_group, false) - default.set_allows_action(defines.input_action.admin_action, false) + game.forces.player.research_queue_enabled = true is_branch_18 = is_branch_18 .. sub(branch_version, 6, 7) get_active_version = get_active_version .. sub(game.active_mods.base, 6, 7) diff --git a/maps/mountain_fortress_v3/entities.lua b/maps/mountain_fortress_v3/entities.lua index 9d8a8b36..5cd6f0d0 100644 --- a/maps/mountain_fortress_v3/entities.lua +++ b/maps/mountain_fortress_v3/entities.lua @@ -753,6 +753,12 @@ local function on_built_entity(event) return end + local map_name = 'mountain_fortress_v3' + + if string.sub(entity.surface.name, 0, #map_name) ~= map_name then + return + end + local upg = this.upgrades local surface = entity.surface @@ -814,6 +820,12 @@ local function on_robot_built_entity(event) return end + local map_name = 'mountain_fortress_v3' + + if string.sub(entity.surface.name, 0, #map_name) ~= map_name then + return + end + local upg = this.upgrades local surface = entity.surface diff --git a/maps/mountain_fortress_v3/locomotive.lua b/maps/mountain_fortress_v3/locomotive.lua index 053c3c00..ba5f84d1 100644 --- a/maps/mountain_fortress_v3/locomotive.lua +++ b/maps/mountain_fortress_v3/locomotive.lua @@ -3,6 +3,7 @@ local Event = require 'utils.event' local Market = require 'maps.mountain_fortress_v3.basic_markets' local ICW = require 'maps.mountain_fortress_v3.icw.main' local WPT = require 'maps.mountain_fortress_v3.table' +local Session = require 'utils.session_data' local Difficulty = require 'modules.difficulty_vote' local Jailed = require 'utils.jail_data' local RPG_Settings = require 'modules.rpg.table' @@ -56,33 +57,77 @@ end function Public.add_player_to_permission_group(player, group) local jailed = Jailed.get_jailed_table() + local enable_permission_group_disconnect = WPT.get('disconnect_wagon') + local tracker = Session.get_tracker_table() + + if player.admin then + return + end + + local playtime = player.online_time + if tracker[player.name] then + playtime = player.online_time + tracker[player.name] + end if jailed[player.name] then return end - if group == 'locomotive' then + if enable_permission_group_disconnect then local locomotive_group = game.permissions.get_group('locomotive') - if not locomotive_group then - locomotive_group = game.permissions.create_group('locomotive') - locomotive_group.set_allows_action(defines.input_action.cancel_craft, false) - locomotive_group.set_allows_action(defines.input_action.edit_permission_group, false) - locomotive_group.set_allows_action(defines.input_action.import_permissions_string, false) - locomotive_group.set_allows_action(defines.input_action.delete_permission_group, false) - locomotive_group.set_allows_action(defines.input_action.add_permission_group, false) - locomotive_group.set_allows_action(defines.input_action.admin_action, false) - locomotive_group.set_allows_action(defines.input_action.drop_item, false) - locomotive_group.set_allows_action(defines.input_action.place_equipment, false) - locomotive_group.set_allows_action(defines.input_action.take_equipment, false) - locomotive_group.set_allows_action(defines.input_action.disconnect_rolling_stock, false) - -- locomotive_group.set_allows_action(defines.input_action.connect_rolling_stock, false) + if locomotive_group then + locomotive_group.set_allows_action(defines.input_action.disconnect_rolling_stock, true) end - locomotive_group = game.permissions.get_group('locomotive') - locomotive_group.add_player(player) - elseif group == 'default' then - local default_group = game.permissions.get_group('Default') + else + local locomotive_group = game.permissions.get_group('locomotive') + if locomotive_group then + locomotive_group.set_allows_action(defines.input_action.disconnect_rolling_stock, false) + end + end - default_group.add_player(player) + local not_trusted = game.permissions.get_group('not_trusted') + if playtime < 2592000 then -- 12 hours + if not not_trusted then + not_trusted = game.permissions.create_group('not_trusted') + not_trusted.set_allows_action(defines.input_action.cancel_craft, false) + not_trusted.set_allows_action(defines.input_action.edit_permission_group, false) + not_trusted.set_allows_action(defines.input_action.import_permissions_string, false) + not_trusted.set_allows_action(defines.input_action.delete_permission_group, false) + not_trusted.set_allows_action(defines.input_action.add_permission_group, false) + not_trusted.set_allows_action(defines.input_action.admin_action, false) + not_trusted.set_allows_action(defines.input_action.drop_item, false) + not_trusted.set_allows_action(defines.input_action.place_equipment, false) + not_trusted.set_allows_action(defines.input_action.take_equipment, false) + not_trusted.set_allows_action(defines.input_action.disconnect_rolling_stock, false) + not_trusted.set_allows_action(defines.input_action.connect_rolling_stock, false) + end + not_trusted = game.permissions.get_group('not_trusted') + not_trusted.add_player(player) + else + if group == 'locomotive' then + local locomotive_group = game.permissions.get_group('locomotive') + if not locomotive_group then + locomotive_group = game.permissions.create_group('locomotive') + locomotive_group.set_allows_action(defines.input_action.cancel_craft, false) + locomotive_group.set_allows_action(defines.input_action.edit_permission_group, false) + locomotive_group.set_allows_action(defines.input_action.import_permissions_string, false) + locomotive_group.set_allows_action(defines.input_action.delete_permission_group, false) + locomotive_group.set_allows_action(defines.input_action.add_permission_group, false) + locomotive_group.set_allows_action(defines.input_action.admin_action, false) + locomotive_group.set_allows_action(defines.input_action.drop_item, false) + locomotive_group.set_allows_action(defines.input_action.place_equipment, false) + locomotive_group.set_allows_action(defines.input_action.take_equipment, false) + -- locomotive_group.set_allows_action(defines.input_action.disconnect_rolling_stock, false) + -- locomotive_group.set_allows_action(defines.input_action.connect_rolling_stock, false) + end + + locomotive_group = game.permissions.get_group('locomotive') + locomotive_group.add_player(player) + elseif group == 'default' then + local default_group = game.permissions.get_group('Default') + + default_group.add_player(player) + end end end @@ -941,6 +986,52 @@ local function on_player_changed_position(event) end end +local function spawn_biter() + local this = WPT.get() + local loco_surface = this.icw_locomotive.surface + + if not loco_surface.valid then + return + end + + local locomotive = this.icw_locomotive + + local center_position = { + x = locomotive.area.left_top.x + (locomotive.area.right_bottom.x - locomotive.area.left_top.x) * 0.5, + y = locomotive.area.left_top.y + (locomotive.area.right_bottom.y - locomotive.area.left_top.y) * 0.5 + } + + if not this.icw_area then + this.icw_area = center_position + end + + local position = loco_surface.find_non_colliding_position('market', center_position, 128, 0.5) + local biters = { + 'big-biter', + 'behemoth-biter', + 'big-spitter', + 'behemoth-spitter' + } + this.locomotive_biter = + loco_surface.create_entity( + {name = biters[math.random(1, 4)], position = position, force = 'player', create_build_effect_smoke = false} + ) + this.locomotive_biter.ai_settings.allow_destroy_when_commands_fail = false + this.locomotive_biter.ai_settings.allow_try_return_to_spawner = false + + rendering.draw_text { + text = 'please donĀ“t shoo at me', + surface = this.locomotive_biter.surface, + target = this.locomotive_biter, + target_offset = {0, -3.5}, + scale = 1.05, + font = 'default-large-semibold', + color = {r = 175, g = 75, b = 255}, + alignment = 'center', + scale_with_zoom = false + } +end + local function create_market(data, rebuild) local surface = data.surface local this = data.this @@ -1001,19 +1092,7 @@ local function create_market(data, rebuild) this.market.destructible = false - local position = loco_surface.find_non_colliding_position('market', center_position, 128, 0.5) - local biters = { - 'big-biter', - 'behemoth-biter', - 'big-spitter', - 'behemoth-spitter' - } - local e = - loco_surface.create_entity( - {name = biters[math.random(1, 4)], position = position, force = 'player', create_build_effect_smoke = false} - ) - e.ai_settings.allow_destroy_when_commands_fail = false - e.ai_settings.allow_try_return_to_spawner = false + spawn_biter() for x = center_position.x - 5, center_position.x + 5, 1 do for y = center_position.y - 5, center_position.y + 5, 1 do @@ -1293,6 +1372,59 @@ local function on_research_finished() Public.refresh_gui() end +local function shoo(event) + local icw_locomotive = WPT.get('icw_locomotive') + local loco_surface = icw_locomotive.surface + + if not loco_surface.valid then + return + end + + local player = game.players[event.player_index] + + if player and player.valid then + if player.surface.index ~= loco_surface.index then + return + end + end + + local locomotive_biter = WPT.get('locomotive_biter') + local surface = player.surface + local message = event.message + message = string.lower(message) + for word in string.gmatch(message, '%g+') do + if word == 'shoo' then + if not locomotive_biter then + spawn_biter() + return + end + surface.create_entity( + { + name = 'rocket', + position = locomotive_biter.position, + force = 'enemy', + speed = 1, + max_range = 1200, + target = locomotive_biter, + source = locomotive_biter + } + ) + if locomotive_biter and locomotive_biter.valid then + locomotive_biter.die() + WPT.set().locomotive_biter = nil + end + return + end + end +end + +local function on_console_chat(event) + if not event.player_index then + return + end + shoo(event) +end + local function tick() local ticker = game.tick @@ -1744,5 +1876,6 @@ Event.add(defines.events.on_robot_built_entity, on_built_entity) Event.add(defines.events.on_entity_died, on_player_and_robot_mined_entity) Event.add(defines.events.on_pre_player_mined_item, on_player_and_robot_mined_entity) Event.add(defines.events.on_robot_mined_entity, on_player_and_robot_mined_entity) +Event.add(defines.events.on_console_chat, on_console_chat) return Public diff --git a/maps/mountain_fortress_v3/main.lua b/maps/mountain_fortress_v3/main.lua index 464152db..2eec8de7 100644 --- a/maps/mountain_fortress_v3/main.lua +++ b/maps/mountain_fortress_v3/main.lua @@ -12,6 +12,7 @@ require 'modules.biters_yield_coins' require 'modules.wave_defense.main' require 'modules.mineable_wreckage_yields_scrap' require 'modules.charging_station' +require 'modules.admins_operate_biters' local Autostash = require 'modules.autostash' local PL = require 'comfy_panel.player_list' @@ -788,6 +789,17 @@ local on_init = function() Explosives.set_destructible_tile('water-mud', 1000) Explosives.set_whitelist_entity('straight-rail') Explosives.set_whitelist_entity('curved-rail') + Explosives.set_whitelist_entity('character') + + if global.biter_command and global.biter_command.whitelist then + global.biter_command.whitelist = { + ['Hanakocz'] = true, + ['mewmew'] = true, + ['Gerkiz'] = true + } + end + + global.biter_command.enabled = false end Event.on_nth_tick(10, on_tick) diff --git a/maps/mountain_fortress_v3/table.lua b/maps/mountain_fortress_v3/table.lua index 15f41a75..ec30348e 100644 --- a/maps/mountain_fortress_v3/table.lua +++ b/maps/mountain_fortress_v3/table.lua @@ -93,6 +93,8 @@ function Public.reset_table() randomized = false } this.collapse_grace = true + this.locomotive_biter = nil + this.disconnect_wagon = true end function Public.get(key) diff --git a/modules/admins_operate_biters.lua b/modules/admins_operate_biters.lua index 27797d29..6afd2ad6 100644 --- a/modules/admins_operate_biters.lua +++ b/modules/admins_operate_biters.lua @@ -6,6 +6,7 @@ global.biter_command.active_unit_groups = {} global.biter_command.enabled = true global.biter_command.whitelist = {} global.biter_command.admin_mode = true --if only admins can see and use the panel + global.biter_command.teleporting = false --if teleporting is allowed for non-admins global.biter_command.buildings = true ---if player can trigger building nests and worms @@ -618,14 +619,14 @@ local function on_player_joined_game(event) end local function on_unit_group_created(event) - if event and event.group then + if event and event.group and event.group.valid then global.biter_command.active_unit_groups[event.group.group_number] = {id = event.group.group_number, group = event.group} refresh_panel() end end local function on_unit_removed_from_group(event) - if event and event.group then + if event and event.group and event.group.valid then if #event.group.members == 1 then global.biter_command.active_unit_groups[event.group.group_number] = nil refresh_panel() diff --git a/modules/rpg/main.lua b/modules/rpg/main.lua index cb733e68..34f7944f 100644 --- a/modules/rpg/main.lua +++ b/modules/rpg/main.lua @@ -9,7 +9,6 @@ local Math2D = require 'math2d' --RPG Modules local RPG = require 'modules.rpg.table' -local Spells = require 'modules.rpg.spells' local Settings = require 'modules.rpg.settings' local Functions = require 'modules.rpg.functions' local RPG_GUI = require 'modules.rpg.gui' @@ -18,8 +17,6 @@ local RPG_GUI = require 'modules.rpg.gui' local enemy_types = RPG.enemy_types local die_cause = RPG.die_cause local rpg_frame_icons = RPG.rpg_frame_icons -local conjure_items = Spells.conjure_items -local projectile_types = Spells.projectile_types local points_per_level = RPG.points_per_level local nth_tick = RPG.nth_tick local visuals_delay = RPG.visuals_delay @@ -853,6 +850,10 @@ local function get_near_coord_modifier(range) end local function damage_entity(e) + if not e or not e.valid then + return + end + if not e.health then return end @@ -916,6 +917,9 @@ local function on_player_used_capsule(event) return end + local conjure_items = RPG.get_spells() + local projectile_types = RPG.get_projectiles + local player = game.players[event.player_index] if not player or not player.valid then return diff --git a/modules/rpg/settings.lua b/modules/rpg/settings.lua index a13e4016..5626cf6d 100644 --- a/modules/rpg/settings.lua +++ b/modules/rpg/settings.lua @@ -1,5 +1,4 @@ local RPG = require 'modules.rpg.table' -local Spells = require 'modules.rpg.spells' local Gui = require 'utils.gui' local P = require 'player_modifiers' local Session = require 'utils.session_data' @@ -29,7 +28,7 @@ function Public.extra_settings(player) local rpg_extra = RPG.get('rpg_extra') local rpg_t = RPG.get('rpg_t') local trusted = Session.get_trusted_table() - local conjure_items = Spells.conjure_items + local conjure_items = RPG.get_spells() local main_frame = player.gui.screen.add( { diff --git a/modules/rpg/table.lua b/modules/rpg/table.lua index c7b48635..e677f9d2 100644 --- a/modules/rpg/table.lua +++ b/modules/rpg/table.lua @@ -1,11 +1,13 @@ -- one table to rule them all! local Global = require 'utils.global' +local Spells = require 'modules.rpg.spells' local Event = require 'utils.event' local Gui = require 'utils.gui' local this = { rpg_extra = {}, - rpg_t = {} + rpg_t = {}, + rpg_spells = {} } --! Gui Frames @@ -120,6 +122,7 @@ function Public.reset_table() ['small-worm-turret'] = 16, ['spitter-spawner'] = 64 } + this.rpg_spells = Spells.conjure_items end --- Gets value from table @@ -272,6 +275,31 @@ function Public.enable_one_punch_globally(value) return this.rpg_extra.enable_one_punch_globally end +--- Retrieves the spell table. +---@param key +function Public.get_spells(key) + if key then + return this.rpg_spells[key] + else + return this.rpg_spells + end +end + +--- Adds a spell to the rpg_spells +---@param key +---@param value +function Public.set_spells(key, value) + if key and value then + this.rpg_spells[key] = value + return this.rpg_spells[key] + elseif key then + return this.rpg_spells[key] + else + return this.rpg_spells + end +end + +Public.get_projectiles = Spells.projectile_types Public.settings_frame_name = settings_frame_name Public.save_button_name = save_button_name Public.discard_button_name = discard_button_name