zombie event overhaul (#10874)
This commit is contained in:
@@ -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<string, string> _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,7 +300,7 @@ 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)
|
||||
//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
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Server.Zombies;
|
||||
|
||||
namespace Content.Server.StationEvents.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Revives several dead entities as zombies
|
||||
/// </summary>
|
||||
public sealed class ZombieOutbreak : StationEventSystem
|
||||
{
|
||||
[Dependency] private readonly ZombifyOnDeathSystem _zombify = default!;
|
||||
|
||||
public override string Prototype => "ZombieOutbreak";
|
||||
|
||||
/// <summary>
|
||||
/// Finds 1-3 random, dead entities across the station
|
||||
/// and turns them into zombies.
|
||||
/// </summary>
|
||||
public override void Started()
|
||||
{
|
||||
base.Started();
|
||||
List<MobStateComponent> deadList = new();
|
||||
foreach (var mobState in EntityManager.EntityQuery<MobStateComponent>())
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,14 @@ namespace Content.Server.Zombies
|
||||
/// The baseline infection chance you have if you are completely nude
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float MaxZombieInfectionChance = 0.75f;
|
||||
public float MaxZombieInfectionChance = 0.50f;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum infection chance possible. This is simply to prevent
|
||||
/// being invincible by bundling up.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float MinZombieInfectionChance = 0.1f;
|
||||
public float MinZombieInfectionChance = 0.05f;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float ZombieMovementSpeedDebuff = 0.75f;
|
||||
|
||||
@@ -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<InventoryComponent>(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;
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
id: ZombieOutbreak
|
||||
config:
|
||||
!type:StationEventRuleConfiguration
|
||||
id: ZombieOutbreak
|
||||
id: Zombie
|
||||
earliestStart: 50
|
||||
weight: 2.5
|
||||
endAfter: 1
|
||||
|
||||
Reference in New Issue
Block a user