Hello peoples.
Been lurking here for a little bit and stealing ideas
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.
Been lurking here for a little bit and stealing ideas

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: