Skip to content

Commit

Permalink
general bugfixes from commit dc16cad on Goob#1235
Browse files Browse the repository at this point in the history
  • Loading branch information
Spielern committed Jan 26, 2025
1 parent 2e0d4eb commit 7ad8b23
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 23 deletions.
4 changes: 4 additions & 0 deletions Content.Server/Cloning/CloningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Content.Server.Materials;
using Content.Server.Popups;
using Content.Server.Power.EntitySystems;
using Content.Shared._EE.Silicon.Components; // Goobstation
using Content.Server.Psionics; // DeltaV
using Content.Server.Traits.Assorted; // DeltaV
using Content.Shared.Atmos;
Expand Down Expand Up @@ -171,6 +172,9 @@ public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Entity<MindComponen
if (!TryComp<HumanoidAppearanceComponent>(bodyToClone, out var humanoid))
return false; // whatever body was to be cloned, was not a humanoid

if (HasComp<SiliconComponent>(bodyToClone))
return false; // Goobstation: Don't clone IPCs.

// Begin Nyano-code: allow paradox anomalies to be cloned.
var pref = humanoid.LastProfileLoaded;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ namespace Content.Server.Objectives.Components;
[RegisterComponent, Access(typeof(KillPersonConditionSystem))]
public sealed partial class PickRandomPersonComponent : Component
{
[DataField]
public bool NeedsOrganic; // Goobstation: Only pick non-silicon players.
}
4 changes: 2 additions & 2 deletions Content.Server/PowerCell/PowerCellSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ private void OnCellEmpAttempt(EntityUid uid, PowerCellComponent component, EmpAt

private void OnCellSlotExamined(EntityUid uid, PowerCellSlotComponent component, ExaminedEvent args)
{
TryGetBatteryFromSlot(uid, out var battery);
OnBatteryExamined(uid, battery, args);
TryGetBatteryFromSlot(uid, out var batteryEnt, out var battery); // Goobstation
OnBatteryExamined(batteryEnt.GetValueOrDefault(uid), battery, args); // Goobstation
}

private void OnBatteryExamined(EntityUid uid, BatteryComponent? component, ExaminedEvent args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Content.Shared.Interaction;
using Content.Shared.Popups;
using Content.Shared.Tools;
using Content.Shared._Shitmed.Targeting;
using Content.Shared.Body.Systems;
using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem;

namespace Content.Server._EE.Silicon.WeldingHealable;
Expand All @@ -18,6 +20,7 @@ public sealed class WeldingHealableSystem : SharedWeldingHealableSystem
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;

[Dependency] private readonly SharedBodySystem _bodySystem = default!;
public override void Initialize()
{
SubscribeLocalEvent<WeldingHealableComponent, InteractUsingEvent>(Repair);
Expand All @@ -31,7 +34,7 @@ private void OnRepairFinished(EntityUid uid, WeldingHealableComponent healableCo
|| !TryComp<WeldingHealingComponent>(args.Used, out var component)
|| damageable.DamageContainerID is null
|| !component.DamageContainers.Contains(damageable.DamageContainerID)
|| !HasDamage(damageable, component)
|| !HasDamage((args.Target.Value, damageable), component, args.User)
|| !TryComp<WelderComponent>(args.Used, out var welder)
|| !TryComp<SolutionContainerManagerComponent>(args.Used, out var solutionContainer)
|| !_solutionContainer.TryGetSolution(((EntityUid) args.Used, solutionContainer), welder.FuelSolutionName, out var solution))
Expand Down Expand Up @@ -67,7 +70,7 @@ private async void Repair(EntityUid uid, WeldingHealableComponent healableCompon
|| !EntityManager.TryGetComponent(args.Target, out DamageableComponent? damageable)
|| damageable.DamageContainerID is null
|| !component.DamageContainers.Contains(damageable.DamageContainerID)
|| !HasDamage(damageable, component)
|| !HasDamage((args.Target, damageable), component, args.User)
|| !_toolSystem.HasQuality(args.Used, component.QualityNeeded)
|| args.User == args.Target && !component.AllowSelfHeal)
return;
Expand All @@ -88,15 +91,25 @@ private async void Repair(EntityUid uid, WeldingHealableComponent healableCompon
});
}

private bool HasDamage(DamageableComponent component, WeldingHealingComponent healable)
private bool HasDamage(Entity<DamageableComponent> damageable, WeldingHealingComponent healable, EntityUid user)
{
if (healable.Damage.DamageDict is null)
return false;

foreach (var type in healable.Damage.DamageDict)
if (component.Damage.DamageDict[type.Key].Value > 0)
if (damageable.Comp.Damage.DamageDict[type.Key].Value > 0)
return true;

// In case the healer is a humanoid entity with targeting, we run the check on the targeted parts.
if (!TryComp(user, out TargetingComponent? targeting))
return false;
var (targetType, targetSymmetry) = _bodySystem.ConvertTargetBodyPart(targeting.Target);
foreach (var part in _bodySystem.GetBodyChildrenOfType(damageable, targetType, symmetry: targetSymmetry))
if (TryComp<DamageableComponent>(part.Id, out var damageablePart))
foreach (var type in healable.Damage.DamageDict)
if (damageablePart.Damage.DamageDict[type.Key].Value > 0)
return true;

return false;
}
}
101 changes: 95 additions & 6 deletions Content.Shared/Mech/EntitySystems/SharedMechSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
using Robust.Shared.Serialization;
using Robust.Shared.Timing;

