Skip to content

Commit

Permalink
MEGA UPDATE DRAGON!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
Lemirda committed Mar 19, 2024
1 parent 26177d3 commit cc0c891
Show file tree
Hide file tree
Showing 8 changed files with 298 additions and 44 deletions.
8 changes: 8 additions & 0 deletions Content.Server/Body/Systems/BloodstreamSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Devour; //A-13 Dragon fix full
using Content.Shared.Drunk;
using Content.Shared.FixedPoint;
using Content.Shared.IdentityManagement;
Expand Down Expand Up @@ -51,6 +52,7 @@ public override void Initialize()
SubscribeLocalEvent<BloodstreamComponent, ReactionAttemptEvent>(OnReactionAttempt);
SubscribeLocalEvent<BloodstreamComponent, SolutionRelayEvent<ReactionAttemptEvent>>(OnReactionAttempt);
SubscribeLocalEvent<BloodstreamComponent, RejuvenateEvent>(OnRejuvenate);
SubscribeLocalEvent<BloodstreamComponent, DevouredEvent>(OnDevoured); //A-13 Dragon fix full
}

private void OnReactionAttempt(Entity<BloodstreamComponent> entity, ref ReactionAttemptEvent args)
Expand Down Expand Up @@ -269,6 +271,12 @@ private void OnRejuvenate(Entity<BloodstreamComponent> entity, ref RejuvenateEve
if (_solutionContainerSystem.ResolveSolution(entity.Owner, entity.Comp.ChemicalSolutionName, ref entity.Comp.ChemicalSolution))
_solutionContainerSystem.RemoveAllSolution(entity.Comp.ChemicalSolution.Value);
}
//A-13 Dragon fix full start
private void OnDevoured(Entity<BloodstreamComponent> entity, ref DevouredEvent args)
{
entity.Comp.BleedAmount = 0;
}
//A-13 Dragon fix full end

/// <summary>
/// Attempt to transfer provided solution to internal solution.
Expand Down
58 changes: 43 additions & 15 deletions Content.Server/Devour/DevourSystem.cs
Original file line number Diff line number Diff line change
@@ -1,49 +1,77 @@
using Content.Server.Body.Systems;
using Content.Shared.Chemistry.Components;
using Content.Server.Body.Components; //A-13 Dragon fix full
using Content.Shared.Damage.Components; //A-13 Dragon fix full
using Content.Shared.Devour;
using Content.Shared.Devour.Components;
using Content.Shared.Humanoid;
using Content.Shared.Mobs.Components; //A-13 Dragon fix full

namespace Content.Server.Devour;

public sealed class DevourSystem : SharedDevourSystem
{
[Dependency] private readonly BloodstreamSystem _bloodstreamSystem = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<DevourerComponent, DevourDoAfterEvent>(OnDoAfter);
SubscribeLocalEvent<DevourerComponent, BeingGibbedEvent>(OnBeingGibbed); //A-13 Dragon fix full
SubscribeLocalEvent<DevourerComponent, ComponentRemove>(OnRemoved); //A-13 Dragon fix full
}

