public void OnDetection(Settlement settlement)
        {
            try
            {
                int   stealRelationPenalty           = KleptomaniaSubModule.settings.StealRelationPenalty;
                float currentTownStealCrimeRating    = KleptomaniaSubModule.settings.TownStealCrimeRating;
                float currentVillageStealCrimeRating = KleptomaniaSubModule.settings.VillageStealCrimeRating;

                if (Hero.MainHero.MapFaction != null && settlement.MapFaction != null)
                {
                    if (Hero.MainHero.MapFaction == settlement.MapFaction)     //if from player faction: realtion penalty x2, decreases relation with players faction leader
                    {
                        stealRelationPenalty *= 2;
                        ChangeRelationAction.ApplyRelationChangeBetweenHeroes(Hero.MainHero, settlement.MapFaction.Leader, stealRelationPenalty, true);
                        KleptomaniaSubModule.Log.Info("Stealing | Faction Leader Hero " + settlement.MapFaction.Leader.Name + "decreases relation with player by " + stealRelationPenalty.ToString());
                    }
                }

                if (settlement.OwnerClan.Leader != null)
                {
                    ChangeRelationAction.ApplyRelationChangeBetweenHeroes(Hero.MainHero, settlement.OwnerClan.Leader, stealRelationPenalty, true);        //decreases relation with settlement owner
                    KleptomaniaSubModule.Log.Info("Stealing | Settlement owner Hero " + settlement.OwnerClan.Leader.Name + "decreases relation with player by " + stealRelationPenalty.ToString());
                }

                if (settlement.Notables != null)
                {
                    foreach (Hero notableHero in settlement.Notables)     //decreases relation with notables
                    {
                        if (notableHero != null && !notableHero.IsGangLeader)
                        {
                            ChangeRelationAction.ApplyRelationChangeBetweenHeroes(Hero.MainHero, notableHero, stealRelationPenalty, true);
                            KleptomaniaSubModule.Log.Info("Stealing | Notable Hero " + notableHero.Name + "decreases relation with player by " + stealRelationPenalty.ToString());
                        }
                    }
                }

                if (settlement.IsTown)
                {
                    ChangeCrimeRatingAction.Apply(settlement.MapFaction, currentTownStealCrimeRating, true);
                    KleptomaniaSubModule.Log.Info("Stealing | Faction " + settlement.MapFaction.Name + " crime rating increases with player by " + currentTownStealCrimeRating.ToString());
                }
                else if (settlement.IsVillage)
                {
                    ChangeCrimeRatingAction.Apply(settlement.MapFaction, currentVillageStealCrimeRating, true);
                    KleptomaniaSubModule.Log.Info("Stealing | Faction " + settlement.Name + " crime rating increases with player by " + currentVillageStealCrimeRating.ToString());
                }
            }
            catch (Exception ex)
            {
                InformationManager.DisplayMessage(new InformationMessage("Kleptomania: An error occured adding consequences for detection. Check the Log file.", Colors.Red));
                KleptomaniaSubModule.Log.Info("Stealing | Exception in DetectionConsequence: " + ex.Message);
            }
        }
        private static void ExiledDmgRelation()
        {
            Hero mainhero = Hero.MainHero;
            Hero lord     = Hero.FindAll((Hero tmp) => (tmp.Culture.StringId == mainhero.Culture.StringId) && tmp.IsAlive && tmp.IsFactionLeader && !tmp.MapFaction.IsMinorFaction).GetRandomElement <Hero>();

            CharacterRelationManager.SetHeroRelation(mainhero, lord, -50);
            foreach (Hero alllord in Hero.FindAll((alllord) => (alllord.MapFaction == lord.MapFaction) && alllord.IsAlive))
            {
                CharacterRelationManager.SetHeroRelation(mainhero, alllord, -5);
            }
            ;
            CharacterRelationManager.SetHeroRelation(mainhero, lord, -50);
            ChangeCrimeRatingAction.Apply(lord.MapFaction, 49, false);
            //float test = Campaign.Current.
        }
        private void ApplyRecurringBankRetaliationForUnpaidLoan(Settlement settlement)
        {
            var bankData = GetBankDataAtSettlement(settlement);

            bankData.LastLoanRecurringRetaliationDate = CampaignTime.Now;
            bankData.RemainingUnpaidLoan += (int)(bankData.RemainingUnpaidLoan * bankData.LoanLateFeeInterestRate);
            if (settlement.MapFaction.MainHeroCrimeRating < SubModule.Config.MaxCriminalRatingForUnpaidLoan)
            {
                var criminalRatingToApply =
                    settlement.MapFaction.MainHeroCrimeRating + SubModule.Config.RecurringCrimeRatingIncreaseForUnpaidLoan > SubModule.Config.MaxCriminalRatingForUnpaidLoan
                        ? SubModule.Config.MaxCriminalRatingForUnpaidLoan - settlement.MapFaction.MainHeroCrimeRating
                        : SubModule.Config.RecurringCrimeRatingIncreaseForUnpaidLoan;
                ChangeCrimeRatingAction.Apply(settlement.MapFaction, criminalRatingToApply);
                InformationManager.DisplayMessage(new InformationMessage($"Your criminal rating with the {settlement.MapFaction.Name} has increased by {criminalRatingToApply} due to an unpaid loan at {settlement.Name}.", Colors.Red));
            }
        }
        private void ArmSeperatists()
        {
            List <InquiryElement> inquiryElements = new List <InquiryElement>();

            foreach (ItemRosterElement item in PartyBase.MainParty.ItemRoster)
            {
                if (isWeapon(item.EquipmentElement.Item))
                {
                    inquiryElements.Add(new InquiryElement((object)new Tuple <EquipmentElement, int>(item.EquipmentElement, item.Amount), (item.EquipmentElement.ItemModifier == null ? item.EquipmentElement.Item.Name.ToString() : (item.EquipmentElement.ItemModifier.Name.ToString()) + item.EquipmentElement.Item.Name.ToString()) + " - " + item.Amount, new ImageIdentifier(item.EquipmentElement.Item)));
                }
            }
            if (inquiryElements.Count < 1)
            {
                InformationManager.ShowInquiry(new InquiryData("No weapons in inventory", "", true, false, "OK", "", (Action)null, (Action)null), true);
                GameMenu.SwitchToMenu("town");
            }
            else
            {
                InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData("", "Select Weapons to give seperatists", inquiryElements, true, 1000, "Continue", (string)null, (Action <List <InquiryElement> >)(args =>
                {
                    List <InquiryElement> source = args;
                    if (source != null && !source.Any <InquiryElement>())
                    {
                        return;
                    }
                    InformationManager.HideInquiry();
                    float WeaponsValue = 0;
                    IEnumerable <Tuple <EquipmentElement, int> > selected = args.Select <InquiryElement, Tuple <EquipmentElement, int> >((Func <InquiryElement, Tuple <EquipmentElement, int> >)(element => element.Identifier as Tuple <EquipmentElement, int>));
                    foreach (Tuple <EquipmentElement, int> pair in selected)
                    {
                        WeaponsValue += pair.Item2 * (2 + Math.Min((int)pair.Item1.Item.Tierf, 6));
                        PartyBase.MainParty.ItemRoster.Remove(new ItemRosterElement(pair.Item1, pair.Item2));
                    }
                    Settlement.CurrentSettlement.Militia += WeaponsValue / 2;
                    float loyaltyChange = Math.Min(100 * (WeaponsValue / Math.Max(Settlement.CurrentSettlement.Town.Prosperity, 1)), Settlement.CurrentSettlement.Town.Loyalty);
                    Settlement.CurrentSettlement.Town.Loyalty -= loyaltyChange;
                    ChangeRelationAction.ApplyPlayerRelation(Settlement.CurrentSettlement.OwnerClan.Leader, (int)(-1 * loyaltyChange));
                    ChangeCrimeRatingAction.Apply(Settlement.CurrentSettlement.MapFaction, loyaltyChange);
                    Hero.MainHero.AddSkillXp(DefaultSkills.Roguery, WeaponsValue * 10);
                }), (Action <List <InquiryElement> >)null));
            }
        }
        internal void ApplyInitialBankRetaliationForUnpaidLoan(Settlement settlement)
        {
            var bankData = GetBankDataAtSettlement(settlement);

            bankData.HasBankPerformedInitialRetaliationForUnpaidLoan = true;
            ChangeCrimeRatingAction.Apply(settlement.MapFaction, SubModule.Config.CrimeRatingIncreaseForUnpaidLoan);
            Hero.MainHero.Clan.Renown -= SubModule.Config.RenownLossForUnpaidLoan;
            InformationManager.DisplayMessage(new InformationMessage($"You failed to repay your loan. Lost {SubModule.Config.RenownLossForUnpaidLoan} renown."));
            InformationManager.ShowInquiry(
                new InquiryData(
                    "Loan Payment Overdue",
                    $"You failed to repay your loan on time with the {settlement.Name} bank. The {settlement.MapFaction.Name} will treat you as an outlaw if you do not repay your debts.",
                    true,
                    false,
                    "OK",
                    "",
                    () => InformationManager.HideInquiry(),
                    () => { }
                    ),
                true
                );
        }
