Пример #1
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();*/
        }
Пример #2
0
        public void RefreshThisCharacter()
        {
            this.Text            = ThisChar.CombatStuff.CombatName;
            lblOB.Text           = "+( " + Convert.ToString(EffectHolder.GetValidEffectsByEffect(ThisChar, EffectHolder.EffectType.OB)) + " )";
            lblDB.Text           = "+( " + Convert.ToString(EffectHolder.GetValidEffectsByEffect(ThisChar, EffectHolder.EffectType.DB)) + " )";
            lblFB.Text           = "+( " + Convert.ToString(Convert.ToDouble(EffectHolder.GetValidEffectsByEffect(ThisChar, EffectHolder.EffectType.Dexterity)) / 2) + " )";
            txtBoxHP.Text        = Convert.ToString(ThisChar.HitPoints + EffectHolder.GetValidEffectsByEffect(ThisChar, EffectHolder.EffectType.Health));
            txtBoxStamina.Text   = Convert.ToString(ThisChar.Stamina);
            richTextBox1.Text    = Utilities.translateCharacterStatusToDisplayString(ThisChar) + "\n\n";
            rtbLastDefenses.Text = "";
            foreach (Effect ef in ThisChar.TemporaryEffects)
            {
                richTextBox1.Text += ef.getDisplayString();
            }
            if (ThisChar.CombatStuff.defendResultsForDisplay != null &&
                ThisChar.CombatStuff.defendResultsForDisplay.Any())
            {
                foreach (List <String> lststr in ThisChar.CombatStuff.defendResultsForDisplay)
                {
                    rtbLastDefenses.Text += lststr[1] + "\n";
                    rtbLastDefenses.Text += lststr[2] + "\n";
                    if (lststr.Count > 10)
                    {
                        rtbLastDefenses.Text += lststr[10] + "\n";
                    }
                    rtbLastDefenses.Text += "\n";
                }
            }
            rtbInbound.Text  = "This Character's Message: \n";
            rtbInbound.Text += ThisChar.GoogleNinjaNotesInbound;
            rtbInbound.Text += "\n\nOther Messages To This Character:\n" + ThisChar.GoogleNinjaNotesRebound;
            rtbOutbound.Text = ThisChar.GoogleNinjaNotesOutbound;

            List <Weapon> WeaponList = ThisChar.Weapons;
            List <Shield> ShieldList = ThisChar.Shields;

            cboBoxWeapon.SelectedIndex = -1;
            cboBoxShield.SelectedIndex = -1;
            cboBoxWeapon.Items.Clear();
            cboBoxShield.Items.Clear();
            foreach (Weapon NowWep in WeaponList)
            {
                cboBoxWeapon.Items.Add(NowWep.ItemName);
            }
            foreach (Shield NowShield in ShieldList)
            {
                cboBoxShield.Items.Add(NowShield.ItemName);
            }
            if (cboBoxWeapon.Items.Count != 0)
            {
                cboBoxWeapon.SelectedIndex = 0;
            }
            if (cboBoxShield.Items.Count != 0)
            {
                cboBoxShield.SelectedIndex = 0;
            }
            if (!(ThisChar.CombatStuff.CombatWeapon == null))
            {
                cboBoxShield.Text = ThisChar.CombatStuff.CombatShield.ItemName;
                cboBoxWeapon.Text = ThisChar.CombatStuff.CombatWeapon.ItemName;
                txtBoxDB.Text     = Convert.ToString(ThisChar.CombatStuff.CombatDB);
                txtBoxOB.Text     = Convert.ToString(ThisChar.CombatStuff.CombatOB);
            }


            SetColorCorrectly();
        }
 public static double GetBaseHealth(Character c)
 {
     return(Convert.ToDouble(Convert.ToDouble((c.Statistics.Constitution) + EffectHolder.GetValidEffectsByEffect(c, EffectHolder.EffectType.Constitution)) * (2 + c.Skills.HPSkill * 0.25)));
 }
 public static double GetBaseStamina(Character c)
 {
     return(Convert.ToDouble((c.Statistics.Constitution + EffectHolder.GetValidEffectsByEffect(c, EffectHolder.EffectType.Constitution) + c.Skills.EnduranceSkill - 10) * 25 + 300));
 }
        public static AttackOutcome RunCombat(Character _attacker, Character _defender, double AttackRoll, double DefendRoll, Utilities.BodyParts?location)
        {
            AttackOutcome outcome = new AttackOutcome();

            _attacker.CombatStuff.aoForEnchantments = outcome;
            _defender.CombatStuff.aoForEnchantments = outcome;
            outcome.attackRoll = AttackRoll;
            outcome.defendRoll = DefendRoll;
            //this is to give the option of one-roll combat on the specific input of DefensiveRoll == -999.0

            /*
             * if (DefendRoll == -999.0)
             * {
             *  DefendRoll = 20 - AttackRoll;
             * }*/

            outcome.Attacker = _attacker;
            outcome.Defender = _defender;

            Weapon _attackerSelectedWeapon = _attacker.CombatStuff.CombatWeapon;
            Weapon _defenderSelectedWeapon = _defender.CombatStuff.CombatWeapon;
            Shield _attackerSelectedShield = _attacker.CombatStuff.CombatShield;
            Shield _defenderSelectedShield = _defender.CombatStuff.CombatShield;

            outcome.Notes.attackerWeaponName = _attackerSelectedWeapon.ItemName;
            outcome.Notes.defenderWeaponName = _defenderSelectedWeapon.ItemName;
            outcome.Notes.stun = -1 * EffectHolder.GetValidEffectsByEffect(_defender, EffectHolder.EffectType.Focus);

            double _attackerWeightFactor = GetWeightFactor(_attacker);
            double _defenderWeightFactor = GetWeightFactor(_defender);

            double _attackerStaminaFactor = GetStaminaFactor(_attacker);
            double _defenderStaminaFactor = GetStaminaFactor(_defender);
            //primary calculators
            double offensiveCalculator = (AttackRoll + _attacker.CombatStuff.CombatOB + _attackerSelectedWeapon.OffensiveBonus + _attackerSelectedShield.OffensiveBonus + EffectHolder.GetValidEffectsByEffect(_attacker, EffectHolder.EffectType.OB) + _attackerWeightFactor) * _attackerStaminaFactor;
            double defensiveCalculator = (DefendRoll + _defender.CombatStuff.CombatDB + _defenderSelectedWeapon.DefensiveBonus + _defenderSelectedShield.DefensiveBonus + EffectHolder.GetValidEffectsByEffect(_defender, EffectHolder.EffectType.DB) + _defenderWeightFactor) * _defenderStaminaFactor;

            foreach (Armor a in _attacker.Armor)
            {
                offensiveCalculator += a.OffensiveBonus;
            }
            foreach (Armor a in _defender.Armor)
            {
                defensiveCalculator += a.DefensiveBonus;
            }

            outcome.Notes.attackroll  = AttackRoll;
            outcome.Notes.attackValue = offensiveCalculator;
            outcome.Notes.defendRoll  = DefendRoll;
            outcome.Notes.defendValue = defensiveCalculator;

            EnchantmentUtilities.triggerAllEnchantmentsForChar(_attacker, new EnchantmentParameters()
            {
                triggerSource = EnchantmentUtilities.SourceTypes.Attack
            });
            EnchantmentUtilities.triggerAllEnchantmentsForChar(_defender, new EnchantmentParameters()
            {
                triggerSource = EnchantmentUtilities.SourceTypes.WasAttacked
            });

            //generate reflex
            double defenderReflex = CalculateReflex(_defender, defensiveCalculator);

            //adjust by a percentage if stamina is low
            defenderReflex = defenderReflex * _defenderStaminaFactor;

            outcome.Notes.reflex = defenderReflex;

            //generate blocking difficulty
            double attackerBlockingDifficulty = _attackerSelectedWeapon.BlockingDifficulty + EffectHolder.GetValidEffectsByEffect(_attacker, EffectHolder.EffectType.BlockingDifficulty) + 0.2 * offensiveCalculator;

            outcome.Notes.blockingDifficulty = attackerBlockingDifficulty;

            //apply 25% of blocking difficulty
            defensiveCalculator -= attackerBlockingDifficulty * 0.25;

            //generate block
            double defenderBlock = defensiveCalculator * (_defenderSelectedShield.Coverage + EffectHolder.GetValidEffectsByEffect(_defender, EffectHolder.EffectType.ShieldCoverage));

            outcome.Notes.block = defenderBlock;

            //apply rest of blocking difficulty
            defensiveCalculator -= attackerBlockingDifficulty * 0.75;

            //generate parry
            double defenderParry = defensiveCalculator * _defenderSelectedWeapon.ParryStrength / System.Math.Max(_attackerSelectedWeapon.ParryBreak, 0.01);

            outcome.Notes.parryBreak    = _attackerSelectedWeapon.ParryBreak;
            outcome.Notes.parryStrength = _defenderSelectedWeapon.ParryStrength;
            outcome.Notes.parry         = defenderParry;
            outcome.Notes.defendValueAfterBlockingDifficulty = defensiveCalculator;


            //perform dodge
            if (defenderReflex > 0)
            {
                offensiveCalculator -= defenderReflex;
            }

            //if the attack has been reduced to 0, it was dodged
            if (offensiveCalculator <= 0)
            {
                outcome.Othertext  = Utilities.AttackResultType.Miss;
                outcome.HitCaliber = offensiveCalculator;
                return(outcome);
            }

            outcome.Notes.attackAfterReflex = offensiveCalculator;

            //perform block
            if (defenderBlock > 0)
            {
                offensiveCalculator -= defenderBlock;
            }

            //if the attack has been reduced to 0, it was blocked
            if (offensiveCalculator <= 0)
            {
                outcome.Othertext  = Utilities.AttackResultType.Block;
                outcome.HitCaliber = offensiveCalculator;
                return(outcome);
            }

            outcome.Notes.attackAfterBlock = offensiveCalculator;

            //perform parry
            if (defenderParry > 0)
            {
                offensiveCalculator -= defenderParry;
            }

            //if the attack has been reduced to 0, it was parried
            if (offensiveCalculator <= 0)
            {
                outcome.Othertext  = Utilities.AttackResultType.Parry;
                outcome.HitCaliber = offensiveCalculator;
                return(outcome);
            }

            outcome.Notes.attackAfterParry = offensiveCalculator;
            if (location == null)
            {
                Utilities.FindCritLocation(outcome);
            }
            else
            {
                outcome.HitLocation = (Utilities.BodyParts)location;
            }

            //otherwise, attacker hit! do damage/armor calculation
            Dictionary <Utilities.DamageType, Double> tempDamageValues = new Dictionary <Utilities.DamageType, double>();

            foreach (Utilities.DamageType dt in _attackerSelectedWeapon.DamageTypes.Keys)
            {
                tempDamageValues.Add(dt, _attackerSelectedWeapon.DamageTypes[dt]);
            }
            foreach (Utilities.DamageType dt in Enum.GetValues(typeof(Utilities.DamageType)))
            {
                double addedDamage = EffectHolder.GetValidEffectsByEffectAndDamageType(_attacker, EffectHolder.EffectType.WeaponDamage, dt);
                if (addedDamage != 0)
                {
                    if (tempDamageValues.ContainsKey(dt))
                    {
                        tempDamageValues[dt] += addedDamage;
                    }
                    else
                    {
                        tempDamageValues.Add(dt, addedDamage);
                    }
                }
            }
            foreach (Utilities.DamageType dt in tempDamageValues.Keys)
            {
                Double strikeAmountForDamageType = offensiveCalculator * tempDamageValues[dt];
                outcome.HitStrength             = outcome.HitStrength + strikeAmountForDamageType;
                outcome.Notes.damageBeforeArmor = outcome.HitStrength;
                //actually percentage of damage that will go through
                double damageResistance = 1.0 - EffectHolder.GetValidEffectsByEffectAndDamageType(_defender, EffectHolder.EffectType.DamageResistance, null);
                damageResistance -= EffectHolder.GetValidEffectsByEffectAndDamageType(_defender, EffectHolder.EffectType.DamageResistance, dt);
                foreach (Armor arm in _defender.Armor)
                {
                    if (arm.CoveredAreas.Contains(outcome.HitLocation) && arm.DamageResistanceTypes.ContainsKey(dt))
                    {
                        //subtraction because a lower percentage of the damage will get through
                        damageResistance -= (arm.DamageResistanceTypes[dt]);
                    }
                }
                outcome.DamageTypes.Add(dt, Math.Max(0, (strikeAmountForDamageType * damageResistance)));
            }

            double generalDamageReduction     = EffectHolder.GetValidEffectsByEffectAndDamageType(_defender, EffectHolder.EffectType.DamageReduction, null);
            double totalDamageBeforeReduction = outcome.TotalStrikeAmountFromAllTypes();

            //weird things happen if this is less than or equal to zero
            if (totalDamageBeforeReduction > 0)
            {
                foreach (Utilities.DamageType dt in tempDamageValues.Keys)
                {
                    //the amount of damage that will be prevented
                    outcome.DamageTypes[dt] -= generalDamageReduction * (outcome.DamageTypes[dt] / totalDamageBeforeReduction);
                    outcome.DamageTypes[dt] -= EffectHolder.GetValidEffectsByEffectAndDamageType(_defender, EffectHolder.EffectType.DamageReduction, dt);
                    foreach (Armor arm in _defender.Armor)
                    {
                        if (arm.CoveredAreas.Contains(outcome.HitLocation) && arm.DamageReductionTypes.ContainsKey(dt))
                        {
                            outcome.DamageTypes[dt] -= (arm.DamageReductionTypes[dt]);
                        }
                    }
                    if (outcome.DamageTypes[dt] < 0)
                    {
                        outcome.DamageTypes[dt] = 0;
                    }
                }
            }



            outcome.Notes.damageAfterArmor = outcome.TotalStrikeAmountFromAllTypes();

            outcome.Othertext  = Utilities.AttackResultType.Hit;
            outcome.HitCaliber = offensiveCalculator;


            CritCalculator.CalculateCrit(outcome);

            EnchantmentUtilities.triggerAllEnchantmentsForChar(_attacker, new EnchantmentParameters()
            {
                triggerSource = EnchantmentUtilities.SourceTypes.PostAttack
            });
            EnchantmentUtilities.triggerAllEnchantmentsForChar(_defender, new EnchantmentParameters()
            {
                triggerSource = EnchantmentUtilities.SourceTypes.PostWasAttacked
            });

            return(outcome);
        }