Party Search + Conditional Buffs
Revised skillbook drops. New drop chances are related to the holder's level and boss flag. Adjusted party bonus EXP gains. The level difference calculation now only takes into account party members that participated in the action. Implemented Party Search in the source. Refactored command classes initialization to take place when booting up the server. Implemented support for conditional buffs (e.g. card buffs that takes place only in certain areas). Implemented topological sorting when updating buffs to the player, this allows a better vision of buff streaks to the player (buff-applying the original way assumes stat override client-side, to circumvent that this algorithm makes up for the best-fit scenario). Fixed Arans not taking Dojo's attack speed buff properly. Fixed pets being improperly removed from the DB after performing certain inventory actions.
This commit is contained in:
@@ -30,37 +30,35 @@ public enum MapleBuffStat {
|
||||
SHARP_EYES(0x20L),
|
||||
MANA_REFLECTION(0x40L),
|
||||
//ALWAYS_RIGHT(0X80L),
|
||||
|
||||
//------ bgn EDITED SLOT (was unused before) --------
|
||||
MAP_PROTECTION(0x100000000000000L),
|
||||
//------ end EDITED SLOT ----------------------------
|
||||
|
||||
SHADOW_CLAW(0x100L),
|
||||
INFINITY(0x200L),
|
||||
HOLY_SHIELD(0x400L),
|
||||
HAMSTRING(0x800L),
|
||||
BLIND(0x1000L),
|
||||
CONCENTRATE(0x2000L),
|
||||
HPREC(0x4000L),
|
||||
PUPPET(0x4000L),
|
||||
ECHO_OF_HERO(0x8000L),
|
||||
MPREC(0x10000L),
|
||||
MESO_UP_BY_ITEM(0x10000L),
|
||||
GHOST_MORPH(0x20000L),
|
||||
AURA(0x40000L),
|
||||
CONFUSE(0x80000L),
|
||||
ARIANT_PQ_SHIELD(0x40000L),
|
||||
|
||||
// ------ COUPON feature ------
|
||||
|
||||
COUPON_EXP1(0x100000L),
|
||||
COUPON_EXP2(0x200000L),
|
||||
COUPON_EXP3(0x400000L),
|
||||
COUPON_EXP4(0x800000L),
|
||||
COUPON_DRP1(0x1000000L),
|
||||
COUPON_DRP2(0x2000000L),
|
||||
COUPON_DRP3(0x4000000L),
|
||||
COUPON_EXP3(0x400000L), COUPON_EXP4(0x400000L),
|
||||
COUPON_DRP1(0x800000L),
|
||||
COUPON_DRP2(0x1000000L), COUPON_DRP3(0x1000000L),
|
||||
|
||||
// ---- end COUPON feature ----
|
||||
// ------ monster card buffs, thanks to Arnah (Vertisy) ------
|
||||
ITEM_UP_BY_ITEM(0x100000L),
|
||||
RESPECT_PIMMUNE(0x200000L),
|
||||
RESPECT_MIMMUNE(0x400000L),
|
||||
DEFENSE_ATT(0x800000L),
|
||||
DEFENSE_STATE(0x1000000L),
|
||||
|
||||
HPREC(0x2000000L),
|
||||
MPREC(0x4000000L),
|
||||
BERSERK_FURY(0x8000000L),
|
||||
DIVINE_BODY(0x10000000L),
|
||||
SPARK(0x20000000L),
|
||||
@@ -73,7 +71,6 @@ public enum MapleBuffStat {
|
||||
ACC(0x1000000000L),
|
||||
AVOID(0x2000000000L),
|
||||
HANDS(0x4000000000L),
|
||||
SHOWDASH(0x4000000000L),
|
||||
SPEED(0x8000000000L),
|
||||
JUMP(0x10000000000L),
|
||||
MAGIC_GUARD(0x20000000000L),
|
||||
@@ -96,11 +93,10 @@ public enum MapleBuffStat {
|
||||
MESOUP(0x200000000000000L),
|
||||
SHADOWPARTNER(0x400000000000000L),
|
||||
PICKPOCKET(0x800000000000000L),
|
||||
PUPPET(0x800000000000000L),
|
||||
MESOGUARD(0x1000000000000000L),
|
||||
EXP_INCREASE(0x2000000000000000L),
|
||||
WEAKEN(0x4000000000000000L),
|
||||
//THAT GAP
|
||||
MAP_PROTECTION(0x8000000000000000L),
|
||||
|
||||
//all incorrect buffstats
|
||||
SLOW(0x200000000L, true),
|
||||
@@ -144,4 +140,9 @@ public enum MapleBuffStat {
|
||||
public boolean isFirst() {
|
||||
return isFirst;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.Comparator;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
@@ -205,7 +206,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
private transient int localstr, localdex, localluk, localint_, localmagic, localwatk;
|
||||
private transient int equipmaxhp, equipmaxmp, equipstr, equipdex, equipluk, equipint_, equipmagic, equipwatk, localchairhp, localchairmp;
|
||||
private int localchairrate;
|
||||
private boolean hidden, equipchanged = true, canDoor = true, berserk, hasMerchant, hasSandboxItem = false, whiteChat = false;
|
||||
private boolean hidden, equipchanged = true, canDoor = true, berserk, hasMerchant, hasSandboxItem = false, whiteChat = false, canRecvPartySearchInvite = true;
|
||||
private boolean equippedMesoMagnet = false, equippedItemPouch = false, equippedPetItemIgnore = false;
|
||||
private int linkedLevel = 0;
|
||||
private String linkedName = null;
|
||||
@@ -286,6 +287,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
private Lock cpnLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.CHARACTER_CPN);
|
||||
private Map<Integer, Set<Integer>> excluded = new LinkedHashMap<>();
|
||||
private Set<Integer> excludedItems = new LinkedHashSet<>();
|
||||
private Set<Integer> disabledPartySearchInvites = new LinkedHashSet<>();
|
||||
private static String[] ariantroomleader = new String[3];
|
||||
private static int[] ariantroomslot = new int[3];
|
||||
private long portaldelay = 0, lastcombo = 0;
|
||||
@@ -484,6 +486,10 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
public void setEnteredChannelWorld() {
|
||||
awayFromWorld.set(false);
|
||||
client.getChannelServer().removePlayerAway(id);
|
||||
|
||||
if (canRecvPartySearchInvite) {
|
||||
this.getWorldServer().getPartySearchCoordinator().attachPlayer(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAwayFromChannelWorld() {
|
||||
@@ -504,6 +510,46 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePartySearchAvailability(boolean psearchAvailable) {
|
||||
if (psearchAvailable) {
|
||||
if (canRecvPartySearchInvite && getParty() == null) {
|
||||
this.getWorldServer().getPartySearchCoordinator().attachPlayer(this);
|
||||
}
|
||||
} else {
|
||||
if (canRecvPartySearchInvite) {
|
||||
this.getWorldServer().getPartySearchCoordinator().detachPlayer(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean toggleRecvPartySearchInvite() {
|
||||
canRecvPartySearchInvite = !canRecvPartySearchInvite;
|
||||
|
||||
if (canRecvPartySearchInvite) {
|
||||
updatePartySearchAvailability(getParty() == null);
|
||||
} else {
|
||||
this.getWorldServer().getPartySearchCoordinator().detachPlayer(this);
|
||||
}
|
||||
|
||||
return canRecvPartySearchInvite;
|
||||
}
|
||||
|
||||
public boolean isRecvPartySearchInviteEnabled() {
|
||||
return canRecvPartySearchInvite;
|
||||
}
|
||||
|
||||
public void resetPartySearchInvite(int fromLeaderid) {
|
||||
disabledPartySearchInvites.remove(fromLeaderid);
|
||||
}
|
||||
|
||||
public void disablePartySearchInvite(int fromLeaderid) {
|
||||
disabledPartySearchInvites.add(fromLeaderid);
|
||||
}
|
||||
|
||||
public boolean hasDisabledPartySearchInvite(int fromLeaderid) {
|
||||
return disabledPartySearchInvites.contains(fromLeaderid);
|
||||
}
|
||||
|
||||
public void setSessionTransitionState() {
|
||||
client.getSession().setAttribute(MapleClient.CLIENT_TRANSITION);
|
||||
}
|
||||
@@ -1047,7 +1093,13 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
return;//the fuck you doing idiot!
|
||||
}
|
||||
|
||||
this.job = newJob;
|
||||
if (canRecvPartySearchInvite && getParty() == null) {
|
||||
this.updatePartySearchAvailability(false);
|
||||
this.job = newJob;
|
||||
this.updatePartySearchAvailability(true);
|
||||
} else {
|
||||
this.job = newJob;
|
||||
}
|
||||
|
||||
int spGain = 1;
|
||||
if (GameConstants.hasSPTable(newJob)) {
|
||||
@@ -3448,6 +3500,10 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
for(Entry<Integer, Map<MapleBuffStat, MapleBuffStatValueHolder>> bpl: buffEffects.entrySet()) {
|
||||
MapleBuffStatValueHolder mbsvhi = bpl.getValue().get(mbs);
|
||||
if(mbsvhi != null) {
|
||||
if(!mbsvhi.effect.isActive(mapid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(mbsvhi.value > max.left) {
|
||||
max = new Pair<>(mbsvhi.value, mbsvhi.effect.getStatups().size());
|
||||
mbsvh = mbsvhi;
|
||||
@@ -3477,6 +3533,11 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
effLock.lock();
|
||||
chrLock.lock();
|
||||
try {
|
||||
System.out.println("-------------------");
|
||||
System.out.println("CACHED BUFF COUNT: ");
|
||||
for(Entry<MapleBuffStat, Byte> bpl : buffEffectsCount.entrySet()) {
|
||||
System.out.println(bpl.getKey() + ": " + bpl.getValue());
|
||||
}
|
||||
System.out.println("-------------------");
|
||||
System.out.println("CACHED BUFFS: ");
|
||||
for(Entry<Integer, Map<MapleBuffStat, MapleBuffStatValueHolder>> bpl : buffEffects.entrySet()) {
|
||||
@@ -3664,46 +3725,33 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateActiveEffects() {
|
||||
chrLock.lock();
|
||||
try {
|
||||
effects.clear();
|
||||
updateEffects(buffEffectsCount.keySet());
|
||||
} finally {
|
||||
chrLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateEffects(Set<MapleBuffStat> removedStats) {
|
||||
chrLock.lock();
|
||||
try {
|
||||
Map<Integer, Pair<MapleStatEffect, Long>> retrievedEffects = new LinkedHashMap<>();
|
||||
Map<MapleBuffStat, Pair<Integer, Integer>> maxStatups = new LinkedHashMap<>();
|
||||
|
||||
for(Entry<Integer, Map<MapleBuffStat, MapleBuffStatValueHolder>> bel : buffEffects.entrySet()) {
|
||||
for(Entry<MapleBuffStat, MapleBuffStatValueHolder> belv : bel.getValue().entrySet()) {
|
||||
if(removedStats.contains(belv.getKey())) {
|
||||
if(!retrievedEffects.containsKey(bel.getKey())) {
|
||||
retrievedEffects.put(bel.getKey(), new Pair<>(belv.getValue().effect, belv.getValue().startTime));
|
||||
}
|
||||
|
||||
Pair<Integer, Integer> thisStat = maxStatups.get(belv.getKey());
|
||||
if(thisStat == null || belv.getValue().value > thisStat.getRight()) {
|
||||
maxStatups.put(belv.getKey(), new Pair<>(bel.getKey(), belv.getValue().value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<Integer, Pair<MapleStatEffect, Long>> bestEffects = new LinkedHashMap<>();
|
||||
Set<MapleBuffStat> retrievedStats = new LinkedHashSet<>();
|
||||
for(Entry<MapleBuffStat, Pair<Integer, Integer>> lmsee: maxStatups.entrySet()) {
|
||||
if(isSingletonStatup(lmsee.getKey())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (MapleBuffStat mbs : removedStats) {
|
||||
fetchBestEffectFromItemEffectHolder(mbs);
|
||||
|
||||
Integer srcid = lmsee.getValue().getLeft();
|
||||
if(!bestEffects.containsKey(srcid)) {
|
||||
Pair<MapleStatEffect, Long> msel = retrievedEffects.get(srcid);
|
||||
|
||||
bestEffects.put(srcid, msel);
|
||||
for(Pair<MapleBuffStat, Integer> mbsi : msel.getLeft().getStatups()) {
|
||||
retrievedStats.add(mbsi.getLeft());
|
||||
MapleBuffStatValueHolder mbsvh = effects.get(mbs);
|
||||
if (mbsvh != null) {
|
||||
for (Pair<MapleBuffStat, Integer> statup : mbsvh.effect.getStatups()) {
|
||||
retrievedStats.add(statup.getLeft());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
propagateBuffEffectUpdates(bestEffects, retrievedStats);
|
||||
propagateBuffEffectUpdates(new LinkedHashMap<Integer, Pair<MapleStatEffect, Long>>(), retrievedStats, removedStats);
|
||||
} finally {
|
||||
chrLock.unlock();
|
||||
}
|
||||
@@ -3771,21 +3819,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
|
||||
if (!overwrite) {
|
||||
List<MapleBuffStat> cancelStats = new LinkedList<>();
|
||||
|
||||
chrLock.lock();
|
||||
try {
|
||||
for(Entry<MapleBuffStat, MapleBuffStatValueHolder> mbsl : buffstats.entrySet()) {
|
||||
cancelStats.add(mbsl.getKey());
|
||||
}
|
||||
} finally {
|
||||
chrLock.unlock();
|
||||
}
|
||||
|
||||
for(MapleBuffStat mbs : cancelStats) {
|
||||
removedStats.add(mbs);
|
||||
}
|
||||
cancelPlayerBuffs(cancelStats);
|
||||
removedStats.addAll(buffstats.keySet());
|
||||
}
|
||||
|
||||
return toCancel;
|
||||
@@ -3909,7 +3943,152 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
return extractedStatBuffs;
|
||||
}
|
||||
|
||||
private void propagateBuffEffectUpdates(Map<Integer, Pair<MapleStatEffect, Long>> retrievedEffects, Set<MapleBuffStat> retrievedStats) {
|
||||
private void cancelInactiveBuffStats(Set<MapleBuffStat> retrievedStats, Set<MapleBuffStat> removedStats) {
|
||||
List<MapleBuffStat> inactiveStats = new LinkedList<>();
|
||||
for (MapleBuffStat mbs : removedStats) {
|
||||
if (!retrievedStats.contains(mbs)) {
|
||||
inactiveStats.add(mbs);
|
||||
}
|
||||
}
|
||||
|
||||
if (!inactiveStats.isEmpty()) {
|
||||
client.announce(MaplePacketCreator.cancelBuff(inactiveStats));
|
||||
getMap().broadcastMessage(this, MaplePacketCreator.cancelForeignBuff(getId(), inactiveStats), false);
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<MapleStatEffect, Integer> topologicalSortLeafStatCount(Map<MapleBuffStat, Stack<MapleStatEffect>> buffStack) {
|
||||
Map<MapleStatEffect, Integer> leafBuffCount = new LinkedHashMap<>();
|
||||
|
||||
for (Entry<MapleBuffStat, Stack<MapleStatEffect>> e : buffStack.entrySet()) {
|
||||
Stack<MapleStatEffect> mseStack = e.getValue();
|
||||
if (mseStack.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MapleStatEffect mse = mseStack.peek();
|
||||
Integer count = leafBuffCount.get(mse);
|
||||
if (count == null) {
|
||||
leafBuffCount.put(mse, 1);
|
||||
} else {
|
||||
leafBuffCount.put(mse, count + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return leafBuffCount;
|
||||
}
|
||||
|
||||
private static List<MapleStatEffect> topologicalSortRemoveLeafStats(Map<MapleStatEffect, Set<MapleBuffStat>> stackedBuffStats, Map<MapleBuffStat, Stack<MapleStatEffect>> buffStack, Map<MapleStatEffect, Integer> leafStatCount) {
|
||||
List<MapleStatEffect> clearedStatEffects = new LinkedList<>();
|
||||
Set<MapleBuffStat> clearedStats = new LinkedHashSet<>();
|
||||
|
||||
for (Entry<MapleStatEffect, Integer> e : leafStatCount.entrySet()) {
|
||||
MapleStatEffect mse = e.getKey();
|
||||
|
||||
if (stackedBuffStats.get(mse).size() <= e.getValue()) {
|
||||
clearedStatEffects.add(mse);
|
||||
|
||||
for (MapleBuffStat mbs : stackedBuffStats.get(mse)) {
|
||||
clearedStats.add(mbs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (MapleBuffStat mbs : clearedStats) {
|
||||
MapleStatEffect mse = buffStack.get(mbs).pop();
|
||||
stackedBuffStats.get(mse).remove(mbs);
|
||||
}
|
||||
|
||||
return clearedStatEffects;
|
||||
}
|
||||
|
||||
private static void topologicalSortRebaseLeafStats(Map<MapleStatEffect, Set<MapleBuffStat>> stackedBuffStats, Map<MapleBuffStat, Stack<MapleStatEffect>> buffStack) {
|
||||
for (Entry<MapleBuffStat, Stack<MapleStatEffect>> e : buffStack.entrySet()) {
|
||||
Stack<MapleStatEffect> mseStack = e.getValue();
|
||||
|
||||
if (!mseStack.isEmpty()) {
|
||||
MapleStatEffect mse = mseStack.pop();
|
||||
stackedBuffStats.get(mse).remove(e.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<MapleStatEffect> topologicalSortEffects(Map<MapleBuffStat, List<Pair<MapleStatEffect, Integer>>> buffEffects) {
|
||||
Map<MapleStatEffect, Set<MapleBuffStat>> stackedBuffStats = new LinkedHashMap<>();
|
||||
Map<MapleBuffStat, Stack<MapleStatEffect>> buffStack = new LinkedHashMap<>();
|
||||
|
||||
for (Entry<MapleBuffStat, List<Pair<MapleStatEffect, Integer>>> e : buffEffects.entrySet()) {
|
||||
MapleBuffStat mbs = e.getKey();
|
||||
|
||||
Stack<MapleStatEffect> mbsStack = new Stack<>();
|
||||
buffStack.put(mbs, mbsStack);
|
||||
|
||||
for (Pair<MapleStatEffect, Integer> emse : e.getValue()) {
|
||||
MapleStatEffect mse = emse.getLeft();
|
||||
mbsStack.push(mse);
|
||||
|
||||
Set<MapleBuffStat> mbsStats = stackedBuffStats.get(mse);
|
||||
if (mbsStats == null) {
|
||||
mbsStats = new LinkedHashSet<>();
|
||||
stackedBuffStats.put(mse, mbsStats);
|
||||
}
|
||||
|
||||
mbsStats.add(mbs);
|
||||
}
|
||||
}
|
||||
|
||||
List<MapleStatEffect> buffList = new LinkedList<>();
|
||||
while (true) {
|
||||
Map<MapleStatEffect, Integer> leafStatCount = topologicalSortLeafStatCount(buffStack);
|
||||
if (leafStatCount.isEmpty()) break;
|
||||
|
||||
List<MapleStatEffect> clearedNodes = topologicalSortRemoveLeafStats(stackedBuffStats, buffStack, leafStatCount);
|
||||
if (clearedNodes.isEmpty()) {
|
||||
topologicalSortRebaseLeafStats(stackedBuffStats, buffStack);
|
||||
} else {
|
||||
buffList.addAll(clearedNodes);
|
||||
}
|
||||
}
|
||||
|
||||
return buffList;
|
||||
}
|
||||
|
||||
private static List<MapleStatEffect> sortEffectsList(Map<MapleStatEffect, Integer> updateEffectsList) {
|
||||
Map<MapleBuffStat, List<Pair<MapleStatEffect, Integer>>> buffEffects = new LinkedHashMap<>();
|
||||
|
||||
for (Entry<MapleStatEffect, Integer> p : updateEffectsList.entrySet()) {
|
||||
MapleStatEffect mse = p.getKey();
|
||||
|
||||
for (Pair<MapleBuffStat, Integer> statup : mse.getStatups()) {
|
||||
MapleBuffStat stat = statup.getLeft();
|
||||
|
||||
List<Pair<MapleStatEffect, Integer>> statBuffs = buffEffects.get(stat);
|
||||
if (statBuffs == null) {
|
||||
statBuffs = new ArrayList<>();
|
||||
buffEffects.put(stat, statBuffs);
|
||||
}
|
||||
|
||||
statBuffs.add(new Pair<>(mse, statup.getRight()));
|
||||
}
|
||||
}
|
||||
|
||||
Comparator cmp = new Comparator<Pair<MapleStatEffect, Integer>>() {
|
||||
@Override
|
||||
public int compare(Pair<MapleStatEffect, Integer> o1, Pair<MapleStatEffect, Integer> o2)
|
||||
{
|
||||
return o2.getRight().compareTo(o1.getRight());
|
||||
}
|
||||
};
|
||||
|
||||
for (Entry<MapleBuffStat, List<Pair<MapleStatEffect, Integer>>> statBuffs : buffEffects.entrySet()) {
|
||||
Collections.sort(statBuffs.getValue(), cmp);
|
||||
}
|
||||
|
||||
return topologicalSortEffects(buffEffects);
|
||||
}
|
||||
|
||||
private void propagateBuffEffectUpdates(Map<Integer, Pair<MapleStatEffect, Long>> retrievedEffects, Set<MapleBuffStat> retrievedStats, Set<MapleBuffStat> removedStats) {
|
||||
cancelInactiveBuffStats(retrievedStats, removedStats);
|
||||
if (retrievedStats.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -3924,7 +4103,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
maxBuffValue.put(mbs, new Pair<>(Integer.MIN_VALUE, (MapleStatEffect) null));
|
||||
}
|
||||
|
||||
Map<MapleStatEffect, Pair<Integer, Integer>> updateEffects = new LinkedHashMap<>();
|
||||
Map<MapleStatEffect, Integer> updateEffects = new LinkedHashMap<>();
|
||||
|
||||
List<MapleStatEffect> recalcMseList = new LinkedList<>();
|
||||
for(Entry<Integer, Pair<MapleStatEffect, Long>> re : retrievedEffects.entrySet()) {
|
||||
@@ -3937,7 +4116,6 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
recalcMseList = new LinkedList<>();
|
||||
|
||||
for(MapleStatEffect mse : mseList) {
|
||||
int mseAmount = 0;
|
||||
int maxEffectiveStatup = Integer.MIN_VALUE;
|
||||
for(Pair<MapleBuffStat, Integer> st : mse.getStatups()) {
|
||||
MapleBuffStat mbs = st.getLeft();
|
||||
@@ -3972,36 +4150,16 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(relevantStatup) {
|
||||
mseAmount += st.getRight();
|
||||
}
|
||||
}
|
||||
|
||||
updateEffects.put(mse, new Pair<>(maxEffectiveStatup, mseAmount));
|
||||
updateEffects.put(mse, maxEffectiveStatup);
|
||||
}
|
||||
} while(!recalcMseList.isEmpty());
|
||||
|
||||
List<Pair<MapleStatEffect, Pair<Integer, Integer>>> updateEffectsList = new ArrayList<>();
|
||||
for(Entry<MapleStatEffect, Pair<Integer, Integer>> ue : updateEffects.entrySet()) {
|
||||
updateEffectsList.add(new Pair<>(ue.getKey(), ue.getValue()));
|
||||
}
|
||||
|
||||
Collections.sort(updateEffectsList, new Comparator<Pair<MapleStatEffect, Pair<Integer, Integer>>>() {
|
||||
@Override
|
||||
public int compare(Pair<MapleStatEffect, Pair<Integer, Integer>> o1, Pair<MapleStatEffect, Pair<Integer, Integer>> o2)
|
||||
{
|
||||
if(o1.getRight().getLeft().equals(o2.getRight().getLeft())) {
|
||||
return o1.getRight().getRight().compareTo(o2.getRight().getRight());
|
||||
} else {
|
||||
return o1.getRight().getLeft().compareTo(o2.getRight().getLeft());
|
||||
}
|
||||
}
|
||||
});
|
||||
List<MapleStatEffect> updateEffectsList = sortEffectsList(updateEffects);
|
||||
|
||||
List<Pair<Integer, Pair<MapleStatEffect, Long>>> toUpdateEffects = new LinkedList<>();
|
||||
for(Pair<MapleStatEffect, Pair<Integer, Integer>> msep : updateEffectsList) {
|
||||
MapleStatEffect mse = msep.getLeft();
|
||||
for(MapleStatEffect mse : updateEffectsList) {
|
||||
toUpdateEffects.add(new Pair<>(mse.getBuffSourceId(), retrievedEffects.get(mse.getBuffSourceId())));
|
||||
}
|
||||
|
||||
@@ -4010,9 +4168,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
Pair<MapleStatEffect, Long> msel = lmse.getRight();
|
||||
|
||||
for(Pair<MapleBuffStat, Integer> statup : getActiveStatupsFromSourceid(lmse.getLeft())) {
|
||||
if(!isSingletonStatup(statup.getLeft())) {
|
||||
activeStatups.add(statup);
|
||||
}
|
||||
activeStatups.add(statup);
|
||||
}
|
||||
|
||||
msel.getLeft().updateBuffEffect(this, activeStatups, msel.getRight());
|
||||
@@ -4061,6 +4217,17 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
}
|
||||
|
||||
private void addItemEffectHolderCount(MapleBuffStat stat) {
|
||||
Byte val = buffEffectsCount.get(stat);
|
||||
if (val != null) {
|
||||
val = (byte) (val + 1);
|
||||
} else {
|
||||
val = (byte) 1;
|
||||
}
|
||||
|
||||
buffEffectsCount.put(stat, val);
|
||||
}
|
||||
|
||||
public void registerEffect(MapleStatEffect effect, long starttime, long expirationtime, boolean isSilent) {
|
||||
if (effect.isDragonBlood()) {
|
||||
prepareDragonBlood(effect);
|
||||
@@ -4180,6 +4347,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
appliedStatups.put(ps.getLeft(), new MapleBuffStatValueHolder(effect, starttime, ps.getRight()));
|
||||
}
|
||||
|
||||
boolean active = effect.isActive(mapid);
|
||||
if(ServerConstants.USE_BUFF_MOST_SIGNIFICANT) {
|
||||
toDeploy = new LinkedHashMap<>();
|
||||
Map<Integer, Pair<MapleStatEffect, Long>> retrievedEffects = new LinkedHashMap<>();
|
||||
@@ -4189,25 +4357,19 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
MapleBuffStatValueHolder mbsvh = effects.get(statup.getKey());
|
||||
MapleBuffStatValueHolder statMbsvh = statup.getValue();
|
||||
|
||||
if(mbsvh == null || mbsvh.value < statMbsvh.value || (mbsvh.value == statMbsvh.value && mbsvh.effect.getStatups().size() <= statMbsvh.effect.getStatups().size())) {
|
||||
toDeploy.put(statup.getKey(), statMbsvh);
|
||||
} else {
|
||||
if(!isSingletonStatup(statup.getKey())) {
|
||||
retrievedEffects.put(mbsvh.effect.getBuffSourceId(), new Pair<>(mbsvh.effect, mbsvh.startTime));
|
||||
for(Pair<MapleBuffStat, Integer> mbs : mbsvh.effect.getStatups()) {
|
||||
retrievedStats.add(mbs.getLeft());
|
||||
if(active) {
|
||||
if(mbsvh == null || mbsvh.value < statMbsvh.value || (mbsvh.value == statMbsvh.value && mbsvh.effect.getStatups().size() <= statMbsvh.effect.getStatups().size())) {
|
||||
toDeploy.put(statup.getKey(), statMbsvh);
|
||||
} else {
|
||||
if(!isSingletonStatup(statup.getKey())) {
|
||||
for(Pair<MapleBuffStat, Integer> mbs : mbsvh.effect.getStatups()) {
|
||||
retrievedStats.add(mbs.getLeft());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Byte val = buffEffectsCount.get(statup.getKey());
|
||||
if (val != null) {
|
||||
val = (byte) (val + 1);
|
||||
} else {
|
||||
val = (byte) 1;
|
||||
}
|
||||
|
||||
buffEffectsCount.put(statup.getKey(), val);
|
||||
addItemEffectHolderCount(statup.getKey());
|
||||
}
|
||||
|
||||
if(!isSilent) {
|
||||
@@ -4216,22 +4378,18 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
effects.put(statup.getKey(), statup.getValue());
|
||||
}
|
||||
|
||||
retrievedEffects.put(sourceid, new Pair<>(effect, starttime));
|
||||
propagateBuffEffectUpdates(retrievedEffects, retrievedStats);
|
||||
if (active) {
|
||||
retrievedEffects.put(sourceid, new Pair<>(effect, starttime));
|
||||
}
|
||||
|
||||
propagateBuffEffectUpdates(retrievedEffects, retrievedStats, new LinkedHashSet<MapleBuffStat>());
|
||||
}
|
||||
} else {
|
||||
for (Entry<MapleBuffStat, MapleBuffStatValueHolder> statup : appliedStatups.entrySet()) {
|
||||
Byte val = buffEffectsCount.get(statup.getKey());
|
||||
if (val != null) {
|
||||
val = (byte) (val + 1);
|
||||
} else {
|
||||
val = (byte) 1;
|
||||
}
|
||||
|
||||
buffEffectsCount.put(statup.getKey(), val);
|
||||
addItemEffectHolderCount(statup.getKey());
|
||||
}
|
||||
|
||||
toDeploy = appliedStatups;
|
||||
toDeploy = (active ? appliedStatups : new LinkedHashMap<MapleBuffStat, MapleBuffStatValueHolder>());
|
||||
}
|
||||
|
||||
addItemEffectHolder(sourceid, expirationtime, appliedStatups);
|
||||
@@ -4607,6 +4765,24 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
return w.getMesoRate() * w.getQuestRate();
|
||||
}
|
||||
|
||||
public float getCardRate(int itemid) {
|
||||
float rate = 100.0f;
|
||||
|
||||
if (itemid == 0) {
|
||||
MapleStatEffect mseMeso = getBuffEffect(MapleBuffStat.MESO_UP_BY_ITEM);
|
||||
if (mseMeso != null) {
|
||||
rate += mseMeso.getCardRate(mapid, itemid);
|
||||
}
|
||||
} else {
|
||||
MapleStatEffect mseItem = getBuffEffect(MapleBuffStat.ITEM_UP_BY_ITEM);
|
||||
if (mseItem != null) {
|
||||
rate += mseItem.getCardRate(mapid, itemid);
|
||||
}
|
||||
}
|
||||
|
||||
return rate / 100;
|
||||
}
|
||||
|
||||
public int getFace() {
|
||||
return face;
|
||||
}
|
||||
@@ -5169,6 +5345,13 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
this.gmLevel = Math.max(level, 0);
|
||||
}
|
||||
|
||||
public void closePartySearchInteractions() {
|
||||
this.getWorldServer().getPartySearchCoordinator().unregisterPartyLeader(this);
|
||||
if (canRecvPartySearchInvite) {
|
||||
this.getWorldServer().getPartySearchCoordinator().detachPlayer(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void closePlayerInteractions() {
|
||||
closeNpcShop();
|
||||
closeTrade();
|
||||
@@ -5570,8 +5753,8 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
return vanquisherStage;
|
||||
}
|
||||
|
||||
public Collection<MapleMapObject> getVisibleMapObjects() {
|
||||
return Collections.unmodifiableCollection(visibleMapObjects);
|
||||
public MapleMapObject[] getVisibleMapObjects() {
|
||||
return visibleMapObjects.toArray(new MapleMapObject[visibleMapObjects.size()]);
|
||||
}
|
||||
|
||||
public int getWorld() {
|
||||
@@ -6717,6 +6900,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
int buddyCapacity = rs.getInt("buddyCapacity");
|
||||
ret.buddylist = new BuddyList(buddyCapacity);
|
||||
ret.lastExpGainTime = rs.getTimestamp("lastExpGainTime").getTime();
|
||||
ret.canRecvPartySearchInvite = rs.getBoolean("partySearch");
|
||||
|
||||
ret.getInventory(MapleInventoryType.EQUIP).setSlotLimit(rs.getByte("equipslots"));
|
||||
ret.getInventory(MapleInventoryType.USE).setSlotLimit(rs.getByte("useslots"));
|
||||
@@ -7979,12 +8163,8 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
|
||||
con.setAutoCommit(false);
|
||||
PreparedStatement ps;
|
||||
ps = con.prepareStatement("UPDATE characters SET level = ?, fame = ?, str = ?, dex = ?, luk = ?, `int` = ?, exp = ?, gachaexp = ?, hp = ?, mp = ?, maxhp = ?, maxmp = ?, sp = ?, ap = ?, gm = ?, skincolor = ?, gender = ?, job = ?, hair = ?, face = ?, map = ?, meso = ?, hpMpUsed = ?, spawnpoint = ?, party = ?, buddyCapacity = ?, messengerid = ?, messengerposition = ?, mountlevel = ?, mountexp = ?, mounttiredness= ?, equipslots = ?, useslots = ?, setupslots = ?, etcslots = ?, monsterbookcover = ?, vanquisherStage = ?, dojoPoints = ?, lastDojoStage = ?, finishedDojoTutorial = ?, vanquisherKills = ?, matchcardwins = ?, matchcardlosses = ?, matchcardties = ?, omokwins = ?, omoklosses = ?, omokties = ?, dataString = ?, fquest = ?, jailexpire = ?, partnerId = ?, marriageItemId = ?, lastExpGainTime = ?, ariantPoints = ? WHERE id = ?", Statement.RETURN_GENERATED_KEYS);
|
||||
if (gmLevel < 1 && level > 199) {
|
||||
ps.setInt(1, isCygnus() ? 120 : 200);
|
||||
} else {
|
||||
ps.setInt(1, level);
|
||||
}
|
||||
ps = con.prepareStatement("UPDATE characters SET level = ?, fame = ?, str = ?, dex = ?, luk = ?, `int` = ?, exp = ?, gachaexp = ?, hp = ?, mp = ?, maxhp = ?, maxmp = ?, sp = ?, ap = ?, gm = ?, skincolor = ?, gender = ?, job = ?, hair = ?, face = ?, map = ?, meso = ?, hpMpUsed = ?, spawnpoint = ?, party = ?, buddyCapacity = ?, messengerid = ?, messengerposition = ?, mountlevel = ?, mountexp = ?, mounttiredness= ?, equipslots = ?, useslots = ?, setupslots = ?, etcslots = ?, monsterbookcover = ?, vanquisherStage = ?, dojoPoints = ?, lastDojoStage = ?, finishedDojoTutorial = ?, vanquisherKills = ?, matchcardwins = ?, matchcardlosses = ?, matchcardties = ?, omokwins = ?, omoklosses = ?, omokties = ?, dataString = ?, fquest = ?, jailexpire = ?, partnerId = ?, marriageItemId = ?, lastExpGainTime = ?, ariantPoints = ?, partySearch = ? WHERE id = ?", Statement.RETURN_GENERATED_KEYS);
|
||||
ps.setInt(1, level); // thanks CanIGetaPR for noticing an unnecessary "level" limitation when persisting DB data
|
||||
ps.setInt(2, fame);
|
||||
|
||||
effLock.lock();
|
||||
@@ -8094,7 +8274,8 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
ps.setInt(52, marriageItemid);
|
||||
ps.setTimestamp(53, new Timestamp(lastExpGainTime));
|
||||
ps.setInt(54, ariantPoints);
|
||||
ps.setInt(55, id);
|
||||
ps.setBoolean(55, canRecvPartySearchInvite);
|
||||
ps.setInt(56, id);
|
||||
|
||||
int updateRows = ps.executeUpdate();
|
||||
ps.close();
|
||||
|
||||
@@ -888,6 +888,7 @@ public class MapleClient {
|
||||
player.cancelAllBuffs(true);
|
||||
|
||||
player.closePlayerInteractions();
|
||||
player.closePartySearchInteractions();
|
||||
|
||||
if (!serverTransition) { // thanks MedicOP for detecting an issue with party leader change on changing channels
|
||||
removePartyPlayer(wserv);
|
||||
@@ -1463,6 +1464,7 @@ public class MapleClient {
|
||||
}
|
||||
|
||||
player.closePlayerInteractions();
|
||||
player.closePartySearchInteractions();
|
||||
|
||||
player.unregisterChairBuff();
|
||||
server.getPlayerBuffStorage().addBuffsToStorage(player.getId(), player.getAllBuffs());
|
||||
|
||||
@@ -114,11 +114,6 @@ public enum MapleJob {
|
||||
return BEGINNER;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBeginner(MapleJob beginners) {
|
||||
return MAGICIAN == beginners || WARRIOR == beginners || THIEF == beginners || PIRATE == beginners || BOWMAN == beginners || ARAN1 == beginners || THUNDERBREAKER1 == beginners
|
||||
|| DAWNWARRIOR1 == beginners || NIGHTWALKER1 == beginners || BLAZEWIZARD1 == beginners;
|
||||
}
|
||||
|
||||
public boolean isA(MapleJob basejob) { // thanks Steve (kaito1410) for pointing out an improvement here
|
||||
int basebranch = basejob.getId() / 10;
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import server.ThreadManager;
|
||||
|
||||
public class IdCommand extends Command {
|
||||
{
|
||||
@@ -34,7 +35,7 @@ public class IdCommand extends Command {
|
||||
return;
|
||||
}
|
||||
final String queryItem = joinStringArr(Arrays.copyOfRange(params, 1, params.length), " ");
|
||||
player.yellowMessage("Querying for entry... May take some time... Please try to refine your search");
|
||||
player.yellowMessage("Querying for entry... May take some time... Please try to refine your search.");
|
||||
Runnable queryRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -42,28 +43,31 @@ public class IdCommand extends Command {
|
||||
populateIdMap(params[0].toLowerCase());
|
||||
|
||||
Map<String, String> resultList = fetchResults(itemMap.get(params[0]), queryItem);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (resultList.size() > 0) {
|
||||
int count = 0;
|
||||
for (Map.Entry<String, String> entry: resultList.entrySet()) {
|
||||
player.yellowMessage(String.format("Id for %s is: %s", entry.getKey(), entry.getValue()));
|
||||
sb.append(String.format("Id for %s is: #b%s#k", entry.getKey(), entry.getValue()) + "\r\n");
|
||||
if (++count > 100) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
player.yellowMessage(String.format("Results found: %d | Returned: %d/100 | Refine search query to improve time.", resultList.size(), count - 1));
|
||||
sb.append(String.format("Results found: #r%d#k | Returned: #b%d#k/100 | Refine search query to improve time.", resultList.size(), count) + "\r\n");
|
||||
|
||||
player.getClient().getAbstractPlayerInteraction().npcTalk(9010000, sb.toString());
|
||||
} else {
|
||||
player.yellowMessage(String.format("Id not found for item: %s, of type: %s", queryItem, params[0]));
|
||||
player.yellowMessage(String.format("Id not found for item: %s, of type: %s.", queryItem, params[0]));
|
||||
}
|
||||
} catch (IdTypeNotSupportedException e) {
|
||||
player.yellowMessage("Your query type is not supported");
|
||||
player.yellowMessage("Your query type is not supported.");
|
||||
} catch (IOException e) {
|
||||
player.yellowMessage("Error reading file, please contact your administrator");
|
||||
player.yellowMessage("Error reading file, please contact your administrator.");
|
||||
}
|
||||
}
|
||||
};
|
||||
Thread thread = new Thread(queryRunnable);
|
||||
thread.start();
|
||||
|
||||
ThreadManager.getInstance().newTask(queryRunnable);
|
||||
}
|
||||
|
||||
private void populateIdMap(String type) throws IdTypeNotSupportedException, IOException {
|
||||
|
||||
@@ -39,10 +39,9 @@ import tools.MaplePacketCreator;
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import tools.packets.Wedding;
|
||||
|
||||
public class DebugCommand extends Command {
|
||||
private final static String debugTypes[] = {"monster", "packet", "portal", "spawnpoint", "pos", "map", "mobsp", "event", "areas", "reactors", "servercoupons", "playercoupons", "timer", "marriage", ""};
|
||||
private final static String debugTypes[] = {"monster", "packet", "portal", "spawnpoint", "pos", "map", "mobsp", "event", "areas", "reactors", "servercoupons", "playercoupons", "timer", "marriage", "buff", ""};
|
||||
|
||||
{
|
||||
setDescription("");
|
||||
@@ -158,7 +157,10 @@ public class DebugCommand extends Command {
|
||||
case "marriage":
|
||||
c.getChannelServer().debugMarriageStatus();
|
||||
break;
|
||||
|
||||
|
||||
case "buff":
|
||||
c.getPlayer().debugListAllBuffs();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +98,65 @@ public class MaplePet extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
private static void unreferenceMissingPetsFromInventoryDb() {
|
||||
PreparedStatement ps = null;
|
||||
Connection con = null;
|
||||
try {
|
||||
con = DatabaseConnection.getConnection();
|
||||
|
||||
ps = con.prepareStatement("UPDATE inventoryitems SET petid = -1, expiration = 0 WHERE petid != -1 AND petid NOT IN (SELECT petid FROM pets)");
|
||||
ps.executeUpdate();
|
||||
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch(SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if(ps != null && !ps.isClosed()) {
|
||||
ps.close();
|
||||
}
|
||||
if(con != null && !con.isClosed()) {
|
||||
con.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void deleteMissingPetsFromDb() {
|
||||
PreparedStatement ps = null;
|
||||
Connection con = null;
|
||||
try {
|
||||
con = DatabaseConnection.getConnection();
|
||||
|
||||
ps = con.prepareStatement("DELETE FROM pets WHERE petid NOT IN (SELECT petid FROM inventoryitems WHERE petid != -1)");
|
||||
ps.executeUpdate();
|
||||
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch(SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if(ps != null && !ps.isClosed()) {
|
||||
ps.close();
|
||||
}
|
||||
if(con != null && !con.isClosed()) {
|
||||
con.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearMissingPetsFromDb() {
|
||||
unreferenceMissingPetsFromInventoryDb();
|
||||
deleteMissingPetsFromDb();
|
||||
}
|
||||
|
||||
public static void deleteFromDb(MapleCharacter owner, int petid) {
|
||||
try {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
|
||||
@@ -439,7 +439,7 @@ public class MapleInventoryManipulator {
|
||||
announceModifyInventory(c, item, fromDrop, allowZero);
|
||||
}
|
||||
|
||||
MaplePet.deleteFromDb(chr, petid);
|
||||
// thanks Robin Schulz for noticing pet issues when moving pets out of inventory
|
||||
} else {
|
||||
inv.removeItem(slot, quantity, allowZero);
|
||||
if(type != MapleInventoryType.CANHOLD) {
|
||||
|
||||
@@ -75,11 +75,10 @@ public class ServerConstants {
|
||||
public static final boolean USE_FIXED_RATIO_HPMP_UPDATE = true; //Enables the HeavenMS-builtin HPMP update based on the current pool to max pool ratio.
|
||||
public static final boolean USE_FAMILY_SYSTEM = false;
|
||||
public static final boolean USE_DUEY = true;
|
||||
public static final boolean USE_RANDOMIZE_HPMP_GAIN = true; //Enables randomizing on MaxHP/MaxMP gains and INT accounting for the MaxMP gain.
|
||||
public static final boolean USE_RANDOMIZE_HPMP_GAIN = true; //Enables randomizing on MaxHP/MaxMP gains and INT accounting for the MaxMP gain on level up.
|
||||
public static final boolean USE_STORAGE_ITEM_SORT = true; //Enables storage "Arrange Items" feature.
|
||||
public static final boolean USE_ITEM_SORT = true; //Enables inventory "Item Sort/Merge" feature.
|
||||
public static final boolean USE_ITEM_SORT_BY_NAME = false; //Item sorting based on name rather than id.
|
||||
public static final boolean USE_PARTY_SEARCH = false;
|
||||
public static final boolean USE_PARTY_FOR_STARTERS = true; //Players level 10 or below can create/invite other players on the given level range.
|
||||
public static final boolean USE_AUTOASSIGN_STARTERS_AP = false; //Beginners level 10 or below have their AP autoassigned (they can't choose to levelup a stat). Set true ONLY if the localhost doesn't support AP assigning for beginners level 10 or below.
|
||||
public static final boolean USE_AUTOASSIGN_SECONDARY_CAP = true;//Prevents AP autoassign from spending on secondary stats after the player class' cap (defined on the autoassign handler) has been reached.
|
||||
@@ -95,8 +94,8 @@ public class ServerConstants {
|
||||
public static final boolean USE_ENFORCE_JOB_LEVEL_RANGE = false;//Caps the player level on the minimum required to advance their current jobs.
|
||||
public static final boolean USE_ENFORCE_JOB_SP_RANGE = false; //Caps the player SP level on the total obtainable by their current jobs. After changing jobs, missing SP will be retrieved.
|
||||
public static final boolean USE_ENFORCE_ITEM_SUGGESTION = false;//Forces the Owl of Minerva and the Cash Shop to always display the defined item array instead of those featured by the players.
|
||||
public static final boolean USE_ENFORCE_UNMERCHABLE_CASH = true;//Forces players to not sell CASH items via merchants.
|
||||
public static final boolean USE_ENFORCE_UNMERCHABLE_PET = true; //Forces players to not sell pets via merchants. (since non-named pets gets dirty name and other possible DB-related issues)
|
||||
public static final boolean USE_ENFORCE_UNMERCHABLE_CASH = false;//Forces players to not sell CASH items via merchants.
|
||||
public static final boolean USE_ENFORCE_UNMERCHABLE_PET = false; //Forces players to not sell pets via merchants. (since non-named pets gets dirty name and other possible DB-related issues)
|
||||
public static final boolean USE_ENFORCE_MERCHANT_SAVE = true; //Forces automatic DB save on merchant owners, at every item movement on shop.
|
||||
public static final boolean USE_ENFORCE_MDOOR_POSITION = false; //Forces mystic door to be spawned near spawnpoints.
|
||||
public static final boolean USE_SPAWN_LOOT_ON_ANIMATION = false;//Makes loot appear some time after the mob has been killed (following the mob death animation, instead of instantly).
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Legend {
|
||||
public static final int MAKER = 20001007;
|
||||
public static final int BAMBOO_THRUST = 20001009;
|
||||
public static final int INVICIBLE_BARRIER = 20001010;
|
||||
public static final int POWER_EXPLOSION = 20011011;
|
||||
public static final int POWER_EXPLOSION = 20001011;
|
||||
public static final int METEO_SHOWER = 20001011;
|
||||
public static final int BLESSING_OF_THE_FAIRY = 20000012;
|
||||
public static final int TUTORIAL_SKILL1 = 20000014;
|
||||
|
||||
@@ -241,13 +241,13 @@ public final class PacketProcessor {
|
||||
registerHandler(RecvOpcode.ACCEPT_FAMILY, new AcceptFamilyHandler());
|
||||
registerHandler(RecvOpcode.DUEY_ACTION, new DueyHandler());
|
||||
registerHandler(RecvOpcode.USE_DEATHITEM, new UseDeathItemHandler());
|
||||
//registerHandler(RecvOpcode.PLAYER_UPDATE, new PlayerUpdateHandler()); unused
|
||||
registerHandler(RecvOpcode.PLAYER_MAP_TRANSFER, new PlayerMapTransitionHandler());
|
||||
registerHandler(RecvOpcode.USE_MAPLELIFE, new UseMapleLifeHandler());
|
||||
registerHandler(RecvOpcode.USE_CATCH_ITEM, new UseCatchItemHandler());
|
||||
registerHandler(RecvOpcode.MOB_DAMAGE_MOB_FRIENDLY, new MobDamageMobFriendlyHandler());
|
||||
registerHandler(RecvOpcode.PARTY_SEARCH_REGISTER, new PartySearchRegisterHandler());
|
||||
registerHandler(RecvOpcode.PARTY_SEARCH_START, new PartySearchStartHandler());
|
||||
registerHandler(RecvOpcode.PARTY_SEARCH_UPDATE, new PartySearchUpdateHandler());
|
||||
registerHandler(RecvOpcode.ITEM_SORT2, new InventorySortHandler());
|
||||
registerHandler(RecvOpcode.LEFT_KNOCKBACK, new LeftKnockbackHandler());
|
||||
registerHandler(RecvOpcode.SNOWBALL, new SnowballHandler());
|
||||
|
||||
@@ -186,7 +186,7 @@ public enum RecvOpcode {
|
||||
MONSTER_CARNIVAL(0xDA),
|
||||
PARTY_SEARCH_REGISTER(0xDC),
|
||||
PARTY_SEARCH_START(0xDE),
|
||||
PLAYER_UPDATE(0xDF),
|
||||
PARTY_SEARCH_UPDATE(0xDF),
|
||||
CHECK_CASH(0xE4),
|
||||
CASHSHOP_OPERATION(0xE5),
|
||||
COUPON_CODE(0xE6),
|
||||
|
||||
@@ -80,8 +80,10 @@ import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
|
||||
import client.MapleClient;
|
||||
import client.MapleCharacter;
|
||||
import client.SkillFactory;
|
||||
import client.command.CommandsExecutor;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.ItemFactory;
|
||||
import client.inventory.MaplePet;
|
||||
import client.inventory.manipulator.MapleCashidGenerator;
|
||||
import client.newyear.NewYearCardRecord;
|
||||
import constants.ItemConstants;
|
||||
@@ -838,33 +840,6 @@ public class Server {
|
||||
return rankSystem;
|
||||
}
|
||||
|
||||
private static void clearUnreferencedPetIds() {
|
||||
PreparedStatement ps = null;
|
||||
Connection con = null;
|
||||
try {
|
||||
con = DatabaseConnection.getConnection();
|
||||
|
||||
ps = con.prepareStatement("UPDATE inventoryitems SET petid = -1, expiration = 0 WHERE petid != -1 AND petid NOT IN (SELECT petid FROM pets)");
|
||||
ps.executeUpdate();
|
||||
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch(SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if(ps != null && !ps.isClosed()) {
|
||||
ps.close();
|
||||
}
|
||||
if(con != null && !con.isClosed()) {
|
||||
con.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void init() {
|
||||
Properties p = loadWorldINI();
|
||||
if(p == null) {
|
||||
@@ -897,7 +872,7 @@ public class Server {
|
||||
sqle.printStackTrace();
|
||||
}
|
||||
|
||||
clearUnreferencedPetIds();
|
||||
MaplePet.clearMissingPetsFromDb();
|
||||
MapleCashidGenerator.loadExistentCashIdsFromDb();
|
||||
|
||||
IoBuffer.setUseDirectBuffer(false);
|
||||
@@ -971,6 +946,7 @@ public class Server {
|
||||
|
||||
MapleSkillbookInformationProvider.getInstance();
|
||||
OpcodeConstants.generateOpcodeNames();
|
||||
CommandsExecutor.getInstance();
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
|
||||
@@ -65,6 +65,7 @@ public enum MonitoredLockType {
|
||||
PARTY,
|
||||
WORLD_PARTY,
|
||||
WORLD_PARTY_SEARCH_ECHELON,
|
||||
WORLD_PARTY_SEARCH_QUEUE,
|
||||
WORLD_PARTY_SEARCH_STORAGE,
|
||||
WORLD_SRVMESSAGES,
|
||||
WORLD_PETS,
|
||||
|
||||
@@ -35,10 +35,15 @@ public final class DenyPartyRequestHandler extends AbstractMaplePacketHandler {
|
||||
@Override
|
||||
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||
slea.readByte();
|
||||
MapleCharacter cfrom = c.getChannelServer().getPlayerStorage().getCharacterByName(slea.readMapleAsciiString());
|
||||
String[] cname = slea.readMapleAsciiString().split("PS: ");
|
||||
|
||||
MapleCharacter cfrom = c.getChannelServer().getPlayerStorage().getCharacterByName(cname[cname.length - 1]);
|
||||
if (cfrom != null) {
|
||||
if (MapleInviteCoordinator.answerInvite(InviteType.PARTY, c.getPlayer().getId(), cfrom.getPartyId(), false).getLeft() == InviteResult.DENIED) {
|
||||
cfrom.getClient().announce(MaplePacketCreator.partyStatusMessage(23, c.getPlayer().getName()));
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
|
||||
if (MapleInviteCoordinator.answerInvite(InviteType.PARTY, chr.getId(), cfrom.getPartyId(), false).getLeft() == InviteResult.DENIED) {
|
||||
chr.updatePartySearchAvailability(chr.getParty() == null);
|
||||
cfrom.getClient().announce(MaplePacketCreator.partyStatusMessage(23, chr.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ public class EnterCashShopHandler extends AbstractMaplePacketHandler {
|
||||
}
|
||||
|
||||
mc.closePlayerInteractions();
|
||||
mc.closePartySearchInteractions();
|
||||
|
||||
mc.unregisterChairBuff();
|
||||
Server.getInstance().getPlayerBuffStorage().addBuffsToStorage(mc.getId(), mc.getAllBuffs());
|
||||
|
||||
@@ -87,6 +87,7 @@ public final class EnterMTSHandler extends AbstractMaplePacketHandler {
|
||||
}
|
||||
|
||||
chr.closePlayerInteractions();
|
||||
chr.closePartySearchInteractions();
|
||||
|
||||
chr.unregisterChairBuff();
|
||||
Server.getInstance().getPlayerBuffStorage().addBuffsToStorage(chr.getId(), chr.getAllBuffs());
|
||||
|
||||
@@ -78,7 +78,8 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
|
||||
Set<MapleCharacter> eligibleMembers = new HashSet<>(MapleGuild.getEligiblePlayersForGuild(mc));
|
||||
if (eligibleMembers.size() < ServerConstants.CREATE_GUILD_MIN_PARTNERS) {
|
||||
if (mc.getMap().getAllPlayers().size() < ServerConstants.CREATE_GUILD_MIN_PARTNERS) {
|
||||
mc.dropMessage(1, "The Guild you are trying to create don't meet the minimum criteria of number of founders.");
|
||||
// thanks NovaStory for noticing message in need of smoother info
|
||||
mc.dropMessage(1, "Your Guild doesn't have enough cofounders present here and therefore cannot be created at this time.");
|
||||
} else {
|
||||
// players may be unaware of not belonging on a party in order to become eligible, thanks Hair (Legalize) for pointing this out
|
||||
mc.dropMessage(1, "Please make sure everyone you are trying to invite is neither on a guild nor on a party.");
|
||||
|
||||
@@ -56,6 +56,7 @@ public final class PartyOperationHandler extends AbstractMaplePacketHandler {
|
||||
List<MapleCharacter> partymembers = player.getPartyMembers();
|
||||
|
||||
MapleParty.leaveParty(party, c);
|
||||
player.updatePartySearchAvailability(true);
|
||||
player.partyOperationUpdate(party, partymembers);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -30,13 +30,7 @@ import client.MapleClient;
|
||||
* @author Quasar
|
||||
*/
|
||||
public class PartySearchRegisterHandler extends AbstractMaplePacketHandler {
|
||||
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||
return; //Disabling this for now.
|
||||
/* MapleCharacter chr = c.getPlayer();
|
||||
int min = slea.readInt();
|
||||
int max = slea.readInt();
|
||||
if (chr.getLevel() < min || chr.getLevel() > max || (max - min) > 30 || min > max) { // Client editing
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {}
|
||||
}
|
||||
@@ -21,108 +21,52 @@
|
||||
*/
|
||||
package net.server.channel.handlers;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.AbstractMaplePacketHandler;
|
||||
import net.server.world.MapleParty;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.MapleMapObject;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.data.input.SeekableLittleEndianAccessor;
|
||||
import tools.MaplePacketCreator;
|
||||
import client.MapleCharacter;
|
||||
import client.MapleClient;
|
||||
import client.MapleJob;
|
||||
import constants.ServerConstants;
|
||||
import net.server.world.MaplePartyCharacter;
|
||||
import net.server.world.PartyOperation;
|
||||
import net.server.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author XoticStory
|
||||
* @author BubblesDev
|
||||
* @author Ronan
|
||||
*/
|
||||
public class PartySearchStartHandler extends AbstractMaplePacketHandler {
|
||||
@Override
|
||||
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||
if(!ServerConstants.USE_PARTY_SEARCH){
|
||||
return;
|
||||
}
|
||||
|
||||
int min = slea.readInt();
|
||||
int max = slea.readInt();
|
||||
slea.readInt(); // members
|
||||
int jobs = slea.readInt();
|
||||
|
||||
MapleParty party = c.getPlayer().getParty();
|
||||
if(party == null) return;
|
||||
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
MapleMap map = chr.getMap();
|
||||
World world = c.getWorldServer();
|
||||
|
||||
Collection<MapleMapObject> mapobjs = map.getPlayers();
|
||||
|
||||
for (MapleMapObject mapobj : mapobjs) {
|
||||
if (party.getMembers().size() > 5) {
|
||||
break;
|
||||
}
|
||||
if (mapobj instanceof MapleCharacter) {
|
||||
MapleCharacter tchar = (MapleCharacter) mapobj;
|
||||
int charlvl = tchar.getLevel();
|
||||
if (charlvl >= min && charlvl <= max && isValidJob(tchar.getJob(), jobs)) {
|
||||
if (tchar.getParty() == null) {
|
||||
MaplePartyCharacter partyplayer = new MaplePartyCharacter(tchar);
|
||||
tchar.getMap().addPartyMember(tchar);
|
||||
int min = slea.readInt();
|
||||
int max = slea.readInt();
|
||||
|
||||
world.updateParty(party.getId(), PartyOperation.JOIN, partyplayer);
|
||||
tchar.receivePartyMemberHP();
|
||||
tchar.updatePartyMemberHP();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
if (min > max) {
|
||||
chr.dropMessage(1, "The min. value is higher than the max!");
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
private static boolean isValidJob(MapleJob thejob, int jobs) {
|
||||
int jobid = thejob.getId();
|
||||
if (jobid == 0) {
|
||||
return ((jobs & 2) > 0);
|
||||
} else if (jobid == 100) {
|
||||
return ((jobs & 4) > 0);
|
||||
} else if (jobid > 100 && jobid < 113) {
|
||||
return ((jobs & 8) > 0);
|
||||
} else if (jobid > 110 && jobid < 123) {
|
||||
return ((jobs & 16) > 0);
|
||||
} else if (jobid > 120 && jobid < 133) {
|
||||
return ((jobs & 32) > 0);
|
||||
} else if (jobid == 200) {
|
||||
return ((jobs & 64) > 0);
|
||||
} else if (jobid > 209 && jobid < 213) {
|
||||
return ((jobs & 128) > 0);
|
||||
} else if (jobid > 219 && jobid < 223) {
|
||||
return ((jobs & 256) > 0);
|
||||
} else if (jobid > 229 && jobid < 233) {
|
||||
return ((jobs & 512) > 0);
|
||||
} else if (jobid == 500) {
|
||||
return ((jobs & 1024) > 0);
|
||||
} else if (jobid > 509 && jobid < 513) {
|
||||
return ((jobs & 2048) > 0);
|
||||
} else if (jobid > 519 && jobid < 523) {
|
||||
return ((jobs & 4096) > 0);
|
||||
} else if (jobid == 400) {
|
||||
return ((jobs & 8192) > 0);
|
||||
} else if (jobid > 400 && jobid < 413) {
|
||||
return ((jobs & 16384) > 0);
|
||||
} else if (jobid > 419 && jobid < 423) {
|
||||
return ((jobs & 32768) > 0);
|
||||
} else if (jobid == 300) {
|
||||
return ((jobs & 65536) > 0);
|
||||
} else if (jobid > 300 && jobid < 313) {
|
||||
return ((jobs & 131072) > 0);
|
||||
} else if (jobid > 319 && jobid < 323) {
|
||||
return ((jobs & 262144) > 0);
|
||||
}
|
||||
return false;
|
||||
if (max - min > 30) {
|
||||
chr.dropMessage(1, "You can only search for party members within a range of 30 levels.");
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
if (chr.getLevel() < min || chr.getLevel() > max) {
|
||||
chr.dropMessage(1, "The range of level for search has to include your own level.");
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
slea.readInt(); // members
|
||||
int jobs = slea.readInt();
|
||||
|
||||
MapleParty party = c.getPlayer().getParty();
|
||||
if (party == null || !c.getPlayer().isPartyLeader()) return;
|
||||
|
||||
World world = c.getWorldServer();
|
||||
world.getPartySearchCoordinator().registerPartyLeader(chr, min, max, jobs);
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,10 @@ import client.MapleClient;
|
||||
import net.AbstractMaplePacketHandler;
|
||||
import tools.data.input.SeekableLittleEndianAccessor;
|
||||
|
||||
public final class PlayerUpdateHandler extends AbstractMaplePacketHandler {
|
||||
public final class PartySearchUpdateHandler extends AbstractMaplePacketHandler {
|
||||
|
||||
@Override
|
||||
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {}
|
||||
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||
c.getWorldServer().getPartySearchCoordinator().unregisterPartyLeader(c.getPlayer());
|
||||
}
|
||||
}
|
||||
@@ -608,6 +608,8 @@ public final class PlayerInteractionHandler extends AbstractMaplePacketHandler {
|
||||
MaplePlayerShop shop = chr.getPlayerShop();
|
||||
MapleHiredMerchant merchant = chr.getHiredMerchant();
|
||||
if (shop != null && shop.isOwner(chr)) {
|
||||
System.out.println(shopItem.getItem().getPet() + " " + shopItem.getItem().getPetId());
|
||||
System.out.println(ivItem.getPet() + " " + ivItem.getPetId());
|
||||
if (shop.isOpen() || !shop.addItem(shopItem)) { // thanks Vcoc for pointing an exploit with unlimited shop slots
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You can't sell it anymore."));
|
||||
return;
|
||||
|
||||
@@ -107,7 +107,7 @@ public final class TakeDamageHandler extends AbstractMaplePacketHandler {
|
||||
if (damage > 0) {
|
||||
loseItems = attacker.getStats().loseItem();
|
||||
if (loseItems != null) {
|
||||
if (chr.getBuffEffect(MapleBuffStat.ARIANT_PQ_SHIELD) == null) {
|
||||
if (chr.getBuffEffect(MapleBuffStat.AURA) == null) {
|
||||
MapleInventoryType type;
|
||||
final int playerpos = chr.getPosition().x;
|
||||
byte d = 1;
|
||||
|
||||
366
src/net/server/coordinator/MaplePartySearchCoordinator.java
Normal file
366
src/net/server/coordinator/MaplePartySearchCoordinator.java
Normal file
@@ -0,0 +1,366 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2018 RonanLana
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.server.coordinator;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleJob;
|
||||
import constants.ServerConstants;
|
||||
import java.io.File;
|
||||
import net.server.world.MapleParty;
|
||||
import net.server.coordinator.MapleInviteCoordinator.InviteType;
|
||||
import net.server.coordinator.partysearch.PartySearchEchelon;
|
||||
import net.server.coordinator.partysearch.PartySearchStorage;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.MonitoredReentrantReadWriteLock;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataProviderFactory;
|
||||
import provider.MapleDataTool;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class MaplePartySearchCoordinator {
|
||||
|
||||
private Map<MapleJob, PartySearchStorage> storage = new HashMap<>();
|
||||
private Map<MapleJob, PartySearchEchelon> upcomers = new HashMap<>();
|
||||
|
||||
private List<MapleCharacter> leaderQueue = new LinkedList<>();
|
||||
private final ReentrantReadWriteLock leaderQueueLock = new MonitoredReentrantReadWriteLock(MonitoredLockType.WORLD_PARTY_SEARCH_QUEUE, true);
|
||||
private final ReadLock leaderQueueRLock = leaderQueueLock.readLock();
|
||||
private final WriteLock leaderQueueWLock = leaderQueueLock.writeLock();
|
||||
|
||||
private Map<Integer, MapleCharacter> searchLeaders = new HashMap<>();
|
||||
private Map<Integer, LeaderSearchMetadata> searchSettings = new HashMap<>();
|
||||
|
||||
private static Map<Integer, Set<Integer>> mapNeighbors = fetchNeighbouringMaps();
|
||||
private static Map<Integer, MapleJob> jobTable = instantiateJobTable();
|
||||
|
||||
private static Map<Integer, Set<Integer>> fetchNeighbouringMaps() {
|
||||
Map<Integer, Set<Integer>> mapLinks = new HashMap<>();
|
||||
|
||||
MapleData data = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/" + "Etc.wz")).getData("MapNeighbors.img");
|
||||
if (data != null) {
|
||||
for (MapleData mapdata : data.getChildren()) {
|
||||
int mapid = Integer.valueOf(mapdata.getName());
|
||||
|
||||
Set<Integer> neighborMaps = new HashSet<>();
|
||||
mapLinks.put(mapid, neighborMaps);
|
||||
|
||||
for (MapleData neighbordata : mapdata.getChildren()) {
|
||||
int neighborid = MapleDataTool.getInt(neighbordata, 999999999);
|
||||
|
||||
if (neighborid != 999999999) {
|
||||
neighborMaps.add(neighborid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mapLinks;
|
||||
}
|
||||
|
||||
public static boolean isInVicinity(int callerMapid, int calleeMapid) {
|
||||
Set<Integer> vicinityMapids = mapNeighbors.get(calleeMapid);
|
||||
|
||||
if (vicinityMapids != null) {
|
||||
return vicinityMapids.contains(calleeMapid);
|
||||
} else {
|
||||
int callerRange = callerMapid / 10000000;
|
||||
if (callerRange >= 90) {
|
||||
return callerRange == (calleeMapid / 1000000);
|
||||
} else {
|
||||
return callerRange == (calleeMapid / 10000000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<Integer, MapleJob> instantiateJobTable() {
|
||||
Map<Integer, MapleJob> table = new HashMap<>();
|
||||
|
||||
List<Pair<Integer, Integer>> jobSearchTypes = new LinkedList<Pair<Integer, Integer>>() {{
|
||||
add(new Pair<>(MapleJob.MAPLELEAF_BRIGADIER.getId(), 0));
|
||||
add(new Pair<>(0, 0));
|
||||
add(new Pair<>(MapleJob.ARAN1.getId(), 0));
|
||||
add(new Pair<>(100, 3));
|
||||
add(new Pair<>(MapleJob.DAWNWARRIOR1.getId(), 0));
|
||||
add(new Pair<>(200, 3));
|
||||
add(new Pair<>(MapleJob.BLAZEWIZARD1.getId(), 0));
|
||||
add(new Pair<>(500, 2));
|
||||
add(new Pair<>(MapleJob.THUNDERBREAKER1.getId(), 0));
|
||||
add(new Pair<>(400, 2));
|
||||
add(new Pair<>(MapleJob.NIGHTWALKER1.getId(), 0));
|
||||
add(new Pair<>(300, 2));
|
||||
add(new Pair<>(MapleJob.WINDARCHER1.getId(), 0));
|
||||
add(new Pair<>(MapleJob.EVAN1.getId(), 0));
|
||||
}};
|
||||
|
||||
int i = 0;
|
||||
for (Pair<Integer, Integer> p : jobSearchTypes) {
|
||||
table.put(i, MapleJob.getById(p.getLeft()));
|
||||
i++;
|
||||
|
||||
for (int j = 1; j <= p.getRight(); j++) {
|
||||
table.put(i, MapleJob.getById(p.getLeft() + 10 * j));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
private class LeaderSearchMetadata {
|
||||
private int minLevel;
|
||||
private int maxLevel;
|
||||
private List<MapleJob> searchedJobs;
|
||||
|
||||
private int reentryCount;
|
||||
|
||||
private List<MapleJob> decodeSearchedJobs(int jobsSelected) {
|
||||
List<MapleJob> searchedJobs = new LinkedList<>();
|
||||
|
||||
int topByte = (int)((Math.log(jobsSelected) / Math.log(2)) + 1e-5);
|
||||
|
||||
for (int i = 0; i <= topByte; i++) {
|
||||
if (jobsSelected % 2 == 1) {
|
||||
MapleJob job = jobTable.get(i);
|
||||
if (job != null) {
|
||||
searchedJobs.add(job);
|
||||
}
|
||||
}
|
||||
|
||||
jobsSelected = jobsSelected >> 1;
|
||||
if (jobsSelected == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return searchedJobs;
|
||||
}
|
||||
|
||||
private LeaderSearchMetadata(int minLevel, int maxLevel, int jobs) {
|
||||
this.minLevel = minLevel;
|
||||
this.maxLevel = maxLevel;
|
||||
this.searchedJobs = decodeSearchedJobs(jobs);
|
||||
this.reentryCount = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MaplePartySearchCoordinator() {
|
||||
for (MapleJob job : jobTable.values()) {
|
||||
storage.put(job, new PartySearchStorage());
|
||||
upcomers.put(job, new PartySearchEchelon());
|
||||
}
|
||||
}
|
||||
|
||||
public void attachPlayer(MapleCharacter chr) {
|
||||
upcomers.get(getPartySearchJob(chr.getJob())).attachPlayer(chr);
|
||||
}
|
||||
|
||||
public void detachPlayer(MapleCharacter chr) {
|
||||
MapleJob psJob = getPartySearchJob(chr.getJob());
|
||||
|
||||
if (!upcomers.get(psJob).detachPlayer(chr)) {
|
||||
storage.get(psJob).detachPlayer(chr);
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePartySearchStorage() {
|
||||
for (Entry<MapleJob, PartySearchEchelon> psUpdate : upcomers.entrySet()) {
|
||||
storage.get(psUpdate.getKey()).updateStorage(psUpdate.getValue().exportEchelon());
|
||||
}
|
||||
}
|
||||
|
||||
private static MapleJob getPartySearchJob(MapleJob job) {
|
||||
if (job.getJobNiche() == 0) {
|
||||
return MapleJob.BEGINNER;
|
||||
} else if (job.getId() < 600) { // explorers
|
||||
return MapleJob.getById((job.getId() / 10) * 10);
|
||||
} else if (job.getId() >= 1000) {
|
||||
return MapleJob.getById((job.getId() / 100) * 100);
|
||||
} else {
|
||||
return MapleJob.MAPLELEAF_BRIGADIER;
|
||||
}
|
||||
}
|
||||
|
||||
private MapleCharacter fetchPlayer(int callerCid, int callerMapid, MapleJob job, int minLevel, int maxLevel) {
|
||||
return storage.get(getPartySearchJob(job)).callPlayer(callerCid, callerMapid, minLevel, maxLevel);
|
||||
}
|
||||
|
||||
private void addQueueLeader(MapleCharacter leader) {
|
||||
leaderQueueRLock.lock();
|
||||
try {
|
||||
leaderQueue.add(leader);
|
||||
} finally {
|
||||
leaderQueueRLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeQueueLeader(MapleCharacter leader) {
|
||||
leaderQueueRLock.lock();
|
||||
try {
|
||||
leaderQueue.remove(leader);
|
||||
} finally {
|
||||
leaderQueueRLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void registerPartyLeader(MapleCharacter leader, int minLevel, int maxLevel, int jobs) {
|
||||
if (searchLeaders.containsKey(leader.getId())) return;
|
||||
|
||||
searchSettings.put(leader.getId(), new LeaderSearchMetadata(minLevel, maxLevel, jobs));
|
||||
searchLeaders.put(leader.getId(), leader);
|
||||
addQueueLeader(leader);
|
||||
}
|
||||
|
||||
public void unregisterPartyLeader(MapleCharacter leader) {
|
||||
MapleCharacter toRemove = searchLeaders.remove(leader.getId());
|
||||
if (toRemove != null) {
|
||||
removeQueueLeader(toRemove);
|
||||
searchSettings.remove(leader.getId());
|
||||
}
|
||||
}
|
||||
|
||||
private MapleCharacter searchPlayer(MapleCharacter leader) {
|
||||
LeaderSearchMetadata settings = searchSettings.get(leader.getId());
|
||||
if (settings != null) {
|
||||
int minLevel = settings.minLevel, maxLevel = settings.maxLevel;
|
||||
Collections.shuffle(settings.searchedJobs);
|
||||
|
||||
int leaderCid = leader.getId();
|
||||
int leaderMapid = leader.getMapId();
|
||||
for (MapleJob searchJob : settings.searchedJobs) {
|
||||
MapleCharacter chr = fetchPlayer(leaderCid, leaderMapid, searchJob, minLevel, maxLevel);
|
||||
if (chr != null) {
|
||||
return chr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean sendPartyInviteFromSearch(MapleCharacter chr, MapleCharacter leader) {
|
||||
if (chr == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int partyid = leader.getPartyId();
|
||||
if (partyid < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (MapleInviteCoordinator.createInvite(InviteType.PARTY, leader, partyid, chr.getId())) {
|
||||
chr.disablePartySearchInvite(leader.getId());
|
||||
chr.announce(MaplePacketCreator.partySearchInvite(leader));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private Pair<List<MapleCharacter>, List<MapleCharacter>> fetchQueuedLeaders() {
|
||||
List<MapleCharacter> queuedLeaders, nextLeaders;
|
||||
|
||||
leaderQueueWLock.lock();
|
||||
try {
|
||||
int splitIdx = Math.min(leaderQueue.size(), 100);
|
||||
|
||||
queuedLeaders = new LinkedList<>(leaderQueue.subList(0, splitIdx));
|
||||
nextLeaders = new LinkedList<>(leaderQueue.subList(splitIdx, leaderQueue.size()));
|
||||
} finally {
|
||||
leaderQueueWLock.unlock();
|
||||
}
|
||||
|
||||
return new Pair<>(queuedLeaders, nextLeaders);
|
||||
}
|
||||
|
||||
public void runPartySearch() {
|
||||
Pair<List<MapleCharacter>, List<MapleCharacter>> queuedLeaders = fetchQueuedLeaders();
|
||||
|
||||
List<MapleCharacter> searchedLeaders = new LinkedList<>();
|
||||
List<MapleCharacter> recalledLeaders = new LinkedList<>();
|
||||
List<MapleCharacter> expiredLeaders = new LinkedList<>();
|
||||
|
||||
for (MapleCharacter leader : queuedLeaders.getLeft()) {
|
||||
MapleCharacter chr = searchPlayer(leader);
|
||||
if (sendPartyInviteFromSearch(chr, leader)) {
|
||||
searchedLeaders.add(leader);
|
||||
} else {
|
||||
LeaderSearchMetadata settings = searchSettings.get(leader.getId());
|
||||
if (settings != null) {
|
||||
if (settings.reentryCount < ServerConstants.PARTY_SEARCH_REENTRY_LIMIT) {
|
||||
settings.reentryCount += 1;
|
||||
recalledLeaders.add(leader);
|
||||
} else {
|
||||
expiredLeaders.add(leader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
leaderQueueRLock.lock();
|
||||
try {
|
||||
leaderQueue.clear();
|
||||
leaderQueue.addAll(queuedLeaders.getRight());
|
||||
|
||||
try {
|
||||
leaderQueue.addAll(25, recalledLeaders);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
leaderQueue.addAll(recalledLeaders);
|
||||
}
|
||||
} finally {
|
||||
leaderQueueRLock.unlock();
|
||||
}
|
||||
|
||||
for (MapleCharacter leader : searchedLeaders) {
|
||||
MapleParty party = leader.getParty();
|
||||
if (party != null && party.getMembers().size() < 6) {
|
||||
addQueueLeader(leader);
|
||||
} else {
|
||||
if (leader.isLoggedinWorld()) leader.dropMessage(5, "Your Party Search token session has finished as your party reached full capacity.");
|
||||
searchLeaders.remove(leader.getId());
|
||||
searchSettings.remove(leader.getId());
|
||||
}
|
||||
}
|
||||
|
||||
for (MapleCharacter leader : expiredLeaders) {
|
||||
if (leader.isLoggedinWorld()) leader.dropMessage(5, "Your Party Search token session expired, please stop your Party Search and retry again later.");
|
||||
searchLeaders.remove(leader.getId());
|
||||
searchSettings.remove(leader.getId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2018 RonanLana
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.server.coordinator.partysearch;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import net.server.coordinator.MaplePartySearchCoordinator;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class PartySearchCharacter {
|
||||
|
||||
private WeakReference<MapleCharacter> player;
|
||||
private int level;
|
||||
private boolean queued;
|
||||
|
||||
public PartySearchCharacter(MapleCharacter chr) {
|
||||
player = new WeakReference(chr);
|
||||
level = chr.getLevel();
|
||||
queued = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
MapleCharacter chr = player.get();
|
||||
return chr == null ? "[empty]" : chr.toString();
|
||||
}
|
||||
|
||||
public MapleCharacter callPlayer(int leaderid, int callerMapid) {
|
||||
MapleCharacter chr = player.get();
|
||||
if (chr == null || !MaplePartySearchCoordinator.isInVicinity(callerMapid, chr.getMapId())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (chr.hasDisabledPartySearchInvite(leaderid)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
queued = false;
|
||||
if (chr.isLoggedinWorld() && chr.getParty() == null) {
|
||||
return chr;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public MapleCharacter getPlayer() {
|
||||
return player.get();
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public boolean isQueued() {
|
||||
return queued;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2018 RonanLana
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.server.coordinator.partysearch;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.MonitoredReentrantReadWriteLock;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class PartySearchEchelon {
|
||||
|
||||
private final ReentrantReadWriteLock psLock = new MonitoredReentrantReadWriteLock(MonitoredLockType.WORLD_PARTY_SEARCH_ECHELON, true);
|
||||
private final ReadLock psRLock = psLock.readLock();
|
||||
private final WriteLock psWLock = psLock.writeLock();
|
||||
|
||||
private Map<Integer, WeakReference<MapleCharacter>> echelon = new HashMap<>(20);
|
||||
|
||||
public List<MapleCharacter> exportEchelon() {
|
||||
psWLock.lock(); // reversing read/write actually could provide a lax yet sure performance/precision trade-off here
|
||||
try {
|
||||
List<MapleCharacter> players = new ArrayList<>(echelon.size());
|
||||
|
||||
for (WeakReference<MapleCharacter> chrRef : echelon.values()) {
|
||||
MapleCharacter chr = chrRef.get();
|
||||
if (chr != null) {
|
||||
players.add(chr);
|
||||
}
|
||||
}
|
||||
|
||||
echelon.clear();
|
||||
return players;
|
||||
} finally {
|
||||
psWLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void attachPlayer(MapleCharacter chr) {
|
||||
psRLock.lock();
|
||||
try {
|
||||
echelon.put(chr.getId(), new WeakReference<>(chr));
|
||||
} finally {
|
||||
psRLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean detachPlayer(MapleCharacter chr) {
|
||||
psRLock.lock();
|
||||
try {
|
||||
return echelon.remove(chr.getId()) != null;
|
||||
} finally {
|
||||
psRLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
258
src/net/server/coordinator/partysearch/PartySearchStorage.java
Normal file
258
src/net/server/coordinator/partysearch/PartySearchStorage.java
Normal file
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2018 RonanLana
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.server.coordinator.partysearch;
|
||||
|
||||
import client.MapleCharacter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.MonitoredReentrantReadWriteLock;
|
||||
|
||||
import java.awt.geom.Line2D;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class PartySearchStorage {
|
||||
|
||||
private List<PartySearchCharacter> storage = new ArrayList<>(20);
|
||||
private PartySearchEmptyIntervals emptyManager = new PartySearchEmptyIntervals();
|
||||
|
||||
private class PartySearchEmptyIntervals {
|
||||
|
||||
private List<Line2D> emptyLimits = new ArrayList<>();
|
||||
|
||||
private void refitEmptyIntervals(int st, int en, int minLevel, int maxLevel) {
|
||||
List<Line2D> checkLimits = new ArrayList<>(emptyLimits.subList(st, en));
|
||||
|
||||
float newLimitX1, newLimitX2;
|
||||
if (!checkLimits.isEmpty()) {
|
||||
Line2D firstLimit = checkLimits.get(0);
|
||||
Line2D lastLimit = checkLimits.get(checkLimits.size() - 1);
|
||||
|
||||
newLimitX1 = (float) ((minLevel < firstLimit.getX1()) ? minLevel : firstLimit.getX1());
|
||||
newLimitX2 = (float) ((maxLevel > lastLimit.getX2()) ? maxLevel : lastLimit.getX2());
|
||||
|
||||
for (Line2D limit : checkLimits) {
|
||||
emptyLimits.remove(st);
|
||||
}
|
||||
} else {
|
||||
newLimitX1 = minLevel;
|
||||
newLimitX2 = maxLevel;
|
||||
}
|
||||
|
||||
emptyLimits.add(st, new Line2D.Float((float) newLimitX1, 0, (float) newLimitX2, 0));
|
||||
}
|
||||
|
||||
private int bsearchInterval(int level) {
|
||||
int st = 0, en = emptyLimits.size() - 1;
|
||||
|
||||
int mid, idx;
|
||||
while (en >= st) {
|
||||
idx = (st + en) / 2;
|
||||
mid = (int) emptyLimits.get(idx).getX1();
|
||||
|
||||
if (mid == level) {
|
||||
return idx;
|
||||
} else if (mid < level) {
|
||||
st = idx + 1;
|
||||
} else {
|
||||
en = idx - 1;
|
||||
}
|
||||
}
|
||||
|
||||
return en;
|
||||
}
|
||||
|
||||
public void addEmptyInterval(int fromLevel, int toLevel) {
|
||||
synchronized (emptyLimits) { // adding intervals occurs on a same-thread process, so this is actually not performance grinding
|
||||
int st = bsearchInterval(fromLevel);
|
||||
if (st < 0) {
|
||||
st = 0;
|
||||
} else if (emptyLimits.get(st).getX2() < fromLevel) {
|
||||
st += 1;
|
||||
}
|
||||
|
||||
int en = bsearchInterval(toLevel);
|
||||
if (en < st) en = st - 1;
|
||||
|
||||
refitEmptyIntervals(st, en + 1, fromLevel, toLevel);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInEmptyInterval(int minLevel, int maxLevel) {
|
||||
synchronized (emptyLimits) {
|
||||
int idx = bsearchInterval(minLevel);
|
||||
return idx >= 0 && maxLevel <= emptyLimits.get(idx).getX2();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearEmptyInterval() {
|
||||
synchronized (emptyLimits) {
|
||||
emptyLimits.clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final ReentrantReadWriteLock psLock = new MonitoredReentrantReadWriteLock(MonitoredLockType.WORLD_PARTY_SEARCH_STORAGE, true);
|
||||
private final ReadLock psRLock = psLock.readLock();
|
||||
private final WriteLock psWLock = psLock.writeLock();
|
||||
|
||||
public List<PartySearchCharacter> getStorageList() {
|
||||
psRLock.lock();
|
||||
try {
|
||||
return new ArrayList<>(storage);
|
||||
} finally {
|
||||
psRLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private Map<Integer, MapleCharacter> fetchRemainingPlayers() {
|
||||
List<PartySearchCharacter> players = getStorageList();
|
||||
Map<Integer, MapleCharacter> remainingPlayers = new HashMap<>(players.size());
|
||||
|
||||
for (PartySearchCharacter psc : players) {
|
||||
if (psc.isQueued()) {
|
||||
MapleCharacter chr = psc.getPlayer();
|
||||
if (chr != null) {
|
||||
remainingPlayers.put(chr.getId(), chr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return remainingPlayers;
|
||||
}
|
||||
|
||||
public void updateStorage(Collection<MapleCharacter> echelon) {
|
||||
Map<Integer, MapleCharacter> newcomers = new HashMap<>();
|
||||
for (MapleCharacter chr : echelon) {
|
||||
newcomers.put(chr.getId(), chr);
|
||||
}
|
||||
|
||||
Map<Integer, MapleCharacter> curStorage = fetchRemainingPlayers();
|
||||
curStorage.putAll(newcomers);
|
||||
|
||||
List<PartySearchCharacter> pscList = new ArrayList<>(curStorage.size());
|
||||
for (MapleCharacter chr : curStorage.values()) {
|
||||
pscList.add(new PartySearchCharacter(chr));
|
||||
}
|
||||
|
||||
Collections.sort(pscList, new Comparator<PartySearchCharacter>() {
|
||||
@Override
|
||||
public int compare(PartySearchCharacter c1, PartySearchCharacter c2)
|
||||
{
|
||||
int levelP1 = c1.getLevel(), levelP2 = c2.getLevel();
|
||||
return levelP1 > levelP2 ? 1 : (levelP1 == levelP2 ? 0 : -1);
|
||||
}
|
||||
});
|
||||
|
||||
psWLock.lock();
|
||||
try {
|
||||
storage.clear();
|
||||
storage.addAll(pscList);
|
||||
} finally {
|
||||
psWLock.unlock();
|
||||
}
|
||||
|
||||
emptyManager.clearEmptyInterval();
|
||||
}
|
||||
|
||||
private static int bsearchStorage(List<PartySearchCharacter> storage, int level) {
|
||||
int st = 0, en = storage.size() - 1;
|
||||
|
||||
int mid, idx;
|
||||
while (en >= st) {
|
||||
idx = (st + en) / 2;
|
||||
mid = storage.get(idx).getLevel();
|
||||
|
||||
if (mid == level) {
|
||||
return idx;
|
||||
} else if (mid < level) {
|
||||
st = idx + 1;
|
||||
} else {
|
||||
en = idx - 1;
|
||||
}
|
||||
}
|
||||
|
||||
return en;
|
||||
}
|
||||
|
||||
public MapleCharacter callPlayer(int callerCid, int callerMapid, int minLevel, int maxLevel) {
|
||||
if (emptyManager.isInEmptyInterval(minLevel, maxLevel)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<PartySearchCharacter> pscList = getStorageList();
|
||||
|
||||
int idx = bsearchStorage(pscList, maxLevel);
|
||||
for (int i = idx; i >= 0; i--) {
|
||||
PartySearchCharacter psc = pscList.get(i);
|
||||
if (!psc.isQueued()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (psc.getLevel() < minLevel) {
|
||||
break;
|
||||
}
|
||||
|
||||
MapleCharacter chr = psc.callPlayer(callerCid, callerMapid);
|
||||
if (chr != null) {
|
||||
return chr;
|
||||
}
|
||||
}
|
||||
|
||||
emptyManager.addEmptyInterval(minLevel, maxLevel);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void detachPlayer(MapleCharacter chr) {
|
||||
PartySearchCharacter toRemove = null;
|
||||
for (PartySearchCharacter psc : getStorageList()) {
|
||||
MapleCharacter player = psc.getPlayer();
|
||||
|
||||
if (player != null && player.getId() == chr.getId()) {
|
||||
toRemove = psc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (toRemove != null) {
|
||||
psWLock.lock();
|
||||
try {
|
||||
storage.remove(toRemove);
|
||||
} finally {
|
||||
psWLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
38
src/net/server/worker/PartySearchWorker.java
Normal file
38
src/net/server/worker/PartySearchWorker.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2018 RonanLana
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.server.worker;
|
||||
|
||||
import net.server.world.World;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class PartySearchWorker extends BaseWorker implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
wserv.runPartySearchUpdateSchedule();
|
||||
}
|
||||
|
||||
public PartySearchWorker(World world) {
|
||||
super(world);
|
||||
}
|
||||
}
|
||||
@@ -341,7 +341,8 @@ public class MapleParty {
|
||||
player.setMPC(partyplayer);
|
||||
player.getMap().addPartyMember(player);
|
||||
player.silentPartyUpdate();
|
||||
|
||||
|
||||
player.updatePartySearchAvailability(false);
|
||||
player.partyOperationUpdate(party, null);
|
||||
|
||||
player.announce(MaplePacketCreator.partyCreated(party, partyplayer.getId()));
|
||||
@@ -370,7 +371,9 @@ public class MapleParty {
|
||||
world.updateParty(party.getId(), PartyOperation.JOIN, partyplayer);
|
||||
player.receivePartyMemberHP();
|
||||
player.updatePartyMemberHP();
|
||||
|
||||
|
||||
player.resetPartySearchInvite(party.getLeaderId());
|
||||
player.updatePartySearchAvailability(false);
|
||||
player.partyOperationUpdate(party, null);
|
||||
return true;
|
||||
} else {
|
||||
@@ -466,7 +469,8 @@ public class MapleParty {
|
||||
|
||||
emc.setParty(null);
|
||||
world.updateParty(party.getId(), PartyOperation.EXPEL, expelled);
|
||||
|
||||
|
||||
emc.updatePartySearchAvailability(true);
|
||||
emc.partyOperationUpdate(party, partyMembers);
|
||||
} else {
|
||||
world.updateParty(party.getId(), PartyOperation.EXPEL, expelled);
|
||||
|
||||
@@ -70,6 +70,7 @@ import net.server.worker.FishingWorker;
|
||||
import net.server.worker.HiredMerchantWorker;
|
||||
import net.server.worker.MapOwnershipWorker;
|
||||
import net.server.worker.MountTirednessWorker;
|
||||
import net.server.worker.PartySearchWorker;
|
||||
import net.server.worker.PetFullnessWorker;
|
||||
import net.server.worker.ServerMessageWorker;
|
||||
import net.server.worker.TimedMapObjectWorker;
|
||||
@@ -94,6 +95,7 @@ import net.server.coordinator.MapleInviteCoordinator;
|
||||
import net.server.coordinator.MapleInviteCoordinator.InviteResult;
|
||||
import net.server.coordinator.MapleInviteCoordinator.InviteType;
|
||||
import net.server.coordinator.MapleMatchCheckerCoordinator;
|
||||
import net.server.coordinator.MaplePartySearchCoordinator;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -115,6 +117,7 @@ public class World {
|
||||
private Map<Integer, MapleGuildSummary> gsStore = new HashMap<>();
|
||||
private PlayerStorage players = new PlayerStorage();
|
||||
private MapleMatchCheckerCoordinator matchChecker = new MapleMatchCheckerCoordinator();
|
||||
private MaplePartySearchCoordinator partySearch = new MaplePartySearchCoordinator();
|
||||
|
||||
private final ReentrantReadWriteLock chnLock = new MonitoredReentrantReadWriteLock(MonitoredLockType.WORLD_CHANNELS, true);
|
||||
private ReadLock chnRLock = chnLock.readLock();
|
||||
@@ -170,6 +173,7 @@ public class World {
|
||||
private ScheduledFuture<?> marriagesSchedule;
|
||||
private ScheduledFuture<?> mapOwnershipSchedule;
|
||||
private ScheduledFuture<?> fishingSchedule;
|
||||
private ScheduledFuture<?> partySearchSchedule;
|
||||
|
||||
public World(int world, int flag, String eventmsg, int exprate, int droprate, int bossdroprate, int mesorate, int questrate, int travelrate, int fishingrate) {
|
||||
this.id = world;
|
||||
@@ -202,6 +206,7 @@ public class World {
|
||||
marriagesSchedule = tman.register(new WeddingReservationWorker(this), ServerConstants.WEDDING_RESERVATION_INTERVAL * 60 * 1000, ServerConstants.WEDDING_RESERVATION_INTERVAL * 60 * 1000);
|
||||
mapOwnershipSchedule = tman.register(new MapOwnershipWorker(this), 20 * 1000, 20 * 1000);
|
||||
fishingSchedule = tman.register(new FishingWorker(this), 10 * 1000, 10 * 1000);
|
||||
partySearchSchedule = tman.register(new PartySearchWorker(this), 10 * 1000, 10 * 1000);
|
||||
|
||||
}
|
||||
|
||||
@@ -494,6 +499,10 @@ public class World {
|
||||
public MapleMatchCheckerCoordinator getMatchCheckerCoordinator() {
|
||||
return matchChecker;
|
||||
}
|
||||
|
||||
public MaplePartySearchCoordinator getPartySearchCoordinator() {
|
||||
return partySearch;
|
||||
}
|
||||
|
||||
public void addPlayer(MapleCharacter chr) {
|
||||
players.addPlayer(chr);
|
||||
@@ -1975,6 +1984,11 @@ public class World {
|
||||
}
|
||||
}
|
||||
|
||||
public void runPartySearchUpdateSchedule() {
|
||||
partySearch.updatePartySearchStorage();
|
||||
partySearch.runPartySearch();
|
||||
}
|
||||
|
||||
private void clearWorldData() {
|
||||
List<MapleParty> pList;
|
||||
partyLock.lock();
|
||||
@@ -2061,6 +2075,11 @@ public class World {
|
||||
fishingSchedule = null;
|
||||
}
|
||||
|
||||
if(partySearchSchedule != null) {
|
||||
partySearchSchedule.cancel(false);
|
||||
partySearchSchedule = null;
|
||||
}
|
||||
|
||||
players.disconnectAll();
|
||||
players = null;
|
||||
|
||||
|
||||
@@ -146,7 +146,55 @@ public class MapleStatEffect {
|
||||
private Point lt, rb;
|
||||
private byte bulletCount, bulletConsume;
|
||||
private byte mapProtection;
|
||||
|
||||
private CardItemupStats cardStats;
|
||||
|
||||
private static class CardItemupStats {
|
||||
protected int itemCode, prob;
|
||||
private List<Pair<Integer, Integer>> areas;
|
||||
|
||||
private CardItemupStats(int code, int prob, List<Pair<Integer, Integer>> areas) {
|
||||
this.itemCode = code;
|
||||
this.prob = prob;
|
||||
this.areas = areas;
|
||||
}
|
||||
|
||||
private boolean isInArea(int mapid) {
|
||||
if (this.areas == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Pair<Integer, Integer> a : this.areas) {
|
||||
if (mapid >= a.left && mapid <= a.right) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isActive(int mapid) {
|
||||
return cardStats == null || cardStats.isInArea(mapid);
|
||||
}
|
||||
|
||||
public int getCardRate(int mapid, int itemid) {
|
||||
if (cardStats != null) {
|
||||
if (cardStats.itemCode == Integer.MAX_VALUE) {
|
||||
return cardStats.prob;
|
||||
} else if (cardStats.itemCode < 1000) {
|
||||
if (itemid / 10000 == cardStats.itemCode) {
|
||||
return cardStats.prob;
|
||||
}
|
||||
} else {
|
||||
if (itemid == cardStats.itemCode) {
|
||||
return cardStats.prob;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static MapleStatEffect loadSkillEffectFromData(MapleData source, int skillid, boolean overtime) {
|
||||
return loadFromData(source, skillid, true, overtime);
|
||||
}
|
||||
@@ -248,7 +296,7 @@ public class MapleStatEffect {
|
||||
ret.jump = (short) MapleDataTool.getInt("jump", source, 0);
|
||||
|
||||
ret.barrier = MapleDataTool.getInt("barrier", source, 0);
|
||||
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.ARIANT_PQ_SHIELD, ret.barrier);
|
||||
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.AURA, ret.barrier);
|
||||
|
||||
ret.mapProtection = mapProtection(sourceid);
|
||||
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.MAP_PROTECTION, Integer.valueOf(ret.mapProtection));
|
||||
@@ -303,6 +351,65 @@ public class MapleStatEffect {
|
||||
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.COUPON_DRP3, 1);
|
||||
break;
|
||||
}
|
||||
} else if (isMonsterCard(sourceid)) {
|
||||
int prob = 0, itemupCode = Integer.MAX_VALUE;
|
||||
List<Pair<Integer, Integer>> areas = null;
|
||||
|
||||
MapleData con = source.getChildByPath("con");
|
||||
if (con != null) {
|
||||
areas = new ArrayList<>(3);
|
||||
|
||||
for (MapleData conData : con.getChildren()) {
|
||||
int startMap = MapleDataTool.getInt("sMap", conData, 0);
|
||||
int endMap = MapleDataTool.getInt("eMap", conData, 0);
|
||||
|
||||
areas.add(new Pair<>(startMap, endMap));
|
||||
}
|
||||
}
|
||||
|
||||
if (MapleDataTool.getInt("mesoupbyitem", source, 0) != 0) {
|
||||
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.MESO_UP_BY_ITEM, 4);
|
||||
prob = MapleDataTool.getInt("prob", source, 1);
|
||||
}
|
||||
|
||||
int itemupType = MapleDataTool.getInt("itemupbyitem", source, 0);
|
||||
if (itemupType != 0) {
|
||||
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.ITEM_UP_BY_ITEM, 4);
|
||||
prob = MapleDataTool.getInt("prob", source, 1);
|
||||
|
||||
switch (itemupType) {
|
||||
case 2:
|
||||
itemupCode = MapleDataTool.getInt("itemCode", source, 1);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
itemupCode = MapleDataTool.getInt("itemRange", source, 1); // 3 digits
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (MapleDataTool.getInt("respectPimmune", source, 0) != 0) {
|
||||
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.RESPECT_PIMMUNE, 4);
|
||||
}
|
||||
|
||||
if (MapleDataTool.getInt("respectMimmune", source, 0) != 0) {
|
||||
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.RESPECT_MIMMUNE, 4);
|
||||
}
|
||||
|
||||
if (MapleDataTool.getString("defenseAtt", source, null) != null) {
|
||||
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.DEFENSE_ATT, 4);
|
||||
}
|
||||
|
||||
if (MapleDataTool.getString("defenseState", source, null) != null) {
|
||||
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.DEFENSE_STATE, 4);
|
||||
}
|
||||
|
||||
int thaw = MapleDataTool.getInt("thaw", source, 0);
|
||||
if (thaw != 0) {
|
||||
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.MAP_PROTECTION, thaw > 0 ? 1 : 2);
|
||||
}
|
||||
|
||||
ret.cardStats = new CardItemupStats(itemupCode, prob, areas);
|
||||
} else if (isExpIncrease(sourceid)) {
|
||||
addBuffStatPairToListIfNotZero(statups, MapleBuffStat.EXP_INCREASE, MapleDataTool.getInt("expinc", source, 0));
|
||||
}
|
||||
@@ -1139,7 +1246,7 @@ public class MapleStatEffect {
|
||||
target.announce(MaplePacketCreator.giveBuff((skill ? sourceid : -sourceid), (int) leftDuration, activeStats));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void applyBuffEffect(MapleCharacter applyfrom, MapleCharacter applyto, boolean primary) {
|
||||
if (!isMonsterRiding() && !isCouponBuff() && !isMysticDoor() && !isHyperBody() && !isCombo()) { // last mystic door already dispelled if it has been used before.
|
||||
applyto.cancelEffect(this, true, -1);
|
||||
@@ -1208,7 +1315,7 @@ public class MapleStatEffect {
|
||||
if (localstatups.size() > 0) {
|
||||
byte[] buff = null;
|
||||
byte[] mbuff = null;
|
||||
if (getSummonMovementType() == null) {
|
||||
if (getSummonMovementType() == null && this.isActive(applyto.getMapId())) {
|
||||
buff = MaplePacketCreator.giveBuff((skill ? sourceid : -sourceid), localDuration, localstatups);
|
||||
}
|
||||
if (isDash()) {
|
||||
@@ -1253,7 +1360,7 @@ public class MapleStatEffect {
|
||||
List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.MORPH, Integer.valueOf(getMorph(applyto))));
|
||||
mbuff = MaplePacketCreator.giveForeignBuff(applyto.getId(), stat);
|
||||
} else if (isAriantShield()) {
|
||||
List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.ARIANT_PQ_SHIELD, 1));
|
||||
List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.AURA, 1));
|
||||
mbuff = MaplePacketCreator.giveForeignBuff(applyto.getId(), stat);
|
||||
}
|
||||
|
||||
@@ -1495,6 +1602,11 @@ public class MapleStatEffect {
|
||||
public static boolean isAriantShield(int sourceid) {
|
||||
return sourceid == 2022269;
|
||||
}
|
||||
|
||||
public static boolean isMonsterCard(int sourceid) {
|
||||
int itemType = sourceid / 10000;
|
||||
return itemType == 238;
|
||||
}
|
||||
|
||||
private boolean isDs() {
|
||||
return skill && (sourceid == Rogue.DARK_SIGHT || sourceid == NightWalker.DARK_SIGHT);
|
||||
|
||||
@@ -475,7 +475,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
return takenDamage.containsKey(chr.getId());
|
||||
}
|
||||
|
||||
private void distributeExperienceToParty(int pid, float exp, int mostDamageCid, int minThresholdLevel, int killerLevel, Set<MapleCharacter> underleveled, Map<MapleCharacter, Float> partyExpReward) {
|
||||
private void distributeExperienceToParty(int pid, float exp, int mostDamageCid, int minThresholdLevel, int killerLevel, Set<MapleCharacter> underleveled, Map<MapleCharacter, Float> partyExpReward, Set<MapleCharacter> participants) {
|
||||
MapleCharacter pchar = getMap().getAnyCharacterFromParty(pid); // thanks G h o s t, Alfred, Vcoc, BHB for poiting out a bug in detecting party members after membership transactions in a party took place
|
||||
|
||||
List<MapleCharacter> members;
|
||||
@@ -486,7 +486,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
}
|
||||
|
||||
List<MapleCharacter> expSharers = new LinkedList<>();
|
||||
int expSharersMaxLevel = 1;
|
||||
int expParticipantsMaxLevel = 1;
|
||||
boolean hasMostDamageCid = false;
|
||||
for (MapleCharacter mc : members) {
|
||||
if (mc.getId() == mostDamageCid) {
|
||||
@@ -497,8 +497,8 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
if (Math.abs(killerLevel - mc.getLevel()) < ServerConstants.MIN_RANGELEVEL_TO_EXP_LEECH) {
|
||||
// thanks Thora for pointing out leech level limitation
|
||||
|
||||
if (expSharersMaxLevel < mc.getLevel()) {
|
||||
expSharersMaxLevel = mc.getLevel();
|
||||
if (expParticipantsMaxLevel < mc.getLevel() && participants.contains(mc)) {
|
||||
expParticipantsMaxLevel = mc.getLevel();
|
||||
}
|
||||
expSharers.add(mc);
|
||||
}
|
||||
@@ -509,14 +509,16 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
|
||||
int numExpSharers = expSharers.size();
|
||||
|
||||
// PARTY BONUS: 2p -> +2% , 3p -> +4% , 4p -> +6% , 5p -> +8% , 6p -> +10%
|
||||
// PARTY BONUS: 2p -> +5% , 3p -> +6.25% , 4p -> +7.5% , 5p -> +8.75% , 6p -> +10%
|
||||
// MOST DAMAGE BONUS: 1.5x bonus
|
||||
final float partyModifier = numExpSharers <= 1 ? 0.0f : 0.02f * (numExpSharers - 1);
|
||||
|
||||
// thanks Crypter for reporting an insufficiency on party exp bonuses
|
||||
final float partyModifier = numExpSharers <= 1 ? 0.0f : 0.05f + (0.0125f * (numExpSharers - 1));
|
||||
final float mostDamageModifier = hasMostDamageCid ? 1.5f : 1.0f;
|
||||
final float partyExp = exp * partyModifier * mostDamageModifier;
|
||||
|
||||
for (MapleCharacter mc : expSharers) {
|
||||
float levelPenaltyModifier = (float) Math.sqrt(((float) mc.getLevel()) / expSharersMaxLevel);
|
||||
float levelPenaltyModifier = (float) Math.min(1.0, Math.sqrt(((float) mc.getLevel()) / expParticipantsMaxLevel));
|
||||
partyExpReward.put(mc, partyExp * levelPenaltyModifier);
|
||||
}
|
||||
}
|
||||
@@ -640,9 +642,10 @@ public class MapleMonster extends AbstractLoadedMapleLife {
|
||||
}
|
||||
}
|
||||
|
||||
Set<MapleCharacter> participants = personalExpReward.keySet();
|
||||
int mostDamageCid = this.getHighestDamagerId();
|
||||
for (Entry<Integer, Float> party : partyExp.entrySet()) {
|
||||
distributeExperienceToParty(party.getKey(), party.getValue(), mostDamageCid, minThresholdLevel, killerLevel, underleveled, partyExpReward);
|
||||
distributeExperienceToParty(party.getKey(), party.getValue(), mostDamageCid, minThresholdLevel, killerLevel, underleveled, partyExpReward, participants);
|
||||
}
|
||||
|
||||
for(MapleCharacter mc : underleveled) {
|
||||
|
||||
@@ -239,6 +239,7 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
|
||||
}
|
||||
|
||||
private static boolean canBuy(MapleClient c, Item newItem) {
|
||||
System.out.println(newItem.getPet().getName());
|
||||
return MapleInventoryManipulator.checkSpace(c, newItem.getItemId(), newItem.getQuantity(), newItem.getOwner()) && MapleInventoryManipulator.addFromDrop(c, newItem, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -652,7 +652,8 @@ public class MapleMap {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
|
||||
for (final MonsterDropEntry de : dropEntry) {
|
||||
int dropChance = (int) Math.min((float) de.chance * chRate, Integer.MAX_VALUE);
|
||||
float cardRate = chr.getCardRate(de.itemId);
|
||||
int dropChance = (int) Math.min((float) de.chance * chRate * cardRate, Integer.MAX_VALUE);
|
||||
|
||||
if (Randomizer.nextInt(999999) < dropChance) {
|
||||
if (droptype == 3) {
|
||||
@@ -2481,7 +2482,9 @@ public class MapleMap {
|
||||
} finally {
|
||||
chrWLock.unlock();
|
||||
}
|
||||
|
||||
chr.setMapId(mapid);
|
||||
chr.updateActiveEffects();
|
||||
|
||||
if (chrSize == 1) {
|
||||
if(!hasItemMonitor()) {
|
||||
@@ -3305,11 +3308,10 @@ public class MapleMap {
|
||||
player.setPosition(newPosition);
|
||||
|
||||
try {
|
||||
Collection<MapleMapObject> visibleObjects = player.getVisibleMapObjects();
|
||||
MapleMapObject[] visibleObjectsNow = visibleObjects.toArray(new MapleMapObject[visibleObjects.size()]);
|
||||
MapleMapObject[] visibleObjects = player.getVisibleMapObjects();
|
||||
|
||||
Map<Integer, MapleMapObject> mapObjects = getCopyMapObjects();
|
||||
for (MapleMapObject mo : visibleObjectsNow) {
|
||||
for (MapleMapObject mo : visibleObjects) {
|
||||
if (mo != null) {
|
||||
if (mapObjects.get(mo.getObjectId()) == mo) {
|
||||
updateMapObjectVisibility(player, mo);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package server.partyquest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import client.MapleCharacter;
|
||||
import constants.LanguageConstants;
|
||||
@@ -10,9 +9,7 @@ import net.server.channel.Channel;
|
||||
import net.server.world.MapleParty;
|
||||
import net.server.world.MaplePartyCharacter;
|
||||
import server.TimerManager;
|
||||
import server.life.MapleMonster;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.MapleMapObject;
|
||||
import server.maps.MapleReactor;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
|
||||
@@ -1853,36 +1853,7 @@ public class MaplePacketCreator {
|
||||
return mplew.getPacket();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a packet spawning a player as a mapobject to other clients.
|
||||
*
|
||||
* @param target The client receiving this packet.
|
||||
* @param chr The character to spawn to other clients.
|
||||
* @param enteringField Whether the character to spawn is not yet present in the map or already is.
|
||||
* @return The spawn player packet.
|
||||
*/
|
||||
public static byte[] spawnPlayerMapObject(MapleClient target, MapleCharacter chr, boolean enteringField) {
|
||||
final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
||||
mplew.writeShort(SendOpcode.SPAWN_PLAYER.getValue());
|
||||
mplew.writeInt(chr.getId());
|
||||
mplew.write(chr.getLevel()); //v83
|
||||
mplew.writeMapleAsciiString(chr.getName());
|
||||
if (chr.getGuildId() < 1) {
|
||||
mplew.writeMapleAsciiString("");
|
||||
mplew.write(new byte[6]);
|
||||
} else {
|
||||
MapleGuildSummary gs = chr.getClient().getWorldServer().getGuildSummary(chr.getGuildId(), chr.getWorld());
|
||||
if (gs != null) {
|
||||
mplew.writeMapleAsciiString(gs.getName());
|
||||
mplew.writeShort(gs.getLogoBG());
|
||||
mplew.write(gs.getLogoBGColor());
|
||||
mplew.writeShort(gs.getLogo());
|
||||
mplew.write(gs.getLogoColor());
|
||||
} else {
|
||||
mplew.writeMapleAsciiString("");
|
||||
mplew.write(new byte[6]);
|
||||
}
|
||||
}
|
||||
private static void writeForeignBuffs(MaplePacketLittleEndianWriter mplew, MapleCharacter chr) {
|
||||
mplew.writeInt(0);
|
||||
mplew.writeShort(0); //v83
|
||||
mplew.write(0xFC);
|
||||
@@ -1962,6 +1933,40 @@ public class MaplePacketCreator {
|
||||
mplew.writeInt(CHAR_MAGIC_SPAWN);
|
||||
mplew.writeShort(0);
|
||||
mplew.write(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a packet spawning a player as a mapobject to other clients.
|
||||
*
|
||||
* @param target The client receiving this packet.
|
||||
* @param chr The character to spawn to other clients.
|
||||
* @param enteringField Whether the character to spawn is not yet present in the map or already is.
|
||||
* @return The spawn player packet.
|
||||
*/
|
||||
public static byte[] spawnPlayerMapObject(MapleClient target, MapleCharacter chr, boolean enteringField) {
|
||||
final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
||||
mplew.writeShort(SendOpcode.SPAWN_PLAYER.getValue());
|
||||
mplew.writeInt(chr.getId());
|
||||
mplew.write(chr.getLevel()); //v83
|
||||
mplew.writeMapleAsciiString(chr.getName());
|
||||
if (chr.getGuildId() < 1) {
|
||||
mplew.writeMapleAsciiString("");
|
||||
mplew.write(new byte[6]);
|
||||
} else {
|
||||
MapleGuildSummary gs = chr.getClient().getWorldServer().getGuildSummary(chr.getGuildId(), chr.getWorld());
|
||||
if (gs != null) {
|
||||
mplew.writeMapleAsciiString(gs.getName());
|
||||
mplew.writeShort(gs.getLogoBG());
|
||||
mplew.write(gs.getLogoBGColor());
|
||||
mplew.writeShort(gs.getLogo());
|
||||
mplew.write(gs.getLogoColor());
|
||||
} else {
|
||||
mplew.writeMapleAsciiString("");
|
||||
mplew.write(new byte[6]);
|
||||
}
|
||||
}
|
||||
|
||||
writeForeignBuffs(mplew, chr);
|
||||
|
||||
mplew.writeShort(chr.getJob().getId());
|
||||
|
||||
@@ -3807,6 +3812,16 @@ public class MaplePacketCreator {
|
||||
mplew.write(0);
|
||||
return mplew.getPacket();
|
||||
}
|
||||
|
||||
public static byte[] partySearchInvite(MapleCharacter from) {
|
||||
final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
||||
mplew.writeShort(SendOpcode.PARTY_OPERATION.getValue());
|
||||
mplew.write(4);
|
||||
mplew.writeInt(from.getParty().getId());
|
||||
mplew.writeMapleAsciiString("PS: " + from.getName());
|
||||
mplew.write(0);
|
||||
return mplew.getPacket();
|
||||
}
|
||||
|
||||
/**
|
||||
* 10: A beginner can't create a party. 1/5/6/11/14/19: Your request for a
|
||||
|
||||
Reference in New Issue
Block a user