Hello,

I'm currently using ORK Framework 3.19.0 and Makinom 2.17.0 for Unity. I want to write a script that searches for all members within the active group who have a specific `StatusEffect` applied to them.

Here is what I'm trying to achieve:
1. Iterate through the ActiveGroup members.
2. Check if a member has a specific `StatusEffect` (e.g., "SetDeck-BTL").
3. Display or return a list of all members with that `StatusEffect`.

I have attempted the following code, but I'm encountering issues:
```csharp
var activeGroup = ORK.Game.ActiveGroup.GetGroup();
foreach (var combatant in activeGroup)
{
if (combatant.StatusEffects.HasEffect("SetDeck-BTL")) // Example usage
{
Debug.Log($"{combatant.GetName()} has the SetDeck-BTL StatusEffect.");
}
}
  • Status effects are handled in a sub-part of the combatant: combatant.Status.Effects

    E.g. you can check if an effect is applied like this:
    if(combatant.Status.Effects.IsApplied(effectSettings))

    effectSettings is the StatusEffectSettings class of the effect you want to check for.
    You can e.g. get it from ORK.StatusEffects via the index or GUID of the effect, e.g. in total like this:
    if(combatant.Status.Effects.IsApplied(ORK.StatusEffects.Get("GUID")))

    Since all data is stored in separate assets, you can also use a status effect asset and get the settings from it, e.g. if your script has a field for the StatusEffectAsset named effectAsset:
    if(combatant.Status.Effects.IsApplied(this.effectAsset.Settings))
    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!
  • I now understand combatant.Status.Effects!
    Thanks for your answer!
  • edited January 14
    Thank you for your response regarding checking if a StatusEffect is applied. Using the IsApplied method, I was able to correctly identify characters with the effect. I now want to take this one step further.

    My goal is to ensure that a specific StatusEffect can only be applied to one character at a time. To achieve this:

    I want to add the effect to the selected character.
    At the same time, I want to remove the same effect from all other characters in the active group.
    Here is my current implementation for removing the effect:


    foreach (var combatant in ORK.Game.ActiveGroup.GetGroup())
    {
    if (combatant != null && combatant.Status.Effects.IsApplied(statusEffect))
    {
    combatant.Status.Effects.Remove(statusEffect, true);
    Debug.Log($"Status effect '{statusEffect.GetName()}' removed from {combatant.GetName()}.");
    }
    }


    However, I'm encountering the following error:
    Argument 2: Cannot convert from 'bool' to 'expected_type'.

    It seems I may have misunderstood the purpose of the second argument in the Remove method. Could you clarify the correct usage of this method? Specifically:

    What should I pass as the second argument for Remove?
    How can I ensure that the StatusEffect is properly removed from all characters except the selected one?
    Is there an alternative or better approach to enforce this "one-character-only" restriction for the effect?
    Thank you again for your assistance!
    Post edited by shinanoishiguro2 on
  • I would be happy if you could confirm the above questions!
  • edited January 17
    You'll need to change it to match the called function's parameters:
    combatant.Status.Effects.Remove(statusEffect, true, null);
    You need to check if the combatant is the original combatant the effect was applied to and not remove it in that case. Since I don't know how you call your code I can't really tell how, though.

    Also, you can handle this using schematics in your effects. E.g. on Apply status change, execute a schematic. The schematic can get all combatants from the target's group (Select Combatant node) and remove the effect from them.
    Post edited by gamingislove on
    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!
  • Thank you very much for your detailed feedback.

    I have made the suggested corrections, and I am pleased to confirm that the script is now functioning as intended.

    Once again, I sincerely appreciate you taking the time to provide your valuable advice. I look forward to your continued support.
Sign In or Register to comment.