The great MCPQ Merge offensive

Fulfilled the lovely pull request #427 from @dragoso, which added in backing code content to HeavenMS.
Implemented structural changes for the Marriage wishlist, in order to receive, maintain and distribute gifts to spouses.
Added untradeable check on wishlist gift handler.
Adjusted CPQ drops to actually load from DB rathe than hard-coded.
Fixed CPQ "random disease to player/party" functionality not applying properly.
Adjusted how CPQ maps are generated. It directly loads a new area from WZ (this process should at least removes the player's spawned mobs) rather than reset the cache at every MCPQ creation.
This commit is contained in:
ronancpl
2019-03-15 12:08:21 -03:00
parent 1383efd6c3
commit 3bdf8cb2be
52 changed files with 2258 additions and 678 deletions
+26 -41
View File
@@ -68,6 +68,7 @@ import scripting.event.EventInstanceManager;
import server.CashShop;
import server.MapleItemInformationProvider;
import server.MapleItemInformationProvider.ScriptedItem;
import server.MapleMarriage;
import server.MaplePortal;
import server.MapleShop;
import server.MapleStatEffect;
@@ -130,7 +131,7 @@ import client.processor.FredrickProcessor;
import constants.ExpTable;
import constants.GameConstants;
import constants.ItemConstants;
import constants.LinguaConstants;
import constants.LanguageConstants;
import constants.ServerConstants;
import constants.skills.Aran;
import constants.skills.Beginner;
@@ -166,6 +167,7 @@ import server.life.MobSkillFactory;
import server.maps.MapleMapItem;
import net.server.audit.locks.MonitoredLockType;
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
import scripting.AbstractPlayerInteraction;
public class MapleCharacter extends AbstractMapleCharacterObject {
private static final MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
@@ -277,7 +279,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
private ScheduledFuture<?> extraRecoveryTask = null;
private ScheduledFuture<?> chairRecoveryTask = null;
private ScheduledFuture<?> pendantOfSpirit = null; //1122017
public ScheduledFuture<?> timer;
private ScheduledFuture<?> cpqSchedule = null;
private Lock chrLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.CHARACTER_CHR, true);
private Lock evtLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.CHARACTER_EVT, true);
private Lock petLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.CHARACTER_PET, true);
@@ -4383,6 +4385,16 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
evtLock.unlock();
}
}
public MapleMarriage getMarriageInstance() {
EventInstanceManager eim = getEventInstance();
if (eim != null || !(eim instanceof MapleMarriage)) {
return (MapleMarriage) eim;
} else {
return null;
}
}
public void resetExcluded(int petId) {
chrLock.lock();
@@ -9848,6 +9860,15 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
this.partyQuest = pq;
}
public void setCpqTimer(ScheduledFuture timer) {
this.cpqSchedule = timer;
}
public void clearCpqTimer() {
if (cpqSchedule != null) { cpqSchedule.cancel(true); }
cpqSchedule = null;
}
public final void empty(final boolean remove) {
if (dragonBloodSchedule != null) { dragonBloodSchedule.cancel(true); }
dragonBloodSchedule = null;
@@ -9886,8 +9907,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
if (pendantOfSpirit != null) { pendantOfSpirit.cancel(true); }
pendantOfSpirit = null;
if (timer != null) { timer.cancel(true); }
timer = null;
clearCpqTimer();
evtLock.lock();
try {
@@ -10130,9 +10150,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
private MapleFitness fitness;
private MapleOla ola;
private long snowballattack;
public static final List<String> itens = new ArrayList();
public static final List<Item> item = new ArrayList();
public byte getTeam() {
return team;
}
@@ -10289,38 +10307,5 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
public int getLingua() {
return getClient().getLingua();
}
public void setItens(String item) {
if (!itens.contains(item)) {
this.itens.add(item);
}
}
public static List<String> getItens() {
return itens;
}
public void setEquips(Item item) {
this.item.add(item);
}
public static List<Item> getItem() {
return item;
}
public Item getItemid(int numb) {
return this.item.get(numb);
}
public void removeItem(Item item) {
if (this.item.contains(item)) {
this.item.remove(item);
}
}
public void obterItens() {
for (Item item : getItem()) {
getClient().getAbstractPlayerInteraction().gainItem(item.getItemId(), item.getQuantity());
}
}
}
+16 -17
View File
@@ -21,7 +21,7 @@
*/
package client;
import tools.Randomizer;
import constants.GameConstants;
public enum MapleDisease {
NULL(0x0),
@@ -39,16 +39,20 @@ public enum MapleDisease {
private long i;
private boolean first;
private int disease;
private int mobskill;
private MapleDisease(long i) {
this.i = i;
this.first = false;
this(i, false, 0);
}
private MapleDisease(long i, int disease) {
private MapleDisease(long i, int skill) {
this(i, false, skill);
}
private MapleDisease(long i, boolean first, int skill) {
this.i = i;
this.disease = disease;
this.first = first;
this.mobskill = skill;
}
public long getValue() {
@@ -56,11 +60,11 @@ public enum MapleDisease {
}
public boolean isFirst() {
return first;
return first;
}
public int getDisease() {
return disease;
return mobskill;
}
public static MapleDisease ordinal(int ord) {
@@ -72,13 +76,8 @@ public enum MapleDisease {
}
public static final MapleDisease getRandom() {
while (true) {
for (MapleDisease dis : MapleDisease.values()) {
if (Randomizer.nextInt(MapleDisease.values().length) == 0) {
return dis;
}
}
}
MapleDisease[] diseases = GameConstants.CPQ_DISEASES;
return diseases[(int) (Math.random() * diseases.length)];
}
public static final MapleDisease getBySkill(final int skill) {
@@ -90,4 +89,4 @@ public enum MapleDisease {
return null;
}
}
}
+2 -1
View File
@@ -45,7 +45,8 @@ public enum ItemFactory {
CASH_CYGNUS(4, true),
CASH_ARAN(5, true),
MERCHANT(6, false),
CASH_OVERALL(7, true);
CASH_OVERALL(7, true),
MARRIAGE_GIFTS(8, false);
private final int value;
private final boolean account;
private static final Lock locks[] = new Lock[200]; // thanks Masterrulax for pointing out a bottleneck issue here
+10 -1
View File
@@ -436,7 +436,16 @@ public class MapleInventory implements Iterable<Item> {
}
public static boolean checkSpot(MapleCharacter chr, Item item) { // thanks Vcoc for noticing pshops not checking item stacks when taking item back
return checkSpotsAndOwnership(chr, Collections.singletonList(new Pair<>(item, item.getInventoryType())));
return checkSpot(chr, Collections.singletonList(item));
}
public static boolean checkSpot(MapleCharacter chr, List<Item> items) {
List<Pair<Item, MapleInventoryType>> listItems = new LinkedList<>();
for (Item item : items) {
listItems.add(new Pair<>(item, item.getInventoryType()));
}
return checkSpotsAndOwnership(chr, listItems);
}
public static boolean checkSpots(MapleCharacter chr, List<Pair<Item, MapleInventoryType>> items) {
+4
View File
@@ -1,5 +1,6 @@
package constants;
import client.MapleDisease;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
@@ -33,6 +34,9 @@ public class GameConstants {
private final static NumberFormat nfFormatter = new DecimalFormat("#,###,###,###");
private final static NumberFormat nfParser = NumberFormat.getInstance(ServerConstants.USE_UNITPRICE_WITH_COMMA ? Locale.FRANCE : Locale.UK);
public static final MapleDisease[] CPQ_DISEASES = {MapleDisease.SLOW, MapleDisease.SEDUCE, MapleDisease.STUN, MapleDisease.POISON,
MapleDisease.SEAL, MapleDisease.DARKNESS, MapleDisease.WEAKEN, MapleDisease.CURSE};
public static int getPlayerBonusDropRate(int slot) {
return(DROP_RATE_GAIN[slot]);
}
+73
View File
@@ -0,0 +1,73 @@
package constants;
import client.MapleCharacter;
/**
*
* @author Drago - Dragohe4rt
*/
public class LanguageConstants {
// Portugues
public static String CPQAzul;
public static String CPQErro;
public static String CPQEntrada;
public static String CPQEscolha;
public static String CPQVermelho;
public static String CPQPlayerExit;
public static String CPQEntradaLobby;
public static String CPQInicioEscolha;
public static String CPQTempoExtendido;
public static String CPQLiderNaoEncontrado;
public static String CPQInicioEscolhaEmEscolha;
public static String CPQInicioEscolhaEnviada;
public static LanguageConstants Linguas(MapleCharacter chr) {
if (chr.getLingua() == 0) {
LanguageConstants.CPQAzul = "Maple Azul";
LanguageConstants.CPQVermelho = "Maple Vermelho";
LanguageConstants.CPQTempoExtendido = "O tempo foi estendido.";
LanguageConstants.CPQPlayerExit = " deixou o Carnaval de Monstros.";
LanguageConstants.CPQErro = "Ocorreu um problema. Favor recriar a sala.";
LanguageConstants.CPQLiderNaoEncontrado = "Nao foi possivel encontrar o Lider.";
LanguageConstants.CPQInicioEscolha = "Inscreva-se no Festival de Monstros!\\r\\n";
LanguageConstants.CPQInicioEscolhaEmEscolha = "O grupo esta respondendo um desafio no momento.";
LanguageConstants.CPQInicioEscolhaEnviada = "Um desafio foi enviado para o grupo na sala. Aguarde um momento.";
LanguageConstants.CPQEscolha = "Nao foi possivel encontrar um grupo nesta sala.\\r\\nProvavelmente o grupo foi desfeito dentro da sala!";
LanguageConstants.CPQEntradaLobby = "Agora voce ira receber desafios de outros grupos. Se voce nao aceitar um desafio em 3 minutos, voce sera levado para fora.";
LanguageConstants.CPQEntrada = "Voce pode selecionar \"Invocar Monstros\", \"Habilidade\", ou \"Protetor\" como sua tatica durante o Carnaval dos Monstros. Use Tab a F1~F12 para acesso rapido!";
} else if (chr.getLingua() == 1) {
LanguageConstants.CPQAzul = "Maple Azul";
LanguageConstants.CPQVermelho = "Maple Rojo";
LanguageConstants.CPQTempoExtendido = "El tiempo se ha ampliado.";
LanguageConstants.CPQPlayerExit = " ha dejado el Carnaval de Monstruos.";
LanguageConstants.CPQLiderNaoEncontrado = "No se pudo encontrar el Lider.";
LanguageConstants.CPQInicioEscolha = "!Inscribete en el Festival de Monstruos!\\r\\n";
LanguageConstants.CPQErro = "Se ha producido un problema. Por favor, volver a crear una sala.";
LanguageConstants.CPQInicioEscolhaEmEscolha = "El grupo esta respondiendo un desafio en el momento.";
LanguageConstants.CPQInicioEscolhaEnviada = "Un desafio fue enviado al grupo en la sala. Espera un momento.";
LanguageConstants.CPQEscolha = "No se pudo encontrar un grupo en esta sala.\\r\\nProbablemente el grupo fue deshecho dentro de la sala!";
LanguageConstants.CPQEntradaLobby = "Ahora usted recibira los retos de otros grupos. Si usted no acepta un desafio en 3 minutos, usted sera llevado hacia fuera.";
LanguageConstants.CPQEntrada = "Usted puede seleccionar \"Invocar Monstruos \", \"Habilidad \", o \"Protector \" como su tactica durante el Carnaval de los Monstruos. Utilice Tab y F1 ~ F12 para acceso rapido!";
} else if (chr.getLingua() == 2) {
LanguageConstants.CPQAzul = "Maple Blue";
LanguageConstants.CPQVermelho = "Maple Red";
LanguageConstants.CPQPlayerExit = " left the Carnival of Monsters.";
LanguageConstants.CPQTempoExtendido = "The time has been extended.";
LanguageConstants.CPQLiderNaoEncontrado = "Could not find the Leader.";
LanguageConstants.CPQErro = "There was a problem. Please re-create a room.";
LanguageConstants.CPQInicioEscolha = "Sign up for the Monster Festival!\\r\\n";
LanguageConstants.CPQInicioEscolhaEmEscolha = "The group is currently facing a challenge.";
LanguageConstants.CPQInicioEscolhaEnviada = "A challenge has been sent to the group in the room. Please wait a while.";
LanguageConstants.CPQEscolha = "We could not find a group in this room.\\r\\nProbably the group was scrapped inside the room!";
LanguageConstants.CPQEntradaLobby = "You will now receive challenges from other groups. If you do not accept a challenge within 3 minutes, you will be taken out.";
LanguageConstants.CPQEntrada = "You can select \"Summon Monsters \", \"Ability \", or \"Protector \" as your tactic during the Monster Carnival. Use Tab and F1 ~ F12 for quick access!";
}
return null;
}
}
-69
View File
@@ -1,69 +0,0 @@
package constants;
import client.MapleCharacter;
/**
*
* @author Drago - Dragohe4rt
*/
public class LinguaConstants {
// Portugues
public static String CPQAzul;
public static String CPQErro;
public static String CPQEntrada;
public static String CPQEscolha;
public static String CPQVermelho;
public static String CPQPlayerExit;
public static String CPQEntradaLobby;
public static String CPQInicioEscolha;
public static String CPQTempoExtendido;
public static String CPQLiderNaoEncontrado;
public static String CPQInicioEscolhaEmEscolha;
public static LinguaConstants Linguas(MapleCharacter chr) {
if (chr.getLingua() == 0) {
LinguaConstants.CPQAzul = "Maple Azul";
LinguaConstants.CPQVermelho = "Maple Vermelho";
LinguaConstants.CPQTempoExtendido = "O tempo foi estendido.";
LinguaConstants.CPQPlayerExit = " deixou o Carnaval de Monstros.";
LinguaConstants.CPQErro = "Ocorreu um problema. Favor recriar a sala.";
LinguaConstants.CPQLiderNaoEncontrado = "Não foi possível encontrar o Lider.";
LinguaConstants.CPQInicioEscolha = "Inscreva-se no Festival de Monstros!\\r\\n";
LinguaConstants.CPQInicioEscolhaEmEscolha = "O grupo esta respondendo um desafio no momento.";
LinguaConstants.CPQEscolha = "Não foi possí­vel encontrar um grupo nesta sala.\\r\\nProvavelmente o grupo foi desfeito dentro da sala!";
LinguaConstants.CPQEntradaLobby = "[CPQ MapleStorySA] Agora você irá receber desafios de outros grupos. Se você não aceitar um desafio em 3 minutos, você será levado para fora.";
LinguaConstants.CPQEntrada = "Você pode selecionar \"Invocar Monstros\", \"Habilidade\", ou \"Protetor\" como sua tática durante o Carnaval dos Monstros. Use Tab a F1~F12 para acesso rápido!";
} else if (chr.getLingua() == 1) {
LinguaConstants.CPQAzul = "Maple Azul";
LinguaConstants.CPQVermelho = "Maple Rojo";
LinguaConstants.CPQTempoExtendido = "El tiempo se ha ampliado.";
LinguaConstants.CPQPlayerExit = " ha dejado el Carnaval de Monstruos.";
LinguaConstants.CPQLiderNaoEncontrado = "No se pudo encontrar el Lider.";
LinguaConstants.CPQInicioEscolha = "¡Inscríbete en el Festival de Monstruos!\\r\\n";
LinguaConstants.CPQErro = "Se ha producido un problema. Por favor, volver a crear una sala.";
LinguaConstants.CPQInicioEscolhaEmEscolha = "El grupo esta respondiendo un desafío en el momento.";
LinguaConstants.CPQEscolha = "No se pudo encontrar un grupo en esta sala.\\r\\nProbablemente el grupo fue deshecho dentro de la sala!";
LinguaConstants.CPQEntradaLobby = "[CPQ MapleStorySA] Ahora usted recibirá los retos de otros grupos. Si usted no acepta un desafío en 3 minutos, usted será llevado hacia fuera.";
LinguaConstants.CPQEntrada = "Usted puede seleccionar \"Invocar Monstruos \", \"Habilidad \", o \"Protector \" como su táctica durante el Carnaval de los Monstruos. Utilice Tab y F1 ~ F12 para acceso rápido!";
} else if (chr.getLingua() == 2) {
LinguaConstants.CPQAzul = "Maple Blue";
LinguaConstants.CPQVermelho = "Maple Red";
LinguaConstants.CPQPlayerExit = " left the Carnival of Monsters.";
LinguaConstants.CPQTempoExtendido = "The time has been extended.";
LinguaConstants.CPQLiderNaoEncontrado = "Could not find the Leader.";
LinguaConstants.CPQErro = "There was a problem. Please re-create a room.";
LinguaConstants.CPQInicioEscolha = "Sign up for the Monster Festival!\\r\\n";
LinguaConstants.CPQInicioEscolhaEmEscolha = "The group is currently facing a challenge.";
LinguaConstants.CPQEscolha = "We could not find a group in this room.\\r\\nProbably the group was scrapped inside the room!";
LinguaConstants.CPQEntradaLobby = "[CPQ MapleStorySA] You will now receive challenges from other groups. If you do not accept a challenge within 3 minutes, you will be taken out.";
LinguaConstants.CPQEntrada = "You can select \"Summon Monsters \", \"Ability \", or \"Protector \" as your tactic during the Monster Carnival. Use Tab and F1 ~ F12 for quick access!";
}
return null;
}
}
+3 -2
View File
@@ -34,7 +34,7 @@ public class ServerConstants {
public static final int BYPASS_PIC_EXPIRATION = 20; //Enables PIC bypass, which will remain active for that account by that client machine for N minutes. Set 0 to disable.
public static final int BYPASS_PIN_EXPIRATION = 15; //Enables PIN bypass, which will remain active for that account by that client machine for N minutes. Set 0 to disable.
public static final boolean AUTOMATIC_REGISTER = false; //Automatically register players when they login with a nonexistent username.
public static final boolean AUTOMATIC_REGISTER = true; //Automatically register players when they login with a nonexistent username.
public static final boolean BCRYPT_MIGRATION = true; //Performs a migration from old SHA-1 and SHA-512 password to bcrypt.
public static final boolean COLLECTIVE_CHARSLOT = false; //Available character slots are contabilized globally rather than per world server.
public static final boolean DETERRED_MULTICLIENT = false; //Enables multi-client and suspicious remote IP detection on the login system.
@@ -59,7 +59,7 @@ public class ServerConstants {
public static final boolean USE_CUSTOM_KEYSET = true; //Enables auto-setup of the HeavenMS's custom keybindings when creating characters.
public static final boolean USE_DEBUG = false; //Will enable some text prints on the client, oriented for debugging purposes.
public static final boolean USE_DEBUG_SHOW_INFO_EQPEXP = false; //Prints on the cmd all equip exp gain info.
public static boolean USE_DEBUG_SHOW_RCVD_PACKET = true; //Prints on the cmd all received packet ids.
public static boolean USE_DEBUG_SHOW_RCVD_PACKET = false; //Prints on the cmd all received packet ids.
public static boolean USE_DEBUG_SHOW_RCVD_MVLIFE = false; //Prints on the cmd all received move life content.
public static boolean USE_SUPPLY_RATE_COUPONS = true; //Allows rate coupons to be sold through the Cash Shop.
@@ -277,6 +277,7 @@ public class ServerConstants {
public static final int WEDDING_RESERVATION_TIMEOUT = 10; //Limit time in minutes for the couple to show up before cancelling the wedding reservation.
public static final int WEDDING_RESERVATION_INTERVAL = 60; //Time between wedding starts in minutes.
public static final int WEDDING_BLESS_EXP = 30000; //Exp gained per bless count.
public static final int WEDDING_GIFT_LIMIT = 1; //Max number of gifts per person to same wishlist on marriage instances.
public static final boolean WEDDING_BLESSER_SHOWFX = true; //Pops bubble sprite effect on players blessing the couple. Setting this false shows the blessing effect on the couple instead.
//Buyback Configuration
@@ -33,6 +33,7 @@ import server.life.MapleLifeFactory;
import server.life.MapleMonster;
import server.partyquest.MapleCarnivalFactory;
import server.partyquest.MapleCarnivalFactory.MCSkill;
import server.partyquest.MonsterCarnival;
import tools.MaplePacketCreator;
import tools.Pair;
import tools.data.input.SeekableLittleEndianAccessor;
@@ -46,87 +47,95 @@ public final class MonsterCarnivalHandler extends AbstractMaplePacketHandler {
@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
c.tryacquireClient();
try {
int tab = slea.readByte();
int num = slea.readByte();
int neededCP = 0;
if (tab == 0) {
final List<Pair<Integer, Integer>> mobs = c.getPlayer().getMap().getMobsToSpawn();
if (num >= mobs.size() || c.getPlayer().getCP() < mobs.get(num).right) {
c.announce(MaplePacketCreator.CPQMessage((byte) 1));
c.getSession().write(MaplePacketCreator.enableActions());
return;
}
final MapleMonster mob = MapleLifeFactory.getMonster(mobs.get(num).left);
if (c.getPlayer().getMonsterCarnival() != null) {
Point spawnPos = c.getPlayer().getMap().getRandomSP(c.getPlayer().getTeam());
if (!c.getPlayer().getMonsterCarnival().canSummon() && c.getPlayer().getTeam() == 0 || !c.getPlayer().getMonsterCarnival().canSummons() && c.getPlayer().getTeam() == 1) {
c.announce(MaplePacketCreator.CPQMessage((byte) 2));
c.getSession().write(MaplePacketCreator.enableActions());
try {
int tab = slea.readByte();
int num = slea.readByte();
int neededCP = 0;
if (tab == 0) {
final List<Pair<Integer, Integer>> mobs = c.getPlayer().getMap().getMobsToSpawn();
if (num >= mobs.size() || c.getPlayer().getCP() < mobs.get(num).right) {
c.announce(MaplePacketCreator.CPQMessage((byte) 1));
c.announce(MaplePacketCreator.enableActions());
return;
}
mob.setPosition(spawnPos);
if (c.getPlayer().getTeam() == 0) {
c.getPlayer().getMonsterCarnival().summon();
} else {
c.getPlayer().getMonsterCarnival().summons();
}
final MapleMonster mob = MapleLifeFactory.getMonster(mobs.get(num).left);
MonsterCarnival mcpq = c.getPlayer().getMonsterCarnival();
if (mcpq != null) {
if (!mcpq.canSummonR() && c.getPlayer().getTeam() == 0 || !mcpq.canSummonB() && c.getPlayer().getTeam() == 1) {
c.announce(MaplePacketCreator.CPQMessage((byte) 2));
c.announce(MaplePacketCreator.enableActions());
return;
}
if (c.getPlayer().getTeam() == 0) {
mcpq.summonR();
} else {
mcpq.summonB();
}
Point spawnPos = c.getPlayer().getMap().getRandomSP(c.getPlayer().getTeam());
mob.setPosition(spawnPos);
c.getPlayer().getMap().addMonsterSpawn(mob, 1, c.getPlayer().getTeam());
c.getSession().write(MaplePacketCreator.enableActions());
c.getPlayer().getMap().addAllMonsterSpawn(mob, 1, c.getPlayer().getTeam());
c.announce(MaplePacketCreator.enableActions());
}
neededCP = mobs.get(num).right;
} else if (tab == 1) { //debuffs
final List<Integer> skillid = c.getPlayer().getMap().getSkillIds();
if (num >= skillid.size()) {
c.getPlayer().dropMessage(5, "Ocorreu um erro.");
c.getSession().write(MaplePacketCreator.enableActions());
c.announce(MaplePacketCreator.enableActions());
return;
}
final MCSkill skil = MapleCarnivalFactory.getInstance().getSkill(skillid.get(num)); //ugh wtf
if (skil == null || c.getPlayer().getCP() < skil.cpLoss) {
final MCSkill skill = MapleCarnivalFactory.getInstance().getSkill(skillid.get(num)); //ugh wtf
if (skill == null || c.getPlayer().getCP() < skill.cpLoss) {
c.announce(MaplePacketCreator.CPQMessage((byte) 1));
c.getSession().write(MaplePacketCreator.enableActions());
c.announce(MaplePacketCreator.enableActions());
return;
}
final MapleDisease dis = skil.getDisease();
MapleParty inimigos = c.getPlayer().getParty().getEnemy();
if (skil.targetsAll) {
final MapleDisease dis = skill.getDisease();
MapleParty enemies = c.getPlayer().getParty().getEnemy();
if (skill.targetsAll) {
int chanceAcerto = 0;
if (dis.getDisease() == 121 || dis.getDisease() == 122 || dis.getDisease() == 125 || dis.getDisease() == 126) {
chanceAcerto = (int) (Math.random() * 100);
}
if (chanceAcerto <= 80) {
for (MaplePartyCharacter chrS : inimigos.getPartyMembers()) {
for (MaplePartyCharacter chrS : enemies.getPartyMembers()) {
if (dis == null) {
chrS.getPlayer().dispel();
} else {
chrS.getPlayer().giveDebuff(dis, skil.getSkill());
chrS.getPlayer().giveDebuff(dis, skill.getSkill());
}
if (!skil.targetsAll) {
if (!skill.targetsAll) {
break;
}
}
}
} else {
int amount = inimigos.getMembers().size() - 1;
int amount = enemies.getMembers().size() - 1;
int randd = (int) Math.floor(Math.random() * amount);
MapleCharacter chrApp = c.getChannelServer().getPlayerStorage().getCharacterById(inimigos.getMemberByPos(randd).getId());
MapleCharacter chrApp = c.getChannelServer().getPlayerStorage().getCharacterById(enemies.getMemberByPos(randd).getId());
if (chrApp != null && chrApp.getMap().isCPQMap()) {
if (dis == null) {
chrApp.dispel();
} else {
chrApp.giveDebuff(dis, skil.getSkill());
chrApp.giveDebuff(dis, skill.getSkill());
}
}
}
neededCP = skil.cpLoss;
c.getSession().write(MaplePacketCreator.enableActions());
neededCP = skill.cpLoss;
c.announce(MaplePacketCreator.enableActions());
} else if (tab == 2) { //protectors
final MCSkill skil = MapleCarnivalFactory.getInstance().getGuardian(num);
if (skil == null || c.getPlayer().getCP() < skil.cpLoss) {
final MCSkill skill = MapleCarnivalFactory.getInstance().getGuardian(num);
if (skill == null || c.getPlayer().getCP() < skill.cpLoss) {
c.announce(MaplePacketCreator.CPQMessage((byte) 1));
c.getSession().write(MaplePacketCreator.enableActions());
c.announce(MaplePacketCreator.enableActions());
return;
}
int success = c.getPlayer().getMap().spawnGuardian(c.getPlayer().getTeam(), num);
@@ -138,17 +147,20 @@ public final class MonsterCarnivalHandler extends AbstractMaplePacketHandler {
} else if (success == 2) {
c.announce(MaplePacketCreator.CPQMessage((byte) 3));
}
c.getSession().write(MaplePacketCreator.enableActions());
c.announce(MaplePacketCreator.enableActions());
return;
} else {
neededCP = skil.cpLoss;
neededCP = skill.cpLoss;
}
}
c.getPlayer().gainCP(-neededCP);
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.playerSummoned(c.getPlayer().getName(), tab, num));
}catch (Exception e) {
e.printStackTrace();
e.printStackTrace();
}
} finally {
c.releaseClient();
}
}
}
}
@@ -21,32 +21,34 @@
*/
package net.server.channel.handlers;
import client.MapleClient;
import client.MapleCharacter;
import client.inventory.MapleInventoryType;
import client.processor.DueyProcessor;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import net.AbstractMaplePacketHandler;
import client.inventory.manipulator.MapleInventoryManipulator;
import tools.DatabaseConnection;
import tools.data.input.SeekableLittleEndianAccessor;
import tools.Pair;
import tools.MaplePacketCreator;
import tools.packets.Wedding;
import net.server.world.World;
import net.server.channel.Channel;
import server.MapleItemInformationProvider;
import client.MapleClient;
import client.MapleCharacter;
import client.MapleRing;
import client.inventory.Equip;
import client.inventory.Item;
import client.inventory.MapleInventoryType;
import client.inventory.manipulator.MapleInventoryManipulator;
import client.processor.DueyProcessor;
import net.AbstractMaplePacketHandler;
import net.server.world.World;
import net.server.channel.Channel;
import server.MapleItemInformationProvider;
import scripting.event.EventInstanceManager;
import tools.DatabaseConnection;
import tools.Pair;
import tools.MaplePacketCreator;
import tools.data.input.SeekableLittleEndianAccessor;
import tools.packets.Wedding;
/**
* @author Jvlaple
* @author Ronan - major overhaul on Ring handling mechanics
* @author Drago/Dragohe4rt on Wishlist
* @author Drago/Dragohe4rt - on Wishlist
*/
public final class RingActionHandler extends AbstractMaplePacketHandler {
private static int getBoxId(int useItemId) {
@@ -463,57 +465,42 @@ public final class RingActionHandler extends AbstractMaplePacketHandler {
break;
case 9:
// By Drago/Dragohe4rt
// Groom and Bride's Wishlist
//short size = slea.readShort();
int amount = slea.readShort();
if (amount > 10) {
amount = 10;
}
for (int i = 0; i < amount; i++) {
c.getPlayer().setItens(slea.readMapleAsciiString());
}
//System.out.println("G&B WISHLIST: " + itemnames);
/*
if (c.getPlayer().getMarriageItemId() > -1) {
switch(c.getPlayer().getMarriageItemId()) {
case 10: // Premium Cathedral
c.getAbstractPlayerInteraction().gainItem(4031375, (short)1);
c.getAbstractPlayerInteraction().gainItem(4031395, (short)15);
break;
case 11: // Normal Cathedral
c.getAbstractPlayerInteraction().gainItem(4031480, (short)1);
c.getAbstractPlayerInteraction().gainItem(4031395, (short)15);
break;
case 20: // Premium Chapel
c.getAbstractPlayerInteraction().gainItem(4031376, (short)1);
c.getAbstractPlayerInteraction().gainItem(4031377, (short)15);
break;
case 21: // Normal Chapel
c.getAbstractPlayerInteraction().gainItem(4031481, (short)1);
c.getAbstractPlayerInteraction().gainItem(4031377, (short)15);
break;
default: {
System.out.println("Invalid Wedding Type for player " + c.getPlayer().getName() + "!");
break;
try {
// By Drago/Dragohe4rt
// Groom and Bride's Wishlist
MapleCharacter player = c.getPlayer();
EventInstanceManager eim = player.getEventInstance();
if (eim != null) {
boolean isMarrying = (player.getId() == eim.getIntProperty("groomId") || player.getId() == eim.getIntProperty("brideId"));
if (isMarrying) {
int amount = slea.readShort();
if (amount > 10) {
amount = 10;
}
String wishlistItems = "";
for (int i = 0; i < amount; i++) {
String s = slea.readMapleAsciiString();
wishlistItems += (s + "\r\n");
}
String wlKey;
if (player.getId() == eim.getIntProperty("groomId")) {
wlKey = "groomWishlist";
} else {
wlKey = "brideWishlist";
}
if (eim.getProperty(wlKey).contentEquals("")) {
eim.setProperty(wlKey, wishlistItems);
}
}
}
//c.getPlayer().setMarriageItemId(-1); ?????
}
} catch (NumberFormatException nfe) {}
if (c.getPlayer().getWishlist() == null) {
c.getPlayer().registerWishlist(itemnames);
}
if (c.getPlayer().getWedding() != null) {
if (c.getPlayer().getGender() == 0 ? c.getPlayer().getWedding().isExistantGroom(c.getPlayer().getId()) : c.getPlayer().getWedding().isExistantBride(c.getPlayer().getId())) {
c.getPlayer().getWedding().registerWishlist(c.getPlayer().getGender() == 1, itemnames);
}
}
*/
break;
default:
@@ -6,19 +6,23 @@
package net.server.channel.handlers;
import client.inventory.Item;
import client.inventory.MapleInventoryType;
import client.MapleCharacter;
import client.MapleClient;
import client.inventory.Equip;
import constants.ItemConstants;
import net.AbstractMaplePacketHandler;
import client.inventory.Item;
import client.inventory.MapleInventory;
import client.inventory.MapleInventoryType;
import client.inventory.manipulator.MapleInventoryManipulator;
import net.server.channel.Channel;
import scripting.event.EventInstanceManager;
import client.inventory.manipulator.MapleKarmaManipulator;
import constants.ItemConstants;
import constants.ServerConstants;
import net.AbstractMaplePacketHandler;
import server.MapleMarriage;
import tools.MaplePacketCreator;
import tools.data.input.SeekableLittleEndianAccessor;
import tools.packets.Wedding;
import java.util.Collections;
import java.util.List;
/**
*
@@ -28,43 +32,123 @@ public final class WeddingHandler extends AbstractMaplePacketHandler {
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
MapleCharacter chr = c.getPlayer();
final byte mode = slea.readByte();
Channel cs = c.getChannelServer();
if (mode == 6) { //additem
short slot = slea.readShort();
int itemid = slea.readInt();
short quantity = slea.readShort();
EventInstanceManager eim = c.getPlayer().getEventInstance();
if (eim != null) {
String name = eim.getProperty("brideId");
MapleCharacter chrs = cs.getPlayerStorage().getCharacterById(Integer.parseInt(name));
//MapleCharacter chrs = cs.getPlayerStorage().getCharacterById(3);
MapleInventoryType type = ItemConstants.getInventoryType(itemid);
Item item = chr.getInventory(type).getItem((byte) slot);
if (itemid == item.getItemId() && quantity <= item.getQuantity()) {
if(!(item instanceof Equip)) {
item = new Item(itemid, slot, quantity);
}
chrs.setEquips(item);
MapleInventoryManipulator.removeById(chr.getClient(), type, itemid, quantity, false, false);
c.announce(Wedding.OnWeddingGiftResult((byte) 0xB, chrs.getItens(), chrs.getItem()));
}
}
} else if (mode == 7) { // noiva abre e pega itens
byte inventId = slea.readByte();
int itemPos = slea.readByte();
MapleInventoryType inv = MapleInventoryType.getByType(inventId);
Item item = chr.getItemid(itemPos);
c.getAbstractPlayerInteraction().gainItem(item.getItemId(), item.getQuantity());
chr.removeItem(item);
c.announce(Wedding.OnWeddingGiftResult((byte) 0xF, chr.getItens(), chr.getItem()));
} else if (mode == 8) { // sair update?
c.tryacquireClient();
try {
MapleCharacter chr = c.getPlayer();
final byte mode = slea.readByte();
c.announce(MaplePacketCreator.enableActions());
} else {
System.out.println(mode);
if (mode == 6) { //additem
short slot = slea.readShort();
int itemid = slea.readInt();
short quantity = slea.readShort();
MapleMarriage marriage = c.getPlayer().getMarriageInstance();
if (marriage != null) {
try {
boolean groomWishlist = marriage.giftItemToSpouse(chr.getId());
String groomWishlistProp = "giftedItem" + (groomWishlist ? "G" : "B") + chr.getId();
int giftCount = marriage.getIntProperty(groomWishlistProp);
if (giftCount < ServerConstants.WEDDING_GIFT_LIMIT) {
int cid = marriage.getIntProperty(groomWishlist ? "groomId" : "brideId");
if (chr.getId() != cid) { // cannot gift yourself
MapleCharacter spouse = marriage.getPlayerById(cid);
if (spouse != null) {
MapleInventoryType type = ItemConstants.getInventoryType(itemid);
MapleInventory chrInv = chr.getInventory(type);
chrInv.lockInventory();
try {
Item item = chrInv.getItem((byte) slot);
if (item != null) {
if (!item.isUntradeable()) {
if (itemid == item.getItemId() && quantity <= item.getQuantity()) {
Item newItem = item.copy();
marriage.addGiftItem(groomWishlist, newItem);
MapleInventoryManipulator.removeFromSlot(c, type, slot, quantity, false, false);
if (ServerConstants.USE_ENFORCE_MERCHANT_SAVE) chr.saveCharToDB(false);
marriage.saveGiftItemsToDb(c, groomWishlist, cid);
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(newItem);
marriage.setIntProperty(groomWishlistProp, giftCount + 1);
c.announce(Wedding.OnWeddingGiftResult((byte) 0xB, marriage.getWishlistItems(groomWishlist), Collections.singletonList(newItem)));
}
} else {
c.announce(Wedding.OnWeddingGiftResult((byte) 0xE, marriage.getWishlistItems(groomWishlist), null));
}
}
} finally {
chrInv.unlockInventory();
}
} else {
c.announce(Wedding.OnWeddingGiftResult((byte) 0xE, marriage.getWishlistItems(groomWishlist), null));
}
} else {
c.announce(Wedding.OnWeddingGiftResult((byte) 0xE, marriage.getWishlistItems(groomWishlist), null));
}
} else {
c.announce(Wedding.OnWeddingGiftResult((byte) 0xC, marriage.getWishlistItems(groomWishlist), null));
}
} catch (NumberFormatException nfe) {}
} else {
c.announce(MaplePacketCreator.enableActions());
}
} else if (mode == 7) { // take items
slea.readByte(); // invType
int itemPos = slea.readByte();
MapleMarriage marriage = chr.getMarriageInstance();
if (marriage != null) {
Boolean groomWishlist = marriage.isMarriageGroom(chr);
if (groomWishlist != null) {
Item item = marriage.getGiftItem(c, groomWishlist, itemPos);
if (item != null) {
if (MapleInventory.checkSpot(chr, item)) {
marriage.removeGiftItem(groomWishlist, item);
marriage.saveGiftItemsToDb(c, groomWishlist, chr.getId());
MapleInventoryManipulator.addFromDrop(c, item, true);
c.announce(Wedding.OnWeddingGiftResult((byte) 0xF, marriage.getWishlistItems(groomWishlist), marriage.getGiftItems(c, groomWishlist)));
} else {
c.getPlayer().dropMessage(1, "Free a slot on your inventory before collecting this item.");
c.announce(Wedding.OnWeddingGiftResult((byte) 0xE, marriage.getWishlistItems(groomWishlist), marriage.getGiftItems(c, groomWishlist)));
}
} else {
c.getPlayer().dropMessage(1, "You have already collected this item.");
c.announce(Wedding.OnWeddingGiftResult((byte) 0xE, marriage.getWishlistItems(groomWishlist), marriage.getGiftItems(c, groomWishlist)));
}
}
} else {
List<Item> items = c.getAbstractPlayerInteraction().getUnclaimedMarriageGifts();
try {
Item item = items.get(itemPos);
if (MapleInventory.checkSpot(chr, item)) {
items.remove(itemPos);
MapleMarriage.saveGiftItemsToDb(c, items, chr.getId());
MapleInventoryManipulator.addFromDrop(c, item, true);
c.announce(Wedding.OnWeddingGiftResult((byte) 0xF, Collections.singletonList(""), items));
} else {
c.getPlayer().dropMessage(1, "Free a slot on your inventory before collecting this item.");
c.announce(Wedding.OnWeddingGiftResult((byte) 0xE, Collections.singletonList(""), items));
}
} catch (Exception e) {
c.getPlayer().dropMessage(1, "You have already collected this item.");
c.announce(Wedding.OnWeddingGiftResult((byte) 0xE, Collections.singletonList(""), items));
}
}
} else if (mode == 8) { // out of Wedding Registry
c.announce(MaplePacketCreator.enableActions());
} else {
System.out.println(mode);
}
} finally {
c.releaseClient();
}
}
}
@@ -182,7 +182,7 @@ public class MaplePartyCharacter {
case 222:
return "Arquimago (Gelo, Raio)";
case 230:
return "Clérigo";
return "Clerigo";
case 231:
return "Sacerdote";
case 232:
@@ -191,7 +191,7 @@ public class MaplePartyCharacter {
case 300:
return "Arqueiro";
case 310:
return "Caçador";
return "Cacador";
case 311:
return "Rastreador";
case 312:
@@ -231,7 +231,7 @@ public class MaplePartyCharacter {
case 521:
return "Bucaneiro";
case 522:
return "Captain";
return "Capitao";
default:
return "Unknown Job";
+8 -4
View File
@@ -55,7 +55,6 @@ import tools.MaplePacketCreator;
import client.MapleCharacter;
import client.MapleClient;
import client.MapleQuestStatus;
import client.MapleStat;
import client.SkillFactory;
import client.inventory.Equip;
import client.inventory.Item;
@@ -68,6 +67,7 @@ import client.inventory.manipulator.MapleInventoryManipulator;
import constants.GameConstants;
import constants.ItemConstants;
import constants.ServerConstants;
import server.MapleMarriage;
import server.life.MapleNPC;
import tools.Pair;
@@ -1048,6 +1048,10 @@ public class AbstractPlayerInteraction {
return list;
}
public List<Item> getUnclaimedMarriageGifts() {
return MapleMarriage.loadGiftItemsFromDb(this.getClient(), this.getPlayer().getId());
}
public boolean startDungeonInstance(int dungeonid) {
return c.getChannelServer().addMiniDungeon(dungeonid);
}
@@ -1101,7 +1105,7 @@ public class AbstractPlayerInteraction {
c.announce(MaplePacketCreator.getNPCTalk(npcid, (byte) 0, message, "00 00", (byte) 0));
}
public long getCurrentTime() {
return System.currentTimeMillis();
}
public long getCurrentTime() {
return Server.getInstance().getCurrentTime();
}
}
@@ -55,10 +55,16 @@ import tools.DatabaseConnection;
import client.MapleCharacter;
import client.SkillFactory;
import client.Skill;
import client.inventory.Item;
import client.inventory.ItemFactory;
import client.inventory.MapleInventory;
import client.inventory.MapleInventoryType;
import client.inventory.manipulator.MapleInventoryManipulator;
import constants.ItemConstants;
import constants.ServerConstants;
import java.awt.Point;
import java.sql.Connection;
import java.util.Arrays;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
@@ -73,6 +79,7 @@ import server.ThreadManager;
import server.life.MapleLifeFactory;
import server.life.MapleNPC;
import tools.MaplePacketCreator;
import tools.Randomizer;
/**
*
@@ -89,6 +96,7 @@ public class EventInstanceManager {
private MapleMapFactory mapFactory;
private String name;
private Properties props = new Properties();
private Map<String, Object> objectProps = new HashMap<>();
private long timeStarted = 0;
private long eventTime = 0;
private MapleExpedition expedition = null;
@@ -628,6 +636,7 @@ public class EventInstanceManager {
killCount.clear();
mapIds.clear();
props.clear();
objectProps.clear();
disposeExpedition();
@@ -741,6 +750,15 @@ public class EventInstanceManager {
pL.unlock();
}
}
public void setObjectProperty(String key, Object obj) {
pL.lock();
try {
objectProps.put(key, obj);
} finally {
pL.unlock();
}
}
public String getProperty(String key) {
pL.lock();
@@ -759,6 +777,15 @@ public class EventInstanceManager {
pL.unlock();
}
}
public Object getObjectProperty(String key) {
pL.lock();
try {
return objectProps.get(key);
} finally {
pL.unlock();
}
}
public void leftParty(final MapleCharacter chr) {
try {
+14
View File
@@ -42,6 +42,7 @@ import net.server.guild.MapleGuild;
import net.server.world.MapleParty;
import net.server.world.MaplePartyCharacter;
import scripting.event.worker.EventScriptScheduler;
import server.MapleMarriage;
import server.expeditions.MapleExpedition;
import server.maps.MapleMap;
import server.life.MapleMonster;
@@ -279,6 +280,19 @@ public class EventManager {
}
return ret;
}
public MapleMarriage newMarriage(String name) throws EventInstanceInProgressException {
MapleMarriage ret = new MapleMarriage(this, name);
synchronized (instances) {
if (instances.containsKey(name)) {
throw new EventInstanceInProgressException(name, this.getName());
}
instances.put(name, ret);
}
return ret;
}
public void disposeInstance(final String name) {
ess.registerEntry(new Runnable() {
+98 -68
View File
@@ -58,22 +58,23 @@ import client.inventory.Item;
import client.inventory.ItemFactory;
import client.inventory.MaplePet;
import constants.ItemConstants;
import constants.LinguaConstants;
import constants.LanguageConstants;
import net.server.PlayerStorage;
import net.server.channel.Channel;
import scripting.event.EventInstanceManager;
import server.MapleSkillbookInformationProvider;
import server.MapleSkillbookInformationProvider.SkillBookEntry;
import server.TimerManager;
import server.maps.MapleMapObject;
import server.maps.MapleMapObjectType;
import server.partyquest.MonsterCarnival;
import tools.FilePrinter;
import tools.packets.Wedding;
import java.awt.Point;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import server.MapleMarriage;
/**
*
@@ -619,8 +620,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
public int calcAvgLvl(int map) {
int num = 0;
int avg = 0;
for (MapleMapObject mmo
: c.getChannelServer().getMapFactory().getMap(map).getAllPlayer()) {
for (MapleMapObject mmo : c.getChannelServer().getMapFactory().getMap(map).getAllPlayer()) {
avg += ((MapleCharacter) mmo).getLevel();
num++;
}
@@ -629,7 +629,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
}
public void sendCPQMapLists() {
String msg = LinguaConstants.Linguas(getPlayer()).CPQInicioEscolha;
String msg = LanguageConstants.Linguas(getPlayer()).CPQInicioEscolha;
for (int i = 0; i < 6; i++) {
if (fieldTaken(i)) {
if (fieldLobbied(i)) {
@@ -641,7 +641,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
continue;
}
} else {
if (i == 0 || i == 1 || i == 2 || i == 3) {
if (i >= 0 && i <= 3) {
msg += "#b#L" + i + "#Map " + (i + 1) + " (2x2) #l\\r\\n";
} else {
msg += "#b#L" + i + "#Map " + (i + 1) + " (3x3) #l\\r\\n";
@@ -673,16 +673,18 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
public void cpqLobby(int field) {
try {
final MapleMap map, mapsaida;
final MapleMap map, mapExit;
Channel cs = c.getChannelServer();
PlayerStorage ps = cs.getPlayerStorage();
map = cs.getMapFactory().getMap(980000100 + 100 * field);
mapsaida = cs.getMapFactory().getMap(980000000);
mapExit = cs.getMapFactory().getMap(980000000);
for (MaplePartyCharacter mpc : c.getPlayer().getParty().getMembers()) {
final MapleCharacter mc;
mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
mc = ps.getCharacterById(mpc.getId());
if (mc != null) {
mc.changeMap(map, map.getPortal(0));
mc.getClient().getSession().write(MaplePacketCreator.serverNotice(6, LinguaConstants.Linguas(mc).CPQEntradaLobby));
mc.announce(MaplePacketCreator.serverNotice(6, LanguageConstants.Linguas(mc).CPQEntradaLobby));
TimerManager tMan = TimerManager.getInstance();
tMan.schedule(new Runnable() {
@Override
@@ -690,13 +692,14 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
mapClock(3 * 60);
}
}, 1500);
mc.setCpqTimer(TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
mc.changeMap(mapExit, mapExit.getPortal(0));
}
}, 3 * 60 * 1000));
}
mc.timer = TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
mc.changeMap(mapsaida, mapsaida.getPortal(0));
}
}, 3 * 60 * 1000);
}
} catch (Exception ex) {
ex.printStackTrace();
@@ -704,17 +707,15 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
}
public MapleCharacter getChrById(int id) {
Channel cs = c.getChannelServer();
return cs.getPlayerStorage().getCharacterById(id);
return c.getChannelServer().getPlayerStorage().getCharacterById(id);
}
public void cancelarSaida() {
Channel cs = c.getChannelServer();
PlayerStorage ps = c.getChannelServer().getPlayerStorage();
for (MaplePartyCharacter mpc : c.getPlayer().getParty().getMembers()) {
MapleCharacter mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
if (mc.timer != null) {
mc.timer.cancel(true);
mc.timer = null;
MapleCharacter mc = ps.getCharacterById(mpc.getId());
if (mc != null) {
mc.clearCpqTimer();
}
}
}
@@ -726,8 +727,9 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
if (challenger.getParty() == null) {
throw new RuntimeException("Nao existe oponente!");
}
PlayerStorage ps = c.getChannelServer().getPlayerStorage();
for (MaplePartyCharacter mpc : challenger.getParty().getMembers()) {
MapleCharacter mc = c.getChannelServer().getPlayerStorage().getCharacterByName(mpc.getName());
MapleCharacter mc = ps.getCharacterById(mpc.getId());
if (mc != null) {
mc.changeMap(getPlayer().getMap(), getPlayer().getMap().getPortal(0));
TimerManager tMan = TimerManager.getInstance();
@@ -740,7 +742,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
}
}
for (MaplePartyCharacter mpc : getPlayer().getParty().getMembers()) {
MapleCharacter mc = c.getChannelServer().getPlayerStorage().getCharacterByName(mpc.getName());
MapleCharacter mc = ps.getCharacterById(mpc.getId());
if (mc != null) {
TimerManager tMan = TimerManager.getInstance();
tMan.schedule(new Runnable() {
@@ -757,17 +759,17 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
tMan.schedule(new Runnable() {
@Override
public void run() {
Channel cs = c.getChannelServer();
PlayerStorage ps = c.getChannelServer().getPlayerStorage();
for (MaplePartyCharacter mpc : getPlayer().getParty().getMembers()) {
MapleCharacter mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
MapleCharacter mc = ps.getCharacterById(mpc.getId());
mc.setMonsterCarnival(null);
}
for (MaplePartyCharacter mpc : challenger.getParty().getMembers()) {
MapleCharacter mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
MapleCharacter mc = ps.getCharacterById(mpc.getId());
mc.setMonsterCarnival(null);
}
new MonsterCarnival(getPlayer().getParty(), challenger.getParty(), mapid, true);
new MonsterCarnival(getPlayer().getParty(), challenger.getParty(), mapid, true, (field / 100) % 10);
}
}, 11000);
} catch (Exception e) {
@@ -782,8 +784,9 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
if (challenger.getParty() == null) {
throw new RuntimeException("Não existe oponente!");
}
PlayerStorage ps = c.getChannelServer().getPlayerStorage();
for (MaplePartyCharacter mpc : challenger.getParty().getMembers()) {
MapleCharacter mc = c.getChannelServer().getPlayerStorage().getCharacterByName(mpc.getName());
MapleCharacter mc = ps.getCharacterById(mpc.getId());
if (mc != null) {
mc.changeMap(getPlayer().getMap(), getPlayer().getMap().getPortal(0));
mapClock(10);
@@ -795,17 +798,18 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
tMan.schedule(new Runnable() {
@Override
public void run() {
Channel cs = c.getChannelServer();
PlayerStorage ps = c.getChannelServer().getPlayerStorage();
for (MaplePartyCharacter mpc : getPlayer().getParty().getMembers()) {
MapleCharacter mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
MapleCharacter mc = ps.getCharacterById(mpc.getId());
mc.setMonsterCarnival(null);
}
for (MaplePartyCharacter mpc : challenger.getParty().getMembers()) {
MapleCharacter mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
MapleCharacter mc = ps.getCharacterById(mpc.getId());
mc.setMonsterCarnival(null);
}
new MonsterCarnival(getPlayer().getParty(), challenger.getParty(), mapid, false);
new MonsterCarnival(getPlayer().getParty(), challenger.getParty(), mapid, false, (field / 1000) % 10);
}
}, 10000);
} catch (Exception e) {
@@ -814,7 +818,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
}
public void sendCPQMapLists2() {
String msg = LinguaConstants.Linguas(getPlayer()).CPQInicioEscolha;
String msg = LanguageConstants.Linguas(getPlayer()).CPQInicioEscolha;
for (int i = 0; i < 3; i++) {
if (fieldTaken2(i)) {
if (fieldLobbied2(i)) {
@@ -856,16 +860,18 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
public void cpqLobby2(int field) {
try {
final MapleMap map, mapsaida;
final MapleMap map, mapExit;
Channel cs = c.getChannelServer();
mapsaida = cs.getMapFactory().getMap(980030000);
PlayerStorage ps = c.getChannelServer().getPlayerStorage();
mapExit = cs.getMapFactory().getMap(980030000);
map = cs.getMapFactory().getMap(980031000 + 1000 * field);
for (MaplePartyCharacter mpc : c.getPlayer().getParty().getMembers()) {
final MapleCharacter mc;
mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
mc = ps.getCharacterByName(mpc.getName());
if (mc != null) {
mc.changeMap(map, map.getPortal(0));
mc.getClient().getSession().write(MaplePacketCreator.serverNotice(6, LinguaConstants.Linguas(mc).CPQEntradaLobby));
mc.announce(MaplePacketCreator.serverNotice(6, LanguageConstants.Linguas(mc).CPQEntradaLobby));
TimerManager tMan = TimerManager.getInstance();
tMan.schedule(new Runnable() {
@Override
@@ -873,13 +879,14 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
mapClock(3 * 60);
}
}, 1500);
mc.setCpqTimer(TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
mc.changeMap(mapExit, mapExit.getPortal(0));
}
}, 3 * 60 * 1000));
}
mc.timer = TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
mc.changeMap(mapsaida, mapsaida.getPortal(0));
}
}, 3 * 60 * 1000);
}
} catch (Exception ex) {
ex.printStackTrace();
@@ -892,7 +899,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
for (MapleMapObject mmo : map.getAllPlayer()) {
MapleCharacter mc = (MapleCharacter) mmo;
if (mc.getParty() == null) {
sendOk(LinguaConstants.Linguas(mc).CPQEscolha);
sendOk(LanguageConstants.Linguas(mc).CPQEscolha);
return;
}
if (mc.getParty().getLeader().getId() == mc.getId()) {
@@ -908,15 +915,14 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
}
NPCScriptManager.getInstance().start("cpqchallenge2", leader.getClient(), npc, members);
} else {
sendOk(LinguaConstants.Linguas(leader).CPQInicioEscolhaEmEscolha);
sendOk(LanguageConstants.Linguas(leader).CPQInicioEscolhaEmEscolha);
}
} else {
sendOk(LinguaConstants.Linguas(leader).CPQLiderNaoEncontrado);
sendOk(LanguageConstants.Linguas(leader).CPQLiderNaoEncontrado);
}
}
public void mapClock(int time) {
//getPlayer().getMap().broadcastMessage(MaplePacketCreator.serverNotice(type, message));
getPlayer().getMap().broadcastMessage(MaplePacketCreator.getClock(time));
}
@@ -930,7 +936,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
for (MapleMapObject mmo : map.getAllPlayer()) {
MapleCharacter mc = (MapleCharacter) mmo;
if (mc.getParty() == null) {
sendOk(LinguaConstants.Linguas(mc).CPQEscolha);
sendOk(LanguageConstants.Linguas(mc).CPQEscolha);
return;
}
if (mc.getParty().getLeader().getId() == mc.getId()) {
@@ -941,15 +947,17 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
if (leader != null) {
if (!leader.isChallenged()) {
List<MaplePartyCharacter> members = new LinkedList<>();
for (MaplePartyCharacter fucker : c.getPlayer().getParty().getMembers()) {
members.add(fucker);
for (MaplePartyCharacter mpc : c.getPlayer().getParty().getMembers()) {
members.add(mpc);
}
NPCScriptManager.getInstance().start("cpqchallenge", leader.getClient(), npc, members);
sendOk(LanguageConstants.Linguas(leader).CPQInicioEscolhaEnviada);
} else {
sendOk(LinguaConstants.Linguas(leader).CPQInicioEscolhaEmEscolha);
sendOk(LanguageConstants.Linguas(leader).CPQInicioEscolhaEmEscolha);
}
} else {
sendOk(LinguaConstants.Linguas(leader).CPQLiderNaoEncontrado);
sendOk(LanguageConstants.Linguas(leader).CPQLiderNaoEncontrado);
}
}
@@ -961,24 +969,46 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
}
}
public void enviarLista() {
EventInstanceManager eim = getEventInstance();
if(eim != null) {
String name = eim.getProperty("brideId");
MapleCharacter chr = getChrById(Integer.parseInt(name));
//MapleCharacter chr = getChrById(3);
public void sendMarriageWishlist(boolean groom) {
MapleCharacter player = this.getPlayer();
MapleMarriage marriage = player.getMarriageInstance();
if(marriage != null) {
int cid = marriage.getIntProperty(groom ? "groomId" : "brideId");
MapleCharacter chr = marriage.getPlayerById(cid);
if (chr != null) {
if (chr.getId() == getPlayer().getId()) {
getPlayer().announce(Wedding.OnWeddingGiftResult((byte) 0xA, chr.getItens(), chr.getItem()));
if (chr.getId() == player.getId()) {
player.announce(Wedding.OnWeddingGiftResult((byte) 0xA, marriage.getWishlistItems(groom), marriage.getGiftItems(player.getClient(), groom)));
} else {
getPlayer().announce(Wedding.OnWeddingGiftResult((byte) 0x09, chr.getItens(), chr.getItem()));
marriage.setIntProperty("wishlistSelection", groom ? 0 : 1);
player.announce(Wedding.OnWeddingGiftResult((byte) 0x09, marriage.getWishlistItems(groom), marriage.getGiftItems(player.getClient(), groom)));
}
}
}
}
public void criarLista() {
getClient().getSession().write(Wedding.sendWishList());
}
public void sendMarriageGifts(List<Item> gifts) {
this.getPlayer().announce(Wedding.OnWeddingGiftResult((byte) 0xA, Collections.singletonList(""), gifts));
}
public boolean createMarriageWishlist() {
MapleMarriage marriage = this.getPlayer().getMarriageInstance();
if (marriage != null) {
Boolean groom = marriage.isMarriageGroom(this.getPlayer());
if (groom != null) {
String wlKey;
if (groom) {
wlKey = "groomWishlist";
} else {
wlKey = "brideWishlist";
}
if (marriage.getProperty(wlKey).contentEquals("")) {
getClient().announce(Wedding.sendWishList());
return true;
}
}
}
return false;
}
}
+183
View File
@@ -0,0 +1,183 @@
/*
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 server;
import client.MapleClient;
import client.MapleCharacter;
import client.inventory.Item;
import client.inventory.ItemFactory;
import client.inventory.MapleInventory;
import client.inventory.MapleInventoryType;
import client.inventory.manipulator.MapleInventoryManipulator;
import scripting.event.EventInstanceManager;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import scripting.event.EventManager;
import tools.DatabaseConnection;
import tools.Pair;
/**
*
* @author Ronan
*/
public class MapleMarriage extends EventInstanceManager {
public MapleMarriage(EventManager em, String name) {
super(em, name);
}
public boolean giftItemToSpouse(int cid) {
return this.getIntProperty("wishlistSelection") == 0;
}
public List<String> getWishlistItems(boolean groom) {
String strItems = this.getProperty(groom ? "groomWishlist" : "brideWishlist");
if (strItems != null) {
return Arrays.asList(strItems.split("\r\n"));
}
return new LinkedList<>();
}
public void initializeGiftItems() {
List<Item> groomGifts = new ArrayList<>();
this.setObjectProperty("groomGiftlist", groomGifts);
List<Item> brideGifts = new ArrayList<>();
this.setObjectProperty("brideGiftlist", brideGifts);
}
public List<Item> getGiftItems(MapleClient c, boolean groom) {
c.tryacquireClient();
try {
List<Item> gifts = getGiftItemsList(groom);
synchronized (gifts) {
return new LinkedList<>(gifts);
}
} finally {
c.releaseClient();
}
}
private List<Item> getGiftItemsList(boolean groom) {
return (List<Item>) this.getObjectProperty(groom ? "groomGiftlist" : "brideGiftlist");
}
public Item getGiftItem(MapleClient c, boolean groom, int idx) {
try {
return getGiftItems(c, groom).get(idx);
} catch (IndexOutOfBoundsException e) {
return null;
}
}
public void addGiftItem(boolean groom, Item item) {
List<Item> gifts = getGiftItemsList(groom);
synchronized (gifts) {
gifts.add(item);
}
}
public void removeGiftItem(boolean groom, Item item) {
List<Item> gifts = getGiftItemsList(groom);
synchronized (gifts) {
gifts.remove(item);
}
}
public Boolean isMarriageGroom(MapleCharacter chr) {
Boolean groom = null;
try {
int groomid = this.getIntProperty("groomId"), brideid = this.getIntProperty("brideId");
if (chr.getId() == groomid) {
groom = true;
} else if (chr.getId() == brideid) {
groom = false;
}
} catch (NumberFormatException nfe) {}
return groom;
}
public static boolean claimGiftItems(MapleClient c, MapleCharacter chr) {
List<Item> gifts = loadGiftItemsFromDb(c, chr.getId());
if (MapleInventory.checkSpot(chr, gifts)) {
try {
Connection con = DatabaseConnection.getConnection();
ItemFactory.MARRIAGE_GIFTS.saveItems(new LinkedList<Pair<Item, MapleInventoryType>>(), chr.getId(), con);
con.close();
} catch (SQLException sqle) {}
for (Item item : gifts) {
MapleInventoryManipulator.addFromDrop(chr.getClient(), item, false);
}
return true;
}
return false;
}
public static List<Item> loadGiftItemsFromDb(MapleClient c, int cid) {
c.tryacquireClient();
try {
List<Item> items = new LinkedList<>();
try {
for (Pair<Item, MapleInventoryType> it : ItemFactory.MARRIAGE_GIFTS.loadItems(cid, false)) {
items.add(it.getLeft());
}
} catch (SQLException sqle) {
sqle.printStackTrace();
}
return items;
} finally {
c.releaseClient();
}
}
public void saveGiftItemsToDb(MapleClient c, boolean groom, int cid) {
MapleMarriage.saveGiftItemsToDb(c, getGiftItems(c, groom), cid);
}
public static void saveGiftItemsToDb(MapleClient c, List<Item> giftItems, int cid) {
List<Pair<Item, MapleInventoryType>> items = new LinkedList<>();
for (Item it : giftItems) {
items.add(new Pair<>(it, it.getInventoryType()));
}
c.tryacquireClient();
try {
try {
Connection con = DatabaseConnection.getConnection();
ItemFactory.MARRIAGE_GIFTS.saveItems(items, cid, con);
con.close();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
} finally {
c.releaseClient();
}
}
}
+10 -19
View File
@@ -940,26 +940,17 @@ public class MapleStatEffect {
} else if (cp != 0 && applyto.getMonsterCarnival() != null) {
applyto.gainCP(cp);
} else if (nuffSkill != 0 && applyto.getParty() != null && applyto.getMap().isCPQMap()) { // by Drago-Dragohe4rt
final MCSkill skil = MapleCarnivalFactory.getInstance().getSkill(nuffSkill);
if (skil != null) {
final MapleDisease dis = skil.getDisease();
MapleParty inimigos = applyfrom.getParty().getEnemy();
if (nuffSkill == 8) {
int amount = inimigos.getMembers().size() - 1;
int randd = (int) Math.floor(Math.random() * amount);
MapleCharacter chrApp = applyfrom.getClient().getChannelServer().getPlayerStorage().getCharacterById(inimigos.getMemberByPos(randd).getId());
final MCSkill skill = MapleCarnivalFactory.getInstance().getSkill(nuffSkill);
if (skill != null) {
final MapleDisease dis = skill.getDisease();
MapleParty opposition = applyfrom.getParty().getEnemy();
for (MaplePartyCharacter enemyChrs : opposition.getPartyMembers()) {
MapleCharacter chrApp = enemyChrs.getPlayer();
if (chrApp != null && chrApp.getMap().isCPQMap()) {
chrApp.dispel();
}
} else {
for (MaplePartyCharacter chrsInimigos : inimigos.getPartyMembers()) {
MapleCharacter chrApp = chrsInimigos.getPlayer();
if (chrApp != null && chrApp.getMap().isCPQMap()) {
if (dis == null) {
chrApp.dispel();
} else if (skil.getSkill() != null) {
chrApp.giveDebuff(dis, skil.getSkill());
}
if (dis == null) {
chrApp.dispel();
} else {
chrApp.giveDebuff(dis, MCSkill.getMobSkill(dis.getDisease()));
}
}
}
@@ -182,45 +182,38 @@ public class MapleMonsterInformationProvider {
return drops.get(monsterId);
}
final List<MonsterDropEntry> ret = new LinkedList<>();
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = null;
try {
con = DatabaseConnection.getConnection();
ps = con.prepareStatement("SELECT itemid, chance, minimum_quantity, maximum_quantity, questid FROM drop_data WHERE dropperid = ?");
ps.setInt(1, monsterId);
rs = ps.executeQuery();
if (monsterId >= 9300127 && monsterId <= 9300136 || monsterId >= 9300315 && monsterId <= 9300324) {
int dropArray[] = {2022157, 2022158, 2022159, 2022160, 2022161, 2022162, 2022163, 2022164, 2022165, 2022166, 2022167, 2022168, 2022169, 2022170, 2022171, 2022172, 2022173, 2022174, 2022175, 2022176, 2022177, 2022178, 4001129}; //These are the drops, -1 means meso :D
for (int id : dropArray) {
ret.add(new MonsterDropEntry(id, 2000, 1, 1, (short) 0));
while (rs.next()) {
ret.add(new MonsterDropEntry(rs.getInt("itemid"), rs.getInt("chance"), rs.getInt("minimum_quantity"), rs.getInt("maximum_quantity"), rs.getShort("questid")));
}
} else {
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = null;
con.close();
} catch (SQLException e) {
e.printStackTrace();
return ret;
} finally {
try {
con = DatabaseConnection.getConnection();
ps = con.prepareStatement("SELECT itemid, chance, minimum_quantity, maximum_quantity, questid FROM drop_data WHERE dropperid = ?");
ps.setInt(1, monsterId);
rs = ps.executeQuery();
while (rs.next()) {
ret.add(new MonsterDropEntry(rs.getInt("itemid"), rs.getInt("chance"), rs.getInt("minimum_quantity"), rs.getInt("maximum_quantity"), rs.getShort("questid")));
if (ps != null && !ps.isClosed()) {
ps.close();
}
con.close();
} catch (SQLException e) {
e.printStackTrace();
if (rs != null && !rs.isClosed()) {
rs.close();
}
if (con != null && !con.isClosed()) {
con.close();
}
} catch (SQLException ignore) {
ignore.printStackTrace();
return ret;
} finally {
try {
if (ps != null && !ps.isClosed()) {
ps.close();
}
if (rs != null && !rs.isClosed()) {
rs.close();
}
if (con != null && !con.isClosed()) {
con.close();
}
} catch (SQLException ignore) {
ignore.printStackTrace();
return ret;
}
}
}
drops.put(monsterId, ret);
+23 -15
View File
@@ -166,18 +166,20 @@ public class MapleMapFactory {
}
}
private synchronized MapleMap loadMapFromWz(int mapid, Integer omapid) {
private synchronized MapleMap loadMapFromWz(int mapid, Integer omapid, boolean cache) {
MapleMap map;
mapsRLock.lock();
try {
map = maps.get(omapid);
} finally {
mapsRLock.unlock();
}
if (cache) {
mapsRLock.lock();
try {
map = maps.get(omapid);
} finally {
mapsRLock.unlock();
}
if (map != null) {
return map;
if (map != null) {
return map;
}
}
String mapName = getMapName(mapid);
@@ -389,11 +391,13 @@ public class MapleMapFactory {
map.setBackgroundTypes(backTypes);
map.generateMapDropRangeCache();
mapsWLock.lock();
try {
maps.put(omapid, map);
} finally {
mapsWLock.unlock();
if (cache) {
mapsWLock.lock();
try {
maps.put(omapid, map);
} finally {
mapsWLock.unlock();
}
}
return map;
@@ -410,7 +414,11 @@ public class MapleMapFactory {
mapsRLock.unlock();
}
return (map != null) ? map : loadMapFromWz(mapid, omapid);
return (map != null) ? map : loadMapFromWz(mapid, omapid, true);
}
public MapleMap getDisposableMap(int mapid) {
return loadMapFromWz(mapid, mapid, false);
}
public boolean isMapLoaded(int mapId) {
@@ -63,6 +63,10 @@ public class MapleCarnivalFactory {
}
public MobSkill getSkill() {
return getMobSkill(skillid);
}
public static MobSkill getMobSkill(int skillid) {
return MobSkillFactory.getMobSkill(skillid, 1); //level?
}
+56 -34
View File
@@ -2,7 +2,8 @@ package server.partyquest;
import java.util.concurrent.ScheduledFuture;
import client.MapleCharacter;
import constants.LinguaConstants;
import constants.LanguageConstants;
import constants.ServerConstants;
import net.server.Server;
import net.server.channel.Channel;
import net.server.world.MapleParty;
@@ -24,22 +25,23 @@ public class MonsterCarnival {
private MapleParty p1, p2;
private MapleMap map;
private ScheduledFuture<?> timer, effectTimer;
private ScheduledFuture<?> timer, effectTimer, respawnTask;
private long startTime = 0;
private int summons = 8, summonss = 8;
private int summonsR = 8, summonsB = 8, room = 0;
private MapleCharacter leader1, leader2, Grupo1, Grupo2;
private int redCP, blueCP, redTotalCP, blueTotalCP;
private boolean cpq1;
public MonsterCarnival(MapleParty p1, MapleParty p2, int mapid, boolean cpq1) {
public MonsterCarnival(MapleParty p1, MapleParty p2, int mapid, boolean cpq1, int room) {
try {
this.cpq1 = cpq1;
this.room = room;
this.p1 = p1;
this.p2 = p2;
Channel cs = Server.getInstance().getWorld(p2.getLeader().getWorld()).getChannel(p2.getLeader().getChannel());
p1.setEnemy(p2);
p2.setEnemy(p1);
map = cs.getMapFactory().resetMap(mapid);
map = cs.getMapFactory().getDisposableMap(mapid);
int redPortal = 0;
int bluePortal = 0;
if (map.isPurpleCPQMap()) {
@@ -47,13 +49,13 @@ public class MonsterCarnival {
bluePortal = 1;
}
for (MaplePartyCharacter mpc : p1.getMembers()) {
MapleCharacter mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
MapleCharacter mc = cs.getPlayerStorage().getCharacterById(mpc.getId());
if (mc != null) {
mc.setMonsterCarnival(this);
mc.setTeam(0);
mc.setFestivalPoints(0);
mc.changeMap(map, map.getPortal(redPortal));
mc.dropMessage(6, LinguaConstants.Linguas(mc).CPQEntrada);
mc.forceChangeMap(map, map.getPortal(redPortal));
mc.dropMessage(6, LanguageConstants.Linguas(mc).CPQEntrada);
if (p1.getLeader().getId() == mc.getId()) {
leader1 = mc;
}
@@ -61,13 +63,13 @@ public class MonsterCarnival {
}
}
for (MaplePartyCharacter mpc : p2.getMembers()) {
MapleCharacter mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
MapleCharacter mc = cs.getPlayerStorage().getCharacterById(mpc.getId());
if (mc != null) {
mc.setMonsterCarnival(this);
mc.setTeam(1);
mc.setFestivalPoints(0);
mc.changeMap(map, map.getPortal(bluePortal));
mc.dropMessage(6, LinguaConstants.Linguas(mc).CPQEntrada);
mc.forceChangeMap(map, map.getPortal(bluePortal));
mc.dropMessage(6, LanguageConstants.Linguas(mc).CPQEntrada);
if (p2.getLeader().getId() == mc.getId()) {
leader2 = mc;
}
@@ -76,10 +78,10 @@ public class MonsterCarnival {
}
if (Grupo1 == null || Grupo2 == null) {
for (MaplePartyCharacter mpc : p2.getMembers()) {
mpc.getPlayer().dropMessage(5, LinguaConstants.Linguas(mpc.getPlayer()).CPQErro);
mpc.getPlayer().dropMessage(5, LanguageConstants.Linguas(mpc.getPlayer()).CPQErro);
}
for (MaplePartyCharacter mpc : p2.getMembers()) {
mpc.getPlayer().dropMessage(5, LinguaConstants.Linguas(mpc.getPlayer()).CPQErro);
mpc.getPlayer().dropMessage(5, LanguageConstants.Linguas(mpc.getPlayer()).CPQErro);
}
return;
}
@@ -98,6 +100,12 @@ public class MonsterCarnival {
complete();
}
}, 10 * 60 * 1000 - 10 * 1000);
respawnTask = TimerManager.getInstance().register(new Runnable() {
@Override
public void run() {
respawn();
}
}, ServerConstants.RESPAWN_INTERVAL);
TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
@@ -109,6 +117,10 @@ public class MonsterCarnival {
}
}
private void respawn() {
map.respawn();
}
public void playerDisconnected(int charid) {
int team = -1;
for (MaplePartyCharacter mpc : leader1.getParty().getMembers()) {
@@ -128,13 +140,13 @@ public class MonsterCarnival {
String teamS = "";
switch (team) {
case 0:
teamS = LinguaConstants.Linguas(chrMap).CPQVermelho;
teamS = LanguageConstants.Linguas(chrMap).CPQVermelho;
break;
case 1:
teamS = LinguaConstants.Linguas(chrMap).CPQAzul;
teamS = LanguageConstants.Linguas(chrMap).CPQAzul;
break;
}
chrMap.dropMessage(5, teamS + LinguaConstants.Linguas(chrMap).CPQPlayerExit);
chrMap.dropMessage(5, teamS + LanguageConstants.Linguas(chrMap).CPQPlayerExit);
}
earlyFinish();
}
@@ -151,20 +163,20 @@ public class MonsterCarnival {
dispose(false);
}
public void summon() {
this.summons--;
public void summonR() {
this.summonsR--;
}
public boolean canSummon() {
return this.summons > 0;
public boolean canSummonR() {
return this.summonsR > 0;
}
public void summons() {
this.summonss--;
public void summonB() {
this.summonsB--;
}
public boolean canSummons() {
return this.summonss > 0;
public boolean canSummonB() {
return this.summonsB > 0;
}
protected void dispose(boolean warpout) {
@@ -176,7 +188,7 @@ public class MonsterCarnival {
out = cs.getMapFactory().getMap(980000000);
}
for (MaplePartyCharacter mpc : leader1.getParty().getMembers()) {
MapleCharacter mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
MapleCharacter mc = cs.getPlayerStorage().getCharacterById(mpc.getId());
if (mc != null) {
mc.resetCP();
mc.setTeam(-1);
@@ -187,7 +199,7 @@ public class MonsterCarnival {
}
}
for (MaplePartyCharacter mpc : leader2.getParty().getMembers()) {
MapleCharacter mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
MapleCharacter mc = cs.getPlayerStorage().getCharacterById(mpc.getId());
if (mc != null) {
mc.resetCP();
mc.setTeam(-1);
@@ -205,10 +217,16 @@ public class MonsterCarnival {
this.effectTimer.cancel(true);
this.effectTimer = null;
}
if (this.respawnTask != null) {
this.respawnTask.cancel(true);
this.respawnTask = null;
}
redTotalCP = 0;
blueTotalCP = 0;
leader1.getParty().setEnemy(null);
leader2.getParty().setEnemy(null);
map.dispose();
map = null;
}
@@ -225,7 +243,7 @@ public class MonsterCarnival {
Channel cs = Server.getInstance().getWorld(p1.getLeader().getWorld()).getChannel(p1.getLeader().getChannel());
if (winningTeam == 0) {
for (MaplePartyCharacter mpc : leader1.getParty().getMembers()) {
MapleCharacter mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
MapleCharacter mc = cs.getPlayerStorage().getCharacterById(mpc.getId());
if (mc != null) {
mc.gainFestivalPoints(this.redTotalCP);
mc.setMonsterCarnival(null);
@@ -239,7 +257,7 @@ public class MonsterCarnival {
}
}
for (MaplePartyCharacter mpc : leader2.getParty().getMembers()) {
MapleCharacter mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
MapleCharacter mc = cs.getPlayerStorage().getCharacterById(mpc.getId());
if (mc != null) {
mc.gainFestivalPoints(this.blueTotalCP);
mc.setMonsterCarnival(null);
@@ -254,7 +272,7 @@ public class MonsterCarnival {
}
} else if (winningTeam == 1) {
for (MaplePartyCharacter mpc : leader2.getParty().getMembers()) {
MapleCharacter mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
MapleCharacter mc = cs.getPlayerStorage().getCharacterById(mpc.getId());
if (mc != null) {
mc.gainFestivalPoints(this.blueTotalCP);
mc.setMonsterCarnival(null);
@@ -268,7 +286,7 @@ public class MonsterCarnival {
}
}
for (MaplePartyCharacter mpc : leader1.getParty().getMembers()) {
MapleCharacter mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
MapleCharacter mc = cs.getPlayerStorage().getCharacterById(mpc.getId());
if (mc != null) {
mc.gainFestivalPoints(this.redTotalCP);
mc.setMonsterCarnival(null);
@@ -312,7 +330,7 @@ public class MonsterCarnival {
public void extendTime() {
for (MapleCharacter chrMap : map.getAllPlayers()) {
chrMap.dropMessage(5, LinguaConstants.Linguas(chrMap).CPQTempoExtendido);
chrMap.dropMessage(5, LanguageConstants.Linguas(chrMap).CPQTempoExtendido);
}
startTime = System.currentTimeMillis() + 3 * 1000;
map.addClock(3 * 60);
@@ -340,14 +358,14 @@ public class MonsterCarnival {
int chnl = leader1.getClient().getChannel();
int chnl1 = leader2.getClient().getChannel();
if (chnl != chnl1) {
throw new RuntimeException("Os líderes estão em canais diferentes.");
throw new RuntimeException("Os lideres estao em canais diferentes.");
}
Channel cs = Server.getInstance().getWorld(p1.getLeader().getWorld()).getChannel(p1.getLeader().getChannel());
map.killAllMonsters();
for (MaplePartyCharacter mpc : leader1.getParty().getMembers()) {
MapleCharacter mc;
mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
mc = cs.getPlayerStorage().getCharacterById(mpc.getId());
if (mc != null) {
if (redWin) {
mc.getClient().announce(MaplePacketCreator.showEffect("quest/carnival/win"));
@@ -362,7 +380,7 @@ public class MonsterCarnival {
}
for (MaplePartyCharacter mpc : leader2.getParty().getMembers()) {
MapleCharacter mc;
mc = cs.getPlayerStorage().getCharacterByName(mpc.getName());
mc = cs.getPlayerStorage().getCharacterById(mpc.getId());
if (mc != null) {
if (!redWin) {
mc.getClient().announce(MaplePacketCreator.showEffect("quest/carnival/win"));
@@ -486,4 +504,8 @@ public class MonsterCarnival {
this.blueCP = CP;
}
}
public int getRoom() {
return this.room;
}
}
@@ -15,7 +15,7 @@ public class MonsterCarnivalParty {
private MapleCharacter leader;
private byte team;
private short availableCP = 0, totalCP = 0;
private int summons = 7;
private int summons = 8;
private boolean winner = false;
public MonsterCarnivalParty(final MapleCharacter owner, final List<MapleCharacter> members1, final byte team1) {
@@ -24,7 +24,7 @@ public class MonsterCarnivalParty {
team = team1;
for (final MapleCharacter chr : members) {
chr.setCarnivalParty(this);
chr.setMonsterCarnivalParty(this);
chr.setTeam(team);
}
}
@@ -63,8 +63,8 @@ public class MonsterCarnivalParty {
public void warpOut(final int map) {
for (MapleCharacter chr : members) {
chr.changeMap(map, 0);
chr.setCarnivalParty(null);
chr.setCarnival(null);
chr.setMonsterCarnivalParty(null);
chr.setMonsterCarnival(null);
}
members.clear();
}
@@ -77,9 +77,9 @@ public class MonsterCarnivalParty {
public void warpOut() {
if (winner == true)
warpOut(980000003 + (leader.getCarnival().getRoom() * 100));
warpOut(980000003 + (leader.getMonsterCarnival().getRoom() * 100));
else
warpOut(980000004 + (leader.getCarnival().getRoom() * 100));
warpOut(980000004 + (leader.getMonsterCarnival().getRoom() * 100));
}
public boolean allInMap(MapleMap map) {
@@ -95,8 +95,8 @@ public class MonsterCarnivalParty {
public void removeMember(MapleCharacter chr) {
members.remove(chr);
chr.changeMap(980000010);
chr.setCarnivalParty(null);
chr.setCarnival(null);
chr.setMonsterCarnivalParty(null);
chr.setMonsterCarnival(null);
}
public boolean isWinner() {
+1 -1
View File
@@ -4213,7 +4213,7 @@ public class MaplePacketCreator {
mplew.write(reactor.getState());
mplew.writePos(pos);
mplew.writeShort(0);
mplew.write(reactor.getFacingDirection()); // stance, thanks to Drago/Dragohe4rt
mplew.write(0);
return mplew.getPacket();
}
@@ -33,7 +33,7 @@ import constants.CharsetConstants.MapleLanguageType;
* @since Revision 323
*/
public class GenericLittleEndianWriter implements LittleEndianWriter {
private static Charset ASCII = Charset.forName(MapleLanguageType.LANGUAGE_PT_BR.getAscii());
private static Charset ASCII = Charset.forName(MapleLanguageType.LANGUAGE_US.getAscii());
private ByteOutputStream bos;
/**
+6 -34
View File
@@ -7,7 +7,6 @@
package tools.packets;
import client.inventory.Item;
import client.inventory.MapleInventoryType;
import client.MapleCharacter;
import java.util.ArrayList;
import java.util.List;
@@ -383,59 +382,32 @@ public class Wedding extends MaplePacketCreator {
* @return mplew
*/
public static byte[] OnWeddingGiftResult(byte mode, List<String> itemnames, List<Item> items) {
// if (itemnames == null || itemnames.size() < 1) { // for now lol
// itemnames = new ArrayList<>();
// itemnames.add("mesos");
// itemnames.add("rare items");
// itemnames.add("more mesos");
// }
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
mplew.writeShort(WEDDING_GIFT_RESULT);
mplew.write(mode);
switch (mode) {
case 0xC: // 12 : You cannot give more than one present for each wishlist
case 0xE: // 14 : Failed to send the gift.
break;
case 0x09: { // Load Wedding Registry
mplew.write(itemnames.size());
for (String names : itemnames) {
mplew.writeMapleAsciiString(names);
}
mplew.write(items.size());
for (Item item : items) {
addItemInfo(mplew, item, true);
}
break;
}
case 0xA: // Load Bride's Wishlist
case 0xF: // 10, 15, 16 = CWishListRecvDlg::OnPacket
case 0xB: { // Add Item to Wedding Registry
// 11 : You have sent a gift | 12 : You cannot give more than one present for each wishlist | 13 : Failed to send the gift. | 14 : Failed to send the gift.
// 11 : You have sent a gift | | 13 : Failed to send the gift. |
if (mode == 0xB) {
mplew.write(itemnames.size());
for (String names : itemnames) {
mplew.writeMapleAsciiString(names);
}
}
if (items.size() >= 1) {
switch (items.get((items.size() - 1)).getInventoryType()) {
case EQUIP:
mplew.writeLong(4);
break;
case USE:
mplew.writeLong(8);
break;
case SETUP:
mplew.writeLong(16);
break;
case ETC:
mplew.writeLong(32);
break;
default: // impossible flag, cash item can't be sent
if (items.get((items.size() - 1)).getInventoryType() != MapleInventoryType.CASH) {
mplew.writeLong(0);
}
}
} else {
mplew.writeLong(0);
}
mplew.writeLong(32);
mplew.write(items.size());
for (Item item : items) {
addItemInfo(mplew, item, true);