Skip to content

Commit

Permalink
qol: Unified Blood Adjust (#6180)
Browse files Browse the repository at this point in the history
* refactor: Unified Blood Adjust

* fastfix

* setBlood

* vamp subclass

* correct name in signals

* Tlumaczenie

* fix

* forgotten

* упс

* упс. Но теперь я понял, да.

* 1 fortgotten

* Update code/modules/surgery/organs/blood.dm

Co-authored-by: BeebBeebBoob <[email protected]>

* Update code/modules/reagents/chemistry/reagents/medicine.dm

Co-authored-by: BeebBeebBoob <[email protected]>

* Update code/modules/reagents/chemistry/reagents/medicine.dm

Co-authored-by: BeebBeebBoob <[email protected]>

* Update code/game/gamemodes/miniantags/abduction/gland.dm

Co-authored-by: BeebBeebBoob <[email protected]>

* Update code/modules/antagonists/vampire/vampire_datum.dm

Co-authored-by: BeebBeebBoob <[email protected]>

* Update code/modules/antagonists/vampire/vampire_datum.dm

Co-authored-by: BeebBeebBoob <[email protected]>

* Update code/modules/reagents/chemistry/reagents/medicine.dm

Co-authored-by: BeebBeebBoob <[email protected]>

* Update code/modules/antagonists/vampire/vampire_powers/bestia_powers.dm

Co-authored-by: BeebBeebBoob <[email protected]>

* Update code/modules/antagonists/vampire/vampire_powers/bestia_powers.dm

Co-authored-by: BeebBeebBoob <[email protected]>

* Update code/modules/paperwork/contract.dm

Co-authored-by: BeebBeebBoob <[email protected]>

* Update code/modules/surgery/organs/blood.dm

Co-authored-by: BeebBeebBoob <[email protected]>

* Update code/modules/reagents/chemistry/reagents/medicine.dm

Co-authored-by: BeebBeebBoob <[email protected]>

---------

Co-authored-by: BeebBeebBoob <[email protected]>
  • Loading branch information
Antoonij and BeebBeebBoob authored Dec 31, 2024
1 parent d4af951 commit c1fe8c4
Show file tree
Hide file tree
Showing 19 changed files with 116 additions and 43 deletions.
10 changes: 10 additions & 0 deletions code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,16 @@
#define COMSIG_LIVING_CAN_TRACK "mob_cantrack"
#define COMPONENT_CANT_TRACK (1<<0)

/// Source: /mob/living/AdjustBlood(amount)
#define COMSIG_LIVING_BLOOD_ADJUST "living_blood_adjust"
#define COMPONENT_PREVENT_BLOODLOSS (1<<0)
/// Source: /mob/living/AdjustBlood(amount)
#define COMSIG_LIVING_BLOOD_ADJUSTED "living_blood_adjusted"
/// Source: /mob/living/setBlood(amount)
#define COMSIG_LIVING_EARLY_SET_BLOOD "living_early_set_blood"
/// Source: /mob/living/setBlood(amount)
#define COMSIG_LIVING_SET_BLOOD "living_set_blood"

/// From /mob/add_language() (language_name)
#define COMSIG_MOB_LANGUAGE_ADD "mob_language_add"
/// From /mob/remove_language() (language_name)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/aura_healing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
animal_candidate.adjustHealth(-simple_heal * seconds_per_tick, updating_health = FALSE)

if(!HAS_TRAIT(candidate, TRAIT_NO_BLOOD_RESTORE) && candidate.blood_volume < BLOOD_VOLUME_NORMAL)
candidate.blood_volume += blood_heal * seconds_per_tick
candidate.AdjustBlood(blood_heal * seconds_per_tick)

var/external_organ_heal_done = FALSE
if(ishuman(candidate))
Expand Down
2 changes: 1 addition & 1 deletion code/datums/diseases/viruses/advance/symptoms/blood.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ Bonus
if(prob(10))
to_chat(affected, span_notice("You can hear own heartbeat"))
if(!HAS_TRAIT(affected, TRAIT_NO_BLOOD) && !HAS_TRAIT(affected, TRAIT_NO_BLOOD_RESTORE) && affected.blood_volume < BLOOD_VOLUME_NORMAL)
affected.blood_volume += 0.4
affected.AdjustBlood(0.4)
affected.adjust_nutrition(-2)

2 changes: 1 addition & 1 deletion code/datums/rituals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@

/datum/ritual/ashwalker/summon/proc/deal_damage()
for(var/mob/living/carbon/human/summoner in range(finding_range, ritual_object))
summoner.blood_volume -= (summoner.blood_volume * 0.20)
summoner.AdjustBlood(-(summoner.blood_volume * 0.20))
summoner.apply_damage(25, def_zone = pick(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM))

return TRUE
Expand Down
12 changes: 10 additions & 2 deletions code/datums/status_effects/buffs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -374,22 +374,30 @@
active_instances += instance_duration

/datum/status_effect/fleshmend/tick(seconds_between_ticks)
if(length(active_instances) >= 1)
if(LAZYLEN(active_instances) >= 1)
var/heal_amount = (length(active_instances) / tolerance) * (freezing ? 2 : 10)
var/blood_restore = 30 * length(active_instances)
var/update = NONE

update |= owner.heal_overall_damage(heal_amount, heal_amount, updating_health = FALSE)
update |= owner.heal_damage_type(heal_amount, OXY, FALSE)

if(update)
owner.updatehealth("fleshmend")

if(!HAS_TRAIT(owner, TRAIT_NO_BLOOD_RESTORE))
owner.blood_volume = min(owner.blood_volume + blood_restore, BLOOD_VOLUME_NORMAL)
owner.setBlood(min(owner.blood_volume + blood_restore, BLOOD_VOLUME_NORMAL))

var/list/expired_instances = list()

for(var/i in 1 to length(active_instances))
active_instances[i]--

if(active_instances[i] <= 0)
expired_instances += active_instances[i]

active_instances -= expired_instances

tolerance = max(tolerance - 0.05, 1)
if(tolerance <= 1 && length(active_instances) == 0)
qdel(src)
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/clockwork/clockwork_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@
if(bodypart.internal_bleeding())
to_chat(user, span_warning("You tear through [human]'s skin releasing the blood from [human.p_their()] [bodypart.name]!"))
playsound(get_turf(human), 'sound/effects/pierce.ogg', 30, TRUE)
human.blood_volume = max(human.blood_volume - 100, 0)
human.setBlood(max(human.blood_volume - 100, 0))
var/splatter_dir = get_dir(user, human)
blood_color = human.dna.species.blood_color
new /obj/effect/temp_visual/dir_setting/bloodsplatter(human.drop_location(), splatter_dir, blood_color)
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/clockwork/clockwork_structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
M.adjustHealth(-8)

if(ishuman(L) && !HAS_TRAIT(L, TRAIT_NO_BLOOD_RESTORE) && L.blood_volume < BLOOD_VOLUME_NORMAL)
L.blood_volume += 1
L.AdjustBlood(1)


/obj/structure/clockwork/functional/beacon/Destroy()
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/cult/blood_magic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@
if(H.blood_volume < BLOOD_VOLUME_SAFE)
var/restore_blood = BLOOD_VOLUME_SAFE - H.blood_volume
if(uses * 2 < restore_blood)
H.blood_volume += uses * 2
H.AdjustBlood(uses * 2)
to_chat(user, "<span class='danger'>You use the last of your charges to restore what blood you could, and the spell dissipates!</span>")
uses = 0
return ..()
Expand Down
12 changes: 7 additions & 5 deletions code/game/gamemodes/miniantags/abduction/gland.dm
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,15 @@
uses = -1

/obj/item/organ/internal/heart/gland/bloody/activate()
owner.blood_volume = max(owner.blood_volume - 20, 0)
owner.visible_message("<span class='danger'>[owner]'s skin erupts with blood!</span>",\
"<span class='userdanger'>Blood pours from your skin!</span>")
owner.AdjustBlood(-20)

for(var/turf/T in oview(3,owner)) //Make this respect walls and such
owner.visible_message(span_danger("Из кожи [owner] льётся кровь!"), \
span_userdanger("Из вашей кожи хлещет кровь!"))

for(var/turf/T in oview(3, owner)) // Make this respect walls and such
owner.add_splatter_floor(T)
for(var/mob/living/carbon/human/H in oview(3,owner)) //Blood decals for simple animals would be neat. aka Carp with blood on it.

for(var/mob/living/carbon/human/H in oview(3, owner)) // Blood decals for simple animals would be neat. aka Carp with blood on it.
H.add_mob_blood(owner)


Expand Down
4 changes: 2 additions & 2 deletions code/modules/antagonists/vampire/vampire_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
if(unique_suck_id in drained_humans)
if(drained_humans[unique_suck_id] >= BLOOD_DRAIN_LIMIT)
to_chat(cur, span_warning("Вы поглотили всю жизненную эссенцию [target], дальнейшее питьё крови будет только утолять голод!"))
target.blood_volume = max(target.blood_volume - 25, 0)
target.AdjustBlood(-25)
cur.set_nutrition(min(NUTRITION_LEVEL_WELL_FED, cur.nutrition + 5))
continue

Expand Down Expand Up @@ -297,7 +297,7 @@

to_chat(cur, span_boldnotice("Вы накопили [bloodtotal] единиц[declension_ru(bloodtotal, "у", "ы", "")] крови[bloodusable != old_bloodusable ? ", и теперь вам доступно [bloodusable] единиц[declension_ru(bloodusable, "а", "ы", "")] крови" : ""]."))

target.blood_volume = max(target.blood_volume - 25, 0)
target.AdjustBlood(-25)

//Blood level warnings (Code 'borrowed' from Fulp)
if(target.blood_volume)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@

// blood
if(!HAS_TRAIT(human_vampire, TRAIT_NO_BLOOD_RESTORE))
human_vampire.blood_volume = clamp(human_vampire.blood_volume + heal_blood, 0, BLOOD_VOLUME_NORMAL)
human_vampire.setBlood(clamp(human_vampire.blood_volume + heal_blood, 0, BLOOD_VOLUME_NORMAL))

// internal organs
for(var/obj/item/organ/internal/organ as anything in human_vampire.internal_organs)
Expand Down Expand Up @@ -2076,7 +2076,7 @@
if(t_livers && human_vampire && l_target.mind && l_target.ckey)
var/blood_amt = round(t_livers / 2)
vampire.adjust_blood(l_target, blood_amt) // +5 vampire blood max
l_target.blood_volume = max(l_target.blood_volume - blood_amt, 0) // -5 blood MAX
l_target.AdjustBlood(-blood_amt) // -5 blood MAX
human_vampire.set_nutrition(min(NUTRITION_LEVEL_WELL_FED, human_vampire.nutrition + 5))


Expand Down Expand Up @@ -2249,7 +2249,7 @@
if(t_livers && human_vampire && l_target.mind && l_target.ckey)
var/blood_amt = round(t_livers / 2)
vampire.adjust_blood(l_target, blood_amt) // +5 vampire blood max
l_target.blood_volume = max(l_target.blood_volume - blood_amt, 0) // -5 blood MAX
l_target.AdjustBlood(-blood_amt) // -5 blood MAX
human_vampire.set_nutrition(min(NUTRITION_LEVEL_WELL_FED, human_vampire.nutrition + 5))


Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/vampire/vampire_subclasses.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
/obj/effect/proc_holder/spell/vampire/self/blood_spill)

