Skip to content

Commit

Permalink
[MIRROR] Adds tram throwing mobs through glass windows (#2048)
Browse files Browse the repository at this point in the history
* Adds tram throwing mobs through glass windows (#81284)

## About The Pull Request

- Adds a PASSWINDOW flag so that you can throw mobs through window
panes, smashing them
- Being thrown into the tram window by event only (not player thrown)
has a chance to break through the window
- Reduced throw range of tram emergency stop

## Why It's Good For The Game

Sometimes you don't want them to bounce off the window when they hit,
rather comically fly through it.

## Changelog

:cl: LT3
add: The tram has been equipped with enhanced safety glass to reduce the
severity of crew injuries
/:cl:

* Adds tram throwing mobs through glass windows

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: lessthanthree <[email protected]>
  • Loading branch information
3 people authored Feb 19, 2024
1 parent bbbcadf commit 67e738c
Show file tree
Hide file tree
Showing 16 changed files with 269 additions and 232 deletions.
417 changes: 190 additions & 227 deletions _maps/map_files/tramstation/tramstation.dmm

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions code/__DEFINES/_flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -133,22 +133,36 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
the atom/checkpass() proc uses them (tables will call movable atom checkpass(PASSTABLE) for example)
*/
//flags for pass_flags
/// Allows you to pass over tables.
#define PASSTABLE (1<<0)
/// Allows you to pass over glass(this generally includes anything see-through that's glass-adjacent, ie. windows, windoors, airlocks with glass, etc.)
#define PASSGLASS (1<<1)
/// Allows you to pass over grilles.
#define PASSGRILLE (1<<2)
/// Allows you to pass over blob tiles.
#define PASSBLOB (1<<3)
/// Allows you to pass over mobs.
#define PASSMOB (1<<4)
/// Allows you to pass over closed turfs, ie. walls.
#define PASSCLOSEDTURF (1<<5)
/// Let thrown things past us. **ONLY MEANINGFUL ON pass_flags_self!**
#define LETPASSTHROW (1<<6)
/// Allows you to pass over machinery, ie. vending machines, computers, protolathes, etc.
#define PASSMACHINE (1<<7)
/// Allows you to pass over structures, ie. racks, tables(if you don't already have PASSTABLE), etc.
#define PASSSTRUCTURE (1<<8)
/// Allows you to pass over plastic flaps, often found at cargo or MULE dropoffs.
#define PASSFLAPS (1<<9)
/// Allows you to pass over airlocks and mineral doors.
#define PASSDOORS (1<<10)
/// Allows you to pass over vehicles, ie. mecha, secways, the pimpin' ride, etc.
#define PASSVEHICLE (1<<11)
/// Allows you to pass over dense items.
#define PASSITEM (1<<12)
/// Do not intercept click attempts during Adjacent() checks. See [turf/proc/ClickCross]. **ONLY MEANINGFUL ON pass_flags_self!**
#define LETPASSCLICKS (1<<13)
/// Allows you to pass over windows and window-adjacent stuff, like windows and windoors. Does not include airlocks with glass in them.
#define PASSWINDOW (1<<14)

//Movement Types
#define GROUND (1<<0)
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/traits/declarations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
/// Is a medbot healing you
#define TRAIT_MEDIBOTCOMINGTHROUGH "medbot"
#define TRAIT_PASSTABLE "passtable"
/// Lets you fly through windows
#define TRAIT_PASSWINDOW "passwindow"
/// Makes you immune to flashes
#define TRAIT_NOFLASH "noflash"
/// prevents xeno huggies implanting skeletons
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/traits/sources.dm
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@
#define TRAIT_SUBTREE_REQUIRED_OPERATIONAL_DATUM "element-required"
/// Trait applied by MODsuits.
#define MOD_TRAIT "mod"
/// Trait applied to tram passengers
#define TRAM_PASSENGER_TRAIT "tram-passenger"

/// Trait granted by the berserker hood.
#define BERSERK_TRAIT "berserk_trait"
Expand Down
13 changes: 13 additions & 0 deletions code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,19 @@ GLOBAL_LIST_EMPTY(species_list)
if(!HAS_TRAIT(L, TRAIT_PASSTABLE))
L.pass_flags &= ~PASSTABLE

/proc/passwindow_on(target, source)
var/mob/living/target_mob = target
if (!HAS_TRAIT(target_mob, TRAIT_PASSWINDOW) && target_mob.pass_flags & PASSWINDOW)
ADD_TRAIT(target_mob, TRAIT_PASSWINDOW, INNATE_TRAIT)
ADD_TRAIT(target_mob, TRAIT_PASSWINDOW, source)
target_mob.pass_flags |= PASSWINDOW

/proc/passwindow_off(target, source)
var/mob/living/target_mob = target
REMOVE_TRAIT(target_mob, TRAIT_PASSWINDOW, source)
if(!HAS_TRAIT(target_mob, TRAIT_PASSWINDOW))
target_mob.pass_flags &= ~PASSWINDOW

/proc/dance_rotate(atom/movable/AM, datum/callback/callperrotate, set_original_dir=FALSE)
set waitfor = FALSE
var/originaldir = AM.dir
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ DEFINE_BITFIELD(pass_flags, list(
"PASSGRILLE" = PASSGRILLE,
"PASSMOB" = PASSMOB,
"PASSTABLE" = PASSTABLE,
"PASSWINDOW" = PASSWINDOW,
))

DEFINE_BITFIELD(resistance_flags, list(
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/traits/_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ GLOBAL_LIST_INIT(traits_by_type, list(
"TRAIT_PARALYSIS_R_LEG" = TRAIT_PARALYSIS_R_LEG,
"TRAIT_PARROT_PERCHED" = TRAIT_PARROT_PERCHED,
"TRAIT_PASSTABLE" = TRAIT_PASSTABLE,
"TRAIT_PASSWINDOW" = TRAIT_PASSWINDOW,
"TRAIT_PERFECT_ATTACKER" = TRAIT_PERFECT_ATTACKER,
"TRAIT_PERMANENTLY_MORTAL" = TRAIT_PERMANENTLY_MORTAL,
"TRAIT_PHOTOGRAPHER" = TRAIT_PHOTOGRAPHER,
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/traits/admin_tooling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ GLOBAL_LIST_INIT(admin_visible_traits, list(
"TRAIT_PARALYSIS_R_ARM" = TRAIT_PARALYSIS_R_ARM,
"TRAIT_PARALYSIS_R_LEG" = TRAIT_PARALYSIS_R_LEG,
"TRAIT_PASSTABLE" = TRAIT_PASSTABLE,
"TRAIT_PASSWINDOW" = TRAIT_PASSWINDOW,
"TRAIT_PERFECT_ATTACKER" = TRAIT_PERFECT_ATTACKER,
"TRAIT_PHOTOGRAPHER" = TRAIT_PHOTOGRAPHER,
"TRAIT_PIERCEIMMUNE" = TRAIT_PIERCEIMMUNE,
Expand Down
30 changes: 30 additions & 0 deletions code/datums/elements/window_smash.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* # Window Smashing
* An element you put on mobs to let them smash through walls on movement
* For example, throwing someone through a glass window
*/
/datum/element/window_smashing

/datum/element/window_smashing/Attach(datum/target, duration = 1.5 SECONDS)
. = ..()
if(!isliving(target))
return ELEMENT_INCOMPATIBLE
var/mob/living/living_target = target
RegisterSignal(living_target, COMSIG_MOVABLE_MOVED, PROC_REF(flying_window_smash))
passwindow_on(target, TRAM_PASSENGER_TRAIT)
addtimer(CALLBACK(src, PROC_REF(Detach), living_target), duration)

/// Smash any windows that the mob is flying through
/datum/element/window_smashing/proc/flying_window_smash(atom/movable/flying_mob, atom/old_loc, direction)
SIGNAL_HANDLER
var/turf/target_turf = get_turf(flying_mob)
for(var/obj/structure/tram/tram_wall in target_turf)
tram_wall.smash_and_injure(flying_mob, old_loc, direction)

for(var/obj/structure/window/window in target_turf)
window.smash_and_injure(flying_mob, old_loc, direction)

/datum/element/window_smashing/Detach(datum/source)
UnregisterSignal(source, COMSIG_MOVABLE_MOVED)
passwindow_off(source, TRAM_PASSENGER_TRAIT)
return ..()
2 changes: 1 addition & 1 deletion code/game/machinery/doors/windowdoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
visible = FALSE
flags_1 = ON_BORDER_1
opacity = FALSE
pass_flags_self = PASSGLASS
pass_flags_self = PASSGLASS | PASSWINDOW
can_atmos_pass = ATMOS_PASS_PROC
interaction_flags_machine = INTERACT_MACHINE_WIRES_IF_OPEN | INTERACT_MACHINE_ALLOW_SILICON | INTERACT_MACHINE_OPEN_SILICON | INTERACT_MACHINE_REQUIRES_SILICON | INTERACT_MACHINE_OPEN
set_dir_on_move = FALSE
Expand Down
7 changes: 7 additions & 0 deletions code/game/objects/structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,10 @@

/obj/structure/animate_atom_living(mob/living/owner)
new /mob/living/simple_animal/hostile/mimic/copy(drop_location(), src, owner)

/// For when a mob comes flying through the window, smash it and damage the mob
/obj/structure/proc/smash_and_injure(mob/living/flying_mob, atom/oldloc, direction)
flying_mob.balloon_alert_to_viewers("smashed through!")
flying_mob.apply_damage(damage = rand(5, 15), damagetype = BRUTE, wound_bonus = 15, bare_wound_bonus = 25, sharpness = SHARP_EDGED, attack_direction = get_dir(src, oldloc))
new /obj/effect/decal/cleanable/glass(get_step(flying_mob, flying_mob.dir))
deconstruct(disassembled = FALSE)
2 changes: 1 addition & 1 deletion code/game/objects/structures/grille.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
base_icon_state = "grille"
density = TRUE
anchored = TRUE
pass_flags_self = PASSGRILLE
pass_flags_self = PASSGRILLE | PASSWINDOW
obj_flags = CONDUCTS_ELECTRICITY
obj_flags = CAN_BE_HIT | IGNORE_DENSITY
pressure_resistance = 5*ONE_ATMOSPHERE
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/window.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
armor_type = /datum/armor/structure_window
can_atmos_pass = ATMOS_PASS_PROC
rad_insulation = RAD_VERY_LIGHT_INSULATION
pass_flags_self = PASSGLASS
pass_flags_self = PASSGLASS | PASSWINDOW
set_dir_on_move = FALSE
flags_ricochet = RICOCHET_HARD
receive_ricochet_chance_mod = 0.5
Expand Down
1 change: 1 addition & 0 deletions code/modules/transport/tram/tram_structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
opacity = FALSE
anchored = TRUE
flags_1 = PREVENT_CLICK_UNDER_1
pass_flags_self = PASSWINDOW
armor_type = /datum/armor/tram_structure
smoothing_flags = SMOOTH_BITMASK
smoothing_groups = SMOOTH_GROUP_TRAM_STRUCTURE
Expand Down
5 changes: 3 additions & 2 deletions code/modules/transport/transport_module.dm
Original file line number Diff line number Diff line change
Expand Up @@ -934,9 +934,10 @@
/obj/structure/transport/linear/tram/proc/estop_throw(throw_direction)
for(var/mob/living/passenger in transport_contents)
to_chat(passenger, span_userdanger("The tram comes to a sudden, grinding stop!"))
if(prob(17.5)) // sometimes you go through a window
passenger.AddElement(/datum/element/window_smashing, duration = 1.5 SECONDS)
var/throw_target = get_edge_target_turf(src, throw_direction)
var/datum/callback/land_slam = new(passenger, TYPE_PROC_REF(/mob/living/, tram_slam_land))
passenger.throw_at(throw_target, 400, 4, force = MOVE_FORCE_OVERPOWERING, callback = land_slam)
passenger.throw_at(throw_target, 30, 7, force = MOVE_FORCE_OVERPOWERING)

/obj/structure/transport/linear/tram/slow
transport_controller_type = /datum/transport_controller/linear/tram/slow
Expand Down
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,7 @@
#include "code\datums\elements\weather_listener.dm"
#include "code\datums\elements\web_walker.dm"
#include "code\datums\elements\wheel.dm"
#include "code\datums\elements\window_smash.dm"
#include "code\datums\elements\decals\_decal.dm"
#include "code\datums\elements\decals\blood.dm"
#include "code\datums\elements\food\dunkable.dm"
Expand Down

0 comments on commit 67e738c

Please sign in to comment.