Starsector API
Loading...
Searching...
No Matches
WolfpackTactics.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.skills;
2
3import com.fs.starfarer.api.characters.AfterShipCreationSkillEffect;
4import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;
5import com.fs.starfarer.api.characters.ShipSkillEffect;
6import com.fs.starfarer.api.characters.SkillSpecAPI;
7import com.fs.starfarer.api.combat.MutableShipStatsAPI;
8import com.fs.starfarer.api.combat.ShipAPI;
9import com.fs.starfarer.api.combat.ShipAPI.HullSize;
10import com.fs.starfarer.api.fleet.FleetMemberAPI;
11import com.fs.starfarer.api.ui.TooltipMakerAPI;
12
13public class WolfpackTactics {
14
15 public static float DAMAGE_TO_LARGER_BONUS = 20f;
16 public static float DAMAGE_TO_LARGER_BONUS_DEST = 10f;
17 public static float PEAK_TIME_BONUS = 50f;
18 public static float PEAK_TIME_BONUS_DEST = 25f;
19
20// public static float FLAGSHIP_SPEED_BONUS = 25f;
21// public static float FLAGSHIP_CP_BONUS = 100f;
22
23 public static boolean isFrigateAndOfficer(MutableShipStatsAPI stats) {
24 if (stats.getEntity() instanceof ShipAPI) {
25 ShipAPI ship = (ShipAPI) stats.getEntity();
26 if (!ship.isFrigate()) return false;
27 return !ship.getCaptain().isDefault();
28 } else {
29 FleetMemberAPI member = stats.getFleetMember();
30 if (member == null) return false;
31 if (!member.isFrigate()) return false;
32 return !member.getCaptain().isDefault();
33 }
34 }
35
36 public static boolean isDestroyerAndOfficer(MutableShipStatsAPI stats) {
37 if (stats.getEntity() instanceof ShipAPI) {
38 ShipAPI ship = (ShipAPI) stats.getEntity();
39 if (!ship.isDestroyer()) return false;
40 return !ship.getCaptain().isDefault();
41 } else {
42 FleetMemberAPI member = stats.getFleetMember();
43 if (member == null) return false;
44 if (!member.isDestroyer()) return false;
45 return !member.getCaptain().isDefault();
46 }
47 }
48
49// public static boolean isFrigateAndFlagship(MutableShipStatsAPI stats) {
50// if (stats.getEntity() instanceof ShipAPI) {
51// ShipAPI ship = (ShipAPI) stats.getEntity();
52// if (!ship.isFrigate()) return false;
53// if (ship.getFleetMember() != null &&
54// ship.getFleetMember().getFleetCommander() == ship.getCaptain()) {
55// return true;
56// }
57// return ship.getCaptain().isPlayer();
58// } else {
59// FleetMemberAPI member = stats.getFleetMember();
60// if (member == null) return false;
61// if (!member.isFrigate()) return false;
62// if (member.isFlagship()) {
63// return true;
64// }
65// return member.getCaptain().isPlayer();
66// }
67// }
68// public static boolean isDestroyerAndFlagship(MutableShipStatsAPI stats) {
69// if (stats.getEntity() instanceof ShipAPI) {
70// ShipAPI ship = (ShipAPI) stats.getEntity();
71// if (!ship.isDestroyer()) return false;
72// if (ship.getFleetMember() != null &&
73// ship.getFleetMember().getFleetCommander() == ship.getCaptain()) {
74// return true;
75// }
76// return ship.getCaptain().isPlayer();
77// } else {
78// FleetMemberAPI member = stats.getFleetMember();
79// if (member == null) return false;
80// if (!member.isDestroyer()) return false;
81// if (member.isFlagship()) {
82// return true;
83// }
84// return member.getCaptain().isPlayer();
85// }
86// }
87
88 public static class Level1A implements ShipSkillEffect {
89 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
90 if (isFrigateAndOfficer(stats)) {
91 stats.getDamageToDestroyers().modifyPercent(id, DAMAGE_TO_LARGER_BONUS);
92 stats.getDamageToCruisers().modifyPercent(id, DAMAGE_TO_LARGER_BONUS);
93 stats.getDamageToCapital().modifyPercent(id, DAMAGE_TO_LARGER_BONUS);
94
95 stats.getPeakCRDuration().modifyPercent(id, PEAK_TIME_BONUS);
96 //stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD).modifyFlat(id, 1000f);
97 } else if (isDestroyerAndOfficer(stats)) {
98 stats.getDamageToCruisers().modifyPercent(id, DAMAGE_TO_LARGER_BONUS_DEST);
99 stats.getDamageToCapital().modifyPercent(id, DAMAGE_TO_LARGER_BONUS_DEST);
100
101 stats.getPeakCRDuration().modifyPercent(id, PEAK_TIME_BONUS_DEST);
102 //stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD).modifyFlat(id, 1000f);
103 }
104 }
105
106 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
107 stats.getDamageToDestroyers().unmodifyPercent(id);
108 stats.getDamageToCruisers().unmodifyPercent(id);
109 stats.getDamageToCapital().unmodifyPercent(id);
110
111 stats.getPeakCRDuration().unmodifyPercent(id);
112 //stats.getDynamic().getMod(Stats.INDIVIDUAL_SHIP_RECOVERY_MOD).unmodify(id);
113 }
114
115 public String getEffectDescription(float level) {
116 //return "+" + (int)Math.round(DAMAGE_TO_LARGER_BONUS) + "% damage to ships larger than frigates";
117
118 return "+" + (int)Math.round(DAMAGE_TO_LARGER_BONUS) + "% damage to ships larger than frigates if frigate, " +
119 "+" + (int)Math.round(DAMAGE_TO_LARGER_BONUS_DEST) + "% damage to capital ships and cruisers if destroyer\n" +
120 "+" + (int)(PEAK_TIME_BONUS) + "% seconds peak operating time if frigate, " +
121 "+" + (int)(PEAK_TIME_BONUS_DEST) + "% if destroyer";
122// return "+" + (int)Math.round(DAMAGE_TO_LARGER_BONUS) + "% damage to ships larger than frigates\n" +
123// "+" + (int)(PEAK_TIME_BONUS) + " seconds peak operating time\n" +
124// "If lost in combat, ship is almost always recoverable";
125 }
126
127 public String getEffectPerLevelDescription() {
128 return null;
129 }
130
131 public ScopeDescription getScopeDescription() {
132 return ScopeDescription.PILOTED_SHIP;
133 }
134 }
135
136
137// public static class Level1B extends BaseSkillEffectDescription implements ShipSkillEffect {
138// public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
139// if (isFrigateAndFlagship(stats)) {
140// stats.getDynamic().getMod(Stats.COMMAND_POINT_RATE_FLAT).modifyFlat(id, FLAGSHIP_CP_BONUS * 0.01f);
141// } else if (isDestroyerAndFlagship(stats)) {
142// stats.getZeroFluxSpeedBoost().modifyFlat(id, FLAGSHIP_SPEED_BONUS);
143// }
144// }
145//
146// public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
147// stats.getDynamic().getMod(Stats.COMMAND_POINT_RATE_FLAT).unmodify(id);
148// stats.getZeroFluxSpeedBoost().unmodifyFlat(id);
149// }
150//
151// public String getEffectDescription(float level) {
152// return null;
153// //return "\n+" + (int) DESTROYER_CP_BONUS + "% to command point recovery rate if flagship is a destroyer";
154// }
155//
156// public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
157// TooltipMakerAPI info, float width) {
158// init(stats, skill);
159//
160// float opad = 10f;
161// Color c = Misc.getBasePlayerColor();
162// info.addPara("Affects: %s", opad + 5f, Misc.getGrayColor(), c, "flagship");
163// info.addSpacer(opad);
164// info.addPara("+%s to command point recovery rate if flagship is a frigate", 0f, hc, hc,
165// "" + (int) FLAGSHIP_CP_BONUS + "%");
166// info.addPara("+%s to 0-flux speed boost if flagship is a destroyer", 0f, hc, hc,
167// "" + (int) FLAGSHIP_SPEED_BONUS + "");
168//
169// //info.addSpacer(5f);
170// }
171//
172// public String getEffectPerLevelDescription() {
173// return null;
174// }
175//
176// public ScopeDescription getScopeDescription() {
177// return ScopeDescription.PILOTED_SHIP;
178// }
179// }
180
181
182 //public static class Level1C extends BaseSkillEffectDescription implements ShipSkillEffect, AfterShipCreationSkillEffect {
183 public static class Level1C extends BaseSkillEffectDescription implements AfterShipCreationSkillEffect {
184 public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
185// MutableShipStatsAPI stats = ship.getMutableStats();
186// Global.getCombatEngine().getListenerManager().addListener(listener);
187// if (isDmoddedAndOfficer(stats)) {
188// ship.addListener(new DCDamageTakenMod(ship));
189//
190// float dmods = DModManager.getNumDMods(ship.getVariant());
191// if (dmods <= 0) return;
192// if (dmods > MAX_DMODS) dmods = MAX_DMODS;
193//
194// if (ship.getShield() == null) {
195// stats.getMinArmorFraction().modifyFlat(id, SHIELDLESS_ARMOR_BONUS_PER_DMOD * dmods);
196// }
197// }
198 }
199
200 public void unapplyEffectsAfterShipCreation(ShipAPI ship, String id) {
201// ship.removeListenerOfClass(DCDamageTakenMod.class);
202//
203// if (ship.getShield() == null) {
204// MutableShipStatsAPI stats = ship.getMutableStats();
205// stats.getMinArmorFraction().unmodifyFlat(id);
206// }
207 }
208
209
210 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
211 TooltipMakerAPI info, float width) {
212// init(stats, skill);
213
214// info.addPara("%s chance per d-mod* to have incoming hull damage reduced by %s", 0f, hc, hc,
215// "" + (int)AVOID_DAMAGE_CHANCE_PER_DMOD + "%",
216// "" + (int)Math.round((1f - AVOID_DAMAGE_DAMAGE_MULT) * 100f) + "%"
217// );
218// info.addPara("%s crew lost due to hull damage in combat per d-mod*", 0f, hc, hc,
219// "-" + (int)CREW_LOSS_REDUCTION_PER_DMOD + "%"
220// );
221// info.addPara("%s maximum combat readiness per d-mod*", 0f, hc, hc,
222// "+" + (int)CR_PER_DMOD + "%"
223// );
224//
225// info.addSpacer(5f);
226// info.addPara("%s minimum armor value** for damage reduction per d-mod for unshielded ships", 0f, hc, hc,
227// "+" + (int)Math.round(SHIELDLESS_ARMOR_BONUS_PER_DMOD * 100f) + "%"
228// );
229//
230 }
231
232 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
233 }
234
235 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
236 }
237 }
238
239 /*
240 public static class WolfpackExtraDamageMod implements DamageDealtModifier, AdvanceableListener {
241 protected int owner;
242 public WolfpackExtraDamageMod(int owner) {
243 this.owner = owner;
244 }
245
246 protected boolean addDamage = false;
247 protected boolean addDamageAlly = false;
248 public void advance(float amount) {
249 CombatFleetManagerAPI cfm = Global.getCombatEngine().getFleetManager(owner);
250 for (DeployedFleetMemberAPI dfm : cfm.getDeployedCopyDFM()) {
251 FleetMemberAPI member = dfm.getMember();
252 if (member == null) continue;
253 PersonAPI commander = member.getFleetCommanderForStats();
254 if (commander == null) continue;
255
256 ShipAPI ship = cfm.getShipFor(commander);
257
258 }
259 }
260
261 public String modifyDamageDealt(Object param, CombatEntityAPI target, DamageAPI damage, Vector2f point, boolean shieldHit) {
262 return null;
263 }
264
265 public String modifyDamageTaken(Object param,
266 CombatEntityAPI target, DamageAPI damage,
267 Vector2f point, boolean shieldHit) {
268 MutableShipStatsAPI stats = ship.getMutableStats();
269 stats.getHullDamageTakenMult().unmodifyMult(DAMAGE_MOD_ID);
270
271 if (shieldHit) return null;
272
273 float chance = stats.getDynamic().getMod(AVOID_HULL_DAMAGE_CHANCE).computeEffective(0f);
274 if (Math.random() >= chance) {
275 return null;
276 }
277
278 stats.getHullDamageTakenMult().modifyMult(DAMAGE_MOD_ID, AVOID_DAMAGE_DAMAGE_MULT);
279
280 return null;
281 }
282 }
283 */
284
285
286}
static boolean isDestroyerAndOfficer(MutableShipStatsAPI stats)
static boolean isFrigateAndOfficer(MutableShipStatsAPI stats)