• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Random Tables lookups?

Hello peoples.

Been lurking here for a little bit and stealing ideas :cool:

So - I am using the code posted above and modifying it to produce random encounters for the kingmaker game I am setting up, but had a few questions.

I have finished the 'Forest' and 'Lake/River' sections (renamed the 'aquatic' button name as I am not a programmer and didn't want to break something).

You will notice that on these tables there are items like '1d6 bandits' and I was wondering if there was a way for the random number of things (in this case bandits) could be rolled as part of the table itself?

Also - How do I change the item names or order of the buttons...can i just copy paste a section from above to below? Do all sections need to be re-ordered or can I just change the order of the buttons at the bottom?

One final thing - Is it possible to have the results hyperlinked to data within RW (so that if I get a result of Bandits, I can then click on that link to go to the entry for the Bandits)?
Thankyou for your help.

Below is the partially modified code I have currently.

Code:
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>Kingmaker - Stolen Land</TITLE>
</HEAD>
<BODY>

<script language="JavaScript">

// Some Arrays




rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
}

function rand(number) {
return Math.ceil(rnd()*number);
}

function tableResults(argument) {

var aquaticArray = [];
var forestArray = [];
var hillsArray = [];
var mountainsArray = [];
var tundraArray = [];

aquaticArray.push({"max": 5, "content": "1d6 bandits; CR 1"});
aquaticArray.push({"max": 11, "content": "1d4 boars; CR 3" });
aquaticArray.push({"max": 17, "content": "1d4 boggards; CR 3"});
aquaticArray.push({"max": 21, "content": "1 brush thylacine; CR 2"});
aquaticArray.push({"max": 28, "content": "1d6 elk; CR 5"});
aquaticArray.push({"max": 32, "content": "1 faerie dragon; CR 2"});
aquaticArray.push({"max": 35, "content": "1d4 grigs; CR 2"});
aquaticArray.push({"max": 41, "content": "1 grizzly bear; CR 4"});
aquaticArray.push({"max": 49, "content": "1 hunter; CR 1/3"});
aquaticArray.push({"max": 57, "content": "1 nixie; CR 1"});
aquaticArray.push({"max": 62, "content": "1 owlbear; CR 4"});
aquaticArray.push({"max": 69, "content": "1 shambling mound; CR 6"});
aquaticArray.push({"max": 75, "content": "1 slurk; CR 2"});
aquaticArray.push({"max": 79, "content": "1 tatzlwyrm; CR 2"});
aquaticArray.push({"max": 83, "content": "1d4 trolls; CR 7"});
aquaticArray.push({"max": 90, "content": "1 will o wisp; CR 6"});
aquaticArray.push({"max": 96, "content": "1d6 wolves; CR 4"});
aquaticArray.push({"max": 100, "content": "1 worg; CR 2"});


forestArray.push({"max": 4, "content": "1D6 bandits; CR 1"});
forestArray.push({"max": 11, "content": "1D4 Boars; CR 3"});
forestArray.push({"max": 14, "content": "1d4 boggards; CR 3"});
forestArray.push({"max": 20, "content": "1 brush thylacine; CR 2"});
forestArray.push({"max": 29, "content": "1d6 elk; CR 5"});
forestArray.push({"max": 35, "content": "1 faerie dragon; CR 2"});
forestArray.push({"max": 42, "content": "1d4 grigs; CR 2"});
forestArray.push({"max": 47, "content": "1 grizzly bear; CR 4"});
forestArray.push({"max": 54, "content": "1 hunter; CR 1/3"});
forestArray.push({"max": 57, "content": "1d8 mites; CR 1"});
forestArray.push({"max": 63, "content": "1 owlbear; CR 4"});
forestArray.push({"max": 68, "content": "1 shambling mound; CR 6"});
forestArray.push({"max": 71, "content": "1 slurk; CR 2"});
forestArray.push({"max": 75, "content": "1 tatzlwyrm; CR 2"});
forestArray.push({"max": 79, "content": "1d4 trolls; CR 7"});
forestArray.push({"max": 82, "content": "1 werewolf; CR 2"});
forestArray.push({"max": 85, "content": "1 giant whiptail centipede; CR 3"});
forestArray.push({"max": 90, "content": "1 will o wisp; CR 6"});
forestArray.push({"max": 97, "content": "1d6 wolves; CR 4"});
forestArray.push({"max": 100, "content": "1 worg; CR 2"});


hillsArray.push({"max": 11, "content": "1 hoarfrost spirit; CR 3; Pathfinder #51 pg 14"});
hillsArray.push({"max": 24, "content": "1 ice troll; CR 4; Bestiary 2 pg 271"});
hillsArray.push({"max": 32, "content": "1 yeti; CR 4; Bestiary pg 287"});
hillsArray.push({"max": 42, "content": "1 winter wolf; CR 5; Bestiary pg 280"});
hillsArray.push({"max": 51, "content": "1 woolly rhinoceros; CR 6; Bestiary pg 235"});
hillsArray.push({"max": 59, "content": "1 frost drake; CR 7 Bestiary 2 pg 108"});
hillsArray.push({"max": 69, "content": "1 mastodon; CR 9; Bestiary pg 128"});
hillsArray.push({"max": 75, "content": "1 frost giant; CR 9 Bestiary pg 149"});
hillsArray.push({"max": 79, "content": "1 frostfallen mammoth; CR 10; Pathfinder #51 pg 84"});
hillsArray.push({"max": 88, "content": "1 saumen kar; CR 10; Pathfinder #51 pg 90"});
hillsArray.push({"max": 92, "content": "1 white pudding; CR 10; ToH pg 276"});
hillsArray.push({"max": 97, "content": "1 frost worm; CR 12; Bestiary 2 pg 126"});
hillsArray.push({"max": 100, "content": "1 taiga giant; CR 12; Bestiary 2 pg 131"});


mountainsArray.push({"max": 7, "content": "1 hoarfrost spirit; CR 3; Pathfinder #51 pg 14"});
mountainsArray.push({"max": 14, "content": "1 ice troll; CR 4; Bestiary 2 pg 271"});
mountainsArray.push({"max": 43, "content": "1 yeti; CR 4; Bestiary pg 287"});
mountainsArray.push({"max": 56, "content": "1 frost drake; CR 7 Bestiary 2 pg 108"});
mountainsArray.push({"max": 69, "content": "1 frost giant; CR 9 Bestiary pg 149"});
mountainsArray.push({"max": 75, "content": "1 witchfire; CR 9; Bestiary 2 pg 284"});
mountainsArray.push({"max": 84, "content": "1 frostfallen mammoth; CR 10; Pathfinder #51 pg 84"});
mountainsArray.push({"max": 92, "content": "1 saumen kar; CR 10; Pathfinder #51 pg 90"});
mountainsArray.push({"max": 100, "content": "1 frost worm; CR 12; Bestiary 2 pg 126"});


tundraArray.push({"max": 8, "content": "1 draugr; CR 2; Bestiary 2 pg 110"});
tundraArray.push({"max": 15, "content": "1 hoarfrost spirit; CR 3; Pathfinder #51 pg 14"});
tundraArray.push({"max": 22, "content": "1 ice troll; CR 4; Bestiary 2 pg 271"});
tundraArray.push({"max": 29, "content": "1 yeti; CR 4; Bestiary pg 287"});
tundraArray.push({"max": 40, "content": "1 winter wolf; CR 5; Bestiary pg 280"});
tundraArray.push({"max": 43, "content": "1 glacier toad; CR 6; Bestiary 2 pg 268"});
tundraArray.push({"max": 49, "content": "1 woolly rhinoceros; CR 6; Bestiary pg 235"});
tundraArray.push({"max": 54, "content": "1 frost drake; CR 7 Bestiary 2 pg 108"});
tundraArray.push({"max": 62, "content": "1 qallupilluk; CR 7; Pathfinder #51 pg 88"});
tundraArray.push({"max": 72, "content": "1 mastodon; CR 9; Bestiary pg 128"});
tundraArray.push({"max": 79, "content": "1 frost giant; CR 9 Bestiary pg 149"});
tundraArray.push({"max": 84, "content": "1 frostfallen mammoth; CR 10; Pathfinder #51 pg 84"});
tundraArray.push({"max": 89, "content": "1 saumen kar; CR 10; Pathfinder #51 pg 90"});
tundraArray.push({"max": 94, "content": "1 white pudding; CR 10; ToH pg 276"});
tundraArray.push({"max": 97, "content": "1 frost worm; CR 12; Bestiary 2 pg 126"});
tundraArray.push({"max": 100, "content": "1 taiga giant; CR 12; Bestiary 2 pg 131"});



var allArrays = {
"aquatic": aquaticArray,
"forest": forestArray,
"hills": hillsArray,
"mountains": mountainsArray,
"tundra": tundraArray
};

var randomNum = rand(100) + 1;
var arrayOfChoices = allArrays[argument];
if (!arrayOfChoices) {
return "no such set: " + argument;
}

var chosenString = "";
for (var itemIndex in arrayOfChoices) {
var item = arrayOfChoices[itemIndex];
if (randomNum <= item.max) {
chosenString = item.content;
break;
} 
}
return chosenString;
}

