If the option availability is based on the "base" cost of the model (i.e. without any options attached), then this can be easily done. AB automatically defines a "costvalue" tag for every entity that corresponds to the base cost of that entity. You could easily setup a Live tag expression for each of the special options that requires the unit to have a "costvalue" tag with a value of at least X (whatever the minimum is). For example, if an option requires the model cost to be at least 30 points, the tagexpr would look like the following:
val:costvalue.? >= 30
You could further restrict the Live tagexpr to only apply when the certain "flavor" of army is selected. This would be done by using rulesets to have the user specify which "flavor" he wishes to field. Each ruleset would define a corresponding global tag. You could then include tests of the appropriate ruleset tag(s) within the Live tagexpr by combining them with the cost test above via a boolean expression.
The above approach would completely hide the option for units that were not allowed to take it based on the point requirement. However, this approach assumes you can use the "base" cost of the model. If you have to use the adjusted cost, then you'll have to use a rule-based method to solve this.
If you need to handle this via a rule, your outlined approach below is on the right track, but it's not quite going to work. For each option that requires a minimum cost, you'll need to assign an appropriate tag. Since we're talking about minimum costs, I'd create a new tag group and name it "mincost". You could then assign the tags as "mincost.19" to reflect a minimum cost of 19 points. This is much like what you are proposing below.
To detect and handle these conditions, things get a bit more interesting. What you really want is to identify the maximum cost requirement of any options and then compare that against the actual model cost of the unit. This will flag a validation error to indicate that one or more options selected for the unit are invalid based on the cost requirement. To identify the maximum cost, you'll need to use "tagmax[costvalue.?]". You'll then ned to compare that against the MODEL cost of the unit, just in case the user selects multiple models of the unit. This entails using the "entity" context and accessing the "cost[one]" target reference. So your rule would look something like the following:
var maxcost as number
maxcost = this.tagmax[costvalue.?]
if (maxcost <= this.entity.cost[one]) then
@valid = 1
endif
I haven't tried the above myself, but I'm 99% sure it should work. If I've missed something, let me know and I'll see what I can do to get things sorted out.
Hope this helps,
Rob
At 03:25 PM 12/27/2005, you wrote:
Well, to get back to this.
It is something that's popped up a few times with Rackham's new army packs.
For instance certain options when you build a particular "flavor" of an Undead army are available to models of a certain points cost ( I wish they would have used the Rank system they have built into the game instead, but.... ).
If I set up a "limit" group and assign a tag through the EVAL like "limit.cost19" I would be able to set up a Unit scope Rule to check
if tagcount[limit.cost19 ] >=1 then
if cost[unit] < 19 then
@valid = 1
endif
endif
Thanks
Butcher