Exemplo n.º 1
0
        private void challengeHappen(TroopDamage damage, Person maxStrengthPerson, Person destination, int chance)
        {
            int flag = 0;

            //damage.ChallengeHappened = true;  //单挑发生
            if ((Setting.Current.GlobalVariables.ShowChallengeAnimation) &&                                                                                                                                                                                                   //Session.GlobalVariables.ShowChallengeAnimation
                (Session.Current.Scenario.IsPlayer(maxStrengthPerson.BelongedFaction) || Session.Current.Scenario.IsPlayer(destination.BelongedFaction) || (Session.GlobalVariables.SkyEye && !Session.GlobalVariables.SkyEyeSimpleNotification) || this.ChallengeOftenShow)) //单挑双方有玩家的武将才演示
            {
                try
                {
                    Session.MainGame.mainGameScreen.EnableUpdate = false;

                    challengeShow(damage, maxStrengthPerson, destination);

                    //int returnValue;
                    //returnValue = this.challengeShow(maxStrengthPerson, destination);
                    //returnValue = 10;

                    //if (returnValue >= -4 && returnValue <= 10 && returnValue != 0)
                    //{
                    //    flag = returnValue;
                    //}
                    //else   //返回值出错时避免跳出
                    //{
                    //    flag = (GameObject.Chance(chance) ? 1 : 2);
                    //}
                }
                catch
                {
                    flag = (GameObject.Chance(chance) ? 1 : 2);
                    damage.ChallengeHappened = true;  //单挑发生
                }
            }
            else
            {
                flag = (GameObject.Chance(chance) ? 1 : 2);
                damage.ChallengeHappened = true;  //单挑发生
            }

            //flag = -4;
            if (damage.ChallengeHappened)
            {
                damage.ChallengeResult            = flag;
                damage.ChallengeSourcePerson      = maxStrengthPerson;
                damage.ChallengeDestinationPerson = destination;
            }
        }
Exemplo n.º 2
0
        private void challengeShow(TroopDamage damage, Person maxStrengthPerson, Person destination)
        {
            bool LeftIsPlayer = Session.Current.Scenario.IsPlayer(maxStrengthPerson.BelongedFaction);

            DantiaoLayer.Persons = new List <Person>()
            {
                maxStrengthPerson,
                destination
            };

            damage.ChallengeStarted = true;

            Session.MainGame.mainGameScreen.cloudLayer.Reverse = true;

            Session.MainGame.mainGameScreen.cloudLayer.Start();

            Session.MainGame.mainGameScreen.dantiaoLayer = new DantiaoLayer(DantiaoLayer.Persons[DantiaoLayer.Persons.Count - 2], DantiaoLayer.Persons[DantiaoLayer.Persons.Count - 1], LeftIsPlayer);

            Session.MainGame.mainGameScreen.dantiaoLayer.damage = damage;

            //throw new NotImplementedException("跨平台單挑程序尚未實現!");

            /////////////////////////////////////////////////调用单挑程序
            //string fileName = @"Dantiao\start.exe";

            //string para = "";
            //para += this.challengePersonString(maxStrengthPerson);
            //para += this.challengePersonString(destination);

            //Process myProcess = new Process();
            //ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(fileName, para);
            //myProcess.StartInfo = myProcessStartInfo;
            //myProcess.Start();
            //while (!myProcess.HasExited)
            //{

            //    myProcess.WaitForExit();

            //}

            //return myProcess.ExitCode;
        }
Exemplo n.º 3
0
        private bool ChallengeOftenShow = false;  //暴击必然触发单挑,调试单挑程序用,默认为false


        internal void ChallgenEvent(Troop sourceTroop, Troop troop, TroopDamage damage, GameScenario gameScenario)
        {
            if ((!sourceTroop.IsFriendly(troop.BelongedFaction) && !sourceTroop.AirOffence) && (this.ChallengeOftenShow || GameObject.Chance(20)))
            {
                Person maxStrengthPerson = sourceTroop.Persons.GetMaxStrengthPerson();
                Person destination = troop.Persons.GetMaxStrengthPerson();
                if (((maxStrengthPerson != null) && (destination != null)) && (this.ChallengeOftenShow || (GameObject.Random(GameObject.Square(destination.Calmness)) < GameObject.Random(0x19))))
                {
                    if (maxStrengthPerson.IsCivil() || destination.IsCivil())  //文官不单挑
                    {
                        return;
                    }
                    int chance = Person.ChanlengeWinningChance(maxStrengthPerson, destination);
                    if (this.ChallengeOftenShow || (maxStrengthPerson.Character.ChallengeChance + chance) >= 60)
                    {
                        this.challengeHappen(damage, maxStrengthPerson, destination, chance, gameScenario);
                    }
                }
            }
        }
Exemplo n.º 4
0
        private bool ChallengeOftenShow = false;  //暴击必然触发单挑,调试单挑程序用,默认为false


        public void ChallgenEvent(Troop sourceTroop, Troop troop, TroopDamage damage)
        {
            if ((!sourceTroop.IsFriendly(troop.BelongedFaction) && !sourceTroop.AirOffence) && (this.ChallengeOftenShow || GameObject.Chance(20)))
            {
                Person maxStrengthPerson = sourceTroop.Persons.GetMaxStrengthPerson();
                Person destination       = troop.Persons.GetMaxStrengthPerson();
                if (((maxStrengthPerson != null) && (destination != null)) && (this.ChallengeOftenShow || (GameObject.Random(GameObject.Square(destination.Calmness)) < GameObject.Random(0x19))))
                {
                    if (maxStrengthPerson.IsCivil() || destination.IsCivil() || maxStrengthPerson.ID == 7108 || destination.ID == 7108)  //文官不单挑
                    {
                        return;
                    }
                    int chance = Person.ChanlengeWinningChance(maxStrengthPerson, destination);
                    if (this.ChallengeOftenShow || (maxStrengthPerson.Character.ChallengeChance + chance) >= 60)
                    {
                        this.challengeHappen(damage, maxStrengthPerson, destination, chance);
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void challengeHappen(TroopDamage damage, Person maxStrengthPerson, Person destination, int chance,GameScenario scenario)
        {
            int flag = 0;
            damage.ChallengeHappened = true;  //单挑发生
            if ((GlobalVariables.ShowChallengeAnimation) &&
                (scenario.IsPlayer(maxStrengthPerson.BelongedFaction) || scenario.IsPlayer(destination.BelongedFaction) || GlobalVariables.SkyEye || this.ChallengeOftenShow))  //单挑双方有玩家的武将才演示
            {
                try
                {
                    int returnValue;
                    returnValue = this.challengeShow(maxStrengthPerson, destination);
                    //returnValue = 10;
                    if (returnValue >= -4 && returnValue <= 10 && returnValue != 0)
                    {
                        flag = returnValue;
                    }
                    else   //返回值出错时避免跳出
                    {
                        flag = (GameObject.Chance(chance) ? 1 : 2);
                    }

                }
                catch
                {
                    flag = (GameObject.Chance(chance) ? 1 : 2);
                }
            }
            else
            {
                flag = (GameObject.Chance(chance) ? 1 : 2);
            }

            //flag = -4;

            damage.ChallengeResult = flag;
            damage.ChallengeSourcePerson = maxStrengthPerson;
            damage.ChallengeDestinationPerson = destination;

        }
Exemplo n.º 6
0
        private void challengeHappen(TroopDamage damage, Person maxStrengthPerson, Person destination, int chance, GameScenario scenario)
        {
            int flag = 0;

            damage.ChallengeHappened = true;                                                                                                                                   //单挑发生
            if ((GlobalVariables.ShowChallengeAnimation) &&
                (scenario.IsPlayer(maxStrengthPerson.BelongedFaction) || scenario.IsPlayer(destination.BelongedFaction) || GlobalVariables.SkyEye || this.ChallengeOftenShow)) //单挑双方有玩家的武将才演示
            {
                try
                {
                    int returnValue;
                    returnValue = this.challengeShow(maxStrengthPerson, destination);
                    //returnValue = 10;
                    if (returnValue >= -4 && returnValue <= 10 && returnValue != 0)
                    {
                        flag = returnValue;
                    }
                    else   //返回值出错时避免跳出
                    {
                        flag = (GameObject.Chance(chance) ? 1 : 2);
                    }
                }
                catch
                {
                    flag = (GameObject.Chance(chance) ? 1 : 2);
                }
            }
            else
            {
                flag = (GameObject.Chance(chance) ? 1 : 2);
            }

            //flag = -4;

            damage.ChallengeResult            = flag;
            damage.ChallengeSourcePerson      = maxStrengthPerson;
            damage.ChallengeDestinationPerson = destination;
        }
Exemplo n.º 7
0
        internal void HandleChallengeResult(TroopDamage damage, int result, Troop sourceTroop, Person sourcePerson, Troop destinationTroop, Person destinationPerson, GameScenario scenario)
        {
            scenario.GameScreen.TroopPersonChallenge(result, sourceTroop, sourcePerson, destinationTroop, destinationPerson);

            switch (result)
            {
                case 1: //P1武将胜利
                    sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson, "被打下馬");
                    damage.SourceMoraleChange += 20;
                    damage.DestinationMoraleChange -= 20;
                    damage.SourceCombativityChange += 20;
                    damage.DestinationCombativityChange -= 20;  //第2只军队战意下降
                    break;
                case 2: //2:P2武将胜利
                    sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, destinationPerson, sourcePerson, "被打下馬");
                    damage.SourceMoraleChange -= 20;
                    damage.DestinationMoraleChange += 20;
                    damage.SourceCombativityChange -= 20;
                    damage.DestinationCombativityChange += 20;
                    break;
                case 3: //3:P1武将被杀
                    sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, destinationPerson, sourcePerson, "被擊殺");
                    this.challengePersonDie(sourcePerson,sourceTroop, destinationPerson);
                    damage.SourceMoraleChange -= 30;
                    damage.DestinationMoraleChange += 30;
                    damage.SourceCombativityChange -= 30;
                    damage.DestinationCombativityChange += 30;
                    break;
                case 4: //4:P2武将被杀
                    sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson, "被擊殺");
                    this.challengePersonDie(destinationPerson, destinationTroop, sourcePerson);
                    damage.SourceMoraleChange += 30;
                    damage.DestinationMoraleChange -= 30;
                    damage.SourceCombativityChange += 30;
                    damage.DestinationCombativityChange -= 30;
                    break;
                case 5: //5:P1武将逃跑
                    sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, destinationPerson, sourcePerson, "逃跑");
                    damage.SourceMoraleChange -= 20;
                    damage.DestinationMoraleChange += 20;
                    break;
                case 6: //6:P2武将逃跑
                    sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson, "逃跑");
                    damage.SourceMoraleChange += 20;
                    damage.DestinationMoraleChange -= 20;
                    break;
                case 7: //7、P1武将被俘虏
                    sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, destinationPerson, sourcePerson, "被俘虜");
                    destinationTroop.CatchCaptiveFromTroop(sourcePerson);
                    sourceTroop.RefreshAfterLosePerson();
                    damage.SourceMoraleChange -= 20;
                    damage.DestinationMoraleChange += 20;
                    damage.SourceCombativityChange -= 20;
                    damage.DestinationCombativityChange += 20;
                    break;
                case 8: //8、P2武将被俘虏
                    sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson, "被俘虜");
                    sourceTroop.CatchCaptiveFromTroop(destinationPerson);
                    destinationTroop.RefreshAfterLosePerson();
                    damage.SourceMoraleChange += 20;
                    damage.DestinationMoraleChange -= 20;
                    damage.SourceCombativityChange += 20;
                    damage.DestinationCombativityChange -= 20; 
                    break;
                case 9: //9、P1武将被说服
                    sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, destinationPerson, sourcePerson, "被說服");
                    destinationPerson.ConvincePersonSuccess(sourcePerson);
                    damage.SourceCombativityChange -= 30;
                    damage.DestinationCombativityChange += 30;
                    break;
                case 10: //10、P2武将被说服
                    sourcePerson.Scenario.YearTable.addChallengeEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson, "被說服");
                    sourcePerson.ConvincePersonSuccess(destinationPerson);
                    damage.SourceCombativityChange += 30;
                    damage.DestinationCombativityChange -= 30; 
                    break;
                case -1: //-1:平局
                    sourcePerson.Scenario.YearTable.addChallengeDrawEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson);
                    break;
                case -2: //-2:平局:P1武将被杀
                    sourcePerson.Scenario.YearTable.addChallengeDrawKilledEntry(sourcePerson.Scenario.Date, destinationPerson, sourcePerson);
                    this.challengePersonDie(sourcePerson, sourceTroop, destinationPerson);
                    break;
                case -3: //-3:平局:P2武将被杀
                    sourcePerson.Scenario.YearTable.addChallengeDrawKilledEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson);
                    this.challengePersonDie(destinationPerson, destinationTroop, sourcePerson);
                    break;
                case -4: //-4:平局:双方武将被杀
                    sourcePerson.Scenario.YearTable.addChallengeDrawBothKilledEntry(sourcePerson.Scenario.Date, sourcePerson, destinationPerson);
                    this.challengePersonDie(sourcePerson, sourceTroop, destinationPerson);
                    this.challengePersonDie(destinationPerson, destinationTroop, sourcePerson);
                    break;
            }


        }
