Skip to content

Commit

Permalink
Merge remote-tracking branch 'cmss13-devs/master' into project/ares/t…
Browse files Browse the repository at this point in the history
…echs
  • Loading branch information
realforest2001 committed Jan 30, 2024
2 parents c19a09f + 192b809 commit 2724029
Show file tree
Hide file tree
Showing 181 changed files with 2,151 additions and 1,780 deletions.
4 changes: 2 additions & 2 deletions code/__DEFINES/conflict.dm
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@
#define WIELD_DELAY_VERY_SLOW 10
#define WIELD_DELAY_HORRIBLE 12

///This is how long you must wait after throwing something to throw again
#define THROW_DELAY (0.4 SECONDS)
///This is how long you must wait to throw again after throwing two things
#define THROW_DELAY (1.5 SECONDS)

//Explosion level thresholds. Upper bounds
#define EXPLOSION_THRESHOLD_VLOW 50
Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ GLOBAL_LIST_INIT(emissive_color, EMISSIVE_COLOR)
GLOBAL_LIST_INIT(em_block_color, EM_BLOCK_COLOR)
/// A set of appearance flags applied to all emissive and emissive blocker overlays.
#define EMISSIVE_APPEARANCE_FLAGS (KEEP_APART|KEEP_TOGETHER|RESET_COLOR|RESET_TRANSFORM)
/// The color matrix used to mask out emissive blockers on the emissive plane. Alpha should default to zero, be solely dependent on the RGB value of [EMISSIVE_COLOR], and be independant of the RGB value of [EM_BLOCK_COLOR].
/// The color matrix used to mask out emissive blockers on the emissive plane. Alpha should default to zero, be solely dependent on the RGB value of [EMISSIVE_COLOR], and be independent of the RGB value of [EM_BLOCK_COLOR].
#define EM_MASK_MATRIX list(0,0,0,1/3, 0,0,0,1/3, 0,0,0,1/3, 0,0,0,0, 1,1,1,0)
/// A globaly cached version of [EM_MASK_MATRIX] for quick access.
GLOBAL_LIST_INIT(em_mask_matrix, EM_MASK_MATRIX)
Expand Down
5 changes: 4 additions & 1 deletion code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
#define DAZE "daze"
#define SLOW "slow"
#define SUPERSLOW "superslow"
#define ROOT "root"

//=================================================

//I hate adding defines like this but I'd much rather deal with bitflags than lists and string searches
Expand All @@ -100,14 +102,15 @@

//Bitflags defining which status effects could be or are inflicted on a mob

#define STATUS_FLAGS_DEBILITATE (CANSTUN|CANKNOCKOUT|CANDAZE|CANSLOW)
#define STATUS_FLAGS_DEBILITATE (CANSTUN|CANKNOCKOUT|CANDAZE|CANSLOW|CANROOT)

#define CANSTUN (1<<0)
#define CANKNOCKDOWN (1<<1)
#define CANKNOCKOUT (1<<2)
#define CANPUSH (1<<3)
#define LEAPING (1<<4)
#define PASSEMOTES (1<<5) //holders inside of mob that need to see emotes.
#define CANROOT (1<<6)
#define GODMODE (1<<12)
#define FAKEDEATH (1<<13) //Replaces stuff like changeling.changeling_fakedeath
#define DISFIGURED (1<<14) //I'll probably move this elsewhere if I ever get wround to writing a bitflag mob-damage system
Expand Down
4 changes: 2 additions & 2 deletions code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@
//! ### SS initialization hints
/**
* Negative values incidate a failure or warning of some kind, positive are good.
* 0 and 1 are unused so that TRUE and FALSE are guarenteed to be invalid values.
* 0 and 1 are unused so that TRUE and FALSE are guaranteed to be invalid values.
*/

/// Subsystem failed to initialize entirely. Print a warning, log, and disable firing.
#define SS_INIT_FAILURE -2

