예제 #1
0
 public bool isIgnoredInbound(InboundOpcodes opcode)
 {
     switch (opcode)
     {
     case ALIVE_REQ:
     case InboundOpcodes.SECURITY_PACKET:
     case TEMPORARY_STAT_RESET:
     case TEMPORARY_STAT_SET:
     case InboundOpcodes.NPC_MOVE:
     case InboundOpcodes.MOB_MOVE:
     case InboundOpcodes.MOB_CONTROL_ACK:
     case InboundOpcodes.DROP_ENTER_FIELD:
     case InboundOpcodes.DROP_LEAVE_FIELD:
     case MOB_ENTER_FIELD:
     case MOB_LEAVE_FIELD:
     case MOB_CHANGE_CONTROLLER:
     case MOB_STAT_SET:
     case MOB_STAT_RESET:
     case MOB_HP_INDICATOR:
     case AVATAR_MEGAPHONE_RES:
     case SET_AVATAR_MEGAPHONE:
     case UNIVERSE_BOSS_IMPOSSIBLE:
     case InboundOpcodes.PRIVATE_SERVER_PACKET:
     case MONSTER_COLLECTION_RESULT:
     case CHARACTER_HONOR_EXP:
     case SKILL_COOLTIME_SET_M:
     case USER_ENTER_FIELD:
     case InboundOpcodes.PARTY_RESULT:
     case SET_QUICK_MOVE_INFO:
     case COMPLETE_SPECIAL_CHECK_SUCCESS:
     case ANTI_MACRO_RESULT:
     case CLEAR_AVATAR_MEGAPHONE:
         return(true);
     }
     if (Util.isNumber(opcode.ToString()))
     {
         return(true);
     }
     return(false);
 }
예제 #2
0
 public static void parseInbound(InboundOpcodes opcode, Packet packet, long timestamp)
 {
     if (packet == null || activeScript == null)
     {
         return;
     }
     if (opcode == InboundOpcodes.SET_FIELD)
     {
         int mapID = Handler.parseSetField(activeScript, packet);
         if (Util.hasMapScript(mapID))
         {
             LifeStorage.clear();
             dispose();
             activeScript.setMapID(mapID);
         }
         return;
     }
     if (Program.DEBUG_PACKETS)
     {
         Console.WriteLine("Reading Inbound Packet " + opcode);
     }
     activeScript.handleInboundPackets(opcode, packet, timestamp);
 }
