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. ;)
Variable - Set CTBRange = (Real((Value of Abilities rangeCheckLink "Range[0]" for player Any Player)))
Don't use Any Player. Specify a player whenever working with catalogs, it's a good rule of thumb as you manipulate catalogs in a per-player basis.
You can see how to grab various catalog values by going into the data editor and clicking the 01010 with the hex string button (View Raw Data), it can be faster than going through import's show reserved XML.
e.g. UI - Display (Text((Value of Abilities "Blink" "Range[0]" for player 1))) for (All players) to Subtitle area
Works fine. I used Value field and didn't quote Range[0], just entered it in manually. I also pressed enter. XD
Know when a value is an array or not can be figured out by adding fields to the entry and seeing if it accepts multiple values. In raw view, arrays look something like (1|2|3|4|5), [0] being 1, [4] being 5.
Hey! It's a bit late here and I can't seem to get this to work.
I want to have the range value checked for the weapon object that a unit uses on being ordered to attack. If the distance between the unit and the attack target is greater than the range of the weapon, I want the unit to be ordered to move to a point where the attack will be in range.
So,
Unit A attacks Unit B
Distance AB = 20
Unit A Range = 7
Unit A ordered to move 13 units closer to Unit B along Line AB.
Unit A then ordered to attack Unit B.
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. ;)
Helpful. Thanks! I didn't know the import window had the show reserved checkbox.
@SuraklinSC2: Go
Hey! It's a bit late here and I can't seem to get this to work.
I want to have the range value checked for the weapon object that a unit uses on being ordered to attack. If the distance between the unit and the attack target is greater than the range of the weapon, I want the unit to be ordered to move to a point where the attack will be in range.
So,
Unit A attacks Unit B
Distance AB = 20
Unit A Range = 7
Unit A ordered to move 13 units closer to Unit B along Line AB.
Unit A then ordered to attack Unit B.
Or, in picture format:
http://screencast.com/t/1n1asvZw
Also, sorry for necro.