My map needed a bit of math trickery to intercept the position of an action's execute destination then do some calculations to see that if using my custom teleporters would get the unit to where it wanted to be faster than the normal pathing algorithm. Now, one of the "problems" I ran into was that if a unit fired off one of my custom ranged abilites near a teleporter, it would make the unit use the teleporter even if the target destination was within range when the action was first fired. (This ended up in stuff happening like, standing near one teleporter pad, targetting the other, and firing a grenade. The trigger would intercept that it was on the "other side" of the teleporter and make the unit go through, and fire the grenade next to itself, rather than just firing the grenade across the teleporter gap because the target was well within range in the first place.
So, enough of the "why" babble, and down to the simple fact that I needed to pull the abilities range data from the ability itself to check if the unit should take the teleporter in the first place.
Step 1: Identitfying the name of the field you want to get.
I wanted the "Range" field from an ability, so, open up the Import window, then check off that "Show Reserved" button.
Convienient! "<Range value="7"/>" appears on... CAbilEffectTarget entries... but not my CAbilBehavior ones... hmmm.
Catch #1: If you notice, on an "Effect - Target" ability, under the "Range" field, if you have entires in there, they appear in brackets... like "(7)". What that means, is that for the field "Range", the data is stored as an array. So, the real name of the field we want to "get" is "Range[0]".
The first time I entered this in, it compiled fine. But when it was running in a game, every time it checked an order, it would throw an error. I *think* I figured out why... someone else could confirm why, but here goes:
Catch #2: The field "Range" is NOT defined by default in the default CAbilEffectTarget. When I entered "Field Path:" I just typed it in happily with the "Value" button selected. Nothing worked.
What ended up working is:
- Click the "Field Path" to edit it.
- Click the "Source" over to "Custom Script".
- Type in: "Range[0]" (This NEEDS the quotes around it when you type it in)
- Do NOT press enter. Click OK.
For some reason, pressing enter just made it throw errors all the time for me. (Perhaps there's some sort of pre-validation of the field name against the default definition of the ability or something when you enter it in the other ways?)
Suddenly, things started working.... kinda.
Catch #3: Doing it this way will throw an error if the ability you are checking does NOT have a "Range" defined.
Explanation of the IF statement: To get around errors being thrown all the time, I just put two checks in before I did the catalog call. The first condition is a substring check to see if the abilities ID starts with "CTB", which is what I start the id of all my abilities for this map with. I just want to check my custom abilities. The second condition is to check if the ability is the type that actually has a target.
Well, I think that's it... just something to think about when you're having problems pulling a value from a catalog entry and can't seem to get it to work no matter what you do.
Hope this helps someone out, if you're having problems pulling data from an object, check the default definition of whatever you're trying to get data from to see if the variable you want is defined in it. If not, give this approach a shot and see if it works out. ;)
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
My map needed a bit of math trickery to intercept the position of an action's execute destination then do some calculations to see that if using my custom teleporters would get the unit to where it wanted to be faster than the normal pathing algorithm. Now, one of the "problems" I ran into was that if a unit fired off one of my custom ranged abilites near a teleporter, it would make the unit use the teleporter even if the target destination was within range when the action was first fired. (This ended up in stuff happening like, standing near one teleporter pad, targetting the other, and firing a grenade. The trigger would intercept that it was on the "other side" of the teleporter and make the unit go through, and fire the grenade next to itself, rather than just firing the grenade across the teleporter gap because the target was well within range in the first place.
So, enough of the "why" babble, and down to the simple fact that I needed to pull the abilities range data from the ability itself to check if the unit should take the teleporter in the first place.
Step 1: Identitfying the name of the field you want to get.
Catch #1: If you notice, on an "Effect - Target" ability, under the "Range" field, if you have entires in there, they appear in brackets... like "(7)". What that means, is that for the field "Range", the data is stored as an array. So, the real name of the field we want to "get" is "Range[0]".
Step 2: Variable setup
I'll need that link string to check something later, and of course range is the final range of the ability.
Step 3: Get the game link string for the ability you want
I wanted the game link text for an ability that was passed in through a (Triggering order) into my trigger:
Which is in the editor:
Step 4: Pulling the value from the ability catalog
I'm just going to paste the final incantation of it, then explain:
Now the "fun" line there, which the the set variable.
The first time I entered this in, it compiled fine. But when it was running in a game, every time it checked an order, it would throw an error. I *think* I figured out why... someone else could confirm why, but here goes:
Catch #2: The field "Range" is NOT defined by default in the default CAbilEffectTarget. When I entered "Field Path:" I just typed it in happily with the "Value" button selected. Nothing worked. What ended up working is:
- Click the "Field Path" to edit it. - Click the "Source" over to "Custom Script". - Type in: "Range[0]" (This NEEDS the quotes around it when you type it in) - Do NOT press enter. Click OK.
For some reason, pressing enter just made it throw errors all the time for me. (Perhaps there's some sort of pre-validation of the field name against the default definition of the ability or something when you enter it in the other ways?)
Suddenly, things started working.... kinda.
Catch #3: Doing it this way will throw an error if the ability you are checking does NOT have a "Range" defined.
Explanation of the IF statement: To get around errors being thrown all the time, I just put two checks in before I did the catalog call. The first condition is a substring check to see if the abilities ID starts with "CTB", which is what I start the id of all my abilities for this map with. I just want to check my custom abilities. The second condition is to check if the ability is the type that actually has a target.
Well, I think that's it... just something to think about when you're having problems pulling a value from a catalog entry and can't seem to get it to work no matter what you do.
Hope this helps someone out, if you're having problems pulling data from an object, check the default definition of whatever you're trying to get data from to see if the variable you want is defined in it. If not, give this approach a shot and see if it works out. ;)