Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Up #278

Closed
wants to merge 13 commits into from
12 changes: 12 additions & 0 deletions Content.Server/Devour/DevourSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Devour;
Expand All @@ -15,6 +16,7 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<DevourerComponent, DevourDoAfterEvent>(OnDoAfter);
SubscribeLocalEvent<DevourerComponent, BeingGibbedEvent>(OnGibContents);
}

private void OnDoAfter(EntityUid uid, DevourerComponent component, DevourDoAfterEvent args)
Expand Down Expand Up @@ -45,5 +47,15 @@ private void OnDoAfter(EntityUid uid, DevourerComponent component, DevourDoAfter

_audioSystem.PlayPvs(component.SoundDevour, uid);
}

private void OnGibContents(EntityUid uid, DevourerComponent component, ref BeingGibbedEvent args)
{
if (!component.ShouldStoreDevoured)
return;

// For some reason we have two different systems that should handle gibbing,
// and for some another reason GibbingSystem, which should empty all containers, doesn't get involved in this process
ContainerSystem.EmptyContainer(component.Stomach);
}
}

17 changes: 17 additions & 0 deletions Content.Server/Mech/Systems/MechSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.Player;
using Content.Shared.Mobs.Components; // Frontier
using Content.Shared.NPC.Components; // Frontier
using Content.Shared.Mobs; // Frontier

namespace Content.Server.Mech.Systems;

Expand Down Expand Up @@ -228,6 +231,17 @@ private void OnMechEntry(EntityUid uid, MechComponent component, MechEntryEvent
return;
}

// Frontier - Make AI Attack mechs based on user.
if (TryComp<MobStateComponent>(args.User, out var _))
EnsureComp<MobStateComponent>(uid);
if (TryComp<NpcFactionMemberComponent>(args.User, out var faction))
{
var factionMech = EnsureComp<NpcFactionMemberComponent>(uid);
if (faction.Factions != null)
factionMech.Factions = faction.Factions;
}
// Frontier

TryInsert(uid, args.Args.User, component);
_actionBlocker.UpdateCanMove(uid);

Expand Down Expand Up @@ -256,6 +270,9 @@ private void OnDamageChanged(EntityUid uid, MechComponent component, DamageChang
var damage = args.DamageDelta * component.MechToPilotDamageMultiplier;
_damageable.TryChangeDamage(component.PilotSlot.ContainedEntity, damage);
}

if (TryComp<MobStateComponent>(component.PilotSlot.ContainedEntity, out var state) && state.CurrentState != MobState.Alive) // Frontier - Eject players from mechs when they go crit
TryEject(uid, component);
}

private void ToggleMechUi(EntityUid uid, MechComponent? component = null, EntityUid? user = null)
Expand Down
27 changes: 27 additions & 0 deletions Content.Server/NPC/HTN/HTNSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using Content.Server.Worldgen; // Frontier
using Content.Server.Worldgen.Components; // Frontier
using Content.Server.Worldgen.Systems; // Frontier
using Robust.Server.GameObjects; // Frontier

namespace Content.Server.NPC.HTN;

Expand All @@ -22,6 +26,12 @@ public sealed class HTNSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly NPCSystem _npc = default!;
[Dependency] private readonly NPCUtilitySystem _utility = default!;
// Frontier
[Dependency] private readonly WorldControllerSystem _world = default!;
[Dependency] private readonly TransformSystem _transform = default!;
private EntityQuery<WorldControllerComponent> _mapQuery;
private EntityQuery<LoadedChunkComponent> _loadedQuery;
// Frontier

private readonly JobQueue _planQueue = new(0.004);

