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

Доработка вампира и мелочи #598

Merged
merged 23 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
33 changes: 25 additions & 8 deletions Content.Client/Vampire/VampireSystem.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
using System.Linq;
using Content.Client.Alerts;
using Content.Client.UserInterface.Systems.Alerts.Controls;
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
using Content.Shared.Vampire;
using Content.Shared.Vampire.Components;
using Content.Shared.StatusIcon.Components;
using Robust.Client.GameObjects;
using Robust.Shared.Prototypes;

namespace Content.Client.Vampire;

public sealed partial class VampireSystem : EntitySystem
public sealed class VampireSystem : EntitySystem
{

[Dependency] private readonly IPrototypeManager _prototype = default!;

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

SubscribeLocalEvent<VampireComponent, GetStatusIconsEvent>(GetVampireIcon);
SubscribeLocalEvent<VampireIconComponent, GetStatusIconsEvent>(GetVampireIcon);
SubscribeLocalEvent<VampireAlertComponent, UpdateAlertSpriteEvent>(OnUpdateAlert);
}

private void GetVampireIcon(Entity<VampireComponent> ent, ref GetStatusIconsEvent args)
{
var iconPrototype = _prototype.Index(ent.Comp.StatusIcon);
private void GetVampireIcon(EntityUid uid, VampireIconComponent component, ref GetStatusIconsEvent args)
{
var iconPrototype = _prototype.Index(component.StatusIcon);
args.StatusIcons.Add(iconPrototype);
}

private void OnUpdateAlert(EntityUid uid, VampireAlertComponent component, ref UpdateAlertSpriteEvent args)
{
if (args.Alert.ID != component.BloodAlert)
return;

var sprite = args.SpriteViewEnt.Comp;
var blood = Math.Clamp(component.BloodAmount, 0, 999);
sprite.LayerSetState(VampireVisualLayers.Digit1, $"{(blood / 100) % 10}");
sprite.LayerSetState(VampireVisualLayers.Digit2, $"{(blood / 10) % 10}");
sprite.LayerSetState(VampireVisualLayers.Digit3, $"{blood % 10}");
}
}
1 change: 1 addition & 0 deletions Content.IntegrationTests/Tests/PostMapInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public sealed class PostMapInitTest
"/Maps/Shuttles/cargo.yml",
"/Maps/Shuttles/emergency.yml",
"/Maps/Shuttles/infiltrator.yml",
"/Maps/_Sunrise/Shuttles/infiltrator.yml",
};

private static readonly string[] GameMaps =
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Administration/Managers/BanManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ public async void CreateServerBan(NetUserId? target, string? targetUsername, Net
("name", targetName),
("ip", addressRangeString),
("hwid", hwidString),
("reason", reason));
("reason", reason),
("round", roundId == null ? Loc.GetString("server-ban-unknown-round") : roundId));

