Starsector API
Loading...
Searching...
No Matches
DwellerCombatStrategyAI.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.combat.dweller;
2
3import java.util.ArrayList;
4import java.util.List;
5
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.combat.CombatAssignmentType;
8import com.fs.starfarer.api.combat.CombatEngineAPI;
9import com.fs.starfarer.api.combat.CombatFleetManagerAPI;
10import com.fs.starfarer.api.combat.CombatFleetManagerAPI.AssignmentInfo;
11import com.fs.starfarer.api.combat.CombatTaskManagerAPI;
12import com.fs.starfarer.api.combat.DeployedFleetMemberAPI;
13import com.fs.starfarer.api.combat.ShipAPI;
14import com.fs.starfarer.api.fleet.FleetGoal;
15import com.fs.starfarer.api.impl.campaign.ids.HullMods;
16import com.fs.starfarer.api.impl.campaign.ids.Tags;
17import com.fs.starfarer.api.util.IntervalUtil;
18
29
30 public static float SND_BASE = 60f;
31 public static float SND_TIMER = 60f;
32 public static float SND_FRACTION = 0.5f;
33
34 protected boolean playerSide;
38 protected int owner;
39 protected boolean allyMode = false;
40
41 protected IntervalUtil everySecond = new IntervalUtil(0.8f, 1.2f);
43 protected float mw, mh;
44
45 protected boolean abort = false;
46
49
50 protected boolean gaveInitialOrders = false;
51
52
55 this.owner = owner;
56 playerSide = owner == 0;
58 //allyMode = false;
61 taskManager.getCommandPointsStat().modifyFlat("DwellerCombatStrategyAI", 1000000000);
62
64
66 abort = true;
67 } else {
68 if (fleetManager.getAdmiralAI() != null) {
71 }
72 }
73
76 }
77
78 protected void giveInitialOrders() {
79
80 }
81
82
83 public void advance(float amount) {
84 //if (true) return;
85 if (abort) return;
86 if (engine.isPaused()) return;
87
88 everySecond.advance(amount);
89 if (everySecond.intervalElapsed()) {
90 // if non-threat ships are deployed from this fleetManager, don't want to be doing any Threat things
91 List<DeployedFleetMemberAPI> deployed = fleetManager.getDeployedCopyDFM();
92 if (deployed.isEmpty()) return;
93
94 boolean someMatching = false;
95 for (DeployedFleetMemberAPI member : deployed) {
96 if (!member.isFighterWing() && member.getShip() != null &&
97 member.isAlly() == allyMode &&
98 !member.getShip().getVariant().hasHullMod(HullMods.DWELLER_HULLMOD)) {
99 abort = true;
100 return;
101 } else if (!member.isFighterWing() && member.getShip() != null &&
102 member.isAlly() == allyMode) {
103 someMatching = true;
104 }
105 }
106
107 if (!someMatching) return;
108
109 if (!gaveInitialOrders) {
111 gaveInitialOrders = true;
112 }
113
115 ShipAPI ship = member.getShip();
116 if (ship == null || ship.getAI() == null) continue;
117
118 if (isMaw(ship)) {
120 if (curr == null) {
122 taskManager.orderSearchAndDestroy(member, false);
123 }
124 } else if (isEye(ship)) {
126 if (curr == null) {
128 taskManager.orderSearchAndDestroy(member, false);
129 }
130 } else if (isStinger(ship)) {
131// AssignmentInfo curr = taskManager.getAssignmentInfoForTarget(member);
132// if (curr == null) {
133// taskManager.createAssignment(CombatAssignmentType.HEAVY_ESCORT, member, false);
134// taskManager.orderSearchAndDestroy(member, false);
135// }
136 }
137 }
138
140 }
141 }
142
143
144 protected void cancelOrders(DeployedFleetMemberAPI member, boolean withSearchAndDestroy) {
146 if (curr != null) {
148 }
149 if (withSearchAndDestroy) {
150 taskManager.orderSearchAndDestroy(member, false);
151 }
152 }
153
155 taskManager.reassign(); // so assigned members isn't empty
156 List<AssignmentInfo> remove = new ArrayList<>();
158 if (curr.getType() == CombatAssignmentType.CONTROL) continue;
159 if (curr.getType() == CombatAssignmentType.CAPTURE) continue;
160 if (curr.getType() == CombatAssignmentType.DEFEND) continue;
161 if (curr.getAssignedMembers().isEmpty()) {
162 remove.add(curr);
163 }
164 }
165 for (AssignmentInfo curr : remove) {
167 }
168
170 }
171
172
173 public static boolean isMaw(ShipAPI ship) {
174 boolean isMaw = ship != null && ship.isCapital();
175 return isMaw;
176 }
177 public static boolean isEye(ShipAPI ship) {
178 boolean isEye = ship != null && ship.isCruiser() && ship.getHullSpec().hasTag(Tags.DWELLER_RECKLESS);
179 return isEye;
180 }
181 public static boolean isStinger(ShipAPI ship) {
182 boolean isEye = ship != null && ship.isCruiser() && ship.getHullSpec().hasTag(Tags.DWELLER_TIMID);
183 return isEye;
184 }
185 public static boolean isTendril(ShipAPI ship) {
186 boolean isTendril = ship != null && ship.isDestroyer();
187 return isTendril;
188 }
189}
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
static CombatEngineAPI getCombatEngine()
Definition Global.java:69
void modifyFlat(String source, float value)
void cancelOrders(DeployedFleetMemberAPI member, boolean withSearchAndDestroy)
default void setNoOrders(boolean noOrders)
CombatFleetManagerAPI getFleetManager(FleetSide side)
List< DeployedFleetMemberAPI > getDeployedCopyDFM()
CombatTaskManagerAPI getTaskManager(boolean ally)
AssignmentInfo getAssignmentInfoForTarget(AssignmentTargetAPI target)
AssignmentInfo createAssignment(CombatAssignmentType type, AssignmentTargetAPI target, boolean useCommandPoint)
AssignmentInfo getAssignmentFor(ShipAPI ship)
void orderSearchAndDestroy(DeployedFleetMemberAPI member, boolean useCommandPointIfNeeded)