Skip to content

Commit

Permalink
Adding functionality for plasma cutters (#327)
Browse files Browse the repository at this point in the history
* Plasma-recharge system for cutters

* Cutters rebalance

* Asteroid rock fix

* Remove ATLAS from pull, yea (#326)

* How did it get here?

* Shit happens

* Cutters system upgrade

* Add funny shape for cutters (+RP)

* Adv cutter recipe & craft nerf

* "Ion cutters" are no more!

* "shitty code" is now less "shitty"

* "Equipment" to "Weapon"

* Clear code

* Add `technologyPrerequisites:`

* I don't know how this happen

* `AddCharge` raises localevent now
# Conflicts:
#	Resources/Locale/en-US/research/technologies.ftl
#	Resources/Locale/en-US/ss14-ru/prototypes/entities/objects/weapons/guns/battery/battery_guns.ftl
#	Resources/Locale/ru-RU/research/technologies.ftl
#	Resources/Locale/ru-RU/ss14-ru/prototypes/entities/objects/weapons/guns/battery/battery_guns.ftl
#	Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml
#	Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml
#	Resources/Prototypes/Entities/Structures/Machines/lathe.yml
#	Resources/Prototypes/Recipes/Lathes/security.yml
  • Loading branch information
Ratyyy committed Sep 11, 2024
1 parent dabf0f6 commit 8f29193
Show file tree
Hide file tree
Showing 34 changed files with 349 additions and 4 deletions.
27 changes: 27 additions & 0 deletions Content.Server/ADT/PlasmaCutter/BatteryRechargeComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
///TAKEN FROM: https://github.com/Workbench-Team/space-station-14/pull/327

namespace Content.Server.AruMoon.Plasmacutter;

[RegisterComponent]
public sealed partial class BatteryRechargeComponent : Component
{

/// <summary>
/// NOT (material.Amount * Multiplier)
/// This is (material.materialComposition * Multiplier)
/// 1 plasma sheet = 100 material units
/// 1 plasma ore = 500 material units
/// </summary>
///
[DataField("multiplier"), ViewVariables(VVAccess.ReadWrite)]
public float Multiplier = 1.0f;


/// <summary>
/// Max material storage limit
/// 7500 = 15 plasma ore
/// </summary>
[DataField("storageMaxCapacity"), ViewVariables(VVAccess.ReadWrite)]
public int StorageMaxCapacity = 7500;
}

74 changes: 74 additions & 0 deletions Content.Server/ADT/PlasmaCutter/BatteryRechargeSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
///TAKEN FROM: https://github.com/Workbench-Team/space-station-14/pull/327

using Content.Server.Materials;
using Content.Shared.Materials;
using Content.Server.Power.EntitySystems;
using Content.Server.Power.Components;

namespace Content.Server.AruMoon.Plasmacutter
{

/// <summary>
/// This CODE FULL OF SHICODE!!!
/// <see cref="BatteryRechargeComponent"/>
/// </summary>
public sealed class BatteryRechargeSystem : EntitySystem
{
[Dependency] private readonly MaterialStorageSystem _materialStorage = default!;
[Dependency] private readonly BatterySystem _batterySystem = default!;



public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<MaterialStorageComponent, MaterialEntityInsertedEvent>(OnMaterialAmountChanged);
SubscribeLocalEvent<BatteryRechargeComponent, ChargeChangedEvent>(OnChargeChanged);
}

private void OnMaterialAmountChanged(EntityUid uid, MaterialStorageComponent component, MaterialEntityInsertedEvent args)
{
if (component.MaterialWhiteList != null)
foreach (var fuelType in component.MaterialWhiteList)
{
FuelAddCharge(uid, fuelType);
}
}

private void OnChargeChanged(EntityUid uid, BatteryRechargeComponent component, ChargeChangedEvent args)
{
ChangeStorageLimit(uid, component.StorageMaxCapacity);
}

private void ChangeStorageLimit(
EntityUid uid,
int value,
BatteryComponent? battery = null)
{
if (!Resolve(uid, ref battery))
return;
if (battery.CurrentCharge == battery.MaxCharge)
value = 0;
_materialStorage.TryChangeStorageLimit(uid, value);
}

private void FuelAddCharge(
EntityUid uid,
string fuelType,
BatteryRechargeComponent? recharge = null)
{
if (!Resolve(uid, ref recharge))
return;

var availableMaterial = _materialStorage.GetMaterialAmount(uid, fuelType);
var chargePerMaterial = availableMaterial * recharge.Multiplier;

if (_materialStorage.TryChangeMaterialAmount(uid, fuelType, -availableMaterial))
{
_batterySystem.TryAddCharge(uid, chargePerMaterial);
}
}
}

}
20 changes: 20 additions & 0 deletions Content.Server/Power/EntitySystems/BatterySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,27 @@ public float UseCharge(EntityUid uid, float value, BatteryComponent? battery = n
RaiseLocalEvent(uid, ref ev);
return delta;
}
///ADT plasmacutters start
public float AddCharge(EntityUid uid, float value, BatteryComponent? battery = null)
{
if (value <= 0 || !Resolve(uid, ref battery))
return 0;

var newValue = Math.Clamp(battery.CurrentCharge + value, 0, battery.MaxCharge);
battery.CurrentCharge = newValue;
var ev = new ChargeChangedEvent(battery.CurrentCharge, battery.MaxCharge);
RaiseLocalEvent(uid, ref ev);
return newValue;
}
public bool TryAddCharge(EntityUid uid, float value, BatteryComponent? battery = null)
{
if (!Resolve(uid, ref battery, false))
return false;

AddCharge(uid, value, battery);
return true;
}
///ADT plasmacutters end
public void SetMaxCharge(EntityUid uid, float value, BatteryComponent? battery = null)
{
if (!Resolve(uid, ref battery))
Expand Down
13 changes: 13 additions & 0 deletions Content.Shared/Materials/SharedMaterialStorageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,17 @@ public int GetSheetVolume(MaterialPrototype material)

return composition.MaterialComposition.FirstOrDefault(kvp => kvp.Key == material.ID).Value;
}
///ADT plasmacutters start
public bool TryChangeStorageLimit(
EntityUid uid,
int value,
MaterialStorageComponent? storage = null)
{
if (!Resolve(uid, ref storage) || value < 0)
return false;

storage.StorageLimit = value;
return true;
}
///ADT plasmacutters end
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ ent-ADTWeaponLaserCarbineBorg = лазерная винтовка борга
.desc = от боргов, для боргов.
ent-ADTWeaponDisablerBorg = дизаблер борга
.desc = дизаблер, не требующий зарядки.
.desc = дизаблер, не требующий зарядки.
ent-ADTWeaponCutter = плазменный резак
.desc = Инструмент шахтеров, предназначенный для расчистки горных пород.
ent-ADTWeaponCutterAdv = улучшенный плазменный резак
.desc = Инструмент шахтеров, предназначенный для расчистки горных пород. Обладает усовершенствованной батареей и усиленной концентрирующей линзой.
1 change: 1 addition & 0 deletions Resources/Locale/ru-RU/ADT/prototypes/Research/arsenal.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
research-technology-salvage-weapons-adv = Продвинутое оружие утилизаторов
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,54 @@
- type: BatterySelfRecharger
autoRecharge: true
autoRechargeRate: 20

- type: entity
name: Cutter
parent: BaseWeaponBatterySmall
id: ADTWeaponCutter
description: A self-defense weapon that exhausts organic targets, weakening them until they collapse.
components:
- type: Item
size: Normal
shape:
- 0,1,0,2
- 1,1,1,1
- 2,0,2,2
- type: MaterialStorage
storageLimit: 0
materialWhiteList: [RawPlasma, Plasma]
canEjectStoredMaterial: false
- type: BatteryRecharge
multiplier: 1.25
- type: Sprite
sprite: ADT/Objects/Weapons/Guns/Battery/cutter.rsi
state: icon
- type: Gun
fireRate: 0.6
soundGunshot:
path: /Audio/Weapons/plasma_cutter.ogg
- type: ProjectileBatteryAmmoProvider
proto: ADTBulletCutter
fireCost: 100
- type: Battery
maxCharge: 2500
startingCharge: 2500
- type: Appearance

- type: entity
name: Advanced Cutter
parent: ADTWeaponCutter
id: ADTWeaponCutterAdv
description: A self-defense weapon that exhausts organic targets, weakening them until they collapse.
components:
- type: Sprite
sprite: ADT/Objects/Weapons/Guns/Battery/cutteradv.rsi
state: icon
- type: Gun
fireRate: 1
soundGunshot:
path: /Audio/Weapons/plasma_cutter.ogg
- type: ProjectileBatteryAmmoProvider
proto: ADTBulletCutterAdv
fireCost: 75
- type: Appearance
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,48 @@
soundHit:
path: /Audio/Weapons/Guns/Hits/snap.ogg
- type: StaminaDamageOnCollide
damage: 22 # 5 hits to stun sounds reasonable
damage: 22 # 5 hits to stun sounds reasonable

- type: entity
id: ADTBulletCutter
name: cutter bolt
parent: BaseBullet
noSpawn: true
description: Not too bad, but you still don't want to get hit by it.
components:
- type: Reflective
reflective:
- NonEnergy
- type: Sprite
noRot: false
sprite: Objects/Weapons/Guns/Projectiles/projectiles_tg.rsi
layers:
- state: omnilaser_greyscale
shader: unshaded
color: "#9f1e86"
- type: GatheringProjectile
amount: 40
- type: Projectile
deleteOnCollide: false
damage:
types:
Heat: 15
- type: TimedDespawn
lifetime: 0.2
- type: PointLight
radius: 2
color: purple
energy: 1

- type: entity
id: ADTBulletCutterAdv
name: cutter bolt advanced
parent: ADTBulletCutter
noSpawn: true
components:
- type: Projectile
damage:
types:
Heat: 20
- type: TimedDespawn
lifetime: 0.25
20 changes: 20 additions & 0 deletions Resources/Prototypes/ADT/Recipes/Lathes/armory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- type: latheRecipe
id: ADTWeaponCutter
result: ADTWeaponCutter
completetime: 10
materials:
Steel: 1100
Glass: 200
Gold: 300
Plasma: 800

- type: latheRecipe
id: ADTWeaponCutterAdv
result: ADTWeaponCutterAdv
completetime: 10
materials:
Steel: 1700
Glass: 200
Gold: 300
Plasma: 900
Diamond: 200
13 changes: 13 additions & 0 deletions Resources/Prototypes/ADT/Research/arsenal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- type: technology
id: AdvSalvageWeapons
name: research-technology-salvage-weapons-adv
icon:
sprite: ADT/Objects/Weapons/Guns/Battery/cutteradv.rsi
state: icon
discipline: Arsenal
tier: 2
cost: 10000
recipeUnlocks:
- ADTWeaponCutterAdv
technologyPrerequisites:
- SalvageWeapons
4 changes: 4 additions & 0 deletions Resources/Prototypes/Entities/Structures/Machines/lathe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@
- WeaponForceGun
- WeaponLaserSvalinn
- WeaponProtoKineticAccelerator
#ADT plasmacutters start
- ADTWeaponCutter
- ADTWeaponCutterAdv
#ADT plasmacutters end
- WeaponTetherGun
- ClothingBackpackHolding
- ClothingBackpackSatchelHolding
Expand Down
5 changes: 5 additions & 0 deletions Resources/Prototypes/Entities/Structures/Power/chargers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@
- HitscanBatteryAmmoProvider
- ProjectileBatteryAmmoProvider
- Stunbaton
blacklist: # ADT plasmacutters start
components:
- BatteryRecharge # ADT plasmacutters end

- type: entity
parent: BaseItemRecharger
Expand All @@ -191,6 +194,8 @@
blacklist:
tags:
- PotatoBattery
components: # ADT plasmacutters
- BatteryRecharge # ADT plasmacutters

- type: entity
parent: BaseItemRecharger
Expand Down
5 changes: 5 additions & 0 deletions Resources/Prototypes/Entities/Structures/Walls/asteroid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
path: /Audio/Effects/break_stone.ogg
params:
volume: -6
- type: SoundOnGather #ADT plasmacutters start
- type: Gatherable
toolWhitelist:
tags:
- Pickaxe #ADT plasmacutters end

# Ore veins
- type: entity
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Research/arsenal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
recipeUnlocks:
- WeaponProtoKineticAccelerator
- ShuttleGunKineticCircuitboard
- ADTWeaponCutter #ADT plasmacutter
# These are roundstart but not replenishable for salvage

- type: technology
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/2b8b045d5a237147d736e3ba3c77c8cc5fb66cb5",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8f29193

Please sign in to comment.