From 686b1da3fbb983fcb206e44f7492dea29fe28109 Mon Sep 17 00:00:00 2001 From: ps1337 Date: Sun, 30 May 2021 15:31:28 +0200 Subject: [PATCH] probabilities --- CMakeModules/InstallConfig.cmake | 2 +- README.md | 15 ++- code/ui/globalShuffledTiers.h | 162 ++++++++++++++++++++++++------- files/randomizerOptions.json | 83 ++++++++++++++++ 4 files changed, 223 insertions(+), 39 deletions(-) mode change 100644 => 100755 CMakeModules/InstallConfig.cmake mode change 100644 => 100755 README.md mode change 100644 => 100755 code/ui/globalShuffledTiers.h mode change 100644 => 100755 files/randomizerOptions.json diff --git a/CMakeModules/InstallConfig.cmake b/CMakeModules/InstallConfig.cmake old mode 100644 new mode 100755 index 8e0094a6e9..28b1331bac --- a/CMakeModules/InstallConfig.cmake +++ b/CMakeModules/InstallConfig.cmake @@ -67,7 +67,7 @@ cpack_add_component_group(JK2SP DESCRIPTION "Jedi Outcast single player game") if(WIN32) - include(CPackNSIS) + #include(CPackNSIS) set(CPACK_NSIS_DISPLAY_NAME "OpenJK") set(CPACK_NSIS_PACKAGE_NAME "OpenJK") set(CPACK_NSIS_MUI_ICON "${SharedDir}/icons/icon.ico") diff --git a/README.md b/README.md old mode 100644 new mode 100755 index fb0e04b14a..ee85290474 --- a/README.md +++ b/README.md @@ -108,6 +108,14 @@ Currently, there is a limit of 100 possible sets per map, which should be enough If you add a set, make sure you use a unique index in the range of 0-99. +# Probabilities + +They can be set for each force level in the `randomizerOptions.json` file. +These are applied when randomizing the force levels, not when randomizing the +actual force powers that are available. This means, that setting something to +`100.00` does *not* make the force power appear every time. Instead, it ensures +the respective for level *in case* the force power is available. + # Additional Notes * Considering map loading: If you load from a previous save game, **NO** randomization will be performed as the savegame will be treated as is. Quicksaves will be treated the same. * Please note that for yavin1b, the force powers currently won't get randomized. Starting from yavin2, randomizations kicks in. @@ -115,7 +123,10 @@ If you add a set, make sure you use a unique index in the range of 0-99. # Building -Please refer to the original notes on the build process of OpenJK. I added an option to the CMake project which allows you to pass the installation directory with an environment variable. Check the `CMakeList` files for additional info. +1. Please refer to the original notes on the build process of OpenJK. +2. Define WINDOWS_IGNORE_PACKING_MISMATCH + +I added an option to the CMake project which allows you to pass the installation directory with an environment variable. Check the `CMakeList` files for additional info. **After compiling this project, copy the files of the** `files` **folder into the same directory your JKA executable lives in. If you don't do this, the game will crash as intended.** Please refer to the troubleshooting sections in case of problems. @@ -123,7 +134,7 @@ Please refer to the original notes on the build process of OpenJK. I added an op Thanks go out to Raven, the JACoders and the JKA speedrunning community. Additionally, to nlohmann for the great JSON library. -~ Joe Bananas (@JoeBananas1337_) +~ CaptnBanana (@CaptnBanana) # Todos * Clean this project from MP files and folders diff --git a/code/ui/globalShuffledTiers.h b/code/ui/globalShuffledTiers.h old mode 100644 new mode 100755 index 0adab8000f..0adad66a77 --- a/code/ui/globalShuffledTiers.h +++ b/code/ui/globalShuffledTiers.h @@ -235,6 +235,8 @@ const static std::vector FORCE_POWERS_CORE = { const static std::vector ALL_WEAPONS = { + WP_SABER, + WP_BLASTER_PISTOL, WP_BLASTER, WP_DISRUPTOR, @@ -618,6 +620,81 @@ static void _updateForceData(playerState_t *pState) { } } +static double getProb(int fp, int lvl) { + + std::string lvlstr = "LVL1"; + switch (lvl) { + case 1: + lvlstr = "LVL1"; + break; + case 2: + lvlstr = "LVL2"; + break; + case 3: + lvlstr = "LVL3"; + + default: + break; + } + + std::string fpstr = "FP_JUMP"; + switch (fp) { + case FP_LEVITATION: + fpstr = "FP_JUMP"; + break; + case FP_PUSH: + fpstr = "FP_PUSH"; + break; + case FP_PULL: + fpstr = "FP_PULL"; + break; + case FP_SABERTHROW: + fpstr = "FP_SABERTHROW"; + break; + case FP_SABER_DEFENSE: + fpstr = "FP_SABER_DEFENSE"; + break; + case FP_SABER_OFFENSE: + fpstr = "FP_SABER_OFFENSE"; + break; + case FP_SEE: + fpstr = "FP_SENSE"; + break; + case FP_SPEED: + fpstr = "FP_SPEED"; + break; + case FP_HEAL: + fpstr = "FP_HEAL"; + break; + case FP_TELEPATHY: + fpstr = "FP_MINDTRICK"; + break; + case FP_GRIP: + fpstr = "FP_GRIP"; + break; + case FP_LIGHTNING: + fpstr = "FP_LIGHTNING"; + break; + case FP_RAGE: + fpstr = "FP_RAGE"; + break; + case FP_PROTECT: + fpstr = "FP_PROTECT"; + break; + case FP_ABSORB: + fpstr = "FP_ABSORB"; + break; + case FP_DRAIN: + fpstr = "FP_DRAIN"; + break; + + default: + break; + } + + return SETTINGS_JSON.at("probability").at(fpstr).at(lvlstr); +} + // returns the known force powers static void randomizeForcePowers(playerState_t* pState, std::string mapname = "") { @@ -685,34 +762,29 @@ static void randomizeForcePowers(playerState_t* pState, std::string mapname = "" if (TIER_MISSIONS_COMPLETED >= 5 && TIER_MISSIONS_COMPLETED < 10) { corePointsToSpend = fps_core_shuffled.size() * 2; } if (TIER_MISSIONS_COMPLETED >= 10) { corePointsToSpend = fps_core_shuffled.size() * 3; } + // core for (auto fp : fps_core_shuffled) { // finished if (corePointsToSpend <= 0) { break; } - int randomLevel = Q_min(GET_RANDOM(1, 3), corePointsToSpend); - - // don't make it too easy ;) - if (fp == FP_LEVITATION) { - int randNo = GET_RANDOM(0, 100); - - if (randNo > (100 - _forceJumpOneProbability)) { - randomLevel = 1; - } + int randomLevel = 0; + int randNo = GET_RANDOM(0, 100); - if (randNo > (100 - _forceJumpTwoProbability)) { - randomLevel = 2; - } + if (randNo <= (getProb(fp, 1))) { + randomLevel = 1; + } - if (randomLevel > (100 - _forceJumpThreeProbability)) { - randomLevel = 3; - } + if (randNo > (getProb(fp, 1))) { + randomLevel = 2; + } + if (randomLevel > (getProb(fp, 1) + getProb(fp, 2))) { + randomLevel = 3; } corePointsToSpend -= randomLevel; - pState->forcePowerLevel[fp] = randomLevel; // enable or disable the force power @@ -726,12 +798,26 @@ static void randomizeForcePowers(playerState_t* pState, std::string mapname = "" } } + // player for (auto fp : fps_player_shuffled) { // finished if (playerPointsToSpend <= 0) { break; } - int randomLevel = Q_min(GET_RANDOM(1, 3), playerPointsToSpend); + int randomLevel = 0; + int randNo = GET_RANDOM(0, 100); + + if (randNo <= (getProb(fp, 1))) { + randomLevel = 1; + } + + if (randNo > (getProb(fp, 1))) { + randomLevel = 2; + } + + if (randomLevel > (getProb(fp, 1) + getProb(fp, 2))) { + randomLevel = 3; + } playerPointsToSpend -= randomLevel; pState->forcePowerLevel[fp] = randomLevel; @@ -757,27 +843,18 @@ static void randomizeForcePowers(playerState_t* pState, std::string mapname = "" if (GET_RANDOM_MAX(100) > 60) { continue; } int randomLevel = 0; - // don't make it too easy ;) - if (fp == FP_LEVITATION) { - int randNo = GET_RANDOM(0, 100); + int randNo = GET_RANDOM(0, 100); - if (randNo > (100 - _forceJumpOneProbability)) { - randomLevel = 1; - } - - if (randNo > (100 - _forceJumpTwoProbability)) { - randomLevel = 2; - } - - if (randomLevel > (100 - _forceJumpThreeProbability)) { - randomLevel = 3; - } - - } else { + if (randNo <= (getProb(fp, 1))) { + randomLevel = 1; + } + if (randNo > (getProb(fp, 1))) { + randomLevel = 2; + } - // from 0..3 - randomLevel = GET_RANDOM(0, GET_RANDOM(1, 3)); + if (randomLevel > (getProb(fp, 1) + getProb(fp, 2))) { + randomLevel = 3; } pState->forcePowerLevel[fp] = randomLevel; @@ -803,7 +880,20 @@ static void randomizeForcePowers(playerState_t* pState, std::string mapname = "" for (auto fp : fps_player_shuffled) { if (maxPoints == 0) { break; } - int randomLevel = Q_min(GET_RANDOM(0, GET_RANDOM(1, GET_RANDOM(2, 3))), maxPoints); + int randomLevel = 0; + int randNo = GET_RANDOM(0, 100); + + if (randNo <= (getProb(fp, 1))) { + randomLevel = 1; + } + + if (randNo > (getProb(fp, 1))) { + randomLevel = 2; + } + + if (randomLevel > (getProb(fp, 1) + getProb(fp, 2))) { + randomLevel = 3; + } maxPoints -= randomLevel; diff --git a/files/randomizerOptions.json b/files/randomizerOptions.json old mode 100644 new mode 100755 index 8083e600db..84540cfa99 --- a/files/randomizerOptions.json +++ b/files/randomizerOptions.json @@ -3,6 +3,89 @@ "forceRandomizationMode" : 0, "weaponRandomizationMode" : 0, + "probability": { + "FP_HEAL": { + "LVL1": 33.0, + "LVL2": 33.0, + "LVL3": 33.0 + }, + "FP_JUMP": { + "LVL1": 60.0, + "LVL2": 30.0, + "LVL3": 10.0 + }, + "FP_SPEED": { + "LVL1": 33.0, + "LVL2": 33.0, + "LVL3": 33.0 + }, + "FP_PUSH": { + "LVL1": 33.0, + "LVL2": 33.0, + "LVL3": 33.0 + }, + "FP_PULL": { + "LVL1": 33.0, + "LVL2": 33.0, + "LVL3": 33.0 + }, + "FP_MINDTRICK": { + "LVL1": 33.0, + "LVL2": 33.0, + "LVL3": 33.0 + }, + "FP_GRIP": { + "LVL1": 33.0, + "LVL2": 33.0, + "LVL3": 33.0 + }, + "FP_LIGHTNING": { + "LVL1": 33.0, + "LVL2": 33.0, + "LVL3": 33.0 + }, + "FP_SABERTHROW": { + "LVL1": 33.0, + "LVL2": 33.0, + "LVL3": 33.0 + }, + "FP_SABER_DEFENSE": { + "LVL1": 33.0, + "LVL2": 33.0, + "LVL3": 33.0 + }, + "FP_SABER_OFFENSE": { + "LVL1": 33.0, + "LVL2": 33.0, + "LVL3": 33.0 + }, + "FP_RAGE": { + "LVL1": 33.0, + "LVL2": 33.0, + "LVL3": 33.0 + }, + "FP_PROTECT": { + "LVL1": 33.0, + "LVL2": 33.0, + "LVL3": 33.0 + }, + "FP_ABSORB": { + "LVL1": 33.0, + "LVL2": 33.0, + "LVL3": 33.0 + }, + "FP_DRAIN": { + "LVL1": 33.0, + "LVL2": 33.0, + "LVL3": 33.0 + }, + "FP_SENSE": { + "LVL1": 33.0, + "LVL2": 33.0, + "LVL3": 33.0 + } + }, + "weapons": { "t1_sour_0": { "WP_SABER" : 1,