Skip to content

Commit

Permalink
Add New Game+ curve scalar and randomization Merge pull request #573
Browse files Browse the repository at this point in the history
…from MQDuck/newgameplus_scalar

Add New Game+ curve scalar and randomization
  • Loading branch information
Die4Ever authored Dec 11, 2023
2 parents 086868a + d92e72d commit 0272537
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 36 deletions.
3 changes: 3 additions & 0 deletions DXRCore/DeusEx/Classes/DXRMenuSetupRando.uc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ function BindControls(optional string action)
EnumOption("Pause", 1, f.settings.menus_pause);
EnumOption("Don't Pause", 0, f.settings.menus_pause);

NewMenuItem("New Game+ Scaling %", "Scales the curve of New Game+ changes over successive loops.");
Slider(f.moresettings.newgameplus_curve_scalar, 0, 200);

NewGroup("Bingo");

NewMenuItem("Bingo Win", "How many completed lines to instantly win");
Expand Down
6 changes: 6 additions & 0 deletions DXRModules/DeusEx/Classes/DXRFlags.uc
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ function CheckConfig()
difficulty_settings[i].energy = 200;
difficulty_settings[i].starting_map = 0;
more_difficulty_settings[i].grenadeswap = 100;
more_difficulty_settings[i].newgameplus_curve_scalar = 100;
i++;
#endif
Expand Down Expand Up @@ -246,6 +247,7 @@ function CheckConfig()
difficulty_settings[i].energy = 100;
difficulty_settings[i].starting_map = 0;
more_difficulty_settings[i].grenadeswap = 100;
more_difficulty_settings[i].newgameplus_curve_scalar = 100;
i++;

#ifdef hx
Expand Down Expand Up @@ -315,6 +317,7 @@ function CheckConfig()
difficulty_settings[i].energy = 100;
difficulty_settings[i].starting_map = 0;
more_difficulty_settings[i].grenadeswap = 100;
more_difficulty_settings[i].newgameplus_curve_scalar = 100;
i++;

#ifdef hx
Expand Down Expand Up @@ -384,6 +387,7 @@ function CheckConfig()
difficulty_settings[i].energy = 100;
difficulty_settings[i].starting_map = 0;
more_difficulty_settings[i].grenadeswap = 100;
more_difficulty_settings[i].newgameplus_curve_scalar = 100;
i++;

#ifdef hx
Expand Down Expand Up @@ -453,6 +457,7 @@ function CheckConfig()
difficulty_settings[i].energy = 80;
difficulty_settings[i].starting_map = 0;
more_difficulty_settings[i].grenadeswap = 100;
more_difficulty_settings[i].newgameplus_curve_scalar = 100;
i++;

