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 txtBoxOffensiveRoll_TextChanged(object sender, EventArgs e)
        {
            double d1;

            Double.TryParse(txtBoxOffensiveRoll.Text, out d1);
            d1 += _attacker.CombatStuff.CombatOB;
            d1 += Utilities.GetWeaponByName(comboBoxAttackerWeapon.Text).OffensiveBonus;
            d1 += _attacker.CombatStuff.CombatShield.OffensiveBonus;
            d1 += Utilities.GetTotalOffensiveBonusOfAllArmor(_attacker);
            d1 += CombatScripts.GetWeightFactor(_attacker);
            d1  = d1 * CombatScripts.GetStaminaFactor(_attacker);

            labelAfterOffensiveMods.Text = d1.ToString();
        }
        private void txtBoxDefensiveRoll_TextChanged(object sender, EventArgs e)
        {
            double d1;

            Double.TryParse(txtBoxDefensiveRoll.Text, out d1);
            Character _defender = Utilities.getCharacterFromXmlOrCombatHolderByString(comboBox1.Text);

            d1 += _defender.CombatStuff.CombatDB;
            d1 += Utilities.GetWeaponByName(comboBoxDefenderWeapon.Text).DefensiveBonus;
            d1 += _defender.CombatStuff.CombatShield.DefensiveBonus;
            d1 += Utilities.GetTotalDefensiveBonusOfAllArmor(_defender);
            d1 += CombatScripts.GetWeightFactor(_defender);
            d1  = d1 * CombatScripts.GetStaminaFactor(_defender);

            labelAfterDefensiveMods.Text = d1.ToString();
        }
        //next round
        private void button3_Click(object sender, EventArgs e)
        {
            CombatHolder._alreadyAttackedThisRound.Clear();

            int rounds = 1;

            Int32.TryParse(textBoxRoundsToJump.Text, out rounds);
            if (rounds < 1)
            {
                rounds = 1;
            }
            textBoxRoundsToJump.Text = "";
            for (int i = 0; i < rounds; i++)
            {
                EffectHolder.ProcAndDecayEffects();
                foreach (Character c in CombatHolder._inCombatChars)
                {
                    EnchantmentUtilities.triggerAllEnchantmentsForChar(c, new EnchantmentParameters()
                    {
                        triggerSource = EnchantmentUtilities.SourceTypes.Round
                    });
                    foreach (SpellToCast stc in c.CombatStuff.SpellsToCast)
                    {
                        if (stc != null)
                        {
                            stc.hasBeenCast = false;
                            if (!stc.castAtBeginningOfNextRound)
                            {
                                stc.spellPower = -1;
                            }
                        }
                    }
                }
                if (rounds < 10)
                {
                    SpellResults frmCreator = new SpellResults(false);
                }
                CombatScripts.slowlyRegenerateCharacters();
                CombatScripts.removeOverhealFromCharacters();
            }



            UpdateRTB();
            CombatHolder.updateCombatDeclarations();
        }
