Всякие приколы с телекристаллами (#564)

* Crossbow telecrystal

* Other stuff

* Less power
This commit is contained in:
Aviu00
2023-12-11 18:11:48 +09:00
committed by Aviu00
parent d84f0896d5
commit 44efb7f6d9
10 changed files with 73 additions and 7 deletions

View File

@@ -1,5 +1,10 @@
using Content.Server.Body.Systems; using System.Linq;
using Content.Server.Body.Systems;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.Ghost.Components;
using Content.Server.Kitchen.Components; using Content.Server.Kitchen.Components;
using Content.Server.Mind.Components;
using Content.Server.Roles;
using Content.Shared.Body.Components; using Content.Shared.Body.Components;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Nutrition.Components; using Content.Shared.Nutrition.Components;
@@ -59,6 +64,16 @@ public sealed class SharpSystem : EntitySystem
return; return;
} }
// WD START
if (butcher.SyndieRoleRequired && !HasComp<NukeOperativeComponent>(user) && !HasComp<GhostComponent>(user) &&
TryComp(user, out MindContainerComponent? mc) && mc.Mind != null &&
!mc.Mind.Roles.OfType<TraitorRole>().Any())
{
_popupSystem.PopupEntity("Вы не можете разделать столь милое существо.", user, user);
return;
}
// WD END
if (TryComp<MobStateComponent>(target, out var mobState) && !_mobStateSystem.IsDead(target, mobState)) if (TryComp<MobStateComponent>(target, out var mobState) && !_mobStateSystem.IsDead(target, mobState))
return; return;

View File

@@ -14,6 +14,7 @@ public sealed class PoweredSystem : EntitySystem
[Dependency] private readonly BatterySystem _battery = default!; [Dependency] private readonly BatterySystem _battery = default!;
private const string CellSlot = "cell_slot"; private const string CellSlot = "cell_slot";
private const string CrystalSlot = "crystal_slot";
public override void Initialize() public override void Initialize()
{ {
@@ -27,7 +28,7 @@ public sealed class PoweredSystem : EntitySystem
if (!TryGetBatteryComponent(uid, out var battery, out var batteryUid)) if (!TryGetBatteryComponent(uid, out var battery, out var batteryUid))
return; return;
var (factor, charge) = GetFactor(component, battery, batteryUid.Value); var (factor, charge) = GetFactor(uid, component, battery, batteryUid.Value);
// Чтобы затриггерить взрыв на полную мощь, если есть плазма в батарейке // Чтобы затриггерить взрыв на полную мощь, если есть плазма в батарейке
_battery.SetCharge(batteryUid.Value, battery.CurrentCharge, battery); _battery.SetCharge(batteryUid.Value, battery.CurrentCharge, battery);
@@ -54,17 +55,24 @@ public sealed class PoweredSystem : EntitySystem
!TryGetBatteryComponent(uid, out var battery, out var batteryUid)) !TryGetBatteryComponent(uid, out var battery, out var batteryUid))
return 1f; return 1f;
return 1f + GetFactor(component, battery, batteryUid.Value).Item1; return 1f + GetFactor(uid, component, battery, batteryUid.Value).Item1;
} }
private (float, float) GetFactor(PoweredComponent component, BatteryComponent battery, EntityUid batteryUid) private (float, float) GetFactor(EntityUid uid, PoweredComponent component, BatteryComponent battery, EntityUid batteryUid)
{ {
DebugTools.Assert(component.Charge != 0f); DebugTools.Assert(component.Charge != 0f);
var charge = MathF.Min(battery.CurrentCharge, component.Charge); var charge = MathF.Min(battery.CurrentCharge, component.Charge);
var factor = charge / component.Charge; var factor = charge / component.Charge;
var multiplier = 1f;
if (TryComp(batteryUid, out RiggableComponent? rig) && rig.IsRigged) if (TryComp(batteryUid, out RiggableComponent? rig) && rig.IsRigged)
factor *= 2f; multiplier += 1f;
if (_containers.TryGetContainer(uid, CrystalSlot, out var container) && container is ContainerSlot slot &&
slot.ContainedEntity.HasValue)
multiplier += 1f;
factor *= multiplier;
return (factor, charge); return (factor, charge);
} }

View File

@@ -219,6 +219,9 @@ namespace Content.Shared.Containers.ItemSlots
[DataField("priority")] [DataField("priority")]
public int Priority = 0; public int Priority = 0;
[DataField("maxStackAmount")] // WD
public int MaxStackAmount;
/// <summary> /// <summary>
/// If false, errors when adding an item slot with a duplicate key are suppressed. Local==true implies that /// If false, errors when adding an item slot with a duplicate key are suppressed. Local==true implies that
/// the slot was added via client component state handling. /// the slot was added via client component state handling.

