mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 09:42:29 +00:00
* Basic Guardians/Holoparasites (#79473) ## About The Pull Request Fixes #79485 Fixes #77552 Converts Guardians (aka Holoparasites) into Basic Mobs. Changes a bunch of their behaviours into actions or components which we can reuse. Replaces some verbs it would give to you and hide in the status panel with action buttons that you may be able to find more quickly. They _**should**_ work basically like they did before but a bit smoother. It is not unlikely that I made some changes by accident or just by changing framework though. My one creative touch was adding random name suggestions. The Wizard federation have a convention of naming their arcane spirit guardians by combining a colour and a major arcana of the tarot. The Syndicate of course won't truck with any of that mystical claptrap and for their codenames use the much more sensible construction of a colour and a gamepiece. This lets you be randomly assigned such creative names as "Sparkling Hermit", "Bloody Queen", "Blue World", or "Purple Diamond". You can of course still ignore this entirely and type "The Brapmaster" into the box if so desired. I made _one_ other intentional change, which is to swap to Mothblocks' nice leash component instead of instantly teleporting guardians back to you when they are pulled out of the edge of their range. They should now be "dragged" along behind you until they can't path, at which point they will teleport. This should make the experience a bit less disorienting, you have the recall button if you _want_ to instantly catch up. This is unfortunately a bumper-sized PR because it did not seem plausible to not do all of it at once, but I can make a project branch for atomisation if people think this is too much of a pain in the ass to review. Other changes: - Some refactoring to how the charge action works so I could individually override "what you can hit" and "what happens when you hit" instead of those being the same proc - Lightning Guardian damage chain is now a component - Explosive Guardian explosive trap is now a component - Added even more arguments to the Healing Touch component to allow it to heal tox/oxy damage and require a specific click modifier - Life Link component which implements the Guardian behaviour of using another mob as your health bar - Moved some stuff about deciding what guardians look and are described like into a theming datum - Added a generic proc which can return whether your mob is meant to apply some kind of damage multiplier to a certain damage type. It's not perfect because I couldn't figure out how ot cram limb modifiers in there, which is where most of it is on carbons. Oh well. - Riders of vehicles now inherit all movement traits of those vehicles, so riding a charging holoparasite will let you cross chasms. Also works if you piggyback someone with wings, probably. ## Changelog 🆑 refactor: Guardians/Powerminers/Holoparasites now use the basic mob framework. Please report any unexpected changes or behaviour. qol: The verbs used to communicate with, recall, or banish your Guardian are now action buttons. balance: If (as a Guardian) your host moves slightly out of range you will now be dragged back into range if possible, rather than being instantly teleported to them. balance: Protectors now have a shorter leash range rather than a longer one, in order to more easily take advantage of their ability to drag their charge out of danger. balance: Ranged Guardians can now hold down the mouse button to fire automatically. balance: People riding vehicles or other mobs now inherit all of their movement traits, so riding a flying mob (or vehicle, if we have any of those) will allow you to cross chasms and lava safely. /🆑 --------- Co-authored-by: san7890 <the@ san7890.com> * Basic Guardians/Holoparasites * Modular --------- Co-authored-by: Jacquerel <hnevard@gmail.com> Co-authored-by: san7890 <the@ san7890.com> Co-authored-by: Giz <13398309+vinylspiders@users.noreply.github.com>
152 lines
7.0 KiB
Plaintext
152 lines
7.0 KiB
Plaintext
/**
|
|
* Validates that all shapeshift type spells have a valid possible_shapes setup.
|
|
*/
|
|
/datum/unit_test/shapeshift_spell_validity
|
|
|
|
/datum/unit_test/shapeshift_spell_validity/Run()
|
|
|
|
var/list/types_to_test = subtypesof(/datum/action/cooldown/spell/shapeshift)
|
|
|
|
for(var/spell_type in types_to_test)
|
|
var/datum/action/cooldown/spell/shapeshift/shift = new spell_type()
|
|
if(!LAZYLEN(shift.possible_shapes))
|
|
TEST_FAIL("Shapeshift spell: [shift] ([spell_type]) did not have any possible shapeshift options.")
|
|
|
|
for(var/shift_type in shift.possible_shapes)
|
|
if(!ispath(shift_type, /mob/living))
|
|
TEST_FAIL("Shapeshift spell: [shift] had an invalid / non-living shift type ([shift_type]) in their possible shapes list.")
|
|
|
|
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.
|
|
*/
|
|
/datum/unit_test/shapeshift_spell
|
|
|
|
/datum/unit_test/shapeshift_spell/Run()
|
|
|
|
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))
|
|
// Test all shapeshifts as if they were on the mob's body
|
|
var/datum/action/cooldown/spell/shapeshift/bodybound_shift = new spell_type(dummy)
|
|
bodybound_shift.Grant(dummy)
|
|
if(LAZYLEN(bodybound_shift.possible_shapes) > 1)
|
|
for(var/forced_shape in bodybound_shift.possible_shapes)
|
|
test_spell(dummy, bodybound_shift, forced_shape)
|
|
|
|
else if(LAZYLEN(bodybound_shift.possible_shapes) == 1)
|
|
test_spell(dummy, bodybound_shift)
|
|
|
|
qdel(bodybound_shift)
|
|
|
|
// And test all shapeshifts as if they were on the mob's mind
|
|
var/datum/action/cooldown/spell/shapeshift/mindbound_shift = new spell_type(dummy.mind)
|
|
mindbound_shift.Grant(dummy)
|
|
if(LAZYLEN(mindbound_shift.possible_shapes) > 1)
|
|
for(var/forced_shape in mindbound_shift.possible_shapes)
|
|
test_spell(dummy, mindbound_shift, forced_shape)
|
|
|
|
else if(LAZYLEN(bodybound_shift.possible_shapes) == 1)
|
|
test_spell(dummy, mindbound_shift)
|
|
|
|
qdel(mindbound_shift)
|
|
|
|
/datum/unit_test/shapeshift_spell/proc/test_spell(mob/living/carbon/human/dummy, datum/action/cooldown/spell/shapeshift/shift, forced_shape)
|
|
if(forced_shape)
|
|
shift.shapeshift_type = forced_shape
|
|
|
|
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)]. \
|
|
([dummy] was located within [dummy.loc], which is a [dummy.loc?.type || "null"]).")
|
|
|
|
var/mob/living/shape = dummy.loc
|
|
if(!(shift in shape.actions))
|
|
return TEST_FAIL("Shapeshift spell: [shift.name] failed to grant the spell to the dummy's shape.")
|
|
|
|
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.")
|
|
|
|
|
|
/**
|
|
* Validates that shapeshifts function properly with holoparasites.
|
|
*/
|
|
/datum/unit_test/shapeshift_holoparasites
|
|
|
|
/datum/unit_test/shapeshift_holoparasites/Run()
|
|
|
|
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]
|
|
shift.Grant(dummy)
|
|
|
|
var/mob/living/basic/guardian/test_stand = allocate(/mob/living/basic/guardian)
|
|
test_stand.set_summoner(dummy)
|
|
|
|
// The stand's summoner is dummy.
|
|
TEST_ASSERT_EQUAL(test_stand.summoner, dummy, "Holoparasite failed to set the summoner to the correct mob.")
|
|
|
|
// Dummy casts shapeshift. The stand's summoner should become the shape the dummy is within.
|
|
shift.Trigger()
|
|
TEST_ASSERT(istype(dummy.loc, shift.shapeshift_type), "Shapeshift spell failed to transform the dummy into the shape [initial(shift.shapeshift_type.name)].")
|
|
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.
|
|
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
|