Skip to content

Commit

Permalink
Make Loadout MinLimit not count failed attempts (#29264)
Browse files Browse the repository at this point in the history
Loadout MinLimit doesn't count failed attempts
  • Loading branch information
Tayrtahn authored Jun 21, 2024
1 parent a3ffe22 commit 831d962
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions Content.Shared/Preferences/Loadouts/RoleLoadout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,14 @@ public void SetDefault(HumanoidCharacterProfile? profile, ICommonSession? sessio
if (groupProto.MinLimit > 0)
{
// Apply any loadouts we can.
for (var j = 0; j < Math.Min(groupProto.MinLimit, groupProto.Loadouts.Count); j++)
var addedCount = 0;
foreach (var protoId in groupProto.Loadouts)
{
if (!protoManager.TryIndex(groupProto.Loadouts[j], out var loadoutProto))
// Reached the limit, time to stop
if (addedCount >= groupProto.MinLimit)
break;

if (!protoManager.TryIndex(protoId, out var loadoutProto))
continue;

var defaultLoadout = new Loadout()
Expand All @@ -209,6 +214,7 @@ public void SetDefault(HumanoidCharacterProfile? profile, ICommonSession? sessio

loadouts.Add(defaultLoadout);
Apply(loadoutProto);
addedCount++;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Resources/Prototypes/Loadouts/loadout_groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
- type: loadoutGroup
id: Survival
name: loadout-group-survival-basic
minLimit: 2
maxLimit: 2
minLimit: 1
maxLimit: 1
hidden: true
loadouts:
- EmergencyNitrogen
Expand Down

0 comments on commit 831d962

Please sign in to comment.