Skip to content

Commit

Permalink
Merge pull request #3695 from MistakeNot4892/tweak/blood
Browse files Browse the repository at this point in the history
Condensing blood code.
  • Loading branch information
out-of-phaze authored Feb 18, 2024
2 parents 4a609a1 + 01cc081 commit cd4707c
Show file tree
Hide file tree
Showing 38 changed files with 287 additions and 325 deletions.
4 changes: 2 additions & 2 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@
- `M?`: The mob whose blood will be used
- Returns: TRUE if made bloody, otherwise FALSE
*/
/atom/proc/add_blood(mob/living/carbon/human/M)
/atom/proc/add_blood(mob/living/M)
if(atom_flags & ATOM_FLAG_NO_BLOOD)
return FALSE

Expand All @@ -482,7 +482,7 @@
M.dna = new /datum/dna()
M.dna.real_name = M.real_name
M.check_dna()
blood_color = M.species.get_blood_color(M)
blood_color = M.get_blood_color()
return TRUE

/**
Expand Down
8 changes: 1 addition & 7 deletions code/game/gamemodes/cult/ritual.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
remove_blood_simple(cost * damage)
if(locate(/obj/effect/rune) in T)
return
var/obj/effect/rune/R = new rune(T, get_rune_color(), get_blood_name())
var/obj/effect/rune/R = new rune(T, get_blood_color(), get_blood_name())
var/area/A = get_area(R)
log_and_message_admins("created \an [R.cultname] rune at \the [A.proper_name].")
R.add_fingerprint(src)
Expand Down Expand Up @@ -129,12 +129,6 @@
/mob/living/carbon/human/mob_needs_tome()
return 1

/mob/proc/get_rune_color()
return "#c80000"

/mob/living/carbon/human/get_rune_color()
return species.get_blood_color(src)

var/global/list/Tier1Runes = list(
/mob/proc/convert_rune,
/mob/proc/teleport_rune,
Expand Down
6 changes: 0 additions & 6 deletions code/game/objects/effects/decals/Cleanable/aliens.dm

This file was deleted.

8 changes: 8 additions & 0 deletions code/game/objects/effects/decals/Cleanable/humans.dm
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ var/global/list/image/splatter_cache=list()
. = ..()
drips = list(icon_state)

/obj/effect/decal/cleanable/blood/drip/on_update_icon()
SHOULD_CALL_PARENT(FALSE)
set_overlays(drips?.Copy())

/obj/effect/decal/cleanable/blood/drip/Destroy()
LAZYCLEARLIST(drips)
return ..()

/obj/effect/decal/cleanable/blood/writing
icon = 'icons/effects/writing.dmi'
icon_state = "writing"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/proc/gibs(var/atom/location, var/gibber_type = /obj/effect/gibspawner/generic, var/_blood_type, var/_unique_enzymes, var/_fleshcolor, var/_bloodcolor)
new gibber_type(location, _blood_type, _unique_enzymes, _fleshcolor, _bloodcolor)

/obj/effect/gibspawner
var/sparks = 0 //whether sparks spread on Gib()
var/list/gibtypes = list()
Expand Down
8 changes: 0 additions & 8 deletions code/game/turfs/simulated.dm
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,6 @@
return 1 //we bloodied the floor
return 0

// Only adds blood on the floor -- Skie
/turf/simulated/proc/add_blood_floor(mob/living/carbon/M)
if(isalien(M))
var/obj/effect/decal/cleanable/blood/xeno/this = new /obj/effect/decal/cleanable/blood/xeno(src)
this.blood_DNA["UNKNOWN BLOOD"] = "X*"
else if(isrobot(M))
new /obj/effect/decal/cleanable/blood/oil(src)

/turf/simulated/attackby(var/obj/item/thing, var/mob/user)
if(IS_COIL(thing) && try_build_cable(thing, user))
return TRUE
Expand Down
8 changes: 0 additions & 8 deletions code/modules/admin/verbs/randomverbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -638,21 +638,13 @@ Traitors and the like can also be revived with the previous role mostly intact.
/client/proc/cmd_admin_gib(mob/M as mob in SSmobs.mob_list)
set category = "Special Verbs"
set name = "Gib"

if(!check_rights(R_ADMIN|R_FUN)) return

var/confirm = alert(src, "You sure?", "Confirm", "Yes", "No")
if(confirm != "Yes") return
//Due to the delay here its easy for something to have happened to the mob
if(!M) return

log_admin("[key_name(usr)] has gibbed [key_name(M)]")
message_admins("[key_name_admin(usr)] has gibbed [key_name_admin(M)]", 1)

if(isobserver(M))
gibs(M.loc)
return

M.gib()
SSstatistics.add_field_details("admin_verb","GIB") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!

Expand Down
76 changes: 76 additions & 0 deletions code/modules/blood/blood.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/proc/blood_splatter(atom/target, atom/source, var/large = FALSE, var/spray_dir)

var/obj/effect/decal/cleanable/blood/splatter
var/decal_type = /obj/effect/decal/cleanable/blood/splatter
var/turf/bleed_turf = get_turf(target)

// Are we dripping or splattering?
var/list/drips
// Only a certain number of drips (or one large splatter) can be on a given turf.
for(var/obj/effect/decal/cleanable/blood/drip/drop in bleed_turf)
LAZYDISTINCTADD(drips, drop.drips)
qdel(drop)
if(!large && LAZYLEN(drips) < 3)
decal_type = /obj/effect/decal/cleanable/blood/drip

// Find a blood decal or create a new one.
if(bleed_turf)
var/list/existing = filter_list(bleed_turf.contents, decal_type)
if(length(existing) > 3)
splatter = pick(existing)
if(!splatter)
splatter = new decal_type(bleed_turf)

if(QDELETED(splatter))
return

var/obj/effect/decal/cleanable/blood/drip/drop = splatter
if(istype(drop) && LAZYLEN(drips) && !large)
drop.drips |= drips
drop.update_icon()

// If there's no data to copy, call it quits here.
var/blood_data
var/blood_type
if(isliving(source))
var/mob/living/donor = source
blood_data = donor.get_blood_data()
blood_type = donor.get_blood_type()
else if(isatom(source))
var/atom/donor = source
blood_data = REAGENT_DATA(donor.reagents, /decl/material/liquid/blood)
if(!islist(blood_data))
return splatter

if(spray_dir)
splatter.icon_state = "squirt"
splatter.set_dir(spray_dir)

// Update blood information.
if(LAZYACCESS(blood_data, "blood_DNA"))
LAZYSET(splatter.blood_data, blood_data["blood_DNA"], blood_data)
splatter.blood_DNA = list()
if(LAZYACCESS(blood_data, "blood_type"))
splatter.blood_DNA[blood_data["blood_DNA"]] = blood_data["blood_type"]
else
splatter.blood_DNA[blood_data["blood_DNA"]] = "O+"
var/datum/extension/forensic_evidence/forensics = get_or_create_extension(splatter, /datum/extension/forensic_evidence)
forensics.add_data(/datum/forensics/blood_dna, blood_data["blood_DNA"])

if(!blood_type && LAZYACCESS(blood_data, "blood_type"))
blood_type = LAZYACCESS(blood_data, "blood_type")

// Update appearance.
if(blood_type)
var/decl/blood_type/blood_type_decl = get_blood_type_by_name(blood_type)
splatter.name = blood_type_decl.splatter_name
splatter.desc = blood_type_decl.splatter_desc
splatter.basecolor = blood_type_decl.splatter_colour

if(LAZYACCESS(blood_data, "blood_color"))
splatter.basecolor = blood_data["blood_color"]

splatter.update_icon()
splatter.fluorescent = FALSE
splatter.set_invisibility(INVISIBILITY_NONE)
return splatter
Original file line number Diff line number Diff line change
Expand Up @@ -59,62 +59,3 @@ var/global/list/antigen_comparison_cache = list()
. = FALSE
break
global.antigen_comparison_cache[type][other_blood_type.type] = .

/decl/blood_type/ominus
name = "O-"
random_weighting = 4

/decl/blood_type/oplus
name = "O+"
antigens = list("Rh")
random_weighting = 36

/decl/blood_type/aminus
name = "A-"
antigens = list("A")
random_weighting = 3

/decl/blood_type/aplus
name = "A+"
antigens = list("A", "Rh")
random_weighting = 28

/decl/blood_type/bminus
name = "B-"
antigens = list("B")

/decl/blood_type/bplus
name = "B+"
antigens = list("B", "Rh")
random_weighting = 20

/decl/blood_type/abminus
name = "AB-"
antigens = list("A", "B")

/decl/blood_type/abplus
name = "AB+"
antigens = list("A", "B", "Rh")
random_weighting = 5

// Insect blood.
/decl/blood_type/hemolymph

name = "hemolymph"
antigen_category = "insect"

splatter_name = "ichor"
splatter_desc = "A smear of insect ichor. It smells acrid."
splatter_colour = "#525252"

// Robo-blood.
/decl/blood_type/coolant

name = "coolant"
antigen_category = "machine"

splatter_name = "coolant"
splatter_desc = "A smear of machine coolant. It looks discoloured."
splatter_colour = SYNTH_BLOOD_COLOR

transfusion_fail_reagent = /decl/material/liquid/acid
58 changes: 58 additions & 0 deletions code/modules/blood/blood_types_subtypes.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/decl/blood_type/ominus
name = "O-"
random_weighting = 4

/decl/blood_type/oplus
name = "O+"
antigens = list("Rh")
random_weighting = 36

/decl/blood_type/aminus
name = "A-"
antigens = list("A")
random_weighting = 3

/decl/blood_type/aplus
name = "A+"
antigens = list("A", "Rh")
random_weighting = 28

/decl/blood_type/bminus
name = "B-"
antigens = list("B")

/decl/blood_type/bplus
name = "B+"
antigens = list("B", "Rh")
random_weighting = 20

/decl/blood_type/abminus
name = "AB-"
antigens = list("A", "B")

/decl/blood_type/abplus
name = "AB+"
antigens = list("A", "B", "Rh")
random_weighting = 5

// Insect blood.
/decl/blood_type/hemolymph

name = "hemolymph"
antigen_category = "insect"

splatter_name = "ichor"
splatter_desc = "A smear of insect ichor. It smells acrid."
splatter_colour = "#525252"

// Robo-blood.
/decl/blood_type/coolant

name = "coolant"
antigen_category = "machine"

splatter_name = "coolant"
splatter_desc = "A smear of machine coolant. It looks discoloured."
splatter_colour = SYNTH_BLOOD_COLOR

transfusion_fail_reagent = /decl/material/liquid/acid
2 changes: 1 addition & 1 deletion code/modules/mob/death.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

flick(anim, animation)
if(do_gibs)
gibs(loc, _blood_type = get_blood_type(), _unique_enzymes = get_unique_enzymes())
gibs()

QDEL_IN(animation, 15)
QDEL_IN(src, 15)
Expand Down
4 changes: 1 addition & 3 deletions code/modules/mob/living/bot/cleanbot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
/mob/living/bot/cleanbot/handleIdle()
if(!screwloose && !oddbutton && prob(5))
visible_message("\The [src] makes an excited beeping booping sound!")

if(screwloose && prob(5)) // Make a mess
if(istype(loc, /turf/simulated))
var/turf/simulated/T = loc
T.wet_floor()

if(oddbutton && prob(5)) // Make a big mess
visible_message("Something flies out of [src]. He seems to be acting oddly.")
var/obj/effect/decal/cleanable/blood/gibs/gib = new /obj/effect/decal/cleanable/blood/gibs(loc)
var/obj/effect/decal/cleanable/blood/gibs/gib = new(loc)
var/weakref/g = weakref(gib)
ignore_list += g
spawn(600)
Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/living/carbon/alien/alien.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
gender = NEUTER
. = ..()

/mob/living/carbon/alien/get_blood_color()
return COLOR_LIME

/mob/living/carbon/alien/restrained()
return 0

Expand Down
3 changes: 0 additions & 3 deletions code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,6 @@
RETURN_TYPE(/decl/species)
return species

/mob/living/carbon/get_species_name()
return species.name

/mob/living/carbon/get_contact_reagents()
return touching

Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/death.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
var/last_loc = loc
..(species.gibbed_anim, do_gibs = FALSE)
if(last_loc)
gibs(last_loc, _fleshcolor = species.get_flesh_colour(src), _bloodcolor = species.get_blood_color(src))
gibs(last_loc)

/mob/living/carbon/human/dust()
if(species)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/examine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
species_name += "[species.cyborg_noun] [species.get_root_species_name(src)]"
else
species_name += "[species.name]"
msg += ", <b><font color='[species.get_flesh_colour(src)]'>\a [species_name]!</font></b>[(user.can_use_codex() && SScodex.get_codex_entry(get_codex_value(user))) ? SPAN_NOTICE(" \[<a href='?src=\ref[SScodex];show_examined_info=\ref[src];show_to=\ref[user]'>?</a>\]") : ""]"
msg += ", <b><font color='[species.get_species_flesh_color(src)]'>\a [species_name]!</font></b>[(user.can_use_codex() && SScodex.get_codex_entry(get_codex_value(user))) ? SPAN_NOTICE(" \[<a href='?src=\ref[SScodex];show_examined_info=\ref[src];show_to=\ref[user]'>?</a>\]") : ""]"
var/extra_species_text = species.get_additional_examine_text(src)
if(extra_species_text)
msg += "<br>[extra_species_text]"
Expand Down
17 changes: 0 additions & 17 deletions code/modules/mob/living/carbon/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,6 @@
return FALSE
return ..()

/mob/living/carbon/human/proc/check_dna()
dna.check_integrity(src)
return

/mob/living/carbon/human/empty_stomach()
SET_STATUS_MAX(src, STAT_STUN, 3)

Expand Down Expand Up @@ -1001,19 +997,6 @@
return BULLET_IMPACT_METAL
return BULLET_IMPACT_MEAT

/mob/living/carbon/human/bullet_impact_visuals(var/obj/item/projectile/P, var/def_zone, var/damage)
..()
switch(get_bullet_impact_effect_type(def_zone))
if(BULLET_IMPACT_MEAT)
if(damage && P.damtype == BRUTE)
var/hit_dir = get_dir(P.starting, src)
var/obj/effect/decal/cleanable/blood/B = blood_splatter(get_step(src, hit_dir), src, 1, hit_dir)
if(!QDELETED(B))
B.icon_state = pick("dir_splatter_1","dir_splatter_2")
var/scale = min(1, round(P.damage / 50, 0.2))
B.set_scale(scale)
new /obj/effect/temp_visual/bloodsplatter(loc, hit_dir, species.get_blood_color(src))

/mob/living/carbon/human/lose_hair()
if(get_bodytype().set_default_hair(src))
. = TRUE
Expand Down
Loading

0 comments on commit cd4707c

Please sign in to comment.