Exemple #5
0
        public void ChangeStatLabels()
        {
            //Now, fill out some labels about the attacker's stats

            Character statCharacter = Utilities.getCharacterFromXmlOrCombatHolderByString(cboBoxChar1.Text);

            lblHealth.Text  = "Health: " + Convert.ToString(CombatScripts.GetBaseHealth(statCharacter));
            lblStamina.Text = "Stamina: " + Convert.ToString(CombatScripts.GetBaseStamina(statCharacter));

            statCharacter.CombatStuff.CombatWeapon = statCharacter.Weapons.Find(A => A.ItemName == cboBoxWeapon1.Text) ?? new Weapon();
            statCharacter.CombatStuff.CombatShield = statCharacter.Shields.Find(A => A.ItemName == cboBoxShield1.Text) ?? new Shield();


            double attackerWeightFactor = CombatScripts.GetWeightFactor(statCharacter);

            lblWeightFactor.Text = "WeightFactor: " + Convert.ToString(CombatScripts.GetWeightFactor(statCharacter));

            double dxMod1 = (Convert.ToDouble(statCharacter.Statistics.Dexterity + EffectHolder.GetValidEffectsByEffect(statCharacter, EffectHolder.EffectType.Dexterity)) - 10) / 2;

            double attackerReflex = CombatScripts.GetBaseReflex(statCharacter);

            lblReflex.Text = "Reflex: " + attackerReflex.ToString();
        }
        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();
        }
        //add character
        private void button3_Click(object sender, EventArgs e)
        {
            if (cboBoxNames.Text == "")
            {
                MessageBox.Show("Please Enter A Character");
                return;
            }
            Character charToAdd = Utilities.GetCharByName(cboBoxNames.Text);

            if (!charToAdd.Weapons.Any() || !charToAdd.Shields.Any())
            {
                return;
            }
            charToAdd.CombatStuff.CombatWeapon = charToAdd.Weapons[0];
            charToAdd.CombatStuff.CombatShield = charToAdd.Shields[0];
            List <Character> found = CombatHolder._inCombatChars.FindAll(FitChar => cboBoxNames.Text == FitChar.Name);
            int appendnum          = found.Count + 1;

            //while there is a character that has the same combatname
            while (CombatHolder._inCombatChars.FindAll(FitChar => charToAdd.Name + appendnum == FitChar.CombatStuff.CombatName).Count != 0)
            {
                appendnum++;
            }
            charToAdd.CombatStuff.CombatName = charToAdd.Name + appendnum;
            charToAdd.Stamina             = CombatScripts.GetBaseStamina(charToAdd);
            charToAdd.HitPoints           = CombatScripts.GetBaseHealth(charToAdd);
            charToAdd.CombatStuff.targets = new List <Character>();
            CombatHolder._inCombatChars.Add(charToAdd);

            EnchantmentUtilities.triggerAllEnchantmentsForChar(charToAdd, new EnchantmentParameters()
            {
                triggerSource = EnchantmentUtilities.SourceTypes.CombatEntry
            });

            updateRTBWithCharacternames();
            cboBoxInCombat.DataSource = CombatHolder.getInCombatCharNames();
        }
        private void resolveSpells(bool updateboxes)
        {
            foreach (SpellToCast stc in spells)
            {
                foreach (Effect eff in stc.effectResult.Keys)
                {
                    EffectHolder.CreateEffect(eff, stc.effectResult[eff], false);
                }
                foreach (AttackOutcome ao in stc.weaponResult)
                {
                    CombatScripts.applyAttackOutcome(ao);
                }
                stc.caster.Stamina -= stc.spell.SpellCost;
                attemptToAddResult(stc.caster, stc);
                foreach (Character c in stc.targets)
                {
                    attemptToAddResult(c, stc);
                }
                stc.targets.Clear();
                stc.spellPower = 0;
            }
            EffectHolder.ClearUselessEffects();

            if (updateboxes)
            {
                if (CombatHolder._masterOfDeclarations != null)
                {
                    CombatHolder._masterOfDeclarations.UpdateRTB();
                }
                CombatHolder.updateCombatDeclarations();
            }

            SpellResults 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);
        }
