Starsector API
Loading...
Searching...
No Matches
TacticalDrills.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.skills;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.campaign.FleetDataAPI;
6import com.fs.starfarer.api.characters.FleetStatsSkillEffect;
7import com.fs.starfarer.api.characters.FleetTotalItem;
8import com.fs.starfarer.api.characters.FleetTotalSource;
9import com.fs.starfarer.api.characters.MutableCharacterStatsAPI;
10import com.fs.starfarer.api.characters.ShipSkillEffect;
11import com.fs.starfarer.api.characters.SkillSpecAPI;
12import com.fs.starfarer.api.combat.MutableShipStatsAPI;
13import com.fs.starfarer.api.combat.ShipAPI.HullSize;
14import com.fs.starfarer.api.fleet.MutableFleetStatsAPI;
15import com.fs.starfarer.api.impl.campaign.ids.Stats;
16import com.fs.starfarer.api.ui.TooltipMakerAPI;
17import com.fs.starfarer.api.util.Misc;
18
19public class TacticalDrills {
20
21 public static float DAMAGE_PERCENT = 5;
22
23 public static int ATTACK_BONUS = 50;
24 public static float CASUALTIES_MULT = 0.75f;
25
26
27 public static class Level1 extends BaseSkillEffectDescription implements ShipSkillEffect, FleetTotalSource {
28
29 public FleetTotalItem getFleetTotalItem() {
30 return getCombatOPTotal();
31 }
32
33 public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
34 if (!isCivilian(stats)) {
35 float damBonus = computeAndCacheThresholdBonus(stats, "td_dam", DAMAGE_PERCENT, ThresholdBonusType.OP);
36 stats.getBallisticWeaponDamageMult().modifyPercent(id, damBonus);
37 stats.getEnergyWeaponDamageMult().modifyPercent(id, damBonus);
38 stats.getMissileWeaponDamageMult().modifyPercent(id, damBonus);
39 }
40 }
41
42 public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
43 stats.getBallisticWeaponDamageMult().unmodifyPercent(id);
44 stats.getEnergyWeaponDamageMult().unmodifyPercent(id);
45 stats.getMissileWeaponDamageMult().unmodifyPercent(id);
46 }
47
48 public String getEffectDescription(float level) {
49 return null;
50 }
51
52 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
53 TooltipMakerAPI info, float width) {
54 init(stats, skill);
55
56 FleetDataAPI data = getFleetData(null);
57 float damBonus = computeAndCacheThresholdBonus(data, stats, "td_dam", DAMAGE_PERCENT, ThresholdBonusType.OP);
58
59 info.addPara("+%s weapon damage for combat ships (maximum: %s)", 0f, hc, hc,
60 "" + (int) damBonus + "%",
61 "" + (int) DAMAGE_PERCENT + "%");
62 addOPThresholdInfo(info, data, stats, OP_THRESHOLD);
63
64 //info.addSpacer(5f);
65 }
66
67 public ScopeDescription getScopeDescription() {
68 return ScopeDescription.ALL_SHIPS;
69 }
70 }
71
72
73 public static class Level2 extends BaseSkillEffectDescription implements FleetStatsSkillEffect {
74 public void apply(MutableFleetStatsAPI stats, String id, float level) {
75 stats.getDynamic().getMod(Stats.PLANETARY_OPERATIONS_MOD).modifyPercent(id, ATTACK_BONUS, "Tactical drills");
76 }
77
78 public void unapply(MutableFleetStatsAPI stats, String id) {
79 stats.getDynamic().getMod(Stats.PLANETARY_OPERATIONS_MOD).unmodifyPercent(id);
80 }
81
82 public void createCustomDescription(MutableCharacterStatsAPI stats, SkillSpecAPI skill,
83 TooltipMakerAPI info, float width) {
84 init(stats, skill);
85
86 float opad = 10f;
87 Color c = Misc.getBasePlayerColor();
88 //info.addPara("Affects: %s", opad + 5f, Misc.getGrayColor(), c, "fleet");
89 info.addPara("Affects: %s", opad + 5f, Misc.getGrayColor(), c, "ground operations");
90 info.addSpacer(opad);
91 info.addPara("+%s effectiveness of ground operations such as raids", 0f, hc, hc,
92 "" + (int) ATTACK_BONUS + "%");
93 }
94
95 public String getEffectDescription(float level) {
96 return "+" + (int)(ATTACK_BONUS) + "% effectiveness of ground operations such as raids";
97 }
98
99 public String getEffectPerLevelDescription() {
100 return null;
101 }
102
103 public ScopeDescription getScopeDescription() {
104 return ScopeDescription.FLEET;
105 }
106 }
107
108 public static class Level3 implements FleetStatsSkillEffect {
109 public void apply(MutableFleetStatsAPI stats, String id, float level) {
110 stats.getDynamic().getStat(Stats.PLANETARY_OPERATIONS_CASUALTIES_MULT).modifyMult(id, CASUALTIES_MULT, "Tactical drills");
111 }
112
113 public void unapply(MutableFleetStatsAPI stats, String id) {
114 stats.getDynamic().getStat(Stats.PLANETARY_OPERATIONS_CASUALTIES_MULT).unmodifyMult(id);
115 }
116
117 public String getEffectDescription(float level) {
118 return "-" + (int)Math.round((1f - CASUALTIES_MULT) * 100f) + "% marine casualties suffered during ground operations such as raids";
119 }
120
121 public String getEffectPerLevelDescription() {
122 return null;
123 }
124
125 public ScopeDescription getScopeDescription() {
126 return ScopeDescription.FLEET;
127 }
128 }
129}
130
131
132
133
134
void addOPThresholdInfo(TooltipMakerAPI info, FleetDataAPI data, MutableCharacterStatsAPI cStats)
void init(MutableCharacterStatsAPI stats, SkillSpecAPI skill)
float computeAndCacheThresholdBonus(MutableShipStatsAPI stats, String key, float maxBonus, ThresholdBonusType type)