Fix staggered exploding mesos

Thanks teto: "the staggering should only go up to 400ms [attack.attackDelay + (index++ % 5) * 100], and the total delay should be capped at 1000ms according to the BMS implementation"
This commit is contained in:
P0nk
2024-08-27 07:41:24 +02:00
parent 86da9b0b29
commit 5064ee936a

View File

@@ -112,6 +112,8 @@ import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.SECONDS;
public abstract class AbstractDealDamageHandler extends AbstractPacketHandler {
private static final int EXPLODED_MESO_SPREAD_DELAY = 100;
private static final int EXPLODED_MESO_MAX_DELAY = 1000;
public static class AttackInfo {
@@ -936,7 +938,7 @@ public abstract class AbstractDealDamageHandler extends AbstractPacketHandler {
}
private void removeExplodedMesos(MapleMap map, AttackInfo attack) {
short delay = attack.attackDelay;
int index = 0;
for (Integer mesoId : attack.explodedMesos) {
MapObject mapobject = map.getMapObject(mesoId);
if (!(mapobject instanceof MapItem mapItem)) {
@@ -951,11 +953,12 @@ public abstract class AbstractDealDamageHandler extends AbstractPacketHandler {
if (mapItem.isPickedUp()) {
return;
}
map.pickItemDrop(PacketCreator.removeExplodedMesoFromMap(mapItem.getObjectId(), delay), mapItem);
int delay = attack.attackDelay + (index++ % 5) * EXPLODED_MESO_SPREAD_DELAY;
delay = Math.min(delay, EXPLODED_MESO_MAX_DELAY);
map.pickItemDrop(PacketCreator.removeExplodedMesoFromMap(mapItem.getObjectId(), (short) delay), mapItem);
} finally {
mapItem.unlockItem();
}
delay += 100;
}
}
}