Пример #6
0
        public static void ApplyStoryOptions()
        {
            //Take away all the stuff to apply to each option
            GiveGoldAction.ApplyBetweenCharacters(Hero.MainHero, null, Hero.MainHero.Gold, true);
            PartyBase.MainParty.ItemRoster.Clear();
            int Option = CSCharCreationOption.CSSelectOption;

            if (CSCharCreationOption.SelectedCulture != null)
            {
                Hero.MainHero.Culture   = CSCharCreationOption.SelectedCulture;
                Clan.PlayerClan.Culture = CSCharCreationOption.SelectedCulture;
            }
            ;
            Settlement Castle;

            switch (Option)
            {
            case 1:     //Default
                GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, 1000, true);
                PartyBase.MainParty.ItemRoster.AddToCounts(DefaultItems.Grain, 2);
                break;

            case 2:     //Merchant
                GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, 1600, true);
                PartyBase.MainParty.ItemRoster.AddToCounts(DefaultItems.Grain, 2);
                PartyBase.MainParty.ItemRoster.AddToCounts(MBObjectManager.Instance.GetObject <ItemObject>("mule"), 5);
                CSAddTroop(1, 5, PartyBase.MainParty);
                CSAddTroop(2, 3, PartyBase.MainParty);
                break;

            case 3:     //Exiled Option
                GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, 3000, true);
                PartyBase.MainParty.ItemRoster.AddToCounts(DefaultItems.Grain, 2);
                AddExiledHero();
                ExiledDmgRelation();
                break;

            case 4:     // Merc
                GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, 250, true);
                PartyBase.MainParty.ItemRoster.AddToCounts(DefaultItems.Grain, 1);
                CSAddTroop(1, 10, PartyBase.MainParty);
                CSAddTroop(2, 5, PartyBase.MainParty);
                CSAddTroop(3, 3, PartyBase.MainParty);
                CSAddTroop(4, 1, PartyBase.MainParty);
                MobileParty.MainParty.RecentEventsMorale += -40;
                Hero.MainHero.BattleEquipment.FillFrom((from x in CharacterObject.All
                                                        where x.Tier == 3 && x.Culture.StringId == Hero.MainHero.Culture.StringId && !x.IsHero && (x.Occupation == Occupation.Soldier || x.Occupation == Occupation.Mercenary)
                                                        select x).GetRandomElementInefficiently <CharacterObject>().Equipment);
                break;

            case 5:     // looter
                GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, 40, true);
                CSAddLooter(7);
                foreach (Kingdom x in Campaign.Current.Kingdoms)
                {
                    ChangeCrimeRatingAction.Apply(x.MapFaction, 50, false);
                    // DeclareWarAction.Apply(x, Hero.MainHero.MapFaction);
                }
                break;

            case 6:    //Vassal
                GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, 3000, true);
                PartyBase.MainParty.ItemRoster.AddToCounts(DefaultItems.Grain, 2);
                SetVassal(Hero.MainHero);
                CSSetEquip(Hero.MainHero, 3);
                CSAddTroop(1, 10, PartyBase.MainParty);
                CSAddTroop(2, 4, PartyBase.MainParty);
                break;

            case 7:    //Kingdom
                GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, 8000, true);
                PartyBase.MainParty.ItemRoster.AddToCounts(DefaultItems.Grain, 15);
                CSAddTroop(1, 31, PartyBase.MainParty);
                CSAddTroop(2, 20, PartyBase.MainParty);
                CSAddTroop(3, 14, PartyBase.MainParty);
                CSAddTroop(4, 10, PartyBase.MainParty);
                CSAddTroop(5, 6, PartyBase.MainParty);
                //CSCreateKingdom();
                CSSetEquip(Hero.MainHero, 5);
                Hero.MainHero.Clan.Influence = 100;
                CSAddCompanionAsArmy(2);
                CSAddCompanion(1);
                break;

            case 8:    //Holding
                GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, 10000, true);
                PartyBase.MainParty.ItemRoster.AddToCounts(DefaultItems.Grain, 15);

                CSGiveCastle(out Castle);

                CSAddTroop(1, 31, PartyBase.MainParty);
                CSAddTroop(2, 20, PartyBase.MainParty);
                CSAddTroop(3, 14, PartyBase.MainParty);
                CSAddTroop(4, 10, PartyBase.MainParty);
                CSAddTroop(5, 6, PartyBase.MainParty);
                //CSCreateKingdom();
                CSSetEquip(Hero.MainHero, 5);
                CSAddCompanionAsArmy(1);

                break;

            case 9:    //Vassal
                GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, 10000, true);
                PartyBase.MainParty.ItemRoster.AddToCounts(DefaultItems.Grain, 2);
                SetVassal(Hero.MainHero);
                //Settlement Castle;
                CSGiveCastle(out Castle);
                CSSetEquip(Hero.MainHero, 3);
                CSAddTroop(1, 10, PartyBase.MainParty);
                CSAddTroop(2, 4, PartyBase.MainParty);
                break;

            case 10:
                PartyBase.MainParty.ItemRoster.AddToCounts(DefaultItems.Grain, 1);
                EscapedPrisoner();
                break;

            default:
                break;
            }
            //Culture swap
        }
 private void game_menu_steal_threat_on_consequence(MenuCallbackArgs args)
 {
     ChangeCrimeRatingAction.Apply(Settlement.CurrentSettlement.MapFaction, 5, true);
     OnStealAttempt(Settlement.CurrentSettlement, isDetected, prosperityGoodsAmmount, stealQuantity);
 }