コード例 #1
0
        private void pasteLegendaryIdButton_Click(object sender, EventArgs e)
        {
            if (activeSaveFile.GetItemStatData(activeItem) == null)
            {
                if (MessageBox.Show("Item has no stat data. Fallback to old method?", "Notice", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    modsBaseIdBox.Text = ((ulong)88400986533).ToString();
                }
            }
            else
            {
                var foundQualityStat = false;
                foreach (Handle <GameStatModifierData> modifier in activeSaveFile.GetItemStatData(activeItem).StatModifiers)
                {
                    if (modifier.Value.GetType().Name == "GameConstantStatModifierData")
                    {
                        if (((GameConstantStatModifierData)modifier.Value).StatType == gamedataStatType.Quality)
                        {
                            ((GameConstantStatModifierData)modifier.Value).Value = 4;
                            foundQualityStat = true;
                        }
                    }
                }

                if (!foundQualityStat)
                {
                    var newModifierData = new GameConstantStatModifierData();
                    newModifierData.ModifierType = gameStatModifierType.Additive;
                    newModifierData.StatType     = gamedataStatType.Quality;
                    newModifierData.Value        = 4;

                    var newModifier = activeSaveFile.GetStatsContainer().CreateHandle <GameStatModifierData>(newModifierData);
                    activeSaveFile.GetItemStatData(activeItem).StatModifiers = activeSaveFile.GetItemStatData(activeItem).StatModifiers.Append(newModifier).ToArray();
                }

                ReloadData();
                MessageBox.Show("Legendary quality stat applied.");
            }
        }