Beispiel #1
0
        public void AiGeneratePatrols()
        {
            PatrolProperties properties;

            foreach (Settlement settlement in Settlement.All)
            {
                if (settlement.IsVillage && settlement.OwnerClan != Clan.PlayerClan)
                {
                    if (settlementPatrolProperties.ContainsKey(settlement.StringId))
                    {
                        settlementPatrolProperties.TryGetValue(settlement.StringId, out properties);
                        if (properties != null && properties.patrols.Count < Settings.Instance.AiMaxPatrolPerSettlement && settlement.OwnerClan.Gold > (BaseCost + properties.getPatrolCost()) * 3)
                        {
                            if (rand.Next(0, 100) < Settings.Instance.AiGenerationChance)
                            {
                                MobileParty party;
                                if (rand.Next(0, 100) < 60)
                                {
                                    GiveGoldAction.ApplyForCharacterToSettlement(settlement.OwnerClan.Leader, settlement, (BaseCost + properties.getPatrolCost()) * 3, true);
                                    party = spawnPatrol(settlement, TroopsPerPatrol * 3);
                                }
                                else if (rand.Next(0, 100) < 85)
                                {
                                    GiveGoldAction.ApplyForCharacterToSettlement(settlement.OwnerClan.Leader, settlement, (BaseCost + properties.getPatrolCost()) * 2, true);
                                    party = spawnPatrol(settlement, TroopsPerPatrol * 2);
                                }
                                else
                                {
                                    GiveGoldAction.ApplyForCharacterToSettlement(settlement.OwnerClan.Leader, settlement, BaseCost + properties.getPatrolCost(), true);
                                    party = spawnPatrol(settlement, TroopsPerPatrol);
                                }
                                properties.patrols.Add(party);
                                settlementPatrolProperties[settlement.StringId] = properties;
                                allPatrols.Add(party);
                                //InformationManager.DisplayMessage(new InformationMessage(new TextObject(settlement.OwnerClan.Leader.ToString() + " has hired a patrol at " + settlement.ToString()).ToString()));
                            }
                        }
                    }
                }
            }
        }
        private void RepayLoanAtSettlement(Settlement settlement)
        {
            var remainingUnpaidLoanAmount = GetRemainingUnpaidLoanAtSettlement(settlement);

            if (remainingUnpaidLoanAmount > GetPlayerMoneyOnPerson())
            {
                InformationManager.DisplayMessage(new InformationMessage("You do not have enough money to repay this loan."));
                return;
            }
            var bankData = GetBankDataAtSettlement(settlement);

            GiveGoldAction.ApplyForCharacterToSettlement(Hero.MainHero, settlement, remainingUnpaidLoanAmount, true);
            InformationManager.DisplayMessage(new InformationMessage($"You repaid the loan of {remainingUnpaidLoanAmount}<img src=\"Icons\\Coin@2x\"> from {settlement.Name}.", "event:/ui/notification/coins_negative"));
            if (bankData.LoanQuest?.IsOngoing == true)
            {
                bankData.LoanQuest.OnLoanRepaidOnTime();
            }
            bankData.LoanQuest = null;
            bankData.LastLoanRecurringRetaliationDate = CampaignTime.Never;
            bankData.OriginalLoanAmount  = 0;
            bankData.RemainingUnpaidLoan = 0;
            bankData.HasBankPerformedInitialRetaliationForUnpaidLoan = false;
            GameMenu.SwitchToMenu("bank_account");
        }
        public static void BuyPlot(VillageData villageData)
        {
            EntrepreneurCampaignBehaviour entrepreneur = Campaign.Current.GetCampaignBehavior <EntrepreneurCampaignBehaviour>();

            Dictionary <string, int> itemRequirements = new Dictionary <string, int>();

            itemRequirements.Add("tools", 5);
            itemRequirements.Add("hardwood", 5);

            Dictionary <string, int> missingRequirements = new Dictionary <string, int>();

            missingRequirements.Add("tools", 5);
            missingRequirements.Add("hardwood", 5);

            Dictionary <ItemRosterElement, int> itemsToRemove = new Dictionary <ItemRosterElement, int>();

            foreach (KeyValuePair <string, int> requirement in itemRequirements)
            {
                IEnumerable <ItemRosterElement> items = Hero.MainHero.PartyBelongedTo.ItemRoster.AsQueryable().Where(item => item.Amount >= requirement.Value && item.EquipmentElement.Item.StringId.Equals(requirement.Key));
                if (items.Count() != 0)
                {
                    int currentAmount = items.First().Amount;
                    itemsToRemove.Add(items.First(), currentAmount - requirement.Value);
                    missingRequirements.Remove(requirement.Key);
                }
            }
            if (missingRequirements.Count == 0)
            {
                int buyPrice = villageData.AcreSellPrice;
                if (villageData.AvailableAcres > 0)
                {
                    if (Hero.MainHero.Gold >= buyPrice)
                    {
                        villageData.buyAcre();
                        foreach (var item in itemsToRemove)
                        {
                            // Remove whole stack.
                            Hero.MainHero.PartyBelongedTo.ItemRoster.Remove(item.Key);

                            // Add the difference.
                            Hero.MainHero.PartyBelongedTo.ItemRoster.AddToCounts(item.Key.EquipmentElement.Item, item.Value);
                        }
                        GiveGoldAction.ApplyForCharacterToSettlement(Hero.MainHero, Settlement.CurrentSettlement, buyPrice);
                    }
                    else
                    {
                        InformationManager.DisplayMessage(new InformationMessage("You dont have enouph gold to buy this plot."));
                    }
                }
                else
                {
                    InformationManager.DisplayMessage(new InformationMessage("There are no plots acres to buy."));
                }
            }
            else
            {
                foreach (KeyValuePair <string, int> requirement in missingRequirements)
                {
                    InformationManager.DisplayMessage(new InformationMessage(($"You are missing {requirement.Value} items of {requirement.Key}.")));
                }
            }
        }
        public static void Add(int goldPrice, float villagersToAdd, Hero hero,
                               TaleWorlds.CampaignSystem.Village village)
        {
            if (goldPrice > Hero.MainHero.Gold)
            {
                if (hero == Hero.MainHero)
                {
                    Logger.DisplayInfoMsg(Main.Localization.GetTranslation(Localization.SettlersActionLackOfGold));
                }
                Logger.logDebug("Not enough gold - " + hero.Name);
                return;
            }

            if (hero == Hero.MainHero && Main.Settings.MaxCallsForSettlersPerDayForVillageEnabled)
            {
                if (SettlersCampaignBehavior.Instance._settlersForVillagesData.ContainsKey(Settlement.CurrentSettlement
                                                                                           .StringId))
                {
                    if (SettlersCampaignBehavior.Instance
                        ._settlersForVillagesData[Settlement.CurrentSettlement.StringId].SettlementToday >=
                        Main.Settings.MaxCallsForSettlersPerDayForVillage)
                    {
                        Logger.DisplayInfoMsg(
                            Main.Localization.GetTranslation(Localization.SettlersActionTooManyCalls));

                        return;
                    }
                }
            }

            if (
                village.MarketTown != null &&
                villagersToAdd >= village.MarketTown.Prosperity
                )
            {
                if (hero == Hero.MainHero)
                {
                    Logger.DisplayInfoMsg(Main.Localization.GetTranslation(Localization.SettlersActionLackOfSettlers));
                }
                return;
            }

            GiveGoldAction.ApplyForCharacterToSettlement(hero, village.Settlement, goldPrice);
            village.Hearth += villagersToAdd;

            if (hero == Hero.MainHero && Main.Settings.MaxCallsForSettlersPerDayForVillageEnabled)
            {
                if (SettlersCampaignBehavior.Instance._settlersForVillagesData.ContainsKey(Settlement.CurrentSettlement
                                                                                           .StringId))
                {
                    SettlersCampaignBehavior.Instance._settlersForVillagesData[Settlement.CurrentSettlement.StringId]
                    .SettlementToday++;
                }
                else
                {
                    SettlersCampaignBehavior.Instance._settlersForVillagesData.Add(
                        Settlement.CurrentSettlement.StringId,
                        new VillageDetailsModel(Settlement.CurrentSettlement.StringId, -1));
                    SettlersCampaignBehavior.Instance._settlersForVillagesData[Settlement.CurrentSettlement.StringId]
                    .SettlementToday++;
                }
            }

            if (!Main.Settings.ProsperityAffection || village.MarketTown == null)
            {
                return;
            }
            village.MarketTown.Settlement.Prosperity -= villagersToAdd / 2;
            Logger.logDebug("Changed prosperity in " +
                            village.MarketTown.Name + " by " +
                            villagersToAdd / 2);
        }
 private void game_menu_steal_encounter_persuade_on_consequence(MenuCallbackArgs args)
 {
     GiveGoldAction.ApplyForCharacterToSettlement(Hero.MainHero, Settlement.CurrentSettlement, KleptomaniaSubModule.settings.EncounterBribeCost);
     OnStealAttempt(Settlement.CurrentSettlement, isDetected, prosperityGoodsAmmount, stealQuantity);
 }