Exemplo n.º 8
0
        internal void StartAttackTroop(Troop troop, TroopDamage damage, bool area)
        {
            if (this.CombatMethodApplied)
            {
                if (this.OnCombatMethodAttack != null)
                {
                    if (this.CurrentCombatMethodID == 0)   // 如果是大盾
                    {
                        this.AddSelfzhanfaAnimation();
                    }
                    else
                    {
                        this.AddzhanfaAnimation(troop, true);
                    }
                    //this.OnCombatMethodAttack(this, troop, this.CurrentCombatMethod);
                }
            }



            if (!area)
            {
                if (!damage.Counter)
                {
                    if ((this.CombatMethodApplied && !damage.Surround) && (!damage.Critical || (this.Leader.PersonTextMessage.CriticalStrike.Count == 0)))
                    {
                        if (this.OnCombatMethodAttack != null)
                        {
                            /*if (this.CurrentCombatMethodID == 0)   // 如果是大盾
                            {
                                this.AddSelfzhanfaAnimation();
                            }
                            else
                            {
                                this.AddzhanfaAnimation(troop, true);
                            }*/
                            this.OnCombatMethodAttack(this, troop, this.CurrentCombatMethod);
                        }
                    }
                    else if (damage.Waylay)                      //这些if判断成立的话仅仅只添加了部队说话
                    {
                        if (this.OnWaylay != null)
                        {
                            this.OnWaylay(this, troop);
                        }
                    }
                    else if (damage.Critical)
                    {
                        if (this.OnCriticalStrike != null)
                        {
                            this.OnCriticalStrike(this, troop);
                        }
                    }
                    else if (damage.Surround)
                    {
                        if (this.OnSurround != null)
                        {
                            this.OnSurround(this, troop);
                        }
                    }
                    else if (this.OnNormalAttack != null)
                    {
                        this.OnNormalAttack(this, troop);
                    }
                }
                this.ResetDirectionTroop(troop);
                this.Action = TroopAction.Attack;
                if (this.PreAction == TroopPreAction.无 && !this.CombatMethodApplied)
                {
                    this.TryToPlaySound(this.Position, this.Army.Kind.Sounds.NormalAttackSoundPath, false);
                }

                this.AttackStarted = false;
            }
            troop.Action = TroopAction.BeAttacked;
            this.operationDone = true;
            if (troop == this.TargetTroop)
            {
               // this.MovabilityLeft = -1;
            }
            if (this.BaseAttackEveryAround || this.AttackEveryAround)
            {
                this.AttackedTroopList.Add(troop);
                this.OperationDone = false;
            }
            this.TroopDamageList.Add(damage);
        }
