Beispiel #1
0
        public static void handleFieldEffect(Packet packet)
        {
            FieldEffectType type = Util.GetEnumObjectByValue <FieldEffectType>(packet.ReadByte());
            String          str;
            int             x, y;

            switch (type)
            {
            case ObjectStateByString:
                Parser.getActiveScript().addLine(String.Format("sm.objectStateByString({0})", Util.quotes(packet.ReadString())));
                break;

            case Tremble:
                Parser.getActiveScript().addLine(String.Format("sm.tremble({0}, {1}, {2})", packet.ReadByte(), packet.ReadInt(), packet.ReadShort()));
                break;

            case PlaySound:
                str = packet.ReadString();
                x   = packet.ReadInt();
                Parser.getActiveScript().addLine(String.Format("sm.playSound({0}, {1})", Util.quotes(str), x));
                break;

            case ChangeBGM:
                str = packet.ReadString();
                x   = packet.ReadInt();
                y   = packet.ReadInt();
                Parser.getActiveScript().addLine(String.Format("sm.changeBGM({0}, {1}, {2})", Util.quotes(str), x, y));
                break;

            case SetBGMVolume:
                Parser.getActiveScript().addLine(String.Format("sm.setBGMVolume({0}, {1})", packet.ReadInt(), packet.ReadInt()));
                break;

            case BackScreen:
                str = packet.ReadString();
                x   = packet.ReadInt();
                Parser.getActiveScript().addLine(String.Format("sm.showFieldBackgroundEffect({0}, {1})", Util.quotes(str), x));
                break;

            case ScreenEffect:
                str = packet.ReadString();
                x   = packet.ReadInt();
                Parser.getActiveScript().addLine(String.Format("sm.showFieldEffect({0}, {1})", Util.quotes(str), x));
                break;

            case Blind:
                int enable = packet.ReadByte();
                x = packet.ReadShort();
                int color = packet.ReadShort();
                int unk1  = packet.ReadShort();
                int unk2  = packet.ReadShort();
                int time  = packet.ReadInt();
                int unk3  = packet.ReadInt();
                Parser.getActiveScript().addLine(String.Format("sm.blind({0}, {1}, {2}, {3}, {4}, {5}, {6})", enable, x, color, unk1, unk2, time, unk3));
                break;

            case OnOffLayer:
                byte   layerType = packet.ReadByte();
                int    term      = packet.ReadInt();
                String key       = packet.ReadString();
                if (layerType == 0)
                {
                    x = packet.ReadInt();
                    y = packet.ReadInt();
                    int    z      = packet.ReadInt();
                    String effect = packet.ReadString();
                    int    origin = packet.ReadInt();
                    int    unk4   = packet.ReadByte();
                    int    unk5   = packet.ReadInt();
                    int    unk6   = packet.ReadByte();
                    Parser.getActiveScript().addLine(String.Format("sm.OnOffLayer_On({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9})", term, Util.quotes(key), x, y, z, Util.quotes(effect), origin, unk4, unk5, unk6));
                }
                else if (layerType == 1)
                {
                    x = packet.ReadInt();
                    y = packet.ReadInt();
                    Parser.getActiveScript().addLine(String.Format("sm.OnOffLayer_Move({0}, {1}, {2}, {3})", term, Util.quotes(key), x, y));
                }
                else if (layerType == 2)
                {
                    x = packet.ReadByte();
                    Parser.getActiveScript().addLine(String.Format("sm.OnOffLayer_Off({0}, {1}, {2})", term, Util.quotes(key), x));
                }
                break;

            case OverlapScreen:
                x = packet.ReadInt();
                Parser.getActiveScript().addLine(String.Format("sm.showFade({0})", x));
                break;

            case OverlapScreenDetail:
                int duration    = packet.ReadInt();
                int fadeInTime  = packet.ReadInt();
                int fadeOutTime = packet.ReadInt();
                Parser.getActiveScript().addLine(String.Format("sm.showFadeTransition({0}, {1}, {2})", duration, fadeInTime, fadeOutTime));
                break;

            case RemoveOverlapScreen:
                x = packet.ReadInt();
                Parser.getActiveScript().addLine(String.Format("sm.removeOverlapScreen({0})", x));
                break;

            case StageClearExpOnly:
                x = packet.ReadInt();
                Parser.getActiveScript().addLine(String.Format("sm.showClearStageExpWindow({0})", x));
                break;

            case SpineScreen:
                Parser.getActiveScript().addLine(String.Format("sm.spineScreen({0}, {1}, {2}, {3}, {4}, {5}, {6})", packet.ReadBoolPy(), packet.ReadBoolPy(), packet.ReadBoolPy(), packet.ReadInt(), Util.quotes(packet.ReadString()), Util.quotes(packet.ReadString()), packet.ReadBool() ? Util.quotes(packet.ReadString()) : "None"));
                break;

            case OffSpineScreen:
                String layer     = packet.ReadString();
                int    spineType = packet.ReadInt();
                if (spineType == 1)
                {
                    Parser.getActiveScript().addLine(String.Format("sm.offSpineScreenAlpha({0}, {1})", Util.quotes(layer), packet.ReadInt()));
                }
                else if (spineType == 2)
                {
                    Parser.getActiveScript().addLine(String.Format("sm.offSpineScreenAni({0}, {1})", Util.quotes(layer), Util.quotes(packet.ReadString())));
                }
                else
                {
                    Parser.getActiveScript().addLine(String.Format("sm.offSpineScreenImmediate({0})", Util.quotes(layer)));
                }
                break;

            default:
                Parser.getActiveScript().addComment(String.Format("Unhandled Field Effect [{0}] Packet: {1}", type, packet.ToString()));
                break;
            }
        }
