Ejemplo n.º 1
0
 public bool GetCurrentStratagemSuccess(Troop troop, bool inevitableSuccess, bool invincible, bool lowerIntelligenceInvincible)
 {
     int num = 0;
     bool flag = false;
     if (!this.CurrentStratagem.Friendly)
     {
         if (invincible)
         {
             flag = false;
         }
         else if (lowerIntelligenceInvincible && (this.TroopIntelligence < troop.TroopIntelligence))
         {
             flag = false;
         }
         else if (inevitableSuccess && (this.TroopIntelligence > troop.TroopIntelligence))
         {
             flag = true;
         }
         else
         {
             num = ((((this.TroopIntelligence + this.StratagemChanceIncrement) + this.Leader.Calmness) - troop.TroopIntelligence) - troop.ChanceDecrementOfStratagem) - troop.Leader.Calmness;
             int chance = this.CurrentStratagem.Chance + num;
             flag = GameObject.Chance(chance);
         }
     }
     else
     {
         flag = GameObject.Chance(this.TroopIntelligence + this.StratagemChanceIncrement);
     }
     if (!this.CurrentStratagem.Friendly)
     {
         if (flag)
         {
             if (this.OrientationTroop == troop)
             {
                 this.WaitForDeepChaos = !troop.NeverBeIntoChaos && GameObject.Chance(this.ChaosAfterStratagemSuccessChance);
                 this.WaitForDeepChaosFrameCount = 100;
             }
             if (this.OnStratagemSuccess != null)
             {
                 this.OnStratagemSuccess(this, troop, this.CurrentStratagem, true);
             }
         }
         else
         {
             GameObjects.Animations.TileAnimation animation = base.Scenario.GeneratorOfTileAnimation.AddTileAnimation(TileAnimationKind.抵挡, troop.Position, false);
             if (animation != null)
             {
                 troop.TryToPlaySound(troop.Position, animation.LinkedAnimation.SoundPath, false);
             }
             if (this.OnResistStratagem != null)
             {
                 this.OnResistStratagem(this, troop, this.CurrentStratagem, true);
             }
         }
     }
     else if (flag)
     {
         if (((troop != null) && (this.OnStratagemSuccess != null)) && (this != troop))
         {
             this.OnStratagemSuccess(this, troop, this.CurrentStratagem, false);
         }
     }
     else if ((troop != null) && (this.OnResistStratagem != null))
     {
         this.OnResistStratagem(this, troop, this.CurrentStratagem, false);
     }
     int increment = (2 + (flag ? 1 : 0)) + (this.WaitForDeepChaos ? 2 : 0);
     this.IncreaseStratagemExperience(increment, true);
     if (troop != null)
     {
         troop.IncreaseStratagemExperience(increment, false);
     }
     if (this.BelongedFaction != null)
     {
         if (flag)
         {
             if (this.BelongedFaction.RateOfCombativityRecoveryAfterStratagemSuccess > 0f)
             {
                 this.IncreaseCombativity(StaticMethods.GetRandomValue((int) ((this.Leader.Calmness * 100) * this.BelongedFaction.RateOfCombativityRecoveryAfterStratagemSuccess), 100));
             }
             return flag;
         }
         if (this.BelongedFaction.RateOfCombativityRecoveryAfterStratagemFail > 0f)
         {
             this.IncreaseCombativity(StaticMethods.GetRandomValue((int) ((this.Leader.Calmness * 100) * this.BelongedFaction.RateOfCombativityRecoveryAfterStratagemFail), 100));
         }
     }
     return flag;
 }
