[Release] v55 Ring effects (3rd Party)
Uhh, 2 reasons i'm releasing this, because everyone is moving on to v60 and because I quit so I dun care anymore. Figured out restructuring it would be a total waste of time since i might as well take everything thats already there and working. Yeah call me a leecher if you wish but even with everything there you guys can't get it done =/
I take credits only for extracting it properly, everything else goes to RMZero.
List of files needed :
Code:
1) Equip.java
2) IEquip.java
3) MapleCharacter.java
4) MaplePacketCreator.java
5) MapleRing.java
6) MapleInventoryManipulator.java
7) MapleItemInformationProvider.java
8) MapleStorage.java
9) CommandProcessor.java
Execute these sql :
Code:
CREATE TABLE `rings` (
`id` int(11) NOT NULL auto_increment,
`partnerRingId` int(11) NOT NULL default '0',
`partnerChrId` int(11) NOT NULL default '0',
`itemid` int(11) NOT NULL default '0',
`partnername` varchar(255) NOT NULL,
PRIMARY KEY USING BTREE (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=latin1;
and :
Code:
ALTER TABLE `inventoryequipment` ADD `ringid` int(11) NOT NULL default '-1'
Here we go.
Before you begin anything, make sure you have a MapleRing.java in net.sf.odinms.client.
In MapleRing.java :
In src\net\sf\odinms\client, create a new text document. Inside it, paste all of this. After that save it as all files as MapleRing.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/>.
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.sf.odinms.client;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.odinms.database.DatabaseConnection;
import net.sf.odinms.server.MapleInventoryManipulator;
import net.sf.odinms.tools.MaplePacketCreator;
/**
*
* @author Danny
*/
public class MapleRing implements Comparable<MapleRing> {
private int ringId;
private int ringId2;
private int partnerId;
private int itemId;
private String partnerName;
private boolean equipped;
private MapleRing(int id, int id2, int partnerId, int itemid, String partnerName) {
this.ringId = id;
this.ringId2 = id2;
this.partnerId = partnerId;
this.itemId = itemid;
this.partnerName = partnerName;
}
public static MapleRing loadFromDb(int ringId) {
try {
Connection con = DatabaseConnection.getConnection(); // Get a connection to the database
PreparedStatement ps = con.prepareStatement("SELECT * FROM rings WHERE id = ?");
ps.setInt(1, ringId);
ResultSet rs = ps.executeQuery();
rs.next();
MapleRing ret = new MapleRing(ringId,
rs.getInt("partnerRingId"),
rs.getInt("partnerChrId"),
rs.getInt("itemid"),
rs.getString("partnerName"));
rs.close();
ps.close();
return ret;
} catch (SQLException ex) {
Logger.getLogger(MaplePet.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
public static int[] createRing(MapleClient c, int itemid, int chrId, String chrName, int partnerId, String partnerName) {
try {
MapleCharacter chr = c.getChannelServer().getPlayerStorage().getCharacterById(partnerId);
if (chr == null) {
int[] ret_ = new int[2];
ret_[0] = -1;
ret_[1] = -1;
return ret_;
}
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO rings (itemid, partnerChrId, partnerName) VALUES (?, ?, ?)");
ps.setInt(1, itemid);
ps.setInt(2, partnerId);
ps.setString(3, partnerName);
ps.executeUpdate();
ResultSet rs = ps.getGeneratedKeys();
rs.next();
int[] ret = new int[2];
ret[0] = rs.getInt(1);
rs.close();
ps.close();
ps = con.prepareStatement("INSERT INTO rings (itemid, partnerRingId, partnerChrId, partnerName) VALUES (?, ?, ?, ?)");
ps.setInt(1, itemid);
ps.setInt(2, ret[0]);
ps.setInt(3, chrId);
ps.setString(4, chrName);
ps.executeUpdate();
rs = ps.getGeneratedKeys();
rs.next();
ret[1] = rs.getInt(1);
rs.close();
ps.close();
ps = con.prepareStatement("UPDATE rings SET partnerRingId = ? WHERE id = ?");
ps.setInt(1, ret[1]);
ps.setInt(2, ret[0]);
ps.executeUpdate();
ps.close();
MapleCharacter player = c.getPlayer();
MapleInventoryManipulator.addRing(player, itemid, ret[0]);
MapleInventoryManipulator.addRing(chr, itemid, ret[1]);
c.getSession().write(MaplePacketCreator.getCharInfo(player));
player.getMap().removePlayer(player);
player.getMap().addPlayer(player);
chr.getClient().getSession().write(MaplePacketCreator.getCharInfo(chr));
chr.getMap().removePlayer(chr);
chr.getMap().addPlayer(chr);
chr.getClient().getSession().write(MaplePacketCreator.serverNotice(5, "You have received a ring from " + player.getName() + ". Please log out and log back in again if it does not work correctly."));
return ret;
} catch (SQLException ex) {
Logger.getLogger(MaplePet.class.getName()).log(Level.SEVERE, null, ex);
int[] ret = new int[2];
ret[0] = -1;
ret[1] = -1;
return ret;
}
}
public int getRingId() {
return ringId;
}
public int getPartnerRingId() {
return ringId2;
}
public int getPartnerChrId() {
return partnerId;
}
public int getItemId() {
return itemId;
}
public String getPartnerName() {
return partnerName;
}
public boolean isEquipped() {
return equipped;
}
public void setEquipped(boolean equipped) {
this.equipped = equipped;
}
@Override
public boolean equals(Object o) {
if (o instanceof MapleRing) {
if (((MapleRing) o).getRingId() == getRingId()) {
return true;
} else {
return false;
}
}
return false;
}
@Override
public int hashCode() {
int hash = 5;
hash = 53 * hash + this.ringId;
return hash;
}
@Override
public int compareTo(MapleRing other) {
if (ringId < other.getRingId())
return -1;
else if (ringId == other.getRingId())
return 0;
else
return 1;
}
}
Save and close MapleRing.java.
In Equip.java :
Ctrl + F and search for :
Code:
private short str, dex, _int, luk, hp, mp, watk, matk, wdef, mdef, acc, avoid, hands, speed, jump;
Under that add :
Code:
private int ringid;
Ctrl + F and search for :
Code:
public Equip(int id, byte position) {
super(id, position, (short) 1);
}
Replace that with :
Code:
public Equip(int id, byte position) {
super(id, position, (short) 1);
this.ringid = -1;
}
public Equip(int id, byte position, int ringid) {
super(id, position, (short) 1);
this.ringid = ringid;
}
Scroll down slightly and search for :
Code:
Equip ret = new Equip(getItemId(), getPosition());
Change that to :
Code:
Equip ret = new Equip(getItemId(), getPosition(), getRingId());
Now, search
Code:
@Override
public short getJump() {
return jump;
}
Under it add
Code:
@Override
public int getRingId() {
return ringid;
}
Save and close Equip.java.
In IEquip.java :
Ctrl + F and search for :
Code:
public short getJump();
Under that add :
Code:
public int getRingId();
Save and close IEquip.java.
In MapleCharacter.java :
Ctrl + F and search for :
Code:
Equip equip = new Equip(itemid, (byte) rs.getInt("position"));
Replace that with :
Code:
Equip equip = new Equip(itemid, (byte) rs.getInt("position"), rs.getInt("ringid"));
Then, Ctrl + F and search
Code:
pse.setInt(18, equip.getJump());
Under it, add :
Code:
pse.setInt(19, equip.getRingId());
Then, Ctrl + F and search
Code:
"INSERT INTO inventoryequipment "
Below it, replace
Code:
"VALUES (DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
With
Code:
"VALUES (DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
Save and close MapleCharacter.java.
In MaplePacketCreator.java :
Ctrl + F and search for :
Code:
if (chr.getPlayerShop() != null && chr.getPlayerShop().isOwner(chr)) {
Replace the function with :
Code:
if (chr.getPlayerShop() != null && chr.getPlayerShop().isOwner(chr)) {
if (chr.getPlayerShop().hasFreeSlot()) {
addAnnounceBox(mplew, chr.getPlayerShop(), 4 );
} else {
addAnnounceBox(mplew, chr.getPlayerShop(), 1 );
}
} else {
mplew.write(0);
}
//loop for rings begin here
List<MapleRing> rings = getRing(chr);
mplew.write(0);
mplew.writeShort(0);
mplew.write(rings.size());
if (rings.size() > 0) {
for (MapleRing ring : rings) {
mplew.writeInt(chr.getId());
mplew.writeInt(ring.getPartnerChrId());
mplew.writeInt(ring.getItemId());
mplew.writeShort(0);
}
} else {
mplew.write(0);
}
return mplew.getPacket();
}
private static List<MapleRing> getRing(MapleCharacter chr) {
MapleInventory iv = chr.getInventory(MapleInventoryType.EQUIPPED);
Collection<IItem> equippedC = iv.list();
List<Item> equipped = new ArrayList<Item>(equippedC.size());
for (IItem item : equippedC) {
equipped.add((Item) item);
}
Collections.sort(equipped);
List<MapleRing> rings = new ArrayList<MapleRing>();
for (Item item : equipped) {
if (((IEquip) item).getRingId() > -1) {
rings.add(MapleRing.loadFromDb(((IEquip) item).getRingId()));
}
}
Collections.sort(rings);
return rings;
}
Ctrl + F and find :
Code:
public static MaplePacket updateCharLook(MapleCharacter chr) {
At the end of the function, replace
Code:
mplew.write(0);
return mplew.getPacket();
}
With this :
Code:
List<MapleRing> rings = getRing(chr);
mplew.write(rings.size());
//if (rings.size() == 0) {
// mplew.writeShort(0);
//} else {
for (MapleRing ring : rings) {
mplew.writeInt(chr.getId());
mplew.writeInt(ring.getPartnerChrId());
mplew.writeInt(ring.getItemId());
mplew.writeShort(0);
}
//}
return mplew.getPacket();
}
If you get an addAnnounceBox error(cannot be applied to blah blah blah), search :
Code:
private static void addAnnounceBox
Replace the function with :
Code:
private static void addAnnounceBox(MaplePacketLittleEndianWriter mplew, MaplePlayerShop shop, int availability) {
// 00: no game
// 01: omok game
// 02: card game
// 04: shop
mplew.write(4);
mplew.writeInt(shop.getObjectId()); // gameid/shopid
mplew.writeMapleAsciiString(shop.getDescription()); // desc
// 00: public
// 01: private
mplew.write(0);
// 00: red 4x3
// 01: green 5x4
// 02: blue 6x5
// omok:
// 00: normal
mplew.write(0);
// first slot: 1/2/3/4
// second slot: 1/2/3/4
mplew.write(1);
mplew.write(availability);
// 0: open
// 1: in progress
mplew.write(0);
}
Add this import :
Code:
import net.sf.odinms.client.MapleRing;
Save and close your MaplePacketCreator.java.
In MapleInventoryManipulator.java :
Add this import :
Code:
import net.sf.odinms.client.MapleCharacter;
Ctrl + F and search :
Code:
private static Logger log = LoggerFactory.getLogger(MapleInventoryManipulator.class);
Under it add :
Code:
public static boolean addRing(MapleCharacter chr, int itemId, int ringId) {
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
MapleInventoryType type = ii.getInventoryType(itemId);
IItem nEquip = ii.getEquipById(itemId, ringId);
String logMsg = "Ring created by " + chr.getName();
nEquip.log(logMsg, false);
byte newSlot = chr.getInventory(type).addItem(nEquip);
if (newSlot == -1) {
return false;
}
chr.getClient().getSession().write(MaplePacketCreator.addInventorySlot(type, nEquip));
return true;
}
Save and close MapleInventoryManipulator.java.
In MapleItemInformationProvider.java :
Ctrl + F and search :
Code:
public IItem getEquipById(int equipId) {
if (equipCache.containsKey(equipId))
return equipCache.get(equipId).copy();
Equip nEquip = new Equip(equipId, (byte) 0);
nEquip.setQuantity((short) 1);
Map<String, Integer> stats = this.getEquipStats(equipId);
Replace that with :
Code:
public IItem getEquipById(int equipId) {
if (equipCache.containsKey(equipId))
return equipCache.get(equipId).copy();
return getEquipById(equipId, -1);
}
public IItem getEquipById(int equipId, int ringId) {
if (equipCache.containsKey(equipId))
return equipCache.get(equipId).copy();
Equip nEquip = new Equip(equipId, (byte) 0, ringId);
nEquip.setQuantity((short) 1);
Map<String, Integer> stats = this.getEquipStats(equipId);
Ctrl + F and search :
Code:
public boolean isArrowForBow(int itemId) {
return itemId >= 2060000 && itemId < 2061000;
}
Under it add :
Code:
public boolean isRing(int itemId) {
return itemId >= 1112000 && itemId < 1120000;
}
public boolean isEffectRing(int itemid) {
if (itemid < 1112000 || itemid > 1120000) {
return false;
} else if (itemid > 1112006 && itemid < 1112800) {
return false;
} else if (itemid == 1112808) {
return false;
} else {
return true;
}
}
Save and close MapleItemInformationProvider.java.
In MapleStorage.java :
Ctrl + F and search :
Code:
Equip equip = new Equip(itemid, (byte) rs.getInt("position"));
Change that to :
Code:
Equip equip = new Equip(itemid, (byte) rs.getInt("position"), rs.getInt("ringid"));
Ctrl + F and search :
Code:
pse.setInt(18, equip.getJump());
Under it add :
Code:
pse.setInt(19, equip.getRingId());
Search :
Code:
"INSERT INTO inventoryequipment "
Replace :
Code:
"VALUES (DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
With :
Code:
"VALUES (DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
Save and close MapleStorage.java.
Finally, in CommandProcessor.java, paste this above anything that looks like this :
Code:
} else if (splitted[0].equals("!commandnamehere")) {
Paste this :
Code:
} else if (splitted[0].equals("!ring")) {
int itemId = Integer.parseInt(splitted[1]);
String partnerName = splitted[2];
int partnerId = MapleCharacter.getIdByName(partnerName, 0);
int[] ret = MapleRing.createRing(c, itemId, c.getPlayer().getId(), c.getPlayer().getName(), partnerId, partnerName);
if (ret[0] == -1 || ret[1] == -1) {
mc.dropMessage("There was an unknown error.");
mc.dropMessage("Make sure the person you are attempting to create a ring with is online.");
}
Add this import :
Code:
import.net.sf.odinms.client.MapleRing;
Save and close CommandProcessor.java.
Compile and you're done !
*Note* If you get any errors just add in the required imports cause I may have missed some.
Fixed what all of you guys failed, the rollbacks and the storage screw ups.
-- For Player Usage --
In NPCConversationManager.java :
Code:
public static boolean makeRing(MapleClient mc, String partner, int ringId){
int partnerId = MapleCharacter.getIdByName(partner, 0);
int[] ret = net.sf.odinms.client.MapleRing.createRing(mc, ringId, mc.getPlayer().getId(), mc.getPlayer().getName(), partnerId, partner);
if (ret[0] == -1 || ret[1] == -1) {
return false;
}else{
return true;
}
}
NPC Script should look something like this (untested just rushed it) :
Code:
/*
Mong From Kong - Ring NPC (NPCId - 1052012)
@author - AceEvolution
RingIds :
Sparkling ring - 1112000
Crush ring - 1112001
Cloud ring - 1112002
Cupid ring - 1112003
Venus fireworks - 1112005
Crossed hearts - 1112006
*/
var status = 0;
var ringid;
var partnername;
var c = cm.c;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0 && status == 0) {
cm.dispose();
return;
}
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendSimple("Hello ! I make rings for married couples ! Choose a ring : \r\n#L0#Sparlking Ring#l\r\n#L1#Crush Ring#l\r\n#L2#Cloud Ring#l\r\n#L3#Cupid Ring#l\r\n#L4#Venus Fireworks#l\r\n#L5#Crossed Hearts#l");
} else if (status == 1) {
if (selection == 0) {
ringid = 1112000;
cm.sendGetText("Partner's name :");
} else if (selection == 1) {
ringid = 1112001;
cm.sendGetText("Partner's name :");
} else if (selection == 2) {
ringid = 1112002;
cm.sendGetText("Partner's name :");
} else if (selection == 3) {
ringid = 1112003;
cm.sendGetText("Partner's name :");
} else if (selection == 4) {
ringid = 1112005;
cm.sendGetText("Partner's name :");
} else if (selection == 5) {
ringid = 1112006;
cm.sendGetText("Partner's name :");
}
} else if (status == 2) {
partnername = cm.getText();
cm.makeRing(c, partnername, ringid);
}
}
}
Re: [Release] v55 Ring effects
Re: [Release] v55 Ring effects
Re: [Release] v55 Ring effects (3rd Party)
I like the rings nice job acEvolution. (:
Re: [Release] v55 Ring effects (3rd Party)
good luck in getting them working. though the guide is long and tedious it should work if you follow it step by step.
Re: [Release] v55 Ring effects (3rd Party)
Re: [Release] v55 Ring effects (3rd Party)
Im going to try to add this to my server
very nice release
Re: [Release] v55 Ring effects (3rd Party)
nice job posting might use if i ever downgrade my server to v.55 =]
Re: [Release] v55 Ring effects (3rd Party)
Nice release! only multi pets too go..
Re: [Release] v55 Ring effects (3rd Party)
Quote:
Originally Posted by
Gmanpopinjay
nice job posting might use if i ever downgrade my server to v.55 =]
same. il use this if i get a v55 server lol.
Re: [Release] v55 Ring effects (3rd Party)
Nice! But i already have this working :P
Re: [Release] v55 Ring effects (3rd Party)
Quote:
Nice! But i already have this working :P
You Do o.0.
Well good job on extracting this out of the source and making it and individual release for people to use :D it is quite helpful and good work on the effort in doing it
Re: [Release] v55 Ring effects (3rd Party)
Ok by looking at the command, does it onyl work with the command or the ring works as-well?