private float EstimateHitDistance(ISoldier soldier, RangedWeapon weapon, float targetSize, int freeHands) { float baseTotal = soldier.GetTotalSkillValue(weapon.Template.RelatedSkill); if (weapon.Template.Location == EquipLocation.TwoHand && freeHands == 1) { // unless the soldier is strong enough, the weapon can't be used one-handed if (weapon.Template.RequiredStrength * 1.5f > soldier.Strength) { return(0); } if (weapon.Template.RequiredStrength * 2 > soldier.Strength) { baseTotal -= (weapon.Template.RequiredStrength * 2) - soldier.Strength; } } // we'd like to get to a range where at least 1 bullet will hit more often than not when we aim // +1 for all-out attack, - ROF after the first shot // z value of 0.43 is baseTotal = baseTotal + 1 + weapon.Template.Accuracy; baseTotal += BattleModifiersUtil.CalculateRateOfFireModifier(weapon.Template.RateOfFire); baseTotal += BattleModifiersUtil.CalculateSizeModifier(targetSize); // if the total doesn't get to 10.5, there will be no range where there's a good chance of hitting, so just keep getting closer if (baseTotal < 10.5) { return(0); } return(BattleModifiersUtil.GetRangeForModifier(10.5f - baseTotal)); }
public void ApplySoldierWorkExperience(ISoldier soldier, float points) { float powerArmorSkill = soldier.GetTotalSkillValue(_skillsByName["Power Armor"]); // if any gunnery, ranged, melee, or vehicle skill is below the PA skill, focus on improving PA float gunnerySkill = soldier.GetTotalSkillValue(soldier.GetBestSkillInCategory(SkillCategory.Gunnery).BaseSkill); float meleeSkill = soldier.GetTotalSkillValue(soldier.GetBestSkillInCategory(SkillCategory.Melee).BaseSkill); float rangedSkill = soldier.GetTotalSkillValue(soldier.GetBestSkillInCategory(SkillCategory.Ranged).BaseSkill); float vehicleSkill = soldier.GetTotalSkillValue(soldier.GetBestSkillInCategory(SkillCategory.Vehicle).BaseSkill); float[] floatArray = { gunnerySkill, meleeSkill, rangedSkill, vehicleSkill }; float totalMax = Mathf.Max(floatArray); if (totalMax > powerArmorSkill) { soldier.AddSkillPoints(_skillsByName["Power Armor"], points); } else { ApplyMarineWorkExperienceByType(soldier, points); } }