/datum/vampire_subclass/hemomancer/on_blood_sucking(mob/living/carbon/human/H)
H.blood_volume = min(H.blood_volume + 5, BLOOD_VOLUME_NORMAL)
H.setBlood(min(H.blood_volume + 5, BLOOD_VOLUME_NORMAL))

/datum/vampire_subclass/gargantua
name = "gargantua"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/species/diona.dm
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
if(update)
H.updatehealth()
if(H.blood_volume < BLOOD_VOLUME_NORMAL)
H.blood_volume += 0.5
H.AdjustBlood(0.5)

if(!is_vamp && H.nutrition < NUTRITION_LEVEL_STARVING + 50)
H.adjustBruteLoss(2)
Expand Down
23 changes: 18 additions & 5 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -873,36 +873,49 @@
/mob/living/proc/makeTrail(turf/T)
if(!has_gravity())
return
var/blood_exists = 0

for(var/obj/effect/decal/cleanable/trail_holder/C in loc) //checks for blood splatter already on the floor
blood_exists = 1
var/blood_exists = FALSE

for(var/obj/effect/decal/cleanable/trail_holder/C in loc) // checks for blood splatter already on the floor
blood_exists = TRUE

if(isturf(loc))
var/trail_type = getTrail()

if(trail_type)
var/brute_ratio = round(getBruteLoss()/maxHealth, 0.1)
if(blood_volume && blood_volume > max(BLOOD_VOLUME_NORMAL*(1 - brute_ratio * 0.25), 0))//don't leave trail if blood volume below a threshold
blood_volume = max(blood_volume - max(1, brute_ratio * 2), 0) //that depends on our brute damage.

