Starsector API
Loading...
Searching...
No Matches
SupportDoctrine.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.MutableCharacterStatsAPI;
6import com.fs.starfarer.api.characters.ShipSkillEffect;
7import com.fs.starfarer.api.characters.SkillSpecAPI;
8import com.fs.starfarer.api.combat.MutableShipStatsAPI;
9import com.fs.starfarer.api.combat.ShipAPI;
10import com.fs.starfarer.api.combat.ShipAPI.HullSize;
11import com.fs.starfarer.api.fleet.FleetMemberAPI;
12import com.fs.starfarer.api.impl.campaign.ids.HullMods;
13import com.fs.starfarer.api.impl.campaign.ids.Stats;
14import com.fs.starfarer.api.ui.TooltipMakerAPI;
15import com.fs.starfarer.api.util.Misc;
16
17public class SupportDoctrine {
18
19 public static float COMMAND_POINT_REGEN_PERCENT = 100f;
20
21 public static String SUPPORT_DOCTRINE_DP_REDUCTION_ID = "support_doctrine_dp_reduction";
22 public static float DP_REDUCTION = 0.2f;
23 public static float DP_REDUCTION_MAX = 10f;
24
25 public static boolean isNoOfficer(MutableShipStatsAPI stats) {
26 if (stats.getEntity() instanceof ShipAPI) {
27 ShipAPI ship = (ShipAPI) stats.getEntity();
28// if (ship == Global.getCombatEngine().getShipPlayerIsTransferringCommandFrom()) {
29// return false; // player is transferring command, no bonus until the shuttle is done flying
30// // issue: won't get called again when transfer finishes
31// }
32 return ship.getCaptain().isDefault();
33 } else {
34 FleetMemberAPI member = stats.getFleetMember();
35 if (member == null) return true;
36 return member.getCaptain().isDefault();
37 }
38 }
39
40 public static boolean isOriginalNoOfficer(MutableShipStatsAPI stats) {
41 if (stats.getEntity() instanceof ShipAPI) {
42 ShipAPI ship = (ShipAPI) stats.getEntity();
43// if (ship == Global.getCombatEngine().getShipPlayerIsTransferringCommandFrom()) {
44// return false; // player is transferring command, no bonus until the shuttle is done flying
45// }
46 return ship.getOriginalCaptain() != null && ship.getOriginalCaptain().isDefault();
47 } else {
48 FleetMemberAPI member = stats.getFleetMember();
49 if (member == null) return true;
50 return member.getCaptain().isDefault();
51 }
52 }
53
54
55 public static class Level1 implements ShipSkillEffect {
56 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
57 if (isNoOfficer(stats)) {
58 new Helmsmanship.Level1().apply(stats, hullSize, id, level);
59 new Helmsmanship.Level2().apply(stats, hullSize, id, level);
60
61 new DamageControl.Level2().apply(stats, hullSize, id, level);
62 new DamageControl.Level3().apply(stats, hullSize, id, level);
63 new DamageControl.Level4().apply(stats, hullSize, id, level);
64
65 new CombatEndurance.Level1().apply(stats, hullSize, id, level);
66 new CombatEndurance.Level2().apply(stats, hullSize, id, level);
67 new CombatEndurance.Level3().apply(stats, hullSize, id, level);
68
69 new OrdnanceExpertise.Level1().apply(stats, hullSize, id, level);
70 }
71 }
72
73 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
74 new Helmsmanship.Level1().unapply(stats, hullSize, id);
75 new Helmsmanship.Level2().unapply(stats, hullSize, id);
76
77 new DamageControl.Level2().unapply(stats, hullSize, id);
78 new DamageControl.Level3().unapply(stats, hullSize, id);
79 new DamageControl.Level4().unapply(stats, hullSize, id);
80
81 new CombatEndurance.Level1().unapply(stats, hullSize, id);
82 new CombatEndurance.Level2().unapply(stats, hullSize, id);
83 new CombatEndurance.Level3().unapply(stats, hullSize, id);
84
85 new OrdnanceExpertise.Level1().unapply(stats, hullSize, id);
86 }
87
88 public String getEffectDescription(float level) {
89 return "Gain non-elite Helmsmanship, Damage Control, Combat Endurance, and Ordnance Expertise";
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 Level2 implements ShipSkillEffect {
102 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
103 if (isNoOfficer(stats)) {
104 float baseCost = stats.getSuppliesToRecover().getBaseValue();
105 float reduction = Math.min(DP_REDUCTION_MAX, baseCost * DP_REDUCTION);
106
107 if (stats.getFleetMember() == null || stats.getFleetMember().getVariant() == null ||
108 (!stats.getFleetMember().getVariant().hasHullMod(HullMods.NEURAL_INTERFACE) &&
109 !stats.getFleetMember().getVariant().hasHullMod(HullMods.NEURAL_INTEGRATOR))
110 ) {
111 stats.getDynamic().getMod(Stats.DEPLOYMENT_POINTS_MOD).modifyFlat(SUPPORT_DOCTRINE_DP_REDUCTION_ID, -reduction);
112 }
113 }
114 }
115
116 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
117 stats.getDynamic().getMod(Stats.DEPLOYMENT_POINTS_MOD).unmodifyFlat(SUPPORT_DOCTRINE_DP_REDUCTION_ID);
118 }
119
120 public String getEffectDescription(float level) {
121 String max = "" + (int) DP_REDUCTION_MAX;
122 String percent = "" + (int)Math.round(DP_REDUCTION * 100f) + "%";
123 return "Deployment point cost reduced by " + percent + " or " + max + " points, whichever is less";
124 }
125
126 public String getEffectPerLevelDescription() {
127 return null;
128 }
129
130 public ScopeDescription getScopeDescription() {
131 return ScopeDescription.PILOTED_SHIP;
132 }
133 }
134
135
136 public static class Level3 extends BaseSkillEffectDescription implements ShipSkillEffect {
137 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
138 TooltipMakerAPI info, float width) {
139 init(stats, skill);
140 float opad = 10f;
141 Color c = Misc.getBasePlayerColor();
142 //info.addPara("Affects: %s", opad + 5f, Misc.getGrayColor(), c, "fleet");
143 info.addPara("Affects: %s", opad + 5f, Misc.getGrayColor(), c, "fleet");
144 info.addSpacer(opad);
145 info.addPara("%s faster command point recovery unless command was transferred to a ship originally without an officer", 0f, hc, hc,
146 "" + (int) COMMAND_POINT_REGEN_PERCENT + "%");
147 }
148
149 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
150 if (!isOriginalNoOfficer(stats)) {
151 stats.getDynamic().getMod(Stats.COMMAND_POINT_RATE_FLAT).modifyFlat(id, COMMAND_POINT_REGEN_PERCENT * 0.01f);
152 }
153 }
154
155 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
156 stats.getDynamic().getMod(Stats.COMMAND_POINT_RATE_FLAT).unmodify(id);
157 }
158 }
159
160}
161
162
163
164
165
void init(MutableCharacterStatsAPI stats, SkillSpecAPI skill)
static boolean isOriginalNoOfficer(MutableShipStatsAPI stats)
static boolean isNoOfficer(MutableShipStatsAPI stats)