for(i=0; i<ArrayCount(difficulty_settings); i++) {
Expand Down Expand Up @@ -611,6 +616,7 @@ function FlagsSettings SetDifficulty(int new_difficulty)
settings.prison_pocket = 100; //Keep your items in mission 5
bingo_duration = 1;
bingo_scale = 0;
moresettings.newgameplus_curve_scalar = 50;

l("applying WaltonWare, DXRando: " $ dxr @ dxr.seed);
settings.starting_map = class'DXRStartMap'.static.ChooseRandomStartMap(self, 10);
Expand Down
6 changes: 6 additions & 0 deletions DXRModules/DeusEx/Classes/DXRFlagsBase.uc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct FlagsSettings {

struct MoreFlagsSettings{
var int grenadeswap;
var int newgameplus_curve_scalar;

var int remove_paris_mj12;// keep this at the end for automated tests
};
Expand Down Expand Up @@ -396,6 +397,8 @@ simulated function string BindFlags(int mode, optional string str)
FlagInt('Rando_starting_map', settings.starting_map, mode, str);
FlagInt('Rando_grenadeswap', moresettings.grenadeswap, mode, str);

FlagInt('Rando_newgameplus_curve_scalar', moresettings.newgameplus_curve_scalar, mode, str);

return str;
}

Expand All @@ -415,6 +418,8 @@ simulated function string flagNameToHumanName(name flagname){
return "Loadout";
case 'Rando_newgameplus_loops':
return "New Game+ Loop";
case 'Rando_newgameplus_curve_scalar':
return "New Game+ Curve Scalar";
case 'Rando_playthrough_id':
return "Playthrough ID";
case 'Rando_gamemode':
Expand Down Expand Up @@ -625,6 +630,7 @@ simulated function string flagValToHumanVal(name flagname, int val){
case 'Rando_removeparismj12':
case 'Rando_bingo_scale':
case 'Rando_grenadeswap':
case 'Rando_newgameplus_curve_scalar':
return val$"%";
case 'Rando_enemyrespawn':
Expand Down
97 changes: 61 additions & 36 deletions DXRModules/DeusEx/Classes/DXRFlagsNGPMaxRando.uc
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ function NewGamePlus()
local DataStorage ds;
local DXRSkills skills;
local DXRAugmentations augs;
local int i, bingo_win,bingo_freespaces;
local int i, bingo_win, bingo_freespaces, newgameplus_curve_scalar;
local float exp;
local int randomStart;
local int oldseed;
if( flagsversion == 0 ) {
warning("NewGamePlus() flagsversion == 0");
Expand All @@ -181,38 +182,45 @@ function NewGamePlus()
p.saveCount=0;
exp = 1;
randomStart = settings.starting_map;
bingo_win = settings.bingo_win;
bingo_freespaces = settings.bingo_freespaces;
// always enable maxrando when doing NG+?
maxrando = 1;
if(maxrando > 0) {
// rollback settings to the default for the current difficulty
// we only want to do this on maxrando because we want to retain the user's custom choices
bingo_win = settings.bingo_win;
bingo_freespaces = settings.bingo_freespaces;
newgameplus_curve_scalar = moresettings.newgameplus_curve_scalar;
SetDifficulty(difficulty);
ExecMaxRando();
settings.bingo_win = bingo_win;
settings.bingo_freespaces = bingo_freespaces;
moresettings.newgameplus_curve_scalar = newgameplus_curve_scalar;
// increase difficulty on each flag like exp = newgameplus_loops; x *= 1.2 ^ exp;
exp = newgameplus_loops;
}
dxr.SetSeed(dxr.Crc("NG+ curve tweak " $ (seed - newgameplus_loops)));
p.CombatDifficulty = DXRFlags(self).GetDifficulty(difficulty).CombatDifficulty;
p.CombatDifficulty = NewGamePlusVal(p.CombatDifficulty, 1.3, exp, 0, 15); // Anything over 15 is kind of unreasonably impossible
settings.minskill = NewGamePlusVal(settings.minskill, 1.1, exp, 10, 400);
settings.maxskill = NewGamePlusVal(settings.maxskill, 1.1, exp, 10, 700);
settings.enemiesrandomized = NewGamePlusVal(settings.enemiesrandomized, 1.2, exp, 10, 1000);
settings.enemystats = NewGamePlusVal(settings.enemystats, 1.2, exp, 5, 100);
settings.hiddenenemiesrandomized = NewGamePlusVal(settings.hiddenenemiesrandomized, 1.2, exp, 10, 1000);
settings.ammo = NewGamePlusVal(settings.ammo, 0.9, exp, 5, 100);
settings.medkits = NewGamePlusVal(settings.medkits, 0.9, exp, 5, 100);
settings.multitools = NewGamePlusVal(settings.multitools, 0.9, exp, 5, 100);
settings.lockpicks = NewGamePlusVal(settings.lockpicks, 0.9, exp, 5, 100);
settings.biocells = NewGamePlusVal(settings.biocells, 0.9, exp, 5, 100);
settings.medbots = NewGamePlusVal(settings.medbots, 0.9, exp, 3, 100);
settings.repairbots = NewGamePlusVal(settings.repairbots, 0.9, exp, 3, 100);
settings.turrets_add = NewGamePlusVal(settings.turrets_add, 1.3, exp, 3, 1000);
settings.merchants = NewGamePlusVal(settings.merchants, 0.9, exp, 5, 100);
SetGlobalSeed("NewGamePlus");
p.CombatDifficulty=FClamp(p.CombatDifficulty*1.3,0,15); //Anything over 15 is kind of unreasonably impossible
NewGamePlusVal(settings.minskill, 1.1, exp, 10, 400);
NewGamePlusVal(settings.maxskill, 1.1, exp, 10, 700);
NewGamePlusVal(settings.enemiesrandomized, 1.2, exp, 10, 1000);
NewGamePlusVal(settings.enemystats, 1.2, exp, 5, 100);
NewGamePlusVal(settings.hiddenenemiesrandomized, 1.2, exp, 10, 1000);
NewGamePlusVal(settings.ammo, 0.9, exp, 5, 100);
NewGamePlusVal(settings.medkits, 0.9, exp, 5, 100);
NewGamePlusVal(settings.multitools, 0.9, exp, 5, 100);
NewGamePlusVal(settings.lockpicks, 0.9, exp, 5, 100);
NewGamePlusVal(settings.biocells, 0.9, exp, 5, 100);
NewGamePlusVal(settings.medbots, 0.9, exp, 3, 100);
NewGamePlusVal(settings.repairbots, 0.9, exp, 3, 100);
NewGamePlusVal(settings.turrets_add, 1.3, exp, 3, 1000);
NewGamePlusVal(settings.merchants, 0.9, exp, 5, 100);
settings.bingo_win = bingo_win;
settings.bingo_freespaces = bingo_freespaces;
if (randomStart!=0){
settings.starting_map = class'DXRStartMap'.static.ChooseRandomStartMap(self, randomStart);
}
Expand Down Expand Up @@ -340,42 +348,49 @@ simulated function MaxRandoValPair(out int min, out int max)
}
}

function NewGamePlusVal(out int val, float curve, float exp, int min, int max)
function float NewGamePlusVal(float val, float curve, float exp, float min, float max)
{
val = val * (curve ** exp);// int *= float doesn't give as good accuracy as int = int*float
val = Self.Min(val, max);
val = Self.Max(val, min);
local bool increases;
local float tweak;

increases = curve > 1.0;

tweak = rngfn() * 0.045;
curve = 1.0 + ((curve - 1.0) * float(moresettings.newgameplus_curve_scalar) / 100.0) + tweak;
if (increases) {
curve = FMax(curve, 1.02);
} else {
curve = FMin(curve, 0.98);
}
val = val * curve ** exp;

return FClamp(val, min, max);
}

function ExtendedTests()
{
local int val, i, oldSeed;
local float fval;
local string s;

Super.ExtendedTests();

val = 5;
NewGamePlusVal(val, 1.2, 3, 1, 100);
val = NewGamePlusVal(5, 1.2, 3, 1, 100);
testint(val, 8, "NewGamePlusVal 1.2 goes up");

val = 5;
NewGamePlusVal(val, 0.8, 3, 1, 100);
val = NewGamePlusVal(5, 0.8, 3, 1, 100);
testint(val, 2, "NewGamePlusVal 1.2 goes down");

val = 5;
NewGamePlusVal(val, 0.8, 3, 5, 100);
val = NewGamePlusVal(5, 0.8, 3, 5, 100);
testint(val, 5, "NewGamePlusVal with minimum stays the same"); // can't explain that!

val = 5;
NewGamePlusVal(val, 1.2, 3, 1, 5);
val = NewGamePlusVal(5, 1.2, 3, 1, 5);
testint(val, 5, "NewGamePlusVal 1.2 with maximum");

val = 0;
NewGamePlusVal(val, 1.2, 3, -10, 100);
val = NewGamePlusVal(0, 1.2, 3, -10, 100);
testint(val, 0, "NewGamePlusVal 1.2 val==0");

val = -5;
NewGamePlusVal(val, 1.2, 3, -6, 100);
val = NewGamePlusVal(-5, 1.2, 3, -6, 100);
testint(val, -6, "NewGamePlusVal 1.2 negative value");

oldSeed = dxr.seed;
Expand All @@ -386,4 +401,14 @@ function ExtendedTests()
}
test(true, "DXRStartMap " $ s);
dxr.seed = oldSeed;

oldSeed = dxr.SetSeed(9876); // first two rngfn values are: 0.759380, -0.177720

fval = NewGamePlusVal(50.0, 0.99, 3, 0, 100);
test(fval < 50.0, "NewGamePlusVal doesn't switch from decreasing to increasing");

fval = NewGamePlusVal(50.0, 1.01, 3, 0, 100);
test(fval > 50.0, "NewGamePlusVal doesn't switch from increasing to decreasing");

dxr.SetSeed(oldSeed);
}
Binary file modified DeusEx.u
Binary file not shown.

0 comments on commit 0272537

Please sign in to comment.