Advice Needed: Path of War Granted Maneuvers

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
biolink22
Kobold
Posts: 2
Joined: Wed Aug 21, 2024 11:49 pm

Advice Needed: Path of War Granted Maneuvers

Post by biolink22 »

So I'm trying to set up a macro to easily and painlessly replicate the granted maneuvers mechanic from the Mystic in Path of War.

To be clear on what I need to macro to do, which I'm honestly not sure is possible, I will have a Group of macros for my maneuvers, each of which when used will turn the macro button black, this is the easy part. The hard part is I need a macro that can change macro button colors in the selected Group to a different color, at random, without choosing the same button twice, using a token variable (stat mod) to determine the number of buttons to randomly choose.

Any help on this would be amazing and thanks in advance.

User avatar
bubblobill
Giant
Posts: 176
Joined: Sun Jan 24, 2010 3:07 pm

Re: Advice Needed: Path of War Granted Maneuvers

Post by bubblobill »

Code: Select all

[h: magicNumber = 3]
[h: macGroupIndexes = getMacroGroup("group", "json")]
[h: numPicks = min(json.length(macGroupIndexes), magicNumber)]
[h: macGroupIndexes = getMacroGroup("group", "json")]
[h: props = json.set("", "color", "blue")]
[h, while(numPicks > 0), code:{
	[pick = roll(1, json.length(macGroupIndexes))]
	[idx = json.get(macGroupIndexes, pick)]
	[setMacroProps(idx, props)]
	[macGroupIndexes = json.remove(macGroupIndexes, pick)]
	[numPicks = numPicks - 1]
}]
Bubblobill on the forum.
@Reverend on the MapTool Discord Server

Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework

biolink22
Kobold
Posts: 2
Joined: Wed Aug 21, 2024 11:49 pm

Re: Advice Needed: Path of War Granted Maneuvers

Post by biolink22 »

Thank you for the reply, as I have no real experience with Json macros, what parameters would I need to edit in that macro to suit my token?

User avatar
aliasmask
RPTools Team
Posts: 9089
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: Advice Needed: Path of War Granted Maneuvers

Post by aliasmask »

Code: Select all

<!-- This macro could be its own macro in another group or at end of code of specified macro -->

<!-- stat that holds the number of buttons to change -->
[h: magicNumber = 3]

<!-- ids of macro buttons in "group" name, randomized -->
[h: macGroupIndexes = json.shuffle(getMacroGroup("group", "json"))]

<!-- validate number isnt greater than the number of macro buttons -->
[h: numPicks = min(json.length(macGroupIndexes), magicNumber)]

<!-- list of colors to assign to buttons, randomized -->
[H: colors = json.shuffle(json.append("[]","green","blue","red"))]

<!-- loop to change first picks in randomized list -->
[H, for(i,0,numPicks), code: {
   <!-- get button index -->
   [H: index = json.get(macGroupIndexes,i)]
   
   <!-- set color of button -->
   [H: setMacroProps(index,json.set("{}","color",json.get(colors,i))]
}]

User avatar
bubblobill
Giant
Posts: 176
Joined: Sun Jan 24, 2010 3:07 pm

Re: Advice Needed: Path of War Granted Maneuvers

Post by bubblobill »

I see you aliasmask and I raise you
Biolink change appropriateStat & macroButtonGroupName values (top two lines of code) to your values.

Code: Select all

<!-- This macro could be its own macro in another group or at end of code of specified macro -->

<!-- stat that determines the number of buttons to change -->
[h: appropriateStat = "maneouvreStatName"] 

<!-- name of the macro button group that you want to affect -->
[h: macroButtonGroupName = "buttonGroupName"]

<!-- get the stored value of the stat -->
[h: magicNumber = getProperty(appropriateStat)]

<!-- possible calculation to derive the number of buttons to change -->
[h: magicNumber = ceil(magicNumber/2)]

<!-- ids of macro buttons in group, randomized -->
[h: macGroupIndexes = json.shuffle(getMacroGroup(macroButtonGroupName, "json"))]

<!-- id of this macro button -->
[h: thisIndex = getMacroButtonIndex()]

<!-- remove this button from the list if it is in the same group -->
[h, if(json.contains(macGroupIndexes, thisIndex)): 
	macGroupIndexes = json.remove(macGroupIndexes, json.indexOf(macGroupIndexes, thisIndex))]


<!-- validate number is not greater than the number of macro buttons -->
[h: numPicks = min(json.length(macGroupIndexes), magicNumber)]

<!-- list of colors to assign to buttons, randomized -->
[h: colours = json.append("[]","green","blue","red")]

<!-- loop to change first picks in randomized list -->
[h, while(numPicks > -1), code: {
   [numPicks = numPicks -1]
   
   <!-- get button index -->
   [index = json.get(macGroupIndexes,0)]

   <!-- remove button index from the list -->
   [macGroupIndexes = json.remove(macGroupIndexes, 0)]

   <!-- set random color of button -->
   [setMacroProps(index,json.set("{}","color",json.get(json.shuffle(colours),0))]
}]
Bubblobill on the forum.
@Reverend on the MapTool Discord Server

Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework

Post Reply

Return to “Macros”