001package com.fs.starfarer.api.impl.campaign.skills; 002 003import java.awt.Color; 004 005import com.fs.starfarer.api.Global; 006import com.fs.starfarer.api.campaign.FleetDataAPI; 007import com.fs.starfarer.api.characters.CharacterStatsSkillEffect; 008import com.fs.starfarer.api.characters.DescriptionSkillEffect; 009import com.fs.starfarer.api.characters.FleetTotalItem; 010import com.fs.starfarer.api.characters.FleetTotalSource; 011import com.fs.starfarer.api.characters.MutableCharacterStatsAPI; 012import com.fs.starfarer.api.characters.ShipSkillEffect; 013import com.fs.starfarer.api.characters.SkillSpecAPI; 014import com.fs.starfarer.api.combat.MutableShipStatsAPI; 015import com.fs.starfarer.api.combat.ShipAPI.HullSize; 016import com.fs.starfarer.api.impl.campaign.AICoreOfficerPluginImpl; 017import com.fs.starfarer.api.impl.campaign.ids.Skills; 018import com.fs.starfarer.api.impl.campaign.ids.Strings; 019import com.fs.starfarer.api.impl.campaign.ids.Tags; 020import com.fs.starfarer.api.impl.hullmods.Automated; 021import com.fs.starfarer.api.ui.TooltipMakerAPI; 022import com.fs.starfarer.api.util.Misc; 023 024public class AutomatedShips { 025 026 public static float MAX_CR_BONUS = 100f; 027 028 public static class Level0 implements DescriptionSkillEffect { 029 public String getString() { 030 int alpha = (int) Math.round(AICoreOfficerPluginImpl.ALPHA_MULT); 031 int beta = (int) Math.round(AICoreOfficerPluginImpl.BETA_MULT); 032 int gamma = (int) Math.round(AICoreOfficerPluginImpl.GAMMA_MULT); 033 034 return "*The total \"automated ship points\" are equal to the deployment points cost of " + 035 "all automated ships in the fleet, with a multiplier for installed AI cores - " + 036 alpha + Strings.X + " for an Alpha Core, " + 037 beta + Strings.X + " for a Beta Core, and " + 038 gamma + Strings.X + " for a Gamma Core. " 039 + "Due to safety interlocks, ships with AI cores do not contribute to the deployment point distribution."; 040// int alpha = AICoreOfficerPluginImpl.ALPHA_POINTS; 041// int beta = AICoreOfficerPluginImpl.BETA_POINTS; 042// int gamma = AICoreOfficerPluginImpl.GAMMA_POINTS; 043// if (BaseSkillEffectDescription.USE_RECOVERY_COST) { 044// return "*The total \"automated ship points\" are equal to the deployment recovery cost of " + 045// "all automated ships in the fleet, plus extra points for installed AI cores - " + 046// alpha + " for an Alpha Core, " + 047// beta + " for a Beta Core, and " + 048// gamma + " for a Gamma Core." 049// ; 050// } else { 051// return "*The total \"automated ship points\" are equal to the ordnance points of " + 052// "all automated ships in the fleet, plus extra points for AI cores installed on any of the " + 053// "automated ships - " + 054// alpha + " for an Alpha Core, " + 055// beta + " for a Beta Core, and " + 056// gamma + " for a Gamma Core." 057// ; 058// } 059 } 060 public Color[] getHighlightColors() { 061 Color h = Misc.getHighlightColor(); 062 h = Misc.getDarkHighlightColor(); 063 Color bad = Misc.getNegativeHighlightColor(); 064 //bad = Misc.setAlpha(bad, 240); 065 return new Color[] {h, h, h, bad}; 066 } 067 public String[] getHighlights() { 068// int alpha = AICoreOfficerPluginImpl.ALPHA_POINTS; 069// int beta = AICoreOfficerPluginImpl.BETA_POINTS; 070// int gamma = AICoreOfficerPluginImpl.GAMMA_POINTS; 071 int alpha = (int) Math.round(AICoreOfficerPluginImpl.ALPHA_MULT); 072 int beta = (int) Math.round(AICoreOfficerPluginImpl.BETA_MULT); 073 int gamma = (int) Math.round(AICoreOfficerPluginImpl.GAMMA_MULT); 074 return new String [] {"" + alpha + Strings.X, "" + beta + Strings.X, "" + gamma + Strings.X, 075 "do not contribute to the deployment point distribution"}; 076 } 077 public Color getTextColor() { 078 return null; 079 } 080 } 081 082 083 public static class Level1 extends BaseSkillEffectDescription implements ShipSkillEffect, FleetTotalSource { 084 085 public FleetTotalItem getFleetTotalItem() { 086 return getAutomatedPointsTotal(); 087 } 088 089 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) { 090 if (Misc.isAutomated(stats) && 091 !Automated.isAutomatedNoPenalty(stats)) { 092 float crBonus = computeAndCacheThresholdBonus(stats, "auto_cr", MAX_CR_BONUS, ThresholdBonusType.AUTOMATED_POINTS); 093 SkillSpecAPI skill = Global.getSettings().getSkillSpec(Skills.AUTOMATED_SHIPS); 094 stats.getMaxCombatReadiness().modifyFlat(id, crBonus * 0.01f, skill.getName() + " skill"); 095 } 096 } 097 098 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) { 099 stats.getMaxCombatReadiness().unmodifyFlat(id); 100 } 101 102 public String getEffectDescription(float level) { 103 return null; 104 } 105 106 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill, 107 TooltipMakerAPI info, float width) { 108 init(stats, skill); 109 110 FleetDataAPI data = getFleetData(null); 111 float crBonus = computeAndCacheThresholdBonus(data, stats, "auto_cr", MAX_CR_BONUS, ThresholdBonusType.AUTOMATED_POINTS); 112 113 String partially = ""; 114 String penalty = "" + (int)Math.round(Automated.MAX_CR_PENALTY * 100f) + "%%"; 115 if ((int) crBonus < 100f) partially = "partially "; 116 info.addPara("+%s combat readiness (maximum: %s); " + partially + "offsets built-in " + penalty + " penalty", 0f, hc, hc, 117 "" + (int) crBonus + "%", 118 "" + (int) MAX_CR_BONUS + "%"); 119 addAutomatedThresholdInfo(info, data, stats); 120 121 //info.addSpacer(5f); 122 } 123 124 public ScopeDescription getScopeDescription() { 125 return ScopeDescription.ALL_SHIPS; 126 } 127 } 128 129 public static class Level2 extends BaseSkillEffectDescription implements CharacterStatsSkillEffect { 130 131 public void apply(MutableCharacterStatsAPI stats, String id, float level) { 132 if (stats.isPlayerStats()) { 133 Misc.getAllowedRecoveryTags().add(Tags.AUTOMATED_RECOVERABLE); 134 } 135 } 136 137 public void unapply(MutableCharacterStatsAPI stats, String id) { 138 if (stats.isPlayerStats()) { 139 Misc.getAllowedRecoveryTags().remove(Tags.AUTOMATED_RECOVERABLE); 140 } 141 } 142 143 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill, 144 TooltipMakerAPI info, float width) { 145 init(stats, skill); 146 info.addPara("Enables the recovery of some automated ships, such as derelict drones", hc, 0f); 147 info.addPara("Automated ships can only be captained by AI cores", hc, 0f); 148 info.addSpacer(5f); 149 } 150 151 public String getEffectPerLevelDescription() { 152 return null; 153 } 154 155 public ScopeDescription getScopeDescription() { 156 return ScopeDescription.FLEET; 157 } 158 } 159 160} 161 162 163 164 165