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

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)
}
}
}
}
}