How to Use ItemSetGroup / ItemSetRule to Change the Active ItemSetRules at Runtime?

airoll

Member
I have a use case where depending on what items that the character has equipped, I want to change what item set rules are active.

  1. Specifically, if the character only has a shield equipped, it can equip the shield without a weapon. I have this defined as ShieldItemSetRule.
  2. Or if the character has a weapon and a shield, it can equip both the weapon and the shield. I have this defined as WeaponShieldItemSetRule.
At runtime, I want to be able to activate or deactivate these item set rules. However, reading through the documentation for item set rules here, I'm unclear on the best way to do this. I want to achieve the following:
  1. By default, the character has a single item set group with WeaponShieldItemSetRule as the single item set rule.
  2. When the character spawns for the first time, it checks the weapon loadout. If there's no weapon, then we want to activate ShieldItemSetRule. My initial thought was to simply add the item set rule using
    Code:
    m_ItemSetGroup.AddItemSetRule(itemSetRule);
  3. Then, when the character picks up a weapon for the first time, I want to disable the ShieldItemSetRule so that the character must equip a weapon. Do I do this by calling
    Code:
    m_ItemSetGroup.RemoveItemSetRule(itemSetRule);
    Would that remove the item sets that were previously created by ShieldItemSetRule?
Looking at the ItemSetManager, there's also the concept of ItemSetGroups. What is the logical purpose of ItemSetGroups? Could I use those to also achieve what I'm looking to do?
 
I think that you have a good overall approach. When an item is equipped there must be at least one Item Set Rule active so you'll want to make sure you switch weapons before removing all of the previous rules. Item Set Groups are normally used for different category of weapons, such as right hand grenades versus magic items, but I could see it also working for you here. You'd have an active group and then when you are ready to switch you add a new staging group. As soon as you equip the new item the staging group becomes the active group and remove the previous active group.
 
Top