zombie event overhaul (#10874)
This commit is contained in:
@@ -2,8 +2,8 @@ using System.Linq;
|
|||||||
using Content.Server.Actions;
|
using Content.Server.Actions;
|
||||||
using Content.Server.Chat.Managers;
|
using Content.Server.Chat.Managers;
|
||||||
using Content.Server.Disease;
|
using Content.Server.Disease;
|
||||||
using Content.Server.GameTicking.Rules.Configurations;
|
|
||||||
using Content.Server.Mind.Components;
|
using Content.Server.Mind.Components;
|
||||||
|
using Content.Server.MobState;
|
||||||
using Content.Server.Players;
|
using Content.Server.Players;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Preferences.Managers;
|
using Content.Server.Preferences.Managers;
|
||||||
@@ -13,7 +13,6 @@ using Content.Server.Zombies;
|
|||||||
using Content.Shared.Actions.ActionTypes;
|
using Content.Shared.Actions.ActionTypes;
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.CharacterAppearance.Components;
|
using Content.Shared.CharacterAppearance.Components;
|
||||||
using Content.Shared.FixedPoint;
|
|
||||||
using Content.Shared.MobState;
|
using Content.Shared.MobState;
|
||||||
using Content.Shared.MobState.Components;
|
using Content.Shared.MobState.Components;
|
||||||
using Content.Shared.Preferences;
|
using Content.Shared.Preferences;
|
||||||
@@ -40,6 +39,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem
|
|||||||
[Dependency] private readonly DiseaseSystem _diseaseSystem = default!;
|
[Dependency] private readonly DiseaseSystem _diseaseSystem = default!;
|
||||||
[Dependency] private readonly PopupSystem _popup = default!;
|
[Dependency] private readonly PopupSystem _popup = default!;
|
||||||
[Dependency] private readonly ActionsSystem _action = default!;
|
[Dependency] private readonly ActionsSystem _action = default!;
|
||||||
|
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||||
[Dependency] private readonly ZombifyOnDeathSystem _zombify = default!;
|
[Dependency] private readonly ZombifyOnDeathSystem _zombify = default!;
|
||||||
|
|
||||||
private Dictionary<string, string> _initialInfectedNames = new();
|
private Dictionary<string, string> _initialInfectedNames = new();
|
||||||
@@ -90,8 +90,8 @@ public sealed class ZombieRuleSystem : GameRuleSystem
|
|||||||
("username", player.Value)));
|
("username", player.Value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
///Gets a bunch of the living players and displays them if they're under a threshold.
|
//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.
|
//InitialInfected is used for the threshold because it scales with the player count well.
|
||||||
if (livingHumans.Count > 0 && livingHumans.Count <= _initialInfectedNames.Count)
|
if (livingHumans.Count > 0 && livingHumans.Count <= _initialInfectedNames.Count)
|
||||||
{
|
{
|
||||||
ev.AddLine("");
|
ev.AddLine("");
|
||||||
@@ -203,16 +203,16 @@ public sealed class ZombieRuleSystem : GameRuleSystem
|
|||||||
|
|
||||||
livingHumans = new();
|
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))
|
if (allZombers.HasComponent(mob.Owner))
|
||||||
livingZombies.Add(ent.Item2.Owner);
|
livingZombies.Add(mob.Owner);
|
||||||
else
|
else
|
||||||
livingHumans.Add(ent.Item2.Owner);
|
livingHumans.Add(mob.Owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ((float) livingZombies.Count) / (float) totalPlayers.Count;
|
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");
|
var messageWrapper = Loc.GetString("chat-manager-server-wrap-message");
|
||||||
|
|
||||||
//gets the names now in case the players leave.
|
//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);
|
_initialInfectedNames.Add(inCharacterName, mind.Session.Name);
|
||||||
|
|
||||||
// I went all the way to ChatManager.cs and all i got was this lousy T-shirt
|
// 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
|
/// The baseline infection chance you have if you are completely nude
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public float MaxZombieInfectionChance = 0.75f;
|
public float MaxZombieInfectionChance = 0.50f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The minimum infection chance possible. This is simply to prevent
|
/// The minimum infection chance possible. This is simply to prevent
|
||||||
/// being invincible by bundling up.
|
/// being invincible by bundling up.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public float MinZombieInfectionChance = 0.1f;
|
public float MinZombieInfectionChance = 0.05f;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public float ZombieMovementSpeedDebuff = 0.75f;
|
public float ZombieMovementSpeedDebuff = 0.75f;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace Content.Server.Zombies
|
|||||||
|
|
||||||
private float GetZombieInfectionChance(EntityUid uid, ZombieComponent component)
|
private float GetZombieInfectionChance(EntityUid uid, ZombieComponent component)
|
||||||
{
|
{
|
||||||
float baseChance = component.MaxZombieInfectionChance;
|
var baseChance = component.MaxZombieInfectionChance;
|
||||||
|
|
||||||
if (!TryComp<InventoryComponent>(uid, out var inventoryComponent))
|
if (!TryComp<InventoryComponent>(uid, out var inventoryComponent))
|
||||||
return baseChance;
|
return baseChance;
|
||||||
@@ -90,7 +90,7 @@ namespace Content.Server.Zombies
|
|||||||
var max = component.MaxZombieInfectionChance;
|
var max = component.MaxZombieInfectionChance;
|
||||||
var min = component.MinZombieInfectionChance;
|
var min = component.MinZombieInfectionChance;
|
||||||
//gets a value between the max and min based on how many items the entity is wearing
|
//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;
|
return chance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ namespace Content.Server.Zombies
|
|||||||
if (!args.HitEntities.Any())
|
if (!args.HitEntities.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (EntityUid entity in args.HitEntities)
|
foreach (var entity in args.HitEntities)
|
||||||
{
|
{
|
||||||
if (args.User == entity)
|
if (args.User == entity)
|
||||||
continue;
|
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)
|
if (component.LastDamageGroanCooldown > 0)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -158,7 +158,7 @@
|
|||||||
id: ZombieOutbreak
|
id: ZombieOutbreak
|
||||||
config:
|
config:
|
||||||
!type:StationEventRuleConfiguration
|
!type:StationEventRuleConfiguration
|
||||||
id: ZombieOutbreak
|
id: Zombie
|
||||||
earliestStart: 50
|
earliestStart: 50
|
||||||
weight: 2.5
|
weight: 2.5
|
||||||
endAfter: 1
|
endAfter: 1
|
||||||
|
|||||||
Reference in New Issue
Block a user