</script>

<form>
<input type="button" name="Button1" value="Lake/River" onClick="this.form.textField1.value = 

tableResults('aquatic')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button2" value="Forest" onClick="this.form.textField1.value = 

tableResults('forest')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button3" value="Hills" onClick="this.form.textField1.value = 

tableResults('hills')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button4" value="Mountains" onClick="this.form.textField1.value = 

tableResults('mountains')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button5" value="Tundra" onClick="this.form.textField1.value = 

tableResults('tundra')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

</BODY>
</HTML>
 
Last edited:
i can look into answer 1 and 2, as thats a pure JS question. The third is a different story alltogether... as thats a RW question. I'm guessing probably not. But thats a guess.

The order of the buttons on the page? Thats just the order they appear in the document. Is that what you mean?

Having a random number of bandits as an item, yes, it could be done, it would require a code call in another section... not overly difficult:

something like this:

"content": "1D6 bandits; CR 1" becomes

"content": rand(6) + " bandits; CR 1"

Im at work, so unfortunately, I am unable to write anything more specific.
 
Thanks mirtos...for some reason this doesnt work for me (probably user error).

I changed the line:
aquaticArray.push({"max": 5, "content": "1d6 bandits; CR 1"});

To:
aquaticArray.push({"max": 5, "content": rand(6) + "bandits; CR 1"});

But no luck. Seems to return results of 1 bandit every time :(
I have also noticed that sometimes I click the button and no result is returned, but not sure why?

Next question - How hard would it be to add 2 buttons at the top returning results of 'encounter' or 'no encounter' for the following variables:
5% chance per hex explored
15% day or night cycle exploring

Cheers again :)

*Edit* Here is my current code with the right encounters and re-arranged buttons. I know there is some redundant code in there (Mountains) but I didn't want to mess with too much in case I broke it)

Code:
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>Kingmaker - Stolen Land</TITLE>
</HEAD>
<BODY>

<script language="JavaScript">

// Some Arrays




rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
}

function rand(number) {
return Math.ceil(rnd()*number);
}

