1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-21 21:17:04 +02:00

minor changes to fishy and mtn

This commit is contained in:
Gerkiz 2020-07-11 09:32:36 +02:00
parent cda53a6bdd
commit 647d52859c
7 changed files with 83 additions and 47 deletions

View File

@ -1,5 +1,5 @@
--antigrief things made by mewmew --antigrief things made by mewmew
--modified by gerkiz-- --rewritten by gerkiz--
--as an admin, write either /trust or /untrust and the players name in the chat to grant/revoke immunity from protection --as an admin, write either /trust or /untrust and the players name in the chat to grant/revoke immunity from protection
local Event = require 'utils.event' local Event = require 'utils.event'
@ -26,7 +26,7 @@ local this = {
players_warned = {}, players_warned = {},
log_tree_harvest = false, log_tree_harvest = false,
do_not_check_trusted = true, do_not_check_trusted = true,
protect_entities = false, protect_entities = true,
enable_autokick = true, enable_autokick = true,
enable_autoban = false enable_autoban = false
} }
@ -53,10 +53,50 @@ local ammo_names = {
['rocket'] = true ['rocket'] = true
} }
local not_protected = { local protected = {
['wall'] = true, ['reactor'] = true,
['container'] = true, ['roboport'] = true,
['logistic-container'] = true ['rocket-silo'] = true,
['solar-panel'] = true,
['generator'] = true,
['splitter'] = true,
['transport-belt'] = true,
['underground-belt'] = true,
['assembling-machine'] = true,
['storage-tank'] = true,
['pump'] = true,
['mining-drill'] = true,
['market'] = true,
['accumulator'] = true,
['ammo-turret'] = true,
['artillery-turret'] = true,
['artillery-wagon'] = true,
['beacon'] = true,
['boiler'] = true,
['burner-generator'] = true,
['car'] = true,
['cargo-wagon'] = true,
['constant-combinator'] = true,
['straight-rail'] = true,
['curved-rail'] = true,
['decider-combinator'] = true,
['electric-pole'] = true,
['electric-turret'] = true,
['fluid-turret'] = true,
['fluid-wagon'] = true,
['furnace'] = true,
['gate'] = true,
['heat-interface'] = true,
['heat-pipe'] = true,
['inserter'] = true,
['lab'] = true,
['lamp'] = true,
['loader'] = true,
['locomotive'] = true,
['logistic-robot'] = true,
['offshore-pump'] = true,
['pipe-to-ground'] = true,
['pipe'] = true
} }
Global.register( Global.register(
@ -637,11 +677,11 @@ local function protect_entities(event)
local entity = event.entity local entity = event.entity
local function is_protected(e) local function is_protected(e)
if not_protected[e.type] then if protected[e.type] then
return false return true
end end
return true return false
end end
if is_protected(entity) then if is_protected(entity) then
@ -649,21 +689,29 @@ local function protect_entities(event)
end end
end end
--- Protect entities from the player force
---@param event
local function on_entity_damaged(event) local function on_entity_damaged(event)
if not this.protect_entities then
return
end
local entity = event.entity local entity = event.entity
if not entity or not entity.valid then if not entity or not entity.valid then
return return
end end
if event.force.index ~= 1 then
return
end
if entity.force.index ~= 1 then if entity.force.index ~= 1 then
return return
end end
if this.protect_entities then
protect_entities(event) protect_entities(event)
end end
end
--- Enabling this will protect all entities except for those in the not_protected table. --- Enabling this will protect all entities except for those in the not_protected table.
---@param boolean true/false ---@param boolean true/false

View File

@ -478,10 +478,10 @@ local function player_list_show(player, frame, sort_by)
tooltip = 'This player is an admin of this server.' tooltip = 'This player is an admin of this server.'
elseif play_table[player_list[i].name] then elseif play_table[player_list[i].name] then
trusted = '[color=#008000][T][/color]' trusted = '[color=#008000][T][/color]'
tooltip = 'This player trusted.' tooltip = 'This player is trusted.'
else else
trusted = '[color=#ffff00][U][/color]' trusted = '[color=#ffff00][U][/color]'
tooltip = 'This player not trusted.' tooltip = 'This player is not trusted.'
end end
-- Name -- Name

View File

@ -1040,10 +1040,6 @@ local function on_player_joined_game(event)
return return
end end
if player.gui.left['fish_defense_game_lost'] then
player.gui.left['fish_defense_game_lost'].destroy()
end
if player.online_time == 0 then if player.online_time == 0 then
for item, amount in pairs(starting_items) do for item, amount in pairs(starting_items) do
player.insert({name = item, count = amount}) player.insert({name = item, count = amount})
@ -1058,7 +1054,7 @@ local function on_player_joined_game(event)
local pos = surface.find_non_colliding_position('character', spawn, 3, 0.5) local pos = surface.find_non_colliding_position('character', spawn, 3, 0.5)
if not pos and player.online_time < 2 then if not pos and player.online_time < 2 then
player.teleport(game.forces['player'].get_spawn_position(surface), surface) player.teleport(spawn, surface)
elseif player.online_time < 2 or player.surface.index ~= this.active_surface_index then elseif player.online_time < 2 or player.surface.index ~= this.active_surface_index then
player.teleport(pos, surface) player.teleport(pos, surface)
end end
@ -1434,6 +1430,8 @@ function Public.reset_game()
global.chunk_queue = {} global.chunk_queue = {}
Terrain.fish_eye(surface, {x = -2150, y = -300})
game.map_settings.enemy_expansion.enabled = false game.map_settings.enemy_expansion.enabled = false
game.map_settings.enemy_evolution.destroy_factor = 0 game.map_settings.enemy_evolution.destroy_factor = 0
game.map_settings.enemy_evolution.time_factor = 0 game.map_settings.enemy_evolution.time_factor = 0
@ -1533,17 +1531,4 @@ Event.add(defines.events.on_robot_mined_entity, on_robot_mined_entity)
Event.add(defines.events.on_tick, on_tick) Event.add(defines.events.on_tick, on_tick)
Event.on_init(on_init) Event.on_init(on_init)
local gmeta = getmetatable(_ENV)
if not gmeta then
gmeta = {}
setmetatable(_ENV, gmeta)
end
gmeta.__newindex = function(_, n, v)
log('Desync warning: attempt to write to undeclared var ' .. n)
global[n] = v
end
gmeta.__index = function(_, n)
return global[n]
end
return Public return Public

View File

@ -330,6 +330,7 @@ local function process_chunk_queue()
if chunks <= 0 then if chunks <= 0 then
return return
end end
for k, left_top in pairs(global.chunk_queue) do for k, left_top in pairs(global.chunk_queue) do
process_chunk(left_top) process_chunk(left_top)
global.chunk_queue[k] = nil global.chunk_queue[k] = nil
@ -480,8 +481,6 @@ function Public.generate_spawn_area(this, surface)
render_market_hp() render_market_hp()
Public.fish_eye(surface, {x = -2150, y = -300})
local r = 16 local r = 16
for _, entity in pairs( for _, entity in pairs(
surface.find_entities_filtered( surface.find_entities_filtered(
@ -544,6 +543,7 @@ end
function Public.fish_eye(surface, position) function Public.fish_eye(surface, position)
surface.request_to_generate_chunks(position, 2) surface.request_to_generate_chunks(position, 2)
surface.force_generate_chunk_requests()
for x = -48, 48, 1 do for x = -48, 48, 1 do
for y = -48, 48, 1 do for y = -48, 48, 1 do
local p = {x = position.x + x, y = position.y + y} local p = {x = position.x + x, y = position.y + y}

View File

@ -434,10 +434,10 @@ function Public.create_wagon_room(icw, wagon)
local multiple_chests = ICW.get('multiple_chests') local multiple_chests = ICW.get('multiple_chests')
local wagon_areas = ICW.get('wagon_areas') local wagon_areas = ICW.get('wagon_areas')
local cargo_wagon = wagon_areas['cargo-wagon'] local cargo_wagon = wagon_areas['cargo-wagon']
local position1 = {cargo_wagon.left_top.x + 7, cargo_wagon.left_top.y + 1} local position1 = {cargo_wagon.left_top.x + 4, cargo_wagon.left_top.y + 1}
local position2 = {cargo_wagon.right_bottom.x - 8, cargo_wagon.left_top.y + 1} local position2 = {cargo_wagon.right_bottom.x - 5, cargo_wagon.left_top.y + 1}
local position3 = {cargo_wagon.left_top.x + 7, cargo_wagon.right_bottom.y - 2} local position3 = {cargo_wagon.left_top.x + 4, cargo_wagon.right_bottom.y - 2}
local position4 = {cargo_wagon.right_bottom.x - 8, cargo_wagon.right_bottom.y - 2} local position4 = {cargo_wagon.right_bottom.x - 5, cargo_wagon.right_bottom.y - 2}
if multiple_chests then if multiple_chests then
local e1 = local e1 =

View File

@ -51,12 +51,11 @@ function Public.get(key)
end end
function Public.set_wagon_area(tbl) function Public.set_wagon_area(tbl)
local arg = tbl if not tbl then
if not arg then
return return
end end
this.wagon_areas = arg this.wagon_areas = tbl
end end
return Public return Public

View File

@ -244,8 +244,14 @@ function Public.reset_map()
Entities.set_scores() Entities.set_scores()
AntiGrief.log_tree_harvest(true) AntiGrief.log_tree_harvest(true)
AntiGrief.whitelist_types('tree', true) AntiGrief.whitelist_types('tree', true)
AntiGrief.protect_entities(true) --AntiGrief.protect_entities(true)
get_score.score_table = {}
local players = game.connected_players
for i = 1, #players do
local player = players[i]
Score.init_player_table(player)
end
Difficulty.reset_difficulty_poll({difficulty_poll_closing_timeout = game.tick + 36000}) Difficulty.reset_difficulty_poll({difficulty_poll_closing_timeout = game.tick + 36000})
Diff.gui_width = 20 Diff.gui_width = 20
@ -259,7 +265,7 @@ function Public.reset_map()
Collapse.set_direction('north') Collapse.set_direction('north')
Collapse.start_now(false) Collapse.start_now(false)
local x_value = rng(15, 25) --[[ local x_value = rng(15, 25)
local y_value = rng(50, 60) local y_value = rng(50, 60)
local data = { local data = {
@ -268,9 +274,7 @@ function Public.reset_map()
['fluid-wagon'] = {left_top = {x = -x_value, y = 0}, right_bottom = {x = x_value, y = y_value}}, ['fluid-wagon'] = {left_top = {x = -x_value, y = 0}, right_bottom = {x = x_value, y = y_value}},
['locomotive'] = {left_top = {x = -x_value, y = 0}, right_bottom = {x = x_value, y = y_value}} ['locomotive'] = {left_top = {x = -x_value, y = 0}, right_bottom = {x = x_value, y = y_value}}
} }
ICT.set_wagon_area(data) ]]
ICT.set_wagon_area(data)
this.locomotive_health = 10000 this.locomotive_health = 10000
this.locomotive_max_health = 10000 this.locomotive_max_health = 10000