View Single Post
jkthomsen9
Senior Member
 
Join Date: Jun 2010
Location: Beaverton, OR
Posts: 267

Old August 10th, 2014, 05:02 PM
Again Thank you to all. This was so much FUN that I decided to try it on a different random encounter chart. I got it to work more or less but there are a couple tweaks I would like to do to this one.

1. I would like the button at the top of the text verses the bottom.
2. I would like to bold the name of the encounter.
3. I noticed that it doesn't like +,-, or ' in the text....is there a way past that?




<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>Varisia Caravan Encounters</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 varisiaArray = [];

varisiaArray.push({"max": 15, "content": "Bad Weather: Fog, rain, high winds, or some other form of bad weather slows the caravan, reducing its overall speed by half for the day unless the caravan makes a DC 12 Security check." });
varisiaArray.push({"max": 30, "content": "Bandit Ambush (CR 2): The caravan must make a DC 15 Security check to notice this ambush in time to react; if this check fails, the caravan takes a –2 penalty to its Armor Class and on attack rolls for the first round of combat. The ambushers could be a group of bandits, a gang of highwaymen, or even a small tribe of Nolander barbarians. Regardless of their makeup, the ambushers’ stats and aggression are identical (AC 14; hp 20; Attack +4; Damage 2d6+3). They fight to the death. If defeated, 1 cargo unit of treasure worth 250 gp can be recovered."});
varisiaArray.push({"max": 50, "content": "Goblin Raiders (CR 1/2): A shrieking band of goblins wielding dogslicers and broken branches attacks the caravan (AC 11; hp 10; Attack +1; Damage 1d8). If the PCs have a horse train, the goblins are more timid than normal and take a –2 penalty on attack rolls. If defeated, a search of the goblins reveals a single cargo unit of treasure worth 125 gp."});
varisiaArray.push({"max": 55, "content": "Ogre Assault (CR 3): A small band of ogres lumbers out of the surrounding foliage to attack the caravan (AC 15; hp 30; Attack +6; Damage 3d4+6). The ogres flee if reduced below 10 hit points. If they are slain, looting produces 2 cargo units of treasure worth 400 gp each."});
varisiaArray.push({"max": 65, "content": "Treacherous Road: The road conditions become hazardous. They might be muddy, partially flooded, or even blocked by a fallen tree. The caravan must make a DC 14 Security check or lose 2d6 miles of progress for the day as the situation is dealt with."});
varisiaArray.push({"max": 100,"content": "Varisian Caravan: The PCs encounter another Varisian caravan heading in the opposite direction. With a DC 12 Resolve check, the PCs can befriend the other caravan. If this encounter occurs during the day, the caravan can give the PCs advice as to what lies ahead, reducing the chance of an encounter to 5% per day for the next 1d6 days. If the encounter occurs during the evening, the caravan agrees to share their camp, allowing the PCs to trade with them. The caravan can purchase up to 2,000 gp in objects, and can offer anything worth 600 gp or less for sale."});



var allArrays = {
"varisia": varisiaArray,
};

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="Varisia Caravan Encounters" onClick="this.form.textField1.value = tableResults

('varisia')" size="" />
<textarea name="textField1" cols="40" rows="10" wrap="soft"></textarea>
</form>
jkthomsen9 is offline   #30 Reply With Quote