From 91068835b05661a513bda4acbb9cfa57039d7f2d Mon Sep 17 00:00:00 2001 From: Ascense Date: Tue, 8 Oct 2024 22:35:16 +0300 Subject: [PATCH] Add sample mod 'Lightly Weathered' Add a sample mod that improves on some of the atmospheric aspects of Public Demo 2 v2. 'Lightly Weathered' implements a basic weather progression system tied to level transitions, and picks the background music according to zone. --- sample_mods/LightlyWeathered/mod.txt | 7 +++ .../mods/LightlyWeathered/Main.gd | 11 ++++ .../mods/LightlyWeathered/Transition.gd | 60 +++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 sample_mods/LightlyWeathered/mod.txt create mode 100644 sample_mods/LightlyWeathered/mods/LightlyWeathered/Main.gd create mode 100644 sample_mods/LightlyWeathered/mods/LightlyWeathered/Transition.gd diff --git a/sample_mods/LightlyWeathered/mod.txt b/sample_mods/LightlyWeathered/mod.txt new file mode 100644 index 0000000..5061fa1 --- /dev/null +++ b/sample_mods/LightlyWeathered/mod.txt @@ -0,0 +1,7 @@ +[mod] +name="Lightly Weathered" +id="lightly-weathered" +version="1.0.0" + +[autoload] +0="res://mods/LightlyWeathered/Main.gd" diff --git a/sample_mods/LightlyWeathered/mods/LightlyWeathered/Main.gd b/sample_mods/LightlyWeathered/mods/LightlyWeathered/Main.gd new file mode 100644 index 0000000..9b4f135 --- /dev/null +++ b/sample_mods/LightlyWeathered/mods/LightlyWeathered/Main.gd @@ -0,0 +1,11 @@ +extends Node + +func _ready(): + overrideScript("res://mods/LightlyWeathered/Transition.gd") + queue_free() + +func overrideScript(overrideScriptPath : String): + var script : Script = load(overrideScriptPath) + script.reload() + var parentScript = script.get_base_script() + script.take_over_path(parentScript.resource_path) diff --git a/sample_mods/LightlyWeathered/mods/LightlyWeathered/Transition.gd b/sample_mods/LightlyWeathered/mods/LightlyWeathered/Transition.gd new file mode 100644 index 0000000..9e2199d --- /dev/null +++ b/sample_mods/LightlyWeathered/mods/LightlyWeathered/Transition.gd @@ -0,0 +1,60 @@ +extends "res://Scripts/Transition.gd" + +var preferences: Preferences + +func Interact(): + if not deactivated and not tutorialExit: + ProgressWeather() + + super() + + if not deactivated and not tutorialExit: + SetMusic() + +func ProgressWeather(): + if shelterExit: + if randf() < 0.15: + gameData.season = (gameData.season % 2) + 1 + + if randf() < 0.5: + if randf() < 0.75: + gameData.TOD = (randi() % 2) + 1 + else: + gameData.TOD = (randi() % 4) + 1 + + else: + if (gameData.TOD == 2 && randf() < 0.33) or (gameData.TOD != 2 && randf() < 0.5): + gameData.TOD = (gameData.TOD % 4) + 1 + + if randf() < 0.15: + gameData.aurora = true + else: + gameData.aurora = false + + if randf() < 0.5: + if randf() < 0.75: + gameData.weather = 1 + else: + gameData.weather = (randi() % 4) + 1 + + preferences = Preferences.Load() + preferences.season = gameData.season + preferences.TOD = gameData.TOD + preferences.weather = gameData.weather + preferences.aurora = gameData.aurora + preferences.Save() + +func SetMusic(): + if gameData.shelter: + gameData.musicPreset = 1 + elif gameData.permadeath: + gameData.musicPreset = 4 + elif gameData.currentMap == "Minefield": + gameData.musicPreset = 3 + else: + gameData.musicPreset = 2 + + preferences = Preferences.Load() + if preferences.musicPreset != gameData.musicPreset: + preferences.musicPreset = gameData.musicPreset + preferences.Save()