Пример #1
0
        private void OutsideTacticsAI()
        {
            ConvinceNoFactionAI();

            if (this.PlanArchitecture == null && this.RecentlyAttacked <= 0 && this.HasPerson() && this.IsFundEnough)
            {
                Architecture architecture2;
                int diplomaticRelation;
                Person firstHalfPerson;
                ArchitectureList unknownArch = new ArchitectureList();
                ArchitectureList knownArch = new ArchitectureList();
                foreach (Architecture architecture in this.GetClosestArchitectures(20, 40))
                {
                    if (!this.BelongedFaction.IsArchitectureKnown(architecture))
                    {
                        unknownArch.Add(architecture);
                    }
                    else
                    {
                        knownArch.Add(architecture);
                    }
                }
                if (this.BelongedSection != null && (unknownArch.Count > 0) && this.BelongedSection.AIDetail.AllowInvestigateTactics)
                {
                    if (unknownArch.Count > 1)
                    {
                        unknownArch.PropertyName = "Population";
                        unknownArch.IsNumber = true;
                        unknownArch.ReSort();
                    }
                    if ((((this.RecentlyAttacked <= 0) && (GameObject.Random(40) < GameObject.Random(unknownArch.Count))) && GameObject.Chance(20)) && this.InformationAvail())
                    {
                        architecture2 = unknownArch[GameObject.Random(unknownArch.Count / 2)] as Architecture;
                        if ((!this.BelongedFaction.IsArchitectureKnown(architecture2) || GameObject.Chance(20)) && ((architecture2.BelongedFaction != null) && (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10))))
                        {
                            diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID);
                            if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100))))
                            {
                                firstHalfPerson = this.GetFirstHalfPerson("InformationAbility");
                                if ((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100))
                                {
                                    firstHalfPerson.CurrentInformationKind = this.GetFirstHalfInformationKind();
                                    if (firstHalfPerson.CurrentInformationKind != null)
                                    {
                                        firstHalfPerson.GoForInformation(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position));
                                    }
                                }
                            }
                        }
                    }
                }
                if ((this.BelongedSection != null) && ((knownArch.Count > 0) && (this.PlanArchitecture == null)) && this.BelongedSection.AIDetail.AllowPersonTactics)
                {
                    if (knownArch.Count > 1)
                    {
                        knownArch.PropertyName = "PersonCount";
                        knownArch.IsNumber = true;
                        knownArch.ReSort();
                    }
                    if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.GossipArchitectureFund)) && GameObject.Chance(50))
                    {
                        ArchitectureList list3 = new ArchitectureList();
                        foreach (Architecture architecture in knownArch)
                        {
                            if ((architecture.BelongedFaction != this.BelongedFaction) && (architecture.BelongedFaction != null))
                            {
                                list3.Add(architecture);
                            }
                        }
                        if (list3.Count > 0)
                        {
                            architecture2 = list3[GameObject.Random(list3.Count / 2)] as Architecture;
                            if (GameObject.Chance(100 - architecture2.noEscapeChance * 2))
                            {
                                if ((!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10)) && ((architecture2.Fund < architecture2.EnoughFund) || ((architecture2.Fund < architecture2.AbundantFund) && GameObject.Chance(20))))
                                {
                                    diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID);
                                    if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100))))
                                    {
                                        firstHalfPerson = this.GetFirstHalfPerson("GossipAbility");
                                        if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)) && ((GameObject.Random(architecture2.GetGossipablePersonCount() + 4) >= 4) && (GameObject.Random(firstHalfPerson.GossipAbility) >= 200)))
                                        {
                                            firstHalfPerson.GoForGossip(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position));
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.ConvincePersonFund)) && GameObject.Chance(50))
                    {
                        ArchitectureList list4 = new ArchitectureList();
                        foreach (Architecture architecture in knownArch)
                        {
                            if (((architecture.BelongedFaction != this.BelongedFaction) && (architecture.BelongedFaction != null)) && architecture.HasPerson())
                            {
                                list4.Add(architecture);
                            }
                        }
                        foreach (Architecture architecture in this.BelongedFaction.Architectures)
                        {
                            if (architecture.HasCaptive())
                            {
                                list4.Add(architecture);
                            }
                        }
                        if (list4.Count > 0)
                        {
                            architecture2 = list4[GameObject.Random(list4.Count)] as Architecture;
                            if (architecture2.BelongedFaction == this.BelongedFaction)
                            {
                                ConvinceCaptivesAI(architecture2);
                            }
                            else if (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(50))
                            {
                                diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID);
                                if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 50) <= GameObject.Random(50))) || (diplomaticRelation < 0))
                                {
                                    Person extremeLoyaltyPerson = architecture2.GetLowestLoyaltyPersonRecruitable();
                                    if ((extremeLoyaltyPerson != null) && ((extremeLoyaltyPerson.Loyalty < 100) && (extremeLoyaltyPerson.BelongedFaction != null)) && (extremeLoyaltyPerson != extremeLoyaltyPerson.BelongedFaction.Leader))
                                    {
                                        firstHalfPerson = this.GetFirstHalfPerson("ConvinceAbility");
                                        if ((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(20))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && ((GameObject.Random(firstHalfPerson.ConvinceAbility) >= 200) && (GameObject.Random(firstHalfPerson.ConvinceAbility) > GameObject.Random(extremeLoyaltyPerson.Loyalty * 5))))
                                        {
                                            firstHalfPerson.OutsideDestination = new Point?(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position));
                                            firstHalfPerson.GoForConvince(extremeLoyaltyPerson);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.JailBreakArchitectureFund)) && GameObject.Chance(50) && this.JailBreakAvail())
                    {
                        List<Architecture> a = new List<Architecture>();
                        foreach (Architecture architecture in base.Scenario.Architectures)
                        {
                            if (architecture.HasFactionCaptive(this.BelongedFaction) && knownArch.GameObjects.Contains(architecture))
                            {
                                a.Add(architecture);
                            }
                        }
                        if (a.Count > 0)
                        {
                            Architecture target = a[GameObject.Random(a.Count)] as Architecture;
                            if (GameObject.Chance(100 - target.noEscapeChance * 2))
                            {
                                int totalCaptiveValue = 0;
                                foreach (Captive c in target.Captives)
                                {
                                    if (c.CaptiveFaction == this.BelongedFaction)
                                    {
                                        totalCaptiveValue += c.AIWantsTheCaptive;
                                    }
                                }
                                if (GameObject.Random(totalCaptiveValue) > GameObject.Random(100000))
                                {
                                    firstHalfPerson = this.GetFirstHalfPerson("JailBreakAbility");
                                    if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)))
                                    {
                                        firstHalfPerson.GoForJailBreak(base.Scenario.GetClosestPoint(target.ArchitectureArea, this.Position));
                                    }
                                }
                            }
                        }
                    }
                }
            }

            InformationList toRemove = new InformationList();
            int dayCost = this.InformationDayCost;
            foreach (Information i in this.Informations)
            {
                bool stop = true;
                if (i.DaysStarted <= 3)
                {
                    stop = false;
                }
                else if (i.DaysStarted < GameObject.Random(10) + 30 && this.IsFundIncomeEnough && this.IsFundEnough
                    && dayCost < 500)
                {
                    foreach (Point p in i.Area.Area)
                    {
                        Architecture a = base.Scenario.GetArchitectureByPosition(p);
                        if (a != null && !this.IsFriendly(a.BelongedFaction))
                        {
                            stop = false;
                            break;
                        }
                    }
                }

                if (stop)
                {
                    bool hasEnemy = false;
                    bool hasOwn = false;
                    foreach (Point p in i.Area.Area)
                    {
                        Troop t = base.Scenario.GetTroopByPosition(p);
                        if (t != null && !this.IsFriendly(t.BelongedFaction))
                        {
                            hasEnemy = true;
                        }
                        if (t != null && t.BelongedFaction == this.BelongedFaction)
                        {
                            hasOwn = true;
                        }
                        if (hasEnemy && hasOwn)
                        {
                            stop = false;
                            break;
                        }
                    }
                }

                if (stop && this.PlanArchitecture != null)
                {
                    foreach (Point p in i.Area.Area)
                    {
                        Architecture a = base.Scenario.GetArchitectureByPosition(p);
                        if (a == this.PlanArchitecture)
                        {
                            stop = false;
                            break;
                        }
                    }
                }

                if (!stop)
                {
                    foreach (Information j in this.Informations)
                    {
                        if (i == j) continue;
                        if (toRemove.GameObjects.Contains(i)) continue;
                        if (j.Position == i.Position && j.Radius >= i.Radius && j.DayCost < i.DayCost)
                        {
                            stop = true;
                            break;
                        }
                    }
                }

                if (stop)
                {
                    toRemove.Add(i);
                    dayCost -= i.DayCost;
                }
            }
            foreach (Information i in toRemove)
            {
                i.Purify();
                this.RemoveInformation(i);
                base.Scenario.Informations.Remove(i);
            }
        }
