Skip to content

Commit

Permalink
Heads zombies (#504)
Browse files Browse the repository at this point in the history
* Добавлен тег проверки возможности стать зомби.

* Проставлены теги возможности стать зомби везде, где указано в запросе.

* Поправил код, убрал старые комметарии.

* Косяк нашел)

* Хоп снова может быть нулевым
  • Loading branch information
SkaldetSkaeg authored Nov 9, 2023
1 parent c862502 commit 82521b4
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Content.Server/GameTicking/Rules/ZombieRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Content.Shared.Mobs.Systems;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.Roles.Jobs;
using Content.Shared.Zombies;
using Robust.Server.GameObjects;
using Robust.Server.Player;
Expand All @@ -45,6 +46,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem<ZombieRuleComponent>
[Dependency] private readonly ZombieSystem _zombie = default!;
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
[Dependency] private readonly SharedRoleSystem _roles = default!;
[Dependency] private readonly SharedJobSystem _jobs = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;

Expand Down Expand Up @@ -271,6 +273,13 @@ private void InfectInitialPlayers(ZombieRuleComponent component)
{
if (player.AttachedEntity == null || !HasComp<HumanoidAppearanceComponent>(player.AttachedEntity) || HasComp<ZombieImmuneComponent>(player.AttachedEntity))
continue;

// Role prevents being a zombie.
if (!_jobs.CanBeZombie(player))
{
continue;
}

playerList.Add(player);

var pref = (HumanoidCharacterProfile) _prefs.GetPreferences(player.UserId).SelectedCharacter;
Expand Down
3 changes: 3 additions & 0 deletions Content.Shared/Roles/JobPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public sealed class JobPrototype : IPrototype
[DataField("canBeAntag")]
public bool CanBeAntag { get; private set; } = true;

[DataField("canBeZombie")]
public bool CanBeZombie { get; private set; } = true;

[DataField("radioBold")]
public bool RadioIsBold { get; } = false;

Expand Down
13 changes: 12 additions & 1 deletion Content.Shared/Roles/Jobs/SharedJobSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Shared.Players;
using Content.Shared.Players.PlayTimeTracking;
Expand Down Expand Up @@ -135,4 +135,15 @@ public bool CanBeAntag(ICommonSession player)

return prototype.CanBeAntag;
}

public bool CanBeZombie(ICommonSession player)
{
if (_playerSystem.ContentData(player) is not { Mind: { } mindId })
return false;

if (!MindTryGetJob(mindId, out _, out var prototype))
return true;

return prototype.CanBeZombie;
}
}
1 change: 1 addition & 0 deletions Resources/Prototypes/Roles/Jobs/Command/captain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
joinNotifyCrew: true
supervisors: job-supervisors-centcom
canBeAntag: false
canBeZombie: false
radioBold: true
accessGroups:
- AllAccess
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Roles/Jobs/Security/brigmedic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
icon: "JobIconBrigmedic"
supervisors: job-supervisors-hos
canBeAntag: false
canBeZombie: false
access:
- Medical
- Security
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Roles/Jobs/Security/detective.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
icon: "JobIconDetective"
supervisors: job-supervisors-hos
canBeAntag: false
canBeZombie: false
access:
- Security
- Brig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
requireAdminNotify: true
supervisors: job-supervisors-captain
canBeAntag: false
canBeZombie: false
radioBold: true
access:
- HeadOfSecurity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
icon: "JobIconSecurityCadet"
supervisors: job-supervisors-security
canBeAntag: false
canBeZombie: false
access:
- Security
- Brig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
icon: "JobIconSecurityOfficer"
supervisors: job-supervisors-hos
canBeAntag: false
canBeZombie: false
access:
- Security
- Brig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
icon: "JobIconSeniorOfficer"
supervisors: job-supervisors-hos
canBeAntag: false
canBeZombie: false
access:
- Security
- Brig
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Roles/Jobs/Security/warden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
icon: "JobIconWarden"
supervisors: job-supervisors-hos
canBeAntag: false
canBeZombie: false
access:
- Security
- Armory
Expand Down
3 changes: 2 additions & 1 deletion Resources/Prototypes/SS220/Roles/Jobs/ghost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
playTimeTracker: JobGhostRole
name: Ghost role
description: Utility job for correct work job ban.
canBeAntag: true
canBeAntag: true
canBeZombie: true

0 comments on commit 82521b4

Please sign in to comment.