1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-04 00:15:45 +02:00

cargo wagon update

This commit is contained in:
MewMew 2019-11-20 19:26:34 +01:00
parent b8e973f2df
commit e327d08280
6 changed files with 90 additions and 16 deletions

View File

@ -25,7 +25,7 @@ require "comfy_panel.poll"
require "comfy_panel.score"
require "comfy_panel.config"
--require "modules.autostash"
require "modules.autostash"
---- enable modules here ----
--require "modules.the_floor_is_lava"
@ -66,8 +66,8 @@ require "comfy_panel.config"
---- enable maps here ----
--require "maps.fish_defender.main"
--require "maps.fish_defender_v1.fish_defender"
require "maps.biter_battles_v2.main"
--require "maps.mountain_fortress_v2.main"
--require "maps.biter_battles_v2.main"
require "maps.mountain_fortress_v2.main"
--require "maps.mountain_fortress"
--require "maps.island_troopers.main"
--require "maps.biter_hatchery.main"

View File

@ -1,4 +1,4 @@
require "modules.no_turrets"
--require "modules.no_turrets"
local RPG = require "modules.rpg"
local Tabs = require 'comfy_panel.main'
local Map_score = require "modules.map_score"
@ -26,15 +26,15 @@ local map_gen_settings = {
},
}
local m = 3
local m = 5
local health_boost_food_values = {
["automation-science-pack"] = 0.000001 * m,
["logistic-science-pack"] = 0.0000025 * m,
["military-science-pack"] = 0.0000096 * m,
["chemical-science-pack"] = 0.0000264 * m,
["production-science-pack"] = 0.00008874 * m,
["utility-science-pack"] = 0.00009943 * m,
["space-science-pack"] = 0.00028957 * m,
["logistic-science-pack"] = 0.000003 * m,
["military-science-pack"] = 0.00000822 * m,
["chemical-science-pack"] = 0.00002271 * m,
["production-science-pack"] = 0.00009786 * m,
["utility-science-pack"] = 0.00010634 * m,
["space-science-pack"] = 0.00041828 * m,
}
local worm_turret_spawn_radius = 18
@ -394,7 +394,7 @@ local function on_init()
"Lay transport belts to your hatchery and they will happily nom the juice off the conveyor.\n",
"Higher tier flasks will breed stronger biters!\n",
"\n",
"Player turrets are disabled.\n",
--"Player turrets are disabled.\n",
"Feeding may spawn friendly worm turrets.\n",
"The center river may not be crossed.\n",
"Construction robots may not build over the river.\n",

View File

@ -25,7 +25,7 @@ function Public.set_force_attributes()
global.map_forces[force_name].unit_health_boost = 1
global.map_forces[force_name].unit_count = 0
global.map_forces[force_name].units = {}
global.map_forces[force_name].max_unit_count = 1024
global.map_forces[force_name].max_unit_count = 768
global.map_forces[force_name].player_count = 0
end
end

View File

