• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Question on adding models to unit from a stat

shaggai

Well-known member
Setup: Unit X is allowed to have a "free" number of models based on the selection of units A, B C, etc. So if you take three unit A's - squad X is allowed 3 "free" models.

The stat is accumulated and I have seen that it accumulates properly, but how do I get unit X to get the free models based on the stat. Ive tried several versions of:

model[count] = model[count] + stat[marine]
model[minimum] = model[count] + stat[marine]

but unit X never seems to increase or start with the expected number when selected.

Note that I have tried these in the pre-link section of the unit - do I need to have a procedure call to do this instead? And assuming that this works out, if the player selects more eligible units will unit X's model count increase "automatically" or will it have to be deleted and then reselected so that the free model count stays accurate?
 
At 11:30 PM 5/6/2007, you wrote:
Setup: Unit X is allowed to have a "free" number of models based on the selection of units A, B C, etc. So if you take three unit A's - squad X is allowed 3 "free" models.

The stat is accumulated and I have seen that it accumulates properly, but how do I get unit X to get the free models based on the stat. Ive tried several versions of:

model[count] = model[count] + stat[marine]
model[minimum] = model[count] + stat[marine]

but unit X never seems to increase or start with the expected number when selected.

Note that I have tried these in the pre-link section of the unit - do I need to have a procedure call to do this instead? And assuming that this works out, if the player selects more eligible units will unit X's model count increase "automatically" or will it have to be deleted and then reselected so that the free model count stays accurate?
Unfortunately, you won't be able to accomplish this in an "enforced" fashion. You'll have to use a validation rule for it. The problem is evaluation timing. You can't perform tests on the values that haven't been calculated yet - and CAN'T be calculated yet. The model counts are calculated during the evaluation sequence. The accumulated stats are tallied up AFTER all evaluation is complete, which is required since they have to wait until the various values they reference have become stable.

There is also the sequencing issue. Even if we changed accumulated stats to be processed on-the-fly, this wouldn't work. Since units are processed in the order they appear in the roster, the only way it would work is if the user put the dependent unit (i.e. the one with free models) AFTER all of the units that dictate the free model allowance. If that unit appears first, the value would be incorrect and the behavior would be wrong, because the other units hadn't been tallied yet.

So you're stuck with only being able to use validation with this. Fortunately, the validation should be easy to write and should be able to specify to the user exactly which unit is invalid and why. So there shouldn't be any confusion for the user.

I strongly recommend you re-check the section entitled "Evaluation Sequence" in the Critical Concepts chapter of the Kit documentation. That section outlines all the details you need for what happens when during AB's processing. And it should prove helpful when trying to map out what you can and can't accomplish before you spend a lot of time trying to get something to work that isn't compliant with the evaluation sequence. :-)
 
Back
Top