To Automate or not to automate

Hello all,

I am just getting back into working on a module I started over a year ago and am noticing sluggishness with some features I had previously developed. In particular, I’ve designed a few global command keys which trigger dynamic properties, picking up on modifiers from individual pieces in the game, rolling a die and implementing a result. What I’m not sure about is whether there is an easier way to automate some of these things or if automation inherently slows down the performance.

The way I have approached it is to create a Dynamic Property using a nested set of boolean if:then statements to reflect die results. Using a made-up example, if I wanted a CRT to roll a die and implement the results, I would create something along the lines of:

Global command key triggers the Dynamic Property Combat
Combat has the following expression:
{((CombatDieRoll<=1) ? (Exchange) : (((CombatDieRoll>1&&CombatDieRoll<=4) ? (AttackerRetreat) : (((CombatDieRoll==5) ? (DefenderRetreat) : (DefenderEliminated))))))}

CombatDieRoll would be a Calculated Property with the expression Random(6).

This would be used to represent:
Die
1 = Exchange
2 = Attacker Retreat
3 = Attacker Retreat
4 = Attacker Retreat
5 = Defender Retreat
6 = Defender Eliminated

An alternative way I’ve formulated something like this is through individual Trigger Actions associated to a global command key firing CombatDieRoll. In this case, I might have a prototype embedded in pieces with the following Trigger Actions:

ExchangeTrigger with a matching property {CombatDieRoll<=1}
AttackerRetreatTrigger with a matching property {CombatDieRoll>1&&CombatDieRoll<=4}
DefenderRetreatTrigger with a matching property {CombatDieRoll==5}
DefenderEliminatedTrigger with a matching property {CombatDieRoll>=6}

Are either of these approaches faster than the other, or alternatively, am I just going about this the wrong way and there is another trick which might work better? Or … is this too much to try to automate within VASSAL?

Thanks again for any insights.

If my understanding of Calculated Properties is correct, that is a very bad way to do it: I’m fairly certain that it’s going to recalculate the die roll for every single reference to CombatDieRoll–i.e., when you compare it to <=1, it rolls the die, then when you compare it to >1, it rolls the die, then again when you compare it to <=4, etc.! If I’m correct, you need CombatDieRoll to be a Dynamic Property, instead, with a Key Command to Set value directly to {Random(6)} so it only gets rolled when you specifically tell it to (or, you could just use the built-in Dice Button, instead, if you want an easy way for the players to roll the die and visually see the result).

Also, I’m not sure what your first example is supposed to do–as written, it would set the Dynamic Property Combat to the value of one of the properties Exchange, AttackerRetreat, DefenderRetreat, or DefenderEliminated, not actually trigger anything to happen. So, your 2nd example is the way to go.

I’m not even sure what you are trying to accomplish here with the GKCs and die rolls. Isn’t the typical CRT based on the sum off the attacker’s combat strength or a ratio of attacker-defender strengths? I’d avoid GKCs altogether as I have found them to be the only Vassal operation that can get painfully slow. I use a combination of several hundred Global Properties and about a dozen Dynamic Properties or Calculated Properties per unit to obtain just about full automation. Doing it with GKCs would create unplayable lag…