165 final CampaignFleetAPI player =
getFleet();
166 if (player ==
null)
return;
167 if (!(player.getContainingLocation() instanceof StarSystemAPI))
return;
169 final StarSystemAPI system = (StarSystemAPI) player.getContainingLocation();
171 final JumpPointAPI inner = Misc.getDistressJumpPoint(system);
172 if (inner ==
null)
return;
174 JumpPointAPI outerTemp =
null;
175 if (inner.getDestinations().size() >= 1) {
176 SectorEntityToken test = inner.getDestinations().get(0).getDestination();
177 if (test instanceof JumpPointAPI) {
178 outerTemp = (JumpPointAPI) test;
181 final JumpPointAPI outer = outerTemp;
182 if (outer ==
null)
return;
185 if (outcome == DistressCallOutcome.HELP) {
187 }
else if (outcome == DistressCallOutcome.PIRATES) {
316 DistressResponseData data = (DistressResponseData) route.getCustom();
319 if (player ==
null)
return null;
321 if (data.outcome == DistressCallOutcome.HELP) {
322 WeightedRandomPicker<String> factions = SalvageSpecialAssigner.getNearbyFactions(
326 String faction = factions.pick();
329 if (faction ==
null)
return null;
331 CampaignFleetAPI fleet =
null;
332 if (Factions.INDEPENDENT.equals(faction)) {
333 WeightedRandomPicker<String> typePicker =
new WeightedRandomPicker<String>();
334 typePicker.add(FleetTypes.SCAVENGER_SMALL, 5f);
335 typePicker.add(FleetTypes.SCAVENGER_MEDIUM, 10f);
336 typePicker.add(FleetTypes.SCAVENGER_LARGE, 5f);
337 String type = typePicker.pick();
339 fleet = RuinsFleetRouteManager.createScavenger(
340 type, data.inner.getLocationInHyperspace(),
341 route,
null,
false,
null);
343 WeightedRandomPicker<PatrolType> picker =
new WeightedRandomPicker<PatrolType>();
344 picker.add(PatrolType.FAST, 5f);
345 picker.add(PatrolType.COMBAT, 10f);
346 picker.add(PatrolType.HEAVY, 5f);
347 PatrolType type = picker.pick();
349 fleet = MilitaryBase.createPatrol(type, faction, route,
null, data.inner.getLocationInHyperspace(), route.getRandom());
352 if (fleet ==
null)
return null;
354 if (Misc.getSourceMarket(fleet) ==
null)
return null;
358 FullName name =
new FullName(
"Mel",
"Greenish", fleet.getCommander().getGender());
359 fleet.getCommander().setName(name);
360 fleet.getFlagship().setShipName(
"IS In All Circumstances");
363 Misc.makeImportant(fleet,
"distressResponse", 30f);
364 fleet.getMemoryWithoutUpdate().set(
"$distressResponse",
true);
368 if (!player.isInHyperspace() &&
369 (
Global.
getSector().getHyperspace().getDaysSinceLastPlayerVisit() > 5 ||
370 player.getCargo().getFuel() <= 0)) {
372 Vector2f loc = data.outer.getLocation();
373 fleet.setLocation(loc.x, loc.y + fleet.getRadius() + 100f);
375 float dir = (float) Math.random() * 360f;
376 if (player.isInHyperspace()) {
377 dir = Misc.getAngleInDegrees(player.getLocation(), data.inner.getLocationInHyperspace());
378 dir += (float) Math.random() * 120f - 60f;
380 Vector2f loc = Misc.getUnitVectorAtDegreeAngle(dir);
381 loc.scale(3000f + 1000f * (
float) Math.random());
382 Vector2f.add(data.inner.getLocationInHyperspace(), loc, loc);
383 fleet.setLocation(loc.x, loc.y + fleet.getRadius() + 100f);
387 data.inner, data.outer));
390 }
else if (data.outcome == DistressCallOutcome.PIRATES) {
391 int points = 5 +
new Random().nextInt(15);
393 CampaignFleetAPI fleet = PirateFleetManager.createPirateFleet(points, route, data.inner.getLocationInHyperspace());
394 if (fleet ==
null)
return null;
395 if (Misc.getSourceMarket(fleet) ==
null)
return null;
399 if (!player.isInHyperspace() &&
400 (
Global.
getSector().getHyperspace().getDaysSinceLastPlayerVisit() > 5 ||
401 player.getCargo().getFuel() <= 0)) {
403 Vector2f loc = data.outer.getLocation();
404 fleet.setLocation(loc.x, loc.y + fleet.getRadius() + 100f);
406 float dir = (float) Math.random() * 360f;
407 if (player.isInHyperspace()) {
408 dir = Misc.getAngleInDegrees(player.getLocation(), data.inner.getLocationInHyperspace());
409 dir += (float) Math.random() * 120f - 60f;
411 Vector2f loc = Misc.getUnitVectorAtDegreeAngle(dir);
412 loc.scale(3000f + 1000f * (
float) Math.random());
413 Vector2f.add(data.inner.getLocationInHyperspace(), loc, loc);
414 fleet.setLocation(loc.x, loc.y + fleet.getRadius() + 100f);