Starsector API
Loading...
Searching...
No Matches
GunneryImplants.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.HullSize;
6import com.fs.starfarer.api.impl.campaign.ids.Stats;
7
8public class GunneryImplants {
9
10 public static float RECOIL_BONUS = 25f;
11 public static float TARGET_LEADING_BONUS = 100f;
12 public static float RANGE_BONUS = 15f;
13 public static float RANGE_BONUS_ELITE = 5f;
14
15 public static float EW_FRIGATES = 4f;
16 public static float EW_DESTROYERS = 2f;
17 public static float EW_OTHER = 1f;
18
19 public static class Level1A implements ShipSkillEffect {
20 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
21 float bonus = 0f;
22 if (hullSize == HullSize.FRIGATE) bonus = EW_FRIGATES;
23 if (hullSize == HullSize.DESTROYER) bonus = EW_DESTROYERS;
24 if (hullSize == HullSize.CRUISER || hullSize == HullSize.CAPITAL_SHIP) bonus = EW_OTHER;
25 if (bonus > 0f) {
26 stats.getDynamic().getMod(Stats.ELECTRONIC_WARFARE_FLAT).modifyFlat(id, bonus);
27 }
28 }
29 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
30 stats.getDynamic().getMod(Stats.ELECTRONIC_WARFARE_FLAT).unmodify(id);
31 }
32 public String getEffectDescription(float level) {
33 //return "+1-4" + "% to ECM rating of ships, depending on ship size";
34 return "+" + (int)EW_FRIGATES + "% to ECM rating* of fleet when piloting a frigate, " +
35 "+" + (int) EW_DESTROYERS + "% when piloting a destroyer, " +
36 "+" + (int) EW_OTHER + "% for larger hulls";
37// "Destroyers: grants " + (int)EW_DESTROYERS + "% to ECM rating of fleet";
38// return "Frigates: grants " + (int)EW_FRIGATES + "% to ECM rating of fleet\n"+
39// "Destroyers: grants " + (int)EW_DESTROYERS + "% to ECM rating of fleet";
40 }
41 public String getEffectPerLevelDescription() {
42 return null;
43 }
44 public ScopeDescription getScopeDescription() {
45 return ScopeDescription.PILOTED_SHIP;
46 }
47 }
48
49 public static class Level1 implements ShipSkillEffect {
50 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
51 stats.getMaxRecoilMult().modifyMult(id, 1f - (0.01f * RECOIL_BONUS));
52 stats.getRecoilPerShotMult().modifyMult(id, 1f - (0.01f * RECOIL_BONUS));
53 // slower recoil recovery, also, to match the reduced recoil-per-shot
54 // overall effect is same as without skill but halved in every respect
55 stats.getRecoilDecayMult().modifyMult(id, 1f - (0.01f * RECOIL_BONUS));
56 }
57
58 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
59 stats.getMaxRecoilMult().unmodify(id);
60 stats.getRecoilPerShotMult().unmodify(id);
61 stats.getRecoilDecayMult().unmodify(id);
62 }
63
64 public String getEffectDescription(float level) {
65 return "-" + (int)(RECOIL_BONUS) + "% weapon recoil";
66 }
67
68 public String getEffectPerLevelDescription() {
69 return null;
70 }
71
72 public ScopeDescription getScopeDescription() {
73 return ScopeDescription.PILOTED_SHIP;
74 }
75 }
76
77 public static class Level2 implements ShipSkillEffect {
78 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
79 stats.getAutofireAimAccuracy().modifyFlat(id, TARGET_LEADING_BONUS * 0.01f);
80 //stats.getCargoMod().modifyFlat(id, 100 * level);
81 }
82
83 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
84 stats.getAutofireAimAccuracy().unmodify(id);
85 //stats.getCargoMod().unmodify();
86 }
87
88 public String getEffectDescription(float level) {
89 return "+" + (int)(TARGET_LEADING_BONUS) + "% target leading accuracy for autofiring weapons";
90 }
91
92 public String getEffectPerLevelDescription() {
93 return null;
94 }
95
96 public ScopeDescription getScopeDescription() {
97 return ScopeDescription.PILOTED_SHIP;
98 }
99 }
100
101 public static class Level3 implements ShipSkillEffect {
102 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
103 stats.getBallisticWeaponRangeBonus().modifyPercent(id, RANGE_BONUS);
104 stats.getEnergyWeaponRangeBonus().modifyPercent(id, RANGE_BONUS);
105 }
106
107 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
108 stats.getBallisticWeaponRangeBonus().unmodify(id);
109 stats.getEnergyWeaponRangeBonus().unmodify(id);
110 }
111
112 public String getEffectDescription(float level) {
113 return "+" + (int)(RANGE_BONUS) + "% ballistic and energy weapon range";
114 }
115
116 public String getEffectPerLevelDescription() {
117 return null;
118 }
119
120 public ScopeDescription getScopeDescription() {
121 return ScopeDescription.PILOTED_SHIP;
122 }
123 }
124
125 public static class Level3A implements ShipSkillEffect {
126 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
127 stats.getBallisticWeaponRangeBonus().modifyPercent(id, RANGE_BONUS_ELITE);
128 stats.getEnergyWeaponRangeBonus().modifyPercent(id, RANGE_BONUS_ELITE);
129 }
130
131 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
132 stats.getBallisticWeaponRangeBonus().unmodify(id);
133 stats.getEnergyWeaponRangeBonus().unmodify(id);
134 }
135
136 public String getEffectDescription(float level) {
137 return "+" + (int)(RANGE_BONUS_ELITE) + "% ballistic and energy weapon range";
138 }
139
140 public String getEffectPerLevelDescription() {
141 return null;
142 }
143
144 public ScopeDescription getScopeDescription() {
145 return ScopeDescription.PILOTED_SHIP;
146 }
147 }
148
149}