001package com.fs.starfarer.api.impl.campaign.skills; 002 003import com.fs.starfarer.api.characters.ShipSkillEffect; 004import com.fs.starfarer.api.combat.MutableShipStatsAPI; 005import com.fs.starfarer.api.combat.ShipAPI; 006import com.fs.starfarer.api.combat.ShipAPI.HullSize; 007import com.fs.starfarer.api.fleet.FleetMemberAPI; 008 009public class ImpactMitigation { 010 011// public static final float ARMOR_BONUS = 50; 012 public static float MANEUVERABILITY_BONUS_LARGE = 50; 013 public static float MANEUVERABILITY_BONUS_SMALL = 25; 014 015 public static float MAX_DAMAGE_REDUCTION_BONUS = 0.05f; 016// public static float MIN_ARMOR_FRACTION_BONUS = 0.1f; 017 public static float ARMOR_DAMAGE_REDUCTION = 25f; 018 public static float ARMOR_KINETIC_REDUCTION = 50f; 019 020 public static float DAMAGE_TO_MODULES_REDUCTION = 50; 021 022 public static float ELITE_HIT_STRENGTH_PERCENT = 10f; 023 024 public static HullSize getHullSize(MutableShipStatsAPI stats) { 025 if (stats.getEntity() instanceof ShipAPI) { 026 ShipAPI ship = (ShipAPI) stats.getEntity(); 027 return ship.getHullSize(); 028 } else { 029 FleetMemberAPI member = stats.getFleetMember(); 030 if (member == null) return HullSize.CAPITAL_SHIP; 031 return member.getHullSpec().getHullSize(); 032 } 033 } 034 035// public static class Level1 implements ShipSkillEffect { 036// public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 037// //stats.getArmorBonus().modifyFlat(id, ARMOR_BONUS); 038// stats.getEffectiveArmorBonus().modifyFlat(id, ARMOR_BONUS); 039// } 040// 041// public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 042// //stats.getArmorBonus().unmodify(id); 043// stats.getEffectiveArmorBonus().unmodify(id); 044// } 045// 046// public String getEffectDescription(float level) { 047// return "+" + (int)(ARMOR_BONUS) + " armor for damage reduction calculation only"; 048// //return "+" + (int)(ARMOR_BONUS) + " maximum armor"; 049// } 050// 051// public String getEffectPerLevelDescription() { 052// return null; 053// } 054// 055// public ScopeDescription getScopeDescription() { 056// return ScopeDescription.PILOTED_SHIP; 057// } 058// 059// } 060 061 public static class Level2 implements ShipSkillEffect { 062 063 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 064 stats.getArmorDamageTakenMult().modifyMult(id, 1f - ARMOR_DAMAGE_REDUCTION / 100f); 065 } 066 067 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 068 stats.getArmorDamageTakenMult().unmodify(id); 069 } 070 071 public String getEffectDescription(float level) { 072 return "-" + (int)(ARMOR_DAMAGE_REDUCTION) + "% armor damage taken"; 073 } 074 075 public String getEffectPerLevelDescription() { 076 return null; 077 } 078 079 public ScopeDescription getScopeDescription() { 080 return ScopeDescription.PILOTED_SHIP; 081 } 082 } 083 084 public static class Level3 implements ShipSkillEffect { 085 086 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 087 stats.getKineticArmorDamageTakenMult().modifyMult(id, 1f - ARMOR_KINETIC_REDUCTION / 100f); 088 } 089 090 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 091 stats.getKineticArmorDamageTakenMult().unmodify(id); 092 } 093 094 public String getEffectDescription(float level) { 095 return "-" + (int)(ARMOR_KINETIC_REDUCTION) + "% kinetic damage taken by armor"; 096 } 097 098 public String getEffectPerLevelDescription() { 099 return null; 100 } 101 102 public ScopeDescription getScopeDescription() { 103 return ScopeDescription.PILOTED_SHIP; 104 } 105 } 106 107 public static class Level4 implements ShipSkillEffect { 108 109 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 110 stats.getEngineDamageTakenMult().modifyMult(id, 1f - DAMAGE_TO_MODULES_REDUCTION / 100f); 111 stats.getWeaponDamageTakenMult().modifyMult(id, 1f - DAMAGE_TO_MODULES_REDUCTION / 100f); 112 } 113 114 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 115 stats.getEngineDamageTakenMult().unmodify(id); 116 stats.getWeaponDamageTakenMult().unmodify(id); 117 } 118 119 public String getEffectDescription(float level) { 120 return "-" + (int)(DAMAGE_TO_MODULES_REDUCTION) + "% weapon and engine damage taken"; 121 } 122 123 public String getEffectPerLevelDescription() { 124 return null; 125 } 126 127 public ScopeDescription getScopeDescription() { 128 return ScopeDescription.PILOTED_SHIP; 129 } 130 } 131 public static class Level5 implements ShipSkillEffect { 132 133 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 134 stats.getMaxArmorDamageReduction().modifyFlat(id, MAX_DAMAGE_REDUCTION_BONUS); 135 } 136 137 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 138 stats.getMaxArmorDamageReduction().unmodify(id); 139 } 140 141 public String getEffectDescription(float level) { 142 return "Maximum damage reduction by armor increased from 85% to 90%"; 143 } 144 145 public String getEffectPerLevelDescription() { 146 return null; 147 } 148 149 public ScopeDescription getScopeDescription() { 150 return ScopeDescription.PILOTED_SHIP; 151 } 152 } 153 154 155 public static class Level6 implements ShipSkillEffect { 156 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 157 float bonus = MANEUVERABILITY_BONUS_LARGE; 158 HullSize size = getHullSize(stats); 159 if (size == HullSize.FRIGATE || size == HullSize.DESTROYER) { 160 bonus = MANEUVERABILITY_BONUS_SMALL; 161 } 162 stats.getAcceleration().modifyPercent(id, bonus); 163 stats.getDeceleration().modifyPercent(id, bonus); 164 stats.getTurnAcceleration().modifyPercent(id, bonus * 2f); 165 stats.getMaxTurnRate().modifyPercent(id, bonus); 166 } 167 168 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 169 stats.getAcceleration().unmodify(id); 170 stats.getDeceleration().unmodify(id); 171 stats.getTurnAcceleration().unmodify(id); 172 stats.getMaxTurnRate().unmodify(id); 173 } 174 175 public String getEffectDescription(float level) { 176 return "+" + (int)(MANEUVERABILITY_BONUS_LARGE) + "% maneuverability for capital ships and cruisers, " 177 + "+" + (int)(MANEUVERABILITY_BONUS_SMALL) + "% for destroyers and frigates"; 178 } 179 180 public String getEffectPerLevelDescription() { 181 return null; 182 } 183 184 public ScopeDescription getScopeDescription() { 185 return ScopeDescription.PILOTED_SHIP; 186 } 187 } 188 189 public static class Level7 implements ShipSkillEffect { 190 191 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 192 stats.getHitStrengthBonus().modifyPercent(id, ELITE_HIT_STRENGTH_PERCENT); 193 } 194 195 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 196 stats.getHitStrengthBonus().unmodifyPercent(id); 197 } 198 199 public String getEffectDescription(float level) { 200 return "+" + (int)(ELITE_HIT_STRENGTH_PERCENT) + "% hit strength vs armor, for damage reduction calculation only"; 201 } 202 203 public String getEffectPerLevelDescription() { 204 return null; 205 } 206 207 public ScopeDescription getScopeDescription() { 208 return ScopeDescription.PILOTED_SHIP; 209 } 210 } 211 212// public static class Level2 implements ShipSkillEffect { 213// 214// public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 215// stats.getMinArmorFraction().modifyFlat(id, MIN_ARMOR_FRACTION_BONUS); 216// } 217// 218// public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 219// stats.getMinArmorFraction().unmodify(id); 220// } 221// 222// public String getEffectDescription(float level) { 223// return "Minimum armor value for damage reduction raised from 5% to 15% of maximum"; 224// } 225// 226// public String getEffectPerLevelDescription() { 227// return null; 228// } 229// 230// public ScopeDescription getScopeDescription() { 231// return ScopeDescription.PILOTED_SHIP; 232// } 233// } 234 235 236}