CPQ 1 CPQ 2 CASAMENTO

This commit is contained in:
Diego Armando de Freitas Matos
2019-03-06 21:55:47 -03:00
parent 799870df63
commit 90ad58f17f
60 changed files with 17442 additions and 15142 deletions

View File

@@ -1,23 +1,23 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
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 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.
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/>.
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;
@@ -39,131 +39,130 @@ import tools.data.input.SeekableLittleEndianAccessor;
public final class ChangeMapHandler extends AbstractMaplePacketHandler {
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
MapleCharacter chr = c.getPlayer();
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
MapleCharacter chr = c.getPlayer();
if (chr.isChangingMaps() || chr.isBanned()) {
if(chr.isChangingMaps()) {
FilePrinter.printError(FilePrinter.PORTAL_STUCK + chr.getName() + ".txt", "Player " + chr.getName() + " got stuck when changing maps. Timestamp: " + Calendar.getInstance().getTime().toString() + " Last visited mapids: " + chr.getLastVisitedMapids());
}
c.announce(MaplePacketCreator.enableActions());
return;
}
if (chr.getTrade() != null) {
MapleTrade.cancelTrade(chr);
}
if (slea.available() == 0) { //Cash Shop :)
if(!chr.getCashShop().isOpened()) {
c.disconnect(false, false);
return;
}
String[] socket = c.getChannelServer().getIP().split(":");
chr.getCashShop().open(false);
c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION);
try {
c.announce(MaplePacketCreator.getChannelChange(InetAddress.getByName(socket[0]), Integer.parseInt(socket[1])));
} catch (UnknownHostException ex) {
ex.printStackTrace();
}
} else {
if(chr.getCashShop().isOpened()) {
c.disconnect(false, false);
return;
}
try {
slea.readByte(); // 1 = from dying 0 = regular portals
int targetid = slea.readInt();
String startwp = slea.readMapleAsciiString();
MaplePortal portal = chr.getMap().getPortal(startwp);
slea.readByte();
boolean wheel = slea.readShort() > 0;
if (targetid != -1 && !chr.isAlive()) {
MapleMap map = chr.getMap();
if (wheel && chr.haveItemWithId(5510000, false)) {
if (chr.isChangingMaps() || chr.isBanned()) {
if (chr.isChangingMaps()) {
FilePrinter.printError(FilePrinter.PORTAL_STUCK + chr.getName() + ".txt", "Player " + chr.getName() + " got stuck when changing maps. Timestamp: " + Calendar.getInstance().getTime().toString() + " Last visited mapids: " + chr.getLastVisitedMapids());
}
c.announce(MaplePacketCreator.enableActions());
return;
}
if (chr.getTrade() != null) {
MapleTrade.cancelTrade(chr);
}
if (slea.available() == 0) { //Cash Shop :)
if (!chr.getCashShop().isOpened()) {
c.disconnect(false, false);
return;
}
String[] socket = c.getChannelServer().getIP().split(":");
chr.getCashShop().open(false);
c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION);
try {
c.announce(MaplePacketCreator.getChannelChange(InetAddress.getByName(socket[0]), Integer.parseInt(socket[1])));
} catch (UnknownHostException ex) {
ex.printStackTrace();
}
} else {
if (chr.getCashShop().isOpened()) {
c.disconnect(false, false);
return;
}
try {
slea.readByte(); // 1 = from dying 0 = regular portals
int targetid = slea.readInt();
String startwp = slea.readMapleAsciiString();
MaplePortal portal = chr.getMap().getPortal(startwp);
slea.readByte();
boolean wheel = slea.readShort() > 0;
if (targetid != -1 && !chr.isAlive()) {
MapleMap map = chr.getMap();
if (wheel && chr.haveItemWithId(5510000, false)) {
// thanks lucasziron for showing revivePlayer() also being triggered by Wheel
MapleInventoryManipulator.removeById(c, MapleInventoryType.CASH, 5510000, 1, true, false);
chr.announce(MaplePacketCreator.showWheelsLeft(chr.getItemQuantity(5510000, false)));
chr.updateHp(50);
chr.changeMap(map, map.findClosestPlayerSpawnpoint(chr.getPosition()));
} else {
boolean executeStandardPath = true;
if (chr.getEventInstance() != null) {
executeStandardPath = chr.getEventInstance().revivePlayer(chr);
}
if (executeStandardPath) {
chr.respawn(map.getReturnMapId());
}
}
} else if (targetid != -1) {
if(chr.isGM()) {
MapleMap to = chr.getWarpMap(targetid);
chr.changeMap(to, to.getPortal(0));
}
else {
final int divi = chr.getMapId() / 100;
boolean warp = false;
if (divi == 0) {
if (targetid == 10000) {
warp = true;
}
} else if (divi == 20100) {
if (targetid == 104000000) {
c.announce(MaplePacketCreator.lockUI(false));
c.announce(MaplePacketCreator.disableUI(false));
warp = true;
}
} else if (divi == 9130401) { // Only allow warp if player is already in Intro map, or else = hack
if (targetid == 130000000 || targetid / 100 == 9130401) { // Cygnus introduction
warp = true;
}
} else if (divi == 9140900) { // Aran Introduction
if (targetid == 914090011 || targetid == 914090012 || targetid == 914090013 || targetid == 140090000) {
warp = true;
}
} else if (divi / 10 == 1020) { // Adventurer movie clip Intro
if (targetid == 1020000) {
warp = true;
}
} else if(divi / 10 >= 980040 && divi / 10 <= 980045) {
if(targetid == 980040000) {
warp = true;
}
}
if (warp) {
final MapleMap to = chr.getWarpMap(targetid);
chr.changeMap(to, to.getPortal(0));
}
}
}
if (portal != null && !portal.getPortalStatus()) {
c.announce(MaplePacketCreator.blockedMessage(1));
c.announce(MaplePacketCreator.enableActions());
return;
}
if (chr.getMapId() == 109040004) {
chr.getFitness().resetTimes();
} else if (chr.getMapId() == 109030003 || chr.getMapId() == 109030103) {
chr.getOla().resetTimes();
}
if (portal != null) {
if(portal.getPosition().distanceSq(chr.getPosition()) > 400000) {
c.announce(MaplePacketCreator.enableActions());
return;
}
portal.enterPortal(c);
} else {
c.announce(MaplePacketCreator.enableActions());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
MapleInventoryManipulator.removeById(c, MapleInventoryType.CASH, 5510000, 1, true, false);
chr.announce(MaplePacketCreator.showWheelsLeft(chr.getItemQuantity(5510000, false)));
chr.updateHp(50);
chr.changeMap(map, map.findClosestPlayerSpawnpoint(chr.getPosition()));
} else {
boolean executeStandardPath = true;
if (chr.getEventInstance() != null) {
executeStandardPath = chr.getEventInstance().revivePlayer(chr);
}
if (executeStandardPath) {
chr.respawn(map.getReturnMapId());
}
}
} else if (targetid != -1) {
if (chr.isGM()) {
MapleMap to = chr.getWarpMap(targetid);
chr.changeMap(to, to.getPortal(0));
} else {
final int divi = chr.getMapId() / 100;
boolean warp = false;
if (divi == 0) {
if (targetid == 10000) {
warp = true;
}
} else if (divi == 20100) {
if (targetid == 104000000) {
c.announce(MaplePacketCreator.lockUI(false));
c.announce(MaplePacketCreator.disableUI(false));
warp = true;
}
} else if (divi == 9130401) { // Only allow warp if player is already in Intro map, or else = hack
if (targetid == 130000000 || targetid / 100 == 9130401) { // Cygnus introduction
warp = true;
}
} else if (divi == 9140900) { // Aran Introduction
if (targetid == 914090011 || targetid == 914090012 || targetid == 914090013 || targetid == 140090000) {
warp = true;
}
} else if (divi / 10 == 1020) { // Adventurer movie clip Intro
if (targetid == 1020000) {
warp = true;
}
} else if (divi / 10 >= 980040 && divi / 10 <= 980045) {
if (targetid == 980040000) {
warp = true;
}
}
if (warp) {
final MapleMap to = chr.getWarpMap(targetid);
chr.changeMap(to, to.getPortal(0));
}
}
}
if (portal != null && !portal.getPortalStatus()) {
c.announce(MaplePacketCreator.blockedMessage(1));
c.announce(MaplePacketCreator.enableActions());
return;
}
if (chr.getMapId() == 109040004) {
chr.getFitness().resetTimes();
} else if (chr.getMapId() == 109030003 || chr.getMapId() == 109030103) {
chr.getOla().resetTimes();
}
if (portal != null) {
if (portal.getPosition().distanceSq(chr.getPosition()) > 400000) {
c.announce(MaplePacketCreator.enableActions());
return;
}
portal.enterPortal(c);
} else {
c.announce(MaplePacketCreator.enableActions());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

View File

@@ -1,223 +1,154 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
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 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/>.
*/
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.MapleCharacter;
import client.MapleClient;
import client.MapleDisease;
import java.awt.Point;
import java.util.List;
import net.AbstractMaplePacketHandler;
import server.partyquest.MonsterCarnival;
import net.server.world.MapleParty;
import net.server.world.MaplePartyCharacter;
import server.life.MapleLifeFactory;
import server.maps.MapleReactor;
import server.maps.MapleReactorFactory;
import server.life.MapleMonster;
import server.partyquest.MapleCarnivalFactory;
import server.partyquest.MapleCarnivalFactory.MCSkill;
import tools.MaplePacketCreator;
import tools.Pair;
import tools.data.input.SeekableLittleEndianAccessor;
/**
*
* @author kevintjuh93
*/
public final class MonsterCarnivalHandler extends AbstractMaplePacketHandler{
*@author Drago/Dragohe4rt
*/
public final class MonsterCarnivalHandler extends AbstractMaplePacketHandler {
@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
MapleCharacter chr = c.getPlayer();
MonsterCarnival carnival = chr.getCarnival();
int tab = slea.readByte();
int number = slea.readShort();
if (carnival != null) {
if (chr.getCarnivalParty() != carnival.getPartyRed() || chr.getCarnivalParty() != carnival.getPartyBlue()) {
chr.getMap().broadcastMessage(MaplePacketCreator.leaveCPQ(chr));
chr.changeMap(980000010);
}
if (chr.getCP() > getPrice(tab, number)) {
if (tab == 0) { //SPAWNING
if (chr.getCarnivalParty().canSummon()) {
chr.getMap().spawnCPQMonster(MapleLifeFactory.getMonster(getMonster(number)), new Point(1, 1), carnival.oppositeTeam(chr.getCarnivalParty()).getTeam());
chr.getCarnivalParty().summon();
} else
chr.announce(MaplePacketCreator.CPQMessage((byte) 2));
} else if (tab == 1) {
} else if (tab == 2) {
int rid = 9980000 + chr.getTeam();
MapleReactor reactor = new MapleReactor(MapleReactorFactory.getReactor(rid), rid);
/*switch (number) {
case 0:
reactor.setMonsterStatus(tab, MonsterStatus.WEAPON_ATTACK_UP, MobSkillFactory.getMobSkill(150, 1));
break;
case 1:
reactor.setMonsterStatus(tab, MonsterStatus.WEAPON_DEFENSE_UP, MobSkillFactory.getMobSkill(151, 1));
break;
case 2:
reactor.setMonsterStatus(tab, MonsterStatus.MAGIC_ATTACK_UP, MobSkillFactory.getMobSkill(152, 1));
break;
case 3:
reactor.setMonsterStatus(tab, MonsterStatus.MAGIC_DEFENSE_UP, MobSkillFactory.getMobSkill(153, 1));
break;
case 4:
reactor.setMonsterStatus(tab, MonsterStatus.ACC, MobSkillFactory.getMobSkill(154, 1));
break;
case 5:
reactor.setMonsterStatus(tab, MonsterStatus.AVOID, MobSkillFactory.getMobSkill(155, 1));
break;
case 6:
reactor.setMonsterStatus(tab, MonsterStatus.SPEED, MobSkillFactory.getMobSkill(156, 1));
break;
case 7:
reactor.setMonsterStatus(tab, MonsterStatus.WEAPON_IMMUNITY, MobSkillFactory.getMobSkill(140, 1));
break;
case 8:
reactor.setMonsterStatus(tab, MonsterStatus.MAGIC_IMMUNITY, MobSkillFactory.getMobSkill(141, 1));
break;
} */
chr.getMap().spawnReactor(reactor);
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;
}
} else {
chr.getMap().broadcastMessage(MaplePacketCreator.CPQMessage((byte) 1));
}
} else {
chr.announce(MaplePacketCreator.CPQMessage((byte) 5));
}
chr.announce(MaplePacketCreator.enableActions());
}
public int getMonster(int num) {
int mid = 0;
num++;
switch (num) {
case 1:
mid = 9300127;
break;
case 2:
mid = 9300128;
break;
case 3:
mid = 9300129;
break;
case 4:
mid = 9300130;
break;
case 5:
mid = 9300131;
break;
case 6:
mid = 9300132;
break;
case 7:
mid = 9300133;
break;
case 8:
mid = 9300134;
break;
case 9:
mid = 9300135;
break;
case 10:
mid = 9300136;
break;
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());
return;
}
mob.setPosition(spawnPos);
if (c.getPlayer().getTeam() == 0) {
c.getPlayer().getMonsterCarnival().summon();
} else {
c.getPlayer().getMonsterCarnival().summons();
}
c.getPlayer().getMap().addMonsterSpawn(mob, 1, c.getPlayer().getTeam());
c.getSession().write(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());
return;
}
final MCSkill skil = MapleCarnivalFactory.getInstance().getSkill(skillid.get(num)); //ugh wtf
if (skil == null || c.getPlayer().getCP() < skil.cpLoss) {
c.announce(MaplePacketCreator.CPQMessage((byte) 1));
c.getSession().write(MaplePacketCreator.enableActions());
return;
}
final MapleDisease dis = skil.getDisease();
MapleParty inimigos = c.getPlayer().getParty().getEnemy();
if (skil.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()) {
if (dis == null) {
chrS.getPlayer().dispel();
} else {
chrS.getPlayer().giveDebuff(dis, skil.getSkill());
}
if (!skil.targetsAll) {
break;
}
}
}
} else {
int amount = inimigos.getMembers().size() - 1;
int randd = (int) Math.floor(Math.random() * amount);
MapleCharacter chrApp = c.getChannelServer().getPlayerStorage().getCharacterById(inimigos.getMemberByPos(randd).getId());
if (chrApp != null && chrApp.getMap().isCPQMap()) {
if (dis == null) {
chrApp.dispel();
} else {
chrApp.giveDebuff(dis, skil.getSkill());
}
}
}
neededCP = skil.cpLoss;
c.getSession().write(MaplePacketCreator.enableActions());
} else if (tab == 2) { //protectors
final MCSkill skil = MapleCarnivalFactory.getInstance().getGuardian(num);
if (skil == null || c.getPlayer().getCP() < skil.cpLoss) {
c.announce(MaplePacketCreator.CPQMessage((byte) 1));
c.getSession().write(MaplePacketCreator.enableActions());
return;
}
int success = c.getPlayer().getMap().spawnGuardian(c.getPlayer().getTeam(), num);
if (success == -1 || success == 0 || success == 2) {
if (success == -1) {
c.announce(MaplePacketCreator.CPQMessage((byte) 3));
} else if (success == 0) {
c.announce(MaplePacketCreator.CPQMessage((byte) 4));
} else if (success == 2) {
c.announce(MaplePacketCreator.CPQMessage((byte) 3));
}
c.getSession().write(MaplePacketCreator.enableActions());
return;
} else {
neededCP = skil.cpLoss;
}
}
c.getPlayer().gainCP(-neededCP);
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.playerSummoned(c.getPlayer().getName(), tab, num));
}catch (Exception e) {
e.printStackTrace();
}
return mid;
}
public int getPrice(int num, int tab) {
int price = 0;
num++;
if (tab == 0) {
switch (num) {
case 1:
case 2:
price = 7;
break;
case 3:
case 4:
price = 8;
break;
case 5:
case 6:
price = 9;
break;
case 7:
price = 10;
break;
case 8:
price = 11;
break;
case 9:
price = 12;
break;
case 10:
price = 30;
break;
}
} else if (tab == 1) {
switch (num) {
case 1:
price = 17;
break;
case 2:
case 4:
price = 19;
break;
case 3:
price = 12;
break;
case 5:
price = 16;
break;
case 6:
price = 14;
break;
case 7:
price = 22;
break;
case 8:
price = 18;
break;
}
} else {
switch (num) {
case 1:
case 3:
price = 17;
break;
case 2:
case 4:
case 6:
price = 16;
break;
case 5:
price = 13;
break;
case 7:
price = 12;
break;
case 8:
case 9:
price = 35;
break;
}
}
return price;
}
}

