Starsector API
Loading...
Searching...
No Matches
CoordinatedManeuvers.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.skills;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.characters.CharacterStatsSkillEffect;
6import com.fs.starfarer.api.characters.DescriptionSkillEffect;
7import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;
8import com.fs.starfarer.api.characters.ShipSkillEffect;
9import com.fs.starfarer.api.characters.SkillSpecAPI;
10import com.fs.starfarer.api.combat.MutableShipStatsAPI;
11import com.fs.starfarer.api.combat.ShipAPI.HullSize;
12import com.fs.starfarer.api.fleet.FleetMemberAPI;
13import com.fs.starfarer.api.impl.campaign.ids.Stats;
14import com.fs.starfarer.api.ui.TooltipMakerAPI;
15import com.fs.starfarer.api.util.Misc;
16
18
19 public static final float CP_BONUS = 3f;
20
21 public static float NAV_FRIGATES = 6f;
22 public static float NAV_DESTROYERS = 3f;
23 public static float NAV_OTHER = 1f;
24
25 public static float CP_REGEN_FRIGATES = 50f;
26 public static float CP_REGEN_DESTROYERS = 25f;
27
28
29 public static class Level0 implements DescriptionSkillEffect {
30 public String getString() {
31 String max = (int)CoordinatedManeuversScript.BASE_MAXIMUM + "%";
32// String buoy = "+" + (int)CoordinatedManeuversScript.PER_BUOY + "%";
33// return "Does not apply to fighters. Bonus from each ship only applies to other ships.\n" +
34// "Nav buoys grant " + buoy + " each, up to a maximum of " + max + " without skill.";
35// return "Nav buoys grant " + buoy + " top speed each, up to a maximum of " + max + " without skills. " +
36// "Does not apply to fighters. Bonus from each ship does not apply to itself.";
37 return "*The total nav rating for the deployed ships of the fleet increases the top speed of all ships " +
38 "in the fleet, up to a maximum of " +
39 "" + max + ". Does not apply to fighters.";
40 }
41 public Color[] getHighlightColors() {
42 Color h = Misc.getHighlightColor();
43 h = Misc.getDarkHighlightColor();
44 return new Color[] {h, h};
45 }
46 public String[] getHighlights() {
47 String max = (int)CoordinatedManeuversScript.BASE_MAXIMUM + "%";
48 String jammer = "+" + (int)CoordinatedManeuversScript.PER_BUOY + "%";
49 return new String [] {jammer, max};
50 }
51 public Color getTextColor() {
52 return null;
53 }
54 }
55
56 public static boolean isFrigateOrDestroyerAndOfficer(MutableShipStatsAPI stats) {
57 FleetMemberAPI member = stats.getFleetMember();
58 if (member == null) return false;
59 // applies at least 1% in all cases now
60 //if (!member.isFrigate() && !member.isDestroyer()) return false;
61
62 return !member.getCaptain().isDefault();
63 }
64 //return "Every deployed ship grants +1-4% (depending on ship size) to top speed of allied ships";
65 public static class Level1A extends BaseSkillEffectDescription implements ShipSkillEffect {
66 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
68 float bonus = 0f;
69 if (hullSize == HullSize.FRIGATE) bonus = NAV_FRIGATES;
70 if (hullSize == HullSize.DESTROYER) bonus = NAV_DESTROYERS;
71 if (hullSize == HullSize.CRUISER || hullSize == HullSize.CAPITAL_SHIP) bonus = NAV_OTHER;
72 if (bonus > 0f) {
73 stats.getDynamic().getMod(Stats.COORDINATED_MANEUVERS_FLAT).modifyFlat(id, bonus);
74 }
75 }
76 }
77 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
78 stats.getDynamic().getMod(Stats.COORDINATED_MANEUVERS_FLAT).unmodify(id);
79 }
80 public String getEffectDescription(float level) {
81// return "+" + (int)NAV_FRIGATES + "% to nav rating* of fleet when piloting a frigate, " +
82// "+" + (int) NAV_DESTROYERS + "% when piloting a destroyer";
83 return null;
84 }
85
86 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
87 TooltipMakerAPI info, float width) {
88 init(stats, skill);
89
90 float opad = 10f;
91 info.addPara("+%s to nav rating* of fleet for deployed frigates, " +
92 "+%s for destroyers, +%s for larger hulls", 0f, hc, hc,
93 "" + (int) NAV_FRIGATES + "%",
94 "" + (int) NAV_DESTROYERS + "%",
95 "" + (int) NAV_OTHER + "%"
96 );
97 //info.addSpacer(opad);
98
99// Color c = Misc.getBasePlayerColor();
100// info.addPara("Affects: %s", opad, Misc.getGrayColor(), c, "fleet");
101// info.addSpacer(opad);
102 }
103
104 public String getEffectPerLevelDescription() {
105 return null;
106 }
107 public ScopeDescription getScopeDescription() {
108 return ScopeDescription.PILOTED_SHIP;
109 }
110 }
111
112 public static class Level1B extends BaseSkillEffectDescription implements CharacterStatsSkillEffect {
113
114 public void apply(MutableCharacterStatsAPI stats, String id, float level) {
115 stats.getCommandPoints().modifyFlat(id, CP_BONUS);
116 }
117
118 public void unapply(MutableCharacterStatsAPI stats, String id) {
119 stats.getCommandPoints().unmodify(id);
120 }
121
122 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
123 TooltipMakerAPI info, float width) {
124 init(stats, skill);
125
126// float opad = 10f;
127// Color c = Misc.getBasePlayerColor();
128// info.addPara("Affects: %s", opad + 5f, Misc.getGrayColor(), c, "fleet");
129// info.addSpacer(opad);
130 info.addPara("+%s command points", 0f, hc, hc,
131 "" + (int) CP_BONUS + "");
132 }
133
134 public String getEffectDescription(float level) {
135 return "+" + (int) CP_BONUS + " command points";
136 }
137
138 public String getEffectPerLevelDescription() {
139 return null;
140 }
141
142 public ScopeDescription getScopeDescription() {
143 return ScopeDescription.FLEET;
144 }
145 }
146
147 public static class Level1C extends BaseSkillEffectDescription implements ShipSkillEffect {
148 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
150 float bonus = 0f;
151 if (hullSize == HullSize.FRIGATE) bonus = CP_REGEN_FRIGATES;
152 if (hullSize == HullSize.DESTROYER) bonus = CP_REGEN_DESTROYERS;
153 if (bonus > 0f) {
154 stats.getDynamic().getMod(Stats.COMMAND_POINT_RATE_FLAT).modifyFlat(id, bonus * 0.01f);
155 }
156 }
157 }
158 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
159 stats.getDynamic().getMod(Stats.COMMAND_POINT_RATE_FLAT).unmodify(id);
160 }
161 public String getEffectDescription(float level) {
162 return null;
163 }
164
165 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
166 TooltipMakerAPI info, float width) {
167 init(stats, skill);
168
169 info.addPara("+%s to command point recovery rate from deployed frigates, " +
170 "+%s from destroyers", 0f, hc, hc,
171 "" + (int) CP_REGEN_FRIGATES + "%",
172 "" + (int) CP_REGEN_DESTROYERS + "%");
173 }
174
175 public String getEffectPerLevelDescription() {
176 return null;
177 }
178 public ScopeDescription getScopeDescription() {
179 return ScopeDescription.PILOTED_SHIP;
180 }
181 }
182}
void init(MutableCharacterStatsAPI stats, SkillSpecAPI skill)
static boolean isFrigateOrDestroyerAndOfficer(MutableShipStatsAPI stats)