View File

@@ -8,6 +8,7 @@ using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Stacks;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems; using Robust.Shared.Audio.Systems;
@@ -206,6 +207,20 @@ namespace Content.Shared.Containers.ItemSlots
if (!CanInsert(uid, args.Used, args.User, slot, swap: slot.Swap, popup: args.User)) if (!CanInsert(uid, args.Used, args.User, slot, swap: slot.Swap, popup: args.User))
continue; continue;
// WD START
if (slot.MaxStackAmount > 0 && TryComp(args.Used, out StackComponent? stack) &&
stack.Count > slot.MaxStackAmount)
{
if (_netManager.IsClient && _timing.IsFirstTimePredicted)
{
_popupSystem.PopupEntity(
$"Невозможно одновременно вставить {stack.Count}, максимум: {slot.MaxStackAmount}.", uid,
args.User);
}
continue;
}
// WD END
// Drop the held item onto the floor. Return if the user cannot drop. // Drop the held item onto the floor. Return if the user cannot drop.
if (!_handsSystem.TryDrop(args.User, args.Used, handsComp: hands)) if (!_handsSystem.TryDrop(args.User, args.Used, handsComp: hands))
return; return;

View File

@@ -18,6 +18,9 @@ namespace Content.Shared.Nutrition.Components
[ViewVariables(VVAccess.ReadWrite), DataField("butcheringType")] [ViewVariables(VVAccess.ReadWrite), DataField("butcheringType")]
public ButcheringType Type = ButcheringType.Knife; public ButcheringType Type = ButcheringType.Knife;
[DataField("syndieRoleRequired")] // WD
public bool SyndieRoleRequired;
/// <summary> /// <summary>
/// Prevents butchering same entity on two and more spikes simultaneously and multiple doAfters on the same Spike /// Prevents butchering same entity on two and more spikes simultaneously and multiple doAfters on the same Spike
/// </summary> /// </summary>

View File

@@ -531,6 +531,7 @@
interactSuccessSound: interactSuccessSound:
path: /Audio/Animals/fox_squeak.ogg path: /Audio/Animals/fox_squeak.ogg
- type: Butcherable - type: Butcherable
syndieRoleRequired: true
spawned: spawned:
- id: FoodMeat - id: FoodMeat
amount: 3 amount: 3

View File

@@ -21,6 +21,9 @@
- type: Currency - type: Currency
price: price:
Telecrystal: 1 Telecrystal: 1
- type: Tag
tags:
- Telecrystal
- type: entity - type: entity
parent: Telecrystal parent: Telecrystal

View File

@@ -34,17 +34,24 @@
ballistic-ammo: !type:Container ballistic-ammo: !type:Container
ents: [] ents: []
cell_slot: !type:ContainerSlot cell_slot: !type:ContainerSlot
crystal_slot: !type:ContainerSlot
- type: PowerCellSlot - type: PowerCellSlot
cellSlotId: cell_slot cellSlotId: cell_slot
- type: ItemSlots - type: ItemSlots
slots: slots:
cell_slot: cell_slot:
name: power-cell-slot-component-slot-name-default name: power-cell-slot-component-slot-name-default
crystal_slot:
name: Кристалл
whitelist:
tags:
- Telecrystal
maxStackAmount: 1
- type: Drawable - type: Drawable
- type: Appearance - type: Appearance
- type: ModifyDamageOnShoot - type: ModifyDamageOnShoot
addEmbedding: true addEmbedding: true
offset: 0.2,0.2 offset: 0.1,0.1
damage: damage:
types: types:
Piercing: 15 Piercing: 15

View File

@@ -119,6 +119,14 @@
- to: snatcherprod - to: snatcherprod
steps: steps:
- material: Telecrystal - material: Telecrystal
traitorOnly: true
- node: snatcherprod - node: snatcherprod
entity: Snatcherprod entity: Snatcherprod
edges:
- to: rod
steps:
- tool: Cutting
doAfter: 5
completed:
- !type:SpawnPrototype
prototype: Telecrystal1
- !type:EmptyAllContainers

View File

@@ -39,3 +39,6 @@
- type: Tag - type: Tag
id: WallMountConsoleElectronics id: WallMountConsoleElectronics
- type: Tag
id: Telecrystal