生成怪物阵营问题,指定阵营生成后的阵营会发生改变

当我使用 WukongApi.Sync.SpawnEnemy 生成boss时teamId=1大概率会生成其他阵营的boss

1 Like

Hi,

this issue will be fixed in SDK 0.3.0. For now, you can add this patch anywhere in your mod to fix it:

[HarmonyPatch]
[HarmonyPatchCategory(PatchCategory.Connected)]
public class TamerTeamResetPatch
{
    [HarmonyTargetMethodHint("b1.BUS_TeamIDManageComp", "SetDefaultTeamIDInternal")]
    private static MethodBase TargetMethod()
    {
        return AccessTools.Method("b1.BUS_TeamIDManageComp:SetDefaultTeamIDInternal");
    }

    public static bool Prefix(BGUCharacterCS ___OwnerAsCharacterCS)
    {
        if (!WukongApi.Sync.InArea)
            return true;

        foreach (var tamer in WukongApi.Sync.AllTamers)
        {
            if (tamer.Pawn == ___OwnerAsCharacterCS && tamer.TeamId != 0)
            {
                Logging.LogDebug("Prevented team ID reset for {Guid} with team ID {TeamId}", tamer.Guid, tamer.TeamId);
                return false;
            }
        }

        return true;
    }
}