示例#1
0
        // New one with id AND playfield as filter
        public new void readTexturesfromSQL()
        {
            SqlWrapper ms = new SqlWrapper();
            AOTextures m_tex;

            Textures.Clear();

            DataTable dt = ms.ReadDT("SELECT textures0, textures1, textures2, textures3, textures4 from " + getSQLTablefromDynelType() + " WHERE ID=" + ID.ToString() + " AND playfield=" + PlayField.ToString());

            if (dt.Rows.Count > 0)
            {
                m_tex = new AOTextures(0, (Int32)dt.Rows[0]["textures0"]);
                Textures.Add(m_tex);

                m_tex = new AOTextures(1, (Int32)dt.Rows[0]["textures1"]);
                Textures.Add(m_tex);

                m_tex = new AOTextures(2, (Int32)dt.Rows[0]["textures2"]);
                Textures.Add(m_tex);

                m_tex = new AOTextures(3, (Int32)dt.Rows[0]["textures3"]);
                Textures.Add(m_tex);

                m_tex = new AOTextures(4, (Int32)dt.Rows[0]["textures4"]);
                Textures.Add(m_tex);
            }
        }
示例#2
0
        // New one with id AND playfield as filter
        /// <summary>
        /// Read NPC textures from database
        /// </summary>
        public void ReadTexturesfromSql()
        {
            SqlWrapper ms = new SqlWrapper();
            AOTextures m_tex;

            this.Textures.Clear();

            DataTable dt =
                ms.ReadDatatable(
                    "SELECT textures0, textures1, textures2, textures3, textures4 from "
                    + this.GetSqlTablefromDynelType() + " WHERE ID=" + this.Id.ToString() + " AND playfield="
                    + this.PlayField.ToString());

            if (dt.Rows.Count > 0)
            {
                m_tex = new AOTextures(0, (Int32)dt.Rows[0]["textures0"]);
                this.Textures.Add(m_tex);

                m_tex = new AOTextures(1, (Int32)dt.Rows[0]["textures1"]);
                this.Textures.Add(m_tex);

                m_tex = new AOTextures(2, (Int32)dt.Rows[0]["textures2"]);
                this.Textures.Add(m_tex);

                m_tex = new AOTextures(3, (Int32)dt.Rows[0]["textures3"]);
                this.Textures.Add(m_tex);

                m_tex = new AOTextures(4, (Int32)dt.Rows[0]["textures4"]);
                this.Textures.Add(m_tex);
            }
        }
示例#3
0
        /// <summary>
        /// Read Textures from Sql Table
        /// </summary>
        public void ReadTexturesFromSql()
        {
            SqlWrapper ms = new SqlWrapper();

            this.Textures.Clear();

            DataTable dt =
                ms.ReadDatatable(
                    "SELECT textures0, textures1, textures2, textures3, textures4 from "
                    + this.GetSqlTablefromDynelType() + " WHERE ID=" + this.Id.ToString() + ";");

            if (dt.Rows.Count > 0)
            {
                AOTextures textures = new AOTextures(0, (Int32)dt.Rows[0][0]);
                this.Textures.Add(textures);

                textures = new AOTextures(1, (Int32)dt.Rows[0][1]);
                this.Textures.Add(textures);

                textures = new AOTextures(2, (Int32)dt.Rows[0][2]);
                this.Textures.Add(textures);

                textures = new AOTextures(3, (Int32)dt.Rows[0][3]);
                this.Textures.Add(textures);

                textures = new AOTextures(4, (Int32)dt.Rows[0][4]);
                this.Textures.Add(textures);
            }
        }
示例#4
0
        /// <summary>
        /// Read Textures from Packetreader
        /// </summary>
        /// <param name="packet">Packet reader</param>
        public void ReadTexturesfromPacket(PacketReader packet)
        {
            int        count = packet.Pop3F1Count();
            AOTextures textures;

            while (count > 0)
            {
                textures = new AOTextures(packet.PopInt(), packet.PopInt());
                count--;
            }
        }
示例#5
0
        // New one with id AND playfield as filter
        public void readTexturesfromSQLfast(DataRow row)
        {
            Textures.Clear();
            AOTextures m_tex;

            m_tex = new AOTextures(0, (Int32)row["textures0"]);
            Textures.Add(m_tex);

            m_tex = new AOTextures(1, (Int32)row["textures1"]);
            Textures.Add(m_tex);

            m_tex = new AOTextures(2, (Int32)row["textures2"]);
            Textures.Add(m_tex);

            m_tex = new AOTextures(3, (Int32)row["textures3"]);
            Textures.Add(m_tex);

            m_tex = new AOTextures(4, (Int32)row["textures4"]);
            Textures.Add(m_tex);
        }