@ -58,6 +58,45 @@ local function remove_acceleration()
global.locomotive_driver = nil
end
]]
local function create_wagon_room()
local width = 15
local height = 35
local map_gen_settings = {
["width"] = width,
["height"] = height,
["water"] = 0,
["starting_area"] = 1,
["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
["default_enable_all_autoplace_controls"] = true,
["autoplace_settings"] = {
["entity"] = {treat_missing_as_default = false},
["tile"] = {treat_missing_as_default = true},
["decorative"] = {treat_missing_as_default = false},
},
}
local surface = game.create_surface("cargo_wagon", map_gen_settings)
surface.request_to_generate_chunks({0,0}, 1)
surface.force_generate_chunk_requests()
for x = width * -0.5, width * 0.5, 1 do
for y = height * -0.5, height * 0.5, 1 do
surface.set_tiles({{name = "tutorial-grid", position = {x,y}}})
if math.random(1, 5) == 1 then
surface.spill_item_stack({x + math.random(0, 9) * 0.1,y + math.random(0, 9) * 0.1},{name = "raw-fish", count = 1}, false)
end
end
end
for _, x in pairs({width * -0.5 - 1, width * 0.5 + 1}) do
local e = surface.create_entity({name = "car", position = {x, 0}, force = "player"})
e.get_inventory(defines.inventory.fuel).insert({name = "wood", count = 16})
e.destructible = false
e.minable = false
e.operable = false
end
end
function Public.set_player_spawn_and_refill_fish()
if not global.locomotive_cargo then return end
if not global.locomotive_cargo.valid then return end
@ -68,4 +107,31 @@ function Public.set_player_spawn_and_refill_fish()
game.forces.player.set_spawn_position({x = position.x, y = position.y}, global.locomotive_cargo.surface)
end
function Public.enter_cargo_wagon(player, vehicle)
if not vehicle then return end
if not vehicle.valid then return end
if not global.locomotive_cargo then return end
if not global.locomotive_cargo.valid then return end
if vehicle == global.locomotive_cargo then
if not game.surfaces["cargo_wagon"] then create_wagon_room() end
local surface = game.surfaces["cargo_wagon"]
local x_vector = vehicle.position.x - player.position.x
local position
if x_vector > 0 then
position = {surface.map_gen_settings.width * -0.5, 0}
else
position = {surface.map_gen_settings.width * 0.5, 0}
end
player.teleport(surface.find_non_colliding_position("character", position, 128, 0.5), surface)
end
if player.surface.name == "cargo_wagon" and vehicle.type == "car" then
local surface = global.locomotive_cargo.surface
local x_vector = (vehicle.position.x / math.abs(vehicle.position.x)) * 2
local position = {global.locomotive_cargo.position.x + x_vector, global.locomotive_cargo.position.y}
local position = surface.find_non_colliding_position("character", position, 128, 0.5)
if not position then return end
player.teleport(position, surface)
end
end
return Public

View File

@ -41,8 +41,8 @@ local function set_difficulty()
-- threat gain / wave
wave_defense_table.threat_gain_multiplier = 2 + player_count * 0.1
--1 additional map collapse tile / 8 players in game
global.map_collapse.speed = math.floor(player_count * 0.125) + 2
--1 additional map collapse tile / 10 players in game
global.map_collapse.speed = math.floor(player_count * 0.1) + 1
--20 Players for fastest wave_interval
wave_defense_table.wave_interval = 3600 - player_count * 90
@ -86,6 +86,7 @@ function Public.reset_map()
surface.force_generate_chunk_requests()
end
game.difficulty_settings.technology_price_multiplier = 0.5
game.map_settings.enemy_evolution.destroy_factor = 0
game.map_settings.enemy_evolution.pollution_factor = 0
game.map_settings.enemy_evolution.time_factor = 0
@ -377,6 +378,12 @@ local function on_init()
Public.reset_map()
end
local function on_player_driving_changed_state(event)
local player = game.players[event.player_index]
local vehicle = event.entity
Locomotive.enter_cargo_wagon(player, vehicle)
end
local event = require 'utils.event'
event.on_init(on_init)
event.on_nth_tick(2, tick)
@ -386,6 +393,7 @@ event.add(defines.events.on_player_joined_game, on_player_joined_game)
event.add(defines.events.on_player_left_game, on_player_left_game)
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
event.add(defines.events.on_research_finished, on_research_finished)
event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state)
require "modules.rocks_yield_ore"

View File

@ -925,7 +925,7 @@ end
]]
local function on_chunk_generated(event)
if event.surface.index == 1 then return end
if event.surface.index ~= global.active_surface_index then return end
process_chunk(event.surface, event.area.left_top)
--global.chunk_queue[#global.chunk_queue + 1] = {left_top = {x = event.area.left_top.x, y = event.area.left_top.y}, surface_index = event.surface.index}
end