from dust we came to dust we shall return

This commit is contained in:
BIGZi0348
2024-11-24 22:12:50 +03:00
parent 4af9112264
commit 7340f36489
14 changed files with 340 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
using Robust.Shared.Prototypes;
using Content.Shared.Damage;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Content.Shared.Chat.Prototypes;
using Robust.Shared.Audio;
namespace Content.Server._White._Engi.Suhariki;
/// <summary>
/// Makes you loose your tooth and have funny accent.
/// WD Engi Exclusive.
/// </summary>
[RegisterComponent, Access(typeof(SuharikiSystem))]
public sealed partial class SuharikiComponent : Component
{
/// <summary>
/// Amount and type of damage that will be dealt on event.
/// </summary>
[DataField(required: true)]
[ViewVariables(VVAccess.ReadWrite)]
public DamageSpecifier Damage = new();
/// <summary>
/// Chance of event activation.
/// </summary>
[DataField]
public float Chance = 0;
/// <summary>
/// Amount of rolls for event.
/// </summary>
[DataField]
public int StonesInFood = 1;
/// <summary>
/// The prototype that will be spawned on event.
/// </summary>
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>)), ViewVariables(VVAccess.ReadWrite)]
public string HoldingPrototype = "SuharikiTooth";
/// <summary>
/// Emote triggered on event.
/// </summary>
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<EmotePrototype>))]
public string EmoteId = "Scream";
/// <summary>
/// Sound triggered on event.
/// </summary>
[DataField]
public SoundSpecifier UseSound { get; set; } = new SoundPathSpecifier("/Audio/White/_Engi/Object/Misc/Suhariki/tooth_break.ogg");
}

View File

@@ -0,0 +1,152 @@
using Content.Server.Inventory;
using Content.Server.Nutrition.Components;
using Content.Server.Popups;
using Content.Shared.Interaction.Events;
using Content.Shared.Nutrition.EntitySystems;
using Robust.Shared.Random;
using Content.Shared.Damage;
using Content.Server.Effects;
using Robust.Shared.Player;
using Content.Server.Administration.Logs;
using Content.Shared.Database;
using Content.Server.Chat.Systems;
using Content.Server.Nutrition.EntitySystems;
using Robust.Shared.Timing;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Content.Shared.Verbs;
using Robust.Shared.Utility;
using Content.Shared.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Body.Components;
using Content.Server.Speech.Components;
namespace Content.Server._White._Engi.Suhariki;
/// <summary>
/// WD Engi Exclusive.
/// </summary>
public sealed class SuharikiSystem : EntitySystem
{
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly ColorFlashEffectSystem _color = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly FoodSystem _food = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly BodySystem _body = default!;
private EntityQuery<MetaDataComponent> _metaQuery;
public override void Initialize()
{
base.Initialize();
_metaQuery = GetEntityQuery<MetaDataComponent>();
SubscribeLocalEvent<SuharikiComponent, UseInHandEvent>(OnUseInHand, after: new[] { typeof(OpenableSystem), typeof(ServerInventorySystem) });
SubscribeLocalEvent<SuharikiComponent, GetVerbsEvent<AlternativeVerb>>(AddEatVerb);
}
private void OnUseInHand(Entity<SuharikiComponent> entity, ref UseInHandEvent ev)
{
if (ev.Handled)
return;
var result = TryUse(ev.User, ev.User, entity, entity.Comp);
ev.Handled = result.Handled;
}
private (bool Success, bool Handled) TryUse(EntityUid user, EntityUid target, EntityUid food, SuharikiComponent scomponent)
{
var foodComponents = _metaQuery.GetComponent(food).EntityPrototype;
if (foodComponents == null)
return (false, false);
foodComponents.Components.TryGetComponent("Food", out var component);
if (component == null)
return (false, false);
// idk what I'm doing but otherwise the owner is "0" and it throws fatal error
component.Owner = food;
var result = _food.TryFeed(user, target, food, (FoodComponent) component);
if (result.Success)
Timer.Spawn(300, () => RollEvent(scomponent, user));
return (true, true);
}
private void RollEvent(SuharikiComponent scomponent, EntityUid user)
{
if (scomponent.StonesInFood < 1)
return;
scomponent.StonesInFood -= 1;
// Pseudorandom shit
if (!_random.Prob(scomponent.Chance))
return;
// Normally slimes don't care about hard food
var whomst = _metaQuery.GetComponent(user).EntityPrototype;
var isUserSlime = whomst!.ID.Contains("slime", StringComparison.OrdinalIgnoreCase);
if (isUserSlime)
return;
var modifiedDamage = _damageableSystem.TryChangeDamage(user, scomponent.Damage, true);
var deleted = Deleted(user);
if (modifiedDamage is null || !EntityManager.EntityExists(user))
return;
if (!modifiedDamage.Any() || deleted)
return;
// Damaging the user with appropriate effects
var stringTopopup = Loc.GetString("suhariki-lost", ("user", user));
_popup.PopupEntity(Name(user) + " " + stringTopopup, user, Shared.Popups.PopupType.LargeCaution);
_color.RaiseEffect(Color.Red, new List<EntityUid> { user }, Filter.Pvs(user, entityManager: EntityManager));
_audio.PlayPvs(scomponent.UseSound, user, AudioParams.Default.WithVolume(-1f));
_adminLogger.Add(LogType.Damaged,
LogImpact.Medium,
$"This idiot {ToPrettyString(user):user} tried to eat Suhariki and lost tooth, received {modifiedDamage.GetTotal():damage} damage and recieved FrontalLisp accent");
// Spawns prototype
var coords = Transform(user).Coordinates;
Spawn(scomponent.HoldingPrototype, coords.Offset(_random.NextVector2(0.2f)));
// Scream
Timer.Spawn(300, () => _chat.TryEmoteWithChat(user, scomponent.EmoteId));
// Adding FrontalLisp accent
EnsureComp<FrontalLispComponent>(user);
return;
}
private void AddEatVerb(Entity<SuharikiComponent> entity, ref GetVerbsEvent<AlternativeVerb> ev)
{
if (entity.Owner == ev.User ||
!ev.CanInteract ||
!ev.CanAccess ||
!TryComp<BodyComponent>(ev.User, out var body) ||
!_body.TryGetBodyOrganComponents<StomachComponent>(ev.User, out var stomachs))
return;
var user = ev.User;
AlternativeVerb verb = new()
{
Act = () =>
{
TryUse(user, user, entity, entity.Comp);
},
Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/cutlery.svg.192dpi.png")),
Text = Loc.GetString("food-system-verb-eat"),
Priority = -1
};
ev.Verbs.Add(verb);
}
}