_sawmill.Info(logMessage);
_chat.SendAdminAlert(logMessage);
Expand Down
5 changes: 5 additions & 0 deletions Content.Server/GameTicking/Rules/VampireRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Content.Server.Objectives;
using Content.Server.Roles;
using Content.Server.Vampire;
using Content.Shared.Alert;
using Content.Shared.Vampire.Components;
using Content.Shared.NPC.Prototypes;
using Content.Shared.NPC.Systems;
Expand All @@ -25,6 +26,7 @@ public sealed partial class VampireRuleSystem : GameRuleSystem<VampireRuleCompon
{
[Dependency] private readonly MindSystem _mind = default!;
[Dependency] private readonly AntagSelectionSystem _antag = default!;
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly SharedRoleSystem _role = default!;
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
[Dependency] private readonly ObjectivesSystem _objective = default!;
Expand Down Expand Up @@ -82,6 +84,8 @@ public bool MakeVampire(EntityUid target, VampireRuleComponent rule)

// make sure it's initial chems are set to max
var vampireComponent = EnsureComp<VampireComponent>(target);
EnsureComp<VampireIconComponent>(target);
var vampireAlertComponent = EnsureComp<VampireAlertComponent>(target);
var interfaceComponent = EnsureComp<UserInterfaceComponent>(target);

if (HasComp<UserInterfaceComponent>(target))
Expand All @@ -99,6 +103,7 @@ public bool MakeVampire(EntityUid target, VampireRuleComponent rule)

_vampire.AddStartingAbilities(vampire);
_vampire.MakeVulnerableToHoly(vampire);
_alerts.ShowAlert(vampire, vampireAlertComponent.BloodAlert);

Random random = new Random();

Expand Down
26 changes: 23 additions & 3 deletions Content.Server/Vampire/VampireSystem.Abilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Popups;
using Content.Shared.Polymorph;
using Content.Shared.Prying.Components;
using Content.Shared.Stealth.Components;
using Content.Shared.Store.Events;
Expand Down Expand Up @@ -324,10 +325,29 @@ private void Glare(Entity<VampireComponent> vampire, EntityUid? target, TimeSpan
}
private void PolymorphSelf(Entity<VampireComponent> vampire, string? polymorphTarget)
{
if (polymorphTarget == null)
if (string.IsNullOrEmpty(polymorphTarget))
return;

var prototypeId = polymorphTarget switch
{
"MobMouse" => "VampireMouse",
"mobBatVampire" => "VampireBat",
_ => null
};

if (prototypeId == null)
{
Logger.Warning($"Unknown polymorph target: {polymorphTarget}. Polymorph operation aborted.");
return;
}

if (!_prototypeManager.TryIndex<PolymorphPrototype>(prototypeId, out var prototype))
{
Logger.Warning($"Unknown prototype: {prototypeId}. Polymorph operation aborted.");
return;
}

_polymorph.PolymorphEntity(vampire, polymorphTarget);
_polymorph.PolymorphEntity(vampire, prototype);
}
private void BloodSteal(Entity<VampireComponent> vampire)
{
Expand Down Expand Up @@ -652,7 +672,7 @@ private void DrinkDoAfter(Entity<VampireComponent> entity, ref VampireDrinkBlood

if (_mind.TryGetMind(entity, out var mindId, out var mind))
if (_mind.TryGetObjectiveComp<BloodDrainConditionComponent>(mindId, out var objective, mind))
objective.BloodDranked += entity.Comp.TotalBloodDrank;
objective.BloodDranked = entity.Comp.TotalBloodDrank;

//Slurp
_audio.PlayPvs(entity.Comp.BloodDrainSound, entity.Owner, AudioParams.Default.WithVolume(-3f));
Expand Down
3 changes: 1 addition & 2 deletions Content.Server/Vampire/VampireSystem.Objectives.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ public sealed partial class VampireSystem

private void InitializeObjectives()
{

SubscribeLocalEvent<BloodDrainConditionComponent, ObjectiveGetProgressEvent>(OnBloodDrainGetProgress);
}

private void OnBloodDrainGetProgress(EntityUid uid, BloodDrainConditionComponent comp, ref ObjectiveGetProgressEvent args)
{
var target = _number.GetTarget(uid);
if (target != 0)
if (target > 0)
args.Progress = MathF.Min(comp.BloodDranked / target, 1f);
else args.Progress = 1f;
}
Expand Down
47 changes: 20 additions & 27 deletions Content.Server/Vampire/VampireSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public sealed partial class VampireSystem : EntitySystem
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly MetabolizerSystem _metabolism = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly SharedVampireSystem _vampire = default!;

private Dictionary<string, EntityUid> _actionEntities = new();

Expand Down Expand Up @@ -214,16 +215,19 @@ public void UpdateBloodDisplay(EntityUid vampire)

private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent component, VampireBloodChangedEvent args)
{
if (TryComp<VampireAlertComponent>(uid, out var alertComp))
_vampire.SetAlertBloodAmount(alertComp,_vampire.GetBloodEssence(uid).Int());

EntityUid? newEntity = null;
EntityUid entity = default;
// Mutations
if (GetBloodEssence(uid) >= FixedPoint2.New(50) && !_actionEntities.TryGetValue(VampireComponent.MutationsActionPrototype, out entity))
if (_vampire.GetBloodEssence(uid) >= FixedPoint2.New(50) && !_actionEntities.TryGetValue(VampireComponent.MutationsActionPrototype, out entity))
{
_action.AddAction(uid, ref newEntity, VampireComponent.MutationsActionPrototype);
if (newEntity != null)
_actionEntities[VampireComponent.MutationsActionPrototype] = newEntity.Value;
}
else if (GetBloodEssence(uid) < FixedPoint2.New(50) && _actionEntities.TryGetValue(VampireComponent.MutationsActionPrototype, out entity))
else if (_vampire.GetBloodEssence(uid) < FixedPoint2.New(50) && _actionEntities.TryGetValue(VampireComponent.MutationsActionPrototype, out entity))
{
if (!TryComp(uid, out ActionsComponent? comp))
return;
Expand All @@ -235,7 +239,7 @@ private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent componen

//Hemomancer

if (GetBloodEssence(uid) >= FixedPoint2.New(200) && !_actionEntities.TryGetValue("ActionVampireBloodSteal", out entity) && component.CurrentMutation == VampireMutationsType.Hemomancer)
if (_vampire.GetBloodEssence(uid) >= FixedPoint2.New(200) && !_actionEntities.TryGetValue("ActionVampireBloodSteal", out entity) && component.CurrentMutation == VampireMutationsType.Hemomancer)
{
_action.AddAction(uid, ref newEntity , "ActionVampireBloodSteal");
if (newEntity != null)
Expand All @@ -247,7 +251,7 @@ private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent componen
}
}
}
else if (GetBloodEssence(uid) < FixedPoint2.New(200) && _actionEntities.TryGetValue("ActionVampireBloodSteal", out entity))
else if (_vampire.GetBloodEssence(uid) < FixedPoint2.New(200) && _actionEntities.TryGetValue("ActionVampireBloodSteal", out entity))
{
if (!TryComp(uid, out ActionsComponent? comp))
return;
Expand All @@ -257,7 +261,7 @@ private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent componen
_actionEntities.Remove("ActionVampireBloodSteal");
}

if (GetBloodEssence(uid) >= FixedPoint2.New(300) && !_actionEntities.TryGetValue("ActionVampireScreech", out entity) && component.CurrentMutation == VampireMutationsType.Hemomancer)
if (_vampire.GetBloodEssence(uid) >= FixedPoint2.New(300) && !_actionEntities.TryGetValue("ActionVampireScreech", out entity) && component.CurrentMutation == VampireMutationsType.Hemomancer)
{
_action.AddAction(uid, ref newEntity , "ActionVampireScreech");
if (newEntity != null)
Expand All @@ -269,7 +273,7 @@ private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent componen
}
}
}
else if (GetBloodEssence(uid) < FixedPoint2.New(300) && _actionEntities.TryGetValue("ActionVampireScreech", out entity))
else if (_vampire.GetBloodEssence(uid) < FixedPoint2.New(300) && _actionEntities.TryGetValue("ActionVampireScreech", out entity))
{
if (!TryComp(uid, out ActionsComponent? comp))
return;
Expand All @@ -281,7 +285,7 @@ private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent componen

//Umbrae

if (GetBloodEssence(uid) >= FixedPoint2.New(200) && !_actionEntities.TryGetValue("ActionVampireGlare", out entity) && component.CurrentMutation == VampireMutationsType.Umbrae)
if (_vampire.GetBloodEssence(uid) >= FixedPoint2.New(200) && !_actionEntities.TryGetValue("ActionVampireGlare", out entity) && component.CurrentMutation == VampireMutationsType.Umbrae)
{
_action.AddAction(uid, ref newEntity , "ActionVampireGlare");
if (newEntity != null)
Expand All @@ -293,7 +297,7 @@ private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent componen
}
}
}
else if (GetBloodEssence(uid) < FixedPoint2.New(200) && _actionEntities.TryGetValue("ActionVampireGlare", out entity))
else if (_vampire.GetBloodEssence(uid) < FixedPoint2.New(200) && _actionEntities.TryGetValue("ActionVampireGlare", out entity))
{
if (!TryComp(uid, out ActionsComponent? comp))
return;
Expand All @@ -303,7 +307,7 @@ private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent componen
_actionEntities.Remove("ActionVampireGlare");
}

