Exemple #1
0
        /* fired when item combo box is changed*/
        private void itemBoxChanged(object sender, EventArgs e)
        {
            unBindEvents();

            Data.Character character   = (Data.Character)unitList.SelectedItem;
            Data.Item      currentItem = (Data.Item)cbItem.SelectedItem;
            byte[]         itemHex     = hexToBytes(currentItem.Hex);
            byte[]         itemID      = hexToBytes(currentItem.ItemID);
            byte[]         itemMiddleHex;
            if (currentItem.isDLC)
            {
                itemMiddleHex = hexToBytes("010008");                    //I see this pattern if its a dlc
            }
            else
            {
                itemMiddleHex = hexToBytes("000000");                                  //default value, no forges, etc.
            }
            IEnumerable <byte> itemVal = itemID.Concat(itemMiddleHex).Concat(itemHex); //combine the bytes to form 12 bytes of item value
            int start = character.ItemAddress + 2;

            foreach (byte b in itemVal)
            {
                _saveFile[start] = b; //insert the new value in file
                start++;
            }

            updateForgeBox(currentItem.MaxForges); //disable/enable forge box depending on current item

            bindEvents();
        }
Exemple #2
0
        /* updates the numeric updowns based on character's current stat*/
        private void updateStatBox()
        {
            Data.Character character   = (Data.Character)unitList.SelectedItem;
            int            level       = _saveFile[character.StartAddress - 2]; //level offset 2 bytes before character id
            int            exp         = _saveFile[character.StartAddress - 1]; //exp offset 1 byte before character id
            int            statAddress = character.StartAddress + 21;           //character stats offset 21 bytes after character id
            int            counter     = -2;

            foreach (IntegerUpDown iUD in upDwnBoxes)
            {
                if (counter == -2)
                {
                    iUD.Value = level;
                }
                else if (counter == -1)
                {
                    iUD.Value = exp;
                }
                else
                {
                    //calculates stat using character base and value from save file
                    //character stats = value from save file + base stats
                    iUD.Minimum = character.BaseStats[counter];
                    iUD.Maximum = character.MaxStats[counter];
                    iUD.Value   = _saveFile[statAddress + counter] + character.BaseStats[counter];
                }
                counter++;
            }
        }
Exemple #3
0
        /* updates class box based on selected character*/
        private void updateClassBox()
        {
            cbClass.IsHitTestVisible = true;
            Data.Character character = (Data.Character)unitList.SelectedItem;
            string         classHex  = getBytesValue(character.StartAddress + 8, 8);

            cbClass.SelectedValue = classHex;
        }
Exemple #4
0
        /* fired when forge combo box changed */
        private void forgeBoxChanged(object sender, EventArgs e)
        {
            unBindEvents();

            Data.Character character = (Data.Character)unitList.SelectedItem;
            byte           forgeVal  = Convert.ToByte(cbForge.SelectedItem.ToString(), 16); //get the value changed
            byte           val       = _saveFile[character.ItemAddress + 5];                //forge offset 5 after 02 01, the leftmost 4 bits only

            val = (byte)(val & 0x0F);                                                       //clear leftmost 4 bits
            val = (byte)(val | (forgeVal << 4));                                            //add the new value to leftmost 4 bits
            _saveFile[character.ItemAddress + 5] = val;

            bindEvents();
        }
Exemple #5
0
        private void classChanged(object sender, EventArgs e)
        {
            unBindEvents();

            Data.Character      character = (Data.Character)unitList.SelectedItem;
            Data.CharacterClass cc        = (Data.CharacterClass)cbClass.SelectedItem;
            byte[] classVal = hexToBytes(cc.ClassID);
            int    index    = character.StartAddress + 8;

            foreach (byte b in classVal)
            {
                _saveFile[index] = b; //insert new value of class into save file
                index++;
            }

            bindEvents();
        }
Exemple #6
0
        private void statChanged(object sender, EventArgs e)
        {
            unBindEvents();

            Data.Character character = (Data.Character)unitList.SelectedItem;
            IntegerUpDown  statBox   = (IntegerUpDown)sender;             //get the control that fired the event

            Enum.Stat stat = XMLProperties.StatProperty.GetStat(statBox); //get value of attached property

            if (stat == Enum.Stat.Level || stat == Enum.Stat.Experience)
            {
                _saveFile[character.StartAddress + (int)stat] = (byte)statBox.Value; //update exp or level based on current value
            }
            else
            {
                // new value is the character base stats subtracted from current value
                // because the value in save file is just the values to be added to the base stat
                byte newVal = (byte)(statBox.Value - character.BaseStats[(int)stat]);
                _saveFile[character.StartAddress + 21 + (int)stat] = newVal;
            }

            bindEvents();
        }