Ejemplo n.º 2
0
        public bool GetCurrentStratagemSuccess(Troop troop, bool inevitableSuccess, bool invincible, bool lowerIntelligenceInvincible)
        {
            int num = 0;
            bool flag = false;
            if (!this.CurrentStratagem.Friendly)
            {
                if (invincible)
                {
                    flag = false;
                }
                else if (lowerIntelligenceInvincible && (this.TroopIntelligence < troop.TroopIntelligence))
                {
                    flag = false;
                }
                else if (inevitableSuccess && (this.TroopIntelligence > troop.TroopIntelligence))
                {
                    flag = true;
                }
                else
                {
                    num = ((((this.TroopIntelligence + this.StratagemChanceIncrement) + this.Leader.Calmness) - troop.TroopIntelligence) - troop.ChanceDecrementOfStratagem) - troop.Leader.Calmness;
                    int chance = this.CurrentStratagem.Chance + num;
                    flag = GameObject.Chance(chance);
                }
            }
            else
            {
                flag = GameObject.Chance(this.TroopIntelligence + this.StratagemChanceIncrement);
            }
            if (!this.CurrentStratagem.Friendly)
            {
                if (flag)
                {
                    if (this.OrientationTroop == troop)
                    {
                        this.WaitForDeepChaos = !troop.NeverBeIntoChaos && GameObject.Chance(this.ChaosAfterStratagemSuccessChance);
                        this.WaitForDeepChaosFrameCount = 100;
                    }
                    if (this.OnStratagemSuccess != null)
                    {
                        this.OnStratagemSuccess(this, troop, this.CurrentStratagem, true);
                    }

                    this.Persons.GetMaxIntelligencePerson().StratagemSuccessCount++;
                    troop.Persons.GetMaxIntelligencePerson().StratagemBeSuccessCount++;

                }
                else
                {
                    GameObjects.Animations.TileAnimation animation = base.Scenario.GeneratorOfTileAnimation.AddTileAnimation(TileAnimationKind.抵挡, troop.Position, false);
                    if (animation != null)
                    {
                        troop.TryToPlaySound(troop.Position, this.getSoundPath(animation.LinkedAnimation), false);
                    }
                    if (this.OnResistStratagem != null)
                    {
                        this.OnResistStratagem(this, troop, this.CurrentStratagem, true);
                    }

                    this.Persons.GetMaxIntelligencePerson().StratagemFailCount++;
                    troop.Persons.GetMaxIntelligencePerson().StratagemBeFailCount++;

                }
            }
            else if (flag)
            {
                if (((troop != null) && (this.OnStratagemSuccess != null)) && (this != troop))
                {
                    this.OnStratagemSuccess(this, troop, this.CurrentStratagem, false);
                }
                this.Persons.GetMaxIntelligencePerson().StratagemSuccessCount++;
            }
            else if ((troop != null) && (this.OnResistStratagem != null))
            {
                this.OnResistStratagem(this, troop, this.CurrentStratagem, false);
                this.Persons.GetMaxIntelligencePerson().StratagemFailCount++;
            }
            int increment = (2 + (flag ? 1 : 0)) + (this.WaitForDeepChaos ? 2 : 0);
            this.IncreaseStratagemExperience(increment, true);
            if (troop != null)
            {
                troop.IncreaseStratagemExperience(increment, false);
            }
            if (this.BelongedFaction != null)
            {
                if (flag)
                {
                    if (this.BelongedFaction.RateOfCombativityRecoveryAfterStratagemSuccess > 0f)
                    {
                        this.IncreaseCombativity(StaticMethods.GetRandomValue((int)((this.Leader.Calmness * 100) * this.BelongedFaction.RateOfCombativityRecoveryAfterStratagemSuccess), 100));
                    }
                    if (troop.BelongedFaction != this.BelongedFaction)
                    {
                        troop.army.Tiredness += this.stratagemTirednessIncrease;
                    }
                    if (this.stratagemStealTroop > 0 && troop.BelongedFaction != this.BelongedFaction)
                    {
                        int c = Math.Min(troop.Quantity, this.stratagemStealTroop);
                        troop.DecreaseQuantity(c);
                        this.IncreaseQuantity(c);
                        Troop.CheckTroopRout(this, troop);
                    }
                    if (this.stratagemStealInjury > 0 && troop.BelongedFaction != this.BelongedFaction)
                    {
                        int c = Math.Min(troop.InjuryQuantity, this.stratagemStealInjury);
                        troop.DecreaseInjuryQuantity(c);
                        this.IncreaseInjuryQuantity(c);
                    }
                    if (this.stratagemMoraleDecrease > 0 && troop.BelongedFaction != this.BelongedFaction)
                    {
                        troop.DecreaseMorale(this.stratagemMoraleDecrease);
                    }
                    if (this.stratagemCombativityDecrease > 0 && troop.BelongedFaction != this.BelongedFaction)
                    {
                        troop.DecreaseCombativity(this.stratagemCombativityDecrease);
                    }
                    if (this.stratagemTroopDecrease > 0 && troop.BelongedFaction != this.BelongedFaction)
                    {
                        troop.DecreaseQuantity(this.stratagemTroopDecrease);
                        Troop.CheckTroopRout(this, troop);
                    }
                    if (this.stratagemInjuryDecrease > 0 && troop.BelongedFaction != this.BelongedFaction)
                    {
                        troop.DecreaseInjuryQuantity(this.stratagemInjuryDecrease);
                    }
                    if (this.stratagemLoyaltyDecrease > 0 && troop.BelongedFaction != this.BelongedFaction)
                    {
                        foreach (Person p in troop.Persons)
                        {
                            p.Loyalty -= this.stratagemLoyaltyDecrease;
                            if (p.Loyalty < 0)
                            {
                                p.Loyalty = 0;
                            }
                        }
                    }
                    if (this.stratagemStealFood > 0 && troop.BelongedFaction != this.BelongedFaction)
                    {
                        int c = Math.Min(troop.Food, this.stratagemStealFood);
                        troop.Food -= c;
                        this.IncreaseFood(c);
                    }
                    return flag;
                }
                if (this.BelongedFaction.RateOfCombativityRecoveryAfterStratagemFail > 0f)
                {
                    this.IncreaseCombativity(StaticMethods.GetRandomValue((int)((this.Leader.Calmness * 100) * this.BelongedFaction.RateOfCombativityRecoveryAfterStratagemFail), 100));
                }
            }
            return flag;
        }