示例#1
0
        private static void ApplyStatChangeVars(Heroine heroine, PregnancyData preg, Dictionary <string, ValData> vars)
        {
            if (vars.TryGetVarValue("PillUsed", out bool used) && used)
            {
                PregnancyGameController.ForceStopPregnancyDelayed(heroine);

                var freePill = _personalityHasPills.TryGetValue(heroine.personality, out var val) && val;
                if (!freePill)
                {
                    StoreApi.SetItemAmountBought(AfterpillStoreId, Mathf.Clamp(StoreApi.GetItemAmountBought(AfterpillStoreId) - 1, 0, 99));
                }
            }

            if (vars.TryGetVarValue <int>("FavorChange", out var favor))
            {
                heroine.favor = Mathf.Clamp(heroine.favor + favor, 0, 150);
            }

            if (vars.TryGetVarValue <int>("LewdChange", out var lewd))
            {
                heroine.lewdness = Mathf.Clamp(heroine.lewdness + lewd, 0, 100);
            }

            if (vars.TryGetVarValue <int>("MoneyChange", out var money))
            {
                Manager.Game.saveData.player.koikatsuPoint += money;
            }
        }
示例#2
0
        private static void RunIntroEvent(Heroine heroine, PregnancyData preg, bool isPillEvent)
        {
            var loadedEvt = GetEvent(heroine, preg, isPillEvent);

            if (loadedEvt == null)
            {
                PregnancyPlugin.Logger.LogError("Unexpected null GetEvent result");
                return;
            }

            // Init needed first since the custom event starts empty
            var evt = EventApi.CreateNewEvent(setPlayerParam: true);

            heroine.SetADVParam(evt);
            var freePill = _personalityHasPills.TryGetValue(heroine.personality, out var val) && val;

            evt.Add(Program.Transfer.VAR("bool", "PillForFree", freePill.ToString(CultureInfo.InvariantCulture)));
            evt.Add(Program.Transfer.VAR("bool", "PlayerHasPill", (StoreApi.GetItemAmountBought(AfterpillStoreId) >= 1).ToString(CultureInfo.InvariantCulture)));
            // Give favor by default, gets overriden if the event specifies any other value
            evt.Add(Program.Transfer.VAR("int", "FavorChange", "30"));

            evt.AddRange(loadedEvt);

            var scene = TalkScene.instance;

            scene.StartADV(evt, scene.cancellation.Token)
            .ContinueWith(() => Program.ADVProcessingCheck(scene.cancellation.Token))
            .ContinueWith(() =>
            {
                PregnancyGameController.ApplyToAllDatas((chara, data) =>
                {
                    if (chara == heroine)
                    {
                        if (isPillEvent)
                        {
                            data.CanAskForAfterpill = false;
                        }
                        else
                        {
                            data.CanTellAboutPregnancy = false;
                        }
                        return(true);
                    }
                    return(false);
                });

                var vars = ActionScene.instance.AdvScene.Scenario.Vars;
                ApplyStatChangeVars(heroine, preg, vars);

                // Fix mouth getting permanently locked by the events
                heroine.chaCtrl.ChangeMouthFixed(false);
            })
            .Forget();
        }
示例#3
0
        private static ChangeValueTopicInfo GetAdvResult(TalkScene scene, int topicno, int personality, bool isnpc, Dictionary <string, ValData> advvars)
        {
            if (advvars.TryGetVarValue <bool>("Success", out var passed) && passed)
            {
                var data = scene.targetHeroine.GetPregnancyData();
                if (data.GameplayEnabled && !data.IsPregnant)
                {
                    PregnancyGameController.StartPregnancy(scene.targetHeroine);
                }
            }

            advvars.TryGetVarValue <int>("FavorChange", out var favor);
            advvars.TryGetVarValue <int>("LewdChange", out var lewd);
            return(new ChangeValueTopicInfo(favor, lewd));
        }
示例#4
0
        [HarmonyWrapSafe] // Ignore crashes
        private static void OnFinishInside(HFlag __instance)
        {
            if (!IsEffectActive())
            {
                return;
            }

            var heroine    = __instance.GetLeadingHeroine();
            var controller = PregnancyPlugin.GetEffectController(heroine);

            if (controller.Data.GameplayEnabled && !controller.Data.IsPregnant && controller.Data.Fertility > 0.001f)
            {
                var isDangerousDay = HFlag.GetMenstruation(heroine.MenstruationDay) == HFlag.MenstruationType.危険日;
                if (UnityEngine.Random.RandomRangeInt(0, 100) < (isDangerousDay ? 95 : 30))
                {
                    PregnancyPlugin.Logger.LogInfo("Through the power of a pin hole, pregnancy");
                    PregnancyGameController.StartPregnancyDelayed(heroine, true);
                }
            }
        }