// Goobstation Change
using Content.Shared.CCVar;
using Content.Shared._Goobstation.CCVar;
using Content.Shared.Weapons.Ranged.Events;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Inventory.VirtualItem;
using Robust.Shared.Configuration;
using Content.Shared.Implants.Components;

namespace Content.Shared.Mech.EntitySystems;

/// <summary>
Expand All @@ -39,6 +49,12 @@ public abstract class SharedMechSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!; // Goobstation Change
[Dependency] private readonly SharedVirtualItemSystem _virtualItem = default!; // Goobstation Change
[Dependency] private readonly IConfigurationManager _config = default!; // Goobstation Change

// Goobstation: Local variable for checking if mech guns can be used out of them.
private bool _canUseMechGunOutside;

/// <inheritdoc/>
public override void Initialize()
Expand All @@ -55,6 +71,14 @@ public override void Initialize()
SubscribeLocalEvent<MechPilotComponent, GetMeleeWeaponEvent>(OnGetMeleeWeapon);
SubscribeLocalEvent<MechPilotComponent, CanAttackFromContainerEvent>(OnCanAttackFromContainer);
SubscribeLocalEvent<MechPilotComponent, AttackAttemptEvent>(OnAttackAttempt);
SubscribeLocalEvent<MechPilotComponent, EntGotRemovedFromContainerMessage>(OnEntGotRemovedFromContainer);
SubscribeLocalEvent<MechEquipmentComponent, ShotAttemptedEvent>(OnShotAttempted); // Goobstation
Subs.CVar(_config, GoobCVars.MechGunOutsideMech, value => _canUseMechGunOutside = value, true); // Goobstation
}
// GoobStation: Fixes scram implants or teleports locking the pilot out of being able to move.
private void OnEntGotRemovedFromContainer(EntityUid uid, MechPilotComponent component, EntGotRemovedFromContainerMessage args)
{
TryEject(component.Mech, pilot: uid);
}

private void OnToggleEquipmentAction(EntityUid uid, MechComponent component, MechToggleEquipmentEvent args)
Expand Down Expand Up @@ -368,6 +392,7 @@ public bool TryInsert(EntityUid uid, EntityUid? toInsert, MechComponent? compone
SetupUser(uid, toInsert.Value);
_container.Insert(toInsert.Value, component.PilotSlot);
UpdateAppearance(uid, component);
UpdateHands(toInsert.Value, uid, true); // Goobstation
return true;
}