if (GetBloodEssence(uid) >= FixedPoint2.New(300) && !_actionEntities.TryGetValue("ActionVampireCloakOfDarkness", out entity) && component.CurrentMutation == VampireMutationsType.Umbrae)
if (_vampire.GetBloodEssence(uid) >= FixedPoint2.New(300) && !_actionEntities.TryGetValue("ActionVampireCloakOfDarkness", out entity) && component.CurrentMutation == VampireMutationsType.Umbrae)
{
_action.AddAction(uid, ref newEntity , "ActionVampireCloakOfDarkness");
if (newEntity != null)
Expand All @@ -315,7 +319,7 @@ private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent componen
}
}
}
else if (GetBloodEssence(uid) < FixedPoint2.New(300) && _actionEntities.TryGetValue("ActionVampireCloakOfDarkness", out entity))
else if (_vampire.GetBloodEssence(uid) < FixedPoint2.New(300) && _actionEntities.TryGetValue("ActionVampireCloakOfDarkness", out entity))
{
if (!TryComp(uid, out ActionsComponent? comp))
return;
Expand All @@ -327,7 +331,7 @@ private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent componen

//Gargantua

if (GetBloodEssence(uid) >= FixedPoint2.New(200) && !_actionEntities.TryGetValue("ActionVampireUnnaturalStrength", out entity) && component.CurrentMutation == VampireMutationsType.Gargantua)
if (_vampire.GetBloodEssence(uid) >= FixedPoint2.New(200) && !_actionEntities.TryGetValue("ActionVampireUnnaturalStrength", out entity) && component.CurrentMutation == VampireMutationsType.Gargantua)
{
var vampire = new Entity<VampireComponent>(uid, component);

Expand All @@ -336,7 +340,7 @@ private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent componen
_actionEntities["ActionVampireUnnaturalStrength"] = vampire;
}

if (GetBloodEssence(uid) >= FixedPoint2.New(300) && !_actionEntities.TryGetValue("ActionVampireSupernaturalStrength", out entity) && component.CurrentMutation == VampireMutationsType.Gargantua)
if (_vampire.GetBloodEssence(uid) >= FixedPoint2.New(300) && !_actionEntities.TryGetValue("ActionVampireSupernaturalStrength", out entity) && component.CurrentMutation == VampireMutationsType.Gargantua)
{
var vampire = new Entity<VampireComponent>(uid, component);

Expand All @@ -347,7 +351,7 @@ private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent componen

//Bestia

if (GetBloodEssence(uid) >= FixedPoint2.New(200) && !_actionEntities.TryGetValue("ActionVampireBatform", out entity) && component.CurrentMutation == VampireMutationsType.Bestia)
if (_vampire.GetBloodEssence(uid) >= FixedPoint2.New(200) && !_actionEntities.TryGetValue("ActionVampireBatform", out entity) && component.CurrentMutation == VampireMutationsType.Bestia)
{
_action.AddAction(uid, ref newEntity , "ActionVampireBatform");
if (newEntity != null)
Expand All @@ -359,7 +363,7 @@ private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent componen
}
}
}
else if (GetBloodEssence(uid) < FixedPoint2.New(200) && _actionEntities.TryGetValue("ActionVampireBatform", out entity))
else if (_vampire.GetBloodEssence(uid) < FixedPoint2.New(200) && _actionEntities.TryGetValue("ActionVampireBatform", out entity))
{
if (!TryComp(uid, out ActionsComponent? comp))
return;
Expand All @@ -369,7 +373,7 @@ private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent componen
_actionEntities.Remove("ActionVampireBatform");
}