function tableResults(argument) {

var aquaticArray = [];
var forestArray = [];
var hillsArray = [];
var mountainsArray = [];
var tundraArray = [];

aquaticArray.push({"max": 5, "content": "1d6 bandits; CR 1"});
aquaticArray.push({"max": 11, "content": "1d4 boars; CR 3" });
aquaticArray.push({"max": 17, "content": "1d4 boggards; CR 3"});
aquaticArray.push({"max": 21, "content": "1 brush thylacine; CR 2"});
aquaticArray.push({"max": 28, "content": "1d6 elk; CR 5"});
aquaticArray.push({"max": 32, "content": "1 faerie dragon; CR 2"});
aquaticArray.push({"max": 35, "content": "1d4 grigs; CR 2"});
aquaticArray.push({"max": 41, "content": "1 grizzly bear; CR 4"});
aquaticArray.push({"max": 49, "content": "1 hunter; CR 1/3"});
aquaticArray.push({"max": 57, "content": "1 nixie; CR 1"});
aquaticArray.push({"max": 62, "content": "1 owlbear; CR 4"});
aquaticArray.push({"max": 69, "content": "1 shambling mound; CR 6"});
aquaticArray.push({"max": 75, "content": "1 slurk; CR 2"});
aquaticArray.push({"max": 79, "content": "1 tatzlwyrm; CR 2"});
aquaticArray.push({"max": 83, "content": "1d4 trolls; CR 7"});
aquaticArray.push({"max": 90, "content": "1 will o wisp; CR 6"});
aquaticArray.push({"max": 96, "content": "1d6 wolves; CR 4"});
aquaticArray.push({"max": 100, "content": "1 worg; CR 2"});


forestArray.push({"max": 4, "content": "1D6 bandits; CR 1"});
forestArray.push({"max": 11, "content": "1D4 Boars; CR 3"});
forestArray.push({"max": 14, "content": "1d4 boggards; CR 3"});
forestArray.push({"max": 20, "content": "1 brush thylacine; CR 2"});
forestArray.push({"max": 29, "content": "1d6 elk; CR 5"});
forestArray.push({"max": 35, "content": "1 faerie dragon; CR 2"});
forestArray.push({"max": 42, "content": "1d4 grigs; CR 2"});
forestArray.push({"max": 47, "content": "1 grizzly bear; CR 4"});
forestArray.push({"max": 54, "content": "1 hunter; CR 1/3"});
forestArray.push({"max": 57, "content": "1d8 mites; CR 1"});
forestArray.push({"max": 63, "content": "1 owlbear; CR 4"});
forestArray.push({"max": 68, "content": "1 shambling mound; CR 6"});
forestArray.push({"max": 71, "content": "1 slurk; CR 2"});
forestArray.push({"max": 75, "content": "1 tatzlwyrm; CR 2"});
forestArray.push({"max": 79, "content": "1d4 trolls; CR 7"});
forestArray.push({"max": 82, "content": "1 werewolf; CR 2"});
forestArray.push({"max": 85, "content": "1 giant whiptail centipede; CR 3"});
forestArray.push({"max": 90, "content": "1 will o wisp; CR 6"});
forestArray.push({"max": 97, "content": "1d6 wolves; CR 4"});
forestArray.push({"max": 100, "content": "1 worg; CR 2"});


hillsArray.push({"max": 8, "content": "1D6 bandits; CR 1"});
hillsArray.push({"max": 14, "content": "1D4 Boars; CR 3"});
hillsArray.push({"max": 19, "content": "1 brush thylacine; CR 2"});
hillsArray.push({"max": 27, "content": "1d6 elk; CR 5"});
hillsArray.push({"max": 30, "content": "1 faerie dragon; CR 2"});
hillsArray.push({"max": 35, "content": "1d4 grigs; CR 2"});
hillsArray.push({"max": 45, "content": "1 hunter; CR 1/3"});
hillsArray.push({"max": 51, "content": "1d8 Kobolds; CR 1"});
hillsArray.push({"max": 55, "content": "1d8 mites; CR 1"});
hillsArray.push({"max": 59, "content": "1 owlbear; CR 4"});
hillsArray.push({"max": 62, "content": "1 shambling mound; CR 6"});
hillsArray.push({"max": 67, "content": "1 tatzlwyrm; CR 2"});
hillsArray.push({"max": 70, "content": "1d4 trolls; CR 7"});
hillsArray.push({"max": 74, "content": "1 werewolf; CR 2"});
hillsArray.push({"max": 81, "content": "1 giant whiptail centipede; CR 3"});
hillsArray.push({"max": 86, "content": "1 will o wisp; CR 6"});
hillsArray.push({"max": 95, "content": "1d6 wolves; CR 4"});
hillsArray.push({"max": 100, "content": "1 worg; CR 2"});


mountainsArray.push({"max": 7, "content": "1 hoarfrost spirit; CR 3; Pathfinder #51 pg 14"});
mountainsArray.push({"max": 14, "content": "1 ice troll; CR 4; Bestiary 2 pg 271"});
mountainsArray.push({"max": 43, "content": "1 yeti; CR 4; Bestiary pg 287"});
mountainsArray.push({"max": 56, "content": "1 frost drake; CR 7 Bestiary 2 pg 108"});
mountainsArray.push({"max": 69, "content": "1 frost giant; CR 9 Bestiary pg 149"});
mountainsArray.push({"max": 75, "content": "1 witchfire; CR 9; Bestiary 2 pg 284"});
mountainsArray.push({"max": 84, "content": "1 frostfallen mammoth; CR 10; Pathfinder #51 pg 84"});
mountainsArray.push({"max": 92, "content": "1 saumen kar; CR 10; Pathfinder #51 pg 90"});
mountainsArray.push({"max": 100, "content": "1 frost worm; CR 12; Bestiary 2 pg 126"});


tundraArray.push({"max": 6, "content": "1D6 bandits; CR 1"});
tundraArray.push({"max": 15, "content": "1D4 Boars; CR 3"});
tundraArray.push({"max": 20, "content": "1 brush thylacine; CR 2"});
tundraArray.push({"max": 28, "content": "1d6 elk; CR 5"});
tundraArray.push({"max": 32, "content": "1 faerie dragon; CR 2"});
tundraArray.push({"max": 38, "content": "1d4 grigs; CR 2"});
tundraArray.push({"max": 40, "content": "1 grizzly bear; CR 4"});
tundraArray.push({"max": 51, "content": "1 hunter; CR 1/3"});
tundraArray.push({"max": 55, "content": "1d8 Kobolds; CR 1"});
tundraArray.push({"max": 57, "content": "1d8 mites; CR 1"});
tundraArray.push({"max": 59, "content": "1 owlbear; CR 4"});
tundraArray.push({"max": 63, "content": "1 shambling mound; CR 6"});
tundraArray.push({"max": 66, "content": "1 tatzlwyrm; CR 2"});
tundraArray.push({"max": 71, "content": "1d4 trolls; CR 7"});
tundraArray.push({"max": 75, "content": "1 werewolf; CR 2"});
tundraArray.push({"max": 80, "content": "1 giant whiptail centipede; CR 3"});
tundraArray.push({"max": 86, "content": "1 will o wisp; CR 6"});
tundraArray.push({"max": 95, "content": "1d6 wolves; CR 4"});
tundraArray.push({"max": 100, "content": "1 worg; CR 2"});



var allArrays = {
"aquatic": aquaticArray,
"forest": forestArray,
"hills": hillsArray,
"mountains": mountainsArray,
"tundra": tundraArray
};

var randomNum = rand(100) + 1;
var arrayOfChoices = allArrays[argument];
if (!arrayOfChoices) {
return "no such set: " + argument;
}

var chosenString = "";
for (var itemIndex in arrayOfChoices) {
var item = arrayOfChoices[itemIndex];
if (randomNum <= item.max) {
chosenString = item.content;
break;
} 
}
return chosenString;
}

</script>

<form>
<input type="button" name="Button2" value="Forest" onClick="this.form.textField1.value = 

tableResults('forest')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button1" value="Lake/River" onClick="this.form.textField1.value = 

tableResults('aquatic')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button5" value="Plains" onClick="this.form.textField1.value = 

tableResults('tundra')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button3" value="Hills" onClick="this.form.textField1.value = 