View File

@@ -21,8 +21,6 @@
*/
package net.server.channel.handlers;
//import java.sql.Connection;
//import java.sql.PreparedStatement;
import client.MapleClient;
import client.MapleCharacter;
import client.inventory.MapleInventoryType;
@@ -31,14 +29,10 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
//import tools.DatabaseConnection;
import net.AbstractMaplePacketHandler;
import client.inventory.manipulator.MapleInventoryManipulator;
import tools.DatabaseConnection;
import tools.data.input.SeekableLittleEndianAccessor;
//import scripting.npc.NPCScriptManager;
import tools.Pair;
import tools.MaplePacketCreator;
import tools.packets.Wedding;
@@ -52,6 +46,7 @@ import client.inventory.Item;
/**
* @author Jvlaple
* @author Ronan - major overhaul on Ring handling mechanics
* @author Drago/Dragohe4rt on Wishlist
*/
public final class RingActionHandler extends AbstractMaplePacketHandler {
private static int getBoxId(int useItemId) {
@@ -467,11 +462,16 @@ public final class RingActionHandler extends AbstractMaplePacketHandler {
break;
case 9: // Groom and Bride's Wishlist
short size = slea.readShort();
List<String> itemnames = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
itemnames.add(slea.readMapleAsciiString());
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);

View File

@@ -10,84 +10,61 @@ import client.inventory.Item;
import client.inventory.MapleInventoryType;
import client.MapleCharacter;
import client.MapleClient;
import client.inventory.Equip;
import constants.ItemConstants;
import tools.DatabaseConnection;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import net.AbstractMaplePacketHandler;
import client.inventory.manipulator.MapleInventoryManipulator;
import net.server.channel.Channel;
import scripting.event.EventInstanceManager;
import tools.MaplePacketCreator;
import tools.data.input.SeekableLittleEndianAccessor;
import tools.packets.Wedding;
/**
*
* @author Eric
* @author By Drago/Dragohe4rt
*/
public final class WeddingHandler extends AbstractMaplePacketHandler {
/*
public static final void OnWeddingProgress(byte action, MapleClient c) {
// -- Pelvis Bebop:
// 0x00: "We are gathered here today..."
// 0x01: "Very well! I pronounce you..."
// 0x02: "You two truly are a sight to..."
// 0x03: Wedding Ceremony Ended, initialize the Wedding Effect upon the two married characters
// -- High Priest John: (Unknown action bytes)
// 0x00: " "
// 0x01: " "
// 0x02: "Do you wish to bless this couple?..."
// 0x03: Wedding Ceremony Ended, initialize the Wedding Effect upon the two married characters
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().getMap().broadcastMessage(Wedding.OnWeddingProgress(action == 2, c.getPlayer().getId(), c.getPlayer().getPartnerId(), (byte)(action+1)));
c.getPlayer().getWedding().incrementStage();
c.getPlayer().getPartner().getWedding().incrementStage(); // pls don't b a bitch and throw npe ):<
if (action == 2) {
c.getPlayer().setMarried(true);
c.getChannelServer().getPlayerStorage().getCharacterById(c.getPlayer().getPartnerId()).setMarried(true);
}
}
}
c.announce(MaplePacketCreator.enableActions());
}
public static final void OnWeddingGiftResult(SeekableLittleEndianAccessor slea, MapleClient c) {
System.out.println("New WEDDING_GIFT_RESULT: " + slea.toString());
byte mode = slea.readByte();
switch(mode) {
case 0x06: // "SEND ITEM"
short slot = slea.readShort(); // isn't this a byte? o.O
int itemId = slea.readInt();
short quantity = slea.readShort();
if (c.getPlayer().getInventory(ItemConstants.getInventoryType(itemId)).getItem((byte)slot).getItemId() == itemId && c.getPlayer().getInventory(InventoryConstants.getInventoryType(itemId)).getItem((byte)slot).getQuantity() >= quantity) {
if (c.getPlayer().getWedding() == null) {
c.getPlayer().startWedding(); // TODO
}
List<String> itemnames = new ArrayList<>();
Item item = c.getPlayer().getInventory(ItemConstants.getInventoryType(itemId)).getItem((byte)slot);
boolean bride = false;
c.getPlayer().getWedding().registerWishlistItem(item, bride);
c.announce(Wedding.OnWeddingGiftResult((byte)11, itemnames, c.getPlayer().getWedding().getWishlistItems(bride))); // todo: remove item from inventory if success
}
case 0x08: // "EXIT"
if (slea.available() != 0) {
System.out.println("WEDDING_GIFT_RESULT: " + slea.toString());
}
c.announce(MaplePacketCreator.enableActions());
break;
default: {
System.out.println("Unknown Mode Found: " + mode + " : " + slea.toString());
}
}
}
*/
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
c.announce(MaplePacketCreator.enableActions());
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.announce(MaplePacketCreator.enableActions());
} else {
System.out.println(mode);
}
}
}