Beispiel #6
0
        public void AddRecruiterMenu(CampaignGameStarter obj)
        {
            GameMenuOption.OnConditionDelegate hireRecruiterDelegate = delegate(MenuCallbackArgs args)
            {
                args.optionLeaveType = GameMenuOption.LeaveType.Recruit;
                return(Settlement.CurrentSettlement.OwnerClan == Clan.PlayerClan);
            };
            GameMenuOption.OnConsequenceDelegate hireRecruiterConsequenceDelegate = delegate(MenuCallbackArgs args)
            {
                GameMenu.SwitchToMenu("recruiter_culture_menu");
            };

            obj.AddGameMenu("recruiter_culture_menu", "The Chamberlain asks you what culture your recruits should be.", null, GameOverlays.MenuOverlayType.None, GameMenu.MenuFlags.none, null);

            RecruiterProperties props = new RecruiterProperties();

            foreach (CultureObject culture in getPossibleCultures())
            {
                obj.AddGameMenuOption("recruiter_culture_menu", "recruiter_" + culture.GetName().ToString(), culture.GetName().ToString(),
                                      delegate(MenuCallbackArgs args)
                {
                    return(Settlement.All.Count(settlement => settlement.Culture == culture &&
                                                settlement.OwnerClan != null &&
                                                !((settlement.OwnerClan.Kingdom != null && settlement.OwnerClan.Kingdom.IsAtWarWith(Hero.MainHero.Clan)) ||
                                                  settlement.OwnerClan.IsAtWarWith(Hero.MainHero.Clan) ||
                                                  (settlement.OwnerClan.Kingdom != null && Hero.MainHero.Clan.Kingdom != null && settlement.OwnerClan.Kingdom.IsAtWarWith(Hero.MainHero.Clan.Kingdom))
                                                  )
                                                ) > 0);
                },
                                      delegate(MenuCallbackArgs args)
                {
                    props = new RecruiterProperties();
                    props.SearchCulture = culture;
                    GameMenu.SwitchToMenu("recruiter_pay_menu");
                });
            }

            obj.AddGameMenuOption("town_keep", "recruiter_buy_recruiter", "Hire a Recruiter", hireRecruiterDelegate, hireRecruiterConsequenceDelegate, false, 4, false);
            obj.AddGameMenuOption("castle", "recruiter_buy_recruiter", "Hire a Recruiter", hireRecruiterDelegate, hireRecruiterConsequenceDelegate, false, 4, false);

            obj.AddGameMenu("recruiter_pay_menu", "The Chamberlain asks you for how many denars he should buy recruits.", null, GameOverlays.MenuOverlayType.None, GameMenu.MenuFlags.none, null);

            obj.AddGameMenuOption("recruiter_pay_menu", "recruiter_pay_small", "Pay 500.", delegate(MenuCallbackArgs args)
            {
                args.optionLeaveType = GameMenuOption.LeaveType.Recruit;
                string stringId      = Settlement.CurrentSettlement.StringId;
                int cost             = 500;
                bool flag            = cost >= Hero.MainHero.Gold;
                return(!flag);
            }, delegate(MenuCallbackArgs args)
            {
                string stringId = Settlement.CurrentSettlement.StringId;
                int cost        = 500;
                bool flag       = cost <= Hero.MainHero.Gold;
                if (flag)
                {
                    GiveGoldAction.ApplyForCharacterToSettlement(Hero.MainHero, Settlement.CurrentSettlement, cost, false);
                    MobileParty item = this.spawnRecruiter(Settlement.CurrentSettlement, cost, props);
                }
                GameMenu.SwitchToMenu("castle");
            }, false, -1, false);
            obj.AddGameMenuOption("recruiter_pay_menu", "recruiter_pay_medium", "Pay 1500.", delegate(MenuCallbackArgs args)
            {
                args.optionLeaveType = GameMenuOption.LeaveType.Recruit;
                string stringId      = Settlement.CurrentSettlement.StringId;
                int cost             = 1500;
                bool flag            = cost >= Hero.MainHero.Gold;
                return(!flag);
            }, delegate(MenuCallbackArgs args)
            {
                string stringId = Settlement.CurrentSettlement.StringId;
                int cost        = 1500;
                bool flag       = cost <= Hero.MainHero.Gold;
                if (flag)
                {
                    GiveGoldAction.ApplyForCharacterToSettlement(Hero.MainHero, Settlement.CurrentSettlement, cost, false);
                    MobileParty item = this.spawnRecruiter(Settlement.CurrentSettlement, cost, props);
                }
                GameMenu.SwitchToMenu("castle");
            }, false, -1, false);
            obj.AddGameMenuOption("recruiter_pay_menu", "recruiter_pay_large", "Pay 3000.", delegate(MenuCallbackArgs args)
            {
                args.optionLeaveType = GameMenuOption.LeaveType.Recruit;
                string stringId      = Settlement.CurrentSettlement.StringId;
                int cost             = 3000;
                bool flag            = cost >= Hero.MainHero.Gold;
                return(!flag);
            }, delegate(MenuCallbackArgs args)
            {
                string stringId = Settlement.CurrentSettlement.StringId;
                int cost        = 3000;
                bool flag       = cost <= Hero.MainHero.Gold;
                if (flag)
                {
                    GiveGoldAction.ApplyForCharacterToSettlement(Hero.MainHero, Settlement.CurrentSettlement, cost, false);
                    MobileParty item = this.spawnRecruiter(Settlement.CurrentSettlement, cost, props);
                }
                GameMenu.SwitchToMenu("castle");
            }, false, -1, false);
            obj.AddGameMenuOption("recruiter_pay_menu", "recruiter_leave", "Leave", new GameMenuOption.OnConditionDelegate(this.game_menu_just_add_leave_conditional), new GameMenuOption.OnConsequenceDelegate(this.game_menu_switch_to_village_menu), false, -1, false);
        }
        public void AddTroopMenu(CampaignGameStarter obj)
        {
            obj.AddGameMenuOption("town", "info_troop_type", "Hire Basilisk Guild Troops", game_menu_just_add_recruit_conditional, (MenuCallbackArgs args) => { GameMenu.SwitchToMenu("town_mod_pay"); }, false, 5);

            obj.AddGameMenu("town_mod_pay", "The Basilisk Guild offers its powerful mercenaries, both commoners and nobles, in every town for quite the coin. " +
                            "The guild manager tells you that their mercenaries favor more wealthy places." +
                            " She also tells you that there is a weekly upfront fee of {COST} denars here just to view available mercenaries. The available mercenaries will update weekly." +
                            "She then tells you that they also offer immediate contingents for the extreme wealthy. The larger contingents are of higher quality.",
                            (MenuCallbackArgs args) =>
            {
                TroopProperties troopProps;
                troopDic.TryGetValue(Settlement.CurrentSettlement.StringId, out troopProps);
                MBTextManager.SetTextVariable("COST", troopProps.getCost, false);
                if (Clan.PlayerClan.Tier == 0)
                {
                    MBTextManager.SetTextVariable("RENOWN_STATUS", "No one here has heard of you before", false);
                }
            });

            obj.AddGameMenu("town_mod_troop_type", "The guild manager goes to the back and after a while comes back to the front with two lists of available mercenaries. " +
                            "{RENOWN_STATUS} " +
                            "The ones you paid for will wait by the gates.",
                            (MenuCallbackArgs args) =>
            {
                if (Clan.PlayerClan.Tier == 0)
                {
                    MBTextManager.SetTextVariable("RENOWN_STATUS", "She tells you that no one here has heard of you so not many are willing to join.", false);
                }
                else if (Clan.PlayerClan.Tier == 1)
                {
                    MBTextManager.SetTextVariable("RENOWN_STATUS", "She tells you that she cannot remember you or your face but some of their trainees were talking about you.", false);
                }
                else if (Clan.PlayerClan.Tier == 2)
                {
                    MBTextManager.SetTextVariable("RENOWN_STATUS", "She thanks you for waiting and tells you that some of their trainees were waiting for you to come again.", false);
                }
                else if (Clan.PlayerClan.Tier == 3)
                {
                    MBTextManager.SetTextVariable("RENOWN_STATUS", "She thanks you for waiting and tells you that some of their experienced members were discussing your exploits from time to time.", false);
                }
                else if (Clan.PlayerClan.Tier == 4)
                {
                    MBTextManager.SetTextVariable("RENOWN_STATUS", "She thanks you for your patronage and tells you that noblemen are declining other requests to join you instead.", false);
                }
                else if (Clan.PlayerClan.Tier == 5)
                {
                    MBTextManager.SetTextVariable("RENOWN_STATUS", "She bows and thanks you for your continued patronage. She tells you that there is now a waiting list to get on the list to join your party.", false);
                }
                else
                {
                    MBTextManager.SetTextVariable("RENOWN_STATUS", "She bows and thanks you for your continued patronage. The whole guild is entirely maintained with your money at this point.", false);
                }
            });

            obj.AddGameMenuOption("town_mod_pay", "pay_fee", "Pay {DAILY_COST} denars to see weekly troops",
                                  (MenuCallbackArgs args) =>
            {
                TroopProperties troopProps;
                troopDic.TryGetValue(Settlement.CurrentSettlement.StringId, out troopProps);
                MBTextManager.SetTextVariable("DAILY_COST", troopProps.getCost, false);
                args.optionLeaveType = GameMenuOption.LeaveType.Trade;
                if (troopProps.getCost >= Hero.MainHero.Gold || troopProps.paid)
                {
                    return(false);
                }
                return(true);
            },
                                  (MenuCallbackArgs args) =>
            {
                TroopProperties troopProps;
                troopDic.TryGetValue(Settlement.CurrentSettlement.StringId, out troopProps);
                int cost = troopProps.getCost;
                if (cost <= Hero.MainHero.Gold)
                {
                    GiveGoldAction.ApplyForCharacterToSettlement(Hero.MainHero, Settlement.CurrentSettlement, cost);
                    troopProps.paid = true;
                    troopDic[Settlement.CurrentSettlement.StringId] = troopProps;
                }
                GameMenu.SwitchToMenu("town_mod_troop_type");
            });

            obj.AddGameMenuOption("town_mod_pay", "pay_fee_5", "Pay {COST_5} denars for 5 troops",
                                  (MenuCallbackArgs args) =>
            {
                int cost = (int)Math.Ceiling(3000 + Settlement.CurrentSettlement.Prosperity / 2 + Clan.PlayerClan.Tier * 1000);
                MBTextManager.SetTextVariable("COST_5", cost, false);
                args.optionLeaveType = GameMenuOption.LeaveType.Trade;
                if (cost >= Hero.MainHero.Gold)
                {
                    return(false);
                }
                return(true);
            },
                                  (MenuCallbackArgs args) =>
            {
                int cost = (int)Math.Ceiling(3000 + Settlement.CurrentSettlement.Prosperity / 2 + Clan.PlayerClan.Tier * 1000);
                if (cost <= Hero.MainHero.Gold)
                {
                    GiveGoldAction.ApplyForCharacterToSettlement(Hero.MainHero, Settlement.CurrentSettlement, cost);
                    giveTroops(5);
                }
            });

            obj.AddGameMenuOption("town_mod_pay", "pay_fee_15", "Pay {COST_15} denars for 15 troops",
                                  (MenuCallbackArgs args) =>
            {
                int cost = (int)Math.Ceiling(15000 + Settlement.CurrentSettlement.Prosperity / 2 + Clan.PlayerClan.Tier * 2000);
                MBTextManager.SetTextVariable("COST_15", cost, false);
                args.optionLeaveType = GameMenuOption.LeaveType.Trade;
                if (cost >= Hero.MainHero.Gold)
                {
                    return(false);
                }
                return(true);
            },
                                  (MenuCallbackArgs args) =>
            {
                int cost = (int)Math.Ceiling(15000 + Settlement.CurrentSettlement.Prosperity / 2 + Clan.PlayerClan.Tier * 2000);
                if (cost <= Hero.MainHero.Gold)
                {
                    GiveGoldAction.ApplyForCharacterToSettlement(Hero.MainHero, Settlement.CurrentSettlement, cost);
                    giveTroops(15);
                }
            });

            obj.AddGameMenuOption("town_mod_pay", "pay_fee_25", "Pay {COST_25} denars for 25 troops",
                                  (MenuCallbackArgs args) =>
            {
                int cost = (int)Math.Ceiling(30000 + Settlement.CurrentSettlement.Prosperity / 2 + Clan.PlayerClan.Tier * 3000);
                MBTextManager.SetTextVariable("COST_25", cost, false);
                args.optionLeaveType = GameMenuOption.LeaveType.Trade;
                if (cost >= Hero.MainHero.Gold)
                {
                    return(false);
                }
                return(true);
            },
                                  (MenuCallbackArgs args) =>
            {
                int cost = (int)Math.Ceiling(30000 + Settlement.CurrentSettlement.Prosperity / 2 + Clan.PlayerClan.Tier * 3000);
                if (cost <= Hero.MainHero.Gold)
                {
                    GiveGoldAction.ApplyForCharacterToSettlement(Hero.MainHero, Settlement.CurrentSettlement, cost);
                    giveTroops(25);
                }
                else
                {
                    GameMenu.SwitchToMenu("town");
                }
            });

            obj.AddGameMenuOption("town_mod_pay", "already_paid", "View troops",
                                  (MenuCallbackArgs args) =>
            {
                args.optionLeaveType = GameMenuOption.LeaveType.Recruit;
                TroopProperties troopProps;
                troopDic.TryGetValue(Settlement.CurrentSettlement.StringId, out troopProps);
                if (troopProps.paid)
                {
                    return(true);
                }
                return(false);
            },
                                  (MenuCallbackArgs args) =>
            {
                GameMenu.SwitchToMenu("town_mod_troop_type");
            });


            obj.AddGameMenuOption("town_mod_pay", "notpaying", "Leave", this.game_menu_just_add_leave_conditional, this.game_menu_switch_to_town_menu);

            obj.AddGameMenuOption("town_mod_troop_type", "militia_type", "Look at the Commoners list", this.game_menu_just_add_recruit_conditional, this.conversation_miltia_on_consequence);
            obj.AddGameMenuOption("town_mod_troop_type", "noble_type", "Look at the Nobles list", this.game_menu_just_add_recruit_conditional, this.conversation_noble_on_consequence);
            obj.AddGameMenuOption("town_mod_troop_type", "mod_leave", "Finished looking", this.game_menu_just_add_leave_conditional, this.game_menu_switch_to_town_menu);
        }