Starsector API
Loading...
Searching...
No Matches
RecoveryOperations.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.skills;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.characters.DescriptionSkillEffect;
7import com.fs.starfarer.api.characters.FleetStatsSkillEffect;
8import com.fs.starfarer.api.characters.ShipSkillEffect;
9import com.fs.starfarer.api.combat.MutableShipStatsAPI;
10import com.fs.starfarer.api.combat.ShipAPI.HullSize;
11import com.fs.starfarer.api.fleet.MutableFleetStatsAPI;
12import com.fs.starfarer.api.impl.campaign.ids.Stats;
13import com.fs.starfarer.api.util.Misc;
14
15public class RecoveryOperations {
16
17 public static final float OWN_WEAPON_WING_RECOVERY_BONUS = 30f;
18// public static final float ENEMY_WEAPON_WING_RECOVERY_BONUS = 15f;
19// public static final float SHIP_RECOVERY_BONUS = 15f;
20 public static final float ENEMY_WEAPON_WING_RECOVERY_BONUS = 25f;
21 public static final float SHIP_RECOVERY_BONUS = 25f;
22 public static final float DMOD_REDUCTION = 2f;
23 public static final float CREW_LOSS_REDUCTION = 30f;
24
25 public static final float REPAIR_RATE_BONUS = 100f;
26
27 //public static final float COMBAT_SALVAGE_BONUS = 10f;
28 public static final float FUEL_SALVAGE_BONUS = 50f;
29
30 public static class Level0 implements DescriptionSkillEffect {
31 public String getString() {
32 float baseW = (int) Math.round(Global.getSettings().getFloat("salvageWeaponProb") * 100f);
33 float baseS = (int) Math.round(Global.getSettings().getFloat("baseShipRecoveryChance") * 100f);
34 float baseWO = (int) Math.round(Global.getSettings().getFloat("salvageOwnWeaponProb") * 100f);
35 float baseSO = (int) Math.round(Global.getSettings().getFloat("baseOwnShipRecoveryChance") * 100f);
36// return String.format(
37// "Base chance to recover weapons from lost ships is %d%%, or %d%% for weapons from your ships. " +
38// "Base chance for disabled ships to be recoverable is %d%%, or %d%% for your ships. " +
39 return String.format(
40 "The base chance to be recoverable is %d%% for disabled enemy ships, and %d%% for your ships. " +
41 "The base chance for weapons from disabled enemy ships to be recovered is %d%%, and %d%% for weapons from your ships. " +
42 "Ships that have broken apart have half the chance to be recoverable and always suffer lasting structural damage.",
43 (int)baseS, (int) baseSO, (int)baseW, (int)baseWO);
44// return "Base chance to recover weapons on lost ships is " + (int) baseW + "%. " +
45// "Base chance to recover disabled ships is " + (int) baseS + "%; " +
46// "ships that were broken apart have half the chance to be recovered and always suffer lasting structural damage.";
47 }
48 public Color[] getHighlightColors() {
49 Color h = Misc.getHighlightColor();
50 return new Color[] {h, h, h, h};
51 }
52 public String[] getHighlights() {
53 String baseW = "" + (int) Math.round(Global.getSettings().getFloat("salvageWeaponProb") * 100f) + "%";
54 String baseS = "" + (int) Math.round(Global.getSettings().getFloat("baseShipRecoveryChance") * 100f) + "%";
55 String baseWO = "" + (int) Math.round(Global.getSettings().getFloat("salvageOwnWeaponProb") * 100f) + "%";
56 String baseSO = "" + (int) Math.round(Global.getSettings().getFloat("baseOwnShipRecoveryChance") * 100f) + "%";
57 //return new String [] {baseW, baseWO, baseS, baseSO};
58 return new String [] {baseS, baseSO, baseW, baseWO};
59 }
60 public Color getTextColor() {
61 return null;
62 }
63 }
64
65 public static class Level1 implements FleetStatsSkillEffect {
66 public void apply(MutableFleetStatsAPI stats, String id, float level) {
67 stats.getDynamic().getMod(Stats.OWN_WEAPON_RECOVERY_MOD).modifyFlat(id, OWN_WEAPON_WING_RECOVERY_BONUS * 0.01f);
68 stats.getDynamic().getMod(Stats.OWN_WING_RECOVERY_MOD).modifyFlat(id, OWN_WEAPON_WING_RECOVERY_BONUS * 0.01f);
69 }
70
71 public void unapply(MutableFleetStatsAPI stats, String id) {
72 stats.getDynamic().getMod(Stats.OWN_WEAPON_RECOVERY_MOD).unmodify(id);
73 stats.getDynamic().getMod(Stats.OWN_WING_RECOVERY_MOD).unmodify(id);
74 }
75
76 public String getEffectDescription(float level) {
77 return "+" + (int) (OWN_WEAPON_WING_RECOVERY_BONUS) + "% chance to recover weapons and fighter LPCs from own ships lost in battle";
78 }
79
80 public String getEffectPerLevelDescription() {
81 return null;
82 }
83
84 public ScopeDescription getScopeDescription() {
85 return ScopeDescription.FLEET;
86 }
87 }
88
89 public static class Level1B implements FleetStatsSkillEffect {
90 public void apply(MutableFleetStatsAPI stats, String id, float level) {
91 stats.getDynamic().getMod(Stats.ENEMY_WEAPON_RECOVERY_MOD).modifyFlat(id, ENEMY_WEAPON_WING_RECOVERY_BONUS * 0.01f);
92 stats.getDynamic().getMod(Stats.ENEMY_WING_RECOVERY_MOD).modifyFlat(id, ENEMY_WEAPON_WING_RECOVERY_BONUS * 0.01f);
93 }
94
95 public void unapply(MutableFleetStatsAPI stats, String id) {
96 stats.getDynamic().getMod(Stats.ENEMY_WEAPON_RECOVERY_MOD).unmodify(id);
97 stats.getDynamic().getMod(Stats.ENEMY_WING_RECOVERY_MOD).unmodify(id);
98 }
99
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}
static SettingsAPI getSettings()
Definition Global.java:51