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
Macro code to determine combat advantage
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
Re: Macro code to determine combat advantage
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
Just my two cents here
Roses are grey, violets are grey...I'm dead and colorblind!
Re: Macro code to determine combat advantage
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.
Re: Macro code to determine combat advantage
I agree, facing is not really important. As for the other data, they're all quite accessible, I think.Myrhdraak wrote: ↑Wed Feb 09, 2022 4:31 pmI 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.
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!
Re: Macro code to determine combat advantage
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.
Re: Macro code to determine combat advantage
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!
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!