Several PQ platform patches + Quest complete count + Fast meso drop
Implemented CPQ challenges using the matching system. Fixed LanguageConstants statically acting for all players. Fixed OPQ's <On the Way Up> stage sometimes leading players to unexpected platforms. Fixed EllinPQ fountain not giving Altaire Fragment to players. Fixed "Lab - Unit" stage on RnJPQ, now using correlated sequences between the units. Fixed Fredrick handing out negative values of mesos to players. Improved "goto" command info. Implemented quest complete count. Fixed mobs still being "controlled" by players even though it's already dead. Concurrently protected adding items into inventory. Concurrently protected EXP gain through Writs of Solomon. Adjusted smoothly respawn rate of mobs in map (solo players in a map now experiences 75% of mobs spawned). Fixed mesos not being able to drop so frequently (prior 200ms threshold between drops). Tweaked matchchecking so that match checking doesn't outright dispose matching members on dismissal (match still sticks to the player until they answer or timeout). Fixed a dupe case within storage's item store. Added any-NPC scriptable to the source.
This commit is contained in:
@@ -64,6 +64,7 @@ import net.server.world.MapleParty;
|
||||
import net.server.world.MaplePartyCharacter;
|
||||
import net.server.world.PartyOperation;
|
||||
import net.server.world.World;
|
||||
import scripting.AbstractPlayerInteraction;
|
||||
import scripting.event.EventInstanceManager;
|
||||
import server.CashShop;
|
||||
import server.MapleItemInformationProvider;
|
||||
@@ -199,7 +200,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
private int expRate = 1, mesoRate = 1, dropRate = 1, expCoupon = 1, mesoCoupon = 1, dropCoupon = 1;
|
||||
private int omokwins, omokties, omoklosses, matchcardwins, matchcardties, matchcardlosses;
|
||||
private int owlSearch;
|
||||
private long lastfametime, lastUsedCashItem, lastExpression = 0, lastHealed, lastBuyback = 0, lastDeathtime, lastMesoDrop = -1, jailExpiration = -1;
|
||||
private long lastfametime, lastUsedCashItem, lastExpression = 0, lastHealed, lastBuyback = 0, lastDeathtime, jailExpiration = -1;
|
||||
private transient int localstr, localdex, localluk, localint_, localmagic, localwatk;
|
||||
private transient int equipmaxhp, equipmaxmp, equipstr, equipdex, equipluk, equipint_, equipmagic, equipwatk, localchairhp, localchairmp;
|
||||
private int localchairrate;
|
||||
@@ -2954,22 +2955,24 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
|
||||
public void gainGachaExp() {
|
||||
int expgain = 0;
|
||||
int currentgexp = gachaexp.get();
|
||||
long currentgexp = gachaexp.get();
|
||||
if ((currentgexp + exp.get()) >= ExpTable.getExpNeededForLevel(level)) {
|
||||
expgain += ExpTable.getExpNeededForLevel(level) - exp.get();
|
||||
|
||||
int nextneed = ExpTable.getExpNeededForLevel(level + 1);
|
||||
if ((currentgexp - expgain) >= nextneed) {
|
||||
if (currentgexp - expgain >= nextneed) {
|
||||
expgain += nextneed;
|
||||
}
|
||||
this.gachaexp.set(currentgexp - expgain);
|
||||
|
||||
this.gachaexp.set((int) (currentgexp - expgain));
|
||||
} else {
|
||||
expgain = this.gachaexp.getAndSet(0);
|
||||
}
|
||||
gainExp(expgain, false, false);
|
||||
gainExp(expgain, false, true);
|
||||
updateSingleStat(MapleStat.GACHAEXP, this.gachaexp.get());
|
||||
}
|
||||
|
||||
public void gainGachaExp(int gain) {
|
||||
public void addGachaExp(int gain) {
|
||||
updateSingleStat(MapleStat.GACHAEXP, gachaexp.addAndGet(gain));
|
||||
}
|
||||
|
||||
@@ -4296,6 +4299,10 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
return client;
|
||||
}
|
||||
|
||||
public AbstractPlayerInteraction getAbstractPlayerInteraction() {
|
||||
return client.getAbstractPlayerInteraction();
|
||||
}
|
||||
|
||||
public final List<MapleQuestStatus> getCompletedQuests() {
|
||||
synchronized (quests) {
|
||||
List<MapleQuestStatus> ret = new LinkedList<>();
|
||||
@@ -4930,8 +4937,9 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
|
||||
if (elapsedDays > 100) elapsedDays = 100;
|
||||
|
||||
int netMeso = (merchantmeso * (100 - elapsedDays)) / 100;
|
||||
return netMeso;
|
||||
long netMeso = (long) merchantmeso; // negative mesos issues found thanks to Flash, Vcoc
|
||||
netMeso = (netMeso * (100 - elapsedDays)) / 100;
|
||||
return (int) netMeso;
|
||||
}
|
||||
|
||||
public int getMesosTraded() {
|
||||
@@ -6906,6 +6914,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
|
||||
status.setForfeited(rs.getInt("forfeited"));
|
||||
status.setCompleted(rs.getInt("completed"));
|
||||
ret.quests.put(q.getId(), status);
|
||||
loadedQuestStatus.put(rs.getInt("queststatusid"), status);
|
||||
}
|
||||
@@ -7665,7 +7674,8 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
|
||||
public void resetBattleshipHp() {
|
||||
this.battleshipHp = 400 * getSkillLevel(SkillFactory.getSkill(Corsair.BATTLE_SHIP)) + ((getLevel() - 120) * 200);
|
||||
int bshipLevel = Math.max(getLevel() - 120, 0); // thanks alex12 for noticing battleship HP issues for low-level players
|
||||
this.battleshipHp = 400 * getSkillLevel(SkillFactory.getSkill(Corsair.BATTLE_SHIP)) + (bshipLevel * 200);
|
||||
}
|
||||
|
||||
public void resetEnteredScript() {
|
||||
@@ -8254,7 +8264,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
|
||||
deleteQuestProgressWhereCharacterId(con, id);
|
||||
|
||||
ps = con.prepareStatement("INSERT INTO queststatus (`queststatusid`, `characterid`, `quest`, `status`, `time`, `expires`, `forfeited`) VALUES (DEFAULT, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
|
||||
ps = con.prepareStatement("INSERT INTO queststatus (`queststatusid`, `characterid`, `quest`, `status`, `time`, `expires`, `forfeited`, `completed`) VALUES (DEFAULT, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
|
||||
PreparedStatement psf;
|
||||
try (PreparedStatement pse = con.prepareStatement("INSERT INTO questprogress VALUES (DEFAULT, ?, ?, ?, ?)")) {
|
||||
psf = con.prepareStatement("INSERT INTO medalmaps VALUES (DEFAULT, ?, ?, ?)");
|
||||
@@ -8267,6 +8277,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
ps.setInt(4, (int) (q.getCompletionTime() / 1000));
|
||||
ps.setLong(5, q.getExpirationTime());
|
||||
ps.setInt(6, q.getForfeited());
|
||||
ps.setInt(7, q.getCompleted());
|
||||
ps.executeUpdate();
|
||||
try (ResultSet rs = ps.getGeneratedKeys()) {
|
||||
rs.next();
|
||||
@@ -8549,8 +8560,10 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
|
||||
public synchronized void withdrawMerchantMesos() {
|
||||
int merchantMeso = this.getMerchantNetMeso();
|
||||
int playerMeso = this.getMeso();
|
||||
|
||||
if (merchantMeso > 0) {
|
||||
int possible = Integer.MAX_VALUE - merchantMeso;
|
||||
int possible = Integer.MAX_VALUE - playerMeso;
|
||||
|
||||
if (possible > 0) {
|
||||
if (possible < merchantMeso) {
|
||||
@@ -8562,7 +8575,6 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int playerMeso = this.getMeso();
|
||||
int nextMeso = playerMeso + merchantMeso;
|
||||
|
||||
if (nextMeso < 0) {
|
||||
@@ -9401,9 +9413,10 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
} else if (quest.getStatus().equals(MapleQuestStatus.Status.COMPLETED)) {
|
||||
MapleQuest mquest = quest.getQuest();
|
||||
short questid = mquest.getId();
|
||||
if(!mquest.isSameDayRepeatable() && !MapleQuest.isExploitableQuest(questid)) {
|
||||
if (!mquest.isSameDayRepeatable() && !MapleQuest.isExploitableQuest(questid)) {
|
||||
awardQuestPoint(ServerConstants.QUEST_POINT_PER_QUEST_COMPLETE);
|
||||
}
|
||||
quest.setCompleted(quest.getCompleted() + 1); // count quest completed Jayd's idea
|
||||
|
||||
announce(MaplePacketCreator.completeQuest(questid, quest.getCompletionTime()));
|
||||
} else if (quest.getStatus().equals(MapleQuestStatus.Status.NOT_STARTED)) {
|
||||
@@ -10040,14 +10053,6 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
whiteChat = !whiteChat;
|
||||
}
|
||||
|
||||
public boolean canDropMeso() {
|
||||
if (System.currentTimeMillis() - lastMesoDrop >= 200 || lastMesoDrop == -1) { //About 200 meso drops a minute
|
||||
lastMesoDrop = System.currentTimeMillis();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// These need to be renamed, but I am too lazy right now to go through the scripts and rename them...
|
||||
public String getPartyQuestItems() {
|
||||
return dataString;
|
||||
|
||||
@@ -888,7 +888,6 @@ public class MapleClient {
|
||||
player.cancelAllBuffs(true);
|
||||
|
||||
player.closePlayerInteractions();
|
||||
QuestScriptManager.getInstance().dispose(this);
|
||||
|
||||
if (!serverTransition) { // thanks MedicOP for detecting an issue with party leader change on changing channels
|
||||
removePartyPlayer(wserv);
|
||||
@@ -1463,18 +1462,8 @@ public class MapleClient {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getTrade() != null) {
|
||||
MapleTrade.cancelTrade(getPlayer(), MapleTrade.TradeResult.PARTNER_CANCEL);
|
||||
}
|
||||
|
||||
MapleHiredMerchant merchant = player.getHiredMerchant();
|
||||
if (merchant != null) {
|
||||
if (merchant.isOwner(getPlayer())) {
|
||||
merchant.setOpen(true);
|
||||
} else {
|
||||
merchant.removeVisitor(getPlayer());
|
||||
}
|
||||
}
|
||||
player.closePlayerInteractions();
|
||||
|
||||
player.unregisterChairBuff();
|
||||
server.getPlayerBuffStorage().addBuffsToStorage(player.getId(), player.getAllBuffs());
|
||||
server.getPlayerBuffStorage().addDiseasesToStorage(player.getId(), player.getAllDiseases());
|
||||
@@ -1540,6 +1529,7 @@ public class MapleClient {
|
||||
public void closePlayerScriptInteractions() {
|
||||
this.removeClickedNPC();
|
||||
NPCScriptManager.getInstance().dispose(this);
|
||||
QuestScriptManager.getInstance().dispose(this);
|
||||
}
|
||||
|
||||
public boolean attemptCsCoupon() {
|
||||
|
||||
@@ -65,7 +65,7 @@ public class MapleQuestStatus {
|
||||
private final List<Integer> medalProgress = new LinkedList<Integer>();
|
||||
private int npc;
|
||||
private long completionTime, expirationTime;
|
||||
private int forfeited = 0;
|
||||
private int forfeited = 0, completed = 0;
|
||||
private String customData;
|
||||
|
||||
public MapleQuestStatus(MapleQuest quest, Status status) {
|
||||
@@ -214,6 +214,10 @@ public class MapleQuestStatus {
|
||||
return forfeited;
|
||||
}
|
||||
|
||||
public int getCompleted() {
|
||||
return completed;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
if(!progress.containsKey(0) && !getMedalMaps().isEmpty()) {
|
||||
return Integer.toString(getMedalProgress());
|
||||
@@ -233,6 +237,14 @@ public class MapleQuestStatus {
|
||||
throw new IllegalArgumentException("Can't set forfeits to something lower than before.");
|
||||
}
|
||||
}
|
||||
|
||||
public void setCompleted(int completed) {
|
||||
if (completed >= this.completed) {
|
||||
this.completed = completed;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Can't set completes to something lower than before.");
|
||||
}
|
||||
}
|
||||
|
||||
public final void setCustomData(final String customData) {
|
||||
this.customData = customData;
|
||||
|
||||
@@ -204,6 +204,8 @@ public class CommandsExecutor {
|
||||
addCommand("enableauth", EnableAuthCommand.class);
|
||||
addCommand("toggleexp", ToggleExpCommand.class);
|
||||
addCommand("mylawn", MapOwnerClaimCommand.class);
|
||||
addCommand("bosshp", BossHpCommand.class);
|
||||
addCommand("mobhp", MobHpCommand.class);
|
||||
|
||||
commandsNameDesc.add(levelCommandsCursor);
|
||||
}
|
||||
@@ -212,8 +214,6 @@ public class CommandsExecutor {
|
||||
private void registerLv1Commands() {
|
||||
levelCommandsCursor = new Pair<>((List<String>) new ArrayList<String>(), (List<String>) new ArrayList<String>());
|
||||
|
||||
addCommand("bosshp", 1, BossHpCommand.class);
|
||||
addCommand("mobhp", 1, MobHpCommand.class);
|
||||
addCommand("whatdropsfrom", 1, WhatDropsFromCommand.class);
|
||||
addCommand("whodrops", 1, WhoDropsCommand.class);
|
||||
addCommand("buffme", 1, BuffMeCommand.class);
|
||||
@@ -291,7 +291,6 @@ public class CommandsExecutor {
|
||||
addCommand("givevp", 3, GiveVpCommand.class);
|
||||
addCommand("givems", 3, GiveMesosCommand.class);
|
||||
addCommand("giverp", 3, GiveRpCommand.class);
|
||||
addCommand("id", 3, IdCommand.class);
|
||||
addCommand("expeds", 3, ExpedsCommand.class);
|
||||
addCommand("kill", 3, KillCommand.class);
|
||||
addCommand("seed", 3, SeedCommand.class);
|
||||
@@ -307,7 +306,6 @@ public class CommandsExecutor {
|
||||
addCommand("startmapevent", 3, StartMapEventCommand.class);
|
||||
addCommand("stopmapevent", 3, StopMapEventCommand.class);
|
||||
addCommand("online2", 3, OnlineTwoCommand.class);
|
||||
addCommand("warpsnowball", 3, WarpSnowBallCommand.class);
|
||||
addCommand("ban", 3, BanCommand.class);
|
||||
addCommand("unban", 3, UnBanCommand.class);
|
||||
addCommand("healmap", 3, HealMapCommand.class);
|
||||
@@ -339,6 +337,7 @@ public class CommandsExecutor {
|
||||
addCommand("exprate", 4, ExpRateCommand.class);
|
||||
addCommand("mesorate", 4, MesoRateCommand.class);
|
||||
addCommand("droprate", 4, DropRateCommand.class);
|
||||
addCommand("bossdroprate", 4, BossDropRateCommand.class);
|
||||
addCommand("questrate", 4, QuestRateCommand.class);
|
||||
addCommand("travelrate", 4, TravelRateCommand.class);
|
||||
addCommand("fishrate", 4, FishingRateCommand.class);
|
||||
|
||||
@@ -27,23 +27,64 @@ import client.MapleCharacter;
|
||||
import client.command.Command;
|
||||
import client.MapleClient;
|
||||
import constants.GameConstants;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import net.server.Server;
|
||||
import server.MaplePortal;
|
||||
import server.maps.FieldLimit;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.MapleMapFactory;
|
||||
import server.maps.MapleMiniDungeonInfo;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class GotoCommand extends Command {
|
||||
|
||||
{
|
||||
setDescription("");
|
||||
|
||||
MapleMapFactory mapFactory = Server.getInstance().getWorlds().get(0).getChannels().get(0).getMapFactory();
|
||||
|
||||
List<Entry<String, Integer>> towns = new ArrayList<>(GameConstants.GOTO_TOWNS.entrySet());
|
||||
sortGotoEntries(towns);
|
||||
for (Map.Entry<String, Integer> e : towns) {
|
||||
GOTO_TOWNS_INFO += ("'" + e.getKey() + "' - #b" + (mapFactory.getMap(e.getValue()).getMapName()) + "#k\r\n");
|
||||
}
|
||||
|
||||
List<Entry<String, Integer>> areas = new ArrayList<>(GameConstants.GOTO_AREAS.entrySet());
|
||||
sortGotoEntries(areas);
|
||||
for (Map.Entry<String, Integer> e : areas) {
|
||||
GOTO_AREAS_INFO += ("'" + e.getKey() + "' - #b" + (mapFactory.getMap(e.getValue()).getMapName()) + "#k\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
public static String GOTO_TOWNS_INFO = "";
|
||||
public static String GOTO_AREAS_INFO = "";
|
||||
|
||||
private static void sortGotoEntries(List<Entry<String, Integer>> listEntries) {
|
||||
Collections.sort(listEntries, new Comparator<Entry<String, Integer>>() {
|
||||
@Override
|
||||
public int compare(Entry<String, Integer> e1, Entry<String, Integer> e2)
|
||||
{
|
||||
return e1.getValue().compareTo(e2.getValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MapleClient c, String[] params) {
|
||||
MapleCharacter player = c.getPlayer();
|
||||
if (params.length < 1){
|
||||
player.yellowMessage("Syntax: @goto <map name>");
|
||||
String sendStr = "Syntax: #b@goto <map name>#k. Available areas:\r\n\r\n#rTowns:#k\r\n" + GOTO_TOWNS_INFO;
|
||||
if (player.isGM()) {
|
||||
sendStr += ("\r\n#rAreas:#k\r\n" + GOTO_AREAS_INFO);
|
||||
}
|
||||
|
||||
player.getAbstractPlayerInteraction().npcTalk(9000020, sendStr);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -74,7 +115,13 @@ public class GotoCommand extends Command {
|
||||
player.saveLocationOnWarp();
|
||||
player.changeMap(target, targetPortal);
|
||||
} else {
|
||||
player.dropMessage(5, "Area '" + params[0] + "' is not registered.");
|
||||
// detailed info on goto available areas suggested thanks to Vcoc
|
||||
String sendStr = "Area '#r" + params[0] + "#k' is not available. Available areas:\r\n\r\n#rTowns:#k" + GOTO_TOWNS_INFO;
|
||||
if (player.isGM()) {
|
||||
sendStr += ("\r\n#rAreas:#k\r\n" + GOTO_AREAS_INFO);
|
||||
}
|
||||
|
||||
player.getAbstractPlayerInteraction().npcTalk(9000020, sendStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class WhatDropsFromCommand extends Command {
|
||||
if (name == null || name.equals("null") || drop.chance == 0){
|
||||
continue;
|
||||
}
|
||||
float chance = 1000000 / drop.chance / (!MapleMonsterInformationProvider.getInstance().isBoss(mobId) ? player.getDropRate() : player.getBossDropRate());
|
||||
float chance = Math.max(1000000 / drop.chance / (!MapleMonsterInformationProvider.getInstance().isBoss(mobId) ? player.getDropRate() : player.getBossDropRate()), 1);
|
||||
output += "- " + name + " (1/" + (int) chance + ")\r\n";
|
||||
} catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
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: Arthur L - Refactored command content into modules
|
||||
*/
|
||||
package client.command.commands.gm3;
|
||||
|
||||
import client.command.Command;
|
||||
import client.MapleClient;
|
||||
import client.MapleCharacter;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
|
||||
public class IdCommand extends Command {
|
||||
{
|
||||
setDescription("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MapleClient c, String[] params) {
|
||||
MapleCharacter player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !id <id>");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
try (BufferedReader dis = new BufferedReader(new InputStreamReader(new URL("http://www.mapletip.com/search_java.php?search_value=" + params[0] + "&check=true").openConnection().getInputStream()))) {
|
||||
String s;
|
||||
while ((s = dis.readLine()) != null) {
|
||||
player.dropMessage(s);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server, commands OdinMS-based
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2018 RonanLana
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -17,19 +17,18 @@
|
||||
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: Arthur L - Refactored command content into modules
|
||||
*/
|
||||
package client.command.commands.gm3;
|
||||
package client.command.commands.gm4;
|
||||
|
||||
import client.command.Command;
|
||||
import client.MapleClient;
|
||||
import client.MapleCharacter;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WarpSnowBallCommand extends Command {
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class BossDropRateCommand extends Command {
|
||||
{
|
||||
setDescription("");
|
||||
}
|
||||
@@ -37,10 +36,13 @@ public class WarpSnowBallCommand extends Command {
|
||||
@Override
|
||||
public void execute(MapleClient c, String[] params) {
|
||||
MapleCharacter player = c.getPlayer();
|
||||
List<MapleCharacter> chars = player.getMap().getAllPlayers();
|
||||
for (MapleCharacter chr : chars) {
|
||||
chr.saveLocationOnWarp();
|
||||
chr.changeMap(109060000, chr.getTeam());
|
||||
if (params.length < 1) {
|
||||
player.yellowMessage("Syntax: !bossdroprate <newrate>");
|
||||
return;
|
||||
}
|
||||
|
||||
int bossdroprate = Math.max(Integer.parseInt(params[0]), 1);
|
||||
c.getWorldServer().setBossDropRate(bossdroprate);
|
||||
c.getWorldServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "[Rate] Boss Drop Rate has been changed to " + bossdroprate + "x."));
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,5 @@ public class MesoRateCommand extends Command {
|
||||
int mesorate = Math.max(Integer.parseInt(params[0]), 1);
|
||||
c.getWorldServer().setMesoRate(mesorate);
|
||||
c.getWorldServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "[Rate] Meso Rate has been changed to " + mesorate + "x."));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ package client.inventory;
|
||||
import client.MapleClient;
|
||||
import constants.ServerConstants;
|
||||
import constants.ExpTable;
|
||||
import constants.ItemConstants;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -302,10 +303,33 @@ public class Equip extends Item {
|
||||
return stat;
|
||||
}
|
||||
|
||||
private static boolean isPhysicalWeapon(int itemid) {
|
||||
Equip eqp = (Equip) MapleItemInformationProvider.getInstance().getEquipById(itemid);
|
||||
return eqp.getWatk() >= eqp.getMatk();
|
||||
}
|
||||
|
||||
private boolean isNotWeaponAffinity(StatUpgrade name) {
|
||||
// WATK/MATK expected gains lessens outside of weapon affinity (physical/magic): Vcoc's idea
|
||||
|
||||
if (ItemConstants.isWeapon(this.getItemId())) {
|
||||
if (name.equals(StatUpgrade.incPAD)) {
|
||||
if (!isPhysicalWeapon(this.getItemId())) {
|
||||
return true;
|
||||
}
|
||||
} else if (name.equals(StatUpgrade.incMAD)) {
|
||||
if (isPhysicalWeapon(this.getItemId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void getUnitStatUpgrade(List<Pair<StatUpgrade, Integer>> stats, StatUpgrade name, int curStat, boolean isAttribute) {
|
||||
isUpgradeable = true;
|
||||
|
||||
int maxUpgrade = randomizeStatUpgrade((int)(1 + (curStat / getStatModifier(isAttribute))));
|
||||
int maxUpgrade = randomizeStatUpgrade((int)(1 + (curStat / (getStatModifier(isAttribute) * (isNotWeaponAffinity(name) ? 2.7 : 1)))));
|
||||
if(maxUpgrade == 0) return;
|
||||
|
||||
stats.add(new Pair<>(name, maxUpgrade));
|
||||
|
||||
@@ -69,10 +69,29 @@ public class MapleInventoryManipulator {
|
||||
}
|
||||
|
||||
public static boolean addById(MapleClient c, int itemId, short quantity, String owner, int petid, byte flag, long expiration) {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
MapleInventoryType type = ItemConstants.getInventoryType(itemId);
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
MapleInventory inv = chr.getInventory(type);
|
||||
MapleInventoryType type = ItemConstants.getInventoryType(itemId);
|
||||
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
MapleInventory inv = chr.getInventory(type);
|
||||
inv.lockInventory();
|
||||
try {
|
||||
return addByIdInternal(c, chr, type, inv, itemId, quantity, owner, petid, flag, expiration);
|
||||
} finally {
|
||||
inv.unlockInventory();
|
||||
}
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean addByIdInternal(MapleClient c, MapleCharacter chr, MapleInventoryType type, MapleInventory inv, int itemId, short quantity, String owner, int petid, byte flag, long expiration) {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
if (!type.equals(MapleInventoryType.EQUIP)) {
|
||||
short slotMax = ii.getSlotMax(c, itemId);
|
||||
List<Item> existing = inv.listById(itemId);
|
||||
@@ -166,15 +185,36 @@ public class MapleInventoryManipulator {
|
||||
|
||||
public static boolean addFromDrop(MapleClient c, Item item, boolean show, int petId) {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
MapleInventoryType type = item.getInventoryType();
|
||||
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
MapleInventory inv = chr.getInventory(type);
|
||||
inv.lockInventory();
|
||||
try {
|
||||
return addFromDropInternal(c, chr, type, inv, item, show, petId);
|
||||
} finally {
|
||||
inv.unlockInventory();
|
||||
}
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean addFromDropInternal(MapleClient c, MapleCharacter chr, MapleInventoryType type, MapleInventory inv, Item item, boolean show, int petId) {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
|
||||
if (ii.isPickupRestricted(item.getItemId()) && chr.haveItemWithId(item.getItemId(), true)) {
|
||||
c.announce(MaplePacketCreator.getInventoryFull());
|
||||
c.announce(MaplePacketCreator.showItemUnavailable());
|
||||
return false;
|
||||
}
|
||||
short quantity = item.getQuantity();
|
||||
MapleInventory inv = chr.getInventory(type);
|
||||
|
||||
if (!type.equals(MapleInventoryType.EQUIP)) {
|
||||
short slotMax = ii.getSlotMax(c, item.getItemId());
|
||||
List<Item> existing = inv.listById(item.getItemId());
|
||||
@@ -214,13 +254,13 @@ public class MapleInventoryManipulator {
|
||||
nItem.setPosition(newSlot);
|
||||
item.setPosition(newSlot);
|
||||
c.announce(MaplePacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, nItem))));
|
||||
if(MapleInventoryManipulator.isSandboxItem(nItem)) chr.setHasSandboxItem();
|
||||
if (MapleInventoryManipulator.isSandboxItem(nItem)) chr.setHasSandboxItem();
|
||||
}
|
||||
} else {
|
||||
Item nItem = new Item(item.getItemId(), (short) 0, quantity, petId);
|
||||
nItem.setExpiration(item.getExpiration());
|
||||
nItem.setFlag(item.getFlag());
|
||||
|
||||
|
||||
short newSlot = inv.addItem(nItem);
|
||||
if (newSlot == -1) {
|
||||
c.announce(MaplePacketCreator.getInventoryFull());
|
||||
@@ -230,7 +270,7 @@ public class MapleInventoryManipulator {
|
||||
nItem.setPosition(newSlot);
|
||||
item.setPosition(newSlot);
|
||||
c.announce(MaplePacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, nItem))));
|
||||
if(MapleInventoryManipulator.isSandboxItem(nItem)) chr.setHasSandboxItem();
|
||||
if (MapleInventoryManipulator.isSandboxItem(nItem)) chr.setHasSandboxItem();
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
}
|
||||
} else if (quantity == 1) {
|
||||
@@ -242,7 +282,7 @@ public class MapleInventoryManipulator {
|
||||
}
|
||||
item.setPosition(newSlot);
|
||||
c.announce(MaplePacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, item))));
|
||||
if(MapleInventoryManipulator.isSandboxItem(item)) chr.setHasSandboxItem();
|
||||
if (MapleInventoryManipulator.isSandboxItem(item)) chr.setHasSandboxItem();
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.ITEM, "Tried to pickup Equip id " + item.getItemId() + " containing more than 1 quantity --> " + quantity);
|
||||
c.announce(MaplePacketCreator.getInventoryFull());
|
||||
|
||||
@@ -40,6 +40,7 @@ import tools.data.input.SeekableLittleEndianAccessor;
|
||||
/**
|
||||
*
|
||||
* @author Matze
|
||||
* @author Ronan - inventory concurrency protection on storing items
|
||||
*/
|
||||
public class StorageProcessor {
|
||||
|
||||
@@ -97,15 +98,15 @@ public class StorageProcessor {
|
||||
short slot = slea.readShort();
|
||||
int itemId = slea.readInt();
|
||||
short quantity = slea.readShort();
|
||||
MapleInventoryType slotType = ItemConstants.getInventoryType(itemId);
|
||||
MapleInventory Inv = chr.getInventory(slotType);
|
||||
if (slot < 1 || slot > Inv.getSlotLimit()) { //player inv starts at one
|
||||
MapleInventoryType invType = ItemConstants.getInventoryType(itemId);
|
||||
MapleInventory inv = chr.getInventory(invType);
|
||||
if (slot < 1 || slot > inv.getSlotLimit()) { //player inv starts at one
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
FilePrinter.print(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to store item at slot " + slot);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
if (quantity < 1 || chr.getItemQuantity(itemId, false) < quantity) {
|
||||
if (quantity < 1) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
@@ -118,28 +119,39 @@ public class StorageProcessor {
|
||||
if (chr.getMeso() < storeFee) {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x0B));
|
||||
} else {
|
||||
MapleInventoryType invType = ItemConstants.getInventoryType(itemId);
|
||||
Item item = chr.getInventory(invType).getItem(slot).copy();
|
||||
if (item != null && item.getItemId() == itemId && (item.getQuantity() >= quantity || ItemConstants.isRechargeable(itemId))) {
|
||||
if (ItemConstants.isWeddingRing(itemId) || ItemConstants.isWeddingToken(itemId)) {
|
||||
Item item;
|
||||
|
||||
inv.lockInventory(); // thanks imbee for pointing a dupe within storage
|
||||
try {
|
||||
item = inv.getItem(slot);
|
||||
if (item != null && item.getItemId() == itemId && (item.getQuantity() >= quantity || ItemConstants.isRechargeable(itemId))) {
|
||||
if (ItemConstants.isWeddingRing(itemId) || ItemConstants.isWeddingToken(itemId)) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
if (ItemConstants.isRechargeable(itemId)) {
|
||||
quantity = item.getQuantity();
|
||||
}
|
||||
|
||||
MapleInventoryManipulator.removeFromSlot(c, invType, slot, quantity, false);
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
if (ItemConstants.isRechargeable(itemId)) {
|
||||
quantity = item.getQuantity();
|
||||
}
|
||||
|
||||
chr.gainMeso(-storeFee, false, true, false);
|
||||
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
MapleInventoryManipulator.removeFromSlot(c, invType, slot, quantity, false);
|
||||
item.setQuantity(quantity);
|
||||
storage.store(item);
|
||||
storage.sendStored(c, ItemConstants.getInventoryType(itemId));
|
||||
String itemName = MapleItemInformationProvider.getInstance().getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " stored " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")");
|
||||
chr.setUsedStorage();
|
||||
} finally {
|
||||
inv.unlockInventory();
|
||||
}
|
||||
|
||||
chr.gainMeso(-storeFee, false, true, false);
|
||||
|
||||
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
item.setQuantity(quantity);
|
||||
storage.store(item);
|
||||
storage.sendStored(c, ItemConstants.getInventoryType(itemId));
|
||||
String itemName = MapleItemInformationProvider.getInstance().getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " stored " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")");
|
||||
chr.setUsedStorage();
|
||||
}
|
||||
} else if (mode == 6) { // arrange items
|
||||
if(ServerConstants.USE_STORAGE_ITEM_SORT) storage.arrangeItems(c);
|
||||
|
||||
Reference in New Issue
Block a user