Exemplo n.º 9
0
        private TroopDamage SendAttackDamage(Troop troop, bool counter)
        {
            this.RecentlyFighting = 3;
            troop.RecentlyFighting = 3;
            TroopDamage damage = new TroopDamage();
            damage.SourceTroop = this;
            damage.DestinationTroop = troop;
            damage.Counter = counter;
            damage.AntiAttack = GameObject.Chance(troop.ChanceOfBlockAttack);
            damage.AntiArrowAttack = this.ArrowOffence && (troop.IsAntiArrowAttack || GameObject.Chance(troop.ChanceOfBlockArrowAttack));
            damage.AntiCounterAttack = !counter && this.IsAntiCounterAttack;
            damage.Critical = (!counter && !troop.OutburstPreventCriticalStrike) && (GameObject.Chance(this.ChanceOfMustCriticalStrike) || GameObject.Chance(this.CriticalStrikeChance - troop.AntiCriticalStrikeChance));
            damage.OnFire = GameObject.Chance((this.ChanceOfOnFire > this.BaseChanceOfOnFire) ? this.ChanceOfOnFire : this.BaseChanceOfOnFire);
            damage.Chaos = GameObject.Chance(this.ChanceOfChaosAttack);
            if (this.Status == TroopStatus.埋伏)
            {
                this.Status = TroopStatus.一般;
                damage.Waylay = true;
                if (!damage.Critical)
                {
                    this.PreAction = TroopPreAction.伏击;
                }
            }
            if (troop.Defence <= 0)
            {
                damage.Damage = troop.Quantity;
                return damage;
            }
            int defence = troop.Defence;
            if ((this.BaseDefenceConsidered > 0) && (this.DefenceConsidered > 0))
            {
                int num2 = (this.BaseDefenceConsidered < this.DefenceConsidered) ? this.BaseDefenceConsidered : this.DefenceConsidered;
                if (defence > num2)
                {
                    defence = num2;
                }
            }
            else if (this.BaseDefenceConsidered > 0)
            {
                if (defence > this.BaseDefenceConsidered)
                {
                    defence = this.BaseDefenceConsidered;
                }
            }
            else if (this.DefenceConsidered > 0)
            {
                if (defence > this.DefenceConsidered)
                {
                    defence = this.DefenceConsidered;
                }
            }
            else if (GameObject.Chance(this.ChanceOfFixDefenceAttack) && (defence > 100))
            {
                defence = 100;
            }
            damage.SourceOffence = this.Offence;
            if ((!troop.StuntAvoidSurround && !counter) && (this.StuntMustSurround || !GameObject.Chance(troop.AvoidSurroundedChance)))
            {
                TroopList surroundAttackingTroop = this.GetSurroundAttackingTroop(troop);
                if (surroundAttackingTroop.Count >= 3)
                {
                    int num3 = 0;
                    damage.Surround = true;
                    damage.DestinationMoraleChange -= 5 * ((surroundAttackingTroop.Count - 3) + 1);
                    troop.Effect = TroopEffect.被包围;
                    foreach (Troop troop2 in surroundAttackingTroop)
                    {
                        if (troop2 != this)
                        {
                            damage.SurroudingList.Add(troop2);
                            troop2.Surrounding = true;
                            damage.SourceOffence += StaticMethods.GetRandomValue(troop2.Offence, 4);
                            num3 += StaticMethods.GetRandomValue(troop2.ChaosAfterSurroundAttackChance, 2);
                        }
                    }
                    damage.Chaos = GameObject.Chance(this.ChaosAfterSurroundAttackChance + num3);
                }
            }
            int num4 = (int) (((damage.SourceOffence * 500) * Parameters.TroopDamageRate) / ((float) defence));
            switch (troop.Army.Kind.Type)
            {
                case MilitaryType.步兵:
                    num4 = (int) (num4 * this.OffenceRateOnSubdueBubing);
                    break;

                case MilitaryType.弩兵:
                    num4 = (int) (num4 * this.OffenceRateOnSubdueNubing);
                    break;

                case MilitaryType.骑兵:
                    num4 = (int) ((num4 * this.OffenceRateOnSubdueQibing) * ((this.RateOfQibingDamage > this.BaseRateOfQibingDamage) ? this.RateOfQibingDamage : this.BaseRateOfQibingDamage));
                    break;

                case MilitaryType.水军:
                    num4 = (int) (num4 * this.OffenceRateOnSubdueShuijun);
                    break;

                case MilitaryType.器械:
                    num4 = (int) (num4 * this.OffenceRateOnSubdueQixie);
                    break;
            }
            if (this.MoraleDownOfAttack > 0)
            {
                damage.DestinationMoraleChange -= this.MoraleDownOfAttack;
            }
            if (damage.OnFire)
            {
                int num5 = (int) ((troop.Army.Kind.MinScale * Parameters.FireDamageScale) * base.Scenario.GetTerrainDetailByPositionNoCheck(troop.Position).FireDamageRate);
                if (troop.AfraidOfFire)
                {
                    num5 *= 3;
                }
                if (troop.RateOfFireProtection > 0f)
                {
                    num5 = (int) (num5 * troop.RateOfFireProtection);
                }
                damage.FireDamage = num5;
            }
            if (damage.Critical)
            {
                this.PreAction = TroopPreAction.暴击;
                num4 = (int) ((num4 * 1.5f) * troop.RateOfCriticalDamageReceived);
                if (!(damage.Chaos || !GameObject.Chance(this.ChaosAfterCriticalStrikeChance)))
                {
                    damage.Chaos = true;
                }
                if (this.MoraleDecrementOfCriticalStrike > 0)
                {
                    damage.DestinationMoraleChange -= this.MoraleDecrementOfCriticalStrike;
                }
                if ((!this.IsFriendly(troop.BelongedFaction) && !this.AirOffence) && GameObject.Chance(20))
                {
                    Person maxStrengthPerson = this.Persons.GetMaxStrengthPerson();
                    Person destination = troop.Persons.GetMaxStrengthPerson();
                    if (((maxStrengthPerson != null) && (destination != null)) && (GameObject.Random(GameObject.Square(destination.Calmness)) < GameObject.Random(0x19)))
                    {
                        int chance = Person.ChanlengeWinningChance(maxStrengthPerson, destination);
                        if ((maxStrengthPerson.Character.ChallengeChance + chance) >= 60)
                        {
                            bool flag = GameObject.Chance(chance);
                            damage.ChallengeHappened = true;
                            damage.ChallengeResult = flag;
                            damage.ChallengeSourcePerson = maxStrengthPerson;
                            damage.ChallengeDestinationPerson = destination;
                            if (flag)
                            {
                                damage.SourceMoraleChange += 20;
                                damage.DestinationMoraleChange -= 20;
                            }
                            else
                            {
                                damage.SourceMoraleChange -= 20;
                                damage.DestinationMoraleChange += 20;
                            }
                        }
                    }
                }
            }
            if (damage.Waylay)
            {
                damage.DestinationMoraleChange -= 10;
                if (troop.NeverBeIntoChaosWhileWaylay)
                {
                    damage.Chaos = false;
                }
                else if (!this.Army.Kind.AirOffence)
                {
                    damage.Chaos = this.InevitableChaosOnWaylay || GameObject.Chance(30);
                }
            }
            if (damage.Counter)
            {
                num4 = (int) (num4 * 0.5f);
            }
            if (!(counter || (this.AttackDecrementOfCombativity <= 0)))
            {
                damage.CombativityDown += this.AttackDecrementOfCombativity;
            }
            if (counter && (this.CounterAttackDecrementOfCombativity > 0))
            {
                damage.CounterCombativityDown += this.CounterAttackDecrementOfCombativity;
            }
            if (!troop.HasCombatTitle)
            {
                if (this.CombativityDecrementOnPower > 0)
                {
                    damage.CombativityDown += this.CombativityDecrementOnPower;
                }
                if (this.MoraleDecrementOnPrestige > 0)
                {
                    damage.DestinationMoraleChange -= this.MoraleDecrementOnPrestige;
                }
            }
            if (GameObject.Chance(this.ChanceOfTrippleDamage))
            {
                num4 *= 3;
            }
            else if (GameObject.Chance(this.ChanceOfDoubleDamage))
            {
                num4 *= 2;
            }
            if (GameObject.Chance(troop.ChanceOfHalfDamage))
            {
                num4 /= 2;
            }
            damage.Damage = num4;
            return damage;
        }
Exemplo n.º 10
0
        private TroopDamage ReceiveAttackDamage(TroopDamage receivedDamage)
        {
            int damage = receivedDamage.Damage;
            if (receivedDamage.SourceTroop.Army.Kind.ArrowOffence)
            {
                damage = (int) (damage * this.DefenceRateOnSubdueNubing);
            }
            else
            {
                switch (receivedDamage.SourceTroop.Army.Kind.Type)
                {
                    case MilitaryType.步兵:
                        damage = (int) (damage * this.DefenceRateOnSubdueBubing);
                        break;

                    case MilitaryType.弩兵:
                        damage = (int) (damage * this.DefenceRateOnSubdueNubing);
                        break;

                    case MilitaryType.骑兵:
                        damage = (int) (damage * this.DefenceRateOnSubdueQibing);
                        break;

                    case MilitaryType.水军:
                        damage = (int) (damage * this.DefenceRateOnSubdueShuijun);
                        break;

                    case MilitaryType.器械:
                        damage = (int) (damage * this.DefenceRateOnSubdueQixie);
                        break;

                    case MilitaryType.其他:
                        break;
                }
            }
        Label_00AC:
            receivedDamage.Damage = damage;
            if (receivedDamage.Damage > this.Quantity)
            {
                receivedDamage.Damage = this.Quantity;
            }
            if (receivedDamage.Damage <= 0)
            {
                receivedDamage.Damage = 1;
            }
            receivedDamage.Injury = ((damage + receivedDamage.FireDamage) * this.InjuryChance) / 100;
            if (receivedDamage.Critical && (receivedDamage.SourceTroop.RateOfInjuryOnCriticalStrike < 1f))
            {
                receivedDamage.Injury = (int) (receivedDamage.Injury * receivedDamage.SourceTroop.RateOfInjuryOnCriticalStrike);
            }
            if (receivedDamage.Injury > receivedDamage.DestinationTroop.Quantity)
            {
                receivedDamage.Injury = receivedDamage.DestinationTroop.Quantity;
            }
            return receivedDamage;
        }
