This commit is contained in:
Raktbastr 2025-04-03 11:10:35 -05:00
parent 8871c644fb
commit e5fe71ce46
16 changed files with 573 additions and 638 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View file

@ -1,14 +1 @@
// Adding from other files console.log(time.now)
// main.js
const variables = require("./variables.js");
variables.sleep(1000);
// variables.js
module.exports = { //add any functions or variables you want to export in here
sleep
}
function sleep(time) {
setTimeout(() => {}, time);
}

BIN
files/.DS_Store vendored Normal file

Binary file not shown.

151
files/encounters.js Normal file
View file

@ -0,0 +1,151 @@
// Holds encounter code, seperate from poiscreens.js
import { randomNumber } from "./functions.js";
export function calcEncounter() {
if (randomNumber(1,100) <= 20) {
if (location >= 255) {
if (locationA > locationB) {
if ((locationA >= 5 && locationA < 17) || (locationA >= 23 && locationA < 40)) {
initializeEncounter(NCR,4,true,true,false);
}
if (locationB >= 40) {
initializeEncounter(NCR,5,true,true,false);
}
} else if (locationA < locationB) {
if ((locationB >= 0 && locationB < 30) || (locationB >= 40 && locationB < 80)) {
initializeEncounter(abomination,3,true,true,false)
}
if ((locationB >= 30 && locationB < 40) || (locationB >= 90)) {
initializeEncounter(NCR,5,true,true,false)
}
if (locationB >= 80 && locationB < 90) {
initializeEncounter(enclave,4,true,true,false)
}
} else {
if (location >= 5 && location < 50) {
initializeEncounter(abomination,1,true,true,false)
}
if (location >= 50 && location < 200) {
initializeEncounter(MWBOS,2,true,true,false)
}
if (location >= 200 && location < 255) {
initializeEncounter(legion,3,true,true,false)
}
}
}
}
}
export function encounterMenuMaker(reqFactionEMM, diffWeightingEMM, forceOptEMM){
switch(diffWeightingEMM){
case 1:
reqFactionEMM = encounterDiffOne
break;
case 2:
reqFactionEMM = encounterDiffTwo
break;
case 3:
reqFactionEMM = encounterDiffThree
break;
case 4:
reqFactionEMM = encounterDiffFour
break;
case 5:
reqFactionEMM = encounterDiffFive
break;
}
var encounterDifficulty = (diffWeightingEMM * randomNumber(1, 20));
factionFailsafe = reqFactionEMM.toLowerCase();
switch(factionFailsafe){
case "NCR":
faction = 0;
break;
case "legion":
faction = 1;
break;
case "raider":
faction = 2;
break;
case "settler":
faction = 3;
break;
case "BOS":
faction = 4;
break;
case "abomination":
faction = 5;
break;
case "MWBOS":
faction = 6;
break;
}
if (forceOptEMM == true) {
if(encounterDifficulty <= 20){
encountered.push(encounterDiffOne[faction][randomNumber(0, encounterDiffOne[faction].length - 1)]);
} else if(21 <= encounterDifficulty <= 40){
encountered.push(encounterDiffTwo[faction][randomNumber(0, encounterDiffTwo[faction].length - 1)]);
} else if(41 <= encounterDifficulty <= 60){
encountered.push(encounterDiffThree[faction][randomNumber(0, encounterDiffThree[faction].length - 1)]);
} else if(61 <= encounterDifficulty <= 80){
encountered.push(encounterDiffFour[faction][randomNumber(0, encounterDiffFour[faction].length - 1)]);
} else {
encountered.push(encounterDiffFive[faction][randomNumber(0, encounterDiffFive[faction].length - 1)]);
}
return encountered[encountered.length - 1];
} else {
let x = randomNumber(0, 100)
if (x >= 75) {
if (x <=80) {
encountered.push(encounterDiffOne[raider][randomNumber(0, encounterDiffOne[raider].length - 1)])
}
if (x <=90) {
encountered.push(encounterDiffOne[settler][randomNumber(0, encounterDiffOne[settler].length - 1)])
}
if (x <=100) {
encountered.push(encounterDiffOne[abomination][randomNumber(0, encounterDiffOne[abomination].length - 1)])
}
}
if (x < 75) {
encountered.push(encounterDiffOne[faction][randomNumber(0, encounterDiffOne[faction].length - 1)])
}
}
}
export function initializeEncounter(reqFaction, diffWeighting, fight, flee, forceFaction){
var encounter = encounterMenuMaker(reqFaction, diffWeighting, forceFaction);
console.clear();
console.log("You come across a " + encounter.name);
var encounterHealth = randomNumber(encounter.minHealth, encounter.maxHealth);
console.log("Health: " + encounterHealth);
console.log("What would you like to do?");
console.log("--------------------------");
var playerOptions = 1;
console.log(playerOptions + ") Inventory");
playerOptions++
if(fight == true){
console.log(playerOptions + ") Fight");
playerOptions++;
}
if(flee == true){
console.log(playerOptions + ") Flee");
playerOptions++;
}
while(true) {
let encounterInput = userInput("Enter: ")
switch(encounterInput) {
case "1":
console.log(inventory);
case "2":
initCombat(encounter);
break;
case "3":
if (reputation.reqFaction < 4) {
if (randomNumber(1,100) < 40){
console.log("You tried to flee... but they noticed you.");
initCombat(encounter);
}
}
}
}
}

