Exemplo n.º 1
0
        private static List <Program.Transfer> GetAdvScript(TalkScene scene, int topicno, int personality, bool isnpc)
        {
            // todo variations for rejectng, already pregnant (don't need them anymore)
            var list = EventApi.CreateNewEvent();

            list.Add(Program.Transfer.Text(EventApi.Narrator, "I activated these earlier with my cum, I wonder if I should try giving this pack to her as a gift..."));
            list.Add(Program.Transfer.Text(EventApi.Heroine, "Hmm? What's wrong?"));
            list.Add(Program.Transfer.Text(EventApi.Player, "Umm, actually I bought you a gift, but it might be a bit weird."));
            list.Add(Program.Transfer.Text(EventApi.Heroine, "Haha, don't worry you're plenty weird anyways. So, what's the gift?"));
            list.Add(Program.Transfer.Text(EventApi.Narrator, "I take out the box and offer it to her. There was a replacement seal included in the box so it looks unopened."));
            list.Add(Program.Transfer.Text(EventApi.Player, "Here."));
            list.Add(Program.Transfer.Text(EventApi.Heroine, "Huh? Are those..?"));
            list.Add(Program.Transfer.Text(EventApi.Narrator, "She stares at the box in silence for a good while."));
            list.Add(Program.Transfer.Text(EventApi.Player, "It's too weird after all. Sorry, can you forget about-"));
            list.Add(Program.Transfer.Text(EventApi.Heroine, "Ah, no it's fine! I was just surprised since I didn't know guys knew about these things."));
            list.Add(Program.Transfer.Text(EventApi.Player, "Yeah, I guess that's true."));
            list.Add(Program.Transfer.Text(EventApi.Heroine, "I use similar looking ones so they should be fine, I'll take them. You won't have any use for them anyways, haha."));
            list.Add(Program.Transfer.Text(EventApi.Player, "Really? Here you go then."));
            list.Add(Program.Transfer.Text(EventApi.Narrator, "She carefully takes the box from my hand."));
            list.Add(Program.Transfer.Text(EventApi.Heroine, "Thanks!"));
            list.Add(Program.Transfer.Text(EventApi.Heroine, "Ahh, just so you know, you shouldn't give these to other girls! You got lucky with me, but others might think it's sexual harassment and kick you in the groin."));
            list.Add(Program.Transfer.Text(EventApi.Player, "I-I'll keep that in mind."));
            list.Add(Program.Transfer.VAR("System.Boolean", "Success", "true"));
            list.Add(Program.Transfer.VAR("System.Int32", "FavorChange", "20"));
            list.Add(Program.Transfer.VAR("System.Int32", "LewdChange", "10"));
            list.Add(Program.Transfer.Close());
            return(list);
        }
Exemplo n.º 2
0
            private static bool TryPlayCustomTopicAdvHook(TalkScene scene)
            {
                var topic   = scene.topics[scene.selectTopic];
                var topicNo = topic.No;

                _customTopics.TryGetValue(topicNo, out var topicInfo);
                if (topicInfo != null)
                {
                    KoikatuAPI.Logger.LogDebug("Handling custom topic No=" + topicNo);
                    var script = topicInfo.ScriptGetter(scene, topicNo, scene.targetHeroine.personality, scene.isNPC);
                    if (script != null)
                    {
                        KoikatuAPI.Logger.LogDebug("Playing ADV scene for the topic");

                        scene.StartADV(script, CancellationToken.None).GetAwaiter().GetResult(); //todo handle cancelling

                        var vars = ActionScene.initialized ? ActionScene.instance.AdvScene.Scenario.Vars : SceneParameter.advScene.Scenario.Vars;

                        var result = topicInfo.ResultGetter(scene, topicNo, scene.targetHeroine.personality, scene.isNPC, vars);
                        scene.m_CVInfo = result ?? new ChangeValueTopicInfo();
                    }
                    return(true);
                }

                return(false);
            }
        private static void AwakePost(TalkScene __instance)
        {
            var sourceTransform      = __instance.buttonTouch[0].transform;
            var otherSourceTransform = __instance.buttonTouch[1].transform;
            var change = (sourceTransform.localPosition - otherSourceTransform.localPosition).x;

            foreach (var entryRow in _buttons.GroupBy(x => x.Row))
            {
                var xOffset = -change;
                // Take account of the 2 stock buttons
                if (entryRow.Key == 0)
                {
                    xOffset += 2 * change;
                }
                // Tweak the offset to make buttons in row 2 fit on the black letterbox part
                var yOffset      = change * entryRow.Key * 0.97f;
                var lastPosition = otherSourceTransform.localPosition + new Vector3(xOffset, yOffset, 0);

                foreach (var entry in entryRow.OrderBy(x => x.Order).ThenBy(x => _buttons.IndexOf(x)))
                {
                    var copy = Object.Instantiate(sourceTransform.gameObject, sourceTransform.parent, false);
                    copy.transform.localPosition = lastPosition + new Vector3(change, 0, 0);
                    lastPosition = copy.transform.localPosition;

                    var btn = copy.GetComponent <Button>();
                    btn.onClick.ActuallyRemoveAllListeners();

                    btn.image.sprite = entry.Icon;
                    btn.transition   = Selectable.Transition.ColorTint;

                    entry.Instance = copy;
                    entry.OnCreated(btn);
                }
            }
        }
