Useful Maptools Macros

From OttGaming Wiki
Jump to: navigation, search

New Turn Changer And Announcer

Performs the useful task of advancing initiative and shouting at the next person up.

<hr />
[h: jsonInit = getInitiativeList() ]
[H: ThisChar = nextInitiative() ]
[H: AllTokens = json.get(jsonInit, "tokens")]
[H: YourUP = json.get(json.get(AllTokens, ThisChar), "tokenId")]
Round Number [r: getInitiativeRound()]: <font size=4><b>You are up, {getName(YourUP)}!!</b></font>
<hr />

Alternative version, also warns the guy after the next guy.

<hr />
[h: jsonInit = getInitiativeList() ]
[H: ThisChar = nextInitiative() ]
[H: AllTokens = json.get(jsonInit, "tokens")]
[H: YourUP = json.get(json.get(AllTokens, ThisChar), "tokenId")]
Round Number [r: getInitiativeRound()]: <font size=4><b>You are up, {getName(YourUP)}!!</b></font><BR />
[H:NextChar = if(ThisChar == initiativeSize()-1,0, ThisChar+1)]
[H: YourUP = json.get(json.get(AllTokens, NextChar), "tokenId")]
<i>{getName(YourUP)}, get ready to go!</i>
<hr />

Luck Timer

Some abilities can only be used in a certain period of real-time, not game time, such as GURPS Luck.

Make sure to update TimeZone with your local Time Zone. There is no way, unfortunately, to get this information programmatically, so MapTools cannot calculate vs a central time benchmark (server time, the GMs time, etc). It's local only.

/me [H: TimeZone="EST"]
[H: curIndex = getMacroButtonIndex()]
[H: NewTime = json.get(getInfo("client"),"timeDate")]
[H: props=getMacroProps(curIndex,"json")]
[H: OldTime = json.get(props, "label")]
last used {OldTime} {TimeZone}, and uses LUCK again at {NewTime} {TimeZone}.
[H: setMacroProps(curIndex, "label=Luck ("+NewTime+")")]

Initiative Setter

Selected Token setting, grouped by token image

This macro assumes that PCs do not share token images with NPCs, and NPCs with similar token images should have the same slot on initiative. It looks at selected tokens (PC and NPC) and ignores unselected.

 [h: initList = "booga=-1"];
 
 [h, foreach(Selected, getSelected("json")), CODE:
 {
 	[switchToken(Selected)]
 	[SelectedGMName = getTokenImage()]
 	[arr = json.fromStrProp(initList)]
 	[if(json.contains(arr, SelectedGMName) != 0), CODE:
 	{
 		[init = json.get(arr, SelectedGMName)]
 	};
 	{
 		[result = 0] 
 		[init = result + getProperty("Reflexes", Selected)] 
 		[tie = getProperty("DX", Selected) / 100] 
 		[init = init + tie]
 		[initList = concat(initList, ";", SelectedGMName, "=", init)]
 	}]
 	
 	[switchToken(Selected)]
 	[addToInitiative()]
 	[setInitiative(init)]
 }]
 
 [h: sortInitiative()]
 
 [h,foreach(Selected, getSelected("json")), CODE:
 {
 	[switchToken(Selected)]
 	[init = getInitiative()]
 	[init = floor(init)]
 	[setInitiative(init)]
 }]

Mass NPC setting

Loops through every NPC token on the map, pops up a window with the NPC name and icon (to remind you) and asks for the NPC's initative modifier. NPC is added to the initiative list, it's initative is rolled, and finally the list is sorted in order of initative once all NPCs are added.

For non-random initatives, pull out the 1d20 roll. If Initative modifiers are stored on the tokens, replace the whole Label/input foofrah with just a lookup on the token.

/self Added [R:addAllNPCsToInitiative()] NPCs to initiative. Updating position in initiative...
[h:args=json.set("","npc",1)] [h:NPCsList = getTokens("json",args)]
[H,FOR (x,0,json.length(NPCsList),1,""), CODE:{
[H:switchToken(json.get(NPCsList,x))]
[h:Label = getTokenImage()]
[h:status=input(
                "junk|"+getTokenImage()+"|"+ getName() + "|LABEL| ICON=TRUE ICONSIZE=30",
                "InitBonus|0|Initiative Bonus"
                )]
[h:setInitiative(1d20+InitBonus)]
}]
[h:sortInitiative()]

