316 public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
317 if (dialog ==
null)
return false;
319 OptionPanelAPI options = dialog.getOptionPanel();
320 TextPanelAPI text = dialog.getTextPanel();
322 CargoAPI cargo = pf.getCargo();
324 String action = params.get(0).getString(memoryMap);
326 MemoryAPI memory = memoryMap.get(MemKeys.LOCAL);
327 if (memory ==
null)
return false;
329 MarketAPI market = dialog.getInteractionTarget().getMarket();
331 if (
"findLargeOmega".equals(action)) {
332 for (CargoStackAPI stack : cargo.getStacksCopy()) {
333 if (!stack.isWeaponStack())
continue;
335 WeaponSpecAPI spec = stack.getWeaponSpecIfWeapon();
336 if (spec.getSize() != WeaponSize.LARGE)
continue;
338 if (!spec.hasTag(Tags.OMEGA))
continue;
340 memory.set(
"$foundWeaponId", spec.getWeaponId());
341 memory.set(
"$foundWeaponName", spec.getWeaponName());
342 memory.set(
"$foundWeaponQuantity", (
int) Math.round(stack.getSize()));
345 }
else if (
"findContactToBetray".equals(action)) {
346 ContactIntel best =
null;
347 int bestImportance = 0;
349 for (IntelInfoPlugin curr :
Global.
getSector().getIntelManager().getIntel(ContactIntel.class)) {
350 ContactIntel intel = (ContactIntel) curr;
351 if (intel.isEnding() || intel.isEnded() || intel.getState() == ContactState.POTENTIAL)
continue;
353 int importance = intel.getPerson().getImportance().ordinal();
354 float rel = intel.getPerson().getRelToPlayer().getRel();
356 if (intel.getPerson().getImportance().ordinal() <= PersonImportance.MEDIUM.ordinal())
continue;
359 if (importance > bestImportance || (importance >= bestImportance && rel > bestRel)) {
361 bestImportance = importance;
366 if (best ==
null)
return false;
368 PersonAPI contact = best.getPerson();
369 memory.set(
"$foundContactName", contact.getNameString());
370 memory.set(
"$foundContactRank", contact.getRank().toLowerCase());
371 memory.set(
"$foundContactPost", contact.getPost().toLowerCase());
372 memory.set(
"$foundContactFaction", contact.getFaction().getPersonNamePrefixAOrAn() +
" " + contact.getFaction().getPersonNamePrefix());
373 memory.set(
"$foundContactIntel", best);
376 }
else if (
"betrayContact".equals(action)) {
377 ContactIntel intel = (ContactIntel) memory.get(
"$foundContactIntel");
378 CustomRepImpact impact =
new CustomRepImpact();
379 impact.delta = -0.75f;
381 new RepActionEnvelope(RepActions.CUSTOM,
382 impact,
null, text,
true,
true),
384 intel.loseContact(dialog);
385 }
else if (
"gaveHamatsu".equals(action)) {
386 PersonAPI ibrahim = People.getPerson(People.IBRAHIM);
387 if (ibrahim !=
null) {
388 CustomRepImpact impact =
new CustomRepImpact();
391 new RepActionEnvelope(RepActions.CUSTOM,
392 impact,
null, text,
true,
true),
394 ContactIntel intel = ContactIntel.getContactIntel(ibrahim);
396 intel.loseContact(dialog);
399 }
else if (
"findRemnantCapital".equals(action)) {
400 for (FleetMemberAPI member : pf.getFleetData().getMembersListCopy()) {
401 if (member.getHullSpec().hasTag(Tags.SHIP_REMNANTS) && member.isCapital()) {
402 memory.set(
"$foundShipId", member.getId());
403 memory.set(
"$foundShipClass", member.getHullSpec().getNameWithDesignationWithDashClass());
404 memory.set(
"$foundShipName", member.getShipName());
408 }
else if (
"findShieldBlueprint".equals(action)) {
409 for (CargoStackAPI stack : cargo.getStacksCopy()) {
410 if (!stack.isSpecialStack())
continue;
412 SpecialItemData data = stack.getSpecialDataIfSpecial();
413 if (data.getData() ==
null)
continue;
415 if (!data.getId().equals(Items.INDUSTRY_BP))
continue;
419 if (spec.getId().equals(Industries.PLANETARYSHIELD)) {
420 memory.set(
"$foundIndustryId", spec.getId());
421 String firstWord = stack.getDisplayName().split(
" ")[0];
422 memory.set(
"$foundIndustryName", Misc.ucFirst(Misc.getAOrAnFor(firstWord)) +
" " + stack.getDisplayName().replace(
"Blueprint",
"blueprint"));
426 }
else if (
"findShipBlueprint".equals(action)) {
428 for (CargoStackAPI stack : cargo.getStacksCopy()) {
429 if (!stack.isSpecialStack())
continue;
431 SpecialItemData data = stack.getSpecialDataIfSpecial();
432 if (data.getData() ==
null)
continue;
434 if (!data.getId().equals(Items.SHIP_BP))
continue;
436 if (pirates.knowsShip(data.getData()))
continue;
440 boolean match = spec.hasTag(Tags.KANTA_GIFT);
441 match |= !spec.isCivilianNonCarrier() && spec.getHullSize() == HullSize.CAPITAL_SHIP;
444 memory.set(
"$foundShipBPId", data.getData());
445 String firstWord = stack.getDisplayName().split(
" ")[0];
446 memory.set(
"$foundShipBPName", Misc.ucFirst(Misc.getAOrAnFor(firstWord)) +
" " + stack.getDisplayName().replace(
"Blueprint",
"blueprint"));
450 }
else if (
"learnShipBP".equals(action)) {
451 String hullId = params.get(1).getString(memoryMap);
452 float daysDelay = params.get(2).getFloat(memoryMap);
457 }
else if (
"oweKantaAFavor".equals(action)) {
459 }
else if (
"abortFavor".equals(action)) {
461 }
else if (
"alreadyDidFavor".equals(action)) {
464 }
else if (
"installFusionLamp".equals(action)) {
465 SpecialItemData data =
new SpecialItemData(Items.ORBITAL_FUSION_LAMP,
null);
466 InstallableItemEffect effect = ItemEffectsRepo.ITEM_EFFECTS.get(data.getId());
467 Industry ind = market.getIndustry(Industries.POPULATION);
468 if (ind !=
null && effect !=
null) {
469 List<String> unmet = effect.getUnmetRequirements(ind);
470 if (unmet ==
null || unmet.isEmpty()) {
471 ind.setSpecialItem(data);
472 market.getPrimaryEntity().addScript(
new FusionLampColorChanger(market));
476 }
else if (
"buildPlanetaryShield".equals(action)) {
477 Industry ind = market.getIndustry(Industries.PLANETARYSHIELD);
479 market.addIndustry(Industries.PLANETARYSHIELD);
490 }
else if (
"gavePristineNanoforge".equals(action)) {
491 float daysDelay = params.get(1).getFloat(memoryMap);
493 MarketAPI kapteyn =
Global.
getSector().getEconomy().getMarket(
"station_kapteyn");
494 if (kapteyn !=
null) {
496 new DelayedInstallItemScript(daysDelay,
497 kapteyn, Industries.ORBITALWORKS, Items.PRISTINE_NANOFORGE));
498 Global.
getSector().getListenerManager().addListener(
new TakingBackTheNanoforgeChecker(kapteyn));
501 }
else if (
"kapteynHasForge".equals(action)) {
502 MarketAPI kapteyn =
Global.
getSector().getEconomy().getMarket(
"station_kapteyn");
503 if (kapteyn ==
null || kapteyn.hasCondition(Conditions.DECIVILIZED))
return false;
505 Industry ind = market.getIndustry(Industries.ORBITALWORKS);
506 if (ind ==
null)
return false;
508 return ind.getSpecialItem() !=
null && Items.PRISTINE_NANOFORGE.equals(ind.getSpecialItem().getId());
509 }
else if (
"gainProtection".equals(action)) {
512 text.setFontSmallInsignia();
513 text.addPara(
"Kanta's Protection gained", Misc.getPositiveHighlightColor());
514 text.setFontInsignia();
518 PirateHostileActivityFactor.avertOrAbortRaid();
520 HostileActivityEventIntel intel = HostileActivityEventIntel.get();
522 intel.addFactor(
new KantasProtectionOneTimeFactor(-
Global.
getSettings().
getInt(
"HA_kantaProtection")), dialog);
525 new PiracyRespiteScript();
527 }
else if (
"loseProtection".equals(action)) {