Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit c8d06f3

Browse files
it started as a quick bugfix, how did we get here
1 parent d04c9f6 commit c8d06f3

File tree

84 files changed

+312
-357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+312
-357
lines changed

code/__DEFINES/flags.dm

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,30 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
4141
/// For machines and structures that should not break into parts, eg, holodeck stuff
4242
#define NODECONSTRUCT_1 (1<<7)
4343
/// Prevent clicking things below it on the same turf eg. doors/ fulltile windows
44-
#define PREVENT_CLICK_UNDER_1 (1<<9)
44+
#define PREVENT_CLICK_UNDER_1 (1<<8)
4545
/// Can players recolor this in-game via vendors (and maybe more if support is added)?
46-
#define IS_PLAYER_COLORABLE_1 (1<<10)
47-
/// TESLA_IGNORE grants immunity from being targeted by tesla-style electricity
48-
#define TESLA_IGNORE_1 (1<<11)
46+
#define IS_PLAYER_COLORABLE_1 (1<<9)
4947
/// If a turf can be made dirty at roundstart. This is also used in areas.
50-
#define CAN_BE_DIRTY_1 (1<<12)
48+
#define CAN_BE_DIRTY_1 (1<<10)
5149
/// Should we use the initial icon for display? Mostly used by overlay only objects
52-
#define HTML_USE_INITAL_ICON_1 (1<<13)
50+
#define HTML_USE_INITAL_ICON_1 (1<<11)
5351
/// conducts electricity (metal etc.)
54-
#define CONDUCT_1 (1<<14)
52+
#define CONDUCT_1 (1<<12)
5553
/// should not get harmed if this gets caught by an explosion?
56-
#define PREVENT_CONTENTS_EXPLOSION_1 (1<<15)
54+
#define PREVENT_CONTENTS_EXPLOSION_1 (1<<13)
5755
/// should the contents of this atom be acted upon
58-
#define RAD_PROTECT_CONTENTS_1 (1<<16)
56+
#define RAD_PROTECT_CONTENTS_1 (1<<14)
5957
/// should this object be allowed to be contaminated
60-
#define RAD_NO_CONTAMINATE_1 (1<<17)
58+
#define RAD_NO_CONTAMINATE_1 (1<<15)
6159
/// Prevents most radiation on this turf from leaving it
62-
#define RAD_CONTAIN_CONTENTS (1<<18)
60+
#define RAD_CONTAIN_CONTENTS (1<<16)
6361
/// Is the thing currently spinning?
64-
#define IS_SPINNING_1 (1<<19)
62+
#define IS_SPINNING_1 (1<<17)
6563
/// If this atom has experienced a decal element "init finished" sourced appearance update
6664
/// We use this to ensure stacked decals don't double up appearance updates for no rasin
6765
/// Flag as an optimization, don't make this a trait without profiling
6866
/// Yes I know this is a stupid flag, no you can't take him from me
69-
#define DECAL_INIT_UPDATE_EXPERIENCED_1 (1<<20)
67+
#define DECAL_INIT_UPDATE_EXPERIENCED_1 (1<<18)
7068

7169
//TURF FLAGS
7270
/// If a turf cant be jaunted through.
@@ -168,9 +166,11 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
168166
//tesla_zap
169167
#define TESLA_MACHINE_EXPLOSIVE (1<<0)
170168
#define TESLA_ALLOW_DUPLICATES (1<<1)
171-
#define TESLA_OBJ_DAMAGE (1<<2)
172-
#define TESLA_MOB_DAMAGE (1<<3)
173-
#define TESLA_MOB_STUN (1<<4)
169+
#define TESLA_NO_CHAINING (1<<2)
170+
#define TESLA_OBJ_DAMAGE (1<<3)
171+
#define TESLA_MOB_DAMAGE (1<<4)
172+
#define TESLA_MOB_STUN (1<<5)
173+
#define TESLA_MOB_GIB (1<<6)
174174

