Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Random Encounter Macro

Hey everyone.  I've been trying to make a macro for encounter math and I'm having a hard time trying to get the job done.  I have a way of doing it but it is extremely inelegant. I thought someone might be able to show me a Better Way (TM). Here is the math I'm trying to Figure out. The idea is that each hex on the map has a certain % of having an encounter.  That % is determined by a combination of factors.  The Patrol level of the nearby town, a base encounter level of the world and a modifier based on how close the hex is to dangerous threats. The basic formula if no threats are nearby should look roughly like this: 10*(5- (( 1+ Level of the Town - Hexes from Town), 0)k1) Example 1: Town Level 3, Adjacent to town (Hexes from town = 1) 10*(5-(1+3-1), 0)k1) = 10*(5-3)= 20.  So a 20% Encounter Rate. Adding in the Level of Dungeons should mean I get something like this: 10*(5- ((1+Level of the Town - Hexes from Town), 0)k1 + ((1+Level of Dungeon - Hexes from Dungeon), 0)k1) Example 2: Town Level: 3, 2 Hexes from town, 1 Hex from a Level 2 Dungeon 10* (5 - ((1+3-2)+(1+2-1))) = 10*(5-(2)+(2))= 10*(5) = 50.  So a 50% Encounter Rate. For numbers below 50% this works well.  However once you get beyond 50% the encounter rate is supposed to drop off.  For every 1 step above the base the threat should increase at half rate. This is the part where everything I try to make ultimately breaks down or I just don't know what to do to get the job done. From Example 2, ideally there would be a way for the macro to return a 50% encounter rate with the numbers given, but if the numbers changed slightly, it should start to scale by 5% instead of 10%.  So if you change the example to being Town Level 3, 2 Hexes from Town, 1 Hex from a Level 3 Dungeon instead of returning 60% I need it to return 55%.  I don't really know how to do this. Once that gets done I'd like a way for me to be able to macro in multiple threats on a given area. Example 3 Town Level: 3, 4 Hexes from Town, 2 Hexes from a Level 4 Dungeon, 1 Hex from a Level 1 Dungeon. 10*(5 -( (1+3-4) + (1+4-2) + (1+1-1) ) ) = 10 * (5 - (0) + (3) + (1) ) = 10 * (9) = 90% Encounter Rate.  I don't know how to do the math properly, but if I can get the right formula instead of 90% that should return a total of 70% Encounter Rate (10*(5+(4/2))). I was thinking of having different macros based on how many dungeons are nearby, just to minimize the number of prompts during play.  I'd also like for it to roll an encounter roll at the end.  So the output would be something like this: Encounter Chance: 20 Encounter Roll: 85 (Just a simple 1d100) Or, if I could get it to work, If I could get it to return a 1 or a 0 depending on the result of the d100 and the encounter chance.  If the formula would be something like [[(Encounter Chance Formula)-1d100]] Where if the number is below 0 it returns a 0, if it is above 0 it returns a 1.  I don't know how to do that either, but I feel reasonably strongly that it is possible I just don't have the expertise to be able to get the job done while also maintaining my sanity. Any help would be greatly appreciated.  Thanks in advance. PS. The closest thing that I've gotten to a working macro is as follows: **Encounter Chance**: [[50-10*({@{Town Level}+1-?{Hexes From Town|1},0}k1)+10*(?{Dungeon 1 Level|1}+1-?{Hexes From Dungeon 1|1}),0}k1)+10*(?{Dungeon 2 Level|1}+1-?{Hexes From Dungeon 2|1}),0}k1)+10*(?{Dungeon 3 Level|1}+1-?{Hexes From Dungeon 3|1}),0}k1)]] **Encounter Roll**: [[1d100]]
1498481039
The Aaron
Pro
API Scripter
Something like: 5* ( (5- (( 1+ Level of the Town - Hexes from Town), 0)k1) + ((5- (( 1+ Level of the Town - Hexes from Town), 0)k1),5)kl1) )
1498484040
Silvyre
Forum Champion
Try this out: [[ 50 + 10 * ({?{Dungeon Level - Distance|3-1}, 0}kh1 - {?{Town Level - Distance|3-2}, 0}kh1) - 5 * {{?{Dungeon Level - Distance}, 0}kh1 - {?{Town Level - Distance}, 0}kh1, {0}}kh1 ]]
Silvyre said: Try this out: [[ 50 + 10 * ({?{Dungeon Level - Distance|3-1}, 0}kh1 - {?{Town Level - Distance|3-2}, 0}kh1) - 5 * {{?{Dungeon Level - Distance}, 0}kh1 - {?{Town Level - Distance}, 0}kh1, {0}}kh1 ]] Doesn't work.  Might be partially because if the town is out of range odd things happen? Example: Town Level: 3 Distance from Town: 4 Level of Dungeon: 4 Distance from Dungeon: 1 Correct Answer: 70% (50+(40/2)) Macro returns: 65% Thanks for all the help so far.  I'll try to trouble shoot.
1498486017

