Hi i failed to find any info on this. Lets say a unit has an attribute called speed. I am looking for a way to pull this information into a variable. any ideas?
You can use CatalogFieldValueGet to pull any information out of the data editor into a variable. For attributes, this is quite a hazzle, though. Depending on what kind of information you need, you might need to get the veterancy behavior, then link to the levels, or you might need to cycle all the unit behaviors until you find speed or the speed behavior itself.
I recommend using a generalized system to improve accessibility; for example always put your attributes in a specific order, so you can easily check for specific ones. Other than that, it heavily depends on exactly what kind of information you need.
let me describe a bit more what i am trying to do. i have an attribute set on a unit called speed, as well as a veterency behavior. I am trying to retrieve the current speed value for a particular unit. so lets say i create two of this particular unit on the map, i want to make sure i am referring to the correct unit.
the function you mention with this prototype seems promising but im not really sure what is meant by entry?
string CatalogFieldValueGet ( preset catalog, string entry, string fieldPath, int player )
Also it seems like its pulling data from the data editor, but how useful would this be when i need to get the current value of speed of a particular unit?
i looked through the catalog values and im guessing that c_gameCatalogBehavior is what I want. Im not sure how this would identify a particular unit though.
the field path that I looking at using is CUnit_BehaviorArray[0]. so my function call kind of looks like this CatalogFieldValueGet ( c_gameCatalogBehavior, string entry, CUnit_BehaviorArray[0], 1 ). this obviously doesnt work, perhaps there is something I am missing about entry that lets me look at a specific unit?
The entry refers to the id of your behavior, probably speed, The field path is used without prefix and as a string (with ""): "BehaviorArray[0]".
However, you are right, for your application, this would not be very useful, I did interpret your first post in a different way. If you just want to get the current behavior stack of the unit, try:
So if im not mistaken this will return the number of behaviors attached to the unit. So if I have 2 behaviors (speed, unitVeterency) this will return 2. Maybe this is not right though. Am i telling it to look in a behavior in the function parameter inBehavior? so the call would look like currSpeed = UnitBehaviorCount( myUnit, "speed"). If i just wanted to pull the current value of the speed attribute this is what i would use?
So if im not mistaken this will return the number of behaviors attached to the unit. So if I have 2 behaviors (speed, unitVeterency) this will return 2.
No, it will display the stack count of the behavior with the id you specify as the 2nd parameter. So if you use UnitBehaviorCount(u,"speed"), it should return the amount of stacks of your speed attribute.
There is a 2nd function called UnitBehaviorCountAll(unit inUnit), this should count all behaviors instead.
Quote:
Maybe this is not right though. Am i telling it to look in a behavior in the function parameter inBehavior? so the call would look like currSpeed = UnitBehaviorCount( myUnit, "speed"). If i just wanted to pull the current value of the speed attribute this is what i would use?
Exactly.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hi i failed to find any info on this. Lets say a unit has an attribute called speed. I am looking for a way to pull this information into a variable. any ideas?
You can use CatalogFieldValueGet to pull any information out of the data editor into a variable. For attributes, this is quite a hazzle, though. Depending on what kind of information you need, you might need to get the veterancy behavior, then link to the levels, or you might need to cycle all the unit behaviors until you find speed or the speed behavior itself.
I recommend using a generalized system to improve accessibility; for example always put your attributes in a specific order, so you can easily check for specific ones. Other than that, it heavily depends on exactly what kind of information you need.
@Kueken531: Go
let me describe a bit more what i am trying to do. i have an attribute set on a unit called speed, as well as a veterency behavior. I am trying to retrieve the current speed value for a particular unit. so lets say i create two of this particular unit on the map, i want to make sure i am referring to the correct unit.
the function you mention with this prototype seems promising but im not really sure what is meant by entry? string CatalogFieldValueGet ( preset catalog, string entry, string fieldPath, int player )
Also it seems like its pulling data from the data editor, but how useful would this be when i need to get the current value of speed of a particular unit?
i looked through the catalog values and im guessing that c_gameCatalogBehavior is what I want. Im not sure how this would identify a particular unit though. the field path that I looking at using is CUnit_BehaviorArray[0]. so my function call kind of looks like this CatalogFieldValueGet ( c_gameCatalogBehavior, string entry, CUnit_BehaviorArray[0], 1 ). this obviously doesnt work, perhaps there is something I am missing about entry that lets me look at a specific unit?
The entry refers to the id of your behavior, probably speed, The field path is used without prefix and as a string (with ""): "BehaviorArray[0]".
However, you are right, for your application, this would not be very useful, I did interpret your first post in a different way. If you just want to get the current behavior stack of the unit, try:
@Kueken531: Go
So if im not mistaken this will return the number of behaviors attached to the unit. So if I have 2 behaviors (speed, unitVeterency) this will return 2. Maybe this is not right though. Am i telling it to look in a behavior in the function parameter inBehavior? so the call would look like currSpeed = UnitBehaviorCount( myUnit, "speed"). If i just wanted to pull the current value of the speed attribute this is what i would use?
No, it will display the stack count of the behavior with the id you specify as the 2nd parameter. So if you use UnitBehaviorCount(u,"speed"), it should return the amount of stacks of your speed attribute.
There is a 2nd function called UnitBehaviorCountAll(unit inUnit), this should count all behaviors instead.
Exactly.