Starsector API
Loading...
Searching...
No Matches
DefensiveTargetingArray.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.hullmods;
2
3import com.fs.starfarer.api.combat.BaseHullMod;
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.impl.campaign.ids.Tags;
8
9public class DefensiveTargetingArray extends BaseHullMod {
10
11 public static float PD_DAMAGE_BONUS = 50f;
12 public static float SMOD_RANGE_BONUS = 100f;
13
14
15 @Override
16 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
17 stats.getFighterWingRange().modifyMult(id, 0f);
18 }
19
20 @Override
21 public void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id) {
22 fighter.getMutableStats().getDamageToFighters().modifyFlat(id, PD_DAMAGE_BONUS / 100f);
23 fighter.getMutableStats().getDamageToMissiles().modifyFlat(id, PD_DAMAGE_BONUS / 100f);
24
25 boolean sMod = isSMod(ship);
26 if (sMod) {
27 fighter.getMutableStats().getBallisticWeaponRangeBonus().modifyFlat(id, SMOD_RANGE_BONUS);
28 fighter.getMutableStats().getEnergyWeaponRangeBonus().modifyFlat(id, SMOD_RANGE_BONUS);
29 }
30
31 if (fighter.getWing() != null && fighter.getWing().getSpec() != null) {
32 if (fighter.getWing().getSpec().isRegularFighter() ||
33 fighter.getWing().getSpec().isAssault() ||
34 fighter.getWing().getSpec().isBomber() ||
35 fighter.getWing().getSpec().isInterceptor()) {
36 fighter.addTag(Tags.WING_STAY_IN_FRONT_OF_SHIP);
37 }
38 }
39 }
40
41 public String getSModDescriptionParam(int index, HullSize hullSize) {
42 if (index == 0) return "" + (int) SMOD_RANGE_BONUS + "";
43 return null;
44 }
45
46 public String getDescriptionParam(int index, HullSize hullSize) {
47 if (index == 0) return "" + (int) PD_DAMAGE_BONUS + "%";
48 return null;
49 }
50
51 public boolean isApplicableToShip(ShipAPI ship) {
52 int bays = (int) ship.getMutableStats().getNumFighterBays().getModifiedValue();
53 return ship != null && bays > 0;
54 }
55
56 public String getUnapplicableReason(ShipAPI ship) {
57 return "Ship does not have fighter bays";
58 }
59}
60
61
62
63
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id)