diff --git a/maps/pirates/balance.lua b/maps/pirates/balance.lua index 36789dfc..e41dc0b1 100644 --- a/maps/pirates/balance.lua +++ b/maps/pirates/balance.lua @@ -173,10 +173,10 @@ function Public.evolution_per_second() end end - if _DEBUG then - local surface = game.surfaces[destination.surface_name] - game.print(Common.spawner_count(surface) .. ' ' .. destination.dynamic_data.initial_spawner_count) - end + -- if _DEBUG then + -- local surface = game.surfaces[destination.surface_name] + -- game.print(Common.spawner_count(surface) .. ' ' .. destination.dynamic_data.initial_spawner_count) + -- end return rate end diff --git a/maps/pirates/from_comfy/tick_tack_trap.lua b/maps/pirates/from_comfy/tick_tack_trap.lua new file mode 100644 index 00000000..4ba9f245 --- /dev/null +++ b/maps/pirates/from_comfy/tick_tack_trap.lua @@ -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 diff --git a/maps/pirates/interface.lua b/maps/pirates/interface.lua index 2cf40da0..dc1b3f06 100644 --- a/maps/pirates/interface.lua +++ b/maps/pirates/interface.lua @@ -36,7 +36,7 @@ local Classes = require 'maps.pirates.roles.classes' local Server = require 'utils.server' -- 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 = {} @@ -314,7 +314,7 @@ local function quartermaster_damage_dealt_changes(event) end -local function resist_poison(event) +local function swamp_resist_poison(event) local memory = Memory.get_crew_memory() local entity = event.entity @@ -334,6 +334,26 @@ local function resist_poison(event) 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) -- figure out which crew this is about: @@ -355,7 +375,9 @@ local function event_on_entity_damaged(event) biters_chew_stuff_faster(event) extra_player_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 kraken_damage(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 destination and destination.subtype and destination.subtype == Islands.enum.MAZE then - if Math.random(1, 300) == 1 then - tick_tack_trap(entity.surface, entity.position) + if Math.random(1, 30) == 1 then + tick_tack_trap(memory.enemy_force_name, entity.surface, entity.position) return end else @@ -622,8 +644,8 @@ local function event_on_player_mined_entity(event) if available and destination.type == Surfaces.enum.ISLAND then if destination and destination.subtype and destination.subtype == Islands.enum.MAZE then - if Math.random(1, 300) == 1 then - tick_tack_trap(entity.surface, entity.position) + if Math.random(1, 30) == 1 then + tick_tack_trap(memory.enemy_force_name, entity.surface, entity.position) return end else diff --git a/maps/pirates/overworld.lua b/maps/pirates/overworld.lua index 360373ad..ed986535 100644 --- a/maps/pirates/overworld.lua +++ b/maps/pirates/overworld.lua @@ -141,10 +141,10 @@ function Public.generate_overworld_destination(p) -- debug override to test islands: - -- 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. - -- subtype = Surfaces.Island.enum.MAZE - -- end + 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. + subtype = Surfaces.Island.enum.MAZE + end -- if _DEBUG and ((macrop.x > 0 and macrop.x < 25)) and type ~= Surfaces.enum.DOCK then -- type = nil