This variation only asks once per token image - this assumes that PCs each have a unique image, and NPC "types" that share an image should all share an initiative. This is a good macro to use if you have 40 identical mooks.

 /self Added [R:addAllNPCsToInitiative()] NPCs to initiative. Updating position in initiative...
 
 [h: initList = "booga=-1"];
 
 [h:args=json.set("","npc",1)] [h:NPCsList = getTokens("json",args)]
 [H,FOR (x,0,json.length(NPCsList),1,""), CODE:{
 	[H:switchToken(json.get(NPCsList,x))]
 	[arr = json.fromStrProp(initList)]
 	[h:Label = getTokenImage()]
 	[if(json.contains(arr, Label) == 0), CODE:
 	{
 		[h:status=input(
 			"junk|"+getTokenImage()+"|"+ getName() + "|LABEL| ICON=TRUE ICONSIZE=30",
 			"InitBonus|0|Initiative Bonus"
 			)]
		[result = 1d20] 
		[init = result+InitBonus]
 		[h:setInitiative(init)]
		[initList = concat(initList, ";", SelectedGMName, "=", init)]
 	}]
 }]
 [h:sortInitiative()]

Mass PC autosetting

Loops through every PC token on the map, pulls out their initiative modifier rolls 1d20+Init, adds them to the initiative list, and sorts.

/self Added [R:addAllPCsToInitiative()] PCs to initiative. Updating position in initiative...
[h:args=json.set("","pc",1)] [h:PCsList = getTokens("json",args)]
[H,FOR (x,0,json.length(PCsList),1,""), CODE:{
[H:switchToken(json.get(PCsList,x))]
[h:setInitiative(1d20+Init)]
}]
[h:sortInitiative()]

PC Autosetting with announcement of initiative numbers

Added [R:addAllPCsToInitiative()] PCs to the initiative tracker. Rolling initiative...
[h:args=json.set("","pc",1)] [h:PCsList = getTokens("json",args)] [FOR (x,0,json.length(PCsList),1,""), CODE:{ [H:switchToken(json.get(PCsList,x))] {getName()} rolled {Initroll=1d20} and so goes on {setInitiative(Initroll+Init)}
}] [h:sortInitiative()]

Mass Add PCs or NPCs

Just churns through PCs and adds them, does not set up their initative values at all.

/self Added [R:addAllPCsToInitiative()] PCs to the initiative.


Just churns through NPCs and adds them, does not set up their initative values at all.

/self Added [R:addAllNPCsToInitiative()] NPCs to the initiative.

Clear Initiative

/self Removed [R: removeAllFromInitiative()] tokens from the initiative list.

Arrow Counter

Assumes a JSON hash in the characters Description property. Update macro to reflect correct Property as required.

The hash must contain your current number of arrows in the hash-key "arrows", and will use "look-for-arrows" as the tally of arrows you need to go look for after the fight.

Example:

{"level":1,"arrows":29,"look-for-arrows":0}

Arrow "Spender"

Hit this button once per shot. It reports to you quietly, as most people REALLY don't want to know the gory details.

/self
[h:jsoncount=getProperty("Description")]
You had [R:ArrowCount = json.get(jsoncount,"arrows")] arrows, and had [R:LookFor = json.get(jsoncount,"look-for-arrows")] arrows lying around.<Br />
You now have [R:ArrowCount=ArrowCount-1] arrows, and have [R:LookFor=LookFor+1] lying around.
[H:jsoncount = json.set(jsoncount, "arrows",ArrowCount)]
[H:jsoncount = json.set(jsoncount, "look-for-arrows",LookFor)]
[H:setProperty("Description",jsoncount)]

Arrow "Searcher"

Hit this button once at the end of the fight. It checks all your fired arrows for you, and announces to the GM only.

/GM
[h:jsoncount=getProperty("Description")]
[h:Loop = json.get(jsoncount,"look-for-arrows")]
[h:Recovered=0]
Looking for {Loop} lost arrows...
[FOR (x,1,Loop+1,1, "; "), CODE:{[H:Test=3d6]
[H:Found = IF(Test <= 9, 1, 0)]
[H:Recovered = Recovered + Found]
[R,T(IF(Found,"Found","Lost forever")):"Rolled: "+Test]}].
[H:arrowTotal=json.get(jsoncount, "arrows")]
I now have {arrowTotal+Recovered} arrows.
[H:jsoncount = json.set(jsoncount, "arrows", arrowTotal+Recovered)]
[H:jsoncount = json.set(jsoncount, "look-for-arrows", 0)]
[H:setProperty("Description", jsoncount)]