87 super.advanceInCombat(ship, amount);
89 if (!ship.isAlive())
return;
92 ship.getCustomData().get(key);
93 MissileAutoloaderData data = (MissileAutoloaderData) ship.getCustomData().get(key);
95 data =
new MissileAutoloaderData();
99 data.opLeft = cap.capacity;
101 data.showExhaustedStatus = 0;
103 ship.setCustomData(key, data);
106 if (data.opLeft <= 0.05f) {
108 data.showExhaustedStatus -= amount;
109 if (data.showExhaustedStatus <= 0) {
117 float mult = ship.getMutableStats().getMissileRoFMult().getModifiedValue();
118 data.cooldown.advance(amount * mult);
119 for (WeaponAPI w : data.cooldown.getItems()) {
120 w.setRemainingCooldownTo(w.getCooldown());
123 data.interval.advance(amount);
124 if (data.interval.intervalElapsed()) {
125 boolean playSound =
false;
126 for (WeaponAPI w : ship.getAllWeapons()) {
128 if (data.cooldown.contains(w))
continue;
130 if (w.usesAmmo() && w.getAmmo() <= 0) {
131 float reloadSize = w.getSpec().getMaxAmmo();
133 float salvoSize = w.getSpec().getBurstSize();
134 if (salvoSize < 1) salvoSize = 1;
135 if (reloadCost > data.opLeft) {
136 float f = data.opLeft / reloadCost;
137 if (f <= 0f)
continue;
140 reloadSize /= salvoSize;
141 reloadSize = (float) Math.ceil(reloadSize);
142 reloadSize *= salvoSize;
143 reloadSize = (int) Math.round(reloadSize);
148 w.setAmmo((
int) reloadSize);
149 boolean sMod = isSMod(ship);
161 data.opLeft -= reloadCost;
164 if (data.opLeft < 0) data.opLeft = 0;
165 if (data.opLeft <= 0)
break;
170 if (playerShip && playSound) {
176 String status =
"" + Misc.getRoundedValueOneAfterDecimalIfNotWhole(data.opLeft) +
" CAPACITY REMAINING";
177 if (data.opLeft <= 0) status =
"CAPACITY EXHAUSTED";
180 spec.getDisplayName(),
181 status, data.opLeft <= 0);
187 if (ship ==
null)
return null;
195 for (WeaponSlotAPI slot : ship.getHullSpec().getAllWeaponSlotsCopy()) {
196 if (slot.getSlotSize() == WeaponSize.SMALL &&
197 slot.getWeaponType() == WeaponType.MISSILE) {
203 if (data.size == ship.getHullSize()) {
204 if (count >= data.minW && count <= data.maxW)
return data;
205 if (count >= data.minW && data.maxW < 0)
return data;
212 if (w ==
null)
return false;
213 if (w.getType() != WeaponType.MISSILE)
return false;
214 if (w.getSize() != WeaponSize.SMALL)
return false;
216 if (w.getSlot().getWeaponType() != WeaponType.MISSILE)
return false;
217 if (w.getSlot().getSlotSize() != WeaponSize.SMALL)
return false;
219 if (w.getSpec().hasTag(Tags.NO_RELOAD))
return false;
220 if (!w.usesAmmo() || w.getAmmoPerSecond() > 0)
return false;
221 if (w.isDecorative())
return false;
222 if (w.getSlot() !=
null && w.getSlot().isSystemSlot())
return false;
227 if (w.getSpec().hasTag(Tags.RELOAD_1PT))
return 1f;
228 if (w.getSpec().hasTag(Tags.RELOAD_1_AND_A_HALF_PT))
return 1.5f;
229 if (w.getSpec().hasTag(Tags.RELOAD_2PT))
return 2f;
230 if (w.getSpec().hasTag(Tags.RELOAD_3PT))
return 3f;
231 if (w.getSpec().hasTag(Tags.RELOAD_4PT))
return 4f;
232 if (w.getSpec().hasTag(Tags.RELOAD_5PT))
return 5f;
233 if (w.getSpec().hasTag(Tags.RELOAD_6PT))
return 6f;
235 int op = (int) Math.round(w.getSpec().getOrdnancePointCost(
null,
null));
236 if (op == 1)
return 1f;
237 if (op == 2 || op == 3)
return 2f;
238 if (op == 4)
return 3f;
239 if (op == 5 || op == 6)
return 4f;
240 if (op == 7 || op == 8)
return 6f;
250 public void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize,
final ShipAPI ship,
float width,
boolean isForModSpec) {
253 Color h = Misc.getHighlightColor();
254 Color bad = Misc.getNegativeHighlightColor();
257 tooltip.addPara(
"A combat-rated autoloader that provides a limited number of reloads, out of a shared reload capacity, to "
258 +
"missile weapons installed in small missile mounts.", opad, h,
"missile weapons installed in small missile mounts");
263 tooltip.addPara(
"Does not affect weapons that do not use ammo or regenerate it, or are mounted in any other type of slot."
264 +
" Reload size is not affected by skills or hullmods that "
265 +
"increase missile ammo capacity.", opad);
273 tooltip.addSectionHeading(
"Reload capacity", Alignment.MID, opad);
274 tooltip.addPara(
"Determined by ship size and number of small missile "
275 +
"slots, both filled and empty. "
276 +
"Having fewer of these simplifies the task and "
277 +
"increases the number of possible reloads.", opad);
279 if (isForModSpec || ship ==
null)
return;
281 tooltip.setBgAlpha(0.9f);
283 List<WeaponAPI> weapons =
new ArrayList<WeaponAPI>();
284 Set<String> seen =
new LinkedHashSet<String>();
285 for (WeaponAPI w : ship.getAllWeapons()) {
287 String
id = w.getId();
288 if (seen.contains(
id))
continue;
294 float reloadW = 130f;
295 float sizeW = width - numW - reloadW - 10f;
296 tooltip.beginTable(Misc.getBasePlayerColor(), Misc.getDarkPlayerColor(), Misc.getBrightPlayerColor(),
298 new Object [] {
"Ship size", sizeW,
"Small missiles", numW,
"Reload capacity", reloadW});
302 List<ReloadCapacityData> sortedCap =
new ArrayList<ReloadCapacityData>(
CAPACITY_DATA);
303 Collections.sort(sortedCap,
new Comparator<ReloadCapacityData>() {
304 public int compare(ReloadCapacityData o1, ReloadCapacityData o2) {
306 if (o1.size != o2.size) {
307 return (
int) Math.signum(o1.size.ordinal() - o2.size.ordinal());
309 return (
int) Math.signum(o1.capacity - o2.capacity);
314 HullSize prev = HullSize.FRIGATE;
315 for (ReloadCapacityData curr : sortedCap) {
316 Color c = Misc.getGrayColor();
318 c = Misc.getHighlightColor();
320 if (curr.size != hullSize)
continue;
324 tooltip.addRow(Alignment.MID, c, curr.getSizeStr(),
325 Alignment.MID, c, curr.getWeaponsString(),
326 Alignment.MID, c,
"" + curr.capacity);
329 tooltip.addTable(
"", 0, opad);
332 Collections.sort(weapons,
new Comparator<WeaponAPI>() {
333 public int compare(WeaponAPI o1, WeaponAPI o2) {
336 return (
int) Math.signum(c1 - c2);
341 tooltip.addSectionHeading(
"Reload cost", Alignment.MID, opad + 5f);
344 float nameW = width - costW - 5f;
345 tooltip.beginTable(Misc.getBasePlayerColor(), Misc.getDarkPlayerColor(), Misc.getBrightPlayerColor(),
347 new Object [] {
"Affected weapon", nameW,
"Reload cost", costW});
350 for (WeaponAPI w : weapons) {
353 String name = tooltip.shortenString(w.getDisplayName(), nameW - 20f);
354 tooltip.addRow(Alignment.LMID, Misc.getTextColor(), name,
355 Alignment.MID, h, Misc.getRoundedValueOneAfterDecimalIfNotWhole(cost));
356 if (count >= max)
break;
358 tooltip.addTable(
"No affected weapons mounted", weapons.size() - max, opad);
361 tooltip.addPara(
"A partial reload is possible when running out of capacity.", opad);
366 tooltip.addPara(
"After a reload, the weapon requires an extra %s seconds,"
367 +
" in addition to its normal cooldown, before it can fire again.", opad,