Nice! Glad to hear that system is working for you.
I just messed around with the dynamic ability actions. It looks like with some tinkering we should be able to get our cloning to work perfectly :D
- Go to Data and add the buttons of all the possible abilities that can be cloned, to one slot in the cloner unit's command card.
- Make sure to set their command type to 'Ability Command' in the drop-down for the button.
- Then, go to XML view (still in the Data module), and add the bit: 'AbilCmd="[XML_NAME_OF_ABILITY_HERE],Execute"' to each listed '<LayoutButtons>' row under '<CardLayouts index="0">'.
- Note the ',Execute' that comes after the XML ID of the ability
- Make sure to put that bit right before the row/column information for that LayoutButtons entry (so that it is the 2nd to last item listed)
- Now go to Triggers and setup a switch that will handle the unit casting the clone ability (event - unit uses ability etc).
- Make the cases of the switch be based off of the unit type of targeted unit.
- Depending on the type of targeted unit, use the new PTR action 'Add Ability' or its raw-data name 'UnitAbilityAdd' to add whichever ability needs to be cloned to your cloner unit (e.g. if the cloner is targeting a zealot, add the Zealot - Charge ability, since it just stole the zealot's Charge).
- Note: Use the new PTR action 'Remove Ability' or in raw-data 'UnitAbilityRemove' to remove the last cloned ability before adding the new one.
- You can do this right before you add the new one, in the above mentioned switch statement cases. You can reference the last cloned ability by using the 'convert string to game link' function and for the string pass in a global variable that has been set to the XML name (ID) of the cloned ability (set in the above switch cases).
I've tested this out and it works great. The only problem I could foresee is possibly, since you're adding the 'AbilCmd' of each button manually in XML, that may count as actually adding the ability to the unit, which would then be capped at 31 (our original problem). But I don't think this is the case, since none of the abilities actually show up in the GUI list of the unit's abilities nor in the XML list '<AbilArray>' for the unit. They only show up as linked icons on the left underneath the unit's name under 'Abilities' in the context menu column to the left. So hopefully you can add as many buttons and AbilCmd ref's as you want.
What's cool is that it won't show any of the ability buttons when the cloner unit is selected, until you've added the ability using that PTR action.
Overall this means you can add any type of ability you want, at any time, in-game, to any unit.
I've attached a test map that uses key words entered by the player to "clone" abilities :)
Please see attached.
0.954011065006916
Yeah I found that the problem with
UnitAbilityAdd
not working for certain abilities has to do with<AbilSetId value=""/>
being set in about 50% of cases. In those cases removing that line fixes the problem. In the rest of cases, copying the ability and then removing that line from the copied ability can work, along withDataCollection
fixes the problem.Not sure if this is intentional or not but seems like a bug to me.
0.953798234988752
Thanks for taking the time and effort to explain that Banebirst!
I was able to get it part of it working via the PTR features. However, I have noticed both on your test map and on mine that certain cloned abilities will not cast. The button will appear fine but when you try and use the ability (either via clicking or hotkey) it just does nothing.
I noticed this on Zealot charge and Marine stimpack on the test map and several abilities on my map. Can't seem to find the source of it.
Would be super sweet to get it working this way though. Code bloat is way down and it looks cleaner :)