public static Tuple <List <AttackOutcome>, List <Effect> > castSpell(Character caster, Character target, Spell s, double spellPower, double defensePower)
        {
            Tuple <List <AttackOutcome>, List <Effect> > ret = new Tuple <List <AttackOutcome>, List <Effect> >(new List <AttackOutcome>(), new List <Effect>());

            spellPower += EffectHolder.GetValidEffectsByEffect(caster, EffectHolder.EffectType.SpellBonus);
            foreach (Effect eff in s.SpellEffects.Keys)
            {
                Effect effMultiplied = new Effect(eff.effectTypes,
                                                  eff.effectStrength + s.SpellEffects[eff].Item1 * spellPower,
                                                  eff.effectLength + (int)Math.Round(s.SpellEffects[eff].Item2 * spellPower),
                                                  eff.deterioration + s.SpellEffects[eff].Item3 * spellPower);
                effMultiplied.effectTag = eff.effectTag;
                ret.Item2.Add(effMultiplied);
            }

            foreach (Weapon weap in s.SpellWeapons.Keys)
            {
                Weapon save = caster.CombatStuff.CombatWeapon;
                caster.CombatStuff.CombatWeapon = Utilities.GetWeaponByName(weap.ItemName);

                AttackOutcome outcome = CombatScripts.RunCombat(caster.MakeDeepCopy(), target, s.SpellWeapons[weap] + spellPower, defensePower, null);
                outcome.Attacker.CombatStuff.attackResultsForDisplay = new List <List <string> >();
                outcome.Defender.CombatStuff.defendResultsForDisplay = new List <List <string> >();
                ret.Item1.Add(outcome);

                caster.CombatStuff.CombatWeapon = save;
            }


            return(ret);
        }
        private void FOLLOWTHETACO_Click(object sender, EventArgs e)
        {
            List <AttackOutcome> followedTacos = new List <AttackOutcome>();

            foreach (AttackOutcome tacoToFollow in allAttacks)
            {
                AttackOutcome followedTaco = CombatScripts.RunCombat(tacoToFollow.Attacker, tacoToFollow.Defender, tacoToFollow.attackRoll, tacoToFollow.defendRoll, null);


                followedTaco.Attacker.CombatStuff.AttackNotes = followedTaco.Notes;
                followedTaco.Defender.CombatStuff.DefendNotes = followedTaco.Notes;

                followedTacos.Add(followedTaco);
            }

            CombatScripts.fatigueCharactersAndRecordCombat(followedTacos);

            foreach (AttackOutcome Whack in followedTacos)
            {
                CombatScripts.applyAttackOutcome(Whack);
            }

            EffectHolder.ClearUselessEffects();
            CombatHolder.MoveAttackingCharsToHasAttackedChars();
            if (CombatHolder._masterOfDeclarations != null)
            {
                CombatHolder._masterOfDeclarations.UpdateRTB();
            }
            CombatHolder.updateCombatDeclarations();
            AfterCrits frmCreator = new AfterCrits();

            frmCreator.Show();

            Master_Attacker frmCloser = this;

            frmCloser.Hide();
        }
        private void runSingleAttack()
        {
            clearDedPeople();
            if (leftSide.Count == 0 || rightSide.Count == 0)
            {
                return;
            }
            Character attackingChar = new Character();
            Character toAttackChar  = new Character();
            bool      thereIsACharThatHasNotAttacked = false;
            bool      thereIsAnAttackingChar         = false;

            ifThisThenLeftAttacksNext = !ifThisThenLeftAttacksNext;
            foreach (Character c in leftSide.Keys)
            {
                if (!leftSide[c])
                {
                    thereIsACharThatHasNotAttacked = true;
                    break;
                }
            }
            foreach (Character c in rightSide.Keys)
            {
                if (!rightSide[c])
                {
                    thereIsACharThatHasNotAttacked = true;
                    break;
                }
            }
            if (!thereIsACharThatHasNotAttacked)
            {
                EffectHolder.ProcAndDecayEffectsForSingleChar(rightSide.Keys.Last());
                EffectHolder.ProcAndDecayEffectsForSingleChar(leftSide.Keys.Last());
                clearDedPeople();
                //c# really does make you do it this way. Iteration through a dictionary is hard for some reason
                List <Character> temp = new List <Character>();
                foreach (Character c in leftSide.Keys)
                {
                    temp.Add(c);
                }
                foreach (Character c in temp)
                {
                    leftSide[c] = false;
                }
                temp.Clear();
                foreach (Character c in rightSide.Keys)
                {
                    temp.Add(c);
                }
                foreach (Character c in temp)
                {
                    rightSide[c] = false;
                }
                if (leftSide.Count == 0 || rightSide.Count == 0)
                {
                    return;
                }
            }
            if (ifThisThenLeftAttacksNext)
            {
                foreach (Character c in leftSide.Keys)
                {
                    if (!leftSide[c])
                    {
                        attackingChar          = c;
                        thereIsAnAttackingChar = true;
                        leftSide[c]            = true;
                        break;
                    }
                }
                toAttackChar = rightSide.Keys.Last();
            }
            else
            {
                foreach (Character c in rightSide.Keys)
                {
                    if (!rightSide[c])
                    {
                        attackingChar          = c;
                        thereIsAnAttackingChar = true;
                        rightSide[c]           = true;
                        break;
                    }
                }
                toAttackChar = leftSide.Keys.Last();
            }
            if (!thereIsAnAttackingChar)
            {
                return;
            }
            AttackOutcome ao = CombatScripts.RunCombat(attackingChar, toAttackChar, Math.Round(r.NextDouble() * 20), Math.Round(r.NextDouble() * 20), null);


            if (ao.Othertext.ToString() == "Hit")
            {
                toAttackChar.HitPoints = toAttackChar.HitPoints - ao.harm;
                Effect bleed        = new Effect(EffectHolder.EffectType.Regeneration, ao.bleed * -1, -1, 0);
                Effect focus        = new Effect(EffectHolder.EffectType.Focus, ao.trauma * -1, -1, 0);
                Effect impairmentOB = new Effect(EffectHolder.EffectType.OB, ao.impairment * -1, -1, 0);
                Effect impairmentDB = new Effect(EffectHolder.EffectType.DB, ao.impairment * -1, -1, 0);
                Effect OB           = new Effect(EffectHolder.EffectType.OB, ao.disorientation * -1, ao.disorientation, 1);
                Effect DB           = new Effect(EffectHolder.EffectType.DB, ao.disorientation * -1, ao.disorientation, 1);
                EffectHolder.CreateEffect(OB, toAttackChar, false);
                EffectHolder.CreateEffect(DB, toAttackChar, false);
                EffectHolder.CreateEffect(bleed, toAttackChar, false);
                EffectHolder.CreateEffect(focus, toAttackChar, false);
                EffectHolder.CreateEffect(impairmentOB, toAttackChar, false);
                EffectHolder.CreateEffect(impairmentDB, toAttackChar, false);
                EffectHolder.ClearUselessEffects();
            }

            if (doPrinting)
            {
                richTextBoxBig.Text += attackingChar.CombatStuff.CombatName + " -> " + toAttackChar.CombatStuff.CombatName + " " + " " + ao.Othertext.ToString() + "\n";
            }

            clearDedPeople();
        }
        public static List <List <Double> > CreateDataPoints(AttackOutcome ao,
                                                             bool doTotalDamage,
                                                             bool doHarm,
                                                             bool doBleed,
                                                             bool doDisorientation,
                                                             bool doImpairment,
                                                             bool doTrauma,
                                                             bool doKO,
                                                             Utilities.BodyParts?location,
                                                             int perception)
        {
            List <List <Double> > gridOfPoints = new List <List <double> >();

            for (double j = ao.defendRoll - perception; j <= ao.defendRoll + perception; j++)
            {
                List <double> rowOfPoints = new List <double>();
                for (double i = ao.attackRoll - perception; i <= ao.attackRoll + perception; i++)
                {
                    AttackOutcome oneOutcome = CombatScripts.RunCombat(Utilities.GetSameCharWithCurrentState(ao.Attacker), Utilities.GetSameCharWithCurrentState(ao.Defender), i, j, location);
                    double        Damage     = 0.0;
                    switch (oneOutcome.Othertext.ToString())
                    {
                    case "Miss":
                        Damage = -1;
                        break;

                    case "Block":
                        Damage = -2;
                        break;

                    case "Parry":
                        Damage = -3;
                        break;

                    case "Hit":
                        if (doTotalDamage)
                        {
                            Damage += oneOutcome.TotalStrikeAmountFromAllTypes();
                        }
                        if (doHarm)
                        {
                            Damage += oneOutcome.harm;
                        }
                        if (doBleed)
                        {
                            Damage += oneOutcome.bleed;
                        }
                        if (doDisorientation)
                        {
                            Damage += oneOutcome.disorientation;
                        }
                        if (doImpairment)
                        {
                            Damage += oneOutcome.impairment;
                        }
                        if (doTrauma)
                        {
                            Damage += oneOutcome.trauma;
                        }
                        if (doTrauma)
                        {
                            Damage += oneOutcome.ko;
                        }
                        if (ao.Othertext != Utilities.AttackResultType.Hit)
                        {
                            Damage = 99;
                        }
                        break;

                    default:
                        throw new Exception("WTF did you give me?");
                    }
                    rowOfPoints.Add(Damage);
                }
                gridOfPoints.Add(rowOfPoints);
            }
            return(gridOfPoints);
        }
        private List <DataPoint> CreateDataPoints()
        {
            List <DataPoint> lstData = new List <DataPoint>();
            Random           r       = new Random();
            Double           average = 0;
            Character        copy1   = Utilities.GetSameCharWithCurrentState(_char1);
            Character        copy2   = Utilities.GetSameCharWithCurrentState(_char2);

            for (int i = 1; i < 21; i++)
            {
                for (int j = 1; j < 21; j++)
                {
                    copy1.TemporaryEffects = new List <Effect>();
                    foreach (Effect ef in _char1.TemporaryEffects)
                    {
                        copy1.TemporaryEffects.Add(ef);
                    }
                    copy2.TemporaryEffects = new List <Effect>();
                    foreach (Effect ef in _char2.TemporaryEffects)
                    {
                        copy2.TemporaryEffects.Add(ef);
                    }
                    AttackOutcome _outcome = CombatScripts.RunCombat(copy1, copy2, i, j, null);
                    if (!checkBoxDoLocationCheck.Checked)
                    {
                        //_outcome.recalculateWithoutLocation();
                    }

                    double Red    = 0;
                    double Blue   = 0;
                    double Green  = 0;
                    double Damage = 0.0;
                    if (!checkBoxHarm.Checked &&
                        !checkBoxBleed.Checked &&
                        !checkBoxDisorientation.Checked &&
                        !checkBoxImpairment.Checked &&
                        !checkBoxTrauma.Checked &&
                        !checkBoxKO.Checked)
                    {
                        Damage = _outcome.TotalStrikeAmountFromAllTypes();
                    }
                    if (checkBoxHarm.Checked)
                    {
                        Damage += _outcome.harm;
                    }
                    if (checkBoxBleed.Checked)
                    {
                        Damage += _outcome.bleed;
                    }
                    if (checkBoxDisorientation.Checked)
                    {
                        Damage += _outcome.disorientation;
                    }
                    if (checkBoxImpairment.Checked)
                    {
                        Damage += _outcome.impairment;
                    }
                    if (checkBoxTrauma.Checked)
                    {
                        Damage += _outcome.trauma;
                    }
                    if (checkBoxKO.Checked)
                    {
                        Damage += _outcome.ko;
                    }
                    switch (_outcome.Othertext.ToString())
                    {
                    case "Miss":
                        Red   = 0;
                        Blue  = 0;
                        Green = 0;
                        break;

                    case "Block":
                        Red   = 100;
                        Blue  = 100;
                        Green = 100;
                        break;

                    case "Parry":
                        Red   = 200;
                        Blue  = 200;
                        Green = 200;
                        break;

                    case "Hit":
                        if (Damage < 100)
                        {
                            Red   = 255;
                            Blue  = 255;
                            Green = 255;
                        }
                        if (Damage < 50)
                        {
                            Red   = 200;
                            Blue  = 0;
                            Green = 0;
                        }
                        if (Damage < 20)
                        {
                            Red   = 200;
                            Blue  = 0;
                            Green = 200;
                        }
                        if (Damage < 15)
                        {
                            Red   = 0;
                            Blue  = 0;
                            Green = 200;
                        }
                        if (Damage < 10)
                        {
                            Red   = 0;
                            Blue  = 200;
                            Green = 200;
                        }
                        if (Damage < 5)
                        {
                            Red   = 0;
                            Blue  = 250;
                            Green = 100;
                        }
                        if (Damage < 4)
                        {
                            Red   = 50;
                            Blue  = 200;
                            Green = 0;
                        }
                        if (Damage < 3)
                        {
                            Red   = 100;
                            Blue  = 125;
                            Green = 0;
                        }
                        if (Damage < 2)
                        {
                            Red   = 200;
                            Blue  = 100;
                            Green = 50;
                        }
                        if (Damage < 1)
                        {
                            Red   = 225;
                            Blue  = 0;
                            Green = 125;
                        }
                        break;

                    default:
                        throw new Exception("WTF did you give me?");
                    }
                    int       iRed   = Convert.ToInt32(Math.Floor(Red));
                    int       iBlue  = Convert.ToInt32(Math.Floor(Blue));
                    int       iGreen = Convert.ToInt32(Math.Floor(Green));
                    DataPoint dp     = new DataPoint(10, 10, 11 * i, 11 * j, iRed, iGreen, iBlue);
                    lstData.Add(dp);
                    average += Damage;
                }
            }
            lblAverage.Text = "Average Damage: " + Math.Round(average * 10 / 400) / 10;
            return(lstData);
        }