Пример #2
0
 private void OutsideTacticsAI()
 {
     if (((this.PlanArchitecture == null) || GameObject.Chance(10)) && (((this.RecentlyAttacked <= 0) && this.HasPerson()) && this.IsFundEnough))
     {
         Architecture architecture2;
         int diplomaticRelation;
         Person firstHalfPerson;
         ArchitectureList list = new ArchitectureList();
         ArchitectureList list2 = new ArchitectureList();
         foreach (Architecture architecture in this.GetClosestArchitectures(20))
         {
             if (!this.BelongedFaction.IsArchitectureKnown(architecture))
             {
                 list.Add(architecture);
             }
             else
             {
                 list2.Add(architecture);
             }
         }
         if ((list.Count > 0) && this.BelongedSection.AIDetail.AllowInvestigateTactics)
         {
             if (list.Count > 1)
             {
                 list.PropertyName = "Population";
                 list.IsNumber = true;
                 list.ReSort();
             }
             if ((((this.RecentlyAttacked <= 0) && (GameObject.Random(40) < GameObject.Random(list.Count))) && GameObject.Chance(20)) && this.InformationAvail())
             {
                 architecture2 = list[GameObject.Random(list.Count / 2)] as Architecture;
                 if ((!this.BelongedFaction.IsArchitectureKnown(architecture2) || GameObject.Chance(20)) && ((architecture2.BelongedFaction != null) && (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10))))
                 {
                     diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID);
                     if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100))))
                     {
                         firstHalfPerson = this.GetFirstHalfPerson("InformationAbility");
                         if ((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100))
                         {
                             firstHalfPerson.CurrentInformationKind = this.GetFirstHalfInformationKind();
                             if (firstHalfPerson.CurrentInformationKind != null)
                             {
                                 firstHalfPerson.GoForInformation(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position));
                             }
                         }
                     }
                 }
             }
             if (((this.PlanArchitecture == null) && (GameObject.Random(40) < GameObject.Random(list.Count))) && (this.HasPerson() && (GameObject.Random(this.Fund) >= this.SpyArchitectureFund)))
             {
                 architecture2 = list[GameObject.Random(list.Count / 2)] as Architecture;
                 if ((!architecture2.HasFactionSpy(this.BelongedFaction) || GameObject.Chance(20)) && (((architecture2.BelongedFaction != null) && (GameObject.Random(architecture2.AreaCount + 4) >= 4)) && (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10))))
                 {
                     diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID);
                     if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100))))
                     {
                         firstHalfPerson = this.GetFirstHalfPerson("SpyAbility");
                         if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)) && (GameObject.Random(firstHalfPerson.SpyAbility) >= 200))
                         {
                             firstHalfPerson.GoForSpy(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position));
                         }
                     }
                 }
             }
         }
         if (((list2.Count > 0) && (this.PlanArchitecture == null)) && this.BelongedSection.AIDetail.AllowPersonTactics)
         {
             if (list2.Count > 1)
             {
                 list2.PropertyName = "PersonCount";
                 list2.IsNumber = true;
                 list2.ReSort();
             }
             if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.GossipArchitectureFund)) && GameObject.Chance(50))
             {
                 ArchitectureList list3 = new ArchitectureList();
                 foreach (Architecture architecture in list2)
                 {
                     if ((architecture.BelongedFaction != this.BelongedFaction) && (architecture.BelongedFaction != null))
                     {
                         list3.Add(architecture);
                     }
                 }
                 if (list3.Count > 0)
                 {
                     architecture2 = list3[GameObject.Random(list3.Count / 2)] as Architecture;
                     if ((!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10)) && ((architecture2.Fund < architecture2.EnoughFund) || ((architecture2.Fund < architecture2.AbundantFund) && GameObject.Chance(20))))
                     {
                         diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID);
                         if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100))))
                         {
                             firstHalfPerson = this.GetFirstHalfPerson("GossipAbility");
                             if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)) && ((GameObject.Random(architecture2.GetGossipablePersonCount() + 4) >= 4) && (GameObject.Random(firstHalfPerson.GossipAbility) >= 200)))
                             {
                                 firstHalfPerson.GoForGossip(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position));
                             }
                         }
                     }
                 }
             }
             if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.ConvincePersonFund)) && GameObject.Chance(50))
             {
                 ArchitectureList list4 = new ArchitectureList();
                 foreach (Architecture architecture in list2)
                 {
                     if (((architecture.BelongedFaction != this.BelongedFaction) && (architecture.BelongedFaction != null)) && architecture.HasPerson())
                     {
                         list4.Add(architecture);
                     }
                 }
                 foreach (Architecture architecture in this.BelongedFaction.Architectures)
                 {
                     if (architecture.HasCaptive())
                     {
                         list4.Add(architecture);
                     }
                 }
                 if (list4.Count > 0)
                 {
                     architecture2 = list4[GameObject.Random(list4.Count)] as Architecture;
                     if (architecture2.BelongedFaction == this.BelongedFaction)
                     {
                         Captive extremeLoyaltyCaptive = architecture2.GetExtremeLoyaltyCaptive(true);
                         if ((((extremeLoyaltyCaptive != null) && (extremeLoyaltyCaptive.CaptivePerson != null)) && ((extremeLoyaltyCaptive.Loyalty < 100) && (extremeLoyaltyCaptive.CaptiveFaction != null))) && (extremeLoyaltyCaptive.CaptivePerson != extremeLoyaltyCaptive.CaptiveFaction.Leader))
                         {
                             firstHalfPerson = this.GetFirstHalfPerson("ConvinceAbility");
                             if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(0x21))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)) && ((GameObject.Random(firstHalfPerson.ConvinceAbility) >= 200) && (GameObject.Random(firstHalfPerson.ConvinceAbility) > GameObject.Random(extremeLoyaltyCaptive.Loyalty * 5))))
                             {
                                 firstHalfPerson.OutsideDestination = new Point?(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position));
                                 firstHalfPerson.GoForConvince(extremeLoyaltyCaptive.CaptivePerson);
                             }
                         }
                     }
                     else if (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(50))
                     {
                         diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID);
                         if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 50) <= GameObject.Random(50))) || (diplomaticRelation < 0))
                         {
                             Person extremeLoyaltyPerson = architecture2.GetExtremeLoyaltyPerson(true);
                             if (((extremeLoyaltyPerson.Loyalty < 100) && (extremeLoyaltyPerson.BelongedFaction != null)) && (extremeLoyaltyPerson != extremeLoyaltyPerson.BelongedFaction.Leader))
                             {
                                 firstHalfPerson = this.GetFirstHalfPerson("ConvinceAbility");
                                 if ((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(20))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && ((GameObject.Random(firstHalfPerson.ConvinceAbility) >= 200) && (GameObject.Random(firstHalfPerson.ConvinceAbility) > GameObject.Random(extremeLoyaltyPerson.Loyalty * 5))))
                                 {
                                     firstHalfPerson.OutsideDestination = new Point?(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position));
                                     firstHalfPerson.GoForConvince(extremeLoyaltyPerson);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Пример #3
0
 private void OutsideTacticsAI()
 {
     if (((this.PlanArchitecture == null) || GameObject.Chance(10)) && (((this.RecentlyAttacked <= 0) && this.HasPerson()) && this.IsFundEnough))
     {
         Architecture architecture2;
         int diplomaticRelation;
         Person firstHalfPerson;
         ArchitectureList list = new ArchitectureList();
         ArchitectureList list2 = new ArchitectureList();
         foreach (Architecture architecture in this.GetClosestArchitectures(20, 40))
         {
             if (!this.BelongedFaction.IsArchitectureKnown(architecture))
             {
                 list.Add(architecture);
             }
             else
             {
                 list2.Add(architecture);
             }
         }
         /*if (this.BelongedSection != null && (list.Count > 0) && this.BelongedSection.AIDetail.AllowInvestigateTactics)
         {
             if (list.Count > 1)
             {
                 list.PropertyName = "Population";
                 list.IsNumber = true;
                 list.ReSort();
             }
             if ((((this.RecentlyAttacked <= 0) && (GameObject.Random(40) < GameObject.Random(list.Count))) && GameObject.Chance(20)) && this.InformationAvail())
             {
                 architecture2 = list[GameObject.Random(list.Count / 2)] as Architecture;
                 if ((!this.BelongedFaction.IsArchitectureKnown(architecture2) || GameObject.Chance(20)) && ((architecture2.BelongedFaction != null) && (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10))))
                 {
                     diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID);
                     if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100))))
                     {
                         firstHalfPerson = this.GetFirstHalfPerson("InformationAbility");
                         if ((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100))
                         {
                             firstHalfPerson.CurrentInformationKind = this.GetFirstHalfInformationKind();
                             if (firstHalfPerson.CurrentInformationKind != null)
                             {
                                 firstHalfPerson.GoForInformation(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position));
                             }
                         }
                     }
                 }
             }
             if (((this.PlanArchitecture == null) && (GameObject.Random(40) < GameObject.Random(list.Count))) && (this.HasPerson() && (GameObject.Random(this.Fund) >= this.SpyArchitectureFund)))
             {
                 architecture2 = list[GameObject.Random(list.Count / 2)] as Architecture;
                 if ((!architecture2.HasFactionSpy(this.BelongedFaction) || GameObject.Chance(20)) && (((architecture2.BelongedFaction != null) && (GameObject.Random(architecture2.AreaCount + 4) >= 4)) && (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10))))
                 {
                     diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID);
                     if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100))))
                     {
                         firstHalfPerson = this.GetFirstHalfPerson("SpyAbility");
                         if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)) && (GameObject.Random(firstHalfPerson.SpyAbility) >= 200))
                         {
                             firstHalfPerson.GoForSpy(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position));
                         }
                     }
                 }
             }
         }*/
         if ((this.BelongedSection != null) && ((list2.Count > 0) && (this.PlanArchitecture == null)) && this.BelongedSection.AIDetail.AllowPersonTactics)
         {
             if (list2.Count > 1)
             {
                 list2.PropertyName = "PersonCount";
                 list2.IsNumber = true;
                 list2.ReSort();
             }
             if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.GossipArchitectureFund)) && GameObject.Chance(50))
             {
                 ArchitectureList list3 = new ArchitectureList();
                 foreach (Architecture architecture in list2)
                 {
                     if ((architecture.BelongedFaction != this.BelongedFaction) && (architecture.BelongedFaction != null))
                     {
                         list3.Add(architecture);
                     }
                 }
                 if (list3.Count > 0)
                 {
                     architecture2 = list3[GameObject.Random(list3.Count / 2)] as Architecture;
                     if (GameObject.Chance(100 - architecture2.noEscapeChance * 2))
                     {
                         if ((!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10)) && ((architecture2.Fund < architecture2.EnoughFund) || ((architecture2.Fund < architecture2.AbundantFund) && GameObject.Chance(20))))
                         {
                             diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID);
                             if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100))))
                             {
                                 firstHalfPerson = this.GetFirstHalfPerson("GossipAbility");
                                 if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)) && ((GameObject.Random(architecture2.GetGossipablePersonCount() + 4) >= 4) && (GameObject.Random(firstHalfPerson.GossipAbility) >= 200)))
                                 {
                                     firstHalfPerson.GoForGossip(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position));
                                 }
                             }
                         }
                     }
                 }
             }
             if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.ConvincePersonFund)) && GameObject.Chance(50))
             {
                 ArchitectureList list4 = new ArchitectureList();
                 foreach (Architecture architecture in list2)
                 {
                     if (((architecture.BelongedFaction != this.BelongedFaction) && (architecture.BelongedFaction != null)) && architecture.HasPerson())
                     {
                         list4.Add(architecture);
                     }
                 }
                 foreach (Architecture architecture in this.BelongedFaction.Architectures)
                 {
                     if (architecture.HasCaptive())
                     {
                         list4.Add(architecture);
                     }
                 }
                 if (list4.Count > 0)
                 {
                     architecture2 = list4[GameObject.Random(list4.Count)] as Architecture;
                     if (architecture2.BelongedFaction == this.BelongedFaction)
                     {
                         Captive extremeLoyaltyCaptive = architecture2.GetLowestLoyaltyCaptiveRecruitable();
                         if ((((extremeLoyaltyCaptive != null) && (extremeLoyaltyCaptive.CaptivePerson != null)) &&
                             ((extremeLoyaltyCaptive.Loyalty < 100 || (GlobalVariables.AIAutoTakePlayerCaptives && !GlobalVariables.AIAutoTakePlayerCaptiveOnlyUnfull && base.Scenario.IsPlayer(extremeLoyaltyCaptive.CaptiveFaction)))))
                             && (extremeLoyaltyCaptive.CaptiveFaction == null || extremeLoyaltyCaptive.CaptivePerson != extremeLoyaltyCaptive.CaptiveFaction.Leader))
                         {
                             PersonList firstHalfPersonList = this.GetFirstHalfPersonList("ConvinceAbility");
                             foreach (Person i in firstHalfPersonList)
                             {
                                 if ((GameObject.Random(this.BelongedFaction.PersonCount) < 5 && i != null) || ((((i != null) && (!this.HasFollowedLeaderMilitary(i) || GameObject.Chance(33))) && (GameObject.Random(i.NonFightingNumber) > GameObject.Random(i.FightingNumber))) && (GameObject.Random(i.FightingNumber) < 100)) && ((GameObject.Random(i.ConvinceAbility) >= 200) && (GameObject.Random(i.ConvinceAbility) > GameObject.Random(extremeLoyaltyCaptive.Loyalty * 5))))
                                 {
                                     i.OutsideDestination = new Point?(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position));
                                     i.GoForConvince(extremeLoyaltyCaptive.CaptivePerson);
                                 }
                             }
                         }
                     }
                     else if (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(50))
                     {
                         diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID);
                         if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 50) <= GameObject.Random(50))) || (diplomaticRelation < 0))
                         {
                             Person extremeLoyaltyPerson = architecture2.GetLowestLoyaltyPersonRecruitable();
                             if ((extremeLoyaltyPerson != null) && ((extremeLoyaltyPerson.Loyalty < 100) && (extremeLoyaltyPerson.BelongedFaction != null)) && (extremeLoyaltyPerson != extremeLoyaltyPerson.BelongedFaction.Leader))
                             {
                                 firstHalfPerson = this.GetFirstHalfPerson("ConvinceAbility");
                                 if ((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(20))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && ((GameObject.Random(firstHalfPerson.ConvinceAbility) >= 200) && (GameObject.Random(firstHalfPerson.ConvinceAbility) > GameObject.Random(extremeLoyaltyPerson.Loyalty * 5))))
                                 {
                                     firstHalfPerson.OutsideDestination = new Point?(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position));
                                     firstHalfPerson.GoForConvince(extremeLoyaltyPerson);
                                 }
                             }
                         }
                     }
                 }
             }
             if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.JailBreakArchitectureFund)) && GameObject.Chance(50) && this.JailBreakAvail())
             {
                 List<Architecture> a = new List<Architecture>();
                 foreach (Architecture architecture in base.Scenario.Architectures)
                 {
                     if (architecture.HasFactionCaptive(this.BelongedFaction) && list2.GameObjects.Contains(architecture))
                     {
                         a.Add(architecture);
                     }
                 }
                 if (a.Count > 0)
                 {
                     Architecture target = a[GameObject.Random(a.Count)] as Architecture;
                     if (GameObject.Chance(100 - target.noEscapeChance * 2))
                     {
                         int totalCaptiveValue = 0;
                         foreach (Captive c in target.Captives)
                         {
                             if (c.CaptiveFaction == this.BelongedFaction)
                             {
                                 totalCaptiveValue += c.AIWantsTheCaptive;
                             }
                         }
                         if (GameObject.Random(totalCaptiveValue) > GameObject.Random(100000))
                         {
                             firstHalfPerson = this.GetFirstHalfPerson("JailBreakAbility");
                             if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)))
                             {
                                 firstHalfPerson.GoForJailBreak(base.Scenario.GetClosestPoint(target.ArchitectureArea, this.Position));
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Пример #4
0
 private void AIPersonTransfer()
 {
     int num2;
     if ((this.MilitaryCount == 0) && ((this.IsImportant || (this.AreaCount > 1)) || (this.Population > this.RecruitmentPopulationBoundary)))
     {
         this.AIRecruitment(false);
     }
     if ((((this.BelongedFaction.ArchitectureCount > 1) && (this.PersonCount > this.MilitaryCount)) && (this.RecentlyAttacked > 0)) && ((this.Endurance == 0) || ((this.Endurance < 30) && GameObject.Chance(0x21))))
     {
         int num = this.PersonCount - this.MilitaryCount;
         GameObjectList list = new GameObjectList();
         list = this.Persons.GetList();
         if (list.Count > 1)
         {
             list.IsNumber = true;
             list.SmallToBig = true;
             list.PropertyName = "FightingForce";
             list.ReSort();
         }
         Architecture capital = this.BelongedFaction.Capital;
         if (capital == this)
         {
             ArchitectureList otherArchitectureList = this.GetOtherArchitectureList();
             if (otherArchitectureList.Count > 1)
             {
                 otherArchitectureList.IsNumber = true;
                 otherArchitectureList.PropertyName = "ArmyScaleWeighing";
                 otherArchitectureList.ReSort();
             }
             capital = otherArchitectureList[0] as Architecture;
         }
         num2 = 0;
         while (num2 < num)
         {
             (list[num2] as Person).MoveToArchitecture(capital);
             this.RemovePerson(list[num2] as Person);
             if (GameObject.Chance(20))
             {
                 break;
             }
             num2++;
         }
     }
     else if (((this.PersonCount + this.MovingPersons.Count) < this.MilitaryCount) || (this.PlanArchitecture != null))
     {
         if (this.RecentlyAttacked > 0)
         {
             int num3 = (this.MilitaryCount - this.PersonCount) - this.MovingPersons.Count;
             PersonList list3 = new PersonList();
             foreach (Architecture architecture2 in GameObject.Chance(20) ? this.BelongedFaction.Architectures : this.BelongedSection.Architectures)
             {
                 if ((architecture2 != this) && (((architecture2.BelongedSection.AIDetail != null) && architecture2.BelongedSection.AIDetail.AutoRun) && (((architecture2.RecentlyAttacked <= 0) && ((architecture2.PersonCount + architecture2.MovingPersons.Count) >= architecture2.MilitaryCount)) || (((architecture2.Fund < (100 * this.AreaCount)) && (architecture2.Domination >= (architecture2.DominationCeiling * 0.8))) && (architecture2.Endurance >= (architecture2.EnduranceCeiling * 0.2f))))))
                 {
                     foreach (Person person in architecture2.Persons)
                     {
                         if ((!architecture2.HasFollowedLeaderMilitary(person) && (GameObject.Chance(10) || !architecture2.HasExperiencedLeaderMilitary(person))) && (person.Command >= 40))
                         {
                             list3.Add(person);
                         }
                     }
                 }
             }
             if (list3.Count > 0)
             {
                 if (list3.Count > 1)
                 {
                     list3.IsNumber = true;
                     list3.PropertyName = "FightingForce";
                     list3.ReSort();
                 }
                 for (num2 = 0; (num2 < num3) && (num2 < list3.Count); num2++)
                 {
                     Architecture locationArchitecture = (list3[num2] as Person).LocationArchitecture;
                     (list3[num2] as Person).MoveToArchitecture(this);
                     locationArchitecture.RemovePerson(list3[num2] as Person);
                 }
             }
         }
     }
     else if (this.HasPerson() && GameObject.Chance(10))
     {
         PersonList list4 = new PersonList();
         if (this.Kind.HasPopulation && (this.Population < (0x3e8 * this.AreaCount)))
         {
             if (this.IsCapital && (this.Fund >= this.ChangeCapitalCost))
             {
                 Architecture newCapital = this.BelongedFaction.SelectNewCapital();
                 if (newCapital != this)
                 {
                     this.DecreaseFund(this.ChangeCapitalCost);
                     this.BelongedFaction.ChangeCapital(newCapital);
                 }
             }
             foreach (Person person in this.Persons)
             {
                 if (!this.HasFollowedLeaderMilitary(person) && (GameObject.Chance(10) || !this.HasExperiencedLeaderMilitary(person)))
                 {
                     list4.Add(person);
                 }
             }
         }
         else
         {
             foreach (Person person in this.Persons)
             {
                 if ((person.WorkKind == ArchitectureWorkKind.无) && (!this.HasFollowedLeaderMilitary(person) && (GameObject.Chance(10) || !this.HasExperiencedLeaderMilitary(person))))
                 {
                     list4.Add(person);
                 }
             }
         }
         if (list4.Count > 0)
         {
             ArchitectureList list5 = new ArchitectureList();
             foreach (Architecture architecture2 in (base.Scenario.Date.Day == 1) ? this.BelongedFaction.Architectures : this.BelongedSection.Architectures)
             {
                 if ((architecture2 != this) && ((((architecture2.IsRegionCore || architecture2.IsStateAdmin) || (architecture2.Kind.HasPopulation && (architecture2.Population > this.Population))) || GameObject.Chance(5)) || ((architecture2.Fund >= (100 * this.AreaCount)) && ((((architecture2.PersonCount + architecture2.MovingPersons.Count) < architecture2.MilitaryCount) || (architecture2.Domination < (architecture2.DominationCeiling * 0.8))) || (architecture2.Endurance < (architecture2.EnduranceCeiling * 0.2f))))))
                 {
                     list5.Add(architecture2);
                 }
             }
             if (list5.Count > 0)
             {
                 if (list5.Count > 1)
                 {
                     list5.PropertyName = "ArmyScaleWeighing";
                     list5.IsNumber = true;
                     list5.ReSort();
                 }
                 for (num2 = 0; (num2 < list4.Count) && (num2 < list5.Count); num2++)
                 {
                     (list4[num2] as Person).MoveToArchitecture(list5[num2] as Architecture);
                     this.RemovePerson(list4[num2] as Person);
                 }
             }
         }
     }
 }