I have a string attribute inside a script component for every combatant prefab, which is kinda of a "second class" for the character, independent from the first class.
I want to make an event that, for every combatant in the active group, asks the player via dialogue what secondary class will the character be and changes the attribute in the script to the choosen option. `

Here is what i've tried so far, but it doesn't work properly.:

i tried an event editor approach:
I have a main event that iterates members of the active calling events that change the component for every combatant index.
Since team size is variable (5-9 combatants), i check how many members does the team have using Select Combatant (with active group filter) and Selected data Count.
If there are 9, i call the event that changes the component for member with index 8.
If there are 8, i call the event that changes the component for member with index 7...

As you can notice, there are various copies of the same event, just changing the event senttings and the question in the options dialogue, so it's obvious i'm missing a better way of making the loop

The main event uses these nodes:
image

The event called looks something like this:
image

The script component has just a string attribute with set and print methods.

Given this situation, i have some doubts:

- Is it possible to pass an index as a parameter inside of a variable for a general event in the event editor and use this index for choosing a member of the active team in the event settings? If i could do that, i could use the same event multiple times, instead of creating an event for every member. I have copies of the same event since i couldn't find a way to do that

- Is there an effective way to loop an event in the event editor for every combatant in the team?

I will try using scripting but, for future events, i would love to know if there are event editor alternatives that i've missed or if this idea could actually be implemented using just the events editor.

Thanks in advance!
  • Even better, you can use selected data to just go through your combatants one by one. No need to use index based actors and copy/paste everything for everyone.

    To do this:
    - add a player actor
    - use a Select Combatant node to select all combatants from the player's group and store them in selected data (e.g. 'group')
    - use a Select Selected Data node to get one from the 'group' selected data and store it into a different selected data (e.g. 'combatant'), and remove the used one from 'group' (all in one node)
    - go through your stuff using the 'combatant' selected data
    - return to the Select Selected Data node to get the next one, it'll exit the loop via Failed when no more combatants are in the 'group' data
    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 very much! :D
    Now i can iterate actors in the active group!

    But it doesn't work properly yet. Analyzing the event with the other person i'm working with, we realized that there are some things that we don't undertand about vars...

    The event looks like this right now:
    image

    We're confused on how variables and selected data actually work. Right now, the event loops the exact number of iterations as members in the player work, but we're not sure how could we access to one combatant's prefab to get a script component or storing it's name into a variable to print it in a dialogue.
    (We don't know either how to print variables values in a dialogue)
    When we tried the event, we got to the dialogue node in the fail case of the store selected data content.
    Since i don't know why it could be failing, i'll show node by node.

    Step One: Select Combatant (to get the group)

    image

    Step Two: Select Selected Data (for iterations)
    image

    Step Three: Store selected data content (trying to save combatant's name to show it in the dialogue) If it fails, it gets to a dialogue node we're using for knowing where the loop breaks.
    image

    Step Four: a Dialogue with options. Each option would pass a different string parameter to the script component of a combatant's prefab.
    image

    Step Five: Call function node, which tries to set a simple string atribute in a script component.
    image

    Step Six: Show dialogue, just for controlling when an iteration has ended.

    Obviously, there must be basic concepts that we're not getting.
    How should variables or nodes be for this idea to work? Are we even using right nodes?
    Thank you in advance! :D
  • Step Two: set the Change Type to Set - you want to set the randomly selected combatant into the new data, not remove it.
    Removing the combatant from the other selected data is handled by the Remove setting below.
    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 a lot! Finally, it works!
    Thanks!!
Sign In or Register to comment.