Exemplo n.º 4
0
        public static void InitializeCheats()
        {
            CheatToolsWindow.OnShown = window =>
            {
                _hFlag                 = Object.FindObjectOfType <HFlag>();
                _talkScene             = Object.FindObjectOfType <TalkScene>();
                _hSprite               = Object.FindObjectOfType <HSprite>();
                _studioInstance        = Studio.Studio.Instance;
                _soundInstance         = Manager.Sound.Instance;
                _communicationInstance = Communication.Instance;
                _sceneInstance         = Scene.Instance;
                _gameMgr               = Game.Instance;

                _openInInspectorButtons = new[]
                {
                    new KeyValuePair <object, string>(_gameMgr != null && _gameMgr.HeroineList.Count > 0 ? (Func <object>)(() => _gameMgr.HeroineList.Select(x => new ReadonlyCacheEntry(x.ChaName, x))) : null, "Heroine list"),
                    new KeyValuePair <object, string>(_gameMgr, "Manager.Game.Instance"),
                    new KeyValuePair <object, string>(_sceneInstance, "Manager.Scene.Instance"),
                    new KeyValuePair <object, string>(_communicationInstance, "Manager.Communication.Instance"),
                    new KeyValuePair <object, string>(_soundInstance, "Manager.Sound.Instance"),
                    new KeyValuePair <object, string>(_hFlag, "HFlag"),
                    new KeyValuePair <object, string>(_talkScene, "TalkScene"),
                    new KeyValuePair <object, string>(_studioInstance, "Studio.Instance"),
                    new KeyValuePair <object, string>((Func <object>)EditorUtilities.GetRootGoScanner, "Root Objects")
                };
            };

            CheatToolsWindow.Cheats.Add(new CheatEntry(w => _studioInstance == null && _gameMgr != null && !_gameMgr.saveData.isOpening, DrawPlayerCheats, "Start the game to see player cheats"));
            CheatToolsWindow.Cheats.Add(new CheatEntry(w => _hFlag != null, DrawHSceneCheats, null));
            CheatToolsWindow.Cheats.Add(new CheatEntry(w => _gameMgr != null, DrawGirlCheatMenu, null));

            CheatToolsWindow.Cheats.Add(CheatEntry.CreateOpenInInspectorButtons(() => _openInInspectorButtons));

            CheatToolsWindow.Cheats.Add(new CheatEntry(w => _gameMgr != null, DrawGlobalUnlocks, null));
        }
        /// <summary>
        /// Simulate touching the character in TalkScene with mouse.
        /// </summary>
        /// <param name="talkScene">Talk scene</param>
        /// <param name="touchLocation">Where to touch</param>
        /// <param name="touchKind">How to touch</param>
        /// <param name="touchPosition">Optional position at which the touch happened (essentially mouse position)</param>
        public static void Touch(this TalkScene talkScene, TouchLocation touchLocation, TouchKind touchKind, Vector3 touchPosition = default)
        {
            var prevKind = talkScene.m_touchMode;

            talkScene.m_touchMode = (int)touchKind;

            talkScene.TouchFunc(touchLocation.ToString(), touchPosition);

            talkScene.m_touchMode = prevKind;
        }
