1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-05-13 21:56:29 +02:00

more changes

This commit is contained in:
Gerkiz 2021-03-22 11:33:54 +01:00
parent 27c0e9ed34
commit 3e0bbb2946
3 changed files with 278 additions and 15 deletions

View File

@ -1,3 +1,6 @@
-- map by Cogito
-- heavily modified by Gerkiz
local Global = require('utils.global')
local Event = require('utils.event')
local Server = require('utils.server')
@ -14,6 +17,7 @@ local Task = require 'utils.task'
local this = {}
local Public = {}
local insert = table.insert
Global.register(
this,
@ -64,6 +68,48 @@ this.maps = {
frequency = 0
}
}
},
{
name = 'swampy-rivers',
height = 1500,
width = 1500,
water = 1,
terrain_segmentation = 6,
property_expression_names = {
moisture = 0,
temperature = 25.
},
cliff_settings = {
richness = 0
},
starting_area = 'none',
autoplace_controls = {
['iron-ore'] = {
frequency = 0
},
['copper-ore'] = {
frequency = 0
},
['uranium-ore'] = {
frequency = 0
},
['stone'] = {
frequency = 0
},
['coal'] = {
frequency = 0
},
['crude-oil'] = {
frequency = 900,
size = 1
},
['trees'] = {
frequency = 4
},
['enemy-base'] = {
frequency = 0
}
}
}
}
@ -108,6 +154,14 @@ local set_neutral_to_entity =
end
)
local set_neutral_and_not_mineable_to_entity =
Token.register(
function(entity)
entity.force = 'neutral'
entity.minable = false
end
)
local fetch_common =
Token.register(
function()
@ -162,7 +216,7 @@ local industrial_zone_layers = {
},
elevation = 0.5,
resolution = 0.1,
hook = nil,
hook = set_neutral_to_entity,
deps = nil
},
{
@ -173,8 +227,93 @@ local industrial_zone_layers = {
},
elevation = 0.5,
resolution = 0.09,
hook = set_neutral_and_not_mineable_to_entity,
deps = nil
},
{
type = 'LuaEntity',
name = 'hostile',
objects = {
'character',
'gun-turret',
'small-biter'
},
elevation = 0.92,
resolution = 0.99,
hook = set_noise_hostile_hook,
deps = fetch_common
},
{
type = 'LuaEntity',
name = 'structures',
objects = {
'big-electric-pole',
'medium-electric-pole'
},
elevation = 0.9,
resolution = 0.9,
hook = set_neutral_to_entity,
deps = nil
}
}
local swampy_rivers_layers = {
{
type = 'LuaTile',
name = 'speedy_tiles',
objects = {
'black-refined-concrete'
},
elevation = 0.3,
resolution = 0.2,
hook = nil,
deps = nil
},
{
type = 'LuaTile',
name = 'nuclear',
objects = {
'nuclear-ground'
},
elevation = 0.2,
resolution = 0.4,
hook = nil,
deps = nil
},
{
type = 'LuaTile',
name = 'shallows',
objects = {
'water-shallow'
},
elevation = 0.7,
resolution = 0.01,
hook = nil,
deps = nil
},
{
type = 'LuaEntity',
name = 'rocky',
objects = {
'sand-rock-big',
'rock-big',
'rock-huge'
},
elevation = 0.5,
resolution = 0.1,
hook = set_neutral_to_entity,
deps = nil
},
{
type = 'LuaEntity',
name = 'walls',
objects = {
'stone-wall'
},
elevation = 0.5,
resolution = 0.09,
hook = set_neutral_and_not_mineable_to_entity,
deps = nil
},
{
type = 'LuaEntity',
@ -203,7 +342,8 @@ local industrial_zone_layers = {
}
this.presets = {
['flooded-metropolia'] = industrial_zone_layers
['flooded-metropolia'] = industrial_zone_layers,
['swampy-rivers'] = swampy_rivers_layers
}
this.entities_cache = nil
@ -356,10 +496,27 @@ local function do_spawn_point(player)
}
local instance = Blueprints.build(player.surface, 'player_ship', point, player)
LayersFunctions.push_excluding_bounding_box(instance.bb)
local time_left = MapConfig.self_explode
Task.set_timeout_in_ticks(60, explode_ship, {time_left = time_left, ship = instance, surface = player.surface})
local object = {
text = CommonFunctions.get_time(time_left),
surface = player.surface,
color = {
r = 255,
g = 20,
b = 20
},
target = {
x = point.x - 2,
y = point.y - 3
},
scale = 2.0
}
local id = rendering.draw_text(object)
local data = {id = id, time_left = time_left, ship = instance, surface = player.surface}
Task.set_timeout_in_ticks(time_left, explode_ship, data)
Task.start_queue()
end
@ -702,7 +859,7 @@ local function _get_outer_points(surf, x, y, deps)
return
end
table.insert(points, point)
insert(points, point)
end
local function _calculate_attack_costs(surf, bb)
@ -791,7 +948,7 @@ local function _create_npc_group(claim, surf)
prop.count = 1
end
table.insert(stash, prop)
insert(stash, prop)
end
for _, stack in pairs(stash) do
@ -800,7 +957,7 @@ local function _create_npc_group(claim, surf)
assign_camouflage(agent, CommonFunctions)
table.insert(agents, agent)
insert(agents, agent)
::continue::
end
@ -825,7 +982,7 @@ local function populate_raid_event(surf)
agents = _create_npc_group(claim, surf),
objects = claim
}
table.insert(groups[p.name], group)
insert(groups[p.name], group)
::continue::
end
@ -961,13 +1118,15 @@ local valid_ents = {
}
local function mined_wreckage(e)
if e and e.valid then
if not valid_ents[e.name] then
return
end
local ent = e.entity
if not ent.valid then
return
end
if not valid_ents[ent.name] then
return
end
local candidates = {}
local chance = CommonFunctions.rand_range(0, 1000)
for name, attrs in pairs(MapConfig.wreck_loot) do
local prob = attrs.rare * 100
@ -976,7 +1135,7 @@ local function mined_wreckage(e)
name = name,
count = CommonFunctions.rand_range(attrs.count[1], attrs.count[2])
}
table.insert(candidates, cand)
insert(candidates, cand)
end
end

