116 if (!(
eventTarget.getCustom() instanceof InvestigationGoodRepData)) {
120 target = (InvestigationGoodRepData)
eventTarget.getCustom();
122 other = target.other;
124 numPrior =
faction.getMemoryWithoutUpdate().getFloat(MemFlags.MEMORY_KEY_NUM_GR_INVESTIGATIONS);
132 if (
faction.isAtBest(Factions.PLAYER, RepLevel.HOSTILE) ||
133 other.isAtBest(Factions.PLAYER, RepLevel.FAVORABLE) ||
134 faction.isAtWorst(other, RepLevel.COOPERATIVE) ||
135 !
faction.getCustom().optBoolean(Factions.CUSTOM_INVESTIGATES_PLAYER_FOR_GOOD_REP) ||
136 !other.getCustom().optBoolean(Factions.CUSTOM_WORTH_INVESTIGATING_FOR_GOOD_REP) ||
144 float repFaction =
faction.getRelationship(Factions.PLAYER);
145 float repOther = other.getRelationship(Factions.PLAYER);
146 RepLevel relFaction =
faction.getRelationshipLevel(Factions.PLAYER);
147 RepLevel relOther = other.getRelationshipLevel(Factions.PLAYER);
163 switch ((
int) numPrior) {
166 punishment = RepActions.OTHER_FACTION_GOOD_REP_INVESTIGATION_MINOR;
170 punishment = RepActions.OTHER_FACTION_GOOD_REP_INVESTIGATION_MAJOR;
174 punishment = RepActions.OTHER_FACTION_GOOD_REP_INVESTIGATION_CRITICAL;
177 bribeAmount = (int) (10000 + (
int)(10000 * (numPrior + guiltProb * 2f + (float) Math.random())) / 1000 * 1000);
180 duration = 60f + 30f * (float) Math.random();
184 log.info(String.format(
"Starting faction investigation at %s, %s -> %s",
market.getName(),
faction.getDisplayName(), other.getDisplayName()));
188 market.getCommDirectory().addPerson(investigator);
190 investigator.getMemoryWithoutUpdate().set(
"$igr_eventRef",
this, duration);
191 investigator.getMemoryWithoutUpdate().set(
"$igr_investigator",
true, duration);
192 investigator.getMemoryWithoutUpdate().set(
"$igr_bribeAmount",
"" + bribeAmount, duration);
193 investigator.getMemoryWithoutUpdate().set(
"$igr_bribeAmountDGS", Misc.getWithDGS(bribeAmount), duration);
194 Misc.setFlagWithReason(investigator.getMemoryWithoutUpdate(),
195 MemFlags.MEMORY_KEY_REQUIRES_DISCRETION,
"igr",
198 Global.
getSector().reportEventStage(
this,
"start_goodrep",
null, MessagePriority.ENSURE_DELIVERY,
null);
208 if (elapsedDays >= duration) {
210 !other.isAtBest(Factions.PLAYER, RepLevel.FAVORABLE) &&
211 (
float) Math.random() < guiltProb) {
212 Global.
getSector().reportEventStage(
this,
"player_guilty_goodrep",
null, MessagePriority.ENSURE_DELIVERY,
new BaseOnMessageDeliveryScript() {
213 public void beforeDelivery(CommMessageAPI message) {
214 if (punishment !=
null) {
216 new RepActionEnvelope(punishment,
null,
null,
true),
223 Global.
getSector().reportEventStage(
this,
"clear_goodrep_bribe",
null, MessagePriority.ENSURE_DELIVERY,
null);
225 Global.
getSector().reportEventStage(
this,
"clear_goodrep",
null, MessagePriority.ENSURE_DELIVERY,
null);
229 faction.getMemoryWithoutUpdate().set(MemFlags.MEMORY_KEY_NUM_GR_INVESTIGATIONS, numPrior);
253 public boolean callEvent(String ruleId, InteractionDialogAPI dialog,
254 List<Token> params, Map<String, MemoryAPI> memoryMap) {
255 String action = params.get(0).getString(memoryMap);
258 CargoAPI cargo = playerFleet.getCargo();
260 if (action.equals(
"paidBribe")) {
262 }
else if (action.equals(
"setBribePaid")) {
271 Map<String, String> map = super.getTokenReplacements();
273 map.put(
"$otherFaction", other.getDisplayName());
274 map.put(
"$OtherFaction", Misc.ucFirst(other.getDisplayName()));
275 map.put(
"$TheOtherFaction", Misc.ucFirst(other.getDisplayNameWithArticle()));
276 map.put(
"$theOtherFaction", other.getDisplayNameWithArticle());
277 map.put(
"$TheOtherFactionLong", Misc.ucFirst(other.getDisplayNameLongWithArticle()));
278 map.put(
"$theOtherFactionLong", other.getDisplayNameLongWithArticle());
280 map.put(
"$InvestigatorPost", Misc.ucFirst(investigator.getPost()));
281 map.put(
"$investigatorName", investigator.getName().getFullName());
282 if (investigator.isMale()) {
283 map.put(
"$invHimOrHer",
"him");
285 map.put(
"$invHimOrHer",
"her");
288 map.put(
"$sender",
"Unknown");
289 map.put(
"$duration", Misc.getAtLeastStringForDays((
int)duration));
302 if (investigator !=
null) {
303 investigator.getMemoryWithoutUpdate().unset(
"$igr_eventRef");
304 investigator.getMemoryWithoutUpdate().unset(
"$igr_investigator");
305 investigator.getMemoryWithoutUpdate().unset(
"$igr_bribeAmount");
306 investigator.getMemoryWithoutUpdate().unset(
"$igr_bribeAmountDGS");
307 Misc.setFlagWithReason(investigator.getMemoryWithoutUpdate(),
308 MemFlags.MEMORY_KEY_REQUIRES_DISCRETION,
"igr",
312 if (!
Global.
getSector().getImportantPeople().isCheckedOutForAnything(investigator)) {
313 market.getCommDirectory().removePerson(investigator);