If I understand your question properly then what you want is a variable of string type, a trigger to record it into the variable, and a trigger to return 60%.
It should be something like this:
Global Variable: CostofAbility (array if you need to keep several) Type: String
Trigger 1
Event: Unit uses ability
Conditions: (any that you would need)
Actions: SetVariable(CostofAbility, (CatalogFieldValueGet(c_gameCatalogAbil, "Name of ability", "Cost[0].Resource[Minerals]", EventPlayer)))
Trigger 2
Event: What ever event you want to give back resource
Conditions: Same as above
Actions: PlayerModifyPropertyInt((EventPlayer()), c_playerPropMinerals, c_playerPropOperAdd, (FixedToInt((ArithmeticReal((StringToFixed(CostofAbility)), *, 0.6)))))
This should get you what you need if i understand correctly. resources(Non-vitals) are integers and to get 60% you need a real and sense your variable is a string that is why you get that long section at the end on second trigger.
Exactly what neverwin said; but just to add: the reason your first method doesn't work is just because the cost of ability function is bugged. You have to use catalog functions as neverwin did.
When you see an abilities cost in the catalog (check out the XML view of the ability data), it is in an array, hence the "[0]" in "cost[0]." The array is for ability levels (level one index 0, level two index 1, etc.). Contained in the cost field are subfields like Resource, and Vitals, and those are also arrays, based on what resource ("[minerals]") or vital.
Thanks. I am able to store the cost now, but for some reason it won't let me times it by .60. It's returning a 0 amount. When I test just adding the amount it works.
I guess I don't understand. This field "(Integer(0.6)))" is "convert real to integer" but looking at this it makes sense now that .06 isn't an integer.
Ok, so I've now realized you are trying to modify a players resources; this number indeed must be an integer. In order to achieve the effect of multiplying by 0.6 using integers, just use fractions, like 0.6 = 6/10, so:
This is because 6/10 is handled as an integer division, aka it returns 0 again. You have to change the order of your calculation, so your 0.6 is used in the real calculation and the whole thing is converted to integer afterwards:
lol sorry christmas so i didnt get on to clarify. the way i did it works because it converts it all to reals then does the math then converts it back into an integer. I tried to explain that at the end of my last post but i guess not well enough. Integers are only whole numbers so 1,2,3,4,5 while reals, or sometimes in the editor called fixed, are numbers with a decimal and also can be whole numbers 1.0, 1.1, 2.0, 3.546433 are all reals. the way shown by those above works just fine but i prefer not to use cause depending on when you use * or / it can give you a different number then what you intended. but yeah i know my way looks confusing cause it changes strings to reals and reals to ints so it is easy to get lost in it.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
So I'm trying to get the cost of an ability threw triggers and the only option I have is "Catalog - Cost of Ability," but it doesn't work.
What am I doing wrong?
I'm ultimately trying to be able to set the cost of the ability into a variable then at a later late return 60% of it.
If I understand your question properly then what you want is a variable of string type, a trigger to record it into the variable, and a trigger to return 60%. It should be something like this:
Global Variable: CostofAbility (array if you need to keep several) Type: String
Trigger 1
Event: Unit uses ability
Conditions: (any that you would need)
Actions: SetVariable(CostofAbility, (CatalogFieldValueGet(c_gameCatalogAbil, "Name of ability", "Cost[0].Resource[Minerals]", EventPlayer)))
Trigger 2
Event: What ever event you want to give back resource
Conditions: Same as above
Actions: PlayerModifyPropertyInt((EventPlayer()), c_playerPropMinerals, c_playerPropOperAdd, (FixedToInt((ArithmeticReal((StringToFixed(CostofAbility)), *, 0.6)))))
This should get you what you need if i understand correctly. resources(Non-vitals) are integers and to get 60% you need a real and sense your variable is a string that is why you get that long section at the end on second trigger.
@Zero0018: Go
Exactly what neverwin said; but just to add: the reason your first method doesn't work is just because the cost of ability function is bugged. You have to use catalog functions as neverwin did.
When you see an abilities cost in the catalog (check out the XML view of the ability data), it is in an array, hence the "[0]" in "cost[0]." The array is for ability levels (level one index 0, level two index 1, etc.). Contained in the cost field are subfields like Resource, and Vitals, and those are also arrays, based on what resource ("[minerals]") or vital.
@neverwin1011: Go
Thanks. I am able to store the cost now, but for some reason it won't let me times it by .60. It's returning a 0 amount. When I test just adding the amount it works.
This works:
So It's something with the .60 function....
Why doesn't it let me times it by .60? I tried storing a normal number into a variable and times it by .60 and it also returns 0...
@Zero0018: Go
This is occurring because 0.6 is not an integer, its real. The system interprets the integer 0.6 as zero. Try changing it to a real number.
@Swagblanket: Go
I guess I don't understand. This field "(Integer(0.6)))" is "convert real to integer" but looking at this it makes sense now that .06 isn't an integer.
Ok then. How do I make it a real number?
@Zero0018: Go
Ok, so I've now realized you are trying to modify a players resources; this number indeed must be an integer. In order to achieve the effect of multiplying by 0.6 using integers, just use fractions, like 0.6 = 6/10, so:
Add (((Integer(Ability Cost[1])) * 6 / 10 ))
@Swagblanket: Go
This doesn't work either.
This is because 6/10 is handled as an integer division, aka it returns 0 again. You have to change the order of your calculation, so your 0.6 is used in the real calculation and the whole thing is converted to integer afterwards:
Or you multiply your stuff by 6 and then divide the entire result by 10, instead of just the 6
@Zero0018: Go
Like this:
( x * 6 ) / 10
Ok this worked. Thanks guys
lol sorry christmas so i didnt get on to clarify. the way i did it works because it converts it all to reals then does the math then converts it back into an integer. I tried to explain that at the end of my last post but i guess not well enough.
Integers are only whole numbers so 1,2,3,4,5 while reals, or sometimes in the editor called fixed, are numbers with a decimal and also can be whole numbers 1.0, 1.1, 2.0, 3.546433 are all reals. the way shown by those above works just fine but i prefer not to use cause depending on when you use * or / it can give you a different number then what you intended. but yeah i know my way looks confusing cause it changes strings to reals and reals to ints so it is easy to get lost in it.