diff --git a/Commands/FamiliarCommands.cs b/Commands/FamiliarCommands.cs
index 5eb7274..166461b 100644
--- a/Commands/FamiliarCommands.cs
+++ b/Commands/FamiliarCommands.cs
@@ -91,7 +91,7 @@ public static void BindFamiliar(ChatCommandContext ctx, int choice)
{
if (choice < 1 || choice > famKeys.Count)
{
- LocalizationService.HandleReply(ctx, $"Invalid choice, please use 1 to {famKeys.Count} (Current List:{set})");
+ LocalizationService.HandleReply(ctx, $"Invalid choice, please use 1 to {famKeys.Count} (Current List: {set})");
return;
}
@@ -352,8 +352,7 @@ public static void AddFamiliar(ChatCommandContext ctx, string name, string unit)
lastListName = $"box{unlocksData.UnlockedFamiliars.Count + 1}";
unlocksData.UnlockedFamiliars[lastListName] = [];
SaveUnlockedFamiliars(steamId, unlocksData);
- FamiliarUtilities.
- ParseAddedFamiliar(ctx, steamId, unit, lastListName);
+ FamiliarUtilities.ParseAddedFamiliar(ctx, steamId, unit, lastListName);
}
else
{
@@ -379,7 +378,7 @@ public static void RemoveFamiliarFromSet(ChatCommandContext ctx, int choice)
// Remove the old set
if (choice < 1 || choice > familiarSet.Count)
{
- LocalizationService.HandleReply(ctx, $"Invalid choice, please use 1 to {familiarSet.Count} (Current List:{familiarSet})");
+ LocalizationService.HandleReply(ctx, $"Invalid choice, please use 1 to {familiarSet.Count} (Current List:{activeSet})");
return;
}
PrefabGUID familiarId = new(familiarSet[choice - 1]);
diff --git a/Core.cs b/Core.cs
index 52ffe7f..fd95445 100644
--- a/Core.cs
+++ b/Core.cs
@@ -8,18 +8,11 @@
using Bloodcraft.Systems.Leveling;
using Bloodcraft.Systems.Quests;
using Bloodcraft.Utilities;
-using Il2CppInterop.Runtime;
-using ProjectM;
-using ProjectM.Network;
using ProjectM.Physics;
using ProjectM.Scripting;
-using ProjectM.Shared;
-using Stunlock.Core;
using System.Collections;
using Unity.Entities;
-using Unity.Mathematics;
using UnityEngine;
-using static Bloodcraft.Utilities.EntityUtilities;
namespace Bloodcraft;
internal static class Core
@@ -38,8 +31,6 @@ public static void Initialize()
{
if (hasInitialized) return;
- //SCTFixTest(); // only useful for removing SCT prefabs if for some reason they are being generated in mass
-
hasInitialized = true;
_ = new PlayerService();
@@ -82,9 +73,10 @@ public static void StartCoroutine(IEnumerator routine)
MonoBehaviour.StartCoroutine(routine.WrapToIl2Cpp());
}
+ /*
static readonly ComponentType[] SCTComponent =
[
- ComponentType.ReadOnly(Il2CppType.Of()),
+ ComponentType.ReadOnly(Il2CppType.Of()),
];
static readonly PrefabGUID SCTPrefab = new(-1661525964);
@@ -100,8 +92,12 @@ static void SCTFixTest() // one off thing hopefully but leaving since those have
int counter = 0;
try
{
+ Dictionary> userTargetCounts = [];
IEnumerable prefabEntities = GetEntitiesEnumerable(sctQuery); // destroy errant SCT entities and log what's going on
- if (prefabEntities.Count() > 5000)
+ int entityCount = prefabEntities.Count();
+
+ Core.Log.LogInfo(entityCount); // okay yeah definitely something with either familiar summons or just undead summons?
+ if (entityCount > 5000)
{
foreach (Entity entity in prefabEntities)
{
@@ -111,12 +107,32 @@ static void SCTFixTest() // one off thing hopefully but leaving since those have
{
if (ServerGameManager.TryGetBuffer(entity, out var syncToUserBuffer))
{
- if (entity.TryGetComponent(out ScrollingCombatTextMessage scrollingCombatText))
+ if (!syncToUserBuffer.IsEmpty)
{
- Entity target = scrollingCombatText.Target.GetSyncedEntityOrNull();
- if (target.Exists())
+ string userName = syncToUserBuffer[0].UserEntity.Read().CharacterName.Value;
+
+ if (entity.TryGetComponent(out ScrollingCombatTextMessage scrollingCombatText))
{
- DestroyUtility.Destroy(EntityManager, target);
+ Entity target = scrollingCombatText.Target.GetSyncedEntityOrNull();
+ if (target.Exists() && !target.IsPlayer())
+ {
+ string targetName = target.Read().LookupName();
+
+ if (!userTargetCounts.ContainsKey(userName))
+ {
+ userTargetCounts[userName] = [];
+ }
+
+ Dictionary targetCounts = userTargetCounts[userName];
+
+ if (!targetCounts.ContainsKey(targetName))
+ {
+ targetCounts[targetName] = 0;
+ }
+
+ targetCounts[targetName]++;
+ DestroyUtility.Destroy(EntityManager, target);
+ }
}
}
}
@@ -126,6 +142,20 @@ static void SCTFixTest() // one off thing hopefully but leaving since those have
}
Log.LogWarning($"Cleared {counter} SCT entities");
}
+
+ foreach (var userEntry in userTargetCounts)
+ {
+ string userName = userEntry.Key;
+ var targetCounts = userEntry.Value;
+
+ Log.LogInfo($"User: {userName}");
+ foreach (var targetEntry in targetCounts)
+ {
+ string targetName = targetEntry.Key;
+ int count = targetEntry.Value;
+ Log.LogInfo($"\tTarget: {targetName}, Count: {count}");
+ }
+ }
}
catch (Exception e)
{
@@ -136,4 +166,48 @@ static void SCTFixTest() // one off thing hopefully but leaving since those have
sctQuery.Dispose();
}
}
+
+ static readonly ComponentType[] PrefabGUIDComponent =
+ [
+ ComponentType.ReadOnly(Il2CppType.Of()),
+ ];
+
+ static readonly PrefabGUID WitheredPrefab = new(-1584807109);
+ static void UnitFixTest() // one off thing hopefully but leaving since those have a habit of coming back around
+ {
+ // -1661525964 SCT prefab
+ EntityQuery prefabQuery = EntityManager.CreateEntityQuery(new EntityQueryDesc
+ {
+ All = PrefabGUIDComponent,
+ Options = EntityQueryOptions.IncludeAll
+ });
+
+ try
+ {
+ Dictionary> userTargetCounts = [];
+ IEnumerable prefabEntities = GetEntitiesEnumerable(prefabQuery);
+ int entityCount = prefabEntities.Count();
+
+ int counter = 0;
+ //Core.Log.LogInfo(entityCount);
+ foreach (Entity entity in prefabEntities)
+ {
+ if (entity.TryGetComponent(out PrefabGUID prefab) && prefab.Equals(WitheredPrefab) && entity.Has() && entity.TryGetComponent(out EntityOwner owner) && owner.Owner.Exists())
+ {
+ StatChangeUtility.KillOrDestroyEntity(EntityManager, entity, owner.Owner, owner.Owner, ServerTime, StatChangeReason.Default, true);
+ counter++;
+ }
+ }
+ Log.LogWarning($"Destroyed {counter} withered units");
+ }
+ catch (Exception e)
+ {
+ Log.LogError(e);
+ }
+ finally
+ {
+ prefabQuery.Dispose();
+ }
+ }
+ */
}
\ No newline at end of file
diff --git a/Patches/BuffSystemSpawnServerPatch.cs b/Patches/BuffSystemSpawnServerPatch.cs
index 1806b79..b864d5a 100644
--- a/Patches/BuffSystemSpawnServerPatch.cs
+++ b/Patches/BuffSystemSpawnServerPatch.cs
@@ -3,7 +3,6 @@
using Bloodcraft.Utilities;
using HarmonyLib;
using ProjectM;
-using ProjectM.Gameplay.Scripting;
using ProjectM.Network;
using ProjectM.Scripting;
using ProjectM.Shared;
@@ -71,6 +70,7 @@ static void OnUpdatePrefix(BuffSystem_Spawn_Server __instance)
Entity player = Entity.Null;
// sections should be grouped appropriately to not interfere with each other
+ //Core.Log.LogInfo($"BuffSystem_Spawn_Server Prefix: {prefabGUID.LookupName()}");
/* there might be some reason I'm forgetting I don't just process these over in deathEventListerSystem but let's try and find out
if (prefabGUID.Equals(feedExecute) && entity.GetBuffTarget().TryGetPlayer(out player)) // feed execute kills
@@ -242,14 +242,17 @@ static void OnUpdatePrefix(BuffSystem_Spawn_Server __instance)
if (swordPermabuff.Has()) swordPermabuff.Remove();
}
}
- else if (prefabGUID.Equals(castlemanCombatBuff))
- {
- if (entity.Has()) entity.Remove();
- }
else if (prefabGUID.Equals(holyBeamPowerBuff))
{
if (entity.Has()) entity.Write(new LifeTime { Duration = 30f, EndAction = LifeTimeEndAction.Destroy });
}
+ /* apparently doesn't actually go through here, huh
+ else if (prefabGUID.Equals(castlemanCombatBuff))
+ {
+ if (entity.Has()) entity.Remove();
+ Core.Log.LogInfo("Removed AdaptLevel from CastleMan combat buff...");
+ }
+ */
}
}
/*
diff --git a/Patches/LinkMinionToOwnerOnSpawnSystemPatch.cs b/Patches/LinkMinionToOwnerOnSpawnSystemPatch.cs
index ded020e..0f9cb37 100644
--- a/Patches/LinkMinionToOwnerOnSpawnSystemPatch.cs
+++ b/Patches/LinkMinionToOwnerOnSpawnSystemPatch.cs
@@ -70,10 +70,6 @@ static void OnUpdatePrefix(LinkMinionToOwnerOnSpawnSystem __instance)
}
}
}
- else if (entity.GetOwner().TryGetPlayer(out Entity character))
- {
- Core.Log.LogInfo($" {entity.Read().LookupName()} minion linked to {character.Read().Name.Value}");
- }
}
}
finally
diff --git a/Patches/ScriptSpawnServerPatch.cs b/Patches/ScriptSpawnServerPatch.cs
index cd49cfd..50d4643 100644
--- a/Patches/ScriptSpawnServerPatch.cs
+++ b/Patches/ScriptSpawnServerPatch.cs
@@ -3,6 +3,7 @@
using HarmonyLib;
using ProjectM;
using ProjectM.Gameplay.Scripting;
+using ProjectM.Scripting;
using ProjectM.Shared.Systems;
using Stunlock.Core;
using Unity.Collections;
@@ -27,6 +28,19 @@ static void OnUpdatePrefix(ScriptSpawnServer __instance)
{
foreach (Entity entity in entities)
{
+ if (entity.Has())
+ {
+ //Core.Log.LogInfo("CastleManCombatBuff");
+ if (entity.GetBuffTarget().TryGetFollowedPlayer(out Entity _))
+ {
+ if (entity.Has()) entity.Remove();
+ if (entity.Has()) entity.Remove();
+ if (entity.Has()) entity.Remove();
+ if (entity.Has()) entity.Remove();
+ entity.Remove();
+ }
+ }
+
if (!entity.Has() || !entity.Has()) continue;
if (entity.GetOwner().TryGetPlayer(out Entity player))
diff --git a/Utilities/FamiliarUtilities.cs b/Utilities/FamiliarUtilities.cs
index d5b2b4d..21b8834 100644
--- a/Utilities/FamiliarUtilities.cs
+++ b/Utilities/FamiliarUtilities.cs
@@ -110,7 +110,7 @@ public static void ParseAddedFamiliar(ChatCommandContext ctx, ulong steamId, str
return;
}
- data.UnlockedFamiliars[activeSet].Add(prefab);
+ data.UnlockedFamiliars[activeSet].Add(result.GuidHash);
SaveUnlockedFamiliars(steamId, data);
LocalizationService.HandleReply(ctx, $"{result.GetPrefabName()} ({result.GuidHash}) added to {activeSet}.");
}