Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DO: Silo Defense scenario #1403

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,7 @@ stds.factorio_defines = {
'on_unit_added_to_group',
'on_unit_group_created',
'on_unit_removed_from_group',
'on_unit_group_finished_gathering',
'script_raised_built',
'script_raised_destroy',
'script_raised_revive'
Expand Down
3 changes: 2 additions & 1 deletion locale/en/redmew_maps.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ anti_grief_jail_reason=You have spilled too many items on the ground, contact an

[danger_ores]
biters_disabled=Launching the first [item=satellite] has killed all the biters. Launch __1__ [item=satellite] to win the map.
win=Congratulations! The map has been won. Restart the map with /restart
win=[color=green]Congratulations! The map has been won. Restart the map with /restart[/color]
lose=[color=red]Alas! Unfortunately, the map has been lost. Restart the map with /restart[/color]
satellite_launch=Launch another __1__ [item=satellite] to win the map.
biters_disabled_k2=Launching the first [item=satellite] has killed all the biters. Build and activate the Intergalactic Transceiver to win the map.
biters_disabled_ei=Launching the first [item=satellite] has killed all the biters. Launch more Exploration Satellites to the asteroids to unlock the final age.
Expand Down
3 changes: 2 additions & 1 deletion map_gen/maps/danger_ores/modules/enemy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ return function(config)
local max_chance = config.enemy_max_chance or 1 / 6
local scale_factor = config.enemy_scale_factor or 32
local seed = config.enemy_seed or seed_provider()
local radius = config.enemy_radius or 64

local sf = 1 / scale_factor
local m = 1 / 768
Expand All @@ -29,7 +30,7 @@ return function(config)

local d = sqrt(world.x * world.x + world.y * world.y)

if d < 64 then
if d < radius then
return nil
end

Expand Down
22 changes: 22 additions & 0 deletions map_gen/maps/danger_ores/modules/evolution_control.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local Event = require 'utils.event'

local relations = {
['logistic-science-pack'] = 10,
['military-science-pack'] = 20,
['chemical-science-pack'] = 40,
['production-science-pack'] = 50,
['utility-science-pack'] = 90,
}

Event.on_nth_tick(103, function()
local max = 0
local tech = game.forces.player.technologies
for name, evo in pairs(relations) do
if tech[name] and tech[name].researched then
max = math.max(max, evo)
end
end
if game.forces.enemy.evolution_factor > 10 and max > 2 then
game.forces.enemy.evolution_factor = math.min(game.forces.enemy.evolution_factor, max - 1)
end
end)
7 changes: 7 additions & 0 deletions map_gen/maps/danger_ores/modules/map_poll.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ local ei_mod_pack = 'ei_mod_pack'
-- local py_short_mod_pack = 'py_short_mod_pack'
local ir3_mod_pack = 'ir3_mod_pack'
local scrap_mod_pack = 'scrap_mod_pack'
local silo_defense_mod_pack = 'silo_defense_mod_pack'

local mod_packs = {
normal_mod_pack = 'danger_ore29',
Expand All @@ -35,6 +36,7 @@ local mod_packs = {
py_short_mod_pack = 'danger_ore_py_short',
ir3_mod_pack = 'danger_ore_ir3',
scrap_mod_pack = 'danger_ore_scrap',
silo_defense_mod_pack = 'danger_ore_silo_defense',
}

local maps = {
Expand Down Expand Up @@ -189,6 +191,11 @@ local maps = {
name = 'danger-ore-scrap',
mod_pack = scrap_mod_pack,
display_name = 'Scrapworld (no ores, all scraps)'
},
{
name = 'danger-ore-silo-defense',
mod_pack = silo_defense_mod_pack,
display_name = 'Silo Defense (wave defense style)'
}
}

Expand Down
44 changes: 44 additions & 0 deletions map_gen/maps/danger_ores/modules/memory_storage_control.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
local Event = require 'utils.event'
local RS = require 'map_gen.shared.redmew_surface'

if not script.active_mods['deep-storage-unit'] then
return
end

-- Disable MU tech & drop 4 of them at spawn
Event.on_init(function()
game.forces.player.technologies['memory-unit'].enabled = false

local chest = RS.get_surface().create_entity{
name = 'iron-chest',
position = {0, 0},
force = 'player',
create_build_effect_smoke = true,
move_stuck_players = true
}

chest.insert({ count = 4, name = 'memory-unit'})
end)

-- If a player disconnects with any Memory Storage in its inventory, spill all of it immediately
Event.add(defines.events.on_pre_player_left_game, function(event)
local player = game.get_player(event.player_index)
if not (player and player.valid) then
return
end

for _, inv_type in pairs({defines.inventory.character_main, defines.inventory.character_trash}) do
local inv = player.get_inventory(inv_type)
local count = inv.get_item_count

if count('memory-unit') + count('memory-unit-with-tags') > 0 then
local spill_stack = player.surface and player.surface.spill_item_stack
local position = player.position

for i=1, #inv do
spill_stack(position, inv[i], true, nil, false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if spilling items is the best idea here. Isn't this punishing the other players who now have to clean up the mess.

What if we spawned a player corpse instead. You can set the corpse to inactive to prevent it from despairing. You can look at dump_offline_inventories.lua for inspiration.

Also I wonder if only dumping the memory storage items instead of the whole inventory would make more sense? Logging off with a memory storage item might be accidently rather than deliberate/griefing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I made it harsh on purpose since there are only 4 of the in game, & you can't get others, so it would act both as anti-grief & punishment if you log off with one of them in your inventory, since you're not supposed to have any

(Memory Storages have a scripted inventory so when picking up one Memory Storage, it appends a tag with the stored quantity to the item. So you can have 1000, 1M, 100Billions items stored in 1 inventory slot of yours)

But this may be indeed too harsh, I can tone it down by spilling just the MUs

inv[i].clear()
end
end
end
end)
7 changes: 6 additions & 1 deletion map_gen/maps/danger_ores/modules/restart_command.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,15 @@ return function(config)
end
ore_totals_message = ore_totals_message:sub(1, -3)..')' -- remove the last ", " and add a bracket
ore_totals_message = "Total ore mined: "..format_number(total_ore, true).. "\\n"..ore_totals_message
local map_won = true
if ShareGlobals.data.map_won_objective ~= nil then
map_won = ShareGlobals.data.map_won_objective
end

local statistics_message = statistics.scenario..' completed!\\n\\n'..
local statistics_message = statistics.scenario..' finished!\\n\\n'..
'Statistics:\\n'..
'Map time: '..time_string..'\\n'..
'Status: ' ..(map_won and 'Victorious!' or 'Defeated!')..'\\n'..
'Total entities built: '..statistics.entities_built..'\\n'..
'Total ore mined:'..ore_totals_message..'\\n'..
'Total ore resources exhausted: '..statistics.resources_exhausted..'\\n'..
Expand Down
Loading
Loading