175175
#define TESLA_DEFAULT_FLAGS TESLA_OBJ_DAMAGE | TESLA_MOB_DAMAGE | TESLA_MOB_STUN | TESLA_MACHINE_EXPLOSIVE
176176
#define TESLA_FUSION_FLAGS TESLA_OBJ_DAMAGE | TESLA_MOB_DAMAGE | TESLA_MOB_STUN

code/__DEFINES/obj_flags.dm

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
#define IN_USE (1<<1) // If we have a user using us, this will be set on. We will check if the user has stopped using us, and thus stop updating and LAGGING EVERYTHING!
66
#define CAN_BE_HIT (1<<2) //can this be bludgeoned by items?
77
#define DANGEROUS_POSSESSION (1<<3) //Admin possession yes/no
8-
#define BEING_SHOCKED (1<<4) // Whether this thing is currently (already) being shocked by a tesla
9-
#define BLOCK_Z_OUT_DOWN (1<<5) // Should this object block z falling from loc?
10-
#define BLOCK_Z_OUT_UP (1<<6) // Should this object block z uprise from loc?
11-
#define BLOCK_Z_IN_DOWN (1<<7) // Should this object block z falling from above?
12-
#define BLOCK_Z_IN_UP (1<<8) // Should this object block z uprise from below?
13-
#define BLOCKS_CONSTRUCTION (1<<9) //! Does this object prevent things from being built on it?
14-
#define BLOCKS_CONSTRUCTION_DIR (1<<10) //! Does this object prevent same-direction things from being built on it?
15-
#define IGNORE_DENSITY (1<<11) //! Can we ignore density when building on this object? (for example, directional windows and grilles)
16-
#define ON_BLUEPRINTS (1<<12) //Are we visible on the station blueprints at roundstart?
17-
#define UNIQUE_RENAME (1<<13) // can you customize the name of the thing?
18-
#define USES_TGUI (1<<14) //put on things that use tgui on ui_interact instead of custom/old UI.
19-
#define FROZEN (1<<15)
20-
#define UNIQUE_REDESC (1<<16) // can you customize the description of the thing?
21-
#define CMAGGED (1<<17)
8+
#define BLOCK_Z_OUT_DOWN (1<<4) // Should this object block z falling from loc?
9+
#define BLOCK_Z_OUT_UP (1<<5) // Should this object block z uprise from loc?
10+
#define BLOCK_Z_IN_DOWN (1<<6) // Should this object block z falling from above?
11+
#define BLOCK_Z_IN_UP (1<<7) // Should this object block z uprise from below?
12+
#define BLOCKS_CONSTRUCTION (1<<8) //! Does this object prevent things from being built on it?
13+
#define BLOCKS_CONSTRUCTION_DIR (1<<9) //! Does this object prevent same-direction things from being built on it?
14+
#define IGNORE_DENSITY (1<<10) //! Can we ignore density when building on this object? (for example, directional windows and grilles)
15+
#define ON_BLUEPRINTS (1<<11) //Are we visible on the station blueprints at roundstart?
16+
#define UNIQUE_RENAME (1<<12) // can you customize the name of the thing?
17+
#define USES_TGUI (1<<13) //put on things that use tgui on ui_interact instead of custom/old UI.
18+
#define FROZEN (1<<14)
19+
#define UNIQUE_REDESC (1<<15) // can you customize the description of the thing?
20+
#define CMAGGED (1<<16)
2221

2322
// If you add new ones, be sure to add them to /obj/Initialize as well for complete mapping support
2423

code/__DEFINES/traits/declarations.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@
202202
#define TRAIT_PUSHIMMUNE "push_immunity"
203203
/// Are we immune to shocks?
204204
#define TRAIT_SHOCKIMMUNE "shock_immunity"
205+
/// Completely ignored by tesla zaps
206+
#define TRAIT_TESLA_IGNORE "tesla_ignore"
205207
/// Immunity to low temperature damage
206208
#define TRAIT_RESISTCOLD "resist_cold"
207209
/// Immunity to high temperature damage

code/__HELPERS/unsorted.dm

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -790,22 +790,36 @@ B --><-- A
790790
sleep(duration)
791791
A.cut_overlay(O)
792792

