Macro code to determine combat advantage

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
Myrhdraak
Kobold
Posts: 16
Joined: Wed Nov 28, 2018 3:05 pm

Macro code to determine combat advantage

Post by Myrhdraak »

I am running D&D 4th Edition or a modification of it, but it is first now I have started to use MapTool macros to implement all the powers with macros. I have now started on the rogue, and have been looking around for a macro that determine if a PC have combat advantage vs. a monster based on if there is another PC on the othter side of the monster token that then grants combat advantage due to its position and the size of the monster token. I have not found one yet, but I would be surprised if not someone have already created code for this. Anybody aware of such code in some thread?

/Myrhdraak

User avatar
Torlan
Kobold
Posts: 15
Joined: Fri Jan 07, 2022 8:12 am

Re: Macro code to determine combat advantage

Post by Torlan »

Never tried to do that, but looking at the function list you might want to check token type (getPC and getNPC), position (getTokenX and getTokenY) and facing (getTokenFacing). Once you have all these data you can determine the mutual distance of each couple of tokens involved in the scene and where each of them is facing, so you can check if they’re all on the same NPC, on different sides of it and so on.
Just my two cents here :wink:
Roses are grey, violets are grey...I'm dead and colorblind!

Myrhdraak
Kobold
Posts: 16
Joined: Wed Nov 28, 2018 3:05 pm

Re: Macro code to determine combat advantage

Post by Myrhdraak »

I do not care about facing in D&D 4th Edition, but I have to keep track of the weapon reach of both PCs, their positions in relation to the monster and the monster size. Was hoping some already had created it. Would have been great to have a macro function where you just enter PC tokenId in the macro and then get all monsters in a json list which the PC have combat advantage against.

User avatar
Torlan
Kobold
Posts: 15
Joined: Fri Jan 07, 2022 8:12 am

Re: Macro code to determine combat advantage

Post by Torlan »

Myrhdraak wrote:
Wed Feb 09, 2022 4:31 pm
I do not care about facing in D&D 4th Edition, but I have to keep track of the weapon reach of both PCs, their positions in relation to the monster and the monster size. Was hoping some already had created it. Would have been great to have a macro function where you just enter PC tokenId in the macro and then get all monsters in a json list which the PC have combat advantage against.
I agree, facing is not really important. As for the other data, they're all quite accessible, I think.
Sorry for not providing any code, but I currently am short of time... :( Maybe in a not-too-distant future...
Roses are grey, violets are grey...I'm dead and colorblind!

Myrhdraak
Kobold
Posts: 16
Joined: Wed Nov 28, 2018 3:05 pm

Re: Macro code to determine combat advantage

Post by Myrhdraak »


Myrhdraak
Kobold
Posts: 16
Joined: Wed Nov 28, 2018 3:05 pm

Re: Macro code to determine combat advantage

Post by Myrhdraak »

Starting to wonder if it wouldn't be easier to just rotate the coordinate system 45 degree, and then determine flanking. As long as the PC and Ally is in opposite quadrants (which then is going to be quite easy to determine) they are setup for flanking, as long as both are within weapon reach of the enemy. Don't remember the math behind coordinate-system rotation, but it shouldn't be to hard to do with some if statements as well. Will have a look into it.

User avatar
StarMan
Dragon
Posts: 939
Joined: Mon Jul 18, 2011 1:10 pm
Location: Toronto

Re: Macro code to determine combat advantage

Post by StarMan »

Just seeing this now as I don't visit this forum too often

https://youtu.be/ntRXkLLDxq8?t=590

Download my framework (see "Please read" section at http://macropolicebox.ihostfull.com/index.php ) and look at the "Test for Flank" macro which is called by "Attack Power". You're right to be stumped as this took me a WEEK working 2 to 3 hours a day to finally get right!
StarMan - The MacroPolicebox D&D 4E Framework: Import ANYTHING!

Post Reply

Return to “Macros”