122
files/functions.js Normal file
View file

@ -0,0 +1,122 @@
// Holds all functions used in multiple files
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
var readlineSync = require('readline-sync');
import { food, foodRate, health, healthCap, locationA, locationB, name, radPoints, radSeverity, walkRate } from "./variables.js";
// Used for basic functions, not game specific
export function userInput(question) { // Basic user input functions, takes in the question to be asked.
let answer = readlineSync.question(question);
return(answer);
}
export function randomNumber(min, max) { // Takes in two parameters, min and max, and returns a random number between those boundries.
while (true) {
var randNum = Math.floor(Math.random() * (max+1));
if (randNum >= min) { break; }
}
return randNum;
}
// Used for game
export function healthCapCalc() { // Calculates HP cap given current radPoints
healthCap = healthCap-radPoints;
if (health > healthCap) { health = healthCap; }
}
export function radPointsCalc() { // Calculates radPoints given walk/foodrate
radPoints = radPoints + 0.5 * (radSeverity * 10 + 5 * (walkRate + foodRate))
}
export function eatFood() { // Calculates food amount after a day of eating
if (food == 0) {
health = health - 3*walkRate
} else {
food = food - walkRate * foodRate
}
}
export function checkLose() { // Checks to see if any lose conditions have been met
if (health <= 0 || radPoints >= 100) {
death();
}
}
export function calcLocation() {
if (walkRate == 1) {
if (path = 0) {
location++;
}
if (path = 1) {
locationA++;
}
if (path = 2) {
locationB++;
}
}
if (walkRate == 2) {
if (path = 0) {
location * 2;
}
if (path = 1) {
locationA * 2;
}
if (path = 2) {
locationB * 2;
}
}
if (walkRate == 3) {
if (path = 0) {
location * 3;
}
if (path = 1) {
locationA * 3;
}
if (path = 2) {
locationB * 3;
}
}
}
function death() {
let random = variables.randomNumber(1,3);
if (random = 1) { deathScreen1(); }
if (random = 2) { deathScreen2(); }
if (random = 3) { deathScreen3(); }
}
function death1() {
console.log("")
}
function death2() {
}
function death3() {
}
function timeDeath() { // The death screen for passing the time limit
console.clear;
console.log("Your PIP-Boy starts ringing...\n\n")
console.log("BEEP...BEEP...BEEP");
console.log("INCOMING MESAGE FROM: Raven_Rock_Comms-1\n\n");
console.log("|||||||")
console.log("|| Enclave Intranet Messager");
console.log("|||||||")
console.log("|| Message From: automessager");
console.log("|||||||\n\n")
console.log("Dear, "+name+",\n\n");
console.log("You have failed to faithfully execute the tasks laid before you in a timely manner.");
console.log("In consequence you have been dishonorably discharged from the Enclave Armed Forces");
console.log("Please return to the nearest active Enclave Military Installation immeditely\n\n");
console.log("Signed, Enclave Internal Messager");
console.clear;
}

View file