793+
/// Returns the closest atom of a given type to the source atom.
793794
/proc/get_closest_atom(type, list, source)
794795
var/list/closest_atoms = list()
795-
var/closest_distance
796+
var/closest_distance = INFINITY
796797
for(var/A in list)
797798
if(!istype(A, type))
798799
continue
799800
var/distance = get_dist(source, A)
800-
if(!closest_atoms.len)
801+
if(closest_distance > distance)
801802
closest_distance = distance
802803
closest_atoms = list(A)
803-
else
804-
if(closest_distance > distance)
805-
closest_distance = distance
806-
closest_atoms = list(A)
807-
else if(closest_distance == distance)
808-
closest_atoms += A
804+
else if(closest_distance == distance)
805+
closest_atoms += A
806+
return pick(closest_atoms) //if there are multiple atoms with the same distance, picks randomly from a list of them
807+
808+
/// Returns the closest atom of a given type to the center of a list of atoms. Can be very expensive with large lists.
809+
/proc/get_closest_atom_to_group(type, list, list/sources)
810+
var/list/closest_atoms = list()
811+
var/closest_distance = INFINITY
812+
for(var/A in list)
813+
if(!istype(A, type))
814+
continue
815+
var/distance = 0
816+
for(var/atom/source as anything in sources)
817+
distance += get_dist(source, A)
818+
if(closest_distance > distance)
819+
closest_distance = distance
820+
closest_atoms = list(A)
821+
else if(closest_distance == distance)
822+
closest_atoms += A
809823
return pick(closest_atoms) //if there are multiple atoms with the same distance, picks randomly from a list of them
810824

811825
proc/pick_closest_path(value, list/matches = get_fancy_list_of_atom_types())

