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

Weapons #296

Merged
merged 11 commits into from
Nov 5, 2023
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Content.IntegrationTests/Tests/EntityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ await server.WaitPost(() =>

Assert.That(entityMan.EntityCount, Is.Zero);
});

await server.WaitRunTicks(15);
await pair.CleanReturnAsync();
}

Expand Down
247 changes: 129 additions & 118 deletions Content.Server/Backmen/EvilTwin/EvilTwinSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Player;
using Robust.Shared.Timing;
using Robust.Shared.Utility;

namespace Content.Server.Backmen.EvilTwin;
Expand All @@ -68,8 +69,122 @@ public override void Initialize()
SubscribeLocalEvent<EvilTwinSpawnerComponent, GhostRoleSpawnerUsedEvent>(OnGhostRoleSpawnerUsed);
SubscribeLocalEvent<EvilTwinComponent, MobStateChangedEvent>(OnHandleComponentState);
SubscribeLocalEvent<PickEvilTwinPersonComponent, ObjectiveAssignedEvent>(OnPersonAssigned);
SubscribeLocalEvent<SpawnEvilTwinEvent>(OnSpawn);
}

private void OnSpawn(SpawnEvilTwinEvent ev)
{
var uid = ev.Entity.Owner;
var component = ev.Entity.Comp;
HumanoidCharacterProfile? pref = null;

EntityUid? targetUid = null;

if (component.TargetForce != EntityUid.Invalid)
{
if (IsEligibleHumanoid(component.TargetForce))
{
targetUid = component.TargetForce;
}
}
else
{
TryGetEligibleHumanoid(out targetUid);
}

if (targetUid.HasValue)
{
var xform = Transform(uid);
(var twinMob, pref) = SpawnEvilTwin(targetUid.Value, xform.Coordinates);
if (twinMob != null)
{
var playerData = ev.Session.ContentData();
if (playerData != null && _mindSystem.TryGetMind(playerData, out var mindId, out var mind))
{
_mindSystem.TransferTo(mindId, null, true, false, mind);
RemComp<MindContainerComponent>(twinMob.Value);
Timer.Spawn(0, () =>
{
_mindSystem.TransferTo(mindId, twinMob, true, false, mind);
});

var station = _stationSystem.GetOwningStation(targetUid.Value) ?? _stationSystem.GetStations()
.FirstOrNull(HasComp<StationEventEligibleComponent>);
if (pref != null && station != null &&
_mindSystem.TryGetMind(targetUid.Value, out var targetMindId, out var targetMind)
&& _roles.MindHasRole<JobComponent>(targetMindId))
{
/*if (TryComp<BankMemoryComponent>(targetMindId, out var mindBank) && TryComp<BankAccountComponent>(mindBank.BankAccount, out var bankAccountComponent))
{
_economySystem.AddPlayerBank(twinMob.Value, bankAccountComponent);
if (TryComp<BankMemoryComponent>(mindId, out var twinBank))
{
twinBank.BankAccount = mindBank.BankAccount;
}
}*/

var currentJob = Comp<JobComponent>(targetMindId);

var targetSession = targetMind?.Session;
var targetUserId = targetMind?.UserId ?? targetMind?.OriginalOwnerUserId;
if (targetUserId == null)
{
targetSession = ev.Session;

}
else if (targetSession == null)
{
targetSession = _playerManager.GetSessionByUserId(targetUserId.Value);
}

RaiseLocalEvent(new PlayerSpawnCompleteEvent(twinMob.Value,
targetSession,
currentJob?.PrototypeId, false,
0, station.Value, pref));

if (!_roles.MindHasRole<JobComponent>(mindId))
{
_roles.MindAddRole(mindId, new JobComponent(){ PrototypeId = currentJob?.PrototypeId });
}

if (_inventory.TryGetSlotEntity(targetUid.Value, "id", out var targetPda) &&
_inventory.TryGetSlotEntity(twinMob.Value, "id", out var twinPda) &&
TryComp<CartridgeLoaderComponent>(targetPda, out var targetPdaComp) &&
TryComp<CartridgeLoaderComponent>(twinPda, out var twinPdaComp))
{
var twinProgram =
twinPdaComp.BackgroundPrograms.FirstOrDefault(HasComp<NotekeeperCartridgeComponent>);
var targetProgram =
targetPdaComp.BackgroundPrograms.FirstOrDefault(HasComp<NotekeeperCartridgeComponent>);
if (twinProgram.Valid &&
targetProgram.Valid &&
TryComp<NotekeeperCartridgeComponent>(targetProgram, out var targetNotesComp) &&
TryComp<NotekeeperCartridgeComponent>(twinProgram, out var twinNotesComp))
{
foreach (var note in targetNotesComp.Notes)
{
twinNotesComp.Notes.Add(note);
}
}
}
}

_allEvilTwins.Add((twinMob.Value, mind));
_adminLogger.Add(LogType.Action, LogImpact.Extreme,
$"{_entityManager.ToPrettyString(twinMob.Value)} take EvilTwin with target {_entityManager.ToPrettyString(targetUid.Value)}");
}
}
}
else
{
_adminLogger.Add(LogType.Action, LogImpact.Extreme,
$"{_entityManager.ToPrettyString(uid)} take EvilTwin with no target (delete)");
_prayerSystem.SendSubtleMessage(ev.Session, ev.Session, Loc.GetString("evil-twin-error-message"),
Loc.GetString("prayer-popup-subtle-default"));
}

QueueDel(uid);
}