Beispiel #2
0
        public static int parseSetField(Script script, Packet packet)
        {
            int mapID, portal;

            packet.ReadBytes(23);
            bool  bCharacterData = packet.ReadBool();
            short notifierCheck  = packet.ReadShort();

            if (notifierCheck > 0)
            {
                packet.ReadString();
                for (int i = 0; i < notifierCheck; i++)
                {
                    packet.ReadString();
                }
            }
            if (bCharacterData)
            {
                packet.ReadBytes(12);            // damage calc
                long dbFlag = packet.ReadLong(); // dbFlag
                packet.ReadByte();               //combat orders
                packet.ReadBytes(13);            // pet active skill cooltime

                int count = packet.ReadByte();
                for (int i = 0; i < count; i++)
                {
                    packet.ReadInt();
                }
                count = packet.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    packet.ReadInt();
                    packet.ReadLong();
                }
                bool read = packet.ReadBool();
                if (read)
                {
                    packet.ReadByte();
                    count = packet.ReadInt();
                    for (int i = 0; i < count; i++)
                    {
                        packet.ReadLong();
                    }
                }
                packet.ReadBytes(42);
                int jobID = packet.ReadShort();
                packet.ReadBytes(26);
                if (Util.isExtendSPJob(jobID))
                {
                    int size = packet.ReadByte();
                    packet.ReadBytes(size * 5);
                }
                else
                {
                    packet.ReadShort();
                }
                packet.ReadBytes(20);
                mapID  = packet.ReadInt();
                portal = packet.ReadByte();
            }
            else
            {
                packet.ReadByte();
                mapID  = packet.ReadInt();
                portal = packet.ReadByte();
            }
            if (Parser.MAP_ID != 0 && Parser.getActiveScript().GetScriptType() != ScriptType.None)
            {
                Parser.getActiveScript().addLine(String.Format("sm.warp({0}, {1})", mapID, portal));
            }
            return(mapID);
        }