Пример #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!Utilities.ValidateComboBox(cboBoxChar1.Text))
            {
                return;
            }
            if (!Utilities.ValidateComboBox(cboBoxChar2.Text))
            {
                return;/*
                        * if (!Utilities.ValidateComboBox(cboBoxWeapon1.Text))
                        * return;
                        * if (!Utilities.ValidateComboBox(cboBoxWeapon2.Text))
                        * return;*/
            }
            Character char1 = Utilities.getCharacterFromXmlOrCombatHolderByString(cboBoxChar1.Text);

            if (!CombatHolder._inCombatChars.Contains(char1))
            {
                char1.HitPoints = CombatScripts.GetBaseHealth(char1);
                char1.Stamina   = CombatScripts.GetBaseStamina(char1);
            }
            Character char2 = Utilities.getCharacterFromXmlOrCombatHolderByString(cboBoxChar2.Text);

            if (!CombatHolder._inCombatChars.Contains(char1))
            {
                char2.HitPoints = CombatScripts.GetBaseHealth(char2);
                char2.Stamina   = CombatScripts.GetBaseStamina(char2);
            }
            Character CharCopy1 = Utilities.GetSameCharWithCurrentState(char1);
            Character CharCopy2 = Utilities.GetSameCharWithCurrentState(char2);

            CharCopy1.CombatStuff.CombatOB     = Utilities.ParseDoubleFromDangerousString(txtBoxOffensiveBonus.Text);
            CharCopy1.CombatStuff.CombatWeapon = char1.Weapons.Find(A => A.ItemName == cboBoxWeapon1.Text);
            CharCopy1.CombatStuff.CombatShield = char1.Shields.Find(A => A.ItemName == cboBoxShield1.Text);
            if (CharCopy1.CombatStuff.CombatShield == null)
            {
                CharCopy1.CombatStuff.CombatShield = new Shield();
            }


            CharCopy2.CombatStuff.CombatDB     = Utilities.ParseDoubleFromDangerousString(txtBoxDefensiveBonus.Text);
            CharCopy2.CombatStuff.CombatWeapon = char2.Weapons.Find(A => A.ItemName == cboBoxWeapon2.Text);
            CharCopy2.CombatStuff.CombatShield = char2.Shields.Find(A => A.ItemName == cboBoxShield2.Text);
            if (CharCopy2.CombatStuff.CombatShield == null)
            {
                CharCopy2.CombatStuff.CombatShield = new Shield();
            }
            if (checkBoxStartup.Checked)
            {
                EnchantmentUtilities.triggerAllEnchantmentsForChar(CharCopy1, new EnchantmentParameters()
                {
                    triggerSource = EnchantmentUtilities.SourceTypes.CombatEntry
                });
                EnchantmentUtilities.triggerAllEnchantmentsForChar(CharCopy2, new EnchantmentParameters()
                {
                    triggerSource = EnchantmentUtilities.SourceTypes.CombatEntry
                });
            }
            _outcome            = CombatScripts.RunCombat(Utilities.GetSameCharWithCurrentState(CharCopy1), Utilities.GetSameCharWithCurrentState(CharCopy2), Utilities.ParseDoubleFromDangerousString(txtBoxOffensiveRoll.Text), Utilities.ParseDoubleFromDangerousString(txtBoxDefensiveRoll.Text), null);
            txtBoxCrit.Text     = _outcome.Othertext.ToString();
            txtBoxDamage.Text   = Convert.ToString(0);
            lblHitCaliber.Text  = Convert.ToString(0);
            lblHitStrength.Text = Convert.ToString(0);
            if (_outcome.Othertext.ToString() == "Hit")
            {
                lblHitCaliber.Text  = "Hit Caliber: " + _outcome.HitCaliber.ToString();
                lblHitStrength.Text = "Hit Strength: " + _outcome.HitStrength.ToString();
                double damage = _outcome.TotalStrikeAmountFromAllTypes();
                txtBoxDamage.Text = Convert.ToString(damage);
                txtBoxCrit.Text   = _outcome.HitLocation.ToString();
                AttackOutcome cumulative = new AttackOutcome();
                for (int i = 0; i < 1000; i++)
                {
                    //calculate the same crit every time
                    Utilities.FindCritLocation(_outcome);
                    CritCalculator.CalculateCrit(_outcome);
                    //store it in a different place so it doesnt get reset
                    cumulative.bleed          += _outcome.bleed;
                    cumulative.harm           += _outcome.harm;
                    cumulative.disorientation += _outcome.disorientation;
                    cumulative.impairment     += _outcome.impairment;
                    cumulative.ko             += _outcome.ko;
                    cumulative.trauma         += _outcome.trauma;
                }

                Console.WriteLine("Harm: " + Convert.ToDouble(cumulative.harm) / 1000);
                Console.WriteLine("Bleed: " + Convert.ToDouble(cumulative.bleed) / 1000);
                Console.WriteLine("Disorientation: " + Convert.ToDouble(cumulative.disorientation) / 1000);
                Console.WriteLine("Impairment: " + Convert.ToDouble(cumulative.impairment) / 1000);
                Console.WriteLine("Trauma: " + Convert.ToDouble(cumulative.trauma) / 1000);
                Console.WriteLine("KO: " + Convert.ToDouble(cumulative.ko) / 1000);

                rtbAverageResults.Text  = "";
                rtbAverageResults.Text += "Harm: " + Convert.ToDouble(cumulative.harm) / 1000 + "\n";
                rtbAverageResults.Text += "Bleed: " + Convert.ToDouble(cumulative.bleed) / 1000 + "\n";
                rtbAverageResults.Text += "Disorientation: " + Convert.ToDouble(cumulative.disorientation) / 1000 + "\n";
                rtbAverageResults.Text += "Impairment: " + Convert.ToDouble(cumulative.impairment) / 1000 + "\n";
                rtbAverageResults.Text += "Trauma: " + Convert.ToDouble(cumulative.trauma) / 1000 + "\n";
                rtbAverageResults.Text += "KO: " + Convert.ToDouble(cumulative.ko) / 1000 + "\n";
            }
            if (chkBoxGraph.Checked)
            {
                AttackChart frmCreator = new AttackChart(Utilities.GetSameCharWithCurrentState(CharCopy1), Utilities.GetSameCharWithCurrentState(CharCopy2));
                frmCreator.Show();
            }
        }