Exemplo n.º 11
0
 private void HandleTroopDamage(TroopDamage damage)
 {
     GameObjects.Animations.TileAnimation animation;
     if (damage.Surround)
     {
         damage.DestinationTroop.Effect = TroopEffect.无;
         foreach (Troop troop in damage.SurroudingList)
         {
             troop.Surrounding = false;
         }
     }
     int num = (((((2 + (damage.AntiArrowAttack ? 1 : 0)) + (damage.Critical ? 1 : 0)) + (damage.Chaos ? 1 : 0)) + (damage.OnFire ? 1 : 0)) + (damage.Waylay ? 1 : 0)) + (damage.SourceTroop.CombatMethodApplied ? 1 : 0);
     damage.SourceTroop.IncreaseAttackExperience(num * 2);
     damage.DestinationTroop.IncreaseBeAttackedExperience(num * 2);
     if (damage.AntiAttack)
     {
         animation = base.Scenario.GeneratorOfTileAnimation.AddTileAnimation(TileAnimationKind.抵挡, damage.DestinationTroop.Position, false);
         if (animation != null)
         {
             damage.DestinationTroop.TryToPlaySound(damage.DestinationTroop.Position, animation.LinkedAnimation.SoundPath, false);
         }
         if (this.OnAntiAttack != null)
         {
             this.OnAntiAttack(damage.SourceTroop, damage.DestinationTroop);
         }
     }
     else if (damage.AntiArrowAttack)
     {
         animation = base.Scenario.GeneratorOfTileAnimation.AddTileAnimation(TileAnimationKind.抵挡, damage.DestinationTroop.Position, false);
         if (animation != null)
         {
             damage.DestinationTroop.TryToPlaySound(damage.DestinationTroop.Position, animation.LinkedAnimation.SoundPath, false);
         }
         if (this.OnAntiArrowAttack != null)
         {
             this.OnAntiArrowAttack(damage.SourceTroop, damage.DestinationTroop);
         }
     }
     else
     {
         if (damage.OnFire && base.Scenario.IsFireVaild(damage.DestinationTroop.Position, false, MilitaryType.步兵))
         {
             base.Scenario.SetPositionOnFire(damage.DestinationTroop.Position);
         }
         if ((damage.SourceTroop.StuntDayDecrementOfAttack > 0) && (damage.DestinationTroop.StuntDayLeft > 0))
         {
             damage.DestinationTroop.StuntDayLeft -= damage.SourceTroop.StuntDayDecrementOfAttack;
             if (damage.DestinationTroop.StuntDayLeft < 1)
             {
                 damage.DestinationTroop.StuntDayLeft = 1;
             }
         }
         if (!damage.SourceTroop.Destroyed && !damage.DestinationTroop.Destroyed)
         {
             if (!damage.SourceTroop.MoraleNoChanceAfterAttacked)
             {
                 damage.SourceTroop.ChangeMorale(damage.SourceMoraleChange);
                 CheckTroopRout(damage.SourceTroop);
             }
             damage.DestinationTroop.DecreaseQuantity(damage.Damage);
             if (damage.OnFire)
             {
                 damage.DestinationTroop.DecreaseQuantity(damage.FireDamage);
             }
             damage.DestinationTroop.IncreaseInjuryQuantity(damage.Injury);
             if (!damage.DestinationTroop.CombativityNoChanceAfterAttacked)
             {
                 damage.DestinationTroop.DecreaseCombativity(damage.CombativityDown);
             }
             if (!damage.DestinationTroop.MoraleNoChanceAfterAttacked)
             {
                 damage.DestinationTroop.ChangeMorale(damage.DestinationMoraleChange);
             }
             if (!damage.SourceTroop.Destroyed)
             {
                 CheckTroopRout(damage.SourceTroop, damage.DestinationTroop);
             }
             else
             {
                 CheckTroopRout(damage.DestinationTroop);
             }
             if (!damage.DestinationTroop.Destroyed)
             {
                 if ((damage.DestinationTroop.BelongedFaction != null) && (damage.DestinationTroop.BelongedFaction.RateOfCombativityRecoveryAfterAttacked > 0f))
                 {
                     damage.DestinationTroop.IncreaseCombativity(StaticMethods.GetRandomValue((int) ((damage.DestinationTroop.Leader.Braveness * 100) * damage.DestinationTroop.BelongedFaction.RateOfCombativityRecoveryAfterAttacked), 100));
                 }
                 if (damage.BeCountered && !damage.SourceTroop.Destroyed)
                 {
                     damage.SourceTroop.DecreaseQuantity(damage.CounterDamage);
                     damage.SourceTroop.IncreaseInjuryQuantity(damage.CounterInjury);
                     if (!damage.SourceTroop.CombativityNoChanceAfterAttacked)
                     {
                         damage.SourceTroop.DecreaseCombativity(damage.CounterCombativityDown);
                     }
                     CheckTroopRout(damage.DestinationTroop, damage.SourceTroop);
                 }
                 if (damage.ChallengeHappened)
                 {
                     this.CurrentSourceChallengePerson = damage.ChallengeSourcePerson;
                     this.CurrentDestinationChallengePerson = damage.ChallengeDestinationPerson;
                     if (this.OnPersonChallenge != null)
                     {
                         this.OnPersonChallenge(damage.ChallengeResult, damage.SourceTroop, this.CurrentSourceChallengePerson, damage.DestinationTroop, this.CurrentDestinationChallengePerson);
                     }
                 }
                 if (!damage.SourceTroop.Destroyed)
                 {
                     if (damage.Waylay)
                     {
                         damage.DestinationTroop.OperationDone = true;
                         damage.DestinationTroop.MovabilityLeft = -1;
                         if (this.OnReceiveWaylay != null)
                         {
                             this.OnReceiveWaylay(damage.SourceTroop, damage.DestinationTroop);
                         }
                     }
                     if (damage.Critical && (!damage.Waylay && (this.OnReceiveCriticalStrike != null)))
                     {
                         this.OnReceiveCriticalStrike(damage.SourceTroop, damage.DestinationTroop);
                     }
                     if (damage.Chaos)
                     {
                         damage.DestinationTroop.SetChaos(damage.SourceTroop.GenerateAttackChaosDay(2));
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 12
0
        private TroopDamage SendAttackDamage(Troop troop, bool counter)
        {
            this.RecentlyFighting = 3;
            troop.RecentlyFighting = 3;
            TroopDamage damage = new TroopDamage();
            damage.SourceTroop = this;
            damage.DestinationTroop = troop;
            damage.Counter = counter;
            damage.AntiAttack = GameObject.Chance(troop.ChanceOfBlockAttack);
            damage.AntiArrowAttack = this.ArrowOffence && (troop.IsAntiArrowAttack || GameObject.Chance(troop.ChanceOfBlockArrowAttack));
            damage.AntiCounterAttack = !counter && this.IsAntiCounterAttack;
            damage.Critical = (!counter && !troop.OutburstPreventCriticalStrike) && (GameObject.Chance(this.ChanceOfMustCriticalStrike) || GameObject.Chance(this.CriticalStrikeChance - troop.AntiCriticalStrikeChance));
            damage.OnFire = GameObject.Chance((this.ChanceOfOnFire > this.BaseChanceOfOnFire) ? this.ChanceOfOnFire : this.BaseChanceOfOnFire);
            damage.Chaos = GameObject.Chance(this.ChanceOfChaosAttack);
            if (this.Status == TroopStatus.埋伏)
            {
                this.Status = TroopStatus.一般;
                damage.Waylay = true;
                if (!damage.Critical)
                {
                    this.PreAction = TroopPreAction.伏击;
                }
            }
            if (troop.Defence <= 0)
            {
                damage.Damage = troop.Quantity;
                return damage;
            }
            int defence = troop.Defence;
            if ((this.BaseDefenceConsidered > 0) && (this.DefenceConsidered > 0))
            {
                int num2 = (this.BaseDefenceConsidered < this.DefenceConsidered) ? this.BaseDefenceConsidered : this.DefenceConsidered;
                if (defence > num2)
                {
                    defence = num2;
                }
            }
            else if (this.BaseDefenceConsidered > 0)
            {
                if (defence > this.BaseDefenceConsidered)
                {
                    defence = this.BaseDefenceConsidered;
                }
            }
            else if (this.DefenceConsidered > 0)
            {
                if (defence > this.DefenceConsidered)
                {
                    defence = this.DefenceConsidered;
                }
            }
            else if (GameObject.Chance(this.ChanceOfFixDefenceAttack) && (defence > 100))
            {
                defence = 100;
            }
            damage.SourceOffence = this.Offence;
            if ((!troop.StuntAvoidSurround && !counter) && (this.StuntMustSurround || !GameObject.Chance(troop.AvoidSurroundedChance)))
            {
                TroopList surroundAttackingTroop = this.GetSurroundAttackingTroop(troop);
                if (surroundAttackingTroop.Count >= 3)
                {
                    int num3 = 0;
                    damage.Surround = true;
                    damage.DestinationMoraleChange -= GlobalVariables.SurroundFactor * ((surroundAttackingTroop.Count - 3) + 1);
                    troop.Effect = TroopEffect.被包围;
                    foreach (Troop troop2 in surroundAttackingTroop)
                    {
                        if (troop2 != this)
                        {
                            damage.SurroudingList.Add(troop2);
                            troop2.Surrounding = true;
                            damage.SourceOffence += StaticMethods.GetRandomValue(troop2.Offence, GlobalVariables.SurroundFactor * 4 / 5);
                            num3 += StaticMethods.GetRandomValue(troop2.ChaosAfterSurroundAttackChance, GlobalVariables.SurroundFactor * 2 / 5);
                        }
                    }
                    damage.Chaos = GameObject.Chance(this.ChaosAfterSurroundAttackChance + num3);
                }
            }
            //int num4 = (int) (((damage.SourceOffence * 500) * Parameters.TroopDamageRate) / ((float) defence));
            int num4 = (int)(Math.Pow(damage.SourceOffence / (float)defence, 0.62) * 1.16 * 500 * Parameters.TroopDamageRate);
            switch (troop.Army.Kind.Type)
            {
                case MilitaryType.步兵:
                    num4 = (int)(num4 * this.OffenceRateOnSubdueBubing);
                    break;

                case MilitaryType.弩兵:
                    num4 = (int)(num4 * this.OffenceRateOnSubdueNubing);
                    break;

                case MilitaryType.骑兵:
                    num4 = (int)((num4 * this.OffenceRateOnSubdueQibing) * ((this.RateOfQibingDamage > this.BaseRateOfQibingDamage) ? this.RateOfQibingDamage : this.BaseRateOfQibingDamage));
                    break;

                case MilitaryType.水军:
                    num4 = (int)(num4 * this.OffenceRateOnSubdueShuijun);
                    break;

                case MilitaryType.器械:
                    num4 = (int)(num4 * this.OffenceRateOnSubdueQixie);
                    break;
            }
            if (this.MoraleDownOfAttack > 0)
            {
                damage.DestinationMoraleChange -= this.MoraleDownOfAttack;
            }
            if (damage.OnFire)
            {
                int num5 = (int)((troop.Army.Kind.MinScale * Parameters.FireDamageScale) * base.Scenario.GetTerrainDetailByPositionNoCheck(troop.Position).FireDamageRate);
                num5 = (int)(num5 * this.FireDamageRate);
                if (troop.RateOfFireProtection > 0f)
                {
                    num5 = (int)(num5 * troop.RateOfFireProtection);
                }
                damage.FireDamage = num5;
            }
            damage.InjuredDamage = (int)(this.reduceInjuredOnAttack * damage.DestinationTroop.Army.Kind.MinScale);
            damage.TirednessIncrease = this.TirednessIncreaseOnAttack;
            damage.StealFood = Math.Min(damage.DestinationTroop.Food, this.StealFood);
            if (damage.Critical) //控制单挑发生相关
            {
                this.PreAction = TroopPreAction.暴击;
                num4 = (int)((num4 * 1.5f) * troop.RateOfCriticalDamageReceived);
                if (!(damage.Chaos || !GameObject.Chance(this.ChaosAfterCriticalStrikeChance)))
                {
                    damage.Chaos = true;
                }
                if (this.MoraleDecrementOfCriticalStrike > 0)
                {
                    damage.DestinationMoraleChange -= this.MoraleDecrementOfCriticalStrike;
                }
                Challenge challenge = new Challenge();
                challenge.ChallgenEvent(this, troop, damage, base.Scenario);  //单挑事件
                damage.InjuredDamage += (int)(this.reduceInjuredOnCritical * damage.DestinationTroop.Army.Kind.MinScale);
                damage.TirednessIncrease += this.TirednessIncreaseOnCritical;
            }
            if (damage.Waylay)
            {
                damage.DestinationMoraleChange -= 10;
                if (troop.NeverBeIntoChaosWhileWaylay)
                {
                    damage.Chaos = false;
                }
                else if (!this.Army.Kind.AirOffence)
                {
                    damage.Chaos = this.InevitableChaosOnWaylay || GameObject.Chance(30);
                }
            }
            if (damage.Counter)
            {
                num4 = (int)(num4 * 0.5f);
            }
            if (!(counter || (this.AttackDecrementOfCombativity <= 0)))
            {
                damage.DestinationCombativityChange -= this.AttackDecrementOfCombativity;
            }
            if (counter && (this.CounterAttackDecrementOfCombativity > 0))
            {
                damage.CounterCombativityDown += this.CounterAttackDecrementOfCombativity;
            }
            if (!troop.HasCombatTitle)
            {
                if (this.CombativityDecrementOnPower > 0)
                {
                    damage.DestinationCombativityChange -= this.CombativityDecrementOnPower;
                }
                if (this.MoraleDecrementOnPrestige > 0)
                {
                    damage.DestinationMoraleChange -= this.MoraleDecrementOnPrestige;
                }
            }
            if (GameObject.Chance(this.ChanceOfTrippleDamage))
            {
                num4 *= 3;
            }
            else if (GameObject.Chance(this.ChanceOfDoubleDamage))
            {
                num4 *= 2;
            }
            if (GameObject.Chance(troop.ChanceOfHalfDamage))
            {
                num4 /= 2;
            }
            damage.Damage = num4;
            damage.StealTroop = Math.Min(damage.DestinationTroop.Quantity, (int)(damage.Damage * this.StealTroop));
            damage.StealInjured = Math.Min(damage.DestinationTroop.InjuryQuantity, (int)(damage.Damage * this.StealInjured));
            damage.OfficerInjury = 0;
            if ((damage.Critical || troop.Quantity <= damage.Damage) && damage.Damage > 0 && GlobalVariables.OfficerDieInBattleRate > 0)
            {
                float dieChance = GlobalVariables.OfficerDieInBattleRate / 10000.0f;
                if (troop.Quantity <= damage.Damage)
                {
                    dieChance *= 2;
                }
                if (damage.Surround)
                {
                    dieChance *= 1.5f;
                }
                if (damage.Waylay)
                {
                    dieChance *= 3;
                }
                dieChance *= (damage.SourceTroop.Leader.Strength + damage.SourceTroop.Leader.Braveness * 10
                    - damage.DestinationTroop.Leader.Strength - damage.DestinationTroop.Leader.Braveness * 10 + 100) / 100.0f;
                double rand = GameObject.Random(100000) / 100000.0;
                damage.OfficerInjury = (float) (dieChance / rand);
                if (damage.OfficerInjury < 0.1)
                {
                    damage.OfficerInjury = 0;
                }
            }
            ExtensionInterface.call("TroopSendTroopDamage", new Object[] { this.Scenario, this, damage, troop, counter });
            return damage;
        }
Exemplo n.º 13
0
        private void HandleTroopDamage(TroopDamage damage)
        {
            GameObjects.Animations.TileAnimation animation;
            if (damage.Surround)
            {
                damage.DestinationTroop.Effect = TroopEffect.无;
                foreach (Troop troop in damage.SurroudingList)
                {
                    troop.Surrounding = false;
                }
            }
            int num = (((((2 + (damage.AntiArrowAttack ? 1 : 0)) + (damage.Critical ? 1 : 0)) + (damage.Chaos ? 1 : 0)) + (damage.OnFire ? 1 : 0)) + (damage.Waylay ? 1 : 0)) + (damage.SourceTroop.CombatMethodApplied ? 1 : 0);
            damage.SourceTroop.IncreaseAttackExperience(num * 2);
            damage.DestinationTroop.IncreaseBeAttackedExperience(num * 2);

            damage.SourceTroop.Leader.TroopDamageDealt += damage.Damage;
            damage.DestinationTroop.Leader.TroopBeDamageDealt += damage.Damage;



            if (damage.AntiAttack)
            {
                animation = base.Scenario.GeneratorOfTileAnimation.AddTileAnimation(TileAnimationKind.抵挡, damage.DestinationTroop.Position, false);
                if (animation != null)
                {
                    damage.DestinationTroop.TryToPlaySound(damage.DestinationTroop.Position, this.getSoundPath(animation.LinkedAnimation), false);
                }
                if (this.OnAntiAttack != null)
                {
                    this.OnAntiAttack(damage.SourceTroop, damage.DestinationTroop);
                }
            }
            else if (damage.AntiArrowAttack)
            {
                animation = base.Scenario.GeneratorOfTileAnimation.AddTileAnimation(TileAnimationKind.抵挡, damage.DestinationTroop.Position, false);
                if (animation != null)
                {
                    damage.DestinationTroop.TryToPlaySound(damage.DestinationTroop.Position, this.getSoundPath(animation.LinkedAnimation), false);
                }
                if (this.OnAntiArrowAttack != null)
                {
                    this.OnAntiArrowAttack(damage.SourceTroop, damage.DestinationTroop);
                }
            }
            else
            {
                if (damage.ChallengeHappened)  //处理单挑结果
                {
                    /*
                    this.CurrentSourceChallengePerson = damage.ChallengeSourcePerson;
                    this.CurrentDestinationChallengePerson = damage.ChallengeDestinationPerson;
                    if (this.OnPersonChallenge != null)
                    {
                        this.OnPersonChallenge(damage.ChallengeResult, damage.SourceTroop, this.CurrentSourceChallengePerson, damage.DestinationTroop, this.CurrentDestinationChallengePerson);
                    }
                    */
                    Challenge challeng = new Challenge();
                    challeng.HandleChallengeResult(damage, damage.ChallengeResult, damage.SourceTroop, damage.ChallengeSourcePerson, damage.DestinationTroop, damage.ChallengeDestinationPerson, base.Scenario);
                }
                if (damage.OfficerInjury > 0 && !damage.DestinationTroop.ImmunityOfDieInBattle)
                {
                    int c = GameObject.Random(damage.DestinationTroop.Persons.Count);
                    Person toInjure = damage.DestinationTroop.Persons[c] as Person;
                    toInjure.InjureRate -= damage.OfficerInjury;
                    if (toInjure.InjureRate < 0.05)
                    {
                        if (damage.DestinationTroop == damage.DestinationTroop.StartingArchitecture.RobberTroop)
                        {
                            damage.DestinationTroop.Persons.Remove(damage.DestinationTroop.Leader);
                            damage.DestinationTroop.Leader.LocationTroop = null;
                        }
                        else
                        {
                            if (!toInjure.ImmunityOfDieInBattle)
                            {
                                toInjure.KilledInBattle(damage.SourceTroop);
                            }
                        }
                    }
                }


                if (damage.OnFire && base.Scenario.IsFireVaild(damage.DestinationTroop.Position, false, MilitaryType.步兵))
                {
                    base.Scenario.SetPositionOnFire(damage.DestinationTroop.Position);
                }
                if ((damage.SourceTroop.StuntDayDecrementOfAttack > 0) && (damage.DestinationTroop.StuntDayLeft > 0))
                {
                    damage.DestinationTroop.StuntDayLeft -= damage.SourceTroop.StuntDayDecrementOfAttack;
                    if (damage.DestinationTroop.StuntDayLeft < 1)
                    {
                        damage.DestinationTroop.StuntDayLeft = 1;
                    }
                }
                if (!damage.SourceTroop.Destroyed && !damage.DestinationTroop.Destroyed)
                {
                    if (!damage.SourceTroop.MoraleNoChanceAfterAttacked)
                    {
                        damage.SourceTroop.ChangeMorale(damage.SourceMoraleChange);
                        CheckTroopRout(damage.SourceTroop);
                    }
                    if (!damage.SourceTroop.CombativityNoChanceAfterAttacked)
                    {
                        damage.SourceTroop.ChangeCombativity(damage.SourceCombativityChange);
                    }
                    /////////////////////////////////////////////////////////////////////
                    damage.DestinationTroop.DecreaseQuantity(damage.Damage);
                    if (damage.OnFire)
                    {
                        damage.DestinationTroop.DecreaseQuantity(damage.FireDamage);
                    }
                    damage.DestinationTroop.IncreaseInjuryQuantity(damage.Injury);
                    if (!damage.DestinationTroop.CombativityNoChanceAfterAttacked)
                    {
                        damage.DestinationTroop.ChangeCombativity(damage.DestinationCombativityChange);
                    }
                    if (!damage.DestinationTroop.MoraleNoChanceAfterAttacked)
                    {
                        damage.DestinationTroop.ChangeMorale(damage.DestinationMoraleChange);
                    }
                    damage.DestinationTroop.DecreaseInjuryQuantity(damage.InjuredDamage);
                    //////////////////////////////////////////////////////////////////////////////////
                    damage.SourceTroop.IncreaseQuantity(damage.StealTroop);
                    //damage.DestinationTroop.DecreaseQuantity(damage.StealTroop);
                    damage.SourceTroop.InjuryQuantity += damage.StealInjured;
                    //damage.DestinationTroop.DecreaseInjuryQuantity(damage.StealInjured);
                    ///////////////////////////////////////////////////////////////////////////////////
                    damage.DestinationTroop.Army.Tiredness += damage.TirednessIncrease;
                    damage.DestinationTroop.Food -= damage.StealFood;
                    damage.SourceTroop.IncreaseFood(damage.StealFood);
                    foreach (Person p in damage.DestinationTroop.Persons)
                    {
                        p.Tiredness += damage.TirednessIncrease;
                    }
                    if (!damage.SourceTroop.Destroyed)
                    {
                        CheckTroopRout(damage.SourceTroop, damage.DestinationTroop);
                    }
                    else
                    {
                        CheckTroopRout(damage.DestinationTroop);
                    }
                    if (!damage.DestinationTroop.Destroyed)
                    {
                        if ((damage.DestinationTroop.BelongedFaction != null) && (damage.DestinationTroop.BelongedFaction.RateOfCombativityRecoveryAfterAttacked > 0f))
                        {
                            damage.DestinationTroop.IncreaseCombativity(StaticMethods.GetRandomValue((int)((damage.DestinationTroop.Leader.Braveness * 100) * damage.DestinationTroop.BelongedFaction.RateOfCombativityRecoveryAfterAttacked), 100));
                        }
                        if (damage.BeCountered && !damage.SourceTroop.Destroyed)
                        {
                            damage.SourceTroop.DecreaseQuantity(damage.CounterDamage);
                            damage.SourceTroop.IncreaseInjuryQuantity(damage.CounterInjury);
                            if (!damage.SourceTroop.CombativityNoChanceAfterAttacked)
                            {
                                damage.SourceTroop.DecreaseCombativity(damage.CounterCombativityDown);
                            }
                            CheckTroopRout(damage.DestinationTroop, damage.SourceTroop);
                        }

                        //原来的单挑结果处理位置。因为必须在部队毁灭前处理人物,所以把代码上移。


                        if (!damage.SourceTroop.Destroyed)
                        {
                            if (damage.Waylay)
                            {
                                damage.DestinationTroop.OperationDone = true;
                                damage.DestinationTroop.MovabilityLeft = -1;
                                if (this.OnReceiveWaylay != null)
                                {
                                    this.OnReceiveWaylay(damage.SourceTroop, damage.DestinationTroop);
                                }
                            }
                            if (damage.Critical && (!damage.Waylay && (this.OnReceiveCriticalStrike != null)))
                            {
                                this.OnReceiveCriticalStrike(damage.SourceTroop, damage.DestinationTroop);
                            }
                            if (damage.Chaos)
                            {
                                damage.DestinationTroop.SetChaos(damage.SourceTroop.GenerateAttackChaosDay(2));
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
        public void HandleChallengeResult(TroopDamage damage, int result, Troop sourceTroop, Person sourcePerson, Troop destinationTroop, Person destinationPerson)
        {
            Session.MainGame.mainGameScreen.TroopPersonChallenge(result, sourceTroop, sourcePerson, destinationTroop, destinationPerson);

            switch (result)
            {
            case 1:     //P1武将胜利
                Session.Current.Scenario.YearTable.addChallengeEntry(Session.Current.Scenario.Date, sourcePerson, destinationPerson, "被打下馬");
                damage.SourceMoraleChange           += 20;
                damage.DestinationMoraleChange      -= 20;
                damage.SourceCombativityChange      += 20;
                damage.DestinationCombativityChange -= 20;      //第2只军队战意下降
                break;

            case 2:     //2:P2武将胜利
                Session.Current.Scenario.YearTable.addChallengeEntry(Session.Current.Scenario.Date, destinationPerson, sourcePerson, "被打下馬");
                damage.SourceMoraleChange           -= 20;
                damage.DestinationMoraleChange      += 20;
                damage.SourceCombativityChange      -= 20;
                damage.DestinationCombativityChange += 20;
                break;

            case 3:     //3:P1武将被杀
                Session.Current.Scenario.YearTable.addChallengeEntry(Session.Current.Scenario.Date, destinationPerson, sourcePerson, "被擊殺");
                this.challengePersonDie(sourcePerson, sourceTroop, destinationPerson);
                damage.SourceMoraleChange           -= 30;
                damage.DestinationMoraleChange      += 30;
                damage.SourceCombativityChange      -= 30;
                damage.DestinationCombativityChange += 30;
                break;

            case 4:     //4:P2武将被杀
                Session.Current.Scenario.YearTable.addChallengeEntry(Session.Current.Scenario.Date, sourcePerson, destinationPerson, "被擊殺");
                this.challengePersonDie(destinationPerson, destinationTroop, sourcePerson);
                damage.SourceMoraleChange           += 30;
                damage.DestinationMoraleChange      -= 30;
                damage.SourceCombativityChange      += 30;
                damage.DestinationCombativityChange -= 30;
                break;

            case 5:     //5:P1武将逃跑
                Session.Current.Scenario.YearTable.addChallengeEntry(Session.Current.Scenario.Date, destinationPerson, sourcePerson, "逃跑");
                damage.SourceMoraleChange      -= 20;
                damage.DestinationMoraleChange += 20;
                break;

            case 6:     //6:P2武将逃跑
                Session.Current.Scenario.YearTable.addChallengeEntry(Session.Current.Scenario.Date, sourcePerson, destinationPerson, "逃跑");
                damage.SourceMoraleChange      += 20;
                damage.DestinationMoraleChange -= 20;
                break;

            case 7:     //7、P1武将被俘虏
                Session.Current.Scenario.YearTable.addChallengeEntry(Session.Current.Scenario.Date, destinationPerson, sourcePerson, "被俘虜");
                destinationTroop.CatchCaptiveFromTroop(sourcePerson);
                sourceTroop.RefreshAfterLosePerson();
                damage.SourceMoraleChange           -= 20;
                damage.DestinationMoraleChange      += 20;
                damage.SourceCombativityChange      -= 20;
                damage.DestinationCombativityChange += 20;
                break;

            case 8:     //8、P2武将被俘虏
                Session.Current.Scenario.YearTable.addChallengeEntry(Session.Current.Scenario.Date, sourcePerson, destinationPerson, "被俘虜");
                sourceTroop.CatchCaptiveFromTroop(destinationPerson);
                destinationTroop.RefreshAfterLosePerson();
                damage.SourceMoraleChange           += 20;
                damage.DestinationMoraleChange      -= 20;
                damage.SourceCombativityChange      += 20;
                damage.DestinationCombativityChange -= 20;
                break;

            case 9:     //9、P1武将被说服
                Session.Current.Scenario.YearTable.addChallengeEntry(Session.Current.Scenario.Date, destinationPerson, sourcePerson, "被说服");
                destinationPerson.ConvincePersonSuccess(sourcePerson);
                damage.SourceCombativityChange      -= 30;
                damage.DestinationCombativityChange += 30;
                break;

            case 10:     //10、P2武将被说服
                Session.Current.Scenario.YearTable.addChallengeEntry(Session.Current.Scenario.Date, sourcePerson, destinationPerson, "被说服");
                sourcePerson.ConvincePersonSuccess(destinationPerson);
                damage.SourceCombativityChange      += 30;
                damage.DestinationCombativityChange -= 30;
                break;

            case -1:     //-1:平局
                Session.Current.Scenario.YearTable.addChallengeDrawEntry(Session.Current.Scenario.Date, sourcePerson, destinationPerson);
                break;

            case -2:     //-2:平局:P1武将被杀
                Session.Current.Scenario.YearTable.addChallengeDrawKilledEntry(Session.Current.Scenario.Date, destinationPerson, sourcePerson);
                this.challengePersonDie(sourcePerson, sourceTroop, destinationPerson);
                break;

            case -3:     //-3:平局:P2武将被杀
                Session.Current.Scenario.YearTable.addChallengeDrawKilledEntry(Session.Current.Scenario.Date, sourcePerson, destinationPerson);
                this.challengePersonDie(destinationPerson, destinationTroop, sourcePerson);
                break;

            case -4:     //-4:平局:双方武将被杀
                Session.Current.Scenario.YearTable.addChallengeDrawBothKilledEntry(Session.Current.Scenario.Date, sourcePerson, destinationPerson);
                this.challengePersonDie(sourcePerson, sourceTroop, destinationPerson);
                this.challengePersonDie(destinationPerson, destinationTroop, sourcePerson);
                break;
            }
        }
Exemplo n.º 15
0
        internal void HandleChallengeResult(TroopDamage damage, int result, Troop sourceTroop, Person sourcePerson, Troop destinationTroop, Person destinationPerson, GameScenario scenario)
        {
            scenario.GameScreen.TroopPersonChallenge(result, sourceTroop, sourcePerson, destinationTroop, destinationPerson);

            switch (result)
            {
            case 1:     //P1武将胜利
                damage.SourceMoraleChange           += 20;
                damage.DestinationMoraleChange      -= 20;
                damage.SourceCombativityChange      += 20;
                damage.DestinationCombativityChange -= 20;      //第2只军队战意下降
                break;

            case 2:     //2:P2武将胜利
                damage.SourceMoraleChange           -= 20;
                damage.DestinationMoraleChange      += 20;
                damage.SourceCombativityChange      -= 20;
                damage.DestinationCombativityChange += 20;
                break;

            case 3:     //3:P1武将被杀
                this.challengePersonDie(sourcePerson, sourceTroop);
                damage.SourceMoraleChange           -= 30;
                damage.DestinationMoraleChange      += 30;
                damage.SourceCombativityChange      -= 30;
                damage.DestinationCombativityChange += 30;
                break;

            case 4:     //4:P2武将被杀
                this.challengePersonDie(destinationPerson, destinationTroop);
                damage.SourceMoraleChange           += 30;
                damage.DestinationMoraleChange      -= 30;
                damage.SourceCombativityChange      += 30;
                damage.DestinationCombativityChange -= 30;
                break;

            case 5:     //5:P1武将逃跑
                damage.SourceMoraleChange      -= 20;
                damage.DestinationMoraleChange += 20;
                break;

            case 6:     //6:P2武将逃跑
                damage.SourceMoraleChange      += 20;
                damage.DestinationMoraleChange -= 20;
                break;

            case 7:     //7、P1武将被俘虏
                destinationTroop.CatchCaptiveFromTroop(sourcePerson);
                sourceTroop.RefreshAfterLosePerson();
                damage.SourceMoraleChange           -= 20;
                damage.DestinationMoraleChange      += 20;
                damage.SourceCombativityChange      -= 20;
                damage.DestinationCombativityChange += 20;
                break;

            case 8:     //8、P2武将被俘虏
                sourceTroop.CatchCaptiveFromTroop(destinationPerson);
                destinationTroop.RefreshAfterLosePerson();
                damage.SourceMoraleChange           += 20;
                damage.DestinationMoraleChange      -= 20;
                damage.SourceCombativityChange      += 20;
                damage.DestinationCombativityChange -= 20;
                break;

            case 9:     //9、P1武将被说服
                destinationPerson.ConvincePersonSuccess(sourcePerson);
                damage.SourceCombativityChange      -= 30;
                damage.DestinationCombativityChange += 30;
                break;

            case 10:     //10、P2武将被说服
                sourcePerson.ConvincePersonSuccess(destinationPerson);

                damage.SourceCombativityChange      += 30;
                damage.DestinationCombativityChange -= 30;
                break;

            case -1:     //-1:平局
                break;

            case -2:     //-2:平局:P1武将被杀
                this.challengePersonDie(sourcePerson, sourceTroop);
                break;

            case -3:     //-3:平局:P2武将被杀
                this.challengePersonDie(destinationPerson, destinationTroop);
                break;

            case -4:     //-4:平局:双方武将被杀
                this.challengePersonDie(sourcePerson, sourceTroop);
                this.challengePersonDie(destinationPerson, destinationTroop);
                break;
            }
        }
Exemplo n.º 16
0
        private TroopDamage SendAttackDamage(Troop troop, bool counter)
        {
            this.RecentlyFighting = 3;
            troop.RecentlyFighting = 3;
            TroopDamage damage = new TroopDamage();
            damage.SourceTroop = this;
            damage.DestinationTroop = troop;
            damage.Counter = counter;
            damage.AntiAttack = GameObject.Chance(troop.ChanceOfBlockAttack);
            damage.AntiArrowAttack = this.ArrowOffence && (troop.IsAntiArrowAttack || GameObject.Chance(troop.ChanceOfBlockArrowAttack));
            damage.AntiCounterAttack = !counter && this.IsAntiCounterAttack;
            damage.Critical = (!counter && !troop.OutburstPreventCriticalStrike) && (GameObject.Chance(this.ChanceOfMustCriticalStrike) || GameObject.Chance(this.CriticalStrikeChance - troop.AntiCriticalStrikeChance));
            damage.OnFire = GameObject.Chance((this.ChanceOfOnFire > this.BaseChanceOfOnFire) ? this.ChanceOfOnFire : this.BaseChanceOfOnFire);
            damage.Chaos = GameObject.Chance(this.ChanceOfChaosAttack);
            if (this.Status == TroopStatus.埋伏)
            {
                this.Status = TroopStatus.一般;
                damage.Waylay = true;
                if (!damage.Critical)
                {
                    this.PreAction = TroopPreAction.伏击;
                }
            }
            if (troop.Defence <= 0)
            {
                damage.Damage = troop.Quantity;
                return damage;
            }
            int defence = troop.Defence;
            if ((this.BaseDefenceConsidered > 0) && (this.DefenceConsidered > 0))
            {
                int num2 = (this.BaseDefenceConsidered < this.DefenceConsidered) ? this.BaseDefenceConsidered : this.DefenceConsidered;
                if (defence > num2)
                {
                    defence = num2;
                }
            }
            else if (this.BaseDefenceConsidered > 0)
            {
                if (defence > this.BaseDefenceConsidered)
                {
                    defence = this.BaseDefenceConsidered;
                }
            }
            else if (this.DefenceConsidered > 0)
            {
                if (defence > this.DefenceConsidered)
                {
                    defence = this.DefenceConsidered;
                }
            }
            else if (GameObject.Chance(this.ChanceOfFixDefenceAttack) && (defence > 100))
            {
                defence = 100;
            }
            damage.SourceOffence = this.Offence;
            if ((!troop.StuntAvoidSurround && !counter) && (this.StuntMustSurround || !GameObject.Chance(troop.AvoidSurroundedChance)))
            {
                TroopList surroundAttackingTroop = this.GetSurroundAttackingTroop(troop);
                if (surroundAttackingTroop.Count >= 3)
                {
                    int num3 = 0;
                    damage.Surround = true;
                    damage.DestinationMoraleChange -= 5 * ((surroundAttackingTroop.Count - 3) + 1);
                    troop.Effect = TroopEffect.被包围;
                    foreach (Troop troop2 in surroundAttackingTroop)
                    {
                        if (troop2 != this)
                        {
                            damage.SurroudingList.Add(troop2);
                            troop2.Surrounding = true;
                            damage.SourceOffence += StaticMethods.GetRandomValue(troop2.Offence, 4);
                            num3 += StaticMethods.GetRandomValue(troop2.ChaosAfterSurroundAttackChance, 2);
                        }
                    }
                    damage.Chaos = GameObject.Chance(this.ChaosAfterSurroundAttackChance + num3);
                }
            }
            //int num4 = (int) (((damage.SourceOffence * 500) * Parameters.TroopDamageRate) / ((float) defence));
            int num4 = (int)(Math.Pow(damage.SourceOffence / (float)defence, 0.62) * 1.16 * 500 * Parameters.TroopDamageRate);
            switch (troop.Army.Kind.Type)
            {
                case MilitaryType.步兵:
                    num4 = (int) (num4 * this.OffenceRateOnSubdueBubing);
                    break;

                case MilitaryType.弩兵:
                    num4 = (int) (num4 * this.OffenceRateOnSubdueNubing);
                    break;

                case MilitaryType.骑兵:
                    num4 = (int) ((num4 * this.OffenceRateOnSubdueQibing) * ((this.RateOfQibingDamage > this.BaseRateOfQibingDamage) ? this.RateOfQibingDamage : this.BaseRateOfQibingDamage));
                    break;

                case MilitaryType.水军:
                    num4 = (int) (num4 * this.OffenceRateOnSubdueShuijun);
                    break;

                case MilitaryType.器械:
                    num4 = (int) (num4 * this.OffenceRateOnSubdueQixie);
                    break;
            }
            if (this.MoraleDownOfAttack > 0)
            {
                damage.DestinationMoraleChange -= this.MoraleDownOfAttack;
            }
            if (damage.OnFire)
            {
                int num5 = (int) ((troop.Army.Kind.MinScale * Parameters.FireDamageScale) * base.Scenario.GetTerrainDetailByPositionNoCheck(troop.Position).FireDamageRate);
                if (troop.AfraidOfFire)
                {
                    num5 *= 3;
                }
                if (troop.RateOfFireProtection > 0f)
                {
                    num5 = (int) (num5 * troop.RateOfFireProtection);
                }
                damage.FireDamage = num5;
            }
            damage.InjuredDamage = (int) (this.reduceInjuredOnAttack * damage.DestinationTroop.Army.Kind.MinScale);
            damage.TirednessIncrease = this.TirednessIncreaseOnAttack;
            damage.StealFood = Math.Min(damage.DestinationTroop.Food, this.StealFood);
            //if (true)  //单挑必然发生
            if (damage.Critical)
            {
                this.PreAction = TroopPreAction.暴击;
                num4 = (int) ((num4 * 1.5f) * troop.RateOfCriticalDamageReceived);
                if (!(damage.Chaos || !GameObject.Chance(this.ChaosAfterCriticalStrikeChance)))
                {
                    damage.Chaos = true;
                }
                if (this.MoraleDecrementOfCriticalStrike > 0)
                {
                    damage.DestinationMoraleChange -= this.MoraleDecrementOfCriticalStrike;
                }
                //if ((!this.IsFriendly(troop.BelongedFaction) && !this.AirOffence)) //单挑必然发生
                if ((!this.IsFriendly(troop.BelongedFaction) && !this.AirOffence) && GameObject.Chance(20))
                {
                    Person maxStrengthPerson = this.Persons.GetMaxStrengthPerson();
                    Person destination = troop.Persons.GetMaxStrengthPerson();
                    //if (((maxStrengthPerson != null) && (destination != null))) //单挑必然发生
                    if (((maxStrengthPerson != null) && (destination != null)) && (GameObject.Random(GameObject.Square(destination.Calmness)) < GameObject.Random(0x19)))
                    {
                        int chance = Person.ChanlengeWinningChance(maxStrengthPerson, destination);
                        if ((maxStrengthPerson.Character.ChallengeChance + chance) >= 60)
                        {
                            int flag=0;
                            damage.ChallengeHappened = true;
                            //if (true) //单挑必然发生
                            if (GlobalVariables.ShowChallengeAnimation && (base.Scenario.IsPlayer(maxStrengthPerson.BelongedFaction) || base.Scenario.IsPlayer(destination.BelongedFaction)))  //单挑双方有玩家的武将才演示
                            {
                                try
                                {
                                    /////////////////////////////////////////////////调用单挑程序
                                    string fileName = @"Dantiao\start.exe";

                                    //武将ID,姓,名,字,性别(0,女、1,男),头像编号,
                                    //生命,体力,力量,敏捷,
                                    //武艺,统御,智谋,政治,魅力,
                                    //相性,勇猛,冷静,义理,野心,名声,
                                    //坐骑(1、没有马;300、赤兔马;301、的卢;302、绝影;303、爪黄飞电;304、大宛马),
                                    //忠诚度,当前所属势力声望

                                    string para = maxStrengthPerson.ID.ToString() + "," + maxStrengthPerson.SurName + "," + maxStrengthPerson.GivenName + "," + (maxStrengthPerson.CalledName == "" ? "无" : maxStrengthPerson.CalledName) + "," + (maxStrengthPerson.Sex ? "0" : "1") + "," + maxStrengthPerson.PictureIndex.ToString() + ",";
                                    para += maxStrengthPerson.Strength.ToString() + "," + maxStrengthPerson.Strength.ToString() + "," + maxStrengthPerson.Strength.ToString() + "," + maxStrengthPerson.Strength.ToString() + ",";
                                    para += maxStrengthPerson.Strength.ToString() + "," + maxStrengthPerson.Command.ToString() +"," + maxStrengthPerson.Intelligence.ToString() + "," + maxStrengthPerson.Politics.ToString() + "," + maxStrengthPerson.Glamour.ToString() + ",";
                                    para += maxStrengthPerson.Ideal.ToString() + "," + maxStrengthPerson.Braveness.ToString() + "," + maxStrengthPerson.Calmness.ToString() + "," + maxStrengthPerson.PersonalLoyalty.ToString() + "," + maxStrengthPerson.Ambition.ToString()+","+maxStrengthPerson.Reputation.ToString()+",";
                                    ///////////////////////////////判断有没有宝物马
                                    if (maxStrengthPerson.HasHorse()==-1)
                                    {
                                        para += "1" + ",";
                                    }
                                    else
                                    {
                                        para += maxStrengthPerson.HasHorse().ToString() + ",";
                                    }
                                    /////////////////////////////////
                                    para += maxStrengthPerson.Loyalty.ToString() + "," + (maxStrengthPerson.BelongedFaction==null?0: maxStrengthPerson.BelongedFaction.Reputation).ToString();
                                    para += "\r\n";

                                    /////////------------------------------------以下添加第二个人的字符串
                                    para += destination.ID.ToString() + "," + destination.SurName + "," + destination.GivenName + "," + (destination.CalledName == "" ? "无" : destination.CalledName) + "," + (destination.Sex ? "0" : "1") + "," + destination.PictureIndex.ToString() + ",";
                                    para += destination.Strength.ToString() + "," + destination.Strength.ToString() + "," + destination.Strength.ToString() + "," + destination.Strength.ToString() + ",";
                                    para += destination.Strength.ToString() + "," + destination.Command.ToString() +"," + destination.Intelligence.ToString() + "," + destination.Politics.ToString() + "," + destination.Glamour.ToString() + ",";
                                    para += destination.Ideal.ToString() + "," + destination.Braveness.ToString() + "," + destination.Calmness.ToString() + "," + destination.PersonalLoyalty.ToString() + "," + destination.Ambition.ToString() + "," + destination.Reputation.ToString() + ",";
                                    ///////////////////////////////判断有没有宝物马
                                    if (destination.HasHorse() == -1)
                                    {
                                        para += "1" + ",";
                                    }
                                    else
                                    {
                                        para += destination.HasHorse().ToString() + ",";
                                    }
                                    /////////////////////////////////
                                    para += destination.Loyalty.ToString() + "," + (destination.BelongedFaction == null ? 0 : destination.BelongedFaction.Reputation).ToString();
                                    para += "\r\n";

                                    Process myProcess = new Process();
                                    ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(fileName, para);
                                    myProcess.StartInfo = myProcessStartInfo;
                                    myProcess.Start();
                                    while (!myProcess.HasExited)
                                    {

                                        myProcess.WaitForExit();

                                    }
                                    int returnValue = myProcess.ExitCode;

                                    ////////////////////////////////////////////////
                                    if (returnValue == 1)
                                    {
                                        flag = 1;

                                    }
                                    else if (returnValue == 2)
                                    {
                                        flag = 2;
                                    }
                                    else if (returnValue == -1)
                                    {
                                        flag = -1;
                                    }
                                    else   //返回值出错时避免跳出
                                    {
                                        flag = (GameObject.Chance(chance) ? 1 : 2);
                                    }

                                }
                                catch
                                {
                                    flag = (GameObject.Chance(chance) ? 1 : 2);
                                }
                            }
                            else
                            {
                                flag = (GameObject.Chance(chance) ? 1 : 2);
                            }
                            damage.ChallengeResult = flag;
                            damage.ChallengeSourcePerson = maxStrengthPerson;
                            damage.ChallengeDestinationPerson = destination;
                            if (flag==1)
                            {
                                damage.SourceMoraleChange += 20;
                                damage.DestinationMoraleChange -= 20;
                            }
                            else if (flag == 2)
                            {
                                damage.SourceMoraleChange -= 20;
                                damage.DestinationMoraleChange += 20;
                            }
                            else  //flag==-1,打平,只有在单挑演示中才有可能发生
                            {
                            }
                        }
                    }
                }
                damage.InjuredDamage += (int)(this.reduceInjuredOnCritical * damage.DestinationTroop.Army.Kind.MinScale);
                damage.TirednessIncrease += this.TirednessIncreaseOnCritical;
            }
            if (damage.Waylay)
            {
                damage.DestinationMoraleChange -= 10;
                if (troop.NeverBeIntoChaosWhileWaylay)
                {
                    damage.Chaos = false;
                }
                else if (!this.Army.Kind.AirOffence)
                {
                    damage.Chaos = this.InevitableChaosOnWaylay || GameObject.Chance(30);
                }
            }
            if (damage.Counter)
            {
                num4 = (int) (num4 * 0.5f);
            }
            if (!(counter || (this.AttackDecrementOfCombativity <= 0)))
            {
                damage.CombativityDown += this.AttackDecrementOfCombativity;
            }
            if (counter && (this.CounterAttackDecrementOfCombativity > 0))
            {
                damage.CounterCombativityDown += this.CounterAttackDecrementOfCombativity;
            }
            if (!troop.HasCombatTitle)
            {
                if (this.CombativityDecrementOnPower > 0)
                {
                    damage.CombativityDown += this.CombativityDecrementOnPower;
                }
                if (this.MoraleDecrementOnPrestige > 0)
                {
                    damage.DestinationMoraleChange -= this.MoraleDecrementOnPrestige;
                }
            }
            if (GameObject.Chance(this.ChanceOfTrippleDamage))
            {
                num4 *= 3;
            }
            else if (GameObject.Chance(this.ChanceOfDoubleDamage))
            {
                num4 *= 2;
            }
            if (GameObject.Chance(troop.ChanceOfHalfDamage))
            {
                num4 /= 2;
            }
            damage.Damage = num4;
            damage.StealTroop = Math.Min(damage.DestinationTroop.Quantity, (int)(damage.Damage * this.StealTroop));
            damage.StealInjured = Math.Min(damage.DestinationTroop.InjuryQuantity, (int)(damage.Damage * this.StealInjured));
            ExtensionInterface.call("TroopSendTroopDamage", new Object[] { this.Scenario, this, damage, troop, counter });
            return damage;
        }