Quest Item Restore + Packets w/ Timezone + Item/Exp-dec Field Limits

Fixed leaders being able to create expeditions even though the already passed the day limit.
Fixed overflow case in calculated max value of skills.
Implemented item expiration from DB after the due date.
Refactored item flags using byte-length instead of short.
Added FieldLimit checks for disappearing item drops and no EXP deduction in limited areas.
Added "Quest Item Restore" functionality.
Implemented item flag auto-instantiation when generating items.
Added gate state update in Papulatus lobby area.
Fixed a recent issue regarding bounding box calculation of AoE player skills.
Implemented minidungeon close, to occur as soon as the party leader leaves the area.
Refactored HenesysPQ attributed out of the MapleMap object, now they should be available from the respective event script.
Fixed friendly mobs not dropping item periodically, a recent issue after tweaking the loot system.
Fixed Papulatus expedition closing after the exped leader leaves or a minimum of player required to start is no longer there.
Fixed several expeditions closing after performing party operations, such as "change party leader".
Reviewed expected max damage calculation for summons, which would not work properly in several occasions.
Normalized timezone from packets sent to client, now using the same timezone defined from the server flags.
Fixed certain scenarios in CPQ that would happen within the stage between the "challenge accepted" and ingress in the battlefield.
Revised credits script.
Added GM checks in the autoban method.
This commit is contained in:
ronancpl
2019-07-15 20:22:39 -03:00
parent 0228d4e176
commit ab5cec7f33
73 changed files with 1200 additions and 393 deletions
+32 -25
View File
@@ -168,6 +168,7 @@ import server.maps.MapleMapItem;
import net.server.audit.locks.MonitoredLockType;
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
import org.apache.mina.util.ConcurrentHashSet;
import server.maps.FieldLimit;
public class MapleCharacter extends AbstractMapleCharacterObject {
private static final MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
@@ -2956,9 +2957,9 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
expiration = item.getExpiration();
if (expiration != -1 && (expiration < currenttime) && ((item.getFlag() & ItemConstants.LOCK) == ItemConstants.LOCK)) {
byte aids = item.getFlag();
aids &= ~(ItemConstants.LOCK);
item.setFlag(aids); //Probably need a check, else people can make expiring items into permanent items...
short lock = item.getFlag();
lock &= ~(ItemConstants.LOCK);
item.setFlag(lock); //Probably need a check, else people can make expiring items into permanent items...
item.setExpiration(-1);
forceUpdateItem(item); //TEST :3
} else if (expiration != -1 && expiration < currenttime) {
@@ -6099,7 +6100,8 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
public boolean isPartyLeader() {
prtLock.lock();
try {
return party.getLeaderId() == getId();
MapleParty party = getParty();
return party != null && party.getLeaderId() == getId();
} finally {
prtLock.unlock();
}
@@ -6410,7 +6412,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
prtLock.lock();
try {
party = getParty();
partyLeader = party != null && isPartyLeader();
partyLeader = isPartyLeader();
} finally {
prtLock.unlock();
}
@@ -6932,7 +6934,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
ret.getInventory(MapleInventoryType.SETUP).setSlotLimit(rs.getByte("setupslots"));
ret.getInventory(MapleInventoryType.ETC).setSlotLimit(rs.getByte("etcslots"));
byte sandboxCheck = 0x0;
short sandboxCheck = 0x0;
for (Pair<Item, MapleInventoryType> item : ItemFactory.INVENTORY.loadItems(ret.id, !channelserver)) {
sandboxCheck |= item.getLeft().getFlag();
@@ -7402,28 +7404,29 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
if (possesed > 0) {
message("You have used a safety charm, so your EXP points have not been decreased.");
MapleInventoryManipulator.removeById(client, ItemConstants.getInventoryType(charmID[i]), charmID[i], 1, true, false);
} else if (mapid > 925020000 && mapid < 925030000) {
this.dojoStage = 0;
} else if (getJob() != MapleJob.BEGINNER) { //Hmm...
int XPdummy = ExpTable.getExpNeededForLevel(getLevel());
if (getMap().isTown()) {
XPdummy /= 100;
}
if (XPdummy == ExpTable.getExpNeededForLevel(getLevel())) {
if (getLuk() <= 100 && getLuk() > 8) {
XPdummy *= (200 - getLuk()) / 2000;
} else if (getLuk() < 8) {
XPdummy /= 10;
if (!FieldLimit.NO_EXP_DECREASE.check(getMap().getFieldLimit())) { // thanks Conrad for noticing missing FieldLimit check
int XPdummy = ExpTable.getExpNeededForLevel(getLevel());
if (getMap().isTown()) {
XPdummy /= 100;
}
if (XPdummy == ExpTable.getExpNeededForLevel(getLevel())) {
if (getLuk() <= 100 && getLuk() > 8) {
XPdummy *= (200 - getLuk()) / 2000;
} else if (getLuk() < 8) {
XPdummy /= 10;
} else {
XPdummy /= 20;
}
}
if (getExp() > XPdummy) {
loseExp(XPdummy, false, false);
} else {
XPdummy /= 20;
loseExp(getExp(), false, false);
}
}
if (getExp() > XPdummy) {
loseExp(XPdummy, false, false);
} else {
loseExp(getExp(), false, false);
}
}
if (getBuffedValue(MapleBuffStat.MORPH) != null) {
cancelEffectFromBuffStat(MapleBuffStat.MORPH);
}
@@ -9168,10 +9171,10 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
}
private static void setMergeFlag(Item item) {
int flag = item.getFlag();
short flag = item.getFlag();
flag |= ItemConstants.MERGE_UNTRADEABLE;
flag |= ItemConstants.UNTRADEABLE;
item.setFlag((byte) flag);
item.setFlag(flag);
}
private List<Equip> getUpgradeableEquipped() {
@@ -9911,6 +9914,10 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
}
public void autoban(String reason) {
if (this.isGM() || this.isBanned()){ // thanks RedHat for noticing GM's being able to get banned
return;
}
this.ban(reason);
announce(MaplePacketCreator.sendPolice(String.format("You have been blocked by the#b %s Police for HACK reason.#k", "HeavenMS")));
TimerManager.getInstance().schedule(new Runnable() {
+4 -3
View File
@@ -33,10 +33,11 @@ public class AutobanManager {
}
public void addPoint(AutobanFactory fac, String reason) {
if (chr.isGM() || chr.isBanned()){
return;
}
if (ServerConstants.USE_AUTOBAN) {
if (chr.isGM() || chr.isBanned()){
return;
}
if (lastTime.containsKey(fac)) {
if (lastTime.get(fac) < (Server.getInstance().getCurrentTime() - fac.getExpire())) {
points.put(fac, points.get(fac) / 2); //So the points are not completely gone.
@@ -77,12 +77,12 @@ public class ItemCommand extends Command {
}
}
byte flag = 0;
short flag = 0;
if(player.gmLevel() < 3) {
flag |= ItemConstants.ACCOUNT_SHARING;
flag |= ItemConstants.UNTRADEABLE;
}
MapleInventoryManipulator.addById(c, itemId, quantity, player.getName(), -1, flag, -1);
}
}
@@ -75,12 +75,12 @@ public class ItemDropCommand extends Command {
toDrop.setOwner("");
if(player.gmLevel() < 3) {
byte b = toDrop.getFlag();
b |= ItemConstants.ACCOUNT_SHARING;
b |= ItemConstants.UNTRADEABLE;
b |= ItemConstants.SANDBOX;
short f = toDrop.getFlag();
f |= ItemConstants.ACCOUNT_SHARING;
f |= ItemConstants.UNTRADEABLE;
f |= ItemConstants.SANDBOX;
toDrop.setFlag(b);
toDrop.setFlag(f);
toDrop.setOwner("TRIAL-MODE");
}
@@ -102,12 +102,12 @@ public class ItemDropCommand extends Command {
toDrop.setOwner(player.getName());
if(player.gmLevel() < 3) {
byte b = toDrop.getFlag();
b |= ItemConstants.ACCOUNT_SHARING;
b |= ItemConstants.UNTRADEABLE;
b |= ItemConstants.SANDBOX;
short f = toDrop.getFlag();
f |= ItemConstants.ACCOUNT_SHARING;
f |= ItemConstants.UNTRADEABLE;
f |= ItemConstants.SANDBOX;
toDrop.setFlag(b);
toDrop.setFlag(f);
toDrop.setOwner("TRIAL-MODE");
}
@@ -0,0 +1,51 @@
/*
This file is part of the HeavenMS MapleStory Server, commands OdinMS-based
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/>.
*/
/*
@Author: Resinate
*/
package client.command.commands.gm2;
import client.MapleClient;
import client.command.Command;
import java.util.Arrays;
import java.util.List;
import server.maps.MapleMapItem;
import server.maps.MapleMapObject;
import server.maps.MapleMapObjectType;
public class LootCommand extends Command {
{
setDescription("Loots all items that belong to you.");
}
@Override
public void execute(MapleClient c, String[] params) {
List<MapleMapObject> items = c.getPlayer().getMap().getMapObjectsInRange(c.getPlayer().getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.ITEM));
for (MapleMapObject item : items) {
MapleMapItem mapItem = (MapleMapItem) item;
if (mapItem.getOwnerId() == c.getPlayer().getId() || mapItem.getOwnerId() == c.getPlayer().getPartyId()) {
c.getPlayer().pickupItem(mapItem);
}
}
}
}
@@ -36,6 +36,8 @@ public class PapCommand extends Command {
@Override
public void execute(MapleClient c, String[] params) {
MapleCharacter player = c.getPlayer();
player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8510000), player.getPosition());
// thanks Conrad for noticing mobid typo here
player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8500001), player.getPosition());
}
}
@@ -84,7 +84,7 @@ public class ProItemCommand extends Command {
equip.setHp(stat);
equip.setMp(stat);
byte flag = equip.getFlag();
short flag = equip.getFlag();
flag |= ItemConstants.UNTRADEABLE;
equip.setFlag(flag);
}
@@ -68,7 +68,7 @@ public class SetEqStatCommand extends Command {
eq.setStr(newStat);
eq.setLuk(newStat);
byte flag = eq.getFlag();
short flag = eq.getFlag();
flag |= ItemConstants.UNTRADEABLE;
eq.setFlag(flag);
+4 -3
View File
@@ -64,7 +64,8 @@ public class Equip extends Item {
}
private byte upgradeSlots;
private byte level, flag, itemLevel;
private byte level, itemLevel;
private short flag;
private short str, dex, _int, luk, hp, mp, watk, matk, wdef, mdef, acc, avoid, hands, speed, jump, vicious;
private float itemExp;
private int ringid = -1;
@@ -117,7 +118,7 @@ public class Equip extends Item {
}
@Override
public byte getFlag() {
public short getFlag() {
return flag;
}
@@ -195,7 +196,7 @@ public class Equip extends Item {
}
@Override
public void setFlag(byte flag) {
public void setFlag(short flag) {
this.flag = flag;
}
+8 -3
View File
@@ -40,7 +40,7 @@ public class Item implements Comparable<Item> {
private MaplePet pet = null;
private String owner = "";
protected List<String> log;
private byte flag;
private short flag;
private long expiration = -1;
private String giftFrom = "";
@@ -146,11 +146,16 @@ public class Item implements Comparable<Item> {
return Collections.unmodifiableList(log);
}
public byte getFlag() {
public short getFlag() {
return flag;
}
public void setFlag(byte b) {
public void setFlag(short b) {
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
if (ii.isAccountRestricted(id)) {
b |= ItemConstants.ACCOUNT_SHARING; // thanks Shinigami15 for noticing ACCOUNT_SHARING flag not being applied properly to items server-side
}
this.flag = b;
}
+3 -3
View File
@@ -97,7 +97,7 @@ public enum ItemFactory {
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setVicious((short) rs.getInt("vicious"));
equip.setFlag((byte) rs.getInt("flag"));
equip.setFlag((short) rs.getInt("flag"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
@@ -177,7 +177,7 @@ public enum ItemFactory {
item.setOwner(rs.getString("owner"));
item.setExpiration(rs.getLong("expiration"));
item.setGiftFrom(rs.getString("giftFrom"));
item.setFlag((byte) rs.getInt("flag"));
item.setFlag((short) rs.getInt("flag"));
items.add(new Pair<>(item, mit));
}
}
@@ -333,7 +333,7 @@ public enum ItemFactory {
item.setOwner(rs.getString("owner"));
item.setExpiration(rs.getLong("expiration"));
item.setGiftFrom(rs.getString("giftFrom"));
item.setFlag((byte) rs.getInt("flag"));
item.setFlag((short) rs.getInt("flag"));
items.add(new Pair<>(item, mit));
}
}
@@ -68,7 +68,7 @@ public class MapleInventoryManipulator {
return addById(c, itemId, quantity, owner, petid, (byte) 0, expiration);
}
public static boolean addById(MapleClient c, int itemId, short quantity, String owner, int petid, byte flag, long expiration) {
public static boolean addById(MapleClient c, int itemId, short quantity, String owner, int petid, short flag, long expiration) {
MapleCharacter chr = c.getPlayer();
MapleInventoryType type = ItemConstants.getInventoryType(itemId);
@@ -90,7 +90,7 @@ public class MapleInventoryManipulator {
}
}
private static boolean addByIdInternal(MapleClient c, MapleCharacter chr, MapleInventoryType type, MapleInventory inv, int itemId, short quantity, String owner, int petid, byte flag, long expiration) {
private static boolean addByIdInternal(MapleClient c, MapleCharacter chr, MapleInventoryType type, MapleInventory inv, int itemId, short quantity, String owner, int petid, short flag, long expiration) {
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
if (!type.equals(MapleInventoryType.EQUIP)) {
short slotMax = ii.getSlotMax(c, itemId);
@@ -27,18 +27,18 @@ import client.inventory.Item;
* @author RonanLana
*/
public class MapleKarmaManipulator {
private static int getKarmaFlag(Item item) {
private static short getKarmaFlag(Item item) {
return item.getItemType() == 1 ? ItemConstants.KARMA_EQP : ItemConstants.KARMA_USE;
}
public static boolean hasKarmaFlag(Item item) {
int karmaFlag = getKarmaFlag(item);
short karmaFlag = getKarmaFlag(item);
return (item.getFlag() & karmaFlag) == karmaFlag;
}
public static void toggleKarmaFlagToUntradeable(Item item) {
int karmaFlag = getKarmaFlag(item);
int flag = item.getFlag();
short karmaFlag = getKarmaFlag(item);
short flag = item.getFlag();
if ((flag & karmaFlag) == karmaFlag) {
flag ^= karmaFlag;
@@ -49,8 +49,8 @@ public class MapleKarmaManipulator {
}
public static void setKarmaFlag(Item item) {
int karmaFlag = getKarmaFlag(item);
int flag = item.getFlag();
short karmaFlag = getKarmaFlag(item);
short flag = item.getFlag();
flag |= karmaFlag;
flag &= (0xFFFFFFFF ^ ItemConstants.UNTRADEABLE);
+45 -13
View File
@@ -39,6 +39,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Collections;
import java.util.LinkedList;
@@ -112,21 +113,13 @@ public class DueyProcessor {
return null;
}
private static String getCurrentDate(boolean quick) {
String date = "";
private static Timestamp getCurrentDate(boolean quick) {
Calendar cal = Calendar.getInstance();
if (!quick) {
cal.add(Calendar.DATE, 1);
}
int day = cal.get(Calendar.DATE);
int month = cal.get(Calendar.MONTH) + 1; // its an array of months.
int year = cal.get(Calendar.YEAR);
date += day <= 9 ? "0" + day + "-" : "" + day + "-";
date += month <= 9 ? "0" + month + "-" : "" + month + "-";
date += year;
return date;
return new Timestamp(cal.getTime().getTime());
}
private static void showDueyNotification(MapleClient c, MapleCharacter player) {
@@ -211,7 +204,7 @@ public class DueyProcessor {
dueypack.setSender(rs.getString("SenderName"));
dueypack.setMesos(rs.getInt("Mesos"));
dueypack.setSentTime(rs.getString("TimeStamp"));
dueypack.setSentTime(rs.getTimestamp("TimeStamp"));
dueypack.setMessage(rs.getString("Message"));
return dueypack;
@@ -257,7 +250,7 @@ public class DueyProcessor {
ps.setInt(1, toCid);
ps.setString(2, sender);
ps.setInt(3, mesos);
ps.setString(4, getCurrentDate(quick));
ps.setTimestamp(4, getCurrentDate(quick));
ps.setString(5, message);
ps.setInt(6, quick ? 1 : 0);
@@ -468,11 +461,16 @@ public class DueyProcessor {
}
con.close();
if(dp == null) {
if (dp == null) {
c.announce(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_UNKNOWN_ERROR.getCode()));
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to receive package from duey with id " + packageId);
return;
}
if (dp.isDeliveringTime()) {
c.announce(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_UNKNOWN_ERROR.getCode()));
return;
}
Item dpItem = dp.getItem();
if (dpItem != null) {
@@ -530,4 +528,38 @@ public class DueyProcessor {
insertPackageItem(packageId, item);
}
}
public static void runDueyExpireSchedule() {
try {
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, -30);
Timestamp ts = new Timestamp(c.getTime().getTime());
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT `PackageId` FROM dueypackages WHERE `TimeStamp` < ?");
ps.setTimestamp(1, ts);
List<Integer> toRemove = new LinkedList<>();
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
toRemove.add(rs.getInt("PackageId"));
}
}
ps.close();
for (Integer pid : toRemove) {
removePackageFromDB(pid);
}
ps = con.prepareStatement("DELETE FROM dueypackages WHERE `TimeStamp` < ?");
ps.setTimestamp(1, ts);
ps.executeUpdate();
ps.close();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
+11 -11
View File
@@ -35,16 +35,16 @@ import java.util.Map;
public final class ItemConstants {
protected static Map<Integer, MapleInventoryType> inventoryTypeCache = new HashMap<>();
public final static int LOCK = 0x01;
public final static int SPIKES = 0x02;
public final static int KARMA_USE = 0x02;
public final static int COLD = 0x04;
public final static int UNTRADEABLE = 0x08;
public final static int KARMA_EQP = 0x10;
public final static int SANDBOX = 0x40; // let 0x40 until it's proven something uses this
public final static int PET_COME = 0x80;
public final static int ACCOUNT_SHARING = 0x100;
public final static int MERGE_UNTRADEABLE = 0x200;
public final static short LOCK = 0x01;
public final static short SPIKES = 0x02;
public final static short KARMA_USE = 0x02;
public final static short COLD = 0x04;
public final static short UNTRADEABLE = 0x08;
public final static short KARMA_EQP = 0x10;
public final static short SANDBOX = 0x40; // let 0x40 until it's proven something uses this
public final static short PET_COME = 0x80;
public final static short ACCOUNT_SHARING = 0x100;
public final static short MERGE_UNTRADEABLE = 0x200;
public final static boolean EXPIRING_ITEMS = true;
public final static Set<Integer> permanentItemids = new HashSet<>();
@@ -147,7 +147,7 @@ public final class ItemConstants {
return scrollId == 2040727 || scrollId == 2041058;
}
public static boolean isFlagModifier(int scrollId, byte flag) {
public static boolean isFlagModifier(int scrollId, short flag) {
if(scrollId == 2041058 && ((flag & ItemConstants.COLD) == ItemConstants.COLD)) return true;
if(scrollId == 2040727 && ((flag & ItemConstants.SPIKES) == ItemConstants.SPIKES)) return true;
return false;
+5 -3
View File
@@ -116,9 +116,10 @@ public class ServerConstants {
public static final boolean USE_NPCS_SCRIPTABLE = true; //Flag to enable/disable serverside predefined script NPCs.
//Events/PQs Configuration
public static final boolean USE_OLD_GMS_STYLED_PQ_NPCS = true; //Enables PQ NPCs with similar behaviour to old GMS style, that skips info about the PQs and immediately tries to register the party in.
public static final boolean USE_ENABLE_SOLO_EXPEDITIONS = true; //Enables start expeditions with any number of players. This will also bypass all the Zakum prequest.
public static final boolean USE_ENABLE_RECALL_EVENT = true; //Enables a disconnected player to reaccess the last event instance they were in before logging out. Recall only works if the event isn't cleared or disposed yet. Suggestion thanks to Alisson (Goukken).
public static final boolean USE_OLD_GMS_STYLED_PQ_NPCS = true; //Enables PQ NPCs with similar behaviour to old GMS style, that skips info about the PQs and immediately tries to register the party in.
public static final boolean USE_ENABLE_SOLO_EXPEDITIONS = true; //Enables start expeditions with any number of players. This will also bypass all the Zakum prequest.
public static final boolean USE_ENABLE_DAILY_EXPEDITIONS = false;//Enables daily entry limitations in expeditions.
public static final boolean USE_ENABLE_RECALL_EVENT = false; //Enables a disconnected player to reaccess the last event instance they were in before logging out. Recall only works if the event isn't cleared or disposed yet. Suggestion thanks to Alisson (Goukken).
//Announcement Configuration
public static final boolean USE_ANNOUNCE_SHOPITEMSOLD = false; //Automatic message sent to owner when an item from the Player Shop or Hired Merchant is sold.
@@ -210,6 +211,7 @@ public class ServerConstants {
public static final boolean USE_FAST_REUSE_HERO_WILL = true;//Greatly reduce cooldown on Hero's Will.
public static final boolean USE_ANTI_IMMUNITY_CRASH = true; //Crash skills additionally removes the mob's invincibility buffs. Suggestion thanks to Celestial.
public static final boolean USE_UNDISPEL_HOLY_SHIELD = true;//Holy shield buff also prevents players from suffering dispel from mobs.
public static final boolean USE_FULL_HOLY_SYMBOL = true; //Holy symbol doesn't require EXP sharers to work in full.
//Character Configuration
public static final boolean USE_ADD_SLOTS_BY_LEVEL = true; //Slots are added each 20 levels.
+2 -2
View File
@@ -182,7 +182,7 @@ public enum SendOpcode {
CONTI_STATE(0x95),
SET_QUEST_CLEAR(0x96),
SET_QUEST_TIME(0x97),
WARN_MESSAGE(0x98),
ARIANT_RESULT(0x98), // thanks lrenex
SET_OBJECT_STATE(0x99),
STOP_CLOCK(0x9A),
ARIANT_ARENA_SHOW_RESULT(0x9B),
@@ -302,7 +302,7 @@ public enum SendOpcode {
ARIANT_ARENA_USER_SCORE(0x129),
SHEEP_RANCH_INFO(0x12B),
SHEEP_RANCH_CLOTHES(0x12C),
ARIANT_SCORE(0x12D),
WITCH_TOWER_SCORE_UPDATE(0x12D), // thanks lrenex
HORNTAIL_CAVE(0x12E),
ZAKUM_SHRINE(0x12F),
NPC_TALK(0x130),
+4 -2
View File
@@ -61,13 +61,14 @@ import net.server.worker.BossLogWorker;
import net.server.worker.CharacterDiseaseWorker;
import net.server.worker.CouponWorker;
import net.server.worker.EventRecallCoordinatorWorker;
import net.server.worker.FredrickWorker;
import net.server.worker.DueyFredrickWorker;
import net.server.worker.InvitationWorker;
import net.server.worker.LoginCoordinatorWorker;
import net.server.worker.LoginStorageWorker;
import net.server.worker.RankingCommandWorker;
import net.server.worker.RankingLoginWorker;
import net.server.worker.ReleaseLockWorker;
import net.server.worker.RespawnWorker;
import net.server.world.World;
import org.apache.mina.core.buffer.IoBuffer;
@@ -904,8 +905,9 @@ public class Server {
tMan.register(new LoginCoordinatorWorker(), 60 * 60 * 1000, timeLeft);
tMan.register(new EventRecallCoordinatorWorker(), 60 * 60 * 1000, timeLeft);
tMan.register(new LoginStorageWorker(), 2 * 60 * 1000, 2 * 60 * 1000);
tMan.register(new FredrickWorker(), 60 * 60 * 1000, 60 * 60 * 1000);
tMan.register(new DueyFredrickWorker(), 60 * 60 * 1000, timeLeft);
tMan.register(new InvitationWorker(), 30 * 1000, 30 * 1000);
tMan.register(new RespawnWorker(), ServerConstants.RESPAWN_INTERVAL, ServerConstants.RESPAWN_INTERVAL);
timeLeft = getTimeLeftForNextDay();
MapleExpeditionBossLog.resetBossLogTable();
@@ -49,7 +49,6 @@ import tools.data.input.LittleEndianAccessor;
import client.MapleBuffStat;
import client.MapleCharacter;
import client.MapleJob;
import client.MapleStat;
import client.Skill;
import client.SkillFactory;
import client.autoban.AutobanFactory;
@@ -650,7 +649,7 @@ public abstract class AbstractDealDamageHandler extends AbstractMaplePacketHandl
// Find the base damage to base futher calculations on.
// Several skills have their own formula in this section.
int calcDmgMax = 0;
long calcDmgMax = 0;
if(magic && ret.skill != 0) {
calcDmgMax = (chr.getTotalMagic() * chr.getTotalMagic() / 1000 + chr.getTotalMagic()) / 30 + chr.getTotalInt() / 200;
@@ -714,7 +713,7 @@ public abstract class AbstractDealDamageHandler extends AbstractMaplePacketHandl
if(comboBuff > 6) {
// Advanced Combo
MapleStatEffect ceffect = SkillFactory.getSkill(advcomboid).getEffect(chr.getSkillLevel(advcomboid));
calcDmgMax = (int) Math.floor(calcDmgMax * (ceffect.getDamage() + 50) / 100 + 0.20 + (comboBuff - 5) * 0.04);
calcDmgMax = (long) Math.floor(calcDmgMax * (ceffect.getDamage() + 50) / 100 + 0.20 + (comboBuff - 5) * 0.04);
} else {
// Normal Combo
int skillLv = chr.getSkillLevel(oid);
@@ -722,7 +721,7 @@ public abstract class AbstractDealDamageHandler extends AbstractMaplePacketHandl
if(skillLv > 0) {
MapleStatEffect ceffect = SkillFactory.getSkill(oid).getEffect(skillLv);
calcDmgMax = (int) Math.floor(calcDmgMax * (ceffect.getDamage() + 50) / 100 + Math.floor((comboBuff - 1) * (skillLv / 6)) / 100);
calcDmgMax = (long) Math.floor(calcDmgMax * (ceffect.getDamage() + 50) / 100 + Math.floor((comboBuff - 1) * (skillLv / 6)) / 100);
}
}
@@ -850,7 +849,7 @@ public abstract class AbstractDealDamageHandler extends AbstractMaplePacketHandl
for (int j = 0; j < ret.numDamage; j++) {
int damage = lea.readInt();
int hitDmgMax = calcDmgMax;
long hitDmgMax = calcDmgMax;
if(ret.skill == Buccaneer.BARRAGE || ret.skill == ThunderBreaker.BARRAGE) {
if(j > 3)
hitDmgMax *= Math.pow(2, (j - 3));
@@ -870,7 +869,7 @@ public abstract class AbstractDealDamageHandler extends AbstractMaplePacketHandl
hitDmgMax = 82569000; // 30% of Max HP of strongest Dojo boss
}
int maxWithCrit = hitDmgMax;
long maxWithCrit = hitDmgMax;
if(canCrit) // They can crit, so up the max.
maxWithCrit *= 2;
@@ -47,6 +47,7 @@ public final class DueyHandler extends AbstractMaplePacketHandler {
String recipient = slea.readMapleAsciiString();
boolean quick = slea.readByte() != 0;
String message = quick ? slea.readMapleAsciiString() : "";
DueyProcessor.dueySendItem(c, inventId, itemPos, amount, mesos, message, recipient, quick);
} else if (operation == DueyProcessor.Actions.TOSERVER_REMOVE_PACKAGE.getCode()) {
int packageid = slea.readInt();
@@ -141,7 +141,7 @@ public final class EnterMTSHandler extends AbstractMaplePacketHandler {
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setVicious((short) rs.getInt("vicious"));
equip.setFlag((byte) rs.getInt("flag"));
equip.setFlag((short) rs.getInt("flag"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
@@ -209,7 +209,7 @@ public final class EnterMTSHandler extends AbstractMaplePacketHandler {
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLevel((byte) rs.getInt("level"));
equip.setFlag((byte) rs.getInt("flag"));
equip.setFlag((short) rs.getInt("flag"));
items.add(new MTSItemInfo((Item) equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
@@ -256,7 +256,7 @@ public final class EnterMTSHandler extends AbstractMaplePacketHandler {
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLevel((byte) rs.getInt("level"));
equip.setFlag((byte) rs.getInt("flag"));
equip.setFlag((short) rs.getInt("flag"));
items.add(new MTSItemInfo((Item) equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
@@ -321,7 +321,7 @@ public final class MTSHandler extends AbstractMaplePacketHandler {
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLevel((byte) rs.getInt("level"));
equip.setVicious((byte) rs.getInt("vicious"));
equip.setFlag((byte) rs.getInt("flag"));
equip.setFlag((short) rs.getInt("flag"));
equip.setPosition(c.getPlayer().getInventory(ItemConstants.getInventoryType(rs.getInt("itemid"))).getNextFreeSlot());
i = equip.copy();
}
@@ -568,7 +568,7 @@ public final class MTSHandler extends AbstractMaplePacketHandler {
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLevel((byte) rs.getInt("level"));
equip.setFlag((byte) rs.getInt("flag"));
equip.setFlag((short) rs.getInt("flag"));
items.add(new MTSItemInfo((Item) equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
@@ -623,7 +623,7 @@ public final class MTSHandler extends AbstractMaplePacketHandler {
equip.setWdef((short) rse.getInt("wdef"));
equip.setUpgradeSlots((byte) rse.getInt("upgradeslots"));
equip.setLevel((byte) rse.getInt("level"));
equip.setFlag((byte) rs.getInt("flag"));
equip.setFlag((short) rs.getInt("flag"));
items.add(new MTSItemInfo((Item) equip, rse.getInt("price"), rse.getInt("id"), rse.getInt("seller"), rse.getString("sellername"), rse.getString("sell_ends")));
}
}
@@ -686,7 +686,7 @@ public final class MTSHandler extends AbstractMaplePacketHandler {
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLevel((byte) rs.getInt("level"));
equip.setFlag((byte) rs.getInt("flag"));
equip.setFlag((short) rs.getInt("flag"));
items.add(new MTSItemInfo((Item) equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
@@ -747,7 +747,7 @@ public final class MTSHandler extends AbstractMaplePacketHandler {
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLevel((byte) rs.getInt("level"));
equip.setFlag((byte) rs.getInt("flag"));
equip.setFlag((short) rs.getInt("flag"));
items.add(new MTSItemInfo((Item) equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
@@ -841,7 +841,7 @@ public final class MTSHandler extends AbstractMaplePacketHandler {
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLevel((byte) rs.getInt("level"));
equip.setFlag((byte) rs.getInt("flag"));
equip.setFlag((short) rs.getInt("flag"));
items.add(new MTSItemInfo((Item) equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
@@ -22,6 +22,7 @@
package net.server.channel.handlers;
import net.AbstractMaplePacketHandler;
import scripting.event.EventInstanceManager;
import server.life.MapleMonster;
import server.maps.MapleMap;
import tools.MaplePacketCreator;
@@ -40,9 +41,11 @@ public final class MobDamageMobFriendlyHandler extends AbstractMaplePacketHandle
int attacker = slea.readInt();
slea.readInt();
int damaged = slea.readInt();
MapleMonster monster = c.getPlayer().getMap().getMonsterByOid(damaged);
MapleMap map = c.getPlayer().getMap();
MapleMonster monster = map.getMonsterByOid(damaged);
if (monster == null || c.getPlayer().getMap().getMonsterByOid(attacker) == null) {
if (monster == null || map.getMonsterByOid(attacker) == null) {
return;
}
@@ -50,26 +53,26 @@ public final class MobDamageMobFriendlyHandler extends AbstractMaplePacketHandle
if (monster.getHp() - damage < 1) { // friendly dies
if(monster.getId() == 9300102) {
monster.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, "The Watch Hog has been injured by the aliens. Better luck next time..."));
map.broadcastMessage(MaplePacketCreator.serverNotice(6, "The Watch Hog has been injured by the aliens. Better luck next time..."));
} else if (monster.getId() == 9300061) { //moon bunny
monster.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, "The Moon Bunny went home because he was sick."));
map.broadcastMessage(MaplePacketCreator.serverNotice(6, "The Moon Bunny went home because he was sick."));
} else if(monster.getId() == 9300093) { //tylus
monster.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, "Tylus has fallen by the overwhelming forces of the ambush."));
map.broadcastMessage(MaplePacketCreator.serverNotice(6, "Tylus has fallen by the overwhelming forces of the ambush."));
} else if(monster.getId() == 9300137) { //juliet
monster.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, "Juliet has fainted in the middle of the combat."));
map.broadcastMessage(MaplePacketCreator.serverNotice(6, "Juliet has fainted in the middle of the combat."));
} else if(monster.getId() == 9300138) { //romeo
monster.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, "Romeo has fainted in the middle of the combat."));
map.broadcastMessage(MaplePacketCreator.serverNotice(6, "Romeo has fainted in the middle of the combat."));
} else if(monster.getId() == 9400322 || monster.getId() == 9400327 || monster.getId() == 9400332) { //snowman
monster.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, "The Snowman has melted on the heat of the battle."));
map.broadcastMessage(MaplePacketCreator.serverNotice(6, "The Snowman has melted on the heat of the battle."));
} else if(monster.getId() == 9300162) { //delli
monster.getMap().broadcastMessage(MaplePacketCreator.serverNotice(6, "Delli vanished after the ambush, sheets still laying on the ground..."));
map.broadcastMessage(MaplePacketCreator.serverNotice(6, "Delli vanished after the ambush, sheets still laying on the ground..."));
}
c.getPlayer().getMap().killFriendlies(monster);
map.killFriendlies(monster);
} else {
if (monster.getId() == 9300061) {
MapleMap map = c.getPlayer().getEventInstance().getMapInstance(monster.getMap().getId());
map.addBunnyHit();
EventInstanceManager eim = map.getEventInstance();
if (eim != null) {
eim.friendlyDamaged(monster);
}
}
@@ -77,10 +80,10 @@ public final class MobDamageMobFriendlyHandler extends AbstractMaplePacketHandle
int remainingHp = monster.getHp();
if(remainingHp <= 0) {
remainingHp = 0;
monster.getMap().removeMapObject(monster);
map.removeMapObject(monster);
}
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.MobDamageMobFriendly(monster, damage, remainingHp), monster.getPosition());
map.broadcastMessage(MaplePacketCreator.MobDamageMobFriendly(monster, damage, remainingHp), monster.getPosition());
c.announce(MaplePacketCreator.enableActions());
}
}
@@ -72,7 +72,12 @@ public final class QuestActionHandler extends AbstractMaplePacketHandler {
short questid = slea.readShort();
MapleCharacter player = c.getPlayer();
MapleQuest quest = MapleQuest.getInstance(questid);
if (action == 1) { //Start Quest
if (action == 0) { // Restore lost item, Credits Darter ( Rajan )
slea.readInt();
int itemid = slea.readInt();
quest.restoreLostItem(player, itemid);
} else if (action == 1) { //Start Quest
int npc = slea.readInt();
if(!isNpcNearby(slea, player, quest, npc)) {
return;
@@ -28,9 +28,7 @@ import client.SkillFactory;
import client.autoban.AutobanFactory;
import client.status.MonsterStatusEffect;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import server.MapleStatEffect;
import server.life.MapleMonster;
import server.life.MapleMonsterInformationProvider;
@@ -45,12 +43,10 @@ public final class SummonDamageHandler extends AbstractDealDamageHandler {
private int monsterOid;
private int damage;
private boolean magic;
public SummonAttackEntry(int monsterOid, int damage, boolean magic) {
public SummonAttackEntry(int monsterOid, int damage) {
this.monsterOid = monsterOid;
this.damage = damage;
this.magic = magic;
}
public int getMonsterOid() {
@@ -61,9 +57,6 @@ public final class SummonDamageHandler extends AbstractDealDamageHandler {
return damage;
}
public boolean isMagic() {
return magic;
}
}
@Override
@@ -91,27 +84,22 @@ public final class SummonDamageHandler extends AbstractDealDamageHandler {
slea.skip(8); //Thanks Gerald :D, I failed lol (mob x,y and summon x,y)
for (int x = 0; x < numAttacked; x++) {
int monsterOid = slea.readInt(); // attacked oid
slea.skip(17);
boolean magic = slea.readByte() != 0;
slea.skip(18);
int damage = slea.readInt();
allDamage.add(new SummonAttackEntry(monsterOid, damage, magic));
allDamage.add(new SummonAttackEntry(monsterOid, damage));
}
player.getMap().broadcastMessage(player, MaplePacketCreator.summonAttack(player.getId(), summon.getObjectId(), direction, allDamage), summon.getPosition());
if (player.getMap().isOwnershipRestricted(player)) {
return;
}
Map<Integer, Integer> maxDmgEntries = new HashMap<>();
boolean magic = summonEffect.getWatk() == 0;
int maxDmg = calcMaxDamage(summonEffect, player, magic); // thanks Darter (YungMoozi) for reporting unchecked max dmg
for (SummonAttackEntry attackEntry : allDamage) {
int damage = attackEntry.getDamage();
MapleMonster target = player.getMap().getMonsterByOid(attackEntry.getMonsterOid());
if (target != null) {
Integer maxDmg = maxDmgEntries.get(attackEntry.getMonsterOid());
if (maxDmg == null) {
maxDmg = calcMaxDamage(summonEffect, player, attackEntry.isMagic()); // thanks Darter (YungMoozi) for reporting unchecked max dmg
maxDmgEntries.put(attackEntry.getMonsterOid(), maxDmg);
}
if (damage > maxDmg) {
AutobanFactory.DAMAGE_HACK.alert(c.getPlayer(), "Possible packet editing summon damage exploit.");
@@ -135,7 +123,9 @@ public final class SummonDamageHandler extends AbstractDealDamageHandler {
if (magic) {
maxDamage = player.calculateMaxBaseMagicDamage() * (0.05 * summonEffect.getMatk());
} else {
maxDamage = player.calculateMaxBaseDamage(player.getTotalWatk()) * (0.021 * summonEffect.getWatk());
int maxBaseDmg = player.calculateMaxBaseDamage(player.getTotalWatk()); // thanks Conrad for detecting some summons legitimately hitting over the calculated limit
float summonDmgMod = (maxBaseDmg >= 438) ? 0.054f : 0.077f;
maxDamage = maxBaseDmg * (summonDmgMod * summonEffect.getWatk());
}
return (int) maxDamage;
@@ -189,7 +189,7 @@ public final class UseCashItemHandler extends AbstractMaplePacketHandler {
if (eq == null) { //Check if the type is EQUIPMENT?
return;
}
byte flag = eq.getFlag();
short flag = eq.getFlag();
flag |= ItemConstants.LOCK;
if (eq.getExpiration() > -1) {
return; //No perma items pls
@@ -19,15 +19,17 @@
*/
package net.server.worker;
import client.processor.DueyProcessor;
import client.processor.FredrickProcessor;
/**
* @author Ronan
*/
public class FredrickWorker implements Runnable {
public class DueyFredrickWorker implements Runnable {
@Override
public void run() {
FredrickProcessor.runFredrickSchedule();
DueyProcessor.runDueyExpireSchedule();
}
}
+19
View File
@@ -0,0 +1,19 @@
package net.server.worker;
import net.server.Server;
import net.server.channel.Channel;
/**
* @author Resinate
*/
public class RespawnWorker implements Runnable {
@Override
public void run() {
for (Channel ch : Server.getInstance().getAllChannels()) {
if (!ch.getPlayerStorage().getAllCharacters().isEmpty()) {
ch.getMapFactory().updateMaps();
}
}
}
}
+16 -1
View File
@@ -96,6 +96,8 @@ import net.server.coordinator.MapleInviteCoordinator.InviteResult;
import net.server.coordinator.MapleInviteCoordinator.InviteType;
import net.server.coordinator.MapleMatchCheckerCoordinator;
import net.server.coordinator.MaplePartySearchCoordinator;
import server.maps.MapleMiniDungeon;
import server.maps.MapleMiniDungeonInfo;
/**
*
@@ -927,10 +929,23 @@ public class World {
break;
case CHANGE_LEADER:
MapleCharacter mc = party.getLeader().getPlayer();
MapleCharacter newLeader = target.getPlayer();
EventInstanceManager eim = mc.getEventInstance();
if(eim != null && eim.isEventLeader(mc)) {
eim.changedLeader(target.getPlayer());
eim.changedLeader(newLeader);
} else {
int oldLeaderMapid = mc.getMapId();
if (MapleMiniDungeonInfo.isDungeonMap(oldLeaderMapid)) {
if (oldLeaderMapid != newLeader.getMapId()) {
MapleMiniDungeon mmd = newLeader.getClient().getChannelServer().getMiniDungeon(oldLeaderMapid);
if(mmd != null) {
mmd.close();
}
}
}
}
party.setLeader(target);
break;
+16 -4
View File
@@ -68,6 +68,7 @@ import constants.GameConstants;
import constants.ItemConstants;
import constants.ServerConstants;
import server.MapleMarriage;
import server.expeditions.MapleExpeditionBossLog;
import server.life.MapleNPC;
import tools.Pair;
@@ -1067,13 +1068,24 @@ public class AbstractPlayerInteraction {
return (Pyramid) getPlayer().getPartyQuest();
}
public boolean createExpedition(MapleExpeditionType type) {
public int createExpedition(MapleExpeditionType type) {
return createExpedition(type, false, 0, 0);
}
public boolean createExpedition(MapleExpeditionType type, boolean silent, int minPlayers, int maxPlayers) {
MapleExpedition exped = new MapleExpedition(getPlayer(), type, silent, minPlayers, maxPlayers);
return exped.addChannelExpedition(getPlayer().getClient().getChannelServer());
public int createExpedition(MapleExpeditionType type, boolean silent, int minPlayers, int maxPlayers) {
MapleCharacter player = getPlayer();
MapleExpedition exped = new MapleExpedition(player, type, silent, minPlayers, maxPlayers);
int channel = player.getMap().getChannelServer().getId();
if (!MapleExpeditionBossLog.attemptBoss(player.getId(), channel, exped, false)) { // thanks Conrad for noticing missing expeditions entry limit
return 1;
}
if (exped.addChannelExpedition(player.getClient().getChannelServer())) {
return 0;
} else {
return -1;
}
}
public void endExpedition(MapleExpedition exped) {
@@ -518,6 +518,18 @@ public class EventInstanceManager {
invokeScriptFunction("friendlyKilled", mob, EventInstanceManager.this, hasKiller);
} catch (ScriptException | NoSuchMethodException ex) {} //optional
}
public void friendlyDamaged(final MapleMonster mob) {
try {
invokeScriptFunction("friendlyDamaged", EventInstanceManager.this, mob);
} catch (ScriptException | NoSuchMethodException ex) {} // optional
}
public void friendlyItemDrop(final MapleMonster mob) {
try {
invokeScriptFunction("friendlyItemDrop", EventInstanceManager.this, mob);
} catch (ScriptException | NoSuchMethodException ex) {} // optional
}
public void playerKilled(final MapleCharacter chr) {
ThreadManager.getInstance().newTask(new Runnable() {
+12 -7
View File
@@ -678,6 +678,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
final MapleCharacter mc;
mc = ps.getCharacterById(mpc.getId());
if (mc != null) {
mc.setChallenged(false);
mc.changeMap(map, map.getPortal(0));
mc.announce(MaplePacketCreator.serverNotice(6, LanguageConstants.getMessage(mc, LanguageConstants.CPQEntryLobby)));
TimerManager tMan = TimerManager.getInstance();
@@ -715,9 +716,8 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
}
}
private void warpoutCPQLobby() {
MapleMap lobbyMap = c.getPlayer().getMap();
MapleMap out = this.getWarpMap((lobbyMap.getId() > 980030000) ? 980000000 : 980030000);
private void warpoutCPQLobby(MapleMap lobbyMap) {
MapleMap out = lobbyMap.getChannelServer().getMapFactory().getMap((lobbyMap.getId() < 980030000) ? 980000000 : 980030000);
for (MapleCharacter mc : lobbyMap.getAllPlayers()) {
mc.resetCP();
mc.setTeam(-1);
@@ -729,6 +729,8 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
public void startCPQ(final MapleCharacter challenger, final int field) {
try {
cancelCPQLobby();
final MapleMap lobbyMap = getPlayer().getMap();
if (challenger != null) {
if (challenger.getParty() == null) {
throw new RuntimeException("Nao existe oponente!");
@@ -737,7 +739,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
for (MaplePartyCharacter mpc : challenger.getParty().getMembers()) {
MapleCharacter mc = ps.getCharacterById(mpc.getId());
if (mc != null) {
mc.changeMap(getPlayer().getMap(), getPlayer().getMap().getPortal(0));
mc.changeMap(lobbyMap, lobbyMap.getPortal(0));
TimerManager tMan = TimerManager.getInstance();
tMan.schedule(new Runnable() {
@Override
@@ -776,7 +778,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
mc.setMonsterCarnival(null);
}
} catch (NullPointerException npe) {
warpoutCPQLobby();
warpoutCPQLobby(lobbyMap);
return;
}
@@ -791,6 +793,8 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
public void startCPQ2(final MapleCharacter challenger, final int field) {
try {
cancelCPQLobby();
final MapleMap lobbyMap = getPlayer().getMap();
if (challenger != null) {
if (challenger.getParty() == null) {
throw new RuntimeException("Não existe oponente!");
@@ -799,7 +803,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
for (MaplePartyCharacter mpc : challenger.getParty().getMembers()) {
MapleCharacter mc = ps.getCharacterById(mpc.getId());
if (mc != null) {
mc.changeMap(getPlayer().getMap(), getPlayer().getMap().getPortal(0));
mc.changeMap(lobbyMap, lobbyMap.getPortal(0));
mapClock(10);
}
}
@@ -820,7 +824,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
mc.setMonsterCarnival(null);
}
} catch (NullPointerException npe) {
warpoutCPQLobby();
warpoutCPQLobby(lobbyMap);
return;
}
@@ -895,6 +899,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
final MapleCharacter mc;
mc = ps.getCharacterById(mpc.getId());
if (mc != null) {
mc.setChallenged(false);
mc.changeMap(map, map.getPortal(0));
mc.announce(MaplePacketCreator.serverNotice(6, LanguageConstants.getMessage(mc, LanguageConstants.CPQEntryLobby)));
TimerManager tMan = TimerManager.getInstance();
+27 -11
View File
@@ -23,15 +23,14 @@ package server;
import client.inventory.Item;
import java.util.Calendar;
import java.sql.Timestamp;
public class DueyPackage {
private String sender = null;
private Item item = null;
private int mesos = 0;
private String message = "";
private int day;
private int month;
private int year;
private Calendar timestamp;
private int packageId = 0;
public DueyPackage(int pId, Item item) {
@@ -76,18 +75,35 @@ public class DueyPackage {
}
public long sentTimeInMilliseconds() {
Calendar ts = timestamp;
if (ts != null) {
Calendar cal = Calendar.getInstance();
cal.setTime(ts.getTime());
cal.add(Calendar.MONTH, 1); // duey representation is in an array of months.
return cal.getTimeInMillis();
} else {
return 0;
}
}
public boolean isDeliveringTime() {
Calendar ts = timestamp;
if (ts != null) {
return ts.getTimeInMillis() >= System.currentTimeMillis();
} else {
return false;
}
}
public void setSentTime(Timestamp ts) {
Calendar cal = Calendar.getInstance();
cal.set(year, month, day);
cal.setTimeInMillis(ts.getTime());
cal.set(Calendar.HOUR, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTimeInMillis();
}
public void setSentTime(String sentTime) {
day = Integer.parseInt(sentTime.substring(0, 2));
month = Integer.parseInt(sentTime.substring(3, 5));
year = Integer.parseInt(sentTime.substring(6, 10));
this.timestamp = cal;
}
}
+22 -4
View File
@@ -106,6 +106,7 @@ public class MapleItemInformationProvider {
protected Map<Integer, String> nameCache = new HashMap<>();
protected Map<Integer, String> descCache = new HashMap<>();
protected Map<Integer, String> msgCache = new HashMap<>();
protected Map<Integer, Boolean> accountItemRestrictionCache = new HashMap<>();
protected Map<Integer, Boolean> dropRestrictionCache = new HashMap<>();
protected Map<Integer, Boolean> pickupRestrictionCache = new HashMap<>();
protected Map<Integer, Integer> getMesoCache = new HashMap<>();
@@ -1046,7 +1047,7 @@ public class MapleItemInformationProvider {
return getEquipById(equipId, -1);
}
Item getEquipById(int equipId, int ringId) {
private Item getEquipById(int equipId, int ringId) {
Equip nEquip;
nEquip = new Equip(equipId, (byte) 0, ringId);
nEquip.setQuantity((short) 1);
@@ -1084,11 +1085,11 @@ public class MapleItemInformationProvider {
} else if (stat.getKey().equals("tuc")) {
nEquip.setUpgradeSlots((byte) stat.getValue().intValue());
} else if (isUntradeableRestricted(equipId)) { // thanks Hyun & Thora for showing an issue with more than only "Untradeable" items being flagged as such here
byte flag = nEquip.getFlag();
short flag = nEquip.getFlag();
flag |= ItemConstants.UNTRADEABLE;
nEquip.setFlag(flag);
} else if (stats.get("fs") > 0) {
byte flag = nEquip.getFlag();
short flag = nEquip.getFlag();
flag |= ItemConstants.SPIKES;
nEquip.setFlag(flag);
equipCache.put(equipId, nEquip);
@@ -1230,6 +1231,23 @@ public class MapleItemInformationProvider {
untradeableCache.put(itemId, bRestricted);
return bRestricted;
}
public boolean isAccountRestricted(int itemId) {
if (accountItemRestrictionCache.containsKey(itemId)) {
return accountItemRestrictionCache.get(itemId);
}
boolean bRestricted = false;
if(itemId != 0) {
MapleData data = getItemData(itemId);
if (data != null) {
bRestricted = MapleDataTool.getIntConvert("info/accountSharable", data, 0) == 1;
}
}
accountItemRestrictionCache.put(itemId, bRestricted);
return bRestricted;
}
public boolean isLootRestricted(int itemId) {
if (dropRestrictionCache.containsKey(itemId)) {
@@ -1242,7 +1260,7 @@ public class MapleItemInformationProvider {
if (data != null) {
bRestricted = MapleDataTool.getIntConvert("info/tradeBlock", data, 0) == 1;
if (!bRestricted) {
bRestricted = MapleDataTool.getIntConvert("info/accountSharable", data, 0) == 1;
bRestricted = isAccountRestricted(itemId);
}
}
}
@@ -245,6 +245,8 @@ public class MapleSkillbookInformationProvider {
} catch(IOException ioe) {
System.out.println("Failed to read Quest.wz file. Line " + lineNumber + ": " + line);
ioe.printStackTrace();
} catch (Exception e) {
System.out.println("Failed to parse Quest.wz XML file."); // catch this exception, thanks to YonhNi
}
}
+9 -3
View File
@@ -1207,9 +1207,15 @@ public class MapleStatEffect {
}
private Rectangle calculateBoundingBox(Point posFrom, boolean facingLeft) {
int multiplier = facingLeft ? 1 : -1;
Point mylt = new Point(lt.x * multiplier + posFrom.x, lt.y + posFrom.y);
Point myrb = new Point(rb.x * multiplier + posFrom.x, rb.y + posFrom.y);
Point mylt;
Point myrb;
if (facingLeft) {
mylt = new Point(lt.x + posFrom.x, lt.y + posFrom.y);
myrb = new Point(rb.x + posFrom.x, rb.y + posFrom.y);
} else {
myrb = new Point(-lt.x + posFrom.x, rb.y + posFrom.y); // thanks Conrad, April for noticing a disturbance in AoE skill behavior after a hitched refactor here
mylt = new Point(-rb.x + posFrom.x, lt.y + posFrom.y);
}
Rectangle bounds = new Rectangle(mylt.x, mylt.y, myrb.x - mylt.x, myrb.y - mylt.y);
return bounds;
}
@@ -27,6 +27,7 @@ import java.sql.Timestamp;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import constants.ServerConstants;
import tools.DatabaseConnection;
import tools.Pair;
@@ -184,6 +185,10 @@ public class MapleExpeditionBossLog {
}
public static boolean attemptBoss(int cid, int channel, MapleExpedition exped, boolean log) {
if (!ServerConstants.USE_ENABLE_DAILY_EXPEDITIONS) {
return true;
}
BossLogEntry boss = BossLogEntry.getBossEntryByName(exped.getType().name());
if (boss == null) {
return true;
+54 -10
View File
@@ -52,6 +52,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import net.server.audit.locks.MonitoredReentrantLock;
@@ -100,6 +101,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
private int team;
private int parentMobOid = 0;
private final HashMap<Integer, AtomicLong> takenDamage = new HashMap<>();
private ScheduledFuture<?> monsterItemDrop = null;
private Runnable removeAfterAction = null;
private boolean availablePuppetUpdate = true;
@@ -512,14 +514,14 @@ public class MapleMonster extends AbstractLoadedMapleLife {
return avgExpReward + Math.sqrt(varExpReward);
}
private void distributePlayerExperience(MapleCharacter chr, float exp, float partyBonusMod, int totalPartyLevel, boolean highestPartyDamager, boolean whiteExpGain) {
private void distributePlayerExperience(MapleCharacter chr, float exp, float partyBonusMod, int totalPartyLevel, boolean highestPartyDamager, boolean whiteExpGain, boolean hasPartySharers) {
float playerExp = (ServerConstants.EXP_SPLIT_COMMON_MOD * chr.getLevel()) / totalPartyLevel;
if (highestPartyDamager) playerExp += ServerConstants.EXP_SPLIT_MVP_MOD;
playerExp *= exp;
float bonusExp = partyBonusMod * playerExp;
this.giveExpToCharacter(chr, playerExp, bonusExp, whiteExpGain);
this.giveExpToCharacter(chr, playerExp, bonusExp, whiteExpGain, hasPartySharers);
}
private void distributePartyExperience(Map<MapleCharacter, Long> partyParticipation, float expPerDmg, Set<MapleCharacter> underleveled, Map<Integer, Float> personalRatio, double sdevRatio) {
@@ -560,10 +562,11 @@ public class MapleMonster extends AbstractLoadedMapleLife {
float participationExp = partyDamage * expPerDmg;
// thanks Crypter for reporting an insufficiency on party exp bonuses
float partyBonusMod = (membersSize > 1) ? 0.05f * membersSize : 0.0f;
boolean hasPartySharers = membersSize > 1;
float partyBonusMod = hasPartySharers ? 0.05f * membersSize : 0.0f;
for (MapleCharacter mc : expMembers) {
distributePlayerExperience(mc, participationExp, partyBonusMod, totalPartyLevel, mc == participationMvp, isWhiteExpGain(mc, personalRatio, sdevRatio));
distributePlayerExperience(mc, participationExp, partyBonusMod, totalPartyLevel, mc == participationMvp, isWhiteExpGain(mc, personalRatio, sdevRatio), hasPartySharers);
}
}
@@ -636,7 +639,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
float exp = chrParticipation.getValue() * expPerDmg;
MapleCharacter chr = chrParticipation.getKey();
distributePlayerExperience(chr, exp, 0.0f, chr.getLevel(), true, isWhiteExpGain(chr, personalRatio, sdevRatio));
distributePlayerExperience(chr, exp, 0.0f, chr.getLevel(), true, isWhiteExpGain(chr, personalRatio, sdevRatio), false);
}
for (Map<MapleCharacter, Long> partyParticipation : partyExpDist.values()) {
@@ -657,13 +660,17 @@ public class MapleMonster extends AbstractLoadedMapleLife {
}
private float getStatusExpMultiplier(MapleCharacter attacker) {
private float getStatusExpMultiplier(MapleCharacter attacker, boolean hasPartySharers) {
float multiplier = 1.0f;
// thanks Prophecy & Aika for finding out Holy Symbol not being applied on party bonuses
Integer holySymbol = attacker.getBuffedValue(MapleBuffStat.HOLY_SYMBOL);
if (holySymbol != null) {
multiplier *= (1.0 + (holySymbol.doubleValue() / 100.0));
if (ServerConstants.USE_FULL_HOLY_SYMBOL) { // thanks Mordred, xinyifly, AyumiLove, andy33 for noticing HS hands out 20% of its potential on less than 3 players
multiplier *= (1.0 + (holySymbol.doubleValue() / 100.0));
} else {
multiplier *= (1.0 + (holySymbol.doubleValue() / (hasPartySharers ? 100.0 : 500.0)));
}
}
statiLock.lock();
@@ -689,10 +696,10 @@ public class MapleMonster extends AbstractLoadedMapleLife {
return (int) exp;
}
private void giveExpToCharacter(MapleCharacter attacker, Float personalExp, Float partyExp, boolean white) {
private void giveExpToCharacter(MapleCharacter attacker, Float personalExp, Float partyExp, boolean white, boolean hasPartySharers) {
if (attacker.isAlive()) {
if (personalExp != null) {
personalExp *= getStatusExpMultiplier(attacker);
personalExp *= getStatusExpMultiplier(attacker, hasPartySharers);
personalExp *= attacker.getExpRate();
} else {
personalExp = 0.0f;
@@ -706,7 +713,7 @@ public class MapleMonster extends AbstractLoadedMapleLife {
int _personalExp = expValueToInteger(personalExp); // assuming no negative xp here
if (partyExp != null) {
partyExp *= getStatusExpMultiplier(attacker);
partyExp *= getStatusExpMultiplier(attacker, hasPartySharers);
partyExp *= attacker.getExpRate();
partyExp *= ServerConstants.PARTY_BONUS_EXP_RATE;
} else {
@@ -722,6 +729,10 @@ public class MapleMonster extends AbstractLoadedMapleLife {
}
public List<MonsterDropEntry> retrieveRelevantDrops() {
if (this.getStats().isFriendly()) { // thanks Conrad for noticing friendly mobs not spawning loots after a recent update
return MapleMonsterInformationProvider.getInstance().retrieveEffectiveDrop(this.getId());
}
Map<Integer, MapleCharacter> pchars = map.getMapAllPlayers();
List<MapleCharacter> lootChars = new LinkedList<>();
@@ -814,6 +825,35 @@ public class MapleMonster extends AbstractLoadedMapleLife {
return looter != null ? looter : killer;
}
public void dropFromFriendlyMonster(long delay) {
final MapleMonster m = this;
monsterItemDrop = TimerManager.getInstance().register(new Runnable() {
@Override
public void run() {
if (!m.isAlive()) {
if (monsterItemDrop != null) {
monsterItemDrop.cancel(false);
}
return;
}
MapleMap map = m.getMap();
List<MapleCharacter> chrList = map.getAllPlayers();
if (!chrList.isEmpty()) {
MapleCharacter chr = (MapleCharacter) chrList.get(0);
EventInstanceManager eim = map.getEventInstance();
if (eim != null) {
eim.friendlyItemDrop(m);
}
map.dropFromFriendlyMonster(chr, m);
}
}
}, delay, delay);
}
private void dispatchUpdateQuestMobCount() {
Set<Integer> attackerChrids = takenDamage.keySet();
if(!attackerChrids.isEmpty()) {
@@ -2176,6 +2216,10 @@ public class MapleMonster extends AbstractLoadedMapleLife {
}
public void dispose() {
if (monsterItemDrop != null) {
monsterItemDrop.cancel(false);
}
this.getMap().dismissRemoveAfter(this);
disposeLocks();
}
+3 -3
View File
@@ -42,15 +42,15 @@ public enum FieldLimit {
//CASH_WEATHER_CONSUME_LIMIT(0x4000),
//NO_PET(0x8000), // Ariant colosseum-related?
//ANTI_MACRO_LIMIT(0x10000), // No notes
CANNOTJUMPDOWN(0x20000);
CANNOTJUMPDOWN(0x20000),
//SUMMON_NPC_LIMIT(0x40000); // Seems to .. disable Rush if 0x2 is set
//......... EVEN MORE LIMITS ............
//SUMMON_NPC_LIMIT(0x40000),
//NO_EXP_DECREASE(0x80000),
NO_EXP_DECREASE(0x80000),
//NO_DAMAGE_ON_FALLING(0x100000),
//PARCEL_OPEN_LIMIT(0x200000),
//DROP_LIMIT(0x400000),
DROP_LIMIT(0x400000);
//ROCKETBOOSTER_LIMIT(0x800000) //lol we don't even have mechanics <3
private long i;
+6 -35
View File
@@ -159,9 +159,6 @@ public class MapleMap {
private MapleCharacter mapOwner = null;
private long mapOwnerLastActivityTime = Long.MAX_VALUE;
// HPQ
private int riceCakes = 0;
private int bunnyDamage = 0;
// events
private boolean eventstarted = false, isMuted = false;
private MapleSnowball snowball0 = null;
@@ -1864,35 +1861,8 @@ public class MapleMap {
spawnMonster(mob);
}
public void addBunnyHit() {
bunnyDamage++;
if (bunnyDamage > 5) {
broadcastMessage(MaplePacketCreator.serverNotice(6, "The Moon Bunny is feeling sick. Please protect it so it can make delicious rice cakes."));
bunnyDamage = 0;
}
}
private void monsterItemDrop(final MapleMonster m, long delay) {
final ScheduledFuture<?> monsterItemDrop = TimerManager.getInstance().register(new Runnable() {
@Override
public void run() {
List<MapleMapObject> chrList = MapleMap.this.getPlayers();
if (m.isAlive() && !chrList.isEmpty()) {
MapleCharacter chr = (MapleCharacter) chrList.get(0);
if (m.getId() == 9300061) {
MapleMap.this.riceCakes++;
MapleMap.this.broadcastMessage(MaplePacketCreator.serverNotice(6, "The Moon Bunny made rice cake number " + (MapleMap.this.riceCakes) + "."));
}
dropFromFriendlyMonster(chr, m);
}
}
}, delay, delay);
if (!m.isAlive()) {
monsterItemDrop.cancel(true);
}
m.dropFromFriendlyMonster(delay);
}
public void spawnFakeMonsterOnGroundBelow(MapleMonster mob, Point pos) {
@@ -2259,6 +2229,11 @@ public class MapleMap {
}
public final void spawnItemDrop(final MapleMapObject dropper, final MapleCharacter owner, final Item item, Point pos, final byte dropType, final boolean playerDrop) {
if (FieldLimit.DROP_LIMIT.check(this.getFieldLimit())) { // thanks Conrad for noticing some maps shouldn't have loots available
this.disappearingItemDrop(dropper, owner, item, pos);
return;
}
final Point droppos = calcDropPos(pos, pos);
final MapleMapItem mdrop = new MapleMapItem(item, droppos, dropper, owner, owner.getClient(), dropType, playerDrop);
mdrop.setDropTime(Server.getInstance().getCurrentTime());
@@ -3938,10 +3913,6 @@ public class MapleMap {
return fieldLimit;
}
public void resetRiceCakes() {
this.riceCakes = 0;
}
public void allowSummonState(boolean b) {
MapleMap.this.allowSummons = b;
}
+1 -18
View File
@@ -19,17 +19,14 @@
*/
package server.maps;
import constants.ServerConstants;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ScheduledFuture;
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 scripting.event.EventInstanceManager;
import server.TimerManager;
public class MapleMapManager {
@@ -38,8 +35,6 @@ public class MapleMapManager {
private Map<Integer, MapleMap> maps = new HashMap<>();
private ScheduledFuture<?> updateTask;
private ReadLock mapsRLock;
private WriteLock mapsWLock;
@@ -51,13 +46,6 @@ public class MapleMapManager {
ReentrantReadWriteLock rrwl = new MonitoredReentrantReadWriteLock(MonitoredLockType.MAP_MANAGER);
this.mapsRLock = rrwl.readLock();
this.mapsWLock = rrwl.writeLock();
updateTask = TimerManager.getInstance().register(new Runnable() {
@Override
public void run() {
updateMaps();
}
}, ServerConstants.RESPAWN_INTERVAL);
}
public MapleMap resetMap(int mapid) {
@@ -136,7 +124,7 @@ public class MapleMapManager {
}
}
private void updateMaps() {
public void updateMaps() {
for (MapleMap map : getMaps().values()) {
map.respawn();
map.mobMpRecovery();
@@ -144,11 +132,6 @@ public class MapleMapManager {
}
public void dispose() {
if (updateTask != null) {
updateTask.cancel(false);
updateTask = null;
}
for (MapleMap map : getMaps().values()) {
map.dispose();
}
+23 -15
View File
@@ -49,19 +49,7 @@ public class MapleMiniDungeon {
timeoutTask = TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
lock.lock();
try {
List<MapleCharacter> lchr = new ArrayList<>(players);
for(MapleCharacter chr : lchr) {
chr.changeMap(baseMap);
}
dispose();
timeoutTask = null;
} finally {
lock.unlock();
}
close();
}
}, expireTime);
@@ -95,8 +83,28 @@ public class MapleMiniDungeon {
dispose();
return false;
}
return true;
} finally {
lock.unlock();
}
if (chr.isPartyLeader()) { // thanks Conrad for noticing party is not sent out of the MD as soon as leader leaves it
close();
}
return true;
}
public void close() {
lock.lock();
try {
List<MapleCharacter> lchr = new ArrayList<>(players);
for(MapleCharacter chr : lchr) {
chr.changeMap(baseMap);
}
dispose();
timeoutTask = null;
} finally {
lock.unlock();
}
+12 -3
View File
@@ -174,7 +174,7 @@ public class MapleQuest {
}
}
}
public boolean isAutoComplete() {
return autoPreComplete || autoComplete;
}
@@ -544,8 +544,13 @@ public class MapleQuest {
return ret;
}
public static boolean isExploitableQuest(short questid) {
return exploitableQuests.contains(questid);
public boolean restoreLostItem(MapleCharacter chr, int itemid) {
ItemAction itemAct = (ItemAction) startActs.get(MapleQuestActionType.ITEM);
if (itemAct != null) {
return itemAct.restoreLostItem(chr, itemid);
}
return false;
}
public int getMedalRequirement() {
@@ -572,6 +577,10 @@ public class MapleQuest {
return parent;
}
public static boolean isExploitableQuest(short questid) {
return exploitableQuests.contains(questid);
}
public static List<MapleQuest> getMatchedQuests(String search) {
List<MapleQuest> ret = new LinkedList<>();
+30 -2
View File
@@ -35,8 +35,10 @@ import java.util.List;
import provider.MapleData;
import provider.MapleDataTool;
import client.inventory.manipulator.MapleInventoryManipulator;
import server.MapleItemInformationProvider;
import server.quest.MapleQuest;
import server.quest.MapleQuestActionType;
import tools.FilePrinter;
import tools.MaplePacketCreator;
import tools.Pair;
import tools.Randomizer;
@@ -250,8 +252,34 @@ public class ItemAction extends MapleQuestAction {
}
return jobFound;
}
return true;
}
return true;
}
public boolean restoreLostItem(MapleCharacter chr, int itemid) {
if (!MapleItemInformationProvider.getInstance().isQuestItem(itemid)) {
return false;
}
// thanks danielktran (MapleHeroesD)
for (ItemData item : items) {
if (item.getId() == itemid) {
int missingQty = item.getCount() - chr.countItem(itemid);
if (missingQty > 0) {
if (!chr.canHold(itemid, missingQty)) {
chr.dropMessage(1, "Please check if you have enough space in your inventory.");
return false;
}
MapleInventoryManipulator.addById(chr.getClient(), item.getId(), (short) missingQty);
FilePrinter.print(FilePrinter.QUEST_RESTORE_ITEM, chr + " obtained " + itemid + " qty. " + missingQty + " from quest " + questID);
}
return true;
}
}
return false;
}
private class ItemData {
private final int map, id, count, job, gender;
+1
View File
@@ -21,6 +21,7 @@ public class FilePrinter {
LOG_LEAF = "interactions/MapleLeaves.txt",
LOG_GACHAPON = "interactions/Gachapon.txt",
LOG_CHAT = "interactions/ChatLog.txt",
QUEST_RESTORE_ITEM = "game/QuestItemRestore.txt",
EXCEPTION_CAUGHT = "game/ExceptionCaught.txt",
CLIENT_START = "game/ClientStartError.txt",
MAPLE_MAP = "game/MapleMap.txt",
+21 -11
View File
@@ -110,7 +110,7 @@ import constants.ServerConstants;
import constants.skills.Buccaneer;
import constants.skills.Corsair;
import constants.skills.ThunderBreaker;
import scripting.npc.NPCConversationManager;
import java.util.TimeZone;
import server.maps.AbstractMapleMapObject;
/**
@@ -120,20 +120,23 @@ import server.maps.AbstractMapleMapObject;
public class MaplePacketCreator {
public static final List<Pair<MapleStat, Integer>> EMPTY_STATUPDATE = Collections.emptyList();
private final static long FT_UT_OFFSET = 116444628000000000L;
private final static long FT_UT_OFFSET = 116444736010800000L + (10000L * TimeZone.getDefault().getOffset(System.currentTimeMillis())); // normalize with timezone offset suggested by Ari
private final static long DEFAULT_TIME = 150842304000000000L;//00 80 05 BB 46 E6 17 02
public final static long ZERO_TIME = 94354848000000000L;//00 40 E0 FD 3B 37 4F 01
private final static long PERMANENT = 150841440000000000L; // 00 C0 9B 90 7D E5 17 02
private static long getTime(long realTimestamp) {
if (realTimestamp == -1) {
return DEFAULT_TIME;//high number ll
} else if (realTimestamp == -2) {
return ZERO_TIME;
} else if (realTimestamp == -3) {
return PERMANENT;
private static long getTime(long utcTimestamp) {
if (utcTimestamp < 0 && utcTimestamp >= -3) {
if (utcTimestamp == -1) {
return DEFAULT_TIME; //high number ll
} else if (utcTimestamp == -2) {
return ZERO_TIME;
} else {
return PERMANENT;
}
}
return realTimestamp * 10000 + FT_UT_OFFSET;
return utcTimestamp * 10000 + FT_UT_OFFSET;
}
public static byte[] showHpHealed(int cid, int amount) {
@@ -361,7 +364,7 @@ public class MaplePacketCreator {
mplew.writeLong(getTime(q.getCompletionTime()));
}
}
private static void addExpirationTime(final MaplePacketLittleEndianWriter mplew, long time) {
mplew.writeLong(getTime(time)); // offset expiration time issue found thanks to Thora
}
@@ -2568,6 +2571,13 @@ public class MaplePacketCreator {
return mplew.getPacket();
}
public static byte[] updateWitchTowerScore(int score) {
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
mplew.writeShort(SendOpcode.WITCH_TOWER_SCORE_UPDATE.getValue());
mplew.write(score);
return mplew.getPacket();
}
public static byte[] silentRemoveItemFromMap(int oid) {
return removeItemFromMap(oid, 1, 0);
}