originalItem.GetEquipmentLevel().bonus.useCustomBonus = true;
originalItem.GetEquipmentLevel().bonus.custom = new StatusBonusSetting();
originalItem.GetEquipmentLevel().bonus.custom.statusBonus = new StatusValueBonus[selectedAffixes.Count];
int randomIndex = Random.Range(0, selectedAffixes.Count - 1);
Affix mainAffix = selectedAffixes[randomIndex];
StatusValueBonus mainSVBonus = new StatusValueBonus();
mainSVBonus.status.SetAsset(ORK.StatusValues.GetAsset(mainAffix.statusValueIndex));
mainSVBonus.bonus = Random.Range((int)mainAffix.m_RandomBonusValueMin, (int)mainAffix.m_RandomBonusValueMax);
mainSVBonus.bonusPercent = 0.0f;
originalItem.GetEquipmentLevel().bonus.custom.statusBonus[0] = mainSVBonus;
It looks like you're new here. If you want to get involved, click one of these buttons!
You can add status value bonuses directly to the instance of an equipment, which is saved with save games. An instance of an equipment uses the EquipShortcut class, and the init schematic has the equipment available as selected data via the key action.
There's even a node to change status value bonuses, the Change Equp Status Value node.
If you want to do it via scripting, the EquipShortcut class has the StatusValue property for this (int array that simply holds the status value bonuses).
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
The loot logic is a bit complicated so I decided to do it via scripting.
After a quick test, bonus values set to the StatusValue property can be saved, but only for the status changes in value. What if the bonus is a percentage? We don't know which combatant will equip the equipment so I can't calculate the bonus value and set it to the StatusValue property of EquipShortcut in the init schematic.
I can store all the bonuses info(status index, value/percentage) in equipment variables, and calculate the percentage bonuses every time a combatant selects the equipment in the Inventory menu, then set the calculated values to the StatusValue property, is this the right way to do it?
Alternatively, you could create a status effect that uses equipment variables to calculate bonuses and add that to each combatant.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Loot the equipment and give random bonuses, upgrade the equipment will increase the main status bonus value and unlock new extra bonuses.