001package com.fs.starfarer.api.impl.campaign.skills; 002 003import java.awt.Color; 004 005import com.fs.starfarer.api.characters.DescriptionSkillEffect; 006import com.fs.starfarer.api.characters.FleetStatsSkillEffect; 007import com.fs.starfarer.api.characters.MutableCharacterStatsAPI; 008import com.fs.starfarer.api.characters.ShipSkillEffect; 009import com.fs.starfarer.api.characters.SkillSpecAPI; 010import com.fs.starfarer.api.combat.MutableShipStatsAPI; 011import com.fs.starfarer.api.combat.ShipAPI.HullSize; 012import com.fs.starfarer.api.fleet.FleetMemberAPI; 013import com.fs.starfarer.api.fleet.MutableFleetStatsAPI; 014import com.fs.starfarer.api.impl.campaign.DModManager; 015import com.fs.starfarer.api.impl.campaign.ids.Stats; 016import com.fs.starfarer.api.ui.TooltipMakerAPI; 017import com.fs.starfarer.api.util.Misc; 018 019public class DerelictContingent { 020 021 public static float MAX_DMODS = 5; 022 //public static float MINUS_CR_PER_DMOD = 3f; 023 public static float MINUS_CR_PER_DMOD = 0f; 024 public static float MINUS_DP_PERCENT_PER_DMOD = 6f; 025 public static float EXTRA_DMODS = 4; 026 027 028 029 public static class Level0 implements DescriptionSkillEffect { 030 public String getString() { 031 return "*Maximum effect reached " + 032 "at " + (int) MAX_DMODS + " d-mods." 033 ; 034 } 035 public Color[] getHighlightColors() { 036 Color h = Misc.getHighlightColor(); 037 h = Misc.getDarkHighlightColor(); 038 return new Color[] {h}; 039 } 040 public String[] getHighlights() { 041 return new String [] {"" + (int) MAX_DMODS}; 042 } 043 public Color getTextColor() { 044 return null; 045 } 046 } 047 048 public static class Level1 extends BaseSkillEffectDescription implements ShipSkillEffect { 049 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 050 FleetMemberAPI member = stats.getFleetMember(); 051 float dmods = 0; 052 if (member != null) { 053 dmods = DModManager.getNumDMods(member.getVariant()); 054 if (dmods > MAX_DMODS) dmods = MAX_DMODS; 055 } 056 057 if (dmods > 0) { 058 float depBonus = dmods * MINUS_DP_PERCENT_PER_DMOD; 059 //stats.getDynamic().getMod(Stats.DEPLOYMENT_POINTS_MOD).modifyPercent(id, -depBonus); 060 stats.getDynamic().getMod(Stats.DEPLOYMENT_POINTS_MOD).modifyMult(id, 1f - (depBonus/100f)); 061 062 stats.getDynamic().getMod(Stats.DMOD_REDUCE_MAINTENANCE).modifyFlat(id, 1f); 063 if (MINUS_CR_PER_DMOD > 0) { 064 float crPenalty = MINUS_CR_PER_DMOD * dmods; 065 stats.getMaxCombatReadiness().modifyFlat(id, -crPenalty * 0.01f, "Derelict Operations skill"); 066 } 067 } 068 069// if (EXTRA_DMODS > 0) { 070// stats.getDynamic().getMod(Stats.DMOD_ACQUIRE_PROB_MOD).modifyFlat(id, 1000f); 071// } 072 } 073 074 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 075 stats.getDynamic().getMod(Stats.DEPLOYMENT_POINTS_MOD).unmodify(id); 076 stats.getDynamic().getMod(Stats.DMOD_REDUCE_MAINTENANCE).unmodify(id); 077 if (MINUS_CR_PER_DMOD > 0) { 078 stats.getMaxCombatReadiness().unmodify(id); 079 } 080 081// if (EXTRA_DMODS > 0) { 082// stats.getDynamic().getMod(Stats.DMOD_ACQUIRE_PROB_MOD).unmodify(id); 083// } 084 } 085 086 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill, 087 TooltipMakerAPI info, float width) { 088 init(stats, skill); 089 090 info.addPara("Deployment point cost of ships reduced by %s per d-mod*", 0f, 091 hc, hc, "" + (int)MINUS_DP_PERCENT_PER_DMOD + "%"); 092 if (MINUS_CR_PER_DMOD > 0) { 093 info.addPara("(D) hull deployment cost reduction also applies to maintenance cost," 094 + " but maximum CR is reduced by %s per d-mod*", 0f, 095 hc, hc, "" + (int)MINUS_CR_PER_DMOD + "%"); 096 } else { 097 info.addPara("(D) hull deployment cost reduction also applies to maintenance cost", hc, 0f); 098 } 099 100 } 101 } 102 103 public static class Level2 implements FleetStatsSkillEffect { 104 public void apply(MutableFleetStatsAPI stats, String id, float level) { 105 stats.getDynamic().getMod(Stats.SHIP_DMOD_REDUCTION).modifyFlat(id, -EXTRA_DMODS); 106 } 107 108 public void unapply(MutableFleetStatsAPI stats, String id) { 109 stats.getDynamic().getMod(Stats.SHIP_DMOD_REDUCTION).unmodify(id); 110 } 111 112 public String getEffectDescription(float level) { 113 //return "Recovered ships have " + (int) EXTRA_DMODS + " more d-mods on average"; 114 return "Recovered ships have more d-mods than normal"; 115 } 116 117 public String getEffectPerLevelDescription() { 118 return null; 119 } 120 121 public ScopeDescription getScopeDescription() { 122 return ScopeDescription.FLEET; 123 } 124 } 125 126}