if(blood_volume && blood_volume > max(BLOOD_VOLUME_NORMAL*(1 - brute_ratio * 0.25), 0)) // don't leave trail if blood volume below a threshold
setBlood(max(blood_volume - max(1, brute_ratio * 2), 0)) // that depends on our brute damage.
var/newdir = get_dir(T, loc)

if(newdir != src.dir)
newdir = newdir | dir

if(newdir == 3) //N + S
newdir = NORTH

else if(newdir == 12) //E + W
newdir = EAST

if((newdir in GLOB.cardinal) && (prob(50)))
newdir = turn(get_dir(T, loc), 180)

if(!blood_exists)
new /obj/effect/decal/cleanable/trail_holder(loc)

for(var/obj/effect/decal/cleanable/trail_holder/TH in loc)
if((!(newdir in TH.existing_dirs) || trail_type == "trails_1" || trail_type == "trails_2") && TH.existing_dirs.len <= 16) //maximum amount of overlays is 16 (all light & heavy directions filled)
TH.existing_dirs += newdir
TH.overlays.Add(image('icons/effects/blood.dmi', trail_type, dir = newdir))
TH.transfer_mob_blood_dna(src)

if(ishuman(src))
var/mob/living/carbon/human/H = src

if(H.dna.species.blood_color)
TH.color = H.dna.species.blood_color

