getTokenNames within the same map cell.

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
shindu
Kobold
Posts: 3
Joined: Sat Jun 18, 2016 12:16 pm

getTokenNames within the same map cell.

Post by shindu »

Hey folks, I have made some pretty good progress on making an AOE damage macro. The damage is reduced by half with each additional cell of range from the epicenter. For the most part, this is working however, the getTokenNames() API call is not returning the tokens within range 0. they are limped in with the range 1 results. Normally this is fine but i have an encounter coming up with a swarm a wee little creatures that are not set to snap to cell. you can fit like 4 of them within a typical map cell.

one option is to get all within 1, the split that up using the getDistance with NO_GRID flag. This take a little more effort to sort the results into range 0 and range 1. Plus, it would be inaccurate because a cell does not necessarily start at the center of the target.

Is there another way to make getTokenNames give you all tokens inside the same cell housing the target?

example of what i use now:

Code: Select all

    [h: condition = '{ "range": {"upto":'+range+', "distancePerCell":1, "metric": "NO_GRID", "token":"' +primaryTarget+ '"}, "unsetStates":["Dead"] }']
    [h: tokensInRange = getTokenNames("json", condition)]

I can just base the whole thing off of getDistance calls but i would then have to group them because the damage in each range is divided among the targets in said range.

Any advice would be greatly appreciated.

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: getTokenNames within the same map cell.

Post by JamzTheMan »

there's also canSeeToken(condition) but VBL/vision is used as well. Not sure if range affects it the same.

RPTroll had a similiar macro as well using this:

Code: Select all

[h:tokens = getVisibleTokens("json")]
[h:exposedTokens=getExposedTokens("json")]
[h:tokens=json.intersection(tokens,exposedTokens)]
[h:distanceJSON="[]"]
[h,foreach(token,tokens,"<br>-"), code:{
  [tokenType=getPropertyType(token)]
  [if((tokenType=="Basic" || tokenType=="Vehicle") && token != currentToken()), code:{
    [h:targetDistance=getDistance(token)-1]
    [h:stuff=json.set("","Name",getName(token),"Distance",targetDistance)]
    [h:distanceJSON=json.append(distanceJSON,stuff)]
  };{
  }]
}]
[h:distanceJSON=json.sort(distanceJSON,"a","Distance","Name")]
[r:distanceJSON]
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

Post Reply

Return to “Macros”