Created
September 7, 2024 02:12
-
-
Save RecoX/07ddd5e7eb818c076d974fe27830fc2e to your computer and use it in GitHub Desktop.
Incrementar porcentualmente dificultad global
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Este script incrementa la dificultad del juego globalmente. | |
# Reduce la cantidad de oro y experiencia que da cada NPC | |
import os | |
import re | |
# Ruta al archivo NPCS.DAT | |
file_path = r'C:\Users\reco_\github-projects\ao20\Recursos\Dat\npcs.dat' | |
# Verificar si el archivo existe | |
if not os.path.exists(file_path): | |
print(f"El archivo no se encuentra en la ruta especificada: {file_path}") | |
else: | |
# Función para reducir en un 30% los valores de GiveExp y GiveGld | |
def reduce_values(match): | |
# Extraer el nombre de la variable (GiveExp o GiveGld) y su valor | |
var_name, value = match.groups() | |
# Calcular el nuevo valor reducido en un 70% | |
new_value = int(int(value) * 0.3) | |
# Retornar la línea modificada | |
return f'{var_name}={new_value}' | |
# Cargar el archivo original con un encoding más compatible | |
with open(file_path, 'r', encoding='ISO-8859-1') as file: | |
content = file.read() | |
# Expresión regular para encontrar las líneas GiveExp y GiveGld | |
pattern = re.compile(r'(GiveExp|GiveGld)=(\d+)') | |
# Modificar los valores de GiveExp y GiveGld | |
modified_content = re.sub(pattern, reduce_values, content) | |
# Guardar el contenido modificado en un nuevo archivo | |
output_path = r'C:\Users\reco_\github-projects\ao20\Recursos\Dat\npcs_modified.dat' | |
with open(output_path, 'w', encoding='ISO-8859-1') as file: | |
file.write(modified_content) | |
print(f"Archivo npcs.dat modificado y guardado como {output_path}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment