From 699c55ab2e2f736de8b8e9d1f89175baf4a11441 Mon Sep 17 00:00:00 2001 From: BL02DL Date: Sat, 21 Dec 2024 15:45:15 +0700 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=2012?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Weapons/Ranged/Systems/GunSystem.cs | 48 ++++++++++++++++++- .../Projectiles/ProjectileSpreadComponent.cs | 32 +++++++++++++ .../Mobs/NPCs/mob_hostile_bloodcultist.yml | 8 ---- .../NPCs/mob_hostile_wizardfederation.yml | 3 -- .../Weapons/Guns/Crossbow/crossbow.yml | 2 +- .../Weapons/Throwable/throwable_weapons.yml | 2 +- .../Furniture/Armory/base_weapon_rack.yml | 1 - .../Structures/Machines/vending_machines.yml | 4 +- 8 files changed, 82 insertions(+), 18 deletions(-) create mode 100644 Content.Shared/Projectiles/ProjectileSpreadComponent.cs diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs index cbbfc289cf5..73edf3d8bc1 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs @@ -128,6 +128,14 @@ public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid? case CartridgeAmmoComponent cartridge: if (!cartridge.Spent) { + + /// Start _LostParadise + + var uid = Spawn(cartridge.Prototype, fromEnt); + CreateAndFireProjectiles(uid, cartridge); + + /// End _LostParadise + if (cartridge.Count > 1) { var ev = new GunGetAmmoSpreadEvent(cartridge.Spread); @@ -138,14 +146,12 @@ public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid? for (var i = 0; i < cartridge.Count; i++) { - var uid = Spawn(cartridge.Prototype, fromEnt); ShootOrThrow(uid, angles[i].ToVec(), gunVelocity, gun, gunUid, user); shotProjectiles.Add(uid); } } else { - var uid = Spawn(cartridge.Prototype, fromEnt); ShootOrThrow(uid, mapDirection, gunVelocity, gun, gunUid, user); shotProjectiles.Add(uid); } @@ -176,6 +182,9 @@ public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid? break; // Ammo shoots itself case AmmoComponent newAmmo: + if (ent == null) + break; + CreateAndFireProjectiles(ent.Value, newAmmo); shotProjectiles.Add(ent!.Value); MuzzleFlash(gunUid, newAmmo, mapDirection.ToAngle(), user); Audio.PlayPredicted(gun.SoundGunshotModified, gunUid, user); @@ -276,6 +285,41 @@ public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid? { FiredProjectiles = shotProjectiles, }); + + /// Start _LostParadise + + void CreateAndFireProjectiles(EntityUid ammoEnt, AmmoComponent ammoComp) + { + if (TryComp(ammoEnt, out var ammoSpreadComp)) + { + var spreadEvent = new GunGetAmmoSpreadEvent(ammoSpreadComp.Spread); + RaiseLocalEvent(gunUid, ref spreadEvent); + + var angles = LinearSpread(mapAngle - spreadEvent.Spread / 2, + mapAngle + spreadEvent.Spread / 2, ammoSpreadComp.Count); + + ShootOrThrow(ammoEnt, angles[0].ToVec(), gunVelocity, gun, gunUid, user); + shotProjectiles.Add(ammoEnt); + + for (var i = 1; i < ammoSpreadComp.Count; i++) + { + var newuid = Spawn(ammoSpreadComp.Proto, fromEnt); + ShootOrThrow(newuid, angles[i].ToVec(), gunVelocity, gun, gunUid, user); + shotProjectiles.Add(newuid); + } + } + else + { + ShootOrThrow(ammoEnt, mapDirection, gunVelocity, gun, gunUid, user); + shotProjectiles.Add(ammoEnt); + } + + MuzzleFlash(gunUid, ammoComp, mapDirection.ToAngle(), user); + Audio.PlayPredicted(gun.SoundGunshotModified, gunUid, user); + } + + /// End _LostParadise + } private void ShootOrThrow(EntityUid uid, Vector2 mapDirection, Vector2 gunVelocity, GunComponent gun, EntityUid gunUid, EntityUid? user) diff --git a/Content.Shared/Projectiles/ProjectileSpreadComponent.cs b/Content.Shared/Projectiles/ProjectileSpreadComponent.cs new file mode 100644 index 00000000000..1edffe3ba56 --- /dev/null +++ b/Content.Shared/Projectiles/ProjectileSpreadComponent.cs @@ -0,0 +1,32 @@ +using Content.Shared.Weapons.Ranged.Systems; +using Robust.Shared.GameStates; +using Robust.Shared.Prototypes; + +namespace Content.Shared.Projectiles; + +/// +/// Spawns a spread of the projectiles when fired +/// +[RegisterComponent, NetworkedComponent, Access(typeof(SharedGunSystem))] +public sealed partial class ProjectileSpreadComponent : Component +{ + /// + /// The entity prototype that will be fired by the rest of the spread. + /// Will generally be the same entity prototype as the first projectile being fired. + /// Needed for ammo components that do not specify a fired prototype, unlike cartridges. + /// + [DataField(required: true)] + public EntProtoId Proto; + + /// + /// How much the ammo spreads when shot, in degrees. Does nothing if count is 0. + /// + [DataField] + public Angle Spread = Angle.FromDegrees(5); + + /// + /// How many prototypes are spawned when shot. + /// + [DataField] + public int Count = 1; +} diff --git a/Resources/Prototypes/_LostParadise/Entities/Mobs/NPCs/mob_hostile_bloodcultist.yml b/Resources/Prototypes/_LostParadise/Entities/Mobs/NPCs/mob_hostile_bloodcultist.yml index 12c98354be9..f10680431fb 100644 --- a/Resources/Prototypes/_LostParadise/Entities/Mobs/NPCs/mob_hostile_bloodcultist.yml +++ b/Resources/Prototypes/_LostParadise/Entities/Mobs/NPCs/mob_hostile_bloodcultist.yml @@ -23,13 +23,11 @@ # Humans # Blood Cult Priest, ranged mab, bolts deal 10 slash damage -# Look for magic bolt here:\Resources\Prototypes\_NF\Entities\Objects\Weapons\Guns\Projectiles\magic.yml - type: entity name: blood cult priest parent: - MobBloodCultistBase - MobHumanoidHostileAISimpleRanged - #- MobLaserReflect # Added to prevent laser abuse from players id: MobBloodCultistPriest description: Enlightened by the whispers of The Void That Is, these individuals are initiated into secret rituals. They lead the blood harvest and perform rites, bringing the day when Nar'Sie rises ever closer. categories: [ HideSpawnMenu ] @@ -57,13 +55,11 @@ path: /Audio/Effects/Lightning/lightningshock.ogg # Blood Cult Janitor, ranged mab, bolts deal 10 slash damage -# Look for magic bolt here:\Resources\Prototypes\_NF\Entities\Objects\Weapons\Guns\Projectiles\magic.yml - type: entity name: blood cult janitor parent: - MobBloodCultistBase - MobHumanoidHostileAISimpleRanged - #- MobLaserReflect # Added to prevent laser abuse from players id: MobBloodCultistJanitor description: The fate of blood cults on space stations hinges on the actions of a single individual - the station janitor. This humble worker serves as the primary line of defense against the presence of blood cults, but even the most resolute individuals can be swayed by corruption. categories: [ HideSpawnMenu ] @@ -98,7 +94,6 @@ parent: - MobBloodCultistBase - MobHumanoidHostileAISimpleMelee - #- MobLaserReflect # Added to prevent laser abuse from players id: MobBloodCultistAcolyte description: |- The acolyte - The most trusted cult follower and bodyguard of a priest, clad in the finest armor the cult has to offer and armed with the most vile weapons: eldrich blades and unholy halberds. @@ -123,7 +118,6 @@ - BloodCultistZealotMeleeGear # Blood Cult Zealot, ranged mob, crossbow bolt deals 20 slash and 5 bloodloss -# Look for crossbow bolt here: \Resources\Prototypes\_NF\Entities\Objects\Weapons\Guns\Projectiles\crossbow_bolts.yml - type: entity name: blood cult zealot parent: @@ -155,7 +149,6 @@ collection: BulletMiss # Blood Cult Zealot, ranged mob, magic bolt deals 5 slash and 2 bloodloss -# Look for magic bolt here:\Resources\Prototypes\_LostParadise\Entities\Objects\Weapons\Guns\Projectiles\magic.yml - type: entity name: blood cult zealot parent: @@ -470,7 +463,6 @@ # Turrets # blood pylon, ranged, magic bolt deals 5 slash and 2 bloodloss -# Look for magic bolt here:\Resources\Prototypes\_NF\Entities\Objects\Weapons\Guns\Projectiles\magic.yml - type: entity parent: - BaseWeaponTurret diff --git a/Resources/Prototypes/_LostParadise/Entities/Mobs/NPCs/mob_hostile_wizardfederation.yml b/Resources/Prototypes/_LostParadise/Entities/Mobs/NPCs/mob_hostile_wizardfederation.yml index eb4a6e51beb..838c7dcd349 100644 --- a/Resources/Prototypes/_LostParadise/Entities/Mobs/NPCs/mob_hostile_wizardfederation.yml +++ b/Resources/Prototypes/_LostParadise/Entities/Mobs/NPCs/mob_hostile_wizardfederation.yml @@ -68,7 +68,6 @@ path: /Audio/_LostParadise/Effects/silence.ogg # Red Wizard, shoots magic bolts that put targets on fire (2 heat damage, 2 fire stacks) -# Look for magic bolt here:\Resources\Prototypes\_NF\Entities\Objects\Weapons\Guns\Projectiles\magic.yml - type: entity name: Red Wizard parent: MobWizFedlBase @@ -89,7 +88,6 @@ path: /Audio/Magic/fireball.ogg # Violet Wizard, shoots asphyxiation magic bolts (4 bloodloss, 4 asphyxiation) -# Look for magic bolt here:\Resources\Prototypes\_NF\Entities\Objects\Weapons\Guns\Projectiles\magic.yml - type: entity name: Violet Wizard parent: MobWizFedlBase @@ -114,7 +112,6 @@ path: /Audio/_LostParadise/Effects/silence.ogg # Soap Wizard, summons soap to slip targets -# Look for soap here: \Resources\Prototypes\_NF\Entities\Objects\Specific\Wizard\conjured_items.yml - type: entity name: Soap Wizard parent: MobWizFedlBase diff --git a/Resources/Prototypes/_LostParadise/Entities/Objects/Weapons/Guns/Crossbow/crossbow.yml b/Resources/Prototypes/_LostParadise/Entities/Objects/Weapons/Guns/Crossbow/crossbow.yml index 959c6ca3278..027bd8adcc3 100644 --- a/Resources/Prototypes/_LostParadise/Entities/Objects/Weapons/Guns/Crossbow/crossbow.yml +++ b/Resources/Prototypes/_LostParadise/Entities/Objects/Weapons/Guns/Crossbow/crossbow.yml @@ -1,7 +1,7 @@ - type: entity id: BaseCrossbow name: crossbow - parent: [ BaseItem, GunMeleeAttackBluntBase ] # \Resources\Prototypes\_NF\Entities\Objects\Weapons\Melee\base_melee_weapon.yml + parent: [ BaseItem, GunMeleeAttackBluntBase ] description: The original rooty tooty point and shooty. abstract: true components: diff --git a/Resources/Prototypes/_LostParadise/Entities/Objects/Weapons/Throwable/throwable_weapons.yml b/Resources/Prototypes/_LostParadise/Entities/Objects/Weapons/Throwable/throwable_weapons.yml index 54fa79536fc..2552442b714 100644 --- a/Resources/Prototypes/_LostParadise/Entities/Objects/Weapons/Throwable/throwable_weapons.yml +++ b/Resources/Prototypes/_LostParadise/Entities/Objects/Weapons/Throwable/throwable_weapons.yml @@ -7,7 +7,7 @@ - type: EmbeddableProjectile offset: -0.15,0.0 - type: Sprite - sprite: _NF/Mobs/Aliens/flesh.rsi + sprite: _LostParadise/Mobs/Aliens/flesh.rsi layers: - state: spike - state: spikeSolution1 diff --git a/Resources/Prototypes/_LostParadise/Entities/Structures/Furniture/Armory/base_weapon_rack.yml b/Resources/Prototypes/_LostParadise/Entities/Structures/Furniture/Armory/base_weapon_rack.yml index 19aa8bfd501..05532afa05e 100644 --- a/Resources/Prototypes/_LostParadise/Entities/Structures/Furniture/Armory/base_weapon_rack.yml +++ b/Resources/Prototypes/_LostParadise/Entities/Structures/Furniture/Armory/base_weapon_rack.yml @@ -1,5 +1,4 @@ # Base -# Localisation file \Resources\Locale\en-US\_NF\structure\weapon-racks.ftl - type: entity id: StructureWeaponRackBase name: weapon rack diff --git a/Resources/Prototypes/_LostParadise/Entities/Structures/Machines/vending_machines.yml b/Resources/Prototypes/_LostParadise/Entities/Structures/Machines/vending_machines.yml index 2c0c44e256e..07d6b30f6a4 100644 --- a/Resources/Prototypes/_LostParadise/Entities/Structures/Machines/vending_machines.yml +++ b/Resources/Prototypes/_LostParadise/Entities/Structures/Machines/vending_machines.yml @@ -798,7 +798,7 @@ # - type: entity # parent: # - VendingMachine -# - PunkHoloGraffitiOverlay # Prototype can be located at \Resources\Prototypes\_NF\Entities\Structures\Holographic\graffiti.yml +# - PunkHoloGraffitiOverlay # id: VendingMachineClothingPunk # name: ThreadsChoom # description: A vandalized ClothesMate. @@ -833,7 +833,7 @@ # - type: entity # parent: # - VendingMachine -# - PunkHoloGraffitiOverlay # Prototype can be located at \Resources\Prototypes\_NF\Entities\Structures\Holographic\graffiti.yml +# - PunkHoloGraffitiOverlay # id: VendingMachineBountyVendPunk # name: BonanzaMatic # description: A vandalised BountyVend.