Example #1
0
        public static void DialogueBox_Prefix(ref List <string> dialogues)
        {
            try
            {
                if (dialogues == null || dialogues.Count < 2)
                {
                    return;
                }

                if (dialogues[1] == Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1826"))
                {
                    List <string> newDialogues = new List <string>()
                    {
                        dialogues[0]
                    };



                    List <NPC> spouses = Misc.GetSpouses(Game1.player, 1).Values.OrderBy(o => Game1.player.friendshipData[o.Name].Points).Reverse().Take(4).ToList();

                    List <int> which = new List <int> {
                        0, 1, 2, 3
                    };

                    Misc.ShuffleList(ref which);

                    List <int> myWhich = new List <int>(which).Take(spouses.Count).ToList();

                    for (int i = 0; i < spouses.Count; i++)
                    {
                        switch (which[i])
                        {
                        case 0:
                            newDialogues.Add(Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1827", spouses[i].displayName));
                            break;

                        case 1:
                            newDialogues.Add(((spouses[i].Gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1832") : Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1834")) + " " + ((spouses[i].Gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1837", spouses[i].displayName[0]) : Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1838", spouses[i].displayName[0])));
                            break;

                        case 2:
                            newDialogues.Add(Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1843", spouses[i].displayName));
                            break;

                        case 3:
                            newDialogues.Add(((spouses[i].Gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1831") : Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1833")) + " " + ((spouses[i].Gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1837", spouses[i].displayName[0]) : Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1838", spouses[i].displayName[i])));
                            break;
                        }
                    }
                    dialogues = new List <string>(newDialogues);
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed in {nameof(DialogueBox_Prefix)}:\n{ex}", LogLevel.Error);
            }
        }
Example #2
0
        public static bool Utility_pickPersonalFarmEvent_Prefix(ref FarmEvent __result)
        {
            lastBirthingSpouse = null;
            lastPregnantSpouse = null;
            ModEntry.PMonitor.Log("picking event");
            if (Game1.weddingToday)
            {
                __result = null;
                return(false);
            }

            List <NPC> allSpouses = Misc.GetSpouses(Game1.player, 1).Values.ToList();

            Misc.ShuffleList(ref allSpouses);

            foreach (NPC spouse in allSpouses)
            {
                if (spouse == null)
                {
                    Monitor.Log($"Utility_pickPersonalFarmEvent_Prefix spouse is null");
                    continue;
                }
                Farmer f = spouse.getSpouse();

                Friendship friendship = f.friendshipData[spouse.Name];

                if (friendship.DaysUntilBirthing <= 0 && friendship.NextBirthingDate != null)
                {
                    lastBirthingSpouse = spouse;
                    __result           = new BirthingEvent();
                    return(false);
                }
            }
            foreach (NPC spouse in allSpouses)
            {
                Farmer f = spouse.getSpouse();
                if (!ModEntry.config.RoommateRomance && f.friendshipData[spouse.Name].RoommateMarriage)
                {
                    continue;
                }

                int          heartsWithSpouse = f.getFriendshipHeartLevelForNPC(spouse.Name);
                Friendship   friendship       = f.friendshipData[spouse.Name];
                List <Child> kids             = f.getChildren();
                bool         can = spouse.daysAfterLastBirth <= 0 && Utility.getHomeOfFarmer(f).upgradeLevel >= 2 && friendship.DaysUntilBirthing < 0 && heartsWithSpouse >= 10 && friendship.DaysMarried >= 7 && (ModEntry.config.MaxChildren < 0 || kids.Count == 0 || (kids.Count < ModEntry.config.MaxChildren));
                ModEntry.PMonitor.Log($"Checking ability to get pregnant: {spouse.Name} {can}:{(Utility.getHomeOfFarmer(f).upgradeLevel < 2 ? $" house level too low {Utility.getHomeOfFarmer(f).upgradeLevel}":"")}{(friendship.DaysMarried < 7 ? $" not married long enough {friendship.DaysMarried}":"")}{(friendship.DaysUntilBirthing >= 0 ? "Already pregnant! Gives birth in: "+friendship.DaysUntilBirthing:"")}");
                if (can && Game1.player.currentLocation == Game1.getLocationFromName(Game1.player.homeLocation) && ModEntry.myRand.NextDouble() < ModEntry.config.BabyRequestChance)
                {
                    ModEntry.PMonitor.Log("Making a baby!");
                    lastPregnantSpouse = spouse;
                    __result           = new QuestionEvent(1);
                    return(false);
                }
            }
            return(true);
        }
Example #3
0
        public static void Event_setUpCharacters_Postfix(Event __instance, GameLocation location)
        {
            try
            {
                if (!__instance.isWedding || !ModEntry.config.AllSpousesJoinWeddings)
                {
                    return;
                }

                List <string> spouses = Misc.GetSpouses(Game1.player, 0).Keys.ToList();
                Misc.ShuffleList(ref spouses);
                foreach (NPC actor in __instance.actors)
                {
                    if (spouses.Contains(actor.Name))
                    {
                        int     idx = spouses.IndexOf(actor.Name);
                        Vector2 pos;
                        if (idx < weddingPositions.Count)
                        {
                            pos = new Vector2(weddingPositions[idx][0] * Game1.tileSize, weddingPositions[idx][1] * Game1.tileSize);
                        }
                        else
                        {
                            int x = 25 + ((idx - 4) % 6);
                            int y = 62 - ((idx - 4) / 6);
                            pos = new Vector2(x * Game1.tileSize, y * Game1.tileSize);
                        }
                        actor.position.Value = pos;
                        if (ModEntry.config.AllSpousesWearMarriageClothesAtWeddings)
                        {
                            bool flipped = false;
                            int  frame   = 37;
                            if (pos.Y < 62 * Game1.tileSize)
                            {
                                if (pos.X == 25 * Game1.tileSize)
                                {
                                    flipped = true;
                                }
                                else if (pos.X < 30 * Game1.tileSize)
                                {
                                    frame = 36;
                                }
                            }
                            else if (pos.X < 28 * Game1.tileSize)
                            {
                                flipped = true;
                            }

                            actor.Sprite.setCurrentAnimation(new List <FarmerSprite.AnimationFrame>
                            {
                                new FarmerSprite.AnimationFrame(frame, 0, false, flipped, null, true)
                            });
                        }
                        else
                        {
                            Utility.facePlayerEndBehavior(actor, location);
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                Monitor.Log($"Failed in {nameof(Event_answerDialogueQuestion_Prefix)}:\n{ex}", LogLevel.Error);
            }
        }
Example #4
0
        public static void TrySpousesKiss()
        {
            GameLocation location = Game1.currentLocation;

            if (location == null || !ReferenceEquals(location.GetType(), typeof(FarmHouse)))
            {
                return;
            }

            Farmer owner = (location as FarmHouse).owner;

            lastKissTime++;

            if (location == null || location.characters == null)
            {
                return;
            }

            List <NPC> list = location.characters.ToList();

            Misc.ShuffleList(ref list);

            foreach (NPC npc1 in list)
            {
                if (!owner.friendshipData.ContainsKey(npc1.Name))
                {
                    continue;
                }

                if (!ModEntry.config.RoommateRomance && owner.friendshipData[npc1.Name].RoommateMarriage)
                {
                    continue;
                }


                foreach (NPC npc2 in list)
                {
                    if (!owner.friendshipData.ContainsKey(npc2.Name))
                    {
                        continue;
                    }

                    if (npc1.Name == npc2.Name || (!ModEntry.config.RoommateRomance && owner.friendshipData[npc2.Name].RoommateMarriage))
                    {
                        continue;
                    }

                    if (lastKissTime >= ModEntry.config.MinSpouseKissInterval)
                    {
                        kissingSpouses.Clear();
                    }


                    float distance = Vector2.Distance(npc1.position, npc2.position);
                    if (
                        npc1.getSpouse() != null && npc2.getSpouse() != null &&
                        npc1.getSpouse().Name == npc2.getSpouse().Name &&
                        distance < ModEntry.config.MaxDistanceToKiss &&
                        !kissingSpouses.Contains(npc1.Name) &&
                        !kissingSpouses.Contains(npc2.Name) &&
                        owner.getFriendshipHeartLevelForNPC(npc1.Name) >= ModEntry.config.MinHeartsForKiss &&
                        owner.getFriendshipHeartLevelForNPC(npc2.Name) >= ModEntry.config.MinHeartsForKiss &&
                        lastKissTime > ModEntry.config.MinSpouseKissInterval &&
                        ModEntry.myRand.NextDouble() < ModEntry.config.SpouseKissChance &&
                        (!ModEntry.config.PreventRelativesFromKissing || !Misc.AreSpousesRelated(npc1.Name, npc2.Name))
                        )
                    {
                        kissingSpouses.Add(npc1.Name);
                        kissingSpouses.Add(npc2.Name);
                        ModEntry.PMonitor.Log("spouses kissing");
                        lastKissTime = 0;
                        Vector2 npc1pos  = npc1.position;
                        Vector2 npc2pos  = npc2.position;
                        int     npc1face = npc1.facingDirection;
                        int     npc2face = npc1.facingDirection;
                        Vector2 midpoint = new Vector2((npc1.position.X + npc2.position.X) / 2, (npc1.position.Y + npc2.position.Y) / 2);
                        PerformKiss(npc1, midpoint, npc2.Name);
                        PerformKiss(npc2, midpoint, npc1.Name);
                        DelayedAction action = new DelayedAction(1000);
                        var           t      = Task.Run(async delegate
                        {
                            await Task.Delay(TimeSpan.FromSeconds(1));
                            npc1.position.Value  = npc1pos;
                            npc2.position.Value  = npc2pos;
                            npc1.FacingDirection = npc1face;
                            npc2.FacingDirection = npc2face;
                            return;
                        });
                    }
                }
            }
        }