001package com.fs.starfarer.api.impl.campaign.skills;
002
003import com.fs.starfarer.api.characters.ShipSkillEffect;
004import com.fs.starfarer.api.combat.MutableShipStatsAPI;
005import com.fs.starfarer.api.combat.ShipAPI.HullSize;
006import com.fs.starfarer.api.impl.campaign.ids.Stats;
007
008public class GunneryImplants {
009        
010        public static float RECOIL_BONUS = 25f;
011        public static float TARGET_LEADING_BONUS = 100f;
012        public static float RANGE_BONUS = 15f;
013        public static float RANGE_BONUS_ELITE = 5f;
014        
015        public static float EW_FRIGATES = 4f;
016        public static float EW_DESTROYERS = 2f;
017        public static float EW_OTHER = 1f;
018        
019        public static class Level1A implements ShipSkillEffect {
020                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
021                        float bonus = 0f;
022                        if (hullSize == HullSize.FRIGATE) bonus = EW_FRIGATES;
023                        if (hullSize == HullSize.DESTROYER) bonus = EW_DESTROYERS;
024                        if (hullSize == HullSize.CRUISER || hullSize == HullSize.CAPITAL_SHIP) bonus = EW_OTHER;
025                        if (bonus > 0f) {
026                                stats.getDynamic().getMod(Stats.ELECTRONIC_WARFARE_FLAT).modifyFlat(id, bonus);
027                        }
028                }
029                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
030                        stats.getDynamic().getMod(Stats.ELECTRONIC_WARFARE_FLAT).unmodify(id);
031                }
032                public String getEffectDescription(float level) {
033                        //return "+1-4" + "% to ECM rating of ships, depending on ship size";
034                        return "+" + (int)EW_FRIGATES + "% to ECM rating* of fleet when piloting a frigate, " +
035                                   "+" + (int) EW_DESTROYERS + "% when piloting a destroyer, " +
036                                   "+" + (int) EW_OTHER + "% for larger hulls";
037//                      "Destroyers: grants " + (int)EW_DESTROYERS + "% to ECM rating of fleet";
038//                      return "Frigates: grants " + (int)EW_FRIGATES + "% to ECM rating of fleet\n"+
039//                                 "Destroyers: grants " + (int)EW_DESTROYERS + "% to ECM rating of fleet";
040                }
041                public String getEffectPerLevelDescription() {
042                        return null;
043                }
044                public ScopeDescription getScopeDescription() {
045                        return ScopeDescription.PILOTED_SHIP;
046                }
047        }
048
049        public static class Level1 implements ShipSkillEffect {
050                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
051                        stats.getMaxRecoilMult().modifyMult(id, 1f - (0.01f * RECOIL_BONUS));
052                        stats.getRecoilPerShotMult().modifyMult(id, 1f - (0.01f * RECOIL_BONUS));
053                        // slower recoil recovery, also, to match the reduced recoil-per-shot
054                        // overall effect is same as without skill but halved in every respect
055                        stats.getRecoilDecayMult().modifyMult(id, 1f - (0.01f * RECOIL_BONUS));
056                }
057                
058                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
059                        stats.getMaxRecoilMult().unmodify(id);
060                        stats.getRecoilPerShotMult().unmodify(id);
061                        stats.getRecoilDecayMult().unmodify(id);
062                }
063                
064                public String getEffectDescription(float level) {
065                        return "-" + (int)(RECOIL_BONUS) + "% weapon recoil";
066                }
067                
068                public String getEffectPerLevelDescription() {
069                        return null;
070                }
071
072                public ScopeDescription getScopeDescription() {
073                        return ScopeDescription.PILOTED_SHIP;
074                }
075        }
076
077        public static class Level2 implements ShipSkillEffect {
078                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
079                        stats.getAutofireAimAccuracy().modifyFlat(id, TARGET_LEADING_BONUS * 0.01f);
080                        //stats.getCargoMod().modifyFlat(id, 100 * level);
081                }
082                
083                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
084                        stats.getAutofireAimAccuracy().unmodify(id);
085                        //stats.getCargoMod().unmodify();
086                }
087                
088                public String getEffectDescription(float level) {
089                        return "+" + (int)(TARGET_LEADING_BONUS) + "% target leading accuracy for autofiring weapons";
090                }
091                
092                public String getEffectPerLevelDescription() {
093                        return null;
094                }
095
096                public ScopeDescription getScopeDescription() {
097                        return ScopeDescription.PILOTED_SHIP;
098                }
099        }
100        
101        public static class Level3 implements ShipSkillEffect {
102                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
103                        stats.getBallisticWeaponRangeBonus().modifyPercent(id, RANGE_BONUS);
104                        stats.getEnergyWeaponRangeBonus().modifyPercent(id, RANGE_BONUS);
105                }
106                
107                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
108                        stats.getBallisticWeaponRangeBonus().unmodify(id);
109                        stats.getEnergyWeaponRangeBonus().unmodify(id);
110                }
111                
112                public String getEffectDescription(float level) {
113                        return "+" + (int)(RANGE_BONUS) + "% ballistic and energy weapon range";
114                }
115                
116                public String getEffectPerLevelDescription() {
117                        return null;
118                }
119
120                public ScopeDescription getScopeDescription() {
121                        return ScopeDescription.PILOTED_SHIP;
122                }
123        }
124        
125        public static class Level3A implements ShipSkillEffect {
126                public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
127                        stats.getBallisticWeaponRangeBonus().modifyPercent(id, RANGE_BONUS_ELITE);
128                        stats.getEnergyWeaponRangeBonus().modifyPercent(id, RANGE_BONUS_ELITE);
129                }
130                
131                public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
132                        stats.getBallisticWeaponRangeBonus().unmodify(id);
133                        stats.getEnergyWeaponRangeBonus().unmodify(id);
134                }
135                
136                public String getEffectDescription(float level) {
137                        return "+" + (int)(RANGE_BONUS_ELITE) + "% ballistic and energy weapon range";
138                }
139                
140                public String getEffectPerLevelDescription() {
141                        return null;
142                }
143                
144                public ScopeDescription getScopeDescription() {
145                        return ScopeDescription.PILOTED_SHIP;
146                }
147        }
148        
149}