mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2024-12-30 23:17:53 +02:00
more changes to mtn fortress
This commit is contained in:
parent
c5b9bc1346
commit
6d21857adb
@ -143,7 +143,7 @@ local function protect_entities(event)
|
||||
end
|
||||
|
||||
if is_protected(entity) then
|
||||
if event.cause then
|
||||
if event.cause and event.cause.valid then
|
||||
if event.cause.force.index == 2 and entity.unit_number == this.locomotive.unit_number then
|
||||
set_objective_health(event.final_damage_amount)
|
||||
elseif event.cause.force.index == 2 then
|
||||
@ -725,6 +725,7 @@ function Public.loco_died()
|
||||
rendering.set_text(this.health_text, 'HP: ' .. this.locomotive_health .. ' / ' .. this.locomotive_max_health)
|
||||
wave_defense_table.game_lost = true
|
||||
wave_defense_table.target = nil
|
||||
this.game_lost = true
|
||||
local msg
|
||||
if this.soft_reset then
|
||||
msg =
|
||||
|
@ -9,7 +9,8 @@ local this = {
|
||||
refill_turrets = {index = 1},
|
||||
magic_crafters = {index = 1},
|
||||
magic_fluid_crafters = {index = 1},
|
||||
art_table = {index = 1}
|
||||
art_table = {index = 1},
|
||||
surface_cleared = false
|
||||
}
|
||||
|
||||
Global.register(
|
||||
|
@ -5,10 +5,6 @@ local Token = require 'utils.token'
|
||||
|
||||
local Public = {}
|
||||
|
||||
function Public.request_reconstruction(ic)
|
||||
ic.rebuild_tick = game.tick + 30
|
||||
end
|
||||
|
||||
local function validate_entity(entity)
|
||||
if not entity then
|
||||
return false
|
||||
@ -19,6 +15,14 @@ local function validate_entity(entity)
|
||||
return true
|
||||
end
|
||||
|
||||
local function log_err(ic, err)
|
||||
if ic.debug_mode then
|
||||
if type(err) == 'string' then
|
||||
log('IC: ' .. err)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function upperCase(str)
|
||||
return (str:gsub('^%l', string.upper))
|
||||
end
|
||||
@ -62,25 +66,43 @@ local function get_saved_entity(cars, entity, index)
|
||||
for k, car in pairs(cars) do
|
||||
if index and index.name ~= entity.name then
|
||||
local msg =
|
||||
'The built entity is not the same as the saved one. ' ..
|
||||
upperCase(car.name) .. ' is not equal to ' .. upperCase(entity.name) .. '.'
|
||||
table.concat(
|
||||
{
|
||||
'The built entity is not the same as the saved one. ',
|
||||
'Saved entity is: ' ..
|
||||
upperCase(car.name) .. ' - Built entity is: ' .. upperCase(entity.name) .. '. ',
|
||||
'This is not a bug. Do not report this!'
|
||||
}
|
||||
)
|
||||
return false, msg
|
||||
end
|
||||
if car.entity == false then
|
||||
t[unit_number] = car
|
||||
t[unit_number].entity = entity
|
||||
t[unit_number].transfer_entities = car.transfer_entities
|
||||
t[k] = nil
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function replace_doors(t, saved, entity)
|
||||
for k, door in pairs(t) do
|
||||
local function replace_entity(cars, entity, index)
|
||||
local unit_number = entity.unit_number
|
||||
for k, car in pairs(cars) do
|
||||
if car.saved_entity == index.saved_entity then
|
||||
local c = car
|
||||
cars[unit_number] = c
|
||||
cars[unit_number].entity = entity
|
||||
cars[unit_number].saved_entity = nil
|
||||
cars[unit_number].transfer_entities = car.transfer_entities
|
||||
cars[k] = nil
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function replace_doors(doors, entity, index)
|
||||
if not validate_entity(entity) then
|
||||
return
|
||||
end
|
||||
for k, door in pairs(doors) do
|
||||
local unit_number = entity.unit_number
|
||||
if saved == door then
|
||||
t[k] = unit_number
|
||||
if index.saved_entity == door then
|
||||
doors[k] = unit_number
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -163,8 +185,9 @@ local function save_surface(ic, entity, player)
|
||||
local car = ic.cars[entity.unit_number]
|
||||
|
||||
car.entity = false
|
||||
car.saved_entity = entity.unit_number
|
||||
|
||||
ic.saved_surfaces[player.index] = entity.unit_number
|
||||
ic.saved_surfaces[player.index] = {saved_entity = entity.unit_number, name = entity.name}
|
||||
end
|
||||
|
||||
local function validate_player(player)
|
||||
@ -186,15 +209,6 @@ local function validate_player(player)
|
||||
return true
|
||||
end
|
||||
|
||||
local function delete_empty_surfaces(ic)
|
||||
for k, surface in pairs(ic.surfaces) do
|
||||
if not ic.cars[tonumber(surface.name)] or ic.cars.entity == false then
|
||||
game.delete_surface(surface)
|
||||
ic.surfaces[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function kick_players_out_of_vehicles(car)
|
||||
for _, player in pairs(game.connected_players) do
|
||||
local character = player.character
|
||||
@ -207,6 +221,10 @@ local function kick_players_out_of_vehicles(car)
|
||||
end
|
||||
|
||||
local function kick_player_from_surface(car)
|
||||
if not car.surface or not car.surface.valid then
|
||||
return log_err('Car surface was not valid.')
|
||||
end
|
||||
|
||||
for _, e in pairs(car.surface.find_entities_filtered({area = car.area})) do
|
||||
if e and e.valid and e.name == 'character' and e.player then
|
||||
local p = car.entity.surface.find_non_colliding_position('character', car.entity.position, 128, 0.5)
|
||||
@ -219,8 +237,37 @@ local function kick_player_from_surface(car)
|
||||
end
|
||||
end
|
||||
|
||||
local function restore_surface(ic, player, entity)
|
||||
local ce = entity
|
||||
local saved_surfaces = ic.saved_surfaces
|
||||
local cars = ic.cars
|
||||
local door = ic.doors
|
||||
local surfaces = ic.surfaces
|
||||
local index = saved_surfaces[player.index]
|
||||
if not index then
|
||||
return
|
||||
end
|
||||
|
||||
if saved_surfaces[player.index] then
|
||||
local success, msg = get_saved_entity(cars, ce, index)
|
||||
if not success then
|
||||
player.print(msg, Color.warning)
|
||||
ce.destroy()
|
||||
return true
|
||||
end
|
||||
replace_entity(cars, ce, index)
|
||||
replace_doors(door, ce, index)
|
||||
replace_surface(surfaces, ce, index)
|
||||
replace_surface_entity(cars, ce, index)
|
||||
saved_surfaces[player.index] = nil
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function input_filtered(car_inv, chest, chest_inv, free_slots)
|
||||
local request_stacks = {}
|
||||
|
||||
local prototypes = game.item_prototypes
|
||||
for slot_index = 1, 30, 1 do
|
||||
local stack = chest.get_request_slot(slot_index)
|
||||
@ -261,6 +308,7 @@ local function input_cargo(car, chest)
|
||||
|
||||
local chest_inventory = chest.get_inventory(defines.inventory.chest)
|
||||
local free_slots = 0
|
||||
|
||||
for i = 1, chest_inventory.get_bar() - 1, 1 do
|
||||
if not chest_inventory[i].valid_for_read then
|
||||
free_slots = free_slots + 1
|
||||
@ -347,7 +395,8 @@ local function get_player_data(ic, player)
|
||||
|
||||
ic.players[player.index] = {
|
||||
surface = 1,
|
||||
fallback_surface = 1
|
||||
fallback_surface = 1,
|
||||
notified = false
|
||||
}
|
||||
return ic.players[player.index]
|
||||
end
|
||||
@ -363,31 +412,35 @@ local remove_car =
|
||||
|
||||
function Public.save_car(ic, event)
|
||||
local entity = event.entity
|
||||
if not validate_entity(entity) then
|
||||
return
|
||||
end
|
||||
|
||||
local player = game.players[event.player_index]
|
||||
if not validate_player(player) then
|
||||
return
|
||||
end
|
||||
|
||||
local entity_type = ic.entity_type
|
||||
|
||||
if not entity_type[entity.name] then
|
||||
return
|
||||
end
|
||||
local car = ic.cars[entity.unit_number]
|
||||
|
||||
if not car then
|
||||
log_err('Car was not valid.')
|
||||
return
|
||||
end
|
||||
|
||||
local position = entity.position
|
||||
local health = entity.health
|
||||
|
||||
kick_players_out_of_vehicles(car)
|
||||
kick_player_from_surface(car)
|
||||
get_player_data(ic, player)
|
||||
|
||||
if car.owner == player.index then
|
||||
save_surface(ic, entity, player)
|
||||
if not ic.players[player.index].notified then
|
||||
player.print(
|
||||
player.name ..
|
||||
', the ' ..
|
||||
car.name ..
|
||||
' surface has been saved. Do notice that you can´t place down anything else other than a ' ..
|
||||
car.name .. '.',
|
||||
Color.success
|
||||
)
|
||||
ic.players[player.index].notified = true
|
||||
end
|
||||
else
|
||||
local p = game.players[car.owner]
|
||||
if not p then
|
||||
@ -438,7 +491,6 @@ function Public.kill_car(ic, entity)
|
||||
end
|
||||
car.entity.force.chart(surface, car.area)
|
||||
ic.cars[entity.unit_number] = nil
|
||||
Public.request_reconstruction(ic)
|
||||
end
|
||||
|
||||
function Public.create_room_surface(ic, unit_number)
|
||||
@ -467,7 +519,7 @@ function Public.create_room_surface(ic, unit_number)
|
||||
for _, tile in pairs(surface.find_tiles_filtered({area = {{-2, -2}, {2, 2}}})) do
|
||||
surface.set_tiles({{name = 'out-of-map', position = tile.position}}, true)
|
||||
end
|
||||
ic.surfaces[#ic.surfaces + 1] = surface
|
||||
ic.surfaces[unit_number] = surface
|
||||
return surface
|
||||
end
|
||||
|
||||
@ -545,26 +597,21 @@ function Public.create_car_room(ic, car)
|
||||
end
|
||||
|
||||
function Public.create_car(ic, event)
|
||||
local created_entity = event.created_entity
|
||||
if not validate_entity(created_entity) then
|
||||
return
|
||||
end
|
||||
local player = game.get_player(event.player_index)
|
||||
if not validate_player(player) then
|
||||
return
|
||||
end
|
||||
local ce = event.created_entity
|
||||
|
||||
local saved_surfaces = ic.saved_surfaces
|
||||
local cars = ic.cars
|
||||
local door = ic.doors
|
||||
local player = game.get_player(event.player_index)
|
||||
|
||||
local map_name = ic.allowed_surface
|
||||
|
||||
local entity_type = ic.entity_type
|
||||
local car_areas = ic.car_areas
|
||||
local cars = ic.cars
|
||||
local un = ce.unit_number
|
||||
|
||||
if not created_entity.unit_number then
|
||||
if not un then
|
||||
return
|
||||
end
|
||||
if not entity_type[created_entity.name] then
|
||||
|
||||
if not entity_type[ce.name] then
|
||||
return
|
||||
end
|
||||
|
||||
@ -585,30 +632,30 @@ function Public.create_car(ic, event)
|
||||
|
||||
for _, c in pairs(cars) do
|
||||
if c.owner == player.index then
|
||||
created_entity.destroy()
|
||||
return player.print('You already have a portable vehicle.', Color.fail)
|
||||
ce.destroy()
|
||||
return player.print('You already have a portable vehicle.', Color.warning)
|
||||
end
|
||||
end
|
||||
|
||||
local car_area = car_areas[created_entity.name]
|
||||
local car_areas = ic.car_areas
|
||||
local car_area = car_areas[ce.name]
|
||||
|
||||
ic.cars[created_entity.unit_number] = {
|
||||
entity = created_entity,
|
||||
ic.cars[un] = {
|
||||
entity = ce,
|
||||
area = {
|
||||
left_top = {x = car_area.left_top.x, y = car_area.left_top.y},
|
||||
right_bottom = {x = car_area.right_bottom.x, y = car_area.right_bottom.y}
|
||||
},
|
||||
doors = {},
|
||||
owner = player.index,
|
||||
name = created_entity.name
|
||||
name = ce.name
|
||||
}
|
||||
|
||||
local car = ic.cars[created_entity.unit_number]
|
||||
local car = ic.cars[un]
|
||||
|
||||
car.surface = Public.create_room_surface(ic, un)
|
||||
Public.create_car_room(ic, car)
|
||||
|
||||
Public.request_reconstruction(ic)
|
||||
return car
|
||||
end
|
||||
|
||||
@ -642,7 +689,7 @@ function Public.teleport_players_around(ic)
|
||||
|
||||
if player.surface.find_entity('player-port', player.position) then
|
||||
local door = player.surface.find_entity('player-port', player.position)
|
||||
if door and door.valid then
|
||||
if validate_entity(door) then
|
||||
local doors = ic.doors
|
||||
local cars = ic.cars
|
||||
|
||||
@ -666,6 +713,10 @@ function Public.teleport_players_around(ic)
|
||||
return
|
||||
end
|
||||
|
||||
if not validate_entity(car.entity) then
|
||||
return
|
||||
end
|
||||
|
||||
if car.entity.surface.name ~= player.surface.name then
|
||||
if validate_entity(car.entity) and car.owner == player.index then
|
||||
car.entity.minable = true
|
||||
@ -682,31 +733,6 @@ function Public.teleport_players_around(ic)
|
||||
player.teleport(surface_position, surface)
|
||||
end
|
||||
player_data.surface = surface.index
|
||||
elseif car.entity.type == 'car' and player.driving then
|
||||
player.driving = false
|
||||
else
|
||||
local surface = car.surface
|
||||
local area = car.area
|
||||
local x_vector = door.position.x - player.position.x
|
||||
local position
|
||||
if x_vector > 0 then
|
||||
position = {
|
||||
area.left_top.x + 0.5,
|
||||
area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)
|
||||
}
|
||||
else
|
||||
position = {
|
||||
area.right_bottom.x - 0.5,
|
||||
area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)
|
||||
}
|
||||
end
|
||||
local p = surface.find_non_colliding_position('character', position, 128, 0.5)
|
||||
if p then
|
||||
player.teleport(p, surface)
|
||||
else
|
||||
player.teleport(position, surface)
|
||||
end
|
||||
player_data.surface = surface.index
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -723,10 +749,7 @@ function Public.use_door_with_entity(ic, player, door)
|
||||
return
|
||||
end
|
||||
|
||||
if not door then
|
||||
return
|
||||
end
|
||||
if not door.valid then
|
||||
if not validate_entity(door) then
|
||||
return
|
||||
end
|
||||
local doors = ic.doors
|
||||
@ -750,22 +773,26 @@ function Public.use_door_with_entity(ic, player, door)
|
||||
if validate_entity(car.entity) and car.owner == player.index then
|
||||
car.entity.minable = false
|
||||
end
|
||||
end
|
||||
|
||||
function Public.reconstruct_all_cars(ic)
|
||||
for unit_number, car in pairs(ic.cars) do
|
||||
if not validate_entity(car.entity) then
|
||||
ic.cars[unit_number] = nil
|
||||
Public.request_reconstruction(ic)
|
||||
return
|
||||
end
|
||||
|
||||
if not car.surface then
|
||||
car.surface = Public.create_room_surface(ic, unit_number)
|
||||
Public.create_car_room(ic, car)
|
||||
end
|
||||
if not validate_entity(surface) then
|
||||
return
|
||||
end
|
||||
delete_empty_surfaces(ic)
|
||||
|
||||
local area = car.area
|
||||
local x_vector = door.position.x - player.position.x
|
||||
local position
|
||||
if x_vector > 0 then
|
||||
position = {area.left_top.x + 0.5, area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)}
|
||||
else
|
||||
position = {area.right_bottom.x - 0.5, area.left_top.y + ((area.right_bottom.y - area.left_top.y) * 0.5)}
|
||||
end
|
||||
local p = surface.find_non_colliding_position('character', position, 128, 0.5)
|
||||
if p then
|
||||
player.teleport(p, surface)
|
||||
else
|
||||
player.teleport(position, surface)
|
||||
end
|
||||
player_data.surface = surface.index
|
||||
end
|
||||
|
||||
function Public.item_transfer(ic)
|
||||
|
@ -8,7 +8,7 @@ Public.get_table = IC.get
|
||||
|
||||
local function on_entity_died(event)
|
||||
local entity = event.entity
|
||||
if not entity and not entity.valid then
|
||||
if not entity or not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
@ -22,7 +22,7 @@ end
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
local entity = event.entity
|
||||
if not entity and not entity.valid then
|
||||
if not entity or not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
@ -30,6 +30,11 @@ local function on_player_mined_entity(event)
|
||||
return
|
||||
end
|
||||
|
||||
local player = game.players[event.player_index]
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local ic = IC.get()
|
||||
Functions.save_car(ic, event)
|
||||
end
|
||||
@ -50,8 +55,17 @@ local function on_robot_mined_entity(event)
|
||||
end
|
||||
|
||||
local function on_built_entity(event)
|
||||
local created_entity = event.created_entity
|
||||
if not created_entity.type == 'car' then
|
||||
local ce = event.created_entity
|
||||
|
||||
if not ce or not ce.valid then
|
||||
return
|
||||
end
|
||||
if not ce.type == 'car' then
|
||||
return
|
||||
end
|
||||
|
||||
local player = game.get_player(event.player_index)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
@ -78,13 +92,6 @@ local function on_tick()
|
||||
if tick % 600 == 0 then
|
||||
Functions.remove_invalid_cars(ic)
|
||||
end
|
||||
|
||||
if ic.rebuild_tick ~= tick then
|
||||
return
|
||||
end
|
||||
|
||||
Functions.reconstruct_all_cars(ic)
|
||||
ic.rebuild_tick = nil
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
|
@ -21,9 +21,12 @@ function Public.reset()
|
||||
for k, _ in pairs(this) do
|
||||
this[k] = nil
|
||||
end
|
||||
this.debug_mode = true
|
||||
this.restore_on_theft = false
|
||||
this.doors = {}
|
||||
this.cars = {}
|
||||
this.saved_surfaces = {}
|
||||
this.allowed_surface = 'nauvis'
|
||||
this.players = {}
|
||||
this.surfaces = {}
|
||||
this.entity_type = {
|
||||
@ -53,4 +56,11 @@ function Public.set_car_area(tbl)
|
||||
this.car_areas = tbl
|
||||
end
|
||||
|
||||
function Public.allowed_surface(value)
|
||||
if value then
|
||||
this.allowed_surface = value
|
||||
end
|
||||
return this.allowed_surface
|
||||
end
|
||||
|
||||
return Public
|
||||
|
@ -2,6 +2,22 @@ local Public = {}
|
||||
|
||||
local ICW = require 'maps.mountain_fortress_v3.icw.table'
|
||||
|
||||
local rock_raffle = {
|
||||
'sand-rock-big',
|
||||
'sand-rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-big',
|
||||
'rock-huge'
|
||||
}
|
||||
|
||||
local size_of_rock_raffle = #rock_raffle
|
||||
|
||||
function Public.request_reconstruction(icw)
|
||||
icw.rebuild_tick = game.tick + 30
|
||||
end
|
||||
@ -413,6 +429,14 @@ function Public.create_wagon_room(icw, wagon)
|
||||
end
|
||||
end
|
||||
|
||||
-- for x = -35, 30, 1 do
|
||||
-- for y = -5, 45, 1 do
|
||||
-- if math.random(1, 4) == 1 then
|
||||
-- fishes[#fishes + 1] = {name = rock_raffle[math.random(1, size_of_rock_raffle)], position = {x, y}}
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
surface.set_tiles(tiles, true)
|
||||
|
||||
for _, fish in pairs(fishes) do
|
||||
|
@ -63,7 +63,7 @@ local function validate_player(player)
|
||||
return true
|
||||
end
|
||||
|
||||
function Public.add_player_to_permission_group(player, group)
|
||||
function Public.add_player_to_permission_group(player, group, forced)
|
||||
local jailed = Jailed.get_jailed_table()
|
||||
local enable_permission_group_disconnect = WPT.get('disconnect_wagon')
|
||||
local session = Session.get_session_table()
|
||||
@ -72,6 +72,27 @@ function Public.add_player_to_permission_group(player, group)
|
||||
return
|
||||
end
|
||||
|
||||
if forced 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)
|
||||
end
|
||||
|
||||
local playtime = player.online_time
|
||||
if session[player.name] then
|
||||
playtime = player.online_time + session[player.name]
|
||||
@ -1368,15 +1389,15 @@ local function add_random_loot_to_main_market(rarity)
|
||||
tooltip = types[v.offer.item].localised_name,
|
||||
upgrade = false
|
||||
}
|
||||
if ticker >= 12 then
|
||||
if ticker >= 25 then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_research_finished()
|
||||
local difficulty_poll_closing_timeout = Difficulty.get('difficulty_poll_closing_timeout')
|
||||
if game.tick < difficulty_poll_closing_timeout then
|
||||
local game_lost = WPT.get('game_lost')
|
||||
if game_lost then
|
||||
return
|
||||
end
|
||||
|
||||
@ -1445,6 +1466,38 @@ local function on_console_chat(event)
|
||||
shoo(event)
|
||||
end
|
||||
|
||||
-- local function tp_player()
|
||||
-- for _, player in pairs(game.connected_players) do
|
||||
-- if not validate_player(player) then
|
||||
-- return
|
||||
-- end
|
||||
|
||||
-- local active_surface_index = WPT.get('active_surface_index')
|
||||
-- if not active_surface_index then
|
||||
-- return
|
||||
-- end
|
||||
|
||||
-- local surface = game.surfaces[active_surface_index]
|
||||
|
||||
-- local nauvis = 'nauvis'
|
||||
|
||||
-- if string.sub(player.surface.name, 0, #nauvis) == nauvis then
|
||||
-- if player.surface.find_entity('player-port', player.position) then
|
||||
-- player.teleport(
|
||||
-- surface.find_non_colliding_position(
|
||||
-- 'character',
|
||||
-- game.forces.player.get_spawn_position(surface),
|
||||
-- 3,
|
||||
-- 0,
|
||||
-- 5
|
||||
-- ),
|
||||
-- surface
|
||||
-- )
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
local function on_player_changed_surface(event)
|
||||
local player = game.players[event.player_index]
|
||||
if not validate_player(player) then
|
||||
@ -1746,7 +1799,36 @@ function Public.get_items()
|
||||
upgrade = true,
|
||||
static = true
|
||||
}
|
||||
|
||||
if game.forces.player.technologies['logistics'].researched then
|
||||
main_market_items['loader'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = 128,
|
||||
tooltip = 'Loader',
|
||||
upgrade = false,
|
||||
static = true
|
||||
}
|
||||
end
|
||||
if game.forces.player.technologies['logistics-2'].researched then
|
||||
main_market_items['fast-loader'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = 256,
|
||||
tooltip = 'Fast Loader',
|
||||
upgrade = false,
|
||||
static = true
|
||||
}
|
||||
end
|
||||
if game.forces.player.technologies['logistics-3'].researched then
|
||||
main_market_items['express-loader'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
price = 512,
|
||||
tooltip = 'Express Loader',
|
||||
upgrade = false,
|
||||
static = true
|
||||
}
|
||||
end
|
||||
main_market_items['small-lamp'] = {
|
||||
stack = 1,
|
||||
value = 'coin',
|
||||
@ -1928,6 +2010,7 @@ local function tick()
|
||||
end
|
||||
|
||||
if ticker % 120 == 0 then
|
||||
-- tp_player()
|
||||
boost_players()
|
||||
end
|
||||
|
||||
|
@ -16,6 +16,7 @@ require 'modules.mineable_wreckage_yields_scrap'
|
||||
require 'modules.charging_station'
|
||||
require 'modules.admins_operate_biters'
|
||||
|
||||
local IC = require 'maps.mountain_fortress_v3.ic.table'
|
||||
local Autostash = require 'modules.autostash'
|
||||
local Group = require 'comfy_panel.group'
|
||||
local PL = require 'comfy_panel.player_list'
|
||||
@ -94,7 +95,7 @@ local set_difficulty = function()
|
||||
local Diff = Difficulty.get()
|
||||
local wave_defense_table = WD.get_table()
|
||||
local collapse_speed = WPT.get('collapse_speed')
|
||||
local collapse_amount = WPT.get('collapcollapse_amountse_speed')
|
||||
local collapse_amount = WPT.get('collapse_amount')
|
||||
local player_count = #game.connected_players
|
||||
if not Diff.difficulty_vote_value then
|
||||
Diff.difficulty_vote_value = 0.1
|
||||
@ -144,51 +145,44 @@ local set_difficulty = function()
|
||||
end
|
||||
|
||||
local biter_settings = function()
|
||||
-- biter settings
|
||||
local Diff = Difficulty.get()
|
||||
if not Diff.difficulty_vote_value then
|
||||
Diff.difficulty_vote_value = 0.1
|
||||
end
|
||||
|
||||
local plus = ((game.forces.enemy.evolution_factor * 100) + 50) / (77 - Diff.difficulty_vote_value * 2)
|
||||
local sub = (((1 - game.forces.enemy.evolution_factor) * 100) + 50) / (73 + Diff.difficulty_vote_value * 2)
|
||||
|
||||
local enemy_expansion = game.map_settings.enemy_expansion
|
||||
local unit_group = game.map_settings.unit_group
|
||||
local path_finder = game.map_settings.path_finder
|
||||
unit_group.max_wait_time_for_late_members = 3600 * plus
|
||||
unit_group.min_group_radius = 30 * plus
|
||||
unit_group.max_group_radius = 60 * plus
|
||||
unit_group.max_member_speedup_when_behind = 3 * plus
|
||||
unit_group.member_disown_distance = 20 * plus
|
||||
unit_group.max_gathering_unit_groups = 10 * plus
|
||||
path_finder.max_work_done_per_tick = 6000 * plus
|
||||
|
||||
path_finder.max_steps_worked_per_tick = 20 + (100 * plus)
|
||||
if path_finder.max_steps_worked_per_tick > 2000 then
|
||||
path_finder.max_steps_worked_per_tick = 200
|
||||
end
|
||||
|
||||
enemy_expansion.building_coefficient = 0.1 * sub
|
||||
enemy_expansion.other_base_coefficient = 2.0 * sub
|
||||
enemy_expansion.neighbouring_chunk_coefficient = 0.5 * sub
|
||||
enemy_expansion.neighbouring_base_chunk_coefficient = 0.4 * sub
|
||||
|
||||
enemy_expansion.max_expansion_distance = 20 * plus
|
||||
if enemy_expansion.max_expansion_distance > 20 then
|
||||
enemy_expansion.max_expansion_distance = 20
|
||||
end
|
||||
enemy_expansion.friendly_base_influence_radius = 8 * plus
|
||||
enemy_expansion.enemy_building_influence_radius = 3 * plus
|
||||
|
||||
enemy_expansion.settler_group_min_size = 5 * plus
|
||||
if enemy_expansion.settler_group_min_size < 1 then
|
||||
enemy_expansion.settler_group_min_size = 1
|
||||
end
|
||||
|
||||
enemy_expansion.settler_group_max_size = 20 * plus
|
||||
if enemy_expansion.settler_group_max_size > 50 then
|
||||
enemy_expansion.settler_group_max_size = 50
|
||||
-- -- biter settings
|
||||
if WPT.get('enable_biter_settings') then
|
||||
local Diff = Difficulty.get()
|
||||
if not Diff.difficulty_vote_value then
|
||||
Diff.difficulty_vote_value = 0.1
|
||||
end
|
||||
local plus = ((game.forces.enemy.evolution_factor * 100) + 50) / (77 - Diff.difficulty_vote_value * 2)
|
||||
local sub = (((1 - game.forces.enemy.evolution_factor) * 100) + 50) / (73 + Diff.difficulty_vote_value * 2)
|
||||
local enemy_expansion = game.map_settings.enemy_expansion
|
||||
local unit_group = game.map_settings.unit_group
|
||||
local path_finder = game.map_settings.path_finder
|
||||
unit_group.max_wait_time_for_late_members = 3600 * plus
|
||||
unit_group.max_member_speedup_when_behind = 3 * plus
|
||||
unit_group.member_disown_distance = 20 * plus
|
||||
unit_group.max_gathering_unit_groups = 10 * plus
|
||||
path_finder.max_work_done_per_tick = 6000 * plus
|
||||
path_finder.max_steps_worked_per_tick = 20 + (100 * plus)
|
||||
if path_finder.max_steps_worked_per_tick > 2000 then
|
||||
path_finder.max_steps_worked_per_tick = 200
|
||||
end
|
||||
enemy_expansion.building_coefficient = 0.1 * sub
|
||||
enemy_expansion.other_base_coefficient = 2.0 * sub
|
||||
enemy_expansion.neighbouring_chunk_coefficient = 0.5 * sub
|
||||
enemy_expansion.neighbouring_base_chunk_coefficient = 0.4 * sub
|
||||
enemy_expansion.max_expansion_distance = 20 * plus
|
||||
if enemy_expansion.max_expansion_distance > 20 then
|
||||
enemy_expansion.max_expansion_distance = 20
|
||||
end
|
||||
enemy_expansion.friendly_base_influence_radius = 8 * plus
|
||||
enemy_expansion.enemy_building_influence_radius = 3 * plus
|
||||
enemy_expansion.settler_group_min_size = 5 * plus
|
||||
if enemy_expansion.settler_group_min_size < 1 then
|
||||
enemy_expansion.settler_group_min_size = 1
|
||||
end
|
||||
enemy_expansion.settler_group_max_size = 20 * plus
|
||||
if enemy_expansion.settler_group_max_size > 50 then
|
||||
enemy_expansion.settler_group_max_size = 50
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -304,6 +298,8 @@ function Public.reset_map()
|
||||
|
||||
Poll.reset()
|
||||
ICW.reset()
|
||||
IC.reset()
|
||||
IC.allowed_surface('mountain_fortress_v3')
|
||||
Functions.reset_table()
|
||||
game.reset_time_played()
|
||||
WPT.reset_table()
|
||||
@ -390,14 +386,18 @@ function Public.reset_map()
|
||||
surface.force_generate_chunk_requests()
|
||||
end
|
||||
|
||||
surface.ticks_per_day = surface.ticks_per_day * 2
|
||||
surface.brightness_visual_weights = {1, 0, 0, 0}
|
||||
|
||||
game.forces.player.set_spawn_position({-27, 25}, surface)
|
||||
|
||||
Task.start_queue()
|
||||
Task.set_queue_speed(32)
|
||||
|
||||
biter_settings()
|
||||
-- biter_settings()
|
||||
|
||||
this.chunk_load_tick = game.tick + 1200
|
||||
this.game_lost = false
|
||||
|
||||
--HD.enable_auto_init = false
|
||||
|
||||
@ -840,7 +840,8 @@ local on_tick = function()
|
||||
local update_gui = Gui_mf.update_gui
|
||||
local tick = game.tick
|
||||
|
||||
if tick % 36000 == 0 then
|
||||
-- if tick % 36000 == 0 then
|
||||
if tick % 360 == 0 then
|
||||
biter_settings()
|
||||
end
|
||||
|
||||
|
@ -81,4 +81,50 @@ function Public.get(key)
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
|
||||
|
||||
local function clear_nauvis()
|
||||
local surface = game.surfaces['nauvis']
|
||||
local mgs = surface.map_gen_settings
|
||||
mgs.width = 16
|
||||
mgs.height = 16
|
||||
surface.map_gen_settings = mgs
|
||||
surface.clear()
|
||||
surface.request_to_generate_chunks({0, 0}, 0.5)
|
||||
surface.force_generate_chunk_requests()
|
||||
|
||||
game.forces.player.chart(surface, {{-16, -16}, {16, 16}})
|
||||
end
|
||||
|
||||
local function place_grid()
|
||||
local surface = game.surfaces['nauvis']
|
||||
rendering.draw_text {
|
||||
text = 'How did you end up here? O_o',
|
||||
surface = surface,
|
||||
target = {0, -12},
|
||||
color = {r = 0.98, g = 0.66, b = 0.22},
|
||||
scale = 3,
|
||||
font = 'heading-1',
|
||||
alignment = 'center',
|
||||
scale_with_zoom = false
|
||||
}
|
||||
local e =
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'player-port',
|
||||
position = {0, 5},
|
||||
force = 'neutral',
|
||||
create_build_effect_smoke = false
|
||||
}
|
||||
)
|
||||
e.destructible = false
|
||||
e.minable = false
|
||||
e.operable = false
|
||||
end
|
||||
|
||||
local clear_nauvis_token = Token.register(clear_nauvis)
|
||||
local place_grid_token = Token.register(place_grid)
|
||||
|
||||
]]
|
||||
return Public
|
||||
|
@ -32,9 +32,11 @@ function Public.reset_table()
|
||||
-- @end
|
||||
this.icw_locomotive = nil
|
||||
this.debug = false
|
||||
this.game_lost = false
|
||||
this.fullness_enabled = true
|
||||
this.locomotive_health = 10000
|
||||
this.locomotive_max_health = 10000
|
||||
this.enable_biter_settings = true
|
||||
this.train_upgrades = 0
|
||||
this.offline_players = {}
|
||||
this.biter_pets = {}
|
||||
|
@ -63,7 +63,7 @@ local scrap_entities = {
|
||||
local scrap_entities_index = #scrap_entities
|
||||
|
||||
local spawner_raffle = {'biter-spawner', 'biter-spawner', 'biter-spawner', 'spitter-spawner'}
|
||||
local trees = {'dead-grey-trunk', 'dead-grey-trunk', 'dry-tree'}
|
||||
local trees = {'tree-08-red', 'tree-02-red', 'tree-06-brown'}
|
||||
|
||||
local firearm_magazine_ammo = Functions.firearm_magazine_ammo
|
||||
local piercing_rounds_magazine_ammo = Functions.piercing_rounds_magazine_ammo
|
||||
|
Loading…
Reference in New Issue
Block a user