Exemple #11
0
        public static string CombatTerminal(Character c)
        {
            var doc = new HtmlDocument();

            doc.Load("HTMLPages\\CombatTerminal.html");

            doc.GetElementbyId("menuform").Attributes["action"].Value      = BaseURL();
            doc.GetElementbyId("inventoryform").Attributes["action"].Value = BaseURL() + "/Combat/" + c.CombatStuff.CombatName + "/Inventory";
            doc.GetElementbyId("combatform").Attributes["action"].Value    = CombatTerminalPage(c);
            doc.GetElementbyId("CharacterName").InnerHtml              = c.Name;
            doc.GetElementbyId("str").InnerHtml                        = c.Statistics.Strength.ToString();
            doc.GetElementbyId("dex").InnerHtml                        = c.Statistics.Dexterity.ToString();
            doc.GetElementbyId("con").InnerHtml                        = c.Statistics.Constitution.ToString();
            doc.GetElementbyId("int").InnerHtml                        = c.Statistics.Intelligence.ToString();
            doc.GetElementbyId("wis").InnerHtml                        = c.Statistics.Wisdom.ToString();
            doc.GetElementbyId("cha").InnerHtml                        = c.Statistics.Charisma.ToString();
            doc.GetElementbyId("hp").InnerHtml                         = ((int)(c.HitPoints + EffectHolder.GetValidEffectsByEffect(c, EffectHolder.EffectType.Health))).ToString();
            doc.GetElementbyId("stamina").InnerHtml                    = ((int)c.Stamina).ToString();
            doc.GetElementbyId("regen").InnerHtml                      = EffectHolder.GetValidEffectsByEffect(c, EffectHolder.EffectType.Regeneration).ToString();
            doc.GetElementbyId("exhaustion").InnerHtml                 = (Math.Round(1.0 / CombatScripts.GetStaminaFactor(c), 2)).ToString();
            doc.GetElementbyId("obmod").InnerHtml                      = (EffectHolder.GetValidEffectsByEffect(c, EffectHolder.EffectType.OB)).ToString();
            doc.GetElementbyId("dbmod").InnerHtml                      = (EffectHolder.GetValidEffectsByEffect(c, EffectHolder.EffectType.DB)).ToString();
            doc.GetElementbyId("focus").InnerHtml                      = (EffectHolder.GetValidEffectsByEffect(c, EffectHolder.EffectType.Focus)).ToString();
            doc.GetElementbyId("weightfactor").InnerHtml               = (Math.Round(CombatScripts.GetWeightFactor(c), 2)).ToString();
            doc.GetElementbyId("reflex").InnerHtml                     = (Math.Round(CombatScripts.CalculateReflex(c, 0), 2)).ToString();
            doc.GetElementbyId("offbonus").Attributes["value"].Value   = c.CombatStuff.CombatOB.ToString();
            doc.GetElementbyId("defbonus").Attributes["value"].Value   = c.CombatStuff.CombatDB.ToString();
            doc.GetElementbyId("roll").Attributes["value"].Value       = c.CombatStuff.CombatRoll.ToString();
            doc.GetElementbyId("spellpower").Attributes["value"].Value = c.CombatStuff.SpellsToCast[0].spellPower.ToString();
            foreach (Character target in CombatHolder._inCombatChars)
            {
                if (target.CombatStuff.CombatName == c.LastAttackTargetSelected)
                {
                    doc.GetElementbyId("targets").InnerHtml += "\r\n<option selected>" + target.CombatStuff.CombatName;
                }
                else
                {
                    doc.GetElementbyId("targets").InnerHtml += "\r\n<option>" + target.CombatStuff.CombatName;
                }

                if (target.CombatStuff.CombatName == c.LastSpellTargetSelected)
                {
                    doc.GetElementbyId("spelltargets").InnerHtml += "\r\n<option selected>" + target.CombatStuff.CombatName;
                }
                else
                {
                    doc.GetElementbyId("spelltargets").InnerHtml += "\r\n<option>" + target.CombatStuff.CombatName;
                }
            }
            foreach (Weapon weap in c.Weapons)
            {
                if (weap == c.CombatStuff.CombatWeapon)
                {
                    doc.GetElementbyId("weapons").InnerHtml += "\r\n<option selected>" + weap.ItemName;
                }
                else
                {
                    doc.GetElementbyId("weapons").InnerHtml += "\r\n<option>" + weap.ItemName;
                }
            }

            foreach (Shield sh in c.Shields)
            {
                if (sh == c.CombatStuff.CombatShield)
                {
                    doc.GetElementbyId("shields").InnerHtml += "\r\n<option selected>" + sh.ItemName;
                }
                else
                {
                    doc.GetElementbyId("shields").InnerHtml += "\r\n<option>" + sh.ItemName;
                }
            }

            foreach (Spell sp in c.Spells)
            {
                if (sp == c.CombatStuff.SpellsToCast[0].spell)
                {
                    doc.GetElementbyId("spells").InnerHtml += "\r\n<option selected>" + sp.SpellName;
                }
                else
                {
                    doc.GetElementbyId("spells").InnerHtml += "\r\n<option>" + sp.SpellName;
                }
            }

            if (c.CombatStuff.SpellsToCast[0].targets.Any())
            {
                doc.GetElementbyId("attacks").InnerHtml += "\r\n<p>Casting " + c.CombatStuff.SpellsToCast[0].spell.SpellName + " at:";
                foreach (Character target in c.CombatStuff.SpellsToCast[0].targets)
                {
                    doc.GetElementbyId("attacks").InnerHtml += target.CombatStuff.CombatName + "<br>";
                }
                doc.GetElementbyId("attacks").InnerHtml += " </ p > ";
            }
            foreach (Character attacking in CombatHolder._makingAttackChars)
            {
                doc.GetElementbyId("attacks").InnerHtml += "\r\n<p>" + attacking.CombatStuff.CombatName + " is attacking:";
                foreach (Character beingattacked in attacking.CombatStuff.targets)
                {
                    doc.GetElementbyId("attacks").InnerHtml += beingattacked.CombatStuff.CombatName + "<br>";
                }
                doc.GetElementbyId("attacks").InnerHtml += "with " + attacking.CombatStuff.CombatWeapon.ItemName + " </ p > ";
            }
            doc.GetElementbyId("attackresults").InnerHtml += " </ p > ";
            foreach (List <String> attack in c.CombatStuff.attackResultsForDisplay)
            {
                doc.GetElementbyId("attackresults").InnerHtml += "\r\n<p>ATTACK<br>";
                foreach (string str in attack)
                {
                    if (str.Length > 7 && str.Substring(0, 7) == "http://")
                    {
                        doc.GetElementbyId("attackresults").InnerHtml += "<a href=\"" + str + "\">Display Attack</a>";
                    }
                    else
                    {
                        doc.GetElementbyId("attackresults").InnerHtml += str + "<br>";
                    }
                }
                doc.GetElementbyId("attackresults").InnerHtml += " </ p > ";
            }
            foreach (List <String> defence in c.CombatStuff.defendResultsForDisplay)
            {
                doc.GetElementbyId("attackresults").InnerHtml += "\r\n<p>DEFENCE<br>";
                foreach (string str in defence)
                {
                    if (str.Length > 7 && str.Substring(0, 7) == "http://")
                    {
                        doc.GetElementbyId("attackresults").InnerHtml += "<a href=\"" + str + "\">Display Defense</a>";
                    }
                    else
                    {
                        doc.GetElementbyId("attackresults").InnerHtml += str + "<br>";
                    }
                }
                doc.GetElementbyId("attackresults").InnerHtml += " </ p > ";
            }
            foreach (SpellToCast castSpell in c.CombatStuff.spellResultsForDisplay)
            {
                doc.GetElementbyId("attackresults").InnerHtml += "\r\n<p>SPELL<br>";
                foreach (Effect eff in castSpell.effectResult.Keys)
                {
                    doc.GetElementbyId("attackresults").InnerHtml += eff.getDisplayString() + "<br>";
                }
                doc.GetElementbyId("attackresults").InnerHtml += " </ p > ";
            }
            String lastAttackExp = "\r\n<p style =\"white-space: pre-line;\">\nLast Attack Explanation\n";

            lastAttackExp += c.CombatStuff.AttackNotes.DisplayResults() + "<br></p>";
            doc.GetElementbyId("attackresults").InnerHtml += lastAttackExp;

            String lastDefenceExp = "\r\n<p style =\"white-space: pre-line;\">\nLast Defence Explanation\n";

            lastDefenceExp += c.CombatStuff.DefendNotes.DisplayResults() + "<br></p>";
            doc.GetElementbyId("attackresults").InnerHtml += lastDefenceExp;

            //nodename.Attributes["value"].Value = c.Name;
            // < option > thief
            var bleh = doc.DocumentNode.OuterHtml;

            return(bleh);

            /*
             * ret += wItemName + "<br>\n";
             * ret += w.Description + "<br>\n";
             * foreach (Utilities.DamageType dt in w.DamageTypes.Keys)
             * {
             *  ret += dt.ToString() + " " + w.DamageTypes[dt] + "<br>\n";
             * }
             * ret += EndBit();*/
        }
        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);
        }
        private void btnCastSpell_Click(object sender, EventArgs e)
        {
            if (!Utilities.ValidateComboBox(cboBoxChars.Text) || !Utilities.ValidateComboBox(cboBoxSpells.Text))
            {
                return;
            }
            if (chkBoxSecurity.Checked)
            {
                chkBoxSecurity.Checked = false;
            }
            else
            {
                return;
            }
            richTextBox1.Text = "";
            double spellPower = 0.0;

            Double.TryParse(txtBoxSpellPower.Text, out spellPower);
            double defensePower = 0.0;

            Double.TryParse(txtBoxDefenseRoll.Text, out defensePower);

            // Character c = Utilities.GetCharByName(cboBoxChars.Text); something like this needs to work eventually
            Character target = CombatHolder._inCombatChars.Find(A => A.CombatStuff.CombatName == cboBoxChars.Text);

            Character caster = new Character();

            if (cboBoxCaster.Text.Equals("Nobody"))
            {
                caster = Utilities.GetCharByName("Nobody");
                caster.CombatStuff.CombatShield = caster.Shields.First();
                caster.Stamina = CombatScripts.GetBaseStamina(caster);
                caster.CombatStuff.CombatName = "Nobody";
            }
            else
            {
                caster = CombatHolder._inCombatChars.Find(A => A.CombatStuff.CombatName == cboBoxCaster.Text);
            }


            if (target == null)  //fail
            {
                Utilities.ValidateComboBox("");
            }
            Spell s = Utilities.GetSpellByName(cboBoxSpells.Text);


            caster.Stamina -= s.SpellCost;

            Tuple <List <AttackOutcome>, List <Effect> > results = SpellScripts.castSpell(caster, target, s, spellPower, defensePower);

            foreach (Effect effMultiplied in results.Item2)
            {
                richTextBox1.Text += effMultiplied.getDisplayString();

                EffectHolder.CreateEffect(effMultiplied, target, false);
            }

            foreach (AttackOutcome outcome in results.Item1)
            {
                richTextBox1.Text += outcome.Attacker.CombatStuff.CombatName + " against " + outcome.Defender.CombatStuff.CombatName + " with " + outcome.Attacker.CombatStuff.CombatWeapon.ItemName + "\n";
                richTextBox1.Text += "Attackroll: " + outcome.attackRoll.ToString() + "\n";
                richTextBox1.Text += "Defendroll: " + outcome.defendRoll.ToString() + "\n";
                richTextBox1.Text += "Result: " + outcome.Othertext.ToString() + "\n";
                if (outcome.Othertext == Utilities.AttackResultType.Hit)
                {
                    richTextBox1.Text += "Location: " + outcome.HitLocation + "\n";
                    richTextBox1.Text += "Hit Caliber: " + Convert.ToString(outcome.HitCaliber) + "\n";
                    richTextBox1.Text += "Hit Strength: " + Convert.ToString(outcome.HitStrength) + "\n";
                    richTextBox1.Text += "Strike Power: " + Convert.ToString(outcome.TotalStrikeAmountFromAllTypes()) + "\n\n";
                    richTextBox1.Text += "Harm: " + Convert.ToString(outcome.harm) + "\n" + "Bleed: " + Convert.ToString(outcome.bleed) + "\n" + "Disorientation: " + Convert.ToString(outcome.disorientation) + "\n" + "Impairment: " + Convert.ToString(outcome.impairment) + "\n" + "Trauma: " + Convert.ToString(outcome.trauma) + "\n" + "KO: " + Convert.ToString(outcome.ko) + "\n";
                }
                richTextBox1.Text += outcome.HitLocation.ToString() + "\n\n";
                CombatScripts.applyAttackOutcome(outcome);
                EffectHolder.ClearUselessEffects();
            }
        }
Exemple #14
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();
            }
        }