Exemplo n.º 6
0
        static void UpdateUIFinalizer(TalkScene __instance, Button[] ___buttonEventContents)
        {
            Console.WriteLine("UpdateUIFinalizer " + _currentCrestType);
            if (_currentCrestType == CrestType.libido)
            {
                // 3 is lets have h
                // todo avoid using index for better compat?
                ___buttonEventContents[3]?.gameObject.SetActiveIfDifferent(true);
            }

            _currentCrestType = CrestType.None;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Simulate touching the character in TalkScene with mouse.
        /// </summary>
        /// <param name="talkScene">Talk scene</param>
        /// <param name="touchLocation">Where to touch</param>
        /// <param name="touchKind">How to touch</param>
        /// <param name="touchPosition">Optional position at which the touch happened (essentially mouse position)</param>
        public static void Touch(this TalkScene talkScene, TouchLocation touchLocation, TouchKind touchKind, Vector3 touchPosition = default)
        {
            var tv = Traverse.Create(talkScene);

            var tmf      = tv.Field <int>("m_touchMode");
            var prevKind = tmf.Value;

            tmf.Value = (int)touchKind;

            tv.Method("TouchFunc", new[] { typeof(string), typeof(Vector3) }).GetValue(touchLocation.ToString(), touchPosition);

            tmf.Value = prevKind;
        }
Exemplo n.º 8
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));
        }
Exemplo n.º 9
0
 static void ReflectChangeValuePrefix(TalkScene __instance)
 {
     // This is set by using the talk lewd option
     if (__instance.isDesire)
     {
         var heroine = __instance.targetHeroine;
         if (heroine.GetCurrentCrest() == CrestType.triggered)
         {
             var actCtrl = GameAPI.GetActionControl();
             actCtrl.AddDesire(4, heroine, 60);
             actCtrl.AddDesire(5, heroine, 60);
             actCtrl.AddDesire(26, heroine, heroine.parameter.attribute.likeGirls ? 60 : 30);
             actCtrl.AddDesire(29, heroine, 40);
             heroine.lewdness = Mathf.Min(100, heroine.lewdness + 60);
         }
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Start a new ADV event inside of a TalkScene (same as stock game events when talking).
        /// The target heroine is automatically added to the heroine list, and its vars are set at the very start.
        /// </summary>
        /// <param name="talkScene">Currently opened talk scene</param>
        /// <param name="list">List of commands for the event</param>
        /// <param name="endTalkScene">If true, end the talk scene after this event finishes.</param>
        /// <param name="decreaseTalkTime">Should the talk time bar decrease after the event. If the bar runs out then the talk scene will end.</param>
        public static IEnumerator StartTextSceneEvent(TalkScene talkScene, List <Program.Transfer> list, bool endTalkScene = false, bool decreaseTalkTime = false)
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }
            if (talkScene == null)
            {
                throw new ArgumentNullException(nameof(talkScene), "Has to be ran inside a TalkScene");
            }
            if (talkScene.targetHeroine == null)
            {
                throw new ArgumentNullException(nameof(talkScene.targetHeroine), "Heroine in TalkScene is null somehow?");
            }

            list.Insert(0, Program.Transfer.Create(true, Command.CharaChange, "-2", "true"));

            AccessTools.Field(typeof(TalkScene), "isUpdateCamera").SetValue(talkScene, false);
            AccessTools.Method(typeof(TalkScene), "StartADV", new[] { typeof(List <Program.Transfer>) }).Invoke(talkScene, new object[] { list });

            yield return(null);

            yield return(Program.Wait("Talk"));

            if (decreaseTalkTime)
            {
                Communication.Instance.DecreaseTalkTime(talkScene.targetHeroine, 1);
                if (talkScene.targetHeroine.talkTime <= 0)
                {
                    endTalkScene = true;
                }
            }

            if (endTalkScene)
            {
                var talkEndM = AccessTools.Method(typeof(TalkScene), "TalkEnd");
                IEnumerator TalkEnd() => (IEnumerator)talkEndM.Invoke(talkScene, null);

                Observable.FromCoroutine(TalkEnd).Subscribe().AddTo(talkScene);
            }
        }
