From a92ce539bc497becaaed02b08ba59d4a159d03dd Mon Sep 17 00:00:00 2001 From: Die4Ever Date: Mon, 25 Jul 2022 10:46:01 -0500 Subject: [PATCH] v0.5.7 Alpha, small balance tweaks --- BuildLibs/__init__.py | 2 +- BuildLibs/confile.py | 24 ++++++++++----------- BuildLibs/games.py | 50 +++++++++++++++++++++++-------------------- BuildLibs/gui.py | 26 +++++++++++----------- 4 files changed, 53 insertions(+), 49 deletions(-) diff --git a/BuildLibs/__init__.py b/BuildLibs/__init__.py index f6201ca..4700088 100644 --- a/BuildLibs/__init__.py +++ b/BuildLibs/__init__.py @@ -16,7 +16,7 @@ import re def GetVersion() -> str: - return 'v0.5.6 Alpha' + return 'v0.5.7 Alpha' packLengthRegex = re.compile('^(.*?)(\d+)(\w)(.*?)$') class FancyPacker: diff --git a/BuildLibs/confile.py b/BuildLibs/confile.py index 0c85a69..a530680 100644 --- a/BuildLibs/confile.py +++ b/BuildLibs/confile.py @@ -9,19 +9,17 @@ class ConFile: def __init__(self, game, conSettings, name, text): info('\n', name, len(text)) self.game = game - self.conSettings = conSettings + self.conSettings:dict = conSettings self.name:str = name self.text:str = text - self.regexes = [] - self.difficulties = [] - for r in self.conSettings: - self.regexes.append(re.compile('^'+r+'$')) - self.difficulties.append(self.conSettings[r]['difficulty']) + for v in self.conSettings: + r = re.compile('^'+v['regexstr']+'$') + v['regex'] = r - def ShouldRandomizeVar(self, name) -> Union[float,None]: - for i in range(len(self.regexes)): - if self.regexes[i].match(name): - return self.difficulties[i] + def GetVarSettings(self, name) -> Union[None,dict]: + for v in self.conSettings: + if v['regex'].match(name): + return v return None def RandomizeLine(self, l:str, seed:int, range:float, scale:float, difficulty:float) -> str: @@ -32,11 +30,13 @@ def RandomizeLine(self, l:str, seed:int, range:float, scale:float, difficulty:fl oldval = int(m.group(2)) theRest = m.group(3) - var_difficulty = self.ShouldRandomizeVar(name) - if var_difficulty is None: + var_settings:dict = self.GetVarSettings(name) + if var_settings is None: return l + var_difficulty = var_settings.get('difficulty', 0) rng = random.Random(crc32('define', name, seed)) + range *= var_settings.get('range', 1) r = rng.random() * range + 1 if var_difficulty < 0: diff --git a/BuildLibs/games.py b/BuildLibs/games.py index 062819f..6d4fff6 100644 --- a/BuildLibs/games.py +++ b/BuildLibs/games.py @@ -129,6 +129,9 @@ def SpriteRange(min:int, max:int, value:dict): d[i] = value return d +def ConVar(regex:str, difficulty:float=0, range:float=1) -> dict: + return { 'regexstr': regex, 'difficulty': difficulty, 'range': 1 } + @@ -679,34 +682,35 @@ def SpriteRange(min:int, max:int, value:dict): # difficulty > 0 means higher number makes the game harder AddConSettings('Ion Fury', conFiles = { - 'scripts/customize.con': { - '.*\wHEALTH': {'difficulty': -1}, - '.*MAXAMMO': {'difficulty': -1}, - '.*AMOUNT': {'difficulty': -1}, + 'scripts/customize.con': [ + ConVar('.*\wHEALTH', -1, range=0.5), + ConVar('MEDKIT_HEALTHAMOUNT', -1, range=0.5), + ConVar('.*MAXAMMO', -1), + ConVar('.*AMOUNT', -1), - '.*_DMG': {'difficulty': 0}, # not sure if this affects enemies too or just the player? + ConVar('.*_DMG', 0), # not sure if this affects enemies too or just the player? - '.*_HEALTH': {'difficulty': 1}, - } + ConVar('.*_HEALTH', 1), + ] }) AddConSettings('Duke Nukem 3D', conFiles = { - 'USER.CON': { - 'SWEARFREQUENCY': {'difficulty': 0}, - '.*HEALTH': {'difficulty': -1}, - 'MAX.*AMMO': {'difficulty': -1}, - '.*AMMOAMOUNT': {'difficulty': -1}, - '.*_AMOUNT': {'difficulty': -1}, - 'HANDBOMBBOX': {'difficulty': -1}, - '.*_WEAPON_STRENGTH': {'difficulty': -1}, - - '.*\wSTRENGTH': {'difficulty': 1}, - 'PIG_SHIELD_AMOUNT\d': {'difficulty': 1}, + 'USER.CON': [ + ConVar('SWEARFREQUENCY', 0), + ConVar('.*HEALTH', -1, range=0.5), + ConVar('MAX.*AMMO', -1), + ConVar('.*AMMOAMOUNT', -1), + ConVar('.*_AMOUNT', -1), + ConVar('HANDBOMBBOX', -1), + ConVar('.*_WEAPON_STRENGTH', -1), + + ConVar('.*\wSTRENGTH', 1), + ConVar('PIG_SHIELD_AMOUNT\d', 1), # idk what these do - 'OCTASCRATCHINGPLAYER': {'difficulty': 0}, - 'LIZGETTINGDAZEDAT': {'difficulty': 0}, - 'LIZEATINGPLAYER': {'difficulty': 0}, - 'NEWBEASTSCRATCHAMOUNT': {'difficulty': 0}, - } + ConVar('OCTASCRATCHINGPLAYER', 0), + ConVar('LIZGETTINGDAZEDAT', 0), + ConVar('LIZEATINGPLAYER', 0), + ConVar('NEWBEASTSCRATCHAMOUNT', 0), + ] }) diff --git a/BuildLibs/gui.py b/BuildLibs/gui.py index 8c8216f..92e120c 100644 --- a/BuildLibs/gui.py +++ b/BuildLibs/gui.py @@ -137,15 +137,15 @@ def ReadSettings(self): settings['MapFile.chanceDupeItem'] = {'Few': 0.4, 'Some': 0.55, 'Many': 0.7, 'Extreme': 0.9}[self.enemiesVar.get()] settings['MapFile.chanceDeleteItem'] = {'Few': 0.4, 'Some': 0.25, 'Many': 0.15, 'Extreme': 0.1}[self.enemiesVar.get()] - settings['MapFile.chanceDupeEnemy'] = {'Few': 0.4, 'Some': 0.55, 'Many': 0.7, 'Extreme': 0.9}[self.enemiesVar.get()] - settings['MapFile.chanceDeleteEnemy'] = {'Few': 0.4, 'Some': 0.25, 'Many': 0.15, 'Extreme': 0.1}[self.enemiesVar.get()] + settings['MapFile.chanceDupeEnemy'] = {'Few': 0.4, 'Some': 0.55, 'Many': 0.6, 'Extreme': 0.75}[self.enemiesVar.get()] + settings['MapFile.chanceDeleteEnemy'] = {'Few': 0.4, 'Some': 0.25, 'Many': 0.2, 'Extreme': 0.15}[self.enemiesVar.get()] settings['MapFile.itemVariety'] = {'Normal': 0, 'Increased': 0.2, 'Extreme': 0.5, unavail: 0}[self.itemVarietyVar.get()] settings['MapFile.enemyVariety'] = {'Normal': 0, 'Increased': 0.2, 'Extreme': 0.5, unavail: 0}[self.enemyVarietyVar.get()] - settings['conFile.range'] = {'Low': 0.5, 'Medium': 1, 'High': 1.5, 'Extreme': 2.0, unavail: 1}[self.rangeVar.get()] + settings['conFile.range'] = {'Low': 0.5, 'Medium': 1, 'High': 1.3, 'Extreme': 1.6, unavail: 1}[self.rangeVar.get()] settings['conFile.scale'] = 1.0 - settings['conFile.difficulty'] = {'Easy': 0.3, 'Medium': 0.5, 'Difficult': 0.7, 'Extreme': 0.9, unavail: 0.5}[self.difficultyVar.get()] + settings['conFile.difficulty'] = {'Easy': 0.2, 'Medium': 0.4, 'Difficult': 0.6, 'Extreme': 0.75, unavail: 0.4}[self.difficultyVar.get()] settings['grp.reorderMaps'] = enabled[self.reorderMapsVar.get()] settings['useRandomizerFolder'] = enabled[self.randomizerFolderVar.get()] @@ -220,45 +220,45 @@ def initWindow(self): infoLabel.grid(column=0,row=row,columnspan=2,rowspan=1) row+=1 - self.seedEntry = self.newInput(Entry, 'Seed: ', 'RNG Seed. Each seed is a different game!\nLeave blank for a random seed.', row) + self.seedEntry:Entry = self.newInput(Entry, 'Seed: ', 'RNG Seed. Each seed is a different game!\nLeave blank for a random seed.', row) row+=1 # items add/reduce? maybe combine them into presets so it's simpler to understand self.itemsVar = StringVar(self.win, 'Some') - items = self.newInput(OptionMenu, 'Items: ', 'How many items.\n"Some" is a similar amount to vanilla.', row, self.itemsVar, 'Few', 'Some', 'Many', 'Extreme') + items:OptionMenu = self.newInput(OptionMenu, 'Items: ', 'How many items.\n"Some" is a similar amount to vanilla.', row, self.itemsVar, 'Few', 'Some', 'Many', 'Extreme') row+=1 # enemies add/reduce? self.enemiesVar = StringVar(self.win, 'Some') - enemies = self.newInput(OptionMenu, 'Enemies: ', 'How many enemies.\n"Some" is a similar amount to vanilla.', row, self.enemiesVar, 'Few', 'Some', 'Many', 'Extreme') + enemies:OptionMenu = self.newInput(OptionMenu, 'Enemies: ', 'How many enemies.\n"Some" is a similar amount to vanilla.', row, self.enemiesVar, 'Few', 'Some', 'Many', 'Extreme') row+=1 # values range self.rangeVar = StringVar(self.win, 'Medium') - self.range = self.newInput(OptionMenu, 'Randomization Range: ', 'How wide the range of values can be randomized.\nThis affects the values in CON files.', row, self.rangeVar, 'Low', 'Medium', 'High', 'Extreme') + self.range:OptionMenu = self.newInput(OptionMenu, 'Randomization Range: ', 'How wide the range of values can be randomized.\nThis affects the values in CON files.', row, self.rangeVar, 'Low', 'Medium', 'High', 'Extreme') row+=1 # difficulty? values difficulty? self.difficultyVar = StringVar(self.win, 'Medium') - self.difficulty = self.newInput(OptionMenu, 'Difficulty: ', 'Increase the difficulty for more challenge.\nThis affects the values in CON files.', row, self.difficultyVar, 'Easy', 'Medium', 'Difficult', 'Extreme') + self.difficulty:OptionMenu = self.newInput(OptionMenu, 'Difficulty: ', 'Increase the difficulty for more challenge.\nThis affects the values in CON files.', row, self.difficultyVar, 'Easy', 'Medium', 'Difficult', 'Extreme') row+=1 self.itemVarietyVar = StringVar(self.win, 'Normal') - self.itemVariety = self.newInput(OptionMenu, 'Item Variety: ', 'Chance to add items that shouldn\'t be on the map.', row, self.itemVarietyVar, 'Normal', 'Increased', 'Extreme') + self.itemVariety:OptionMenu = self.newInput(OptionMenu, 'Item Variety: ', 'Chance to add items that shouldn\'t be on the map.', row, self.itemVarietyVar, 'Normal', 'Increased', 'Extreme') row+=1 self.enemyVarietyVar = StringVar(self.win, 'Normal') - self.enemyVariety = self.newInput(OptionMenu, 'Enemy Variety: ', 'Chance to add enemies that shouldn\'t be on the map.\nThis can create difficult situations.', row, self.enemyVarietyVar, 'Normal', 'Increased', 'Extreme') + self.enemyVariety:OptionMenu = self.newInput(OptionMenu, 'Enemy Variety: ', 'Chance to add enemies that shouldn\'t be on the map.\nThis can create difficult situations.', row, self.enemyVarietyVar, 'Normal', 'Increased', 'Extreme') row+=1 self.reorderMapsVar = StringVar(self.win, 'Disabled') - reorderMaps = self.newInput(OptionMenu, 'Reorder Maps: ', 'Shuffle the order of the maps.', row, self.reorderMapsVar, 'Disabled', 'Enabled') + reorderMaps:OptionMenu = self.newInput(OptionMenu, 'Reorder Maps: ', 'Shuffle the order of the maps.', row, self.reorderMapsVar, 'Disabled', 'Enabled') row+=1 # TODO: option to enable/disable loading external files? self.randomizerFolderVar = StringVar(self.win, '') - self.randomizerFolder = self.newInput(OptionMenu, 'Use Randomizer Folder: ', 'Put randomized files inside Randomizer folder.\nWorks great with EDuke32, doesn\'t work with voidsw or Ion Fury.\nJust use the default setting.', row, self.randomizerFolderVar, 'Disabled', 'Enabled') + self.randomizerFolder:OptionMenu = self.newInput(OptionMenu, 'Use Randomizer Folder: ', 'Put randomized files inside Randomizer folder.\nWorks great with EDuke32, doesn\'t work with voidsw or Ion Fury.\nJust use the default setting.', row, self.randomizerFolderVar, 'Disabled', 'Enabled') row+=1 #self.progressbar = Progressbar(self.win, maximum=1)