View File

@@ -105,3 +105,9 @@
type: Add
id: 16
time: '2024-11-21T18:00:13.0000000+00:00'
- author: BIG_Zi_348
changes:
- message: "Сухарики всегда были на станции, надо просто поискать их в технических туннелях и может быть, вам повезёт."
type: Add
id: 17
time: '2024-11-24T18:00:13.0000000+00:00'

View File

@@ -0,0 +1,7 @@
ent-FoodSnackSuhariki = сухарики
.desc = Старая реликвия из прошлого, на этикетке едва можно прочитать слово «Кириешки».
ent-FoodPacketSuharikiTrash = упаковка от сухариков
ent-SuharikiTooth = зуб
.desc = Может быть он твой, а может и не твой.
suhariki-lost = сломал свой зуб!

View File

@@ -186,6 +186,8 @@
prob: 0.10
- id: BarberScissors
prob: 0.05
- id: FoodSnackSuhariki # WD from Engi to Amour
prob: 0.10
# Syndicate loot
- id: null
prob: 0.95
@@ -594,6 +596,8 @@
prob: 0.10
- id: BarberScissors
prob: 0.05
- id: FoodSnackSuhariki # WD from Engi to Amour
prob: 0.10
# Syndicate loot
- id: null
prob: 0.95

View File

@@ -45,5 +45,6 @@
- FoodFrozenSnowconeRainbow
- FoodSnackPistachios
- FoodSnackSemki
- FoodSnackSuhariki # WD from Engi to Amour
chance: 0.8
offset: 0.0

View File

@@ -0,0 +1,78 @@
# WD Engi Exclusive
- type: entity
parent: BaseItem
id: FoodSnackSuhariki
name: suhariki
description: Old relic of the past, you can barely read the label "Kirieshki".
components:
- type: Food
trash: FoodPacketSuharikiTrash
- type: FlavorProfile
flavors:
- cheap
- bread
- type: Sprite
sprite: White/_Engi/Objects/Consumable/Food/Suhariki/suhariki.rsi
state: suhariki
- type: Tag
tags:
- FoodSnack
- type: BadFood
- type: Suhariki
chance: 0.25
damage:
types:
Blunt: 10
- type: Item
size: Tiny
sprite: White/_Engi/Objects/Consumable/Food/Suhariki/suhariki.rsi
heldPrefix: suhariki
- type: SolutionContainerManager
solutions:
food:
maxVol: 5 # No extra room for condiments
reagents:
- ReagentId: Nutriment
Quantity: 1
- ReagentId: Omnizine
Quantity: 4
- type: SpaceGarbage
- type: StaticPrice
price: 500
- type: entity
noSpawn: true
parent: FoodPacketTrash
id: FoodPacketSuharikiTrash
name: suhariki bag
components:
- type: Sprite
sprite: White/_Engi/Objects/Consumable/Food/Suhariki/suhariki.rsi
state: suhariki-trash
- type: Item
size: Tiny
sprite: White/_Engi/Objects/Consumable/Food/Suhariki/suhariki.rsi
heldPrefix: suhariki
- type: entity
noSpawn: true
name: Зуб
parent: BaseItem
id: SuharikiTooth
description: Может быть он твой, а может и не твой.
components:
- type: Sprite
sprite: White/_Engi/Objects/Consumable/Food/Suhariki/tooth.rsi
state: icon
- type: Item
size: Tiny
- type: EmitSoundOnLand
sound:
path: /Audio/White/_Engi/Object/Misc/Suhariki/tooth_drop_1.ogg
- type: EmitSoundOnCollide
sound:
path: /Audio/White/_Engi/Object/Misc/Suhariki/tooth_drop_2.ogg
- type: SpaceGarbage
- type: StaticPrice
price: 100

View File

@@ -0,0 +1,25 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "deadisko and BIG_Zi_348",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "suhariki"
},
{
"name": "suhariki-trash"
},
{
"name": "suhariki-inhand-right",
"directions": 4
},
{
"name": "suhariki-inhand-left",
"directions": 4
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,14 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "xd",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
}
]
}