edited June 13 in ORK Scripting
Hi,
I'm working on a loot system like Diablo. The settings of an equipment can be used as template and will spawn a lot of equipments with the same settings(name,prefab,description) but different status value bonuses.
In the equipment's init schematic, I use a custom node to give the equipment random prefixes and suffixes. The prefixes/suffixes are random and they are picked up in a list of scriptable object assets.

Some prefixes/suffixes will give status value bonus to the equipment.
My problem is, that the status value bonus can be added at runtime(via script, not ORK editor), but can not be saved. They disappeared after loading the saved game.

Here is my code:


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;
Post edited by bitmore on
  • Well, yeah, you try to change the settings of the equipment, which isn't saved with save games.

    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).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thanks for your reply.
    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?
  • That could be a way to solve it - though loading the game doesn't cause any schematic execution.

    Alternatively, you could create a status effect that uses equipment variables to calculate bonuses and add that to each combatant.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thanks for your help! It works as expected.

    Loot the equipment and give random bonuses, upgrade the equipment will increase the main status bonus value and unlock new extra bonuses.
    upgrade
Sign In or Register to comment.