else
TH.color = "#A10808"

Expand Down
2 changes: 1 addition & 1 deletion code/modules/paperwork/contract.dm
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
span_danger("You slice your wrist open and scrawl your name in blood."),
)
if(ishuman(user))
user.blood_volume = max(0, user.blood_volume - 100)
user.AdjustBlood(-100)


/obj/item/paper/contract/infernal/proc/attempt_signature(mob/living/carbon/human/user, blood = 0)
Expand Down
15 changes: 8 additions & 7 deletions code/modules/reagents/chemistry/reagents/medicine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
if(method == REAGENT_INGEST && iscarbon(M))
var/mob/living/carbon/C = M
if(C.get_blood_id() == id && !HAS_TRAIT(C, TRAIT_NO_BLOOD_RESTORE))
C.blood_volume = min(C.blood_volume + round(volume, 0.1), BLOOD_VOLUME_NORMAL)
C.setBlood(min(C.blood_volume + round(volume, 0.1), BLOOD_VOLUME_NORMAL))
C.reagents.del_reagent(id)

/datum/reagent/medicine/cryoxadone/on_mob_life(mob/living/M)
Expand Down Expand Up @@ -295,7 +295,8 @@
var/mob/living/carbon/human/H = M
//do not restore blood on things with no blood by nature.
if(!HAS_TRAIT(H, TRAIT_NO_BLOOD) && !HAS_TRAIT(H, TRAIT_NO_BLOOD_RESTORE) && H.blood_volume < BLOOD_VOLUME_NORMAL)
H.blood_volume += 1
H.AdjustBlood(1)

