Skip to content

Commit

Permalink
Fix m56d and m2c crushing, labeling, and damage retention (#5481)
Browse files Browse the repository at this point in the history
# About the pull request

This PR addresses 5 things regarding the m56d and m2c:
1. Both now properly retain labeler labels (though technically the m56d
post can lose its label - gun takes priority)
2. The m56d now retains its damage when disassembled
3. The m56d's post now has an implementation for handle_charge_collision
so they can croosh not fully assembled guns
4. It appeared possible to duplicate the m56d when a charger crushed it
if it both was destroyed by the impact and the update_health resulted in
the gun being refunded; this is no longer possible since the charge
logic returns early if it is destroyed
5. Vehicles running over a m56d post now undeploys the m56d correctly if
it had a gun attached (it would downgrade to just a post)

# Explain why it's good for the game

Fixes #5477 but I don't think this *ever* worked. Rather the issue is
purely when the gun is in this state:

![image](https://github.com/cmss13-devs/cmss13/assets/76988376/c72209b5-07da-46ac-adaf-c202bff4489e)

Additionally, if we're going to have a mechanic to weld to fix the gun;
you shouldn't be able to circumvent this by simply disassembling it...
However, since the destruction of the m56d didn't have a guaranteed
chance to destroy the gun, technically this results in a fully repaired
gun again if you can make another post for it. It would need to work
more like the m2c if we wanted it to remain in a broken state in this
situation.

# Testing Photographs and Procedure
https://youtu.be/rg1mLFjhsEY (though I forgot to record crowbar
disassembly for the m56d too)

# Changelog
:cl: Drathek
fix: The M56D and the M2C now retain their labels when disassembled
fix: The M56D can now be charger crushed when not fully assembled
fix: The M56D being run over by a vehicle now undeploys the gun
correctly (so it retains the gun if it had a gun)
fix: Fix an edge case that could duplicate the M56D when charger crushed
balance: The M56D now retains the health of the gun through all of its
different disassembled states
/:cl:
  • Loading branch information
Drulikar committed Jan 19, 2024
1 parent 809333f commit 2442f89
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 90 deletions.
34 changes: 18 additions & 16 deletions code/modules/cm_marines/m2c.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,21 @@
if(!check_can_setup(user, rotate_check, OT, ACR))
return

var/obj/structure/machinery/m56d_hmg/auto/M = new /obj/structure/machinery/m56d_hmg/auto(user.loc)
transfer_label_component(M)
M.setDir(user.dir) // Make sure we face the right direction
M.anchored = TRUE
playsound(M, 'sound/items/m56dauto_setup.ogg', 75, TRUE)
to_chat(user, SPAN_NOTICE("You deploy [M]."))
M.rounds = rounds
M.overheat_value = overheat_value
M.health = health
M.update_icon()
var/obj/structure/machinery/m56d_hmg/auto/HMG = new(user.loc)
transfer_label_component(HMG)
HMG.setDir(user.dir) // Make sure we face the right direction
HMG.anchored = TRUE
playsound(HMG, 'sound/items/m56dauto_setup.ogg', 75, TRUE)
to_chat(user, SPAN_NOTICE("You deploy [HMG]."))
HMG.rounds = rounds
HMG.overheat_value = overheat_value
HMG.health = health
HMG.update_damage_state()
HMG.update_icon()
qdel(src)

if(M.rounds > 0)
M.try_mount_gun(user)
if(HMG.rounds > 0)
HMG.try_mount_gun(user)

/obj/item/device/m2c_gun/attackby(obj/item/O as obj, mob/user as mob)
if(!ishuman(user))
Expand Down Expand Up @@ -313,12 +314,13 @@
if(health <= 0)
playsound(src.loc, 'sound/items/Welder2.ogg', 25, 1)
visible_message(SPAN_WARNING("[src] has broken down completely!"))
var/obj/item/device/m2c_gun/HMG = new(src.loc)
var/obj/item/device/m2c_gun/HMG = new(loc)
HMG.rounds = rounds
HMG.broken_gun = TRUE
HMG.unacidable = FALSE
HMG.health = 0
HMG.update_icon()
transfer_label_component(HMG)
qdel(src)
return

Expand Down Expand Up @@ -475,10 +477,10 @@
return
user.visible_message(SPAN_NOTICE("[user] disassembles [src]."),SPAN_NOTICE("You fold up the tripod for [src], disassembling it."))
playsound(src.loc, 'sound/items/m56dauto_setup.ogg', 75, 1)
var/obj/item/device/m2c_gun/HMG = new(src.loc)
var/obj/item/device/m2c_gun/HMG = new(loc)
transfer_label_component(HMG)
HMG.rounds = src.rounds
HMG.overheat_value = round(0.5 * src.overheat_value)
HMG.rounds = rounds
HMG.overheat_value = round(0.5 * overheat_value)
if (HMG.overheat_value <= 10)
HMG.overheat_value = 0
HMG.update_icon()
Expand Down
88 changes: 54 additions & 34 deletions code/modules/cm_marines/smartgun_mount.dm
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,15 @@
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
M.gun_rounds = src.rounds //Inherit the amount of ammo we had.
M.gun_mounted = TRUE
M.anchored = TRUE
M.update_icon()
transfer_label_component(M)
to_chat(user, SPAN_NOTICE("You deploy \the [src]."))
var/obj/structure/machinery/m56d_post/post = new(user.loc)
post.setDir(user.dir) // Make sure we face the right direction
post.gun_rounds = rounds
post.gun_mounted = TRUE
post.gun_health = health // retain damage
post.anchored = TRUE
post.update_icon()
transfer_label_component(post)
to_chat(user, SPAN_NOTICE("You deploy [src]."))
qdel(src)


Expand Down Expand Up @@ -223,8 +224,8 @@
return

to_chat(user, SPAN_NOTICE("You deploy \the [src]."))
var/obj/structure/machinery/m56d_post/M = new /obj/structure/machinery/m56d_post(user.loc)
transfer_label_component(M)
var/obj/structure/machinery/m56d_post/post = new(user.loc)
transfer_label_component(post)
qdel(src)


Expand All @@ -238,8 +239,12 @@
density = TRUE
layer = ABOVE_MOB_LAYER
projectile_coverage = PROJECTILE_COVERAGE_LOW
var/gun_mounted = FALSE //Has the gun been mounted?
var/gun_rounds = 0 //Did the gun come with any ammo?
///Whether a gun is mounted
var/gun_mounted = FALSE
///Ammo amount of the mounted gun
var/gun_rounds = 0
///Health of the mounted gun
var/gun_health = 0
health = 50

/obj/structure/machinery/m56d_post/initialize_pass_flags(datum/pass_flags_container/PF)
Expand Down Expand Up @@ -302,8 +307,9 @@
to_chat(user, SPAN_WARNING("\The [src] can't be folded while screwed to the floor. Unscrew it first."))
return
to_chat(user, SPAN_NOTICE("You fold [src]."))
var/obj/item/device/m56d_post/P = new(loc)
user.put_in_hands(P)
var/obj/item/device/m56d_post/post = new(loc)
transfer_label_component(post)
user.put_in_hands(post)
qdel(src)

/obj/structure/machinery/m56d_post/attackby(obj/item/O, mob/user)
Expand Down Expand Up @@ -331,6 +337,8 @@
user.visible_message(SPAN_NOTICE("[user] installs [MG] into place."),SPAN_NOTICE("You install [MG] into place."))
gun_mounted = 1
gun_rounds = MG.rounds
gun_health = MG.health
MG.transfer_label_component(src)
update_icon()
user.temp_drop_inv_item(MG)
qdel(MG)
Expand All @@ -343,12 +351,19 @@
to_chat(user, "You begin dismounting [src]'s gun...")
if(do_after(user, 30 * user.get_skill_duration_multiplier(SKILL_ENGINEER), INTERRUPT_ALL|BEHAVIOR_IMMOBILE, BUSY_ICON_BUILD) && gun_mounted)
playsound(src.loc, 'sound/items/Crowbar.ogg', 25, 1)
user.visible_message(SPAN_NOTICE("[user] removes [src]'s gun."),SPAN_NOTICE("You remove [src]'s gun."))
var/obj/item/device/m56d_gun/G = new(loc)
G.rounds = gun_rounds
G.update_icon()
user.visible_message(SPAN_NOTICE("[user] removes [src]'s gun."), SPAN_NOTICE("You remove [src]'s gun."))
var/obj/item/device/m56d_gun/HMG = new(loc)
HMG.rounds = gun_rounds
if(gun_health)
HMG.health = gun_health
HMG.update_icon()
transfer_label_component(HMG)
var/datum/component/label/label = GetComponent(/datum/component/label)
if(label)
label.remove_label()
gun_mounted = FALSE
gun_rounds = 0
gun_health = 0
update_icon()
return

Expand Down Expand Up @@ -389,13 +404,16 @@
var/disassemble_time = 30
if(do_after(user, disassemble_time * user.get_skill_duration_multiplier(SKILL_ENGINEER), INTERRUPT_ALL|BEHAVIOR_IMMOBILE, BUSY_ICON_BUILD))
playsound(src.loc, 'sound/items/Deconstruct.ogg', 25, 1)
user.visible_message(SPAN_NOTICE("[user] screws the M56D into the mount."),SPAN_NOTICE("You finalize the M56D heavy machine gun."))
var/obj/structure/machinery/m56d_hmg/G = new(src.loc) //Here comes our new turret.
transfer_label_component(G)
G.visible_message("[icon2html(G, viewers(src))] <B>\The [G] is now complete!</B>") //finished it for everyone to
G.setDir(dir) //make sure we face the right direction
G.rounds = src.gun_rounds //Inherent the amount of ammo we had.
G.update_icon()
user.visible_message(SPAN_NOTICE("[user] screws the M56D into the mount."), SPAN_NOTICE("You finalize the M56D heavy machine gun."))
var/obj/structure/machinery/m56d_hmg/HMG = new(loc)
transfer_label_component(HMG)
HMG.visible_message("[icon2html(HMG, viewers(src))] <B>\The [HMG] is now complete!</B>")
HMG.setDir(dir)
HMG.rounds = gun_rounds
if(gun_health)
HMG.health = gun_health
HMG.update_damage_state()
HMG.update_icon()
qdel(src)
else
if(anchored)
Expand Down Expand Up @@ -562,7 +580,7 @@
return
else
playsound(src.loc, 'sound/items/Ratchet.ogg', 25, 1)
user.visible_message("[user] rotates \the [src].","You rotate \the [src].")
user.visible_message("[user] rotates [src].", "You rotate [src].")
setDir(turn(dir, -90))
if(operator)
update_pixels(operator)
Expand All @@ -576,14 +594,15 @@

var/disassemble_time = 30
if(do_after(user, disassemble_time * user.get_skill_duration_multiplier(SKILL_ENGINEER), INTERRUPT_ALL|BEHAVIOR_IMMOBILE, BUSY_ICON_BUILD))
user.visible_message(SPAN_NOTICE(" [user] disassembles [src]! "),SPAN_NOTICE(" You disassemble [src]!"))
user.visible_message(SPAN_NOTICE("[user] disassembles [src]!"), SPAN_NOTICE("You disassemble [src]!"))
playsound(src.loc, 'sound/items/Screwdriver.ogg', 25, 1)
var/obj/item/device/m56d_gun/HMG = new(src.loc) //Here we generate our disassembled mg.
var/obj/item/device/m56d_gun/HMG = new(loc)
transfer_label_component(HMG)
HMG.rounds = src.rounds //Inherent the amount of ammo we had.
HMG.rounds = rounds
HMG.has_mount = TRUE
HMG.health = health
HMG.update_icon()
qdel(src) //Now we clean up the constructed gun.
qdel(src)
return

if(istype(O, /obj/item/ammo_magazine/m56d)) // RELOADING DOCTOR FREEMAN.
Expand All @@ -595,7 +614,7 @@
if(user.action_busy) return
if(!do_after(user, 25 * user.get_skill_duration_multiplier(SKILL_ENGINEER), INTERRUPT_ALL, BUSY_ICON_FRIENDLY))
return
user.visible_message(SPAN_NOTICE("[user] loads [src]! "),SPAN_NOTICE("You load [src]!"))
user.visible_message(SPAN_NOTICE("[user] loads [src]!"), SPAN_NOTICE("You load [src]!"))
playsound(loc, 'sound/weapons/gun_minigun_cocked.ogg', 25, 1)
if(rounds)
var/obj/item/ammo_magazine/m56d/D = new(user.loc)
Expand Down Expand Up @@ -638,10 +657,10 @@
if(health <= 0)
var/destroyed = rand(0,1) //Ammo cooks off or something. Who knows.
playsound(src.loc, 'sound/items/Welder2.ogg', 25, 1)
if(!destroyed) new /obj/structure/machinery/m56d_post(loc)
else
if(!destroyed)
var/obj/item/device/m56d_gun/HMG = new(loc)
HMG.rounds = src.rounds //Inherent the amount of ammo we had.
transfer_label_component(HMG)
HMG.rounds = rounds
qdel(src)
return

Expand Down Expand Up @@ -981,6 +1000,7 @@
to_chat(operator, SPAN_HIGHDANGER("You are knocked off the gun by the sheer force of the ram!"))
operator.unset_interaction()
operator.apply_effect(3, WEAKEN)
operator.emote("pain")

/// Getter for burst_firing
/obj/structure/machinery/m56d_hmg/proc/get_burst_firing()
Expand Down
Loading

0 comments on commit 2442f89

Please sign in to comment.