Reactor spray-drop + Quest with equipped items + MapleMapInfoRetriever
Implemented GMS-like "item spraying" from reactors. All boxes holding more than 5 drops have been changed to use this behavior. Added information for players trying to start/complete quests having the required item equipped. It is expected to have all required items unequipped before handling a quest operation. New check-purpose tool: MapleMapInfoRetriever. It's sole function is to detect and report map XMLs that has no "info" node in between the server files.
This commit is contained in:
@@ -24,7 +24,7 @@ public class ServerConstants {
|
||||
public static final long RESPAWN_INTERVAL = 10 * 1000; //10 seconds, 10000.
|
||||
public static final long PURGING_INTERVAL = 5 * 60 * 1000;
|
||||
public static final long RANKING_INTERVAL = 60 * 60 * 1000; //60 minutes, 3600000.
|
||||
public static final long COUPON_INTERVAL = 60 * 60 * 1000; //60 minutes, 3600000.
|
||||
public static final long COUPON_INTERVAL = 60 * 60 * 1000; //60 minutes, 3600000.
|
||||
|
||||
public static final boolean ENABLE_PIC = false; //Pick true/false to enable or disable Pic. Delete character needs this feature ENABLED.
|
||||
public static final boolean ENABLE_PIN = false; //Pick true/false to enable or disable Pin.
|
||||
|
||||
@@ -133,7 +133,7 @@ public abstract class AbstractDealDamageHandler extends AbstractMaplePacketHandl
|
||||
return null;
|
||||
}
|
||||
if (display > 80) { //Hmm
|
||||
if (!theSkill.getAction()) {
|
||||
if (!mySkill.getAction()) {
|
||||
AutobanFactory.FAST_ATTACK.autoban(chr, "WZ Edit; adding action to a skill: " + display);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package scripting.reactor;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleClient;
|
||||
import client.inventory.Equip;
|
||||
import client.inventory.Item;
|
||||
@@ -53,6 +54,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||
private MapleReactor reactor;
|
||||
private MapleClient client;
|
||||
private Invocable iv;
|
||||
private ScheduledFuture<?> sprayTask = null;
|
||||
|
||||
public ReactorActionManager(MapleClient c, MapleReactor reactor, Invocable iv) {
|
||||
super(c);
|
||||
@@ -69,6 +71,22 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||
reactor.getMap().destroyNPC(npcId);
|
||||
}
|
||||
|
||||
public void sprayItems() {
|
||||
sprayItems(false, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public void sprayItems(boolean meso, int mesoChance, int minMeso, int maxMeso) {
|
||||
sprayItems(meso, mesoChance, minMeso, maxMeso, 0);
|
||||
}
|
||||
|
||||
public void sprayItems(boolean meso, int mesoChance, int minMeso, int maxMeso, int minItems) {
|
||||
sprayItems((int)reactor.getPosition().getX(), (int)reactor.getPosition().getY(), meso, mesoChance, minMeso, maxMeso, minItems);
|
||||
}
|
||||
|
||||
public void sprayItems(int posX, int posY, boolean meso, int mesoChance, int minMeso, int maxMeso, int minItems) {
|
||||
dropItems(true, posX, posY, meso, mesoChance, minMeso, maxMeso, minItems);
|
||||
}
|
||||
|
||||
public void dropItems() {
|
||||
dropItems(false, 0, 0, 0, 0);
|
||||
}
|
||||
@@ -82,6 +100,10 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||
}
|
||||
|
||||
public void dropItems(int posX, int posY, boolean meso, int mesoChance, int minMeso, int maxMeso, int minItems) {
|
||||
dropItems(false, posX, posY, meso, mesoChance, minMeso, maxMeso, minItems);
|
||||
}
|
||||
|
||||
public void dropItems(boolean delayed, int posX, int posY, boolean meso, int mesoChance, final int minMeso, final int maxMeso, int minItems) {
|
||||
List<ReactorDropEntry> chances = getDropChances();
|
||||
List<ReactorDropEntry> items = new LinkedList<>();
|
||||
int numItems = 0;
|
||||
@@ -105,24 +127,61 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||
final Point dropPos = new Point(posX, posY);
|
||||
dropPos.x -= (12 * numItems);
|
||||
|
||||
for (ReactorDropEntry d : items) {
|
||||
if (d.itemId == 0) {
|
||||
int range = maxMeso - minMeso;
|
||||
int displayDrop = (int) (Math.random() * range) + minMeso;
|
||||
int mesoDrop = (displayDrop * client.getWorldServer().getMesoRate());
|
||||
reactor.getMap().spawnMesoDrop(mesoDrop, reactor.getMap().calcDropPos(dropPos, reactor.getPosition()), reactor, client.getPlayer(), false, (byte) 2);
|
||||
} else {
|
||||
Item drop;
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
if (ii.getInventoryType(d.itemId) != MapleInventoryType.EQUIP) {
|
||||
drop = new Item(d.itemId, (short) 0, (short) 1);
|
||||
if(!delayed) {
|
||||
for (ReactorDropEntry d : items) {
|
||||
if (d.itemId == 0) {
|
||||
int range = maxMeso - minMeso;
|
||||
int displayDrop = (int) (Math.random() * range) + minMeso;
|
||||
int mesoDrop = (displayDrop * client.getWorldServer().getMesoRate());
|
||||
reactor.getMap().spawnMesoDrop(mesoDrop, reactor.getMap().calcDropPos(dropPos, reactor.getPosition()), reactor, client.getPlayer(), false, (byte) 2);
|
||||
} else {
|
||||
drop = ii.randomizeStats((Equip) ii.getEquipById(d.itemId));
|
||||
Item drop;
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
if (ii.getInventoryType(d.itemId) != MapleInventoryType.EQUIP) {
|
||||
drop = new Item(d.itemId, (short) 0, (short) 1);
|
||||
} else {
|
||||
drop = ii.randomizeStats((Equip) ii.getEquipById(d.itemId));
|
||||
}
|
||||
|
||||
reactor.getMap().dropFromReactor(getPlayer(), reactor, drop, dropPos, (short)d.questid);
|
||||
}
|
||||
|
||||
reactor.getMap().dropFromReactor(getPlayer(), reactor, drop, dropPos, (short)d.questid);
|
||||
dropPos.x += 25;
|
||||
}
|
||||
dropPos.x += 25;
|
||||
} else {
|
||||
final MapleCharacter chr = client.getPlayer();
|
||||
final MapleReactor r = reactor;
|
||||
final List<ReactorDropEntry> dropItems = items;
|
||||
final int worldMesoRate = client.getWorldServer().getMesoRate();
|
||||
|
||||
sprayTask = TimerManager.getInstance().register(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(dropItems.isEmpty()) {
|
||||
sprayTask.cancel(false);
|
||||
return;
|
||||
}
|
||||
|
||||
ReactorDropEntry d = dropItems.remove(0);
|
||||
if (d.itemId == 0) {
|
||||
int range = maxMeso - minMeso;
|
||||
int displayDrop = (int) (Math.random() * range) + minMeso;
|
||||
int mesoDrop = (displayDrop * worldMesoRate);
|
||||
r.getMap().spawnMesoDrop(mesoDrop, r.getMap().calcDropPos(dropPos, r.getPosition()), r, chr, false, (byte) 2);
|
||||
} else {
|
||||
Item drop;
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
if (ii.getInventoryType(d.itemId) != MapleInventoryType.EQUIP) {
|
||||
drop = new Item(d.itemId, (short) 0, (short) 1);
|
||||
} else {
|
||||
drop = ii.randomizeStats((Equip) ii.getEquipById(d.itemId));
|
||||
}
|
||||
|
||||
r.getMap().dropFromReactor(getPlayer(), r, drop, dropPos, (short)d.questid);
|
||||
}
|
||||
|
||||
dropPos.x += 25;
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,9 @@ import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import tools.locks.MonitoredReentrantLock;
|
||||
import tools.locks.MonitoredReentrantReadWriteLock;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||
@@ -90,6 +92,8 @@ import tools.locks.MonitoredLockType;
|
||||
|
||||
public class MapleMap {
|
||||
private static final List<MapleMapObjectType> rangedMapobjectTypes = Arrays.asList(MapleMapObjectType.SHOP, MapleMapObjectType.ITEM, MapleMapObjectType.NPC, MapleMapObjectType.MONSTER, MapleMapObjectType.DOOR, MapleMapObjectType.SUMMON, MapleMapObjectType.REACTOR);
|
||||
private static final Map<Integer, Pair<Integer, Integer>> dropBoundsCache = new HashMap<>(100);
|
||||
|
||||
private Map<Integer, MapleMapObject> mapobjects = new LinkedHashMap<>();
|
||||
private Collection<SpawnPoint> monsterSpawn = Collections.synchronizedList(new LinkedList<SpawnPoint>());
|
||||
private Collection<SpawnPoint> allMonsterSpawn = Collections.synchronizedList(new LinkedList<SpawnPoint>());
|
||||
@@ -104,6 +108,7 @@ public class MapleMap {
|
||||
private LinkedList<WeakReference<MapleMapObject>> registeredDrops = new LinkedList<>();
|
||||
private List<Rectangle> areas = new ArrayList<>();
|
||||
private MapleFootholdTree footholds = null;
|
||||
private Pair<Integer, Integer> xLimits; // caches the min and max x's with available footholds
|
||||
private Rectangle mapArea = new Rectangle();
|
||||
private int mapid;
|
||||
private AtomicInteger runningOid = new AtomicInteger(1000000001);
|
||||
@@ -148,12 +153,16 @@ public class MapleMap {
|
||||
private MapleSnowball snowball0 = null;
|
||||
private MapleSnowball snowball1 = null;
|
||||
private MapleCoconut coconut;
|
||||
|
||||
//locks
|
||||
private final ReadLock chrRLock;
|
||||
private final WriteLock chrWLock;
|
||||
private final ReadLock objectRLock;
|
||||
private final WriteLock objectWLock;
|
||||
|
||||
// due to the nature of loadMapFromWz (synchronized), sole function that calls 'generateMapDropRangeCache', this lock remains optional.
|
||||
private static final Lock bndLock = new MonitoredReentrantLock(MonitoredLockType.MAP_BOUNDS, true);
|
||||
|
||||
public MapleMap(int mapid, int world, int channel, int returnMapId, float monsterRate) {
|
||||
this.mapid = mapid;
|
||||
this.channel = channel;
|
||||
@@ -437,17 +446,63 @@ public class MapleMap {
|
||||
return new Point(initial.x, dropY);
|
||||
}
|
||||
|
||||
public void generateMapDropRangeCache() {
|
||||
bndLock.lock();
|
||||
try {
|
||||
Integer mapId = Integer.valueOf(mapid);
|
||||
Pair<Integer, Integer> bounds = dropBoundsCache.get(mapId);
|
||||
|
||||
if(bounds != null) {
|
||||
xLimits = bounds;
|
||||
} else {
|
||||
Point lp = new Point(mapArea.x, mapArea.y), rp = new Point(mapArea.x + mapArea.width, mapArea.y), fallback = new Point(mapArea.x + (mapArea.width / 2), mapArea.y);
|
||||
|
||||
lp = bsearchDropPos(lp, fallback);
|
||||
rp = bsearchDropPos(rp, fallback);
|
||||
|
||||
xLimits = new Pair<>(lp.x, rp.x);
|
||||
dropBoundsCache.put(mapId, xLimits);
|
||||
}
|
||||
} finally {
|
||||
bndLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public Point bsearchDropPos(Point initial, Point fallback) {
|
||||
Point res, dropPos = null;
|
||||
|
||||
int awayx = fallback.x;
|
||||
int homex = initial.x;
|
||||
|
||||
int y = initial.y - 85;
|
||||
|
||||
do {
|
||||
int distx = awayx - homex;
|
||||
int dx = distx / 2;
|
||||
|
||||
int searchx = homex + dx;
|
||||
if((res = calcPointBelow(new Point(searchx, y))) != null) {
|
||||
awayx = searchx;
|
||||
dropPos = res;
|
||||
} else {
|
||||
homex = searchx;
|
||||
}
|
||||
} while(Math.abs(homex - awayx) > 5);
|
||||
|
||||
return (dropPos != null) ? dropPos : fallback;
|
||||
}
|
||||
|
||||
public Point calcDropPos(Point initial, Point fallback) {
|
||||
if(initial.x < xLimits.left) initial.x = xLimits.left;
|
||||
else if(initial.x > xLimits.right) initial.x = xLimits.right;
|
||||
|
||||
Point ret = calcPointBelow(new Point(initial.x, initial.y - 85));
|
||||
if (ret == null) {
|
||||
ret = bsearchDropPos(initial, fallback);
|
||||
}
|
||||
|
||||
if(!mapArea.contains(ret)) { // found drop pos outside the map :O
|
||||
return fallback;
|
||||
} else if(!mapArea.contains(ret)) {
|
||||
if(initial.y > mapArea.y + mapArea.height) return fallback; // found drop pos underneath the map :O
|
||||
|
||||
int borderX = (initial.x < mapArea.x) ? mapArea.x : mapArea.x + mapArea.width;
|
||||
ret = calcPointBelow(new Point(borderX, initial.y - 85));
|
||||
|
||||
if(ret == null) return fallback;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -275,7 +275,9 @@ public class MapleMapFactory {
|
||||
e.printStackTrace();
|
||||
// swallow cause I'm cool
|
||||
}
|
||||
|
||||
map.setBackgroundTypes(backTypes);
|
||||
map.generateMapDropRangeCache();
|
||||
|
||||
mapsWLock.lock();
|
||||
try {
|
||||
|
||||
@@ -73,10 +73,19 @@ public class ItemRequirement extends MapleQuestRequirement {
|
||||
count += item.getQuantity();
|
||||
}
|
||||
//Weird stuff, nexon made some quests only available when wearing gm clothes. This enables us to accept it ><
|
||||
if (iType.equals(MapleInventoryType.EQUIP) && chr.isGM()) {
|
||||
for (Item item : chr.getInventory(MapleInventoryType.EQUIPPED).listById(itemId)) {
|
||||
count += item.getQuantity();
|
||||
}
|
||||
if (iType.equals(MapleInventoryType.EQUIP)) {
|
||||
if(chr.isGM()) {
|
||||
for (Item item : chr.getInventory(MapleInventoryType.EQUIPPED).listById(itemId)) {
|
||||
count += item.getQuantity();
|
||||
}
|
||||
} else {
|
||||
if(count < countNeeded) {
|
||||
if(chr.getInventory(MapleInventoryType.EQUIPPED).countById(itemId) + count >= countNeeded) {
|
||||
chr.dropMessage(5, "Unequip the required " + ii.getName(itemId) + " before trying this quest operation.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(count < countNeeded || countNeeded <= 0 && count > 0) {
|
||||
|
||||
@@ -66,8 +66,9 @@ public enum MonitoredLockType {
|
||||
MAP_OBJS(37),
|
||||
MAP_FACTORY(38),
|
||||
MAP_ITEM(39),
|
||||
MINIDUNGEON(40),
|
||||
REACTOR(41);
|
||||
MAP_BOUNDS(41),
|
||||
MINIDUNGEON(41),
|
||||
REACTOR(42);
|
||||
|
||||
private final int i;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user