PIN system + player ranking fix + rebalanced equip EXP calculations

Added the PIN feature. Fixed ranking now calculating ranks now
world-based instead of overall. Rebalanced equip exp gain and made
cosmetic equipments no more leveling up (cosmetics leveling up are
useless).
This commit is contained in:
ronancpl
2017-06-03 20:02:19 -03:00
parent 02cc9efb00
commit 809d90564c
43 changed files with 193 additions and 78 deletions

View File

@@ -3454,7 +3454,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
if (this.guildid > 0) {
getGuild().broadcast(MaplePacketCreator.levelUpMessage(2, level, name), this.getId());
}
if (ServerConstants.PERFECT_PITCH && level >= 30) {
if (ServerConstants.USE_PERFECT_PITCH && level >= 30) {
//milestones?
if (MapleInventoryManipulator.checkSpace(client, 4310000, (short) 1, "")) {
MapleInventoryManipulator.addById(client, 4310000, (short) 1);
@@ -6183,6 +6183,20 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
}
}
}
public void showAllEquipFeatures() {
MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();
for (Item item : getInventory(MapleInventoryType.EQUIPPED).list()) {
Equip nEquip = (Equip) item;
String itemName = mii.getName(nEquip.getItemId());
if (itemName == null) {
continue;
}
nEquip.showEquipFeatures(client);
}
}
public Map<String, MapleEvents> getEvents() {
return events;

View File

@@ -310,14 +310,12 @@ public class Commands {
public static boolean executePlayerCommand(MapleClient c, String[] sub, char heading) {
MapleCharacter player = c.getPlayer();
if (heading == '!' && player.gmLevel() == 0) {
player.yellowMessage("You may not use !" + sub[0] + ", please try /" + sub[0]);
player.yellowMessage("You may not use !" + sub[0] + ", please try @" + sub[0] + ". For a full list of commands, try @help.");
return false;
}
switch (sub[0]) {
case "help":
case "commands":
case "playercommands":
player.message("============================================================");
player.message("MapleSolaxiaV2 Player Commands");
@@ -337,6 +335,7 @@ public class Commands {
player.message("@whodrops <item name>: Displays monsters that drop an item given an item name.");
player.message("@uptime: Shows how long Solaxia has been online.");
player.message("@bosshp: Displays the remaining HP of the bosses on your map.");
player.message("@equiplv: Displays relations of level and experience of every item you have equipped.");
if(ServerConstants.USE_DEBUG) {
player.message("@debugpos: Displays the coordinates on the map the player is currently located.");
player.message("@debugmap: Displays info about the current map the player is located.");
@@ -478,6 +477,11 @@ public class Commands {
c.removeClickedNPC();
player.message("You've been disposed.");
break;
case "equiplv":
player.showAllEquipFeatures();
break;
case "rates":
//c.resetVoteTime();
player.yellowMessage("BOSSDROP RATE");

View File

@@ -60,10 +60,6 @@ public class Equip extends Item {
private StatUpgrade(int value) {
this.value = value;
}
private int getValue() {
return value;
}
}
private byte upgradeSlots;
@@ -475,13 +471,14 @@ public class Equip extends Item {
}
private double normalizedMasteryExp(int reqLevel) {
return Math.max((2622.71 * Math.exp(reqLevel * 0.0533649)) - 6000.0, 15);
return Math.max((2622.71 * Math.exp(reqLevel * 0.0733649)) - 6000.0, 15);
}
public void gainItemExp(MapleClient c, int gain) { // Ronan's Equip Exp gain method
if(itemLevel >= 30) return;
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
if(!ii.isUpgradeable(this.getItemId()) || itemLevel >= 30) return;
int reqLevel = MapleItemInformationProvider.getInstance().getEquipStats(this.getItemId()).get("reqLevel");
int reqLevel = ii.getEquipStats(this.getItemId()).get("reqLevel");
float masteryModifier = (float)ExpTable.getExpNeededForLevel(1) / (float)normalizedMasteryExp(reqLevel);
float elementModifier = (isElemental) ? 0.85f : 0.6f;
@@ -491,7 +488,7 @@ public class Equip extends Item {
itemExp += baseExpGain;
int expNeeded = ExpTable.getEquipExpNeededForLevel(itemLevel);
//System.out.println("'" + MapleItemInformationProvider.getInstance().getName(this.getItemId()) + "' -> EXP Gain: " + gain + " Mastery: " + masteryModifier + "Base gain: " + baseExpGain + " exp: " + itemExp + " / " + expNeeded);
if(ServerConstants.USE_DEBUG_SHOW_INFO_EQPEXP) System.out.println("'" + ii.getName(this.getItemId()) + "' -> EXP Gain: " + gain + " Mastery: " + masteryModifier + " Base gain: " + baseExpGain + " exp: " + itemExp + " / " + expNeeded);
if (itemExp >= expNeeded) {
while(itemExp >= expNeeded) {
@@ -507,9 +504,32 @@ public class Equip extends Item {
}
} else {
c.getPlayer().forceUpdateItem(this);
//if(ServerConstants.USE_DEBUG) c.getPlayer().dropMessage("'" + MapleItemInformationProvider.getInstance().getName(this.getItemId()) + "': " + itemExp + " / " + expNeeded);
//if(ServerConstants.USE_DEBUG) c.getPlayer().dropMessage("'" + ii.getName(this.getItemId()) + "': " + itemExp + " / " + expNeeded);
}
}
private boolean reachedMaxLevel(String eqpName) {
if(isElemental) {
if(eqpName.contains("Timeless")) {
if(itemLevel < 6) return false;
} else {
if(itemLevel < 4) return false;
}
}
if(itemLevel < ServerConstants.USE_EQUIPMNT_LVLUP) return false;
return true;
}
public void showEquipFeatures(MapleClient c) {
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
if(!ii.isUpgradeable(this.getItemId())) return;
String eqpName = ii.getName(getItemId());
String eqpInfo = reachedMaxLevel(eqpName) ? " - MAX LEVEL" : (" EXP: " + itemExp + " / " + ExpTable.getEquipExpNeededForLevel(itemLevel));
c.getPlayer().dropMessage(5, "'" + eqpName + "' -> Level: " + itemLevel + eqpInfo);
}
public void setItemExp(int exp) {
this.itemExp = exp;

View File

@@ -15,7 +15,8 @@ public class ServerConstants {
public static final long PURGING_INTERVAL = 5 * 60 * 1000;
public static final long RANKING_INTERVAL = 60 * 60 * 1000; //60 minutes, 3600000.
public static final long COUPON_INTERVAL = 60 * 60 * 1000; //60 minutes, 3600000.
public static final boolean ENABLE_PIC = true; //Pick true/false to enable or disable Pic.
public static final boolean ENABLE_PIC = false; //Pick true/false to enable or disable Pic. Delete character needs this feature ENABLED.
public static final boolean ENABLE_PIN = false; //Pick true/false to enable or disable Pin.
//Ip Configuration
public static String HOST;
@@ -33,7 +34,8 @@ public class ServerConstants {
public static final boolean USE_CUSTOM_KEYSET = true;
public static final boolean USE_MAXRANGE = true; //Will send and receive packets from all events of a map, rather than those of only view range.
public static final boolean USE_DEBUG = true; //Will enable some text prints and new commands in the client oriented for debugging.
public static final boolean USE_DEBUG_SHOW_RCVD_PACKETS = false;
public static final boolean USE_DEBUG_SHOW_RCVD_PACKET = false; //Prints on the cmd all received packet ids.
public static final boolean USE_DEBUG_SHOW_INFO_EQPEXP = false; //Prints on the cmd all equip exp gain info.
public static final boolean USE_MTS = false;
public static final boolean USE_FAMILY_SYSTEM = false;
public static final boolean USE_DUEY = true;
@@ -47,7 +49,7 @@ public class ServerConstants {
public static final int MAX_EVENT_LEVELS = 8; //Event has different levels of rewarding system.
public static final long BLOCK_DUEY_RACE_COND = (long)(0.5 * 1000);
public static final long PET_LOOT_UPON_ATTACK = (long)(0.7 * 1000); //Time the pet must wait before trying to pick items up.
public static final boolean PERFECT_PITCH = true; //For lvl 30 or above, each lvlup player gains 1 perfect pitch.
public static final boolean USE_PERFECT_PITCH = true; //For lvl 30 or above, each lvlup player gains 1 perfect pitch.
//Some Gameplay Enhancing Configuration
public static final boolean USE_PERFECT_SCROLLING = true; //Scrolls doesn't use slots upon failure.
@@ -61,8 +63,8 @@ public class ServerConstants {
public static final boolean USE_STACK_COUPON_RATES = true; //Multiple coupons effects builds up together.
public static final boolean USE_EQUIPMNT_LVLUP_SLOTS = true;//Equips can upgrade slots at level up.
public static final boolean USE_EQUIPMNT_LVLUP_POWER = true;//Enable more powerful stats upgrades at equip level up.
public static final int MAX_EQUIPMNT_LVLUP_STAT_GAIN = 120; //Max stat upgrade an equipment can have on a levelup.
public static final int USE_EQUIPMNT_LVLUP = 7; //All equips lvlup at max level of N, set 0 to disable.
public static final int MAX_EQUIPMNT_LVLUP_STAT_GAIN = 10000; //Max stat upgrade an equipment can have on a levelup.
public static final int USE_EQUIPMNT_LVLUP = 7; //All equips lvlup at max level of N, set 1 to disable.
public static final int FAME_GAIN_BY_QUEST = 4; //Fame gain each N quest completes, set 0 to disable.
public static final int SCROLL_CHANCE_RATE = 10; //Number of tries for success on a scroll, set 0 for default.

View File

@@ -131,7 +131,7 @@ public class MapleServerHandler extends IoHandlerAdapter {
short packetId = slea.readShort();
MapleClient client = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);
if(ServerConstants.USE_DEBUG_SHOW_RCVD_PACKETS) System.out.println("Received packet id " + packetId);
if(ServerConstants.USE_DEBUG_SHOW_RCVD_PACKET) System.out.println("Received packet id " + packetId);
final MaplePacketHandler packetHandler = processor.getHandler(packetId);
if (packetHandler != null && packetHandler.validateState(client)) {
try {

View File

@@ -32,6 +32,7 @@ import constants.ServerConstants;
/**
* @author Matze
* @author Quit
* @author Ronan
*/
public class RankingWorker implements Runnable {
private Connection con;
@@ -43,16 +44,17 @@ public class RankingWorker implements Runnable {
reset.executeUpdate();
}
private void updateRanking(int job) throws SQLException {
String sqlCharSelect = "SELECT c.id, " + (job != -1 ? "c.jobRank, c.jobRankMove" : "c.rank, c.rankMove") + ", a.lastlogin AS lastlogin, a.loggedin FROM characters AS c LEFT JOIN accounts AS a ON c.accountid = a.id ";
private void updateRanking(int job, int world) throws SQLException {
String sqlCharSelect = "SELECT c.id, " + (job != -1 ? "c.jobRank, c.jobRankMove" : "c.rank, c.rankMove") + ", a.lastlogin AS lastlogin, a.loggedin FROM characters AS c LEFT JOIN accounts AS a ON c.accountid = a.id WHERE c.world = ? ";
if (job != -1) {
sqlCharSelect += "WHERE c.job DIV 100 = ? ";
sqlCharSelect += "AND c.job DIV 100 = ? ";
}
sqlCharSelect += "ORDER BY c.level DESC , c.exp DESC , c.fame DESC , c.meso DESC";
PreparedStatement charSelect = con.prepareStatement(sqlCharSelect);
PreparedStatement charSelect = con.prepareStatement(sqlCharSelect);
charSelect.setInt(1, world);
if (job != -1) {
charSelect.setInt(1, job);
charSelect.setInt(2, job);
}
ResultSet rs = charSelect.executeQuery();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET " + (job != -1 ? "jobRank = ?, jobRankMove = ? " : "rank = ?, rankMove = ? ") + "WHERE id = ?");
@@ -87,12 +89,14 @@ public class RankingWorker implements Runnable {
resetMoveRank(false);
}
updateRanking(-1); //overall ranking
for (int i = 0; i <= MapleJob.getMax(); i++) {
updateRanking(i);
for(int j = 0; j < Server.getInstance().getWorlds().size(); j++) {
updateRanking(-1, j); //overall ranking
for (int i = 0; i <= MapleJob.getMax(); i++) {
updateRanking(i, j);
}
con.commit();
}
con.commit();
con.setAutoCommit(true);
lastUpdate = System.currentTimeMillis();
} catch (SQLException ex) {

View File

@@ -601,7 +601,7 @@ public abstract class AbstractDealDamageHandler extends AbstractMaplePacketHandl
MapleStatEffect effect = skill.getEffect(ret.skilllevel);
if (magic) {
// Since the skill is magic based, use the magic formula
// Since the skill is magic based, use the magic formula
if(chr.getJob() == MapleJob.IL_ARCHMAGE || chr.getJob() == MapleJob.IL_MAGE) {
int skillLvl = chr.getSkillLevel(ILMage.ELEMENT_AMPLIFICATION);
if(skillLvl > 0)
@@ -611,7 +611,7 @@ public abstract class AbstractDealDamageHandler extends AbstractMaplePacketHandl
if(skillLvl > 0)
calcDmgMax = calcDmgMax * SkillFactory.getSkill(FPMage.ELEMENT_AMPLIFICATION).getEffect(skillLvl).getY() / 100;
} else if(chr.getJob() == MapleJob.BLAZEWIZARD3 || chr.getJob() == MapleJob.BLAZEWIZARD4) {
int skillLvl = chr.getSkillLevel(BlazeWizard.ELEMENT_AMPLIFICATION);
int skillLvl = chr.getSkillLevel(BlazeWizard.ELEMENT_AMPLIFICATION);
if(skillLvl > 0)
calcDmgMax = calcDmgMax * SkillFactory.getSkill(BlazeWizard.ELEMENT_AMPLIFICATION).getEffect(skillLvl).getY() / 100;
} else if(chr.getJob() == MapleJob.EVAN7 || chr.getJob() == MapleJob.EVAN8 || chr.getJob() == MapleJob.EVAN9 || chr.getJob() == MapleJob.EVAN10) {
@@ -622,16 +622,16 @@ public abstract class AbstractDealDamageHandler extends AbstractMaplePacketHandl
calcDmgMax *= effect.getMatk();
if(ret.skill == Cleric.HEAL) {
// This formula is still a bit wonky, but it is fairly accurate.
// This formula is still a bit wonky, but it is fairly accurate.
calcDmgMax = (int) Math.round((chr.getTotalInt() * 4.8 + chr.getTotalLuk() * 4) * chr.getTotalMagic() / 1000);
calcDmgMax = calcDmgMax * effect.getHp() / 100;
}
} else if(ret.skill == Hermit.SHADOW_MESO) {
// Shadow Meso also has its own formula
calcDmgMax = effect.getMoneyCon() * 10;
calcDmgMax = (int) Math.floor(calcDmgMax * 1.5);
} else if(ret.skill == Hermit.SHADOW_MESO) {
// Shadow Meso also has its own formula
calcDmgMax = effect.getMoneyCon() * 10;
calcDmgMax = (int) Math.floor(calcDmgMax * 1.5);
} else {
// Normal damage formula for skills
// Normal damage formula for skills
calcDmgMax = calcDmgMax * effect.getDamage() / 100;
}
}
@@ -646,9 +646,12 @@ public abstract class AbstractDealDamageHandler extends AbstractMaplePacketHandl
MapleStatEffect ceffect = SkillFactory.getSkill(advcomboid).getEffect(chr.getSkillLevel(advcomboid));
calcDmgMax = (int) Math.floor(calcDmgMax * (ceffect.getDamage() + 50) / 100 + 0.20 + (comboBuff - 5) * 0.04);
} else {
// Normal Combo
MapleStatEffect ceffect = SkillFactory.getSkill(oid).getEffect(chr.getSkillLevel(oid));
calcDmgMax = (int) Math.floor(calcDmgMax * (ceffect.getDamage() + 50) / 100 + Math.floor((comboBuff - 1) * (chr.getSkillLevel(oid) / 6)) / 100);
// Normal Combo
int skillLv = chr.getSkillLevel(oid);
if(skillLv <= 0) skillLv = SkillFactory.getSkill(oid).getMaxLevel();
MapleStatEffect ceffect = SkillFactory.getSkill(oid).getEffect(skillLv);
calcDmgMax = (int) Math.floor(calcDmgMax * (ceffect.getDamage() + 50) / 100 + Math.floor((comboBuff - 1) * (skillLv / 6)) / 100);
}
if(GameConstants.isFinisherSkill(ret.skill)) {

View File

@@ -87,7 +87,9 @@ public final class CloseRangeDamageHandler extends AbstractDealDamageHandler {
if (advComboSkillLevel > 0) {
ceffect = advcombo.getEffect(advComboSkillLevel);
} else {
ceffect = combo.getEffect(player.getSkillLevel(combo));
int comboLv = player.getSkillLevel(combo);
if(comboLv <= 0) comboLv = SkillFactory.getSkill(oid).getMaxLevel();
ceffect = combo.getEffect(comboLv);
}
if (orbcount < ceffect.getX() + 1) {
int neworbcount = orbcount + 1;
@@ -96,7 +98,10 @@ public final class CloseRangeDamageHandler extends AbstractDealDamageHandler {
neworbcount++;
}
}
int duration = combo.getEffect(player.getSkillLevel(oid)).getDuration();
int olv = player.getSkillLevel(oid);
if(olv <= 0) olv = SkillFactory.getSkill(oid).getMaxLevel();
int duration = combo.getEffect(olv).getDuration();
List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.COMBO, neworbcount));
player.setBuffedValue(MapleBuffStat.COMBO, neworbcount);
duration -= (int) (System.currentTimeMillis() - player.getBuffedStarttime(MapleBuffStat.COMBO));

View File

@@ -30,7 +30,6 @@ public final class AfterLoginHandler extends AbstractMaplePacketHandler {
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
System.out.println("after login");
byte c2 = slea.readByte();
byte c3 = 5;

View File

@@ -65,7 +65,7 @@ public final class LoginPasswordHandler implements MaplePacketHandler {
return;
}
if (c.finishLogin() == 0) {
login(c);
login(c);
} else {
c.announce(MaplePacketCreator.getLoginFailed(7));
}

View File

@@ -1295,6 +1295,16 @@ public class MapleItemInformationProvider {
return itemId / 1000000 == 5 || getEquipStats(itemId).get("cash") == 1;
}
public boolean isUpgradeable(int itemId) {
Item it = this.getEquipById(itemId);
Equip eq = (Equip)it;
return (eq.getUpgradeSlots() > 0 || eq.getStr() > 0 || eq.getDex() > 0 || eq.getInt() > 0 || eq.getLuk() > 0 ||
eq.getWatk() > 0 || eq.getMatk() > 0 || eq.getWdef() > 0 || eq.getMdef() > 0 || eq.getAcc() > 0 ||
eq.getAvoid() > 0 || eq.getSpeed() > 0 || eq.getJump() > 0 || eq.getHp() > 0 || eq.getMp() > 0);
}
public boolean isRateCoupon(int itemId) {
int itemType = itemId / 1000;
return itemType == 5211 || itemType == 5360;

View File

@@ -677,6 +677,10 @@ public class MapleStatEffect {
if (primary) {
if (itemConNo != 0) {
if(!applyto.getClient().getAbstractPlayerInteraction().hasItem(itemCon, itemConNo)) {
applyto.getClient().announce(MaplePacketCreator.enableActions());
return false;
}
MapleInventoryManipulator.removeById(applyto.getClient(), MapleItemInformationProvider.getInstance().getInventoryType(itemCon), itemCon, itemConNo, false, true);
}
}

View File

@@ -62,10 +62,10 @@ public class BalrogPQ {
public void run(){
if(fmap.getCharacters().size() <= 3){
if(fmap.getCharacters().size() > 0){
for(MapleCharacter chrs : fmap.getCharacters()){
chrs.message("[The Order]: What? You're down to that many mercenaries? I need you get you out of there.");
chrs.changeMap(105100100);
}
for(MapleCharacter chrs : fmap.getCharacters()){
chrs.message("[The Order]: What? You're down to that many mercenaries? I need to get you out of there.");
chrs.changeMap(105100100);
}
}
fmap.killAllMonsters();
close();

View File

@@ -694,8 +694,10 @@ public class MaplePacketCreator {
mplew.writeLong(0);//isquietban time
mplew.writeLong(c.getSessionId()); //creation time
mplew.writeInt(0);
mplew.writeShort(2);//PIN
if (ServerConstants.ENABLE_PIN) mplew.writeShort(0);
else mplew.writeShort(2);
return mplew.getPacket();
}