예제 #1
0
        /// <summary>
        /// Set Properties
        /// </summary>
        /// <param name="Packet"></param>
        internal void SetProps(CString Packet)
        {
            bool compileScript = false;

            while (Packet.BytesLeft > 0)
            {
                Int32 PropId = Packet.ReadGUByte1();

                switch ((Properties)PropId)
                {
                    case Properties.IMAGE: // 0
                        this.Image = Packet.ReadChars(Packet.ReadGUByte1());
                        break;

                    case Properties.SCRIPT: // 1
                        this.Script = Packet.ReadChars((int)Packet.ReadGUByte5()).Replace("\xa7", "\n");
                        if (this.Script.IndexOf("void") > 0 || this.Script.IndexOf("join(") > 0)
                            compileScript = true;
                        break;

                    case Properties.NPCX: // 2 - obsolete
                        Packet.ReadGByte1();
                        break;

                    case Properties.NPCY: // 3 - obsolete
                        Packet.ReadGByte1();
                        break;

                    case Properties.NPCPOWER: // 4
                        Packet.ReadGUByte1();
                        break;

                    case Properties.NPCRUPEES: // 5
                        this.Gralats = (int)Packet.ReadGUByte3();
                        break;

                    case Properties.ARROWS: // 6
                        this.Arrows = Packet.ReadGUByte1();
                        break;

                    case Properties.BOMBS: // 7
                        this.Bombs = Packet.ReadGUByte1();
                        break;

                    case Properties.GLOVEPOWER: // 8
                        Packet.ReadGUByte1();
                        break;

                    case Properties.BOMBPOWER: // 9
                        Packet.ReadGUByte1();
                        break;

                    case Properties.GANI: // 12
                        Packet.ReadChars(Packet.ReadGUByte1());
                        break;

                    case Properties.VISFLAGS: // 13
                        this.VisFlags = Packet.ReadGByte1();
                        break;

                    case Properties.BLOCKFLAGS: // 14
                        this.BlockFlags = Packet.ReadGByte1();
                        break;

                    case Properties.MESSAGE: // 15
                        this.Chat = Packet.ReadChars(Packet.ReadGUByte1());
                        break;

                    case Properties.NPCID: // 17
                        Packet.ReadGUByte3();
                        break;

                    case Properties.SPRITE: // 18
                        Packet.ReadGUByte1();
                        break;

                    case Properties.COLORS: // 19
                        Packet.ReadGUByte5();
                        break;

                    case Properties.NICKNAME: // 20
                        this.Nickname = Packet.ReadChars(Packet.ReadGUByte1());
                        break;

                    case Properties.HORSEIMG: // 21
                        Packet.ReadChars(Packet.ReadGUByte1());
                        break;

                    case Properties.HEADIMG: // 22
                    {
                        Int32 len = Packet.ReadGUByte1();
                        this.HeadImage = (len < 100 ? "head" + len + ".png" : Packet.ReadChars(len - 100));
                        break;
                    }

                    case Properties.SAVE0: // 23
                        this.Save[0] = Packet.ReadGUByte1();
                        break;

                    case Properties.SAVE1: // 24
                        this.Save[1] = Packet.ReadGUByte1();
                        break;

                    case Properties.SAVE2: // 25
                        this.Save[2] = Packet.ReadGUByte1();
                        break;

                    case Properties.SAVE3: // 26
                        this.Save[3] = Packet.ReadGUByte1();
                        break;

                    case Properties.SAVE4: // 27
                        this.Save[4] = Packet.ReadGUByte1();
                        break;

                    case Properties.SAVE5: // 28
                        this.Save[5] = Packet.ReadGUByte1();
                        break;

                    case Properties.SAVE6: // 29
                        this.Save[6] = Packet.ReadGUByte1();
                        break;

                    case Properties.SAVE7: // 30
                        this.Save[7] = Packet.ReadGUByte1();
                        break;

                    case Properties.SAVE8: // 31
                        this.Save[8] = Packet.ReadGUByte1();
                        break;

                    case Properties.SAVE9: // 32
                        this.Save[9] = Packet.ReadGUByte1();
                        break;

                    case Properties.ALIGNMENT: // 33
                        Packet.ReadGUByte1();
                        break;

                    case Properties.IMAGEPART: // 34
                        this.ImagePart = Packet.Read(6);
                        break;

                    case Properties.BODYIMG: // 35
                        this.BodyImage = Packet.ReadChars(Packet.ReadGUByte1());
                        break;

                    case Properties.GMAPLVLX: // 41
                        this.GMapX = Packet.ReadGUByte1();
                        break;

                    case Properties.GMAPLVLY: // 42
                        this.GMapY = Packet.ReadGUByte1();
                        break;

                    case Properties.PIXELX: // 75
                    {
                        int tmp = this.PixelX = Packet.ReadGUByte2();

                        // If the first bit is 1, our position is negative.
                        this.PixelX >>= 1;
                        if ((tmp & 0x0001) != 0)
                            this.PixelX = -this.PixelX;
                        break;
                    }

                    case Properties.PIXELY: // 76
                    {
                        int tmp = this.PixelY = Packet.ReadGUByte2();

                        // If the first bit is 1, our position is negative.
                        this.PixelY >>= 1;
                        if ((tmp & 0x0001) != 0)
                            this.PixelY = -this.PixelY;
                        break;
                    }

                    default:
                        System.Console.WriteLine("Unknown NPC Prop: " + PropId);
                        return;
                }
            }

            // Compile script if script changed.
            if (compileScript)
                Server.Compiler.CompileAdd(this);
        }