- UID
- 5321
- 閱讀權限
- 10
- 主題
- 64
- 帖子
- 114
- 精華
- 1
- A幣
- 15
- 在線時間
- 92 小時
- 最後登錄
- 2017-2-3
集團新軍
- 主題
- 64
- 帖子
- 114
- 精華
- 1
- 綜合社群主題發文量
- 0
- 電玩社群主題發文量
- 0
- 娛樂社群主題發文量
- 0
- 技術社群主題發文量
- 0
- 閱讀權限
- 10
- 註冊時間
- 2016-11-17
TA的每日心情 | 衰 2017-2-1 17:20 |
---|
簽到天數: 63 天 連續簽到: 0 天 [LV.6]常住居民II
|
以下為 OD端中 UseItemHandler class
主要是 使用物品時的相關控制
目前還在研究中^^
- net.sf.odinms.net.channel.handler
- import net.sf.odinms.client.IItem;
- import net.sf.odinms.client.MapleCharacter;
- import net.sf.odinms.client.MapleClient;
- import net.sf.odinms.client.MapleInventory;
- import net.sf.odinms.client.MapleInventoryType;
- import net.sf.odinms.net.AbstractMaplePacketHandler;
- import net.sf.odinms.scripting.npc.NPCScriptManager;
- import net.sf.odinms.server.MapleInventoryManipulator;
- import net.sf.odinms.server.MapleItemInformationProvider;
- import net.sf.odinms.server.MapleStatEffect;
- import net.sf.odinms.tools.MaplePacketCreator;
- import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
- import org.apache.mina.common.IoSession;
- public class UseItemHandler
- extends AbstractMaplePacketHandler
- {
- public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c)
- {
- c.getPlayer().resetAfkTime();
- if (!c.getPlayer().isAlive())
- {
- c.getSession().write(MaplePacketCreator.enableActions());
- return;
- }
- MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
- slea.readInt();
- byte slot = (byte)slea.readShort();
- int itemId = slea.readInt();
- IItem toUse = c.getPlayer().getInventory(MapleInventoryType.USE).getItem(slot);
- if (itemId == 2022118)
- {
- c.getPlayer().dropMessage(1, "請保留該物品. 他將會讓妳衝捲100%過.");
- c.getSession().write(MaplePacketCreator.enableActions());
- return;
- }
- if (itemId == 2022065)
- {
- NPCScriptManager.getInstance().start(c, 9010000, "JobChanger", null);
- }
- else if ((toUse != null) && (toUse.getQuantity() > 0))
- {
- if (toUse.getItemId() != itemId) {
- return;
- }
- if (ii.isTownScroll(itemId))
- {
- if (ii.getItemEffect(toUse.getItemId()).applyTo(c.getPlayer())) {
- MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, slot, (short)1, false);
- }
- c.getSession().write(MaplePacketCreator.enableActions());
- return;
- }
- MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, slot, (short)1, false);
- ii.getItemEffect(toUse.getItemId()).applyTo(c.getPlayer());
- }
- }
- }
複製代碼
|
|