Beispiel #1
0
        public void Read(BitStream stream)
        {
            stream.Read(out this.id);
            stream.Read(out this.name);

            ulong param = 0;

            BitStreamExtension.Read(stream, out param);
            //stream.Read(out param);
            ItemInstanceParameters paramI = (ItemInstanceParameters)param;

            if (paramI.HasFlag(ItemInstanceParameters.scemeName))
            {
                stream.Read(out this.scemeName);
            }
            for (int i = 0; i < 8; i++)
            {
                if (paramI.HasFlag((ItemInstanceParameters)((ulong)ItemInstanceParameters.protection0 << i)))
                {
                    stream.Read(out protection[i]);
                }
            }
            if (paramI.HasFlag(ItemInstanceParameters.damageType))
            {
                byte dT = 0;
                stream.Read(out dT);
                DamageType = (Enumeration.DamageTypes)dT;
            }
            if (paramI.HasFlag(ItemInstanceParameters.totalDamage))
            {
                stream.Read(out this.totalDamage);
            }
            for (int i = 0; i < 8; i++)
            {
                if (paramI.HasFlag((ItemInstanceParameters)((ulong)ItemInstanceParameters.damages0 << i)))
                {
                    stream.Read(out damages[i]);
                }
            }

            if (paramI.HasFlag(ItemInstanceParameters.range))
            {
                stream.Read(out this.range);
            }

            for (int i = 0; i < conditionAttributes.Length; i++)
            {
                if (paramI.HasFlag((ItemInstanceParameters)((ulong)ItemInstanceParameters.conditionAttributes0 << i)))
                {
                    stream.Read(out conditionAttributes[i]);
                }
            }
            for (int i = 0; i < conditionValues.Length; i++)
            {
                if (paramI.HasFlag((ItemInstanceParameters)((ulong)ItemInstanceParameters.conditionValues0 << i)))
                {
                    stream.Read(out conditionValues[i]);
                }
            }

            if (paramI.HasFlag(ItemInstanceParameters.value))
            {
                stream.Read(out this.value);
            }

            if (paramI.HasFlag(ItemInstanceParameters.mainFlags))
            {
                int dT = 0;
                stream.Read(out dT);
                MainFlags = (Enumeration.MainFlags)dT;
            }

            if (paramI.HasFlag(ItemInstanceParameters.flags))
            {
                int dT = 0;
                stream.Read(out dT);
                Flags = (Enumeration.Flags)dT;
            }

            if (paramI.HasFlag(ItemInstanceParameters.wear))
            {
                byte dT = 0;
                stream.Read(out dT);
                Wear = (Enumeration.ArmorFlags)dT;
            }

            if (paramI.HasFlag(ItemInstanceParameters.materials))
            {
                byte dT = 0;
                stream.Read(out dT);
                Materials = (Enumeration.MaterialType)dT;
            }

            if (paramI.HasFlag(ItemInstanceParameters.description))
            {
                stream.Read(out this.description);
            }


            for (int i = 0; i < text.Length; i++)
            {
                if (paramI.HasFlag((ItemInstanceParameters)((ulong)ItemInstanceParameters.text0 << i)))
                {
                    stream.Read(out text[i]);
                }
            }
            for (int i = 0; i < count.Length; i++)
            {
                if (paramI.HasFlag((ItemInstanceParameters)((ulong)ItemInstanceParameters.count0 << i)))
                {
                    stream.Read(out count[i]);
                }
            }

            if (paramI.HasFlag(ItemInstanceParameters.visual))
            {
                stream.Read(out this.visual);
            }
            if (paramI.HasFlag(ItemInstanceParameters.visual_Change))
            {
                stream.Read(out this.visual_Change);
            }
            if (paramI.HasFlag(ItemInstanceParameters.effect))
            {
                stream.Read(out this.effect);
            }

            if (paramI.HasFlag(ItemInstanceParameters.visual_skin))
            {
                stream.Read(out this.visual_skin);
            }
            if (paramI.HasFlag(ItemInstanceParameters.munition))
            {
                int iiID = 0;
                stream.Read(out iiID);
                this.munition = ItemInstance.ItemInstanceDict[iiID];
            }
            if (paramI.HasFlag(ItemInstanceParameters.isKeyInstance))
            {
                stream.Read(out isKeyInstance);

                if (isKeyInstance)
                {
                    String instanceString = "ITGUC_" + ID;
                    char[] cArr           = instanceString.ToCharArray();
                    byte[] i = new byte[13];
                    Process.ThisProcess().Write(i, 0x008B7CB0);

                    System.Text.Encoding enc = System.Text.Encoding.Default;
                    byte[] arr = enc.GetBytes(instanceString);
                    Process.ThisProcess().Write(arr, 0x008B7CB0);
                }
            }

            if (paramI.HasFlag(ItemInstanceParameters.Spell))
            {
                int spellID = 0;
                stream.Read(out spellID);

                Spell spell = null;
                Spell.SpellDict.TryGetValue(spellID, out spell);

                if (spell == null)
                {
                    throw new Exception("Spell was not found: " + spellID);
                }
                this.Spell = spell;
            }

            if (paramI.HasFlag(ItemInstanceParameters.isTorch))
            {
                stream.Read(out isTorch);

                if (isTorch)
                {
                    String instanceString = "ITGUC_" + ID;

                    if ("ITLSTORCH".Length < instanceString.Length)
                    {
                        throw new Exception("Instance-String is to long: " + instanceString);
                    }

                    char[] cArr = instanceString.ToCharArray();
                    byte[] i    = new byte["ITLSTORCH".Length];
                    Process.ThisProcess().Write(i, 0x008B7144);

                    System.Text.Encoding enc = System.Text.Encoding.Default;
                    byte[] arr = enc.GetBytes(instanceString);
                    Process.ThisProcess().Write(arr, 0x008B7144);
                }
            }

            if (paramI.HasFlag(ItemInstanceParameters.isTorchBurning))
            {
                stream.Read(out isTorchBurning);

                if (isTorchBurning)
                {
                    String instanceString = "ITGUC_" + ID;

                    if ("ITLSTORCHBURNING".Length < instanceString.Length)
                    {
                        throw new Exception("Instance-String is to long: " + instanceString);
                    }
                    char[] cArr = instanceString.ToCharArray();
                    byte[] i    = new byte["ITLSTORCHBURNING".Length];
                    Process.ThisProcess().Write(i, 0x008B2AD8);

                    System.Text.Encoding enc = System.Text.Encoding.Default;
                    byte[] arr = enc.GetBytes(instanceString);
                    Process.ThisProcess().Write(arr, 0x008B2AD8);
                }
            }

            if (paramI.HasFlag(ItemInstanceParameters.isTorchBurned))
            {
                stream.Read(out isTorchBurned);

                if (isTorchBurned)
                {
                    String instanceString = "ITGUC_" + ID;

                    if ("ITLSTORCHBURNED".Length < instanceString.Length)
                    {
                        throw new Exception("Instance-String is to long: " + instanceString);
                    }

                    char[] cArr = instanceString.ToCharArray();
                    byte[] i    = new byte["ITLSTORCHBURNED".Length];
                    Process.ThisProcess().Write(i, 0x008B1228);

                    System.Text.Encoding enc = System.Text.Encoding.Default;
                    byte[] arr = enc.GetBytes(instanceString);
                    Process.ThisProcess().Write(arr, 0x008B1228);
                }
            }

            if (paramI.HasFlag(ItemInstanceParameters.isGold))
            {
                stream.Read(out isGold);

                if (isGold)
                {
                    String instanceString = "ITGUC_" + ID;

                    if ("ITMI_GOLD".Length < instanceString.Length)
                    {
                        throw new Exception("Instance-String is to long: " + instanceString);
                    }

                    char[] cArr = instanceString.ToCharArray();
                    byte[] i    = new byte["ITMI_GOLD".Length];
                    Process.ThisProcess().Write(i, 0x008B6D84);

                    System.Text.Encoding enc = System.Text.Encoding.Default;
                    byte[] arr = enc.GetBytes(instanceString);
                    Process.ThisProcess().Write(arr, 0x008B6D84);
                }
            }
        }
        public void Read(BitStream stream)
        {
            stream.Read(out this.id);
            stream.Read(out this.Name);
            stream.Read(out this.FXName);
            stream.Read(out this.AniName);

            int chargeCount = 0;

            stream.Read(out chargeCount);
            this.processMana = new int[chargeCount];
            for (int i = 0; i < chargeCount; i++)
            {
                stream.Read(out processMana[i]);
            }

            ushort param = 0;

            BitStreamExtension.Read(stream, out param);
            SpellParameters paramI = (SpellParameters)param;

            if (paramI.HasFlag(SpellParameters.TimePerMana))
            {
                stream.Read(out this.TimePerMana);
            }
            if (paramI.HasFlag(SpellParameters.DamagePerLevel))
            {
                stream.Read(out this.DamagePerLevel);
            }
            if (paramI.HasFlag(SpellParameters.DamageType))
            {
                byte dt = 0;
                stream.Read(out dt);
                DamageType = (DamageTypes)dt;
            }
            if (paramI.HasFlag(SpellParameters.SpellType))
            {
                byte dt = 0;
                stream.Read(out dt);
                SpellType = (SPELL_TYPE)dt;
            }
            if (paramI.HasFlag(SpellParameters.CanTurnDuringInvest))
            {
                stream.Read(out this.CanTurnDuringInvest);
            }
            if (paramI.HasFlag(SpellParameters.CanChangeTargetDuringInvest))
            {
                stream.Read(out this.CanChangeTargetDuringInvest);
            }
            if (paramI.HasFlag(SpellParameters.isMultiEffect))
            {
                stream.Read(out this.isMultiEffect);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectionAlgo))
            {
                byte dt = 0;
                stream.Read(out dt);
                TargetCollectionAlgo = (SPELL_TARGET_COLLECT)dt;
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectType))
            {
                byte dt = 0;
                stream.Read(out dt);
                TargetCollectType = (SPELL_TARGET_TYPES)dt;
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectRange))
            {
                stream.Read(out this.TargetCollectRange);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectAzi))
            {
                stream.Read(out this.TargetCollectAzi);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectElev))
            {
                stream.Read(out this.TargetCollectElev);
            }
        }