Proper timing on removing exploded meso
No longer using scheduling on server side but rather a delay value inherent to the "remove item from map" packet.
This commit is contained in:
@@ -96,7 +96,6 @@ import server.life.MonsterDropEntry;
|
||||
import server.life.MonsterInformationProvider;
|
||||
import server.maps.MapItem;
|
||||
import server.maps.MapObject;
|
||||
import server.maps.MapObjectType;
|
||||
import server.maps.MapleMap;
|
||||
import tools.PacketCreator;
|
||||
import tools.Randomizer;
|
||||
@@ -212,48 +211,12 @@ public abstract class AbstractDealDamageHandler extends AbstractPacketHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
//WTF IS THIS F3,1
|
||||
/*if (attackCount != attack.numDamage && attack.skill != ChiefBandit.MESO_EXPLOSION && attack.skill != NightWalker.VAMPIRE && attack.skill != WindArcher.WIND_SHOT && attack.skill != Aran.COMBO_SMASH && attack.skill != Aran.COMBO_FENRIR && attack.skill != Aran.COMBO_TEMPEST && attack.skill != NightLord.NINJA_AMBUSH && attack.skill != Shadower.NINJA_AMBUSH) {
|
||||
return;
|
||||
}*/
|
||||
|
||||
int totDamage = 0;
|
||||
|
||||
if (attack.skill == ChiefBandit.MESO_EXPLOSION) {
|
||||
int delay = 0;
|
||||
for (Integer oned : attack.targets.keySet()) {
|
||||
MapObject mapobject = map.getMapObject(oned);
|
||||
if (mapobject != null && mapobject.getType() == MapObjectType.ITEM) {
|
||||
final MapItem mapitem = (MapItem) mapobject;
|
||||
if (mapitem.getMeso() == 0) { //Maybe it is possible some how?
|
||||
return;
|
||||
}
|
||||
|
||||
mapitem.lockItem();
|
||||
try {
|
||||
if (mapitem.isPickedUp()) {
|
||||
return;
|
||||
}
|
||||
TimerManager.getInstance().schedule(() -> {
|
||||
mapitem.lockItem();
|
||||
try {
|
||||
if (mapitem.isPickedUp()) {
|
||||
return;
|
||||
}
|
||||
map.pickItemDrop(PacketCreator.removeItemFromMap(mapitem.getObjectId(), 4, 0), mapitem);
|
||||
} finally {
|
||||
mapitem.unlockItem();
|
||||
}
|
||||
}, delay);
|
||||
delay += 100;
|
||||
} finally {
|
||||
mapitem.unlockItem();
|
||||
}
|
||||
} else if (mapobject != null && mapobject.getType() != MapObjectType.MONSTER) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
removeExplodedMesos(map, attack);
|
||||
}
|
||||
|
||||
for (Map.Entry<Integer, AttackTarget> target : attack.targets.entrySet()) {
|
||||
final Monster monster = map.getMonsterByOid(target.getKey());
|
||||
if (monster != null) {
|
||||
@@ -971,4 +934,28 @@ public abstract class AbstractDealDamageHandler extends AbstractPacketHandler {
|
||||
attackInfo.targets = targets;
|
||||
return attackInfo;
|
||||
}
|
||||
|
||||
private void removeExplodedMesos(MapleMap map, AttackInfo attack) {
|
||||
short delay = attack.attackDelay;
|
||||
for (Integer mesoId : attack.explodedMesos) {
|
||||
MapObject mapobject = map.getMapObject(mesoId);
|
||||
if (!(mapobject instanceof MapItem mapItem)) {
|
||||
return;
|
||||
}
|
||||
if (mapItem.getMeso() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
mapItem.lockItem();
|
||||
try {
|
||||
if (mapItem.isPickedUp()) {
|
||||
return;
|
||||
}
|
||||
map.pickItemDrop(PacketCreator.removeExplodedMesoFromMap(mapItem.getObjectId(), delay), mapItem);
|
||||
} finally {
|
||||
mapItem.unlockItem();
|
||||
}
|
||||
delay += 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2595,7 +2595,6 @@ public class PacketCreator {
|
||||
* @param slot
|
||||
* @return
|
||||
*/
|
||||
// TODO: look for a "delay" in case animation = 4 (explode). Doesn't make sense for it to be server-sided.
|
||||
public static Packet removeItemFromMap(int objId, int animation, int chrId, boolean pet, int slot) {
|
||||
OutPacket p = OutPacket.create(SendOpcode.REMOVE_ITEM_FROM_MAP);
|
||||
p.writeByte(animation); // expire
|
||||
@@ -2609,6 +2608,14 @@ public class PacketCreator {
|
||||
return p;
|
||||
}
|
||||
|
||||
public static Packet removeExplodedMesoFromMap(int mapObjectId, short delay) {
|
||||
OutPacket p = OutPacket.create(SendOpcode.REMOVE_ITEM_FROM_MAP);
|
||||
p.writeByte(4);
|
||||
p.writeInt(mapObjectId);
|
||||
p.writeShort(delay);
|
||||
return p;
|
||||
}
|
||||
|
||||
public static Packet updateCharLook(Client target, Character chr) {
|
||||
OutPacket p = OutPacket.create(SendOpcode.UPDATE_CHAR_LOOK);
|
||||
p.writeInt(chr.getId());
|
||||
|
||||
Reference in New Issue
Block a user