From 89f8bba648399248378f4cd184f48436e2d5c2e8 Mon Sep 17 00:00:00 2001 From: Qwertytoforty <52090703+Qwertytoforty@users.noreply.github.com> Date: Wed, 7 Jun 2023 15:03:36 -0400 Subject: [PATCH] Getting thrown into things actually hurts now [ready for review] (#21022) * Getting thrown into things actually hurts now * add the blob one too dingus * more changes consoles windows ect * fucking hell one sec * now up to date * Apply suggestions from code review Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com> * early returns * rename of proc --------- Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com> --- code/game/atoms.dm | 4 ++++ code/game/machinery/computer/computer.dm | 8 +++++++ code/game/machinery/vendors/vending.dm | 8 +++++++ code/game/objects/objs.dm | 10 ++++++++ code/game/objects/structures/window.dm | 25 ++++++++++++++++++++ code/game/turfs/turf.dm | 9 +++++++ code/modules/events/blob/theblob.dm | 4 ++++ code/modules/mob/living/carbon/carbon.dm | 30 +++++------------------- code/modules/mob/living/living.dm | 12 ++++++++++ 9 files changed, 86 insertions(+), 24 deletions(-) diff --git a/code/game/atoms.dm b/code/game/atoms.dm index 50c6db6a583..753033dac89 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -547,6 +547,10 @@ if(density && !has_gravity(AM)) //thrown stuff bounces off dense stuff in no grav, unless the thrown stuff ends up inside what it hit(embedding, bola, etc...). addtimer(CALLBACK(src, PROC_REF(hitby_react), AM), 2) +/// This proc applies special effects of a carbon mob hitting something, be it a wall, structure, or window. You can set mob_hurt to false to avoid double dipping through subtypes if returning ..() +/atom/proc/hit_by_thrown_carbon(mob/living/carbon/human/C, datum/thrownthing/throwingdatum, damage, mob_hurt = FALSE, self_hurt = FALSE) + return + /atom/proc/hitby_react(atom/movable/AM) if(AM && isturf(AM.loc)) step(AM, turn(AM.dir, 180)) diff --git a/code/game/machinery/computer/computer.dm b/code/game/machinery/computer/computer.dm index 85429c3949a..f10b2b741e8 100644 --- a/code/game/machinery/computer/computer.dm +++ b/code/game/machinery/computer/computer.dm @@ -176,3 +176,11 @@ if(circuit && !(flags & NODECONSTRUCT)) if(I.use_tool(src, user, 20, volume = I.tool_volume)) deconstruct(TRUE, user) + +/obj/machinery/computer/hit_by_thrown_carbon(mob/living/carbon/human/C, datum/thrownthing/throwingdatum, damage, mob_hurt, self_hurt) + if(!self_hurt && prob(50 * (damage / 15))) + obj_break(MELEE) + take_damage(damage, BRUTE) + self_hurt = TRUE + return ..() + diff --git a/code/game/machinery/vendors/vending.dm b/code/game/machinery/vendors/vending.dm index b394b067f28..1c111203f19 100644 --- a/code/game/machinery/vendors/vending.dm +++ b/code/game/machinery/vendors/vending.dm @@ -1118,6 +1118,14 @@ tilt(target, from_combat = TRUE) return TRUE +/obj/machinery/economy/vending/hit_by_thrown_carbon(mob/living/carbon/human/C, datum/thrownthing/throwingdatum, damage, mob_hurt, self_hurt) + if(HAS_TRAIT(C, TRAIT_FLATTENED)) + return ..() + tilt(C, from_combat = TRUE) + mob_hurt = TRUE + return ..() + + /* * Vending machine types */ diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm index 8c45ccfba31..31257730660 100644 --- a/code/game/objects/objs.dm +++ b/code/game/objects/objs.dm @@ -297,3 +297,13 @@ // In the event that the object doesn't have an overriden version of this proc to do it, log a runtime so one can be added. CRASH("Proc force_eject_occupant() is not overridden on a machine containing a mob.") +/obj/hit_by_thrown_carbon(mob/living/carbon/human/C, datum/thrownthing/throwingdatum, damage, mob_hurt, self_hurt) + damage *= 0.75 //Define this probably somewhere, we want objects to hurt less than walls, unless special impact effects. + playsound(src, 'sound/weapons/punch1.ogg', 35, 1) + if(mob_hurt) //Density check probably not needed, one should only bump into something if it is dense, and blob tiles are not dense, because of course they are not. + return + C.visible_message("[C] slams into [src]!", "You slam into [src]!") + C.take_organ_damage(damage) + if(!self_hurt) + take_damage(damage, BRUTE) + C.KnockDown(3 SECONDS) diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm index 10066401503..05565131778 100644 --- a/code/game/objects/structures/window.dm +++ b/code/game/objects/structures/window.dm @@ -499,6 +499,31 @@ if(exposed_temperature > (T0C + heat_resistance)) take_damage(round(exposed_volume / 100), BURN, 0, 0) +/obj/structure/window/hit_by_thrown_carbon(mob/living/carbon/human/C, datum/thrownthing/throwingdatum, damage, mob_hurt, self_hurt) + var/shattered = FALSE + if(damage * 2 >= obj_integrity && shardtype && !mob_hurt) + shattered = TRUE + var/obj/item/S = new shardtype(loc) + S.embedded_ignore_throwspeed_threshold = TRUE + S.throw_impact(C) + S.embedded_ignore_throwspeed_threshold = FALSE + damage *= (4/3) //Inverts damage loss from being a structure, since glass breaking on you hurts + var/turf/T = get_turf(src) + for(var/obj/structure/grille/G in T.contents) + var/obj/structure/cable/SC = T.get_cable_node() + if(SC) + playsound(G, 'sound/magic/lightningshock.ogg', 100, TRUE, extrarange = 5) + tesla_zap(G, 3, SC.get_queued_available_power() * 0.05, ZAP_MOB_DAMAGE | ZAP_OBJ_DAMAGE | ZAP_MOB_STUN | ZAP_ALLOW_DUPLICATES) //Zap for 1/20 of the amount of power, because I am evil. + SC.add_queued_power_demand(SC.get_queued_available_power() * 0.0375) // you can gain up to 3.5 via the 4x upgrades power is halved by the pole so thats 2x then 1X then .5X for 3.5x the 3 bounces shock. + qdel(G) //We don't want the grille to block the way, we want rule of cool of throwing people into space! + + if(!self_hurt) + take_damage(damage * 2, BRUTE) //Makes windows more vunerable to being thrown so they'll actually shatter in a reasonable ammount of time. + self_hurt = TRUE + ..() + if(shattered) + C.throw_at(throwingdatum.target, throwingdatum.maxrange - 1, throwingdatum.speed - 1) //Annnnnnnd yeet them into space, but slower, now that everything is dealt with + /obj/structure/window/GetExplosionBlock() return reinf && fulltile ? real_explosion_block : 0 diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 09ca5d6419b..8112dae7a59 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -573,3 +573,12 @@ else return I return I + + +/turf/hit_by_thrown_carbon(mob/living/carbon/human/C, datum/thrownthing/throwingdatum, damage, mob_hurt, self_hurt) + if(mob_hurt || !density) + return + playsound(src, 'sound/weapons/punch1.ogg', 35, 1) + C.visible_message("[C] slams into [src]!", "You slam into [src]!") + C.take_organ_damage(damage) + C.KnockDown(3 SECONDS) diff --git a/code/modules/events/blob/theblob.dm b/code/modules/events/blob/theblob.dm index da6feab9aa1..83ce5b73924 100644 --- a/code/modules/events/blob/theblob.dm +++ b/code/modules/events/blob/theblob.dm @@ -268,6 +268,10 @@ GLOBAL_LIST_EMPTY(blob_nodes) return B.blob_reagent_datum.description return "something unknown" +/obj/structure/blob/hit_by_thrown_carbon(mob/living/carbon/human/C, datum/thrownthing/throwingdatum, damage, mob_hurt, self_hurt) + damage *= 0.25 // Lets not have sorium be too much of a blender / rapidly kill itself + return ..() + /obj/structure/blob/normal icon_state = "blob" light_range = 0 diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 00c070b2c4e..603ddf43bb6 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -612,31 +612,13 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/ven playsound(get_turf(src), 'sound/effects/meteorimpact.ogg', 100, TRUE) return - var/hurt = TRUE var/damage = 10 + 1.5 * speed // speed while thrower is standing still is 2, while walking with an aggressive grab is 2.4, highest speed is 14 - /*if(istype(throwingdatum, /datum/thrownthing)) - var/datum/thrownthing/D = throwingdatum - if(isrobot(D.thrower)) - var/mob/living/silicon/robot/R = D.thrower - if(!R.emagged) - hurt = FALSE*/ - if(hit_atom.density && isturf(hit_atom)) - if(hurt) - visible_message("[src] slams into [hit_atom]!", "You slam into [hit_atom]!") - take_organ_damage(damage) - KnockDown(3 SECONDS) - playsound(src, 'sound/weapons/punch1.ogg', 35, 1) - if(iscarbon(hit_atom) && hit_atom != src) - var/mob/living/carbon/victim = hit_atom - if(victim.flying) - return - if(hurt) - victim.take_organ_damage(damage) - take_organ_damage(damage) - victim.KnockDown(3 SECONDS) - KnockDown(3 SECONDS) - visible_message("[src] crashes into [victim], knocking them both over!", "You violently crash into [victim]!") - playsound(src, 'sound/weapons/punch1.ogg', 50, 1) + + hit_atom.hit_by_thrown_carbon(src, throwingdatum, damage, FALSE, FALSE) + +/mob/living/carbon/hit_by_thrown_carbon(mob/living/carbon/human/C, datum/thrownthing/throwingdatum, damage, mob_hurt, self_hurt) + . = ..() + KnockDown(3 SECONDS) /mob/living/carbon/proc/toggle_throw_mode() if(in_throw_mode) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 29077e385cb..8c3970d270d 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -1139,3 +1139,15 @@ /mob/living/throw_at(atom/target, range, speed, mob/thrower, spin, diagonals_first, datum/callback/callback, force, dodgeable) stop_pulling() return ..() + +/mob/living/hit_by_thrown_carbon(mob/living/carbon/human/C, datum/thrownthing/throwingdatum, damage, mob_hurt, self_hurt) + if(C == src || flying || !density) + return + playsound(src, 'sound/weapons/punch1.ogg', 50, 1) + if(mob_hurt) + return + if(!self_hurt) + take_organ_damage(damage) + C.take_organ_damage(damage) + C.KnockDown(3 SECONDS) + C.visible_message("[C] crashes into [src], knocking them both over!", "You violently crash into [src]!")