/// The default return value which must be overriden. Will succeed with a warning.
/// The default return value which must be overridden. Will succeed with a warning.
#define SS_INIT_NONE -1

/// Subsystem initialized sucessfully.
Expand Down
4 changes: 2 additions & 2 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@
#define TRAIT_FOREIGN_BIO "t_foreign_bio"
/// Eye color changes on intent. (G1 Synths and WJs)
#define TRAIT_INTENT_EYES "t_intent_eyes"
/// Masked synthetic biology. Basic medHUDs will percieve the mob as human. (Infiltrator Synths)
/// Masked synthetic biology. Basic medHUDs will perceive the mob as human. (Infiltrator Synths)
#define TRAIT_INFILTRATOR_SYNTH "t_infiltrator_synth"
/// Makes it impossible to strip the inventory of this mob.
#define TRAIT_UNSTRIPPABLE "t_unstrippable"

// HIVE TRAITS
/// If the Hive is a Xenonid Hive
#define TRAIT_XENONID "t_xenonid"
/// If the Hive delays round end (this is overriden for some hives). Does not occur naturally. Must be applied in events.
/// If the Hive delays round end (this is overridden for some hives). Does not occur naturally. Must be applied in events.
#define TRAIT_NO_HIVE_DELAY "t_no_hive_delay"
/// If the Hive uses it's colors on the mobs. Does not occur naturally, excepting the Mutated hive.
#define TRAIT_NO_COLOR "t_no_color"
Expand Down
49 changes: 1 addition & 48 deletions code/__HELPERS/#maths.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ GLOBAL_LIST_INIT(sqrtTable, list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4,
#define Lcm(a, b) (abs(a) / Gcd(a, b) * abs(b))

// Returns the nth root of x.
#define Root(n, x) (x ** (1 / n))
#define NRoot(n, x) (x ** (1 / n))

