Files
Bubberstation/code/modules/unit_tests/embedding.dm
SmArtKar 136b87eba7 Added unit test for embedding (#84981)
## About The Pull Request

Added a unit test that checks if embed chance modification, embedding
and embed modification passing to shrapnel is correct.
There seems to be an inconsistent embedding failure right now that
@necromanceranne discovered, hopefully this can catch it further down
the line.

## Changelog
No player facing changes.
2024-07-17 09:17:01 +02:00

15 lines
909 B
Plaintext

/datum/unit_test/embedding
/datum/unit_test/embedding/Run()
var/mob/living/carbon/human/victim = allocate(/mob/living/carbon/human/consistent)
var/mob/living/carbon/human/firer = allocate(/mob/living/carbon/human/consistent)
var/obj/projectile/bullet/c38/bullet = new(get_turf(firer))
bullet.set_embed(bullet.get_embed().generate_with_values(embed_chance = 100))
TEST_ASSERT_EQUAL(bullet.get_embed().embed_chance, 100, "embed_chance failed to modify")
bullet.preparePixelProjectile(victim, firer)
bullet.fire(get_angle(firer, victim), victim)
var/list/components = victim.GetComponents(/datum/component/embedded)
TEST_ASSERT_EQUAL(components.len, 1, "Projectile with 100% embed chance didn't embed, or embedded multiple times")
var/datum/component/embedded/comp = components[1]
TEST_ASSERT_EQUAL(comp.weapon.get_embed().embed_chance, 100, "embed_chance modification did not transfer to shrapnel")