private List<(EntityUid Id, MindComponent Mind)> _allEvilTwins = new();

Expand Down Expand Up @@ -175,114 +290,10 @@ public bool MakeTwin([NotNullWhen(true)] out EntityUid? twinSpawn, EntityUid? ui
return true;
}

private void OnPlayerAttached(EntityUid uid, EvilTwinSpawnerComponent component, PlayerAttachedEvent args)
private void OnPlayerAttached(Entity<EvilTwinSpawnerComponent> uid, ref PlayerAttachedEvent args)
{
HumanoidCharacterProfile? pref = null;

EntityUid? targetUid = null;

if (component.TargetForce != EntityUid.Invalid)
{
if (IsEligibleHumanoid(component.TargetForce))
{
targetUid = component.TargetForce;
}
}
else
{
TryGetEligibleHumanoid(out targetUid);
}

if (targetUid.HasValue)
{
var xform = Transform(uid);
(var twinMob, pref) = SpawnEvilTwin(targetUid.Value, xform.Coordinates);
if (twinMob != null)
{
var playerData = args.Player.ContentData();
if (playerData != null && _mindSystem.TryGetMind(playerData, out var mindId, out var mind))
{
_mindSystem.TransferTo(mindId, null);
_mindSystem.TransferTo(mindId, twinMob);


var station = _stationSystem.GetOwningStation(targetUid.Value) ?? _stationSystem.GetStations()
.FirstOrNull(HasComp<StationEventEligibleComponent>);
if (pref != null && station != null &&
_mindSystem.TryGetMind(targetUid.Value, out var targetMindId, out var targetMind)
&& _roles.MindHasRole<JobComponent>(targetMindId))
{
/*if (TryComp<BankMemoryComponent>(targetMindId, out var mindBank) && TryComp<BankAccountComponent>(mindBank.BankAccount, out var bankAccountComponent))
{
_economySystem.AddPlayerBank(twinMob.Value, bankAccountComponent);
if (TryComp<BankMemoryComponent>(mindId, out var twinBank))
{
twinBank.BankAccount = mindBank.BankAccount;
}
}*/

var currentJob = Comp<JobComponent>(targetMindId);

var targetSession = targetMind?.Session;
var targetUserId = targetMind?.UserId ?? targetMind?.OriginalOwnerUserId;
if (targetUserId == null)
{
targetSession = args.Player;

}
else if (targetSession == null)
{
targetSession = _playerManager.GetSessionByUserId(targetUserId.Value);
}

RaiseLocalEvent(new PlayerSpawnCompleteEvent(twinMob.Value,
targetSession,
currentJob?.PrototypeId, false,
0, station.Value, pref));

if (!_roles.MindHasRole<JobComponent>(mindId))
{
_roles.MindAddRole(mindId, new JobComponent(){ PrototypeId = currentJob?.PrototypeId });
}
QueueLocalEvent(new SpawnEvilTwinEvent(uid, args.Player));

if (_inventory.TryGetSlotEntity(targetUid.Value, "id", out var targetPda) &&
_inventory.TryGetSlotEntity(twinMob.Value, "id", out var twinPda) &&
TryComp<CartridgeLoaderComponent>(targetPda, out var targetPdaComp) &&
TryComp<CartridgeLoaderComponent>(twinPda, out var twinPdaComp))
{
var twinProgram =
twinPdaComp.BackgroundPrograms.FirstOrDefault(HasComp<NotekeeperCartridgeComponent>);
var targetProgram =
targetPdaComp.BackgroundPrograms.FirstOrDefault(HasComp<NotekeeperCartridgeComponent>);
if (twinProgram.Valid &&
targetProgram.Valid &&
TryComp<NotekeeperCartridgeComponent>(targetProgram, out var targetNotesComp) &&
TryComp<NotekeeperCartridgeComponent>(twinProgram, out var twinNotesComp))
{
foreach (var note in targetNotesComp.Notes)
{
twinNotesComp.Notes.Add(note);
}
}
}
}

_allEvilTwins.Add((twinMob.Value, mind));
_adminLogger.Add(LogType.Action, LogImpact.Extreme,
$"{_entityManager.ToPrettyString(twinMob.Value)} take EvilTwin with target {_entityManager.ToPrettyString(targetUid.Value)}");
}
}
}
else
{
_adminLogger.Add(LogType.Action, LogImpact.Extreme,
$"{_entityManager.ToPrettyString(uid)} take EvilTwin with no target (delete)");
_prayerSystem.SendSubtleMessage(args.Player, args.Player, Loc.GetString("evil-twin-error-message"),
Loc.GetString("prayer-popup-subtle-default"));
}


QueueDel(uid);
}

