36 public List<Pair<SectorEntityToken, Float>> targets =
new ArrayList<Pair<SectorEntityToken,Float>>();
62 super.advance(amount);
64 float days = Misc.getDays(amount);
70 RaidActionSubStage step =
steps.remove(0);
75 float duration = 100f;
77 for (Pair<SectorEntityToken, Float> curr : step.targets) {
78 MilitaryResponseParams params =
new MilitaryResponseParams(ActionType.HOSTILE,
79 "raid_" + curr.one.getId(),
85 curr.one.getContainingLocation().addScript(script);
88 MilitaryResponseParams defParams =
new MilitaryResponseParams(ActionType.HOSTILE,
89 "defRaid_" + curr.one.getId(),
90 curr.one.getFaction(),
95 curr.one.getContainingLocation().addScript(defScript);
117 if (
status != RaidStageStatus.ONGOING)
return;
120 status = RaidStageStatus.FAILURE;
126 if (
steps.isEmpty()) {
127 boolean inSpawnRange = RouteManager.isPlayerInSpawnRange(
system.getCenter());
133 boolean someUnraided =
false;
134 boolean someRaided =
false;
135 for (MarketAPI market :
targets) {
140 if (Misc.flagHasReason(market.getMemoryWithoutUpdate(),
152 status = RaidStageStatus.SUCCESS;
158 status = RaidStageStatus.FAILURE;
189 for (RouteData route : routes) {
190 route.addSegment(
new RouteSegment(1000f,
system.getCenter()));
196 WeightedRandomPicker<MarketAPI> picker =
new WeightedRandomPicker<MarketAPI>();
197 for (MarketAPI target :
targets) {
198 picker.add(target, target.getSize() * target.getSize());
201 float str = WarSimScript.getFactionStrength(faction,
system);
203 Set<String> seen =
new HashSet<String>();
204 for (MarketAPI market :
targets) {
205 if (seen.contains(market.getFactionId()))
continue;
206 seen.add(market.getFactionId());
207 enemyStr += WarSimScript.getFactionStrength(market.getFaction(),
system);
209 if (str < 1) str = 1;
210 if (enemyStr < 1) enemyStr = 1;
212 boolean concurrent =
false;
214 if (str > enemyStr * 2 && (
float) Math.random() > 0.5f) {
217 if (str > enemyStr * 4) {
223 for (
int i = 0; i < numRaids && !picker.isEmpty(); numRaids++) {
224 MarketAPI target = picker.pickAndRemove();
226 float defensiveStr = enemyStr + WarSimScript.getStationStrength(target.getFaction(),
system, target.getPrimaryEntity());
227 if (defensiveStr > str) {
231 RaidActionSubStage step =
new RaidActionSubStage();
232 step.duration = 20f + 10f * (float) Math.random();
235 Industry station = Misc.getStationIndustry(target);
236 if (station !=
null && station.getDisruptedDays() < step.duration) {
237 step.duration += 10f + (float) Math.random() * 5f;
242 step.targets.add(
new Pair<SectorEntityToken, Float>(target.getPrimaryEntity(), weight));
245 this.targets.add(target);
249 for (RaidActionSubStage step :
steps) {
253 RaidActionSubStage step =
new RaidActionSubStage();
254 boolean stationPresent =
false;
255 for (
int i = 0; i < numRaids && !picker.isEmpty(); numRaids++) {
256 MarketAPI target = picker.pickAndRemove();
258 float defensiveStr = enemyStr + WarSimScript.getStationStrength(target.getFaction(),
system, target.getPrimaryEntity());
259 if (defensiveStr > str) {
264 Industry station = Misc.getStationIndustry(target);
265 if (station !=
null && station.getDisruptedDays() < 20f) {
266 stationPresent =
true;
271 step.targets.add(
new Pair<SectorEntityToken, Float>(target.getPrimaryEntity(), weight));
273 this.targets.add(target);
278 step.duration = 20f + 10f * (float) Math.random();
279 if (stationPresent) {
280 step.duration += 10f + (float) Math.random() * 5f;
286 if (this.targets.isEmpty()) {
298 Color h = Misc.getHighlightColor();
299 Color g = Misc.getGrayColor();
300 Color tc = Misc.getTextColor();
304 if (
status == RaidStageStatus.FAILURE) {
305 info.addPara(
"The raiding forces have been defeated by the defenders of the " +
306 intel.
getSystem().getNameWithLowercaseType() +
". The raid is now over.", opad);
307 }
else if (
status == RaidStageStatus.SUCCESS) {
308 List<MarketAPI> raided =
new ArrayList<MarketAPI>();
309 for (MarketAPI market :
targets) {
313 if (Misc.flagHasReason(market.getMemoryWithoutUpdate(),
318 if (!raided.isEmpty()) {
319 info.addPara(
"The raiding forces have been successful in raiding the following colonies:", opad);
320 float initPad = opad;
321 for (MarketAPI market : raided) {
326 }
else if (curr == index) {
327 info.addPara(
"The raiding forces are currently operating in the " +
345 status = RaidStageStatus.FAILURE;
346 for (MarketAPI target :
targets) {
349 float defensiveStr = enemyStr + WarSimScript.getStationStrength(target.getFaction(),
system, target.getPrimaryEntity());
350 if (defensiveStr >= str) {
354 Industry station = Misc.getStationIndustry(target);
355 if (station !=
null) {
356 OrbitalStation.disrupt(station);
363 str -= defensiveStr * 0.5f;
364 status = RaidStageStatus.SUCCESS;
379 public void performRaid(CampaignFleetAPI fleet, MarketAPI market) {
382 raidStr = MarketCMD.getRaidStr(fleet);
385 float maxPenalty = 3f;
390 new MarketCMD(market.getPrimaryEntity()).doGenericRaid(
intel.
getFaction(), raidStr, maxPenalty);
402 public boolean canRaid(CampaignFleetAPI fleet, MarketAPI market) {
403 if (Misc.flagHasReason(market.getMemoryWithoutUpdate(),
407 return market.getFaction().isHostileTo(fleet.getFaction());