Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   Army Builder (http://forums.wolflair.com/forumdisplay.php?f=16)
-   -   Smallest model count script (http://forums.wolflair.com/showthread.php?t=12632)

Decurion March 15th, 2011 04:04 PM

Smallest model count script
 
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

Garfunkel March 17th, 2011 02:59 AM

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

Colen March 17th, 2011 04:46 PM

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!

Decurion March 24th, 2011 09:21 AM

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

Garfunkel March 25th, 2011 07:53 AM

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.


All times are GMT -8. The time now is 11:56 PM.

Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.