Slightly refactors makeTrail() and adds a few comments (#21863)

* The refactor

* Gaxeer review

* Some more reviews

* Last Gaxeer review

* Moving around the comments a bit

* oopsie

* Sirryan review
This commit is contained in:
DGamerL
2023-08-12 19:24:30 +02:00
committed by GitHub
parent 32e023b85e
commit d27b36d021
+34 -34
View File
@@ -586,7 +586,7 @@
if(get_dist(src, pulling) > 1 || (moving_diagonally != SECOND_DIAG_STEP && ((pull_dir - 1) & pull_dir))) // puller and pullee more than one tile away or in diagonal position
if(isliving(pulling))
var/mob/living/M = pulling
if(IS_HORIZONTAL(M) && !M.buckled && (prob(M.getBruteLoss() * 200 / M.maxHealth)))
if(IS_HORIZONTAL(M) && !M.buckled && (prob(M.getBruteLoss() * 200 / M.maxHealth))) // So once you reach 50 brute damage you hit 100% chance to leave a blood trail for every tile you're pulled
M.makeTrail(dest)
pulling.Move(dest, get_dir(pulling, dest), movetime) // the pullee tries to reach our previous position
if(pulling && get_dist(src, pulling) > 1) // the pullee couldn't keep up
@@ -647,41 +647,41 @@
currently_grab_pulled = old_being_pulled
/mob/living/proc/makeTrail(turf/T)
/mob/living/proc/makeTrail(turf/turf_to_trail_on)
if(!has_gravity(src))
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
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.
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"
if(!isturf(loc))
return
var/trail_type = getTrail()
if(!trail_type)
return
var/brute_ratio = round(getBruteLoss() / maxHealth, 0.1)
if(!blood_volume && !(blood_volume > max(BLOOD_VOLUME_NORMAL * (1 - brute_ratio * 0.25), 0))) // Okay let's dive into the maths. For every 50 brute damage taken, the minimal blood level you can have decreases by 12,5%
return
blood_volume = max(blood_volume - max(1, brute_ratio * 2), 0) // The amount of blood lost per tile of movement is always at least 1cl, and every 50 damage after reaching 50 brute damage taken will increase the bleed by 1cl per tile
var/newdir = get_dir(turf_to_trail_on, loc)
if(newdir != dir)
newdir |= dir
if(newdir == (NORTH|SOUTH))
newdir = NORTH
else if(newdir == (EAST|WEST))
newdir = EAST
if(IS_DIR_CARDINAL(newdir) && prob(50))
newdir = turn(get_dir(turf_to_trail_on, loc), 180)
var/blood_exists = locate(/obj/effect/decal/cleanable/trail_holder) in loc //checks for blood splatter already on the floor
if(!blood_exists)
new /obj/effect/decal/cleanable/trail_holder(loc)
for(var/obj/effect/decal/cleanable/trail_holder/existing_trail in loc)
if((!(newdir in existing_trail.existing_dirs) || trail_type == "trails_1" || trail_type == "trails_2") && length(existing_trail.existing_dirs) <= 16) //maximum amount of overlays is 16 (all light & heavy directions filled)
existing_trail.existing_dirs += newdir
existing_trail.overlays.Add(image('icons/effects/blood.dmi', trail_type, dir = newdir))
existing_trail.transfer_mob_blood_dna(src)
if(ishuman(src))
var/mob/living/carbon/human/H = src
if(H.dna.species.blood_color)
existing_trail.color = H.dna.species.blood_color
else
existing_trail.color = "#A10808"
/mob/living/carbon/human/makeTrail(turf/T)