001package com.fs.starfarer.api.impl.hullmods; 002 003import com.fs.starfarer.api.combat.BaseHullMod; 004import com.fs.starfarer.api.combat.MutableShipStatsAPI; 005import com.fs.starfarer.api.combat.ShipAPI; 006import com.fs.starfarer.api.combat.ShipAPI.HullSize; 007import com.fs.starfarer.api.impl.campaign.ids.Stats; 008 009public class DegradedLifeSupport extends BaseHullMod { 010 011 public static float MAX_CREW_MULT = 0.5f; 012 public static float MAX_CR_PENALTY = 0.05f; 013 014 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) { 015 float effect = stats.getDynamic().getValue(Stats.DMOD_EFFECT_MULT); 016 float crewMult = MAX_CREW_MULT + (1f - MAX_CREW_MULT) * (1f - effect); 017 018 stats.getMaxCrewMod().modifyMult(id, crewMult); 019 stats.getMaxCombatReadiness().modifyFlat(id, -Math.round(MAX_CR_PENALTY * effect * 100f) * 0.01f, "Degraded Life Support"); 020 021 CompromisedStructure.modifyCost(hullSize, stats, id); 022 } 023 024 public String getDescriptionParam(int index, HullSize hullSize, ShipAPI ship) { 025 float effect = 1f; 026 if (ship != null) effect = ship.getMutableStats().getDynamic().getValue(Stats.DMOD_EFFECT_MULT); 027 028 float crewMult = MAX_CREW_MULT + (1f - MAX_CREW_MULT) * (1f - effect); 029 030 if (index == 0) return "" + (int)Math.round((1f - crewMult) * 100f) + "%"; 031 if (index == 1) return "" + Math.round(MAX_CR_PENALTY * 100f * effect) + "%"; 032 if (index >= 2) return CompromisedStructure.getCostDescParam(index, 2); 033 return null; 034 } 035 036 037}