View File

@@ -1,24 +1,24 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
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 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.
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/>.
*/
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.world;
import client.MapleClient;
@@ -37,19 +37,20 @@ import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
import server.maps.MapleDoor;
public class MapleParty {
private int id;
private MapleParty enemy = null;
private int leaderId;
private List<MaplePartyCharacter> members = new LinkedList<>();
private List<MaplePartyCharacter> pqMembers = null;
private Map<Integer, Integer> histMembers = new HashMap<>();
private int nextEntry = 0;
private Map<Integer, MapleDoor> doors = new HashMap<>();
private MonitoredReentrantLock lock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.PARTY, true);
public MapleParty(int id, MaplePartyCharacter chrfor) {
this.leaderId = chrfor.getId();
this.id = id;
@@ -103,7 +104,7 @@ public class MapleParty {
lock.unlock();
}
}
public MaplePartyCharacter getMemberById(int id) {
lock.lock();
try {
@@ -126,7 +127,7 @@ public class MapleParty {
lock.unlock();
}
}
public List<MaplePartyCharacter> getPartyMembers() {
lock.lock();
try {
@@ -135,16 +136,16 @@ public class MapleParty {
lock.unlock();
}
}
// used whenever entering PQs: will draw every party member that can attempt a target PQ while ingnoring those unfit.
public Collection<MaplePartyCharacter> getEligibleMembers() {
return Collections.unmodifiableList(pqMembers);
}
public void setEligibleMembers(List<MaplePartyCharacter> eliParty) {
pqMembers = eliParty;
}
public int getId() {
return id;
}
@@ -152,7 +153,7 @@ public class MapleParty {
public void setId(int id) {
this.id = id;
}
public int getLeaderId() {
return leaderId;
}
@@ -160,8 +161,8 @@ public class MapleParty {
public MaplePartyCharacter getLeader() {
lock.lock();
try {
for(MaplePartyCharacter mpc: members) {
if(mpc.getId() == leaderId) {
for (MaplePartyCharacter mpc : members) {
if (mpc.getId() == leaderId) {
return mpc;
}
}
@@ -171,45 +172,53 @@ public class MapleParty {
lock.unlock();
}
}
public MapleParty getEnemy() {
return enemy;
}
public void setEnemy(MapleParty enemy) {
this.enemy = enemy;
}
public List<Integer> getMembersSortedByHistory() {
List<Entry<Integer, Integer>> histList;
lock.lock();
try {
histList = new LinkedList<>(histMembers.entrySet());
} finally {
lock.unlock();
}
Collections.sort(histList, new Comparator<Entry<Integer, Integer>>()
{
@Override
public int compare( Entry<Integer, Integer> o1, Entry<Integer, Integer> o2 )
{
return ( o1.getValue() ).compareTo( o2.getValue() );
}
});
Collections.sort(histList, new Comparator<Entry<Integer, Integer>>() {
@Override
public int compare(Entry<Integer, Integer> o1, Entry<Integer, Integer> o2) {
return (o1.getValue()).compareTo(o2.getValue());
}
});
List<Integer> histSort = new LinkedList<>();
for(Entry<Integer, Integer> e : histList) {
for (Entry<Integer, Integer> e : histList) {
histSort.add(e.getKey());
}
return histSort;
}
public byte getPartyDoor(int cid) {
List<Integer> histList = getMembersSortedByHistory();
byte slot = 0;
for(Integer e: histList) {
if(e == cid) break;
for (Integer e : histList) {
if (e == cid) {
break;
}
slot++;
}
return slot;
}
public void addDoor(Integer owner, MapleDoor door) {
lock.lock();
try {
@@ -218,33 +227,33 @@ public class MapleParty {
lock.unlock();
}
}
public void removeDoor(Integer owner) {
lock.lock();
lock.lock();
try {
this.doors.remove(owner);
} finally {
lock.unlock();
}
}
public Map<Integer, MapleDoor> getDoors() {
lock.lock();
lock.lock();
try {
return Collections.unmodifiableMap(doors);
} finally {
lock.unlock();
}
}
public void assignNewLeader(MapleClient c) {
World world = c.getWorldServer();
MaplePartyCharacter newLeadr = null;
lock.lock();
try {
for(MaplePartyCharacter mpc : members) {
if(mpc.getId() != leaderId && (newLeadr == null || newLeadr.getLevel() < mpc.getLevel())) {
for (MaplePartyCharacter mpc : members) {
if (mpc.getId() != leaderId && (newLeadr == null || newLeadr.getLevel() < mpc.getLevel())) {
newLeadr = mpc;
}
}
@@ -252,9 +261,11 @@ public class MapleParty {
lock.unlock();
}
if(newLeadr != null) world.updateParty(this.getId(), PartyOperation.CHANGE_LEADER, newLeadr);
if (newLeadr != null) {
world.updateParty(this.getId(), PartyOperation.CHANGE_LEADER, newLeadr);
}
}
public void disposeLocks() {
LockCollector.getInstance().registerDisposeAction(new Runnable() {
@Override
@@ -263,11 +274,11 @@ public class MapleParty {
}
});
}
private void emptyLocks() {
lock = lock.dispose();
}
@Override
public int hashCode() {
final int prime = 31;
@@ -276,6 +287,17 @@ public class MapleParty {
return result;
}
public MaplePartyCharacter getMemberByPos(int pos) {
int i = 0;
for (MaplePartyCharacter chr : members) {
if (pos == i) {
return chr;
}
i++;
}
return null;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {

View File

@@ -141,4 +141,100 @@ public class MaplePartyCharacter {
public int getWorld() {
return world;
}
public String getJobNameById(int job) {
switch (job) {
case 0:
return "Aprendiz";
case 100:
return "Guerreiro";// Warrior
case 110:
return "Soldado";
case 111:
return "Templario";
case 112:
return "Heroi";
case 120:
return "Escudeiro";
case 121:
return "Cavaleiro Branco";
case 122:
return "Paladino";
case 130:
return "Lanceiro";
case 131:
return "Cavaleiro Draconiano";
case 132:
return "Cavaleiro Negro";
case 200:
return "Bruxo";
case 210:
return "Feiticeiro (Fogo, Veneno)";
case 211:
return "Mago (Fogo, Veneno)";
case 212:
return "Arquimago (Fogo, Veneno)";
case 220:
return "Feiticeiro (Gelo, Raio)";
case 221:
return "Mago (Gelo, Raio)";
case 222:
return "Arquimago (Gelo, Raio)";
case 230:
return "Clérigo";
case 231:
return "Sacerdote";
case 232:
return "Sumo Sacerdote";
case 300:
return "Arqueiro";
case 310:
return "Caçador";
case 311:
return "Rastreador";
case 312:
return "Mestre Arqueiro";
case 320:
return "Balestreiro";
case 321:
return "Atirador";
case 322:
return "Atirador De Elite";
case 400:
return "Gatuno";
case 410:
return "Mercenario";
case 411:
return "Andarilho";
case 412:
return "Lorde Negro";
case 420:
return "Arruaceiro";
case 421:
return "Mestre Arruaceiro";
case 422:
return "Mestre Das Sombras";
case 500:
return "Pirata";
case 510:
return "Lutador";
case 511:
return "Saqueador";
case 512:
return "Foragido";
case 520:
return "Pistoleiro";
case 521:
return "Bucaneiro";
case 522:
return "Captain";
default:
return "Unknown Job";
}
}
}