Sorry man I'm a bit confused.. I get you need a scope for the switch, but I don't get why triggering ability is used... My trigger is triggered on left mouse click..
Would you be able to comment the section after "Value:" but before the "switch". It's nice to have the code, but more nice to know what it does. :P
The code I posted is just example code. Triggering ability must be replaced with your ability variable.
SetVariableVariable:scope//A string variableValue:CatalogEntryScope//This is the catalog function you must use to retrieve an ability's scopeCatalog:Abilities//Here you select the data type of the entry you want to retrieve the scope from.Entry:ConvertGameLinkToString//The entry must be written in string form, so we convert the ability to a string. An ability is a game link.Value:AbilityOfAbilityCommand//Here you can specify the ability directly if you have it in a variable, or you can get the ability by using the function 'Ability Of Ability Command'.AbilityCommand:TriggeringAbilityDebug-Display(Text(scope))asdebugoutputusingType1,andDodisplayitinthegamewindow//it's a good idea to debug you code before you use it. Check what scope is and then write the code for the switch afterwards.
I don't know if the comments will do any good. Basically, the function Catalog Entry Scope takes an ability/unit/other object and gives you the type of that object as you see it in the data editor after you press Ctrl + D.
Be sure to add all the ability types you need in the switch. I just added the two I use the most as an example.
Edit: By the way, this method will not differentiate between unit target and point target abilities, since that is defined in the effect run by the ability. If you need this functionality you could use catalog functions to dig deeper into the ability and find it's target in the effects used by it. Although, this is not a task to take lightly. With the various ability types and effect types, the code is bound to get very complex, really fast. Only do it if you have no other way.
Is there a way I could determine if the ability targets nothing, targets a point or targets a unit. Just the conditions I can't figure out..
What I want to do is:
On click
If Ability requires no target cast Ability
else if Ability requires target point cast Ability at mouse point
else if Ability requires target unit cast Ability at unit closest to mouse point
Thanks in advance, Simbob ;D
@Simbob: Go
Check the ability's scope, and use a switch to differentiate between the different target types.
Sorry man I'm a bit confused.. I get you need a scope for the switch, but I don't get why triggering ability is used... My trigger is triggered on left mouse click..
Would you be able to comment the section after "Value:" but before the "switch". It's nice to have the code, but more nice to know what it does. :P
Sorry for being a hassle.. Thanks again ;D
@Simbob: Go
The code I posted is just example code. Triggering ability must be replaced with your ability variable.
I don't know if the comments will do any good. Basically, the function Catalog Entry Scope takes an ability/unit/other object and gives you the type of that object as you see it in the data editor after you press Ctrl + D.
Be sure to add all the ability types you need in the switch. I just added the two I use the most as an example.
Edit: By the way, this method will not differentiate between unit target and point target abilities, since that is defined in the effect run by the ability. If you need this functionality you could use catalog functions to dig deeper into the ability and find it's target in the effects used by it. Although, this is not a task to take lightly. With the various ability types and effect types, the code is bound to get very complex, really fast. Only do it if you have no other way.
@Builder_Bob: Go
Alright, now i get it :D.. Thanks man! You are a champion!!!