Starsector API
Loading...
Searching...
No Matches
ReserveWingStats.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.combat;
2
3import com.fs.starfarer.api.Global;
4import com.fs.starfarer.api.combat.FighterLaunchBayAPI;
5import com.fs.starfarer.api.combat.MutableShipStatsAPI;
6import com.fs.starfarer.api.combat.ShipAPI;
7import com.fs.starfarer.api.combat.ShipSystemAPI;
8import com.fs.starfarer.api.loading.FighterWingSpecAPI;
9
11
12 public static String RD_NO_EXTRA_CRAFT = "rd_no_extra_craft";
13 public static String RD_FORCE_EXTRA_CRAFT = "rd_force_extra_craft";
14
15// public static float EXTRA_FIGHTER_DURATION = 15;
16// public static float RATE_COST = 0.25f;
17// public static float RATE_COST_1_BAY = 0.15f;
18 public static float EXTRA_FIGHTER_DURATION = 30;
19 public static float RATE_COST = 0f;
20 public static float RATE_COST_1_BAY = 0f;
21
22 public static float getRateCost(int bays) {
23 if (bays <= 1) return RATE_COST_1_BAY;
24 return RATE_COST;
25 }
26
27 public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
28 ShipAPI ship = null;
29 if (stats.getEntity() instanceof ShipAPI) {
30 ship = (ShipAPI) stats.getEntity();
31 } else {
32 return;
33 }
34
35 if (effectLevel == 1) {
36
37 //need to make this more balanced
38 //possibly don't count the "added" fighters to helping restore the replacement rate?
39 //also: need to adjust the AI to be more conservative using this
40
41
42 float minRate = Global.getSettings().getFloat("minFighterReplacementRate");
43
44 int bays = ship.getLaunchBaysCopy().size();
45 float cost = getRateCost(bays);
46 for (FighterLaunchBayAPI bay : ship.getLaunchBaysCopy()) {
47 if (bay.getWing() == null) continue;
48
49 float rate = Math.max(minRate, bay.getCurrRate() - cost);
50 bay.setCurrRate(rate);
51
52 bay.makeCurrentIntervalFast();
53 FighterWingSpecAPI spec = bay.getWing().getSpec();
54
55 int addForWing = getAdditionalFor(spec, bays);
56 int maxTotal = spec.getNumFighters() + addForWing;
57 int actualAdd = maxTotal - bay.getWing().getWingMembers().size();
58 //int actualAdd = addForWing;
59 //actualAdd = Math.min(spec.getNumFighters(), actualAdd);
60 if (actualAdd > 0) {
61 bay.setFastReplacements(bay.getFastReplacements() + addForWing);
62 bay.setExtraDeployments(actualAdd);
63 bay.setExtraDeploymentLimit(maxTotal);
64 bay.setExtraDuration(EXTRA_FIGHTER_DURATION);
65 //bay.setExtraDuration(99999999999f);
66 }
67 }
68 }
69 }
70
71 public static int getAdditionalFor(FighterWingSpecAPI spec, int bays) {
72 //if (spec.isBomber() && !spec.hasTag(RD_FORCE_EXTRA_CRAFT)) return 0;
73 if (spec.hasTag(RD_NO_EXTRA_CRAFT)) return 0;
74
75 int size = spec.getNumFighters();
76 if (true) return size;
77
78 if (bays == 1) {
79 return Math.max(size, 2);
80 }
81
82// if (size <= 3) return 1;
83// return 2;
84 if (size <= 3) return 1;
85 if (size <= 5) return 2;
86 return 3;
87 }
88
89
90 public void unapply(MutableShipStatsAPI stats, String id) {
91 }
92
93
94
95 public StatusData getStatusData(int index, State state, float effectLevel) {
96// if (index == 0) {
97// return new StatusData("deploying additional fighters", false);
98// }
99 return null;
100 }
101
102
103 @Override
104 public boolean isUsable(ShipSystemAPI system, ShipAPI ship) {
105 return true;
106 }
107
108
109
110}
111
112
113
114
115
116
117
118
static SettingsAPI getSettings()
Definition Global.java:51
boolean isUsable(ShipSystemAPI system, ShipAPI ship)
static int getAdditionalFor(FighterWingSpecAPI spec, int bays)
void unapply(MutableShipStatsAPI stats, String id)
void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel)
StatusData getStatusData(int index, State state, float effectLevel)