View File

@ -797,7 +797,7 @@ This is an ultimate survival scenario with very hostile environment.
[font=default-bold]Coins [img=item/coin] are the main medium that you use in the market. You obtain them by researching stuff and pvp activites.[/font]
[font=heading-1]Other[/font]
[font=default-bold]This scenario was made by cogito123. If you find any bugs/balancing issues, report it to getcomfy.eu/discord. Thanks for playing this map.[/font]
[font=default-bold]If you find any bugs/balancing issues, report it to getcomfy.eu/discord at #opendev. Thanks for playing this map.[/font]
]]
return public

View File

@ -0,0 +1,104 @@
local Global = require('utils.global')
local this = {}
Global.register(
this,
function(tbl)
this = tbl
end
)
local Public = {}
Public.init = function()
this.timers = {}
end
--[[
set_timer - Sets a timer.
@param left - Time left on the timer in ticks.
@param hook - Action executed after timer is elapsed.
--]]
Public.set_timer = function(left, hook)
local id = game.tick
local entry = {
left = left,
hook_finish = hook,
hook_update = nil,
deps = nil,
running = false,
last_update = 0
}
this.timers[id] = entry
return id
end
--[[
set_timer_on_update - Adds a hook that is executed everytime a
timers is updated.
@param id - Id of the timer.
@param hook - Hook that will be executed per update.
--]]
Public.set_timer_on_update = function(id, hook)
this.timers[id].hook_update = hook
end
--[[
set_timer_dependency - Adds dependency into user callback.
@param id - Id of the timer,
@param deps - Dependency of timer to add.
--]]
Public.set_timer_dependency = function(id, deps)
this.timers[id].deps = deps
end
--[[
set_timer_start - Sets the timer to run.
@param id - Id of a timer.
--]]
Public.set_timer_start = function(id)
this.timers[id].running = true
this.timers[id].last_update = game.tick
end
--[[
kill_timer - Effectivly kills the timer.
@param id - Timer id.
--]]
Public.kill_timer = function(id)
this.timers[id] = nil
end
--[[
do_job - Execute timer logic within a tick.
--]]
Public.do_job = function()
for id, entry in pairs(this.timers) do
if entry.running == false then
goto continue
end
entry.left = entry.left - (game.tick - entry.last_update)
if entry.left > 0 then
entry.last_update = game.tick
if entry.hook_update ~= nil then
if not entry.hook_update(entry.left, entry.deps) then
goto premature_finish
end
end
goto continue
end
::premature_finish::
entry.hook_finish(entry.deps)
this.timers[id] = nil
::continue::
end
end
return Public