tableResults('hills')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

</BODY>
</HTML>
 
Last edited:
could be user error on my fault. sorry, so busy lately that i havent been able to sit down and and actually look.

Im having trouble visualizing your second question.

Would they be standalone buttons? would there be an input? What do you mean per hex?
 
In kingmaker there is a chance of a random encounter as the PCs explore.

The tables above have the random encounter info for the adventure, but I want to have a button that determines whether a random encounter event actually occurs or not.

I envision the first button labelled something like 'Hex encounter?' (yes, with the '?'), then as the PCs move to a new hex, I can pull up the page, hit the button and it tells me whether a random encounter occurs (5% Chance). If the roll is 1-5 out of 100 the result field returns 'Encounter!', or if the result is 6-100 the result returned is 'No encounter'.

Same for the day/night encounters - as each cycle passes in game there is a 15% chance of the encounter, so the button would be labelled 'day/night encounter?', with the result 1-15 returning 'Encounter!' and 16-100 returning 'No encounter'.

I hope this makes sense - I am clearly not a programmer :)
 
So the "hacky" way to go would be to create two new array objects, one for each encounter type. Each one will have two entries, encounter, and no encounter. Encounter will have a max of 5 or 15, as appropriate. No encounter, a max of 100.

Then you would add them to the allArray array as you did tundraArray, etc...

Then in your HTML section, you just copy the other way the inputs are done, but pass the array name as you do the others,

If this doesn't make sense, I apologize, I'm typing on a mobile device. If its not clear what to do, say so, and at some point today I will post the code.
 
Thankyou so much Mirtos.

I will give it a go tomorrow and see how I go...will post my results here, for better or for worse :D
 
I tested the random bandits on both chrome and IE (not near a RW).

However, you are missing some things from previous posts, causing RW to not run in the latest version of IE installed on your computer, which might be the problem. I've changed it.

Note ive forced the bandits to always be used by making their max 100. Change back to 5 once you've tested.



<HTML>
<HEAD>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<TITLE>Kingmaker - Stolen Land</TITLE>
</HEAD>
<BODY>

<script language="JavaScript">

// Some Arrays




rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
}

function rand(number) {
return Math.ceil(rnd()*number);
}

function tableResults(argument) {

var aquaticArray = [];
var forestArray = [];
var hillsArray = [];
var mountainsArray = [];
var tundraArray = [];

aquaticArray.push({"max": 100, "content": rand(6) + " bandits; CR 1"});
aquaticArray.push({"max": 11, "content": "1d4 boars; CR 3" });
aquaticArray.push({"max": 17, "content": "1d4 boggards; CR 3"});
aquaticArray.push({"max": 21, "content": "1 brush thylacine; CR 2"});
aquaticArray.push({"max": 28, "content": "1d6 elk; CR 5"});
aquaticArray.push({"max": 32, "content": "1 faerie dragon; CR 2"});
aquaticArray.push({"max": 35, "content": "1d4 grigs; CR 2"});
aquaticArray.push({"max": 41, "content": "1 grizzly bear; CR 4"});
aquaticArray.push({"max": 49, "content": "1 hunter; CR 1/3"});
aquaticArray.push({"max": 57, "content": "1 nixie; CR 1"});
aquaticArray.push({"max": 62, "content": "1 owlbear; CR 4"});
aquaticArray.push({"max": 69, "content": "1 shambling mound; CR 6"});
aquaticArray.push({"max": 75, "content": "1 slurk; CR 2"});
aquaticArray.push({"max": 79, "content": "1 tatzlwyrm; CR 2"});
aquaticArray.push({"max": 83, "content": "1d4 trolls; CR 7"});
aquaticArray.push({"max": 90, "content": "1 will o wisp; CR 6"});
aquaticArray.push({"max": 96, "content": "1d6 wolves; CR 4"});
aquaticArray.push({"max": 100, "content": "1 worg; CR 2"});


forestArray.push({"max": 4, "content": "1D6 bandits; CR 1"});
forestArray.push({"max": 11, "content": "1D4 Boars; CR 3"});
forestArray.push({"max": 14, "content": "1d4 boggards; CR 3"});
forestArray.push({"max": 20, "content": "1 brush thylacine; CR 2"});
forestArray.push({"max": 29, "content": "1d6 elk; CR 5"});
forestArray.push({"max": 35, "content": "1 faerie dragon; CR 2"});
forestArray.push({"max": 42, "content": "1d4 grigs; CR 2"});
forestArray.push({"max": 47, "content": "1 grizzly bear; CR 4"});
forestArray.push({"max": 54, "content": "1 hunter; CR 1/3"});
forestArray.push({"max": 57, "content": "1d8 mites; CR 1"});
forestArray.push({"max": 63, "content": "1 owlbear; CR 4"});
forestArray.push({"max": 68, "content": "1 shambling mound; CR 6"});
forestArray.push({"max": 71, "content": "1 slurk; CR 2"});
forestArray.push({"max": 75, "content": "1 tatzlwyrm; CR 2"});
forestArray.push({"max": 79, "content": "1d4 trolls; CR 7"});
forestArray.push({"max": 82, "content": "1 werewolf; CR 2"});
forestArray.push({"max": 85, "content": "1 giant whiptail centipede; CR 3"});
forestArray.push({"max": 90, "content": "1 will o wisp; CR 6"});
forestArray.push({"max": 97, "content": "1d6 wolves; CR 4"});
forestArray.push({"max": 100, "content": "1 worg; CR 2"});


hillsArray.push({"max": 8, "content": "1D6 bandits; CR 1"});
hillsArray.push({"max": 14, "content": "1D4 Boars; CR 3"});
hillsArray.push({"max": 19, "content": "1 brush thylacine; CR 2"});
hillsArray.push({"max": 27, "content": "1d6 elk; CR 5"});
hillsArray.push({"max": 30, "content": "1 faerie dragon; CR 2"});
hillsArray.push({"max": 35, "content": "1d4 grigs; CR 2"});
hillsArray.push({"max": 45, "content": "1 hunter; CR 1/3"});
hillsArray.push({"max": 51, "content": "1d8 Kobolds; CR 1"});
hillsArray.push({"max": 55, "content": "1d8 mites; CR 1"});
hillsArray.push({"max": 59, "content": "1 owlbear; CR 4"});
hillsArray.push({"max": 62, "content": "1 shambling mound; CR 6"});
hillsArray.push({"max": 67, "content": "1 tatzlwyrm; CR 2"});
hillsArray.push({"max": 70, "content": "1d4 trolls; CR 7"});
hillsArray.push({"max": 74, "content": "1 werewolf; CR 2"});
hillsArray.push({"max": 81, "content": "1 giant whiptail centipede; CR 3"});
hillsArray.push({"max": 86, "content": "1 will o wisp; CR 6"});
hillsArray.push({"max": 95, "content": "1d6 wolves; CR 4"});
hillsArray.push({"max": 100, "content": "1 worg; CR 2"});


mountainsArray.push({"max": 7, "content": "1 hoarfrost spirit; CR 3; Pathfinder #51 pg 14"});
mountainsArray.push({"max": 14, "content": "1 ice troll; CR 4; Bestiary 2 pg 271"});
mountainsArray.push({"max": 43, "content": "1 yeti; CR 4; Bestiary pg 287"});
mountainsArray.push({"max": 56, "content": "1 frost drake; CR 7 Bestiary 2 pg 108"});
mountainsArray.push({"max": 69, "content": "1 frost giant; CR 9 Bestiary pg 149"});
mountainsArray.push({"max": 75, "content": "1 witchfire; CR 9; Bestiary 2 pg 284"});
mountainsArray.push({"max": 84, "content": "1 frostfallen mammoth; CR 10; Pathfinder #51 pg 84"});
mountainsArray.push({"max": 92, "content": "1 saumen kar; CR 10; Pathfinder #51 pg 90"});
mountainsArray.push({"max": 100, "content": "1 frost worm; CR 12; Bestiary 2 pg 126"});


tundraArray.push({"max": 6, "content": "1D6 bandits; CR 1"});
tundraArray.push({"max": 15, "content": "1D4 Boars; CR 3"});
tundraArray.push({"max": 20, "content": "1 brush thylacine; CR 2"});
tundraArray.push({"max": 28, "content": "1d6 elk; CR 5"});
tundraArray.push({"max": 32, "content": "1 faerie dragon; CR 2"});
tundraArray.push({"max": 38, "content": "1d4 grigs; CR 2"});
tundraArray.push({"max": 40, "content": "1 grizzly bear; CR 4"});
tundraArray.push({"max": 51, "content": "1 hunter; CR 1/3"});
tundraArray.push({"max": 55, "content": "1d8 Kobolds; CR 1"});
tundraArray.push({"max": 57, "content": "1d8 mites; CR 1"});
tundraArray.push({"max": 59, "content": "1 owlbear; CR 4"});
tundraArray.push({"max": 63, "content": "1 shambling mound; CR 6"});
tundraArray.push({"max": 66, "content": "1 tatzlwyrm; CR 2"});
tundraArray.push({"max": 71, "content": "1d4 trolls; CR 7"});
tundraArray.push({"max": 75, "content": "1 werewolf; CR 2"});
tundraArray.push({"max": 80, "content": "1 giant whiptail centipede; CR 3"});
tundraArray.push({"max": 86, "content": "1 will o wisp; CR 6"});
tundraArray.push({"max": 95, "content": "1d6 wolves; CR 4"});
tundraArray.push({"max": 100, "content": "1 worg; CR 2"});



var allArrays = {
"aquatic": aquaticArray,
"forest": forestArray,
"hills": hillsArray,
"mountains": mountainsArray,
"tundra": tundraArray
};

var randomNum = rand(100) + 1;
var arrayOfChoices = allArrays[argument];
if (!arrayOfChoices) {
return "no such set: " + argument;
}

var chosenString = "";
for (var itemIndex in arrayOfChoices) {
var item = arrayOfChoices[itemIndex];
if (randomNum <= item.max) {
chosenString = item.content;
break;
}
}
return chosenString;
}

