Skip to content

Commit

Permalink
Final KKS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Nov 5, 2021
1 parent 48b8f37 commit 4072bad
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 227 deletions.
9 changes: 8 additions & 1 deletion src/Core_Pregnancy_KK/Data/PregnancyDataUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,18 @@ public static HeroineStatus GetCharaStatus(this SaveData.CharaData chara, Pregna
if (pregData == null) pregData = heroine.GetPregnancyData();

// Check if she wants to tell //todo need to ask in talk scene
if (heroine.intimacy >= 80 || //todo what is relation in kks
#if KK
if (heroine.intimacy >= 80 ||
heroine.hCount >= 5 ||
heroine.parameter.attribute.bitch && heroine.favor > 50 ||
(heroine.isGirlfriend || heroine.favor >= 90) &&
(!heroine.isVirgin || heroine.hCount >= 2 || heroine.intimacy >= 40))
#else
if (heroine.relation >= 3 ||
heroine.hCount >= 5 ||
heroine.parameter.attribute.bitch && heroine.favor > 50 ||
heroine.isGirlfriend && (heroine.favor >= 90 || heroine.hCount >= 2))
#endif
{
var pregnancyWeek = pregData.Week;
if (pregnancyWeek > 0)
Expand Down
13 changes: 9 additions & 4 deletions src/Core_Pregnancy_KK/LactationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,14 @@ private void InitializeParticles()

PregnancyPlugin.Logger.LogDebug("Adding particles to heroine: " + ChaControl.fileParam.fullname);

#if KK
const string assetFilePath = @"h/common/00_00.unity3d";
#elif KKS
const string assetFilePath = @"h/common/01.unity3d";
#endif
_partHeavyR = new HParticleCtrl.ParticleInfo
{
assetPath = @"h/common/00_00.unity3d",
assetPath = assetFilePath,
file = "LiquidSiru",
numParent = 1,
nameParent = "a_n_nip_R",
Expand All @@ -296,7 +301,7 @@ private void InitializeParticles()
};
_partLightR = new HParticleCtrl.ParticleInfo
{
assetPath = @"h/common/00_00.unity3d",
assetPath = assetFilePath,
file = "LiquidSio",
numParent = 1,
nameParent = "a_n_nip_R",
Expand All @@ -305,7 +310,7 @@ private void InitializeParticles()
};
_partHeavyL = new HParticleCtrl.ParticleInfo
{
assetPath = @"h/common/00_00.unity3d",
assetPath = assetFilePath,
file = "LiquidSiru",
numParent = 1,
nameParent = "a_n_nip_L",
Expand All @@ -314,7 +319,7 @@ private void InitializeParticles()
};
_partLightL = new HParticleCtrl.ParticleInfo
{
assetPath = @"h/common/00_00.unity3d",
assetPath = assetFilePath,
file = "LiquidSio",
numParent = 1,
nameParent = "a_n_nip_L",
Expand Down
25 changes: 13 additions & 12 deletions src/Core_Pregnancy_KK/PregnancyPlugin.Hooks.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using ExtensibleSaveFormat;
using HarmonyLib;
using KKAPI.MainGame;
using KKAPI.Utilities;
using Manager;
using UnityEngine;

Expand All @@ -19,17 +17,14 @@ public static void InitHooks(Harmony harmonyInstance)
{
harmonyInstance.PatchAll(typeof(Hooks));

PatchNPCLoadAll(harmonyInstance, new HarmonyMethod(typeof(Hooks), nameof(NPCLoadAllTpl)));
PatchNPCLoadAll(harmonyInstance);
}

private static bool _lastPullProc;

#region Custom safe day schedule

private static SaveData.Heroine _lastHeroine;
private static byte[] _menstruationsBackup;


[HarmonyPostfix]
[HarmonyPatch(typeof(SaveData.Heroine), nameof(SaveData.Heroine.MenstruationDay), MethodType.Getter)]
private static void LastAccessedHeroinePatch(SaveData.Heroine __instance)
Expand Down Expand Up @@ -71,17 +66,21 @@ private static void GetMenstruationOverridePostfix()
/// <summary>
/// Needed for preventing characters from going to school when on leave after pregnancy
/// </summary>
private static void PatchNPCLoadAll(Harmony instance, HarmonyMethod transpiler)
private static void PatchNPCLoadAll(Harmony instance)
{
var t = typeof(ActionScene).GetNestedTypes(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Single(x => x.Name.StartsWith("<NPCLoadAll>c__Iterator"));
var m = t.GetMethod("MoveNext");
instance.Patch(m, null, null, transpiler);
var transpiler = new HarmonyMethod(typeof(Hooks), nameof(NPCLoadAllTpl));
foreach (var target in typeof(ActionScene).GetMethods(AccessTools.all).Where(x => x.Name == nameof(ActionScene.NPCLoadAll)))
{
Logger.LogDebug("Patching " + target.FullDescription());
instance.PatchMoveNext(target, null, null, transpiler);
}
}

private static IEnumerable<CodeInstruction> NPCLoadAllTpl(IEnumerable<CodeInstruction> instructions)
{
var target = AccessTools.Property(typeof(Game), nameof(Game.HeroineList)).GetGetMethod();
var customFilterM = AccessTools.Method(typeof(Hooks), nameof(GetFilteredHeroines));
var count = 0;
foreach (var instruction in instructions)
{
yield return instruction;
Expand All @@ -90,8 +89,10 @@ private static IEnumerable<CodeInstruction> NPCLoadAllTpl(IEnumerable<CodeInstru
{
// Grab the return of get_HeroineList and process it
yield return new CodeInstruction(OpCodes.Call, customFilterM);
count++;
}
}
Logger.LogDebug("NPCLoadAllTpl calls injected count: " + count);
}

#endregion Preg leave from school
Expand Down
Loading

0 comments on commit 4072bad

Please sign in to comment.