Yeah, target validation was the next step in the process. In fact, this part can get really intricate. Show different marks for Allies, Ranged vs Melee, spell effect targeting, force only 1 valid target. I was going to have different modes in mine where I have order of attack where I can separate a multi attack either by putting one or more attacks before hand on a target or giving the order of attack when a foe goes down.
I designed it, so far, to just cover the basics in targeting and to be used by anyone who can integrate it. I'm glad you like it and I'll checkout your framework to see it in action. As a quick change to your valid targets, I would use
Wiki: getTokens() because it automatically filters lib: and image: tokens.
Here is a code snippet of it in action where I limit token selection for my combat manager:
Code: Select all
...
<!-- Filter for valid tokens -->
[h: allTokens = json.union(getTokens("json"),getOwned(l.player,"json"))]
[h: ids.active = json.intersection(ids.active,allTokens)]
[h: ids.inactive = json.intersection(ids.inactive,allTokens)]
[h: ids.selected = json.intersection(ids.selected,allTokens)]
...
I believe getTokens("json") defaults to getting all the valid visible tokens, so if you're a gm, your selection will be greater unless you are in "player view" than an attached client.
edit: I'm guessing since the campaign won't load it is of a later version of MT than I have [1.3.b63]. I have yet to upgrade. I saw the "my old campaign won't load" posts and some token saving incompatibilities, so I decided to wait. I think it is safe to do now, but I hadn't planned on upgrading until I'm done with the current map I'm using.
edit: I'm working on another update and I'll have an example campaign file using the 3.5/Pathfinder framework by Imarkus. I've reduced the targetingMode macro down it's basic function and any kind of decision making will be made in the called macros.
Code: Select all
[H, if(!json.isEmpty(macro.args)): targetId = json.get(macro.args,0); targetId = ""]
[H: sourceId = getSelected()]
[H, if(listCount(sourceId) == 1 && getCurrentInitiative() != -1): hasInit = if(getInitiativeToken() == sourceId,1,0); hasInit = 0]
[H, if(hasInit), code: {
[H, if(sourceId == targetId):
execLink(macroLinkText("updateSource@Lib:CombatMedic","none",json.append("",sourceId)),1);
execLink(macroLinkText("updateTarget@Lib:CombatMedic","none",json.append("",targetId,sourceId)),1)
]
};{}]
This will allow for a more robust control of source and target manipulation without having to worry about messing up the core functionality. (namely recursion errors). I'll have more later.
I've also given some thought to how to target tokens who are covered by another token and I have expanded the targeting states to include Target Melee, Target Range, Target Ally and Target Magic. An example of Target Ally (which is not a good thing) is attacking someone in a grapple. For my attack macro, it would be nice to know if I have to apply a penalty to the attack because an Ally was in the way. By targeting the opponent and the Ally, that flag will exist to check against for any penalties and miss chance.
Some example pseudocode would be:
Code: Select all
if(Ally is targeted)
true - if(melee attack)
true - if(roll 20% concealment)
true - attack ally
false - attack enemy
false - if(precise shot)
true - no attack penalty
false - minus 4 to hit
false - attack enemy