Starsector API
Loading...
Searching...
No Matches
PolarizedArmor.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.skills;
2
3import java.awt.Color;
4
5import org.lwjgl.util.vector.Vector2f;
6
7import com.fs.starfarer.api.characters.AfterShipCreationSkillEffect;
8import com.fs.starfarer.api.characters.DescriptionSkillEffect;
9import com.fs.starfarer.api.characters.ShipSkillEffect;
10import com.fs.starfarer.api.combat.CombatEntityAPI;
11import com.fs.starfarer.api.combat.DamageAPI;
12import com.fs.starfarer.api.combat.MutableShipStatsAPI;
13import com.fs.starfarer.api.combat.ShipAPI;
14import com.fs.starfarer.api.combat.ShipAPI.HullSize;
15import com.fs.starfarer.api.combat.ShipHullSpecAPI.ShipTypeHints;
16import com.fs.starfarer.api.combat.listeners.AdvanceableListener;
17import com.fs.starfarer.api.combat.listeners.DamageTakenModifier;
18import com.fs.starfarer.api.util.Misc;
19
20public class PolarizedArmor {
21
22 //public static float ARMOR_FRACTION_BONUS = 0.05f;
23 public static float EFFECTIVE_ARMOR_BONUS = 50;
24 public static float EMP_BONUS_PERCENT = 50f;
25
26 public static float VENT_RATE_BONUS = 25f;
27
28 public static float NON_SHIELD_FLUX_LEVEL = 50f;
29
30 public static class Level0 implements DescriptionSkillEffect {
31 public String getString() {
32 return "\n\n*Ships without a shield or a phase cloak are treated as always having " + (int) NON_SHIELD_FLUX_LEVEL + "% hard flux.";
33 }
34 public Color[] getHighlightColors() {
35 Color h = Misc.getHighlightColor();
36 h = Misc.getDarkHighlightColor();
37 return new Color[] {h};
38 }
39 public String[] getHighlights() {
40 return new String [] {"" + (int) NON_SHIELD_FLUX_LEVEL + "%"};
41 }
42 public Color getTextColor() {
43 return null;
44 }
45 }
46
47 public static class PolarizedArmorEffectMod implements DamageTakenModifier, AdvanceableListener {
48 protected ShipAPI ship;
49 protected String id;
50 public PolarizedArmorEffectMod(ShipAPI ship, String id) {
51 this.ship = ship;
52 this.id = id;
53 }
54
55 public void advance(float amount) {
56 MutableShipStatsAPI stats = ship.getMutableStats();
57
58 float fluxLevel = ship.getHardFluxLevel();
59
60 if (ship.getShield() == null && !ship.getHullSpec().isPhase() &&
61 (ship.getPhaseCloak() == null || !ship.getHullSpec().getHints().contains(ShipTypeHints.PHASE))) {
62 fluxLevel = NON_SHIELD_FLUX_LEVEL * 0.01f;
63 }
64
65 //float armorBonus = ship.getArmorGrid().getArmorRating() * ARMOR_FRACTION_BONUS * fluxLevel;
66 float armorBonus = EFFECTIVE_ARMOR_BONUS * fluxLevel;
67 float empBonus = EMP_BONUS_PERCENT * fluxLevel;
68 //armorBonus = 1090000;
69 //wefwef we fe stats.getMaxArmorDamageReduction().modifyFlat(id, 0.1f);
70 //stats.getEffectiveArmorBonus().modifyFlat(id, armorBonus);
71 stats.getEffectiveArmorBonus().modifyPercent(id, armorBonus);
72 stats.getEmpDamageTakenMult().modifyMult(id, 1f - empBonus * 0.01f);
73
74 //Color c = new Color(255, 200, 100, 100);
75 Color c = ship.getSpriteAPI().getAverageColor();
76 c = Misc.setAlpha(c, 127);
77 float b = 0f;
78 if (fluxLevel > 0.75f) {
79 b = 1f * (fluxLevel - 0.75f) / 0.25f;
80 }
81 if (b > 0) {
82 ship.setJitter(this, c, 1f * fluxLevel * b, 1, 0f);
83 }
84 }
85
86 public String modifyDamageTaken(Object param,
87 CombatEntityAPI target, DamageAPI damage,
88 Vector2f point, boolean shieldHit) {
89 return null;
90 }
91
92 }
93
94 public static class Level1 implements ShipSkillEffect {
95
96 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
97 stats.getMaxArmorDamageReduction().modifyFlat(id, 0.05f);
98 }
99
100 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
101 stats.getMaxArmorDamageReduction().unmodify(id);
102 }
103
104 public String getEffectDescription(float level) {
105 return "Maximum damage reduction by armor increased from 85% to 90%";
106 }
107
108 public String getEffectPerLevelDescription() {
109 return null;
110 }
111
112 public ScopeDescription getScopeDescription() {
113 return ScopeDescription.PILOTED_SHIP;
114 }
115 }
116
117
118 public static class Level2 implements AfterShipCreationSkillEffect {
119 public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
120 ship.addListener(new PolarizedArmorEffectMod(ship, id));
121 }
122 public void unapplyEffectsAfterShipCreation(ShipAPI ship, String id) {
123 MutableShipStatsAPI stats = ship.getMutableStats();
124 ship.removeListenerOfClass(PolarizedArmorEffectMod.class);
125 stats.getEffectiveArmorBonus().unmodify(id);
126 stats.getEmpDamageTakenMult().unmodify(id);
127 }
128
129 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {}
130 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {}
131
132 public String getEffectDescription(float level) {
133 //return "Up to +" + (int)Math.round(ARMOR_FRACTION_BONUS * 100f) + "% of base armor for damage reduction calculation only, based on current hard flux level";
134
135 return "Up to +" + (int)(EFFECTIVE_ARMOR_BONUS) + "% armor for damage reduction calculation only, based on current hard flux level*";
136 }
137 public String getEffectPerLevelDescription() {
138 return null;
139 }
140 public ScopeDescription getScopeDescription() {
141 return ScopeDescription.PILOTED_SHIP;
142 }
143 }
144
145 public static class Level3 implements ShipSkillEffect {
146 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {}
147 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {}
148
149 public String getEffectDescription(float level) {
150 return "EMP damage taken reduced by up to " + (int)Math.round(EMP_BONUS_PERCENT) + "%, based on current hard flux level*";
151 }
152 public String getEffectPerLevelDescription() {
153 return null;
154 }
155 public ScopeDescription getScopeDescription() {
156 return ScopeDescription.PILOTED_SHIP;
157 }
158 }
159
160 public static class Level4 implements ShipSkillEffect {
161
162 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
163 stats.getVentRateMult().modifyPercent(id, VENT_RATE_BONUS);
164 }
165
166 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
167 stats.getVentRateMult().unmodify(id);
168 }
169
170 public String getEffectDescription(float level) {
171 return "+" + (int)(VENT_RATE_BONUS) + "% flux dissipation rate while venting";
172 //return "+" + (int)(VENT_RATE_BONUS) + "% flux vent rate";
173 }
174
175 public String getEffectPerLevelDescription() {
176 return null;
177 }
178
179 public ScopeDescription getScopeDescription() {
180 return ScopeDescription.PILOTED_SHIP;
181 }
182 }
183
184}
185
186
187
188
189
190
191
192
193
194
195