Autoassigner update + Multi-equip drop
Fixed spawn effect not working properly after the HT spawn sequence patch. Fixed autoassigner not distributing AP properly for brawlers. More than one of the same equipment can now be dropped by mobs. Feature uses the minimum/maximum quantity fields from the drop data to determine how many of the same will be dropped each instance.
This commit is contained in:
@@ -194,7 +194,7 @@ public class MapleTrade {
|
||||
private boolean fitsInInventory() {
|
||||
List<Pair<Item, MapleInventoryType>> tradeItems = new LinkedList<>();
|
||||
for (Item item : exchangeItems) {
|
||||
tradeItems.add(new Pair(item, item.getInventoryType()));
|
||||
tradeItems.add(new Pair<>(item, item.getInventoryType()));
|
||||
}
|
||||
|
||||
return MapleInventory.checkSpotsAndOwnership(chr, tradeItems);
|
||||
|
||||
@@ -869,12 +869,12 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
} else if (venom) {
|
||||
if (from.getJob() == MapleJob.NIGHTLORD || from.getJob() == MapleJob.SHADOWER || from.getJob().isA(MapleJob.NIGHTWALKER3)) {
|
||||
int poisonLevel, matk, jobid = from.getJob().getId();
|
||||
int skill = (jobid == 412 ? NightLord.VENOMOUS_STAR : (jobid == 422 ? Shadower.VENOMOUS_STAB : NightWalker.VENOM));
|
||||
poisonLevel = from.getSkillLevel(SkillFactory.getSkill(skill));
|
||||
int skillid = (jobid == 412 ? NightLord.VENOMOUS_STAR : (jobid == 422 ? Shadower.VENOMOUS_STAB : NightWalker.VENOM));
|
||||
poisonLevel = from.getSkillLevel(SkillFactory.getSkill(skillid));
|
||||
if (poisonLevel <= 0) {
|
||||
return false;
|
||||
}
|
||||
matk = SkillFactory.getSkill(skill).getEffect(poisonLevel).getMatk();
|
||||
matk = SkillFactory.getSkill(skillid).getEffect(poisonLevel).getMatk();
|
||||
int luk = from.getLuk();
|
||||
int maxDmg = (int) Math.ceil(Math.min(Short.MAX_VALUE, 0.2 * luk * matk));
|
||||
int minDmg = (int) Math.ceil(Math.min(Short.MAX_VALUE, 0.1 * luk * matk));
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
*/
|
||||
package server.life;
|
||||
|
||||
import constants.ItemConstants;
|
||||
import constants.ServerConstants;
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
@@ -27,9 +29,11 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataProvider;
|
||||
import provider.MapleDataProviderFactory;
|
||||
@@ -37,15 +41,18 @@ import provider.MapleDataTool;
|
||||
import server.MapleItemInformationProvider;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.Pair;
|
||||
import tools.Randomizer;
|
||||
|
||||
public class MapleMonsterInformationProvider {
|
||||
// Author : LightPepsi
|
||||
|
||||
private static final MapleMonsterInformationProvider instance = new MapleMonsterInformationProvider();
|
||||
private final Map<Integer, List<MonsterDropEntry>> drops = new HashMap<>();
|
||||
private final Map<Integer, List<MonsterDropEntry>> drops = new HashMap<>();
|
||||
private final List<MonsterGlobalDropEntry> globaldrops = new ArrayList<>();
|
||||
|
||||
private final Map<Integer, List<Integer>> dropsChancePool = new HashMap<>(); // thanks to ronan
|
||||
private final Set<Integer> hasNoMultiEquipDrops = new HashSet<>();
|
||||
private final Map<Integer, List<MonsterDropEntry>> extraMultiEquipDrops = new HashMap<>();
|
||||
|
||||
protected MapleMonsterInformationProvider() {
|
||||
retrieveGlobal();
|
||||
@@ -103,6 +110,46 @@ public class MapleMonsterInformationProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public List<MonsterDropEntry> retrieveEffectiveDrop(final int monsterId) {
|
||||
// this reads the drop entries searching for multi-equip, properly processing them
|
||||
|
||||
List<MonsterDropEntry> list = retrieveDrop(monsterId);
|
||||
if (hasNoMultiEquipDrops.contains(monsterId) || !ServerConstants.USE_MULTIPLE_SAME_EQUIP_DROP) {
|
||||
return list;
|
||||
}
|
||||
|
||||
List<MonsterDropEntry> multiDrops = extraMultiEquipDrops.get(monsterId), extra = new LinkedList<>();
|
||||
if(multiDrops == null) {
|
||||
multiDrops = new LinkedList<>();
|
||||
|
||||
for(MonsterDropEntry mde : list) {
|
||||
if(ItemConstants.isEquipment(mde.itemId) && mde.Maximum > 1) {
|
||||
multiDrops.add(mde);
|
||||
|
||||
int rnd = Randomizer.rand(mde.Minimum, mde.Maximum);
|
||||
for(int i = 0; i < rnd - 1; i++) {
|
||||
extra.add(mde); // this passes copies of the equips' MDE with min/max quantity > 1, but idc it'll be unused anyways
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!multiDrops.isEmpty()) extraMultiEquipDrops.put(monsterId, multiDrops);
|
||||
else hasNoMultiEquipDrops.add(monsterId);
|
||||
} else {
|
||||
for(MonsterDropEntry mde : multiDrops) {
|
||||
int rnd = Randomizer.rand(mde.Minimum, mde.Maximum);
|
||||
for(int i = 0; i < rnd - 1; i++) {
|
||||
extra.add(mde);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<MonsterDropEntry> ret = new LinkedList<>(list);
|
||||
ret.addAll(extra);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public final List<MonsterDropEntry> retrieveDrop(final int monsterId) {
|
||||
if (drops.containsKey(monsterId)) {
|
||||
return drops.get(monsterId);
|
||||
@@ -234,6 +281,8 @@ public class MapleMonsterInformationProvider {
|
||||
|
||||
public final void clearDrops() {
|
||||
drops.clear();
|
||||
hasNoMultiEquipDrops.clear();
|
||||
extraMultiEquipDrops.clear();
|
||||
dropsChancePool.clear();
|
||||
globaldrops.clear();
|
||||
retrieveGlobal();
|
||||
|
||||
@@ -559,7 +559,7 @@ public class MapleMap {
|
||||
}
|
||||
|
||||
distn = Math.sqrt(distn);
|
||||
return new Pair(getRoundedCoordinate(angle), Integer.valueOf((int)distn));
|
||||
return new Pair<>(getRoundedCoordinate(angle), Integer.valueOf((int)distn));
|
||||
}
|
||||
|
||||
private static void sortDropEntries(List<MonsterDropEntry> from, List<MonsterDropEntry> item, List<MonsterDropEntry> quest) {
|
||||
@@ -667,7 +667,7 @@ public class MapleMap {
|
||||
|
||||
final List<MonsterDropEntry> dropEntry = new ArrayList<>();
|
||||
final List<MonsterDropEntry> questEntry = new ArrayList<>();
|
||||
sortDropEntries(mi.retrieveDrop(mob.getId()), dropEntry, questEntry);
|
||||
sortDropEntries(mi.retrieveEffectiveDrop(mob.getId()), dropEntry, questEntry);
|
||||
|
||||
// Normal Drops
|
||||
d = dropItemsFromMonsterOnMap(dropEntry, pos, d, chRate, droptype, mobpos, chr, mob);
|
||||
@@ -1347,9 +1347,9 @@ public class MapleMap {
|
||||
|
||||
objectRLock.lock();
|
||||
try {
|
||||
for (Object obj : list) {
|
||||
if(obj instanceof MapleMapObject) {
|
||||
MapleMapObject mmo = (MapleMapObject) obj;
|
||||
for (Object ob : list) {
|
||||
if(ob instanceof MapleMapObject) {
|
||||
MapleMapObject mmo = (MapleMapObject) ob;
|
||||
|
||||
if(mapobjects.containsValue(mmo) && mmo.getType() == MapleMapObjectType.REACTOR) {
|
||||
listObjects.add(mmo);
|
||||
|
||||
@@ -272,9 +272,9 @@ public class MapleMapFactory {
|
||||
try {
|
||||
for (MapleData layer : mapData.getChildByPath("back")) { // yolo
|
||||
int layerNum = Integer.parseInt(layer.getName());
|
||||
int type = MapleDataTool.getInt(layer.getChildByPath("type"), 0);
|
||||
int btype = MapleDataTool.getInt(layer.getChildByPath("type"), 0);
|
||||
|
||||
backTypes.put(layerNum, type);
|
||||
backTypes.put(layerNum, btype);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -71,12 +71,14 @@ public class MapleMist extends AbstractMapleMapObject {
|
||||
this.isRecoveryMist = false;
|
||||
this.isPoisonMist = false;
|
||||
switch (source.getSourceId()) {
|
||||
case Evan.RECOVERY_AURA:
|
||||
isRecoveryMist = true;
|
||||
break;
|
||||
case Evan.RECOVERY_AURA:
|
||||
isRecoveryMist = true;
|
||||
break;
|
||||
|
||||
case Shadower.SMOKE_SCREEN: // Smoke Screen
|
||||
isPoisonMist = false;
|
||||
break;
|
||||
|
||||
case FPMage.POISON_MIST: // FP mist
|
||||
case BlazeWizard.FLAME_GEAR: // Flame Gear
|
||||
case NightWalker.POISON_BOMB: // Poison Bomb
|
||||
|
||||
@@ -131,26 +131,26 @@ public class ItemAction extends MapleQuestAction {
|
||||
|
||||
// must take all needed items before giving others
|
||||
|
||||
for(Pair<Integer, Integer> iEntry: takeItem) {
|
||||
MapleInventoryType type = ItemConstants.getInventoryType(iEntry.getLeft());
|
||||
int quantity = iEntry.getRight() * -1; // Invert
|
||||
for(Pair<Integer, Integer> iPair: takeItem) {
|
||||
MapleInventoryType type = ItemConstants.getInventoryType(iPair.getLeft());
|
||||
int quantity = iPair.getRight() * -1; // Invert
|
||||
if(type.equals(MapleInventoryType.EQUIP)) {
|
||||
if(chr.getInventory(type).countById(iEntry.getLeft()) < quantity) {
|
||||
if(chr.getInventory(type).countById(iPair.getLeft()) < quantity) {
|
||||
// Not enough in the equip inventoty, so check Equipped...
|
||||
if(chr.getInventory(MapleInventoryType.EQUIPPED).countById(iEntry.getLeft()) > quantity) {
|
||||
if(chr.getInventory(MapleInventoryType.EQUIPPED).countById(iPair.getLeft()) > quantity) {
|
||||
// Found it equipped, so change the type to equipped.
|
||||
type = MapleInventoryType.EQUIPPED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MapleInventoryManipulator.removeById(chr.getClient(), type, iEntry.getLeft(), quantity, true, false);
|
||||
chr.announce(MaplePacketCreator.getShowItemGain(iEntry.getLeft(), (short) iEntry.getRight().shortValue(), true));
|
||||
MapleInventoryManipulator.removeById(chr.getClient(), type, iPair.getLeft(), quantity, true, false);
|
||||
chr.announce(MaplePacketCreator.getShowItemGain(iPair.getLeft(), (short) iPair.getRight().shortValue(), true));
|
||||
}
|
||||
|
||||
for(Pair<Integer, Integer> iEntry: giveItem) {
|
||||
MapleInventoryManipulator.addById(chr.getClient(), iEntry.getLeft(), (short) iEntry.getRight().shortValue());
|
||||
chr.announce(MaplePacketCreator.getShowItemGain(iEntry.getLeft(), (short) iEntry.getRight().shortValue(), true));
|
||||
for(Pair<Integer, Integer> iPair: giveItem) {
|
||||
MapleInventoryManipulator.addById(chr.getClient(), iPair.getLeft(), (short) iPair.getRight().shortValue());
|
||||
chr.announce(MaplePacketCreator.getShowItemGain(iPair.getLeft(), (short) iPair.getRight().shortValue(), true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user