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

фикс вампиров! #905

Merged
merged 2 commits into from
Nov 8, 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
9 changes: 9 additions & 0 deletions Content.Server/Backmen/Vampiric/BkmVampireLevelingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
using Content.Shared.Polymorph;
using Content.Shared.Popups;
using Content.Shared.Slippery;
using Content.Shared.Store;
using Content.Shared.Store.Components;
using Content.Shared.Stunnable;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Prototypes;
Expand Down Expand Up @@ -54,6 +56,7 @@ public sealed class BkmVampireLevelingSystem : EntitySystem
[Dependency] private readonly DamageableSystem _damageableSystem = default!;

[Dependency] private readonly BloodSuckerSystem _bloodSucker = default!;
[Dependency] private readonly UserInterfaceSystem _ui = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -195,6 +198,12 @@ private void OnOpenShop(Entity<BkmVampireComponent> ent, ref VampireShopActionEv

public void InitShop(Entity<BkmVampireComponent> ent)
{
var ui = EnsureComp<UserInterfaceComponent>(ent);
if (!_ui.HasUi(ent, StoreUiKey.Key, ui))
{
// у пользователя нет ui магазин!
return;
}
_actions.AddAction(ent, VmpShop);
var store = EnsureComp<StoreComponent>(ent);
store.RefundAllowed = false;
Expand Down
6 changes: 3 additions & 3 deletions Content.Server/Backmen/Vampiric/BloodSuckerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,20 @@ public void ConvertToVampire(EntityUid uid)
TryComp<BloodSuckedComponent>(uid, out var bloodsucked) &&
bloodsucked.BloodSuckerMindId.HasValue &&
!TerminatingOrDeleted(bloodsucked.BloodSuckerMindId.Value) &&
TryComp<VampireRoleComponent>(bloodsucked.BloodSuckerMindId.Value, out var bloodsucker)
_roleSystem.MindHasRole<VampireRoleComponent>(bloodsucked.BloodSuckerMindId.Value, out var bloodsucker)
)
{
var masterUid = CompOrNull<MindComponent>(bloodsucked.BloodSuckerMindId.Value)?.CurrentEntity;
if (TryComp<BkmVampireComponent>(masterUid, out var master))
{
_leveling.AddCurrency((masterUid.Value,master),
10 * (bloodsucker.Tier + 1),
10 * (bloodsucker.Value.Comp2.Tier + 1),
"обращение"
);
}


bloodsucker.Converted += 1;
bloodsucker.Value.Comp2.Converted += 1;
}

EnsureMindVampire(uid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,6 @@ private void OnConvertAfterAssigned(Entity<BloodsuckerConvertConditionComponent>

private void OnConvertAssigned(Entity<BloodsuckerConvertConditionComponent> ent, ref ObjectiveAssignedEvent args)
{
if (args.Mind.OwnedEntity == null)
{
args.Cancelled = true;
return;
}

var user = args.Mind.OwnedEntity.Value;
if (!HasComp<BkmVampireComponent>(user))
{
args.Cancelled = true;
return;
}

ent.Comp.Goal = _random.Next(
1,
Math.Max(1, // min 1 of 1
Expand All @@ -66,30 +53,17 @@ private void OnConvertAssigned(Entity<BloodsuckerConvertConditionComponent> ent,

private void OnGetConvertProgress(Entity<BloodsuckerConvertConditionComponent> ent, ref ObjectiveGetProgressEvent args)
{
if (args.Mind.OwnedEntity == null || !TryComp<VampireRoleComponent>(args.MindId, out var vmp))
if (!_roleSystem.MindHasRole<VampireRoleComponent>(args.MindId, out var vmp))
{
args.Progress = 0;
return;
}

args.Progress = vmp.Converted / ent.Comp.Goal;
args.Progress = vmp.Value.Comp2.Converted / ent.Comp.Goal;
}

private void OnDrinkAssigned(Entity<BloodsuckerDrinkConditionComponent> ent, ref ObjectiveAssignedEvent args)
{
if (args.Mind.OwnedEntity == null)
{
args.Cancelled = true;
return;
}

var user = args.Mind.OwnedEntity.Value;
if (!HasComp<BkmVampireComponent>(user))
{
args.Cancelled = true;
return;
}

ent.Comp.Goal = _random.Next(
ent.Comp.MinGoal,
Math.Max(ent.Comp.MinGoal + 1, // min 1 of 1
Expand All @@ -100,7 +74,7 @@ private void OnDrinkAssigned(Entity<BloodsuckerDrinkConditionComponent> ent, ref

private void OnGetDrinkProgress(Entity<BloodsuckerDrinkConditionComponent> ent, ref ObjectiveGetProgressEvent args)
{
if (args.Mind.OwnedEntity == null || !_roleSystem.MindHasRole<VampireRoleComponent>(args.MindId, out var role))
if (!_roleSystem.MindHasRole<VampireRoleComponent>(args.MindId, out var role))
{
args.Progress = 0;
return;
Expand Down
19 changes: 12 additions & 7 deletions Content.Server/Backmen/Vampiric/Rule/BloodsuckerRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
using Content.Server.Mind;
using Content.Shared.GameTicking.Components;
using Content.Shared.Mind;
using Content.Shared.Roles;

namespace Content.Server.Backmen.Vampiric.Rule;

public sealed class BloodsuckerRuleSystem : GameRuleSystem<BloodsuckerRuleComponent>
{
[Dependency] private readonly BloodSuckerSystem _bloodSuckerSystem = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
[Dependency] private readonly SharedRoleSystem _roleSystem = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -42,9 +44,9 @@ protected override void AppendRoundEndText(EntityUid uid,
foreach (var player in vampRule.Elders)
{
skip.Add(player.Value);
var role = CompOrNull<VampireRoleComponent>(player.Value);
var count = role?.Converted ?? 0;
var blood = role?.Drink ?? 0;
_roleSystem.MindHasRole<VampireRoleComponent>(player.Value, out var role);
var count = role?.Comp2.Converted ?? 0;
var blood = role?.Comp2.Drink ?? 0;
var countGoal = 0;
var bloodGoal = 0f;

Expand Down Expand Up @@ -81,21 +83,24 @@ protected override void AppendRoundEndText(EntityUid uid,

var isAddLine = true;

var q = EntityQueryEnumerator<MindComponent,VampireRoleComponent>();
while (q.MoveNext(out var mindId,out var mind, out var role))
var q = EntityQueryEnumerator<MindComponent>();
while (q.MoveNext(out var mindId,out var mind))
{
if (skip.Contains(mindId))
{
continue;
}

if(!_roleSystem.MindHasRole<VampireRoleComponent>(mindId, out var role))
continue;

if (isAddLine)
{
ev.AddLine(Loc.GetString("vampire-bitten"));
isAddLine = false;
}
var count = role?.Converted ?? 0;
var blood = role?.Drink ?? 0;
var count = role?.Comp2.Converted ?? 0;
var blood = role?.Comp2.Drink ?? 0;
var countGoal = 0;
var bloodGoal = 0f;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
type: HumanoidMarkingModifierBoundUserInterface
enum.StrippingUiKey.Key:
type: StrippableBoundUserInterface
enum.StoreUiKey.Key:
type: StoreBoundUserInterface
enum.SurgeryUIKey.Key: # backmen: surgery
type: SurgeryBui
- type: Sprite
scale: 0.9, 0.9
layers:
Expand Down
18 changes: 14 additions & 4 deletions Resources/Prototypes/_Backmen/GameRules/roundstart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
- type: AntagSelection
definitions:
- prefRoles: [ Blob ]
min: 1
max: 2
playerRatio: 40 #players = 2 blobs
allowNonHumans: true
Expand All @@ -74,7 +75,7 @@
sound: /Audio/Backmen/Ambience/Antag/blob_start.ogg
mindRoles:
- MindRoleBlob

- type: entity
id: BlobSpawn
parent: BaseGameRule
Expand Down Expand Up @@ -108,6 +109,7 @@
- type: AntagSelection
definitions:
- prefRoles: [ Bloodsucker ]
min: 2
max: 8
playerRatio: 10
blacklist:
Expand All @@ -128,7 +130,10 @@
categories: [ HideSpawnMenu ]
components:
- type: GameRule
minPlayers: 10
minPlayers: 1
delay:
min: 30
max: 60

## Vampire Outbreak
- type: entity
Expand All @@ -137,10 +142,15 @@
categories: [ HideSpawnMenu ]
components:
- type: StationEvent
earliestStart: 50
earliestStart: 20
minimumPlayers: 15
weight: 5
duration: 1
maxOccurrences: 1 # can only happen once per round
startAnnouncement: station-event-communication-interception
startAudio:
path: /Audio/Announcements/intercept.ogg
duration: null # the rule has to last the whole round not 1 second
occursDuringRoundEnd: false

# Shipwrecked
- type: entity
Expand Down
Loading