- Joined
- Jun 8, 2007
- Messages
- 165
- Reaction score
- 8
ALL CREDITS GO TO GROAT@@@@@@@@@@@@
Replace net.sf.odinms.net.channel.handler.MovePetHandler with this:
In net.sf.odinms.toold.maplepacketcreator:
replace
with
In net.sf.odinms.server.movement.AbstractLifeMovement:
add this:
after:
and add:
after:
In net.sf.odinms.server.movement.ChangeEquipSpecialAwesome:
add:
after:
add:
after:
In net.sf.odinms.server.movement.LifeMovementFragment:
add:
after:
add:
after:
In net.sf.odinms.server.movement.LifeMovement:
Add:
after:
1812000:meso magnet
1812001: item pouch
This should do it. Correct me if I forgot something. Again:
ALL CREDITS GO TO GROAT@@@@@@@@@@@@
Replace net.sf.odinms.net.channel.handler.MovePetHandler with this:
Code:
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <[email protected]>
Matthias Butz <[email protected]>
Jan Christian Meyer <[email protected]>
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.awt.Point;
import java.util.Arrays;
import java.util.List;
import net.sf.odinms.client.MapleCharacter;
import net.sf.odinms.client.MapleClient;
import net.sf.odinms.client.MapleInventoryType;
import net.sf.odinms.server.MapleInventoryManipulator;
import net.sf.odinms.server.maps.MapleMapItem;
import net.sf.odinms.server.maps.MapleMapObject;
import net.sf.odinms.server.maps.MapleMapObjectType;
import net.sf.odinms.server.movement.LifeMovementFragment;
import net.sf.odinms.tools.MaplePacketCreator;
import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
import net.sf.odinms.tools.data.input.StreamUtil;
public class MovePetHandler extends AbstractMovementPacketHandler {
//private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(MovePetHandler.class);
@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
int petId = slea.readInt();
slea.readInt();
@SuppressWarnings("Unused")
Point startPos = StreamUtil.readShortPoint(slea);
List<LifeMovementFragment> res = parseMovement(slea);
MapleCharacter player = c.getPlayer();
player.getMap().broadcastMessage(player, MaplePacketCreator.movePet(player.getId(), petId, res), false);
Boolean meso = false;
Boolean item = false;
if (c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).findById(1812001) != null)
item = true;
if (c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).findById(1812000) != null)
meso = true;
if (meso || item) {
List<MapleMapObject> objects = player.getMap().getMapObjectsInRange(player.getPosition(), MapleCharacter.MAX_VIEW_RANGE_SQ, Arrays.asList(MapleMapObjectType.ITEM));
for (LifeMovementFragment move : res) {
Point petPos = move.findPosition();
double petX = petPos.getX();
double petY = petPos.getY();
for (MapleMapObject map_object : objects) {
Point objectPos = map_object.getPosition();
double objectX = objectPos.getX();
double objectY = objectPos.getY();
if (Math.abs(petX - objectX) <= 30 || Math.abs(objectX - petX) <= 30) {
if (Math.abs(petY - objectY) <= 30 || Math.abs(objectY - petY) <= 30) {
if (map_object instanceof MapleMapItem) {
MapleMapItem mapitem = (MapleMapItem)map_object;
synchronized (mapitem) {
if (mapitem.isPickedUp() || mapitem.getOwner().getId() != player.getId()) {
continue;
}
if (mapitem.getMeso() > 0 && meso) {
c.getPlayer().gainMeso(mapitem.getMeso(), true, true);
c.getPlayer().getMap().broadcastMessage(
MaplePacketCreator.removeItemFromMap(mapitem.getObjectId(), 5, c.getPlayer().getId(), true),
mapitem.getPosition());
c.getPlayer().getMap().removeMapObject(map_object);
mapitem.setPickedUp(true);
}
else {
if (item) {
StringBuilder logInfo = new StringBuilder("Picked up by ");
logInfo.append(c.getPlayer().getName());
if (MapleInventoryManipulator.addFromDrop(c, mapitem.getItem(), logInfo.toString())) {
c.getPlayer().getMap().broadcastMessage(
MaplePacketCreator.removeItemFromMap(mapitem.getObjectId(), 5, c.getPlayer().getId(), true),
mapitem.getPosition());
c.getPlayer().getMap().removeMapObject(map_object);
mapitem.setPickedUp(true);
}
}
}
}
}
}
}
}
}
}
}
}
In net.sf.odinms.toold.maplepacketcreator:
replace
Code:
public static MaplePacket removeItemFromMap(int oid, int animation, int cid) {
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
mplew.writeShort(SendPacketOpcode.REMOVE_ITEM_FROM_MAP.getValue());
mplew.write(animation); // expire
mplew.writeInt(oid);
if (animation >= 2) {
mplew.writeInt(cid);
}
return mplew.getPacket();
}
Code:
public static MaplePacket removeItemFromMap(int oid, int animation, int cid) {
return removeItemFromMap(oid, animation, cid, false);
}
public static MaplePacket removeItemFromMap(int oid, int animation, int cid, boolean pet) {
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
mplew.writeShort(SendPacketOpcode.REMOVE_ITEM_FROM_MAP.getValue());
mplew.write(animation); // expire
mplew.writeInt(oid);
if (animation >= 2) {
mplew.writeInt(cid);
if (pet) {
mplew.write(0);
}
}
return mplew.getPacket();
}
In net.sf.odinms.server.movement.AbstractLifeMovement:
add this:
Code:
public Point findPosition() {
return position;
}
Code:
@Override
public Point getPosition() {
return position;
}
and add:
Code:
import java.awt.Point;
Code:
package net.sf.odinms.server.movement;
In net.sf.odinms.server.movement.ChangeEquipSpecialAwesome:
add:
Code:
import java.awt.Point;
Code:
import net.sf.odinms.tools.data.output.LittleEndianWriter;
add:
Code:
@Override
public Point findPosition() {
return new Point(0,0);
}
Code:
public ChangeEquipSpecialAwesome(int wui) {
this.wui = wui;
}
In net.sf.odinms.server.movement.LifeMovementFragment:
add:
Code:
import java.awt.Point;
Code:
import net.sf.odinms.tools.data.output.LittleEndianWriter;
add:
Code:
Point findPosition();
Code:
void serialize(LittleEndianWriter lew);
In net.sf.odinms.server.movement.LifeMovement:
Add:
Code:
Point findPosition();
Code:
int getType();
1812000:meso magnet
1812001: item pouch
This should do it. Correct me if I forgot something. Again:
ALL CREDITS GO TO GROAT@@@@@@@@@@@@
Last edited: