[MIRROR] Fix underlying armor logic and fix bug with constructed ripleys having zero armor [MDB IGNORE] (#19310)

* Fix underlying armor logic and fix bug with constructed ripleys having zero armor (#73319)

## About The Pull Request

See title
## Why It's Good For The Game

Messed up one of the armor procs; it changed the given values but never
carried over existing values.
So you would end up with an armor of that one specific value and nothing
else.

This wasn't actually used anywhere other than mecha, lava burning, and
sentient viruses, so the issue isn't that bad.
It's still an issue however.
## Changelog
🆑
fix: Mechs no longer have zero armor when built.
/🆑

* Fix underlying armor logic and fix bug with constructed ripleys having zero armor

---------

Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-02-13 07:17:07 +01:00
committed by GitHub
parent 657ede86e3
commit dfbaf63d71
4 changed files with 39 additions and 5 deletions
+1
View File
@@ -83,6 +83,7 @@
#include "anchored_mobs.dm"
#include "anonymous_themes.dm"
#include "area_contents.dm"
#include "armor_verification.dm"
#include "autowiki.dm"
#include "barsigns.dm"
#include "baseturfs.dm"
@@ -0,0 +1,33 @@
/// Verifies that armor procs are working as expected
/datum/unit_test/armor_verification
/datum/unit_test/armor_verification/Run()
var/obj/dummy = allocate(/obj)
dummy.set_armor(/datum/armor/none)
var/datum/armor/armor = dummy.get_armor()
TEST_ASSERT_NOTNULL(armor, "armor didn't populate correctly when needed")
TEST_ASSERT_EQUAL(armor_totals(armor), 0, "none armor type had armor values")
armor = armor.generate_new_with_specific(list(FIRE = 20))
TEST_ASSERT_EQUAL(armor_totals(armor), 20, "modified armor type had incorrect values")
armor = armor.generate_new_with_specific(list(ACID = 20))
TEST_ASSERT_EQUAL(armor_totals(armor), 40, "modified armor type had incorrect values")
armor = get_armor_by_type(/datum/armor/immune)
var/totals = armor_totals(armor)
armor = armor.generate_new_with_multipliers(list(ARMOR_ALL = 0))
TEST_ASSERT_EQUAL(armor_totals(armor), totals, "modified an immune armor type")
var/wanted = 40
dummy.set_armor(/datum/armor/none)
dummy.set_armor_rating(ENERGY, wanted * 0.5)
dummy.set_armor_rating(FIRE, wanted * 0.5)
TEST_ASSERT_EQUAL(armor_totals(dummy.get_armor()), wanted, "modified armor type had incorrect values")
/datum/unit_test/armor_verification/proc/armor_totals(datum/armor/armor)
var/total = 0
for(var/key in ARMOR_LIST_ALL())
total += armor.vars[key]
return total
+1 -1
View File
@@ -434,7 +434,7 @@
if(capacitor)
var/datum/armor/stock_armor = get_armor_by_type(armor_type)
var/initial_energy = stock_armor.get_rating(ENERGY)
set_armor_rating(initial_energy + (capacitor.rating * 5))
set_armor_rating(ENERGY, initial_energy + (capacitor.rating * 5))
/obj/vehicle/sealed/mecha/examine(mob/user)
. = ..()