Beispiel #3
0
        public static void handleScriptMessage(Packet packet)
        {
            int speakerType = packet.ReadByte();
            int speakerID   = packet.ReadInt();

            if (packet.ReadBool())
            {
                int overrideNpc = packet.ReadInt();
                if (overrideNpc != 0)
                {
                    speakerID = overrideNpc;
                }
            }
            ScriptMessageType type = Util.GetEnumObjectByValue <ScriptMessageType>(packet.ReadByte());
            int param = packet.ReadShort();
            int color = packet.ReadByte();

            switch (type)
            {
            case Say:
            case AskMenu:
            case AskAccept:
            case AskYesNo:
            case AskText:
            case AskBoxText:
            case SayIllustration:
                if (hasParam(param, ParamType.OverrideSpeakerID))
                {
                    int overrideNpc = packet.ReadInt();
                    if (overrideNpc != 0)
                    {
                        speakerID = overrideNpc;
                    }
                }
                break;
            }
            switch (param)
            {
            case 0x24:
                Parser.getActiveScript().addLine(String.Format("sm.setNpcOverrideBoxChat({0})", speakerID));
                break;

            case 0x25:
                Parser.getActiveScript().addLine(String.Format("sm.setIntroBoxChat({0})", speakerID));
                break;

            default:
                Parser.getActiveScript().addLine(String.Format("sm.setSpeakerID({0})", speakerID));
                handleScriptMessageParam(param);
                if (color != 0)
                {
                    Parser.getActiveScript().addLine(String.Format("sm.setColor({0})", color));
                }
                break;
            }
            if (speakerType != 4)
            {
                Parser.getActiveScript().addLine(String.Format("sm.setSpeakerType({0})", speakerType));
            }
            String text;
            bool   isPrev, isNext;

            switch (type)
            {
            case Say:
                text   = packet.ReadString();
                isPrev = packet.ReadBool();
                isNext = packet.ReadBool();
                if (text.Contains(Environment.NewLine))
                {
                    text.Replace(Environment.NewLine, "\r\n");
                }
                if (isPrev && isNext)
                {
                    Parser.getActiveScript().addLine(String.Format("sm.sendSay({0})", Util.quotes(text)));
                }
                else if (isPrev && !isNext)
                {
                    Parser.getActiveScript().addLine(String.Format("sm.sendPrev({0})", Util.quotes(text)));
                }
                else if (!isPrev && isNext)
                {
                    Parser.getActiveScript().addLine(String.Format("sm.sendNext({0})", Util.quotes(text)));
                }
                else
                {
                    Parser.getActiveScript().addLine(String.Format("sm.sendSayOkay({0})", Util.quotes(text)));
                }
                break;

            case AskYesNo:
                text = packet.ReadString();
                if (text.Contains(Environment.NewLine))
                {
                    text.Replace(Environment.NewLine, "\r\n");
                }
                Parser.getActiveScript().addLine(String.Format("if sm.sendAskYesNo({0}):", Util.quotes(text)));
                break;

            case AskAccept:
                text = packet.ReadString();
                if (text.Contains(Environment.NewLine))
                {
                    text.Replace(Environment.NewLine, "\r\n");
                }
                Parser.getActiveScript().addLine(String.Format("if sm.sendAskAccept({0}):", Util.quotes(text)));
                break;

            case AskMenu:
                text = packet.ReadString();
                if (text.Contains(Environment.NewLine))
                {
                    text.Replace(Environment.NewLine, "\r\n");
                }
                Parser.getActiveScript().addLine(String.Format("selection = sm.sendNext({0})", Util.quotes(text)));
                break;

            case SayIllustration:
                text   = packet.ReadString();
                isPrev = packet.ReadBool();
                isNext = packet.ReadBool();
                int    faceIndex = packet.ReadInt();
                String isLeft    = packet.ReadBoolPy();
                if (isPrev && isNext)
                {
                    Parser.getActiveScript().addLine(String.Format("sm.sendSayIllustration({0}, {1}, {2})", Util.quotes(text), faceIndex, isLeft));
                }
                else if (isPrev && !isNext)
                {
                    Parser.getActiveScript().addLine(String.Format("sm.sendSayPrevIllustration({0}, {1}, {2})", Util.quotes(text), faceIndex, isLeft));
                }
                else if (!isPrev && isNext)
                {
                    Parser.getActiveScript().addLine(String.Format("sm.sendSayNextIllustration({0}, {1}, {2})", Util.quotes(text), faceIndex, isLeft));
                }
                else
                {
                    Parser.getActiveScript().addLine(String.Format("sm.sendSayOkayIllustration({0}, {1}, {2})", Util.quotes(text), faceIndex, isLeft));
                }
                break;

            default:
                Parser.getActiveScript().addComment(String.Format("Unhandled Script Message [{0}] Packet: {1}", type, packet.ToString()));
                break;
            }
            Parser.getActiveScript().setWaitForAnswer(true);
        }