// secant
#define Sec(x) (1 / cos(x))
Expand Down Expand Up @@ -84,53 +84,6 @@ GLOBAL_LIST_INIT(sqrtTable, list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4,
return "[round((powerused * 0.000001),0.001)] MW"
return "[round((powerused * 0.000000001),0.0001)] GW"

/**
* Get a list of turfs in a line from `starting_atom` to `ending_atom`.
*
* Uses the ultra-fast [Bresenham Line-Drawing Algorithm](https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm).
*/
/proc/get_line(atom/starting_atom, atom/ending_atom)
var/current_x_step = starting_atom.x//start at x and y, then add 1 or -1 to these to get every turf from starting_atom to ending_atom
var/current_y_step = starting_atom.y
var/starting_z = starting_atom.z

var/list/line = list(get_turf(starting_atom))//get_turf(atom) is faster than locate(x, y, z)

var/x_distance = ending_atom.x - current_x_step //x distance
var/y_distance = ending_atom.y - current_y_step

var/abs_x_distance = abs(x_distance)//Absolute value of x distance
var/abs_y_distance = abs(y_distance)

var/x_distance_sign = SIGN(x_distance) //Sign of x distance (+ or -)
var/y_distance_sign = SIGN(y_distance)

var/x = abs_x_distance >> 1 //Counters for steps taken, setting to distance/2
var/y = abs_y_distance >> 1 //Bit-shifting makes me l33t. It also makes get_line() unnessecarrily fast.

if(abs_x_distance >= abs_y_distance) //x distance is greater than y
for(var/distance_counter in 0 to (abs_x_distance - 1))//It'll take abs_x_distance steps to get there
y += abs_y_distance

if(y >= abs_x_distance) //Every abs_y_distance steps, step once in y direction
y -= abs_x_distance
current_y_step += y_distance_sign

current_x_step += x_distance_sign //Step on in x direction
line += locate(current_x_step, current_y_step, starting_z)//Add the turf to the list
else
for(var/distance_counter in 0 to (abs_y_distance - 1))
x += abs_x_distance

if(x >= abs_y_distance)
x -= abs_y_distance
current_x_step += x_distance_sign

current_y_step += y_distance_sign
line += locate(current_x_step, current_y_step, starting_z)
return line


///chances are 1:value. anyprob(1) will always return true
/proc/anyprob(value)
return (rand(1,value)==value)
Expand Down
8 changes: 4 additions & 4 deletions code/__HELPERS/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ icon/MinColors(icon)
icon/MaxColors(icon)
The icon is blended with a second icon where the maximum of each RGB pixel is the result.
Opacity may increase, as if the icons were blended with ICON_OR. You may supply a color in place of an icon.
icon/Opaque(background = "#000000")
icon/Opaque(background = COLOR_BLACK)
All alpha values are set to 255 throughout the icon. Transparent pixels become black, or whatever background color you specify.
icon/BecomeAlphaMask()
You can convert a simple grayscale icon into an alpha mask to use with other icons very easily with this proc.
Expand Down Expand Up @@ -246,7 +246,7 @@ world

/icon/proc/AddAlphaMask(mask)
var/icon/M = new(mask)
M.Blend("#ffffff", ICON_SUBTRACT)
M.Blend(COLOR_WHITE, ICON_SUBTRACT)
// apply mask
Blend(M, ICON_ADD)

Expand Down Expand Up @@ -544,7 +544,7 @@ world
return flat_icon

/proc/adjust_brightness(color, value)
if (!color) return "#FFFFFF"
if (!color) return COLOR_WHITE
if (!value) return color

var/list/RGB = ReadRGB(color)
Expand Down Expand Up @@ -581,7 +581,7 @@ world
if(A)
A.overlays.Remove(src)

/mob/proc/flick_heal_overlay(time, color = "#00FF00") //used for warden and queen healing
/mob/proc/flick_heal_overlay(time, color = COLOR_GREEN) //used for warden and queen healing
var/image/I = image('icons/mob/mob.dmi', src, "heal_overlay")
switch(icon_size)
if(48)
Expand Down
4 changes: 2 additions & 2 deletions code/__HELPERS/sorts/_Main.dm
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ GLOBAL_DATUM_INIT(sortInstance, /datum/sortInstance, new())
var/count1 = 0 //# of times in a row that first run won
var/count2 = 0 // " " " " " " second run won

//do the straightfoward thin until one run starts winning consistently
//do the straightforward thin until one run starts winning consistently

do
//ASSERT(len1 > 1 && len2 > 0)
Expand Down Expand Up @@ -493,7 +493,7 @@ GLOBAL_DATUM_INIT(sortInstance, /datum/sortInstance, new())
var/count1 = 0 //# of times in a row that first run won
var/count2 = 0 // " " " " " " second run won

//do the straightfoward thing until one run starts winning consistently
//do the straightforward thing until one run starts winning consistently
do
//ASSERT(len1 > 0 && len2 > 1)
if(call(cmp)(fetchElement(L,cursor2), fetchElement(L,cursor1)) < 0)
Expand Down
119 changes: 39 additions & 80 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1494,88 +1494,47 @@ GLOBAL_LIST_INIT(WALLITEMS, list(
/proc/format_text(text)
return replacetext(replacetext(text,"\proper ",""),"\improper ","")

/proc/getline(atom/M, atom/N, include_from_atom = TRUE)//Ultra-Fast Bresenham Line-Drawing Algorithm
var/px=M.x //starting x
var/py=M.y
var/line[] = list(locate(px,py,M.z))
var/dx=N.x-px //x distance
var/dy=N.y-py
var/dxabs=abs(dx)//Absolute value of x distance
var/dyabs=abs(dy)
var/sdx=sign(dx) //Sign of x distance (+ or -)
var/sdy=sign(dy)
var/x=dxabs>>1 //Counters for steps taken, setting to distance/2
var/y=dyabs>>1 //Bit-shifting makes me l33t. It also makes getline() unnessecarrily fast.
var/j //Generic integer for counting
if(dxabs>=dyabs) //x distance is greater than y
for(j=0;j<dxabs;j++)//It'll take dxabs steps to get there
y+=dyabs
if(y>=dxabs) //Every dyabs steps, step once in y direction
y-=dxabs
py+=sdy
px+=sdx //Step on in x direction
if(j > 0 || include_from_atom)
line+=locate(px,py,M.z)//Add the turf to the list
else
for(j=0;j<dyabs;j++)
x+=dxabs
if(x>=dyabs)
x-=dyabs
px+=sdx
py+=sdy
if(j > 0 || include_from_atom)
line+=locate(px,py,M.z)
return line
/**
* Get a list of turfs in a line from `start_atom` to `end_atom`.
*
* Based on a linear interpolation method from [Red Blob Games](https://www.redblobgames.com/grids/line-drawing/#optimization).
*
* Arguments:
* * start_atom - starting point of the line
* * end_atom - ending point of the line
* * include_start_atom - when truthy includes start_atom in the list, default TRUE
*
* Returns:
* list - turfs from start_atom (in/exclusive) to end_atom (inclusive)
*/
/proc/get_line(atom/start_atom, atom/end_atom, include_start_atom = TRUE)
var/turf/start_turf = get_turf(start_atom)
var/turf/end_turf = get_turf(end_atom)
var/start_z = start_turf.z

//Bresenham's algorithm. This one deals efficiently with all 8 octants.
//Just don't ask me how it works.
/proc/getline2(atom/from_atom, atom/to_atom, include_from_atom = TRUE)
if(!from_atom || !to_atom) return 0
var/list/turf/turfs = list()

var/cur_x = from_atom.x
var/cur_y = from_atom.y

var/w = to_atom.x - from_atom.x
var/h = to_atom.y - from_atom.y
var/dx1 = 0
var/dx2 = 0
var/dy1 = 0
var/dy2 = 0
if(w < 0)
dx1 = -1
dx2 = -1
else if(w > 0)
dx1 = 1
dx2 = 1
if(h < 0) dy1 = -1
else if(h > 0) dy1 = 1
var/longest = abs(w)
var/shortest = abs(h)
if(!(longest > shortest))
longest = abs(h)
shortest = abs(w)
if(h < 0) dy2 = -1
else if (h > 0) dy2 = 1
dx2 = 0

var/numerator = longest >> 1
var/i
for(i = 0; i <= longest; i++)
if(i > 0 || include_from_atom)
turfs += locate(cur_x,cur_y,from_atom.z)
numerator += shortest
if(!(numerator < longest))
numerator -= longest
cur_x += dx1
cur_y += dy1
else
cur_x += dx2
cur_y += dy2
var/list/line = list()
if(include_start_atom)
line += start_turf

var/step_count = get_dist(start_turf, end_turf)
if(!step_count)
return line

return turfs
//as step_count and step size (1) are known can pre-calculate a lerp step, tiny number (1e-5) for rounding consistency
var/step_x = (end_turf.x - start_turf.x) / step_count + 1e-5
var/step_y = (end_turf.y - start_turf.y) / step_count + 1e-5

//locate() truncates the fraction, adding 0.5 so its effectively rounding to nearest coords for free
var/x = start_turf.x + 0.5
var/y = start_turf.y + 0.5
for(var/step in 1 to (step_count - 1)) //increment then locate() skips start_turf (in 1), since end_turf is known can skip that step too (step_count - 1)
x += step_x
y += step_y
line += locate(x, y, start_z)

line += end_turf

return line

//Key thing that stops lag. Cornerstone of performance in ss13, Just sitting here, in unsorted.dm.

Expand Down Expand Up @@ -1621,8 +1580,8 @@ GLOBAL_LIST_INIT(WALLITEMS, list(
/proc/explosive_antigrief_check(obj/item/explosive/explosive, mob/user)
var/turf/Turf = get_turf(explosive)
if(!(Turf.loc.type in GLOB.explosive_antigrief_exempt_areas))
var/crash_occured = (SSticker?.mode?.is_in_endgame)
if((Turf.z in SSmapping.levels_by_any_trait(list(ZTRAIT_MARINE_MAIN_SHIP, ZTRAIT_RESERVED))) && (GLOB.security_level < SEC_LEVEL_RED) && !crash_occured)
var/crash_occurred = (SSticker?.mode?.is_in_endgame)
if((Turf.z in SSmapping.levels_by_any_trait(list(ZTRAIT_MARINE_MAIN_SHIP, ZTRAIT_RESERVED))) && (GLOB.security_level < SEC_LEVEL_RED) && !crash_occurred)
switch(CONFIG_GET(number/explosive_antigrief))
if(ANTIGRIEF_DISABLED)
return FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/adjacent.dm
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ Quick adjacency (to turf):

var/turf/curT = get_turf(A)
var/is_turf = isturf(A)
for(var/turf/T in getline2(A, src))
for(var/turf/T in get_line(A, src))
if(curT == T)
continue
if(T.density)
Expand Down
4 changes: 2 additions & 2 deletions code/_onclick/hud/fullscreen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@
/atom/movable/screen/fullscreen/lighting_backdrop/lit_secondary
invisibility = INVISIBILITY_LIGHTING
layer = BACKGROUND_LAYER + LIGHTING_PRIMARY_DIMMER_LAYER
color = "#000"
color = COLOR_BLACK
alpha = 60

/atom/movable/screen/fullscreen/lighting_backdrop/backplane
invisibility = INVISIBILITY_LIGHTING
layer = LIGHTING_BACKPLANE_LAYER
color = "#000"
color = COLOR_BLACK
blend_mode = BLEND_ADD

/atom/movable/screen/fullscreen/see_through_darkness
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/human.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/datum/hud/human
var/list/gear = list()

/datum/hud/human/New(mob/living/carbon/human/owner, datum/custom_hud/hud_type, ui_color = "#ffffff", ui_alpha = 255)
/datum/hud/human/New(mob/living/carbon/human/owner, datum/custom_hud/hud_type, ui_color = COLOR_WHITE, ui_alpha = 255)
..()
ui_datum = hud_type
if(!istype(ui_datum))
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/observer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
var/message = "You have been dead for [DisplayTimeText(deathtime)]."
message = SPAN_WARNING("[message]")
to_chat(src, message)
to_chat(src, SPAN_WARNING("You must wait atleast 2.5 minutes before rejoining the game!"))
to_chat(src, SPAN_WARNING("You must wait at least 2.5 minutes before rejoining the game!"))
do_observe(target)
return FALSE

Expand Down
4 changes: 2 additions & 2 deletions code/_onclick/xeno.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
return UnarmedAttack(get_step(src, Get_Compass_Dir(src, A)), tile_attack = TRUE, ignores_resin = TRUE)
return FALSE

/**The parent proc, will default to UnarmedAttack behaviour unless overriden
/**The parent proc, will default to UnarmedAttack behaviour unless overridden
Return XENO_ATTACK_ACTION if it does something and the attack should have full attack delay.
Return XENO_NONCOMBAT_ACTION if it did something and should have some delay.
Return XENO_NO_DELAY_ACTION if it gave an error message or should have no delay at all, ex. "You can't X that, it's Y!"
Expand Down Expand Up @@ -131,6 +131,6 @@ so that it doesn't double up on the delays) so that it applies the delay immedia

return ..()

//Larva attack, will default to attack_alien behaviour unless overriden
//Larva attack, will default to attack_alien behaviour unless overridden
/atom/proc/attack_larva(mob/living/carbon/xenomorph/larva/user)
return attack_alien(user)
Loading

0 comments on commit 2724029

Please sign in to comment.