Starsector API
Loading...
Searching...
No Matches
EnergyBoltCoherer.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.hullmods;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.combat.BaseHullMod;
6import com.fs.starfarer.api.combat.MutableShipStatsAPI;
7import com.fs.starfarer.api.combat.ShipAPI;
8import com.fs.starfarer.api.combat.ShipAPI.HullSize;
9import com.fs.starfarer.api.combat.WeaponAPI;
10import com.fs.starfarer.api.combat.WeaponAPI.WeaponType;
11import com.fs.starfarer.api.combat.listeners.WeaponBaseRangeModifier;
12import com.fs.starfarer.api.ui.Alignment;
13import com.fs.starfarer.api.ui.TooltipMakerAPI;
14import com.fs.starfarer.api.util.Misc;
15
16public class EnergyBoltCoherer extends BaseHullMod {
17
18 public static float RANGE_BONUS = 200;
19 public static float CREWED_RANGE_BONUS = 100;
20
21 public static float CREW_CASUALTIES = 50;
22
23 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
24 if (!Misc.isAutomated(stats)) {
25 stats.getCrewLossMult().modifyPercent(id, CREW_CASUALTIES);
26 }
27 }
28
29 @Override
30 public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
31 ship.addListener(new EnergyBoltCohererRangeModifier());
32 }
33
34 public static class EnergyBoltCohererRangeModifier implements WeaponBaseRangeModifier {
35 public EnergyBoltCohererRangeModifier() {
36 }
37
38 public float getWeaponBaseRangePercentMod(ShipAPI ship, WeaponAPI weapon) {
39 return 0;
40 }
41 public float getWeaponBaseRangeMultMod(ShipAPI ship, WeaponAPI weapon) {
42 return 1f;
43 }
44 public float getWeaponBaseRangeFlatMod(ShipAPI ship, WeaponAPI weapon) {
45 if (weapon.isBeam()) return 0f;
46 if (weapon.getType() == WeaponType.ENERGY || weapon.getType() == WeaponType.HYBRID) {
47 if (Misc.isAutomated(ship)) {
48 return RANGE_BONUS;
49 } else {
50 return CREWED_RANGE_BONUS;
51 }
52 }
53 return 0f;
54 }
55 }
56
57 public String getDescriptionParam(int index, HullSize hullSize) {
58 return null;
59 }
60
61 @Override
62 public boolean shouldAddDescriptionToTooltip(HullSize hullSize, ShipAPI ship, boolean isForModSpec) {
63 return false;
64 }
65
66 @Override
67 public void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec) {
68 float pad = 3f;
69 float opad = 10f;
70 Color h = Misc.getHighlightColor();
71 Color bad = Misc.getNegativeHighlightColor();
72
73
74 if (!Misc.isAutomated(ship)) {
75 tooltip.addPara("Originally designed by the Tri-Tachyon Corporation for use on its combat droneships, "
76 + "the coherence field strength has to be dialed down to allow operation on crewed vessels.", opad);
77 tooltip.addPara("Increases the base range of all non-beam Energy and Hybrid weapons by %s.", opad, h,
78 "" + (int)CREWED_RANGE_BONUS);
79 tooltip.addPara("The coherence field is unstable under combat conditions, with stresses on the hull "
80 + "resulting in spot failures that release bursts of lethal radiation. "
81 + "Crew casualties in combat are increased by %s.", opad, h,
82 "" + (int) CREW_CASUALTIES + "%");
83 } else {
84 tooltip.addPara("Increases the base range of all non-beam Energy and Hybrid weapons by %s.", opad, h,
85 "" + (int)RANGE_BONUS);
86 }
87
88 tooltip.addSectionHeading("Interactions with other modifiers", Alignment.MID, opad);
89 tooltip.addPara("Since the base range is increased, this range modifier"
90 + " - unlike most other flat modifiers in the game - "
91 + "is increased by percentage modifiers from other hullmods and skills.", opad);
92 }
93
94// @Override
95// public boolean isApplicableToShip(ShipAPI ship) {
96// return getUnapplicableReason(ship) == null;
97// }
98//
99// public String getUnapplicableReason(ShipAPI ship) {
100// if (ship != null &&
101// ship.getHullSize() != HullSize.CAPITAL_SHIP &&
102// ship.getHullSize() != HullSize.DESTROYER &&
103// ship.getHullSize() != HullSize.CRUISER) {
104// return "Can only be installed on destroyer-class hulls and larger";
105// }
106// return null;
107// }
108
109}
110
111
112
113
114
115
116
117
118
void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec)
String getDescriptionParam(int index, HullSize hullSize)
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
boolean shouldAddDescriptionToTooltip(HullSize hullSize, ShipAPI ship, boolean isForModSpec)