Ghost role probability (#9752)

* Ghost role probability

* give it to regular ticks/bears too
This commit is contained in:
Kara
2022-07-14 22:20:37 -07:00
committed by GitHub
parent 44e4678435
commit c9d9d09e19
8 changed files with 59 additions and 11 deletions

View File

@@ -17,6 +17,7 @@ using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.Random;
using Robust.Shared.Utility;
namespace Content.Server.Ghost.Roles
@@ -27,6 +28,7 @@ namespace Content.Server.Ghost.Roles
[Dependency] private readonly EuiManager _euiManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly FollowerSystem _followerSystem = default!;
private uint _nextRoleIdentifier;
@@ -265,6 +267,12 @@ namespace Content.Server.Ghost.Roles
private void OnInit(EntityUid uid, GhostRoleComponent role, ComponentInit args)
{
if (role.Probability < 1f && !_random.Prob(role.Probability))
{
RemComp<GhostRoleComponent>(uid);
return;
}
if (role.RoleRules == "")
role.RoleRules = Loc.GetString("ghost-role-component-default-rules");
RegisterGhostRole(role);