That macro finds all tokens on the hidden layer with state "isMagical" up to 60 feet. I then pass each macro through a canSeeToken() function and hide any auras the token can't see due to FoW (I know you can see through some material but since thickness is unknown, I assume FoW is blocking aura just the same).
As you can see, tokens 1 & 3 were exposed, where I would expect 2 and 3 instead. All the tokens are either medium or tiny size, but not snapped to grid. It looks like the function is using the Cell of the x,y location of the token so if the upper left pixel of the token is in another cell, it uses that cell which throws everything off. It should use the footprint of the token instead should it not?
Is there a better way of doing this?
Macro code
Code: Select all
[h: cond = '{ range: {upto:12, distancePerCell:0, metric:"ONE_TWO_ONE"}, setStates:["isMagical"], layer:["HIDDEN"] }']
[h: tokenList = getTokenNames("json", cond)]
[h, FOREACH (token, tokenList): setLayer("TOKEN", token)]
[h: count = json.length(tokenList)]
[h, FOREACH(token, tokenList, "<BR>"), CODE:{
[cantSee = json.isEmpty(canSeeToken(token))]
[layer = if(cantSee == 1, "HIDDEN", "OBJECT")]
[setLayer(layer, token)]
[count = if(cantSee == 1, count - 1, count)]
}]
Exposed {count} magical auras.