Starsector API
Loading...
Searching...
No Matches
DegradedLifeSupport.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.hullmods;
2
3import com.fs.starfarer.api.combat.BaseHullMod;
4import com.fs.starfarer.api.combat.MutableShipStatsAPI;
5import com.fs.starfarer.api.combat.ShipAPI;
6import com.fs.starfarer.api.combat.ShipAPI.HullSize;
7import com.fs.starfarer.api.impl.campaign.ids.Stats;
8
9public class DegradedLifeSupport extends BaseHullMod {
10
11 public static float MAX_CREW_MULT = 0.5f;
12 public static float MAX_CR_PENALTY = 0.05f;
13
14 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
15 float effect = stats.getDynamic().getValue(Stats.DMOD_EFFECT_MULT);
16 float crewMult = MAX_CREW_MULT + (1f - MAX_CREW_MULT) * (1f - effect);
17
18 stats.getMaxCrewMod().modifyMult(id, crewMult);
19 stats.getMaxCombatReadiness().modifyFlat(id, -Math.round(MAX_CR_PENALTY * effect * 100f) * 0.01f, "Degraded Life Support");
20
21 CompromisedStructure.modifyCost(hullSize, stats, id);
22 }
23
24 public String getDescriptionParam(int index, HullSize hullSize, ShipAPI ship) {
25 float effect = 1f;
26 if (ship != null) effect = ship.getMutableStats().getDynamic().getValue(Stats.DMOD_EFFECT_MULT);
27
28 float crewMult = MAX_CREW_MULT + (1f - MAX_CREW_MULT) * (1f - effect);
29
30 if (index == 0) return "" + (int)Math.round((1f - crewMult) * 100f) + "%";
31 if (index == 1) return "" + Math.round(MAX_CR_PENALTY * 100f * effect) + "%";
32 if (index >= 2) return CompromisedStructure.getCostDescParam(index, 2);
33 return null;
34 }
35
36
37}
void modifyFlat(String source, float value)
void modifyMult(String source, float value)
static String getCostDescParam(int index, int startIndex)
static void modifyCost(HullSize hullSize, MutableShipStatsAPI stats, String id)
String getDescriptionParam(int index, HullSize hullSize, ShipAPI ship)
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
MutableShipStatsAPI getMutableStats()