Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   Army Builder (http://forums.wolflair.com/forumdisplay.php?f=16)
-   -   Author Question - Army Builder for Firestorm Armada Heavy Cruiser Validation (http://forums.wolflair.com/showthread.php?t=17537)

veritechc February 9th, 2012 08:20 AM

Author Question - Army Builder for Firestorm Armada Heavy Cruiser Validation
 
In Firestorm Armada If you take Heavy Cruisers there are some rules to follow.

Heavy Cruisers are medium ships.

No more than half of your medium ships can be Heavy Cruisers

So I set up a validation rule as follows:

In Firestorm.def I added a rule called hvcruiserv.

In turn that is inherited by my ruleset Tournament.

In validation.dat, under rule I made a rule called cahvalidat and linked that to hvcruiserv under rulesets.

It uses the script:

if (tally[unit:size.M] > tally[unit:type.CAH]) then
@valid = 1
endif

Unfortunately it is not doing what I want. What I need it to do is look at the roster, total the number of medium ships (size.M) and compare that against the number of heavy cruisers (type.CAH) only. I also need it to evaluate the number of Heavy Cruisers and medium per model added no matter where on the roster.

What am I doing wrong?

The data files can be downloaded here: http://www.theblackocean.com/resourc...estormtest.zip

Thank you again for all your help.

Garfunkel February 10th, 2012 03:25 AM

Hello,

I don't know the right behaviour you need :
Is it the number of models, or units ?

For models, you can use the script:
Quote:

if (tally[model:size.M&!type.CAH] > tally[model:type.CAH]) then
@valid = 1
else
if (tally[model:type.CAH] =0) then
@valid = 1
endif
endif
It seems it works.
If it is units number to be compare, just replace the model term with unit.
I added a test in case there is no superheavy. (When the roster is empty for example)

What you misses is that your heavy cruisers also have the tag size.M.
The real test is you need more ship with size.M AND NOT type.CAH than type.CAH ships.

I advise you to show size and type on the available list profil instead of simply display it on the info. It is easyer to fulfill the rule when the discriminating type is displayed for the whole range of ship. (Instead of just one on the info) And use the same terms on the rule message than what is displayed (S or Small, M or Medium, Heavy Cruiser or CAH) or add the abbreviation in the rule message.

Hope that helps,

Garfunkel

veritechc February 13th, 2012 11:38 AM

Quote:

Originally Posted by Garfunkel (Post 73612)
Hello,

I don't know the right behaviour you need :
Is it the number of models, or units ?

For models, you can use the script:

It seems it works.
If it is units number to be compare, just replace the model term with unit.
I added a test in case there is no superheavy. (When the roster is empty for example)

What you misses is that your heavy cruisers also have the tag size.M.
The real test is you need more ship with size.M AND NOT type.CAH than type.CAH ships.

I advise you to show size and type on the available list profil instead of simply display it on the info. It is easyer to fulfill the rule when the discriminating type is displayed for the whole range of ship. (Instead of just one on the info) And use the same terms on the rule message than what is displayed (S or Small, M or Medium, Heavy Cruiser or CAH) or add the abbreviation in the rule message.

Hope that helps,

Garfunkel

Thank you so much. It worked like a charm. I owe you one Garfunkel.

I actually do understand why this worked and your thought on adding a validation for no Heavy Cruisers in the same expression was great.

So now to understand what I don't know.

if (tally[model:size.M&!type.CAH] > tally[model:type.CAH]) then
@valid = 1

What does the "&!" do? Where are those expressions listed?

Garfunkel February 14th, 2012 07:29 AM

Hello,

&! means "AND NOT"

The operators supported are outlined below.

Quote:

& Logical “And”. Evaluates the two terms on either side and returns “true” only if both terms are “true”. Example: “term1 & term2”.

| Logical “Or”. Evaluates the two terms on either side and returns “true” if either of the terms is “true”. Example: “term1 | term2”.

^ Logical “Xor”. Evaluates the two terms on either side and returns “true” if exactly one of the terms is “true”. Example: “term1 ^ term2”.

! Logical “Not”. Evaluates the following term and returns “true” if that term is “false”. Otherwise, it returns “false”. Example: “!term1”.
I suppose you already know the documentation main entry point:C:\Program Files\Army Builder\docs\kit\ab_kit.htm
It is very extensive, but if you need to concentrate on a specific subject, it is very usefull and makes you use the full power of the engine.

It is still OK to ask. :)
I did devellop a lots of such scripts just for fun and I know how valuable it is to get some help and I like to discuss on the behaviors others may need to program. It gives me ideas for my owns. ;)


Regards,
Garfunkel

veritechc February 15th, 2012 06:50 AM

Thank you again. I have read and reread that section to no avail. It gives me that same sinking feeling I had the first time I started begging French, lol. By the way I never got the hang of French...

My problem seems to stem from not thinking like a programmer in the first place. I am hoping that eventually it will just click.

I can tell you that I will be thanking you officially on our podcast. You can find out about us at www.theblackocean.com. The next episode should be out next week sometime.

Thanks!

paladin2019 February 16th, 2012 01:28 PM

Additional issue on heavy cruisers.

You cannot reduce the base size of a cruiser squadron to 1 to create a 2 ship squadron of 1 cruiser and 1 heavy cruiser.


All times are GMT -8. The time now is 01:48 AM.

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