Esempio n. 1
0
        void MessageChat(OP code, PlayerConnection c)
        {
            uint t;
            uint lang;

            c.Seek(2).Get(out t).Get(out lang);

            CHAT mode = (CHAT)t;

            string text   = null;
            string target = null;

            if (mode == CHAT.CHANNEL || mode == CHAT.WHISPER)
            {
                c.Get(out target);
            }
            c.Get(out text);

            if (mode == CHAT.SAY || mode == CHAT.GUILD)
            {
                if (gmcmd.Parse(c.player, text))
                {
                    return;
                }
            }
            c.player.MessageChat(mode, lang, text, target);
        }
Esempio n. 2
0
        public bool CreateNew(PlayerConnection conn, string n)
        {
            Name = n;
            Console.WriteLine(n);
            conn.Get(out race).Get(out class_).Get(out gender).
            Get(out skin).Get(out face).Get(out hairStyle).Get(out hairColor).Get(out facialHair).Get(out outfitId);

            Console.WriteLine("CMSG_CHAR_CREATE {0}/{1} {2} {3} {4} {5} {6} {7} {8} {9} {10}",
                              conn.userName, n, race, class_, gender, skin, face, hairStyle, hairColor, facialHair, outfitId);

            for (int i = 0; i < tutorialFlags.Length; i++)
            {
                tutorialFlags[i] = 0xff;
            }

            Hashtable r = gameServer.DB.classes.Get("race " + race.ToString());

            if (r == null)
            {
                return(false);
            }
            else
            {
                mapID  = (ushort)(int)r["startmap"];
                zoneID = (ushort)(int)r["startzone"];

                float[] xyz = r["startpos"] as float[];
                Pos.x       = xyz[0];
                Pos.y       = xyz[1];
                Pos.z       = xyz[2];
                Orientation = xyz[3];

                /*Console.WriteLine("Startmap:" + r["startmap"] );
                 * Console.WriteLine("startzone:" + r["startzone"]);
                 * Console.WriteLine("startpos: {0}, {1}, {2}, {3} ", xyz[0], xyz[1], xyz[2], xyz[3]);*/


                int[] sstat = r["startstats"] as int[];
                for (int i = 0; i < stat.Length; i++)
                {
                    stat[i] = (byte)sstat[i];
                }

                if (gender > 0)
                {
                    displayID = (uint)(int)r["bodyfemale"];
                }
                else
                {
                    displayID = (uint)(int)r["bodymale"];
                }

                int[] skills = r["skill"] as int[];
                for (int i = 0; i < skills.Length - 2; i += 3)
                {
                    AddSkill(skills[i], skills[i + 1], skills[i + 2]);
                }

                int[] spells = r["spell"] as int[];
                foreach (int sp in spells)
                {
                    AddSpell((uint)sp);
                }
            }

            r = gameServer.DB.classes.Get("class " + class_.ToString());
            if (r != null)
            {
                int[] sstat = r["startstats"] as int[];
                for (int i = 0; i < stat.Length; i++)
                {
                    stat[i] += (byte)sstat[i];
                }

                health = mhealth = (uint)(int)r["health"];

                int[] maxpowers = r["maxpowers"] as int[];
                for (int i = 0; i < mpower.Length; i++)
                {
                    power[i] = mpower[i] = (uint)maxpowers[i];
                    if (power[i] > 0)
                    {
                        powerType = (PowerType)i;
                    }
                }

                int[] attackTime = r["attacktime"] as int[];
                attackTime0 = (uint)attackTime[0];
                attackTime1 = (uint)attackTime[1];

                // ...

                int[] skills = r["skill"] as int[];
                for (int i = 0; i < skills.Length - 2; i += 3)
                {
                    AddSkill(skills[i], skills[i + 1], skills[i + 2]);
                }

                int[] spells = r["spell"] as int[];
                foreach (int sp in spells)
                {
                    AddSpell((uint)sp);
                }
            }
            else
            {
                return(false);
            }
            r = gameServer.DB.classes.Get(String.Format("startitems {0} {1}", race, class_));
            if (r == null)
            {
                return(false);
            }

            ByteArrayBuilder items = new ByteArrayBuilder();

            int[] its = r["item"] as int[];
            for (int i = 0; i < its.Length - 1; i += 2)
            {
                items.Add((byte)its[i]);                 // slot
                items.Add((uint)its[i + 1]);             // entry
                items.Add((ushort)0);                    // addition data
            }
            items.pos = 0;
            return(Create((ByteArrayBase)items));
        }