34 public static class Level1
implements ShipSkillEffect {
35 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String
id,
float level) {
39 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String
id) {
40 stats.getPeakCRDuration().unmodifyFlat(
id);
43 public String getEffectDescription(
float level) {
47 public String getEffectPerLevelDescription() {
51 public ScopeDescription getScopeDescription() {
52 return ScopeDescription.PILOTED_SHIP;
56 public static class Level2
implements ShipSkillEffect {
57 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String
id,
float level) {
61 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String
id) {
62 stats.getCRLossPerSecondPercent().unmodifyMult(
id);
65 public String getEffectDescription(
float level) {
66 return "-" + (int)(
DEGRADE_REDUCTION_PERCENT) +
"% combat readiness degradation rate after peak performance time runs out";
69 public String getEffectPerLevelDescription() {
73 public ScopeDescription getScopeDescription() {
74 return ScopeDescription.PILOTED_SHIP;
78 public static class Level3
implements ShipSkillEffect {
80 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String
id,
float level) {
81 stats.getMaxCombatReadiness().modifyFlat(
id,
MAX_CR_BONUS * 0.01f,
"Combat Endurance skill");
84 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String
id) {
85 stats.getMaxCombatReadiness().unmodify(
id);
88 public String getEffectDescription(
float level) {
89 return "+" + (int)(
MAX_CR_BONUS) +
"% maximum combat readiness";
92 public String getEffectPerLevelDescription() {
96 public ScopeDescription getScopeDescription() {
97 return ScopeDescription.PILOTED_SHIP;
101 public static class Level4
extends BaseSkillEffectDescription implements ShipSkillEffect, AfterShipCreationSkillEffect {
102 public void applyEffectsAfterShipCreation(ShipAPI ship, String
id) {
103 ship.addListener(
new CombatEnduranceRegen(ship));
106 public void unapplyEffectsAfterShipCreation(ShipAPI ship, String
id) {
107 ship.removeListenerOfClass(CombatEnduranceRegen.class);
111 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String
id,
float level) {}
113 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String
id) {}
115 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
116 TooltipMakerAPI info,
float width) {
119 info.addPara(
"When below %s hull, repair %s per second; maximum total repair is "
120 +
"the higher of %s points or %s of maximum hull", 0f,
hc,
hc,
123 "" + Misc.getRoundedValueMaxOneAfterDecimal(
REGEN_RATE * 100f) +
"%",
132 public static class CombatEnduranceRegen
implements DamageTakenModifier, AdvanceableListener {
133 protected ShipAPI ship;
134 protected boolean inited =
false;
135 protected float limit = 0f;
136 protected float repaired = 0f;
137 protected String repKey1;
138 protected String repKey2;
139 public CombatEnduranceRegen(ShipAPI ship) {
143 protected void init() {
146 float maxHull = ship.getMaxHitpoints();
149 repKey1 =
"CombatEnduranceRegen_ " + ship.getId() +
"_repaired";
150 repKey2 =
"CombatEnduranceRegen_ " + ship.getCaptain().getId() +
"_repaired";
151 float r1 = getRepaired(repKey1);
152 float r2 = getRepaired(repKey2);
154 repaired = Math.max(repaired, r1);
155 repaired = Math.max(repaired, r2);
158 protected float getRepaired(String key) {
159 Float r = (Float) Global.getCombatEngine().getCustomData().get(key);
160 if (r ==
null) r = 0f;
164 public void advance(
float amount) {
169 if (repaired >= limit)
return;
171 if (ship.isHulk())
return;
173 float maxHull = ship.getMaxHitpoints();
174 float currHull = ship.getHitpoints();
177 float repairAmount = Math.min(limit - repaired, maxHull *
REGEN_RATE * amount);
185 if (repairAmount > maxPoints - currHull) repairAmount = maxPoints - currHull;
187 if (repairAmount > 0) {
188 ship.setHitpoints(ship.getHitpoints() + repairAmount);
189 repaired += repairAmount;
190 Global.getCombatEngine().getCustomData().put(repKey1, repaired);
192 Global.getCombatEngine().getCustomData().put(repKey2, repaired * 0.5f);
196 public String modifyDamageTaken(Object param,
197 CombatEntityAPI target, DamageAPI damage,
198 Vector2f point,
boolean shieldHit) {