Zombie Mode [New Game Mode] (#8501)
Co-authored-by: Kara <lunarautomaton6@gmail.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Zombies
|
||||
{
|
||||
[RegisterComponent]
|
||||
@@ -7,6 +11,44 @@ namespace Content.Server.Zombies
|
||||
/// The coefficient of the damage reduction applied when a zombie
|
||||
/// attacks another zombie. longe name
|
||||
/// </summary>
|
||||
public float OtherZombieDamageCoefficient = 0.75f;
|
||||
[ViewVariables]
|
||||
public float OtherZombieDamageCoefficient = 0.5f;
|
||||
|
||||
/// <summary>
|
||||
/// The baseline infection chance you have if you are completely nude
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public float MaxZombieInfectionChance = 0.75f;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum infection chance possible. This is simply to prevent
|
||||
/// being invincible by bundling up.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public float MinZombieInfectionChance = 0.1f;
|
||||
|
||||
/// <summary>
|
||||
/// The skin color of the zombie
|
||||
/// </summary>
|
||||
[ViewVariables, DataField("skinColor")]
|
||||
public Color SkinColor = new(0.45f, 0.51f, 0.29f);
|
||||
|
||||
/// <summary>
|
||||
/// The eye color of the zombie
|
||||
/// </summary>
|
||||
[ViewVariables, DataField("eyeColor")]
|
||||
public Color EyeColor = new(0.96f, 0.13f, 0.24f);
|
||||
|
||||
/// <summary>
|
||||
/// The attack arc of the zombie
|
||||
/// </summary>
|
||||
[ViewVariables, DataField("attackArc", customTypeSerializer: typeof(PrototypeIdSerializer<MeleeWeaponAnimationPrototype>))]
|
||||
public string AttackArc = "claw";
|
||||
|
||||
/// <summary>
|
||||
/// The role prototype of the zombie antag role
|
||||
/// </summary>
|
||||
[ViewVariables, DataField("zombieRoldId", customTypeSerializer: typeof(PrototypeIdSerializer<AntagPrototype>))]
|
||||
public readonly string ZombieRoleId = "Zombie";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,11 @@ using Content.Server.Weapon.Melee;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Server.Disease;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Server.Popups;
|
||||
using Robust.Shared.Player;
|
||||
using Content.Server.Inventory;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Zombies
|
||||
{
|
||||
@@ -15,13 +20,52 @@ namespace Content.Server.Zombies
|
||||
[Dependency] private readonly DiseaseSystem _disease = default!;
|
||||
[Dependency] private readonly BloodstreamSystem _bloodstream = default!;
|
||||
[Dependency] private readonly ZombifyOnDeathSystem _zombify = default!;
|
||||
[Dependency] private readonly ServerInventorySystem _inv = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<ZombieComponent, MeleeHitEvent>(OnMeleeHit);
|
||||
}
|
||||
|
||||
private float GetZombieInfectionChance(EntityUid uid, ZombieComponent component)
|
||||
{
|
||||
float baseChance = component.MaxZombieInfectionChance;
|
||||
|
||||
if (!TryComp<InventoryComponent>(uid, out var inventoryComponent))
|
||||
return baseChance;
|
||||
|
||||
var enumerator =
|
||||
new InventorySystem.ContainerSlotEnumerator(uid, inventoryComponent.TemplateId, _protoManager, _inv,
|
||||
SlotFlags.FEET |
|
||||
SlotFlags.HEAD |
|
||||
SlotFlags.EYES |
|
||||
SlotFlags.GLOVES |
|
||||
SlotFlags.MASK |
|
||||
SlotFlags.NECK |
|
||||
SlotFlags.INNERCLOTHING |
|
||||
SlotFlags.OUTERCLOTHING);
|
||||
|
||||
var items = 0f;
|
||||
var total = 0f;
|
||||
while (enumerator.MoveNext(out var con))
|
||||
{
|
||||
total++;
|
||||
|
||||
if (con.ContainedEntity != null)
|
||||
items++;
|
||||
}
|
||||
|
||||
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;
|
||||
return chance;
|
||||
}
|
||||
|
||||
private void OnMeleeHit(EntityUid uid, ZombieComponent component, MeleeHitEvent args)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent<ZombieComponent>(args.User, out var zombieComp))
|
||||
@@ -38,11 +82,11 @@ namespace Content.Server.Zombies
|
||||
if (!TryComp<MobStateComponent>(entity, out var mobState) || HasComp<DroneComponent>(entity))
|
||||
continue;
|
||||
|
||||
if (_robustRandom.Prob(0.5f) && HasComp<DiseaseCarrierComponent>(entity))
|
||||
if (HasComp<DiseaseCarrierComponent>(entity) && _robustRandom.Prob(GetZombieInfectionChance(entity, component)))
|
||||
_disease.TryAddDisease(entity, "ActiveZombieVirus");
|
||||
|
||||
if (HasComp<ZombieComponent>(entity))
|
||||
args.BonusDamage = args.BaseDamage * zombieComp.OtherZombieDamageCoefficient;
|
||||
args.BonusDamage = -args.BaseDamage * zombieComp.OtherZombieDamageCoefficient;
|
||||
|
||||
if ((mobState.IsDead() || mobState.IsCritical())
|
||||
&& !HasComp<ZombieComponent>(entity))
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Zombies
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class ZombifyOnDeathComponent : Component
|
||||
{
|
||||
[DataField("skinColor")]
|
||||
public Color SkinColor = new Color(0.70f, 0.72f, 0.48f, 1);
|
||||
|
||||
[DataField("attackArc", customTypeSerializer: typeof(PrototypeIdSerializer<MeleeWeaponAnimationPrototype>))]
|
||||
public string AttackArc = "claw";
|
||||
//this is not the component you are looking for
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,16 +20,23 @@ using Content.Server.Hands.Components;
|
||||
using Content.Server.Mind.Commands;
|
||||
using Content.Server.Temperature.Components;
|
||||
using Content.Server.Weapon.Melee.Components;
|
||||
using Content.Server.Disease;
|
||||
using Robust.Shared.Containers;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.MobState;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Server.Traitor;
|
||||
using Content.Shared.Zombies;
|
||||
using Content.Server.Atmos.Miasma;
|
||||
|
||||
namespace Content.Server.Zombies
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles zombie propagation and inherent zombie traits
|
||||
/// Handles zombie propagation and inherent zombie traits
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Don't Shitcode Open Inside
|
||||
/// </remarks>
|
||||
public sealed class ZombifyOnDeathSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedHandsSystem _sharedHands = default!;
|
||||
@@ -37,9 +44,9 @@ namespace Content.Server.Zombies
|
||||
[Dependency] private readonly BloodstreamSystem _bloodstream = default!;
|
||||
[Dependency] private readonly ServerInventorySystem _serverInventory = default!;
|
||||
[Dependency] private readonly DamageableSystem _damageable = default!;
|
||||
[Dependency] private readonly DiseaseSystem _disease = default!;
|
||||
[Dependency] private readonly SharedHumanoidAppearanceSystem _sharedHuApp = default!;
|
||||
[Dependency] private readonly IChatManager _chatMan = default!;
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -53,95 +60,135 @@ namespace Content.Server.Zombies
|
||||
/// </summary>
|
||||
private void OnDamageChanged(EntityUid uid, ZombifyOnDeathComponent component, MobStateChangedEvent args)
|
||||
{
|
||||
if (!TryComp<MobStateComponent>(uid, out var mobstate))
|
||||
return;
|
||||
|
||||
if (mobstate.IsDead() ||
|
||||
mobstate.IsCritical())
|
||||
if (args.CurrentMobState.IsDead() ||
|
||||
args.CurrentMobState.IsCritical())
|
||||
{
|
||||
ZombifyEntity(uid);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the general purpose function to call if you want to zombify an entity.
|
||||
/// It handles both humanoid and nonhumanoid transformation.
|
||||
/// This is the general purpose function to call if you want to zombify an entity.
|
||||
/// It handles both humanoid and nonhumanoid transformation and everything should be called through it.
|
||||
/// </summary>
|
||||
/// <param name="target">the entity being zombified</param>
|
||||
/// <remarks>
|
||||
/// ALRIGHT BIG BOY. YOU'VE COME TO THE LAYER OF THE BEAST. THIS IS YOUR WARNING.
|
||||
/// This function is the god function for zombie stuff, and it is cursed. I have
|
||||
/// attempted to label everything thouroughly for your sanity. I have attempted to
|
||||
/// rewrite this, but this is how it shall lie eternal. Turn back now.
|
||||
/// -emo
|
||||
/// </remarks>
|
||||
public void ZombifyEntity(EntityUid target)
|
||||
{
|
||||
//Don't zombfiy zombies
|
||||
if (HasComp<ZombieComponent>(target))
|
||||
return;
|
||||
|
||||
_disease.CureAllDiseases(target);
|
||||
//you're a real zombie now, son.
|
||||
var zombiecomp = AddComp<ZombieComponent>(target);
|
||||
|
||||
///we need to basically remove all of these because zombies shouldn't
|
||||
///get diseases, breath, be thirst, be hungry, or die in space
|
||||
RemComp<DiseaseCarrierComponent>(target);
|
||||
RemComp<RespiratorComponent>(target);
|
||||
RemComp<BarotraumaComponent>(target);
|
||||
RemComp<HungerComponent>(target);
|
||||
RemComp<ThirstComponent>(target);
|
||||
|
||||
var zombiecomp = EnsureComp<ZombifyOnDeathComponent>(target);
|
||||
if (TryComp<HumanoidAppearanceComponent>(target, out var huApComp))
|
||||
{
|
||||
var appearance = huApComp.Appearance;
|
||||
_sharedHuApp.UpdateAppearance(target, appearance.WithSkinColor(zombiecomp.SkinColor), huApComp);
|
||||
_sharedHuApp.ForceAppearanceUpdate(target, huApComp);
|
||||
}
|
||||
|
||||
if (!HasComp<SharedDummyInputMoverComponent>(target))
|
||||
MakeSentientCommand.MakeSentient(target, EntityManager);
|
||||
|
||||
//funny voice
|
||||
EnsureComp<ReplacementAccentComponent>(target).Accent = "zombie";
|
||||
EnsureComp<RottingComponent>(target);
|
||||
|
||||
//funny add delet go brrr
|
||||
///This is needed for stupid entities that fuck up combat mode component
|
||||
///in an attempt to make an entity not attack. This is the easiest way to do it.
|
||||
RemComp<CombatModeComponent>(target);
|
||||
AddComp<CombatModeComponent>(target);
|
||||
|
||||
///This is the actual damage of the zombie. We assign the visual appearance
|
||||
///and range here because of stuff we'll find out later
|
||||
var melee = EnsureComp<MeleeWeaponComponent>(target);
|
||||
melee.Arc = zombiecomp.AttackArc;
|
||||
melee.ClickArc = zombiecomp.AttackArc;
|
||||
//lord forgive me for the hardcoded damage
|
||||
DamageSpecifier dspec = new();
|
||||
dspec.DamageDict.Add("Slash", 13);
|
||||
dspec.DamageDict.Add("Piercing", 7);
|
||||
melee.Damage = dspec;
|
||||
melee.Range = 0.75f;
|
||||
|
||||
//We have specific stuff for humanoid zombies because they matter more
|
||||
if (TryComp<HumanoidAppearanceComponent>(target, out var huApComp)) //huapcomp
|
||||
{
|
||||
//this bs is done because you can't directly update humanoid appearances
|
||||
var appearance = huApComp.Appearance;
|
||||
appearance = appearance.WithSkinColor(zombiecomp.SkinColor).WithEyeColor(zombiecomp.EyeColor);
|
||||
_sharedHuApp.UpdateAppearance(target, appearance, huApComp);
|
||||
_sharedHuApp.ForceAppearanceUpdate(target, huApComp);
|
||||
|
||||
///This is done here because non-humanoids shouldn't get baller damage
|
||||
///lord forgive me for the hardcoded damage
|
||||
DamageSpecifier dspec = new();
|
||||
dspec.DamageDict.Add("Slash", 13);
|
||||
dspec.DamageDict.Add("Piercing", 7);
|
||||
melee.Damage = dspec;
|
||||
}
|
||||
|
||||
//The zombie gets the assigned damage weaknesses and strengths
|
||||
_damageable.SetDamageModifierSetId(target, "Zombie");
|
||||
|
||||
///This makes it so the zombie doesn't take bloodloss damage.
|
||||
///NOTE: they are supposed to bleed, just not take damage
|
||||
_bloodstream.SetBloodLossThreshold(target, 0f);
|
||||
|
||||
_popupSystem.PopupEntity(Loc.GetString("zombie-transform", ("target", target)), target, Filter.Pvs(target));
|
||||
//This is specifically here to combat insuls, because frying zombies on grilles is funny as shit.
|
||||
_serverInventory.TryUnequip(target, "gloves", true, true);
|
||||
|
||||
//popup
|
||||
_popupSystem.PopupEntity(Loc.GetString("zombie-transform", ("target", target)), target, Filter.Pvs(target));
|
||||
|
||||
//Make it sentient if it's an animal or something
|
||||
if (!HasComp<SharedDummyInputMoverComponent>(target)) //this component is cursed and fucks shit up
|
||||
MakeSentientCommand.MakeSentient(target, EntityManager);
|
||||
|
||||
//Make the zombie not die in the cold. Good for space zombies
|
||||
if (TryComp<TemperatureComponent>(target, out var tempComp))
|
||||
tempComp.ColdDamage.ClampMax(0);
|
||||
|
||||
//Heals the zombie from all the damage it took while human
|
||||
if (TryComp<DamageableComponent>(target, out var damageablecomp))
|
||||
_damageable.SetAllDamage(damageablecomp, 0);
|
||||
|
||||
//gives it the funny "Zombie ___" name.
|
||||
if (TryComp<MetaDataComponent>(target, out var meta))
|
||||
meta.EntityName = Loc.GetString("zombie-name-prefix", ("target", meta.EntityName));
|
||||
|
||||
//He's gotta have a mind
|
||||
var mindcomp = EnsureComp<MindComponent>(target);
|
||||
if (mindcomp.Mind != null && mindcomp.Mind.TryGetSession(out var session))
|
||||
_chatMan.DispatchServerMessage(session, Loc.GetString("zombie-infection-greeting"));
|
||||
{
|
||||
//Zombie role for player manifest
|
||||
mindcomp.Mind.AddRole(new TraitorRole(mindcomp.Mind, _proto.Index<AntagPrototype>(zombiecomp.ZombieRoleId)));
|
||||
//Greeting message for new bebe zombers
|
||||
_chatMan.DispatchServerMessage(session, Loc.GetString("zombie-infection-greeting"));
|
||||
}
|
||||
|
||||
if (!HasComp<GhostRoleMobSpawnerComponent>(target) && !mindcomp.HasMind) //this specific component gives build test trouble so pop off, ig
|
||||
{
|
||||
//yet more hardcoding. Visit zombie.ftl for more information.
|
||||
EntityManager.EnsureComponent<GhostTakeoverAvailableComponent>(target, out var ghostcomp);
|
||||
ghostcomp.RoleName = Loc.GetString("zombie-generic");
|
||||
ghostcomp.RoleDescription = Loc.GetString("zombie-role-desc");
|
||||
ghostcomp.RoleRules = Loc.GetString("zombie-role-rules");
|
||||
}
|
||||
|
||||
///Goes through every hand, drops the items in it, then removes the hand
|
||||
///may become the source of various bugs.
|
||||
foreach (var hand in _sharedHands.EnumerateHands(target))
|
||||
{
|
||||
_sharedHands.SetActiveHand(target, hand);
|
||||
hand.Container?.EmptyContainer();
|
||||
_sharedHands.DoDrop(target, hand);
|
||||
_sharedHands.RemoveHand(target, hand.Name);
|
||||
}
|
||||
RemComp<HandsComponent>(target);
|
||||
|
||||
EnsureComp<ZombieComponent>(target);
|
||||
//zombie gamemode stuff
|
||||
RaiseLocalEvent(new EntityZombifiedEvent(target));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user