From 4934f6805a37909cd859eb2112ef975ba0219788 Mon Sep 17 00:00:00 2001 From: Rane Date: Sun, 10 Jul 2022 17:12:55 -0400 Subject: [PATCH 1/3] Steal condition QOL --- .../Objectives/Conditions/StealCondition.cs | 31 +++++++++---------- .../objectives/conditions/steal-condition.ftl | 5 ++- ...rObjectives..yml => traitorObjectives.yml} | 10 ++++++ 3 files changed, 29 insertions(+), 17 deletions(-) rename Resources/Prototypes/Objectives/{traitorObjectives..yml => traitorObjectives.yml} (93%) diff --git a/Content.Server/Objectives/Conditions/StealCondition.cs b/Content.Server/Objectives/Conditions/StealCondition.cs index ecb0dee39f78..36a6402d428c 100644 --- a/Content.Server/Objectives/Conditions/StealCondition.cs +++ b/Content.Server/Objectives/Conditions/StealCondition.cs @@ -14,7 +14,13 @@ public sealed class StealCondition : IObjectiveCondition, ISerializationHooks { private Mind.Mind? _mind; [DataField("prototype")] private string _prototypeId = string.Empty; - [DataField("amount")] private int _amount = 1; + + /// + /// Help newer players by saying e.g. "steal the chief engineer's advanced magboots" + /// instead of "steal advanced magboots. + /// + [ViewVariables] + [DataField("owner", required: true)] private string _owner = string.Empty; public IObjectiveCondition GetAssigned(Mind.Mind mind) { @@ -22,26 +28,16 @@ public IObjectiveCondition GetAssigned(Mind.Mind mind) { _mind = mind, _prototypeId = _prototypeId, - _amount = _amount + _owner = _owner }; } - void ISerializationHooks.AfterDeserialization() - { - if (_amount < 1) - { - Logger.Error("StealCondition has an amount less than 1 ({0})", _amount); - } - } - private string PrototypeName => IoCManager.Resolve().TryIndex(_prototypeId, out var prototype) ? prototype.Name : "[CANNOT FIND NAME]"; - public string Title => Loc.GetString("objective-condition-steal-title", - ("amount", _amount > 1 ? $"{_amount}x " : string.Empty), - ("itemName", Loc.GetString(PrototypeName))); + public string Title => Loc.GetString("objective-condition-steal-title", ("owner", Loc.GetString(_owner)), ("itemName", Loc.GetString(PrototypeName))); public string Description => Loc.GetString("objective-condition-steal-description",("itemName", Loc.GetString(PrototypeName))); @@ -55,7 +51,10 @@ public float Progress if (!IoCManager.Resolve().TryGetComponent(owned, out var containerManagerComponent)) return 0f; float count = containerManagerComponent.CountPrototypeOccurencesRecursive(_prototypeId); - return count/_amount; + if (count >= 1) + return 1; + else + return 0; } } @@ -65,7 +64,7 @@ public bool Equals(IObjectiveCondition? other) { return other is StealCondition stealCondition && Equals(_mind, stealCondition._mind) && - _prototypeId == stealCondition._prototypeId && _amount == stealCondition._amount; + _prototypeId == stealCondition._prototypeId; } public override bool Equals(object? obj) @@ -78,7 +77,7 @@ public override bool Equals(object? obj) public override int GetHashCode() { - return HashCode.Combine(_mind, _prototypeId, _amount); + return HashCode.Combine(_mind, _prototypeId); } } } diff --git a/Resources/Locale/en-US/objectives/conditions/steal-condition.ftl b/Resources/Locale/en-US/objectives/conditions/steal-condition.ftl index 3bb68abedf5c..34b31fd83acc 100644 --- a/Resources/Locale/en-US/objectives/conditions/steal-condition.ftl +++ b/Resources/Locale/en-US/objectives/conditions/steal-condition.ftl @@ -1,2 +1,5 @@ -objective-condition-steal-title = Steal {$amount}{$itemName}. +objective-condition-steal-title = Steal the {$owner}'s {$itemName}. objective-condition-steal-description = We need you to steal {$itemName}. Don't get caught. + +objective-condition-steal-station = station +objective-condition-steal-Ian = Ian diff --git a/Resources/Prototypes/Objectives/traitorObjectives..yml b/Resources/Prototypes/Objectives/traitorObjectives.yml similarity index 93% rename from Resources/Prototypes/Objectives/traitorObjectives..yml rename to Resources/Prototypes/Objectives/traitorObjectives.yml index e644573274be..a3bc28971e89 100644 --- a/Resources/Prototypes/Objectives/traitorObjectives..yml +++ b/Resources/Prototypes/Objectives/traitorObjectives.yml @@ -11,6 +11,7 @@ conditions: - !type:StealCondition prototype: CaptainIDCard + owner: job-name-captain - type: objective id: KillRandomObjective @@ -74,6 +75,7 @@ conditions: - !type:StealCondition prototype: Hypospray + owner: job-name-cmo - type: objective id: RDHardsuitStealObjective @@ -88,6 +90,7 @@ conditions: - !type:StealCondition prototype: ClothingOuterHardsuitRd + owner: job-name-rd - type: objective id: NukeDiskStealObjective @@ -101,6 +104,7 @@ conditions: - !type:StealCondition prototype: NukeDisk + owner: objective-condition-steal-station - type: objective id: IDComputerBoardStealObjective @@ -114,6 +118,7 @@ conditions: - !type:StealCondition prototype: IDComputerCircuitboard + owner: job-name-hop - type: objective id: MagbootsStealObjective @@ -128,6 +133,7 @@ conditions: - !type:StealCondition prototype: ClothingShoesBootsMagAdv + owner: job-name-ce - type: objective id: SupplyConsoleBoardStealObjective @@ -141,6 +147,7 @@ conditions: - !type:StealCondition prototype: SupplyComputerCircuitboard + owner: job-name-qm - type: objective id: CorgiMeatStealObjective @@ -154,6 +161,7 @@ conditions: - !type:StealCondition prototype: FoodMeatCorgi + owner: objective-condition-steal-Ian - type: objective id: CaptainGunStealObjective @@ -168,6 +176,7 @@ conditions: - !type:StealCondition prototype: WeaponAntiqueLaser + owner: job-name-captain - type: objective id: CaptainJetpackStealObjective @@ -182,3 +191,4 @@ conditions: - !type:StealCondition prototype: JetpackCaptainFilled + owner: job-name-captain From 127a66ca4c43f1d2f3e897d16893e546772f7be9 Mon Sep 17 00:00:00 2001 From: Rane Date: Sun, 10 Jul 2022 17:16:14 -0400 Subject: [PATCH 2/3] Some comments --- Content.Server/Objectives/Conditions/StealCondition.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Content.Server/Objectives/Conditions/StealCondition.cs b/Content.Server/Objectives/Conditions/StealCondition.cs index 36a6402d428c..e2348743b409 100644 --- a/Content.Server/Objectives/Conditions/StealCondition.cs +++ b/Content.Server/Objectives/Conditions/StealCondition.cs @@ -17,7 +17,7 @@ public sealed class StealCondition : IObjectiveCondition, ISerializationHooks /// /// Help newer players by saying e.g. "steal the chief engineer's advanced magboots" - /// instead of "steal advanced magboots. + /// instead of "steal advanced magboots. Should be a loc string. /// [ViewVariables] [DataField("owner", required: true)] private string _owner = string.Empty; @@ -50,6 +50,7 @@ public float Progress if (_mind?.OwnedEntity is not {Valid: true} owned) return 0f; if (!IoCManager.Resolve().TryGetComponent(owned, out var containerManagerComponent)) return 0f; + // slightly ugly but fixing it would just be duplicating it with a different return value float count = containerManagerComponent.CountPrototypeOccurencesRecursive(_prototypeId); if (count >= 1) return 1; From 88c334ff97cbf7fa49ad029961ac489d12d0147b Mon Sep 17 00:00:00 2001 From: Rane Date: Sun, 10 Jul 2022 18:26:30 -0400 Subject: [PATCH 3/3] fix locale --- .../Locale/en-US/objectives/conditions/steal-condition.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/Locale/en-US/objectives/conditions/steal-condition.ftl b/Resources/Locale/en-US/objectives/conditions/steal-condition.ftl index 34b31fd83acc..79cdbc2168d0 100644 --- a/Resources/Locale/en-US/objectives/conditions/steal-condition.ftl +++ b/Resources/Locale/en-US/objectives/conditions/steal-condition.ftl @@ -2,4 +2,4 @@ objective-condition-steal-title = Steal the {$owner}'s {$itemName}. objective-condition-steal-description = We need you to steal {$itemName}. Don't get caught. objective-condition-steal-station = station -objective-condition-steal-Ian = Ian +objective-condition-steal-Ian = head of personnel's corgi