Skip to content

Commit

Permalink
Вынес цели вампира с кода в прототипы
Browse files Browse the repository at this point in the history
  • Loading branch information
VigersRay committed Jan 3, 2025
1 parent cb17bfc commit 3bad02b
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,4 @@ namespace Content.Server.GameTicking.Rules.Components;
public sealed partial class VampireRuleComponent : Component
{
public readonly List<EntityUid> VampireMinds = new();


public readonly List<ProtoId<EntityPrototype>> BaseObjectives = new()
{
"VampireKillRandomPersonObjective",
"VampireDrainObjective"
};

public readonly List<ProtoId<EntityPrototype>> EscapeObjectives = new()
{
"VampireSurviveObjective",
"VampireEscapeObjective"
};

public readonly List<ProtoId<EntityPrototype>> StealObjectives = new()
{
"CMOHyposprayVampireStealObjective",
"RDHardsuitVampireStealObjective",
"EnergyShotgunVampireStealObjective",
"MagbootsVampireStealObjective",
"ClipboardVampireStealObjective",
"CaptainIDVampireStealObjective",
"CaptainJetpackVampireStealObjective",
"CaptainGunVampireStealObjective"
};
}
}
39 changes: 11 additions & 28 deletions Content.Server/GameTicking/Rules/VampireRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Content.Server.Objectives;
using Content.Server.Roles;
using Content.Server.Vampire;
using Content.Server.Bible.Components;
using Content.Server.Bible.Components;
using Content.Shared.Alert;
using Content.Shared.Vampire.Components;
using Content.Shared.NPC.Prototypes;
Expand Down Expand Up @@ -56,7 +56,7 @@ public override void Initialize()
private void OnSelectAntag(EntityUid mindId, VampireRuleComponent comp, ref AfterAntagEntitySelectedEvent args)
{
var ent = args.EntityUid;

if (HasComp<BibleUserComponent>(ent))
return;

Expand Down Expand Up @@ -91,63 +91,46 @@ public bool MakeVampire(EntityUid target, VampireRuleComponent rule)
EnsureComp<VampireIconComponent>(target);
var vampireAlertComponent = EnsureComp<VampireAlertComponent>(target);
var interfaceComponent = EnsureComp<UserInterfaceComponent>(target);

if (HasComp<UserInterfaceComponent>(target))
_uiSystem.SetUiState(target, VampireMutationUiKey.Key, new VampireMutationBoundUserInterfaceState(vampireComponent.VampireMutations, vampireComponent.CurrentMutation));

var vampire = new Entity<VampireComponent>(target, vampireComponent);

RemComp<PerishableComponent>(vampire);
RemComp<BarotraumaComponent>(vampire);
RemComp<ThirstComponent>(vampire);

vampireComponent.Balance = new() { { VampireComponent.CurrencyProto, 0 } };

rule.VampireMinds.Add(mindId);

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

Random random = new Random();

foreach (var objective in rule.BaseObjectives)
_mind.TryAddObjective(mindId, mind, objective);

if (rule.EscapeObjectives.Count > 0)
{
var randomEscapeObjective = rule.EscapeObjectives[random.Next(rule.EscapeObjectives.Count)];
_mind.TryAddObjective(mindId, mind, randomEscapeObjective);
}

if (rule.StealObjectives.Count > 0)
{
var randomEscapeObjective = rule.StealObjectives[random.Next(rule.StealObjectives.Count)];
_mind.TryAddObjective(mindId, mind, randomEscapeObjective);
}

return true;
}

private void OnGetBriefing(Entity<VampireRuleComponent> role, ref GetBriefingEvent args)
{
var ent = args.Mind.Comp.OwnedEntity;

if (ent is null)
return;
args.Append(MakeBriefing(ent.Value));
}

private string MakeBriefing(EntityUid ent)
{
if (TryComp<MetaDataComponent>(ent, out var metaData))
{
var briefing = Loc.GetString("vampire-role-greeting", ("name", metaData?.EntityName ?? "Unknown"));

return briefing;
}

return "";
}

Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/GameRules/midround.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
- type: GameRule
minPlayers: 5
- type: VampireRule
- type: AntagRandomObjectives
sets:
- groups: VampireObjectiveGroups
maxDifficulty: 10
- type: AntagSelection
agentName: vampire-roundend-name
definitions:
Expand Down
39 changes: 22 additions & 17 deletions Resources/Prototypes/Objectives/vampire.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
roles:
mindRoles:
- VampireRole

- type: entity
abstract: true
parent: [BaseVampireObjective, BaseStealObjective]
Expand All @@ -24,7 +24,7 @@
difficulty: 1.5
- type: ObjectiveLimit
limit: 2

# Steal

- type: entity
Expand Down Expand Up @@ -115,17 +115,6 @@

# States

- type: entity
parent: [BaseVampireObjective, BaseSurviveObjective]
id: VampireSurviveObjective
name: Survive
description: I must survive no matter what.
components:
- type: Objective
icon:
sprite: Interface/Actions/actions_vampire.rsi
state: survive_icon

- type: entity
parent: [BaseVampireObjective, BaseLivingObjective]
id: VampireEscapeObjective
Expand All @@ -138,9 +127,9 @@
sprite: Structures/Furniture/chairs.rsi
state: shuttle
- type: EscapeShuttleCondition

# Kill

- type: entity
parent: [BaseVampireObjective, BaseKillObjective]
id: VampireKillRandomPersonObjective
Expand All @@ -152,7 +141,23 @@
- type: TargetObjective
title: objective-condition-kill-person-title
- type: PickRandomPerson

- type: KillPersonCondition
requireDead: true

- type: entity
parent: [BaseVampireObjective, BaseKillObjective]
id: VampireKillRandomAntagObjective
description:
components:
- type: Objective
difficulty: 3.0
unique: true
- type: TargetObjective
title: objective-condition-kill-antag-title
- type: PickRandomAntag
- type: KillPersonCondition
requireDead: true

# Drain

- type: entity
Expand All @@ -168,4 +173,4 @@
max: 600
title: objective-condition-drain-title
description: objective-condition-drain-description
- type: BloodDrainCondition
- type: BloodDrainCondition
30 changes: 30 additions & 0 deletions Resources/Prototypes/_Sunrise/Objectives/objectiveGroups.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
- type: weightedRandom
id: VampireObjectiveGroups
weights:
VampireObjectiveGroupSteal: 1
VampireObjectiveGroupKill: 1
VampireObjectiveGroupState: 1

- type: weightedRandom
id: VampireObjectiveGroupSteal
weights:
CMOHyposprayVampireStealObjective: 1
RDHardsuitVampireStealObjective: 1
EnergyShotgunVampireStealObjective: 1
MagbootsVampireStealObjective: 1
ClipboardVampireStealObjective: 1
CaptainIDVampireStealObjective: 1
CaptainJetpackVampireStealObjective: 1
CaptainGunVampireStealObjective: 1

- type: weightedRandom
id: VampireObjectiveGroupKill
weights:
VampireKillRandomAntagObjective: 1
VampireKillRandomPersonObjective: 0.5

- type: weightedRandom
id: VampireObjectiveGroupState
weights:
VampireDrainObjective: 1
VampireEscapeObjective: 1

0 comments on commit 3bad02b

Please sign in to comment.