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(); }
//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 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(); } }
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(); } }