Starsector API
Loading...
Searching...
No Matches
FieldRepairs.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.skills;
2
3import com.fs.starfarer.api.campaign.FleetDataAPI;
4import com.fs.starfarer.api.characters.CharacterStatsSkillEffect;
5import com.fs.starfarer.api.characters.FleetStatsSkillEffect;
6import com.fs.starfarer.api.characters.FleetTotalItem;
7import com.fs.starfarer.api.characters.FleetTotalSource;
8import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;
9import com.fs.starfarer.api.characters.ShipSkillEffect;
10import com.fs.starfarer.api.characters.SkillSpecAPI;
11import com.fs.starfarer.api.combat.MutableShipStatsAPI;
12import com.fs.starfarer.api.combat.ShipAPI.HullSize;
13import com.fs.starfarer.api.fleet.MutableFleetStatsAPI;
14import com.fs.starfarer.api.impl.campaign.ids.Stats;
15import com.fs.starfarer.api.ui.TooltipMakerAPI;
16
17public class FieldRepairs {
18
19 public static final float MIN_HULL = 30f;
20 public static final float MAX_HULL = 40f;
21
22 public static final float MIN_CR = 30f;
23 public static final float MAX_CR = 40f;
24
25 public static final float REPAIR_RATE_BONUS = 50f;
26 public static final float INSTA_REPAIR_PERCENT = 25f;
27 //public static final float DMOD_REDUCTION = 2f;
28
29
30 public static class Level5A implements FleetStatsSkillEffect {
31 public void apply(MutableFleetStatsAPI stats, String id, float level) {
32 stats.getDynamic().getMod(Stats.RECOVERED_HULL_MIN).modifyFlat(id, MIN_HULL * 0.01f);
33 stats.getDynamic().getMod(Stats.RECOVERED_HULL_MAX).modifyFlat(id, MAX_HULL * 0.01f);
34 }
35
36 public void unapply(MutableFleetStatsAPI stats, String id) {
37 stats.getDynamic().getMod(Stats.RECOVERED_HULL_MIN).unmodify(id);
38 stats.getDynamic().getMod(Stats.RECOVERED_HULL_MAX).unmodify(id);
39 }
40
41 public String getEffectDescription(float level) {
42 return "Recovered ships start with " + (int) MIN_HULL + "-" + (int)MAX_HULL + "% hull integrity";
43 }
44
45 public String getEffectPerLevelDescription() {
46 return null;
47 }
48
49 public ScopeDescription getScopeDescription() {
50 return ScopeDescription.FLEET;
51 }
52 }
53
54 public static class Level5B implements FleetStatsSkillEffect {
55 public void apply(MutableFleetStatsAPI stats, String id, float level) {
56 stats.getDynamic().getMod(Stats.RECOVERED_CR_MIN).modifyFlat(id, MIN_CR * 0.01f);
57 stats.getDynamic().getMod(Stats.RECOVERED_CR_MAX).modifyFlat(id, MAX_CR * 0.01f);
58 }
59
60 public void unapply(MutableFleetStatsAPI stats, String id) {
61 stats.getDynamic().getMod(Stats.RECOVERED_CR_MIN).unmodify(id);
62 stats.getDynamic().getMod(Stats.RECOVERED_CR_MAX).unmodify(id);
63 }
64
65 public String getEffectDescription(float level) {
66 return "Recovered ships start with " + (int) MIN_CR + "-" + (int)MAX_CR + "% combat readiness";
67 }
68
69 public String getEffectPerLevelDescription() {
70 return null;
71 }
72
73 public ScopeDescription getScopeDescription() {
74 return ScopeDescription.FLEET;
75 }
76 }
77
78// public static class Level1 implements CharacterStatsSkillEffect {
79// public void apply(MutableCharacterStatsAPI stats, String id, float level) {
80// stats.getRepairRateMult().modifyPercent(id, REPAIR_RATE_BONUS);
81// }
82//
83// public void unapply(MutableCharacterStatsAPI stats, String id) {
84// stats.getRepairRateMult().unmodify(id);
85// }
86//
87// public String getEffectDescription(float level) {
88// return "" + (int) REPAIR_RATE_BONUS + "% faster ship repairs";
89// }
90//
91// public String getEffectPerLevelDescription() {
92// return null;
93// }
94//
95// public ScopeDescription getScopeDescription() {
96// return ScopeDescription.ALL_SHIPS;
97// }
98// }
99
100 public static class Level1 extends BaseSkillEffectDescription implements CharacterStatsSkillEffect, FleetTotalSource {
101
102 public FleetTotalItem getFleetTotalItem() {
103 return getOPTotal();
104 }
105
106 public void apply(MutableCharacterStatsAPI stats, String id, float level) {
107 //if (!isCivilian(stats)) {
108 FleetDataAPI data = null;
109 if (stats != null && stats.getFleet() != null) {
110 data = stats.getFleet().getFleetData();
111 }
112 float repBonus = computeAndCacheThresholdBonus(data, stats, "fr_repRate", REPAIR_RATE_BONUS, ThresholdBonusType.OP_ALL);
113 stats.getRepairRateMult().modifyPercent(id, repBonus);
114 //}
115 }
116
117 public void unapply(MutableCharacterStatsAPI stats, String id) {
118 stats.getRepairRateMult().unmodify(id);
119 }
120
121 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
122 TooltipMakerAPI info, float width) {
123 init(stats, skill);
124
125 FleetDataAPI data = null;
126 if (stats != null && stats.getFleet() != null) {
127 data = stats.getFleet().getFleetData();
128 }
129 float damBonus = computeAndCacheThresholdBonus(data, stats, "fr_repRate", REPAIR_RATE_BONUS, ThresholdBonusType.OP_ALL);
130
131 info.addPara("+%s ship repair rate outside of combat (maximum: %s)", 0f, hc, hc,
132 "" + (int) damBonus + "%",
133 "" + (int) REPAIR_RATE_BONUS + "%");
134 //addOPThresholdInfo(info, data, stats, OP_LOW_THRESHOLD);
135 //info.addSpacer(5f);
136 }
137
138 public ScopeDescription getScopeDescription() {
139 return ScopeDescription.ALL_SHIPS;
140 }
141 }
142
143 public static class Level2 extends BaseSkillEffectDescription implements ShipSkillEffect, FleetTotalSource {
144
145 public FleetTotalItem getFleetTotalItem() {
146 return getOPTotal();
147 }
148
149 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
150 //if (!isCivilian(stats)) {
151 float instaRep = computeAndCacheThresholdBonus(stats, "fr_instaRep", INSTA_REPAIR_PERCENT, ThresholdBonusType.OP_ALL);
152 stats.getDynamic().getMod(Stats.INSTA_REPAIR_FRACTION).modifyFlat(id, instaRep * 0.01f);
153 //}
154 }
155
156 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
157 stats.getDynamic().getMod(Stats.INSTA_REPAIR_FRACTION).unmodifyFlat(id);
158 }
159
160 public String getEffectDescription(float level) {
161 return null;
162 }
163
164 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
165 TooltipMakerAPI info, float width) {
166 init(stats, skill);
167
168 FleetDataAPI data = getFleetData(null);
169 float instaRep = computeAndCacheThresholdBonus(data, stats, "fr_instaRep", INSTA_REPAIR_PERCENT, ThresholdBonusType.OP_ALL);
170
171 info.addPara("%s of hull and armor damage taken repaired after combat ends, at no cost (maximum: %s)", 0f, hc, hc,
172 "" + (int) instaRep + "%",
173 "" + (int) INSTA_REPAIR_PERCENT + "%");
174 addOPThresholdAll(info, data, stats, OP_ALL_THRESHOLD);
175
176 info.addSpacer(5f);
177 }
178
179 public ScopeDescription getScopeDescription() {
180 return ScopeDescription.ALL_SHIPS;
181 }
182 }
183
184
185
186// public static class Level2 implements ShipSkillEffect {
187// public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
188// stats.getDynamic().getMod(Stats.INSTA_REPAIR_FRACTION).modifyFlat(id, INSTA_REPAIR);
189// }
190//
191// public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
192// stats.getDynamic().getMod(Stats.INSTA_REPAIR_FRACTION).unmodify(id);
193// }
194//
195// public String getEffectDescription(float level) {
196// return "" + (int) Math.round(INSTA_REPAIR * 100f) + "% of hull and armor damage taken repaired after combat ends, at no cost";
197// }
198//
199// public String getEffectPerLevelDescription() {
200// return null;
201// }
202//
203// public ScopeDescription getScopeDescription() {
204// return ScopeDescription.ALL_SHIPS;
205// }
206// }
207
208
209// public static class Level3 implements FleetStatsSkillEffect {
210// public void apply(MutableFleetStatsAPI stats, String id, float level) {
211// stats.getDynamic().getMod(Stats.SHIP_DMOD_REDUCTION).modifyFlat(id, DMOD_REDUCTION);
212// }
213//
214// public void unapply(MutableFleetStatsAPI stats, String id) {
215// stats.getDynamic().getMod(Stats.SHIP_DMOD_REDUCTION).unmodifyFlat(id);
216// }
217//
218// public String getEffectDescription(float level) {
219// //return "Recovered non-friendly ships have an average of " + (int) DMOD_REDUCTION + " less subsystem with lasting damage";
220// //return "Recovered ships have up to " + (int) DMOD_REDUCTION + " less d-mods";
221// return "Recovered ships have fewer d-mods on average";
222// }
223//
224// public String getEffectPerLevelDescription() {
225// return null;
226// }
227//
228// public ScopeDescription getScopeDescription() {
229// return ScopeDescription.FLEET;
230// }
231// }
232
233// public static class Level4 implements FleetStatsSkillEffect {
234// public void apply(MutableFleetStatsAPI stats, String id, float level) {
235// }
236//
237// public void unapply(MutableFleetStatsAPI stats, String id) {
238// }
239//
240// public String getEffectDescription(float level) {
241// if (FieldRepairsScript.MONTHS_PER_DMOD_REMOVAL == 1) {
242// return "Chance to remove one d-mod per month from a randomly selected ship in your fleet";
243// } else if (FieldRepairsScript.MONTHS_PER_DMOD_REMOVAL == 2) {
244// return "Chance to remove a d-mod from a randomly selected ship in your fleet every two months";
245// } else {
246// return "Chance to remove a d-mod from a randomly selected ship in your fleet every " +
247// FieldRepairsScript.MONTHS_PER_DMOD_REMOVAL + " months";
248// }
249// }
250//
251// public String getEffectPerLevelDescription() {
252// return null;
253// }
254//
255// public ScopeDescription getScopeDescription() {
256// return ScopeDescription.FLEET;
257// }
258// }
259
260
261// public static class Level3B implements ShipSkillEffect {
262// public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
263// stats.getDynamic().getMod(Stats.DMOD_REDUCE_MAINTENANCE).modifyFlat(id, 1f);
264// }
265//
266// public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
267// stats.getDynamic().getMod(Stats.DMOD_REDUCE_MAINTENANCE).unmodify(id);
268// }
269//
270// public String getEffectDescription(float level) {
271// return "(D) hull deployment cost reduction also applies to maintenance cost";
272// }
273//
274// public String getEffectPerLevelDescription() {
275// return null;
276// }
277//
278// public ScopeDescription getScopeDescription() {
279// return ScopeDescription.ALL_SHIPS;
280// }
281// }
282}
void init(MutableCharacterStatsAPI stats, SkillSpecAPI skill)
float computeAndCacheThresholdBonus(MutableShipStatsAPI stats, String key, float maxBonus, ThresholdBonusType type)
void addOPThresholdAll(TooltipMakerAPI info, FleetDataAPI data, MutableCharacterStatsAPI cStats, float threshold)