</script>

<form>
<input type="button" name="Button2" value="Forest" onClick="this.form.textField1.value =

tableResults('forest')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button1" value="Lake/River" onClick="this.form.textField1.value =

tableResults('aquatic')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button5" value="Plains" onClick="this.form.textField1.value =

tableResults('tundra')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button3" value="Hills" onClick="this.form.textField1.value =

tableResults('hills')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

</BODY>
</HTML>
 
While informative and educational (thanks Mirtos & Jaynay27) Maybe Liz (or Colen?) can add a topic to capture "addons or community content" like this (similar to what exists within HL now)?

ITs less to do with "discussion" and more to do with "actual" tools to enhance.

The intent of the original thread choices were to separate discussion from request. Maybe its time for a third choice?

I am just afraid as the thread progresses, it will be lost to those new to the site.....

Keep up the good work guys.. interesting stuff...
 
once again - thank you for your help Mirtos, but my copy paste coding must be weak :eek:

Using your example the random number of bandits was produced with each click.

I then changed the whole table to the following, but found the random function did not work (tested in chrome - for example, I clicked a bunch of times & everytime trolls were returned as a result, there was always 4 of them. Curiously there was always 1 bandit and 6 wolves:confused:).

*edit* after testing some more, it would appear once the line making the Bandits appear all the time has been changed back to normal (in the first line of code specifying max value of 5) the rand function ceases to work. weird. I tested this with the original code where the only random function was in the bandit line (not the version of code pasted below, with rand functions attached to multiple lines).


aquaticArray.push({"max": 5, "content": rand(6) + " bandits; CR 1"});
aquaticArray.push({"max": 11, "content": rand(4) + " boars; CR 3"});
aquaticArray.push({"max": 17, "content": rand(4) + " boggards; CR 3"});
aquaticArray.push({"max": 21, "content": "1 brush thylacine; CR 2"});
aquaticArray.push({"max": 28, "content": rand(6) + " elk; CR 5"});
aquaticArray.push({"max": 32, "content": "1 faerie dragon; CR 2"});
aquaticArray.push({"max": 35, "content": rand(4) + " grigs; CR 2"});
aquaticArray.push({"max": 41, "content": "1 grizzly bear; CR 4"});
aquaticArray.push({"max": 49, "content": "1 hunter; CR 1/3"});
aquaticArray.push({"max": 57, "content": "1 nixie; CR 1"});
aquaticArray.push({"max": 62, "content": "1 owlbear; CR 4"});
aquaticArray.push({"max": 69, "content": "1 shambling mound; CR 6"});
aquaticArray.push({"max": 75, "content": "1 slurk; CR 2"});
aquaticArray.push({"max": 79, "content": "1 tatzlwyrm; CR 2"});
aquaticArray.push({"max": 83, "content": rand(4) + " trolls; CR 7"});
aquaticArray.push({"max": 90, "content": "1 will o wisp; CR 6"});
aquaticArray.push({"max": 96, "content": rand(6) + " wolves; CR 4"});
aquaticArray.push({"max": 100, "content": "1 worg; CR 2"});
 