private void OnDoAfter(EntityUid uid, DevourerComponent component, DevourDoAfterEvent args)
{
if (args.Handled || args.Cancelled)
return;

var ichorInjection = new Solution(component.Chemical, component.HealRate);

if (component.FoodPreference == FoodPreference.All ||
(component.FoodPreference == FoodPreference.Humanoid && HasComp<HumanoidAppearanceComponent>(args.Args.Target)))
//A-13 Dragon fix full start
if (component.ShouldStoreDevoured && HasComp<MobStateComponent>(args.Args.Target))
{
ichorInjection.ScaleSolution(0.5f);
ContainerSystem.Insert(args.Args.Target.Value, component.Stomach);

if (component.ShouldStoreDevoured && args.Args.Target is not null)
EnsureComp<DevouredComponent>(args.Args.Target.Value);

var ev = new DevouredEvent(uid);
RaiseLocalEvent(args.Args.Target.Value, ref ev);
}

if (component.FoodPreference == FoodPreference.All || component.FoodPreference == FoodPreference.Humanoid && HasComp<HumanoidAppearanceComponent>(args.Args.Target))
{
if (TryComp<PassiveDamageComponent>(uid, out var passiveHealing))
{
ContainerSystem.Insert(args.Args.Target.Value, component.Stomach);
if (component.PassiveDevourHealing != null)
{
passiveHealing.Damage += component.PassiveDevourHealing;
}
}
_bloodstreamSystem.TryAddToChemicals(uid, ichorInjection);
}
//A-13 Dragon fix full end

//TODO: Figure out a better way of removing structures via devour that still entails standing still and waiting for a DoAfter. Somehow.
//If it's not human, it must be a structure
//If it does not have a mobState, it must be a structure
else if (args.Args.Target != null)
{
QueueDel(args.Args.Target.Value);
}

_audioSystem.PlayPvs(component.SoundDevour, uid);
AudioSystem.PlayPvs(component.SoundDevour, uid); //A-13 Dragon fix full
}
//A-13 Dragon fix full start
public void EmptyStomach(EntityUid uid, DevourerComponent component)
{
foreach (var entity in component.Stomach.ContainedEntities)
{
RemComp<DevouredComponent>(entity);
}
ContainerSystem.EmptyContainer(component.Stomach);
}
}

private void OnBeingGibbed(EntityUid uid, DevourerComponent component, BeingGibbedEvent args)
{
EmptyStomach(uid, component);
}
private void OnRemoved(EntityUid uid, DevourerComponent component, ComponentRemove args)
{
EmptyStomach(uid, component);
}
//A-13 Dragon fix full end
}
6 changes: 5 additions & 1 deletion Content.Server/Zombies/ZombieSystem.Transform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Content.Shared.CombatMode;
using Content.Shared.CombatMode.Pacification;
using Content.Shared.Damage;
using Content.Shared.Devour.Components; //A-13 Dragon fix full
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.CombatMode.Pacification;
Expand Down Expand Up @@ -117,7 +118,10 @@ public void ZombifyEntity(EntityUid target, MobStateComponent? mobState = null)
//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.
var combat = EnsureComp<CombatModeComponent>(target);
RemComp<PacifiedComponent>(target);
//A-13 Dragon fix full start
if (!HasComp<DevouredComponent>(target))
RemComp<PacifiedComponent>(target);
//A-13 Dragon fix full end
_combat.SetCanDisarm(target, false, combat);
_combat.SetInCombatMode(target, true, combat);

Expand Down
55 changes: 55 additions & 0 deletions Content.Shared/Devour/Components/DevouredComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Content.Shared.Damage;
using Content.Shared.FixedPoint;
using Content.Shared.Mobs;
using Robust.Shared.GameStates;

namespace Content.Shared.Devour.Components;

[RegisterComponent, NetworkedComponent]
[Access(typeof(DevouredSystem))]
public sealed partial class DevouredComponent : Component
{
/// <summary>
/// Stores the original MobStates the entity was allowed to be healed in.
/// This is so it can be returned to it's original state when the component is removed.
/// </summary>
[DataField]
public List<MobState>? OriginalAllowedMobStates;

/// <summary>
/// Stores the stomach damage so it can be deducted from the devoured entity when the damage is altered.
/// </summary>
[DataField]
public DamageSpecifier? StomachDamage;

/// <summary>
/// How much extra damage can be done to the entity after it has died.
/// </summary>
[DataField]
public FixedPoint2 DamageCap = 100;

/// <summary>
/// Stores the current damage modifier.
/// This is to make sure the correct amount of damage is changed.
/// </summary>
[DataField]
public FixedPoint2 CurrentModifier;

/// <summary>
/// Damage multiplier if the devoured entity is alive.
/// </summary>
[DataField]
public FixedPoint2 AliveMultiplier = 5;

/// <summary>
/// Damage multiplier if the devoured entity is critical.
/// </summary>
[DataField]
public FixedPoint2 CritMultiplier = 1;

/// <summary>
/// Damage multiplier if the devoured entity is dead.
/// </summary>
[DataField]
public FixedPoint2 DeadMultiplier = 0.25;
}
47 changes: 26 additions & 21 deletions Content.Shared/Devour/Components/DevourerComponent.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Damage; //A-13 Dragon fix full
using Content.Shared.Mobs; //A-13 Dragon fix full
using Content.Shared.Whitelist;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Shared.Devour.Components;

