Skip to content
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

Blood cough #388

Merged
merged 16 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions Content.Server/ADT/BloodCough/BloodCoughSystem.cs
Schrodinger71 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using Content.Server.Chat.Systems;
using Content.Shared.ADT.BloodCough;
using Robust.Shared.Timing;
using Robust.Shared.Random;
using Content.Shared.Damage;
using Content.Server.Body.Components;
using Content.Shared.Mobs;
using Content.Shared.Chemistry.Components;
using Content.Server.Fluids.EntitySystems;
using Content.Shared.Mobs.Systems;
using Content.Shared.ADT.Silicon.Components;

public sealed class BloodCoughSystem : EntitySystem
{
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly IGameTiming _time = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly PuddleSystem _puddleSystem = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<BloodCoughComponent, DamageChangedEvent>(OnMobStateDamage);
}

private void OnMobStateDamage(EntityUid uid, BloodCoughComponent component, DamageChangedEvent args)
{
if (EntityManager.TryGetComponent<DamageableComponent>(uid, out var damageable))
{
var currentDamage = damageable.TotalDamage;
if (currentDamage > 70)
{
if (TryComp<BloodCoughComponent>(uid, out var posting))
{
posting.CheckCoughBlood = true;
}
}
if (currentDamage <= 70)
{
if (TryComp<BloodCoughComponent>(uid, out var posting))
{
posting.CheckCoughBlood = false;
}
}
}
else
{
Log.Debug($"Сущность {ToPrettyString(uid)} не имеет компонента BloodCoughComponent.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DamageableComponent а не BloodCoughComponent

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

блятьацацаца

}
}

public override void Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<BloodCoughComponent>();
while (query.MoveNext(out var uid, out var comp))
{
if (_mobState.IsAlive(uid))
{
if (_time.CurTime >= comp.NextSecond)
{
var delay = _random.Next(comp.CoughTimeMin, comp.CoughTimeMax);
if (comp.PostingSayDamage != null)
{
if (comp.CheckCoughBlood)
{
_chat.TrySendInGameICMessage(uid, Loc.GetString(comp.PostingSayDamage), InGameICChatType.Emote, ChatTransmitRange.HideChat);
if (comp.CheckCoughBlood && TryComp<BloodstreamComponent>(uid, out var bloodId) && !TryComp<SiliconComponent>(uid, out var _)) //лютейший костыль, тут проверка, потому что у кпб в крови ВОДА и при кашле он воду спавнит. поэтому сущности с SiliconComponent игнорим
{
Solution blood = new();
blood.AddReagent(bloodId.BloodReagent, 1);
_puddleSystem.TrySpillAt(uid, blood, out _, sound: false);
}
}
}
comp.NextSecond = _time.CurTime + TimeSpan.FromSeconds(delay);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed partial class AutoEmotePostingChatComponent : Component
public int EmoteTimerRead = 9;

[DataField("emoteMessage")]
public string? PostingMessageEmote = "Кхе";
public string? PostingMessageEmote = default;

[DataField("randomIntervalEmote"), ViewVariables(VVAccess.ReadWrite)]
public bool RandomIntervalEmote = false;
Expand All @@ -23,6 +23,4 @@ public sealed partial class AutoEmotePostingChatComponent : Component

[DataField("min"), ViewVariables(VVAccess.ReadWrite)]
public int IntervalRandomEmoteMin = 2;


}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed partial class AutoSpeakPostingChatComponent : Component
public int SpeakTimerRead = 10;

[DataField("speakMessage")]
public string? PostingMessageSpeak = "Вульп-вульп!";
public string? PostingMessageSpeak = default;

[DataField("randomIntervalSpeak"), ViewVariables(VVAccess.ReadWrite)]
public bool RandomIntervalSpeak = false;
Expand Down
22 changes: 22 additions & 0 deletions Content.Shared/ADT/BloodCough/BloodCoughComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared.ADT.BloodCough;

[RegisterComponent]
[NetworkedComponent]
public sealed partial class BloodCoughComponent : Component
{
public TimeSpan NextSecond = TimeSpan.Zero;

[DataField("coughTimeMin"), ViewVariables(VVAccess.ReadWrite)]
public int CoughTimeMin = 11;

[DataField("coughTimeMax"), ViewVariables(VVAccess.ReadWrite)]
public int CoughTimeMax = 17;

[DataField("postingSayDamage")]
public string? PostingSayDamage = default;

public bool CheckCoughBlood = false;
}
3 changes: 3 additions & 0 deletions Resources/Locale/ru-RU/ADT/Chat/blood-cough-system.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
blood-cough = Кашляет кровью.
blood-cough-ipc = Искрит и раздраженно жужит.
blood-cough-novakid = Кашляет плазмой.
4 changes: 3 additions & 1 deletion Resources/Prototypes/ADT/Entities/Mobs/Player/ipc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@
shortscale: 0.9
- type: CanEnterCryostorage
- type: Crawler

- type: BloodCough
postingSayDamage: blood-cough-ipc

- type: entity
save: false
name: Urist McPositronic
Expand Down
1 change: 0 additions & 1 deletion Resources/Prototypes/ADT/Entities/Mobs/Player/kobalt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@
tallscale: 1.1
short: true
shortscale: 0.9

2 changes: 2 additions & 0 deletions Resources/Prototypes/ADT/Entities/Mobs/Player/novakid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
tallscale: 1.1
short: true
shortscale: 0.9
- type: BloodCough
postingSayDamage: blood-cough-novakid

#Weh
1 change: 1 addition & 0 deletions Resources/Prototypes/ADT/Voice/speech_emotes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,4 @@
- раздражённо жужжит.
- раздраженно жужжит
- раздраженно жужжит.
- искрит и раздраженно жужит. # ADT-Tweak-BloodCough
2 changes: 1 addition & 1 deletion Resources/Prototypes/Entities/Mobs/Player/diona.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
name: Reformed Diona
components:
- type: IsDeadIC
- type: RandomHumanoidAppearance
- type: RandomHumanoidAppearance
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Mobs/Species/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@
Asphyxiation: -1.0
- type: FireVisuals
alternateState: Standing
- type: BloodCough # ADT Tweak
postingSayDamage: blood-cough

- type: entity
save: false
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Voice/disease_emotes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
- кашель
- кашляет
# Corvax-Localization-End
# Start-ADT-Tweak-AddComp-BloodCough
- Кашляет кровью.
- Кашляет плазмой.
# End-ADT-Tweak-AddComp-BloodCough

- type: emote
id: CatMeow
Expand Down
Loading