Implemented Kites, PlayerNPCs and C. Shop Surprise & Tweaked login
Added code support for Kites. Reviewed concurrent access issues with pet autopot. Addressed PlayerStorage issue where characters would not be properly deregistered from channel PlayerStorage in certain situations. Implemented harp quest (questid 3314) because of reasons. Added SFX to signalize KC/NLC subway departing/approaching. Changed traveling time values to work similarly to GMS. Properly developed the PlayerNPC feature in the source. Added autodeployable PlayerNPC system and Hall of Fame. Solved a glitch with NLC mayor's quiz questline that would allow a player to restart the quiz as many times one would see fit. Added a custom server flag that allows overwriting the ToT 999 mobs to a new value (technically it doesn't overwrite, rather sets the player at quest start with 999 - n credited mobs). Fixed permanent pets expiring after a while. Added code support for Cash Shop Surprise item. Reviewed login handler system as a whole, protecting many exposed flaws. Solved a bug with ULTRA_THREE_SNAILS sometimes taking wrong etc shell from inventory.
This commit is contained in:
@@ -191,8 +191,8 @@ public final class Channel {
|
||||
return players;
|
||||
}
|
||||
|
||||
public void removePlayer(MapleCharacter chr) {
|
||||
players.removePlayer(chr.getId());
|
||||
public boolean removePlayer(MapleCharacter chr) {
|
||||
return players.removePlayer(chr.getId()) != null;
|
||||
}
|
||||
|
||||
public int getChannelCapacity() {
|
||||
|
||||
@@ -445,29 +445,37 @@ public abstract class AbstractDealDamageHandler extends AbstractMaplePacketHandl
|
||||
AutobanFactory.FIX_DAMAGE.autoban(player, String.valueOf(totDamageToOneMonster) + " damage");
|
||||
}
|
||||
|
||||
if(ServerConstants.USE_ULTRA_THREE_SNAILS) {
|
||||
AbstractPlayerInteraction api = player.getClient().getAbstractPlayerInteraction();
|
||||
|
||||
int shellId;
|
||||
switch(totDamageToOneMonster) {
|
||||
case 10:
|
||||
shellId = 4000019;
|
||||
break;
|
||||
|
||||
case 25:
|
||||
shellId = 4000000;
|
||||
break;
|
||||
|
||||
default:
|
||||
shellId = 4000016;
|
||||
}
|
||||
|
||||
if(api.haveItem(shellId, 1)) {
|
||||
api.gainItem(shellId, (short)-1, false);
|
||||
totDamageToOneMonster *= player.getLevel();
|
||||
}
|
||||
else {
|
||||
player.dropMessage(5, "You ran out of shells to activate the hidden power of Three Snails.");
|
||||
int threeSnailsId = player.getJobType() * 10000000 + 1000;
|
||||
if(attack.skill == threeSnailsId) {
|
||||
if(ServerConstants.USE_ULTRA_THREE_SNAILS) {
|
||||
int skillLv = player.getSkillLevel(threeSnailsId);
|
||||
|
||||
if(skillLv > 0) {
|
||||
AbstractPlayerInteraction api = player.getClient().getAbstractPlayerInteraction();
|
||||
|
||||
int shellId;
|
||||
switch(skillLv) {
|
||||
case 1:
|
||||
shellId = 4000019;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
shellId = 4000000;
|
||||
break;
|
||||
|
||||
default:
|
||||
shellId = 4000016;
|
||||
}
|
||||
|
||||
if(api.haveItem(shellId, 1)) {
|
||||
api.gainItem(shellId, (short) -1, false);
|
||||
totDamageToOneMonster *= player.getLevel();
|
||||
} else {
|
||||
player.dropMessage(5, "You have ran out of shells to activate the hidden power of Three Snails.");
|
||||
}
|
||||
} else {
|
||||
totDamageToOneMonster = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public final class CashOperationHandler extends AbstractMaplePacketHandler {
|
||||
|
||||
if (action == 0x03) { // Item
|
||||
Item item = cItem.toItem();
|
||||
cs.addToInventory(item);
|
||||
cs.addToInventory(item);
|
||||
c.announce(MaplePacketCreator.showBoughtCashItem(item, c.getAccID()));
|
||||
} else { // Package
|
||||
List<Item> cashPackage = CashItemFactory.getPackage(cItem.getItemId());
|
||||
|
||||
48
src/net/server/channel/handlers/CashShopSurpriseHandler.java
Normal file
48
src/net/server/channel/handlers/CashShopSurpriseHandler.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
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
|
||||
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/>.
|
||||
*/
|
||||
package net.server.channel.handlers;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.inventory.Item;
|
||||
import net.AbstractMaplePacketHandler;
|
||||
import server.CashShop;
|
||||
import tools.data.input.SeekableLittleEndianAccessor;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class CashShopSurpriseHandler extends AbstractMaplePacketHandler {
|
||||
@Override
|
||||
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||
CashShop cs = c.getPlayer().getCashShop();
|
||||
|
||||
if(cs.isOpened()) {
|
||||
Item cssItem = cs.openCashShopSurprise();
|
||||
|
||||
if(cssItem != null) {
|
||||
c.announce(MaplePacketCreator.showCashShopMessage((byte) 0xA4));
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.showCashShopMessage((byte) 0x00));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public final class GeneralChatHandler extends net.AbstractMaplePacketHandler {
|
||||
String[] sp = s.split(" ");
|
||||
sp[0] = sp[0].toLowerCase().substring(1);
|
||||
|
||||
if(Commands.executeSolaxiaPlayerCommand(c, sp, heading)) {
|
||||
if(Commands.executeHeavenMSPlayerCommand(c, sp, heading)) {
|
||||
String command = "";
|
||||
for (String used : sp) {
|
||||
command += used + " ";
|
||||
|
||||
@@ -28,7 +28,7 @@ import net.AbstractMaplePacketHandler;
|
||||
import scripting.npc.NPCScriptManager;
|
||||
import server.life.MapleNPC;
|
||||
import server.maps.MapleMapObject;
|
||||
import server.maps.PlayerNPCs;
|
||||
import server.life.MaplePlayerNPC;
|
||||
import tools.FilePrinter;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.data.input.SeekableLittleEndianAccessor;
|
||||
@@ -78,8 +78,14 @@ public final class NPCTalkHandler extends AbstractMaplePacketHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (obj instanceof PlayerNPCs) {
|
||||
NPCScriptManager.getInstance().start(c, ((PlayerNPCs) obj).getId(), null);
|
||||
} else if (obj instanceof MaplePlayerNPC) {
|
||||
MaplePlayerNPC pnpc = (MaplePlayerNPC) obj;
|
||||
|
||||
if(pnpc.getScriptId() < 9977777) {
|
||||
NPCScriptManager.getInstance().start(c, pnpc.getScriptId(), "rank_user", null);
|
||||
} else {
|
||||
NPCScriptManager.getInstance().start(c, pnpc.getScriptId(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import client.MapleClient;
|
||||
import client.MapleCharacter;
|
||||
import client.inventory.Equip;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.MapleInventory;
|
||||
import client.inventory.MapleInventoryType;
|
||||
import net.AbstractMaplePacketHandler;
|
||||
import server.MapleInventoryManipulator;
|
||||
@@ -69,67 +70,74 @@ public final class PetAutoPotHandler extends AbstractMaplePacketHandler {
|
||||
itemId = slea.readInt();
|
||||
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
toUse = chr.getInventory(MapleInventoryType.USE).getItem(slot);
|
||||
MapleInventory useInv = chr.getInventory(MapleInventoryType.USE);
|
||||
|
||||
if(toUse != null) {
|
||||
if (toUse.getItemId() != itemId) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
toUseList = null;
|
||||
|
||||
// from now on, toUse becomes the "cursor" for the current pot being used
|
||||
if(toUse.getQuantity() <= 0) {
|
||||
if(!cursorOnNextAvailablePot(chr)) {
|
||||
useInv.lockInventory();
|
||||
try {
|
||||
toUse = useInv.getItem(slot);
|
||||
|
||||
if(toUse != null) {
|
||||
if (toUse.getItemId() != itemId) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MapleStatEffect stat = MapleItemInformationProvider.getInstance().getItemEffect(toUse.getItemId());
|
||||
hasHpGain = stat.getHp() > 0 || stat.getHpRate() > 0.0;
|
||||
hasMpGain = stat.getMp() > 0 || stat.getMpRate() > 0.0;
|
||||
|
||||
// contabilize the HP and MP gains from equipments on one's effective MaxHP/MaxMP
|
||||
Pair<Short, Short> maxHpMp = calcEffectivePool(chr);
|
||||
maxHp = maxHpMp.left;
|
||||
maxMp = maxHpMp.right;
|
||||
|
||||
incHp = stat.getHp();
|
||||
if(incHp <= 0 && hasHpGain) incHp = (short)(maxHp * stat.getHpRate());
|
||||
|
||||
incMp = stat.getMp();
|
||||
if(incMp <= 0 && hasMpGain) incMp = (short)(maxMp * stat.getMpRate());
|
||||
|
||||
curHp = chr.getHp();
|
||||
curMp = chr.getMp();
|
||||
|
||||
//System.out.println("\n-------------------\n");
|
||||
while(true) {
|
||||
do {
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, slot, (short) 1, false);
|
||||
stat.applyTo(chr);
|
||||
|
||||
curHp += incHp;
|
||||
curMp += incMp;
|
||||
|
||||
//System.out.println();
|
||||
//System.out.println("hp: " + hasHpGain + " hpgain " + incHp + " player hp " + curHp + " maxhp " + maxHp);
|
||||
//System.out.println("mp: " + hasMpGain + " mpgain " + incMp + " player mp " + curMp + " maxmp " + maxMp);
|
||||
//System.out.println("redo? " + (shouldReusePot() && toUse.getQuantity() > 0));
|
||||
} while(shouldReusePot() && toUse.getQuantity() > 0);
|
||||
|
||||
if(toUse.getQuantity() == 0 && shouldReusePot()) {
|
||||
// depleted out the current slot, fetch for more
|
||||
toUseList = null;
|
||||
|
||||
// from now on, toUse becomes the "cursor" for the current pot being used
|
||||
if(toUse.getQuantity() <= 0) {
|
||||
if(!cursorOnNextAvailablePot(chr)) {
|
||||
break; // no more pots available
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MapleStatEffect stat = MapleItemInformationProvider.getInstance().getItemEffect(toUse.getItemId());
|
||||
hasHpGain = stat.getHp() > 0 || stat.getHpRate() > 0.0;
|
||||
hasMpGain = stat.getMp() > 0 || stat.getMpRate() > 0.0;
|
||||
|
||||
// contabilize the HP and MP gains from equipments on one's effective MaxHP/MaxMP
|
||||
Pair<Short, Short> maxHpMp = calcEffectivePool(chr);
|
||||
maxHp = maxHpMp.left;
|
||||
maxMp = maxHpMp.right;
|
||||
|
||||
incHp = stat.getHp();
|
||||
if(incHp <= 0 && hasHpGain) incHp = (short)(maxHp * stat.getHpRate());
|
||||
|
||||
incMp = stat.getMp();
|
||||
if(incMp <= 0 && hasMpGain) incMp = (short)(maxMp * stat.getMpRate());
|
||||
|
||||
curHp = chr.getHp();
|
||||
curMp = chr.getMp();
|
||||
|
||||
//System.out.println("\n-------------------\n");
|
||||
while(true) {
|
||||
do {
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, slot, (short) 1, false);
|
||||
stat.applyTo(chr);
|
||||
|
||||
curHp += incHp;
|
||||
curMp += incMp;
|
||||
|
||||
//System.out.println();
|
||||
//System.out.println("hp: " + hasHpGain + " hpgain " + incHp + " player hp " + curHp + " maxhp " + maxHp);
|
||||
//System.out.println("mp: " + hasMpGain + " mpgain " + incMp + " player mp " + curMp + " maxmp " + maxMp);
|
||||
//System.out.println("redo? " + (shouldReusePot() && toUse.getQuantity() > 0));
|
||||
} while(shouldReusePot() && toUse.getQuantity() > 0);
|
||||
|
||||
if(toUse.getQuantity() == 0 && shouldReusePot()) {
|
||||
// depleted out the current slot, fetch for more
|
||||
|
||||
if(!cursorOnNextAvailablePot(chr)) {
|
||||
break; // no more pots available
|
||||
}
|
||||
} else {
|
||||
break; // gracefully finished it's job, quit the loop
|
||||
}
|
||||
} else {
|
||||
break; // gracefully finished it's job, quit the loop
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
useInv.unlockInventory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import client.inventory.Item;
|
||||
import client.inventory.MapleInventoryType;
|
||||
import client.inventory.MaplePet;
|
||||
import client.inventory.ModifyInventory;
|
||||
import constants.GameConstants;
|
||||
import constants.ItemConstants;
|
||||
import constants.ServerConstants;
|
||||
|
||||
@@ -51,6 +52,7 @@ import server.MapleShopFactory;
|
||||
import server.TimerManager;
|
||||
import server.maps.AbstractMapleMapObject;
|
||||
import server.maps.MaplePlayerShopItem;
|
||||
import server.maps.MapleKite;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.MapleTVEffect;
|
||||
import tools.MaplePacketCreator;
|
||||
@@ -82,7 +84,49 @@ public final class UseCashItemHandler extends AbstractMaplePacketHandler {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
if (itemType == 505) { // AP/SP reset
|
||||
|
||||
if (itemType == 504) { // vip teleport rock
|
||||
String error1 = "Either the player could not be found or you were trying to teleport to an illegal location.";
|
||||
boolean vip = slea.readByte() == 1;
|
||||
remove(c, itemId);
|
||||
if (!vip) {
|
||||
int mapId = slea.readInt();
|
||||
if (c.getChannelServer().getMapFactory().getMap(mapId).getForcedReturnId() == 999999999) {
|
||||
player.changeMap(c.getChannelServer().getMapFactory().getMap(mapId));
|
||||
} else {
|
||||
MapleInventoryManipulator.addById(c, itemId, (short) 1);
|
||||
c.getPlayer().dropMessage(1, error1);
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
}
|
||||
} else {
|
||||
String name = slea.readMapleAsciiString();
|
||||
MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(name);
|
||||
boolean success = false;
|
||||
if (victim != null) {
|
||||
MapleMap target = victim.getMap();
|
||||
if (c.getChannelServer().getMapFactory().getMap(victim.getMapId()).getForcedReturnId() == 999999999 || victim.getMapId() < 100000000) {
|
||||
if (victim.gmLevel() <= player.gmLevel()) {
|
||||
if (itemId == 5041000 || victim.getMapId() / player.getMapId() == 1) { //viprock & same continent
|
||||
player.changeMap(target, target.findClosestPlayerSpawnpoint(victim.getPosition()));
|
||||
success = true;
|
||||
} else {
|
||||
player.dropMessage(1, "You cannot teleport between continents with this teleport rock.");
|
||||
}
|
||||
} else {
|
||||
player.dropMessage(1, error1);
|
||||
}
|
||||
} else {
|
||||
player.dropMessage(1, "You cannot teleport to this map.");
|
||||
}
|
||||
} else {
|
||||
player.dropMessage(1, "Player could not be found in this channel.");
|
||||
}
|
||||
if (!success) {
|
||||
MapleInventoryManipulator.addById(c, itemId, (short) 1);
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
}
|
||||
}
|
||||
} else if (itemType == 505) { // AP/SP reset
|
||||
if(!player.isAlive()) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
@@ -368,9 +412,15 @@ public final class UseCashItemHandler extends AbstractMaplePacketHandler {
|
||||
break;
|
||||
}
|
||||
remove(c, itemId);
|
||||
} else if (itemType == 508) { //graduation banner
|
||||
slea.readMapleAsciiString(); // message, separated by 0A for lines
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
} else if (itemType == 508) { // graduation banner, thanks to tmskdl12
|
||||
MapleKite kite = new MapleKite(c.getPlayer(), slea.readMapleAsciiString(), itemId);
|
||||
|
||||
if (!GameConstants.isFreeMarketRoom(c.getPlayer().getMapId())) {
|
||||
c.getPlayer().getMap().spawnKite(kite);
|
||||
remove(c, itemId);
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.sendCannotSpawnKite());
|
||||
}
|
||||
} else if (itemType == 509) {
|
||||
String sendTo = slea.readMapleAsciiString();
|
||||
String msg = slea.readMapleAsciiString();
|
||||
@@ -408,47 +458,6 @@ public final class UseCashItemHandler extends AbstractMaplePacketHandler {
|
||||
player.getMap().broadcastMessage(player, MaplePacketCreator.changePetName(player, newName, 1), true);
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
remove(c, itemId);
|
||||
} else if (itemType == 504) { // vip teleport rock
|
||||
String error1 = "Either the player could not be found or you were trying to teleport to an illegal location.";
|
||||
boolean vip = slea.readByte() == 1;
|
||||
remove(c, itemId);
|
||||
if (!vip) {
|
||||
int mapId = slea.readInt();
|
||||
if (c.getChannelServer().getMapFactory().getMap(mapId).getForcedReturnId() == 999999999) {
|
||||
player.changeMap(c.getChannelServer().getMapFactory().getMap(mapId));
|
||||
} else {
|
||||
MapleInventoryManipulator.addById(c, itemId, (short) 1);
|
||||
c.getPlayer().dropMessage(1, error1);
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
}
|
||||
} else {
|
||||
String name = slea.readMapleAsciiString();
|
||||
MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(name);
|
||||
boolean success = false;
|
||||
if (victim != null) {
|
||||
MapleMap target = victim.getMap();
|
||||
if (c.getChannelServer().getMapFactory().getMap(victim.getMapId()).getForcedReturnId() == 999999999 || victim.getMapId() < 100000000) {
|
||||
if (victim.gmLevel() <= player.gmLevel()) {
|
||||
if (itemId == 5041000 || victim.getMapId() / player.getMapId() == 1) { //viprock & same continent
|
||||
player.changeMap(target, target.findClosestPlayerSpawnpoint(victim.getPosition()));
|
||||
success = true;
|
||||
} else {
|
||||
player.dropMessage(1, "You cannot teleport between continents with this teleport rock.");
|
||||
}
|
||||
} else {
|
||||
player.dropMessage(1, error1);
|
||||
}
|
||||
} else {
|
||||
player.dropMessage(1, "You cannot teleport to this map.");
|
||||
}
|
||||
} else {
|
||||
player.dropMessage(1, "Player could not be found in this channel.");
|
||||
}
|
||||
if (!success) {
|
||||
MapleInventoryManipulator.addById(c, itemId, (short) 1);
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
}
|
||||
}
|
||||
} else if (itemType == 520) {
|
||||
player.gainMeso(ii.getMeso(itemId), true, false, true);
|
||||
remove(c, itemId);
|
||||
|
||||
Reference in New Issue
Block a user