[RegisterComponent, NetworkedComponent]
[Access(typeof(SharedDevourSystem))]
public sealed partial class DevourerComponent : Component
{
[DataField("devourAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? DevourAction = "ActionDevour";
[DataField] //A-13 Dragon fix full
public ProtoId<EntityPrototype> DevourAction = "ActionDevour"; //A-13 Dragon fix full

[DataField("devourActionEntity")]
[DataField] //A-13 Dragon fix full
public EntityUid? DevourActionEntity;

[ViewVariables(VVAccess.ReadWrite), DataField("soundDevour")]
[ViewVariables(VVAccess.ReadWrite), DataField] //A-13 Dragon fix full
public SoundSpecifier? SoundDevour = new SoundPathSpecifier("/Audio/Effects/demon_consume.ogg")
{
Params = AudioParams.Default.WithVolume(-3f),
};

[DataField("devourTime")]
[ViewVariables(VVAccess.ReadWrite), DataField] //A-13 Dragon fix full
public float DevourTime = 3f;

/// <summary>
Expand All @@ -33,10 +33,10 @@ public sealed partial class DevourerComponent : Component
/// NOTE: original intended design was to increase this proportionally with damage thresholds, but those proved quite difficult to get consistently. right now it devours the structure at a fixed timer.
/// </remarks>
/// </summary>
[DataField("structureDevourTime")]
[ViewVariables(VVAccess.ReadWrite), DataField] //A-13 Dragon fix full
public float StructureDevourTime = 10f;

[ViewVariables(VVAccess.ReadWrite), DataField("soundStructureDevour")]
[ViewVariables(VVAccess.ReadWrite), DataField] //A-13 Dragon fix full
public SoundSpecifier? SoundStructureDevour = new SoundPathSpecifier("/Audio/Machines/airlock_creaking.ogg")
{
Params = AudioParams.Default.WithVolume(-3f),
Expand All @@ -47,10 +47,10 @@ public sealed partial class DevourerComponent : Component
/// </summary>
public Container Stomach = default!;

[ViewVariables(VVAccess.ReadWrite), DataField("shouldStoreDevoured")]
[ViewVariables(VVAccess.ReadWrite), DataField] //A-13 Dragon fix full
public bool ShouldStoreDevoured = true;

[ViewVariables(VVAccess.ReadWrite), DataField("whitelist")]
[ViewVariables(VVAccess.ReadWrite), DataField] //A-13 Dragon fix full
public EntityWhitelist? Whitelist = new()
{
Components = new[]
Expand All @@ -60,21 +60,26 @@ public sealed partial class DevourerComponent : Component
};

/// <summary>
/// The chemical ID injected upon devouring
/// The favorite food not only feeds you, but also increases your passive healing.
/// </summary>
[DataField("chemical", customTypeSerializer: typeof(PrototypeIdSerializer<ReagentPrototype>))]
public string Chemical = "Ichor";
[DataField] //A-13 Dragon fix full
public FoodPreference FoodPreference = FoodPreference.All; //A-13 Dragon fix full

/// <summary>
/// The amount of ichor injected per devour
/// Passive healing added for each devoured favourite food.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("healRate")]
public float HealRate = 15f;
[DataField] //A-13 Dragon fix full
public DamageSpecifier? PassiveDevourHealing = new(); //A-13 Dragon fix full

/// <summary>
/// The favorite food not only feeds you, but also heals
/// The passive damage done to devoured entities.
/// </summary>
[DataField("foodPreference")]
public FoodPreference FoodPreference = FoodPreference.All;
}
[DataField] //A-13 Dragon fix full
public DamageSpecifier? StomachDamage = new(); //A-13 Dragon fix full

/// <summary>
/// The MobStates the stomach is allowed to deal damage on.
/// </summary>
[DataField] //A-13 Dragon fix full
public List<MobState> DigestibleStates = new(); //A-13 Dragon fix full
}
Loading

0 comments on commit cc0c891

Please sign in to comment.