code/_globalvars/bitfields.dm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ DEFINE_BITFIELD(obj_flags, list(
5252
"IGNORE_DENSITY" = IGNORE_DENSITY,
5353
"IN_USE" = IN_USE,
5454
"CAN_BE_HIT" = CAN_BE_HIT,
55-
"BEING_SHOCKED" = BEING_SHOCKED,
5655
"DANGEROUS_POSSESSION" = DANGEROUS_POSSESSION,
5756
"ON_BLUEPRINTS" = ON_BLUEPRINTS,
5857
"UNIQUE_RENAME" = UNIQUE_RENAME,
@@ -170,7 +169,6 @@ DEFINE_BITFIELD(flags_1, list(
170169
"ON_BORDER_1" = ON_BORDER_1,
171170
"PREVENT_CLICK_UNDER_1" = PREVENT_CLICK_UNDER_1,
172171
"HOLOGRAM_1" = HOLOGRAM_1,
173-
"TESLA_IGNORE_1" = TESLA_IGNORE_1,
174172
"INITIALIZED_1" = INITIALIZED_1,
175173
"ADMIN_SPAWNED_1" = ADMIN_SPAWNED_1,
176174
"PREVENT_CONTENTS_EXPLOSION_1" = PREVENT_CONTENTS_EXPLOSION_1,

code/game/atom_defense.dm

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,26 @@
9595
user.changeNext_move(CLICK_CD_MELEE)
9696
return take_damage(damage_amount, damage_type, damage_flag, sound_effect, get_dir(src, user), armor_penetration)
9797

98+
/// Called when the atom is hit by a tesla bolt.
99+
/atom/proc/tesla_act(source, power, zap_range, tesla_flags, list/shocked_targets)
100+
if(HAS_TRAIT(src, TRAIT_TESLA_IGNORE))
101+
return FALSE
102+
if(!(tesla_flags & TESLA_ALLOW_DUPLICATES))
103+
ADD_TRAIT(src, TRAIT_TESLA_IGNORE, WAS_SHOCKED)
104+
addtimer(CALLBACK(src, PROC_REF(reset_shocked)), 10)
105+
if(power < TESLA_MINI_POWER) //tesla bolts bounce twice, tesla miniball bolts bounce only once
106+
return TRUE
107+
if(!(tesla_flags & TESLA_NO_CHAINING) && power >= 1500 && zap_range > 1)
108+
tesla_zap(src, zap_range - 1, power * 0.67, tesla_flags, shocked_targets)
109+
return TRUE
110+
111+
/// Returns whether or not the atom can be targeted by a tesla bolt
112+
/atom/proc/get_conductivity()
113+
return 1
114+
115+
/atom/proc/reset_shocked()
116+
REMOVE_TRAIT(src, TRAIT_TESLA_IGNORE, WAS_SHOCKED)
117+
98118
/// Called after the atom takes damage and integrity is below integrity_failure level
99119
/atom/proc/atom_break(damage_flag)
100120
SHOULD_CALL_PARENT(TRUE)

code/game/atoms_movable.dm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,3 +1385,11 @@
13851385
if(destination)
13861386
forceMove(destination)
13871387
return TRUE
1388+
1389+
//The surgeon general warns that being buckled to certain objects receiving powerful shocks is greatly hazardous to your health
1390+
///Only tesla coils and grounding rods currently call this because mobs are already targeted over all other objects, but this might be useful for more things later.
1391+
/atom/movable/proc/tesla_buckle_check(strength)
1392+
if(has_buckled_mobs())
1393+
for(var/m in buckled_mobs)
1394+
var/mob/living/buckled_mob = m
1395+
buckled_mob.electrocute_act((clamp(round(strength/400), 10, 90) + rand(-5, 5)), src, tesla_shock = TRUE)

code/game/machinery/_machinery.dm

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Class Procs:
143143

144144
/obj/machinery/Initialize(mapload)
145145
if(!armor)
146-
armor = list(MELEE = 25, BULLET = 10, LASER = 10, ENERGY = 0, BOMB = 0, BIO = 0, RAD = 0, FIRE = 50, ACID = 70)
146+
armor = list(MELEE = 25, BULLET = 10, LASER = 10, ENERGY = 0, BOMB = 0, BIO = 0, RAD = 0, FIRE = 50, ACID = 70, ELECTRIC = 0)
147147
. = ..()
148148
SSmachines.register_machine(src)
149149
GLOB.machines += src
@@ -633,15 +633,12 @@ Class Procs:
633633
/obj/machinery/proc/can_be_overridden()
634634
. = 1
635635

636-
/obj/machinery/tesla_act(power, tesla_flags, shocked_objects, zap_gib = FALSE)
637-
..()
638-
if((tesla_flags & TESLA_MACHINE_EXPLOSIVE) && !(resistance_flags & INDESTRUCTIBLE))
639-
if(prob(60))
640-
ex_act(EXPLODE_DEVASTATE)
641-
else if (prob(50))
642-
explosion(src, 1, 2, 4, flame_range = 2, adminlog = FALSE, smoke = FALSE)
636+
/obj/machinery/tesla_act(source, power, zap_range, tesla_flags, shocked_objects)
637+
. = ..()
638+
if((tesla_flags & TESLA_MACHINE_EXPLOSIVE) && !(resistance_flags & INDESTRUCTIBLE) && prob(25))
639+
explosion(src, 1, 2, 4, flame_range = 2, adminlog = FALSE, smoke = FALSE)
643640
if(tesla_flags & TESLA_OBJ_DAMAGE)
644-
take_damage(power/2000, BURN, ENERGY)
641+
take_damage(power / 1000, BURN, ELECTRIC)
645642
if(prob(40))
646643
emp_act(EMP_LIGHT)
647644

code/game/machinery/airlock_cycle_control.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
req_access = list(ACCESS_ATMOSPHERICS)
5454
max_integrity = 250
5555
integrity_failure = 80
56-
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 100, BOMB = 0, BIO = 100, RAD = 100, FIRE = 90, ACID = 30)
56+
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 0, BIO = 100, RAD = 100, FIRE = 90, ACID = 30, ELECTRIC = 100)
5757
resistance_flags = FIRE_PROOF
5858

5959
FASTDMM_PROP(\

code/game/machinery/barsigns.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
energy = 100
2121
fire = 50
2222
acid = 50
23+
electric = 100
2324

2425
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/barsign, 32)
2526

0 commit comments

Comments
 (0)