return ..() | update_flags

/datum/reagent/medicine/synthflesh
Expand Down Expand Up @@ -1052,20 +1053,20 @@
if(severity == 1)
if(effect <= 2)
M.vomit(0, VOMIT_BLOOD, 0 SECONDS)
M.blood_volume = max(M.blood_volume - rand(5, 10), 0)
M.AdjustBlood(-rand(5, 10))
else if(effect <= 4)
M.vomit(0, VOMIT_BLOOD, 0 SECONDS)
M.blood_volume = max(M.blood_volume - rand(1, 2), 0)
M.AdjustBlood(-rand(1, 2))
else if(severity == 2)
if(effect <= 2)
M.visible_message("<span class='warning'>[M] is bleeding from [M.p_their()] very pores!</span>")
M.bleed(rand(10, 20))
else if(effect <= 4)
M.vomit(0, VOMIT_BLOOD, 0 SECONDS)
M.blood_volume = max(M.blood_volume - rand(5, 10), 0)
M.AdjustBlood(-rand(5, 10))
else if(effect <= 8)
M.vomit(0, VOMIT_BLOOD, 0 SECONDS)
M.blood_volume = max(M.blood_volume - rand(1, 2), 0)
M.AdjustBlood(-rand(1, 2))
return list(effect, update_flags)


Expand Down Expand Up @@ -1428,7 +1429,7 @@
for(var/obj/item/organ/internal/I as anything in M.internal_organs) // 56 healing to all internal organs.
I.heal_internal_damage(8)
if(!HAS_TRAIT(H, TRAIT_NO_BLOOD_RESTORE) && H.blood_volume < BLOOD_VOLUME_NORMAL * 0.9)// If below 90% blood, regenerate 210 units total
H.blood_volume += 30
H.AdjustBlood(30)
for(var/datum/disease/critical/heart_failure/HF in H.diseases)
HF.cure() //Won't fix a stopped heart, but it will sure fix a critical one. Shock is not fixed as healing will fix it
if(M.health < 40)
Expand Down
3 changes: 2 additions & 1 deletion code/modules/reagents/chemistry/reagents/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@
if(ishuman(M))
var/mob/living/carbon/human/H = M
if(!HAS_TRAIT(H, TRAIT_NO_BLOOD) && !HAS_TRAIT(H, TRAIT_NO_BLOOD_RESTORE) && H.blood_volume < BLOOD_VOLUME_NORMAL)
H.blood_volume += 0.8
H.AdjustBlood(0.8)

return ..()

/datum/reagent/iron/reaction_mob(mob/living/M, method=REAGENT_TOUCH, volume)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/chemistry/reagents/toxins.dm
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
if(method == REAGENT_INGEST && iscarbon(M))
var/mob/living/carbon/C = M
if(C.get_blood_id() == id && !HAS_TRAIT(C, TRAIT_NO_BLOOD_RESTORE))
C.blood_volume = min(C.blood_volume + round(volume, 0.1), BLOOD_VOLUME_NORMAL)
C.setBlood(min(C.blood_volume + round(volume, 0.1), BLOOD_VOLUME_NORMAL))
C.reagents.del_reagent(id)

/datum/reagent/slimejelly/reaction_turf(turf/T, volume, color)
Expand Down
Loading

0 comments on commit c1fe8c4

Please sign in to comment.