Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
Rxup committed Feb 9, 2024
1 parent 11a5d02 commit db0d1f6
Show file tree
Hide file tree
Showing 14 changed files with 602 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Backmen/Vampiric/BloodSuckerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Content.Client.Backmen.Vampiric;

public sealed class BloodSuckerSystem : EntitySystem
public sealed class BloodSuckerSystem : SharedBloodSuckerSystem
{
public override void Initialize()
{
Expand Down
179 changes: 179 additions & 0 deletions Content.Server/Backmen/Vampiric/BkmVampireLevelingSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
using Content.Server.Backmen.Vampiric.Role;
using Content.Server.Mind;
using Content.Server.Polymorph.Components;
using Content.Server.Polymorph.Systems;
using Content.Server.Store.Components;
using Content.Server.Store.Systems;
using Content.Shared.Actions;
using Content.Shared.Administration.Logs;
using Content.Shared.Backmen.Abilities.Psionics;
using Content.Shared.Backmen.Vampiric;
using Content.Shared.Database;
using Content.Shared.FixedPoint;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Polymorph;
using Content.Shared.Slippery;
using Robust.Shared.Prototypes;

namespace Content.Server.Backmen.Vampiric;

public sealed class BkmVampireLevelingSystem : EntitySystem
{
[Dependency] private readonly StoreSystem _store = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly PolymorphSystem _polymorph = default!;
[Dependency] private readonly MovementSpeedModifierSystem _speedModifier = default!;

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

SubscribeLocalEvent<BkmVampireComponent, VampireShopActionEvent>(OnOpenShop);
SubscribeLocalEvent<BkmVampireComponent, VampireStoreEvent>(OnShopBuyPerk);
SubscribeLocalEvent<BkmVampireComponent, RefreshMovementSpeedModifiersEvent>(OnApplySprint);
}

private void OnApplySprint(Entity<BkmVampireComponent> ent, ref RefreshMovementSpeedModifiersEvent args)
{
if (ent.Comp.SprintLevel == 0)
{
return;
}

switch (ent.Comp.SprintLevel)
{
case 1:
args.ModifySpeed(2f, 1f);
break;
case 2:
args.ModifySpeed(3f, 1f);
break;
case 3:
args.ModifySpeed(3.4f,1f);
break;
case 4:
args.ModifySpeed(3.8f,1f);
break;
case 5:
args.ModifySpeed(4.2f,1f);
break;
}
}

private void OnOpenShop(Entity<BkmVampireComponent> ent, ref VampireShopActionEvent args)
{
if (!TryComp<StoreComponent>(ent, out var store))
return;
_store.ToggleUi(ent, ent, store);
}

[ValidatePrototypeId<EntityPrototype>] private const string VmpShop = "VmpShop";

public void InitShop(Entity<BkmVampireComponent> ent)
{
_actions.AddAction(ent, VmpShop);
var store = EnsureComp<StoreComponent>(ent);
store.RefundAllowed = false;
store.Categories.Add("VapmireT0");
store.CurrencyWhitelist.Add(ent.Comp.CurrencyPrototype);
}

[ValidatePrototypeId<PolymorphPrototype>]
private const string BVampieBat = "BVampieBat";

[ValidatePrototypeId<PolymorphPrototype>]
private const string BVampieMouse = "BVampieMouse";

private void OnShopBuyPerk(Entity<BkmVampireComponent> ent, ref VampireStoreEvent args)
{
_adminLogger.Add(LogType.StorePurchase, LogImpact.Medium,
$"{ToPrettyString(ent):entity} vpm leveling buy {args.BuyType}");
switch (args.BuyType)
{
case VampireStoreType.Tier1Upgrade:
UnlockTier(ent, 1);
break;
case VampireStoreType.Tier2Upgrade:
UnlockTier(ent, 2);
break;
case VampireStoreType.Tier3Upgrade:
UnlockTier(ent, 3);
break;
case VampireStoreType.MakeNewVamp:
_actions.AddAction(ent, ref ent.Comp.ActionNewVamp, ent.Comp.NewVamp);
#if !DEBUG
_actions.SetCooldown(ent.Comp.ActionNewVamp, TimeSpan.FromMinutes(5));
#endif
break;
case VampireStoreType.SkillMouse1:
_polymorph.CreatePolymorphAction(BVampieBat, (ent, EnsureComp<PolymorphableComponent>(ent)));
break;
case VampireStoreType.SkillMouse2:
_polymorph.CreatePolymorphAction(BVampieMouse, (ent, EnsureComp<PolymorphableComponent>(ent)));
break;
case VampireStoreType.Sprint1:
ent.Comp.SprintLevel = 1;
_speedModifier.RefreshMovementSpeedModifiers(ent);
break;
case VampireStoreType.Sprint2:
ent.Comp.SprintLevel = 2;
_speedModifier.RefreshMovementSpeedModifiers(ent);
break;
case VampireStoreType.Sprint3:
ent.Comp.SprintLevel = 3;
_speedModifier.RefreshMovementSpeedModifiers(ent);
break;
case VampireStoreType.Sprint4:
ent.Comp.SprintLevel = 4;
_speedModifier.RefreshMovementSpeedModifiers(ent);
break;
case VampireStoreType.Sprint5:
ent.Comp.SprintLevel = 5;
_speedModifier.RefreshMovementSpeedModifiers(ent);
break;
case VampireStoreType.NoSlip:
EnsureComp<NoSlipComponent>(ent);
break;
case VampireStoreType.DispelPower:
EnsureComp<DispelPowerComponent>(ent);
break;
case VampireStoreType.IgnitePower:
EnsureComp<PyrokinesisPowerComponent>(ent);
break;
case VampireStoreType.RegenPower:
EnsureComp<PsionicRegenerationPowerComponent>(ent);
break;
case VampireStoreType.ZapPower:
EnsureComp<NoosphericZapPowerComponent>(ent);
break;
case VampireStoreType.PsiInvisPower:
EnsureComp<PsionicInvisibilityPowerComponent>(ent);
break;
}
}


public void UnlockTier(Entity<BkmVampireComponent> ent, int tier)
{
var store = EnsureComp<StoreComponent>(ent);
store.Categories.Add("VapmireT" + tier);

if (!_mindSystem.TryGetMind(ent, out var mindId, out var mind) ||
!TryComp<VampireRoleComponent>(mindId, out var vmpRole))
{
return; // no mind? skip;
}

vmpRole.Tier = Math.Max(vmpRole.Tier, tier);
}

public void AddCurrency(Entity<BkmVampireComponent> ent, FixedPoint2 va)
{
_store.TryAddCurrency(new Dictionary<string, FixedPoint2>
{ { ent.Comp.CurrencyPrototype, va } },
ent);
}
}
42 changes: 31 additions & 11 deletions Content.Server/Backmen/Vampiric/BloodSuckerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
using Content.Server.Polymorph.Components;
using Content.Server.Polymorph.Systems;
using Content.Server.Roles;
using Content.Server.Store.Components;
using Content.Server.Store.Systems;
using Content.Shared.Actions;
using Content.Shared.Backmen.Spider.Components;
using Content.Shared.Body.Components;
Expand All @@ -29,13 +31,16 @@
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Content.Shared.Mind;
using Content.Shared.Mobs.Systems;
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition.EntitySystems;
using Content.Shared.Objectives.Components;
using Content.Shared.Polymorph;
using Content.Shared.Roles;
using Content.Shared.Roles.Jobs;
using Content.Shared.Store;
using Content.Shared.Stunnable;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
Expand All @@ -46,7 +51,7 @@

namespace Content.Server.Backmen.Vampiric;

public sealed class BloodSuckerSystem : EntitySystem
public sealed class BloodSuckerSystem : SharedBloodSuckerSystem
{
[Dependency] private readonly BodySystem _bodySystem = default!;
[Dependency] private readonly SolutionContainerSystem _solutionSystem = default!;
Expand All @@ -60,7 +65,6 @@ public sealed class BloodSuckerSystem : EntitySystem
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly ReactiveSystem _reactiveSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly PolymorphSystem _polymorph = default!;
[Dependency] private readonly HungerSystem _hunger = default!;
[Dependency] private readonly RoleSystem _roleSystem = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
Expand All @@ -72,6 +76,7 @@ public sealed class BloodSuckerSystem : EntitySystem
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly SharedStunSystem _stun = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly BkmVampireLevelingSystem _leveling = default!;


[ValidatePrototypeId<AntagPrototype>] private const string BloodsuckerAntagRole = "Bloodsucker";
Expand All @@ -84,7 +89,9 @@ public override void Initialize()
SubscribeLocalEvent<BloodSuckedComponent, DamageChangedEvent>(OnDamageChanged);
SubscribeLocalEvent<BloodSuckerComponent, BloodSuckDoAfterEvent>(OnDoAfter);


SubscribeLocalEvent<BkmVampireComponent, MapInitEvent>(OnInitVmp);

SubscribeLocalEvent<BkmVampireComponent, PlayerAttachedEvent>(OnAttachedVampireMind);
SubscribeLocalEvent<BkmVampireComponent, HealthBeingExaminedEvent>(OnVampireExamined);
SubscribeLocalEvent<BkmVampireComponent, InnateNewVampierActionEvent>(OnUseNewVamp);
Expand All @@ -100,6 +107,10 @@ public override void Initialize()
SubscribeLocalEvent<BloodsuckerDrinkConditionComponent, ObjectiveAfterAssignEvent>(OnDrinkAfterAssigned);
}





private void OnUseNewVampAfter(Entity<BkmVampireComponent> ent, ref InnateNewVampierDoAfterEvent args)
{
if (args.Cancelled || args.Target == null || TerminatingOrDeleted(args.Target.Value))
Expand Down Expand Up @@ -182,10 +193,7 @@ private void OnUseNewVamp(Entity<BkmVampireComponent> ent, ref InnateNewVampierA

private void OnInitVmp(Entity<BkmVampireComponent> ent, ref MapInitEvent args)
{
_actions.AddAction(ent, ref ent.Comp.ActionNewVamp, ent.Comp.NewVamp);
#if !DEBUG
_actions.SetCooldown(ent.Comp.ActionNewVamp, TimeSpan.FromMinutes(5));
#endif
_leveling.InitShop(ent);
}

private void OnVampireExamined(Entity<BkmVampireComponent> ent, ref HealthBeingExaminedEvent args)
Expand Down Expand Up @@ -287,15 +295,13 @@ private void OnAttachedVampireMind(Entity<BkmVampireComponent> ent, ref PlayerAt

private void OnPolymorphActionEvent(Entity<BloodSuckerComponent> ent, ref PolymorphActionEvent args)
{
_hunger.ModifyHunger(ent, -30);
if(TryComp<HungerComponent>(ent, out var hungerComponent))
_hunger.ModifyHunger(ent, -30, hungerComponent);
}

[ValidatePrototypeId<EntityPrototype>]
private const string OrganVampiricHumanoidStomach = "OrganVampiricHumanoidStomach";

[ValidatePrototypeId<PolymorphPrototype>]
private const string BVampieBat = "BVampieBat";

[ValidatePrototypeId<ReagentPrototype>]
private const string BloodSuckerToxin = "BloodSuckerToxin";

Expand Down Expand Up @@ -334,7 +340,7 @@ public void ConvertToVampire(EntityUid uid)
var stomach = Spawn(OrganVampiricHumanoidStomach);

_bodySystem.InsertOrgan(bodyComponent.RootContainer.ContainedEntity.Value, stomach, "stomach", bodyPartComponent);
_polymorph.CreatePolymorphAction(BVampieBat, (uid,EnsureComp<PolymorphableComponent>(uid)));

EnsureComp<BkmVampireComponent>(uid);

if (
Expand All @@ -344,6 +350,13 @@ public void ConvertToVampire(EntityUid uid)
TryComp<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));
}


bloodsucker.Converted += 1;
}

Expand Down Expand Up @@ -533,6 +546,11 @@ public bool TrySucc(EntityUid bloodsucker, EntityUid victim, BloodSuckerComponen
if (TryComp<VampireRoleComponent>(bloodsuckermidId, out var vpm))
{
vpm.Drink += unitsToDrain;

if (TryComp<BkmVampireComponent>(bloodsucker, out var bkmVampireComponent))
{
_leveling.AddCurrency((bloodsucker,bkmVampireComponent), 1 * (vpm.Tier + 1));
}
}
}
else
Expand All @@ -541,6 +559,8 @@ public bool TrySucc(EntityUid bloodsucker, EntityUid victim, BloodSuckerComponen
}




var bloodSolution = bloodstream.BloodSolution.Value;
// Make everything actually ingest.
var temp = _solutionSystem.SplitSolution(bloodSolution, unitsToDrain);
Expand Down
25 changes: 25 additions & 0 deletions Content.Server/Backmen/Vampiric/RequireParentListingCondition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Linq;
using Content.Server.Store.Components;
using Content.Server.Store.Systems;
using Content.Shared.Store;
using Robust.Shared.Prototypes;

namespace Content.Server.Backmen.Vampiric;

public sealed partial class RequireParentListingCondition : ListingCondition
{
[DataField("parent", required: true)]
public ProtoId<ListingPrototype> ParentId;
public override bool Condition(ListingConditionArgs args)
{
if (!args.StoreEntity.HasValue)
return false;

var parent = args.EntityManager.EnsureComponent<StoreComponent>(args.StoreEntity.Value).Listings.FirstOrDefault(x=>x.ID == ParentId);

if (parent == null)
return false;

return parent.PurchaseAmount > 0;
}
}
3 changes: 3 additions & 0 deletions Content.Server/Backmen/Vampiric/Role/VampireRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ public sealed partial class VampireRoleComponent : AntagonistRoleComponent
{
public EntityUid? MasterVampire;

[ViewVariables(VVAccess.ReadWrite)]
public int Tier = 0;

[ViewVariables(VVAccess.ReadWrite)]
public float Drink = 0;

Expand Down
9 changes: 9 additions & 0 deletions Content.Shared/Backmen/Vampiric/BkmVampireComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,28 @@
using Content.Shared.DoAfter;
using Content.Shared.FixedPoint;
using Content.Shared.StatusIcon;
using Content.Shared.Store;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Shared.Backmen.Vampiric;

[RegisterComponent]
[NetworkedComponent]
public sealed partial class BkmVampireComponent : Component, IAntagStatusIconComponent
{
[DataField("currencyPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<CurrencyPrototype>))]
public string CurrencyPrototype = "BloodEssence";

public ProtoId<StatusIconPrototype> StatusIcon { get; set; } = "VampireFaction";
public bool IconVisibleToGhost { get; set; } = true;


[ViewVariables(VVAccess.ReadWrite)]
public int SprintLevel = 0;

public EntityUid? ActionNewVamp;
public ProtoId<EntityPrototype> NewVamp = "ActionConvertToVampier";
}
Expand Down
Loading

0 comments on commit db0d1f6

Please sign in to comment.