Zombification resistance rework (#36485)

* initial commit

* Commit cuz beck said so 👍

* Implement balance changes, and revert some stuff

* fix yaml test real

* Added full stop, ensured display of infection chance, buffed biosuit speed

* Maint reviews, I commit

* Review completed, winter coats nerfed, CMO bio suit removed for future PR

* Final-final commit-REAL (2)-COPY
This commit is contained in:
UpAndLeaves
2025-04-16 19:21:45 +01:00
committed by GitHub
parent c183231834
commit 1c7e6592e9
12 changed files with 153 additions and 34 deletions

View File

@@ -7,6 +7,7 @@ using Content.Server.Emoting.Systems;
using Content.Server.Speech.EntitySystems;
using Content.Server.Roles;
using Content.Shared.Anomaly.Components;
using Content.Shared.Armor;
using Content.Shared.Bed.Sleep;
using Content.Shared.Cloning.Events;
using Content.Shared.Damage;
@@ -74,7 +75,6 @@ namespace Content.Server.Zombies
SubscribeLocalEvent<IncurableZombieComponent, MapInitEvent>(OnPendingMapInit);
SubscribeLocalEvent<ZombifyOnDeathComponent, MobStateChangedEvent>(OnDamageChanged);
}
private void OnBeforeRemoveAnomalyOnDeath(Entity<PendingZombieComponent> ent, ref BeforeRemoveAnomalyOnDeathEvent args)
@@ -199,33 +199,29 @@ namespace Content.Server.Zombies
}
}
private float GetZombieInfectionChance(EntityUid uid, ZombieComponent component)
private float GetZombieInfectionChance(EntityUid uid, ZombieComponent zombieComponent)
{
var max = component.MaxZombieInfectionChance;
var chance = zombieComponent.BaseZombieInfectionChance;
if (!_inventory.TryGetContainerSlotEnumerator(uid, out var enumerator, ProtectiveSlots))
return max;
var items = 0f;
var total = 0f;
while (enumerator.MoveNext(out var con))
var armorEv = new CoefficientQueryEvent(ProtectiveSlots);
RaiseLocalEvent(uid, armorEv);
foreach (var resistanceEffectiveness in zombieComponent.ResistanceEffectiveness.DamageDict)
{
total++;
if (con.ContainedEntity != null)
items++;
if (armorEv.DamageModifiers.Coefficients.TryGetValue(resistanceEffectiveness.Key, out var coefficient))
{
// Scale the coefficient by the resistance effectiveness, very descriptive I know
// For example. With 30% slash resist (0.7 coeff), but only a 60% resistance effectiveness for slash,
// you'll end up with 1 - (0.3 * 0.6) = 0.82 coefficient, or a 18% resistance
var adjustedCoefficient = 1 - ((1 - coefficient) * resistanceEffectiveness.Value.Float());
chance *= adjustedCoefficient;
}
}
if (total == 0)
return max;
var zombificationResistanceEv = new ZombificationResistanceQueryEvent(ProtectiveSlots);
RaiseLocalEvent(uid, zombificationResistanceEv);
chance *= zombificationResistanceEv.TotalCoefficient;
// Everyone knows that when it comes to zombies, socks & sandals provide just as much protection as an
// armored vest. Maybe these should be weighted per-item. I.e. some kind of coverage/protection component.
// Or at the very least different weights per slot.
var min = component.MinZombieInfectionChance;
//gets a value between the max and min based on how many items the entity is wearing
var chance = (max - min) * ((total - items) / total) + min;
return chance;
return MathF.Max(chance, zombieComponent.MinZombieInfectionChance);
}
private void OnMeleeHit(EntityUid uid, ZombieComponent component, MeleeHitEvent args)