[MIRROR] Shapechange health transfer tweaks [MDB IGNORE] (#24590)

* Shapechange health transfer tweaks

* Fix diffs

---------

Co-authored-by: Jacquerel <hnevard@gmail.com>
Co-authored-by: Giz <13398309+vinylspiders@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-10-26 06:16:19 -04:00
committed by GitHub
co-authored by Jacquerel Giz
parent 496cd3d0e2
commit fa5430714f
13 changed files with 133 additions and 65 deletions
+52 -8
View File
@@ -18,6 +18,8 @@
qdel(shift)
#define TRIGGER_RESET_COOLDOWN(spell) spell.next_use_time = 0; spell.Trigger();
/**
* Validates that shapeshift spells put the mob in another mob, as they should.
*/
@@ -25,7 +27,7 @@
/datum/unit_test/shapeshift_spell/Run()
var/mob/living/carbon/human/dummy = allocate(/mob/living/carbon/human/consistent)
var/mob/living/carbon/human/dummy = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left)
dummy.mind_initialize()
for(var/spell_type in subtypesof(/datum/action/cooldown/spell/shapeshift))
@@ -57,8 +59,7 @@
if(forced_shape)
shift.shapeshift_type = forced_shape
shift.next_use_time = 0
shift.Trigger()
TRIGGER_RESET_COOLDOWN(shift)
var/mob/expected_shape = shift.shapeshift_type
if(!istype(dummy.loc, expected_shape))
return TEST_FAIL("Shapeshift spell: [shift.name] failed to transform the dummy into the shape [initial(expected_shape.name)]. \
@@ -68,8 +69,7 @@
if(!(shift in shape.actions))
return TEST_FAIL("Shapeshift spell: [shift.name] failed to grant the spell to the dummy's shape.")
shift.next_use_time = 0
shift.Trigger()
TRIGGER_RESET_COOLDOWN(shift)
if(istype(dummy.loc, shift.shapeshift_type))
return TEST_FAIL("Shapeshift spell: [shift.name] failed to transform the dummy back into a human.")
@@ -81,7 +81,7 @@
/datum/unit_test/shapeshift_holoparasites/Run()
var/mob/living/carbon/human/dummy = allocate(/mob/living/carbon/human/consistent)
var/mob/living/carbon/human/dummy = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left)
var/datum/action/cooldown/spell/shapeshift/wizard/shift = new(dummy)
shift.shapeshift_type = shift.possible_shapes[1]
@@ -99,9 +99,53 @@
TEST_ASSERT_EQUAL(test_stand.summoner, dummy.loc, "Shapeshift spell failed to transfer the holoparasite to the dummy's shape.")
// Dummy casts shapeshfit back, the stand's summoner should become the dummy again.
shift.next_use_time = 0
shift.Trigger()
TRIGGER_RESET_COOLDOWN(shift)
TEST_ASSERT(!istype(dummy.loc, shift.shapeshift_type), "Shapeshift spell failed to transform the dummy back into human form.")
TEST_ASSERT_EQUAL(test_stand.summoner, dummy, "Shapeshift spell failed to transfer the holoparasite back to the dummy's human form.")
qdel(shift)
#define EXPECTED_HEALTH_RATIO 0.5
/// Validates that shapeshifting carries health or death between forms properly, if it is supposed to
/datum/unit_test/shapeshift_health
/datum/unit_test/shapeshift_health/Run()
for(var/spell_type in subtypesof(/datum/action/cooldown/spell/shapeshift))
var/mob/living/carbon/human/dummy = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left)
var/datum/action/cooldown/spell/shapeshift/shift_spell = new spell_type(dummy)
shift_spell.Grant(dummy)
shift_spell.shapeshift_type = shift_spell.possible_shapes[1]
if (istype(shift_spell, /datum/action/cooldown/spell/shapeshift/polymorph_belt))
var/datum/action/cooldown/spell/shapeshift/polymorph_belt/belt_spell = shift_spell
belt_spell.channel_time = 0 SECONDS // No do-afters
if (shift_spell.convert_damage)
shift_spell.Trigger()
TEST_ASSERT(istype(dummy.loc, shift_spell.shapeshift_type), "Failed to transform into [shift_spell.shapeshift_type]using [shift_spell.name].")
var/mob/living/shifted_mob = dummy.loc
shifted_mob.apply_damage(shifted_mob.maxHealth * EXPECTED_HEALTH_RATIO, BRUTE, forced = TRUE)
TRIGGER_RESET_COOLDOWN(shift_spell)
TEST_ASSERT(!istype(dummy.loc, shift_spell.shapeshift_type), "Failed to unfransform from [shift_spell.shapeshift_type] using [shift_spell.name].")
TEST_ASSERT_EQUAL(dummy.get_total_damage(), dummy.maxHealth * EXPECTED_HEALTH_RATIO, "Failed to transfer damage from [shift_spell.shapeshift_type] to original form using [shift_spell.name].")
TRIGGER_RESET_COOLDOWN(shift_spell)
TEST_ASSERT(istype(dummy.loc, shift_spell.shapeshift_type), "Failed to transform into [shift_spell.shapeshift_type] after taking damage using [shift_spell.name].")
shifted_mob = dummy.loc
TEST_ASSERT_EQUAL(shifted_mob.get_total_damage(), shifted_mob.maxHealth * EXPECTED_HEALTH_RATIO, "Failed to transfer damage from original form to [shift_spell.shapeshift_type] using [shift_spell.name].")
TRIGGER_RESET_COOLDOWN(shift_spell)
if (shift_spell.die_with_shapeshifted_form)
TRIGGER_RESET_COOLDOWN(shift_spell)
TEST_ASSERT(istype(dummy.loc, shift_spell.shapeshift_type), "Failed to transform into [shift_spell.shapeshift_type]")
var/mob/living/shifted_mob = dummy.loc
shifted_mob.health = 0 // Fucking megafauna
shifted_mob.death()
if (shift_spell.revert_on_death)
TEST_ASSERT(!istype(dummy.loc, shift_spell.shapeshift_type), "Failed to untransform after death using [shift_spell.name].")
TEST_ASSERT_EQUAL(dummy.stat, DEAD, "Failed to kill original mob when transformed mob died using [shift_spell.name].")
qdel(shift_spell)
#undef EXPECTED_HEALTH_RATIO
#undef TRIGGER_RESET_COOLDOWN