Assign Unique Debuffs/Effects

Hello guys!

I’m having issues in my project. I’ve spent hours trying to figure it out but with no result.

I’m trying to assign unique debuffs/effects to NPCs on my level (Each NPC gets a different debuff than the other NPCs). When I interact with the NPC, I clear the debuff, and make the debuff available again, so that it can be applied again, but there can never be duplicates.

I’ve got arrays of All debuffs and Active debuffs, BP for the NPC, and a BP for a manager that handles the debuffs. I believe I’m having issues managing the arrays.

I think I might be complicating the project too much. Would you be so kind and provide me with a general idea of how could I tackle the logic?

Thanks!

Actor Components

  • base class + inhertiance
  • check if the target actor has the debuff (optional), if no, spawn a debuff
  • debuff can communicate with its owner
  • debuff removes itself or when told to (hard to tell how the intended mechanics works)

There may be no need for arrays. As a bonus, it also works for buffs! :stuck_out_tongue_winking_eye:


If you do want to keep working with arrays (because there’s always need for them anyway), and make it non-repeating:

Remove debuffs => Array => Shuffle => ForEachNPC => assign debuff by index.

Avoid juggling indexes.

1 Like

Thank you for your reply. Let me be more precise, I want to implement a simple system, that:
-assigns a debuff to a single random NPC periodically,
-it can target only unaffected NPCs,
-2 NPCs can’t be affected by the same debuff at the same time,
-debuff starts a timer for the NPC, after the timer ends, the NPC dies,
-each debuff requires that the player brings a different item to the npc (debuffs are permanently linked with those items)
-if the player brings the correct item, it clears the debuff
-the debuff goes back to a pool of “available debuffs” and can be applied again
-after certain time, the NPC can be again affected by the debuff
-there’s 5 NPCs and 5 debuffs

I believe I’m having issues moving the debuffs between “Available” arrays, and “Used” arrays. I’m getting really strange results after “clearing” the debuff. It’s like the debuffs disappear from the array, even though each time I’m “healing” the NPC, I add the debuff back to the Available Array.

I would greatly appreciate your help. Maybe you have a better idea of how I could approach this task. Thank you!

As mentioned above, consider actor components.

  • each buff is a component and has a life of its own; you get a full graph and support for inheritance - complexity of their functionality (what they do) is not an issue. It’s all fully dynamic.

image

  • the buff manager keeps track of things but we never add / remove stuff, merely flag what’s available:

1 Like

Thanks so much, filtering active debuffs just got much easier. Now I’m wondering what would be the best way to make sure that the debuff doesn’t get replaced. Is there a way to check if the target npc already has the component? Thanks, I really appreciate your support.

check if the target npc already has the component

If the return is valid, the actor already own ones of the debuff comps:

image

You’d need to select a specific Component Class, ofc.

Thanks! I’m still struggling to get this all to work. I’ve got a manager that checks if the debuff is in use, and whether the IsSick is true or false.


Then in AC_Flu, I set “IsSick” to true and mark the debuff as used.

I want to then remove the debuff by interacting with the affected NPC. However, whenever I enter the trigger box of any of the NPCs, I remove the debuff. How can I allow interaction with only the affected NPC? Can the debuff itself have a trigger volume?

Not sure I follow. Check if the NPC actor has the debuff, if they do, have the NPC destroy it (only component owners can do it).

You immediately know if the debuff comp is present thanks to the node mentioned above - handle that information

Look into event dispatchers, the destruction event should be a callback to the manager.

If the debuff is already present then it would probably be more optimal to keep it and just extend the existing debuff’s time.
Less GC movement.
If they can stack then just up the multiplier.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.