-
[Add-on] Gold/Silver Box for v62
Hi guys, this is Gold/Silver Box for V62 sources.
recvops.properties:
sendops.properties:
Code:
SILVER_BOX_OPEN = 0x5A
RecvPacketOpcode.java:
SendPacketOpcode.java:
Code:
SILVER_BOX_OPEN, //0x5A
PacketProcessor.java:
Code:
registerHandler(RecvPacketOpcode.SILVER_BOX, new useTreasureBoxHandler());
SilverBoxHandler.java:
Code:
/*
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 version 3
as published by the Free Software Foundation. You may not use, modify
or distribute this program under any other version of the
GNU Affero General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.odinms.net.channel.handler;
import java.util.Random;
import net.sf.odinms.client.MapleClient;
import net.sf.odinms.client.MapleInventoryType;
import net.sf.odinms.net.MaplePacketHandler;
import net.sf.odinms.tools.MaplePacketCreator;
import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
/**
*
* @author Fate
*/
public class useTreasureBoxHandler implements MaplePacketHandler {
@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
slea.readShort();
int itemid = slea.readInt();
if (!c.getPlayer().isAlive()) {
c.getSession().write(MaplePacketCreator.enableActions());
return;
}
if (!c.getPlayer().haveItem(5490000, 1)) { //Check for the key.
c.getPlayer().dropMessage(5, "You do not have the Event Item Box Key to open this box.");
return;
}
for (MapleInventoryType type : MapleInventoryType.values()) { //Check inventory first
if (c.getPlayer().getInventory(type).isFull()) {
c.getPlayer().dropMessage(5, "You do not have enough inventory space for the item. Please clear up some space from your " + type.name().toLowerCase() + " inventory.");
return;
}
}
int prizeid = 0;
double chance = Math.random();
if (itemid == 4280001) { // Silver Box
int[] common = {3010000, 3010001, 3010002, 3010003, 3010006, 1002253, 1002254, 1442019, 1402028, 1312024, 1002339, 1082116, 1082**** 1452014, 1452015, 1452013, 1332029, 1332027, 1332036, 1472026, 1082210, 1482010, 2290124, 2290036, 2290088, 2290117, 2290123, 2044800, 2044900, 2040800, 5200000};
int[] uncommon = {3010018, 3010019, 3010025, 3010011, 3010012, 1432018, 2040801, 2044701, 2043801, 2043301, 2040704, 2044801, 2044401, 2040701, 2022179, 5200001};
int[] rare = {3010007, 3010008, 3010010, 3010040, 3010060, 3010062, 2290061, 2290085, 2290089, 2290063, 2290023, 2290003, 2049**** 2049000, 2049001, 2049002, 2049003, 2022282, 2022283};
if (chance < 0.05) { //Rare
prizeid = rare[new Random().nextInt(rare.length)];
} else if (chance >= 0.06 && chance < 0.35) { // Uncommon
prizeid = uncommon[new Random().nextInt(uncommon.length)];
} else { // Common
prizeid = common[new Random().nextInt(common.length)];
}
} else { //Gold Box
int[] common = {3010004, 3010015, 3010013, 3011000, 1382047, 1382048, 1372010, 1382010, 1002271, 1402016, 1442020, 1402037, 1442008, 1402035, 1422031, 1412019, 1412010, 1462018, 1462013, 1452009, 1332052, 1002283, 1002328, 1002327, 1082210, 1482010, 2290028, 2290056, 2290034, 2290044, 2290121, 2290026, 2044800, 2044900, 2040800, 5200000};
int[] uncommon = {3010009, 3010016, 3010017, 3010014, 3010041, 2040809, 2040811, 2043805, 2043305, 2040715, 2044804, 2044405, 2040713, 2022179, 5200002};
int[] rare = {3010046, 3010047, 3010058, 3010057, 3010043, 3010071, 3010085, 30100*** 2290007, 2290049, 2290043, 2290122, 2290039, 2290**** 2290055, 2290120, 2290087, 2290063, 2290103, 2290069, 2290033, 2049**** 2049000, 2049001, 2049002, 2049003, 2022282, 2022283};
if (chance < 0.1) { //Rare
prizeid = rare[new Random().nextInt(rare.length)];
} else if (chance >= 0.11 && chance < 0.35) { // Uncommon
prizeid = uncommon[new Random().nextInt(uncommon.length)];
} else { // Common
prizeid = common[new Random().nextInt(common.length)];
}
}
if (prizeid != 0) {
c.getPlayer().gainItem(5490000, (short) -1, false, false); // Remove key
c.getPlayer().gainItem(itemid, (short) -1, false, false); // Remove itembox
c.getPlayer().gainItem(prizeid, (short) 1, true, true); // Give item
c.getSession().write(MaplePacketCreator.sendSilverBoxOpened(itemid)); // Show box is open
}
}
}
MaplePacketCreator.java:
Code:
public static MaplePacket sendSilverBoxOpened(int itemid) {
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
mplew.writeShort(SendPacketOpcode.SILVER_BOX_OPEN.getValue());
mplew.writeInt(itemid);
return mplew.getPacket();
}
Extras:
Just update the opcode, you should be able to use them for other versions.
ItemList:
Updates:
I kinda forgot i have some stuffs different XD
here are the things u may need to modify:
change:
Code:
public class useTreasureBoxHandler implements MaplePacketHandler {
to:
Code:
public class useTreasureBoxHandler extends AbstractMaplePacketHandler {
if you are missing the haveItem function:
Code:
public boolean haveItem(int itemid, int quantity) {
return haveItem(itemid, quantity, true,true);
}
Credits:
Fate
-
Re: Gold/Silver Box for v62
-
Re: Gold/Silver Box for v62
trying it out makes things easier to be explained.
-
Re: Gold/Silver Box for v62
-
Re: Gold/Silver Box for v62
u know? treasure box? treasure box key? use them? get item? thats practically it
-
Re: Gold/Silver Box for v62
-
Re: Gold/Silver Box for v62
Already released in Valhalla but yours is better (only send part is new though).
-
Re: Gold/Silver Box for v62
How do I make a world message which tells everybody which player and which item he won?
-
Re: Gold/Silver Box for v62
-
Re: Gold/Silver Box for v62
Nice release like always :D
-
Re: Gold/Silver Box for v62
Quote:
Originally Posted by
dexloos
How do I make a world message which tells everybody which player and which item he won?
PHP Code:
c.getChannelServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "text here"));
-
Re: Gold/Silver Box for v62
Quote:
Originally Posted by
FateJiki
PHP Code:
c.getChannelServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "text here"));
That's for the same channel though.
You have to call worldinterface and stuff or you can just do
for (ChannelServer hm : ChannelServer.getAllInstances())
hm.broadcastPacket(MaplePacketCraetor.serverNotice(5, "hi");
-
Re: Gold/Silver Box for v62
Quote:
Originally Posted by
jakesdexless
That's for the same channel though.
You have to call worldinterface and stuff or you can just do
for (ChannelServer hm : ChannelServer.getAllInstances())
hm.broadcastPacket(MaplePacketCraetor.serverNotice(5, "hi");
The latter will only work if you don't multi-host.
-
Re: Gold/Silver Box for v62
-
Re: Gold/Silver Box for v62
Quote:
Originally Posted by
jakesdexless
That's for the same channel though.
You have to call worldinterface and stuff or you can just do
for (ChannelServer hm : ChannelServer.getAllInstances())
hm.broadcastPacket(MaplePacketCraetor.serverNotice(5, "hi");
I recommend you only do it for channel. It would be too much spam if its world.
-
Re: Gold/Silver Box for v62
i got bats errors when compiling
Compiling 405 source files to C:\Users\KokRong\Desktop\ServerBuildFolder\build\classes
C:\Users\KokRong\Desktop\NarutoMS Source\src\net\sf\odinms\net\channel\handler\SilverBoxHandler.java:34: net.sf.odinms.net.channel.handler.SilverBoxHandler is not abstract and does not override abstract method validateState(net.sf.odinms.client.MapleClient) in net.sf.odinms.net.MaplePacketHandler
public class SilverBoxHandler implements MaplePacketHandler {
C:\Users\KokRong\Desktop\NarutoMS Source\src\net\sf\odinms\net\channel\handler\SilverBoxHandler.java:44: cannot find symbol
symbol : method haveItem(int,int)
location: class net.sf.odinms.client.MapleCharacter
if (!c.getPlayer().haveItem(5490000, 1)) { //Check for the key.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
C:\Users\KokRong\Desktop\ServerBuildFolder\nbproject\build-impl.xml:406: The following error occurred while executing this line:
C:\Users\KokRong\Desktop\ServerBuildFolder\nbproject\build-impl.xml:196: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 4 seconds)
-
Re: Gold/Silver Box for v62
Quote:
Originally Posted by
tsunayoshi
i got bats errors when compiling
Compiling 405 source files to C:\Users\KokRong\Desktop\ServerBuildFolder\build\classes
C:\Users\KokRong\Desktop\NarutoMS Source\src\net\sf\odinms\net\channel\handler\SilverBoxHandler.java:34: net.sf.odinms.net.channel.handler.SilverBoxHandler is not abstract and does not override abstract method validateState(net.sf.odinms.client.MapleClient) in net.sf.odinms.net.MaplePacketHandler
public class SilverBoxHandler implements MaplePacketHandler {
C:\Users\KokRong\Desktop\NarutoMS Source\src\net\sf\odinms\net\channel\handler\SilverBoxHandler.java:44: cannot find symbol
symbol : method haveItem(int,int)
location: class net.sf.odinms.client.MapleCharacter
if (!c.getPlayer().haveItem(5490000, 1)) { //Check for the key.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
C:\Users\KokRong\Desktop\ServerBuildFolder\nbproject\build-impl.xml:406: The following error occurred while executing this line:
C:\Users\KokRong\Desktop\ServerBuildFolder\nbproject\build-impl.xml:196: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 4 seconds)
This isn't made for all sources. You might have to make some modifications to it to work on your source.
-
Re: Gold/Silver Box for v62
so basically, just update the ops code for it to work in v75?
-
Re: Gold/Silver Box for v62
Quote:
Originally Posted by
b0ib0ii
so basically, just update the ops code for it to work in v75?
Yep, thats basicly it. This is meant to work on v62 but im not sure you probably will beable to update it to v75 to by changing up the packets.
-
Re: Gold/Silver Box for v62
Updated.
---------- Post added at 02:59 PM ---------- Previous post was at 02:53 PM ----------
Quote:
Originally Posted by
jakesdexless
Already released in Valhalla but yours is better (only send part is new though).
Actually, not really released. But the opcode was there. I got the recopcode and guessed the sendopcode's packet structure.
-
Re: Gold/Silver Box for v62
Quote:
Originally Posted by
iFayte
Updated.
---------- Post added at 02:59 PM ---------- Previous post was at 02:53 PM ----------
Actually, not really released. But the opcode was there. I got the recopcode and guessed the sendopcode's packet structure.
yes and it's called usetreasureboxhandler
-
Re: Gold/Silver Box for v62
mhm kay il change it :] but it doesnt really affect anything just make things clearer i guess XP
---------- Post added at 04:31 PM ---------- Previous post was at 03:32 PM ----------
Updated with ItemList
-
Re: Gold/Silver Box for v62
so how do I update this to v75?
-
Re: Gold/Silver Box for v62
update the ssend and recieve opcodes.
Start a packet sniffer and use the item
click ok and see what is the packet header.
-
Re: Gold/Silver Box for v62
when i click my gold/silver box and press ok , it says you do not have enough inventory space for the item . Please clear up some space from your undefined inventory while my inventory is not full at all , please help me solve this problem thanks .