From f0dbcbe3bdb37cd13a72e2136c3a65c1ad7217aa Mon Sep 17 00:00:00 2001 From: Jayefuu <28716932+Jayefuu@users.noreply.github.com> Date: Thu, 30 Sep 2021 15:50:00 +0100 Subject: [PATCH 1/5] Added barrage feature to give players more end-game clearing options --- locale/en/redmew_command_text.cfg | 20 +- map_gen/maps/crash_site/commands.lua | 302 ++++++++++++++++++++------- map_gen/maps/crash_site/scenario.lua | 40 +++- 3 files changed, 274 insertions(+), 88 deletions(-) diff --git a/locale/en/redmew_command_text.cfg b/locale/en/redmew_command_text.cfg index ebdc2ec60..b95f1a3ac 100644 --- a/locale/en/redmew_command_text.cfg +++ b/locale/en/redmew_command_text.cfg @@ -12,18 +12,30 @@ crash_site_restart_abort=Aborts the restart of the crashsite scenario. crash_site_spy=Spend coins to send a fish to spy on the enemy for a short time. crash_site_spy_invalid=You need to add a valid location to send a spy fish. e.g /spy [gps=-110,-17,redmew] crash_site_spy_funds=Training these spy fish ain't cheap! You need more coins! -crash_site_airstrike_invalid=Invalid co-ordinates. crash_site_spy_success=__1__ used the /spy command and spent __2__ coins to train a fish to spy on the enemy [gps=__3__,__4__,redmew] + +crash_site_airstrike_invalid=Invalid co-ordinates. crash_site_airstrike=Launch an airstrike against the enemy with poison capsules. -crash_site_airstrike_count=Upgrade the airstrike damage to to level __1__\n\nTo use airstrike place poison capsules in the spawn chest then type /strike with a gps position\n\nDamage upgrades increase the number of poison capsules launched by airstrike.\n\nCurrent level: __2__\nCurrent shell count: __3__\nCurrent cost: __4__ -crash_site_airstrike_radius=Upgrade the airstrike radius to level __1__\n\nTo use airstrike place poison capsules in the spawn chest then type /strike with a gps position\n\nCurrent level: __2__\nCurrent radius: __3__ +crash_site_airstrike_count=Upgrade the airstrike damage to to level __1__\n\nTo use airstrike place poison capsules in the spawn chest then type /strike followed by a gps position\n\nDamage upgrades increase the number of poison capsules launched by airstrike.\n\nCurrent level: __2__\nCurrent shell count: __3__\nCurrent cost: __4__ +crash_site_airstrike_radius=Upgrade the airstrike radius to level __1__\n\nTo use airstrike place poison capsules in the spawn chest then type /strike followed by a gps position\n\nCurrent level: __2__\nCurrent radius: __3__ crash_site_airstrike_radius_name_label=Airstrike Radius __1__ crash_site_airstrike_count_name_label=Airstrike Damage __1__ crash_site_airstrike_not_researched=You have not researched airstrike yet. Visit the market at the spawn [gps=-3,-3,redmew] -crash_site_airstrike_insufficient_currency_error=To send an air strike, load __1__ more poison capsules into the payment chest [gps=-0.5,-3.5,redmew] +crash_site_airstrike_insufficient_currency_error=To send an air strike, load __1__ more poison capsules into the payment chest [gps=2.5,-7.5,redmew] crash_site_airstrike_friendly_fire_error=You don't want to do that, no enemies found in the target area. crash_site_airstrike_damage_upgrade_success=__1__ has upgraded Airstrike Damage to level __2__ crash_site_airstrike_radius_upgrade_success=__1__ has updgraded Airstrike Radius to level __2__ +crash_site_barrage_invalid=Invalid co-ordinates. +crash_site_barrage=Launch a barrage of heat seeking rockets against the enemy. +crash_site_barrage_count=Upgrade the barrage damage to to level __1__\n\nTo use barrage place explosive rockets in the spawn chest then type /barrage followed by a gps position\n\nDamage upgrades increase the number of rockets launched.\n\nCurrent level: __2__\nCurrent rocket count: __3__\nCurrent cost: __4__ rockets +crash_site_barrage_radius=Upgrade the barrage radius to level __1__\n\nTo use barrage place explosive rockets in the spawn chest then type /barrage followed by a gps position\n\nCurrent level: __2__\nCurrent radius: __3__ +crash_site_barrage_radius_name_label=Rocket Barrage Radius __1__ +crash_site_barrage_count_name_label=Rocket Barrage Damage __1__ +crash_site_barrage_not_researched=You have not researched Barrage yet. Visit the market at the spawn [gps=-3,-3,redmew] +crash_site_barrage_insufficient_currency_error=To send a rocket barrage, load __1__ more explosive rockets into the payment chest [gps=2.5,-1.5,redmew] +crash_site_barrage_no_nests=No nests found, what a waste of rockets! +crash_site_barrage_damage_upgrade_success=__1__ has upgraded Rocket Barrage Damage to level __2__ +crash_site_barrage_radius_upgrade_success=__1__ has updgraded Rocket Barrage Radius to level __2__ crash_site_rocket_tanks_name_label=Rocket Tanks Fire Interval __1__ crash_site_rocket_tank_upgrade_success=__1__ has upgraded Rocket Tank interval to level __2__ crash_site_rocket_tanks_description= Upgrade the rocket tank firing interval to reduce the time between rockets.\n\nPlace rockets in the tank inventory to have them automatically target enemy worms and nests. diff --git a/map_gen/maps/crash_site/commands.lua b/map_gen/maps/crash_site/commands.lua index f09da2d50..d40dba891 100644 --- a/map_gen/maps/crash_site/commands.lua +++ b/map_gen/maps/crash_site/commands.lua @@ -29,9 +29,11 @@ function Public.control(config) Restart.set_start_game_data({type = Restart.game_types.scenario, name = config.scenario_name or 'crashsite'}) local airstrike_data = {radius_level = 1, count_level = 1} + local barrage_data = {radius_level = 1, count_level = 1} - Global.register({airstrike_data = airstrike_data}, function(tbl) + Global.register({airstrike_data = airstrike_data, barrage_data = barrage_data}, function(tbl) airstrike_data = tbl.airstrike_data + barrage_data = tbl.barrage_data end) local static_entities_to_check = { @@ -333,7 +335,7 @@ function Public.control(config) local ypos = data.ypos local player = data.player local tag = player.force.add_chart_tag(player.surface, { - icon = {type = 'item', name = 'poison-capsule'}, + icon = {type = 'item', name = data.item}, position = {xpos, ypos}, text = player.name }) @@ -341,15 +343,15 @@ function Public.control(config) end) local function render_crosshair(data) - local red = {r = 0.5, g = 0, b = 0, a = 0.5} - local timeout = 5 * 60 - local line_width = 10 - local line_length = 2 + local red = {r = 0.5, g = 0, b = 0, a = 1} + local timeout = 20 * 60 + local line_width = 5 + local line_length = 1.8 local s = data.player.surface local f = data.player.force rendering.draw_circle { color = red, - radius = 1.5, + radius = 1.2, width = line_width, filled = false, target = data.position, @@ -378,17 +380,18 @@ function Public.control(config) s.create_entity { name = "flying-text", position = {data.position.x + 3, data.position.y}, - text = "[item=poison-capsule] " .. data.player.name, + text = "[item=" .. data.item .. "] " .. data.player.name, + speed = 1/180, + time_to_live = 60*5, color = {r = 1, g = 1, b = 1, a = 1} } end local function render_radius(data) local timeout = 20 * 60 - local blue = {r = 0, g = 0, b = 0.1, a = 0.1} rendering.draw_circle { - color = blue, - radius = data.radius + 10, + color = data.color, + radius = data.radius, filled = true, target = data.position, surface = data.player.surface, @@ -425,18 +428,19 @@ function Public.control(config) end -- Check that the chest is where it should be. - local entities = s.find_entities_filtered {position = {-0.5, -3.5}, type = 'container', limit = 1} + local entities = s.find_entities_filtered {position = {2.5, -7.5}, type = 'logistic-container', limit = 1} local dropbox = entities[1] if dropbox == nil then - player.print("Chest not found. Replace it here: [gps=-0.5,-3.5,redmew]") + player.print("Chest not found. Replace it here: [gps=2.5,-7.5,redmew]") return end - -- process each set of coordinates with a 10 strike limit + -- process each set of coordinates with a 20 strike limit local i = 1 local xpos = coords[i] local ypos = coords[i + 1] + -- This while loop lets players add multiple GPS coordinates to the /strike command arguments to strike more than one place at once. Up to a maximum of 20 while xpos ~= nil and ypos ~= nil and i < 20 do -- Check the contents of the chest by spawn for enough poison capsules to use as payment local inv = dropbox.get_inventory(defines.inventory.chest) @@ -449,33 +453,117 @@ function Public.control(config) }, Color.fail) return end + + inv.remove({name = "poison-capsule", count = strikeCost}) + player.force.chart(s, {{xpos - 32, ypos - 32}, {xpos + 32, ypos + 32}}) + + for j = 1, count do + set_timeout_in_ticks(30 * j, spawn_poison_callback, + {s = s, xpos = xpos, ypos = ypos, count = count, r = radius}) + set_timeout_in_ticks(60 * j, chart_area_callback, {player = player, xpos = xpos, ypos = ypos}) + end + render_crosshair({position = {x = xpos, y = ypos}, player = player, item = "poison-capsule"}) + render_radius({position = {x = xpos, y = ypos}, player = player, radius = radius+10, color = {r = 0, g = 0, b = 0.1, a = 0.1}}) + set_timeout_in_ticks(60, map_chart_tag_place_callback, {player = player, xpos = xpos, ypos = ypos, item = 'poison-capsule'}) + + -- move to the next set of coordinates + i = i + 2 + xpos = coords[i] + ypos = coords[i + 1] + end + end + + local spawn_rocket_callback = Token.register(function(data) + data.s.create_entity { + name = "explosive-rocket", + position = {0, 0}, + target = {data.xpos, data.ypos}, + speed = 10, + max_range = 100000 + } + end) + + local function barrage(args, player) + local s = player.surface + local location_string = args.location + local coords = {} + + local radius_level = barrage_data.radius_level -- max radius of the strike area + local count_level = barrage_data.count_level -- the number of poison capsules launched at the enemy + if count_level == 1 then + player.print({'command_description.crash_site_barrage_not_researched'}, Color.fail) + return + end + + local radius = 25 + (radius_level * 5) + local count = count_level * 6 - -- Do a simple check to make sure the player isn't trying to grief the base - -- local enemyEntities = s.find_entities_filtered {position = {xpos, ypos}, radius = radius, force = "enemy"} - local enemyEntities = player.surface.count_entities_filtered { + -- parse GPS coordinates from map ping + for m in string.gmatch(location_string, "%-?%d+") do -- Assuming the surface name isn't a valid number. + table.insert(coords, tonumber(m)) + end + + -- Do some checks on the coordinates passed in the argument + if #coords < 2 then + player.print({'command_description.crash_site_airstrike_invalid'}, Color.fail) + return + end + + -- Check that the chest is where it should be. + local entities = s.find_entities_filtered {position = {2.5, -1.5}, type = 'logistic-container', limit = 1} + local dropbox = entities[1] + + if dropbox == nil then + player.print("Chest not found. Replace it here: [gps=2.5,-1.5,redmew]") + return + end + + -- process each set of coordinates from the arguments with a 20 strike limit + local i = 1 + local xpos = coords[i] + local ypos = coords[i + 1] + -- This while loop lets players add multiple GPS coordinates to the /strike command arguments to strike more than one place at once. Up to a maximum of 20 + while xpos ~= nil and ypos ~= nil and i < 20 do + -- Check the contents of the chest by spawn for enough poison capsules to use as payment + local inv = dropbox.get_inventory(defines.inventory.chest) + local capCount = inv.get_item_count("explosive-rocket") + + if capCount < count then + player.print({ + 'command_description.crash_site_barrage_insufficient_currency_error', + count - capCount + }, Color.fail) + return + end + + local nests = player.surface.find_entities_filtered { position = {xpos, ypos}, - radius = radius + 30, + radius = radius, force = "enemy", - limit = 1 + type = "unit-spawner" } - if enemyEntities < 1 then - player.print({'command_description.crash_site_airstrike_friendly_fire_error'}, Color.fail) - Utils.print_admins(player.name .. " tried to airstrike the base here: [gps=" .. xpos .. "," .. ypos - .. ",redmew]", nil) + + local nest_count = #nests + inv.remove({name = "explosive-rocket", count = count}) + player.force.chart(s, {{xpos - 32, ypos - 32}, {xpos + 32, ypos + 32}}) + if nest_count == 0 then + player.print({'command_description.crash_site_barrage_no_nests',}, Color.fail) return end - inv.remove({name = "poison-capsule", count = strikeCost}) + -- draw radius + set_timeout_in_ticks(60, map_chart_tag_place_callback, {player = player, xpos = xpos, ypos = ypos, item = 'explosive-rocket'}) + render_radius({position = {x = xpos, y = ypos}, player = player, radius = radius, color = {r = 0.1, g = 0, b = 0, a = 0.1}}) + for i, nest in pairs(nests) do + render_crosshair({position = {x = nest.position.x, y = nest.position.y}, player = player, item = "explosive-rocket"}) + -- send number of rockets + end for j = 1, count do - set_timeout_in_ticks(30 * j, spawn_poison_callback, - {s = s, xpos = xpos, ypos = ypos, count = count, r = radius}) + + set_timeout_in_ticks(60 * j + math.random(0, 30), spawn_rocket_callback, {s = s, xpos = nests[(j%nest_count)+1].position.x, ypos = nests[(j%nest_count)+1].position.y}) set_timeout_in_ticks(60 * j, chart_area_callback, {player = player, xpos = xpos, ypos = ypos}) end - player.force.chart(s, {{xpos - 32, ypos - 32}, {xpos + 32, ypos + 32}}) - render_crosshair({position = {x = xpos, y = ypos}, player = player}) - render_radius({position = {x = xpos, y = ypos}, player = player, radius = radius}) - set_timeout_in_ticks(60, map_chart_tag_place_callback, {player = player, xpos = xpos, ypos = ypos}) -- move to the next set of coordinates i = i + 2 @@ -493,57 +581,107 @@ function Public.control(config) end local item = event.item - if item.type ~= 'airstrike' then + if item.type ~= 'airstrike' and item.type~= 'barrage' then return end - -- airstrike stuff - local radius_level = airstrike_data.radius_level -- max radius of the strike area - local count_level = airstrike_data.count_level -- the number of poison capsules launched at the enemy - local radius = 5 + (radius_level * 3) - local count = (count_level - 1) * 5 + 3 - local strikeCost = count * 4 - - local name = item.name - local player_name = event.player.name - if name == 'airstrike_damage' then - airstrike_data.count_level = airstrike_data.count_level + 1 - - Toast.toast_all_players(15, { - 'command_description.crash_site_airstrike_damage_upgrade_success', - player_name, - count_level - }) - Server.to_discord_bold('*** ' .. player_name .. ' has upgraded Airstrike Damage to level ' .. count_level - .. ' ***') - item.name_label = {'command_description.crash_site_airstrike_count_name_label', (count_level + 1)} - item.price = math.floor(math.exp(airstrike_data.count_level ^ 0.8) / 2) * 1000 - item.description = { - 'command_description.crash_site_airstrike_count', - (count_level + 1), - count_level, - count, - tostring(strikeCost) .. ' poison capsules' - } - Retailer.set_item(market_id, item) -- this updates the retailer with the new item values. - elseif name == 'airstrike_radius' then - airstrike_data.radius_level = airstrike_data.radius_level + 1 - Toast.toast_all_players(15, { - 'command_description.crash_site_airstrike_radius_upgrade_success', - player_name, - radius_level - }) - Server.to_discord_bold('*** ' .. player_name .. ' has upgraded Airstrike Radius to level ' .. radius_level - .. ' ***') - item.name_label = {'command_description.crash_site_airstrike_radius_name_label', (radius_level + 1)} - item.description = { - 'command_description.crash_site_airstrike_radius', - (radius_level + 1), - radius_level, - radius - } - item.price = math.floor(math.exp(airstrike_data.radius_level ^ 0.8) / 2) * 1000 - Retailer.set_item(market_id, item) -- this updates the retailer with the new item values. + if item.type == 'airstrike' then + local radius_level = airstrike_data.radius_level -- max radius of the strike area + local count_level = airstrike_data.count_level -- the number of poison capsules launched at the enemy + local radius = 5 + (radius_level * 3) + local count = (count_level - 1) * 5 + 3 + local strikeCost = count * 4 + + local name = item.name + local player_name = event.player.name + if name == 'airstrike_damage' then + airstrike_data.count_level = airstrike_data.count_level + 1 + + Toast.toast_all_players(15, { + 'command_description.crash_site_airstrike_damage_upgrade_success', + player_name, + count_level + }) + Server.to_discord_bold('*** ' .. player_name .. ' has upgraded Airstrike Damage to level ' .. count_level + .. ' ***') + item.name_label = {'command_description.crash_site_airstrike_count_name_label', (count_level + 1)} + item.price = math.floor(math.exp(airstrike_data.count_level ^ 0.8) / 2) * 1000 + item.description = { + 'command_description.crash_site_airstrike_count', + (count_level + 1), + count_level, + count, + tostring(strikeCost) .. ' poison capsules' + } + Retailer.set_item(market_id, item) -- this updates the retailer with the new item values. + elseif name == 'airstrike_radius' then + airstrike_data.radius_level = airstrike_data.radius_level + 1 + Toast.toast_all_players(15, { + 'command_description.crash_site_airstrike_radius_upgrade_success', + player_name, + radius_level + }) + Server.to_discord_bold('*** ' .. player_name .. ' has upgraded Airstrike Radius to level ' .. radius_level + .. ' ***') + item.name_label = {'command_description.crash_site_airstrike_radius_name_label', (radius_level + 1)} + item.description = { + 'command_description.crash_site_airstrike_radius', + (radius_level + 1), + radius_level, + radius + } + item.price = math.floor(math.exp(airstrike_data.radius_level ^ 0.8) / 2) * 1000 + Retailer.set_item(market_id, item) -- this updates the retailer with the new item values. + end + end + if item.type == 'barrage' then + local radius_level = barrage_data.radius_level -- max radius of the strike area + local count_level = barrage_data.count_level -- the number of poison capsules launched at the enemy + local radius = 5 + (radius_level * 3) + local count = (count_level - 1) * 5 + 3 + local strikeCost = count * 4 + + local name = item.name + local player_name = event.player.name + if name == 'barrage_damage' then + barrage_data.count_level = barrage_data.count_level + 1 + + Toast.toast_all_players(15, { + 'command_description.crash_site_barrage_damage_upgrade_success', + player_name, + count_level + }) + Server.to_discord_bold('*** ' .. player_name .. ' has upgraded Rocket Barrage Damage to level ' .. count_level + .. ' ***') + item.name_label = {'command_description.crash_site_barrage_count_name_label', (count_level + 1)} + item.price = math.floor(math.exp(barrage_data.count_level ^ 0.8) / 2) * 1000 + item.description = { + 'command_description.crash_site_barrage_count', + (count_level + 1), + count_level, + count, + tostring(strikeCost) .. ' explosive rockets' + } + Retailer.set_item(market_id, item) -- this updates the retailer with the new item values. + elseif name == 'barrage_radius' then + barrage_data.radius_level = barrage_data.radius_level + 1 + Toast.toast_all_players(15, { + 'command_description.crash_site_barrage_radius_upgrade_success', + player_name, + radius_level + }) + Server.to_discord_bold('*** ' .. player_name .. ' has upgraded Rocket Barrage Radius to level ' .. radius_level + .. ' ***') + item.name_label = {'command_description.crash_site_barrage_radius_name_label', (radius_level + 1)} + item.description = { + 'command_description.crash_site_barrage_radius', + (radius_level + 1), + radius_level, + radius + } + item.price = math.floor(math.exp(barrage_data.radius_level ^ 0.8) / 2) * 1000 + Retailer.set_item(market_id, item) -- this updates the retailer with the new item values. + end end end) @@ -562,6 +700,14 @@ function Public.control(config) required_rank = Ranks.guest, allowed_by_server = false }, strike) + + Command.add('barrage', { + description = {'command_description.crash_site_barrage'}, + arguments = {'location'}, + capture_excess_arguments = true, + required_rank = Ranks.guest, + allowed_by_server = false + }, barrage) end return Public diff --git a/map_gen/maps/crash_site/scenario.lua b/map_gen/maps/crash_site/scenario.lua index d293a5fb6..eab015a06 100644 --- a/map_gen/maps/crash_site/scenario.lua +++ b/map_gen/maps/crash_site/scenario.lua @@ -787,13 +787,31 @@ local function init(config) sprite = 'virtual-signal/signal-A', description = {'command_description.crash_site_airstrike_radius', 1, 0, 5} }, + { + price = 1000, + stack_limit = 1, + type= 'barrage', + name = 'barrage_damage', + name_label = {'command_description.crash_site_barrage_count_name_label', 1}, + sprite = 'virtual-signal/signal-B', + description = {'command_description.crash_site_barrage_count', 1, 0, "n/a", "n/a"} + }, + { + price = 1000, + stack_limit = 1, + type = 'barrage', + name = 'barrage_radius', + name_label = {'command_description.crash_site_barrage_radius_name_label', 1}, + sprite = 'virtual-signal/signal-B', + description = {'command_description.crash_site_barrage_radius', 1, 0, 5} + }, { price = 1000, stack_limit = 1, type = 'rocket_tanks', name = 'rocket_tanks_fire_rate', name_label = {'command_description.crash_site_rocket_tanks_name_label', 1}, - sprite = 'virtual-signal/signal-T', + sprite = 'virtual-signal/signal-R', description = {'command_description.crash_site_rocket_tanks_description'} }, {name = 'wood', price = 1}, @@ -842,19 +860,22 @@ local function init(config) [1] = { market = market, chest = chest, - [15] = {entity = {name = 'market', force = 'neutral', callback = 'market'}}, - [18] = {entity = {name = 'steel-chest', force = 'player', callback = 'chest'}} + [29] = {entity = {name = 'market', force = 'neutral', callback = 'market'}}, + [32] = {entity = {name = 'steel-chest', force = 'player', callback = 'chest'}} }, [2] = { force = 'player', factory = factory, inserter = inserter, - [13] = {entity = {name = 'burner-inserter', direction = 2, callback = 'inserter'}}, - [15] = {entity = {name = 'electric-furnace', callback = 'factory'}} + chest = chest, + [3] = {entity = {name = 'logistic-chest-requester', force = 'player', callback = 'chest'}}, + [25] = {entity = {name = 'burner-inserter', direction = 2, callback = 'inserter'}}, + [27] = {entity = {name = 'electric-furnace', callback = 'factory'}}, + [51] = {entity = {name = 'logistic-chest-requester', force = 'player', callback = 'chest'}} } } - local spawn_shape = outpost_builder.to_shape(spawn, 6, on_init) + local spawn_shape = outpost_builder.to_shape(spawn, 8, on_init) spawn_shape = b.change_tile(spawn_shape, false, 'stone-path') spawn_shape = b.change_map_gen_collision_hidden_tile(spawn_shape, 'water-tile', 'grass-1') @@ -872,6 +893,11 @@ Global.register_init( {}, function(tbl) game.create_force(cutscene_force_name) + + -- Sprites for the spawn chests. Is there a better place for these? + rendering.draw_sprite{sprite = "item.poison-capsule", target = {2.5, -8.5}, surface = game.surfaces["redmew"], tint={1, 1, 1, 0.1}} + rendering.draw_sprite{sprite = "item.explosive-rocket", target = {2.5, -2.5}, surface = game.surfaces["redmew"], tint={1, 1, 1, 0.1}} + local surface = game.surfaces[1] surface.map_gen_settings = {width = 2, height = 2} surface.clear() @@ -895,6 +921,8 @@ function Public.init(config) return function(x, y, world) return map(x, y, world) end + + end return Public From 8ebd79fce35d0678b94717817157c9974ded843c Mon Sep 17 00:00:00 2001 From: Jayefuu <28716932+Jayefuu@users.noreply.github.com> Date: Thu, 30 Sep 2021 15:55:06 +0100 Subject: [PATCH 2/5] Fixed LUA checks. --- map_gen/maps/crash_site/commands.lua | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/map_gen/maps/crash_site/commands.lua b/map_gen/maps/crash_site/commands.lua index d40dba891..9dd56f7c2 100644 --- a/map_gen/maps/crash_site/commands.lua +++ b/map_gen/maps/crash_site/commands.lua @@ -9,7 +9,6 @@ local Ranks = require 'resources.ranks' local Core = require 'utils.core' local Color = require 'resources.color_presets' local Toast = require 'features.gui.toast' -local Utils = require 'utils.core' local Discord = require 'resources.discord' local ScoreTracker = require 'utils.score_tracker' local PlayerStats = require 'features.player_stats' @@ -453,7 +452,7 @@ function Public.control(config) }, Color.fail) return end - + inv.remove({name = "poison-capsule", count = strikeCost}) player.force.chart(s, {{xpos - 32, ypos - 32}, {xpos + 32, ypos + 32}}) @@ -488,8 +487,9 @@ function Public.control(config) local location_string = args.location local coords = {} - local radius_level = barrage_data.radius_level -- max radius of the strike area - local count_level = barrage_data.count_level -- the number of poison capsules launched at the enemy + local radius_level = barrage_data.radius_level -- max radius of the barrage area + local count_level = barrage_data.count_level -- the number of rockets launched at the enemy + if count_level == 1 then player.print({'command_description.crash_site_barrage_not_researched'}, Color.fail) return @@ -524,7 +524,7 @@ function Public.control(config) local ypos = coords[i + 1] -- This while loop lets players add multiple GPS coordinates to the /strike command arguments to strike more than one place at once. Up to a maximum of 20 while xpos ~= nil and ypos ~= nil and i < 20 do - -- Check the contents of the chest by spawn for enough poison capsules to use as payment + -- Check the contents of the chest by spawn for enough rockets to use as payment local inv = dropbox.get_inventory(defines.inventory.chest) local capCount = inv.get_item_count("explosive-rocket") @@ -554,13 +554,11 @@ function Public.control(config) -- draw radius set_timeout_in_ticks(60, map_chart_tag_place_callback, {player = player, xpos = xpos, ypos = ypos, item = 'explosive-rocket'}) render_radius({position = {x = xpos, y = ypos}, player = player, radius = radius, color = {r = 0.1, g = 0, b = 0, a = 0.1}}) - for i, nest in pairs(nests) do + for _, nest in pairs(nests) do render_crosshair({position = {x = nest.position.x, y = nest.position.y}, player = player, item = "explosive-rocket"}) - -- send number of rockets end for j = 1, count do - set_timeout_in_ticks(60 * j + math.random(0, 30), spawn_rocket_callback, {s = s, xpos = nests[(j%nest_count)+1].position.x, ypos = nests[(j%nest_count)+1].position.y}) set_timeout_in_ticks(60 * j, chart_area_callback, {player = player, xpos = xpos, ypos = ypos}) end From 45294db626a238191a7ce9a8dbce31f5e92f0c4f Mon Sep 17 00:00:00 2001 From: Jayefuu <28716932+Jayefuu@users.noreply.github.com> Date: Thu, 30 Sep 2021 15:58:49 +0100 Subject: [PATCH 3/5] LUA checks --- map_gen/maps/crash_site/scenario.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/map_gen/maps/crash_site/scenario.lua b/map_gen/maps/crash_site/scenario.lua index eab015a06..e4e5fa778 100644 --- a/map_gen/maps/crash_site/scenario.lua +++ b/map_gen/maps/crash_site/scenario.lua @@ -921,8 +921,6 @@ function Public.init(config) return function(x, y, world) return map(x, y, world) end - - end return Public From 64a954652f50815622a911a3d684609b38749255 Mon Sep 17 00:00:00 2001 From: Jayefuu <28716932+Jayefuu@users.noreply.github.com> Date: Sun, 3 Oct 2021 00:37:53 +0100 Subject: [PATCH 4/5] Updated balance and minor bug fixes --- map_gen/maps/crash_site/commands.lua | 14 ++++++++------ map_gen/maps/crash_site/scenario.lua | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/map_gen/maps/crash_site/commands.lua b/map_gen/maps/crash_site/commands.lua index 9dd56f7c2..8de681292 100644 --- a/map_gen/maps/crash_site/commands.lua +++ b/map_gen/maps/crash_site/commands.lua @@ -496,7 +496,8 @@ function Public.control(config) end local radius = 25 + (radius_level * 5) - local count = count_level * 6 + local count = (count_level-1) * 6 + local strikeCost = count * 4 -- parse GPS coordinates from map ping for m in string.gmatch(location_string, "%-?%d+") do -- Assuming the surface name isn't a valid number. @@ -531,7 +532,7 @@ function Public.control(config) if capCount < count then player.print({ 'command_description.crash_site_barrage_insufficient_currency_error', - count - capCount + strikeCost - capCount }, Color.fail) return end @@ -544,13 +545,14 @@ function Public.control(config) } local nest_count = #nests - inv.remove({name = "explosive-rocket", count = count}) - player.force.chart(s, {{xpos - 32, ypos - 32}, {xpos + 32, ypos + 32}}) + inv.remove({name = "explosive-rocket", count = strikeCost}) if nest_count == 0 then player.print({'command_description.crash_site_barrage_no_nests',}, Color.fail) return end + player.force.chart(s, {{xpos - 32, ypos - 32}, {xpos + 32, ypos + 32}}) + -- draw radius set_timeout_in_ticks(60, map_chart_tag_place_callback, {player = player, xpos = xpos, ypos = ypos, item = 'explosive-rocket'}) render_radius({position = {x = xpos, y = ypos}, player = player, radius = radius, color = {r = 0.1, g = 0, b = 0, a = 0.1}}) @@ -635,8 +637,8 @@ function Public.control(config) if item.type == 'barrage' then local radius_level = barrage_data.radius_level -- max radius of the strike area local count_level = barrage_data.count_level -- the number of poison capsules launched at the enemy - local radius = 5 + (radius_level * 3) - local count = (count_level - 1) * 5 + 3 + local radius = 25 + (radius_level * 5) + local count = count_level * 6 local strikeCost = count * 4 local name = item.name diff --git a/map_gen/maps/crash_site/scenario.lua b/map_gen/maps/crash_site/scenario.lua index e4e5fa778..06c3a8911 100644 --- a/map_gen/maps/crash_site/scenario.lua +++ b/map_gen/maps/crash_site/scenario.lua @@ -803,7 +803,8 @@ local function init(config) name = 'barrage_radius', name_label = {'command_description.crash_site_barrage_radius_name_label', 1}, sprite = 'virtual-signal/signal-B', - description = {'command_description.crash_site_barrage_radius', 1, 0, 5} + description = {'command_description.crash_site_barrage_radius', 1, 0, 25} + }, { price = 1000, From ee59a10fd6e644f81566c32275bae800d8639a6e Mon Sep 17 00:00:00 2001 From: Jayefuu <28716932+Jayefuu@users.noreply.github.com> Date: Sun, 3 Oct 2021 19:32:17 +0100 Subject: [PATCH 5/5] Updated some comments as per suggestions --- map_gen/maps/crash_site/commands.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/map_gen/maps/crash_site/commands.lua b/map_gen/maps/crash_site/commands.lua index 8de681292..cde767ff6 100644 --- a/map_gen/maps/crash_site/commands.lua +++ b/map_gen/maps/crash_site/commands.lua @@ -435,12 +435,11 @@ function Public.control(config) return end - -- process each set of coordinates with a 20 strike limit + -- process each set of coordinates from the arguments with a 20 coordinate, 10 strike limit. local i = 1 local xpos = coords[i] local ypos = coords[i + 1] - -- This while loop lets players add multiple GPS coordinates to the /strike command arguments to strike more than one place at once. Up to a maximum of 20 - while xpos ~= nil and ypos ~= nil and i < 20 do + while xpos ~= nil and ypos ~= nil and i < 20 do -- Process multiple GPS coordinates in the /strike command arguments to strike more than one place at once. -- Check the contents of the chest by spawn for enough poison capsules to use as payment local inv = dropbox.get_inventory(defines.inventory.chest) local capCount = inv.get_item_count("poison-capsule") @@ -519,12 +518,11 @@ function Public.control(config) return end - -- process each set of coordinates from the arguments with a 20 strike limit + -- process each set of coordinates from the arguments with a 20 coordinate, 10 barrage limit local i = 1 local xpos = coords[i] local ypos = coords[i + 1] - -- This while loop lets players add multiple GPS coordinates to the /strike command arguments to strike more than one place at once. Up to a maximum of 20 - while xpos ~= nil and ypos ~= nil and i < 20 do + while xpos ~= nil and ypos ~= nil and i < 20 do -- Process multiple GPS coordinates in the /barrage command arguments to strike more than one place at once. -- Check the contents of the chest by spawn for enough rockets to use as payment local inv = dropbox.get_inventory(defines.inventory.chest) local capCount = inv.get_item_count("explosive-rocket")