From ff48d2085be48b84ad6c2d0b5233dcfc4eaf3c05 Mon Sep 17 00:00:00 2001 From: Contrabang <91113370+Contrabang@users.noreply.github.com> Date: Sun, 28 Jan 2024 18:26:33 -0500 Subject: [PATCH 1/3] jumping out of dropships is bad for your health --- code/__DEFINES/traits.dm | 2 + code/controllers/subsystem/shuttles.dm | 16 +-- code/game/turfs/transit.dm | 103 ++++++++++++++++-- .../mob/living/carbon/human/human_damage.dm | 12 +- .../modules/mob/living/living_health_procs.dm | 2 +- code/modules/shuttle/shuttle.dm | 12 ++ code/modules/shuttle/shuttles/dropship.dm | 10 +- 7 files changed, 127 insertions(+), 30 deletions(-) diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index c2abe21a26ad..df89b74e02f8 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -462,6 +462,8 @@ GLOBAL_LIST(trait_name_map) #define XENO_WEED_TRAIT "xeno_weed" /// traits associated with actively interacted machinery #define INTERACTION_TRAIT "interaction" +/// traits associated with interacting with a dropship +#define TRAIT_SOURCE_DROPSHIP_INTERACTION "dropship_interaction" /// traits bound by stunned status effects #define STUNNED_TRAIT "stunned" /// traits bound by knocked_down status effect diff --git a/code/controllers/subsystem/shuttles.dm b/code/controllers/subsystem/shuttles.dm index 3e59744cff31..db0d449b4dd7 100644 --- a/code/controllers/subsystem/shuttles.dm +++ b/code/controllers/subsystem/shuttles.dm @@ -164,9 +164,6 @@ SUBSYSTEM_DEF(shuttle) // First, determine the size of the needed zone // Because of shuttle rotation, the "width" of the shuttle is not // always x. - var/travel_dir = M.preferred_direction - // Remember, the direction is the direction we appear to be - // coming from var/dock_angle = dir2angle(M.preferred_direction) + dir2angle(M.port_direction) + 180 var/dock_dir = angle2dir(dock_angle) @@ -185,19 +182,10 @@ SUBSYSTEM_DEF(shuttle) /* to_chat(world, "The attempted transit dock will be [transit_width] width, and \) - [transit_height] in height. The travel dir is [travel_dir]." + [transit_height] in height. The travel dir is [M.preferred_direction]." */ - var/transit_path = /turf/open/space/transit - switch(travel_dir) - if(NORTH) - transit_path = /turf/open/space/transit/north - if(SOUTH) - transit_path = /turf/open/space/transit/south - if(EAST) - transit_path = /turf/open/space/transit/east - if(WEST) - transit_path = /turf/open/space/transit/west + var/transit_path = M.get_transit_path_type() var/datum/turf_reservation/proposal = SSmapping.RequestBlockReservation(transit_width, transit_height, null, /datum/turf_reservation/transit, transit_path) diff --git a/code/game/turfs/transit.dm b/code/game/turfs/transit.dm index bae6718cfd59..31b110e81039 100644 --- a/code/game/turfs/transit.dm +++ b/code/game/turfs/transit.dm @@ -11,19 +11,106 @@ if(isobserver(crosser) || crosser.anchored) return - if(!(isitem(crosser) || isliving(crosser))) + if(!isitem(crosser) && !isliving(crosser)) return - var/turf/open/floor/floor = old_loc - if(istype(floor)) - var/fling_dir = get_dir(floor, crosser.loc) - - var/turf/near_turf = get_step(crosser.loc, get_step(crosser.loc, fling_dir)) - var/turf/projected = get_ranged_target_turf(near_turf, fling_dir, 50) + if(!istype(old_loc, /turf/open/space)) + var/turf/near_turf = get_step(crosser.loc, get_step(crosser.loc, dir)) + var/turf/projected = get_ranged_target_turf(near_turf, dir, 50) INVOKE_ASYNC(crosser, TYPE_PROC_REF(/atom/movable, throw_atom), projected, 50, SPEED_FAST, null, TRUE) - QDEL_IN(crosser, 0.5 SECONDS) + addtimer(CALLBACK(src, PROC_REF(handle_crosser), crosser), 0.5 SECONDS) + +/turf/open/space/transit/proc/handle_crosser(atom/movable/crosser) + if(QDELETED(crosser)) + return + qdel(crosser) + +/turf/open/space/transit/dropship + var/shuttle_tag + +/turf/open/space/transit/dropship/handle_crosser(atom/movable/crosser) + if(QDELETED(crosser)) + return + if(!shuttle_tag) + return ..() + + var/obj/docking_port/mobile/marine_dropship/dropship = SSshuttle.getShuttle(shuttle_tag) + if(!istype(dropship) || dropship.mode != SHUTTLE_CALL) + return ..() + + if(dropship.destination.id != DROPSHIP_LZ1 && dropship.destination.id != DROPSHIP_LZ2) + return ..() // we're not heading towards the LZs + + // you just jumped out of a dropship heading towards the LZ, if you're lucky, maybe you'll live! + var/list/ground_z_levels = SSmapping.levels_by_trait(ZTRAIT_GROUND) + if(!length(ground_z_levels)) + return ..() + + var/list/area/potential_areas = shuffle(SSmapping.areas_in_z["[ground_z_levels[1]]"]) + + for(var/area/maybe_this_area in potential_areas) + if(CEILING_IS_PROTECTED(maybe_this_area.ceiling, CEILING_PROTECTION_TIER_1)) // prevents out of bounds too + continue + if(istype(maybe_this_area, /area/space)) // make sure its not space, just in case + continue + + var/turf/open/possible_turf = null + var/list/area_turfs = get_area_turfs(maybe_this_area) + for(var/i in 1 to 10) + possible_turf = pick_n_take(area_turfs) + // we're looking for an open, non-dense, and non-space turf. + if(!istype(possible_turf) || is_blocked_turf(possible_turf) || istype(possible_turf, /turf/open/space)) + continue + + if(!istype(possible_turf) || is_blocked_turf(possible_turf) || istype(possible_turf, /turf/open/space)) + continue // couldnt find one in 10 loops, check another area + + // we found a good turf, lets drop em + INVOKE_ASYNC(src, PROC_REF(handle_drop), crosser, possible_turf, dropship.name) + return + + return ..() // they couldn't be dropped, just delete them + +/turf/open/space/transit/dropship/proc/handle_drop(atom/movable/crosser, turf/target, dropship_name) + ADD_TRAIT(crosser, TRAIT_IMMOBILIZED, TRAIT_SOURCE_DROPSHIP_INTERACTION) + + crosser.pixel_z = 300 + crosser.forceMove(target) + crosser.visible_message(SPAN_WARNING("[crosser] falls out of the sky."), SPAN_HIGHDANGER("As you fall out of [dropship_name], you plummet towards the ground.")) + animate(crosser, time = 5, pixel_z = 0) + + REMOVE_TRAIT(crosser, TRAIT_IMMOBILIZED, TRAIT_SOURCE_DROPSHIP_INTERACTION) + if(isitem(crosser)) + var/obj/item/item = crosser + item.explosion_throw(200) // give it a bit of a kick + return + + if(!isliving(crosser)) + return // don't know how you got here, but you shouldnt be here. + var/mob/living/fallen_mob = crosser + fallen_mob.KnockDown(10) // 10 seconds + fallen_mob.Stun(3) // 3 seconds + + if(ishuman(fallen_mob)) + var/mob/living/carbon/human/human = fallen_mob + // I'd say falling from space is pretty much like getting hit by an explosion + human.take_overall_armored_damage(250, ARMOR_BOMB, limb_damage_chance = 100) + // but just in case, you will still take a ton of damage. + human.take_overall_damage(100, used_weapon = "falling", limb_damage_chance = 100) + playsound(human, "bone_break", 45, TRUE) + return + // take a little bit more damage otherwise + fallen_mob.take_overall_damage(400, used_weapon = "falling", limb_damage_chance = 100) + +/turf/open/space/transit/dropship/alamo + shuttle_tag = DROPSHIP_ALAMO + dir = SOUTH + +/turf/open/space/transit/dropship/normandy + shuttle_tag = DROPSHIP_NORMANDY + dir = SOUTH /turf/open/space/transit/south dir = SOUTH diff --git a/code/modules/mob/living/carbon/human/human_damage.dm b/code/modules/mob/living/carbon/human/human_damage.dm index 942c20482230..2a03b4f0abff 100644 --- a/code/modules/mob/living/carbon/human/human_damage.dm +++ b/code/modules/mob/living/carbon/human/human_damage.dm @@ -311,18 +311,18 @@ In most cases it makes more sense to use apply_damage() instead! And make sure t if(update) UpdateDamageIcon() // damage MANY limbs, in random order -/mob/living/carbon/human/take_overall_damage(brute, burn, sharp = 0, edge = 0, used_weapon = null) +/mob/living/carbon/human/take_overall_damage(brute, burn, used_weapon = null, limb_damage_chance = 80) if(status_flags & GODMODE) return //godmode - var/list/obj/limb/parts = get_damageable_limbs(80) + var/list/obj/limb/parts = get_damageable_limbs(limb_damage_chance) var/amount_of_parts = length(parts) for(var/obj/limb/L as anything in parts) - L.take_damage(brute / amount_of_parts, burn / amount_of_parts, sharp, edge, used_weapon) + L.take_damage(brute / amount_of_parts, burn / amount_of_parts, sharp = FALSE, edge = FALSE, used_weapon = used_weapon) updatehealth() UpdateDamageIcon() -// damage MANY LIMBS, in random order -/mob/living/carbon/human/proc/take_overall_armored_damage(damage, armour_type = ARMOR_MELEE, damage_type = BRUTE, limb_damage_chance = 80, penetration = 0, armour_break_pr_pen = 0, armour_break_flat = 0) +// damage MANY LIMBS, in random order, but consider armor +/mob/living/carbon/human/proc/take_overall_armored_damage(damage, armour_type = ARMOR_MELEE, damage_type = BRUTE, limb_damage_chance = 80, penetration = 0) if(status_flags & GODMODE) return //godmode var/list/obj/limb/parts = get_damageable_limbs(limb_damage_chance) @@ -330,6 +330,8 @@ In most cases it makes more sense to use apply_damage() instead! And make sure t var/armour_config = GLOB.marine_ranged if(armour_type == ARMOR_MELEE) armour_config = GLOB.marine_melee + if(armour_type == ARMOR_BOMB) + armour_config = GLOB.marine_explosive for(var/obj/limb/L as anything in parts) var/armor = getarmor(L, armour_type) var/modified_damage = armor_damage_reduction(armour_config, damage, armor, penetration, 0, 0) diff --git a/code/modules/mob/living/living_health_procs.dm b/code/modules/mob/living/living_health_procs.dm index 819b3397c289..6eef0e3b5b3b 100644 --- a/code/modules/mob/living/living_health_procs.dm +++ b/code/modules/mob/living/living_health_procs.dm @@ -445,7 +445,7 @@ src.updatehealth() // damage MANY limbs, in random order -/mob/living/proc/take_overall_damage(brute, burn, used_weapon = null) +/mob/living/proc/take_overall_damage(brute, burn, used_weapon = null, limb_damage_chance = 80) if(status_flags & GODMODE) return 0 //godmode apply_damage(brute, BRUTE) apply_damage(burn, BURN) diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index 85fc38bf5f1b..6f02bf00e89d 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -1004,3 +1004,15 @@ to_chat(user, SPAN_WARNING("Shuttle already in transit.")) return FALSE return TRUE + +/obj/docking_port/mobile/proc/get_transit_path_type() + . = /turf/open/space/transit + switch(preferred_direction) + if(NORTH) + return /turf/open/space/transit/north + if(SOUTH) + return /turf/open/space/transit/south + if(EAST) + return /turf/open/space/transit/east + if(WEST) + return /turf/open/space/transit/west diff --git a/code/modules/shuttle/shuttles/dropship.dm b/code/modules/shuttle/shuttles/dropship.dm index f741df301bbb..ce9ba7c623bb 100644 --- a/code/modules/shuttle/shuttles/dropship.dm +++ b/code/modules/shuttle/shuttles/dropship.dm @@ -121,12 +121,18 @@ /obj/docking_port/mobile/marine_dropship/alamo name = "Alamo" id = DROPSHIP_ALAMO - preferred_direction = SOUTH + preferred_direction = SOUTH // If you are changing this, please update the dir of the path below as well + +/obj/docking_port/mobile/marine_dropship/alamo/get_transit_path_type() + return /turf/open/space/transit/dropship/alamo /obj/docking_port/mobile/marine_dropship/normandy name = "Normandy" id = DROPSHIP_NORMANDY - preferred_direction = SOUTH + preferred_direction = SOUTH // If you are changing this, please update the dir of the path below as well + +/obj/docking_port/mobile/marine_dropship/normandy/get_transit_path_type() + return /turf/open/space/transit/dropship/normandy /obj/docking_port/mobile/marine_dropship/check() . = ..() From 6a9939114320e693c81a43dbfd7d61e8534d4aea Mon Sep 17 00:00:00 2001 From: Contrabang <91113370+Contrabang@users.noreply.github.com> Date: Mon, 29 Jan 2024 07:59:35 -0500 Subject: [PATCH 2/3] i cant believe I forgot to push --- code/game/turfs/transit.dm | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/code/game/turfs/transit.dm b/code/game/turfs/transit.dm index 31b110e81039..afe72055e0af 100644 --- a/code/game/turfs/transit.dm +++ b/code/game/turfs/transit.dm @@ -79,7 +79,7 @@ crosser.pixel_z = 300 crosser.forceMove(target) crosser.visible_message(SPAN_WARNING("[crosser] falls out of the sky."), SPAN_HIGHDANGER("As you fall out of [dropship_name], you plummet towards the ground.")) - animate(crosser, time = 5, pixel_z = 0) + animate(crosser, time = 5, pixel_z = 0, flags = ANIMATION_PARALLEL) REMOVE_TRAIT(crosser, TRAIT_IMMOBILIZED, TRAIT_SOURCE_DROPSHIP_INTERACTION) if(isitem(crosser)) @@ -90,16 +90,26 @@ if(!isliving(crosser)) return // don't know how you got here, but you shouldnt be here. var/mob/living/fallen_mob = crosser + + playsound(target, "punch", rand(20, 70), TRUE) + playsound(target, "punch", rand(20, 70), TRUE) + playsound(target, "bone_break", rand(20, 70), TRUE) + playsound(target, "bone_break", rand(20, 70), TRUE) + fallen_mob.KnockDown(10) // 10 seconds fallen_mob.Stun(3) // 3 seconds + if(ishuman(fallen_mob)) var/mob/living/carbon/human/human = fallen_mob + human.last_damage_data = create_cause_data("falling from [dropship_name]", human) // I'd say falling from space is pretty much like getting hit by an explosion - human.take_overall_armored_damage(250, ARMOR_BOMB, limb_damage_chance = 100) + human.take_overall_armored_damage(300, ARMOR_BOMB, limb_damage_chance = 100) // but just in case, you will still take a ton of damage. - human.take_overall_damage(100, used_weapon = "falling", limb_damage_chance = 100) - playsound(human, "bone_break", 45, TRUE) + human.take_overall_damage(200, used_weapon = "falling", limb_damage_chance = 100) + if(human.stat != DEAD) + human.death(create_cause_data("falling from [dropship_name]", human)) + fallen_mob.status_flags |= PERMANENTLY_DEAD return // take a little bit more damage otherwise fallen_mob.take_overall_damage(400, used_weapon = "falling", limb_damage_chance = 100) From 78ca1d95441dab0a47acd1441dc868792efcde94 Mon Sep 17 00:00:00 2001 From: Contrabang <91113370+Contrabang@users.noreply.github.com> Date: Mon, 29 Jan 2024 13:31:11 -0500 Subject: [PATCH 3/3] Update code/game/turfs/transit.dm Co-authored-by: private-tristan <54422837+private-tristan@users.noreply.github.com> --- code/game/turfs/transit.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/turfs/transit.dm b/code/game/turfs/transit.dm index afe72055e0af..10fc2820b4f1 100644 --- a/code/game/turfs/transit.dm +++ b/code/game/turfs/transit.dm @@ -78,7 +78,7 @@ crosser.pixel_z = 300 crosser.forceMove(target) - crosser.visible_message(SPAN_WARNING("[crosser] falls out of the sky."), SPAN_HIGHDANGER("As you fall out of [dropship_name], you plummet towards the ground.")) + crosser.visible_message(SPAN_WARNING("[crosser] falls out of the sky."), SPAN_HIGHDANGER("As you fall out of the [dropship_name], you plummet towards the ground.")) animate(crosser, time = 5, pixel_z = 0, flags = ANIMATION_PARALLEL) REMOVE_TRAIT(crosser, TRAIT_IMMOBILIZED, TRAIT_SOURCE_DROPSHIP_INTERACTION)