示例#6
0
        /// <summary>
        /// Read NPC template
        /// TODO: catch exceptions
        /// </summary>
        /// <param name="hash">Hash string</param>
        /// <param name="level">NPC level</param>
        public void LoadTemplate(string hash, uint level)
        {
            SqlWrapper ms = new SqlWrapper();
            DataTable  dt = ms.ReadDatatable("SELECT * FROM mobtemplate where hash='" + hash + "'");

            if (dt.Rows.Count > 0)
            {
                this.Starting = true;
                level         = (UInt32)Math.Min(Math.Max(level, (Int32)dt.Rows[0]["MinLvl"]), (Int32)dt.Rows[0]["MaxLvl"]);
                this.Stats.Level.Set(level);
                this.Stats.Side.Set((Int32)dt.Rows[0]["Side"]);
                this.Stats.Breed.Set((Int32)dt.Rows[0]["Breed"]);
                this.Stats.Fatness.Set((Int32)dt.Rows[0]["Fatness"]);
                this.Stats.Sex.Set((Int32)dt.Rows[0]["Sex"]);
                this.Stats.Race.Set((Int32)dt.Rows[0]["Race"]);
                this.Name = (string)dt.Rows[0]["Name"];
                this.Stats.Flags.Set((Int32)dt.Rows[0]["Flags"]);
                this.Stats.NpcFamily.Set((Int32)dt.Rows[0]["NPCFamily"]);
                this.Stats.Health.Set((Int32)dt.Rows[0]["Health"]);
                this.Stats.Life.Set((Int32)dt.Rows[0]["Health"]);
                this.Stats.MonsterData.Set((Int32)dt.Rows[0]["Monsterdata"]);
                this.Stats.MonsterScale.Set((Int32)dt.Rows[0]["MonsterScale"]);
                this.Hash = hash;

                AOTextures m_t = new AOTextures(0, (Int32)dt.Rows[0]["TextureHands"]);
                this.Textures.Add(m_t);

                m_t = new AOTextures(1, (Int32)dt.Rows[0]["TextureBody"]);
                this.Textures.Add(m_t);

                m_t = new AOTextures(2, (Int32)dt.Rows[0]["TextureFeet"]);
                this.Textures.Add(m_t);

                m_t = new AOTextures(3, (Int32)dt.Rows[0]["TextureArms"]);
                this.Textures.Add(m_t);

                m_t = new AOTextures(4, (Int32)dt.Rows[0]["TextureLegs"]);
                this.Textures.Add(m_t);
                this.Starting = false;
            }
        }
        // New one with id AND playfield as filter
        public new void readTexturesfromSQL()
        {
            SqlWrapper ms = new SqlWrapper();
            AOTextures m_tex;
            Textures.Clear();

            DataTable dt = ms.ReadDT("SELECT textures0, textures1, textures2, textures3, textures4 from " + getSQLTablefromDynelType() + " WHERE ID=" + ID.ToString() + " AND playfield=" + PlayField.ToString());
            if (dt.Rows.Count > 0)
            {
                m_tex = new AOTextures(0, (Int32)dt.Rows[0]["textures0"]);
                Textures.Add(m_tex);

                m_tex = new AOTextures(1, (Int32)dt.Rows[0]["textures1"]);
                Textures.Add(m_tex);

                m_tex = new AOTextures(2, (Int32)dt.Rows[0]["textures2"]);
                Textures.Add(m_tex);

                m_tex = new AOTextures(3, (Int32)dt.Rows[0]["textures3"]);
                Textures.Add(m_tex);

                m_tex = new AOTextures(4, (Int32)dt.Rows[0]["textures4"]);
                Textures.Add(m_tex);
            }
        }
            public static bool func_do(Character ch, AOFunctions func, bool dolocalstats, bool tosocialtab, int placement, bool doreqs)
            {
                int c;
                int r;
                Character chartarget = (Character)Misc.FindDynel.FindDynelByID(ch.Target.Type, ch.Target.Instance);
                Boolean reqs_met;
                Character ftarget = null;
                int statval;
                Boolean reqresult;
                if (ch != null)
                {
                    for (c = 0; c < func.TickCount; c++)
                    {
                        reqs_met = true;
                        int childop = -1;
                        if (!doreqs)
                        {
                            for (r = 0; r < func.Requirements.Count; r++)
                            {
                                switch (func.Requirements[r].Target)
                                {
                                    case itemtarget_user:
                                        ftarget = ch;
                                        break;
                                    case itemtarget_wearer:
                                        ftarget = ch;
                                        break;
                                    case itemtarget_target:
                                        ftarget = chartarget;
                                        break;
                                    case itemtarget_fightingtarget:
                                        // Fighting target
                                        break;
                                    case itemtarget_self:
                                        ftarget = ch;
                                        break;
                                    case itemtarget_selectedtarget:
                                        ftarget = chartarget;
                                        break;
                                }
                                if (ftarget == null)
                                {
                                    reqs_met = false;
                                    return false;
                                }
                                statval = ftarget.Stats.Get(func.Requirements[r].Statnumber);
                                switch (func.Requirements[r].Operator)
                                {
                                    case operator_and:
                                        reqresult = ((statval & func.Requirements[r].Value) != 0);
                                        break;
                                    case operator_or:
                                        reqresult = ((statval | func.Requirements[r].Value) != 0);
                                        break;
                                    case operator_equalto:
                                        reqresult = (statval == func.Requirements[r].Value);
                                        break;
                                    case operator_lessthan:
                                        reqresult = (statval < func.Requirements[r].Value);
                                        break;
                                    case operator_greaterthan:
                                        reqresult = (statval > func.Requirements[r].Value);
                                        break;
                                    case operator_unequal:
                                        reqresult = (statval != func.Requirements[r].Value);
                                        break;
                                    case operator_true:
                                        reqresult = (statval != 0);
                                        break;
                                    case operator_false:
                                        reqresult = (statval == 0);
                                        break;
                                    case operator_bitand:
                                        reqresult = ((statval & func.Requirements[r].Value) != 0);
                                        break;
                                    case operator_bitor:
                                        reqresult = ((statval | func.Requirements[r].Value) != 0);
                                        break;
                                    default:
                                        reqresult = true;
                                        break;
                                }

                                switch (childop)
                                {
                                    case operator_and:
                                        reqs_met &= reqresult;
                                        break;
                                    case operator_or:
                                        reqs_met |= reqresult;
                                        break;
                                    case -1:
                                        reqs_met = reqresult;
                                        break;
                                    default:
                                        break;
                                }
                                childop = func.Requirements[r].ChildOperator;
                            }
                        }

                        if (!reqs_met)
                        {
                            return reqs_met;
                        }

                        switch (func.FunctionType)
                        {
                            // Set new Texture
                            case ItemHandler.functiontype_texture:
                                SqlWrapper ms = new SqlWrapper();
                                if (!tosocialtab)
                                {
                                    ms.SqlUpdate("Update " + ch.getSQLTablefromDynelType() + " set Textures" + func.Arguments[1].ToString() + "=" + func.Arguments[0].ToString() + " WHERE ID=" + ch.ID.ToString());
                                    AOTextures ao = new AOTextures((int)func.Arguments[1], (int)func.Arguments[0]);
                                    ch.Textures.Add(ao);
                                }
                                else
                                {
                                    int texnum = Int32.Parse(func.Arguments[1].ToString());
                                    int texval = Int32.Parse(func.Arguments[0].ToString());
                                    if (ch.SocialTab.ContainsKey(texnum))
                                    {
                                        ch.SocialTab[texnum] = texval;
                                    }
                                    else
                                    {
                                        ch.SocialTab.Add(texnum, texval);
                                    }
                                    ch.SaveSocialTab();
                                }

                                break;
                            // Set Headmesh
                            case ItemHandler.functiontype_headmesh:
                                if (!tosocialtab)
                                {
                                    ch.Stats.HeadMesh.StatModifier = (Int32)((Int32)func.Arguments[1] - ch.Stats.HeadMesh.StatBaseValue); // Headmesh
                                    ch.MeshLayer.AddMesh(0, (Int32)func.Arguments[1], (Int32)func.Arguments[0], 0);
                                }
                                else
                                {
                                    if (ch.SocialTab.ContainsKey(ch.Stats.HeadMesh.StatNumber))
                                    {
                                        ch.SocialTab[ch.Stats.HeadMesh.StatNumber] = (Int32)func.Arguments[0];
                                        ch.SocialMeshLayer.AddMesh(0, (Int32)func.Arguments[0], (Int32)func.Arguments[1], 0);
                                    }
                                    else
                                    {
                                        ch.SocialTab.Add(ch.Stats.HeadMesh.StatNumber, (Int32)func.Arguments[0]);
                                        ch.SocialMeshLayer.AddMesh(0, (Int32)func.Arguments[0], (Int32)func.Arguments[1], 0);
                                    }
                                    ch.SaveSocialTab();
                                }
                                break;
                            // Set Shouldermesh
                            case ItemHandler.functiontype_shouldermesh:
                                if ((placement == 19) || (placement == 51))
                                {
                                    if (!tosocialtab)
                                    {
                                        ch.Stats.ShoulderMeshRight.Set((Int32)func.Arguments[1]);
                                        ch.Stats.ShoulderMeshLeft.Set((Int32)func.Arguments[1]);
                                        ch.MeshLayer.AddMesh(3, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                        ch.MeshLayer.AddMesh(4, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                    }
                                    else
                                    {
                                        ch.SocialMeshLayer.AddMesh(3, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                        ch.SocialMeshLayer.AddMesh(4, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                    }
                                }
                                else
                                {
                                    if (!tosocialtab)
                                    {
                                        if (placement == 20)
                                        {
                                            ch.Stats.ShoulderMeshLeft.Set((Int32)func.Arguments[1]);
                                            ch.MeshLayer.AddMesh(3, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                        }
                                        if (placement == 22)
                                        {
                                            ch.Stats.ShoulderMeshLeft.Set((Int32)func.Arguments[1]);
                                            ch.MeshLayer.AddMesh(4, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                        }
                                    }
                                    else
                                    {
                                        if (placement == 52)
                                        {
                                            ch.Stats.ShoulderMeshRight.Set((Int32)func.Arguments[1]);
                                            ch.SocialMeshLayer.AddMesh(3, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                        }
                                        if (placement == 54)
                                        {
                                            ch.Stats.ShoulderMeshLeft.Set((Int32)func.Arguments[1]);
                                            ch.SocialMeshLayer.AddMesh(4, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                        }
                                    }


                                }
                                break;
                            // Set Backmesh
                            case ItemHandler.functiontype_backmesh:
                                if (!tosocialtab)
                                {
                                    ch.Stats.BackMesh.Set((Int32)func.Arguments[0]); // Shouldermesh
                                    ch.MeshLayer.AddMesh(5, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                else
                                {
                                    ch.SocialMeshLayer.AddMesh(5, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                break;
                            // Set Hairmesh
                            case ItemHandler.functiontype_hairmesh:
                                if (!tosocialtab)
                                {
                                    ch.Stats.HairMesh.Set((Int32)func.Arguments[0]); // HairMesh
                                    ch.MeshLayer.AddMesh(0, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                else
                                {
                                    ch.SocialMeshLayer.AddMesh(0, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                break;
                            case ItemHandler.functiontype_attractormesh:
                                if (!tosocialtab)
                                {
                                    ch.Stats.HairMesh.Set((Int32)func.Arguments[0]); // HairMesh
                                    ch.MeshLayer.AddMesh(0, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                else
                                {
                                    ch.SocialMeshLayer.AddMesh(0, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                break;
                            case ItemHandler.functiontype_modify:
                                // TODO: req check for OE
                                if (dolocalstats)
                                {
                                    if (!tosocialtab)
                                    {
                                        ch.Stats.SetModifier((Int32)func.Arguments[0], ch.Stats.GetModifier((Int32)func.Arguments[0]) + (Int32)func.Arguments[1]);
                                    }
                                }
                                break;
                            case ItemHandler.functiontype_modifypercentage:
                                // TODO: req check for OE
                                if (dolocalstats)
                                {
                                    if (!tosocialtab)
                                    {
                                        ch.Stats.SetPercentageModifier((Int32)func.Arguments[0], ch.Stats.GetPercentageModifier((Int32)func.Arguments[0]) + (Int32)func.Arguments[1]);
                                    }
                                }
                                break;
                            case ItemHandler.functiontype_uploadnano:
                                ch.UploadNano((Int32)func.Arguments[0]);
                                Packets.UploadNanoupdate.Send(ch, 53019, (Int32)func.Arguments[0]);
                                break;
                            case ItemHandler.functiontype_shophash:
                                // Do nothing, it's covered in 
                                break;
                            default:
                                break;
                        }
                    }
                }
                return false;
            }
        // New one with id AND playfield as filter
        public void readTexturesfromSQLfast(DataRow row)
        {
            Textures.Clear();
            AOTextures m_tex;
            m_tex = new AOTextures(0, (Int32)row["textures0"]);
            Textures.Add(m_tex);

            m_tex = new AOTextures(1, (Int32)row["textures1"]);
            Textures.Add(m_tex);

            m_tex = new AOTextures(2, (Int32)row["textures2"]);
            Textures.Add(m_tex);

            m_tex = new AOTextures(3, (Int32)row["textures3"]);
            Textures.Add(m_tex);

            m_tex = new AOTextures(4, (Int32)row["textures4"]);
            Textures.Add(m_tex);
        }
        /// <summary>
        /// </summary>
        /// <param name="iCharacter">
        /// </param>
        /// <returns>
        /// </returns>
        private static MessageDataFiller Filler(ICharacter iCharacter)
        {
            return(message =>
            {
                Character character = (Character)iCharacter;
                message.Identity = character.Identity;
                message.Unknown = 0;

                List <AOMeshs> meshs;
                int counter;

                bool socialonly;
                bool showsocial;

                /*
                 * bool showhelmet;
                 * bool LeftPadVisible;
                 * bool RightPadVisible;
                 * bool DoubleLeftPad;
                 * bool DoubleRightPad;
                 *
                 * int TexturesCount;
                 * int HairMeshValue;
                 * int WeaponMeshRightValue;
                 * int WeaponMeshLeftValue;
                 *
                 * uint HeadMeshBaseValue;
                 * int HeadMeshValue;
                 *
                 * int BackMeshValue;
                 * int ShoulderMeshRightValue;
                 */
                // int ShoulderMeshRightValue;
                int VisualFlags;
                int PlayField;
                int bodyMesh = 0;

                /*
                 * int OverrideTextureHead;
                 * int OverrideTextureWeaponRight;
                 * int OverrideTextureWeaponLeft;
                 * int OverrideTextureShoulderpadRight;
                 * int OverrideTextureShoulderpadLeft;
                 * int OverrideTextureBack;
                 * int OverrideTextureAttractor;
                 */
                var textures = new List <AOTextures>();

                var socialTab = new Dictionary <int, int>();

                lock (character)
                {
                    VisualFlags = character.Stats[StatIds.visualflags].Value;

                    socialonly = (VisualFlags & 0x40) > 0;
                    showsocial = (VisualFlags & 0x20) > 0;
                    bodyMesh = character.Stats[StatIds.mesh].Value;

                    /*
                     * showhelmet = ((character.Stats.VisualFlags.Value & 0x4) > 0);
                     * LeftPadVisible = ((character.Stats.VisualFlags.Value & 0x1) > 0);
                     * RightPadVisible = ((character.Stats.VisualFlags.Value & 0x2) > 0);
                     * DoubleLeftPad = ((character.Stats.VisualFlags.Value & 0x8) > 0);
                     * DoubleRightPad = ((character.Stats.VisualFlags.Value & 0x10) > 0);
                     *
                     * HairMeshValue = character.Stats.HairMesh.Value;
                     * TexturesCount = character.Textures.Count;
                     * HairMeshValue = character.Stats.HairMesh.Value;
                     * WeaponMeshRightValue = character.Stats.WeaponMeshRight.Value;
                     * WeaponMeshLeftValue = character.Stats.WeaponMeshLeft.Value;
                     *
                     * HeadMeshBaseValue = character.Stats.HeadMesh.StatBaseValue;
                     * HeadMeshValue = character.Stats.HeadMesh.Value;
                     *
                     * BackMeshValue = character.Stats.BackMesh.Value;
                     * ShoulderMeshRightValue = character.Stats.ShoulderMeshRight.Value;
                     */
                    // ShoulderMeshLeftValue = character.Stats.ShoulderMeshLeft.Value;

                    /*
                     * OverrideTextureHead = character.Stats.OverrideTextureHead.Value;
                     * OverrideTextureWeaponRight = character.Stats.OverrideTextureWeaponRight.Value;
                     * OverrideTextureWeaponLeft = character.Stats.OverrideTextureWeaponLeft.Value;
                     * OverrideTextureShoulderpadRight = character.Stats.OverrideTextureShoulderpadRight.Value;
                     * OverrideTextureShoulderpadLeft = character.Stats.OverrideTextureShoulderpadLeft.Value;
                     * OverrideTextureBack = character.Stats.OverrideTextureBack.Value;
                     * OverrideTextureAttractor = character.Stats.OverrideTextureAttractor.Value;
                     */
                    PlayField = character.Playfield.Identity.Instance;

                    foreach (int num in character.SocialTab.Keys)
                    {
                        socialTab.Add(num, character.SocialTab[num]);
                    }

                    foreach (AOTextures texture in character.Textures)
                    {
                        textures.Add(new AOTextures(texture.place, texture.Texture));

                        // REFACT why recreating a AOTexture ???
                        // Because of thread safety, player could lose texture the same time? - Algorithman
                    }

                    meshs = MeshLayers.GetMeshs(character, showsocial, socialonly);
                }

                var texturesToSend = new List <Texture>();

                var aotemp = new AOTextures(0, 0);
                for (counter = 0; counter < 5; counter++)
                {
                    aotemp.Texture = 0;
                    aotemp.place = counter;
                    int c2;
                    for (c2 = 0; c2 < textures.Count; c2++)
                    {
                        if (textures[c2].place == counter)
                        {
                            aotemp.Texture = textures[c2].Texture;
                            break;
                        }
                    }

                    if (showsocial)
                    {
                        if (socialonly)
                        {
                            aotemp.Texture = socialTab[counter];
                        }
                        else
                        {
                            if (socialTab[counter] != 0)
                            {
                                aotemp.Texture = socialTab[counter];
                            }
                        }
                    }

                    texturesToSend.Add(new Texture {
                        Place = aotemp.place, Id = aotemp.Texture, Unknown = 0
                    });
                }

                message.Textures = texturesToSend.ToArray();

                message.Meshes =
                    meshs.Select(
                        mesh =>
                        new Mesh
                {
                    Position = (byte)mesh.Position,
                    Id = (uint)mesh.Mesh,
                    OverrideTextureId = mesh.OverrideTexture,
                    Layer = (byte)mesh.Layer
                }).ToArray();
                message.VisualFlags = (short)VisualFlags;
                message.Unknown1 = 0;
            });
        }
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        /// <returns>
        /// </returns>
        public static SimpleCharFullUpdateMessage ConstructMessage(Character character)
        {
            // Character Variables
            bool socialonly;
            bool showsocial;

            int        charPlayfield;
            AOCoord    charCoord;
            Identity   charId;
            Quaternion charHeading;

            uint sideValue;
            uint fatValue;
            uint breedValue;
            uint sexValue;
            uint raceValue;

            string charName;
            int    charFlagsValue;
            int    accFlagsValue;

            int expansionValue;
            int currentNano;
            int currentHealth;

            uint strengthBaseValue;
            uint staminaBaseValue;
            uint agilityBaseValue;
            uint senseBaseValue;
            uint intelligenceBaseValue;
            uint psychicBaseValue;

            string firstName;
            string lastName;
            int    orgNameLength;
            string orgName;
            int    levelValue;
            int    healthValue;
            int    losHeight;

            int monsterData;
            int monsterScale;
            int visualFlags;

            int  currentMovementMode;
            uint runSpeedBaseValue;

            int texturesCount;

            int headMeshValue;

            // NPC Values
            int NPCFamily;

            var socialTab = new Dictionary <int, int>();

            var textures = new List <AOTextures>();

            List <AOMeshs> meshs;

            var nanos = new List <AONano>();

            lock (character)
            {
                socialonly = (character.Stats["VisualFlags"].Value & 0x40) > 0;
                showsocial = (character.Stats["VisualFlags"].Value & 0x20) > 0;

                charPlayfield = character.Playfield.Identity.Instance;
                charCoord     = character.Coordinates;
                charId        = character.Identity;
                charHeading   = character.Heading;

                sideValue  = character.Stats["Side"].BaseValue;
                fatValue   = character.Stats["Fatness"].BaseValue;
                breedValue = character.Stats["Breed"].BaseValue;
                sexValue   = character.Stats["Sex"].BaseValue;
                raceValue  = character.Stats["Race"].BaseValue;

                charName       = character.Name;
                charFlagsValue = character.Stats["Flags"].Value;
                accFlagsValue  = character.Stats["AccountFlags"].Value;

                expansionValue = character.Stats["Expansion"].Value;
                currentNano    = character.Stats["CurrentNano"].Value;

                strengthBaseValue     = character.Stats["Strength"].BaseValue;
                staminaBaseValue      = character.Stats["Strength"].BaseValue;
                agilityBaseValue      = character.Stats["Strength"].BaseValue;
                senseBaseValue        = character.Stats["Strength"].BaseValue;
                intelligenceBaseValue = character.Stats["Strength"].BaseValue;
                psychicBaseValue      = character.Stats["Strength"].BaseValue;

                firstName     = character.FirstName;
                lastName      = character.LastName;
                orgNameLength = character.OrganizationName.Length;
                orgName       = character.OrganizationName;
                levelValue    = character.Stats["Level"].Value;
                healthValue   = character.Stats["Life"].Value;

                monsterData  = character.Stats["MonsterData"].Value;
                monsterScale = character.Stats["MonsterScale"].Value;
                visualFlags  = character.Stats["VisualFlags"].Value;

                currentMovementMode = character.Stats["CurrentMovementMode"].Value;
                runSpeedBaseValue   = character.Stats["RunSpeed"].BaseValue;

                texturesCount = character.Textures.Count;

                headMeshValue = character.Stats["HeadMesh"].Value;

                foreach (int num in character.SocialTab.Keys)
                {
                    socialTab.Add(num, character.SocialTab[num]);
                }

                foreach (AOTextures at in character.Textures)
                {
                    textures.Add(new AOTextures(at.place, at.Texture));
                }

                meshs = MeshLayers.GetMeshs(character, showsocial, socialonly);

                foreach (AONano nano in character.ActiveNanos)
                {
                    var tempNano = new AONano();
                    tempNano.ID         = nano.ID;
                    tempNano.Instance   = nano.Instance;
                    tempNano.NanoStrain = nano.NanoStrain;
                    tempNano.Nanotype   = nano.Nanotype;
                    tempNano.Time1      = nano.Time1;
                    tempNano.Time2      = nano.Time2;
                    tempNano.Value3     = nano.Value3;

                    nanos.Add(tempNano);
                }

                losHeight     = character.Stats["LosHeight"].Value;
                NPCFamily     = character.Stats["NpcFamily"].Value;
                currentHealth = character.Stats["Health"].Value;
            }

            var scfu = new SimpleCharFullUpdateMessage();

            // affected identity
            scfu.Identity = charId;

            scfu.Version     = 57;                                       // SCFU packet version (57/0x39)
            scfu.Flags       = SimpleCharFullUpdateFlags.None;           // Try setting to 0x042062C8 if you have problems (old value)
            scfu.Flags      |= SimpleCharFullUpdateFlags.HasPlayfieldId; // Has Playfield ID
            scfu.PlayfieldId = charPlayfield;                            // playfield

            if (character.FightingTarget.Instance != 0)
            {
                scfu.Flags         |= SimpleCharFullUpdateFlags.HasFightingTarget;
                scfu.FightingTarget = new Identity
                {
                    Type     = character.FightingTarget.Type,
                    Instance = character.FightingTarget.Instance
                };
            }

            // Coordinates
            scfu.Coordinates = new Vector3 {
                X = charCoord.x, Y = charCoord.y, Z = charCoord.z
            };

            // Heading Data
            scfu.Flags  |= SimpleCharFullUpdateFlags.HasHeading;
            scfu.Heading = new SmokeLounge.AOtomation.Messaging.GameData.Quaternion
            {
                W = charHeading.wf,
                X = charHeading.xf,
                Y = charHeading.yf,
                Z = charHeading.zf
            };

            // Race
            scfu.Appearance = new Appearance
            {
                Side    = (Side)sideValue,
                Fatness = (Fatness)fatValue,
                Breed   = (Breed)breedValue,
                Gender  = (Gender)sexValue,
                Race    = raceValue
            };                       // appearance

            // Name
            scfu.Name = charName;

            scfu.CharacterFlags = (CharacterFlags)charFlagsValue; // Flags
            scfu.AccountFlags   = (short)accFlagsValue;
            scfu.Expansions     = (short)expansionValue;

            bool isNpc = character is NonPlayerCharacter;

            if (isNpc)
            {
                // Are we a NPC (i think anyway)? So far this is _NOT_ used at all
                scfu.Flags |= SimpleCharFullUpdateFlags.IsNpc;

                var snpc = new SimpleNpcInfo {
                    Family = (short)NPCFamily, LosHeight = (short)losHeight
                };
                scfu.CharacterInfo = snpc;
            }
            else
            {
                // Are we a player?
                var spc = new SimplePcInfo();

                spc.CurrentNano = (uint)currentNano; // CurrentNano
                spc.Team        = 0;                 // team?
                spc.Swim        = 5;                 // swim?

                // The checks here are to prevent the client doing weird things if the character has really large or small base attributes
                spc.StrengthBase     = (short)Math.Min(strengthBaseValue, short.MaxValue);     // Strength
                spc.AgilityBase      = (short)Math.Min(agilityBaseValue, short.MaxValue);      // Agility
                spc.StaminaBase      = (short)Math.Min(staminaBaseValue, short.MaxValue);      // Stamina
                spc.IntelligenceBase = (short)Math.Min(intelligenceBaseValue, short.MaxValue); // Intelligence
                spc.SenseBase        = (short)Math.Min(senseBaseValue, short.MaxValue);        // Sense
                spc.PsychicBase      = (short)Math.Min(psychicBaseValue, short.MaxValue);      // Psychic

                if (scfu.CharacterFlags.HasFlag(CharacterFlags.HasVisibleName))
                {
                    // has visible names? (Flags)
                    spc.FirstName = firstName;
                    spc.LastName  = lastName;
                }

                if (orgNameLength != 0)
                {
                    scfu.Flags |= SimpleCharFullUpdateFlags.HasOrgName; // Has org name data
                    spc.OrgName = orgName;
                }

                scfu.CharacterInfo = spc;
            }

            // Level
            scfu.Level = (short)levelValue;
            if (scfu.Level > sbyte.MaxValue)
            {
                scfu.Flags |= SimpleCharFullUpdateFlags.HasExtendedLevel;
            }

            // Health
            scfu.Health = (uint)healthValue;
            if (scfu.Health <= short.MaxValue)
            {
                scfu.Flags |= SimpleCharFullUpdateFlags.HasSmallHealth;
            }

            scfu.HealthDamage = healthValue - currentHealth;
            if (scfu.HealthDamage <= byte.MaxValue)
            {
                scfu.Flags |= SimpleCharFullUpdateFlags.HasSmallHealthDamage;
            }

            // If player is in grid or fixer grid
            // make him/her/it a nice upside down pyramid
            if ((charPlayfield == 152) || (charPlayfield == 4107))
            {
                scfu.MonsterData = 99902;
            }
            else
            {
                scfu.MonsterData = (uint)monsterData; // Monsterdata
            }

            scfu.MonsterScale = (short)monsterScale; // Monsterscale
            scfu.VisualFlags  = (short)visualFlags;  // VisualFlags
            scfu.VisibleTitle = 0;                   // visible title?

            // 42 bytes long
            scfu.Unknown1 = new byte[]
            {
                0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
                (byte)currentMovementMode, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
                0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00
            };

            if (headMeshValue != 0)
            {
                scfu.Flags   |= SimpleCharFullUpdateFlags.HasHeadMesh; // Has HeadMesh Flag
                scfu.HeadMesh = (uint?)headMeshValue;                  // Headmesh
            }

            // Runspeed
            scfu.RunSpeedBase = (short)runSpeedBaseValue;
            if (runSpeedBaseValue > sbyte.MaxValue)
            {
                scfu.Flags |= SimpleCharFullUpdateFlags.HasExtendedRunSpeed;
            }

            scfu.ActiveNanos = (from nano in nanos
                                select
                                new ActiveNano
            {
                NanoId = nano.ID,
                NanoInstance = nano.Instance,
                Time1 = nano.Time1,
                Time2 = nano.Time2
            }).ToArray();

            // Texture/Cloth Data
            var scfuTextures = new List <Texture>();

            var aotemp = new AOTextures(0, 0);

            for (int c = 0; c < 5; c++)
            {
                aotemp.Texture = 0;
                aotemp.place   = c;
                for (int c2 = 0; c2 < texturesCount; c2++)
                {
                    if (textures[c2].place != c)
                    {
                        continue;
                    }

                    aotemp.Texture = textures[c2].Texture;
                    break;
                }

                if (showsocial)
                {
                    if (socialonly)
                    {
                        aotemp.Texture = socialTab[c];
                    }
                    else
                    {
                        if (socialTab[c] != 0)
                        {
                            aotemp.Texture = socialTab[c];
                        }
                    }
                }

                scfuTextures.Add(new Texture {
                    Place = aotemp.place, Id = aotemp.Texture, Unknown = 0
                });
            }

            scfu.Textures = scfuTextures.ToArray();

            // End Textures

            // ############
            // # Meshs
            // ############
            scfu.Meshes = (from aoMesh in meshs
                           select
                           new Mesh
            {
                Position = (byte)aoMesh.Position,
                Id = (uint)aoMesh.Mesh,
                OverrideTextureId = aoMesh.OverrideTexture,
                Layer = (byte)aoMesh.Layer
            }).ToArray();

            // End Meshs
            scfu.Flags2   = 0; // packetFlags2
            scfu.Unknown2 = 0;

            return(scfu);
        }
示例#12
0
        public void LoadTemplate(string hash, uint level)
        {
            SqlWrapper ms = new SqlWrapper();
            DataTable dt = ms.ReadDT("SELECT * FROM mobtemplate where hash='" + hash + "'");
            if (dt.Rows.Count>0)
            {
                startup = true;
                level = (UInt32)Math.Min(Math.Max(level,(Int32)dt.Rows[0]["MinLvl"]),(Int32)dt.Rows[0]["MaxLvl"]);
                Stats.Level.Set(level);
                Stats.Side.Set((Int32)dt.Rows[0]["Side"]);
                Stats.Breed.Set((Int32)dt.Rows[0]["Breed"]);
                Stats.Fatness.Set((Int32)dt.Rows[0]["Fatness"]);
                Stats.Sex.Set((Int32)dt.Rows[0]["Sex"]);
                Stats.Race.Set((Int32)dt.Rows[0]["Race"]);
                Name = (string)dt.Rows[0]["Name"];
                Stats.Flags.Set((Int32)dt.Rows[0]["Flags"]);
                Stats.NPCFamily.Set((Int32)dt.Rows[0]["NPCFamily"]);
                Stats.Health.Set((Int32)dt.Rows[0]["Health"]);
                Stats.Life.Set((Int32)dt.Rows[0]["Health"]);
                Stats.MonsterData.Set((Int32)dt.Rows[0]["Monsterdata"]);
                Stats.MonsterScale.Set((Int32)dt.Rows[0]["MonsterScale"]);

                AOTextures m_t = new AOTextures(0, (Int32)dt.Rows[0]["TextureHands"]);
                Textures.Add(m_t);

                m_t = new AOTextures(1, (Int32)dt.Rows[0]["TextureBody"]);
                Textures.Add(m_t);

                m_t = new AOTextures(2, (Int32)dt.Rows[0]["TextureFeet"]);
                Textures.Add(m_t);

                m_t = new AOTextures(3, (Int32)dt.Rows[0]["TextureArms"]);
                Textures.Add(m_t);

                m_t = new AOTextures(4, (Int32)dt.Rows[0]["TextureLegs"]);
                Textures.Add(m_t);
                startup = false;
            }
        }
示例#13
0
        /// <summary>
        /// Read Textures from Sql Table
        /// </summary>
        public void ReadTexturesFromSql()
        {
            SqlWrapper ms = new SqlWrapper();
            this.Textures.Clear();

            DataTable dt =
                ms.ReadDatatable(
                    "SELECT textures0, textures1, textures2, textures3, textures4 from "
                    + this.GetSqlTablefromDynelType() + " WHERE ID=" + this.Id.ToString() + ";");
            if (dt.Rows.Count > 0)
            {
                AOTextures textures = new AOTextures(0, (Int32)dt.Rows[0][0]);
                this.Textures.Add(textures);

                textures = new AOTextures(1, (Int32)dt.Rows[0][1]);
                this.Textures.Add(textures);

                textures = new AOTextures(2, (Int32)dt.Rows[0][2]);
                this.Textures.Add(textures);

                textures = new AOTextures(3, (Int32)dt.Rows[0][3]);
                this.Textures.Add(textures);

                textures = new AOTextures(4, (Int32)dt.Rows[0][4]);
                this.Textures.Add(textures);
            }
        }
示例#14
0
        public static void AnnounceAppearanceUpdate(Character character)
        {
            List <AOMeshs> meshs;
            PacketWriter   packetWriter = new PacketWriter();

            packetWriter.PushByte(0xDF);
            packetWriter.PushByte(0xDF);
            packetWriter.PushShort(10);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0); // Packet size. writer will take care of this
            packetWriter.PushInt(3086);
            packetWriter.PushInt(character.Id);
            packetWriter.PushInt(0x41624F0D);
            packetWriter.PushIdentity(50000, character.Id);
            packetWriter.PushByte(0);
            packetWriter.Push3F1Count(5); // Textures are always transferred
            int c;

            bool socialonly;
            bool showsocial;

            /*
             * bool showhelmet;
             * bool LeftPadVisible;
             * bool RightPadVisible;
             * bool DoubleLeftPad;
             * bool DoubleRightPad;
             *
             * int TexturesCount;
             * int HairMeshValue;
             * int WeaponMeshRightValue;
             * int WeaponMeshLeftValue;
             *
             * uint HeadMeshBaseValue;
             * int HeadMeshValue;
             *
             * int BackMeshValue;
             * int ShoulderMeshRightValue;
             */
            //int ShoulderMeshRightValue;

            int VisualFlags;
            int PlayField;

            /*
             * int OverrideTextureHead;
             * int OverrideTextureWeaponRight;
             * int OverrideTextureWeaponLeft;
             * int OverrideTextureShoulderpadRight;
             * int OverrideTextureShoulderpadLeft;
             * int OverrideTextureBack;
             * int OverrideTextureAttractor;
             */
            List <AOTextures> textures = new List <AOTextures>();

            Dictionary <int, int> socialTab = new Dictionary <int, int>();

            lock (character)
            {
                VisualFlags = character.Stats.VisualFlags.Value;

                socialonly = ((character.Stats.VisualFlags.Value & 0x40) > 0);
                showsocial = ((character.Stats.VisualFlags.Value & 0x20) > 0);

                /*
                 * showhelmet = ((character.Stats.VisualFlags.Value & 0x4) > 0);
                 * LeftPadVisible = ((character.Stats.VisualFlags.Value & 0x1) > 0);
                 * RightPadVisible = ((character.Stats.VisualFlags.Value & 0x2) > 0);
                 * DoubleLeftPad = ((character.Stats.VisualFlags.Value & 0x8) > 0);
                 * DoubleRightPad = ((character.Stats.VisualFlags.Value & 0x10) > 0);
                 *
                 * HairMeshValue = character.Stats.HairMesh.Value;
                 * TexturesCount = character.Textures.Count;
                 * HairMeshValue = character.Stats.HairMesh.Value;
                 * WeaponMeshRightValue = character.Stats.WeaponMeshRight.Value;
                 * WeaponMeshLeftValue = character.Stats.WeaponMeshLeft.Value;
                 *
                 * HeadMeshBaseValue = character.Stats.HeadMesh.StatBaseValue;
                 * HeadMeshValue = character.Stats.HeadMesh.Value;
                 *
                 * BackMeshValue = character.Stats.BackMesh.Value;
                 * ShoulderMeshRightValue = character.Stats.ShoulderMeshRight.Value;
                 */
                //ShoulderMeshLeftValue = character.Stats.ShoulderMeshLeft.Value;

                /*
                 * OverrideTextureHead = character.Stats.OverrideTextureHead.Value;
                 * OverrideTextureWeaponRight = character.Stats.OverrideTextureWeaponRight.Value;
                 * OverrideTextureWeaponLeft = character.Stats.OverrideTextureWeaponLeft.Value;
                 * OverrideTextureShoulderpadRight = character.Stats.OverrideTextureShoulderpadRight.Value;
                 * OverrideTextureShoulderpadLeft = character.Stats.OverrideTextureShoulderpadLeft.Value;
                 * OverrideTextureBack = character.Stats.OverrideTextureBack.Value;
                 * OverrideTextureAttractor = character.Stats.OverrideTextureAttractor.Value;
                 */
                PlayField = character.PlayField;

                foreach (int num in character.SocialTab.Keys)
                {
                    socialTab.Add(num, character.SocialTab[num]);
                }

                foreach (AOTextures texture in character.Textures)
                {
                    textures.Add(new AOTextures(texture.place, texture.Texture));
                }

                meshs = MeshLayers.GetMeshs(character, showsocial, socialonly);
            }

            AOTextures aotemp = new AOTextures(0, 0);

            for (c = 0; c < 5; c++)
            {
                aotemp.Texture = 0;
                aotemp.place   = c;
                int c2;
                for (c2 = 0; c2 < textures.Count; c2++)
                {
                    if (textures[c2].place == c)
                    {
                        aotemp.Texture = textures[c2].Texture;
                        break;
                    }
                }
                if (showsocial)
                {
                    if (socialonly)
                    {
                        aotemp.Texture = socialTab[c];
                    }
                    else
                    {
                        if (socialTab[c] != 0)
                        {
                            aotemp.Texture = socialTab[c];
                        }
                    }
                }

                packetWriter.PushInt(aotemp.place);
                packetWriter.PushInt(aotemp.Texture);
                packetWriter.PushInt(0);
            }

            c = meshs.Count;
            packetWriter.Push3F1Count(c);
            foreach (AOMeshs mesh in meshs)
            {
                packetWriter.PushByte((byte)mesh.Position);
                packetWriter.PushUInt(mesh.Mesh);
                packetWriter.PushInt(mesh.OverrideTexture); // Override Texture!!!!!!
                packetWriter.PushByte((byte)mesh.Layer);
            }

            packetWriter.PushShort((short)(VisualFlags)); // 673 = VisualFlags
            packetWriter.PushByte(0);

            byte[] reply = packetWriter.Finish();
            Announce.Playfield(PlayField, reply);
        }
示例#15
0
 /// <summary>
 /// Read Textures from Packetreader
 /// </summary>
 /// <param name="packet">Packet reader</param>
 public void ReadTexturesfromPacket(PacketReader packet)
 {
     int count = packet.Pop3F1Count();
     AOTextures textures;
     while (count > 0)
     {
         textures = new AOTextures(packet.PopInt(), packet.PopInt());
         count--;
     }
 }
        // New one with id AND playfield as filter
        /// <summary>
        /// Read NPC textures from database
        /// </summary>
        public void ReadTexturesfromSql()
        {
            SqlWrapper ms = new SqlWrapper();
            AOTextures m_tex;
            this.Textures.Clear();

            DataTable dt =
                ms.ReadDatatable(
                    "SELECT textures0, textures1, textures2, textures3, textures4 from "
                    + this.GetSqlTablefromDynelType() + " WHERE ID=" + this.Id.ToString() + " AND playfield="
                    + this.PlayField.ToString());
            if (dt.Rows.Count > 0)
            {
                m_tex = new AOTextures(0, (Int32)dt.Rows[0]["textures0"]);
                this.Textures.Add(m_tex);

                m_tex = new AOTextures(1, (Int32)dt.Rows[0]["textures1"]);
                this.Textures.Add(m_tex);

                m_tex = new AOTextures(2, (Int32)dt.Rows[0]["textures2"]);
                this.Textures.Add(m_tex);

                m_tex = new AOTextures(3, (Int32)dt.Rows[0]["textures3"]);
                this.Textures.Add(m_tex);

                m_tex = new AOTextures(4, (Int32)dt.Rows[0]["textures4"]);
                this.Textures.Add(m_tex);
            }
        }
示例#17
0
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        public static void AnnounceAppearanceUpdate(Character character)
        {
            var message = new AppearanceUpdateMessage {
                Identity = character.Identity, Unknown = 0x00,
            };

            List <AOMeshs> meshs;
            int            counter;

            bool socialonly;
            bool showsocial;

            /*
             * bool showhelmet;
             * bool LeftPadVisible;
             * bool RightPadVisible;
             * bool DoubleLeftPad;
             * bool DoubleRightPad;
             *
             * int TexturesCount;
             * int HairMeshValue;
             * int WeaponMeshRightValue;
             * int WeaponMeshLeftValue;
             *
             * uint HeadMeshBaseValue;
             * int HeadMeshValue;
             *
             * int BackMeshValue;
             * int ShoulderMeshRightValue;
             */
            // int ShoulderMeshRightValue;
            int VisualFlags;
            int PlayField;

            /*
             * int OverrideTextureHead;
             * int OverrideTextureWeaponRight;
             * int OverrideTextureWeaponLeft;
             * int OverrideTextureShoulderpadRight;
             * int OverrideTextureShoulderpadLeft;
             * int OverrideTextureBack;
             * int OverrideTextureAttractor;
             */
            var textures = new List <AOTextures>();

            var socialTab = new Dictionary <int, int>();

            lock (character)
            {
                VisualFlags = character.Stats["VisualFlags"].Value;

                socialonly = (character.Stats["VisualFlags"].Value & 0x40) > 0;
                showsocial = (character.Stats["VisualFlags"].Value & 0x20) > 0;

                /*
                 * showhelmet = ((character.Stats.VisualFlags.Value & 0x4) > 0);
                 * LeftPadVisible = ((character.Stats.VisualFlags.Value & 0x1) > 0);
                 * RightPadVisible = ((character.Stats.VisualFlags.Value & 0x2) > 0);
                 * DoubleLeftPad = ((character.Stats.VisualFlags.Value & 0x8) > 0);
                 * DoubleRightPad = ((character.Stats.VisualFlags.Value & 0x10) > 0);
                 *
                 * HairMeshValue = character.Stats.HairMesh.Value;
                 * TexturesCount = character.Textures.Count;
                 * HairMeshValue = character.Stats.HairMesh.Value;
                 * WeaponMeshRightValue = character.Stats.WeaponMeshRight.Value;
                 * WeaponMeshLeftValue = character.Stats.WeaponMeshLeft.Value;
                 *
                 * HeadMeshBaseValue = character.Stats.HeadMesh.StatBaseValue;
                 * HeadMeshValue = character.Stats.HeadMesh.Value;
                 *
                 * BackMeshValue = character.Stats.BackMesh.Value;
                 * ShoulderMeshRightValue = character.Stats.ShoulderMeshRight.Value;
                 */
                // ShoulderMeshLeftValue = character.Stats.ShoulderMeshLeft.Value;

                /*
                 * OverrideTextureHead = character.Stats.OverrideTextureHead.Value;
                 * OverrideTextureWeaponRight = character.Stats.OverrideTextureWeaponRight.Value;
                 * OverrideTextureWeaponLeft = character.Stats.OverrideTextureWeaponLeft.Value;
                 * OverrideTextureShoulderpadRight = character.Stats.OverrideTextureShoulderpadRight.Value;
                 * OverrideTextureShoulderpadLeft = character.Stats.OverrideTextureShoulderpadLeft.Value;
                 * OverrideTextureBack = character.Stats.OverrideTextureBack.Value;
                 * OverrideTextureAttractor = character.Stats.OverrideTextureAttractor.Value;
                 */
                PlayField = character.Playfield.Identity.Instance;

                foreach (int num in character.SocialTab.Keys)
                {
                    socialTab.Add(num, character.SocialTab[num]);
                }

                foreach (AOTextures texture in character.Textures)
                {
                    textures.Add(new AOTextures(texture.place, texture.Texture));
                }

                meshs = MeshLayers.GetMeshs(character, showsocial, socialonly);
            }

            var texturesToSend = new List <Texture>();

            var aotemp = new AOTextures(0, 0);

            for (counter = 0; counter < 5; counter++)
            {
                aotemp.Texture = 0;
                aotemp.place   = counter;
                int c2;
                for (c2 = 0; c2 < textures.Count; c2++)
                {
                    if (textures[c2].place == counter)
                    {
                        aotemp.Texture = textures[c2].Texture;
                        break;
                    }
                }

                if (showsocial)
                {
                    if (socialonly)
                    {
                        aotemp.Texture = socialTab[counter];
                    }
                    else
                    {
                        if (socialTab[counter] != 0)
                        {
                            aotemp.Texture = socialTab[counter];
                        }
                    }
                }

                texturesToSend.Add(new Texture {
                    Place = aotemp.place, Id = aotemp.Texture, Unknown = 0
                });
            }

            message.Textures = texturesToSend.ToArray();

            message.Meshes =
                meshs.Select(
                    mesh =>
                    new Mesh
            {
                Position          = (byte)mesh.Position,
                Id                = (uint)mesh.Mesh,
                OverrideTextureId = mesh.OverrideTexture,
                Layer             = (byte)mesh.Layer
            }).ToArray();
            message.VisualFlags = (short)VisualFlags;

            character.Playfield.Announce(message);
        }
示例#18
0
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        /// <returns>
        /// </returns>
        public static SimpleCharFullUpdateMessage ConstructMessage(Character character)
        {
            // No need to set packet flags here, its all done in the SimpleCharFullUpdateSerializer.cs
            // - Algorithman

            // Character Variables
            bool socialonly;
            bool showsocial;

            int        charPlayfield;
            Coordinate charCoord;
            Identity   charId;
            Quaternion charHeading;

            uint sideValue;
            uint fatValue;
            uint breedValue;
            uint sexValue;
            uint raceValue;

            string charName;
            int    charFlagsValue;
            int    accFlagsValue;

            int expansionValue;
            int currentNano;
            int currentHealth;

            uint strengthBaseValue;
            uint staminaBaseValue;
            uint agilityBaseValue;
            uint senseBaseValue;
            uint intelligenceBaseValue;
            uint psychicBaseValue;

            string firstName;
            string lastName;
            int    orgNameLength;
            string orgName;
            int    levelValue;
            int    healthValue;
            int    losHeight;

            int monsterData;
            int monsterScale;
            int visualFlags;

            int  currentMovementMode;
            uint runSpeedBaseValue;

            int texturesCount;

            int headMeshValue;

            // NPC Values
            int NPCFamily;

            var socialTab = new Dictionary <int, int>();

            var textures = new List <AOTextures>();

            List <AOMeshs> meshs;

            var nanos = new List <AONano>();

            lock (character)
            {
                socialonly = (character.Stats[StatIds.visualflags].Value & 0x40) > 0;
                showsocial = (character.Stats[StatIds.visualflags].Value & 0x20) > 0;

                charPlayfield = character.Playfield.Identity.Instance;
                charCoord     = character.Coordinates();
                charId        = character.Identity;
                charHeading   = character.Heading;

                sideValue  = character.Stats[StatIds.side].BaseValue;
                fatValue   = character.Stats[StatIds.fatness].BaseValue;
                breedValue = character.Stats[StatIds.breed].BaseValue;
                sexValue   = character.Stats[StatIds.sex].BaseValue;
                raceValue  = character.Stats[StatIds.race].BaseValue;

                charName       = character.Name;
                charFlagsValue = character.Stats[StatIds.flags].Value;
                accFlagsValue  = character.Stats[StatIds.accountflags].Value;

                expansionValue = character.Stats[StatIds.expansion].Value;
                currentNano    = character.Stats[StatIds.currentnano].Value;

                strengthBaseValue     = character.Stats[StatIds.strength].BaseValue;
                staminaBaseValue      = character.Stats[StatIds.stamina].BaseValue;
                agilityBaseValue      = character.Stats[StatIds.agility].BaseValue;
                senseBaseValue        = character.Stats[StatIds.sense].BaseValue;
                intelligenceBaseValue = character.Stats[StatIds.intelligence].BaseValue;
                psychicBaseValue      = character.Stats[StatIds.psychic].BaseValue;

                firstName     = character.FirstName;
                lastName      = character.LastName;
                orgNameLength = character.OrganizationName.Length;
                orgName       = character.OrganizationName;
                levelValue    = character.Stats[StatIds.level].Value;
                healthValue   = character.Stats[StatIds.life].Value;

                monsterData  = character.Stats[StatIds.monsterdata].Value;
                monsterScale = character.Stats[StatIds.monsterscale].Value;
                visualFlags  = character.Stats[StatIds.visualflags].Value;

                currentMovementMode = character.Stats[StatIds.currentmovementmode].Value;
                runSpeedBaseValue   = character.Stats[StatIds.runspeed].BaseValue;

                texturesCount = character.Textures.Count;

                headMeshValue = character.Stats[StatIds.headmesh].Value;

                foreach (int num in character.SocialTab.Keys)
                {
                    socialTab.Add(num, character.SocialTab[num]);
                }

                foreach (AOTextures at in character.Textures)
                {
                    textures.Add(new AOTextures(at.place, at.Texture));
                }

                meshs = MeshLayers.GetMeshs(character, showsocial, socialonly);

                foreach (KeyValuePair <int, IActiveNano> kv in character.ActiveNanos)
                {
                    var tempNano = new AONano();
                    tempNano.ID           = kv.Value.ID;
                    tempNano.Instance     = kv.Value.Instance;
                    tempNano.NanoStrain   = kv.Key;
                    tempNano.Nanotype     = kv.Value.Nanotype;
                    tempNano.TickCounter  = kv.Value.TickCounter;
                    tempNano.TickInterval = kv.Value.TickInterval;
                    tempNano.Value3       = kv.Value.Value3;

                    nanos.Add(tempNano);
                }

                losHeight     = character.Stats[StatIds.losheight].Value;
                NPCFamily     = character.Stats[StatIds.npcfamily].Value;
                currentHealth = character.Stats[StatIds.health].Value;
            }

            var scfu = new SimpleCharFullUpdateMessage();

            // affected identity
            scfu.Identity = charId;

            scfu.Version     = 57;            // SCFU packet version (57/0x39)
            scfu.PlayfieldId = charPlayfield; // playfield

            if (character.FightingTarget.Instance != 0)
            {
                scfu.FightingTarget = new Identity
                {
                    Type     = character.FightingTarget.Type,
                    Instance = character.FightingTarget.Instance
                };
            }

            // Coordinates
            scfu.Coordinates = new Vector3 {
                X = charCoord.x, Y = charCoord.y, Z = charCoord.z
            };

            // Heading Data
            scfu.Heading = new SmokeLounge.AOtomation.Messaging.GameData.Quaternion
            {
                W = charHeading.wf,
                X = charHeading.xf,
                Y = charHeading.yf,
                Z = charHeading.zf
            };

            // Race
            scfu.Appearance = new Appearance
            {
                Side    = (Side)sideValue,
                Fatness = (Fatness)fatValue,
                Breed   = (Breed)breedValue,
                Gender  = (Gender)sexValue,
                Race    = raceValue
            };                   // appearance

            // Name
            scfu.Name = charName;

            scfu.CharacterFlags = (CharacterFlags)charFlagsValue; // Flags
            scfu.AccountFlags   = (short)accFlagsValue;
            scfu.Expansions     = (short)expansionValue;

            bool isNpc = (NPCFamily != 1234567890) && (NPCFamily != 0);

            if (isNpc)
            {
                var snpc = new SimpleNpcInfo {
                    Family = (short)NPCFamily, LosHeight = (short)losHeight
                };
                scfu.CharacterInfo = snpc;
            }
            else
            {
                // Are we a player?
                var spc = new SimplePcInfo();

                spc.CurrentNano = (uint)currentNano; // CurrentNano
                spc.Team        = 0;                 // team?
                spc.Swim        = 5;                 // swim?

                // The checks here are to prevent the client doing weird things if the character has really large or small base attributes
                spc.StrengthBase     = (short)Math.Min(strengthBaseValue, short.MaxValue);     // Strength
                spc.AgilityBase      = (short)Math.Min(agilityBaseValue, short.MaxValue);      // Agility
                spc.StaminaBase      = (short)Math.Min(staminaBaseValue, short.MaxValue);      // Stamina
                spc.IntelligenceBase = (short)Math.Min(intelligenceBaseValue, short.MaxValue); // Intelligence
                spc.SenseBase        = (short)Math.Min(senseBaseValue, short.MaxValue);        // Sense
                spc.PsychicBase      = (short)Math.Min(psychicBaseValue, short.MaxValue);      // Psychic

                if (scfu.CharacterFlags.HasFlag(CharacterFlags.HasVisibleName))
                {
                    // has visible names? (Flags)
                    spc.FirstName = firstName;
                    spc.LastName  = lastName;
                }

                if (orgNameLength != 0)
                {
                    spc.OrgName = orgName;
                }

                scfu.CharacterInfo = spc;
            }

            // Level
            scfu.Level = (short)levelValue;

            // Health
            scfu.Health = healthValue;

            scfu.HealthDamage = healthValue - currentHealth;

            // If player is in grid or fixer grid
            // make him/her/it a nice upside down pyramid
            if ((charPlayfield == 152) || (charPlayfield == 4107))
            {
                scfu.MonsterData = 99902;
            }
            else
            {
                scfu.MonsterData = (uint)monsterData; // Monsterdata
            }

            scfu.MonsterScale = (short)monsterScale; // Monsterscale
            scfu.VisualFlags  = (short)visualFlags;  // VisualFlags
            scfu.VisibleTitle = 0;                   // visible title?

            // 42 bytes long
            // For PlayerCharacters that is
            // NPC's have a shorter one?
            scfu.Unknown1 = new byte[]
            {
                0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
                (byte)currentMovementMode, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
                0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00
            };

            // NPC Unknown1
            if ((NPCFamily != 0) && (NPCFamily != 1234567890))
            {
                scfu.Unknown1 = new byte[]
                {
                    // Knubot values??
                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    (byte)currentMovementMode, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
                    0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00
                };
            }

            if (headMeshValue != 0)
            {
                scfu.HeadMesh = (uint?)headMeshValue; // Headmesh
            }

            // Runspeed
            scfu.RunSpeedBase = (short)runSpeedBaseValue;

            scfu.ActiveNanos = (from nano in nanos
                                select
                                new ActiveNano
            {
                NanoId = nano.ID,
                NanoInstance = nano.Instance,
                Time1 = nano.TickCounter,
                Time2 = nano.TickInterval
            }).ToArray();

            // Texture/Cloth Data
            var scfuTextures = new List <Texture>();

            var aotemp = new AOTextures(0, 0);

            for (int c = 0; c < 5; c++)
            {
                aotemp.Texture = 0;
                aotemp.place   = c;
                for (int c2 = 0; c2 < texturesCount; c2++)
                {
                    if (textures[c2].place != c)
                    {
                        continue;
                    }

                    aotemp.Texture = textures[c2].Texture;
                    break;
                }

                if (showsocial)
                {
                    if (socialonly)
                    {
                        aotemp.Texture = socialTab[c];
                    }
                    else
                    {
                        if (socialTab[c] != 0)
                        {
                            aotemp.Texture = socialTab[c];
                        }
                    }
                }

                scfuTextures.Add(new Texture {
                    Place = aotemp.place, Id = aotemp.Texture, Unknown = 0
                });
            }

            scfu.Textures = scfuTextures.ToArray();

            // End Textures

            // ############
            // # Meshs
            // ############
            scfu.Meshes = (from aoMesh in meshs
                           select
                           new Mesh
            {
                Position = (byte)aoMesh.Position,
                Id = (uint)aoMesh.Mesh,
                OverrideTextureId = aoMesh.OverrideTexture,
                Layer = (byte)aoMesh.Layer
            }).ToArray();

            // End Meshs
            scfu.Flags2   = 0; // packetFlags2
            scfu.Unknown2 = 0;

            return(scfu);
        }
示例#19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="character"></param>
        /// <param name="receiver"></param>
        /// <returns></returns>
        public static Byte[] WritePacket(Character character, int receiver)
        {
            /*
             * To set a packetFlag use       packetFlags |= <flagHere>;
             * To unset a packetFlag use     packetFlags &= ~<flagHere>;
             *
             * Wherever you set a flag conditionally, be sure to unset the same flag if the reverse
             * condition is true 'just in case'.
             */
            int packetFlags = 0; // Try setting to 0x042062C8 if you have problems (old value)

            //
            // Character Variables

            bool socialonly;
            bool showsocial;

            /*
             * bool showhelmet;
             * bool LeftPadVisible;
             * bool RightPadVisible;
             * bool DoubleLeftPad;
             * bool DoubleRightPad;
             */

            int        charPlayfield;
            AOCoord    charCoord;
            int        charId;
            Quaternion charHeading;

            uint sideValue;
            uint fatValue;
            uint breedValue;
            uint sexValue;
            uint raceValue;

            int    nameLength;
            string charName;
            int    charFlagsValue;
            int    accFlagsValue;

            int expansionValue;
            int currentNano;
            int currentHealth;

            uint strengthBaseValue;
            uint staminaBaseValue;
            uint agilityBaseValue;
            uint senseBaseValue;
            uint intelligenceBaseValue;
            uint psychicBaseValue;

            int    firstNameLength;
            int    lastNameLength;
            string firstName;
            string lastName;
            int    orgNameLength;
            string orgName;
            int    levelValue;
            int    healthValue;
            int    losHeight;

            int monsterData;
            int monsterScale;
            int visualFlags;

            int  currentMovementMode;
            uint runSpeedBaseValue;

            int texturesCount;

            /*
             * int HairMeshValue;
             * int WeaponMeshRightValue;
             * int WeaponMeshLeftValue;
             *
             * uint HeadMeshBaseValue;
             */
            int headMeshValue;

            /*
             * int BackMeshValue;
             * int ShoulderMeshRightValue;
             */
            //int ShoulderMeshLeftValue;

            /*
             * int OverrideTextureHead;
             * int OverrideTextureWeaponRight;
             * int OverrideTextureWeaponLeft;
             * int OverrideTextureShoulderpadRight;
             * int OverrideTextureShoulderpadLeft;
             * int OverrideTextureBack;
             * int OverrideTextureAttractor;
             */
            //NPC Values

            int NPCFamily;

            Dictionary <int, int> socialTab = new Dictionary <int, int>();

            List <AOTextures> textures = new List <AOTextures>();

            List <AOMeshs> meshs;

            List <AONano> nanos = new List <AONano>();

            lock (character)
            {
                socialonly = ((character.Stats.VisualFlags.Value & 0x40) > 0);
                showsocial = ((character.Stats.VisualFlags.Value & 0x20) > 0);

                /*
                 * showhelmet = ((character.Stats.VisualFlags.Value & 0x4) > 0);
                 * LeftPadVisible = ((character.Stats.VisualFlags.Value & 0x1) > 0);
                 * RightPadVisible = ((character.Stats.VisualFlags.Value & 0x2) > 0);
                 * DoubleLeftPad = ((character.Stats.VisualFlags.Value & 0x8) > 0);
                 * DoubleRightPad = ((character.Stats.VisualFlags.Value & 0x10) > 0);
                 */

                charPlayfield = character.PlayField;
                charCoord     = character.Coordinates;
                charId        = character.Id;
                charHeading   = character.Heading;

                sideValue  = character.Stats.Side.StatBaseValue;
                fatValue   = character.Stats.Fatness.StatBaseValue;
                breedValue = character.Stats.Breed.StatBaseValue;
                sexValue   = character.Stats.Sex.StatBaseValue;
                raceValue  = character.Stats.Race.StatBaseValue;

                nameLength     = character.Name.Length;
                charName       = character.Name;
                charFlagsValue = character.Stats.Flags.Value;
                accFlagsValue  = character.Stats.AccountFlags.Value;

                expansionValue = character.Stats.Expansion.Value;
                currentNano    = character.Stats.CurrentNano.Value;

                strengthBaseValue     = character.Stats.Strength.StatBaseValue;
                staminaBaseValue      = character.Stats.Strength.StatBaseValue;
                agilityBaseValue      = character.Stats.Strength.StatBaseValue;
                senseBaseValue        = character.Stats.Strength.StatBaseValue;
                intelligenceBaseValue = character.Stats.Strength.StatBaseValue;
                psychicBaseValue      = character.Stats.Strength.StatBaseValue;

                firstNameLength = character.FirstName.Length;
                lastNameLength  = character.LastName.Length;
                firstName       = character.FirstName;
                lastName        = character.LastName;
                orgNameLength   = character.OrgName.Length;
                orgName         = character.OrgName;
                levelValue      = character.Stats.Level.Value;
                healthValue     = character.Stats.Life.Value;

                monsterData  = character.Stats.MonsterData.Value;
                monsterScale = character.Stats.MonsterScale.Value;
                visualFlags  = character.Stats.VisualFlags.Value;

                currentMovementMode = character.Stats.CurrentMovementMode.Value;
                runSpeedBaseValue   = character.Stats.RunSpeed.StatBaseValue;

                texturesCount = character.Textures.Count;

                /*
                 * HairMeshValue = character.Stats.HairMesh.Value;
                 * WeaponMeshRightValue = character.Stats.WeaponMeshRight.Value;
                 * WeaponMeshLeftValue = character.Stats.WeaponMeshLeft.Value;
                 *
                 * HeadMeshBaseValue = character.Stats.HeadMesh.StatBaseValue;
                 */
                headMeshValue = character.Stats.HeadMesh.Value;

                /*
                 * BackMeshValue = character.Stats.BackMesh.Value;
                 * ShoulderMeshRightValue = character.Stats.ShoulderMeshRight.Value;
                 */
                //ShoulderMeshLeftValue = character.Stats.ShoulderMeshLeft.Value;

                /*
                 * OverrideTextureHead = character.Stats.OverrideTextureHead.Value;
                 * OverrideTextureWeaponRight = character.Stats.OverrideTextureWeaponRight.Value;
                 * OverrideTextureWeaponLeft = character.Stats.OverrideTextureWeaponLeft.Value;
                 * OverrideTextureShoulderpadRight = character.Stats.OverrideTextureShoulderpadRight.Value;
                 * OverrideTextureShoulderpadLeft = character.Stats.OverrideTextureShoulderpadLeft.Value;
                 * OverrideTextureBack = character.Stats.OverrideTextureBack.Value;
                 * OverrideTextureAttractor = character.Stats.OverrideTextureAttractor.Value;
                 */
                foreach (int num in character.SocialTab.Keys)
                {
                    socialTab.Add(num, character.SocialTab[num]);
                }

                foreach (AOTextures at in character.Textures)
                {
                    textures.Add(new AOTextures(at.place, at.Texture));
                }

                meshs = MeshLayers.GetMeshs(character, showsocial, socialonly);

                foreach (AONano nano in character.ActiveNanos)
                {
                    AONano tempNano = new AONano();
                    tempNano.ID         = nano.ID;
                    tempNano.Instance   = nano.Instance;
                    tempNano.NanoStrain = nano.NanoStrain;
                    tempNano.Nanotype   = nano.Nanotype;
                    tempNano.Time1      = nano.Time1;
                    tempNano.Time2      = nano.Time2;
                    tempNano.Value3     = nano.Value3;

                    nanos.Add(tempNano);
                }

                losHeight     = character.Stats.LosHeight.Value;
                NPCFamily     = character.Stats.NpcFamily.Value;
                currentHealth = character.Stats.Health.Value;
            }
            PacketWriter packetWriter = new PacketWriter();

            // Packet Header
            packetWriter.PushByte(0xDF);
            packetWriter.PushByte(0xDF);
            packetWriter.PushShort(10);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);                // length. writer will take care of this
            packetWriter.PushInt(3086);               // sender. our server ID
            packetWriter.PushInt(receiver);           // receiver
            packetWriter.PushInt(0x271B3A6B);         // packet ID
            packetWriter.PushIdentity(50000, charId); // affected identity
            packetWriter.PushByte(0);                 // Unknown?
            // End Packet Header

            packetWriter.PushByte(57);           // SCFU packet version (57/0x39)
            packetWriter.PushInt(0);             // packet flags (this is set later based on packetFlags variable above)

            packetFlags |= 0x40;                 // Has Playfield ID
            packetWriter.PushInt(charPlayfield); // playfield

            if (character.FightingTarget.Instance != 0)
            {
                packetFlags |= 20;
                packetWriter.PushIdentity(character.FightingTarget);
            }

            // Coordinates
            packetWriter.PushCoord(charCoord);

            // Heading Data
            packetFlags |= 0x200; // Has Heading Data Flag
            packetWriter.PushQuat(charHeading);

            uint appearance = sideValue + (fatValue * 8) + (breedValue * 32) + (sexValue * 256) + (raceValue * 1024);

            // Race
            packetWriter.PushUInt(appearance); // appearance

            // Name
            packetWriter.PushByte((byte)(nameLength + 1));
            packetWriter.PushBytes(Encoding.ASCII.GetBytes(charName));
            packetWriter.PushByte(0);              // 0 terminator for name

            packetWriter.PushUInt(charFlagsValue); // Flags
            packetWriter.PushShort((short)accFlagsValue);
            packetWriter.PushShort((short)expansionValue);

            if (character is NonPlayerCharacterClass)
            {
                packetFlags |= 1;
            }

            packetFlags &= ~0x01; // We are a player
            if ((packetFlags & 0x01) != 0)
            {
                // Are we a NPC (i think anyway)? So far this is _NOT_ used at all

                if (NPCFamily < 256)
                {
                    packetWriter.PushByte((byte)NPCFamily);
                }
                else
                {
                    packetFlags |= 0x20000;
                    packetWriter.PushShort((Int16)NPCFamily);
                }

                if (losHeight < 256)
                {
                    packetWriter.PushByte((byte)losHeight);
                }
                else
                {
                    packetFlags |= 0x80000;
                    packetWriter.PushShort((Int16)losHeight);
                }

                //if (packetFlags & 0x2000000)
                //{
                //    char PetType;
                //}
                //else
                //{
                //    short PetType;
                //}

                //short TowerType;

                //if (TowerType > 0)
                //{
                //    char unknown;
                //}
            }
            else
            {
                // Are we a player?
                packetWriter.PushUInt(currentNano); // CurrentNano
                packetWriter.PushInt(0);            // team?
                packetWriter.PushShort(5);          // swim?

                // The checks here are to prevent the client doing weird things if the character has really large or small base attributes
                if (strengthBaseValue > 32767) // Strength
                {
                    packetWriter.PushShort(32767);
                }
                else
                {
                    packetWriter.PushShort((short)strengthBaseValue);
                }
                if (agilityBaseValue > 32767) // Agility
                {
                    packetWriter.PushShort(32767);
                }
                else
                {
                    packetWriter.PushShort((short)agilityBaseValue);
                }
                if (staminaBaseValue > 32767) //  Stamina
                {
                    packetWriter.PushShort(32767);
                }
                else
                {
                    packetWriter.PushShort((short)staminaBaseValue);
                }
                if (intelligenceBaseValue > 32767) // Intelligence
                {
                    packetWriter.PushShort(32767);
                }
                else
                {
                    packetWriter.PushShort((short)intelligenceBaseValue);
                }
                if (senseBaseValue > 32767) // Sense
                {
                    packetWriter.PushShort(32767);
                }
                else
                {
                    packetWriter.PushShort((short)senseBaseValue);
                }
                if (psychicBaseValue > 32767) // Psychic
                {
                    packetWriter.PushShort(32767);
                }
                else
                {
                    packetWriter.PushShort((short)psychicBaseValue);
                }

                if ((charFlagsValue & 0x400000) != 0) // has visible names? (Flags)
                {
                    packetWriter.PushShort((short)firstNameLength);
                    packetWriter.PushBytes(Encoding.ASCII.GetBytes(firstName));
                    packetWriter.PushShort((short)lastNameLength);
                    packetWriter.PushBytes(Encoding.ASCII.GetBytes(lastName));
                }

                if (orgNameLength != 0)
                {
                    packetFlags |= 0x4000000; // Has org name data

                    packetWriter.PushShort((short)orgNameLength);
                    packetWriter.PushBytes(Encoding.ASCII.GetBytes(orgName));
                }
                else
                {
                    packetFlags &= ~0x4000000; // Does not have org name data
                }
            }

            if (levelValue > 127)      // Level
            {
                packetFlags |= 0x1000; // Has Extended Level
                packetWriter.PushShort((short)levelValue);
            }
            else
            {
                packetFlags &= ~0x1000; // Has Small Level
                packetWriter.PushByte((byte)levelValue);
            }

            if (healthValue > 32767)   // Health
            {
                packetFlags &= ~0x800; // Has Extended Health
                packetWriter.PushUInt(healthValue);
            }
            else
            {
                packetFlags |= 0x800; // Has Small Health
                packetWriter.PushShort((short)healthValue);
            }
            int healthdamage = healthValue - currentHealth;

            if (healthdamage < 256)
            {
                packetFlags |= 0x4000;
                packetWriter.PushByte((byte)healthdamage);
            }
            else
            {
                packetFlags &= ~0x4000;
                if ((packetFlags & 0x800) == 0x800)
                {
                    packetWriter.PushShort((Int16)healthdamage);
                }
                else
                {
                    packetWriter.PushInt(healthdamage);
                }
            }

            // If player is in grid or fixer grid
            // make him/her/it a nice upside down pyramid
            if ((charPlayfield == 152) || (charPlayfield == 4107))
            {
                packetWriter.PushInt(99902);
            }
            else
            {
                packetWriter.PushUInt(monsterData);      // Monsterdata
            }
            packetWriter.PushShort((short)monsterScale); // Monsterscale
            packetWriter.PushShort((short)visualFlags);  // VisualFlags
            packetWriter.PushByte(0);                    // visible title?

            packetWriter.PushInt(42);                    // 'skipdata' length
            // Start 'skipdata'
            packetWriter.PushBytes(
                new Byte[] { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00 });
            packetWriter.PushByte((byte)currentMovementMode); // CurrentMovementMode
            packetWriter.PushByte(1);                         // don't change
            packetWriter.PushShort(1);                        // ?
            packetWriter.PushShort(1);                        // ?
            packetWriter.PushShort(1);                        // ?
            packetWriter.PushShort(1);                        // ?
            packetWriter.PushShort(0);                        // ?
            packetWriter.PushShort(3);                        // ?
            packetWriter.PushInt(0);                          //?
            packetWriter.PushInt(0);                          //?
            packetWriter.PushInt(0);                          //?
            packetWriter.PushInt(0);                          //?
            // End 'skipdata'

            if (headMeshValue != 0)
            {
                packetFlags |= 0x80;                  // Has HeadMesh Flag
                packetWriter.PushUInt(headMeshValue); // Headmesh
            }

            if ((runSpeedBaseValue > 127)) // Runspeed
            {
                packetFlags |= 0x2000;
                packetWriter.PushShort((short)runSpeedBaseValue);
            }
            else
            {
                packetFlags &= ~0x2000;
                packetWriter.PushByte((byte)runSpeedBaseValue);
            }

            //if (packetFlags & 0x400)
            //{
            //    // Pop2Long
            //    /*
            //     * Is this a Type:Instance pair?
            //     * Suspect so as it uses Pop2Long
            //     * which is used for Type:Instance
            //     * pairs. Perhaps pet master?
            //     * (Just a wild guess though that its pet master)
            //     */
            //    long unknown;
            //    long unknown;
            //}

            //if (packetFlags & 0x10)
            //{
            //    long counter;
            //    repeat (counter / 0x3F1 - 1) times
            //        char texturepositionname[32]; // Null padded at the end
            //        long textureid; // Or is this mesh id?
            //        long unknown;
            //        long unknown;
            //    end repeat
            //}

            // Is char/NPC in hide mode?
            //if (packetFlags & 0x100000)
            //{
            //    short Concealment;
            //}

            //if (packetFlags & 0x800000)
            //{
            //    char unknown;
            //}

            //if (packetFlags & 0x1000000)
            //{
            //    char unknown;
            //}

            packetWriter.Push3F1Count(nanos.Count); // running nanos count
            foreach (AONano nano in nanos)
            {
                packetWriter.PushInt(nano.ID);
                packetWriter.PushInt(nano.Instance);
                packetWriter.PushInt(nano.Time1);
                packetWriter.PushInt(nano.Time2);
            }
            // longx5: aoid, instance, unknown(0?), timer1, timer2

            //if (flags & 0x10000)
            //{
            //    // Waypoint Info
            //    // Pop2Long (1010E2D3)
            //    long type;
            //    long instance;
            //    // Waypoint Counter - 3x float per entry
            //    long counter;
            //    repeat counter times
            //        float x;
            //        float y;
            //        float z;
            //    end repeat
            //    // End Waypoint Counter
            //}

            // Texture/Cloth Data
            int c;

            packetWriter.Push3F1Count(5); // textures count

            AOTextures aotemp = new AOTextures(0, 0);

            for (c = 0; c < 5; c++)
            {
                aotemp.Texture = 0;
                aotemp.place   = c;
                int c2;
                for (c2 = 0; c2 < texturesCount; c2++)
                {
                    if (textures[c2].place == c)
                    {
                        aotemp.Texture = textures[c2].Texture;
                        break;
                    }
                }
                if (showsocial)
                {
                    if (socialonly)
                    {
                        aotemp.Texture = socialTab[c];
                    }
                    else
                    {
                        if (socialTab[c] != 0)
                        {
                            aotemp.Texture = socialTab[c];
                        }
                    }
                }

                packetWriter.PushInt(aotemp.place);
                packetWriter.PushInt(aotemp.Texture);
                packetWriter.PushInt(0);
            }
            // End Textures

            // ############
            // # Meshs
            // ############

            c = meshs.Count;

            packetWriter.Push3F1Count(c);
            foreach (AOMeshs aoMeshs in meshs)
            {
                packetWriter.PushByte((byte)aoMeshs.Position);
                packetWriter.PushUInt(aoMeshs.Mesh);
                packetWriter.PushInt(aoMeshs.OverrideTexture); // Override Texture!!!!!!
                packetWriter.PushByte((byte)aoMeshs.Layer);
            }
            // End Meshs

            //if (packetFlags & 0x100)
            //{
            //    // 0x3F1 Unknown Counter - 4x long per entry
            //    long counter;
            //    repeat (counter / 0x3F1 - 1) times
            //        long unknown;
            //        long unknown;
            //        long unknown;
            //        long unknown;
            //    end repeat
            //}

            //if (packetFlags & 0x20000000)
            //{
            //    char ShadowBreed;
            //}

            //if (packetFlags & 0x40000000)
            //{
            //    // 0x3F1 Unknown Counter - 4x long per entry
            //    long counter;
            //    repeat (counter / 0x3F1 - 1) times
            //        Pop2Long (Type:Instance pair maybe?)
            //        long unknown;
            //        long unknown;
            //    end repeat
            //}

            packetWriter.PushInt(0); // packetFlags2

            // Some mech stuff
            //if (packetFlags2 & 0x01)
            //{
            //    long counter;
            //    repeat (counter) times
            //        long unknown;
            //        long unknown;
            //    end repeat

            //    long MechData;
            //    // Pop2Long (Type:Instance pair maybe?)
            //    long unknown;
            //    long unknown;
            //}

            // maybe check if we are in battlestation
            //if (packetFlags2 & 0x02)
            //{
            //    char BattleStationSide;
            //}

            // Are we a pet?
            //if (packetFlags2 & 0x04)
            //{
            //    long PetMaster;
            //}

            packetWriter.PushByte(0);

            Byte[] reply = packetWriter.Finish();

            // Set Packet Flags
            Byte[] packetFlagBytes;
            packetFlagBytes = BitConverter.GetBytes(packetFlags);
            Array.Reverse(packetFlagBytes);
            reply[30] = packetFlagBytes[0];
            reply[31] = packetFlagBytes[1];
            reply[32] = packetFlagBytes[2];
            reply[33] = packetFlagBytes[3];

            return(reply);
        }