Starsector API
Loading...
Searching...
No Matches
AutomatedShips.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.Global;
6import com.fs.starfarer.api.campaign.FleetDataAPI;
7import com.fs.starfarer.api.characters.CharacterStatsSkillEffect;
8import com.fs.starfarer.api.characters.DescriptionSkillEffect;
9import com.fs.starfarer.api.characters.FleetTotalItem;
10import com.fs.starfarer.api.characters.FleetTotalSource;
11import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;
12import com.fs.starfarer.api.characters.ShipSkillEffect;
13import com.fs.starfarer.api.characters.SkillSpecAPI;
14import com.fs.starfarer.api.combat.MutableShipStatsAPI;
15import com.fs.starfarer.api.combat.ShipAPI.HullSize;
16import com.fs.starfarer.api.impl.campaign.AICoreOfficerPluginImpl;
17import com.fs.starfarer.api.impl.campaign.ids.Skills;
18import com.fs.starfarer.api.impl.campaign.ids.Strings;
19import com.fs.starfarer.api.impl.campaign.ids.Tags;
20import com.fs.starfarer.api.impl.hullmods.Automated;
21import com.fs.starfarer.api.ui.TooltipMakerAPI;
22import com.fs.starfarer.api.util.Misc;
23
24public class AutomatedShips {
25
26 public static float MAX_CR_BONUS = 100f;
27
28 public static class Level0 implements DescriptionSkillEffect {
29 public String getString() {
30 int alpha = (int) Math.round(AICoreOfficerPluginImpl.ALPHA_MULT);
31 int beta = (int) Math.round(AICoreOfficerPluginImpl.BETA_MULT);
32 int gamma = (int) Math.round(AICoreOfficerPluginImpl.GAMMA_MULT);
33
34 return "*The total \"automated ship points\" are equal to the deployment points cost of " +
35 "all automated ships in the fleet, with a multiplier for installed AI cores - " +
36 alpha + Strings.X + " for an Alpha Core, " +
37 beta + Strings.X + " for a Beta Core, and " +
38 gamma + Strings.X + " for a Gamma Core. "
39 + "Due to safety interlocks, ships with AI cores do not contribute to the deployment point distribution.";
40// int alpha = AICoreOfficerPluginImpl.ALPHA_POINTS;
41// int beta = AICoreOfficerPluginImpl.BETA_POINTS;
42// int gamma = AICoreOfficerPluginImpl.GAMMA_POINTS;
43// if (BaseSkillEffectDescription.USE_RECOVERY_COST) {
44// return "*The total \"automated ship points\" are equal to the deployment recovery cost of " +
45// "all automated ships in the fleet, plus extra points for installed AI cores - " +
46// alpha + " for an Alpha Core, " +
47// beta + " for a Beta Core, and " +
48// gamma + " for a Gamma Core."
49// ;
50// } else {
51// return "*The total \"automated ship points\" are equal to the ordnance points of " +
52// "all automated ships in the fleet, plus extra points for AI cores installed on any of the " +
53// "automated ships - " +
54// alpha + " for an Alpha Core, " +
55// beta + " for a Beta Core, and " +
56// gamma + " for a Gamma Core."
57// ;
58// }
59 }
60 public Color[] getHighlightColors() {
61 Color h = Misc.getHighlightColor();
63 Color bad = Misc.getNegativeHighlightColor();
64 //bad = Misc.setAlpha(bad, 240);
65 return new Color[] {h, h, h, bad};
66 }
67 public String[] getHighlights() {
68// int alpha = AICoreOfficerPluginImpl.ALPHA_POINTS;
69// int beta = AICoreOfficerPluginImpl.BETA_POINTS;
70// int gamma = AICoreOfficerPluginImpl.GAMMA_POINTS;
71 int alpha = (int) Math.round(AICoreOfficerPluginImpl.ALPHA_MULT);
72 int beta = (int) Math.round(AICoreOfficerPluginImpl.BETA_MULT);
73 int gamma = (int) Math.round(AICoreOfficerPluginImpl.GAMMA_MULT);
74 return new String [] {"" + alpha + Strings.X, "" + beta + Strings.X, "" + gamma + Strings.X,
75 "do not contribute to the deployment point distribution"};
76 }
77 public Color getTextColor() {
78 return null;
79 }
80 }
81
82
83 public static class Level1 extends BaseSkillEffectDescription implements ShipSkillEffect, FleetTotalSource {
84
85 public FleetTotalItem getFleetTotalItem() {
87 }
88
89 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
90 if (Misc.isAutomated(stats) &&
91 !Automated.isAutomatedNoPenalty(stats)) {
92 float crBonus = computeAndCacheThresholdBonus(stats, "auto_cr", MAX_CR_BONUS, ThresholdBonusType.AUTOMATED_POINTS);
94 stats.getMaxCombatReadiness().modifyFlat(id, crBonus * 0.01f, skill.getName() + " skill");
95 }
96 }
97
98 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
99 stats.getMaxCombatReadiness().unmodifyFlat(id);
100 }
101
102 public String getEffectDescription(float level) {
103 return null;
104 }
105
106 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
107 TooltipMakerAPI info, float width) {
108 init(stats, skill);
109
110 FleetDataAPI data = getFleetData(null);
111 float crBonus = computeAndCacheThresholdBonus(data, stats, "auto_cr", MAX_CR_BONUS, ThresholdBonusType.AUTOMATED_POINTS);
112
113 String partially = "";
114 String penalty = "" + (int)Math.round(Automated.MAX_CR_PENALTY * 100f) + "%%";
115 if ((int) crBonus < 100f) partially = "partially ";
116 info.addPara("+%s combat readiness (maximum: %s); " + partially + "offsets built-in " + penalty + " penalty", 0f, hc, hc,
117 "" + (int) crBonus + "%",
118 "" + (int) MAX_CR_BONUS + "%");
119 addAutomatedThresholdInfo(info, data, stats);
120
121 //info.addSpacer(5f);
122 }
123
124 public ScopeDescription getScopeDescription() {
125 return ScopeDescription.ALL_SHIPS;
126 }
127 }
128
129 public static class Level2 extends BaseSkillEffectDescription implements CharacterStatsSkillEffect {
130
131 public void apply(MutableCharacterStatsAPI stats, String id, float level) {
132 if (stats.isPlayerStats()) {
133 Misc.getAllowedRecoveryTags().add(Tags.AUTOMATED_RECOVERABLE);
134 }
135 }
136
137 public void unapply(MutableCharacterStatsAPI stats, String id) {
138 if (stats.isPlayerStats()) {
139 Misc.getAllowedRecoveryTags().remove(Tags.AUTOMATED_RECOVERABLE);
140 }
141 }
142
143 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
144 TooltipMakerAPI info, float width) {
145 init(stats, skill);
146 info.addPara("Enables the recovery of some automated ships, such as derelict drones", hc, 0f);
147 info.addPara("Automated ships can only be captained by AI cores", hc, 0f);
148 info.addSpacer(5f);
149 }
150
151 public String getEffectPerLevelDescription() {
152 return null;
153 }
154
155 public ScopeDescription getScopeDescription() {
156 return ScopeDescription.FLEET;
157 }
158 }
159
160}
161
162
163
164
165
static SettingsAPI getSettings()
Definition Global.java:57
void modifyFlat(String source, float value)
void addAutomatedThresholdInfo(TooltipMakerAPI info, FleetDataAPI data, MutableCharacterStatsAPI cStats)
void init(MutableCharacterStatsAPI stats, SkillSpecAPI skill)
float computeAndCacheThresholdBonus(MutableShipStatsAPI stats, String key, float maxBonus, ThresholdBonusType type)
static Color getNegativeHighlightColor()
Definition Misc.java:802
static boolean isAutomated(MutableShipStatsAPI stats)
Definition Misc.java:5491
static Color getHighlightColor()
Definition Misc.java:792
static Color getDarkHighlightColor()
Definition Misc.java:795
SkillSpecAPI getSkillSpec(String skillId)