Horntail PQ & Exped + Equip levelup fix

Added Horntail PQ and boss fight. Fixed short integer overflow of
equipment stats on client messing up player stats.
This commit is contained in:
ronancpl
2017-07-20 12:02:59 -03:00
parent 8fab2a6e3e
commit c09bc02c85
137 changed files with 1154 additions and 583 deletions

View File

@@ -837,18 +837,11 @@ public class Commands {
player.setMp(player.getMaxMp());
player.updateSingleStat(MapleStat.MP, player.getMaxMp());
} else if (sub[0].equals("buffmap")) {
for (MapleCharacter chr : player.getMap().getCharacters()){
//GM Skills : Haste(Super) - Holy Symbol - Bless - Hyper Body - Echo of Hero
SkillFactory.getSkill(9101001).getEffect(SkillFactory.getSkill(9101001).getMaxLevel()).applyTo(chr);
SkillFactory.getSkill(9101002).getEffect(SkillFactory.getSkill(9101002).getMaxLevel()).applyTo(chr);
SkillFactory.getSkill(9101003).getEffect(SkillFactory.getSkill(9101003).getMaxLevel()).applyTo(chr);
SkillFactory.getSkill(9101008).getEffect(SkillFactory.getSkill(9101008).getMaxLevel()).applyTo(chr);
SkillFactory.getSkill(1005).getEffect(SkillFactory.getSkill(1005).getMaxLevel()).applyTo(chr);
chr.setHp(chr.getMaxHp());
chr.updateSingleStat(MapleStat.HP, chr.getMaxHp());
chr.setMp(chr.getMaxMp());
chr.updateSingleStat(MapleStat.MP, chr.getMaxMp());
}
SkillFactory.getSkill(9101001).getEffect(SkillFactory.getSkill(9101001).getMaxLevel()).applyTo(player, true);
SkillFactory.getSkill(9101002).getEffect(SkillFactory.getSkill(9101002).getMaxLevel()).applyTo(player, true);
SkillFactory.getSkill(9101003).getEffect(SkillFactory.getSkill(9101003).getMaxLevel()).applyTo(player, true);
SkillFactory.getSkill(9101008).getEffect(SkillFactory.getSkill(9101008).getMaxLevel()).applyTo(player, true);
SkillFactory.getSkill(1005).getEffect(SkillFactory.getSkill(1005).getMaxLevel()).applyTo(player, true);
} else if (sub[0].equals("buff")) {
if (sub.length < 2){
player.yellowMessage("Syntax: !buff <buffid>");
@@ -905,7 +898,6 @@ public class Commands {
eu.setHp(incval);
eu.setMp(incval);
eu.setSpeed(incval);
eu.setHands(incval);
eu.setWatk(incval);
eu.setDex(incval);
eu.setInt(incval);

View File

@@ -376,63 +376,79 @@ public class Equip extends Item {
boolean gotVicious = false, gotSlot = false;
String lvupStr = "'" + MapleItemInformationProvider.getInstance().getName(this.getItemId()) + "' is now level " + itemLevel + "! ";
Integer statUp, maxStat = ServerConstants.MAX_EQUIPMNT_STAT;
for (Pair<StatUpgrade, Integer> stat : stats) {
switch (stat.getLeft()) {
case incDEX:
dex += stat.getRight();
lvupStr += "+" + stat.getRight() + "DEX ";
statUp = Math.min(stat.getRight(), maxStat - dex);
dex += statUp;
lvupStr += "+" + statUp + "DEX ";
break;
case incSTR:
str += stat.getRight();
lvupStr += "+" + stat.getRight() + "STR ";
statUp = Math.min(stat.getRight(), maxStat - str);
str += statUp;
lvupStr += "+" + statUp + "STR ";
break;
case incINT:
_int += stat.getRight();
lvupStr += "+" + stat.getRight() + "INT ";
statUp = Math.min(stat.getRight(), maxStat - _int);
_int += statUp;
lvupStr += "+" + statUp + "INT ";
break;
case incLUK:
luk += stat.getRight();
lvupStr += "+" + stat.getRight() + "LUK ";
statUp = Math.min(stat.getRight(), maxStat - luk);
luk += statUp;
lvupStr += "+" + statUp + "LUK ";
break;
case incMHP:
hp += stat.getRight();
lvupStr += "+" + stat.getRight() + "HP ";
statUp = Math.min(stat.getRight(), maxStat - hp);
hp += statUp;
lvupStr += "+" + statUp + "HP ";
break;
case incMMP:
mp += stat.getRight();
lvupStr += "+" + stat.getRight() + "MP ";
statUp = Math.min(stat.getRight(), maxStat - mp);
mp += statUp;
lvupStr += "+" + statUp + "MP ";
break;
case incPAD:
watk += stat.getRight();
lvupStr += "+" + stat.getRight() + "WATK ";
statUp = Math.min(stat.getRight(), maxStat - watk);
watk += statUp;
lvupStr += "+" + statUp + "WATK ";
break;
case incMAD:
matk += stat.getRight();
lvupStr += "+" + stat.getRight() + "MATK ";
statUp = Math.min(stat.getRight(), maxStat - matk);
matk += statUp;
lvupStr += "+" + statUp + "MATK ";
break;
case incPDD:
wdef += stat.getRight();
lvupStr += "+" + stat.getRight() + "WDEF ";
statUp = Math.min(stat.getRight(), maxStat - wdef);
wdef += statUp;
lvupStr += "+" + statUp + "WDEF ";
break;
case incMDD:
mdef += stat.getRight();
lvupStr += "+" + stat.getRight() + "MDEF ";
statUp = Math.min(stat.getRight(), maxStat - mdef);
mdef += statUp;
lvupStr += "+" + statUp + "MDEF ";
break;
case incEVA:
avoid += stat.getRight();
lvupStr += "+" + stat.getRight() + "AVOID ";
statUp = Math.min(stat.getRight(), maxStat - avoid);
avoid += statUp;
lvupStr += "+" + statUp + "AVOID ";
break;
case incACC:
acc += stat.getRight();
lvupStr += "+" + stat.getRight() + "ACC ";
statUp = Math.min(stat.getRight(), maxStat - acc);
acc += statUp;
lvupStr += "+" + statUp + "ACC ";
break;
case incSpeed:
speed += stat.getRight();
lvupStr += "+" + stat.getRight() + "SPEED ";
statUp = Math.min(stat.getRight(), maxStat - speed);
speed += statUp;
lvupStr += "+" + statUp + "SPEED ";
break;
case incJump:
jump += stat.getRight();
lvupStr += "+" + stat.getRight() + "JUMP ";
statUp = Math.min(stat.getRight(), maxStat - jump);
jump += statUp;
lvupStr += "+" + statUp + "JUMP ";
break;
case incVicious:

View File

@@ -70,6 +70,7 @@ public class ServerConstants {
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 = 10000; //Max stat upgrade an equipment can have on a levelup.
public static final int MAX_EQUIPMNT_STAT = 32767; //Max stat on an equipment by leveling up.
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

@@ -90,43 +90,46 @@ public final class ChangeMapHandler extends AbstractMaplePacketHandler {
chr.setHp(50);
chr.changeMap(to, to.getRandomPlayerSpawnpoint());
}
} else if (targetid != -1 && chr.isGM()) {
MapleMap to = chr.getWarpMap(targetid);
chr.changeMap(to, to.getPortal(0));
} else if (targetid != -1 && !chr.isGM()) {//Thanks celino for saving me some time (:
final int divi = chr.getMapId() / 100;
boolean warp = false;
if (divi == 0) {
if (targetid == 10000) {
warp = true;
}
} else if (divi == 20100) {
if (targetid == 104000000) {
c.announce(MaplePacketCreator.lockUI(false));
c.announce(MaplePacketCreator.disableUI(false));
warp = true;
}
} else if (divi == 9130401) { // Only allow warp if player is already in Intro map, or else = hack
if (targetid == 130000000 || targetid / 100 == 9130401) { // Cygnus introduction
warp = true;
}
} else if (divi == 9140900) { // Aran Introduction
if (targetid == 914090011 || targetid == 914090012 || targetid == 914090013 || targetid == 140090000) {
warp = true;
}
} else if (divi / 10 == 1020) { // Adventurer movie clip Intro
if (targetid == 1020000) {
warp = true;
}
} else if(divi / 10 >= 980040 && divi / 10 <= 980045) {
if(targetid == 980040000) {
warp = true;
}
}
if (warp) {
final MapleMap to = chr.getWarpMap(targetid);
chr.changeMap(to, to.getPortal(0));
}
} else if (targetid != -1) {
if(chr.isGM()) {
MapleMap to = chr.getWarpMap(targetid);
chr.changeMap(to, to.getPortal(0));
}
else {
final int divi = chr.getMapId() / 100;
boolean warp = false;
if (divi == 0) {
if (targetid == 10000) {
warp = true;
}
} else if (divi == 20100) {
if (targetid == 104000000) {
c.announce(MaplePacketCreator.lockUI(false));
c.announce(MaplePacketCreator.disableUI(false));
warp = true;
}
} else if (divi == 9130401) { // Only allow warp if player is already in Intro map, or else = hack
if (targetid == 130000000 || targetid / 100 == 9130401) { // Cygnus introduction
warp = true;
}
} else if (divi == 9140900) { // Aran Introduction
if (targetid == 914090011 || targetid == 914090012 || targetid == 914090013 || targetid == 140090000) {
warp = true;
}
} else if (divi / 10 == 1020) { // Adventurer movie clip Intro
if (targetid == 1020000) {
warp = true;
}
} else if(divi / 10 >= 980040 && divi / 10 <= 980045) {
if(targetid == 980040000) {
warp = true;
}
}
if (warp) {
final MapleMap to = chr.getWarpMap(targetid);
chr.changeMap(to, to.getPortal(0));
}
}
}
if (portal != null && !portal.getPortalStatus()) {
c.announce(MaplePacketCreator.blockedMessage(1));

View File

@@ -29,7 +29,8 @@ import tools.data.input.SeekableLittleEndianAccessor;
/**
*
* @author Matze, Ronan
* @author Matze
* @author Ronan
*/
public final class DoorHandler extends AbstractMaplePacketHandler {
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {

View File

@@ -40,11 +40,10 @@ import server.MapleItemInformationProvider;
/**
*
* @author BubblesDev
* @author Ronan
*/
class PairedQuicksort {
/* by RonanLana */
private int i = 0;
private int j = 0;
private final ArrayList<Integer> intersect;

View File

@@ -29,7 +29,8 @@ import client.MapleClient;
/**
*
* @author Matze, Ronan
* @author Matze
* @author Ronan
*/
public final class ItemPickupHandler extends AbstractMaplePacketHandler {

View File

@@ -31,7 +31,8 @@ import tools.data.input.SeekableLittleEndianAccessor;
import constants.ServerConstants;
/**
* @author TheRamon, Ronan
* @author TheRamon
* @author Ronan
*/
public final class PetLootHandler extends AbstractMaplePacketHandler {
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {

View File

@@ -37,7 +37,8 @@ import tools.MaplePacketCreator;
/**
*
* @author XoticStory, Ronan.
* @author XoticStory
* @author Ronan
*/
public class MapleAlliance {
final private List<Integer> guilds = new LinkedList<>();

View File

@@ -748,13 +748,13 @@ public class AbstractPlayerInteraction {
map.broadcastMessage(MaplePacketCreator.spawnNPC(npc));
}
}
public void spawnMonster(int id, int x, int y) {
MapleMonster monster = MapleLifeFactory.getMonster(id);
monster.setPosition(new Point(x, y));
getPlayer().getMap().spawnMonster(monster);
}
public MapleMonster getMonsterLifeFactory(int mid) {
return MapleLifeFactory.getMonster(mid);
}

View File

@@ -68,7 +68,8 @@ import tools.MaplePacketCreator;
/**
*
* @author Matze, Ronan
* @author Matze
* @author Ronan
*/
public class EventInstanceManager {
private Map<Integer, MapleCharacter> chars = new HashMap<>();
@@ -415,11 +416,13 @@ public class EventInstanceManager {
}
public void changedLeader(MapleCharacter ldr) {
try {
try {
em.getIv().invokeFunction("changedLeader", this, ldr);
} catch (ScriptException | NoSuchMethodException ex) {
ex.printStackTrace();
}
leaderId = ldr.getId();
}
public void monsterKilled(MapleMonster mob) {
@@ -1002,6 +1005,10 @@ public class EventInstanceManager {
showClearEffect(hasGate, getLeader().getMapId());
}
public final void showClearEffect(int mapId) {
showClearEffect(false, mapId);
}
public final void showClearEffect(boolean hasGate, int mapId) {
showClearEffect(hasGate, mapId, "gate", 2);
}

View File

@@ -45,7 +45,8 @@ import server.maps.MapleReactor;
import server.maps.ReactorDropEntry;
/**
* @author Lerk, Ronan
* @author Lerk
* @author Ronan
*/
public class ReactorActionManager extends AbstractPlayerInteraction {
private MapleReactor reactor;
@@ -59,6 +60,14 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
this.iv = iv;
}
public void hitReactor() {
reactor.hitReactor(client);
}
public void destroyNpc(int npcId) {
reactor.getMap().destroyNPC(npcId);
}
public void dropItems() {
dropItems(false, 0, 0, 0, 0);
}

View File

@@ -699,14 +699,19 @@ public class MapleStatEffect {
}
public boolean applyTo(MapleCharacter chr) {
return applyTo(chr, chr, true, null);
return applyTo(chr, chr, true, null, false);
}
public boolean applyTo(MapleCharacter chr, boolean useMaxRange) {
return applyTo(chr, chr, true, null, useMaxRange);
}
public boolean applyTo(MapleCharacter chr, Point pos) {
return applyTo(chr, chr, true, pos);
return applyTo(chr, chr, true, pos, false);
}
private boolean applyTo(MapleCharacter applyfrom, MapleCharacter applyto, boolean primary, Point pos) {
// primary: the player caster of the buff
private boolean applyTo(MapleCharacter applyfrom, MapleCharacter applyto, boolean primary, Point pos, boolean useMaxRange) {
if (skill && (sourceid == GM.HIDE || sourceid == SuperGM.HIDE)) {
applyto.toggleHide(false);
return true;
@@ -724,11 +729,14 @@ public class MapleStatEffect {
}
}
List<Pair<MapleStat, Integer>> hpmpupdate = new ArrayList<>(2);
if (!primary && isResurrection()) {
hpchange = applyto.getMaxHp();
applyto.setStance(0);
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.removePlayerFromMap(applyto.getId()), false);
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.spawnPlayerMapobject(applyto), false);
if (!primary) {
if(isResurrection()) {
hpchange = applyto.getMaxHp();
applyto.setStance(0);
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.removePlayerFromMap(applyto.getId()), false);
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.spawnPlayerMapobject(applyto), false);
}
}
if (isDispel() && makeChanceResult()) {
applyto.dispelDebuffs();
@@ -818,7 +826,7 @@ public class MapleStatEffect {
}
if (primary && (overTime || isHeal())) {
applyBuff(applyfrom);
applyBuff(applyfrom, useMaxRange);
}
if (primary && isMonsterBuff()) {
@@ -872,13 +880,17 @@ public class MapleStatEffect {
applyfrom.getMap().spawnMist(mist, getDuration(), mist.isPoisonMist(), false, mist.isRecoveryMist());
} else if(isTimeLeap()) {
applyto.removeAllCooldownsExcept(Buccaneer.TIME_LEAP, true);
} else if(isHyperBody() && !primary) {
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.removePlayerFromMap(applyto.getId()), false);
applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.spawnPlayerMapobject(applyto), false);
}
return true;
}
private void applyBuff(MapleCharacter applyfrom) {
private void applyBuff(MapleCharacter applyfrom, boolean useMaxRange) {
if (isPartyBuff() && (applyfrom.getParty() != null || isGmBuff())) {
Rectangle bounds = calculateBoundingBox(applyfrom.getPosition(), applyfrom.isFacingLeft());
Rectangle bounds = (!useMaxRange) ? calculateBoundingBox(applyfrom.getPosition(), applyfrom.isFacingLeft()) : new Rectangle(Integer.MIN_VALUE / 2, Integer.MIN_VALUE / 2, Integer.MAX_VALUE, Integer.MAX_VALUE);
List<MapleMapObject> affecteds = applyfrom.getMap().getMapObjectsInRect(bounds, Arrays.asList(MapleMapObjectType.PLAYER));
List<MapleCharacter> affectedp = new ArrayList<>(affecteds.size());
for (MapleMapObject affectedmo : affecteds) {
@@ -890,7 +902,7 @@ public class MapleStatEffect {
}
}
for (MapleCharacter affected : affectedp) {
applyTo(applyfrom, affected, false, null);
applyTo(applyfrom, affected, false, null, useMaxRange);
affected.getClient().announce(MaplePacketCreator.showOwnBuffEffect(sourceid, 2));
affected.getMap().broadcastMessage(affected, MaplePacketCreator.showBuffeffect(affected.getId(), sourceid, 2), false);
}
@@ -1379,6 +1391,10 @@ public class MapleStatEffect {
private boolean isCygnusFA() {
return skill && (sourceid == DawnWarrior.FINAL_ATTACK || sourceid == WindArcher.FINAL_ATTACK);
}
private boolean isHyperBody() {
return skill && (sourceid == Spearman.HYPER_BODY || sourceid == GM.HYPER_BODY || sourceid == SuperGM.HYPER_BODY);
}
private boolean isComboReset() {
return sourceid == Aran.COMBO_BARRIER || sourceid == Aran.COMBO_DRAIN;

View File

@@ -38,7 +38,8 @@ import constants.ServerConstants;
/**
*
* @author Matze, Ronan (concurrency safety)
* @author Matze
* @author Ronan (concurrency safety)
*/
public class MapleTrade {
private MapleTrade partner = null;

View File

@@ -54,6 +54,7 @@ public class MapleNPC extends AbstractLoadedMapleLife {
@Override
public void sendDestroyData(MapleClient client) {
client.announce(MaplePacketCreator.removeNPCController(getObjectId()));
client.announce(MaplePacketCreator.removeNPC(getObjectId()));
}

View File

@@ -30,7 +30,8 @@ import client.MapleCharacter;
/**
*
* @author Matze, Ronan
* @author Matze
* @author Ronan
*/
public class MapleDoor {
private int ownerId;

View File

@@ -722,6 +722,14 @@ public class MapleMap {
}
return mobs;
}
public void broadcastHorntailVictory() {
for (Channel cserv : Server.getInstance().getWorld(world).getChannels()) {
for (MapleCharacter player : cserv.getPlayerStorage().getAllCharacters()) {
player.dropMessage("To the crew that have finally conquered Horned Tail after numerous attempts, I salute thee! You are the true heroes of Leafre!!");
}
}
}
public void killMonster(final MapleMonster monster, final MapleCharacter chr, final boolean withDrops) {
killMonster(monster, chr, withDrops, 1);
@@ -760,13 +768,7 @@ public class MapleMap {
}
}
}
if (monster.getId() == 8810018 && chr.getMapId() == 240060200) {
for (Channel cserv : Server.getInstance().getWorld(world).getChannels()) {
for (MapleCharacter player : cserv.getPlayerStorage().getAllCharacters()) {
player.dropMessage("To the crew that have finally conquered Horned Tail after numerous attempts, I salute thee! You are the true heroes of Leafre!!");
}
}
}
spawnedMonstersOnMap.decrementAndGet();
monster.setHp(0);
//if (monster.getStats().selfDestruction() == null) {//FUU BOMBS D:
@@ -1084,6 +1086,24 @@ public class MapleMap {
}
return false;
}
public void destroyNPC(int npcid) {
List<MapleMapObject> npcs = getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.NPC));
objectWLock.lock();
try {
for (MapleMapObject obj : npcs) {
if (((MapleNPC) obj).getId() == npcid) {
broadcastMessage(MaplePacketCreator.removeNPCController(obj.getObjectId()));
broadcastMessage(MaplePacketCreator.removeNPC(obj.getObjectId()));
this.mapobjects.remove(Integer.valueOf(obj.getObjectId()));
}
}
} finally {
objectWLock.unlock();
}
}
public MapleMapObject getMapObject(int oid) {
objectRLock.lock();
@@ -1905,8 +1925,12 @@ public class MapleMap {
}
}
public void dropMessage(int type, String message) {
broadcastStringMessage(type, message);
}
public void broadcastStringMessage(int type, String message) {
broadcastMessage(MaplePacketCreator.serverNotice(type, message));
broadcastMessage(MaplePacketCreator.serverNotice(type, message));
}
public void broadcastMessage(final byte[] packet) {
@@ -2888,7 +2912,7 @@ public class MapleMap {
objectRLock.unlock();
}
}
public void setMobInterval(short interval) {
this.mobInterval = interval;
}

View File

@@ -42,7 +42,8 @@ import tools.Randomizer;
/**
*
* @author Tyler (Twdtwd), Ronan
* @author Tyler (Twdtwd)
* @author Ronan
*/
public class ItemAction extends MapleQuestAction {
List<ItemData> items = new ArrayList<>();

View File

@@ -949,7 +949,7 @@ public class MaplePacketCreator {
/**
* Gets an empty stat update.
*
* @return The empy stat update packet.
* @return The empty stat update packet.
*/
public static byte[] enableActions() {
return updatePlayerStats(EMPTY_STATUPDATE, true, null);
@@ -1325,7 +1325,7 @@ public class MaplePacketCreator {
mplew.writeBool(MiniMap);
return mplew.getPacket();
}
/**
* Gets a spawn monster packet.
*
@@ -2076,7 +2076,7 @@ public class MaplePacketCreator {
List<Integer> onedList = damage.get(oned);
if (onedList != null) {
lew.writeInt(oned.intValue());
lew.write(0xFF);
lew.write(0x0);
if (skill == 4211006) {
lew.write(onedList.size());
}
@@ -5676,11 +5676,21 @@ public class MaplePacketCreator {
return mplew.getPacket();
}
public static byte[] removeNPC(int oid) { //Make npc's invisible
public static byte[] removeNPC(int oid) {
final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
mplew.writeShort(SendOpcode.REMOVE_NPC.getValue());
mplew.writeInt(oid);
return mplew.getPacket();
}
public static byte[] removeNPCController(int objectid) {
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
mplew.writeShort(SendOpcode.SPAWN_NPC_REQUEST_CONTROLLER.getValue());
mplew.write(0);
mplew.writeInt(oid);
mplew.writeInt(objectid);
return mplew.getPacket();
}