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:
ronancpl
2019-05-16 02:14:54 -03:00
parent 397e16bb85
commit bb80441af0
120 changed files with 68917 additions and 383 deletions
+117 -5
View File
@@ -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);
+11 -8
View File
@@ -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) {
+1
View File
@@ -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);
}
+6 -4
View File
@@ -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;