mirror of
https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git
synced 2025-01-18 02:58:37 +02:00
Quite untested, but changed silos to be build-able only in certain areas. Also added loaders.
This commit is contained in:
parent
af4ad8129a
commit
cb4d18ec42
23
control.lua
23
control.lua
@ -197,6 +197,9 @@ script.on_event(defines.events.on_player_left_game, function(event)
|
||||
FindUnusedSpawns(game.players[event.player_index], true)
|
||||
end)
|
||||
|
||||
----------------------------------------
|
||||
-- On BUILD entity. Don't forget on_robot_built_entity too!
|
||||
----------------------------------------
|
||||
script.on_event(defines.events.on_built_entity, function(event)
|
||||
if global.ocfg.enable_autofill then
|
||||
Autofill(event)
|
||||
@ -209,9 +212,14 @@ script.on_event(defines.events.on_built_entity, function(event)
|
||||
if ENABLE_ANTI_GRIEFING then
|
||||
SetItemBlueprintTimeToLive(event)
|
||||
end
|
||||
|
||||
if global.ocfg.frontier_rocket_silo then
|
||||
BuildSiloAttempt(event)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
|
||||
----------------------------------------
|
||||
-- Shared vision, charts a small area around other players
|
||||
----------------------------------------
|
||||
@ -248,7 +256,12 @@ script.on_event(defines.events.on_robot_built_entity, function (event)
|
||||
if global.ocfg.enable_regrowth then
|
||||
OarcRegrowthOffLimits(event.created_entity.position, 2)
|
||||
end
|
||||
|
||||
if global.ocfg.frontier_rocket_silo then
|
||||
BuildSiloAttempt(event)
|
||||
end
|
||||
end)
|
||||
|
||||
-- I disabled this because it's too much overhead for too little gain!
|
||||
-- script.on_event(defines.events.on_player_mined_entity, function(event)
|
||||
-- if global.ocfg.enable_regrowth then
|
||||
@ -281,15 +294,19 @@ end)
|
||||
script.on_event(defines.events.on_research_finished, function(event)
|
||||
|
||||
-- Never allows players to build rocket-silos in "frontier" mode.
|
||||
if global.ocfg.frontier_rocket_silo then
|
||||
RemoveRecipe(event.research.force, "rocket-silo")
|
||||
end
|
||||
-- if global.ocfg.frontier_rocket_silo then
|
||||
-- RemoveRecipe(event.research.force, "rocket-silo")
|
||||
-- end
|
||||
|
||||
if LOCK_GOODIES_UNTIL_ROCKET_LAUNCH and
|
||||
(not global.satellite_sent or not global.satellite_sent[event.research.force.name]) then
|
||||
RemoveRecipe(event.research.force, "productivity-module-3")
|
||||
RemoveRecipe(event.research.force, "speed-module-3")
|
||||
end
|
||||
|
||||
if ENABLE_LOADERS then
|
||||
EnableLoaders(event)
|
||||
end
|
||||
end)
|
||||
|
||||
----------------------------------------
|
||||
|
@ -85,18 +85,22 @@ local function CreateRocketSilo(surface, siloPosition, force)
|
||||
-- Set tiles below the silo
|
||||
tiles = {}
|
||||
i = 1
|
||||
for dx = -5,5 do
|
||||
for dy = -5,5 do
|
||||
tiles[i] = {name = "concrete", position = {siloPosition.x+dx, siloPosition.y+dy}}
|
||||
for dx = -6,6 do
|
||||
for dy = -6,6 do
|
||||
if ((dx % 2 == 0) or (dx % 2 == 0)) then
|
||||
tiles[i] = {name = "concrete", position = {siloPosition.x+dx, siloPosition.y+dy}}
|
||||
else
|
||||
tiles[i] = {name = "hazard-concrete-left", position = {siloPosition.x+dx, siloPosition.y+dy}}
|
||||
end
|
||||
i=i+1
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles, true)
|
||||
|
||||
-- Create indestructible silo and assign to a force
|
||||
local silo = surface.create_entity{name = "rocket-silo", position = {siloPosition.x+0.5, siloPosition.y}, force = force}
|
||||
silo.destructible = false
|
||||
silo.minable = false
|
||||
-- local silo = surface.create_entity{name = "rocket-silo", position = {siloPosition.x+0.5, siloPosition.y}, force = force}
|
||||
-- silo.destructible = false
|
||||
-- silo.minable = false
|
||||
|
||||
-- TAG it on the main force at least.
|
||||
game.forces[global.ocfg.main_force].add_chart_tag(game.surfaces[GAME_SURFACE_NAME],
|
||||
@ -128,6 +132,33 @@ function GenerateAllSilos(surface)
|
||||
end
|
||||
end
|
||||
|
||||
-- Validates any attempt to build a silo.
|
||||
-- Should be call in on_built_entity and on_robot_built_entity
|
||||
function BuildSiloAttempt(event)
|
||||
|
||||
-- Validation
|
||||
if (event.created_entity == nil) then return end
|
||||
if (event.created_entity.name ~= "rocket-silo") then return end
|
||||
|
||||
-- Check if it's in the right area.
|
||||
local epos = event.created_entity.position
|
||||
|
||||
for k,v in pairs(global.siloPosition) do
|
||||
if (getDistance(epos, v) < 5) then
|
||||
SendBroadcastMsg("Rocket silo has been built!")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- If we get here, means it wasn't in a valid position. Need to remove it.
|
||||
if (event.created_entity.last_user ~= nil) then
|
||||
FlyingText("Can't build silo here! Check the map!", epos, my_color_red, event.created_entity.surface)
|
||||
event.created_entity.last_user.mine_entity(event.created_entity, true)
|
||||
else
|
||||
log("ERROR! Rocket-silo had no valid last user?!?!")
|
||||
end
|
||||
end
|
||||
|
||||
-- Generate clean land and trees around silo area on chunk generate event
|
||||
function GenerateRocketSiloChunk(event)
|
||||
|
||||
|
@ -86,7 +86,7 @@ local function ExpandGameOptionsGui(player)
|
||||
game_info_str = game_info_str.."\n".."Everyone (all teams) have shared vision."
|
||||
end
|
||||
if (global.ocfg.frontier_rocket_silo) then
|
||||
game_info_str = game_info_str.."\n".."Silos are NOT craftable. There is at least one already located on the map."
|
||||
game_info_str = game_info_str.."\n".."Silos are only placeable in certain areas on the map!"
|
||||
end
|
||||
if (global.ocfg.enable_regrowth) then
|
||||
game_info_str = game_info_str.."\n".."Old parts of the map will slowly be deleted over time (chunks without any player buildings)."
|
||||
|
@ -392,6 +392,7 @@ end
|
||||
function DisableTech(force, techName)
|
||||
if force.technologies[techName] then
|
||||
force.technologies[techName].enabled = false
|
||||
force.technologies[techName].visible_when_disabled = true
|
||||
end
|
||||
end
|
||||
|
||||
@ -1002,3 +1003,18 @@ function Autofill(event)
|
||||
AutoFillVehicle(player, eventEntity)
|
||||
end
|
||||
end
|
||||
|
||||
-- Map loaders to logistics tech for unlocks.
|
||||
local loaders_technology_map = {
|
||||
['logistics'] = 'loader',
|
||||
['logistics-2'] = 'fast-loader',
|
||||
['logistics-3'] = 'express-loader'
|
||||
}
|
||||
|
||||
function EnableLoaders(event)
|
||||
local research = event.research
|
||||
local recipe = loaders_technology_map[research.name]
|
||||
if recipe then
|
||||
research.force.recipes[recipe].enabled = true
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user