@ -1,216 +0,0 @@
// Holds functions needed to play the game
const variables = require("./variables.js");
const death = require("./deathscreens.js");
const poi = require("./poiscreens.js");
module.exports = {
eatFood,
calcSickPoints,
scavenge,
checkLose,
calcLocation,
calcEncounter,
travelScreen,
checkPOI,
}
function eatFood() {
if (variables.food == 0) {
variables.health - 3*variables.travelSpeed
} else if (variables.isSick == true) {
variables.food = variables.food-((variables.travelSpeed*variables.foodAmt)+variables.sickSeverity);
} else {
variables.food = variables.food-(variables.travelSpeed*variables.foodAmt);
}
variables.health = variables.health+(5*variables.foodAmt);
}
function calcSickPoints() {
if (variables.isSick = true) {
variables.sickPoints = variables.sickPoints+((variables.sickSeverity-(0.5*variables.foodAmt))+(0.5*(variables.travelSpeed+variables.radSeverity)));
}
}
function scavenge() { // Rolls a random number between 1 and 100 to see which loot table you get, then picks a random item from it. ADD COOLDOWN!
if (variables.daysSinceScav < 20 ) {
console.log("You must wait "+(20-variables.daysSinceScav)+" days until you can scavenge again")
} else {
let luck = variables.randomNumber(1,100);
if (luck <= 20) {
let group = 0;
let random = variables.randomNumber(variables.lootTables[group][0], variables.lootTables[group][3]);
inventory.push(random);
} else if (luck <= 40) {
let group = 1;
let random = variables.randomNumber(variables.lootTables[group][0], variables.lootTables[group][3]);
inventory.push(random);
} else if (luck <= 60) {
let group = 2;
let random = variables.randomNumber(variables.lootTables[group][0], variables.lootTables[group][3]);
inventory.push(random);
} else if (luck <= 80) {
let group = 3;
let random = variables.randomNumber(variables.lootTables[group][0], variables.lootTables[group][3]);
inventory.push(random);
} else if (luck <= 100) {
let group = 4;
let random = variables.randomNumber(variables.lootTables[group][0], variables.lootTables[group][3]);
inventory.push(random);
}
}
}
function checkLose() { // Checks to see if any lose conditions have been met
if (variables.health <= 0 || variables.sickPoints >= 50) {
death.deathScreen();
}
if (variables.day >= 365) {
death.timeDeath();
}
}
function calcLocation() { // Calculates your location in the world using location points, You move your move speed per day, but 3/4 of it if you are sick
if (variables.travelSpeed == 1) {
if (variables.isSick == true) {
variables.location = variables.location+0.75;
} else {
variables.location++;
}
}
if (variables.travelSpeed == 2) {
if (variables.isSick == true) {
variables.location = variables.location+1.5;
} else {
variables.location = variables.location+2;
}
}
if (variables.travelSpeed == 3) {
if (variables.isSick == true) {
variables.location = variables.location+2.25;
} else {
variables.location = variables.location+3;
}
}
if (variables.location > 300) {
variables.location = 300;
}
}
// Rundown on how I did this:
/**
* calcEncounter() checks what faction territory you are in and pipes the respective faction into initilizeEncounter().
*
* initEncounter() is pretty much the same however you can use forceFaction (set to true) to bypass the random raider/abomination chance.
* forceFaction will always be false unless under certian circumstances (eg. Lost Hills, Legion Territory, Malcom Holmes).
* Turns out the fight/flee variables work exactly how I want so I did not change them.
*
* encounterMenuMaker() was changed to account for forceFaction. If forceFaction is set to true, EMM's equivilant forceOpt will take its value.
* If true it runs the code you had before, no changes. If it is false it will roll a dice to see if you get the normal faction, given by your switch statement,
* or a radier/abomination. If it is a radier/abomination it will then roll a 50/50. The code for both is the same as the default faction code except that
* 'faction' will just be 'raider' or 'abomination' instead of the default.
*
* I also implemented auto difficulty scaling. Instead of piping in 'encounterDiffOne' you just input the interger of it. This is because you cant
* use a string as a variable name and or whatever. Just trust me, this is the only way it works. initEncounter() will figure it out on the otherside.
*/
function calcEncounter() {
if (variables.randomNumber(1,100) <= 20) {
if (variables.location >= 255) {
if (variables.locationA > variables.locationB) {
if ((variables.locationA >= 5 && variables.locationA < 17) || (variables.locationA >= 23 && variables.locationA < 40)) {
poi.initializeEncounter(NCR,4,true,true,false);
}
if (variables.locationB >= 40) {
poi.initializeEncounter(NCR,5,true,true,false);
}
} else if (variables.locationA < variables.locationB) {
if ((variables.locationB >= 0 && variables.locationB < 30) || (variables.locationB >= 40 && variables.locationB < 80)) {
poi.initializeEncounter(abomination,3,true,true,false)
}
if ((variables.locationB >= 30 && variables.locationB < 40) || (variables.locationB >= 90)) {
poi.initializeEncounter(NCR,5,true,true,false)
}
if (variables.locationB >= 80 && variables.locationB < 90) {
poi.initializeEncounter(enclave,4,true,true,false)
}
} else {
if (variables.location >= 5 && variables.location < 50) {
poi.initializeEncounter(abomination,1,true,true,false)
}
if (variables.location >= 50 && variables.location < 200) {
poi.initializeEncounter(MWBOS,2,true,true,false)
}
if (variables.location >= 200 && variables.location < 255) {
poi.initializeEncounter(legion,3,true,true,false)
}
}
}
}
}
function checkPOI() {
if (variables.location < 300) {
if (variables.location >= (poi.pois[poi.poiCounter].location)-3 && variables.location <= poi.pois[poi.poiCounter].location)
}
if (variables.locationA > 0) {
}
if (variables.locationB > 0) {
}
}
var travelFrame = 0;
function travelScreen() {
if (travelFrame < 0 || travelFrame > 1) {
travelFrame = 0;
} else if (travelFrame == 0) {
console.clear();
console.log("┌──────────────────────────────────────┐");
console.log("│ │");
console.log("│ │");
console.log("│ │");
console.log("│ │");
console.log("│ ◜─◝ │");
console.log("│ ◟_◞ │");
console.log("│ /║\\ │");
console.log("│ \\V/ │");
console.log("│ / \\ │");
console.log("│ ▁\\ ▔╹ │");
console.log("│======================================│");
console.log("│ . . - . . - . . . - │");
console.log("│ - . . . . . . - . .│");
console.log("└──────────────────────────────────────┘");
console.log("Press [ENTER] to open Pip-Boy");
console.log("Current Health: "+variables.health);
console.log("Food Amt: "+variables.food);
console.log("Distance to next POI: ");
travelFrame++
} else {
console.clear();
console.log("┌──────────────────────────────────────┐");
console.log("│ │");
console.log("│ │");
console.log("│ │");
console.log("│ │");
console.log("│ ◜─◝ │");
console.log("│ ◟_◞ │");
console.log("│ /║\\ │");
console.log("│ \\V/ │");
console.log("│ \\ │");
console.log("│ ▁│▔╹ │");
console.log("│======================================│");
console.log("│ - . - . . . - . - . │");
console.log("│ - . . - . . . - .│");
console.log("└──────────────────────────────────────┘");
console.log("Press [ENTER] to open Pip-Boy");
console.log("Current Health: "+variables.health);
console.log("Food Amt: "+variables.food);
console.log("Distance to next POI: ");
travelFrame--
}
}
function haltTravelScreen() {
}

