Beispiel #1
0
        // Method that is used to postfix world change events
        private static void WorldChangeEvent_setUp_Postfix(WorldChangeEvent __instance)
        {
            try
            {
                switch (__instance.whichEvent.Value)
                {
                // If the world change event in question is building the Joja greenhouse, add Joja greenhouse conversation topic
                case 0:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("joja_Greenhouse", Config.JojaGreenhouseDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add Joja greenhouse conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;

                // If the world change event is the abandoned JojaMart being struck by lightning, add JojaMart lightning conversation topic
                case 12:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("jojaMartStruckByLightning", Config.JojaLightningDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add abandonded JojaMart struck by lightning conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;

                // If the world change event is Willy's boat being repaired, add Willy boat repair conversation topic
                case 13:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("willyBoatRepaired", Config.WillyBoatRepairDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add Willy's boat repaired conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;

                // If the world change event in question is Leo arriving in the valley, add Leo arrival conversation topic
                case 14:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("leoValleyArrival", Config.LeoArrivalDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add Leo arrival to the valley conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to do world change event postfix with exception: {ex}", LogLevel.Error);
            }
        }
        // Method that is used to postfix
        private static void Farmer_doDivorce_Postfix(Farmer __instance, DivorceState __state)
        {
            switch (__state)
            {
            // If the prefix failed, don't do the postfix
            case DivorceState.UnAssigned:
                Monitor.Log($"Failed to log divorce state in prefix, skipping divorce conversation topic postfix", LogLevel.Error);
                break;

            // If the prefix logged that the player is not married, obviously they can't get divorced
            case DivorceState.UnMarriedNoDivorce:
                Monitor.Log($"Player tried to get divorced when they were not married", LogLevel.Warn);
                break;

            // If the prefix logged that the player is married to another player, add divorce conversation topics to both players
            case DivorceState.MultiplayerDivorce:

                // Add divorce conversation topic to current player's player spouse
                try
                {
                    // Get spouse
                    long?  spouseID = __instance.team.GetSpouse(__instance.UniqueMultiplayerID);
                    Farmer spouse   = Game1.getFarmerMaybeOffline(spouseID.Value);

                    // Check if spouse is offline or nonexistent, otherwise add divorce conversation topic to spouse
                    if (spouse is null)
                    {
                        Monitor.Log($"Player was married to multiplayer spouse in prefix but multiplayer spouse not found in postfix", LogLevel.Error);
                    }
                    else
                    {
                        MCTHelperFunctions.AddOrExtendCT(spouse, "divorce", Config.DivorceDuration);
                        if (!Game1.getOnlineFarmers().Contains(spouse))
                        {
                            Monitor.Log($"Added divorce conversation topic to offline multiplayer spouse, unknown behavior may result", LogLevel.Warn);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Monitor.Log($"Failed to add player's spouse divorce conversation topic with exception: {ex}", LogLevel.Error);
                }

                // Add divorce conversation topic to current player
                goto case DivorceState.NPCDivorce;

            // If the prefix logged that the player is married to an NPC, only add divorce conversation topic to player
            case DivorceState.NPCDivorce:
                try
                {
                    MCTHelperFunctions.AddOrExtendCT(__instance, "divorce", Config.DivorceDuration);
                }
                catch (Exception ex)
                {
                    Monitor.Log($"Failed to add player's divorce conversation topic with exception: {ex}", LogLevel.Error);
                }
                break;
            }
        }
 // Method that is used to postfix
 private static void Utility_getWeddingEvent_Postfix(Farmer farmer)
 {
     try
     {
         MCTHelperFunctions.AddOrExtendCT(farmer, "wedding", Config.WeddingDuration);
     }
     catch (Exception ex)
     {
         Monitor.Log($"Failed to add wedding conversation topic with exception: {ex}", LogLevel.Error);
     }
 }
        // Method that is used to postfix FairyEvent
        private static void FairyEvent_setUp_Postfix(bool __result)
        {
            // If the event did not trigger, then no need to do anything
            if (__result)
            {
                return;
            }

            // Add the fairy event conversation topic
            try
            {
                MCTHelperFunctions.AddOrExtendCT("fairyFarmVisit", Config.FairyVisitDuration);
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to add fairy visit conversation topic with exception: {ex}", LogLevel.Error);
            }
        }
 // Method that is used to postfix
 private static void BirthingEvent_setUp_Postfix(bool ___isMale)
 {
     // If a player married to an NPC has a child, add conversation topics depending on gender
     try
     {
         if (___isMale)
         {
             MCTHelperFunctions.AddOrExtendCT("babyBoy", Config.BirthDuration);
         }
         else
         {
             MCTHelperFunctions.AddOrExtendCT("babyGirl", Config.BirthDuration);
         }
     }
     catch (Exception ex)
     {
         Monitor.Log($"Failed to add birth conversation topic with exception: {ex}", LogLevel.Error);
     }
 }
        private static void PlayerCoupleBirthingEvent_setUp_Postfix(bool __result, Farmer ___spouse, bool ___isMale)
        {
            // If two players are married and have a child, add the conversation topic for having a new baby to both players
            try
            {
                if (!__result)
                {
                    if (___isMale)
                    {
                        MCTHelperFunctions.AddOrExtendCT("babyBoy", Config.BirthDuration);
                    }
                    else
                    {
                        MCTHelperFunctions.AddOrExtendCT("babyGirl", Config.BirthDuration);
                    }
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to add player's childbirth conversation topic with exception: {ex}", LogLevel.Error);
            }

            try
            {
                if (!__result)
                {
                    if (___isMale)
                    {
                        MCTHelperFunctions.AddOrExtendCT(___spouse, "babyBoy", Config.BirthDuration);
                    }
                    else
                    {
                        MCTHelperFunctions.AddOrExtendCT(___spouse, "babyGirl", Config.BirthDuration);
                    }
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to add spouse's childbirth conversation topic with exception: {ex}", LogLevel.Error);
            }
        }
Beispiel #7
0
 // Method that is used to postfix
 private static void Event_governorTaste_Postfix(Event __instance)
 {
     try
     {
         string governorReactionString = __instance.eventCommands[__instance.CurrentCommand + 1];
         if (governorReactionString.EndsWith("6"))
         {
             MCTHelperFunctions.AddOrExtendCT("luauShorts", Config.LuauDuration);
         }
         else if (governorReactionString.EndsWith("4"))
         {
             MCTHelperFunctions.AddOrExtendCT("luauBest", Config.LuauDuration);
         }
         else if (governorReactionString.EndsWith("0"))
         {
             MCTHelperFunctions.AddOrExtendCT("luauPoisoned", Config.LuauDuration);
         }
     }
     catch (Exception ex)
     {
         Monitor.Log($"Failed to add luau conversation topic with exception: {ex}", LogLevel.Error);
     }
 }
        // Method that is used to postfix WitchEvent
        private static void WitchEvent_setUp_Postfix(WitchEvent __instance, bool __result, Building ___targetBuilding)
        {
            // If the event did not trigger, then no need to do anything
            if (__result)
            {
                return;
            }

            // Add the right witch event conversation topics depending on the witch visit
            try
            {
                // If the witch is visiting a coop, add one of the witch coop conversation topics
                if (___targetBuilding is Coop)
                {
                    // If the witch is a golden witch (post-perfection coop visit), add the golden witch conversation topic
                    if (__instance.goldenWitch)
                    {
                        MCTHelperFunctions.AddOrExtendCT("goldenWitchCoopVisit", Config.WitchVisitDuration);
                    }
                    // Otherwise add the normal witch coop visit conversation topic
                    else
                    {
                        MCTHelperFunctions.AddOrExtendCT("witchCoopVisit", Config.WitchVisitDuration);
                    }
                }
                // Otherwise, if the witch is visiting a Slime Hutch, add the witch slime hut conversation topic
                else if (___targetBuilding.buildingType.Equals("Slime Hutch"))
                {
                    MCTHelperFunctions.AddOrExtendCT("witchSlimeHutVisit", Config.WitchVisitDuration);
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to add witch visit conversation topic with exception: {ex}", LogLevel.Error);
            }
        }
        private static void ParrotUpgradePerch_PerformCompleteAnimation_Postfix(NetString ___upgradeName)
        {
            // Check if the upgrade name is null and then whether it's the right upgrade, and don't do anything if it's not
            if (___upgradeName.Value is not "Resort")
            {
                return;
            }

            // Make sure to add resort built conversation topic to all farmers in the game
            try
            {
                foreach (Farmer f in Game1.getAllFarmers())
                {
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT(f, "islandResortUnlocked", Config.IslandResortDuration);
                    }
                    catch (Exception ex)
                    {// Check to see if the farmer in question is online, and return different exception messages depending
                        if (!Game1.getOnlineFarmers().Contains(f))
                        {
                            Monitor.Log($"Failed to add resort built conversation topic to an offline farmer with exception: {ex}", LogLevel.Error);
                        }
                        else
                        {
                            Monitor.Log($"Failed to add resort built conversation topic to an online farmer with exception: {ex}", LogLevel.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to add resort built conversation topic with exception: {ex}", LogLevel.Error);
                return;
            }
        }
        // Method that is used to postfix SoundInTheNightEvent
        private static void SoundInTheNightEvent_setUp_Postfix(bool __result, NetInt ___behavior)
        {
            // If the event didn't actually happen, no need to do anything
            if (__result)
            {
                return;
            }

            // Decide what to do based on the type of sound in the night event
            try
            {
                switch (___behavior.Value)
                {
                // If the sound in the night event is the UFO landing, add UFO landing conversation topic
                case 0:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("UFOLandedOnFarm", Config.UFOLandedDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add UFO landed on farm conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;

                // If the sound in the night event in question is a meteorite landing on the farm, add meteorite conversation topic
                case 1:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("meteoriteLandedOnFarm", Config.MeteoriteLandedDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add meteorite landed on farm conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;

                // If the sound in the night event in question is an owl statue landing on the farm, add owl statue conversation topic
                case 3:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("owlStatueLandedOnFarm", Config.OwlStatueDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add owl statue landed on farm conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;

                // If the sound in the night event in question is the railroad earthquake, add the railroad earthquake conversation topic
                case 4:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("railroadEarthquake", Config.MeteoriteLandedDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add railroad earthquake conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to do sound in the night event postfix with exception: {ex}", LogLevel.Error);
            }
        }