예제 #3
0
        // Send Opcodes
        public void handleInboundPackets(InboundOpcodes opcode, Packet packet, long timestamp)
        {
            // Format: addLine(String.Format("sm.method({0}, {1})",  0, 1));
            if (waitForScriptAnswer && opcode != InboundOpcodes.EFFECT)
            {
                return;
            }
            int    x, y, size, objectID, templateID;
            Npc    npc = null;
            UIType uiType;

            switch (opcode)
            {
            case PROGRESS_MESSAGE_FONT:
                addLine(String.Format("sm.progressMessageFont({0}, {1}, {2}, {3}, {4})", packet.ReadInt(), packet.ReadInt(), packet.ReadInt(), packet.ReadInt(), Util.quotes(packet.ReadString())));
                break;

            case RANDOM_TELEPORT_KEY:
                addLine(String.Format("sm.sendRandomTeleportKey({0})", packet.ReadByte()));
                break;

            case ADD_POPUP_SAY:
                addLine(String.Format("sm.addPopUpSay({0}, {1}, {2}, {3})", packet.ReadInt(), packet.ReadInt(), Util.quotes(packet.ReadString()), Util.quotes(packet.ReadString())));
                break;

            case USER_SET_FIELD_FLOATING:
                addLine(String.Format("sm.setFieldFloating({0}, {1}, {2}, {3})", packet.ReadInt(), packet.ReadInt(), packet.ReadInt(), packet.ReadInt()));
                break;

            case SET_MAP_TAGGED_OBJECT_VISISBLE:
                size = packet.ReadByte();
                for (int i = 0; i < size; i++)
                {
                    addLine(String.Format("sm.setMapTaggedObjectVisible({0}, {1}, {2}, {3})", Util.quotes(packet.ReadString()), packet.ReadBoolPy(), packet.ReadInt(), packet.ReadInt()));
                }
                break;

            case NPC_SET_FORCE_FLIP:
                npc = LifeStorage.getNpcByObjectID(packet.ReadInt());
                if (npc != null)
                {
                    String left = PythonBool(packet.ReadInt() == -1);
                    addLine(String.Format("sm.flipNpcByObjectId({0}, {1})", npc.ObjectName, left));
                }
                break;

            case TELEPORT:
                packet.ReadByte();
                packet.ReadByte();
                packet.ReadInt();    // char id
                addLine(String.Format("sm.teleportInField({0}, {1})", packet.ReadShort(), packet.ReadShort()));
                break;

            case SET_MAP_TAGGED_OBJECT_ANIMATION:
                size = packet.ReadInt();
                for (int i = 0; i < size; i++)
                {
                    addLine(String.Format("sm.setMapTaggedObjectAnimation({0}, {1})", Util.quotes(packet.ReadString()), packet.ReadInt()));
                }
                break;

            case EMOTION:
                addLine(String.Format("sm.localEmotion({0}, {1}, {2})", packet.ReadInt(), packet.ReadInt(), PythonBool(packet.ReadBool())));
                break;

            case FUNCKEY_SET_BY_SCRIPT:
                bool add    = packet.ReadBool();
                int  action = packet.ReadInt();
                x = 0;
                if (add)
                {
                    x = packet.ReadInt();
                }
                addLine(String.Format("sm.setFuncKeyByScript({0}, {1}, {2})", PythonBool(add), action, x));
                break;

            case SESSION_VALUE:
                String key = packet.ReadString();
                npc = LifeStorage.getNpcByObjectID(Int32.Parse(packet.ReadString()));
                if (npc != null)
                {
                    addLine(String.Format("sm.sendSessionValue({0}, {1})", Util.quotes(key), npc.TemplateID.ToString()));
                }
                break;

            case OPEN_UI_WITH_OPTION:
                uiType = Util.GetEnumObjectByValue <UIType>(packet.ReadInt());
                if (Util.isNumber(uiType.ToString()))
                {
                    addLine(String.Format("sm.openUIWithOption({0}, {1})", uiType, packet.ReadInt()));
                }
                else
                {
                    addLine(String.Format("sm.openUIWithOption(UIType.{0}, {1})", uiType, packet.ReadInt()));
                }
                hasUIScript = true;
                break;

            case OPEN_UI:
                uiType = Util.GetEnumObjectByValue <UIType>(packet.ReadInt());
                if (Util.isNumber(uiType.ToString()))
                {
                    addLine(String.Format("sm.openUI({0})", uiType));
                }
                else
                {
                    addLine(String.Format("sm.openUI(UIType.{0})", uiType));
                }
                hasUIScript = true;
                break;

            case CLOSE_UI:
                uiType = Util.GetEnumObjectByValue <UIType>(packet.ReadInt());
                if (Util.isNumber(uiType.ToString()))
                {
                    addLine(String.Format("sm.closeUI({0})", uiType));
                }
                else
                {
                    addLine(String.Format("sm.closeUI(UIType.{0})", uiType));
                }
                hasUIScript = true;
                break;

            case SCRIPT_PROGRESS_MESSAGE:
                addLine(String.Format("sm.chatScript({0})", Util.quotes(packet.ReadString())));
                break;

            case NPC_SET_FORCE_MOVE:
                npc = LifeStorage.getNpcByObjectID(packet.ReadInt());
                if (npc != null)
                {
                    String left     = PythonBool(packet.ReadInt() == -1);
                    int    distance = packet.ReadInt();
                    int    speed    = packet.ReadInt();
                    addLine(String.Format("sm.moveNpcByObjectId({0}, {1}, {2}, {3})", npc.ObjectName, left, distance, speed));
                }
                break;

            case MAP_SCRIPT_FLAG:
                if (!flagged)
                {
                    read    = true;
                    flagged = true;
                }
                break;

            case CHANGE_SKILL_RECORD_RESULT:
                packet.ReadByte();    // exclRequestSent
                packet.ReadByte();    // showResult
                packet.ReadByte();    // rmeove link skill
                int skillSize = packet.ReadShort();
                for (int i = 0; i < skillSize; i++)
                {
                    int skillID    = packet.ReadInt();
                    int currentSLV = packet.ReadInt();
                    int masterSLV  = packet.ReadInt();
                    if (currentSLV <= 0 || masterSLV <= 0)
                    {
                        addLine(String.Format("sm.removeSkill({0})", skillID));
                    }
                    else
                    {
                        addLine(String.Format("sm.giveSkill({0}, {1}, {2})", skillID, currentSLV, masterSLV));
                    }
                }
                break;

            case EFFECT:
                Handler.handleUserEffect(packet);
                break;

            case INVENTORY_OPERATION:
                Handler.handleInventoryOperation(packet);
                break;

            case SCRIPT_MESSAGE:
                Handler.handleScriptMessage(packet);
                break;

            case VIDEO_BY_SCRIPT_2:
                addLine(String.Format("sm.playURLVideoByScript(\"{0}\")", packet.ReadString()));
                setWaitForAnswer(true);
                break;

            case FIELD_EFFECT:
                Handler.handleFieldEffect(packet);
                break;

            case IN_GAME_DIRECTION_EVENT:
                Handler.handleIngameDirectionEvent(packet);
                break;

            case InboundOpcodes.BROADCAST_MSG:
                byte broadcastType = packet.ReadByte();
                if (broadcastType == 4)
                {
                    byte unk = packet.ReadByte();
                    if (unk == 0)
                    {
                        initedLifeObjects = true;
                    }
                }
                break;

            case NPC_ENTER_FIELD:
                objectID = packet.ReadInt();
                if (LifeStorage.getNpcByObjectID(objectID) != null)
                {
                    return;
                }
                templateID     = packet.ReadInt();
                x              = packet.ReadShort();
                y              = packet.ReadShort();
                npc            = new Npc(objectID, templateID);
                npc.X          = x;
                npc.Y          = y;
                npc.ObjectName = String.Format("OBJECT_{0}", objectCounter++);
                LifeStorage.addNpc(objectID, npc);
                if (initedLifeObjects)
                {
                    addLine(String.Format("{3} = sm.sendNpcEnterField({0}, {1}, {2})", templateID, x, y, npc.ObjectName));
                }
                break;

            case NPC_LEAVE_FIELD:
                npc = LifeStorage.getNpcByObjectID(packet.ReadInt());
                if (npc == null)
                {
                    return;
                }
                LifeStorage.removeNpc(npc.ObjectID);
                if (initedLifeObjects)
                {
                    addLine(String.Format("sm.sendNpcLeaveField({0})", npc.ObjectName));
                }
                break;

            case NPC_CHANGE_CONTROLLER:
                bool controller = packet.ReadBool();
                objectID = packet.ReadInt();
                npc      = LifeStorage.getNpcByObjectID(objectID);
                if (npc == null)
                {
                    if (!controller)
                    {
                        return;
                    }
                    templateID     = packet.ReadInt();
                    x              = packet.ReadShort();
                    y              = packet.ReadShort();
                    npc            = new Npc(objectID, templateID);
                    npc.X          = x;
                    npc.Y          = y;
                    npc.ObjectName = String.Format("OBJECT_{0}", objectCounter++);
                    LifeStorage.addNpc(objectID, npc);
                    if (initedLifeObjects)
                    {
                        addLine(String.Format("{3} = sm.sendNpcController({0}, {1}, {2})", templateID, x, y, npc.ObjectName));
                    }
                }
                else
                {
                    if (initedLifeObjects)
                    {
                        addLine(String.Format("sm.sendNpcController({0}, {1})", npc.ObjectName, PythonBool(controller)));
                    }
                    if (!controller)
                    {
                        LifeStorage.removeNpc(objectID);
                    }
                }
                break;

            case NPC_SET_SPECIAL_ACTION:
                npc = LifeStorage.getNpcByObjectID(packet.ReadInt());
                if (npc != null)
                {
                    String npcEffect = packet.ReadString();
                    int    duration  = packet.ReadInt();
                    addLine(String.Format("sm.showNpcSpecialActionByObjectId({0}, \"{1}\", {2})", npc.ObjectName, npcEffect, duration));
                }
                break;

            case CUR_NODE_EVENT_END:
                addLine(String.Format("sm.curNodeEventEnd({0})", packet.ReadBoolPy()));
                break;

            case SET_TEMPORARY_SKILL_SET:
                addLine(String.Format("sm.setTemporarySkillSet({0})", packet.ReadInt()));
                break;

            case SET_IN_GAME_DIRECTION_MODE:
                bool lockUI = false, blackFrame = false, forceMouseOver = false, showUI = false;
                lockUI     = packet.ReadBool();
                uiLocked   = lockUI;
                blackFrame = packet.ReadBool();
                if (lockUI)
                {
                    forceMouseOver = packet.ReadBool();
                    showUI         = packet.ReadBool();
                }
                addLine(String.Format("sm.setInGameDirectionMode({0}, {1}, {2}, {3})", PythonBool(lockUI), PythonBool(blackFrame), PythonBool(forceMouseOver), PythonBool(showUI)));
                if (!lockUI)
                {
                    //addComment("Set field decoding not working yet so check if ur character warped to somewhere else");
                    //Parser.dispose();
                }
                break;

            case SET_STAND_ALONE_MODE:
                addLine(String.Format("sm.setStandAloneMode({0})", packet.ReadBoolPy()));
                break;

            case MESSAGE:
                Handler.handleMessage(packet);
                break;

            case MOB_CRC_KEY_CHANGED:
                if (type == ScriptType.MapScript)
                {
                    if (!waitForScriptAnswer && flagged)
                    {
                        //Parser.dispose();
                    }
                }
                break;

            case STAT_CHANGED:
                Handler.handleStatChanged(packet);
                break;

            default:
                if (!isIgnoredInbound(opcode) && read)
                {
                    addLine(String.Format("# [{0}] [{1}]", opcode.ToString(), packet.ToString()));
                }
                break;
            }
        }