View file

@ -1,2 +0,0 @@
// Hunting Game, if we even decide to do it.
const variables = require("./variables.js");

View file

@ -1,9 +1,5 @@
const variables = require("./variables"); import { userInput } from "./functions.js";
const main = require("./main"); import { inventory, userInput } from "./variables.js";
module.exports = {
inventoryMenuM,
};
//Builds the main menu inventory //Builds the main menu inventory
function inventoryMenuM(){ function inventoryMenuM(){
@ -13,7 +9,7 @@ function inventoryMenuM(){
console.log("1) Supplies"); console.log("1) Supplies");
console.log("2) Equipment"); console.log("2) Equipment");
console.log("[spacebar to exit]"); console.log("[spacebar to exit]");
var userInput = variables.userInput("Enter: "); let invChoice = userInput("Enter: ");
switch(userInput){ switch(userInput){
case "1": case "1":
supplyInventory(); supplyInventory();
@ -29,11 +25,11 @@ function supplyInventory(){
console.clear(); console.clear();
console.log("SUPPLIES"); console.log("SUPPLIES");
console.log("---------"); console.log("---------");
for(var a = 0; a < variables.inventory[0].length;){ for(var a = 0; a < inventory[0].length;){
console.log((a + 1) + ") " + variables.inventory[0][a].name); console.log((a + 1) + ") " + inventory[0][a].name);
a++; a++;
} }
variables.userInput("[Enter to return]"); userInput("[Enter to return]");
console.clear(); console.clear();
inventoryMenuM(); inventoryMenuM();
} }
@ -43,11 +39,11 @@ function equipmentInventory(){
console.clear(); console.clear();
console.log("EQUIPMENT"); console.log("EQUIPMENT");
console.log("---------"); console.log("---------");
for(var a = 0; a < variables.inventory[1].length;){ for(var a = 0; a < inventory[1].length;){
console.log((a + 1) + ") " + variables.inventory[1][a].name); console.log((a + 1) + ") " + inventory[1][a].name);
a++; a++;
} }
variables.userInput("[Enter to return]"); userInput("[Enter to return]");
console.clear(); console.clear();
inventoryMenuM(); inventoryMenuM();
} }

View file

@ -1,10 +1,8 @@
// Program is started from here, runs functions from other files. // Program is started from here, runs functions from other files.
const variables = require("./variables.js"); import { userInput, calcLocation, radPointsCalc, healthCapCalc, checkLose } from './functions.js';
const game = require("./game.js"); import { pois, poiCounter } from './poiscreens.js';
const shops = require("./shops"); import { name, prewarmoney } from './variables.js';
const readline = require('node:readline');
const encounterMenus = require("./poiscreens.js");
const inventoryStuff = require("./inventory.js");
console.clear(); console.clear();
console.log("__________________________________________________________________________________________________________________________________"); console.log("__________________________________________________________________________________________________________________________________");
@ -13,57 +11,56 @@ console.log(" / ' / / /
console.log("---/__-------__---/---/----__---------_/_---------/-------__----__----__---__----__---_--_----__-------/___ /----__----__----__-/-"); console.log("---/__-------__---/---/----__---------_/_---------/-------__----__----__---__----__---_--_----__-------/___ /----__----__----__-/-");
console.log(" / / ) / / / ) / / / o / / ) / ) /___) (_ ` / ) / / ) /___) / | / ) / ) / / "); console.log(" / / ) / / / ) / / / o / / ) / ) /___) (_ ` / ) / / ) /___) / | / ) / ) / / ");
console.log("_/________(___(_/___/___(___/_(___(__(_ __o_____/____/_(___/_/___/_(___ _(__)_(___/_/_/__/_(___ _____/_____|__(___/_(___(_(___/___"); console.log("_/________(___(_/___/___(___/_(___(__(_ __o_____/____/_(___/_/___/_(___ _(__)_(___/_/_/__/_(___ _____/_____|__(___/_(___(_(___/___");
console.log("Credits: Bethesda Game Studio\n") console.log("Credits: Bethesda Game Studio \n");
variables.sleep(1000);
while(true) { console.log("What would you like to do?");
console.log("What would you like to do?"); console.log("--------------------------");
console.log("--------------------------"); console.log("1) Start new game");
console.log("1) Start new game"); console.log("2) Learn How to play");
console.log("2) Learn How to play"); console.log("3) Quit Game");
console.log("3) Quit Game"); console.log("4) Dev stuff for testing");
console.log("4) Dev stuff for testing");
let mainMenuInput = variables.userInput("Enter: ") var mainMenuInput = userInput("Enter: ")
switch(mainMenuInput) {
case "1": switch(mainMenuInput) {
startGame(); case "1":
break; startGame();
case "2": break;
console.log("Follow the link below for a game manual.") case "2":
console.log("[ENTER LINK HERE]") console.log("Follow the link below for a game manual.")
break; console.log("[ENTER LINK HERE]")
case "3": break;
console.log("Quitting Game..."); case "3":
variables.sleep(1000); console.log("Quitting Game...");
break; break;
case "4": case "4":
game.travelScreen(); console.log(pois[poiCounter]);
break; break;
} }
}
function startGame() { // So far what I have is filler and testing, feel free to change. function startGame() { // So far what I have is filler and testing, feel free to change.
console.clear(); console.clear();
variables.sleep(1000); name = userInput("What is your name? ");
variables.name = variables.userInput("What is your name? "); console.log(name+" Is now your name...")
console.log(variables.name+" Is now your name...")
variables.sleep(2000);
console.clear(); console.clear();
console.log("Intro:"); console.log("Intro:");
console.log("You are an ordinary loyal Enclave Soldier working at Raven Rock. \nYou are typing away at your terminal, entering reports of recovered materials when a message flashes on it.\n\nDear "+variables.name+",\n\n This is a direct order from the Enclave High Command. \nIgnore all previous directives. Proceed to Camp Navarro immediately. \nSeek safe passage through the Brotherhood and NCR territories. \nDo not disclose your mission to anyone but Enclave Personel with \nsecurity clearance 5 or higher. Reqisition supplies before departure. \n\n Signed, President John Henry Eden\n\n"); console.log("You are an ordinary loyal Enclave Soldier working at Raven Rock. \nYou are typing away at your terminal, entering reports of recovered materials when a message flashes on it");
console.log("|||||||")
console.log("|| Enclave Intranet Messager");
console.log("")
console.log("|| Message From: potus");
console.log("|||||||\n\n")
console.log("Dear "+name+",\n\n This is a direct order from the Enclave High Command. \nIgnore all previous directives. Proceed to Camp Navarro immediately. \nSeek safe passage through the Brotherhood and NCR territories. \nDo not disclose your mission to anyone but Enclave Personel with \nsecurity clearance 5 or higher. Reqisition supplies before departure. \nYou have been given 1 YEAR to complete this mission or face discharge.\n\n Signed, President John Henry Eden\n\n");
variables.userInput("[Enter to open shop]"); userInput("[Enter to open shop]");
console.clear(); console.clear();
variables.prewarmoney = 500; prewarmoney = 500;
shops.ravenRock(); ravenRockShop();
for (variables.location = 0; variables.location <= 255; variables.location++) { for (variables.location = 0; variables.location <= 255; variables.location++) {
game.calcLocation(); calcLocation();
game.calcEncounter(); radPointsCalc();
game.checkPOI(); healthCapCalc
game.calcSickPoints(); checkLose();
game.eatFood();
game.checkLose();
game.travelScreen();
} }
} }

View file

@ -1,5 +1,5 @@
{ {
"name": "files", "name": "CT Rewrite",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {

View file

@ -1,5 +1,5 @@
{ {
"name": "files", "name": "CT Rewrite",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {

View file

@ -1,5 +1,6 @@
{ {
"dependencies": { "dependencies": {
"readline-sync": "^1.4.10" "readline-sync": "^1.4.10"
} },
"type": "module"
} }

View file

@ -1,249 +1,218 @@
const variables = require("./variables.js"); // Holds poi code, seperate from encounters.js
const combat = require("./combat.js");
module.exports = { import { userInput } from "./functions.js";
encounterMenuMaker, import { location, locationA, locationB, path } from "./variables.js";
initializeEncounter,
poiCounter, export function checkPOI() {
pois, if (path == 0) {
if (location >= (pois[poiCounter].location)-3 && location <= pois[poiCounter].location && pois[poiCounter].visited == false) {
switch(pois[poiCounter].name) {
case "Whitespring Bunker":
whitespring();
break;
case "BOS Bunker Gamma":
bosGamma();
break;
case "BOS Bunker Delta":
bosDelta();
break;
case "BOS Bunker Epsilon":
bosEpsilon();
break;
case "Vault 0":
vault0();
break;
case "Tibbets Prison":
tibbets();
break;
case "Flagstaff":
flagstaff();
break;
case "New Vegas":
newVegas();
}
}
}
if (path == 1) {
if (locationA >= (pois[poiCounter].location)-3 && locationA <= pois[poiCounter].location && pois[poiCounter].visited == false) {
switch(pois[poiCounter].name) {
case "Mojave Outpost":
mojaveOutpost();
break;
case "Necropolis":
necropolis();
break;
case "The Hub":
hub();
break;
case "Lost Hills":
lostHills();
break;
case "Mariposa MB":
mariposa();
break;
case "San Francisco":
sanFrancisco();
break;
case "Camp Navarro":
navarro();
break;
}
}
}
if (path == 2) {
if (locationB >= (pois[poiCounter].location)-3 && locationB <= pois[poiCounter].location && pois[poiCounter].visited == false) {
switch(pois[poiCounter].name) {
case "Canyon Wreckage":
canyonWreck();
break;
case "Hopeville & Ashton":
hopeville();
break;
case "The Sierra Madre":
sierraMadre();
break;
case "Shady Sands":
shadySands();
break;
case "New Reno":
newReno();
break;
case "Redding":
redding();
break;
case "Eureka":
eureka();
break;
case "Camp Navarro":
navarro();
}
}
}
} }
function initializeEncounter(reqFaction, diffWeighting, fight, flee, forceFaction){ export var poiCounter = 0;
var encounter = encounterMenuMaker(reqFaction, diffWeighting, forceFaction); export var pois = [
{name: "Whitespring Bunker", location: 25, path: 0, visited: false},
{name: "BOS Bunker Gamma", location: 100, path: 0, visited: false},
{name: "BOS Bunker Delta", location: 125, path: 0, visited: false},
{name: "BOS Bunker Epsilon", location: 175, path: 0, visited: false},
{name: "Vault 0", location: 200, path: 0, visited: false},
{name: "Tibbets Prison", location: 250, path: 0, visited: false},
{name: "Flagstaff", location: 275, path: 0, visited: false},
{name: "New Vegas", location: 300, path: 0, visited: false},
{name: "Mojave Outpost", location: 5, path: 1, visited: false},
{name: "Necropolis", location: 10, path: 1, visited: false},
{name: "The Hub", location: 15, path: 1, visited: false},
{name: "Lost Hills", location: 20, path: 1, visited: false},
{name: "Mariposa MB", location: 30, path: 1, visited: false},
{name: "San Franciso", location: 35, path: 1, visited: false},
{name: "Camp Navarro", location: 45, path: 1, visited: false},
{name: "Canyon Wreckage", location: 5, path: 2, visited: false},
{name: "Hopeville & Ashton", location: 15, path: 2, visited: false},
{name: "The Sierra Madre", location: 25, path: 2, visited: false},
{name: "Shady Sands", location: 35, path: 2, visited: false},
{name: "New Reno", location: 55, path: 2, visited: false},
{name: "Redding", location: 75, path: 2, visited: false},
{name: "Eureka", location: 85, path: 2, visited: false},
{name: "Camp Navarro", location: 100, path: 2, visited: false},
]
function whitespring() {
}
function bosGamma() {
}
function bosDelta() {
}
function bosEpsilon() {
}
function vault0() {
}
function tibbets() {
}
function flagstaff() {
}
function newVegas() {
// The below is placeholder, once we add proper code delete this
console.clear(); console.clear();
console.log("You come across a " + encounter.name); console.log("Ahead lies 2 routes to Navarro.");
var encounterHealth = variables.randomNumber(encounter.minHealth, encounter.maxHealth); console.log("The northern route passes through the Divide before going north through the mountains.\nIt offers a longer path with fewer possible enimies, but those you face will not back down.")
console.log("Health: " + encounterHealth); console.log("The southern route goes through the heart of the NCR along I-15.\nIt is shorter and more pleasant, however without proper reputation your many stops may become worrisome.")
console.log("What would you like to do?"); var pathChoice = userInput("Which path would you like to follow, Northern or Southern? ");
console.log("--------------------------"); if (pathChoice.toLowerCase == "northern") {
var playerOptions = 1; path = 2;
console.log(playerOptions + ") Inventory");
playerOptions++
if(fight == true){
console.log(playerOptions + ") Fight");
playerOptions++;
} }
if(flee == true){ if (pathChoice.toLowerCase == "southern") {
console.log(playerOptions + ") Flee"); path = 1;
playerOptions++;
}
while(true) {
let encounterInput = variables.userInput("Enter: ")
switch(mainMenuInput) {
case "1":
console.log(variables.inventory);
case "2":
combat.initCombat(encounter);
break;
case "3":
if (variables.reputation.reqFaction < 4) {
if (variables.randomNumber(1,100) < 40){
console.log("You tried to flee... but they noticed you.");
combat.initCombat(encounter);
}
}
}
} }
} }
//Add any new encounter ideas to their required faction and difficulty function mojaveOutpost() {
var encounterDiffOne = [
//NCR
[],
//Legion
[],
//Raider
[
{name: "raider aspirant", minHealth: 30, maxHealth: 50, lootTable: "teir1A&W", numEnemies: 1},
],
//Settler
[
{name: "drunk", minHealth: 15, maxHealth: 25, lootTable: "junk", numEnemies: 1},
],
//BOS
[],
//Abomination
[
{name: "radroach", minHealth: 1, maxHealth: 10, lootTable: "food", numEnemies: 1},
{name: "weak ghoul", minHealth: 10, maxHealth: 15, lootTable: "junk", numEnemies: 1},
{name: "bloatfly swarm", minHealth: 1, maxHealth: 5, lootTable: "food", numEnemies: 5},
{name: "wolf", minHealth: 5, maxHealth: 10, lootTable: "food", numEnemies: 1},
],
//MWBOS
[]
];
var encounterDiffTwo = [
//NCR
[],
//Legion
[],
//Raider
[],
//Settler
[],
//BOS
[],
//Abomination
[],
//MWBOS
[]
];
var encounterDiffThree = [
//NCR
[],
//Legion
[],
//Raider
[],
//Settler
[],
//BOS
[],
//Abomination
[],
//MWBOS
[]
];
var encounterDiffFour = [
//NCR
[],
//Legion
[],
//Raider
[],
//Settler
[],
//BOS
[],
//Abomination
[],
//MWBOS
[]
];
var encounterDiffFive = [
//NCR
[],
//Legion
[],
//Raider
[],
//Settler
[],
//BOS
[],
//Abomination
[],
//MWBOS
[]
];
//RIP the filterFactionFunction :(
//Declaring some stuff to make them global variables
var faction = 0;
let encountered = [];
//Creates the menu for an encounter. "faction" represents the faction for the encounter, "diffWeighting" changes the odds for
//an encounter's difficulty (1-5)
//IGNORE THE VARIABLE COMMENTS IN THE NESTED SWITCH STATEMENT, they're placeholders for me
function encounterMenuMaker(reqFactionEMM, diffWeightingEMM, forceOptEMM){
switch(diffWeightingEMM){
case 1:
reqFactionEMM = encounterDiffOne
break;
case 2:
reqFactionEMM = encounterDiffTwo
break;
case 3:
reqFactionEMM = encounterDiffThree
break;
case 4:
reqFactionEMM = encounterDiffFour
break;
case 5:
reqFactionEMM = encounterDiffFive
break;
}
var encounterDifficulty = (diffWeightingEMM * variables.randomNumber(1, 20));
factionFailsafe = reqFactionEMM.toLowerCase();
switch(factionFailsafe){
case "NCR":
faction = 0;
break;
case "legion":
faction = 1;
break;
case "raider":
faction = 2;
break;
case "settler":
faction = 3;
break;
case "BOS":
faction = 4;
break;
case "abomination":
faction = 5;
break;
case "MWBOS":
faction = 6;
break;
}
if (forceOptEMM == true) {
if(encounterDifficulty <= 20){
encountered.push(encounterDiffOne[faction][variables.randomNumber(0, encounterDiffOne[faction].length - 1)]);
} else if(21 <= encounterDifficulty <= 40){
encountered.push(encounterDiffTwo[faction][variables.randomNumber(0, encounterDiffTwo[faction].length - 1)]);
} else if(41 <= encounterDifficulty <= 60){
encountered.push(encounterDiffThree[faction][variables.randomNumber(0, encounterDiffThree[faction].length - 1)]);
} else if(61 <= encounterDifficulty <= 80){
encountered.push(encounterDiffFour[faction][variables.randomNumber(0, encounterDiffFour[faction].length - 1)]);
} else {
encountered.push(encounterDiffFive[faction][variables.randomNumber(0, encounterDiffFive[faction].length - 1)]);
}
return encountered[encountered.length - 1];
} else {
let x = variables.randomNumber(0, 100)
if (x >= 75) {
if (x <=80) {
encountered.push(encounterDiffOne[raider][variables.randomNumber(0, encounterDiffOne[raider].length - 1)])
}
if (x <=90) {
encountered.push(encounterDiffOne[settler][variables.randomNumber(0, encounterDiffOne[settler].length - 1)])
}
if (x <=100) {
encountered.push(encounterDiffOne[abomination][variables.randomNumber(0, encounterDiffOne[abomination].length - 1)])
}
}
if (x < 75) {
encountered.push(encounterDiffOne[faction][variables.randomNumber(0, encounterDiffOne[faction].length - 1)])
}
}
} }
var poiCounter = 0; function necropolis() {
var pois = [
{name: "Whitespring Bunker", location: 25, path: 0}, }
{name: "BOS Bunker Gamma", location: 100, path: 0},
{name: "BOS Bunker Delta", location: 125, path: 0}, function hub() {
{name: "BOS Bunker Epsilon", location: 175, path: 0},
{name: "Vault 0", location: 200, path: 0}, }
{name: "Tibbets Prison", location: 250, path: 0},
{name: "Flagstaff", location: 275, path: 0}, function lostHills() {
{name: "New Vegas", location: 300, path: 0},
{name: "Mojave Outpost", location: 5, path: 1}, }
{name: "Necropolis", location: 10, path: 1},
{name: "The Hub", location: 15, path: 1}, function mariposa() {
{name: "Lost Hills", location: 20, path: 1},
{name: "Mariposa MB", location: 30, path: 1}, }
{name: "San Franciso", location: 35, path: 1},
{name: "Camp Navarro", location: 45, path: 1}, function sanFrancisco() {
{name: "Canyon Wreckage", location: 5, path: 2},
{name: "Hopeville & Ashton", location: 15, path: 2}, }
{name: "The Sierra Madre", location: 25, path: 2},
{name: "Shady Sands", location: 35, path: 2}, function canyonWreck() {
{name: "New Reno", location: 55, path: 2},
{name: "Redding", location: 75, path: 2}, }
{name: "Eureka", location: 85, path: 2},
{name: "Camp Navarro", location: 100, path: 2}, function hopeville() {
]
}
function sierraMadre() {
}
function shadySands() {
}
function newReno() {
}
function redding() {
}
function eureka() {
}
function navarro() {
}

View file

@ -1,2 +0,0 @@
// River crossing screens and options.
const variables = require("./variables.js");

View file

@ -1,13 +1,6 @@
const readline = require('readline-sync'); import { randomNumber } from "./functions.js";
const variables = require("./variables.js"); import {} from "./variables.js";
module.exports = {
ravenRock,
vaultZero,
newVegas,
eureka,
trader,
}
// Inventories for the various shops // Inventories for the various shops
var rrInv = []; var rrInv = [];
@ -35,7 +28,7 @@ function eureka() {
function trader() { // Picks a selection of items from a global trader inventory function trader() { // Picks a selection of items from a global trader inventory
var tempTraderInv = []; var tempTraderInv = [];
for (var a = 0; a <= 2; a++) { for (var a = 0; a <= 2; a++) {
let randomPick = Math.m let randomPick = randomNumber()
tempTraderInv.push(traderInv[1]); tempTraderInv.push(traderInv[1]);
console.log(randomPick); console.log(randomPick);
} }

View file

@ -1,100 +1,39 @@
// Holds the global variables and useful functions such as userInput // Now holds only variables
const readline = require('readline-sync');
module.exports = { // Lets variables and functions be used in other files // Player Currency
day, export var prewarmoney = 0; // Used with enclave vendors
location, export var caps = 0; // Used with all other vendors
ammo,
food,
foodAmt,
health,
travelSpeed,
isRadiated,
radSeverity,
isSick,
sickSeverity,
inventory,
name,
prewarmoney,
caps,
locationA,
locationB,
sleep,
userInput,
randomNumber,
};
var name = ''; // Player Stats
export var healthCap = 0; // Maximum health, raises each level
var prewarmoney = 0; // Used in Enclave Stores export var health = 0; // Players current HP
export var food = 0; // Amount of food player has
var caps = 0; // Used everywhere export var isRadiated = false;
export var radSeverity = 0; // Modifies healthCapCalc. 3 Levels
var day = 0; // Should we add a definite end? 365 Days? export var radPoints = 0; // If the player reaches 100 rad points the game ends
export var xpPerLevel = 10; // Amount of XP needed per level. Raises 50% each level
var location = 0; // Location in the world, 0 is Raven Rock, 255 is New Vegas export var level = 0; // Level of player. Modifies enemy scaling
var locationA = 0; // Location on path A, export var inventory = [ // Inventory of player, holds all items
var locationB = 0; // Location on path B, 225 is Navarro // Supplies: chems, aid
var ammo = 0; // Used in encounters and hunting, No cap :)
var food = 0; // Max: 200
var foodAmt = 0; // Amt of food eaten per day, 3 levels, starting at 1
var health = 0; // Max: 100
var travelSpeed = 0; // Location points per day, 3 levels, starting at 1
var isRadiated = false;
var radSeverity = 0; // Modifies many things, 3 levels, starting at 1
var isSick = false;
var sickPoints = 0; // If you accumulate 50 sick points you lose
var sickSeverity = 0; // 3 levls, starting at 1
var sleepVar = 0; // Placeholder variable that allows sleep() to run a command without changing/printing somthing
/*
1 - Villified - Will attack you at all POIs and encounters
2 - Hated - Will only attack you in major POIs
3 - Disliked - Will not engage in combat and will not allow you to trade
4 - Neutral - Can trade
5 - Good - Will offer assistance and minor discounts when trading
6 - Liked - Better discounts and assistance, faction bonus
7 - Idolized - Gives faction bonus and severe discounts when trading, underarmor
Faction bonuses
* MW BOS - X-01 PA
* Legion - The Mark of Caesar, show to frumentari in locations to recieve gear
* NCR - NCR Emergency 2-Way radio, recieve supply drop when in NCR territory. Useable 3 times
* BOS - X-01 upgrade to tesla
* Enclave - X-01 upgrade to APA
*/
var reputation = {mwbos: 4, legion: 4, ncr: 2, bos: 1, enclave: 10, abomination: 0, raider: 0} //Number between 0(worst) and 10(best), 5 is neutral
//Player inventory
//Record all items in the player's inventory as objects with a name, item category, value, and boolean properties. Example below.
//{name: "example", category: "testItems", value: 300, use: true, eat: false, drop: true, equip: true}
var inventory = [
//Supplies
[], [],
//Equipment // Equipment: weapons, armor, tools
[] []
]; ]
var lootTables = [[],[],[],[],[]] // Only small things like food and ammo, 5 Loot tables per scavenge score, 3 items in each, first is best // Game Mechanics
export var walkRate = 0; // Units the player walks per day, affects foodRateCalc and radPointsCalc
export var foodRate = 0; // Amount of food player eats per day, affects radPointsCalc
var daysSinceScav = 0; // Days since your last scavenge, you must wait 15 days before scavenging again. export var path = 0; // Path player is currently on, 0 = Main, 1 = A, 2 = B
export var location = 0; // Location on main path, 0-255 = main, 500-1000 = A, 1500-2000 = B
export var locationA = 0; // Location on path A
export var locationB =0; // Location on path B
export var reputation = {mwbos: 4, legion: 4, ncr: 2, bos: 1, enclave: 10, abomination: 0, raider: 0}
// Rep for each faction. Number between 0(worst) and 10(best), 5 is neutral
export var daysSinceScav = 0; // Days since player last scavenged. Must be >= 15 to scavenge again.
export var name = "placeholder"; // Player name, changed when the game starts
function userInput(question) { // Basic user input functions, takes in the question to be asked.
let answer = readline.question(question);
return(answer);
}
function randomNumber(min, max) { // Takes in two parameters, min and max, and returns a random number between those boundries.
while (true) {
var randNum = Math.floor(Math.random() * (max+1))
if (randNum >= min) { break; }
}
return randNum;
}