Hi, I'm trying to create an ability that will clone the target units ability temporarily then revert back after a certain amount of time only for that one unit (kind of like kirby in smash bro's). Not sure the best way to go about this. The map I am working on has a lot of units with a lot of different abilities. Is there an easy way to go about this? I've thought about using catalog triggers or giving the unit every ability in the game and just using triggers to show/hide the ability they want to clone. Ideally a data solution would be preferable but can't think of a way to do it.
I have something similar to this in my game, and I'm just giving the unit all of the abilities and showing/hiding the ability that is imprinted on, and then disabling the imprint ability until they've used their new 'stolen' ability. So data for adding all the abilities, and triggers for handling the showing/hiding and disabling/re-enabling.
For your scenario, you can just set a timer that on expire, hides the cloned ability and re-enables the clone ability itself.
Like MaskedImposter said, I just recently saw there's a limit on ability count for a unit, so you could only use this method if your amount of abilities you want to imprint is less than the max, like 32.
Maybe consider only allowing the unit to clone a type of ability (a special vs. a basic) from the other units or like for more rare units, this one could only clone one ability out of three from the rare unit, to cut down on the total possible cloned abilities count.
But what you could do, (just thought of it) for needing more than 32 abilities max to clone, is to have a trigger replace the cloner unit with the same exact looking unit but just a replica unit type, that had the next set of 32 abilities.
So like the cloner unit tries to clone another unit's ability, and you run that other unit through a switch. If it ends up belonging to some pre-defined list of group B units (those with abilities 33-64), kill and replace the cloner unit with the exact same unit type except for a new XML ID and its abilities (which would be the ones 33-64) (just restore its xp, hp, and energy values etc. to what they were before it used the clone ability).
That way you could have an infinite amount of abilities to clone because you can just keep making new unit types that are duplicates of your original cloner unit, each with their own unique set of 32 different abilities in data.
Let me know if that made any sense, sorry couldn't think of a better way to write it out, and can't upload any more images ;/
Actually fooled around a bit with the PTR patch. Unfortunately it didn't solve my problem because the abilities i need to replace need to be of the same CAbil class. Perhaps I could just have 1 ability for each CAbil class and replace that but haven't tried it yet and I do not believe it changes the actual button.
Anyways thanks again BaneFirst it has been working fine with killing and recreating the unit for a while now :).
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 :)
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 :)
Yeah I think it's because the abilities weren't designed for that unit. Previously I had charge working, but then it stopped. For those broken abilities you have to mess with them to make them compatible with the cloner unit I think. For instance if it requires energy/life to use, you need to remove that cost, or add the req. energy/life to the cloner unit.
That's my best guess, but hopefully others will mess with these actions soon and give more full answers!
I think it is probably a bug because the abilities worked on the cloner unit with the other method of cloning. All my abilities just require energy and the ones that don't work do not seem to have anything in common.
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 with DataCollection fixes the problem.
Not sure if this is intentional or not but seems like a bug to me.
Hi, I'm trying to create an ability that will clone the target units ability temporarily then revert back after a certain amount of time only for that one unit (kind of like kirby in smash bro's). Not sure the best way to go about this. The map I am working on has a lot of units with a lot of different abilities. Is there an easy way to go about this? I've thought about using catalog triggers or giving the unit every ability in the game and just using triggers to show/hide the ability they want to clone. Ideally a data solution would be preferable but can't think of a way to do it.
Any ideas? Thanks.
I don't think it is possible. I've heard there's a limit on how many abilities a unit can even have. I think it was 32.
I have something similar to this in my game, and I'm just giving the unit all of the abilities and showing/hiding the ability that is imprinted on, and then disabling the imprint ability until they've used their new 'stolen' ability. So data for adding all the abilities, and triggers for handling the showing/hiding and disabling/re-enabling.
For your scenario, you can just set a timer that on expire, hides the cloned ability and re-enables the clone ability itself.
Like MaskedImposter said, I just recently saw there's a limit on ability count for a unit, so you could only use this method if your amount of abilities you want to imprint is less than the max, like 32.
Maybe consider only allowing the unit to clone a type of ability (a special vs. a basic) from the other units or like for more rare units, this one could only clone one ability out of three from the rare unit, to cut down on the total possible cloned abilities count.
But what you could do, (just thought of it) for needing more than 32 abilities max to clone, is to have a trigger replace the cloner unit with the same exact looking unit but just a replica unit type, that had the next set of 32 abilities.
So like the cloner unit tries to clone another unit's ability, and you run that other unit through a switch. If it ends up belonging to some pre-defined list of group B units (those with abilities 33-64), kill and replace the cloner unit with the exact same unit type except for a new XML ID and its abilities (which would be the ones 33-64) (just restore its xp, hp, and energy values etc. to what they were before it used the clone ability).
That way you could have an infinite amount of abilities to clone because you can just keep making new unit types that are duplicates of your original cloner unit, each with their own unique set of 32 different abilities in data.
Let me know if that made any sense, sorry couldn't think of a better way to write it out, and can't upload any more images ;/
Made perfect sense thanks BaneBirst
This is an update, in response to the new major editor patch that is currently in beta testing:
"Dynamic Ability Support
As well as:
"Ability Swap
Reference this for more information (cntrl + f for 'Dynamic Ability Support'):
https://news.blizzard.com/en-us/starcraft2/23471116/starcraft-ii-4-13-0-ptr-patch-notes
Actually fooled around a bit with the PTR patch. Unfortunately it didn't solve my problem because the abilities i need to replace need to be of the same CAbil class. Perhaps I could just have 1 ability for each CAbil class and replace that but haven't tried it yet and I do not believe it changes the actual button.
Anyways thanks again BaneFirst it has been working fine with killing and recreating the unit for a while now :).
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
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.
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 :)
Yeah I think it's because the abilities weren't designed for that unit. Previously I had charge working, but then it stopped. For those broken abilities you have to mess with them to make them compatible with the cloner unit I think. For instance if it requires energy/life to use, you need to remove that cost, or add the req. energy/life to the cloner unit.
That's my best guess, but hopefully others will mess with these actions soon and give more full answers!
I think it is probably a bug because the abilities worked on the cloner unit with the other method of cloning. All my abilities just require energy and the ones that don't work do not seem to have anything in common.
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.
Best solution would be to use a dummy effect that triggers recognise and respond with a Create Effect At Point (From Unit) action to do the casting.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg