mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
## About The Pull Request Heavily refactors wounds AGAIN. The primary thing this PR does is completely change how wounds are generated and added - while the normal "hit a guy til they bleed" stuff works about the same, asking for a specific type of wound, say, like how vending machines try to apply a compound fracture sometimes, isnt going to work if we ever get any non-organic wounds, which the previous refactor allowed. With this PR, however... * You can now ask for a specific type of wound via get_corresponding_wound_type(), which takes wound types, a limb, wound series, etc. and will try to give you a wound fitting those specifications - but also, a wound that can be applied to a limb. * This will allow for a vending machine to apply a compound fracture to a human, but a collapsed superstructure (assuming my synth wounds go in) to a robot There are now new "series types" and "wound specific types" that allow us to designate what series are "mainline" and randomly generatable, and what are "alternate types" and must be generated manually - you can see the documentation in wounds.dm. The behavior of limping and interaction delays has been abstracted to datum/wound from bone wounds to allow just, general ease of development Pregen data now allows for series-specific wound penalties. Example: You could set a burn wound's series wound penalty to 40, which would make wound progression in the burn category easier - but it would not make it any easier to get a slashing wound. As it stands wound penalties are for wounds globally Scar files are now picked in a "priority" list, where the wound checks to see if the limb has a biostate before moving down in said list. Example: Wounds will check for flesh first, if it finds it - it will use the flesh scar list. Failing that, they then check bone - if it uses that, it will use the bone scar list. This allows for significantly more modular scars that dont even need much proc editing when a new wound type is added Misc changes: most initial() usage has been replaced by singleton datums, wound_type is now wound_types and thus wounds can accept multiple wound types, wounds can now accept multiple tool behaviors for treatment, wounds now have a picking weight so we can make certain wounds rarer flatly, This PR also allows for wounds to override lower severity wounds on generation, allowing eswords to jump to avulsions - but in spirit of refactoring, this has been disabled by default (see pregen data's competition_mode var). ## Why It's Good For The Game Code quality is good! Also, all the changes above allow wounds to be a MUCH more modular system, which is one of its biggest problems right now - everything is kinda hardcoded and static, making creative work within wounds harder to do. ## Changelog 🆑 refactor: Refactored wounds yet again fix: Wounds are now picked from the most severe down again, meaning eswords can jump to avulsions fix: Scar descs are now properly applied /🆑
92 lines
6.6 KiB
Plaintext
92 lines
6.6 KiB
Plaintext
/// This test is used to make sure a flesh-and-bone base human can suffer all the types of wounds, and that suffering more severe wounds removes and replaces the lesser wound. Also tests that [/mob/living/carbon/proc/fully_heal] removes all wounds
|
|
/datum/unit_test/test_human_base/Run()
|
|
var/mob/living/carbon/human/victim = allocate(/mob/living/carbon/human/consistent)
|
|
|
|
/// the limbs have no wound resistance like the chest and head do, so let's go with the r_arm
|
|
var/obj/item/bodypart/tested_part = victim.get_bodypart(BODY_ZONE_R_ARM)
|
|
/// In order of the wound types we're trying to inflict, what sharpness do we need to deal them?
|
|
var/list/sharps = list(NONE, SHARP_EDGED, SHARP_POINTY, NONE)
|
|
/// Since burn wounds need burn damage, duh
|
|
var/list/dam_types = list(BRUTE, BRUTE, BRUTE, BURN)
|
|
|
|
var/i = 1
|
|
var/list/iter_test_wound_list
|
|
|
|
for(iter_test_wound_list in list(list(/datum/wound/blunt/bone/moderate, /datum/wound/blunt/bone/severe, /datum/wound/blunt/bone/critical),\
|
|
list(/datum/wound/slash/flesh/moderate, /datum/wound/slash/flesh/severe, /datum/wound/slash/flesh/critical),\
|
|
list(/datum/wound/pierce/bleed/moderate, /datum/wound/pierce/bleed/severe, /datum/wound/pierce/bleed/critical),\
|
|
list(/datum/wound/burn/flesh/moderate, /datum/wound/burn/flesh/severe, /datum/wound/burn/flesh/critical)))
|
|
|
|
TEST_ASSERT_EQUAL(length(victim.all_wounds), 0, "Patient is somehow wounded before test")
|
|
var/datum/wound/iter_test_wound
|
|
var/datum/wound_pregen_data/iter_pregen_data = GLOB.all_wound_pregen_data[iter_test_wound]
|
|
var/threshold_penalty = 0
|
|
|
|
for(iter_test_wound in iter_test_wound_list)
|
|
var/threshold = iter_pregen_data.threshold_minimum - threshold_penalty // just enough to guarantee the next tier of wound, given the existing wound threshold penalty
|
|
if(dam_types[i] == BRUTE)
|
|
tested_part.receive_damage(WOUND_MINIMUM_DAMAGE, 0, wound_bonus = threshold, sharpness=sharps[i])
|
|
else if(dam_types[i] == BURN)
|
|
tested_part.receive_damage(0, WOUND_MINIMUM_DAMAGE, wound_bonus = threshold, sharpness=sharps[i])
|
|
|
|
TEST_ASSERT(length(victim.all_wounds), "Patient has no wounds when one wound is expected. Severity: [initial(iter_test_wound.severity)]")
|
|
TEST_ASSERT_EQUAL(length(victim.all_wounds), 1, "Patient has more than one wound when only one is expected. Severity: [initial(iter_test_wound.severity)]")
|
|
var/datum/wound/actual_wound = victim.all_wounds[1]
|
|
TEST_ASSERT_EQUAL(actual_wound.type, iter_test_wound, "Patient has wound of incorrect severity. Expected: [initial(iter_test_wound.name)] Got: [actual_wound]")
|
|
threshold_penalty = actual_wound.threshold_penalty
|
|
i++
|
|
victim.fully_heal(ADMIN_HEAL_ALL) // should clear all wounds between types
|
|
|
|
|
|
/// This test is used for making sure species with bones but no flesh (skeletons, plasmamen) can only suffer BONE_WOUNDS, and nothing tagged with FLESH_WOUND (it's possible to require both)
|
|
/datum/unit_test/test_human_bone/Run()
|
|
var/mob/living/carbon/human/victim = allocate(/mob/living/carbon/human/consistent)
|
|
|
|
/// the limbs have no wound resistance like the chest and head do, so let's go with the r_arm
|
|
var/obj/item/bodypart/tested_part = victim.get_bodypart(BODY_ZONE_R_ARM)
|
|
/// In order of the wound types we're trying to inflict, what sharpness do we need to deal them?
|
|
var/list/sharps = list(NONE, SHARP_EDGED, SHARP_POINTY, NONE)
|
|
/// Since burn wounds need burn damage, duh
|
|
var/list/dam_types = list(BRUTE, BRUTE, BRUTE, BURN)
|
|
|
|
var/i = 1
|
|
var/list/iter_test_wound_list
|
|
tested_part.biological_state &= ~BIO_FLESH // take away the base limb's flesh (ouchie!) ((not actually ouchie, this just affects their wounds and dismemberment handling))
|
|
|
|
for(iter_test_wound_list in list(list(/datum/wound/blunt/bone/moderate, /datum/wound/blunt/bone/severe, /datum/wound/blunt/bone/critical),\
|
|
list(/datum/wound/slash/flesh/moderate, /datum/wound/slash/flesh/severe, /datum/wound/slash/flesh/critical),\
|
|
list(/datum/wound/pierce/bleed/moderate, /datum/wound/pierce/bleed/severe, /datum/wound/pierce/bleed/critical),\
|
|
list(/datum/wound/burn/flesh/moderate, /datum/wound/burn/flesh/severe, /datum/wound/burn/flesh/critical)))
|
|
|
|
TEST_ASSERT_EQUAL(length(victim.all_wounds), 0, "Patient is somehow wounded before test")
|
|
var/datum/wound/iter_test_wound
|
|
var/datum/wound_pregen_data/iter_pregen_data = GLOB.all_wound_pregen_data[iter_test_wound]
|
|
var/threshold_penalty = 0
|
|
|
|
for(iter_test_wound in iter_test_wound_list)
|
|
var/threshold = iter_pregen_data.threshold_minimum - threshold_penalty // just enough to guarantee the next tier of wound, given the existing wound threshold penalty
|
|
if(dam_types[i] == BRUTE)
|
|
tested_part.receive_damage(WOUND_MINIMUM_DAMAGE, 0, wound_bonus = threshold, sharpness=sharps[i])
|
|
else if(dam_types[i] == BURN)
|
|
tested_part.receive_damage(0, WOUND_MINIMUM_DAMAGE, wound_bonus = threshold, sharpness=sharps[i])
|
|
|
|
// so if we just tried to deal a flesh wound, make sure we didn't actually suffer it. We may have suffered a bone wound instead, but we just want to make sure we don't have a flesh wound
|
|
var/datum/wound_pregen_data/pregen_data = GLOB.all_wound_pregen_data[iter_test_wound]
|
|
if (pregen_data.required_limb_biostate & BIO_FLESH)
|
|
if(!length(victim.all_wounds)) // not having a wound is good news
|
|
continue
|
|
else // we have to check that it's actually a bone wound and not the intended wound type
|
|
TEST_ASSERT_EQUAL(length(victim.all_wounds), 1, "Patient has more than one wound when only one is expected. Severity: [initial(iter_test_wound.severity)]")
|
|
var/datum/wound/actual_wound = victim.all_wounds[1]
|
|
var/datum/wound_pregen_data/actual_pregen_data = GLOB.all_wound_pregen_data[actual_wound.type]
|
|
TEST_ASSERT((actual_pregen_data.required_limb_biostate & ~BIO_FLESH), "Limb has flesh wound despite no BIO_FLESH biological_state, expected either no wound or bone wound. Offending wound: [actual_wound]")
|
|
threshold_penalty = actual_wound.threshold_penalty
|
|
else // otherwise if it's a bone wound, check that we have it per usual
|
|
TEST_ASSERT(length(victim.all_wounds), "Patient has no wounds when one wound is expected. Severity: [initial(iter_test_wound.severity)]")
|
|
TEST_ASSERT_EQUAL(length(victim.all_wounds), 1, "Patient has more than one wound when only one is expected. Severity: [initial(iter_test_wound.severity)]")
|
|
var/datum/wound/actual_wound = victim.all_wounds[1]
|
|
TEST_ASSERT_EQUAL(actual_wound.type, iter_test_wound, "Patient has wound of incorrect severity. Expected: [initial(iter_test_wound.name)] Got: [actual_wound]")
|
|
threshold_penalty = actual_wound.threshold_penalty
|
|
i++
|
|
victim.fully_heal(ADMIN_HEAL_ALL) // should clear all wounds between types
|