// checks public static bool CheckAttackLanded(this Creature attacker, Item weapon, Creature defender) { double attackersHitRate = (attacker.GetWeaponSkill(attacker.Body.MainHand) + (attacker.Stats.Attributes[Attribute.Dexterity] / 2.5) + (dice.Next(0, attacker.Stats.Attributes[Attribute.Luck]) / 10)) * (0.75 + 0.5 * attacker.Stats.Resources[Resource.SP] / attacker.Stats.Resources[Resource.MaxSP]); double defendersEvasion = ((defender.Stats.Attributes[Attribute.Agility] / 5) + (dice.Next(0, defender.Stats.Attributes[Attribute.Luck]) / 10)) * (0.75 + 0.5 * defender.Stats.Resources[Resource.SP] / defender.Stats.Resources[Resource.MaxSP]); double maxMissChance = 150; double chanceToMiss = maxMissChance - attackersHitRate; double chanceToDodge = attackersHitRate - (attackersHitRate - defendersEvasion); int diceRoll = Program.RNG.Next(0, (int)maxMissChance); if (diceRoll <= chanceToMiss) { Program.MsgConsole.WriteLine($"{attacker.Name}'s attack missed."); attacker.LvlWeaponSkill(weapon, 10); return(false); } diceRoll = dice.Next(0, (int)attackersHitRate + 2); if (diceRoll <= chanceToDodge) { Program.MsgConsole.WriteLine($"{defender.Name} evaded {attacker.Name}'s attack."); attacker.LvlWeaponSkill(weapon, 20); return(false); } attacker.LvlWeaponSkill(weapon, 40); return(true); }
public static int GetWepDmg(this Item weapon, Creature c) { int damage; // determine the damage value if (weapon != null) { // minimum skill deals half dmg, max skill deals full damage damage = (int)(weapon.Damage * (.5 + (double)c.GetWeaponSkill(weapon) / 200)); } else // the damage type is bone, for your fist { damage = (int)(Physics.ShearYields[Material.Bone] * (.5 + (double)c.Stats.Skills[Skill.Brawling] / 200)); } return(damage); }
public static int GetWeaponCost(this Item weapon, Creature c) { int returnvalue; int multiplier = 1; if (weapon is Weapon w && w.TwoHanded) { multiplier = 2; } if (weapon != null) { if (weapon is MeleeWeapon) { if (weapon is Sword) { returnvalue = 8 - (c.GetWeaponSkill(weapon) / 25); } else if (weapon is Dagger) { returnvalue = 6 - (c.GetWeaponSkill(weapon) / 33); } else if (weapon is Mace) { returnvalue = 16 - (c.GetWeaponSkill(weapon) / 12); } else if (weapon is Axe) { returnvalue = 16 - (c.GetWeaponSkill(weapon) / 12); } else if (weapon is Spear) { returnvalue = 8 - (c.GetWeaponSkill(weapon) / 25); } else { returnvalue = -1; } } else { returnvalue = 8 - (c.GetWeaponSkill(weapon) / 25); } } else { returnvalue = 4 - (c.Stats.Skills[Skill.Brawling] / 25); } return(returnvalue * multiplier); }