Rewrite
This commit is contained in:
parent
8871c644fb
commit
e5fe71ce46
16 changed files with 573 additions and 638 deletions
151
files/encounters.js
Normal file
151
files/encounters.js
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue