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

Commit

Permalink
Fix mech codes to stop AI abuse (new-frontiers-14#1492)
Browse files Browse the repository at this point in the history
* Fix Mechs

* Update Content.Server/Mech/Systems/MechSystem.cs

Was

Co-authored-by: Whatstone <[email protected]>

* Update Content.Server/Mech/Systems/MechSystem.cs

Sure

Co-authored-by: Whatstone <[email protected]>

* Update Content.Shared/Mech/EntitySystems/SharedMechSystem.cs

Co-authored-by: Whatstone <[email protected]>

---------

Co-authored-by: Whatstone <[email protected]>
  • Loading branch information
dvir001 and whatston3 authored Jun 8, 2024
1 parent a8c22c7 commit 73ecff4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
SheetSteel1:
min: 2
max: 4
- type: MobState # Frontier (otherwise NPCs won't attack the entity)

- type: entity
parent: BaseStructure
Expand Down

0 comments on commit 73ecff4

Please sign in to comment.