Starsector API
Loading...
Searching...
No Matches
DerelictContingent.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.DescriptionSkillEffect;
6import com.fs.starfarer.api.characters.FleetStatsSkillEffect;
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.fleet.MutableFleetStatsAPI;
14import com.fs.starfarer.api.impl.campaign.DModManager;
15import com.fs.starfarer.api.impl.campaign.ids.Stats;
16import com.fs.starfarer.api.ui.TooltipMakerAPI;
17import com.fs.starfarer.api.util.Misc;
18
19public class DerelictContingent {
20
21 public static float MAX_DMODS = 5;
22 //public static float MINUS_CR_PER_DMOD = 3f;
23 public static float MINUS_CR_PER_DMOD = 0f;
24 public static float MINUS_DP_PERCENT_PER_DMOD = 6f;
25 public static float EXTRA_DMODS = 4;
26
27
28
29 public static class Level0 implements DescriptionSkillEffect {
30 public String getString() {
31 return "*Maximum effect reached " +
32 "at " + (int) MAX_DMODS + " d-mods."
33 ;
34 }
35 public Color[] getHighlightColors() {
36 Color h = Misc.getHighlightColor();
37 h = Misc.getDarkHighlightColor();
38 return new Color[] {h};
39 }
40 public String[] getHighlights() {
41 return new String [] {"" + (int) MAX_DMODS};
42 }
43 public Color getTextColor() {
44 return null;
45 }
46 }
47
48 public static class Level1 extends BaseSkillEffectDescription implements ShipSkillEffect {
49 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
50 FleetMemberAPI member = stats.getFleetMember();
51 float dmods = 0;
52 if (member != null) {
53 dmods = DModManager.getNumDMods(member.getVariant());
54 if (dmods > MAX_DMODS) dmods = MAX_DMODS;
55 }
56
57 if (dmods > 0) {
58 float depBonus = dmods * MINUS_DP_PERCENT_PER_DMOD;
59 //stats.getDynamic().getMod(Stats.DEPLOYMENT_POINTS_MOD).modifyPercent(id, -depBonus);
60 stats.getDynamic().getMod(Stats.DEPLOYMENT_POINTS_MOD).modifyMult(id, 1f - (depBonus/100f));
61
62 stats.getDynamic().getMod(Stats.DMOD_REDUCE_MAINTENANCE).modifyFlat(id, 1f);
63 if (MINUS_CR_PER_DMOD > 0) {
64 float crPenalty = MINUS_CR_PER_DMOD * dmods;
65 stats.getMaxCombatReadiness().modifyFlat(id, -crPenalty * 0.01f, "Derelict Operations skill");
66 }
67 }
68
69// if (EXTRA_DMODS > 0) {
70// stats.getDynamic().getMod(Stats.DMOD_ACQUIRE_PROB_MOD).modifyFlat(id, 1000f);
71// }
72 }
73
74 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
75 stats.getDynamic().getMod(Stats.DEPLOYMENT_POINTS_MOD).unmodify(id);
76 stats.getDynamic().getMod(Stats.DMOD_REDUCE_MAINTENANCE).unmodify(id);
77 if (MINUS_CR_PER_DMOD > 0) {
78 stats.getMaxCombatReadiness().unmodify(id);
79 }
80
81// if (EXTRA_DMODS > 0) {
82// stats.getDynamic().getMod(Stats.DMOD_ACQUIRE_PROB_MOD).unmodify(id);
83// }
84 }
85
86 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
87 TooltipMakerAPI info, float width) {
88 init(stats, skill);
89
90 info.addPara("Deployment point cost of ships reduced by %s per d-mod*", 0f,
91 hc, hc, "" + (int)MINUS_DP_PERCENT_PER_DMOD + "%");
92 if (MINUS_CR_PER_DMOD > 0) {
93 info.addPara("(D) hull deployment cost reduction also applies to maintenance cost,"
94 + " but maximum CR is reduced by %s per d-mod*", 0f,
95 hc, hc, "" + (int)MINUS_CR_PER_DMOD + "%");
96 } else {
97 info.addPara("(D) hull deployment cost reduction also applies to maintenance cost", hc, 0f);
98 }
99
100 }
101 }
102
103 public static class Level2 implements FleetStatsSkillEffect {
104 public void apply(MutableFleetStatsAPI stats, String id, float level) {
105 stats.getDynamic().getMod(Stats.SHIP_DMOD_REDUCTION).modifyFlat(id, -EXTRA_DMODS);
106 }
107
108 public void unapply(MutableFleetStatsAPI stats, String id) {
109 stats.getDynamic().getMod(Stats.SHIP_DMOD_REDUCTION).unmodify(id);
110 }
111
112 public String getEffectDescription(float level) {
113 //return "Recovered ships have " + (int) EXTRA_DMODS + " more d-mods on average";
114 return "Recovered ships have more d-mods than normal";
115 }
116
117 public String getEffectPerLevelDescription() {
118 return null;
119 }
120
121 public ScopeDescription getScopeDescription() {
122 return ScopeDescription.FLEET;
123 }
124 }
125
126}
static int getNumDMods(ShipVariantAPI variant)
void init(MutableCharacterStatsAPI stats, SkillSpecAPI skill)