Starsector API
Loading...
Searching...
No Matches
ImpactMitigation.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.skills;
2
3import com.fs.starfarer.api.characters.ShipSkillEffect;
4import com.fs.starfarer.api.combat.MutableShipStatsAPI;
5import com.fs.starfarer.api.combat.ShipAPI;
6import com.fs.starfarer.api.combat.ShipAPI.HullSize;
7import com.fs.starfarer.api.fleet.FleetMemberAPI;
8
9public class ImpactMitigation {
10
11// public static final float ARMOR_BONUS = 50;
12 public static float MANEUVERABILITY_BONUS_LARGE = 50;
13 public static float MANEUVERABILITY_BONUS_SMALL = 25;
14
15 public static float MAX_DAMAGE_REDUCTION_BONUS = 0.05f;
16// public static float MIN_ARMOR_FRACTION_BONUS = 0.1f;
17 public static float ARMOR_DAMAGE_REDUCTION = 25f;
18 public static float ARMOR_KINETIC_REDUCTION = 50f;
19
20 public static float DAMAGE_TO_MODULES_REDUCTION = 50;
21
22 public static float ELITE_HIT_STRENGTH_PERCENT = 10f;
23
24 public static HullSize getHullSize(MutableShipStatsAPI stats) {
25 if (stats.getEntity() instanceof ShipAPI) {
26 ShipAPI ship = (ShipAPI) stats.getEntity();
27 return ship.getHullSize();
28 } else {
29 FleetMemberAPI member = stats.getFleetMember();
30 if (member == null) return HullSize.CAPITAL_SHIP;
31 return member.getHullSpec().getHullSize();
32 }
33 }
34
35// public static class Level1 implements ShipSkillEffect {
36// public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
37// //stats.getArmorBonus().modifyFlat(id, ARMOR_BONUS);
38// stats.getEffectiveArmorBonus().modifyFlat(id, ARMOR_BONUS);
39// }
40//
41// public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
42// //stats.getArmorBonus().unmodify(id);
43// stats.getEffectiveArmorBonus().unmodify(id);
44// }
45//
46// public String getEffectDescription(float level) {
47// return "+" + (int)(ARMOR_BONUS) + " armor for damage reduction calculation only";
48// //return "+" + (int)(ARMOR_BONUS) + " maximum armor";
49// }
50//
51// public String getEffectPerLevelDescription() {
52// return null;
53// }
54//
55// public ScopeDescription getScopeDescription() {
56// return ScopeDescription.PILOTED_SHIP;
57// }
58//
59// }
60
61 public static class Level2 implements ShipSkillEffect {
62
63 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
64 stats.getArmorDamageTakenMult().modifyMult(id, 1f - ARMOR_DAMAGE_REDUCTION / 100f);
65 }
66
67 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
68 stats.getArmorDamageTakenMult().unmodify(id);
69 }
70
71 public String getEffectDescription(float level) {
72 return "-" + (int)(ARMOR_DAMAGE_REDUCTION) + "% armor damage taken";
73 }
74
75 public String getEffectPerLevelDescription() {
76 return null;
77 }
78
79 public ScopeDescription getScopeDescription() {
80 return ScopeDescription.PILOTED_SHIP;
81 }
82 }
83
84 public static class Level3 implements ShipSkillEffect {
85
86 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
87 stats.getKineticArmorDamageTakenMult().modifyMult(id, 1f - ARMOR_KINETIC_REDUCTION / 100f);
88 }
89
90 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
91 stats.getKineticArmorDamageTakenMult().unmodify(id);
92 }
93
94 public String getEffectDescription(float level) {
95 return "-" + (int)(ARMOR_KINETIC_REDUCTION) + "% kinetic damage taken by armor";
96 }
97
98 public String getEffectPerLevelDescription() {
99 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) {
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}
static HullSize getHullSize(MutableShipStatsAPI stats)