コード例 #1
0
        // If you let leaders of the parties you defeat go, same thing with the [Merciful] trait.
        public static void Prefix(Hero prisoner, EndCaptivityDetail detail, Hero facilitatior)
        {
            if (prisoner == null || facilitatior == null || detail != EndCaptivityDetail.ReleasedAfterBattle)
            {
                return;
            }

            var multiplier = facilitatior.Clan.IsUnderMercenaryService
                ? MercenarySettings.Instance !.MercenaryMultiplier
                : MercenarySettings.Instance !.VassalMultiplier;

            if (prisoner.GetTraitLevel(DefaultTraits.Mercy) > 0)
            {
                AragasChangeRelationAction.ApplyRelation(
                    facilitatior,
                    prisoner,
                    2 * multiplier,
                    MercenarySettings.Instance.EnemyCap,
                    true);
            }
            else
            {
                AragasChangeRelationAction.ApplyRelation(
                    facilitatior,
                    prisoner,
                    1 * multiplier,
                    MercenarySettings.Instance.EnemyCap,
                    true);
            }
        }
        private static void OnPrisonerReleased(Hero hero, IFaction arg2, EndCaptivityDetail arg3)
        {
            if (hero == null)
            {
                return;
            }

            ZenDzeeRomanceHelper.EndLoverRomances(hero, ZenDzeeRomanceHelper.RomanceLevel_Prisoner);

            if (hero != Hero.MainHero &&
                !Hero.MainHero.IsPrisoner)
            {
                MenuContext currentMenuContext = Campaign.Current.CurrentMenuContext;
                if (currentMenuContext == null)
                {
                    return;
                }

                if (currentMenuContext.GameMenu.StringId == "zendzee_town_wait_menus" &&
                    ZenDzeeRomanceHelper.GetLover(Hero.MainHero, ZenDzeeRomanceHelper.RomanceLevel_Prisoner) == null)
                {
                    GameMenu.SwitchToMenu("town_wait_menus");
                }
            }
        }
コード例 #3
0
 private static void Postfix(Hero prisoner, EndCaptivityDetail detail, Hero facilitatior = null)
 {
     if (prisoner != Hero.MainHero && !prisoner.IsPlayerCompanion && detail == EndCaptivityDetail.ReleasedAfterBattle)
     {
         prisoner.DaysLeftToRespawn = (int)DiplomacySetting.Instance.PrisonerDaysLeftToRespawn;
     }
 }
コード例 #4
0
        private static void Postfix(Hero companion, EndCaptivityDetail detail)
        {
            if (companion.Clan != Hero.MainHero.Clan || companion.PartyBelongedTo != null && companion.PartyBelongedTo.Party.Owner == companion || ((companion != null ? companion.getOrder() : (PartyOrder)null) == null || !companion.IsAlive || companion.Clan.CommanderLimit <= companion.Clan.WarParties.Count <MobileParty>((Func <MobileParty, bool>)(p => !p.IsGarrison && !p.IsMilitia && !p.IsVillager && !p.IsCaravan))))
            {
                return;
            }
            companion.ChangeState(Hero.CharacterStates.Active);
            MobilePartyHelper.CreateNewClanMobileParty(companion, companion.Clan, out bool _);
            if (companion.PartyBelongedTo == null)
            {
                return;
            }
            PartyOrder order = companion.getOrder();

            if (order.Behavior == AiBehavior.EscortParty && (double)order.ScoreMinimum > 1.0)
            {
                companion.PartyBelongedTo.SetInititave(0.0f, 1f, CampaignTime.YearsFromNow(100f).RemainingHoursFromNow);
            }
            else
            {
                companion.PartyBelongedTo.SetInititave(order.AttackInitiative, order.AvoidInitiative, CampaignTime.YearsFromNow(100f).RemainingHoursFromNow);
            }
        }
コード例 #5
0
        private static bool Prefix(Hero prisoner, EndCaptivityDetail detail)
        {
            if (prisoner.Clan != Hero.MainHero.Clan || prisoner.PartyBelongedToAsPrisoner == null || (prisoner.IsActive || !prisoner.IsAlive) || prisoner.PartyBelongedTo != null && prisoner.PartyBelongedTo.Party.Owner == prisoner || detail != EndCaptivityDetail.ReleasedAfterBattle && detail != EndCaptivityDetail.ReleasedAfterPeace && detail != EndCaptivityDetail.RemovedParty || (prisoner.Clan.CommanderLimit <= prisoner.Clan.WarParties.Count <MobileParty>((Func <MobileParty, bool>)(p => !p.IsGarrison && !p.IsMilitia && !p.IsVillager && !p.IsCaravan)) || (double)prisoner.PartyBelongedToAsPrisoner.Position2D.DistanceSquared(MobileParty.MainParty.VisualPosition2DWithoutError) >= 25.0))
            {
                return(true);
            }
            StatisticsDataLogHelper.AddLog(StatisticsDataLogHelper.LogAction.EndCaptivityAction);
            PartyBase belongedToAsPrisoner = prisoner.PartyBelongedToAsPrisoner;
            IFaction  faction = belongedToAsPrisoner != null ? belongedToAsPrisoner.MapFaction : (IFaction)CampaignData.NeutralFaction;

            Traverse.Create((object)CampaignEventDispatcher.Instance).Method("OnHeroPrisonerReleased", new Type[4]
            {
                typeof(Hero),
                typeof(PartyBase),
                typeof(IFaction),
                typeof(EndCaptivityDetail)
            }, (object[])null).GetValue((object)prisoner, (object)belongedToAsPrisoner, (object)faction, (object)detail);
            EndCaptivityActionPatch.SpawnPartyAtPosition(prisoner, MobileParty.MainParty.VisualPosition2DWithoutError);
            if (prisoner.PartyBelongedTo != null && (prisoner != null ? prisoner.getOrder() : (PartyOrder)null) != null)
            {
                PartyOrder order = prisoner.getOrder();
                if (order.Behavior == AiBehavior.EscortParty && (double)order.ScoreMinimum > 1.0)
                {
                    if ((double)Campaign.Current.Models.MapDistanceModel.GetDistance(prisoner.PartyBelongedTo, MobileParty.MainParty) > 15.0)
                    {
                        prisoner.PartyBelongedTo.SetInititave(0.0f, 1f, CampaignTime.YearsFromNow(100f).RemainingHoursFromNow);
                    }
                    else
                    {
                        prisoner.PartyBelongedTo.SetInititave(order.AttackInitiative, order.AvoidInitiative, CampaignTime.YearsFromNow(100f).RemainingHoursFromNow);
                    }
                    prisoner.PartyBelongedTo.SetMoveEscortParty(order.TargetParty);
                }
            }
            return(false);
        }
コード例 #6
0
 private static bool Prefix(Hero companion, EndCaptivityDetail detail) => !companion.IsActive;