Exp gain & Chaos scroll fix + Diet's MK Overhaul

Fixed issues with negative experience being distributed to characters
when killing a mob, rendering "Exp reset". Fixed chaos scroll behaving
oddly. Refactored debuff expirations to manage one list with registered
debuffs and expire times, thus lifting some load from the TimerManager.
Added concurrency protection on how World deals with parties. Thanks to
the DietStory dev team, fixed some issues with the MK maps.
This commit is contained in:
ronancpl
2017-10-04 02:35:52 -03:00
parent 6445f0b4e4
commit 3a882c7f31
141 changed files with 1719 additions and 524 deletions

View File

@@ -568,6 +568,223 @@ public class MapleItemInformationProvider {
return (short)Math.min(Short.MAX_VALUE, value);
}
private static short chscrollRandomizedStat() {
return (short) Randomizer.rand(-ServerConstants.CHSCROLL_STAT_RANGE, ServerConstants.CHSCROLL_STAT_RANGE);
}
private void scrollEquipWithChaos(Equip nEquip) {
if(ServerConstants.SCROLL_CHANCE_RATE > 0) {
int temp;
short curStr, curDex, curInt, curLuk, curWatk, curWdef, curMatk, curMdef, curAcc, curAvoid, curSpeed, curJump, curHp, curMp;
if(ServerConstants.USE_ENHANCED_CHSCROLL) {
curStr = nEquip.getStr();
curDex = nEquip.getDex();
curInt = nEquip.getInt();
curLuk = nEquip.getLuk();
curWatk = nEquip.getWatk();
curWdef = nEquip.getWdef();
curMatk = nEquip.getMatk();
curMdef = nEquip.getMdef();
curAcc = nEquip.getAcc();
curAvoid = nEquip.getAvoid();
curSpeed = nEquip.getSpeed();
curJump = nEquip.getJump();
curHp = nEquip.getHp();
curMp = nEquip.getMp();
} else {
curStr = Short.MIN_VALUE;
curDex = Short.MIN_VALUE;
curInt = Short.MIN_VALUE;
curLuk = Short.MIN_VALUE;
curWatk = Short.MIN_VALUE;
curWdef = Short.MIN_VALUE;
curMatk = Short.MIN_VALUE;
curMdef = Short.MIN_VALUE;
curAcc = Short.MIN_VALUE;
curAvoid = Short.MIN_VALUE;
curSpeed = Short.MIN_VALUE;
curJump = Short.MIN_VALUE;
curHp = Short.MIN_VALUE;
curMp = Short.MIN_VALUE;
}
for(int i = 0; i < ServerConstants.SCROLL_CHANCE_RATE; i++) {
if (nEquip.getStr() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) temp = curStr + chscrollRandomizedStat();
else temp = nEquip.getStr() + chscrollRandomizedStat();
curStr = getMaximumShortMaxIfOverflow(temp, curStr);
}
if (nEquip.getDex() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) temp = curDex + chscrollRandomizedStat();
else temp = nEquip.getDex() + chscrollRandomizedStat();
curDex = getMaximumShortMaxIfOverflow(temp, curDex);
}
if (nEquip.getInt() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) temp = curInt + chscrollRandomizedStat();
else temp = nEquip.getInt() + chscrollRandomizedStat();
curInt = getMaximumShortMaxIfOverflow(temp, curInt);
}
if (nEquip.getLuk() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) temp = curLuk + chscrollRandomizedStat();
else temp = nEquip.getLuk() + chscrollRandomizedStat();
curLuk = getMaximumShortMaxIfOverflow(temp, curLuk);
}
if (nEquip.getWatk() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) temp = curWatk + chscrollRandomizedStat();
else temp = nEquip.getWatk() + chscrollRandomizedStat();
curWatk = getMaximumShortMaxIfOverflow(temp, curWatk);
}
if (nEquip.getWdef() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) temp = curWdef + chscrollRandomizedStat();
else temp = nEquip.getWdef() + chscrollRandomizedStat();
curWdef = getMaximumShortMaxIfOverflow(temp, curWdef);
}
if (nEquip.getMatk() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) temp = curMatk + chscrollRandomizedStat();
else temp = nEquip.getMatk() + chscrollRandomizedStat();
curMatk = getMaximumShortMaxIfOverflow(temp, curMatk);
}
if (nEquip.getMdef() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) temp = curMdef + chscrollRandomizedStat();
else temp = nEquip.getMdef() + chscrollRandomizedStat();
curMdef = getMaximumShortMaxIfOverflow(temp, curMdef);
}
if (nEquip.getAcc() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) temp = curAcc + chscrollRandomizedStat();
else temp = nEquip.getAcc() + chscrollRandomizedStat();
curAcc = getMaximumShortMaxIfOverflow(temp, curAcc);
}
if (nEquip.getAvoid() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) temp = curAvoid + chscrollRandomizedStat();
else temp = nEquip.getAvoid() + chscrollRandomizedStat();
curAvoid = getMaximumShortMaxIfOverflow(temp, curAvoid);
}
if (nEquip.getSpeed() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) temp = curSpeed + chscrollRandomizedStat();
else temp = nEquip.getSpeed() + chscrollRandomizedStat();
curSpeed = getMaximumShortMaxIfOverflow(temp, curSpeed);
}
if (nEquip.getJump() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) temp = curJump + chscrollRandomizedStat();
else temp = nEquip.getJump() + chscrollRandomizedStat();
curJump = getMaximumShortMaxIfOverflow(temp, curJump);
}
if (nEquip.getHp() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) temp = curHp + chscrollRandomizedStat();
else temp = nEquip.getHp() + chscrollRandomizedStat();
curHp = getMaximumShortMaxIfOverflow(temp, curHp);
}
if (nEquip.getMp() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) temp = curMp + chscrollRandomizedStat();
else temp = nEquip.getMp() + chscrollRandomizedStat();
curMp = getMaximumShortMaxIfOverflow(temp, curMp);
}
}
nEquip.setStr((short) Math.max(0, curStr));
nEquip.setDex((short) Math.max(0, curDex));
nEquip.setInt((short) Math.max(0, curInt));
nEquip.setLuk((short) Math.max(0, curLuk));
nEquip.setWatk((short) Math.max(0, curWatk));
nEquip.setWdef((short) Math.max(0, curWdef));
nEquip.setMatk((short) Math.max(0, curMatk));
nEquip.setMdef((short) Math.max(0, curMdef));
nEquip.setAcc((short) Math.max(0, curAcc));
nEquip.setAvoid((short) Math.max(0, curAvoid));
nEquip.setSpeed((short) Math.max(0, curSpeed));
nEquip.setJump((short) Math.max(0, curJump));
nEquip.setHp((short) Math.max(0, curHp));
nEquip.setMp((short) Math.max(0, curMp));
}
else {
if (nEquip.getStr() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) nEquip.setStr(getMaximumShortMaxIfOverflow(nEquip.getStr(), (nEquip.getStr() + chscrollRandomizedStat())));
else nEquip.setStr(getMaximumShortMaxIfOverflow(0, (nEquip.getStr() + chscrollRandomizedStat())));
}
if (nEquip.getDex() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) nEquip.setDex(getMaximumShortMaxIfOverflow(nEquip.getDex(), (nEquip.getDex() + chscrollRandomizedStat())));
else nEquip.setDex(getMaximumShortMaxIfOverflow(0, (nEquip.getDex() + chscrollRandomizedStat())));
}
if (nEquip.getInt() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) nEquip.setInt(getMaximumShortMaxIfOverflow(nEquip.getInt(), (nEquip.getInt() + chscrollRandomizedStat())));
else nEquip.setInt(getMaximumShortMaxIfOverflow(0, (nEquip.getInt() + chscrollRandomizedStat())));
}
if (nEquip.getLuk() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) nEquip.setLuk(getMaximumShortMaxIfOverflow(nEquip.getLuk(), (nEquip.getLuk() + chscrollRandomizedStat())));
else nEquip.setLuk(getMaximumShortMaxIfOverflow(0, (nEquip.getLuk() + chscrollRandomizedStat())));
}
if (nEquip.getWatk() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) nEquip.setWatk(getMaximumShortMaxIfOverflow(nEquip.getWatk(), (nEquip.getWatk() + chscrollRandomizedStat())));
else nEquip.setWatk(getMaximumShortMaxIfOverflow(0, (nEquip.getWatk() + chscrollRandomizedStat())));
}
if (nEquip.getWdef() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) nEquip.setWdef(getMaximumShortMaxIfOverflow(nEquip.getWdef(), (nEquip.getWdef() + chscrollRandomizedStat())));
else nEquip.setWdef(getMaximumShortMaxIfOverflow(0, (nEquip.getWdef() + chscrollRandomizedStat())));
}
if (nEquip.getMatk() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) nEquip.setMatk(getMaximumShortMaxIfOverflow(nEquip.getMatk(), (nEquip.getMatk() + chscrollRandomizedStat())));
else nEquip.setMatk(getMaximumShortMaxIfOverflow(0, (nEquip.getMatk() + chscrollRandomizedStat())));
}
if (nEquip.getMdef() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) nEquip.setMdef(getMaximumShortMaxIfOverflow(nEquip.getMdef(), (nEquip.getMdef() + chscrollRandomizedStat())));
else nEquip.setMdef(getMaximumShortMaxIfOverflow(0, (nEquip.getMdef() + chscrollRandomizedStat())));
}
if (nEquip.getAcc() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) nEquip.setAcc(getMaximumShortMaxIfOverflow(nEquip.getAcc(), (nEquip.getAcc() + chscrollRandomizedStat())));
else nEquip.setAcc(getMaximumShortMaxIfOverflow(0, (nEquip.getAcc() + chscrollRandomizedStat())));
}
if (nEquip.getAvoid() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) nEquip.setAvoid(getMaximumShortMaxIfOverflow(nEquip.getAvoid(), (nEquip.getAvoid() + chscrollRandomizedStat())));
else nEquip.setAvoid(getMaximumShortMaxIfOverflow(0, (nEquip.getAvoid() + chscrollRandomizedStat())));
}
if (nEquip.getSpeed() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) nEquip.setSpeed(getMaximumShortMaxIfOverflow(nEquip.getSpeed(), (nEquip.getSpeed() + chscrollRandomizedStat())));
else nEquip.setSpeed(getMaximumShortMaxIfOverflow(0, (nEquip.getSpeed() + chscrollRandomizedStat())));
}
if (nEquip.getJump() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) nEquip.setJump(getMaximumShortMaxIfOverflow(nEquip.getJump(), (nEquip.getJump() + chscrollRandomizedStat())));
else nEquip.setJump(getMaximumShortMaxIfOverflow(0, (nEquip.getJump() + chscrollRandomizedStat())));
}
if (nEquip.getHp() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) nEquip.setHp(getMaximumShortMaxIfOverflow(nEquip.getHp(), (nEquip.getHp() + chscrollRandomizedStat())));
else nEquip.setHp(getMaximumShortMaxIfOverflow(0, (nEquip.getHp() + chscrollRandomizedStat())));
}
if (nEquip.getMp() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL) nEquip.setMp(getMaximumShortMaxIfOverflow(nEquip.getMp(), (nEquip.getMp() + chscrollRandomizedStat())));
else nEquip.setMp(getMaximumShortMaxIfOverflow(0, (nEquip.getMp() + chscrollRandomizedStat())));
}
}
}
public Item scrollEquipWithId(Item equip, int scrollId, boolean usingWhiteScroll, int vegaItemId, boolean isGM) {
boolean assertGM = (isGM && ServerConstants.USE_PERFECT_GM_SCROLL);
@@ -607,256 +824,7 @@ public class MapleItemInformationProvider {
case 2049100:
case 2049101:
case 2049102:
int inc, i;
if(ServerConstants.SCROLL_CHANCE_RATE > 0) {
//int tempStr, tempDex, tempInt, tempLuk, tempWatk, tempWdef, tempMatk, tempMdef, tempAcc, tempAvoid, tempSpeed, tempJump, tempHp, tempMp;
int temp;
int mdStr = nEquip.getStr(), mdDex = nEquip.getDex(), mdInt = nEquip.getInt(), mdLuk = nEquip.getLuk(), mdWatk = nEquip.getWatk(), mdWdef = nEquip.getWdef(), mdMatk = nEquip.getMatk(), mdMdef = nEquip.getMdef(), mdAcc = nEquip.getAcc(), mdAvoid = nEquip.getAvoid(), mdSpeed = nEquip.getSpeed(), mdJump = nEquip.getJump(), mdHp = nEquip.getHp(), mdMp = nEquip.getMp();
inc = 1;
if (Randomizer.nextInt(2) == 0) {
inc = -1;
}
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) inc = 1;
for(i = 0; i < ServerConstants.SCROLL_CHANCE_RATE; i++) {
if (nEquip.getStr() > 0) {
temp = (nEquip.getStr() + Randomizer.nextInt(6) * inc);
nEquip.setStr(getMaximumShortMaxIfOverflow(mdStr, temp));
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
mdStr = nEquip.getStr();
}
else {
temp = (mdStr + temp) / 2;
if(temp > mdStr) mdStr = temp;
}
}
if (nEquip.getDex() > 0) {
temp = (nEquip.getDex() + Randomizer.nextInt(6) * inc);
nEquip.setDex(getMaximumShortMaxIfOverflow(mdDex, temp));
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
mdDex = nEquip.getDex();
}
else {
temp = (mdDex + temp) / 2;
if(temp > mdDex) mdDex = temp;
}
}
if (nEquip.getInt() > 0) {
temp = (nEquip.getInt() + Randomizer.nextInt(6) * inc);
nEquip.setInt(getMaximumShortMaxIfOverflow(mdInt, temp));
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
mdInt = nEquip.getInt();
}
else {
temp = (mdInt + temp) / 2;
if(temp > mdInt) mdInt = temp;
}
}
if (nEquip.getLuk() > 0) {
temp = (nEquip.getLuk() + Randomizer.nextInt(6) * inc);
nEquip.setLuk(getMaximumShortMaxIfOverflow(mdLuk, temp));
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
mdLuk = nEquip.getLuk();
}
else {
temp = (mdLuk + temp) / 2;
if(temp > mdLuk) mdLuk = temp;
}
}
if (nEquip.getWatk() > 0) {
temp = (nEquip.getWatk() + Randomizer.nextInt(6) * inc);
nEquip.setWatk(getMaximumShortMaxIfOverflow(mdWatk, temp));
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
mdWatk = nEquip.getWatk();
}
else {
temp = (mdWatk + temp) / 2;
if(temp > mdWatk) mdWatk = temp;
}
}
if (nEquip.getWdef() > 0) {
temp = (nEquip.getWdef() + Randomizer.nextInt(6) * inc);
nEquip.setWdef(getMaximumShortMaxIfOverflow(mdWdef, temp));
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
mdWdef = nEquip.getWdef();
}
else {
temp = (mdWdef + temp) / 2;
if(temp > mdWdef) mdWdef = temp;
}
}
if (nEquip.getMatk() > 0) {
temp = (nEquip.getMatk() + Randomizer.nextInt(6) * inc);
nEquip.setMatk(getMaximumShortMaxIfOverflow(mdMatk, temp));
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
mdMatk = nEquip.getMatk();
}
else {
temp = (mdMatk + temp) / 2;
if(temp > mdMatk) mdMatk = temp;
}
}
if (nEquip.getMdef() > 0) {
temp = (nEquip.getMdef() + Randomizer.nextInt(6) * inc);
nEquip.setMdef(getMaximumShortMaxIfOverflow(mdMdef, temp));
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
mdMdef = nEquip.getMdef();
}
else {
temp = (mdMdef + temp) / 2;
if(temp > mdMdef) mdMdef = temp;
}
}
if (nEquip.getAcc() > 0) {
temp = (nEquip.getAcc() + Randomizer.nextInt(6) * inc);
nEquip.setAcc(getMaximumShortMaxIfOverflow(mdAcc, temp));
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
mdAcc = nEquip.getAcc();
}
else {
temp = (mdAcc + temp) / 2;
if(temp > mdAcc) mdAcc = temp;
}
}
if (nEquip.getAvoid() > 0) {
temp = (nEquip.getAvoid() + Randomizer.nextInt(6) * inc);
nEquip.setAvoid(getMaximumShortMaxIfOverflow(mdAvoid, temp));
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
mdAvoid = nEquip.getAvoid();
}
else {
temp = (mdAvoid + temp) / 2;
if(temp > mdAvoid) mdAvoid = temp;
}
}
if (nEquip.getSpeed() > 0) {
temp = (nEquip.getSpeed() + Randomizer.nextInt(6) * inc);
nEquip.setSpeed(getMaximumShortMaxIfOverflow(mdSpeed, temp));
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
mdSpeed = nEquip.getSpeed();
}
else {
temp = (mdSpeed + temp) / 2;
if(temp > mdSpeed) mdSpeed = temp;
}
}
if (nEquip.getJump() > 0) {
temp = (nEquip.getJump() + Randomizer.nextInt(6) * inc);
nEquip.setJump(getMaximumShortMaxIfOverflow(mdJump, temp));
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
mdJump = nEquip.getJump();
}
else {
temp = (mdJump + temp) / 2;
if(temp > mdJump) mdJump = temp;
}
}
if (nEquip.getHp() > 0) {
temp = (nEquip.getHp() + Randomizer.nextInt(6) * inc);
nEquip.setHp(getMaximumShortMaxIfOverflow(mdHp, temp));
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
mdHp = nEquip.getHp();
}
else {
temp = (mdHp + temp) / 2;
if(temp > mdHp) mdHp = temp;
}
}
if (nEquip.getMp() > 0) {
temp = (nEquip.getMp() + Randomizer.nextInt(6) * inc);
nEquip.setMp(getMaximumShortMaxIfOverflow(mdMp, temp));
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
mdMp = nEquip.getMp();
}
else {
temp = (mdMp + temp) / 2;
if(temp > mdMp) mdMp = temp;
}
}
}
}
else {
inc = 1;
if (Randomizer.nextInt(2) == 0) {
inc = -1;
}
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) inc = 1;
if (nEquip.getStr() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setStr(getMaximumShortMaxIfOverflow(nEquip.getStr(), (nEquip.getStr() + Randomizer.nextInt(6) * inc)));
else nEquip.setStr(getMaximumShortMaxIfOverflow(0, (nEquip.getStr() + Randomizer.nextInt(6) * inc)));
}
if (nEquip.getDex() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setDex(getMaximumShortMaxIfOverflow(nEquip.getDex(), (nEquip.getDex() + Randomizer.nextInt(6) * inc)));
else nEquip.setDex(getMaximumShortMaxIfOverflow(0, (nEquip.getDex() + Randomizer.nextInt(6) * inc)));
}
if (nEquip.getInt() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setInt(getMaximumShortMaxIfOverflow(nEquip.getInt(), (nEquip.getInt() + Randomizer.nextInt(6) * inc)));
else nEquip.setInt(getMaximumShortMaxIfOverflow(0, (nEquip.getInt() + Randomizer.nextInt(6) * inc)));
}
if (nEquip.getLuk() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setLuk(getMaximumShortMaxIfOverflow(nEquip.getLuk(), (nEquip.getLuk() + Randomizer.nextInt(6) * inc)));
else nEquip.setLuk(getMaximumShortMaxIfOverflow(0, (nEquip.getLuk() + Randomizer.nextInt(6) * inc)));
}
if (nEquip.getWatk() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setWatk(getMaximumShortMaxIfOverflow(nEquip.getWatk(), (nEquip.getWatk() + Randomizer.nextInt(6) * inc)));
else nEquip.setWatk(getMaximumShortMaxIfOverflow(0, (nEquip.getWatk() + Randomizer.nextInt(6) * inc)));
}
if (nEquip.getWdef() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setWdef(getMaximumShortMaxIfOverflow(nEquip.getWdef(), (nEquip.getWdef() + Randomizer.nextInt(6) * inc)));
else nEquip.setWdef(getMaximumShortMaxIfOverflow(0, (nEquip.getWdef() + Randomizer.nextInt(6) * inc)));
}
if (nEquip.getMatk() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setMatk(getMaximumShortMaxIfOverflow(nEquip.getMatk(), (nEquip.getMatk() + Randomizer.nextInt(6) * inc)));
else nEquip.setMatk(getMaximumShortMaxIfOverflow(0, (nEquip.getMatk() + Randomizer.nextInt(6) * inc)));
}
if (nEquip.getMdef() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setMdef(getMaximumShortMaxIfOverflow(nEquip.getMdef(), (nEquip.getMdef() + Randomizer.nextInt(6) * inc)));
else nEquip.setMdef(getMaximumShortMaxIfOverflow(0, (nEquip.getMdef() + Randomizer.nextInt(6) * inc)));
}
if (nEquip.getAcc() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setAcc(getMaximumShortMaxIfOverflow(nEquip.getAcc(), (nEquip.getAcc() + Randomizer.nextInt(6) * inc)));
else nEquip.setAcc(getMaximumShortMaxIfOverflow(0, (nEquip.getAcc() + Randomizer.nextInt(6) * inc)));
}
if (nEquip.getAvoid() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setAvoid(getMaximumShortMaxIfOverflow(nEquip.getAvoid(), (nEquip.getAvoid() + Randomizer.nextInt(6) * inc)));
else nEquip.setAvoid(getMaximumShortMaxIfOverflow(0, (nEquip.getAvoid() + Randomizer.nextInt(6) * inc)));
}
if (nEquip.getSpeed() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setSpeed(getMaximumShortMaxIfOverflow(nEquip.getSpeed(), (nEquip.getSpeed() + Randomizer.nextInt(6) * inc)));
else nEquip.setSpeed(getMaximumShortMaxIfOverflow(0, (nEquip.getSpeed() + Randomizer.nextInt(6) * inc)));
}
if (nEquip.getJump() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setJump(getMaximumShortMaxIfOverflow(nEquip.getJump(), (nEquip.getJump() + Randomizer.nextInt(6) * inc)));
else nEquip.setJump(getMaximumShortMaxIfOverflow(0, (nEquip.getJump() + Randomizer.nextInt(6) * inc)));
}
if (nEquip.getHp() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setHp(getMaximumShortMaxIfOverflow(nEquip.getHp(), (nEquip.getHp() + Randomizer.nextInt(6) * inc)));
else nEquip.setHp(getMaximumShortMaxIfOverflow(0, (nEquip.getHp() + Randomizer.nextInt(6) * inc)));
}
if (nEquip.getMp() > 0) {
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setMp(getMaximumShortMaxIfOverflow(nEquip.getMp(), (nEquip.getMp() + Randomizer.nextInt(6) * inc)));
else nEquip.setMp(getMaximumShortMaxIfOverflow(0, (nEquip.getMp() + Randomizer.nextInt(6) * inc)));
}
}
scrollEquipWithChaos(nEquip);
break;
default:
@@ -911,13 +879,13 @@ public class MapleItemInformationProvider {
break;
}
if (!ItemConstants.isCleanSlate(scrollId)) {
if (ServerConstants.USE_PERFECT_SCROLLING == true && !assertGM && !usingWhiteScroll) {
if (!assertGM && !usingWhiteScroll) {
nEquip.setUpgradeSlots((byte) (nEquip.getUpgradeSlots() - 1));
}
nEquip.setLevel((byte) (nEquip.getLevel() + 1));
}
} else {
if (ServerConstants.USE_PERFECT_SCROLLING == false && !usingWhiteScroll && !ItemConstants.isCleanSlate(scrollId) && !assertGM) {
} else {
if (!ServerConstants.USE_PERFECT_SCROLLING && !usingWhiteScroll && !ItemConstants.isCleanSlate(scrollId) && !assertGM) {
nEquip.setUpgradeSlots((byte) (nEquip.getUpgradeSlots() - 1));
}
if (Randomizer.nextInt(101) < stats.get("cursed")) {

View File

@@ -48,6 +48,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import net.server.world.MapleParty;
@@ -257,26 +258,33 @@ public class MapleMonster extends AbstractLoadedMapleLife {
}
private void distributeExperienceToParty(int pid, int exp, int killer, Map<Integer, Integer> expDist) {
LinkedList<MapleCharacter> members = new LinkedList<>();
Collection<MapleCharacter> chrs = map.getCharacters();
for (MapleCharacter mc : chrs) {
if (mc.getPartyId() == pid) {
members.add(mc);
}
List<MapleCharacter> members = new LinkedList<>();
MapleCharacter pchar = getMap().getAnyCharacterFromParty(pid);
if(pchar != null) {
for(MapleCharacter chr : pchar.getPartyMembersOnSameMap()) {
members.add(chr);
}
} else {
MapleCharacter chr = getMap().getCharacterById(killer);
if(chr == null) return;
members.add(chr);
}
final int minLevel = getLevel() - 5;
int partyLevel = 0;
int leechMinLevel = 0;
for (MapleCharacter mc : members) {
if (mc.getLevel() >= minLevel) {
leechMinLevel = Math.min(mc.getLevel() - 5, minLevel);
if(!ServerConstants.USE_UNDERLEVELED_EXP_GAIN) { //NO EXP WILL BE GIVEN for those who are underleveled!
leechMinLevel = minLevel;
for (MapleCharacter mc : members) {
if (mc.getLevel() >= minLevel) {
leechMinLevel = Math.min(mc.getLevel() - 5, leechMinLevel);
}
}
}
int leechCount = 0;
for (MapleCharacter mc : members) {
if (mc.getLevel() >= leechMinLevel) {
@@ -290,13 +298,12 @@ public class MapleMonster extends AbstractLoadedMapleLife {
for (MapleCharacter mc : members) {
int id = mc.getId();
int level = mc.getLevel();
if (expDist.containsKey(id)
|| level >= leechMinLevel) {
if (expDist.containsKey(id) || level >= leechMinLevel) {
boolean isKiller = killer == id;
boolean mostDamage = mostDamageCid == id;
int xp = (int) (exp * 0.80f * level / partyLevel);
int xp = (int) ((0.80f * exp * level) / partyLevel);
if (mostDamage) {
xp += (exp * 0.20f);
xp += (0.20f * exp);
}
giveExpToCharacter(mc, xp, isKiller, leechCount);
}
@@ -311,26 +318,32 @@ public class MapleMonster extends AbstractLoadedMapleLife {
int totalHealth = getMaxHp();
Map<Integer, Integer> expDist = new HashMap<>();
Map<Integer, Integer> partyExp = new HashMap<>();
// 80% of pool is split amongst all the damagers
float exp8 = (0.8f * exp); // 80% of pool is split amongst all the damagers
float exp2 = (0.2f * exp); // 20% of pool goes to the killer or his/her party
for (Entry<Integer, AtomicInteger> damage : takenDamage.entrySet()) {
expDist.put(damage.getKey(), (int) (0.80f * exp * damage.getValue().get() / totalHealth));
expDist.put(damage.getKey(), (int) (Math.min((exp8 * damage.getValue().get()) / totalHealth, Integer.MAX_VALUE)));
}
Collection<MapleCharacter> chrs = map.getCharacters();
for (MapleCharacter mc : chrs) {
if (expDist.containsKey(mc.getId())) {
boolean isKiller = mc.getId() == killerId;
boolean isKiller = (mc.getId() == killerId);
int xp = expDist.get(mc.getId());
if (isKiller) {
xp += exp / 5;
xp = (int)Math.min(exp2 + xp, Integer.MAX_VALUE);
}
MapleParty p = mc.getParty();
if (p != null) {
int pID = p.getId();
int pXP = xp + (partyExp.containsKey(pID) ? partyExp.get(pID) : 0);
partyExp.put(pID, pXP);
long pXP = (long)xp + (partyExp.containsKey(pID) ? partyExp.get(pID) : 0);
partyExp.put(pID, (int)Math.min(pXP, Integer.MAX_VALUE));
} else {
giveExpToCharacter(mc, xp, isKiller, 1);
if(ServerConstants.USE_UNDERLEVELED_EXP_GAIN || mc.getLevel() >= this.getLevel() - 5) {
//NO EXP WILL BE GIVEN for those who are underleveled!
giveExpToCharacter(mc, xp, isKiller, 1);
}
}
}
}

View File

@@ -43,6 +43,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.LinkedList;
import java.util.List;
import java.util.Iterator;
@@ -93,6 +94,7 @@ public class MapleMap {
private AtomicInteger spawnedMonstersOnMap = new AtomicInteger(0);
private AtomicInteger droppedItemCount = new AtomicInteger(0);
private Collection<MapleCharacter> characters = new LinkedHashSet<>();
private Map<Integer, Set<Integer>> mapParty = new LinkedHashMap<>();
private Map<Integer, MaplePortal> portals = new HashMap<>();
private Map<Integer, Integer> backgroundTypes = new HashMap<>();
private Map<String, Integer> environment = new LinkedHashMap<>();
@@ -133,6 +135,7 @@ public class MapleMap {
private short mobInterval = 5000;
private boolean allowSummons = true; // All maps should have this true at the beginning
private int lastDoorOwner = -1;
// HPQ
private int riceCakes = 0;
private int bunnyDamage = 0;
@@ -1781,10 +1784,84 @@ public class MapleMap {
}, time);
}
public MapleCharacter getAnyCharacterFromParty(int partyid) {
chrRLock.lock();
try {
Set<Integer> list = mapParty.get(partyid);
if(list == null) return null;
for(Integer cid : list) {
for (MapleCharacter c : this.characters) {
if (c.getId() == cid) {
return c;
}
}
}
return null;
} finally {
chrRLock.unlock();
}
}
private void addPartyMemberInternal(MapleCharacter chr) {
int partyid = chr.getPartyId();
if(partyid == -1) return;
Set<Integer> partyEntry = mapParty.get(partyid);
if(partyEntry == null) {
partyEntry = new LinkedHashSet<>();
partyEntry.add(chr.getId());
mapParty.put(partyid, partyEntry);
} else {
partyEntry.add(chr.getId());
}
}
private void removePartyMemberInternal(MapleCharacter chr) {
int partyid = chr.getPartyId();
if(partyid == -1) return;
Set<Integer> partyEntry = mapParty.get(partyid);
if(partyEntry != null) {
if(partyEntry.size() > 1) partyEntry.remove(chr.getId());
else mapParty.remove(partyid);
}
}
public void addPartyMember(MapleCharacter chr) {
chrWLock.lock();
try {
addPartyMemberInternal(chr);
} finally {
chrWLock.unlock();
}
}
public void removePartyMember(MapleCharacter chr) {
chrWLock.lock();
try {
removePartyMemberInternal(chr);
} finally {
chrWLock.unlock();
}
}
public void removeParty(int partyid) {
chrWLock.lock();
try {
mapParty.remove(partyid);
} finally {
chrWLock.unlock();
}
}
public void addPlayer(final MapleCharacter chr) {
chrWLock.lock();
try {
characters.add(chr);
addPartyMemberInternal(chr);
} finally {
chrWLock.unlock();
}
@@ -2047,6 +2124,7 @@ public class MapleMap {
public void removePlayer(MapleCharacter chr) {
chrWLock.lock();
try {
removePartyMemberInternal(chr);
characters.remove(chr);
} finally {
chrWLock.unlock();