QuestActionHandler.java
Upload User: gwt600
Upload Date: 2021-06-03
Package Size: 704k
Code Size: 4k
Category:

Games

Development Platform:

Java

  1. /*
  2. This file is part of the OdinMS Maple Story Server
  3. Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc> 
  4. Matthias Butz <matze@odinms.de>
  5. Jan Christian Meyer <vimes@odinms.de>
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU Affero General Public License version 3
  8. as published by the Free Software Foundation. You may not use, modify
  9. or distribute this program under any other version of the
  10. GNU Affero General Public License.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU Affero General Public License for more details.
  15. You should have received a copy of the GNU Affero General Public License
  16. along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18. /*
  19.  * QuestActionHandler.java
  20.  *
  21.  * Created on 9. Dezember 2007, 21:52
  22.  *
  23.  * To change this template, choose Tools | Template Manager
  24.  * and open the template in the editor.
  25.  */
  26. package net.sf.odinms.net.channel.handler;
  27. import net.sf.odinms.client.MapleCharacter;
  28. import net.sf.odinms.client.MapleClient;
  29. import net.sf.odinms.net.AbstractMaplePacketHandler;
  30. import net.sf.odinms.scripting.quest.QuestScriptManager;
  31. import net.sf.odinms.server.quest.MapleQuest;
  32. import net.sf.odinms.tools.MaplePacketCreator;
  33. import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
  34. /**
  35.  *
  36.  * @author Matze
  37.  */
  38. public class QuestActionHandler extends AbstractMaplePacketHandler {
  39.     /** Creates a new instance of QuestActionHandler */
  40.     public QuestActionHandler() {
  41.     }
  42.     //the wz files has startscript and endscript but its not like we care about it anyways
  43.     //for now we just use questid.js with functions start and end in them
  44.     //instead of creating two separate scripts
  45.     //and questaction extends npcconversation, since you cant have both at once
  46.     //and questaction is basically an npc and thus can use the same functions
  47.     //this class only starts the script itself, whereas npcmoretalkhandler extends it
  48.     //but more on that later
  49.     public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
  50.         c.getPlayer().resetAfkTime();
  51.         // [62 00] [01] [69 08] [86 71 0F 00] 7D 09 3E 02
  52.         //System.out.println("nPacket:n" + slea.toString() + "n");
  53.         byte action = slea.readByte();
  54.         short quest = slea.readShort();
  55.         MapleCharacter player = c.getPlayer();
  56.         //System.out.println("quest action: " + action);
  57.         if (action == 1) { // start quest
  58.             int npc = slea.readInt();
  59.             slea.readInt(); // dont know *o*
  60.             MapleQuest.getInstance(quest).start(player, npc);
  61.         } else if (action == 2) { // complete quest
  62.             int npc = slea.readInt();
  63.             slea.readInt(); // dont know *o*
  64.             if (slea.available() >= 4) {
  65.                 int selection = slea.readInt();
  66.                 MapleQuest.getInstance(quest).complete(player, npc, selection);
  67.             } else {
  68.                 MapleQuest.getInstance(quest).complete(player, npc);
  69.             }
  70.             c.getSession().write(MaplePacketCreator.showOwnBuffEffect(0, 9)); // Quest completion
  71.             player.getMap().broadcastMessage(player, MaplePacketCreator.showBuffeffect(player.getId(), 0, 9, (byte) 0), false);
  72.         // c.getSession().write(MaplePacketCreator.completeQuest(c.getPlayer(), quest));
  73.         //c.getSession().write(MaplePacketCreator.updateQuestInfo(c.getPlayer(), quest, npc, (byte)14));
  74.         // 6 = start quest
  75.         // 7 = unknown error
  76.         // 8 = equip is full
  77.         // 9 = not enough mesos
  78.         // 11 = due to the equipment currently being worn wtf o.o
  79.         // 12 = you may not posess more than one of this item
  80.         } else if (action == 3) { // forfeit quest
  81.             MapleQuest.getInstance(quest).forfeit(player);
  82.         } else if (action == 4) { // scripted start quest
  83.             int npc = slea.readInt();
  84.             slea.readInt(); // dont know *o*
  85.             QuestScriptManager.getInstance().start(c, npc, quest);
  86.         } else if (action == 5) { // scripted end quests
  87.             int npc = slea.readInt();
  88.             slea.readInt(); // dont know *o*
  89.             QuestScriptManager.getInstance().end(c, npc, quest);
  90.         }
  91.     }
  92. }