Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <!--
- ---
- Title: Boot Hill 1E character generator
- Author: krusader74
- Version: 0.3
- Date: 2016-10-18
- Copyright: Public Domain
- Description: >-
- Boot Hill is a western-themed RPG written by Brian Blume &
- Gary Gygax in 1975. This code may be used to generate chracters
- and simulate gunfights.
- Discussion: http://odd74.proboards.com/thread/12032/boot-hill-1e-character-generator
- JSFiddle: https://jsfiddle.net/krusader74/zLopw8k2
- Pastebin: http://pastebin.com/Zy5UfD85
- Screenshot: http://i.imgur.com/O1GYMym.png
- ...
- # NAME
- BootHill.html - Boot Hill 1E character generator
- # SYNOPSIS
- BootHill.html [QueryString]
- # DESCRIPTION
- The simplest use is to load the page into a web browser without a QueryString. If you are loading it from your local filesystem, you will likely be using a URL like so:
- file:///C:/Users/krusader74/Downloads/BootHill.html
- Then follow these instructions:
- 1. Hit the Generate Character button to randomly create a new character.
- 2. If desired, increase the experience with the + Won / + Lost buttons.
- 3. Choose a weapon from the drop down list.
- a. This makes a stat block for the weapon with its range, rate, speed, etc.
- b. It also computes First Shot and To Hit
- c. You can add modifiers like movement, surprise, range, etc.
- 4. To attack an opponent, click the Attack button. This randomly determines if you hit. If you hit, then it rolls randomly for
- a. Hit Location
- b. Wound Severity
- 5. To defend against an attack, input your opponent's chance to hit and damage modifiers, then click the Defend button. It randomly determines if you're hit. If you are, then it determines
- a. Hit Location: If you are hit in your right arm, then the program automatically switches to the left arm and applies the wrong hand penalty, unless your left arm is equally or more severely wounded then the right. Damage to arms affects your chances to hit. If both arms are severely damaged, then you cannot attack anymore.
- b. Wound Severity subtracts from your Strength. If Strength falls to 0 or less, you're unconscious and can't attack any more. A mortal wound kills your character and he can't attack anymore either.
- 6. Click the Reset Wounds button to erase any wounds (including a mortal wound) and reset your Strength to its original value.
- # OPTIONS
- Instead of randomly generating a character, you may specify his abilities in the QueryString like so:
- BootHill.html?GunAccuracy=80&ThrowingAccuracy=75&Bravery=52&Speed=22&Strength=57
- You must supply integer values between 1 and 100 for *all* 5 abilities:
- * GunAccuracy
- * ThrowingAccuracy
- * Bravery
- * Speed
- * Strength
- Additionally, you may specify your character's Experience like so:
- BootHill.html?GunAccuracy=80&ThrowingAccuracy=75&Bravery=52&Speed=22&Strength=57&Won=2&Lost=1
- by supplying *both* the number of gunfights he's
- * Won
- * Lost
- Options are case sensitive.
- **NOTE:** To use a QueryString with the JSFiddle-hosted code, modify this URL:
- http://fiddle.jshell.net/krusader74/zLopw8k2/show/?GunAccuracy=80&ThrowingAccuracy=75&Bravery=52&Speed=22&Strength=57&Won=2&Lost=1
- Notice we've changed the URL structure:
- * fiddle.jshell.net instead of jsfiddle.net
- * *show* added to the end of the URL before the query string
- **NOTE:** The QueryString is parsed when the body is loaded. So, to use different parameters, alter the URL and then reload the page.
- # AUTHORS
- * [krusader74](http://odd74.proboards.com/user/2141)
- # COPYRIGHT
- This software has been released by its author into the public domain.
- # SEE ALSO
- * Source code on [JSFiddle](https://jsfiddle.net/krusader74/zLopw8k2)
- * Source code on [Pastebin](http://pastebin.com/Zy5UfD85)
- * Screenshot on [Imgur](http://i.imgur.com/O1GYMym.png)
- * Example of making a custom character using a [QueryString on JSFiddle](http://fiddle.jshell.net/krusader74/zLopw8k2/show/?GunAccuracy=80&ThrowingAccuracy=75&Bravery=52&Speed=22&Strength=57&Won=2&Lost=1)
- * Discussion on the [Original D&D Discussion](http://odd74.proboards.com/thread/12032/boot-hill-1e-character-generator) message board
- # HISTORY
- Version Date Description
- --------- ----------- ---------------------------------------------------
- 0.1 2016-10-14 Initial release
- 0.2 2016-10-17 Added wound tracking
- 0.3 2016-10-18 Added QueryString processing and documentation
- -->
- <html>
- <head>
- <meta name="description" content="Boot Hill 1E character generator" />
- <meta name="author" content="krusader74" />
- <meta name="copyright" content="Public Domain" />
- <meta name="language" content="EN" />
- <meta name="revised" content="2016-10-18" />
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <link rel="author" href="http://odd74.proboards.com/user/2141" />
- <title>Boot Hill 1E character generator</title>
- <style>
- body {
- font-family: Arial, Helvetica, sans-serif;
- }
- th, td {
- padding: 10px;
- }
- </style>
- <script>
- // TABLES ----------------------------------------------------------------------
- var Accuracy = [
- [01, 05, "Very Poor", -9],
- [06, 15, "Poor", -6],
- [16, 25, "Below Average", -3],
- [26, 35, "Average", 0],
- [36, 50, "Above Average", 2],
- [51, 65, "Fair", 5],
- [66, 75, "Good", 7],
- [76, 85, "Very Good", 10],
- [86, 95, "Excellent", 15],
- [96, 98, "Crack Shot", 18],
- [99, 100, "Dead Eye", 20]];
- var Bravery = [
- [01, 10, "Coward", -6],
- [11, 20, "Cowardly", -3],
- [21, 35, "Average", 0],
- [36, 65, "Above Average", 3],
- [66, 80, "Brave", 6],
- [81, 90, "Very Brave", 10],
- [91, 98, "Fearless", 15],
- [99, 100, "Foolhardy", 15]];
- var Speed = [
- [01, 05, "Slow", -5],
- [06, 10, "Below Average", -2],
- [11, 20, "Average", 0],
- [21, 35, "Above Average", 2],
- [36, 50, "Quick", 4],
- [51, 65, "Very Quick", 6],
- [66, 80, "Fast", 9],
- [81, 90, "Very Fast", 12],
- [91, 95, "Lightning", 15],
- [96, 96, "Greased Lightning 96", 18],
- [97, 97, "Greased Lightning 97", 19],
- [98, 98, "Greased Lightning 98", 20],
- [99, 99, "Greased Lightning 99", 21],
- [100, 100, "Greased Lightning 100", 22]];
- var Strength = [
- [01, 02, 8, "Feeble"],
- [03, 05, 9, "Puny"],
- [06, 10, 10, "Frail"],
- [11, 17, 11, "Weakling"],
- [18, 25, 12, "Sickly"],
- [26, 40, 13, "Average"],
- [41, 60, 14, "Above Average"],
- [61, 75, 15, "Sturdy"],
- [76, 83, 16, "Hardy"],
- [84, 90, 17, "Strong"],
- [91, 95, 18, "Very Strong"],
- [96, 98, 19, "Powerful"],
- [99, 100, 20, "Mighty"]];
- var Weapons = [
- // Weapon, Short Range, Medium Range, Long Range, Rate, Speed, Ammunition, Reload first turn, Reload following turns
- ["Choose a weapon"],
- ["Thrown knife or tommahawk", 1, 2, 4, 1, "A"],
- ["Bow and arrows", 8, 20, 40, 1, "BA"],
- ["Thrown lance", 3, 6, 12, 1, "BA"],
- ["Derringer", 2, 4, 10, 1, "A", 1, 1, 1],
- ["Derringer, double barreled", 2, 4, 10, 2, "A", 2, 1, 1],
- ["Cap and ball revolver", 5, 10, 24, 3, "BA", 6, 0, 1],
- ["Std single action revolver", 6, 12, 30, 3, "F", 6, 1, 2],
- ["Double action revolver", 6, 12, 30, 3, "A", 6, 1, 2],
- ["Modified fast draw revolver", 4, 8, 18, 3, "VF", 6, 1, 2],
- ["Long barrel revolver", 8, 16, 36, 1, "BA", 6, 1, 2],
- ["Scatter gun", 4, 6, 10, 1, "BA", 1, 1, 1],
- ["Scatter gun, double barreled",4, 6, 10, 2, "BA", 2, 1, 1],
- ["Shotgun", 6, 10, 24, 1, "S", 1, 1, 1],
- ["Shotgun, double barreled", 6, 10, 24, 2, "S", 2, 1, 1],
- ["Civil war carbine", 12, 36, 100, 1, "S", 1, 1, 1],
- ["Civil war rifle", 18, 46, 130, 1, "VS", 1, 1, 1],
- ["Civil war repeating rifle", 15, 40, 120, 3, "S", 7, 1, 1],
- ["Standard rifle", 20, 50, 150, 3, "S", 15, 2, 2],
- ["Standard carbine", 12, 36, 100, 3, "BA", 12, 2, 2],
- ["Buffalo rifle", 30, 60, 120, 1, "VS", 1, 1, 1]];
- var WeaponSpeed = {
- "VS": -10,
- "S": -5,
- "BA": 0,
- "A": 5,
- "F": 8,
- "VF": 10};
- var Wounds = [
- ["None", 0],
- ["Wounds totalling less than 50% of Strength (-5 to hit)", -5],
- ["Wounds totalling 50% or more of Strength (-20 to hit)", -20]];
- var Surprise = [
- ["None", 0],
- ["Giving opponent first move", -3],
- ["Surprised", -5],
- ["Completely Surprised", -10]];
- var Range = [
- ["Short", 10],
- ["Medium", 0],
- ["Long", -20]];
- var Movement = [
- // Description, Adj Speed, Adj Firer, Adj Target
- ["None", 0, 0, 0],
- ["On foot -- Walk", 0, -5, -5],
- ["On foot -- Crawl", 0, -10, -5],
- ["On foot -- Run & Dodge", -20, -30, -20],
- ["On foot -- Run", -20, -20, -10],
- ["On horse -- Trot", -10, -15, -10],
- ["On horse -- Gallop", -10, -25, -15]];
- var Miscellaneous = [
- // Description speedAdj, toHitAdj
- ["Weapon at rest on solid object", 0, 20],
- ["More than one shot being fired by same figure", 0, -10],
- ["Scattergun at short range", 0, 20],
- ["Shotgun at short range", 0, 10],
- ["Wrong hand shooting", 0, -10],
- ["Drawing two guns", -5, 0],
- ["Firing two pistols", 0, -10],
- ["Hip shooting", -3, -10],
- ["Concealment (1/2 or more)", 0, -10],
- ["Already Aimed", 15, 0]];
- var Exact_Hit_Location = [
- [01, 10, "Left leg", 0, [[01, 40, "Light Wound, -3 from Strength"], [41, 100, "Serious Wound, -7 from Strength"], [0, 0, "Mortal Wound, figure hit is dead"]]],
- [11, 20, "Right leg", 1, [[01, 40, "Light Wound, -3 from Strength"], [41, 100, "Serious Wound, -7 from Strength"], [0, 0, "Mortal Wound, figure hit is dead"]]],
- [21, 25, "Left arm/hand", 2, [[01, 75, "Light Wound, -3 from Strength"], [76, 100, "Serious Wound, -7 from Strength"], [0, 0, "Mortal Wound, figure hit is dead"]]],
- [26, 30, "Right arm/hand", 3, [[01, 30, "Light Wound, -3 from Strength"], [31, 100, "Serious Wound, -7 from Strength"], [0, 0, "Mortal Wound, figure hit is dead"]]],
- [31, 40, "Right shoulder", 4, [[01, 40, "Light Wound, -3 from Strength"], [41, 90, "Serious Wound, -7 from Strength"], [91, 100, "Mortal Wound, figure hit is dead"]]],
- [41, 50, "Left shoulder", 5, [[01, 40, "Light Wound, -3 from Strength"], [41, 80, "Serious Wound, -7 from Strength"], [81, 100, "Mortal Wound, figure hit is dead"]]],
- [51, 70, "Abdomen/groin", 6, [[01, 40, "Light Wound, -3 from Strength"], [41, 80, "Serious Wound, -7 from Strength"], [81, 100, "Mortal Wound, figure hit is dead"]]],
- [71, 85, "Chest", 7, [[01, 20, "Light Wound, -3 from Strength"], [21, 60, "Serious Wound, -7 from Strength"], [61, 100, "Mortal Wound, figure hit is dead"]]],
- [86, 115, "Head", 8, [[01, 20, "Light Wound, -3 from Strength"], [21, 40, "Serious Wound, -7 from Strength"], [41, 100, "Mortal Wound, figure hit is dead"]]]];
- var Experience = [
- [0, 0, -10],
- [1, 2, -5],
- [3, 4, 0],
- [5, 6, 2],
- [7, 8, 6],
- [9, 10, 8],
- [11, Number.MAX_SAFE_INTEGER, 20]];
- // XP for successful showdown. Double for 1 against 2. Halve for 2 against 1.
- var XP_Speed = [
- [01, 50, 2],
- [51, 80, 1],
- [81, 100, 0]];
- var XP_Bravery = [
- [01, 65, 2],
- [66, 90, 1],
- [91, 100, 0]];
- var XP_Accuracy = [
- [01, 25, 3],
- [26, 50, 2],
- [51, 85, 1],
- [86, 100, 0]];
- // VARIABLES -------------------------------------------------------------------
- var query_string = {};
- var
- accuracyWithGunsPercentile,
- accuracyWithGunsName,
- accuracyWithGunsToHitAdj,
- accuracyWithThrownWeaponsPercentile,
- accuracyWithThrownWeaponsName,
- accuracyWithThrownWeaponsToHitAdj,
- braveryPercentile,
- braveryName,
- braveryToHitAdj,
- speedPercentile,
- speedName,
- speedFirstShotAdj,
- strengthPercentile,
- strengthName,
- strengthScore,
- origStrengthScore,
- Won,
- Lost,
- firstShot,
- toHit,
- LightWoundLeftArm,
- SeriousWoundLeftArm,
- LightWoundRightArm,
- SeriousWoundRightArm,
- armSpeedAdj,
- armToHitAdj,
- Unconscious,
- Dead;
- // CODE ------------------------------------------------------------------------
- // Percentile Dice
- function d100() {
- return 1 + Math.floor(Math.random() * 100);
- }
- // Function: getValue
- // Description: Used to extract info from tables given characteristic percentile
- // E.g., to hit adjustment for Accuracy: getValue(Accuracy, percentile, 3, 0);
- // E.g., name for Accuracy: getValue(Accuracy, percentile, 2, "");
- function getValue(table, percentile, col, neutral){
- return table.map(function(row){return (percentile>=row[0]&&percentile<=row[1])?row[col]:neutral;}).reduce(function(a,b){return a+b;});
- }
- // HTML helper functions
- function tbl(rows){
- return "<table>"+rows.join("\n")+"</table>";
- }
- function row(cols){
- return "<tr>"+cols.join("")+"</tr>";
- }
- function hdr(text){
- return "<th>"+text+"</th>";
- }
- function col(text){
- return "<td>"+text+"</td>";
- }
- function bold(text){
- return "<b>"+text+"</b>";
- }
- function sel(opts,id,onchange){
- return "<select id=\""+id+"\" onchange=\""+onchange+"\">"+opts.join("\n")+"</select>";
- }
- function opt(num,text){
- return "<option value=\""+num+"\">"+text+"</option>";
- }
- function span(id,text){
- return "<span id=\""+id+"\">"+text+"</span>";
- }
- function button(procname, text){
- return "<button onclick=\""+procname+"()\">"+text+"</button>";
- }
- function br(){
- return "<br/>";
- }
- function generateCharacter() {
- accuracyWithGunsPercentile = d100();
- accuracyWithGunsPercentile += bonus(accuracyWithGunsPercentile);
- accuracyWithGunsName = getValue(Accuracy, accuracyWithGunsPercentile, 2, "");
- accuracyWithGunsToHitAdj = getValue(Accuracy, accuracyWithGunsPercentile, 3, 0);
- accuracyWithThrownWeaponsPercentile = d100();
- accuracyWithThrownWeaponsPercentile += bonus(accuracyWithThrownWeaponsPercentile);
- accuracyWithThrownWeaponsName = getValue(Accuracy, accuracyWithThrownWeaponsPercentile, 2, "");
- accuracyWithThrownWeaponsToHitAdj = getValue(Accuracy, accuracyWithThrownWeaponsPercentile, 3, 0);
- braveryPercentile = d100();
- braveryPercentile += bonus(braveryPercentile);
- braveryName = getValue(Bravery, braveryPercentile, 2, "");
- braveryToHitAdj = getValue(Bravery, braveryPercentile, 3, 0);
- speedPercentile = d100();
- speedPercentile += bonus(speedPercentile);
- speedName = getValue(Speed, speedPercentile, 2, "");
- speedFirstShotAdj = getValue(Speed, speedPercentile, 3, 0);
- strengthPercentile = d100();
- strengthPercentile += bonus(strengthPercentile);
- strengthName = getValue(Strength, strengthPercentile, 3, "");
- strengthScore = getValue(Strength, strengthPercentile, 2, 0);
- origStrengthScore = strengthScore;
- Won = 0;
- Lost = 0;
- resetWounds();
- showWeaponList();
- showExperience();
- }
- function bonus(percentile) {
- var bonus;
- if(percentile>=01&&percentile<=50){
- bonus = 10;
- } else if (percentile>=51&&percentile<=70){
- bonus = 5;
- } else if (percentile>=71&&percentile<=100) {
- bonus = 0;
- } else {
- throw "bonus: percentile must be between 1 and 100";
- }
- return bonus;
- }
- function resetWounds() {
- strengthScore = origStrengthScore;
- firstShot = 0;
- toHit = 0;
- LightWoundLeftArm = false;
- SeriousWoundLeftArm = false;
- LightWoundRightArm = false;
- SeriousWoundRightArm = false;
- armSpeedAdj = 0;
- armToHitAdj = 0;
- Unconscious = false;
- Dead = false;
- document.getElementById('AttackResult').innerHTML = "";
- document.getElementById('DefenseResult').innerHTML = "";
- document.getElementById('Wounds').innerHTML = "";
- document.getElementById('WoundsList').innerHTML = "";
- if(document.getElementById('check4')!==null) {
- document.getElementById('check4').checked = false;
- }
- showCharacter();
- showBonusesAndPenalties();
- }
- function arm() {
- document.getElementById('check4').checked = false;
- armSpeedAdj = 0;
- armToHitAdj = 0;
- if(SeriousWoundRightArm){ // Must use wrong hand
- if(SeriousWoundLeftArm){
- // Can't shoot at all
- armSpeedAdj = -100;
- armToHitAdj = -100;
- } else if(LightWoundLeftArm) {
- // -25 Speed, -25 To Hit
- armSpeedAdj = -25;
- armToHitAdj = -25;
- } else {
- // Wrong hand shooting, -10 To Hit
- document.getElementById('check4').checked = true;
- armToHitAdj = -10;
- }
- } else if(LightWoundRightArm) { // Attempts to use wrong hand
- if(SeriousWoundLeftArm){
- // Can't use wrong hand
- // -25 Speed, -25 To Hit
- armSpeedAdj = -25;
- armToHitAdj = -25;
- } else if(LightWoundLeftArm) {
- // -25 Speed, -25 To Hit
- armSpeedAdj = -25;
- armToHitAdj = -25;
- } else {
- // Wrong hand shooting, -10 To Hit
- document.getElementById('check4').checked = true;
- armToHitAdj = -10;
- }
- } else {
- // No penalties to speed or to hit
- }
- }
- function showCharacter() {
- document.getElementById('CharacterSheet').innerHTML =
- tbl([
- row([hdr(" "), hdr("Roll"), hdr("Rating"), hdr("Modifier")]),
- row([col(bold("Gun Accuracy")), col(accuracyWithGunsPercentile), col(accuracyWithGunsName), col(accuracyWithGunsToHitAdj)]),
- row([col(bold("Throwing Accuracy")), col(accuracyWithThrownWeaponsPercentile), col(accuracyWithThrownWeaponsName), col(accuracyWithThrownWeaponsToHitAdj)]),
- row([col(bold("Bravery")), col(braveryPercentile), col(braveryName), col(braveryToHitAdj)]),
- row([col(bold("Speed")), col(speedPercentile), col(speedName), col(speedFirstShotAdj)]),
- row([col(bold("Strength")), col(strengthPercentile), col(strengthName), col(strengthScore)])
- ]);
- }
- function showWeaponList() {
- var n = 0;
- document.getElementById('Weapon').innerHTML =
- bold("Weapon: ") +
- sel( Weapons.map(function(w){return opt(n++,w[0]);}), "WeaponList", "doWeapon()" );
- document.getElementById('WeaponDetail').innerHTML = " ";
- }
- function showBonusesAndPenalties() {
- var sn = 0, fn = 0, tn = 0, rn = 0;
- var sl, fl, tl, rl;
- fl = sel( Movement.map(function(m){return opt(fn++,m[0]);}), "MovementFirer", "doWeapon()" );
- tl = sel( Movement.map(function(m){return opt(tn++,m[0]);}), "MovementTarget", "doWeapon()" );
- sl = sel( Surprise.map(function(s){return opt(sn++,s[0]);}), "Surprise", "doWeapon()" );
- rl = sel( Range.map(function(r){return opt(rn++,r[0]);}), "Range", "doWeapon()" );
- document.getElementById('BonusesAndPenalties').innerHTML =
- bold("Combat Bonuses and Penalties") +
- br() +
- tbl([
- row([col(bold("Movement/Firer")), col(fl)]),
- row([col(bold("Movement/Target")), col(tl)]),
- row([col(bold("Surprise")), col(sl)]),
- row([col(bold("Range")), col(rl)])
- ]) +
- br() +
- checkboxes();
- }
- function checkStatus(){
- if(Dead){
- alert("Your character is DEAD!!! R.I.P. Pardner!");
- return false;
- }
- if(Unconscious){
- alert("Your character is unconscious!");
- return false;
- }
- if(SeriousWoundLeftArm&&SeriousWoundRightArm){
- alert("Both your character's arms are shot off, so he can't fight!");
- return false;
- }
- return true;
- }
- function doWeapon() {
- var idx = document.getElementById('WeaponList').value;
- var mf = document.getElementById('MovementFirer').value;
- var mt = document.getElementById('MovementTarget').value;
- var surprise = document.getElementById('Surprise').value;
- var range = document.getElementById('Range').value;
- var toHitExperienceAdj = getValue(Experience, Won+Lost, 2, 0);
- var w;
- var speedMovementAdj, toHitMovementFirerAdj, toHitMovementTargetAdj, woundAdj, surpriseAdj, rangeAdj;
- var i, miscSpeedAdj = 0, miscToHitAdj = 0;
- arm();
- checkShotOrScatterGunAtShortRange();
- if(strengthScore<0.5*origStrengthScore) {
- document.getElementById('Wounds').innerHTML = Wounds[2][0];
- woundAdj = Wounds[2][1];
- } else if(strengthScore<origStrengthScore&&strengthScore>=0.5*origStrengthScore) {
- document.getElementById('Wounds').innerHTML = Wounds[1][0];
- woundAdj = Wounds[1][1];
- } else {
- document.getElementById('Wounds').innerHTML = Wounds[0][0];
- woundAdj = Wounds[0][1];
- }
- if(mf>=0&&mf<Movement.length) {
- speedMovementAdj = Movement[mf][1];
- toHitMovementFirerAdj = Movement[mf][2];
- } else {
- speedMovementAdj = 0;
- toHitMovementFirerAdj = 0;
- }
- if(mt>=0&&mt<Movement.length) {
- toHitMovementTargetAdj = Movement[mt][3];
- } else {
- toHitMovementTargetAdj = 0;
- }
- if(surprise>=0&&surprise<Surprise.length) {
- surpriseAdj = Surprise[surprise][1];
- } else {
- surpriseAdj = 0;
- }
- if(range>=0&&range<Range.length) {
- rangeAdj = Range[range][1];
- } else {
- rangeAdj = 0;
- }
- // Miscellaneous Adj
- for(i=0; i<Miscellaneous.length; i++) {
- if( document.getElementById('check'+i).checked ) {
- miscSpeedAdj += Miscellaneous[i][1];
- miscToHitAdj += Miscellaneous[i][2];
- }
- }
- if(idx==0){ // No Weapon
- document.getElementById('WeaponDetail').innerHTML = " ";
- firstShot = 0;
- toHit = 0;
- } else if(idx>=1&&idx<=3){ // Thrown Weapon
- w = Weapons[idx];
- firstShot = speedFirstShotAdj + WeaponSpeed[w[5]] + speedMovementAdj +
- woundAdj + surpriseAdj + miscSpeedAdj + armSpeedAdj;
- toHit = 50 + accuracyWithThrownWeaponsToHitAdj + braveryToHitAdj +
- toHitMovementFirerAdj + toHitMovementTargetAdj + woundAdj +
- rangeAdj + miscToHitAdj + toHitExperienceAdj + armToHitAdj;
- document.getElementById('WeaponDetail').innerHTML =
- bold(col(w[0]));
- document.getElementById('WeaponDetail').innerHTML +=
- tbl([
- row([col("Short Range"), col(w[1]), col("inches")]),
- row([col("Medium Range"), col(w[2]), col("inches")]),
- row([col("Long Range"), col(w[3]), col("inches")]),
- row([col("Rate"), col(w[4]), col("Note that if more than one shot is fired, 10% is subtracted from the accuracy of each shot")]),
- row([col("Speed"), col(w[5]), col(" ")]),
- row([col("First Shot"), col(firstShot), col(" ")]),
- row([col("To Hit"), col(toHit), col(" ")])
- ]);
- } else { // Gun
- w = Weapons[idx];
- firstShot = speedFirstShotAdj + WeaponSpeed[w[5]] + speedMovementAdj +
- woundAdj + surpriseAdj + miscSpeedAdj + armSpeedAdj;
- toHit = 50 + accuracyWithGunsToHitAdj + braveryToHitAdj +
- toHitMovementFirerAdj + toHitMovementTargetAdj + woundAdj +
- rangeAdj + miscToHitAdj + toHitExperienceAdj + armToHitAdj;
- document.getElementById('WeaponDetail').innerHTML =
- bold(col(w[0]));
- document.getElementById('WeaponDetail').innerHTML +=
- tbl([
- row([col("Short Range"), col(w[1]), col("inches")]),
- row([col("Medium Range"), col(w[2]), col("inches")]),
- row([col("Long Range"), col(w[3]), col("inches")]),
- row([col("Rate"), col(w[4]), col("Note that if more than one shot is fired, 10% is subtracted from the accuracy of each shot")]),
- row([col("Speed"), col(w[5]), col(" ")]),
- row([col("Ammunition"), col(w[6]), col(" ")]),
- row([col("Reload"), col(w[7]), col("first turn")]),
- row([col("Reload"), col(w[8]), col("following turns")]),
- row([col("First Shot"), col(firstShot), col(" ")]),
- row([col("To Hit"), col(toHit), col(" ")])
- ]);
- }
- }
- function checkShotOrScatterGunAtShortRange() {
- if(document.getElementById('Range').value==0) {
- if(document.getElementById('WeaponList').value==11||
- document.getElementById('WeaponList').value==12){
- document.getElementById('check2').checked = true;
- } else {
- document.getElementById('check2').checked = false;
- }
- if(document.getElementById('WeaponList').value==13||
- document.getElementById('WeaponList').value==14){
- document.getElementById('check3').checked = true;
- } else {
- document.getElementById('check3').checked = false;
- }
- } else {
- document.getElementById('check2').checked = false;
- document.getElementById('check3').checked = false;
- }
- }
- function checkboxes() {
- var i, j, checkbox, table = [], rho;
- for(i=0; i<4; i++){
- rho = [];
- for(j=0; j<3; j++){
- if(3*i+j>=Miscellaneous.length) break;
- checkbox = "<input type=\"checkbox\" id=\"check"+(3*i+j)+"\" onchange=\"doWeapon()\">"+Miscellaneous[3*i+j][0]+"</input>";
- rho = rho.concat(col(checkbox));
- }
- rho = row(rho); // your boat, gently down the stream
- table = table.concat(rho);
- }
- table = tbl(table);
- return table;
- }
- function isShotOrScatterGunAtShortRange() {
- if(document.getElementById('Range')!==null&&
- document.getElementById('Range').value==0&&
- (document.getElementById('WeaponList').value==11||
- document.getElementById('WeaponList').value==12||
- document.getElementById('WeaponList').value==13||
- document.getElementById('WeaponList').value==14))
- {
- return true;
- }
- return false;
- }
- function isShotOrScatterGunAtLongRange() {
- if(document.getElementById('Range')!==null&&
- document.getElementById('Range').value==2&&
- (document.getElementById('WeaponList').value==11||
- document.getElementById('WeaponList').value==12||
- document.getElementById('WeaponList').value==13||
- document.getElementById('WeaponList').value==14))
- {
- return true;
- }
- return false;
- }
- function attack(){
- if( checkStatus() ){
- doWeapon();
- if(d100()<=toHit) {
- woundOpponent();
- } else {
- document.getElementById('AttackResult').innerHTML =
- "Your shot misses your opponent.";
- }
- }
- }
- function defend(){
- var oppToHit, roll;
- oppToHit = document.getElementById('OppToHit').value;
- roll = d100();
- console.log("oppToHit="+oppToHit);
- console.log("roll="+roll);
- if(roll<=oppToHit) {
- woundSelf();
- } else {
- document.getElementById('DefenseResult').innerHTML =
- "Your opponent's shot misses you!";
- }
- }
- function woundOpponent(){
- var rollAdj = 0, locationRoll, woundRoll, idx, locationName, woundTable, wound;
- if(isShotOrScatterGunAtShortRange()){
- rollAdj = 15;
- } else if(isShotOrScatterGunAtLongRange()) {
- rollAdj = -20;
- }
- locationRoll = d100() + rollAdj;
- woundRoll = d100() + rollAdj;
- if(locationRoll<1||woundRoll<1) {
- document.getElementById('AttackResult').innerHTML = "No damage.";
- return;
- }
- if(locationRoll>100){
- locationRoll = 100;
- }
- if(woundRoll>100) {
- woundRoll = 100;
- }
- idx = getValue(Exact_Hit_Location, locationRoll, 3, 0);
- locationName = Exact_Hit_Location[idx][2];
- woundTable = Exact_Hit_Location[idx][4];
- wound = getValue(woundTable, woundRoll, 2, "");
- document.getElementById('AttackResult').innerHTML =
- "You successfully shoot your opponent in the " +
- locationName +
- " causing a " +
- wound;
- }
- function woundSelf(){
- var rollAdj, locationRoll, woundRoll, idx, locationName, woundTable, wound;
- rollAdj = parseInt(document.getElementById('DamageMod').value);
- locationRoll = d100() + rollAdj;
- woundRoll = d100() + rollAdj;
- if(locationRoll<1||woundRoll<1) {
- document.getElementById('DefenseResult').innerHTML = "No damage.";
- return;
- }
- if(locationRoll>100){
- locationRoll = 100;
- }
- if(woundRoll>100) {
- woundRoll = 100;
- }
- idx = getValue(Exact_Hit_Location, locationRoll, 3, 0);
- locationName = Exact_Hit_Location[idx][2];
- woundTable = Exact_Hit_Location[idx][4];
- wound = getValue(woundTable, woundRoll, 2, "");
- if(wound.match(/^Mortal/)){
- Dead = true;
- strengthScore = 0;
- } else if(wound.match(/^Serious/)){
- if(idx==2) {
- SeriousWoundLeftArm = true;
- } else if(idx==3) {
- SeriousWoundRightArm = true;
- }
- strengthScore -= 7;
- } else {
- if(idx==2) {
- LightWoundLeftArm = true;
- } else if(idx==3) {
- LightWoundRightArm = true;
- }
- strengthScore -= 3;
- }
- if(strengthScore<=0){
- Unconscious = true;
- }
- document.getElementById('DefenseResult').innerHTML =
- "Your opponent shoots you in the " +
- locationName +
- " causing a " +
- wound;
- document.getElementById('WoundsList').innerHTML +=
- "<li>" +
- locationName +
- " : " +
- wound +
- "</li>";
- showCharacter();
- doWeapon();
- checkStatus();
- }
- function showExperience() {
- document.getElementById('Experience').innerHTML =
- bold("Experience: ") +
- span("xp",Won+Lost) + " Total Gunfights: " +
- span("won", Won) + " Won " + button("incWon", "+") +
- " / " +
- span("lost", Lost) + " Lost " + button("incLost", "+");
- }
- function incWon() {
- Won++;
- document.getElementById('won').innerHTML = Won;
- document.getElementById('xp').innerHTML = Won + Lost;
- accuracyWithGunsPercentile += getValue(XP_Accuracy, accuracyWithGunsPercentile, 2, 0);
- accuracyWithGunsName = getValue(Accuracy, accuracyWithGunsPercentile, 2, "");
- accuracyWithGunsToHitAdj = getValue(Accuracy, accuracyWithGunsPercentile, 3, 0);
- braveryPercentile += getValue(XP_Bravery, braveryPercentile, 2, 0);
- braveryName = getValue(Bravery, braveryPercentile, 2, "");
- braveryToHitAdj = getValue(Bravery, braveryPercentile, 3, 0);
- speedPercentile += getValue(XP_Speed, speedPercentile, 2, 0);
- speedName = getValue(Speed, speedPercentile, 2, "");
- speedFirstShotAdj = getValue(Speed, speedPercentile, 3, 0);
- showCharacter();
- doWeapon();
- }
- function incLost() {
- Lost++;
- document.getElementById('lost').innerHTML = Lost;
- document.getElementById('xp').innerHTML = Won + Lost;
- doWeapon();
- }
- function setCharacter() {
- accuracyWithGunsPercentile = parseInt(query_string.GunAccuracy);
- accuracyWithGunsPercentile += bonus(accuracyWithGunsPercentile);
- accuracyWithGunsName = getValue(Accuracy, accuracyWithGunsPercentile, 2, "");
- accuracyWithGunsToHitAdj = getValue(Accuracy, accuracyWithGunsPercentile, 3, 0);
- accuracyWithThrownWeaponsPercentile = parseInt(query_string.ThrowingAccuracy);
- accuracyWithThrownWeaponsName = getValue(Accuracy, accuracyWithThrownWeaponsPercentile, 2, "");
- accuracyWithThrownWeaponsToHitAdj = getValue(Accuracy, accuracyWithThrownWeaponsPercentile, 3, 0);
- braveryPercentile = parseInt(query_string.Bravery);
- braveryName = getValue(Bravery, braveryPercentile, 2, "");
- braveryToHitAdj = getValue(Bravery, braveryPercentile, 3, 0);
- speedPercentile = parseInt(query_string.Speed);
- speedName = getValue(Speed, speedPercentile, 2, "");
- speedFirstShotAdj = getValue(Speed, speedPercentile, 3, 0);
- strengthPercentile = parseInt(query_string.Strength);
- strengthName = getValue(Strength, strengthPercentile, 3, "");
- strengthScore = getValue(Strength, strengthPercentile, 2, 0);
- origStrengthScore = strengthScore;
- if(query_string.Won&&query_string.Lost) {
- Won = parseInt(query_string.Won);
- Lost = parseInt(query_string.Lost);
- }
- resetWounds();
- showWeaponList();
- showExperience();
- }
- function doQueryString() {
- var query = top.location.search.substring(1);
- var vars = query.split("&");
- for (var i=0;i<vars.length;i++) {
- var pair = vars[i].split("=");
- if (typeof query_string[pair[0]] === "undefined") {
- query_string[pair[0]] = decodeURIComponent(pair[1]);
- } else if (typeof query_string[pair[0]] === "string") {
- var arr = [ query_string[pair[0]],decodeURIComponent(pair[1]) ];
- query_string[pair[0]] = arr;
- } else {
- query_string[pair[0]].push(decodeURIComponent(pair[1]));
- }
- }
- if(query_string.GunAccuracy&&query_string.ThrowingAccuracy&&query_string.Bravery&&query_string.Speed&&query_string.Strength) {
- setCharacter();
- document.getElementById('QueryString').innerHTML = button("setCharacter", "Reset character using query string");
- }
- }
- </script>
- </head>
- <body onload="doQueryString()">
- <div><img src="http://fontmeme.com/freefonts/img.php?f=194637&s=65&t=Boot%20Hill&c=000000" alt="Boot Hill"></div>
- <div><i>Character generator for the 1975 edition of the Western-themed RPG by Brian Blume & Gary Gygax.</i></div>
- <div id="CharacterSheet"></div>
- <div><button onclick="generateCharacter()">Generate Character</button></div>
- <div id="QueryString"></div>
- <div id="Experience"></div>
- <hr>
- <div id="Weapon"></div>
- <div id="BonusesAndPenalties"></div>
- <div id="WeaponDetail"></div>
- <div id="Attack"><button onclick="attack()">Attack</button><span id="AttackResult"></span></div>
- <hr>
- <div id="Defend">Opponent's chance to hit you (01--100): <input id="OppToHit" type="number" value="50"/> %
- <br/>Damage modifiers: <input type="radio" id="DamageMod" value="15"/> Shot/Scatter Gun at Long Range
- <input type="radio" id="DamageMod" value="20"/> Shot/Scatter Gun at Short Range
- <input type="radio" id="DamageMod" value="0" checked="checked"/> Neither
- <br/><button onclick="defend()">Defend</button> <span id="DefenseResult"></span>
- <br/><b>Wounds:</b> <span id="Wounds">None</span>
- <br/><ol id="WoundsList"></ol>
- <br/><button onclick="resetWounds()">Reset Wounds</button>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement