001package com.fs.starfarer.api.impl.campaign.skills; 002 003import java.awt.Color; 004 005import com.fs.starfarer.api.Global; 006import com.fs.starfarer.api.characters.DescriptionSkillEffect; 007import com.fs.starfarer.api.characters.FleetStatsSkillEffect; 008import com.fs.starfarer.api.characters.ShipSkillEffect; 009import com.fs.starfarer.api.combat.MutableShipStatsAPI; 010import com.fs.starfarer.api.combat.ShipAPI.HullSize; 011import com.fs.starfarer.api.fleet.MutableFleetStatsAPI; 012import com.fs.starfarer.api.impl.campaign.ids.Stats; 013import com.fs.starfarer.api.util.Misc; 014 015public class RecoveryOperations { 016 017 public static final float OWN_WEAPON_WING_RECOVERY_BONUS = 30f; 018// public static final float ENEMY_WEAPON_WING_RECOVERY_BONUS = 15f; 019// public static final float SHIP_RECOVERY_BONUS = 15f; 020 public static final float ENEMY_WEAPON_WING_RECOVERY_BONUS = 25f; 021 public static final float SHIP_RECOVERY_BONUS = 25f; 022 public static final float DMOD_REDUCTION = 2f; 023 public static final float CREW_LOSS_REDUCTION = 30f; 024 025 public static final float REPAIR_RATE_BONUS = 100f; 026 027 //public static final float COMBAT_SALVAGE_BONUS = 10f; 028 public static final float FUEL_SALVAGE_BONUS = 50f; 029 030 public static class Level0 implements DescriptionSkillEffect { 031 public String getString() { 032 float baseW = (int) Math.round(Global.getSettings().getFloat("salvageWeaponProb") * 100f); 033 float baseS = (int) Math.round(Global.getSettings().getFloat("baseShipRecoveryChance") * 100f); 034 float baseWO = (int) Math.round(Global.getSettings().getFloat("salvageOwnWeaponProb") * 100f); 035 float baseSO = (int) Math.round(Global.getSettings().getFloat("baseOwnShipRecoveryChance") * 100f); 036// return String.format( 037// "Base chance to recover weapons from lost ships is %d%%, or %d%% for weapons from your ships. " + 038// "Base chance for disabled ships to be recoverable is %d%%, or %d%% for your ships. " + 039 return String.format( 040 "The base chance to be recoverable is %d%% for disabled enemy ships, and %d%% for your ships. " + 041 "The base chance for weapons from disabled enemy ships to be recovered is %d%%, and %d%% for weapons from your ships. " + 042 "Ships that have broken apart have half the chance to be recoverable and always suffer lasting structural damage.", 043 (int)baseS, (int) baseSO, (int)baseW, (int)baseWO); 044// return "Base chance to recover weapons on lost ships is " + (int) baseW + "%. " + 045// "Base chance to recover disabled ships is " + (int) baseS + "%; " + 046// "ships that were broken apart have half the chance to be recovered and always suffer lasting structural damage."; 047 } 048 public Color[] getHighlightColors() { 049 Color h = Misc.getHighlightColor(); 050 return new Color[] {h, h, h, h}; 051 } 052 public String[] getHighlights() { 053 String baseW = "" + (int) Math.round(Global.getSettings().getFloat("salvageWeaponProb") * 100f) + "%"; 054 String baseS = "" + (int) Math.round(Global.getSettings().getFloat("baseShipRecoveryChance") * 100f) + "%"; 055 String baseWO = "" + (int) Math.round(Global.getSettings().getFloat("salvageOwnWeaponProb") * 100f) + "%"; 056 String baseSO = "" + (int) Math.round(Global.getSettings().getFloat("baseOwnShipRecoveryChance") * 100f) + "%"; 057 //return new String [] {baseW, baseWO, baseS, baseSO}; 058 return new String [] {baseS, baseSO, baseW, baseWO}; 059 } 060 public Color getTextColor() { 061 return null; 062 } 063 } 064 065 public static class Level1 implements FleetStatsSkillEffect { 066 public void apply(MutableFleetStatsAPI stats, String id, float level) { 067 stats.getDynamic().getMod(Stats.OWN_WEAPON_RECOVERY_MOD).modifyFlat(id, OWN_WEAPON_WING_RECOVERY_BONUS * 0.01f); 068 stats.getDynamic().getMod(Stats.OWN_WING_RECOVERY_MOD).modifyFlat(id, OWN_WEAPON_WING_RECOVERY_BONUS * 0.01f); 069 } 070 071 public void unapply(MutableFleetStatsAPI stats, String id) { 072 stats.getDynamic().getMod(Stats.OWN_WEAPON_RECOVERY_MOD).unmodify(id); 073 stats.getDynamic().getMod(Stats.OWN_WING_RECOVERY_MOD).unmodify(id); 074 } 075 076 public String getEffectDescription(float level) { 077 return "+" + (int) (OWN_WEAPON_WING_RECOVERY_BONUS) + "% chance to recover weapons and fighter LPCs from own ships lost in battle"; 078 } 079 080 public String getEffectPerLevelDescription() { 081 return null; 082 } 083 084 public ScopeDescription getScopeDescription() { 085 return ScopeDescription.FLEET; 086 } 087 } 088 089 public static class Level1B implements FleetStatsSkillEffect { 090 public void apply(MutableFleetStatsAPI stats, String id, float level) { 091 stats.getDynamic().getMod(Stats.ENEMY_WEAPON_RECOVERY_MOD).modifyFlat(id, ENEMY_WEAPON_WING_RECOVERY_BONUS * 0.01f); 092 stats.getDynamic().getMod(Stats.ENEMY_WING_RECOVERY_MOD).modifyFlat(id, ENEMY_WEAPON_WING_RECOVERY_BONUS * 0.01f); 093 } 094 095 public void unapply(MutableFleetStatsAPI stats, String id) { 096 stats.getDynamic().getMod(Stats.ENEMY_WEAPON_RECOVERY_MOD).unmodify(id); 097 stats.getDynamic().getMod(Stats.ENEMY_WING_RECOVERY_MOD).unmodify(id); 098 } 099 100 public String getEffectDescription(float level) { 101 return "+" + (int) (ENEMY_WEAPON_WING_RECOVERY_BONUS) + "% chance to recover weapons and fighter LPCs from enemy ships"; 102 } 103 104 public String getEffectPerLevelDescription() { 105 return null; 106 } 107 108 public ScopeDescription getScopeDescription() { 109 return ScopeDescription.FLEET; 110 } 111 } 112 113 public static class Level2 implements FleetStatsSkillEffect { 114 public void apply(MutableFleetStatsAPI stats, String id, float level) { 115 stats.getDynamic().getMod(Stats.SHIP_RECOVERY_MOD).modifyFlat(id, SHIP_RECOVERY_BONUS * 0.01f); 116 } 117 118 public void unapply(MutableFleetStatsAPI stats, String id) { 119 stats.getDynamic().getMod(Stats.SHIP_RECOVERY_MOD).unmodify(id); 120 } 121 122 public String getEffectDescription(float level) { 123 return "+" + (int) (SHIP_RECOVERY_BONUS) + "% chance to recover disabled ships after battle"; 124 } 125 126 public String getEffectPerLevelDescription() { 127 return null; 128 } 129 130 public ScopeDescription getScopeDescription() { 131 return ScopeDescription.FLEET; 132 } 133 } 134 135 136 public static class Level2A implements ShipSkillEffect { 137 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 138 stats.getCrewLossMult().modifyMult(id, 1f - CREW_LOSS_REDUCTION / 100f); 139 } 140 141 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 142 stats.getCrewLossMult().unmodify(id); 143 } 144 145 public String getEffectDescription(float level) { 146 return "-" + (int)(CREW_LOSS_REDUCTION) + "% crew lost due to hull damage in combat"; 147 } 148 149 public String getEffectPerLevelDescription() { 150 return null; 151 } 152 153 public ScopeDescription getScopeDescription() { 154 return ScopeDescription.ALL_SHIPS; 155 } 156 } 157 158 public static class Level2B implements FleetStatsSkillEffect { 159 public void apply(MutableFleetStatsAPI stats, String id, float level) { 160 stats.getDynamic().getStat(Stats.NON_COMBAT_CREW_LOSS_MULT).modifyMult(id, 1f - CREW_LOSS_REDUCTION / 100f); 161 } 162 163 public void unapply(MutableFleetStatsAPI stats, String id) { 164 stats.getDynamic().getStat(Stats.NON_COMBAT_CREW_LOSS_MULT).unmodify(id); 165 } 166 167 public String getEffectDescription(float level) { 168 return "-" + (int)(CREW_LOSS_REDUCTION) + "% crew lost in non-combat operations"; 169 } 170 171 public String getEffectPerLevelDescription() { 172 return null; 173 } 174 175 public ScopeDescription getScopeDescription() { 176 return ScopeDescription.FLEET; 177 } 178 } 179 180 181 public static class Level3 implements FleetStatsSkillEffect { 182 public void apply(MutableFleetStatsAPI stats, String id, float level) { 183 stats.getDynamic().getMod(Stats.SHIP_DMOD_REDUCTION).modifyFlat(id, DMOD_REDUCTION); 184 } 185 186 public void unapply(MutableFleetStatsAPI stats, String id) { 187 stats.getDynamic().getMod(Stats.SHIP_DMOD_REDUCTION).unmodify(id); 188 } 189 190 public String getEffectDescription(float level) { 191 //return "Recovered non-friendly ships have an average of " + (int) DMOD_REDUCTION + " less subsystem with lasting damage"; 192 //return "Recovered ships have up to " + (int) DMOD_REDUCTION + " less d-mods"; 193 return "Recovered ships have fewer d-mods on average"; 194 } 195 196 public String getEffectPerLevelDescription() { 197 return null; 198 } 199 200 public ScopeDescription getScopeDescription() { 201 return ScopeDescription.FLEET; 202 } 203 } 204 205 public static class Level3B implements FleetStatsSkillEffect { 206 public void apply(MutableFleetStatsAPI stats, String id, float level) { 207// stats.getDynamic().getStat(Stats.BATTLE_SALVAGE_MULT_FLEET).modifyFlat(id, COMBAT_SALVAGE_BONUS * 0.01f); 208// stats.getDynamic().getStat(Stats.SALVAGE_VALUE_MULT_FLEET).modifyFlat(id, COMBAT_SALVAGE_BONUS * 0.01f); 209 stats.getDynamic().getStat(Stats.FUEL_SALVAGE_VALUE_MULT_FLEET).modifyFlat(id, FUEL_SALVAGE_BONUS * 0.01f); 210 } 211 212 public void unapply(MutableFleetStatsAPI stats, String id) { 213// stats.getDynamic().getStat(Stats.BATTLE_SALVAGE_MULT_FLEET).unmodify(id); 214// stats.getDynamic().getStat(Stats.SALVAGE_VALUE_MULT_FLEET).unmodify(id); 215 stats.getDynamic().getStat(Stats.FUEL_SALVAGE_VALUE_MULT_FLEET).unmodify(id); 216 } 217 218 public String getEffectDescription(float level) { 219 float max = 0f; 220 max += FUEL_SALVAGE_BONUS; 221 return "+" + (int) max + "% fuel salvaged"; 222 } 223 224 public String getEffectPerLevelDescription() { 225 return null; 226 } 227 228 public ScopeDescription getScopeDescription() { 229 return ScopeDescription.FLEET; 230 } 231 } 232 233}