Begin work on rep system. Finished encounter generation for the most part. Needs testing.

This commit is contained in:
Raktbastr 2025-03-20 11:34:17 -05:00
parent 42bf2a484a
commit 49f93574af
5 changed files with 185 additions and 37 deletions

0
files/combat.js Normal file
View file

View file

@ -1,6 +1,7 @@
// 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,
@ -8,6 +9,7 @@ module.exports = {
scavenge,
checkLose,
calcLocation,
calcEncounter,
}
function eatFood() {
@ -88,3 +90,55 @@ function calcLocation() { // Calculates your location in the world using locatio
}
}
}
// 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)
}
}
}
}
}

View file

@ -23,25 +23,28 @@ console.log("2) Learn How to play");
console.log("3) Quit Game");
console.log("4) Dev stuff for testing");
var mainMenuInput = variables.userInput("Enter: ")
switch(mainMenuInput) {
case "1":
startGame();
break;
case "2":
console.log("Follow the link below for a game manual.")
console.log("[ENTER LINK HERE]")
break;
case "3":
console.log("Quitting Game...");
variables.sleep(1000);
break;
case "4":
inventoryStuff.inventoryMenuM();
break;
while(true) {
let mainMenuInput = variables.userInput("Enter: ")
switch(mainMenuInput) {
case "1":
startGame();
break;
case "2":
console.log("Follow the link below for a game manual.")
console.log("[ENTER LINK HERE]")
break;
case "3":
console.log("Quitting Game...");
variables.sleep(1000);
break;
case "4":
let testarr = [1,2,3,4]
console.log(testarr[testarr.length - 1]);
break;
}
}
function startGame() { // So far what I have is filler and testing, feel free to change.
console.clear();
variables.sleep(1000);
@ -57,4 +60,12 @@ function startGame() { // So far what I have is filler and testing, feel free to
variables.prewarmoney = 500;
shops.ravenRock();
for (variables.location = 0; variables.location <= 255; variables.location++) {
game.calcLocation();
game.calcEncounter();
game.calcSickPoints();
game.eatFood();
game.checkLose();
}
}

View file

@ -1,12 +1,13 @@
const variables = require("./variables.js");
const combat = requre("./combat.js");
module.exports = {
encounterMenuMaker,
initializeEncounter,
}
function initializeEncounter(reqFaction, diffWeighting, fight, flee){
var encounter = encounterMenuMaker(reqFaction, diffWeighting);
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 = variables.randomNumber(encounter.minHealth, encounter.maxHealth);
@ -14,6 +15,8 @@ function initializeEncounter(reqFaction, diffWeighting, fight, flee){
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++;
@ -22,7 +25,23 @@ function initializeEncounter(reqFaction, diffWeighting, fight, flee){
console.log(playerOptions + ") Flee");
playerOptions++;
}
console.log(playerOptions + ") Inventory");
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
@ -47,7 +66,9 @@ var encounterDiffOne = [
{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
@ -61,6 +82,8 @@ var encounterDiffTwo = [
//BOS
[],
//Abomination
[],
//MWBOS
[]
];
var encounterDiffThree = [
@ -75,6 +98,8 @@ var encounterDiffThree = [
//BOS
[],
//Abomination
[],
//MWBOS
[]
];
var encounterDiffFour = [
@ -89,6 +114,8 @@ var encounterDiffFour = [
//BOS
[],
//Abomination
[],
//MWBOS
[]
];
var encounterDiffFive = [
@ -103,25 +130,40 @@ var encounterDiffFive = [
//BOS
[],
//Abomination
[],
//MWBOS
[]
];
//RIP the filterFactionFunction :(
//Declaring some stuff to make them global variables
var encountered = [];
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(reqFaction, diffWeighting){
var encounterDifficulty = (diffWeighting * variables.randomNumber(1, 20));
if((reqFaction != "NCR") && (reqFaction != "BOS")){
factionFailsafe = reqFaction.toLowerCase();
} else {
factionFailsafe = reqFaction;
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;
@ -141,17 +183,38 @@ function encounterMenuMaker(reqFaction, diffWeighting){
case "abomination":
faction = 5;
break;
case "MWBOS":
faction = 6;
break;
}
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){
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 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 {
encountered.push(encounterDiffFive[faction][variables.randomNumber(0, encounterDiffFive[faction].length - 1)]);
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)])
}
}
return encountered[0];
}

View file

@ -17,6 +17,8 @@ module.exports = { // Lets variables and functions be used in other files
name,
prewarmoney,
caps,
locationA,
locationB,
sleep,
userInput,
randomNumber,
@ -50,6 +52,24 @@ var isSick = false;
var sickPoints = 0; // If you accumulate 50 sick points you lose
var sickSeverity = 0; // 3 levls, starting at 1
/*
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}