From e8a53566525ac24bd66e883e3b3c695d49234755 Mon Sep 17 00:00:00 2001 From: Jayefuu Date: Fri, 18 Mar 2022 15:48:45 +0000 Subject: [PATCH] Added crash site /strike anti-grief (#1302) --- locale/en/redmew_command_text.cfg | 1 + map_gen/maps/crash_site/commands.lua | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/locale/en/redmew_command_text.cfg b/locale/en/redmew_command_text.cfg index 22a273ac..111bd07f 100644 --- a/locale/en/redmew_command_text.cfg +++ b/locale/en/redmew_command_text.cfg @@ -28,6 +28,7 @@ crash_site_airstrike_damage_upgrade_success=__1__ has upgraded Airstrike Damage crash_site_airstrike_radius_upgrade_success=__1__ has updgraded Airstrike Radius to level __2__ crash_site_airstrike_planner_label=Poison strike targetting remote. crash_site_airstrike_planner_description=Use this deconstruction planner to easily launch a poison strike with a click. Put it in your hotbar for easy access. +crash_site_airstrike_no_enemies=No enemies found at [gps=__1__,__2__,__3__]. What a waste of poison capsules! crash_site_barrage_planner_label=Barrage targetting remote. crash_site_barrage_planner_description=Use this deconstruction planner to easily launch an artillery barrage with a click. Put it in your hotbar for easy access. crash_site_barrage_invalid=Invalid co-ordinates. diff --git a/map_gen/maps/crash_site/commands.lua b/map_gen/maps/crash_site/commands.lua index 8613248a..4b1b75a8 100644 --- a/map_gen/maps/crash_site/commands.lua +++ b/map_gen/maps/crash_site/commands.lua @@ -455,11 +455,21 @@ function Public.control(config) 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}) + -- aim of anti-grief is to stop players accidentally using it on themselves. + -- we don't mind if there's no enemies there, we'll still take the poison capsules and do the charting so it can still be used to reveal parts of the map + local enemies = s.count_entities_filtered{position = {xpos, ypos}, radius=radius+10, force="enemy", limit=1} + + if enemies ~= 0 then + 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 + else + player.print({'command_description.crash_site_airstrike_no_enemies', xpos, ypos, s.name},Color.fail) end + + -- render some items regardless as good visual feedback where their strike was. 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'})