Skip to content

Commit

Permalink
Fix m56d labeling and damage resetting
Browse files Browse the repository at this point in the history
Implement crusher collision for m56d_post
  • Loading branch information
Drulikar committed Jan 17, 2024
1 parent 57241e8 commit f7e0afd
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 67 deletions.
28 changes: 15 additions & 13 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
72 changes: 46 additions & 26 deletions code/modules/cm_marines/smartgun_mount.dm
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,14 @@
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)
var/obj/structure/machinery/m56d_post/post = new(user.loc)
post.setDir(user.dir) // Make sure we face the right direction
post.gun_rounds = src.rounds //Inherit the amount of ammo we had.
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 \the [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) //Here comes our new turret.
transfer_label_component(HMG)
HMG.visible_message("[icon2html(HMG, viewers(src))] <B>\The [HMG] is now complete!</B>") //finished it for everyone to
HMG.setDir(dir) //make sure we face the right direction
HMG.rounds = gun_rounds //Inherent the amount of ammo we had.
if(gun_health)
HMG.health = gun_health
HMG.update_damage_state()
HMG.update_icon()
qdel(src)
else
if(anchored)
Expand Down Expand Up @@ -582,6 +600,7 @@
transfer_label_component(HMG)
HMG.rounds = src.rounds //Inherent the amount of ammo we had.
HMG.has_mount = TRUE
HMG.health = health
HMG.update_icon()
qdel(src) //Now we clean up the constructed gun.
return
Expand Down Expand Up @@ -638,9 +657,9 @@
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)
transfer_label_component(HMG)
HMG.rounds = src.rounds //Inherent the amount of ammo we had.
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
Original file line number Diff line number Diff line change
Expand Up @@ -488,37 +488,77 @@
// Marine MGs

/obj/structure/machinery/m56d_hmg/handle_charge_collision(mob/living/carbon/xenomorph/xeno, datum/action/xeno_action/onclick/charger_charge/charger_ability)
if(charger_ability.momentum > CCA_MOMENTUM_LOSS_MIN)
CrusherImpact()
var/datum/effect_system/spark_spread/sparks = new
update_health(charger_ability.momentum * 15)
if(operator) operator.emote("pain")
sparks.set_up(1, 1, loc)
sparks.start()
xeno.visible_message(
SPAN_DANGER("[xeno] rams \the [src]!"),
SPAN_XENODANGER("You ram \the [src]!")
)
playsound(src, "sound/effects/metal_crash.ogg", 25, TRUE)
if(istype(src,/obj/structure/machinery/m56d_hmg/auto)) // we don't want to charge it to the point of downgrading it (:
var/obj/item/device/m2c_gun/HMG = new(src.loc)
HMG.health = src.health
transfer_label_component(HMG)
HMG.rounds = src.rounds //Inherent the amount of ammo we had.
HMG.update_icon()
qdel(src)
else
var/obj/item/device/m56d_gun/HMG = new(src.loc) // note: find a better way than a copy pasted else statement
HMG.health = src.health
transfer_label_component(HMG)
HMG.rounds = src.rounds //Inherent the amount of ammo we had.
HMG.has_mount = TRUE
HMG.update_icon()
qdel(src) //Now we clean up the constructed gun.
if(charger_ability.momentum <= CCA_MOMENTUM_LOSS_MIN)
charger_ability.stop_momentum()
return

CrusherImpact()
var/datum/effect_system/spark_spread/sparks = new
update_health(charger_ability.momentum * 15)
sparks.set_up(1, 1, loc)
sparks.start()
xeno.visible_message(
SPAN_DANGER("[xeno] rams \the [src]!"),
SPAN_XENODANGER("You ram \the [src]!")
)
playsound(src, "sound/effects/metal_crash.ogg", 25, TRUE)

if(QDELETED(src))
// The crash destroyed it
charger_ability.lose_momentum(CCA_MOMENTUM_LOSS_MIN) //Lose one turfs worth of speed
return XENO_CHARGE_TRY_MOVE
charger_ability.stop_momentum()

// Undeploy
if(istype(src, /obj/structure/machinery/m56d_hmg/auto)) // we don't want to charge it to the point of downgrading it (:
var/obj/item/device/m2c_gun/HMG = new(loc)
HMG.health = health
transfer_label_component(HMG)
HMG.rounds = rounds //Inherent the amount of ammo we had.
HMG.update_icon()
qdel(src)
else
var/obj/item/device/m56d_gun/HMG = new(loc) // note: find a better way than a copy pasted else statement
HMG.health = health
transfer_label_component(HMG)
HMG.rounds = rounds //Inherent the amount of ammo we had.
HMG.has_mount = TRUE
HMG.update_icon()
qdel(src) //Now we clean up the constructed gun.

/obj/structure/machinery/m56d_post/handle_charge_collision(mob/living/carbon/xenomorph/xeno, datum/action/xeno_action/onclick/charger_charge/charger_ability)
if(charger_ability.momentum <= CCA_MOMENTUM_LOSS_MIN)
charger_ability.stop_momentum()

var/datum/effect_system/spark_spread/sparks = new
update_health(charger_ability.momentum * 15)
sparks.set_up(1, 1, loc)
sparks.start()
xeno.visible_message(
SPAN_DANGER("[xeno] rams \the [src]!"),
SPAN_XENODANGER("You ram \the [src]!")
)
playsound(src, "sound/effects/metal_crash.ogg", 25, TRUE)

if(QDELETED(src))
// The crash destroyed it
charger_ability.lose_momentum(CCA_MOMENTUM_LOSS_MIN) //Lose one turfs worth of speed
return XENO_CHARGE_TRY_MOVE

// Undeploy
if(gun_mounted)
var/obj/item/device/m56d_gun/HMG = new(loc)
transfer_label_component(HMG)
HMG.rounds = gun_rounds //Inherent the amount of ammo we had.
HMG.has_mount = TRUE
if(gun_health)
HMG.health = gun_health
HMG.update_icon()
qdel(src) //Now we clean up the partially constructed gun.
else
var/obj/item/device/m56d_post/post = new(loc)
post.health = health
transfer_label_component(post)
qdel(src)

// Prison Windows

Expand Down
2 changes: 2 additions & 0 deletions code/modules/vehicles/multitile/multitile_bump.dm
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@
HMG.name = name
HMG.rounds = rounds
HMG.has_mount = TRUE
HMG.health = health
HMG.update_icon()
transfer_label_component(HMG)
playsound(V, 'sound/effects/metal_crash.ogg', 20)
visible_message(SPAN_DANGER("\The [V] drives over \the [src]!"))
qdel(src)
Expand Down

0 comments on commit f7e0afd

Please sign in to comment.