Junior Member
Join Date: Jun 2010
Location: Los Angeles, California, USA
Posts: 12
|
I am trying to write a script that will make sure UnitA is the smallest unit of its type.
This means I have to compare it to from 1 to many units and verify that UnitA has the smallest number of models. I am sure there is a simple solution here, but I don't see it. Tim |
#1 |
Senior Member
Volunteer Data File Author
Join Date: May 2005
Location: Grenoble, France
Posts: 167
|
Hello,
An idea: - define a dynamic group for unit type tagging ("type" for what follow) - define a GLOBAL dynamic group for unit type tagging with the same tags ("TYPE" for what follow) - On prelink unit, set type.unittypeXX where XX is the model count - create a global linkset 'LTYPE' - Define sets of option with a live script relying on the unit # for enabling which set the associated Global tag: TYPE.unitypeXX This will be quite boring as you will need 1 option for each # in the range * number of unit type as global tags cannot be assigned by other ways... - With a greatest priority, define an option that will compare the minimum of TYPE.unittypeXX assigned to the unit (As it is global, you will have the lowest of the roster) and the type.unittypeXX if equal, the unit is the one with the lowest model. If TYPE.unittypeXX is assigned more than one time, there are several unit with the lowest model count. This is the general description of one solution, just ask if you need more technical details. Which game system is it, and what is the purpose behind the solution you asked for? There may be another way... (Stat, rules...) Regards, Frédéric |
#2 |
Senior Member
Lone Wolf Staff
Join Date: Dec 2008
Posts: 4,690
|
You could also try defining a statcalc that held the unit size of the smallest unit. Then, in a validation rule for Unit A, you can compare your unit size against the statcalc. If it's the same, you're valid - if not, you're bigger than at least one unit, so you're invalid.
Hope this helps! |
#3 |
Junior Member
Join Date: Jun 2010
Location: Los Angeles, California, USA
Posts: 12
|
I appreciate both answers...
Frédéric, I am working with the Warhammer Ancient Battles Ancient Greek list, which has a unit of hoplites which must be the smallest unit of hoplites in the army. I am not sure I follow your solution, I am working at a pretty basic level so if you can point me to an example of what you are talking about I would appreciate it. Colen, would it be possible for you to point me to an example of what you are talking about. I follow what you are saying, but am a bit fuzzy on the execution. Thanks much guys! Tim |
#4 |
Senior Member
Volunteer Data File Author
Join Date: May 2005
Location: Grenoble, France
Posts: 167
|
Hello,
For Colen solution, (I think it is shorter to implement) In the exemple, the valid range of the unit is 20-25. Note you can use runtime.effectXX if needed. The target units to look at for the minimum size are all tagged as type.unitTypeXX and the one which must be of the lowest count is both type.unitTypeXX and type.hopliteMini The statcalc: Id: mini Priority 100 Scope: Roster Calculate Expression: var val as number val = tally[unit:runtime.count25 & type.unitTypeXX] if (val>0) then @value = 25 endif val = tally[unit:runtime.count24 & type.unitTypeXX] if (val>0) then @value = 24 endif val = tally[unit:runtime.count23 & type.unitTypeXX] if (val>0) then @value = 23 endif val = tally[unit:runtime.count22 & type.unitTypeXX] if (val>0) then @value = 22 endif val = tally[unit:runtime.count21 & type.unitTypeXX] if (val>0) then @value = 21 endif val = tally[unit:runtime.count20 & type.unitTypeXX] if (val>0) then @value = 20 endif There may be a shorter way to parse the range of model count... Rule: Scope: Unit Priority: 110 Test Expression: type.unitTypeXX & type.hopliteMini Script: if (statcalc[mini]>= count[model]) then @valid = 1 endif by this way, you identify any unit with the lowest count. (There might be several, but it is OK, only add a unique 'always' to your hoplites) Hope this help. |
#5 |
|
|