if (GetBloodEssence(uid) >= FixedPoint2.New(300) && !_actionEntities.TryGetValue("ActionVampireMouseform", out entity) && component.CurrentMutation == VampireMutationsType.Bestia)
if (_vampire.GetBloodEssence(uid) >= FixedPoint2.New(300) && !_actionEntities.TryGetValue("ActionVampireMouseform", out entity) && component.CurrentMutation == VampireMutationsType.Bestia)
{
_action.AddAction(uid, ref newEntity , "ActionVampireMouseform");
if (newEntity != null)
Expand All @@ -381,7 +385,7 @@ private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent componen
}
}
}
else if (GetBloodEssence(uid) < FixedPoint2.New(300) && _actionEntities.TryGetValue("ActionVampireMouseform", out entity))
else if (_vampire.GetBloodEssence(uid) < FixedPoint2.New(300) && _actionEntities.TryGetValue("ActionVampireMouseform", out entity))
{
if (!TryComp(uid, out ActionsComponent? comp))
return;
Expand All @@ -391,17 +395,6 @@ private void OnVampireBloodChangedEvent(EntityUid uid, VampireComponent componen
_actionEntities.Remove("ActionVampireMouseform");
}
}

private FixedPoint2 GetBloodEssence(EntityUid vampire)
{
if (!TryComp<VampireComponent>(vampire, out var comp))
return 0;

if (!comp.Balance.TryGetValue(VampireComponent.CurrencyProto, out var val))
return 0;

return val;
}

private void DoSpaceDamage(Entity<VampireComponent> vampire)
{
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Changeling/ChangelingComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public sealed partial class ChangelingComponent : Component
/// The status icon corresponding to the Changlings.
/// </summary>

[DataField, ViewVariables(VVAccess.ReadOnly)]
public ProtoId<StatusIconPrototype> StatusIcon { get; set; } = "HivemindFaction";
[DataField("changelingStatusIcon")]
public ProtoId<FactionIconPrototype> StatusIcon { get; set; } = "HivemindFaction";

#endregion

Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Standing/LayingDownComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public sealed partial class LayingDownComponent : Component
public float StandingUpTime { get; set; } = 1f;

[DataField, AutoNetworkedField]
public float SpeedModify { get; set; } = 0.4f;
public float SpeedModify { get; set; } = 0.25f;

[DataField, AutoNetworkedField]
public bool AutoGetUp;
Expand Down
24 changes: 24 additions & 0 deletions Content.Shared/Vampire/SharedVampireSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Content.Shared.Vampire.Components;
using Content.Shared.FixedPoint;

namespace Content.Shared.Vampire;

public sealed class SharedVampireSystem : EntitySystem
{
public FixedPoint2 GetBloodEssence(EntityUid vampire)
{
if (!TryComp<VampireComponent>(vampire, out var comp))
return 0;

if (comp.Balance != null && comp.Balance.TryGetValue(VampireComponent.CurrencyProto, out var val))
return val;

return 0;
}

public void SetAlertBloodAmount(VampireAlertComponent component, int amount)
{
component.BloodAmount = amount;
Dirty(component.Owner, component);
}
}
Loading
Loading