1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-24 03:47:58 +02:00
This commit is contained in:
danielmartin0 2022-03-04 18:24:04 +00:00
parent 3a3c9401be
commit c98be8debe
4 changed files with 185 additions and 15 deletions

View File

@ -173,10 +173,10 @@ function Public.evolution_per_second()
end end
end end
if _DEBUG then -- if _DEBUG then
local surface = game.surfaces[destination.surface_name] -- local surface = game.surfaces[destination.surface_name]
game.print(Common.spawner_count(surface) .. ' ' .. destination.dynamic_data.initial_spawner_count) -- game.print(Common.spawner_count(surface) .. ' ' .. destination.dynamic_data.initial_spawner_count)
end -- end
return rate return rate
end end

View File

@ -0,0 +1,148 @@
-- by mewmew
-- modified by Gerkiz
local Event = require 'utils.event'
local Global = require 'utils.global'
local traps = {}
Global.register(
traps,
function(t)
traps = t
end
)
local tick_tacks = {'*tick*', '*tick*', '*tack*', '*tak*', '*tik*', '*tok*'}
local kaboom_weights = {
{name = 'grenade', chance = 7},
{name = 'cluster-grenade', chance = 1},
{name = 'destroyer-capsule', chance = 1},
{name = 'defender-capsule', chance = 4},
{name = 'distractor-capsule', chance = 3},
{name = 'poison-capsule', chance = 2},
{name = 'explosive-uranium-cannon-projectile', chance = 3},
{name = 'explosive-cannon-projectile', chance = 5}
}
local kabooms = {}
for _, t in pairs(kaboom_weights) do
for _ = 1, t.chance, 1 do
table.insert(kabooms, t.name)
end
end
local function create_flying_text(surface, position, text)
if not surface.valid then
return
end
surface.create_entity(
{
name = 'flying-text',
position = position,
text = text,
color = {r = 0.75, g = 0.75, b = 0.75}
}
)
if text == '...' then
return
end
surface.play_sound({path = 'utility/armor_insert', position = position, volume_modifier = 0.75})
end
local function create_kaboom(force_name, surface, position, name)
if not surface.valid then
return
end
local target = position
local speed = 0.5
if name == 'defender-capsule' or name == 'destroyer-capsule' or name == 'distractor-capsule' then
surface.create_entity(
{
name = 'flying-text',
position = position,
text = '(((Sentries Engaging Target)))',
color = {r = 0.8, g = 0.0, b = 0.0}
}
)
local nearest_player_unit = surface.find_nearest_enemy({position = position, max_distance = 128, force = force_name})
if nearest_player_unit then
target = nearest_player_unit.position
end
speed = 0.001
end
surface.create_entity(
{
name = name,
position = position,
force = force_name,
target = target,
speed = speed
}
)
end
local function tick_tack_trap(force_name, surface, position)
if not surface then
return
end
if not surface.valid then
return
end
if not position then
return
end
if not position.x then
return
end
if not position.y then
return
end
local tick_tack_count = math.random(5, 9)
for t = 60, tick_tack_count * 60, 60 do
local tick = game.tick - (game.tick % 10) + t
if not traps[tick] then
traps[tick] = {}
end
if t < tick_tack_count * 60 then
traps[tick][#traps[tick] + 1] = {
callback = 'create_flying_text',
params = {surface, {x = position.x, y = position.y}, tick_tacks[math.random(1, #tick_tacks)]}
}
else
if math.random(1, 10) == 1 then
traps[tick][#traps[tick] + 1] = {
callback = 'create_flying_text',
params = {surface, {x = position.x, y = position.y}, '...'}
}
else
traps[tick][#traps[tick] + 1] = {
callback = 'create_kaboom',
params = {force_name, surface, {x = position.x, y = position.y}, kabooms[math.random(1, #kabooms)]}
}
end
end
end
end
local function on_tick()
if not traps[game.tick] then
return
end
for _, token in pairs(traps[game.tick]) do
local callback = token.callback
local params = token.params
if callback == 'create_kaboom' then
create_kaboom(params[1], params[2], params[3], params[4])
elseif callback == 'create_flying_text' then
create_flying_text(params[1], params[2], params[3])
end
end
traps[game.tick] = nil
end
Event.on_nth_tick(10, on_tick)
return tick_tack_trap

View File

@ -36,7 +36,7 @@ local Classes = require 'maps.pirates.roles.classes'
local Server = require 'utils.server' local Server = require 'utils.server'
-- local Modifers = require 'player_modifiers' -- local Modifers = require 'player_modifiers'
local tick_tack_trap = require 'functions.tick_tack_trap' --'enemy' force, but that's okay local tick_tack_trap = require 'maps.pirates.from_comfy.tick_tack_trap' --'enemy' force, but that's okay
local Public = {} local Public = {}
@ -314,7 +314,7 @@ local function quartermaster_damage_dealt_changes(event)
end end
local function resist_poison(event) local function swamp_resist_poison(event)
local memory = Memory.get_crew_memory() local memory = Memory.get_crew_memory()
local entity = event.entity local entity = event.entity
@ -334,6 +334,26 @@ local function resist_poison(event)
end end
local function maze_walls_resistance(event)
local memory = Memory.get_crew_memory()
local entity = event.entity
if not entity.valid then return end
if not (event.damage_type.name and (event.damage_type.name == 'explosion' or event.damage_type.name == 'poison')) then return end
local destination = Common.current_destination()
if not (destination and destination.subtype and destination.subtype == Islands.enum.MAZE) then return end
if not (destination.surface_name == entity.surface.name) then return end
if not ((entity.type and entity.type == 'tree') or entity.name == 'rock-huge' or entity.name == 'rock-big' or entity.name == 'sand-rock-big') then return end
local damage = event.final_damage_amount
event.entity.health = event.entity.health + damage
end
local function event_on_entity_damaged(event) local function event_on_entity_damaged(event)
-- figure out which crew this is about: -- figure out which crew this is about:
@ -355,7 +375,9 @@ local function event_on_entity_damaged(event)
biters_chew_stuff_faster(event) biters_chew_stuff_faster(event)
extra_player_damage(event) extra_player_damage(event)
artillery_damage(event) artillery_damage(event)
resist_poison(event) swamp_resist_poison(event)
maze_walls_resistance(event)
if string.sub(event.entity.force.name, 1, 5) == 'enemy' then if string.sub(event.entity.force.name, 1, 5) == 'enemy' then
kraken_damage(event) kraken_damage(event)
-- Balance.biter_immunities(event) -- Balance.biter_immunities(event)
@ -542,8 +564,8 @@ local function event_on_player_mined_entity(event)
if available and destination.type == Surfaces.enum.ISLAND then if available and destination.type == Surfaces.enum.ISLAND then
if destination and destination.subtype and destination.subtype == Islands.enum.MAZE then if destination and destination.subtype and destination.subtype == Islands.enum.MAZE then
if Math.random(1, 300) == 1 then if Math.random(1, 30) == 1 then
tick_tack_trap(entity.surface, entity.position) tick_tack_trap(memory.enemy_force_name, entity.surface, entity.position)
return return
end end
else else
@ -622,8 +644,8 @@ local function event_on_player_mined_entity(event)
if available and destination.type == Surfaces.enum.ISLAND then if available and destination.type == Surfaces.enum.ISLAND then
if destination and destination.subtype and destination.subtype == Islands.enum.MAZE then if destination and destination.subtype and destination.subtype == Islands.enum.MAZE then
if Math.random(1, 300) == 1 then if Math.random(1, 30) == 1 then
tick_tack_trap(entity.surface, entity.position) tick_tack_trap(memory.enemy_force_name, entity.surface, entity.position)
return return
end end
else else

View File

@ -141,10 +141,10 @@ function Public.generate_overworld_destination(p)
-- debug override to test islands: -- debug override to test islands:
-- if _DEBUG and type == Surfaces.enum.ISLAND then if _DEBUG and type == Surfaces.enum.ISLAND then
-- -- warning: the first map is unique in that it isn't all loaded by the time you arrive, which can cause issues. For example, structures might get placed after ore, thereby deleting the ore underneath them. -- warning: the first map is unique in that it isn't all loaded by the time you arrive, which can cause issues. For example, structures might get placed after ore, thereby deleting the ore underneath them.
-- subtype = Surfaces.Island.enum.MAZE subtype = Surfaces.Island.enum.MAZE
-- end end
-- if _DEBUG and ((macrop.x > 0 and macrop.x < 25)) and type ~= Surfaces.enum.DOCK then -- if _DEBUG and ((macrop.x > 0 and macrop.x < 25)) and type ~= Surfaces.enum.DOCK then
-- type = nil -- type = nil