The xCount and xIndex fields are generated with a foreach that uses a sort order to search through the abilities in order by the level they're added at.
The script that assigns them runs after FirstCopy is assigned, and is only run by the firstcopy. As it finds each copy, it increments a variable by +1 and then assigns the current value of that variable to that copy's xIndex.
Then at the end, that variable's value becomes xCount, and then in a script soon after that, all the other copies find the firstcopy of themselves, and set their own xCount equal to the firstcopy's xCount.
|