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

Adds antispam check similar to what sentrygun has to m56d #5246

Merged
merged 9 commits into from
Jan 1, 2024
13 changes: 12 additions & 1 deletion code/modules/cm_marines/smartgun_mount.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
icon_state = "M56D_gun_e"
var/rounds = 0 // How many rounds are in the weapon. This is useful if we break down our guns.
var/has_mount = FALSE // Indicates whether the M56D will come with its folding mount already attached
cuberound marked this conversation as resolved.
Show resolved Hide resolved
var/defense_check_range = 2
var/can_be_near_defense = FALSE
cuberound marked this conversation as resolved.
Show resolved Hide resolved

/obj/item/device/m56d_gun/Initialize(mapload, ...)
. = ..()
Expand Down Expand Up @@ -84,7 +86,11 @@

/obj/item/device/m56d_gun/attack_self(mob/user)
..()

if(!can_be_near_defense)
for(var/obj/structure/machinery/machine in urange(defense_check_range, loc))
if(istype(machine, var/obj/structure/machinery/m56d_hmg) || istype(machine, var/obj/structure/machinery/m56d_post)
cuberound marked this conversation as resolved.
Show resolved Hide resolved
to_chat(user, SPAN_WARNING("This is too close to [machine]!"))
return
if(!ishuman(user))
return
if(!has_mount)
Expand Down Expand Up @@ -125,6 +131,11 @@

if(!do_after(user, 1 SECONDS, INTERRUPT_ALL|BEHAVIOR_IMMOBILE, BUSY_ICON_BUILD))
return
if(!can_be_near_defense)
for(var/obj/structure/machinery/machine in urange(defense_check_range, loc))
if(istype(machine, var/obj/structure/machinery/m56d_hmg) || istype(machine, var/obj/structure/machinery/m56d_post)
cuberound marked this conversation as resolved.
Show resolved Hide resolved
to_chat(user, SPAN_WARNING("This is too close to [machine]!"))
return

var/obj/structure/machinery/m56d_post/M = new /obj/structure/machinery/m56d_post(user.loc)
M.setDir(user.dir) // Make sure we face the right direction
Expand Down
Loading