Exemplo n.º 11
0
        static void UpdateUIFinalizer(TalkScene __instance)
        {
            //Console.WriteLine($"UpdateUIFinalizer crest={_currentCrestType}");
            if (_currentCrestType == CrestType.libido)
            {
                // todo avoid using index for better compat?
#if KK
                // 3 is lets have h
                __instance.buttonEventContents[3]?.gameObject.SetActiveIfDifferent(true);
#elif KKS
                // 0 is lets have h, 1 is invite to room
                __instance.buttonR18Contents[0]?.gameObject.SetActiveIfDifferent(true);
                // Need to turn on the main r18 button in case none of the sub options were active
                __instance.buttonInfos[4].Active = true;
#else
                throw new NotImplementedException();
#endif
            }

            _currentCrestType = CrestType.None;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Start a new ADV event inside of a TalkScene (same as stock game events when talking).
        /// The target heroine is automatically added to the heroine list, and their vars are set at the very start.
        /// Warning: You have to have a Close command or the scene will softlock after reaching the end!
        /// </summary>
        /// <param name="talkScene">Currently opened talk scene</param>
        /// <param name="commands">List of commands for the event</param>
        /// <param name="endTalkScene">If true, end the talk scene after this event finishes.</param>
        /// <param name="decreaseTalkTime">Should the talk time bar decrease after the event. If the bar runs out then the talk scene will end.</param>
        public static IEnumerator StartTextSceneEvent(TalkScene talkScene, IEnumerable <Program.Transfer> commands, bool decreaseTalkTime, bool endTalkScene = false)
        {
            if (commands == null)
            {
                throw new ArgumentNullException(nameof(commands));
            }
            if (talkScene == null || !talkScene.isActive)
            {
                throw new ArgumentNullException(nameof(talkScene), "Has to be ran inside of a TalkScene");
            }
            if (talkScene.targetHeroine == null)
            {
                throw new ArgumentNullException(nameof(talkScene.targetHeroine), "Heroine in TalkScene is null somehow?");
            }

            var token = talkScene.cancellation.Token;

            token.ThrowIfCancellationRequested();

            var list = commands.ToList();

            // Auto load all parameters of the TalkScene heroine
            list.Insert(0, Program.Transfer.Create(true, Command.CharaChange, "-2", "true"));

            talkScene.canvas.enabled  = false;
            talkScene.raycast.enabled = false;
            yield return(talkScene.StartADV(list, token).ToCoroutine(UnityEngine.Debug.LogException));

            if (decreaseTalkTime)
            {
                GameAssist.Instance.DecreaseTalkTime(talkScene.targetHeroine, 1);
                if (talkScene.targetHeroine.talkTime <= 0)
                {
                    endTalkScene = true;
                }
            }

            if (endTalkScene)
            {
                yield return(talkScene.TalkEnd(token).ToCoroutine(UnityEngine.Debug.LogException));
            }

            talkScene.LeaveAloneCancel();
            talkScene.lstColDisposable.ForEach(x => x.End());
            talkScene.TouchCancel();

            if (talkScene.transVoice != null)
            {
                Voice.Stop(talkScene.transVoice);
                talkScene.transVoice = null;
            }

            if (!token.IsCancellationRequested)
            {
                talkScene.OnClickMain(-1);
            }

            if (!endTalkScene)
            {
                yield return(talkScene.CommandWait(token).ToCoroutine(UnityEngine.Debug.LogException));
            }
        }
Exemplo n.º 13
0
 private SaveData.Heroine GetCurrentTalkSceneHeroine(TalkScene talkScene)
 {
     return(talkScene?.targetHeroine);
 }
Exemplo n.º 14
0
 private static void TouchFuncHook(TalkScene __instance, string _kind)
 {
     GetEffectController(__instance.targetHeroine).OnTalkSceneTouch(__instance.targetHeroine, _kind);
 }
Exemplo n.º 15
0
 public static void GetLeaveAloneVoice(TalkScene __instance) => DoSubtitle = true;
Exemplo n.º 16
0
 public static void TouchFunc(TalkScene __instance) => DoSubtitle = true;
Exemplo n.º 17
0
 public static void TouchFunc(TalkScene __instance) => WasTouched = true;
Exemplo n.º 18
0
 static void UpdateUIPrefix(TalkScene __instance)
 {
     _currentCrestType = __instance.targetHeroine.GetCurrentCrest();
     //Console.WriteLine($"UpdateUIPrefix crest={_currentCrestType}");
     _isHEvent = false;
 }