From 0b52ac93895eacb95369fb5a0e29dfd9f8ec4b33 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Mon, 29 Aug 2022 22:35:19 -0400 Subject: [PATCH] zombie event overhaul (#10874) --- .../GameTicking/Rules/ZombieRuleSystem.cs | 24 +++++------ .../StationEvents/Events/ZombieOutbreak.cs | 41 ------------------- Content.Server/Zombies/ZombieComponent.cs | 4 +- Content.Server/Zombies/ZombieSystem.cs | 8 ++-- Resources/Prototypes/GameRules/events.yml | 2 +- 5 files changed, 19 insertions(+), 60 deletions(-) delete mode 100644 Content.Server/StationEvents/Events/ZombieOutbreak.cs diff --git a/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs b/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs index d42effa334..ecb826cdca 100644 --- a/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs @@ -2,8 +2,8 @@ using System.Linq; using Content.Server.Actions; using Content.Server.Chat.Managers; using Content.Server.Disease; -using Content.Server.GameTicking.Rules.Configurations; using Content.Server.Mind.Components; +using Content.Server.MobState; using Content.Server.Players; using Content.Server.Popups; using Content.Server.Preferences.Managers; @@ -13,7 +13,6 @@ using Content.Server.Zombies; using Content.Shared.Actions.ActionTypes; using Content.Shared.CCVar; using Content.Shared.CharacterAppearance.Components; -using Content.Shared.FixedPoint; using Content.Shared.MobState; using Content.Shared.MobState.Components; using Content.Shared.Preferences; @@ -40,6 +39,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem [Dependency] private readonly DiseaseSystem _diseaseSystem = default!; [Dependency] private readonly PopupSystem _popup = default!; [Dependency] private readonly ActionsSystem _action = default!; + [Dependency] private readonly MobStateSystem _mobState = default!; [Dependency] private readonly ZombifyOnDeathSystem _zombify = default!; private Dictionary _initialInfectedNames = new(); @@ -90,8 +90,8 @@ public sealed class ZombieRuleSystem : GameRuleSystem ("username", player.Value))); } - ///Gets a bunch of the living players and displays them if they're under a threshold. - ///InitialInfected is used for the threshold because it scales with the player count well. + //Gets a bunch of the living players and displays them if they're under a threshold. + //InitialInfected is used for the threshold because it scales with the player count well. if (livingHumans.Count > 0 && livingHumans.Count <= _initialInfectedNames.Count) { ev.AddLine(""); @@ -203,16 +203,16 @@ public sealed class ZombieRuleSystem : GameRuleSystem livingHumans = new(); - foreach (var ent in allPlayers) + foreach (var (_, mob) in allPlayers) { - if (ent.Item2.IsAlive()) + if (_mobState.IsAlive(mob.Owner, mob)) { - totalPlayers.Add(ent.Item2.Owner); + totalPlayers.Add(mob.Owner); - if (allZombers.HasComponent(ent.Item1.Owner)) - livingZombies.Add(ent.Item2.Owner); + if (allZombers.HasComponent(mob.Owner)) + livingZombies.Add(mob.Owner); else - livingHumans.Add(ent.Item2.Owner); + livingHumans.Add(mob.Owner); } } return ((float) livingZombies.Count) / (float) totalPlayers.Count; @@ -300,8 +300,8 @@ public sealed class ZombieRuleSystem : GameRuleSystem var messageWrapper = Loc.GetString("chat-manager-server-wrap-message"); //gets the names now in case the players leave. - if (inCharacterName != null) - _initialInfectedNames.Add(inCharacterName, mind.Session.Name); + //this gets unhappy if people with the same name get chose. Probably shouldn't happen. + _initialInfectedNames.Add(inCharacterName, mind.Session.Name); // I went all the way to ChatManager.cs and all i got was this lousy T-shirt _chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Server, Loc.GetString("zombie-patientzero-role-greeting"), diff --git a/Content.Server/StationEvents/Events/ZombieOutbreak.cs b/Content.Server/StationEvents/Events/ZombieOutbreak.cs deleted file mode 100644 index 2b495b402f..0000000000 --- a/Content.Server/StationEvents/Events/ZombieOutbreak.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Content.Shared.MobState.Components; -using Content.Server.Zombies; - -namespace Content.Server.StationEvents.Events -{ - /// - /// Revives several dead entities as zombies - /// - public sealed class ZombieOutbreak : StationEventSystem - { - [Dependency] private readonly ZombifyOnDeathSystem _zombify = default!; - - public override string Prototype => "ZombieOutbreak"; - - /// - /// Finds 1-3 random, dead entities across the station - /// and turns them into zombies. - /// - public override void Started() - { - base.Started(); - List deadList = new(); - foreach (var mobState in EntityManager.EntityQuery()) - { - if (mobState.IsDead() || mobState.IsCritical()) - deadList.Add(mobState); - } - RobustRandom.Shuffle(deadList); - - var toInfect = RobustRandom.Next(1, 3); - - foreach (var target in deadList) - { - if (toInfect-- == 0) - break; - - _zombify.ZombifyEntity(target.Owner); - } - } - } -} diff --git a/Content.Server/Zombies/ZombieComponent.cs b/Content.Server/Zombies/ZombieComponent.cs index 7b00e87dfc..c762af82f5 100644 --- a/Content.Server/Zombies/ZombieComponent.cs +++ b/Content.Server/Zombies/ZombieComponent.cs @@ -18,14 +18,14 @@ namespace Content.Server.Zombies /// The baseline infection chance you have if you are completely nude /// [ViewVariables(VVAccess.ReadWrite)] - public float MaxZombieInfectionChance = 0.75f; + public float MaxZombieInfectionChance = 0.50f; /// /// The minimum infection chance possible. This is simply to prevent /// being invincible by bundling up. /// [ViewVariables(VVAccess.ReadWrite)] - public float MinZombieInfectionChance = 0.1f; + public float MinZombieInfectionChance = 0.05f; [ViewVariables(VVAccess.ReadWrite)] public float ZombieMovementSpeedDebuff = 0.75f; diff --git a/Content.Server/Zombies/ZombieSystem.cs b/Content.Server/Zombies/ZombieSystem.cs index 3022070f48..458894eb9f 100644 --- a/Content.Server/Zombies/ZombieSystem.cs +++ b/Content.Server/Zombies/ZombieSystem.cs @@ -61,7 +61,7 @@ namespace Content.Server.Zombies private float GetZombieInfectionChance(EntityUid uid, ZombieComponent component) { - float baseChance = component.MaxZombieInfectionChance; + var baseChance = component.MaxZombieInfectionChance; if (!TryComp(uid, out var inventoryComponent)) return baseChance; @@ -90,7 +90,7 @@ namespace Content.Server.Zombies var max = component.MaxZombieInfectionChance; var min = component.MinZombieInfectionChance; //gets a value between the max and min based on how many items the entity is wearing - float chance = (max-min) * ((total - items)/total) + min; + var chance = (max-min) * ((total - items)/total) + min; return chance; } @@ -102,7 +102,7 @@ namespace Content.Server.Zombies if (!args.HitEntities.Any()) return; - foreach (EntityUid entity in args.HitEntities) + foreach (var entity in args.HitEntities) { if (args.User == entity) continue; @@ -131,7 +131,7 @@ namespace Content.Server.Zombies } } - public void DoGroan(EntityUid uid, ActiveZombieComponent component) + private void DoGroan(EntityUid uid, ActiveZombieComponent component) { if (component.LastDamageGroanCooldown > 0) return; diff --git a/Resources/Prototypes/GameRules/events.yml b/Resources/Prototypes/GameRules/events.yml index f2849448d7..f438bf4633 100644 --- a/Resources/Prototypes/GameRules/events.yml +++ b/Resources/Prototypes/GameRules/events.yml @@ -158,7 +158,7 @@ id: ZombieOutbreak config: !type:StationEventRuleConfiguration - id: ZombieOutbreak + id: Zombie earliestStart: 50 weight: 2.5 endAfter: 1