-
Notifications
You must be signed in to change notification settings - Fork 925
Gun Rarity System #3616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Gun Rarity System #3616
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fb7ea10
Weapon Rarity
Cheackraze 707aa7d
renaming
Cheackraze d6deb99
number adjustments
Cheackraze 60e8429
add to expeditions
Cheackraze a19a651
debug item cleanup
Cheackraze 09ec647
Merge branch 'master' into gun-rarity
Cheackraze 4f4e69e
Merge branch 'master' into gun-rarity
Cheackraze 9b91c0c
Merge branch 'master' into gun-rarity
Cheackraze 2029dd2
Merge branch 'master' into gun-rarity
Cheackraze f1373d0
Merge branch 'master' into gun-rarity
Cheackraze 5bba283
base implement namemodifiersystem and name cleanup
Cheackraze 5cb0ff4
abstract the base rare weapon case
Cheackraze 8ae9b6c
Various improvements to gun rarity system
arimah 8a139f3
Numbers r hard
arimah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace Content.Server.Storage.Events; | ||
|
|
||
| /// <summary> | ||
| /// Raised when a <see cref="StorageFillComponent"/> is finished filling the storage | ||
| /// </summary> | ||
| [ByRefEvent] | ||
| public record struct StorageFilledEvent; |
14 changes: 14 additions & 0 deletions
14
Content.Server/_NF/Weapons/Rarity/RareWeaponSpawnerCaseComponent.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| namespace Content.Server._NF.Weapons.Rarity; | ||
|
|
||
| /// <summary> | ||
| /// This component is added to weapon cases that transform the containing spawned weapon into a weapon with rare markers. | ||
| /// </summary> | ||
| [RegisterComponent] | ||
| public sealed partial class RareWeaponSpawnerCaseComponent : Component | ||
| { | ||
| [DataField] | ||
| public int Rarity = 1; | ||
|
|
||
| [DataField] | ||
| public bool RandomRarity = false; | ||
| } |
140 changes: 140 additions & 0 deletions
140
Content.Server/_NF/Weapons/Rarity/WeaponRaritySystem.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| using Content.Server.Storage.Events; | ||
| using Content.Shared.Dataset; | ||
| using Content.Shared.Storage; | ||
| using Content.Shared.Weapons.Ranged.Components; | ||
| using Robust.Shared.Prototypes; | ||
| using Robust.Shared.Random; | ||
|
|
||
| namespace Content.Server._NF.Weapons.Rarity; | ||
|
|
||
| /// <summary> | ||
| /// A stand-alone system intended to modularly sit atop the existing gun and weapon systems to create dynamic weapon rarities. | ||
| /// </summary> | ||
| public sealed partial class WeaponRaritySystem : EntitySystem | ||
| { | ||
| [Dependency] private readonly IRobustRandom _random = default!; | ||
| [Dependency] private readonly MetaDataSystem _metaSystem = default!; | ||
| [Dependency] private readonly IPrototypeManager _protoMan = default!; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
| SubscribeLocalEvent<RareWeaponSpawnerCaseComponent, StorageFilledEvent>(OnCaseSpawn); | ||
| } | ||
|
|
||
| private void OnCaseSpawn(Entity<RareWeaponSpawnerCaseComponent> ent, ref StorageFilledEvent args) | ||
| { | ||
| var comp = ent.Comp; | ||
| if (!TryComp<StorageComponent>(ent, out StorageComponent? storage)) | ||
| return; | ||
|
|
||
| var contents = storage.StoredItems; | ||
| GunComponent? gunComp = null; | ||
| EntityUid gun = default; | ||
| foreach (var item in contents) | ||
| { | ||
| if (TryComp(item.Key, out gunComp)) | ||
| { | ||
| gun = item.Key; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (gunComp == null || !gun.IsValid() ) | ||
| return; | ||
|
|
||
| //Basic functionality of 3 rarity levels | ||
| var rarity = comp.Rarity; | ||
| if (comp.RandomRarity) | ||
| { | ||
| rarity = _random.Next(0, 4); | ||
| } | ||
|
|
||
| RenameGun(gun, rarity); | ||
|
|
||
| while (rarity > 0) | ||
| { | ||
| var chance = _random.Next(1, 4); | ||
| switch (chance) | ||
| { | ||
| case 1: | ||
| ImproveAccuracy(gun, gunComp); | ||
| break; | ||
| case 2: | ||
| ImproveFireRate(gun, gunComp); | ||
| break; | ||
| case 3: | ||
| ImproveProjectileSpeed(gun, gunComp); | ||
| break; | ||
| } | ||
| rarity--; | ||
| } | ||
| } | ||
|
|
||
| private void ImproveAccuracy(EntityUid gun, GunComponent? gunComp) | ||
| { | ||
| if (!Resolve(gun, ref gunComp)) | ||
| return; | ||
|
|
||
| var buff = 1 - _random.NextFloat(0.15f, 0.35f); | ||
|
|
||
| gunComp.MinAngle *= buff; | ||
| gunComp.MinAngleModified *= buff; | ||
| gunComp.MaxAngle *= buff; | ||
| gunComp.MaxAngleModified *= buff; | ||
| gunComp.AngleIncrease *= buff; | ||
| gunComp.AngleIncreaseModified *= buff; | ||
| gunComp.AngleDecay *= 1 / buff; | ||
| gunComp.AngleDecayModified *= 1 / buff; | ||
| } | ||
|
|
||
| private void ImproveFireRate(EntityUid gun, GunComponent? gunComp) | ||
| { | ||
| if (!Resolve(gun, ref gunComp)) | ||
| return; | ||
|
|
||
| var buff = 1 + _random.NextFloat(0.15f, 0.35f); | ||
|
|
||
| gunComp.FireRate *= buff; | ||
| gunComp.FireRateModified *= buff; | ||
| } | ||
|
|
||
| private void ImproveProjectileSpeed(EntityUid gun, GunComponent? gunComp) | ||
| { | ||
| if (!Resolve(gun, ref gunComp)) | ||
| return; | ||
|
|
||
| var buff = 1 + _random.NextFloat(0.15f, 0.35f); | ||
|
|
||
| gunComp.ProjectileSpeed *= buff; | ||
| gunComp.ProjectileSpeedModified *= buff; | ||
| } | ||
|
|
||
| private void RenameGun(EntityUid gun, int rarity) | ||
| { | ||
| var datasetUncommon = _protoMan.Index<LocalizedDatasetPrototype>("NFNamesGunsUncommon"); | ||
| var datasetRare = _protoMan.Index<LocalizedDatasetPrototype>("NFNamesGunsRare"); | ||
| var datasetEpic = _protoMan.Index<LocalizedDatasetPrototype>("NFNamesGunsEpic"); | ||
|
|
||
| var meta = MetaData(gun); | ||
|
|
||
| if (rarity == 1) | ||
| { | ||
| var pick = _random.Pick(datasetUncommon.Values); | ||
| var newName = Loc.GetString(pick) + " " + meta.EntityName; | ||
| _metaSystem.SetEntityName(gun, newName, meta, false); | ||
| } | ||
| else if (rarity == 2) | ||
| { | ||
| var pick1 = _random.Pick(datasetUncommon.Values); | ||
| var pick2 = _random.Pick(datasetRare.Values); | ||
| var newName = Loc.GetString(pick2) + " " + Loc.GetString(pick1)+ " " + meta.EntityName; | ||
| _metaSystem.SetEntityName(gun, newName, meta, false); | ||
| } | ||
| else if (rarity >= 3) | ||
| { | ||
| var pick = _random.Pick(datasetEpic.Values); | ||
| _metaSystem.SetEntityName(gun, Loc.GetString(pick), meta, false); | ||
| } | ||
| } | ||
| } | ||
Cheackraze marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| adjectives-nf-gun-uncommon-1 = Sturdy | ||
| adjectives-nf-gun-uncommon-2 = Keen | ||
| adjectives-nf-gun-uncommon-3 = Swift | ||
| adjectives-nf-gun-uncommon-4 = Resilient | ||
| adjectives-nf-gun-uncommon-5 = Hardened | ||
| adjectives-nf-gun-uncommon-6 = Steady | ||
| adjectives-nf-gun-uncommon-7 = Tactical | ||
| adjectives-nf-gun-uncommon-8 = Precision | ||
| adjectives-nf-gun-uncommon-9 = Enhanced | ||
| adjectives-nf-gun-uncommon-10 = Refined | ||
| adjectives-nf-gun-uncommon-11 = Reinforced | ||
| adjectives-nf-gun-uncommon-12 = Stabilized | ||
|
|
||
| adjectives-nf-gun-rare-1 = Deadly | ||
| adjectives-nf-gun-rare-2 = Lethal | ||
| adjectives-nf-gun-rare-3 = Killer | ||
| adjectives-nf-gun-rare-4 = Legendary | ||
| adjectives-nf-gun-rare-5 = Pristine | ||
|
|
||
| names-nf-gun-epic-1 = Blaster Master 9000 | ||
| names-nf-gun-epic-2 = Chrono-Trigger | ||
| names-nf-gun-epic-3 = The Big Bang | ||
| names-nf-gun-epic-4 = Rekt-ifier | ||
| names-nf-gun-epic-5 = Boomstick | ||
| names-nf-gun-epic-6 = Shooty McShooterton | ||
| names-nf-gun-epic-7 = Insurance Policy | ||
| names-nf-gun-epic-8 = Big Friendly Gun | ||
| names-nf-gun-epic-9 = Little Friend | ||
| names-nf-gun-epic-10 = Second Opinion | ||
| names-nf-gun-epic-11 = The Negotiator | ||
| names-nf-gun-epic-12 = Chamber of Justice | ||
| names-nf-gun-epic-13 = Ms. Fire | ||
| names-nf-gun-epic-14 = The Long Shot | ||
| names-nf-gun-epic-15 = The Last Resort | ||
| names-nf-gun-epic-16 = Big Bertha | ||
| names-nf-gun-epic-17 = Voight-Kampf | ||
| names-nf-gun-epic-18 = Rooty Tooty Big And Shooty | ||
| names-nf-gun-epic-19 = Plan B | ||
| names-nf-gun-epic-20 = Plan C | ||
Cheackraze marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.