Expand All @@ -31,6 +41,8 @@ public sealed class HTNSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
_mapQuery = GetEntityQuery<WorldControllerComponent>(); // Frontier
_loadedQuery = GetEntityQuery<LoadedChunkComponent>(); // Frontier
SubscribeLocalEvent<HTNComponent, MobStateChangedEvent>(_npc.OnMobStateChange);
SubscribeLocalEvent<HTNComponent, MapInitEvent>(_npc.OnNPCMapInit);
SubscribeLocalEvent<HTNComponent, PlayerAttachedEvent>(_npc.OnPlayerNPCAttach);
Expand Down Expand Up @@ -153,6 +165,9 @@ public void UpdateNPC(ref int count, int maxUpdates, float frameTime)
if (count >= maxUpdates)
break;

if (!IsNPCActive(uid)) // Frontier
continue;

if (comp.PlanningJob != null)
{
if (comp.PlanningJob.Exception != null)
Expand Down Expand Up @@ -241,6 +256,18 @@ public void UpdateNPC(ref int count, int maxUpdates, float frameTime)
}
}

private bool IsNPCActive(EntityUid entity) // Frontier
{
var transform = Transform(entity);

if (!_mapQuery.TryGetComponent(transform.MapUid, out var worldComponent))
return true;

var chunk = _world.GetOrCreateChunk(WorldGen.WorldToChunkCoords(_transform.GetWorldPosition(transform)).Floored(), transform.MapUid.Value, worldComponent);

return _loadedQuery.TryGetComponent(chunk, out var loaded) && loaded.Loaders is not null;
}

private void AppendDebugText(HTNTask task, StringBuilder text, List<int> planBtr, List<int> btr, ref int level)
{
// If it's the selected BTR then highlight.
Expand Down
10 changes: 10 additions & 0 deletions Content.Shared/Mech/EntitySystems/SharedMechSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
using Robust.Shared.Network;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Content.Shared.Mobs.Components; // Frontier
using Content.Shared.NPC.Components; // Frontier

namespace Content.Shared.Mech.EntitySystems;

Expand Down Expand Up @@ -388,6 +390,14 @@ public bool TryEject(EntityUid uid, MechComponent? component = null)
RemoveUser(uid, pilot);
_container.RemoveEntity(uid, pilot);
UpdateAppearance(uid, component);

// Frontier - Make NPC AI attack Mechs
if (TryComp<MobStateComponent>(uid, out var _))
RemComp<MobStateComponent>(uid);
if (TryComp<NpcFactionMemberComponent>(uid, out var _))
RemComp<NpcFactionMemberComponent>(uid);
// Frontier

return true;
}

Expand Down
3 changes: 2 additions & 1 deletion Content.Shared/NPC/Components/NpcFactionMemberComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
using Content.Shared.NPC.Systems;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Content.Shared.Mech.EntitySystems; // Frontier

namespace Content.Shared.NPC.Components;

[RegisterComponent, NetworkedComponent, Access(typeof(NpcFactionSystem))]
[RegisterComponent, NetworkedComponent, Access(typeof(NpcFactionSystem), typeof(SharedMechSystem))] // Frontier - Added MechSystem
public sealed partial class NpcFactionMemberComponent : Component
{
/// <summary>
Expand Down
26 changes: 26 additions & 0 deletions Resources/Changelog/Changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4861,3 +4861,29 @@ Entries:
existing mail, expect the mail to find you soon.
id: 5017
time: '2024-06-07T17:10:14.0000000+00:00'
- author: dvir01
changes:
- type: Tweak
message: The Mail Truck got a full rework,
id: 5018
time: '2024-06-07T21:53:00.0000000+00:00'
- author: Leander
changes:
- type: Tweak
message: Dragons can devour people again without deleting them.
id: 5019
time: '2024-06-08T14:40:33.0000000+00:00'
- author: whatston3
changes:
- type: Tweak
message: >-
The Brigmedic HUD now has job icon, wanted status, and health icon
display.
id: 5020
time: '2024-06-08T22:01:36.0000000+00:00'
- author: Tych0theSynth and Deeja
changes:
- type: Add
message: Added the NSF Broadhead, a new medium-size detective vessel.
id: 5021
time: '2024-06-09T17:53:08.0000000+00:00'
Loading
Loading