Skip to content

Commit

Permalink
Merge pull request #570 from sailro/setup-items
Browse files Browse the repository at this point in the history
Add extra setup for spawned items
  • Loading branch information
sailro authored Sep 26, 2024
2 parents f7e2847 + 532768d commit 7533eb4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
38 changes: 36 additions & 2 deletions ConsoleCommands/Spawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using EFT.Trainer.Features;
using EFT.Trainer.Properties;
using JetBrains.Annotations;
using UnityEngine;
using Random = UnityEngine.Random;

#nullable enable
Expand Down Expand Up @@ -87,7 +86,7 @@ private static void SpawnTemplate(ItemTemplate template, Player player, ConsoleC
}
else
{
item.SpawnedInSession = true; // found in raid
SetupItem(itemFactory, item);

_ = new TraderControllerClass(item, item.Id, item.ShortName);
var go = poolManager.CreateLootPrefab(item, ECameraType.Default);
Expand All @@ -110,4 +109,39 @@ private static void SpawnTemplate(ItemTemplate template, Player player, ConsoleC
return Task.CompletedTask;
});
}

private static void SetupItem(ItemFactoryClass itemFactory, Item item)
{
item.SpawnedInSession = true; // found in raid

if (item.TryGetItemComponent<DogtagComponent>(out var dogtag))
{
dogtag.AccountId = Random.Range(0, int.MaxValue).ToString();
dogtag.ProfileId = Random.Range(0, int.MaxValue).ToString();
dogtag.Nickname = $"Rambo{Random.Range(1, 256)}";
dogtag.Side = Enum.GetValues(typeof(EPlayerSide)).Cast<EPlayerSide>().Random();
dogtag.Level = Random.Range(1, 69);
dogtag.Time = DateTime.Now;
dogtag.Status = "died";
dogtag.KillerAccountId = Random.Range(0, int.MaxValue).ToString();
dogtag.KillerProfileId = Random.Range(0, int.MaxValue).ToString();
dogtag.KillerName = "";
dogtag.WeaponName = "";
}

if (item.TryGetItemComponent<ArmorHolderComponent>(out var armorHolder))
{
foreach (var slot in armorHolder.ArmorSlots)
{
var plate = itemFactory.CreateItem(MongoID.Generate(), KnownTemplateIds.CultTermiteBallisticPlate, null);
slot.AddWithoutRestrictions(plate);
}
}

if (item.TryGetItemComponent<RepairableComponent>(out var repairable))
{
repairable.MaxDurability = repairable.TemplateDurability;
repairable.Durability = repairable.MaxDurability;
}
}
}
2 changes: 2 additions & 0 deletions KnownTemplateIds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ public static class KnownTemplateIds
public const string AirDropSupply = "622334fa3136504a544d160c";
public const string AirDropWeapon = "6223351bb5d97a7b2c635ca7";

public const string CultTermiteBallisticPlate = "656fa99800d62bcd2e024088";

public static string DefaultInventoryLocalizedShortName = ((MongoID)DefaultInventory).LocalizedShortName();
}

0 comments on commit 7533eb4

Please sign in to comment.