From 3ccf25210cb208011adc84c912def2c41d855973 Mon Sep 17 00:00:00 2001 From: Rane <60792108+Elijahrane@users.noreply.github.com> Date: Wed, 22 Jun 2022 19:25:48 -0400 Subject: [PATCH] Natural immunities (#9026) --- .../Components/DiseaseCarrierComponent.cs | 8 ++++++++ Content.Server/Disease/DiseaseSystem.cs | 20 +++++++++++++++++++ Resources/Prototypes/Damage/modifier_sets.yml | 1 + .../Entities/Mobs/Species/slime.yml | 4 ++++ 4 files changed, 33 insertions(+) diff --git a/Content.Server/Disease/Components/DiseaseCarrierComponent.cs b/Content.Server/Disease/Components/DiseaseCarrierComponent.cs index 56c71b46bc..ac916aff24 100644 --- a/Content.Server/Disease/Components/DiseaseCarrierComponent.cs +++ b/Content.Server/Disease/Components/DiseaseCarrierComponent.cs @@ -44,5 +44,13 @@ namespace Content.Server.Disease.Components /// [ViewVariables, DataField("carrierDiseases", customTypeSerializer: typeof(PrototypeIdHashSetSerializer))] public HashSet? CarrierDiseases; + + /// + /// When this component is initialized, + /// these diseases will be added to past diseases, + /// rendering them immune. + /// + [DataField("naturalImmunities")] + public List? NaturalImmunities; } } diff --git a/Content.Server/Disease/DiseaseSystem.cs b/Content.Server/Disease/DiseaseSystem.cs index f55ee6b03d..3e4dc03aa8 100644 --- a/Content.Server/Disease/DiseaseSystem.cs +++ b/Content.Server/Disease/DiseaseSystem.cs @@ -39,6 +39,7 @@ namespace Content.Server.Disease public override void Initialize() { base.Initialize(); + SubscribeLocalEvent(OnInit); SubscribeLocalEvent(OnTryCureDisease); SubscribeLocalEvent(OnInteractDiseasedHand); SubscribeLocalEvent(OnInteractDiseasedUsing); @@ -127,6 +128,25 @@ namespace Content.Server.Disease /// Event Handlers /// + /// + /// Fill in the natural immunities of this entity. + /// + private void OnInit(EntityUid uid, DiseaseCarrierComponent component, ComponentInit args) + { + if (component.NaturalImmunities == null || component.NaturalImmunities.Count == 0) + return; + + foreach (var immunity in component.NaturalImmunities) + { + if (_prototypeManager.TryIndex(immunity, out var disease)) + component.PastDiseases.Add(disease); + else + { + Logger.Error("Failed to index disease prototype + " + immunity + " for " + uid); + } + } + } + /// /// Used when something is trying to cure ANY disease on the target, /// not for special disease interactions. Randomly diff --git a/Resources/Prototypes/Damage/modifier_sets.yml b/Resources/Prototypes/Damage/modifier_sets.yml index 12f82c7923..8444bb30cb 100644 --- a/Resources/Prototypes/Damage/modifier_sets.yml +++ b/Resources/Prototypes/Damage/modifier_sets.yml @@ -86,6 +86,7 @@ Piercing: 1.2 Cold: 1.5 Poison: 0.8 + Cellular: 0.2 - type: damageModifierSet id: Infernal diff --git a/Resources/Prototypes/Entities/Mobs/Species/slime.yml b/Resources/Prototypes/Entities/Mobs/Species/slime.yml index 128b87fc88..b1e6825e3a 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/slime.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/slime.yml @@ -155,6 +155,10 @@ types: Asphyxiation: -1.0 maxSaturation: 15 + - type: DiseaseCarrier + naturalImmunities: + - Ultragigacancer + - BleedersBite - type: entity save: false