private void OnMindAdded(EntityUid uid, EvilTwinComponent component, MindAddedMessage args)
Expand Down Expand Up @@ -529,29 +540,17 @@ private bool TryGetEligibleHumanoid([NotNullWhen(true)] out EntityUid? uid)
}

[Dependency] private readonly InventorySystem _inventory = default!;

[Dependency] private readonly IRobustRandom _random = default!;

[Dependency] private readonly IPrototypeManager _prototype = default!;

[Dependency] private readonly IServerPreferencesManager _prefs = default!;

[Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!;

[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;

[Dependency] private readonly StationSystem _stationSystem = default!;

[Dependency] private readonly PrayerSystem _prayerSystem = default!;

[Dependency] private readonly IAdminLogManager _adminLogger = default!;

[Dependency] private readonly IEntityManager _entityManager = default!;

[Dependency] private readonly TagSystem _tagSystem = default!;

[Dependency] private readonly MindSystem _mindSystem = default!;

[Dependency] private readonly MetaDataSystem _metaSystem = default!;
[Dependency] private readonly RoleSystem _roles = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
Expand All @@ -569,3 +568,15 @@ private bool TryGetEligibleHumanoid([NotNullWhen(true)] out EntityUid? uid)

[ValidatePrototypeId<EntityPrototype>] private const string SpawnPointPrototype = "SpawnPointEvilTwin";
}

public sealed class SpawnEvilTwinEvent : EntityEventArgs
{
public Entity<EvilTwinSpawnerComponent> Entity;
public ICommonSession Session;

public SpawnEvilTwinEvent(Entity<EvilTwinSpawnerComponent> entity, ICommonSession session)
{
Entity = entity;
Session = session;
}
}
Binary file added Resources/Audio/Weapons/Guns64/EG-C/shot.ogg
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/EG-P/shot.ogg
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/EG-R/shot.ogg
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/EG-S/sniper.ogg
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/EGE-XR/shot.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/LMGs/m60.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/LMGs/t27.ogg
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/LMGs/t42.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/Pistols/colt.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/Rifles/T64.ogg
Binary file not shown.
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/Rifles/ak47.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/Rifles/ar18.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/Rifles/famas.ogg
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/Rifles/g36.ogg
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/Rifles/m16.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/Rifles/m28.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/SMGs/mp38.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/SMGs/mp5.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/SMGs/mp7.ogg
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/SMGs/p90.ogg
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/SMGs/ppsh.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/SMGs/uzi.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/Snipers/svd.ogg
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/Snipers/svd1.ogg
Binary file not shown.
Binary file added Resources/Audio/Weapons/Guns64/Snipers/svd2.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions Resources/Prototypes/Backmen/Adminbuse/DED.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
head: ClothingHeadHatBeretMobileTaskForce
id: DedSquadronLeaderGavnaIDCard
ears: ClothingHeadsetCentComCC
belt: WeaponRevolverMateba
belt: WeaponRevolverMatebaNew
pocket1: EnergySwordDedSad
pocket2: WeaponPulsePistol

Expand All @@ -143,7 +143,7 @@
suitstorage: OxygenTankFilled
id: DedSquadronGavnaIDCard
ears: ClothingHeadsetCentComCC
belt: WeaponRevolverMateba
belt: WeaponRevolverMatebaNew
pocket1: EnergySwordDedSad
pocket2: WeaponPulsePistol

Expand Down
16 changes: 2 additions & 14 deletions Resources/Prototypes/Backmen/Adminbuse/centcomm_kid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -340,25 +340,13 @@


- type: entity
name: автоматический Силовик
parent: WeaponShotgunEnforcer
parent: WeaponShotgun39
id: WeaponShotgunEnforcerRXBZZ
description: Дробовик марки Frozen Star нового поколения. Использует патроны калибра .50 ружейный.
components:
- type: BallisticAmmoProvider
whitelist:
tags:
- ShellShotgun
capacity: 10
proto: ShellShotgun
soundInsert:
path: /Audio/Weapons/Guns/MagIn/shotgun_insert.ogg


- type: entity
name: Лектер
suffix: Зажигательные
parent: WeaponRifleLecter
parent: WeaponRifleAR18
id: WeaponRifleLecterFire
description: Первоклассная армейская штурмовая винтовка. Использует патроны калибра .20 винтовочный.
components:
Expand Down
Loading
Loading