Last edited:
It's possible we should rewrite the rand function to reseed each time. I will check that.

Is your rand function using Math.randomize() that was discussed in the other thread? Or maybe there's another bug in the code I didn't realize. I will look at it later.
 
As posted in the other Random Table thread:

Just want to say thank you very much for this code.
I used to code a long, long time ago, so I could understand
most of what you were doing here and successfully made
my own random encounter tables for Rise of the Runelords.

This has been invigorating looking at code again. :D

Again, thanks.
 
When i test on chrome, (at work not by RW) and changed the rand() function it worked a little better.

<HTML>
<HEAD>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<TITLE>Kingmaker - Stolen Land</TITLE>
</HEAD>
<BODY>

<script language="JavaScript">

// Some Arrays



function rand(x) {
return Math.floor(Math.random() * x) + 1;
}

function tableResults(argument) {

var aquaticArray = [];
var forestArray = [];
var hillsArray = [];
var mountainsArray = [];
var tundraArray = [];

aquaticArray.push({"max": 5, "content": rand(6) + " bandits; CR 1"});
aquaticArray.push({"max": 11, "content": rand(4) + " boars; CR 3"});
aquaticArray.push({"max": 17, "content": rand(4) + " boggards; CR 3"});
aquaticArray.push({"max": 21, "content": "1 brush thylacine; CR 2"});
aquaticArray.push({"max": 28, "content": rand(6) + " elk; CR 5"});
aquaticArray.push({"max": 32, "content": "1 faerie dragon; CR 2"});
aquaticArray.push({"max": 35, "content": rand(4) + " grigs; CR 2"});
aquaticArray.push({"max": 41, "content": "1 grizzly bear; CR 4"});
aquaticArray.push({"max": 49, "content": "1 hunter; CR 1/3"});
aquaticArray.push({"max": 57, "content": "1 nixie; CR 1"});
aquaticArray.push({"max": 62, "content": "1 owlbear; CR 4"});
aquaticArray.push({"max": 69, "content": "1 shambling mound; CR 6"});
aquaticArray.push({"max": 75, "content": "1 slurk; CR 2"});
aquaticArray.push({"max": 79, "content": "1 tatzlwyrm; CR 2"});
aquaticArray.push({"max": 83, "content": rand(4) + " trolls; CR 7"});
aquaticArray.push({"max": 90, "content": "1 will o wisp; CR 6"});
aquaticArray.push({"max": 96, "content": rand(6) + " wolves; CR 4"});
aquaticArray.push({"max": 100, "content": "1 worg; CR 2"});


forestArray.push({"max": 4, "content": "1D6 bandits; CR 1"});
forestArray.push({"max": 11, "content": "1D4 Boars; CR 3"});
forestArray.push({"max": 14, "content": "1d4 boggards; CR 3"});
forestArray.push({"max": 20, "content": "1 brush thylacine; CR 2"});
forestArray.push({"max": 29, "content": "1d6 elk; CR 5"});
forestArray.push({"max": 35, "content": "1 faerie dragon; CR 2"});
forestArray.push({"max": 42, "content": "1d4 grigs; CR 2"});
forestArray.push({"max": 47, "content": "1 grizzly bear; CR 4"});
forestArray.push({"max": 54, "content": "1 hunter; CR 1/3"});
forestArray.push({"max": 57, "content": "1d8 mites; CR 1"});
forestArray.push({"max": 63, "content": "1 owlbear; CR 4"});
forestArray.push({"max": 68, "content": "1 shambling mound; CR 6"});
forestArray.push({"max": 71, "content": "1 slurk; CR 2"});
forestArray.push({"max": 75, "content": "1 tatzlwyrm; CR 2"});
forestArray.push({"max": 79, "content": "1d4 trolls; CR 7"});
forestArray.push({"max": 82, "content": "1 werewolf; CR 2"});
forestArray.push({"max": 85, "content": "1 giant whiptail centipede; CR 3"});
forestArray.push({"max": 90, "content": "1 will o wisp; CR 6"});
forestArray.push({"max": 97, "content": "1d6 wolves; CR 4"});
forestArray.push({"max": 100, "content": "1 worg; CR 2"});


hillsArray.push({"max": 8, "content": "1D6 bandits; CR 1"});
hillsArray.push({"max": 14, "content": "1D4 Boars; CR 3"});
hillsArray.push({"max": 19, "content": "1 brush thylacine; CR 2"});
hillsArray.push({"max": 27, "content": "1d6 elk; CR 5"});
hillsArray.push({"max": 30, "content": "1 faerie dragon; CR 2"});
hillsArray.push({"max": 35, "content": "1d4 grigs; CR 2"});
hillsArray.push({"max": 45, "content": "1 hunter; CR 1/3"});
hillsArray.push({"max": 51, "content": "1d8 Kobolds; CR 1"});
hillsArray.push({"max": 55, "content": "1d8 mites; CR 1"});
hillsArray.push({"max": 59, "content": "1 owlbear; CR 4"});
hillsArray.push({"max": 62, "content": "1 shambling mound; CR 6"});
hillsArray.push({"max": 67, "content": "1 tatzlwyrm; CR 2"});
hillsArray.push({"max": 70, "content": "1d4 trolls; CR 7"});
hillsArray.push({"max": 74, "content": "1 werewolf; CR 2"});
hillsArray.push({"max": 81, "content": "1 giant whiptail centipede; CR 3"});
hillsArray.push({"max": 86, "content": "1 will o wisp; CR 6"});
hillsArray.push({"max": 95, "content": "1d6 wolves; CR 4"});
hillsArray.push({"max": 100, "content": "1 worg; CR 2"});


mountainsArray.push({"max": 7, "content": "1 hoarfrost spirit; CR 3; Pathfinder #51 pg 14"});
mountainsArray.push({"max": 14, "content": "1 ice troll; CR 4; Bestiary 2 pg 271"});
mountainsArray.push({"max": 43, "content": "1 yeti; CR 4; Bestiary pg 287"});
mountainsArray.push({"max": 56, "content": "1 frost drake; CR 7 Bestiary 2 pg 108"});
mountainsArray.push({"max": 69, "content": "1 frost giant; CR 9 Bestiary pg 149"});
mountainsArray.push({"max": 75, "content": "1 witchfire; CR 9; Bestiary 2 pg 284"});
mountainsArray.push({"max": 84, "content": "1 frostfallen mammoth; CR 10; Pathfinder #51 pg 84"});
mountainsArray.push({"max": 92, "content": "1 saumen kar; CR 10; Pathfinder #51 pg 90"});
mountainsArray.push({"max": 100, "content": "1 frost worm; CR 12; Bestiary 2 pg 126"});


tundraArray.push({"max": 6, "content": "1D6 bandits; CR 1"});
tundraArray.push({"max": 15, "content": "1D4 Boars; CR 3"});
tundraArray.push({"max": 20, "content": "1 brush thylacine; CR 2"});
tundraArray.push({"max": 28, "content": "1d6 elk; CR 5"});
tundraArray.push({"max": 32, "content": "1 faerie dragon; CR 2"});
tundraArray.push({"max": 38, "content": "1d4 grigs; CR 2"});
tundraArray.push({"max": 40, "content": "1 grizzly bear; CR 4"});
tundraArray.push({"max": 51, "content": "1 hunter; CR 1/3"});
tundraArray.push({"max": 55, "content": "1d8 Kobolds; CR 1"});
tundraArray.push({"max": 57, "content": "1d8 mites; CR 1"});
tundraArray.push({"max": 59, "content": "1 owlbear; CR 4"});
tundraArray.push({"max": 63, "content": "1 shambling mound; CR 6"});
tundraArray.push({"max": 66, "content": "1 tatzlwyrm; CR 2"});
tundraArray.push({"max": 71, "content": "1d4 trolls; CR 7"});
tundraArray.push({"max": 75, "content": "1 werewolf; CR 2"});
tundraArray.push({"max": 80, "content": "1 giant whiptail centipede; CR 3"});
tundraArray.push({"max": 86, "content": "1 will o wisp; CR 6"});
tundraArray.push({"max": 95, "content": "1d6 wolves; CR 4"});
tundraArray.push({"max": 100, "content": "1 worg; CR 2"});



var allArrays = {
"aquatic": aquaticArray,
"forest": forestArray,
"hills": hillsArray,
"mountains": mountainsArray,
"tundra": tundraArray
};

var randomNum = rand(100) + 1;
var arrayOfChoices = allArrays[argument];
if (!arrayOfChoices) {
return "no such set: " + argument;
}

var chosenString = "";
for (var itemIndex in arrayOfChoices) {
var item = arrayOfChoices[itemIndex];
if (randomNum <= item.max) {
chosenString = item.content;
break;
}
}
return chosenString;
}

