Test for another game piece at same X and Y

I am trying to devise a test that determines whether 1 game piece is stacked with another. The reason is that the game piece has a combat factor of 1 if it is not in the same stack with another specific game piece. Game pieces have a marker trait of “type”. Type can be ‘arty’, ‘div’ or ‘corp’. The arty unit needs to be stacked with either a div or corp to realise its full combat factor.

My first pass at this did not work - no surprise there. The first If is my test. The second If checks whether the unit is flipped and out of supply, if true combat factor = 1, otherwise use the value of the marker trait ‘artycf’. The latter If works by itself. I am using a calculated property.

If(GetProperty(type)!=div||corp&&CurrentX&&CurrentY,1,If(rev_Active==“true”&&OOS_Active==“true”,1,artycf))

Am I on the right track at the very least?

Alas your X/Y check looks, as Marcellus Wallace once said, “pretty fucking far from okay” :smiley:

You’d have to be comparing the CurrentX/CurrentY from the arty piece to all the different X/Y’s of other acceptable units. (So you’d have to be tracking their locations in some massive list of GlobalProperties so that you could access them).

Easier method that I think will work for you: SumStack!
Steps:
(1) Give all your Divisions a Marker “Div” equal to 1 (the 1 is because of how SumStack works)
(2) Give all your Corps a Marker “Corps” equal to 1
(3) Give all your Arty a Marker “Arty” equal to 1
(4) So in the calculated property (I assume) to come up with the artillery’s combat factor, make the expression:
If((SumStack(“Div”) + SumStack(“Corps”) > 0) && !(rev_Active==“true” && OOS_Active==“true”),artycf,1)

Brian

Love the quote. Very apt.

Tried your formula, did not work. Always came out with 1. Tried a few permutations, no different. Decided on nested Ifs. All works now. Many thanks for the assist again.

If((SumStack(“divpres”)+SumStack(“corppres”)>0),If(rev_Active==“true”&&OOS_Active==“true”,1,artycf),1)

Appreciate there’s some complication with this solution, but it works. Your advice did lead to a solution.

Great! Looks like you got it running. I probably slightly confuddled the logic when I was trying to bring the non-SumStack stuff forward for you – mostly I wanted to show you how to use SumStack and looks like you got it going!

:smiley: