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 :
Execute these sql :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
and :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;
Here we go.Code:ALTER TABLE `inventoryequipment` ADD `ringid` int(11) NOT NULL default '-1'
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.
Save and close 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; } }
In Equip.java :
Ctrl + F and search for :Under that add :Code:private short str, dex, _int, luk, hp, mp, watk, matk, wdef, mdef, acc, avoid, hands, speed, jump;Ctrl + F and search for :Code:private int ringid;Replace that with :Code:public Equip(int id, byte position) { super(id, position, (short) 1); }Scroll down slightly and search for :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; }Change that to :Code:Equip ret = new Equip(getItemId(), getPosition());Now, searchCode:Equip ret = new Equip(getItemId(), getPosition(), getRingId());Under it addCode:@Override public short getJump() { return jump; }Save and close Equip.java.Code:@Override public int getRingId() { return ringid; }
In IEquip.java :
Ctrl + F and search for :Under that add :Code:public short getJump();Save and close IEquip.java.Code:public int getRingId();
In MapleCharacter.java :
Ctrl + F and search for :Replace that with :Code:Equip equip = new Equip(itemid, (byte) rs.getInt("position"));Then, Ctrl + F and searchCode:Equip equip = new Equip(itemid, (byte) rs.getInt("position"), rs.getInt("ringid"));Under it, add :Code:pse.setInt(18, equip.getJump());Then, Ctrl + F and searchCode:pse.setInt(19, equip.getRingId());Below it, replaceCode:"INSERT INTO inventoryequipment "WithCode:"VALUES (DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");Save and close MapleCharacter.java.Code:"VALUES (DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
In MaplePacketCreator.java :
Ctrl + F and search for :Replace the function with :Code:if (chr.getPlayerShop() != null && chr.getPlayerShop().isOwner(chr)) {Ctrl + F and find :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; }At the end of the function, replaceCode:public static MaplePacket updateCharLook(MapleCharacter chr) {With this :Code:mplew.write(0); return mplew.getPacket(); }If you get an addAnnounceBox error(cannot be applied to blah blah blah), search :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(); }
Replace the function with :Code:private static void addAnnounceBox
Add this import :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); }Save and close your MaplePacketCreator.java.Code:import net.sf.odinms.client.MapleRing;
In MapleInventoryManipulator.java :
Add this import :Ctrl + F and search :Code:import net.sf.odinms.client.MapleCharacter;Under it add :Code:private static Logger log = LoggerFactory.getLogger(MapleInventoryManipulator.class);Save and close MapleInventoryManipulator.java.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; }
In MapleItemInformationProvider.java :
Ctrl + F and search :Replace that with :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);Ctrl + F and search :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);Under it add :Code:public boolean isArrowForBow(int itemId) { return itemId >= 2060000 && itemId < 2061000; }Save and close MapleItemInformationProvider.java.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; } }
In MapleStorage.java :
Ctrl + F and search :Change that to :Code:Equip equip = new Equip(itemid, (byte) rs.getInt("position"));Ctrl + F and search :Code:Equip equip = new Equip(itemid, (byte) rs.getInt("position"), rs.getInt("ringid"));Under it add :Code:pse.setInt(18, equip.getJump());Search :Code:pse.setInt(19, equip.getRingId());Replace :Code:"INSERT INTO inventoryequipment "With :Code:"VALUES (DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")Save and close MapleStorage.java.Code:"VALUES (DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
Finally, in CommandProcessor.java, paste this above anything that looks like this :Paste this :Code:} else if (splitted[0].equals("!commandnamehere")) {Add this import :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."); }Save and close CommandProcessor.java.Code:import.net.sf.odinms.client.MapleRing;
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 :
NPC Script should look something like this (untested just rushed it) :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; } }
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); } } }



Reply With Quote![[Release] v55 Ring effects (3rd Party)](http://ragezone.com/hyper728.png)


