Starsector API
Loading...
Searching...
No Matches
ThreatHullmod.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.combat.threat;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.combat.BaseHullMod;
7import com.fs.starfarer.api.combat.CombatEngineAPI;
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.impl.campaign.ids.Stats;
12import com.fs.starfarer.api.ui.Alignment;
13import com.fs.starfarer.api.ui.TooltipMakerAPI;
14import com.fs.starfarer.api.util.Misc;
15
21public class ThreatHullmod extends BaseHullMod {
22
23 public static String SHIP_BEING_RECLAIMED = "ship_being_reclaimed";
24
25 public static String HIVE_UNIT = "hive_unit";
26 public static String FABRICATOR_UNIT = "fabricator_unit";
27
28 public static float AIM_BONUS = 1f;
29 public static float MISSILE_GUIDANCE_BONUS = 1f;
30 public static float CR_BONUS = 30f;
31 public static float SENSOR_PROFILE_MULT = 0f;
32 public static float EW_PENALTY_MULT = 0.5f;
33
34// public static float HIVE_UNIT_REGEN_RATE_MULT = 8f;
35// public static float HIVE_UNIT_SWARM_SIZE_MULT = 2f;
36 public static float HIVE_UNIT_REGEN_RATE_MULT = 2f;
37 public static float HIVE_UNIT_SWARM_SIZE_MULT = 4f;
38 public static float FABRICATOR_UNIT_REGEN_RATE_MULT = 1f;
39 public static float FABRICATOR_UNIT_SWARM_SIZE_MULT = 2f;
40
41 public static float MODULE_DAMAGE_TAKEN_MULT = 0.5f;
42 public static float EMP_DAMAGE_TAKEN_MULT = 0.5f;
43
44 @Override
45 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
47
50 stats.getMaxCombatReadiness().modifyFlat(id, CR_BONUS * 0.01f);
51
53
55
60
61 if (stats.getVariant() != null && stats.getVariant().getHullSpec().getHullId().equals(HIVE_UNIT)) {
64// stats.getDynamic().getStat(Stats.FRAGMENT_SWARM_RESPAWN_RATE_MULT).modifyMult(id, 2f);
65// stats.getDynamic().getMod(Stats.FRAGMENT_SWARM_SIZE_MOD).modifyMult(id, 4f);
66 } else if (stats.getVariant() != null && stats.getVariant().getHullSpec().getHullId().equals(FABRICATOR_UNIT)) {
69 }
70
71 //if (hullSize == HullSize.FIGHTER) {
72 //stats.getEnergyAmmoRegenMult().modifyMult(id, 1000f);
73 //}
74
75 // no officers, but baseline affected by certain skill effects
76 // or not - actually really difficult with these
77 if (hullSize != HullSize.FIGHTER) {
78// new ImpactMitigation.Level2().apply(stats, hullSize, id, 1f);
79// new ImpactMitigation.Level4().apply(stats, hullSize, id, 1f);
80//
81// new DamageControl.Level3().apply(stats, hullSize, id, 1f);
82// new DamageControl.Level4().apply(stats, hullSize, id, 1f);
83// new DamageControl.Level8().apply(stats, hullSize, id, 1f); // elite
84//
85// new TargetAnalysis.Level2().apply(stats, hullSize, id, 1f);
86// new TargetAnalysis.Level3().apply(stats, hullSize, id, 1f);
87// new TargetAnalysis.Level1A().apply(stats, hullSize, id, 1f); // elite
88// new TargetAnalysis.Level1().apply(stats, hullSize, id, 1f); // elite
89// new TargetAnalysis.Level4().apply(stats, hullSize, id, 1f); // elite
90//
91// new BallisticMastery.Level1().apply(stats, hullSize, id, 1f);
92// new BallisticMastery.Level2().apply(stats, hullSize, id, 1f);
93 }
94 }
95
96
97 @Override
98 public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
99// CombatEngineAPI engine = Global.getCombatEngine();
100// if (!engine.hasPluginOfClass(ThreatCombatStrategyForBothSidesPlugin.class)) {
101// engine.addPlugin(new ThreatCombatStrategyForBothSidesPlugin());
102// }
103// if (ship.getSystem() != null && ship.getSystem().getScript() instanceof EnergyLashActivatedSystem) {
104// EnergyLashActivatedSystem script = (EnergyLashActivatedSystem) ship.getSystem().getScript();
105// script.resetAfterShipCreation(ship);
106// }
107 }
108
109
110 @Override
117
118
119 @Override
120 public void advanceInCombat(ShipAPI ship, float amount) {
121 super.advanceInCombat(ship, amount);
122
123 if (!ship.isHulk() || ship.hasTag(SHIP_BEING_RECLAIMED)) return;
124 if (ThreatCombatStrategyAI.isFabricator(ship)) return;
125
126 float elapsedAsHulk = 0f;
127 String key = "elapsedAsHulkKey";
128 if (ship.getCustomData().containsKey(key)) {
129 elapsedAsHulk = (float) ship.getCustomData().get(key);
130 }
131 elapsedAsHulk += amount;
132 ship.setCustomData(key, elapsedAsHulk);
133 if (elapsedAsHulk > 1f) {
135 int owner = ship.getOriginalOwner();
136 boolean found = false;
137 for (ShipAPI curr : engine.getShips()) {
138 if (curr == ship || curr.getOwner() != owner) continue;
139 if (curr.isHulk() || curr.getOwner() == 100) continue;
140 if (!ThreatCombatStrategyAI.isFabricator(curr)) continue;
141 if (curr.getCurrentCR() >= 1f) continue;
142 found = true;
143 break;
144 }
145 if (found) {
147 } else {
148 ship.setCustomData(key, 0f);
149 }
150 }
151 }
152
153
154 @Override
155 public void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id) {
156 }
157
158
159 @Override
160 public boolean shouldAddDescriptionToTooltip(HullSize hullSize, ShipAPI ship, boolean isForModSpec) {
161 return false;
162 }
163
164 @Override
165 public void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec) {
166 float pad = 3f;
167 float opad = 10f;
168 Color h = Misc.getHighlightColor();
169 Color bad = Misc.getNegativeHighlightColor();
170 Color t = Misc.getTextColor();
171 Color g = Misc.getGrayColor();
172
173 tooltip.addPara("Threat hulls have a number of shared properties.", opad);
174
175 tooltip.addSectionHeading("Campaign", Alignment.MID, opad);
176 tooltip.addPara("Sensor profile reduced to %s.", opad, h, "0");
177
178 tooltip.addSectionHeading("Combat", Alignment.MID, opad);
179 tooltip.addPara("Target leading accuracy increased to maximum for all weapons, including missiles. Effect "
180 + "of enemy ECM rating reduced by %s.", opad, h, "" + (int) Math.round(EW_PENALTY_MULT * 100f) + "%");
181 tooltip.addPara("Weapon and engine damage taken is reduced by %s. EMP damage taken is reduced by %s. In "
182 + "addition, repairs of damaged but functional weapons and engines can continue while they are under fire.",
183 opad, h,
184 "" + (int) Math.round((1f - MODULE_DAMAGE_TAKEN_MULT) * 100f) + "%",
185 "" + (int) Math.round((1f - EMP_DAMAGE_TAKEN_MULT) * 100f) + "%");
186
187
188 }
189
190 public float getTooltipWidth() {
191 return super.getTooltipWidth();
192 }
193
194
195}
static CombatEngineAPI getCombatEngine()
Definition Global.java:69
void modifyFlat(String source, float value)
void modifyMult(String source, float value)
void modifyMult(String source, float value)
void modifyFlat(String source, float value)
static final String ELECTRONIC_WARFARE_PENALTY_MOD
Definition Stats.java:192
static final String CAN_REPAIR_MODULES_UNDER_FIRE
Definition Stats.java:148
static final String FRAGMENT_SWARM_RESPAWN_RATE_MULT
Definition Stats.java:151
boolean shouldAddDescriptionToTooltip(HullSize hullSize, ShipAPI ship, boolean isForModSpec)
void applyEffectsAfterShipAddedToCombatEngine(ShipAPI ship, String id)
void applyEffectsAfterShipCreation(ShipAPI ship, String id)
void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id)
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec)
static Color getTextColor()
Definition Misc.java:839
static Color getNegativeHighlightColor()
Definition Misc.java:802
static Color getGrayColor()
Definition Misc.java:826
static Color getHighlightColor()
Definition Misc.java:792
void addPlugin(EveryFrameCombatPlugin plugin)
void setCustomData(String key, Object data)
LabelAPI addPara(String format, float pad, Color hl, String... highlights)
LabelAPI addSectionHeading(String str, Alignment align, float pad)