63 if (dialog ==
null)
return false;
71 CargoInspectionResult result =
new CargoInspectionResult();
73 float totalIllegal = 0;
74 float totalIllegalFound = 0;
80 boolean legal = !faction.
isIllegal(stack);
82 totalLegal += stack.getSize();
84 totalIllegal += stack.getSize();
93 float unshieldedFraction = 1f - shieldedFraction;
95 float shieldedMult = (0.5f + 0.5f * unshieldedFraction);
97 if (totalLegal + totalIllegal > 0) {
99 Collections.shuffle(stacks);
100 float illegalSoFar = 0;
102 if (stack.getSize() <= 0)
continue;
103 boolean legal = !faction.
isIllegal(stack);
104 illegalSoFar += stack.getSize();
105 float chanceToFind = illegalSoFar / (totalLegal + totalIllegal);
106 chanceToFind *= guiltMult;
107 chanceToFind *= shieldedMult;
110 }
else if ((
float) Math.random() < chanceToFind) {
111 float qty = stack.getSize();
112 qty = qty * (0.33f + (float) Math.random() * 0.67f);
114 qty = Math.round(qty);
115 if (qty < 1) qty = 1;
116 illegalFound.
addItems(stack.getType(), stack.getData(), qty);
121 result.setLegalFound(legalFound);
122 result.setIllegalFound(illegalFound);
124 result.setType(CargoInspectionResultType.TOLL);
126 result.setType(CargoInspectionResultType.TOLL_AND_FINE);
130 float shipTollAmount = 0f;
132 shipTollAmount += member.getBaseSellValue() * 0.125f * faction.
getTollFraction();
134 shipTollAmount = (int)shipTollAmount;
142 toll += stack.getSize() * stack.getBaseValuePerUnit() * tollFraction * shieldedMult;
145 fine += stack.getSize() * stack.getBaseValuePerUnit() * fineFraction;
146 totalIllegalFound += stack.getSize();
149 float totalTollAndFine = shipTollAmount + toll + fine;
156 result.setTollAmount(totalTollAndFine);
159 memory.
set(
"$tollAmount",
"" + (
int)result.getTollAmount(), 0);
160 memory.
set(
"$inspectionResultType", result.getType().name(), 0);
162 memory.
set(
"$cargoInspectionResult", result, 0);
172 text.
addParagraph(
"-----------------------------------------------------------------------------");
174 text.
addParagraph(
"Fleet size toll: " + (
int) shipTollAmount);
182 List<String> highlights =
new ArrayList<String>();
184 para += stack.getDisplayName() +
" x " + (int)stack.getSize() +
"\n";
185 highlights.add(
"" + (
int)stack.getSize());
187 para = para.substring(0, para.length() - 1);
195 text.
addParagraph(
"Total: " + (
int) totalTollAndFine +
" credits");
198 text.
addParagraph(
"-----------------------------------------------------------------------------");