Starsector API
Loading...
Searching...
No Matches
ElectronicWarfare.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.ShipSkillEffect;
7import com.fs.starfarer.api.combat.MutableShipStatsAPI;
8import com.fs.starfarer.api.combat.ShipAPI.HullSize;
9import com.fs.starfarer.api.impl.campaign.ids.Stats;
10import com.fs.starfarer.api.util.Misc;
11
12public class ElectronicWarfare {
13
14// public static final float LEVEL_1_BONUS = 0f;
15// public static final float LEVEL_2_BONUS = 5f;
16// public static final float LEVEL_3_BONUS = 5f;
17
18 public static float PER_SHIP_BONUS = 1f;
19
20 public static float CAP_RANGE = 1000f;
21 public static float CAP_RATE = 5f;
22
23
24// public static float getBase(HullSize hullSize) {
25// float value = 0f;
26// switch (hullSize) {
27// case CAPITAL_SHIP: value = 4f; break;
28// case CRUISER: value = 3f; break;
29// case DESTROYER: value = 2f; break;
30// case FRIGATE: value = 1f; break;
31// }
32// return value;
33// }
34
35 public static class Level0 implements DescriptionSkillEffect {
36 public String getString() {
37 String max = (int)ElectronicWarfareScript.BASE_MAXIMUM + "%";
38// return "*Enemy weapon range is reduced by half of the total ECM rating of the deployed ships, " +
39// "up to a maximum of " + max +
40// ". Does not apply to fighters, affects all weapons including missiles.";
41// return "*Reduces enemy weapon range. The total reduction is the lesser of " + max +
42// " and the combined ECM rating for both sides. " +
43// "The side with the lower ECM rating gets a higher penalty. " +
44// "Does not apply to fighters, affects all weapons including missiles.";
45
46 return "*Enemy weapon range is reduced by the total ECM rating of your deployed ships, "
47 + "up to a maximum of " + max + ". This penalty is reduced by the ratio "
48 + "of the enemy ECM rating to yours." +
49 "Does not apply to fighters, affects all weapons including missiles.";
50 }
51 public Color[] getHighlightColors() {
52 Color h = Misc.getHighlightColor();
53 h = Misc.getDarkHighlightColor();
54 return new Color[] {h, h, h};
55 }
56 public String[] getHighlights() {
57 String max = (int)ElectronicWarfareScript.BASE_MAXIMUM + "%";
58// String jammer = "+" + (int)ElectronicWarfareScript.PER_JAMMER + "%";
59// return new String [] {jammer, max};
60 //return new String [] {max, "combined", "relative"};
61 //return new String [] {"half", max};
62 return new String [] {max};
63 //return new String [] {"half", "maximum of " + max};
64 }
65 public Color getTextColor() {
66 return null;
67 }
68 }
69
70 public static class Level0WithNewline extends Level0 {
71 public String getString() {
72 return "\n" + super.getString();
73 }
74 }
75
76 public static class Level1A implements ShipSkillEffect {
77 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
78 if (!BaseSkillEffectDescription.isCivilian(stats)) {
79 stats.getDynamic().getMod(Stats.ELECTRONIC_WARFARE_FLAT).modifyFlat(id, PER_SHIP_BONUS);
80 }
81 }
82 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
83 stats.getDynamic().getMod(Stats.ELECTRONIC_WARFARE_FLAT).unmodify(id);
84 }
85 public String getEffectDescription(float level) {
86 //return "+1-4" + "% to ECM rating of ships, depending on ship size";
87 //return "Every deployed ship increases ECM rating* of fleet by " + (int) PER_SHIP_BONUS + "%";
88 return "Every deployed combat ship contributes +" + (int) PER_SHIP_BONUS + "% to ECM rating* of fleet";
89 }
90 public String getEffectPerLevelDescription() {
91 return null;
92 }
93 public ScopeDescription getScopeDescription() {
94 return ScopeDescription.ALL_SHIPS;
95 }
96 }
97
98
99 public static class Level1B implements ShipSkillEffect {
100 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
101 if (!BaseSkillEffectDescription.isCivilian(stats)) {
102 stats.getDynamic().getMod(Stats.SHIP_OBJECTIVE_CAP_RANGE_MOD).modifyFlat(id, CAP_RANGE);
103 stats.getDynamic().getStat(Stats.SHIP_OBJECTIVE_CAP_RATE_MULT).modifyMult(id, CAP_RATE);
104 }
105 }
106 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
107 stats.getDynamic().getMod(Stats.SHIP_OBJECTIVE_CAP_RANGE_MOD).unmodifyFlat(id);
108 stats.getDynamic().getStat(Stats.SHIP_OBJECTIVE_CAP_RATE_MULT).unmodifyMult(id);
109 }
110 public String getEffectDescription(float level) {
111 return "Combat objectives are captured much more quickly and from longer range";
112 }
113 public String getEffectPerLevelDescription() {
114 return null;
115 }
116 public ScopeDescription getScopeDescription() {
117 return ScopeDescription.ALL_SHIPS;
118 }
119 }
120
121 public static class Level1C implements ShipSkillEffect {
122 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
123 stats.getDynamic().getMod(Stats.SHIP_BELONGS_TO_FLEET_THAT_CAN_COUNTER_EW).modifyFlat(id, 1f);
124 }
125 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
126 stats.getDynamic().getMod(Stats.SHIP_BELONGS_TO_FLEET_THAT_CAN_COUNTER_EW).unmodifyFlat(id);
127 }
128 public String getEffectDescription(float level) {
129 String excess = "" + (int)Math.round(ElectronicWarfareScript.BASE_MAXIMUM * 2f);
130 return "Half of your fleet's excess (above " + excess + "%) ECM rating reduces the maximum range penalty due to enemy ECM";
131 }
132 public String getEffectPerLevelDescription() {
133 return null;
134 }
135 public ScopeDescription getScopeDescription() {
136 return ScopeDescription.ALL_SHIPS;
137 }
138 }
139
140}