</script>

<form>
<input type="button" name="Button2" value="Forest" onClick="this.form.textField1.value =

tableResults('forest')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button1" value="Lake/River" onClick="this.form.textField1.value =

tableResults('aquatic')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button5" value="Plains" onClick="this.form.textField1.value =

tableResults('tundra')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button3" value="Hills" onClick="this.form.textField1.value =

tableResults('hills')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

</BODY>
</HTML>
 
Ok - here is my final version (for anyone who may be interested) of the kingmaker random encounter tables (for book 1).

I added text to specify what to do for the buttons/tables etc....I hope it is clear.

I am not a programmer and full credit goes to mirtos for being an amazing help with this (I felt a little like a butcher, with my rampant cut and pasting :eek:)

*edit* forgot to mention - the 'mountains' section is redundant, but i left it in there in case people need a point of reference or want to mess around with the code a bit more.

Code:
<HTML>
<HEAD>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<TITLE>Kingmaker - Stolen Land</TITLE>
</HEAD>
<BODY>

<script language="JavaScript">

// Some Arrays



function rand(x) {
return Math.floor(Math.random() * x) + 1;
}

function tableResults(argument) {

var hexencounterArray = [];
var DayornightArray = [];
var aquaticArray = [];
var forestArray = [];
var hillsArray = [];
var mountainsArray = [];
var tundraArray = [];

hexencounterArray.push({"max": 5, "content": "Random Encounter"});
hexencounterArray.push({"max": 100, "content": "No Encounter"});

DayornightArray.push({"max": 15, "content": "Random Encounter"});
DayornightArray.push({"max": 100, "content": "No Encounter"});

aquaticArray.push({"max": 5, "content": rand(6) + " bandits; CR 1"});
aquaticArray.push({"max": 11, "content": rand(4) + " boars; CR 3"});
aquaticArray.push({"max": 17, "content": rand(4) + " boggards; CR 3"});
aquaticArray.push({"max": 21, "content": "1 brush thylacine; CR 2"});
aquaticArray.push({"max": 28, "content": rand(6) + " elk; CR 5"});
aquaticArray.push({"max": 32, "content": "1 faerie dragon; CR 2"});
aquaticArray.push({"max": 35, "content": rand(4) + " grigs; CR 2"});
aquaticArray.push({"max": 41, "content": "1 grizzly bear; CR 4"});
aquaticArray.push({"max": 49, "content": "1 hunter; CR 1/3"});
aquaticArray.push({"max": 57, "content": "1 nixie; CR 1"});
aquaticArray.push({"max": 62, "content": "1 owlbear; CR 4"});
aquaticArray.push({"max": 69, "content": "1 shambling mound; CR 6"});
aquaticArray.push({"max": 75, "content": "1 slurk; CR 2"});
aquaticArray.push({"max": 79, "content": "1 tatzlwyrm; CR 2"});
aquaticArray.push({"max": 83, "content": rand(4) + " trolls; CR 7"});
aquaticArray.push({"max": 90, "content": "1 will o wisp; CR 6"});
aquaticArray.push({"max": 96, "content": rand(6) + " wolves; CR 4"});
aquaticArray.push({"max": 100, "content": "1 worg; CR 2"});


forestArray.push({"max": 4, "content": rand (6) + " bandits; CR 1"});
forestArray.push({"max": 11, "content": rand(4) + " Boars; CR 3"});
forestArray.push({"max": 14, "content": rand(4) + " boggards; CR 3"});
forestArray.push({"max": 20, "content": "1 brush thylacine; CR 2"});
forestArray.push({"max": 29, "content": rand(6) + " elk; CR 5"});
forestArray.push({"max": 35, "content": "1 faerie dragon; CR 2"});
forestArray.push({"max": 42, "content": rand(4) + " grigs; CR 2"});
forestArray.push({"max": 47, "content": "1 grizzly bear; CR 4"});
forestArray.push({"max": 54, "content": "1 hunter; CR 1/3"});
forestArray.push({"max": 57, "content": rand(8) + " mites; CR 1"});
forestArray.push({"max": 63, "content": "1 owlbear; CR 4"});
forestArray.push({"max": 68, "content": "1 shambling mound; CR 6"});
forestArray.push({"max": 71, "content": "1 slurk; CR 2"});
forestArray.push({"max": 75, "content": "1 tatzlwyrm; CR 2"});
forestArray.push({"max": 79, "content": rand(4) + " trolls; CR 7"});
forestArray.push({"max": 82, "content": "1 werewolf; CR 2"});
forestArray.push({"max": 85, "content": "1 giant whiptail centipede; CR 3"});
forestArray.push({"max": 90, "content": "1 will o wisp; CR 6"});
forestArray.push({"max": 97, "content": rand(6) + " wolves; CR 4"});
forestArray.push({"max": 100, "content": "1 worg; CR 2"});


hillsArray.push({"max": 8, "content": rand(6) + " bandits; CR 1"});
hillsArray.push({"max": 14, "content": rand(4) + " Boars; CR 3"});
hillsArray.push({"max": 19, "content": "1 brush thylacine; CR 2"});
hillsArray.push({"max": 27, "content": rand(6) + " elk; CR 5"});
hillsArray.push({"max": 30, "content": "1 faerie dragon; CR 2"});
hillsArray.push({"max": 35, "content": rand(4) + " grigs; CR 2"});
hillsArray.push({"max": 45, "content": "1 hunter; CR 1/3"});
hillsArray.push({"max": 51, "content": rand(8) + " Kobolds; CR 1"});
hillsArray.push({"max": 55, "content": rand(8) + " mites; CR 1"});
hillsArray.push({"max": 59, "content": "1 owlbear; CR 4"});
hillsArray.push({"max": 62, "content": "1 shambling mound; CR 6"});
hillsArray.push({"max": 67, "content": "1 tatzlwyrm; CR 2"});
hillsArray.push({"max": 70, "content": rand(4) + " trolls; CR 7"});
hillsArray.push({"max": 74, "content": "1 werewolf; CR 2"});
hillsArray.push({"max": 81, "content": "1 giant whiptail centipede; CR 3"});
hillsArray.push({"max": 86, "content": "1 will o wisp; CR 6"});
hillsArray.push({"max": 95, "content": rand(6) + " wolves; CR 4"});
hillsArray.push({"max": 100, "content": "1 worg; CR 2"});


mountainsArray.push({"max": 7, "content": "1 hoarfrost spirit; CR 3; Pathfinder #51 pg 14"});
mountainsArray.push({"max": 14, "content": "1 ice troll; CR 4; Bestiary 2 pg 271"});
mountainsArray.push({"max": 43, "content": "1 yeti; CR 4; Bestiary pg 287"});
mountainsArray.push({"max": 56, "content": "1 frost drake; CR 7 Bestiary 2 pg 108"});
mountainsArray.push({"max": 69, "content": "1 frost giant; CR 9 Bestiary pg 149"});
mountainsArray.push({"max": 75, "content": "1 witchfire; CR 9; Bestiary 2 pg 284"});
mountainsArray.push({"max": 84, "content": "1 frostfallen mammoth; CR 10; Pathfinder #51 pg 84"});
mountainsArray.push({"max": 92, "content": "1 saumen kar; CR 10; Pathfinder #51 pg 90"});
mountainsArray.push({"max": 100, "content": "1 frost worm; CR 12; Bestiary 2 pg 126"});


tundraArray.push({"max": 6, "content": rand(6) + " bandits; CR 1"});
tundraArray.push({"max": 15, "content": rand(4) + " Boars; CR 3"});
tundraArray.push({"max": 20, "content": "1 brush thylacine; CR 2"});
tundraArray.push({"max": 28, "content": rand(6) + " elk; CR 5"});
tundraArray.push({"max": 32, "content": "1 faerie dragon; CR 2"});
tundraArray.push({"max": 38, "content": rand(4) + " grigs; CR 2"});
tundraArray.push({"max": 40, "content": "1 grizzly bear; CR 4"});
tundraArray.push({"max": 51, "content": "1 hunter; CR 1/3"});
tundraArray.push({"max": 55, "content": rand(8) + " Kobolds; CR 1"});
tundraArray.push({"max": 57, "content": rand(8) + " mites; CR 1"});
tundraArray.push({"max": 59, "content": "1 owlbear; CR 4"});
tundraArray.push({"max": 63, "content": "1 shambling mound; CR 6"});
tundraArray.push({"max": 66, "content": "1 tatzlwyrm; CR 2"});
tundraArray.push({"max": 71, "content": rand(4) + " trolls; CR 7"});
tundraArray.push({"max": 75, "content": "1 werewolf; CR 2"});
tundraArray.push({"max": 80, "content": "1 giant whiptail centipede; CR 3"});
tundraArray.push({"max": 86, "content": "1 will o wisp; CR 6"});
tundraArray.push({"max": 95, "content": rand(6) + " wolves; CR 4"});
tundraArray.push({"max": 100, "content": "1 worg; CR 2"});



var allArrays = {
"Hex": hexencounterArray,
"DayNight": DayornightArray,
"aquatic": aquaticArray,
"forest": forestArray,
"hills": hillsArray,
"mountains": mountainsArray,
"tundra": tundraArray
};

var randomNum = rand(100) + 1;
var arrayOfChoices = allArrays[argument];
if (!arrayOfChoices) {
return "no such set: " + argument;
}

var chosenString = "";
for (var itemIndex in arrayOfChoices) {
var item = arrayOfChoices[itemIndex];
if (randomNum <= item.max) {
chosenString = item.content;
break;
} 
}
return chosenString;
}

</script>

As the PCs enter a hex, hit the button to see if there is an encounter (5% chance)

<form>
<input type="button" name="Button1" value="Hex Encounter" onClick="this.form.textField1.value = 

tableResults('Hex')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

For each day or night cycle spent exploring, hit the button to see if there is an encounter (15% chance) 

<form>
<input type="button" name="Button2" value="Day or night encounter" onClick="this.form.textField1.value = 

tableResults('DayNight')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

If there is a random encounter, hit the button of the corresponding terrain to generate an encounter.

<form>
<input type="button" name="Button3" value="Forest" onClick="this.form.textField1.value = 

tableResults('forest')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button4" value="Lake/River" onClick="this.form.textField1.value = 

tableResults('aquatic')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button5" value="Plains" onClick="this.form.textField1.value = 

tableResults('tundra')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

<form>
<input type="button" name="Button6" value="Hills" onClick="this.form.textField1.value = 

tableResults('hills')" size="" />
<textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea>
</form>

</BODY>
</HTML>
 
Last edited:
Back
Top