Edited 1498486035
Silvyre
Forum Champion
Updated: [[ 50 + 10 * ({?{Dungeon Level - Distance|4-1}, -1}kh1 - {?{Town Level - Distance|3-4}, -1}kh1) - 5 * {{?{Dungeon Level - Distance}, -1}kh1 - {?{Town Level - Distance}, -1}kh1, {0}}kh1 ]]
1498495931

Edited 1498542545
Matt
Plus
Gary M said: Hey everyone.  I've been trying to make a macro for encounter math and I'm having a hard time trying to get the job done.  I have a way of doing it but it is extremely inelegant. I thought someone might be able to show me a Better Way (TM). Here is the math I'm trying to Figure out. The idea is that each hex on the map has a certain % of having an encounter.  That % is determined by a combination of factors.  The Patrol level of the nearby town, a base encounter level of the world and a modifier based on how close the hex is to dangerous threats. The basic formula if no threats are nearby should look roughly like this: 10*(5- (( 1+ Level of the Town - Hexes from Town), 0)k1) Example 1: Town Level 3, Adjacent to town (Hexes from town = 1) 10*(5-(1+3-1), 0)k1) = 10*(5-3)= 20.  So a 20% Encounter Rate. Adding in the Level of Dungeons should mean I get something like this: 10*(5- ((1+Level of the Town - Hexes from Town), 0)k1 + ((1+Level of Dungeon - Hexes from Dungeon), 0)k1) Example 2: Town Level: 3, 2 Hexes from town, 1 Hex from a Level 2 Dungeon 10* (5 - ((1+3-2)+(1+2-1))) = 10*(5-(2)+(2))= 10*(5) = 50.  So a 50% Encounter Rate. For numbers below 50% this works well.  However once you get beyond 50% the encounter rate is supposed to drop off.  For every 1 step above the base the threat should increase at half rate. This is the part where everything I try to make ultimately breaks down or I just don't know what to do to get the job done. From Example 2, ideally there would be a way for the macro to return a 50% encounter rate with the numbers given, but if the numbers changed slightly, it should start to scale by 5% instead of 10%.  So if you change the example to being Town Level 3, 2 Hexes from Town, 1 Hex from a Level 3 Dungeon instead of returning 60% I need it to return 55%.  I don't really know how to do this. Once that gets done I'd like a way for me to be able to macro in multiple threats on a given area. Example 3 Town Level: 3, 4 Hexes from Town, 2 Hexes from a Level 4 Dungeon, 1 Hex from a Level 1 Dungeon. 10*(5 -( (1+3-4) + (1+4-2) + (1+1-1) ) ) = 10 * (5 - (0) + (3) + (1) ) = 10 * (9) = 90% Encounter Rate.  I don't know how to do the math properly, but if I can get the right formula instead of 90% that should return a total of 70% Encounter Rate (10*(5+(4/2))). I was thinking of having different macros based on how many dungeons are nearby, just to minimize the number of prompts during play.  I'd also like for it to roll an encounter roll at the end.  So the output would be something like this: Encounter Chance: 20 Encounter Roll: 85 (Just a simple 1d100) Or, if I could get it to work, If I could get it to return a 1 or a 0 depending on the result of the d100 and the encounter chance.  If the formula would be something like [[(Encounter Chance Formula)-1d100]] Where if the number is below 0 it returns a 0, if it is above 0 it returns a 1.  I don't know how to do that either, but I feel reasonably strongly that it is possible I just don't have the expertise to be able to get the job done while also maintaining my sanity. Any help would be greatly appreciated.  Thanks in advance. PS. The closest thing that I've gotten to a working macro is as follows: **Encounter Chance**: [[50-10*({@{Town Level}+1-?{Hexes From Town|1},0}k1)+10*(?{Dungeon 1 Level|1}+1-?{Hexes From Dungeon 1|1}),0}k1)+10*(?{Dungeon 2 Level|1}+1-?{Hexes From Dungeon 2|1}),0}k1)+10*(?{Dungeon 3 Level|1}+1-?{Hexes From Dungeon 3|1}),0}k1)]] **Encounter Roll**: [[1d100]] Here's what I've got that works for a single dungeon (and single town), returning a 1 if you have a random encounter and a 0 if you do not. [[1d100<[[ [[10*( ( 5-{( 1+?{Town Level}-?{Dist to Town}),0}kh1 ) + {(1+?{Dungeon Level}-?{Dist to Dungeon}),0}kh1)]] - {[[ (10*( (5-{( 1+?{Town Level}-?{Dist to Town}),0}kh1) + {(1+?{Dungeon Level}-?{Dist to Dungeon}),0}kh1)-50)/2]],0}kh1 ]] ]] Due to nested rolls, when you mouse over it, all you will see is the roll on the d100 compared to the overall probability (not the entire calculation). Thus, for a "0" it might show something like "1d100<40 = (95)" or for a "1" It might show "1d100<50 = (32)". For 2 Dungeons in the area, use this macro: [[1d100<[[ [[10*( ( 5-{( 1+?{Town Level}-?{Dist to Town}),0}kh1 ) + {(1+?{Dungeon 1 Level}-?{Dist to Dungeon 1}),0}kh1+ {(1+?{Dungeon 2 Level}-?{Dist to Dungeon 2}),0}kh1)]] - {[[ (10*( (5-{( 1+?{Town Level}-?{Dist to Town}),0}kh1) + {(1+?{Dungeon 1 Level}-?{Dist to Dungeon 1}),0}kh1 + {(1+?{Dungeon 2 Level}-?{Dist to Dungeon 2}),0}kh1)-50)/2]],0}kh1 ]] ]] For 3 Dungeons in the area, use this one: [[1d100<[[ [[10*( ( 5-{( 1+?{Town Level}-?{Dist to Town}),0}kh1 ) + {(1+?{Dungeon 1 Level}-?{Dist to Dungeon 1}),0}kh1+ {(1+?{Dungeon 2 Level}-?{Dist to Dungeon 2}),0}kh1+ {(1+?{Dungeon 3 Level}-?{Dist to Dungeon 3}),0}kh1)]] - {[[ (10*( (5-{( 1+?{Town Level}-?{Dist to Town}),0}kh1) + {(1+?{Dungeon 1 Level}-?{Dist to Dungeon 1}),0}kh1 + {(1+?{Dungeon 2 Level}-?{Dist to Dungeon 2}),0}kh1+ {(1+?{Dungeon 3 Level}-?{Dist to Dungeon 3}),0}kh1)-50)/2]],0}kh1 ]] ]] and for 0 Dungeons in the area, use this one: [[1d100<[[10*( 5- {( 1+?{Town Level}-?{Dist to Town}),0}kh1)]] ]] I shall work on compiling these into a single drop-down.