#Select all tokens in range

1 messages · Page 1 of 1 (latest)

brave brook
#

Hello all,

I am still working on warhammer quest framework, adding macros as the characters develop. Currently I would like to have some AOE effects in place, that affects all "enemy" tokens adjacent to token initiating the effect. And honestly I am stuck on how to make it work: select all tokens in range (either PC or NPC but not both). And then deal damage. Damage is working but I need to manualy chose tokens and then run damage from tokens that initiate it and sometimeas it takes longer than its worth it.

Damage part:

[h: ignoreArmor = 1]
[h: ignoreT = 1]
[h: ignoreIP = 1]
[h: dmgRoll = 1d6]
<br>
[r, foreach( id, getSelected(), "<br>"), code: {
[h, if( isNumber(dmgRoll)): dmg=dmgRoll; dmg = eval(dmgRoll)]
<b>[r: getName(id)]</b> took [r:dmg] pts of Tomb Rot damage, resulting in <b>[r: damage(id, dmg, ignoreArmor,ignoreT, ignoreIP)] wounds</b>.
}]

Anyone can help with this, please?

little skiff
#

getTokens has a range condition that you can set, which will find all tokens within a certain distance of a particular token. I have a macro that grabs all enemy tokens within range of the attacker to let you select which one you're hitting. That part of the code looks like this:

[h: rangeToCheck = getProperty("Weapon Range")]
[h: rangeObject = json.set("{}", "upto", rangeToCheck, "distancePerCell", 1)]
[h: conditions = json.set("{}", "range", rangeObject)]
[h: ids = getTokens(",", conditions)]

In theory if you slot that in above your foreach loop (and change the rangeToCheck variable to actually be a number), and replace getSelected() with the ids variable, it should work. If not, I can post more of the code I use to see if that'll help get you there.

brave brook
little skiff
# brave brook Wow you are a star mate. Honestly I was stuck on it for about three weeks, bit a...

There are NPC/PC conditions that you can set as well. So that'd be something like:

[h: conditions = json.set("{}", "range", rangeObject, "npc":1)]

Which should, in theory, work. I dunno, I've not tested it I'm just pulling from examples on the page. If that doesn't work and you don't want to bash your head against conditions (I didn't when making my macro) you could use isNPC within the foreach loop. In that case you'd grab every token, then check them individually as you go to see if it's an NPC or not, and only apply the effect if they are. Less efficient, less elegant, but on a scale of a macro like this, that's not a huge issue.

brave brook
#

Really you just taking it from examples? I keep working with it but to be honest the json is a black magic for me :/

little skiff
#

That's how I learn most of it yeah. Look at an example from the wiki, and then bash it over the head a bunch until it does the thing I want it to. Though I do agree the json is black magic for me too and I will avoid it whenever I can if I can find a solution that's not dramatically more work than just learning a single instance of it