Expand All @@ -376,23 +401,64 @@ public bool TryInsert(EntityUid uid, EntityUid? toInsert, MechComponent? compone
/// </summary>
/// <param name="uid"></param>
/// <param name="component"></param>
/// <param name="pilot">The pilot to eject</param>
/// <returns>Whether or not the pilot was ejected.</returns>
public bool TryEject(EntityUid uid, MechComponent? component = null)
public bool TryEject(EntityUid uid, MechComponent? component = null, EntityUid? pilot = null)
{
if (!Resolve(uid, ref component))
return false;

if (component.PilotSlot.ContainedEntity == null)
return false;
if (component.PilotSlot.ContainedEntity != null)
pilot = component.PilotSlot.ContainedEntity.Value;

var pilot = component.PilotSlot.ContainedEntity.Value;
if (pilot == null)
return false;

RemoveUser(uid, pilot);
_container.RemoveEntity(uid, pilot);
RemoveUser(uid, pilot.Value);
_container.RemoveEntity(uid, pilot.Value);
UpdateAppearance(uid, component);
UpdateHands(pilot.Value, uid, false); // Goobstation
return true;
}

// Goobstation Change Start
private void UpdateHands(EntityUid uid, EntityUid mech, bool active)
{
if (!TryComp<HandsComponent>(uid, out var handsComponent))
return;
if (active)
BlockHands(uid, mech, handsComponent);
else
FreeHands(uid, mech);
}
private void BlockHands(EntityUid uid, EntityUid mech, HandsComponent handsComponent)
{
var freeHands = 0;
foreach (var hand in _hands.EnumerateHands(uid, handsComponent))
{
if (hand.HeldEntity == null)
{
freeHands++;
continue;
}
// Is this entity removable? (they might have handcuffs on)
if (HasComp<UnremoveableComponent>(hand.HeldEntity) && hand.HeldEntity != mech)
continue;
_hands.DoDrop(uid, hand, true, handsComponent);
freeHands++;
if (freeHands == 2)
break;
}
if (_virtualItem.TrySpawnVirtualItemInHand(mech, uid, out var virtItem1))
EnsureComp<UnremoveableComponent>(virtItem1.Value);
if (_virtualItem.TrySpawnVirtualItemInHand(mech, uid, out var virtItem2))
EnsureComp<UnremoveableComponent>(virtItem2.Value);
}
private void FreeHands(EntityUid uid, EntityUid mech)
{
_virtualItem.DeleteInHandsMatching(uid, mech);
}
// Goobstation Change End
private void OnGetMeleeWeapon(EntityUid uid, MechPilotComponent component, GetMeleeWeaponEvent args)
{
if (args.Handled)
Expand All @@ -417,6 +483,20 @@ private void OnAttackAttempt(EntityUid uid, MechPilotComponent component, Attack
args.Cancel();
}

// Goobstation: Prevent guns being used out of mechs if CCVAR is set.
private void OnShotAttempted(EntityUid uid, MechEquipmentComponent component, ref ShotAttemptedEvent args)
{
if (!component.EquipmentOwner.HasValue
|| !HasComp<MechComponent>(component.EquipmentOwner.Value))
{
if (!_canUseMechGunOutside)
args.Cancel();
return;
}
var ev = new HandleMechEquipmentBatteryEvent();
RaiseLocalEvent(uid, ev);
}

private void UpdateAppearance(EntityUid uid, MechComponent? component = null,
AppearanceComponent? appearance = null)
{
Expand Down Expand Up @@ -476,3 +556,12 @@ public sealed partial class MechExitEvent : SimpleDoAfterEvent
public sealed partial class MechEntryEvent : SimpleDoAfterEvent
{
}


/// <summary>
/// Event raised when an user attempts to fire a mech weapon to check if its battery is drained
/// </summary>
[Serializable, NetSerializable]
public sealed partial class HandleMechEquipmentBatteryEvent : EntityEventArgs
{
}
7 changes: 6 additions & 1 deletion Content.Shared/Mind/SharedMindSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Shared._EE.Silicon.Components; // Goobstation
using Content.Shared.Administration.Logs;
using Content.Shared.Database;
using Content.Shared.Examine;
Expand Down Expand Up @@ -532,7 +533,7 @@ public string MindOwnerLoggingString(MindComponent mind)
/// <summary>
/// Returns a list of every living humanoid player's minds, except for a single one which is exluded.
/// </summary>
public HashSet<Entity<MindComponent>> GetAliveHumans(EntityUid? exclude = null)
public HashSet<Entity<MindComponent>> GetAliveHumans(EntityUid? exclude = null, bool excludeSilicon = false)
{
var allHumans = new HashSet<Entity<MindComponent>>();
// HumanoidAppearanceComponent is used to prevent mice, pAIs, etc from being chosen
Expand All @@ -544,6 +545,10 @@ public HashSet<Entity<MindComponent>> GetAliveHumans(EntityUid? exclude = null)
if (!TryGetMind(uid, out var mind, out var mindComp) || mind == exclude || !_mobState.IsAlive(uid, mobState))
continue;

// Goobstation: Skip IPCs from selections
if (excludeSilicon && HasComp<SiliconComponent>(uid))
continue;

allHumans.Add(new Entity<MindComponent>(mind, mindComp));
}

Expand Down
6 changes: 5 additions & 1 deletion Content.Shared/Weapons/Melee/MeleeWeaponComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public sealed partial class MeleeWeaponComponent : Component
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public bool ResistanceBypass = false;

/// <summary>
/// Base damage for this weapon. Can be modified via heavy damage or other means.
/// </summary>
Expand Down Expand Up @@ -170,6 +170,10 @@ public sealed partial class MeleeWeaponComponent : Component
public float HeavyPartDamageMultiplier = 0.5f;

// Shitmed Change End

// Goobstation
[DataField, AutoNetworkedField]
public bool CanWideSwing = true;
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ private void OnHeavyAttack(HeavyAttackEvent msg, EntitySessionEventArgs args)
return;

if (!TryGetWeapon(user, out var weaponUid, out var weapon) ||
weaponUid != GetEntity(msg.Weapon))
weaponUid != GetEntity(msg.Weapon) ||
!weapon.CanWideSwing) // Goobstation Change
{
return;
}
Expand Down
10 changes: 10 additions & 0 deletions Content.Shared/_Goobstation/CCVars/CCVars.Goob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,14 @@ public sealed partial class GoobCVars
/// </summary>
public static readonly CVarDef<bool> AutoGetUp =
CVarDef.Create("white.auto_get_up", true, CVar.CLIENT | CVar.ARCHIVE | CVar.REPLICATED); // WD EDIT

#region Mechs

/// <summary>
/// Whether or not players can use mech guns outside of mechs.
/// </summary>
public static readonly CVarDef<bool> MechGunOutsideMech =
CVarDef.Create("mech.gun_outside_mech", true, CVar.SERVER | CVar.REPLICATED);

#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
enum.MechUiKey.Key:
type: MechBoundUserInterface
- type: MeleeWeapon
canWideSwing: false
hidden: true
attackRate: 0.75
damage:
Expand Down
7 changes: 7 additions & 0 deletions Resources/Prototypes/_EE/Damage/modifier_sets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- type: damageModifierSet
id: IPC
coefficients:
Poison: 0
Cold: 0.2
Heat: 2
Shock: 2.5
20 changes: 12 additions & 8 deletions Resources/Prototypes/_EE/Entities/Mobs/Player/silicon_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
# safe: false
# - type: EyeProtection # You'll want this if your robot can't wear glasses, like an IPC.
# protectionTime: 12
- type: Fixtures
fixtures:
fix1:
shape:
!type:PhysShapeCircle
radius: 0.35
density: 185
restitution: 0.0
mask:
- MobMask
layer:
- MobLayer
- type: Silicon
entityType: enum.SiliconType.Player
batteryPowered: false # Needs to also have a battery!
Expand Down Expand Up @@ -299,11 +311,3 @@
- type: Targeting
- type: SurgeryTarget
- type: LayingDown

- type: damageModifierSet
id: IPC
coefficients:
Poison: 0
Cold: 0.2
Heat: 2
Shock: 2.5

0 comments on commit 7ad8b23

Please sign in to comment.