I want to create a system that selects a group of units, when just one of the units in the group is selected. I can just make it so when one unit in the group is selected, the whole unit group is selected. Simple, right? No. There will be an infinite amount of these groups, and so I cannot make unit group variables for all of them. Instead, I set up a very complex system which works... to a degree.
My System (simplified):
When a unit enters the map, it is assigned to a temporary (global variable) unit group and the units custom value (Index: 0) is set to a global integer variable, GroupDataValue. When the unit group becomes full (8 units), it converts the GroupDataValue (which starts at 1, by the way) to a string which is saved in a global string variable, GroupData. All of the units in the unit group are stored in the global data table (Index: Group[GroupData]) and the value of GroupDataValue is increased by 1, as to prepare for the next group. When a unit is selected, it's custom value (Index:0) is converted to a string, which is saved in a local variable, CustomData. Then, all units in the global data table (Index: Group[CustomData]) are selected. This, after many hours of work is working surprisingly well, however there is one major problem, considering I do not want to make it possible to only select one unit.
If I click on a unit, the whole group is selected, GREAT! Problem: Once the whole group is selected, if I click on ONE unit that is already selected, then it will be the only one selected. I assume this is because instead of deselecting all of the units in the group and selecting that one, it just deselects the others. Therefore, the trigger that detects the selection of a unit is not triggered.
Attempts:
1. I tried setting it so that when a unit is clicked (technically it also selects it) it will select the whole group, but for some reason this did not work.
2. I tried making a trigger that realizes when units are deselected. I was going to make a condition that checked if the deselected unit's custom value was equal to the currently selected unit's value (meaning that they are in the same group), and making it select the whole group of the currently selected unit, but there is no option that returns the unit that is currently selected.
Please help! I have spent 5 hours trying to perfect this, and I do not want to have to trash it all.
Thanks!
-Kyuft
My System (simplified):
When a unit enters the map, it is assigned to a temporary (global variable) unit group and the units custom value (Index: 0) is set to a global integer variable, GroupDataValue. When the unit group becomes full (8 units), it converts the GroupDataValue (which starts at 1, by the way) to a string which is saved in a global string variable, GroupData. All of the units in the unit group are stored in the global data table (Index: Group[GroupData]) and the value of GroupDataValue is increased by 1, as to prepare for the next group. When a unit is selected, it's custom value (Index:0) is converted to a string, which is saved in a local variable, CustomData. Then, all units in the global data table (Index: Group[CustomData]) are selected. This, after many hours of work is working surprisingly well, however there is one major problem, considering I do not want to make it possible to only select one unit.
If I click on a unit, the whole group is selected, GREAT! Problem: Once the whole group is selected, if I click on ONE unit that is already selected, then it will be the only one selected. I assume this is because instead of deselecting all of the units in the group and selecting that one, it just deselects the others. Therefore, the trigger that detects the selection of a unit is not triggered.
Attempts:
1. I tried setting it so that when a unit is clicked (technically it also selects it) it will select the whole group, but for some reason this did not work.
2. I tried making a trigger that realizes when units are deselected. I was going to make a condition that checked if the deselected unit's custom value was equal to the currently selected unit's value (meaning that they are in the same group), and making it select the whole group of the currently selected unit, but there is no option that returns the unit that is currently selected.
Please help! I have spent 5 hours trying to perfect this, and I do not want to have to trash it all.
Thanks!
-Kyuft