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.life.MonsterInformationProvider;
|
||||||
import server.maps.MapItem;
|
import server.maps.MapItem;
|
||||||
import server.maps.MapObject;
|
import server.maps.MapObject;
|
||||||
import server.maps.MapObjectType;
|
|
||||||
import server.maps.MapleMap;
|
import server.maps.MapleMap;
|
||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
import tools.Randomizer;
|
import tools.Randomizer;
|
||||||
@@ -212,48 +211,12 @@ public abstract class AbstractDealDamageHandler extends AbstractPacketHandler {
|
|||||||
return;
|
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;
|
int totDamage = 0;
|
||||||
|
|
||||||
if (attack.skill == ChiefBandit.MESO_EXPLOSION) {
|
if (attack.skill == ChiefBandit.MESO_EXPLOSION) {
|
||||||
int delay = 0;
|
removeExplodedMesos(map, attack);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (Map.Entry<Integer, AttackTarget> target : attack.targets.entrySet()) {
|
for (Map.Entry<Integer, AttackTarget> target : attack.targets.entrySet()) {
|
||||||
final Monster monster = map.getMonsterByOid(target.getKey());
|
final Monster monster = map.getMonsterByOid(target.getKey());
|
||||||
if (monster != null) {
|
if (monster != null) {
|
||||||
@@ -971,4 +934,28 @@ public abstract class AbstractDealDamageHandler extends AbstractPacketHandler {
|
|||||||
attackInfo.targets = targets;
|
attackInfo.targets = targets;
|
||||||
return attackInfo;
|
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
|
* @param slot
|
||||||
* @return
|
* @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) {
|
public static Packet removeItemFromMap(int objId, int animation, int chrId, boolean pet, int slot) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.REMOVE_ITEM_FROM_MAP);
|
OutPacket p = OutPacket.create(SendOpcode.REMOVE_ITEM_FROM_MAP);
|
||||||
p.writeByte(animation); // expire
|
p.writeByte(animation); // expire
|
||||||
@@ -2609,6 +2608,14 @@ public class PacketCreator {
|
|||||||
return p;
|
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) {
|
public static Packet updateCharLook(Client target, Character chr) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.UPDATE_CHAR_LOOK);
|
OutPacket p = OutPacket.create(SendOpcode.UPDATE_CHAR_LOOK);
|
||||||
p.writeInt(chr.getId());
|
p.writeInt(chr.getId());
|
||||||
|
|||||||
Reference in New Issue
Block a user