mirror of
https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git
synced 2025-02-21 19:06:32 +02:00
Grabbing some minor improvements I made in my enemy test branch that I never merged.
Adding a description.json file.
This commit is contained in:
commit
e0923ab674
4
description.json
Normal file
4
description.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"order": "a",
|
||||
"multiplayer-compatible": true
|
||||
}
|
@ -173,8 +173,10 @@ function BuildSiloAttempt(event)
|
||||
|
||||
for k,v in pairs(global.siloPosition) do
|
||||
if (getDistance(epos, v) < 5) then
|
||||
SendBroadcastMsg("Rocket silo has been built!")
|
||||
return
|
||||
if (event.created_entity.name ~= "entity-ghost") then
|
||||
SendBroadcastMsg("Rocket silo has been built!")
|
||||
end
|
||||
return -- THIS MEANS WE SUCCESFULLY BUILT THE SILO (ghost or actual building.)
|
||||
end
|
||||
end
|
||||
|
||||
@ -224,7 +226,7 @@ function GenerateRocketSiloChunk(event)
|
||||
RemoveDecorationsArea(surface, chunkArea)
|
||||
|
||||
-- Create rocket silo
|
||||
CreateCropOctagon(surface, siloPos, chunkArea, CHUNK_SIZE*2, "grass-1")
|
||||
CreateCropOctagon(surface, siloPos, chunkArea, CHUNK_SIZE*2, "landfill")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -9,7 +9,7 @@ require("lib/separate_spawns")
|
||||
|
||||
function GameOptionsGuiClick(event)
|
||||
if not (event and event.element and event.element.valid) then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
local player = game.players[event.player_index]
|
||||
local name = event.element.name
|
||||
|
||||
if (name == "ban_player") then
|
||||
|
@ -53,11 +53,12 @@ end
|
||||
function CreateOarcGuiButton(player)
|
||||
if (mod_gui.get_button_flow(player).oarc_button == nil) then
|
||||
local b = mod_gui.get_button_flow(player).add{name="oarc_button",
|
||||
caption="CLICK ME FOR MORE INFO",
|
||||
type="sprite-button",
|
||||
sprite="utility/expand_dots",
|
||||
-- sprite="utility/expand_dots",
|
||||
style=mod_gui.button_style}
|
||||
b.style.padding=2
|
||||
b.style.width=20
|
||||
-- b.style.width=20
|
||||
end
|
||||
end
|
||||
|
||||
@ -82,10 +83,17 @@ end
|
||||
|
||||
function ClickOarcGuiButton(event)
|
||||
if not (event and event.element and event.element.valid) then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
local player = game.players[event.player_index]
|
||||
local name = event.element.name
|
||||
|
||||
if (name ~= "oarc_button") then return end
|
||||
|
||||
if (event.element.caption ~= "") then
|
||||
event.element.caption = ""
|
||||
event.element.style.width = 20
|
||||
event.element.sprite="utility/expand_dots"
|
||||
end
|
||||
|
||||
if (not DoesOarcGuiExist(player)) then
|
||||
CreateOarcGuiTabsPane(player)
|
||||
else
|
||||
|
@ -31,6 +31,39 @@ function FlyingText(msg, pos, color, surface)
|
||||
end
|
||||
end
|
||||
|
||||
-- Requires having an on_tick handler.
|
||||
function DisplaySpeechBubble(player, text, timeout_secs)
|
||||
|
||||
if (global.oarc_speech_bubbles == nil) then
|
||||
global.oarc_speech_bubbles = {}
|
||||
end
|
||||
|
||||
if (player and player.character) then
|
||||
local sp = player.surface.create_entity{name = "compi-speech-bubble",
|
||||
position = player.position,
|
||||
text = text,
|
||||
source = player.character}
|
||||
table.insert(global.oarc_speech_bubbles, {entity=sp,
|
||||
timeout_tick=game.tick+(timeout_secs*TICKS_PER_SECOND)})
|
||||
end
|
||||
end
|
||||
|
||||
-- Every second, check a global table to see if we have any speech bubbles to kill.
|
||||
function TimeoutSpeechBubblesOnTick()
|
||||
if ((game.tick % (TICKS_PER_SECOND)) == 3) then
|
||||
if (global.oarc_speech_bubbles and (#global.oarc_speech_bubbles > 0)) then
|
||||
for k,sp in pairs(global.oarc_speech_bubbles) do
|
||||
if (game.tick > sp.timeout_tick) then
|
||||
if (sp.entity ~= nil) and (sp.entity.valid) then
|
||||
sp.entity.start_fading_out()
|
||||
end
|
||||
table.remove(global.oarc_speech_bubbles, k)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Broadcast messages to all connected players
|
||||
function SendBroadcastMsg(msg)
|
||||
for name,player in pairs(game.connected_players) do
|
||||
@ -89,6 +122,19 @@ function FYShuffle(tInput)
|
||||
return tReturn
|
||||
end
|
||||
|
||||
-- Get a random KEY from a table.
|
||||
function GetRandomKeyFromTable(t)
|
||||
local keyset = {}
|
||||
for k,v in pairs(t) do
|
||||
table.insert(keyset, k)
|
||||
end
|
||||
return keyset[math.random(#keyset)]
|
||||
end
|
||||
|
||||
function GetRandomValueFromTable(t)
|
||||
return t[GetRandomKeyFromTable(t)]
|
||||
end
|
||||
|
||||
-- Simple function to get distance between two positions.
|
||||
function getDistance(posA, posB)
|
||||
-- Get the length for each of the components x and y
|
||||
@ -255,6 +301,27 @@ function RemoveFish(surface, area)
|
||||
end
|
||||
end
|
||||
|
||||
-- Render a path
|
||||
function RenderPath(path, ttl, players)
|
||||
local last_pos = path[1].position
|
||||
local color = {r = 1, g = 0, b = 0, a = 0.5}
|
||||
|
||||
for i,v in pairs(path) do
|
||||
if (i ~= 1) then
|
||||
|
||||
color={r = 1/(1+(i%3)), g = 1/(1+(i%5)), b = 1/(1+(i%7)), a = 0.5}
|
||||
rendering.draw_line{color=color,
|
||||
width=2,
|
||||
from=v.position,
|
||||
to=last_pos,
|
||||
surface=game.surfaces[GAME_SURFACE_NAME],
|
||||
players=players,
|
||||
time_to_live=ttl}
|
||||
end
|
||||
last_pos = v.position
|
||||
end
|
||||
end
|
||||
|
||||
-- Get a random 1 or -1
|
||||
function RandomNegPos()
|
||||
if (math.random(0,1) == 1) then
|
||||
@ -430,6 +497,10 @@ function GetChunkPosFromTilePos(tile_pos)
|
||||
return {x=math.floor(tile_pos.x/32), y=math.floor(tile_pos.y/32)}
|
||||
end
|
||||
|
||||
function GetCenterTilePosFromChunkPos(c_pos)
|
||||
return {x=c_pos.x*32 + 16, y=c_pos.y*32 + 16}
|
||||
end
|
||||
|
||||
-- Get the left_top
|
||||
function GetChunkTopLeft(pos)
|
||||
return {x=pos.x-(pos.x % 32), y=pos.y-(pos.y % 32)}
|
||||
@ -477,6 +548,11 @@ function CreateGameSurface()
|
||||
end
|
||||
end
|
||||
|
||||
-- If Oarc Enemies are enabled, make sure to turn off enemy spawning!
|
||||
if (global.oe) then
|
||||
nauvis_settings.autoplace_controls["enemy-base"].frequency = 0
|
||||
end
|
||||
|
||||
-- Create new game surface
|
||||
local s = game.create_surface(GAME_SURFACE_NAME, nauvis_settings)
|
||||
|
||||
@ -854,8 +930,8 @@ function CreateCropCircle(surface, centerPos, chunkArea, tileRadius, fillTile)
|
||||
end
|
||||
|
||||
-- Create a circle of trees around the spawn point.
|
||||
if ((distVar < tileRadSqr-200) and
|
||||
(distVar > tileRadSqr-400)) then
|
||||
if ((distVar < tileRadSqr-100) and
|
||||
(distVar > tileRadSqr-500)) then
|
||||
surface.create_entity({name="tree-02", amount=1, position={i, j}})
|
||||
end
|
||||
end
|
||||
@ -905,14 +981,19 @@ function CreateMoat(surface, centerPos, chunkArea, tileRadius, fillTile)
|
||||
for i=chunkArea.left_top.x,chunkArea.right_bottom.x,1 do
|
||||
for j=chunkArea.left_top.y,chunkArea.right_bottom.y,1 do
|
||||
|
||||
-- This ( X^2 + Y^2 ) is used to calculate if something
|
||||
-- is inside a circle area.
|
||||
local distVar = math.floor((centerPos.x - i)^2 + (centerPos.y - j)^2)
|
||||
if (j == centerPos.y-1) or (j == centerPos.y) or (j == centerPos.y+1) then
|
||||
|
||||
-- Create a circle of water
|
||||
if ((distVar < tileRadSqr+(1500*global.ocfg.spawn_config.gen_settings.moat_size_modifier)) and
|
||||
(distVar > tileRadSqr)) then
|
||||
table.insert(waterTiles, {name = "water", position ={i,j}})
|
||||
else
|
||||
|
||||
-- This ( X^2 + Y^2 ) is used to calculate if something
|
||||
-- is inside a circle area.
|
||||
local distVar = math.floor((centerPos.x - i)^2 + (centerPos.y - j)^2)
|
||||
|
||||
-- Create a circle of water
|
||||
if ((distVar < tileRadSqr+(1500*global.ocfg.spawn_config.gen_settings.moat_size_modifier)) and
|
||||
(distVar > tileRadSqr)) then
|
||||
table.insert(waterTiles, {name = "water", position ={i,j}})
|
||||
end
|
||||
end
|
||||
|
||||
-- Enforce land inside the edges of the circle to make sure it's
|
||||
|
@ -37,7 +37,7 @@ end
|
||||
|
||||
function PlayerListGuiClick(event)
|
||||
if not (event and event.element and event.element.valid) then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
local player = game.players[event.player_index]
|
||||
local name = event.element.name
|
||||
|
||||
if (name == "playerList") then
|
||||
|
@ -220,7 +220,7 @@ function SetupAndClearSpawnAreas(surface, chunkArea)
|
||||
RemoveInCircle(surface, chunkArea, "cliff", spawn.pos, global.ocfg.spawn_config.gen_settings.land_area_tiles+5)
|
||||
RemoveDecorationsArea(surface, chunkArea)
|
||||
|
||||
local fill_tile = "grass-1"
|
||||
local fill_tile = "landfill"
|
||||
if (game.active_mods["oarc-restricted-build"]) then
|
||||
fill_tile = global.ocfg.locked_build_area_tile
|
||||
end
|
||||
@ -591,14 +591,18 @@ function SendPlayerToNewSpawnAndCreateIt(delayedSpawn)
|
||||
|
||||
if (not delayedSpawn.vanilla) then
|
||||
|
||||
-- Generate water strip only if we don't have a moat.
|
||||
if (not delayedSpawn.moat) then
|
||||
local water_data = global.ocfg.spawn_config.water
|
||||
CreateWaterStrip(game.surfaces[GAME_SURFACE_NAME],
|
||||
{x=delayedSpawn.pos.x+water_data.x_offset, y=delayedSpawn.pos.y+water_data.y_offset},
|
||||
water_data.length)
|
||||
CreateWaterStrip(game.surfaces[GAME_SURFACE_NAME],
|
||||
{x=delayedSpawn.pos.x+water_data.x_offset, y=delayedSpawn.pos.y+water_data.y_offset+1},
|
||||
water_data.length)
|
||||
end
|
||||
|
||||
-- Create the spawn resources here
|
||||
local water_data = global.ocfg.spawn_config.water
|
||||
CreateWaterStrip(game.surfaces[GAME_SURFACE_NAME],
|
||||
{x=delayedSpawn.pos.x+water_data.x_offset, y=delayedSpawn.pos.y+water_data.y_offset},
|
||||
water_data.length)
|
||||
CreateWaterStrip(game.surfaces[GAME_SURFACE_NAME],
|
||||
{x=delayedSpawn.pos.x+water_data.x_offset, y=delayedSpawn.pos.y+water_data.y_offset+1},
|
||||
water_data.length)
|
||||
GenerateStartingResources(game.surfaces[GAME_SURFACE_NAME], delayedSpawn.pos)
|
||||
|
||||
end
|
||||
|
@ -635,7 +635,7 @@ end
|
||||
function SpawnCtrlGuiOptionsSelect(event)
|
||||
if not (event and event.element and event.element.valid) then return end
|
||||
|
||||
local player = game.players[event.element.player_index]
|
||||
local player = game.players[event.player_index]
|
||||
local name = event.element.name
|
||||
|
||||
if not player then
|
||||
@ -668,7 +668,7 @@ end
|
||||
function SpawnCtrlGuiClick(event)
|
||||
if not (event and event.element and event.element.valid) then return end
|
||||
|
||||
local player = game.players[event.element.player_index]
|
||||
local player = game.players[event.player_index]
|
||||
local elemName = event.element.name
|
||||
|
||||
if not player then
|
||||
|
@ -32,7 +32,7 @@ end
|
||||
|
||||
function TagGuiClick(event)
|
||||
if not (event and event.element and event.element.valid) then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
local player = game.players[event.player_index]
|
||||
local name = event.element.name
|
||||
|
||||
if (name == "clear_btn") then
|
||||
|
Loading…
x
Reference in New Issue
Block a user